kimanh created this revision. kimanh added a reviewer: jankratochvil. kimanh published this revision for review. kimanh added a comment. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
I've split up the other CL (https://reviews.llvm.org/D107456) into the part that was reviewed, and this: the error handling that was requested on that CL. Please take a look whenever you have time! This adds more informative error handling around the usage of GetRngListData. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D109231 Files: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s =================================================================== --- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s +++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s @@ -29,7 +29,7 @@ # RUN: -o exit 2>&1 | FileCheck --check-prefix=RNGLISTBASE %s # RNGLISTBASE-LABEL: image lookup -v -s lookup_rnglists -# RNGLISTBASE: error: {{.*}}-rnglistbase {0x00000043}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 24), please file a bug and attach the file at the start of this error message +# RNGLISTBASE: error: DW_AT_range-DW_FORM_sec_offset.s.tmp-rnglistbase {0x00000043}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 24, offset to range list table is 0x18), please file a bug and attach the file at the start of this error message .text rnglists: Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -286,7 +286,7 @@ const llvm::Optional<llvm::DWARFDebugRnglistTable> &GetRnglistTable(); - lldb_private::DWARFDataExtractor GetRnglistData() const; + lldb_private::DWARFDataExtractor GetRnglistData(uint32_t &Offset) const; SymbolFileDWARF &m_dwarf; std::shared_ptr<DWARFUnit> m_dwo; Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -513,14 +513,16 @@ return data; } -DWARFDataExtractor DWARFUnit::GetRnglistData() const { +DWARFDataExtractor DWARFUnit::GetRnglistData(uint32_t &Offset) 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)) + entry->getContribution(llvm::DW_SECT_RNGLISTS)) { + Offset = contribution->Offset; return DWARFDataExtractor(data, contribution->Offset, contribution->Length); + } GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError( "Failed to find range list contribution for CU with signature " "0x%" PRIx64, @@ -541,14 +543,18 @@ DWARFUnit::GetRnglistTable() { if (GetVersion() >= 5 && !m_rnglist_table_done) { m_rnglist_table_done = true; + uint32_t contribution_off; if (auto table_or_error = ParseListTableHeader<llvm::DWARFDebugRnglistTable>( - GetRnglistData().GetAsLLVM(), m_ranges_base, DWARF32)) + GetRnglistData(contribution_off).GetAsLLVM(), m_ranges_base, + DWARF32)) m_rnglist_table = std::move(table_or_error.get()); else GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError( - "Failed to extract range list table at offset 0x%" PRIx64 ": %s", - m_ranges_base, toString(table_or_error.takeError()).c_str()); + "Failed to extract range list table at offset 0x%" PRIx64 + " (DW_AT_rnglists_base is %" PRIu64 "): %s", + m_ranges_base + contribution_off, m_ranges_base, + toString(table_or_error.takeError()).c_str()); } return m_rnglist_table; } @@ -563,14 +569,17 @@ "DW_FORM_rnglistx cannot be used without " "DW_AT_rnglists_base for CU at 0x%8.8x", GetOffset()); + uint32_t contribution_off; if (llvm::Optional<uint64_t> off = GetRnglistTable()->getOffsetEntry( - GetRnglistData().GetAsLLVM(), Index)) + GetRnglistData(contribution_off).GetAsLLVM(), Index)) return *off + m_ranges_base; return llvm::createStringError( errc::invalid_argument, "invalid range list table index %u; OffsetEntryCount is %u, " - "DW_AT_rnglists_base is %" PRIu64, - Index, GetRnglistTable()->getOffsetEntryCount(), m_ranges_base); + "DW_AT_rnglists_base is %" PRIu64 + ", offset to range list table is 0x%" PRIx64, + Index, GetRnglistTable()->getOffsetEntryCount(), m_ranges_base, + m_ranges_base + contribution_off); } void DWARFUnit::SetStrOffsetsBase(dw_offset_t str_offsets_base) { @@ -1018,7 +1027,9 @@ return llvm::createStringError(errc::invalid_argument, "missing or invalid range list table"); - llvm::DWARFDataExtractor data = GetRnglistData().GetAsLLVM(); + uint32_t contribution_offset; + llvm::DWARFDataExtractor data = + GetRnglistData(contribution_offset).GetAsLLVM(); // As DW_AT_rnglists_base may be missing we need to call setAddressSize. data.setAddressSize(m_header.GetAddressByteSize());
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits