1 //===-- DWARFDebugRanges.h --------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef SymbolFileDWARF_DWARFDebugRanges_h_ 11 #define SymbolFileDWARF_DWARFDebugRanges_h_ 12 13 #include "DWARFDIE.h" 14 #include "SymbolFileDWARF.h" 15 16 #include <map> 17 18 class DWARFDebugRangesBase { 19 public: ~DWARFDebugRangesBase()20 virtual ~DWARFDebugRangesBase(){}; 21 22 virtual void Extract(SymbolFileDWARF *dwarf2Data) = 0; 23 virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset, 24 DWARFRangeList &range_list) const = 0; 25 virtual uint64_t GetOffset(size_t Index) const = 0; 26 }; 27 28 class DWARFDebugRanges final : public DWARFDebugRangesBase { 29 public: 30 DWARFDebugRanges(); 31 32 void Extract(SymbolFileDWARF *dwarf2Data) override; 33 bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset, 34 DWARFRangeList &range_list) const override; 35 uint64_t GetOffset(size_t Index) const override; 36 37 static void Dump(lldb_private::Stream &s, 38 const lldb_private::DWARFDataExtractor &debug_ranges_data, 39 lldb::offset_t *offset_ptr, dw_addr_t cu_base_addr); 40 41 protected: 42 bool Extract(SymbolFileDWARF *dwarf2Data, lldb::offset_t *offset_ptr, 43 DWARFRangeList &range_list); 44 45 typedef std::map<dw_offset_t, DWARFRangeList> range_map; 46 typedef range_map::iterator range_map_iterator; 47 typedef range_map::const_iterator range_map_const_iterator; 48 range_map m_range_map; 49 }; 50 51 // DWARF v5 .debug_rnglists section. 52 class DWARFDebugRngLists final : public DWARFDebugRangesBase { 53 struct RngListEntry { 54 uint8_t encoding; 55 uint64_t value0; 56 uint64_t value1; 57 }; 58 59 public: 60 void Extract(SymbolFileDWARF *dwarf2Data) override; 61 bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset, 62 DWARFRangeList &range_list) const override; 63 uint64_t GetOffset(size_t Index) const override; 64 65 protected: 66 bool ExtractRangeList(const lldb_private::DWARFDataExtractor &data, 67 uint8_t addrSize, lldb::offset_t *offset_ptr, 68 std::vector<RngListEntry> &list); 69 70 std::vector<uint64_t> Offsets; 71 std::map<dw_offset_t, std::vector<RngListEntry>> m_range_map; 72 }; 73 74 #endif // SymbolFileDWARF_DWARFDebugRanges_h_ 75