Skip to content

[lldb] Skip null bytes in embedded type summaries (#8132) #8221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1515,8 +1515,26 @@ static void LoadTypeSummariesForModule(ModuleSP module_sp) {
auto section_size = summaries_sp->GetSectionData(extractor);
lldb::offset_t offset = 0;
while (offset < section_size) {
// Skip null bytes. Can happen with alignment padding.
while (true) {
auto next_offset = offset;
if (extractor.GetU8(&next_offset) != 0) {
break;
}
// Move past the null byte, using the advanced offset.
offset = next_offset;
}

uint64_t version = extractor.GetULEB128(&offset);
uint64_t record_size = extractor.GetULEB128(&offset);
if (record_size == 0) {
LLDB_LOGF(log,
"Skipping empty (malformed) embedded type summary of version "
"%llu in %s.",
version, module_name);
continue;
}

if (version == 1) {
uint64_t type_size = extractor.GetULEB128(&offset);
llvm::StringRef type_name = extractor.GetCStr(&offset, type_size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ struct Player {
int number;
};

__attribute__((aligned(1), used,
section("__DATA_CONST,__lldbsummaries"))) unsigned char
__attribute__((used, section("__DATA_CONST,__lldbsummaries"))) unsigned char
_Player_type_summary[] = "\x01" // version
"\x25" // record size
"\x07" // type name size
Expand All @@ -20,8 +19,7 @@ struct Layer {
};

// Near copy of the record for `Player`, using a regex type name (`^Layer`).
__attribute__((aligned(1), used,
section("__DATA_CONST,__lldbsummaries"))) unsigned char
__attribute__((used, section("__DATA_CONST,__lldbsummaries"))) unsigned char
_Layer_type_summary[] = "\x01" // version
"\x25" // record size
"\x07" // type name size
Expand Down