From 0e5cdbf07e6d45ca168a76b2bc19b6e385cfae17 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 13 Apr 2023 13:02:45 -0700 Subject: [lldb] Make ObjectFileJSON loadable as a module This patch adds support for creating modules from JSON object files. This is necessary for the crashlog use case where we don't have either a module or a symbol file. In that case the ObjectFileJSON serves as both. The patch adds support for an object file type (i.e. executable, shared library, etc). It also adds the ability to specify sections, which is necessary in order specify symbols by address. Finally, this patch improves error handling and fixes a bug where we wouldn't read more than the initial 512 bytes in GetModuleSpecifications. Differential revision: https://reviews.llvm.org/D148062 --- lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.h') diff --git a/lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.h b/lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.h index cb3a7d2..b72565f 100644 --- a/lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.h +++ b/lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.h @@ -82,7 +82,7 @@ public: uint32_t GetDependentModules(FileSpecList &files) override { return 0; } - Type CalculateType() override { return eTypeDebugInfo; } + Type CalculateType() override { return m_type; } Strata CalculateStrata() override { return eStrataUser; } @@ -92,21 +92,27 @@ public: struct Header { std::string triple; std::string uuid; + std::optional type; }; struct Body { + std::vector sections; std::vector symbols; }; private: ArchSpec m_arch; UUID m_uuid; + ObjectFile::Type m_type; + std::optional m_size; std::vector m_symbols; + std::vector m_sections; ObjectFileJSON(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t offset, lldb::offset_t length, ArchSpec arch, - UUID uuid, std::vector symbols); + UUID uuid, Type type, std::vector symbols, + std::vector sections); }; bool fromJSON(const llvm::json::Value &value, ObjectFileJSON::Header &header, -- cgit v1.1