diff options
author | Linus Groh <mail@linusgroh.de> | 2020-12-30 15:20:30 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-30 16:28:27 +0100 |
commit | d84b96bddc458685ea407b4db5d56c75625d439c (patch) | |
tree | 60c10f7a6f667ae5c5a8a50381e755810f796bd0 /Kernel/CoreDump.cpp | |
parent | 91332515a613d054b30e0510b22afed9a3c5d3f6 (diff) | |
download | serenity-d84b96bddc458685ea407b4db5d56c75625d439c.zip |
Kernel: Embed a Metadata notes entry in coredumps
Diffstat (limited to 'Kernel/CoreDump.cpp')
-rw-r--r-- | Kernel/CoreDump.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Kernel/CoreDump.cpp b/Kernel/CoreDump.cpp index f149c578ed..2dd4719488 100644 --- a/Kernel/CoreDump.cpp +++ b/Kernel/CoreDump.cpp @@ -26,6 +26,7 @@ */ #include <AK/ByteBuffer.h> +#include <AK/JsonObject.h> #include <Kernel/CoreDump.h> #include <Kernel/FileSystem/Custody.h> #include <Kernel/FileSystem/FileDescription.h> @@ -273,6 +274,23 @@ ByteBuffer CoreDump::create_notes_regions_data() const return regions_data; } +ByteBuffer CoreDump::create_notes_metadata_data() const +{ + ByteBuffer metadata_data; + + ELF::Core::Metadata metadata {}; + metadata.header.type = ELF::Core::NotesEntryHeader::Type::Metadata; + metadata_data.append((void*)&metadata, sizeof(metadata)); + + JsonObject metadata_obj; + for (auto& it : m_process->coredump_metadata()) + metadata_obj.set(it.key, it.value); + auto json_data = metadata_obj.to_string(); + metadata_data.append(json_data.characters(), json_data.length() + 1); + + return metadata_data; +} + ByteBuffer CoreDump::create_notes_segment_data() const { ByteBuffer notes_buffer; @@ -280,6 +298,7 @@ ByteBuffer CoreDump::create_notes_segment_data() const notes_buffer += create_notes_process_data(); notes_buffer += create_notes_threads_data(); notes_buffer += create_notes_regions_data(); + notes_buffer += create_notes_metadata_data(); ELF::Core::NotesEntryHeader null_entry {}; null_entry.type = ELF::Core::NotesEntryHeader::Type::Null; |