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