1 //===-- DWARFDebugArangeSet.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 LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGESET_H 10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGESET_H 11 12 #include "lldb/Core/dwarf.h" 13 #include <cstdint> 14 #include <vector> 15 16 namespace lldb_private::plugin { 17 namespace dwarf { 18 class DWARFDebugArangeSet { 19 public: 20 struct Header { 21 /// The total length of the entries for that set, not including the length 22 /// field itself. 23 uint32_t length = 0; 24 /// The DWARF version number. 25 uint16_t version = 0; 26 /// The offset from the beginning of the .debug_info section of the 27 /// compilation unit entry referenced by the table. 28 uint32_t cu_offset = 0; 29 /// The size in bytes of an address on the target architecture. For 30 /// segmented addressing, this is the size of the offset portion of the 31 /// address. 32 uint8_t addr_size = 0; 33 /// The size in bytes of a segment descriptor on the target architecture. 34 /// If the target system uses a flat address space, this value is 0. 35 uint8_t seg_size = 0; 36 }; 37 38 struct Descriptor { 39 dw_addr_t address; 40 dw_addr_t length; 41 dw_addr_t end_address() const { return address + length; } 42 }; 43 44 DWARFDebugArangeSet(); 45 void Clear(); 46 void SetOffset(uint32_t offset) { m_offset = offset; } 47 llvm::Error extract(const DWARFDataExtractor &data, 48 lldb::offset_t *offset_ptr); 49 dw_offset_t FindAddress(dw_addr_t address) const; 50 size_t NumDescriptors() const { return m_arange_descriptors.size(); } 51 const Header &GetHeader() const { return m_header; } 52 dw_offset_t GetNextOffset() const { return m_next_offset; } 53 const Descriptor &GetDescriptorRef(uint32_t i) const { 54 return m_arange_descriptors[i]; 55 } 56 57 protected: 58 typedef std::vector<Descriptor> DescriptorColl; 59 typedef DescriptorColl::iterator DescriptorIter; 60 typedef DescriptorColl::const_iterator DescriptorConstIter; 61 62 dw_offset_t m_offset; 63 dw_offset_t m_next_offset; 64 Header m_header; 65 DescriptorColl m_arange_descriptors; 66 }; 67 } // namespace dwarf 68 } // namespace lldb_private::plugin 69 70 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGESET_H 71