[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`
This commit is contained in:
Jacob Lalonde
2025-05-07 09:05:53 -07:00
committed by GitHub
parent 32752913b1
commit 1ad57b58d6
3 changed files with 14 additions and 0 deletions

View File

@@ -247,6 +247,11 @@ public:
std::optional<bool> IsZombie() const { return m_zombie; }
// proc/../status specifies CoreDumping as the field
// so we match the case here.
void SetIsCoreDumping(bool is_coredumping) { m_coredumping = is_coredumping; }
std::optional<bool> IsCoreDumping() const { return m_coredumping; }
void Dump(Stream &s, UserIDResolver &resolver) const;
static void DumpTableHeader(Stream &s, bool show_args, bool verbose);
@@ -266,6 +271,7 @@ protected:
struct timespec m_cumulative_system_time;
std::optional<int8_t> m_priority_value = std::nullopt;
std::optional<bool> m_zombie = std::nullopt;
std::optional<bool> m_coredumping = std::nullopt;
};
typedef std::vector<ProcessInstanceInfo> ProcessInstanceInfoList;

View File

@@ -213,6 +213,11 @@ static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,
} else if (Line.consume_front("Tgid:")) {
Line = Line.ltrim();
Line.consumeInteger(10, Tgid);
} else if (Line.consume_front("CoreDumping:")) {
uint32_t coredumping;
Line = Line.ltrim();
if (!Line.consumeInteger(2, coredumping))
ProcessInfo.SetIsCoreDumping(coredumping);
}
}
return true;

View File

@@ -115,5 +115,8 @@ TEST_F(HostTest, GetProcessInfoSetsPriority) {
}
ASSERT_TRUE(Info.IsZombie().has_value());
ASSERT_FALSE(Info.IsZombie().value());
ASSERT_TRUE(Info.IsCoreDumping().has_value());
ASSERT_FALSE(Info.IsCoreDumping().value());
}
#endif