diff options
author | Linus Groh <mail@linusgroh.de> | 2021-01-13 23:59:22 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-15 23:26:47 +0100 |
commit | 568cde5e233633da1cc199406374bb996236b3cf (patch) | |
tree | 92679e17dc3dd20d7279128fd7333eda13e72e2f /Kernel | |
parent | 7ad9b116f7aef7bce5f8b7abe6095aa7a71804ee (diff) | |
download | serenity-568cde5e233633da1cc199406374bb996236b3cf.zip |
Kernel+LibELF+LibCoreDump+CrashReporter: Use JSON for ProcessInfo
This is in preparation of adding (much) more process information to
coredumps. As we can only have one null-terminated char[] of arbitrary
length in each struct it's now a single JSON blob, which is a great fit:
easily extensible in the future and allows for key/value pairs and even
nested objects, which will be used e.g. for the process environment, for
example.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/CoreDump.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Kernel/CoreDump.cpp b/Kernel/CoreDump.cpp index 5a8cccc489..feaf75a1f3 100644 --- a/Kernel/CoreDump.cpp +++ b/Kernel/CoreDump.cpp @@ -219,15 +219,15 @@ ByteBuffer CoreDump::create_notes_process_data() const ELF::Core::ProcessInfo info {}; info.header.type = ELF::Core::NotesEntryHeader::Type::ProcessInfo; - info.pid = m_process->pid().value(); - info.termination_signal = m_process->termination_signal(); - process_data.append((void*)&info, sizeof(info)); - auto executable_path = String::empty(); - if (auto executable = m_process->executable()) - executable_path = executable->absolute_path(); - process_data.append(executable_path.characters(), executable_path.length() + 1); + JsonObject process_obj; + process_obj.set("pid", m_process->pid().value()); + process_obj.set("termination_signal", m_process->termination_signal()); + process_obj.set("executable_path", m_process->executable() ? m_process->executable()->absolute_path() : String::empty()); + + auto json_data = process_obj.to_string(); + process_data.append(json_data.characters(), json_data.length() + 1); return process_data; } |