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