26 static std::optional<Header> parse(llvm::StringRef text);
30std::optional<Header> Header::parse(llvm::StringRef text) {
32 std::tie(line, text) = text.split(
'\n');
38 triple.setArch(
Module->Arch);
41 std::tie(line, text) = text.split(
'\n');
44 UUID uuid = Info && Info->ID ? Info->ID :
Module->ID;
45 return Header{ArchSpec(triple), std::move(uuid)};
66 if (!extractor_sp || !extractor_sp->HasData()) {
70 extractor_sp = std::make_shared<DataExtractor>(data_sp);
77 extractor_sp->GetContiguousDataExtractorSP();
78 auto text = toStringRef(contiguous_extractor_sp->GetData());
79 std::optional<Header> header = Header::parse(text);
84 if (contiguous_extractor_sp->GetByteSize() < length) {
89 contiguous_extractor_sp = std::make_shared<DataExtractor>(data_sp);
94 module_sp, contiguous_extractor_sp, data_offset, file, file_offset,
95 length, std::move(header->arch), std::move(header->uuid));
107 if (!extractor_sp || !extractor_sp->HasData())
113 extractor_sp->GetContiguousDataExtractorSP();
114 auto text = toStringRef(contiguous_extractor_sp->GetData());
115 std::optional<Header> header = Header::parse(text);
118 ModuleSpec spec(file, std::move(header->arch));
119 spec.
GetUUID() = std::move(header->uuid);
131 :
ObjectFile(module_sp, file, offset, length, extractor_sp, data_offset),
150 std::optional<Record::Kind> current_section;
152 llvm::StringRef text = toStringRef(
m_data_nsp->GetData());
153 uint32_t next_section_id = 1;
154 auto maybe_add_section = [&](
const uint8_t *end_ptr) {
155 if (!current_section)
159 auto section_sp = std::make_shared<Section>(
163 end_offset - section_start, 0, 0);
167 while (!text.empty()) {
168 llvm::StringRef line;
169 std::tie(line, text) = text.split(
'\n');
177 if (next_section == current_section)
181 maybe_add_section(line.bytes_begin());
183 current_section = next_section;
184 section_start = line.bytes_begin() -
m_data_nsp->GetDataStart();
#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::unique_ptr< lldb_private::SectionList > m_sections_up
static lldb::DataBufferSP MapFileData(const FileSpec &file, uint64_t Size, uint64_t Offset)
DataExtractorNSP m_data_nsp
The data for this object file so things can be parsed lazily.
ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, lldb::offset_t file_offset, lldb::offset_t length, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset)
Construct with a parent module, offset, and header data.
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)
Represents UUID's of various sizes.
static std::optional< InfoRecord > parse(llvm::StringRef Line)
static std::optional< ModuleRecord > parse(llvm::StringRef Line)
static ObjectFile * CreateMemoryInstance(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
ObjectFileBreakpad(const lldb::ModuleSP &module_sp, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t offset, lldb::offset_t length, ArchSpec arch, UUID uuid)
static llvm::StringRef GetPluginNameStatic()
void ParseSymtab(lldb_private::Symtab &symtab) override
Parse the symbol table into the provides symbol table object.
static const char * GetPluginDescriptionStatic()
bool ParseHeader() override
Attempts to parse the object header.
static ObjectFile * CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length)
void CreateSections(SectionList &unified_section_list) override
static ModuleSpecList GetModuleSpecifications(const FileSpec &file, lldb::DataExtractorSP &extractor_sp, lldb::offset_t file_offset, lldb::offset_t length)
static std::optional< Kind > classify(llvm::StringRef Line)
Attempt to guess the kind of the record present in the argument without doing a full parse.
llvm::StringRef toString(Record::Kind K)
A class that represents a running process on the host machine.
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::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP