19 std::function<
void(llvm::DataExtractor, llvm::StringRef)> fn) {
47 auto section_size = section_sp->GetSectionData(lldb_extractor);
48 llvm::DataExtractor section = lldb_extractor.
GetAsLLVM();
49 bool le = section.isLittleEndian();
50 uint8_t addr_size = section.getAddressSize();
51 llvm::DataExtractor::Cursor cursor(0);
52 while (cursor && cursor.tell() < section_size) {
53 while (cursor && cursor.tell() < section_size) {
55 if (section.getU8(cursor) == 0)
57 cursor.seek(cursor.tell() - 1);
60 uint64_t version = section.getULEB128(cursor);
61 uint64_t record_size = section.getULEB128(cursor);
63 llvm::DataExtractor record(section.getData().drop_front(cursor.tell()),
65 llvm::DataExtractor::Cursor cursor(0);
66 uint64_t type_size = record.getULEB128(cursor);
67 llvm::StringRef type_name = record.getBytes(cursor, type_size);
68 llvm::Error
error = cursor.takeError();
70 fn(llvm::DataExtractor(record.getData().drop_front(cursor.tell()), le,
80 "Skipping unsupported embedded type summary of version {0} in {1}.",
83 section.skip(cursor, record_size);
92 [&](llvm::DataExtractor extractor, llvm::StringRef type_name) {
102 llvm::DataExtractor::Cursor cursor(0);
103 uint64_t summary_size = extractor.getULEB128(cursor);
104 llvm::StringRef summary_string =
105 extractor.getBytes(cursor, summary_size);
111 if (type_name.empty() || summary_string.empty()) {
113 "Missing string(s) in embedded type summary in {0}, "
114 "type_name={1}, summary={2}",
115 module_sp->GetFileSpec(), type_name, summary_string);
119 auto summary_sp = std::make_shared<StringSummaryFormat>(
120 flags, summary_string.str().c_str());
122 if (type_name.front() ==
'^')
124 category->AddTypeSummary(type_name, match_type, summary_sp);
126 "Loaded embedded type summary for '{0}' from {1}.", type_name,
127 module_sp->GetFileSpec());
134 [&](llvm::DataExtractor extractor, llvm::StringRef type_name) {
141 llvm::DataExtractor::Cursor cursor(0);
142 uint64_t flags = extractor.getULEB128(cursor);
143 while (cursor && cursor.tell() < extractor.size()) {
144 uint8_t signature = extractor.getU8(cursor);
145 uint64_t size = extractor.getULEB128(cursor);
146 llvm::StringRef bytecode = extractor.getBytes(cursor, size);
152 if (signature == 0) {
153 auto summary_sp = std::make_shared<BytecodeSummaryFormat>(
155 llvm::MemoryBuffer::getMemBufferCopy(bytecode));
157 if (type_name.front() ==
'^')
159 category->AddTypeSummary(type_name, match_type, summary_sp);
161 "Loaded embedded type summary for '{0}' from {1}.",
162 type_name, module_sp->GetFileSpec());
165 "Unsupported formatter signature {0} for '{1}' in {2}",
166 signature, type_name, module_sp->GetFileSpec());
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOG_ERROR(log, error,...)
A uniqued constant string class.
static bool GetCategory(ConstString category, lldb::TypeCategoryImplSP &entry, bool allow_create=true)
A class that describes an executable image and its associated object and symbol files.
virtual SectionList * GetSectionList()
Get the unified section list for the module.
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
lldb::SectionSP FindSectionByType(lldb::SectionType sect_type, bool check_children, size_t start_idx=0) const
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.
static void ForEachFormatterInModule(Module &module, SectionType section_type, std::function< void(llvm::DataExtractor, llvm::StringRef)> fn)
void LoadTypeSummariesForModule(lldb::ModuleSP module_sp)
Load type summaries embedded in the binary.
void LoadFormattersForModule(lldb::ModuleSP module_sp)
Load data formatters embedded in the binary.
FormatterMatchType
Type of match to be performed when looking for a formatter for a data type.
std::shared_ptr< lldb_private::TypeCategoryImpl > TypeCategoryImplSP
@ eSectionTypeLLDBFormatters
@ eSectionTypeLLDBTypeSummaries
std::shared_ptr< lldb_private::Module > ModuleSP