[Lldb-commits] [lldb] 9dd861a - [nfc] [lldb] 1/2: Fix DW_AT_ranges DW_FORM_sec_offset not using DW_AT_rnglists_base (used by GCC)
Jan Kratochvil via lldb-commits
lldb-commits at lists.llvm.org
Wed May 19 06:57:57 PDT 2021
Author: Jan Kratochvil
Date: 2021-05-19T15:57:40+02:00
New Revision: 9dd861a4f53968c732531de5d4488ace20d6d075
URL: https://github.com/llvm/llvm-project/commit/9dd861a4f53968c732531de5d4488ace20d6d075
DIFF: https://github.com/llvm/llvm-project/commit/9dd861a4f53968c732531de5d4488ace20d6d075.diff
LOG: [nfc] [lldb] 1/2: Fix DW_AT_ranges DW_FORM_sec_offset not using DW_AT_rnglists_base (used by GCC)
Refactor code only for D98289.
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D99653
Added:
Modified:
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
Removed:
################################################################################
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index ea10ba75afa84..6e233f89c714c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -500,6 +500,19 @@ void DWARFUnit::SetRangesBase(dw_addr_t ranges_base) {
ranges_base, toString(table_or_error.takeError()).c_str());
}
+const llvm::Optional<llvm::DWARFDebugRnglistTable> &DWARFUnit::GetRnglist() {
+ return m_rnglist_table;
+}
+
+llvm::Optional<uint64_t> DWARFUnit::GetRnglistOffset(uint32_t Index) {
+ if (!GetRnglist())
+ return llvm::None;
+ if (llvm::Optional<uint64_t> off = GetRnglist()->getOffsetEntry(
+ m_dwarf.GetDWARFContext().getOrLoadRngListsData().GetAsLLVM(), Index))
+ return *off + m_ranges_base;
+ return llvm::None;
+}
+
void DWARFUnit::SetStrOffsetsBase(dw_offset_t str_offsets_base) {
m_str_offsets_base = str_offsets_base;
}
@@ -941,11 +954,11 @@ DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) {
return ranges;
}
- if (!m_rnglist_table)
+ if (!GetRnglist())
return llvm::createStringError(errc::invalid_argument,
"missing or invalid range list table");
- auto range_list_or_error = m_rnglist_table->findList(
+ auto range_list_or_error = GetRnglist()->findList(
m_dwarf.GetDWARFContext().getOrLoadRngListsData().GetAsLLVM(), offset);
if (!range_list_or_error)
return range_list_or_error.takeError();
@@ -976,7 +989,7 @@ llvm::Expected<DWARFRangeList>
DWARFUnit::FindRnglistFromIndex(uint32_t index) {
if (llvm::Optional<uint64_t> offset = GetRnglistOffset(index))
return FindRnglistFromOffset(*offset);
- if (m_rnglist_table)
+ if (GetRnglist())
return llvm::createStringError(errc::invalid_argument,
"invalid range list table index %d", index);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 0fc8ceae81d28..138012d0d922a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -235,15 +235,7 @@ class DWARFUnit : public lldb_private::UserID {
/// Return a rangelist's offset based on an index. The index designates
/// an entry in the rangelist table's offset array and is supplied by
/// DW_FORM_rnglistx.
- llvm::Optional<uint64_t> GetRnglistOffset(uint32_t Index) const {
- if (!m_rnglist_table)
- return llvm::None;
- if (llvm::Optional<uint64_t> off = m_rnglist_table->getOffsetEntry(
- m_dwarf.GetDWARFContext().getOrLoadRngListsData().GetAsLLVM(),
- Index))
- return *off + m_ranges_base;
- return llvm::None;
- }
+ llvm::Optional<uint64_t> GetRnglistOffset(uint32_t Index);
llvm::Optional<uint64_t> GetLoclistOffset(uint32_t Index) {
if (!m_loclist_table_header)
@@ -291,6 +283,8 @@ class DWARFUnit : public lldb_private::UserID {
return &m_die_array[0];
}
+ const llvm::Optional<llvm::DWARFDebugRnglistTable> &GetRnglist();
+
SymbolFileDWARF &m_dwarf;
std::shared_ptr<DWARFUnit> m_dwo;
DWARFUnitHeader m_header;
More information about the lldb-commits
mailing list