diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -286,6 +286,8 @@ const llvm::Optional &GetRnglistTable(); + lldb_private::DWARFDataExtractor GetRnglistData() const; + SymbolFileDWARF &m_dwarf; std::shared_ptr m_dwo; DWARFUnitHeader m_header; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -508,6 +508,19 @@ return data; } +DWARFDataExtractor DWARFUnit::GetRnglistData() const { + DWARFContext &Ctx = GetSymbolFileDWARF().GetDWARFContext(); + const DWARFDataExtractor &data = Ctx.getOrLoadRngListsData(); + if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) { + if (const auto *contribution = + entry->getContribution(llvm::DW_SECT_RNGLISTS)) + return DWARFDataExtractor(data, contribution->Offset, + contribution->Length); + return DWARFDataExtractor(); + } + return data; +} + void DWARFUnit::SetRangesBase(dw_addr_t ranges_base) { lldbassert(!m_rnglist_table_done); @@ -1009,8 +1022,8 @@ return llvm::createStringError(errc::invalid_argument, "missing or invalid range list table"); - auto range_list_or_error = GetRnglistTable()->findList( - m_dwarf.GetDWARFContext().getOrLoadRngListsData().GetAsLLVM(), offset); + auto range_list_or_error = + GetRnglistTable()->findList(GetRnglistData().GetAsLLVM(), offset); if (!range_list_or_error) return range_list_or_error.takeError(); diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s b/lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s --- a/lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s +++ b/lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwp.s @@ -42,8 +42,8 @@ .byte 4 # DWARF Unit Type .byte 8 # Address Size (in bytes) .long .debug_abbrev # Offset Into Abbrev. Section - .quad 1026699901672188186 # DWO id - .byte 1 # Abbrev [1] 0xc:0x5f DW_TAG_compile_unit + .quad 1026699901672188186 # DWO id + .byte 1 # Abbrev [1] DW_TAG_compile_unit .asciz "debug_rnglists-dwp.s.tmp.dwo" # DW_AT_dwo_name .long .Laddr_table_base0 # DW_AT_addr_base .byte 0 # DW_AT_ranges @@ -127,13 +127,13 @@ .byte 8 # Address Size (in bytes) .long 0 # Offset Into Abbrev. Section .quad 1026699901672188186 # DWO id - .byte 1 # Abbrev [1] 0xc:0x5f DW_TAG_compile_unit + .byte 1 # Abbrev [1] DW_TAG_compile_unit .asciz "Hand-written DWARF" # DW_AT_producer - .byte 2 # Abbrev [2] 0x2b:0x37 DW_TAG_subprogram + .byte 2 # Abbrev [2] DW_TAG_subprogram .byte 0 # DW_AT_low_pc .long .Lrnglists_end-rnglists # DW_AT_high_pc .asciz "rnglists" # DW_AT_name - .byte 5 # Abbrev [5] 0x52:0xf DW_TAG_lexical_block + .byte 5 # Abbrev [5] DW_TAG_lexical_block .byte 0 # DW_AT_ranges .byte 0 # End Of Children Mark .byte 0 # End Of Children Mark @@ -189,5 +189,5 @@ ## Table of Section Sizes: .long .LCUEnd-.LCUBegin # Size in .debug_info.dwo .long .LAbbrevEnd-.LAbbrevBegin # Size in .debug_abbrev.dwo - .long .LRLEnd-.LRLBegin # Size in .debug_loclists.dwo + .long .LRLEnd-.LRLBegin # Size in .debug_rnglists.dwo .endif