]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / source / Plugins / SymbolFile / DWARF / DWARFDebugArangeSet.h
1 //===-- DWARFDebugArangeSet.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_DWARFDebugArangeSet_h_
11 #define SymbolFileDWARF_DWARFDebugArangeSet_h_
12
13 #include "SymbolFileDWARF.h"
14 #include <vector>
15
16 class SymbolFileDWARF;
17
18 class DWARFDebugArangeSet {
19 public:
20   struct Header {
21     uint32_t length;    // The total length of the entries for that set, not
22                         // including the length field itself.
23     uint16_t version;   // The DWARF version number
24     uint32_t cu_offset; // The offset from the beginning of the .debug_info
25                         // section of the compilation unit entry referenced by
26                         // the table.
27     uint8_t addr_size;  // The size in bytes of an address on the target
28                         // architecture. For segmented addressing, this is the
29                         // size of the offset portion of the address
30     uint8_t seg_size; // The size in bytes of a segment descriptor on the target
31                       // architecture. If the target system uses a flat address
32                       // space, this value is 0.
33   };
34
35   struct Descriptor {
36     dw_addr_t address;
37     dw_addr_t length;
38     dw_addr_t end_address() const { return address + length; }
39   };
40
41   DWARFDebugArangeSet();
42   void Clear();
43   void SetOffset(uint32_t offset) { m_offset = offset; }
44   void SetHeader(uint16_t version, uint32_t cu_offset, uint8_t addr_size,
45                  uint8_t seg_size);
46   void AddDescriptor(const DWARFDebugArangeSet::Descriptor &range);
47   void Compact();
48   bool Extract(const lldb_private::DWARFDataExtractor &data,
49                lldb::offset_t *offset_ptr);
50   void Dump(lldb_private::Stream *s) const;
51   dw_offset_t GetCompileUnitDIEOffset() const { return m_header.cu_offset; }
52   dw_offset_t GetOffsetOfNextEntry() const;
53   dw_offset_t FindAddress(dw_addr_t address) const;
54   size_t NumDescriptors() const { return m_arange_descriptors.size(); }
55   const Header &GetHeader() const { return m_header; }
56   const Descriptor *GetDescriptor(uint32_t i) const {
57     if (i < m_arange_descriptors.size())
58       return &m_arange_descriptors[i];
59     return NULL;
60   }
61
62   const Descriptor &GetDescriptorRef(uint32_t i) const {
63     return m_arange_descriptors[i];
64   }
65
66 protected:
67   typedef std::vector<Descriptor> DescriptorColl;
68   typedef DescriptorColl::iterator DescriptorIter;
69   typedef DescriptorColl::const_iterator DescriptorConstIter;
70
71   uint32_t m_offset;
72   Header m_header;
73   DescriptorColl m_arange_descriptors;
74 };
75
76 #endif // SymbolFileDWARF_DWARFDebugArangeSet_h_