Skip to content

Commit ef436d0

Browse files
committed
Added comments and logs
1 parent 70668d5 commit ef436d0

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

lldb/source/Target/Target.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,8 @@ static void LoadScriptingResourceForModule(const ModuleSP &module_sp,
14391439
feedback_stream.GetData());
14401440
}
14411441

1442+
// Load type summaries embedded in the binary. These are type summaries provided
1443+
// by the authors of the code.
14421444
static void LoadTypeSummariesForModule(ModuleSP module_sp) {
14431445
auto *sections = module_sp->GetSectionList();
14441446
if (!sections)
@@ -1457,9 +1459,27 @@ static void LoadTypeSummariesForModule(ModuleSP module_sp) {
14571459
if (!summaries_sp)
14581460
return;
14591461

1462+
Log *log = GetLog(LLDBLog::DataFormatters);
1463+
const char *module_name = module_sp->GetObjectName().GetCString();
1464+
14601465
TypeCategoryImplSP category;
14611466
DataVisualization::Categories::GetCategory(ConstString("default"), category);
14621467

1468+
// The type summary record is serialized as follows.
1469+
//
1470+
// Each record contains, in order:
1471+
// * Version number of the record format
1472+
// * The remaining size of the record
1473+
// * The size of the type identifier
1474+
// * The type identifier, either a type name, or a regex
1475+
// * The size of the summary string
1476+
// * The summary string
1477+
//
1478+
// Integers are encoded using ULEB.
1479+
//
1480+
// Strings are encoded with first a length (ULEB), then the string contents,
1481+
// and lastly a null terminator. The length includes the null.
1482+
14631483
DataExtractor extractor;
14641484
auto section_size = summaries_sp->GetSectionData(extractor);
14651485
lldb::offset_t offset = 0;
@@ -1475,14 +1495,24 @@ static void LoadTypeSummariesForModule(ModuleSP module_sp) {
14751495
TypeSummaryImpl::Flags flags;
14761496
auto summary_sp =
14771497
std::make_shared<StringSummaryFormat>(flags, summary_string.data());
1478-
FormatterMatchType match_type = lldb::eFormatterMatchExact;
1498+
FormatterMatchType match_type = eFormatterMatchExact;
14791499
if (summary_string.front() == '^' && summary_string.back() == '$')
14801500
match_type = eFormatterMatchRegex;
14811501
category->AddTypeSummary(type_name, match_type, summary_sp);
1502+
LLDB_LOGF(log, "Loaded embedded type summary for '%s' from %s.",
1503+
type_name.data(), module_name);
1504+
} else {
1505+
if (type_name.empty())
1506+
LLDB_LOGF(log, "Missing string(s) in embedded type summary in %s.",
1507+
module_name);
14821508
}
14831509
} else {
14841510
// Skip unsupported record.
14851511
offset += record_size;
1512+
LLDB_LOGF(
1513+
log,
1514+
"Skipping unsupported embedded type summary of version %llu in %s.",
1515+
version, module_name);
14861516
}
14871517
}
14881518
}

0 commit comments

Comments
 (0)