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
This commit is contained in:
Pavel Labath 2019-07-26 13:15:28 +00:00
parent 0b28357053
commit d67b550df5
5 changed files with 10 additions and 16 deletions

View File

@ -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<RngListEntry> &rangeList) {

View File

@ -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,

View File

@ -870,7 +870,7 @@ DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) const {
llvm::Expected<DWARFRangeList>
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<llvm::object::GenericBinaryError>(
"No debug_rnglists section");

View File

@ -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,

View File

@ -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<lldb::user_id_t> DIERefSet;
typedef llvm::StringMap<DIERefSet> NameToOffsetMap;
NameToOffsetMap m_function_scope_qualified_name_map;
std::unique_ptr<DWARFDebugRangesBase> m_ranges;
std::unique_ptr<DWARFDebugRangesBase> m_rnglists;
std::unique_ptr<DWARFDebugRanges> m_ranges;
std::unique_ptr<DWARFDebugRngLists> m_rnglists;
UniqueDWARFASTTypeMap m_unique_ast_type_map;
DIEToTypePtr m_die_to_type;
DIEToVariableSP m_die_to_variable_sp;