Skip to content
Merged
Changes from 1 commit
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
24 changes: 19 additions & 5 deletions bolt/lib/Core/GDBIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,19 @@ void GDBIndex::updateGdbIndexSection(
Data += SymbolTableOffset - CUTypesOffset;

// Calculate the size of the new address table.
const auto IsValidAddressRange = [](const DebugAddressRange &Range) {
return Range.HighPC > Range.LowPC;
};

uint32_t NewAddressTableSize = 0;
for (const auto &CURangesPair : ARangesSectionWriter.getCUAddressRanges()) {
const SmallVector<DebugAddressRange, 2> &Ranges = CURangesPair.second;
NewAddressTableSize += Ranges.size() * 20;
NewAddressTableSize +=
llvm::count_if(Ranges,
[&IsValidAddressRange](const DebugAddressRange &Range) {
return IsValidAddressRange(Range);
}) *
20;
}

// Difference between old and new table (and section) sizes.
Expand Down Expand Up @@ -163,10 +172,15 @@ void GDBIndex::updateGdbIndexSection(
const uint32_t CUIndex = OffsetToIndexMap[CURangesPair.first];
const DebugAddressRangesVector &Ranges = CURangesPair.second;
for (const DebugAddressRange &Range : Ranges) {
write64le(Buffer, Range.LowPC);
write64le(Buffer + 8, Range.HighPC);
write32le(Buffer + 16, CUIndex);
Buffer += 20;
// Don't emit ranges that break gdb,
// https://sourceware.org/bugzilla/show_bug.cgi?id=33247.
// We've seen [0, 0) ranges here, for instance.
if (IsValidAddressRange(Range)) {
write64le(Buffer, Range.LowPC);
write64le(Buffer + 8, Range.HighPC);
write32le(Buffer + 16, CUIndex);
Buffer += 20;
}
}
}

Expand Down
Loading