xref: /freebsd-src/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
10b57cec5SDimitry Andric //===-- DWARFDebugArangeSet.h -----------------------------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
95ffd83dbSDimitry Andric #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGESET_H
105ffd83dbSDimitry Andric #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGESET_H
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric #include "lldb/Core/dwarf.h"
130b57cec5SDimitry Andric #include <cstdint>
140b57cec5SDimitry Andric #include <vector>
150b57cec5SDimitry Andric 
16*5f757f3fSDimitry Andric namespace lldb_private::plugin {
17*5f757f3fSDimitry Andric namespace dwarf {
180b57cec5SDimitry Andric class DWARFDebugArangeSet {
190b57cec5SDimitry Andric public:
200b57cec5SDimitry Andric   struct Header {
21fe6060f1SDimitry Andric     /// The total length of the entries for that set, not including the length
22fe6060f1SDimitry Andric     /// field itself.
23fe6060f1SDimitry Andric     uint32_t length = 0;
24fe6060f1SDimitry Andric     /// The DWARF version number.
25fe6060f1SDimitry Andric     uint16_t version = 0;
26fe6060f1SDimitry Andric     /// The offset from the beginning of the .debug_info section of the
27fe6060f1SDimitry Andric     /// compilation unit entry referenced by the table.
28fe6060f1SDimitry Andric     uint32_t cu_offset = 0;
29fe6060f1SDimitry Andric     /// The size in bytes of an address on the target architecture. For
30fe6060f1SDimitry Andric     /// segmented addressing, this is the size of the offset portion of the
31fe6060f1SDimitry Andric     /// address.
32fe6060f1SDimitry Andric     uint8_t addr_size = 0;
33fe6060f1SDimitry Andric     /// The size in bytes of a segment descriptor on the target architecture.
34fe6060f1SDimitry Andric     /// If the target system uses a flat address space, this value is 0.
35fe6060f1SDimitry Andric     uint8_t seg_size = 0;
360b57cec5SDimitry Andric   };
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric   struct Descriptor {
390b57cec5SDimitry Andric     dw_addr_t address;
400b57cec5SDimitry Andric     dw_addr_t length;
end_addressDescriptor410b57cec5SDimitry Andric     dw_addr_t end_address() const { return address + length; }
420b57cec5SDimitry Andric   };
430b57cec5SDimitry Andric 
440b57cec5SDimitry Andric   DWARFDebugArangeSet();
450b57cec5SDimitry Andric   void Clear();
SetOffset(uint32_t offset)460b57cec5SDimitry Andric   void SetOffset(uint32_t offset) { m_offset = offset; }
47*5f757f3fSDimitry Andric   llvm::Error extract(const DWARFDataExtractor &data,
480b57cec5SDimitry Andric                       lldb::offset_t *offset_ptr);
490b57cec5SDimitry Andric   dw_offset_t FindAddress(dw_addr_t address) const;
NumDescriptors()500b57cec5SDimitry Andric   size_t NumDescriptors() const { return m_arange_descriptors.size(); }
GetHeader()510b57cec5SDimitry Andric   const Header &GetHeader() const { return m_header; }
GetNextOffset()52fe6060f1SDimitry Andric   dw_offset_t GetNextOffset() const { return m_next_offset; }
GetDescriptorRef(uint32_t i)530b57cec5SDimitry Andric   const Descriptor &GetDescriptorRef(uint32_t i) const {
540b57cec5SDimitry Andric     return m_arange_descriptors[i];
550b57cec5SDimitry Andric   }
560b57cec5SDimitry Andric 
570b57cec5SDimitry Andric protected:
580b57cec5SDimitry Andric   typedef std::vector<Descriptor> DescriptorColl;
590b57cec5SDimitry Andric   typedef DescriptorColl::iterator DescriptorIter;
600b57cec5SDimitry Andric   typedef DescriptorColl::const_iterator DescriptorConstIter;
610b57cec5SDimitry Andric 
62fe6060f1SDimitry Andric   dw_offset_t m_offset;
63fe6060f1SDimitry Andric   dw_offset_t m_next_offset;
640b57cec5SDimitry Andric   Header m_header;
650b57cec5SDimitry Andric   DescriptorColl m_arange_descriptors;
660b57cec5SDimitry Andric };
67*5f757f3fSDimitry Andric } // namespace dwarf
68*5f757f3fSDimitry Andric } // namespace lldb_private::plugin
690b57cec5SDimitry Andric 
705ffd83dbSDimitry Andric #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGESET_H
71