mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 06:02:07 +03:00
LibCoreDump: Expose arguments and environment
We can pull those from the coredump's ProcessInfo JSON, do some basic sanity checks and expose them as ready-to-use Vector<String>s.
This commit is contained in:
parent
1ccc2e6482
commit
0187fd4fdd
Notes:
sideshowbarker
2024-07-18 23:47:27 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/0187fd4fdd7 Pull-request: https://github.com/SerenityOS/serenity/pull/4963
@ -184,7 +184,35 @@ String Reader::process_executable_path() const
|
||||
return executable_path.as_string_or({});
|
||||
}
|
||||
|
||||
const HashMap<String, String> Reader::metadata() const
|
||||
Vector<String> Reader::process_arguments() const
|
||||
{
|
||||
auto process_info = this->process_info();
|
||||
auto arguments = process_info.get("arguments");
|
||||
if (!arguments.is_array())
|
||||
return {};
|
||||
Vector<String> vector;
|
||||
arguments.as_array().for_each([&](auto& value) {
|
||||
if (value.is_string())
|
||||
vector.append(value.as_string());
|
||||
});
|
||||
return vector;
|
||||
}
|
||||
|
||||
Vector<String> Reader::process_environment() const
|
||||
{
|
||||
auto process_info = this->process_info();
|
||||
auto environment = process_info.get("environment");
|
||||
if (!environment.is_array())
|
||||
return {};
|
||||
Vector<String> vector;
|
||||
environment.as_array().for_each([&](auto& value) {
|
||||
if (value.is_string())
|
||||
vector.append(value.as_string());
|
||||
});
|
||||
return vector;
|
||||
}
|
||||
|
||||
HashMap<String, String> Reader::metadata() const
|
||||
{
|
||||
const ELF::Core::Metadata* metadata_notes_entry = nullptr;
|
||||
for (NotesEntryIterator it((const u8*)m_coredump_image.program_header(m_notes_segment_index).raw_data()); !it.at_end(); it.next()) {
|
||||
|
@ -65,7 +65,9 @@ public:
|
||||
int process_pid() const;
|
||||
u8 process_termination_signal() const;
|
||||
String process_executable_path() const;
|
||||
const HashMap<String, String> metadata() const;
|
||||
Vector<String> process_arguments() const;
|
||||
Vector<String> process_environment() const;
|
||||
HashMap<String, String> metadata() const;
|
||||
|
||||
private:
|
||||
Reader(NonnullRefPtr<MappedFile>);
|
||||
|
Loading…
Reference in New Issue
Block a user