diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h b/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h index 952c41e188c..88e5432851d 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h @@ -45,6 +45,12 @@ struct RangeListEntry : public DWARFListEntryBase { /// A class representing a single rangelist. class DWARFDebugRnglist : public DWARFListType { public: + /// Build a DWARFAddressRangesVector from a rangelist. + DWARFAddressRangesVector + getAbsoluteRanges(Optional BaseAddr, + function_ref(uint32_t)> + LookupPooledAddress) const; + /// Build a DWARFAddressRangesVector from a rangelist. DWARFAddressRangesVector getAbsoluteRanges(llvm::Optional BaseAddr, diff --git a/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp b/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp index f6785b89e86..9ae4c5b73eb 100644 --- a/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp +++ b/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp @@ -114,12 +114,21 @@ Error RangeListEntry::extract(DWARFDataExtractor Data, uint64_t End, DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges( llvm::Optional BaseAddr, DWARFUnit &U) const { + return getAbsoluteRanges(BaseAddr, [&](uint32_t Index) { + return U.getAddrOffsetSectionItem(Index); + }); +} + +DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges( + Optional BaseAddr, + function_ref(uint32_t)> + LookupPooledAddress) const { DWARFAddressRangesVector Res; for (const RangeListEntry &RLE : Entries) { if (RLE.EntryKind == dwarf::DW_RLE_end_of_list) break; if (RLE.EntryKind == dwarf::DW_RLE_base_addressx) { - BaseAddr = U.getAddrOffsetSectionItem(RLE.Value0); + BaseAddr = LookupPooledAddress(RLE.Value0); if (!BaseAddr) BaseAddr = {RLE.Value0, -1ULL}; continue; @@ -152,7 +161,7 @@ DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges( E.HighPC = E.LowPC + RLE.Value1; break; case dwarf::DW_RLE_startx_length: { - auto Start = U.getAddrOffsetSectionItem(RLE.Value0); + auto Start = LookupPooledAddress(RLE.Value0); if (!Start) Start = {0, -1ULL}; E.SectionIndex = Start->SectionIndex;