1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:27:45 +00:00

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.
This commit is contained in:
Linus Groh 2021-01-13 23:59:22 +01:00 committed by Andreas Kling
parent 7ad9b116f7
commit 568cde5e23
5 changed files with 72 additions and 21 deletions

View file

@ -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;
}