17#include "llvm/ADT/DenseSet.h"
53 if (data_sp->GetByteSize() < length) {
63 llvm::StringRef(
reinterpret_cast<const char *
>(data_sp->GetBytes()));
65 Expected<json::Value> json = json::parse(text);
68 "failed to parse JSON object file: {0}");
72 json::Path::Root root;
74 if (!
fromJSON(*json, header, root)) {
76 "failed to parse JSON object file header: {0}");
88 "failed to parse JSON object file body: {0}");
92 return new ObjectFileJSON(module_sp, data_sp, data_offset, file, file_offset,
93 length, std::move(arch), std::move(uuid), type,
111 if (data_sp->GetByteSize() < length) {
121 llvm::StringRef(
reinterpret_cast<const char *
>(data_sp->GetBytes()));
123 Expected<json::Value> json = json::parse(text);
126 "failed to parse JSON object file: {0}");
130 json::Path::Root root;
132 if (!
fromJSON(*json, header, root)) {
134 "failed to parse JSON object file header: {0}");
143 spec.
GetUUID() = std::move(uuid);
152 std::vector<JSONSymbol> symbols,
153 std::vector<JSONSection> sections)
154 :
ObjectFile(module_sp, file, offset, length, data_sp, data_offset),
155 m_arch(std::move(arch)), m_uuid(std::move(uuid)), m_type(type),
156 m_symbols(std::move(symbols)), m_sections(std::move(sections)) {}
167 llvm::Expected<Symbol> symbol =
Symbol::FromJSON(json_symbol, section_list);
184 auto section_sp = std::make_shared<Section>(
187 section.size.value_or(0), 0, 0);
197 data.
SetData(data_sp, data_offset, data_length);
199 uint32_t magic = data.
GetU8(&offset);
207 json::ObjectMapper o(value, path);
208 return o && o.map(
"triple", header.
triple) && o.map(
"uuid", header.
uuid) &&
209 o.map(
"type", header.
type);
214 json::ObjectMapper o(value, path);
215 return o && o.mapOptional(
"symbols", body.
symbols) &&
216 o.mapOptional(
"sections", body.
sections);
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
An architecture specification class.
A uniqued constant string class.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
void Append(const ModuleSpec &spec)
std::vector< JSONSection > m_sections
static ObjectFile * CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length)
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, Type type, std::vector< JSONSymbol > symbols, std::vector< JSONSection > sections)
void ParseSymtab(lldb_private::Symtab &symtab) override
Parse the symbol table into the provides symbol table object.
static bool MagicBytesMatch(lldb::DataBufferSP data_sp, lldb::addr_t offset, lldb::addr_t length)
static const char * GetPluginDescriptionStatic()
static size_t GetModuleSpecifications(const FileSpec &file, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, lldb::offset_t file_offset, lldb::offset_t length, ModuleSpecList &specs)
void CreateSections(SectionList &unified_section_list) override
bool ParseHeader() override
Attempts to parse the object header.
static ObjectFile * CreateMemoryInstance(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
std::vector< JSONSymbol > m_symbols
static llvm::StringRef GetPluginNameStatic()
A plug-in interface definition class for object file parsers.
std::unique_ptr< lldb_private::SectionList > m_sections_up
static lldb::DataBufferSP MapFileData(const FileSpec &file, uint64_t Size, uint64_t Offset)
@ eTypeDebugInfo
An object file that contains only debug information.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
size_t AddSection(const lldb::SectionSP §ion_sp)
static llvm::Expected< Symbol > FromJSON(const JSONSymbol &symbol, SectionList *section_list)
uint32_t AddSymbol(const Symbol &symbol)
bool SetFromStringRef(llvm::StringRef str)
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
bool fromJSON(const llvm::json::Value &value, TraceSupportedResponse &info, llvm::json::Path path)
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::vector< JSONSymbol > symbols
std::vector< JSONSection > sections