• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H
11 #define LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H
12 
13 #include "llvm/Support/DataExtractor.h"
14 #include <vector>
15 
16 namespace llvm {
17 
18 class raw_ostream;
19 
20 class DWARFDebugArangeSet {
21 public:
22   struct Header {
23     // The total length of the entries for that set, not including the length
24     // field itself.
25     uint32_t Length;
26     // The offset from the beginning of the .debug_info section of the
27     // compilation unit entry referenced by the table.
28     uint32_t CuOffset;
29     // The DWARF version number.
30     uint16_t Version;
31     // The size in bytes of an address on the target architecture. For segmented
32     // addressing, this is the size of the offset portion of the address.
33     uint8_t AddrSize;
34     // The size in bytes of a segment descriptor on the target architecture.
35     // If the target system uses a flat address space, this value is 0.
36     uint8_t SegSize;
37   };
38 
39   struct Descriptor {
40     uint64_t Address;
41     uint64_t Length;
getEndAddressDescriptor42     uint64_t getEndAddress() const { return Address + Length; }
43   };
44 
45 private:
46   typedef std::vector<Descriptor> DescriptorColl;
47   typedef DescriptorColl::iterator DescriptorIter;
48   typedef DescriptorColl::const_iterator DescriptorConstIter;
49 
50   uint32_t Offset;
51   Header Header;
52   DescriptorColl ArangeDescriptors;
53 
54 public:
DWARFDebugArangeSet()55   DWARFDebugArangeSet() { clear(); }
56   void clear();
57   void compact();
58   bool extract(DataExtractor data, uint32_t *offset_ptr);
59   void dump(raw_ostream &OS) const;
60 
getCompileUnitDIEOffset()61   uint32_t getCompileUnitDIEOffset() const { return Header.CuOffset; }
getOffsetOfNextEntry()62   uint32_t getOffsetOfNextEntry() const { return Offset + Header.Length + 4; }
63   uint32_t findAddress(uint64_t address) const;
getNumDescriptors()64   uint32_t getNumDescriptors() const { return ArangeDescriptors.size(); }
getHeader()65   const struct Header &getHeader() const { return Header; }
getDescriptor(uint32_t i)66   const Descriptor *getDescriptor(uint32_t i) const {
67     if (i < ArangeDescriptors.size())
68       return &ArangeDescriptors[i];
69     return NULL;
70   }
71 };
72 
73 }
74 
75 #endif
76