From d67b550df53d11bc0abbe7a01516f2fa2bb812cc Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 26 Jul 2019 13:15:28 +0000 Subject: [PATCH] DWARF: Improve type safety or range lists parsing Delete the abstract GetOffset function, which is only defined for rnglists entries. Instead fix up entries which refer to the range list classes so that one can statically know that he is dealing with the rnglists section and call the function that way. llvm-svn: 367106 --- .../Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp | 5 ----- .../Plugins/SymbolFile/DWARF/DWARFDebugRanges.h | 4 +--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp | 2 +- .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 4 ++-- .../source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 11 ++++++----- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp index 207c71211c9a..0b08fa09f906 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp @@ -123,11 +123,6 @@ bool DWARFDebugRanges::FindRanges(const DWARFUnit *cu, return false; } -uint64_t DWARFDebugRanges::GetOffset(size_t Index) const { - lldbassert(false && "DW_FORM_rnglistx is not present before DWARF5"); - return 0; -} - bool DWARFDebugRngLists::ExtractRangeList( const DWARFDataExtractor &data, uint8_t addrSize, lldb::offset_t *offset_ptr, std::vector &rangeList) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h index baf2667f0afe..c398259056b3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h @@ -24,7 +24,6 @@ public: virtual void Extract(lldb_private::DWARFContext &context) = 0; virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset, DWARFRangeList &range_list) const = 0; - virtual uint64_t GetOffset(size_t Index) const = 0; }; class DWARFDebugRanges final : public DWARFDebugRangesBase { @@ -34,7 +33,6 @@ public: void Extract(lldb_private::DWARFContext &context) override; bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset, DWARFRangeList &range_list) const override; - uint64_t GetOffset(size_t Index) const override; static void Dump(lldb_private::Stream &s, const lldb_private::DWARFDataExtractor &debug_ranges_data, @@ -62,7 +60,7 @@ public: void Extract(lldb_private::DWARFContext &context) override; bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset, DWARFRangeList &range_list) const override; - uint64_t GetOffset(size_t Index) const override; + uint64_t GetOffset(size_t Index) const; protected: bool ExtractRangeList(const lldb_private::DWARFDataExtractor &data, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index 33e83d1fe57f..0c60ae82240c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -870,7 +870,7 @@ DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) const { llvm::Expected DWARFUnit::FindRnglistFromIndex(uint32_t index) const { - const DWARFDebugRangesBase *debug_rnglists = m_dwarf.GetDebugRngLists(); + const DWARFDebugRngLists *debug_rnglists = m_dwarf.GetDebugRngLists(); if (!debug_rnglists) return llvm::make_error( "No debug_rnglists section"); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index f14c2db53f99..c1d5506f0577 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -598,7 +598,7 @@ SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) { return nullptr; } -DWARFDebugRangesBase *SymbolFileDWARF::GetDebugRanges() { +DWARFDebugRanges *SymbolFileDWARF::GetDebugRanges() { if (!m_ranges) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION, @@ -613,7 +613,7 @@ DWARFDebugRangesBase *SymbolFileDWARF::GetDebugRanges() { return m_ranges.get(); } -DWARFDebugRangesBase *SymbolFileDWARF::GetDebugRngLists() { +DWARFDebugRngLists *SymbolFileDWARF::GetDebugRngLists() { if (!m_rnglists) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index bf53ad6a82ac..97c75ade6b53 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -46,7 +46,8 @@ class DWARFDebugAranges; class DWARFDebugInfo; class DWARFDebugInfoEntry; class DWARFDebugLine; -class DWARFDebugRangesBase; +class DWARFDebugRanges; +class DWARFDebugRngLists; class DWARFDeclContext; class DWARFFormValue; class DWARFTypeUnit; @@ -217,8 +218,8 @@ public: const DWARFDebugInfo *DebugInfo() const; - DWARFDebugRangesBase *GetDebugRanges(); - DWARFDebugRangesBase *GetDebugRngLists(); + DWARFDebugRanges *GetDebugRanges(); + DWARFDebugRngLists *GetDebugRngLists(); const lldb_private::DWARFDataExtractor &DebugLocData(); @@ -477,8 +478,8 @@ protected: typedef std::set DIERefSet; typedef llvm::StringMap NameToOffsetMap; NameToOffsetMap m_function_scope_qualified_name_map; - std::unique_ptr m_ranges; - std::unique_ptr m_rnglists; + std::unique_ptr m_ranges; + std::unique_ptr m_rnglists; UniqueDWARFASTTypeMap m_unique_ast_type_map; DIEToTypePtr m_die_to_type; DIEToVariableSP m_die_to_variable_sp;