Skip to content

Commit 1ad57b5

Browse files
authored
[LLDB] Add IsCoreDumping to ProcessInstanceInfo (#138580)
This is the first useful patch in the series related to enabling `PTRACE_SEIZE` for processes Coredumping. In order to make the decision if we want to seize or attach, we need to expose that in processinfo. Which we acquire by reading it from `/proc/pid/status` Note that in status it is `CoreDumping` not `Coredumping`, so I kept with that, even if I prefer `Coredumping`
1 parent 3275291 commit 1ad57b5

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

lldb/include/lldb/Utility/ProcessInfo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ class ProcessInstanceInfo : public ProcessInfo {
247247

248248
std::optional<bool> IsZombie() const { return m_zombie; }
249249

250+
// proc/../status specifies CoreDumping as the field
251+
// so we match the case here.
252+
void SetIsCoreDumping(bool is_coredumping) { m_coredumping = is_coredumping; }
253+
std::optional<bool> IsCoreDumping() const { return m_coredumping; }
254+
250255
void Dump(Stream &s, UserIDResolver &resolver) const;
251256

252257
static void DumpTableHeader(Stream &s, bool show_args, bool verbose);
@@ -266,6 +271,7 @@ class ProcessInstanceInfo : public ProcessInfo {
266271
struct timespec m_cumulative_system_time;
267272
std::optional<int8_t> m_priority_value = std::nullopt;
268273
std::optional<bool> m_zombie = std::nullopt;
274+
std::optional<bool> m_coredumping = std::nullopt;
269275
};
270276

271277
typedef std::vector<ProcessInstanceInfo> ProcessInstanceInfoList;

lldb/source/Host/linux/Host.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,
213213
} else if (Line.consume_front("Tgid:")) {
214214
Line = Line.ltrim();
215215
Line.consumeInteger(10, Tgid);
216+
} else if (Line.consume_front("CoreDumping:")) {
217+
uint32_t coredumping;
218+
Line = Line.ltrim();
219+
if (!Line.consumeInteger(2, coredumping))
220+
ProcessInfo.SetIsCoreDumping(coredumping);
216221
}
217222
}
218223
return true;

lldb/unittests/Host/posix/HostTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,8 @@ TEST_F(HostTest, GetProcessInfoSetsPriority) {
115115
}
116116
ASSERT_TRUE(Info.IsZombie().has_value());
117117
ASSERT_FALSE(Info.IsZombie().value());
118+
119+
ASSERT_TRUE(Info.IsCoreDumping().has_value());
120+
ASSERT_FALSE(Info.IsCoreDumping().value());
118121
}
119122
#endif

0 commit comments

Comments
 (0)