[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
This commit is contained in:
Jan Kratochvil 2021-05-19 15:49:14 +02:00
parent ab4e04a0f3
commit 9dd861a4f5
2 changed files with 19 additions and 12 deletions

View File

@ -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);

View File

@ -235,15 +235,7 @@ public:
/// 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 @@ protected:
return &m_die_array[0];
}
const llvm::Optional<llvm::DWARFDebugRnglistTable> &GetRnglist();
SymbolFileDWARF &m_dwarf;
std::shared_ptr<DWARFUnit> m_dwo;
DWARFUnitHeader m_header;