blob: 49a713201d1f65884efe2c755147375c0dae2449 [file] [log] [blame]
Benjamin Kramera6002fd2011-09-14 01:09:52 +00001//===-- 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
16namespace llvm {
17
18class raw_ostream;
19
20class DWARFDebugArangeSet {
21public:
22 struct Header {
23 // The total length of the entries for that set, not including the length
24 // field itself.
25 uint32_t Length;
Benjamin Kramera6002fd2011-09-14 01:09:52 +000026 // The offset from the beginning of the .debug_info section of the
27 // compilation unit entry referenced by the table.
28 uint32_t CuOffset;
Benjamin Kramera59d1182011-09-14 18:34:47 +000029 // The DWARF version number.
30 uint16_t Version;
Benjamin Kramera6002fd2011-09-14 01:09:52 +000031 // 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;
42 uint64_t getEndAddress() const { return Address + Length; }
43 };
44
45private:
46 typedef std::vector<Descriptor> DescriptorColl;
Benjamin Kramera6002fd2011-09-14 01:09:52 +000047 typedef DescriptorColl::const_iterator DescriptorConstIter;
48
49 uint32_t Offset;
Rafael Espindola43e553d2013-03-20 21:03:41 +000050 Header HeaderData;
Benjamin Kramera6002fd2011-09-14 01:09:52 +000051 DescriptorColl ArangeDescriptors;
52
53public:
54 DWARFDebugArangeSet() { clear(); }
55 void clear();
Benjamin Kramera6002fd2011-09-14 01:09:52 +000056 bool extract(DataExtractor data, uint32_t *offset_ptr);
57 void dump(raw_ostream &OS) const;
58
Rafael Espindola43e553d2013-03-20 21:03:41 +000059 uint32_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; }
Benjamin Kramera6002fd2011-09-14 01:09:52 +000060 uint32_t getNumDescriptors() const { return ArangeDescriptors.size(); }
Benjamin Kramera6002fd2011-09-14 01:09:52 +000061 const Descriptor *getDescriptor(uint32_t i) const {
62 if (i < ArangeDescriptors.size())
63 return &ArangeDescriptors[i];
64 return NULL;
65 }
66};
67
68}
69
70#endif