LLVM  6.0.0svn
DWARFDebugAranges.h
Go to the documentation of this file.
1 //===- DWARFDebugAranges.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_DWARFDEBUGARANGES_H
11 #define LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
12 
13 #include "llvm/ADT/DenseSet.h"
15 #include <cstdint>
16 #include <vector>
17 
18 namespace llvm {
19 
20 class DWARFContext;
21 
23 public:
24  void generate(DWARFContext *CTX);
25  uint32_t findAddress(uint64_t Address) const;
26 
27 private:
28  void clear();
29  void extract(DataExtractor DebugArangesData);
30 
31  /// Call appendRange multiple times and then call construct.
32  void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
33  void construct();
34 
35  struct Range {
36  explicit Range(uint64_t LowPC = -1ULL, uint64_t HighPC = -1ULL,
37  uint32_t CUOffset = -1U)
38  : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {}
39 
40  void setHighPC(uint64_t HighPC) {
41  if (HighPC == -1ULL || HighPC <= LowPC)
42  Length = 0;
43  else
44  Length = HighPC - LowPC;
45  }
46 
47  uint64_t HighPC() const {
48  if (Length)
49  return LowPC + Length;
50  return -1ULL;
51  }
52 
53  bool containsAddress(uint64_t Address) const {
54  return LowPC <= Address && Address < HighPC();
55  }
56 
57  bool operator<(const Range &other) const {
58  return LowPC < other.LowPC;
59  }
60 
61  uint64_t LowPC; /// Start of address range.
62  uint32_t Length; /// End of address range (not including this address).
63  uint32_t CUOffset; /// Offset of the compile unit or die.
64  };
65 
66  struct RangeEndpoint {
67  uint64_t Address;
68  uint32_t CUOffset;
69  bool IsRangeStart;
70 
71  RangeEndpoint(uint64_t Address, uint32_t CUOffset, bool IsRangeStart)
72  : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {}
73 
74  bool operator<(const RangeEndpoint &Other) const {
75  return Address < Other.Address;
76  }
77  };
78 
79  using RangeColl = std::vector<Range>;
80  using RangeCollIterator = RangeColl::const_iterator;
81 
82  std::vector<RangeEndpoint> Endpoints;
83  RangeColl Aranges;
84  DenseSet<uint32_t> ParsedCUOffsets;
85 };
86 
87 } // end namespace llvm
88 
89 #endif // LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
uint32_t findAddress(uint64_t Address) const
void generate(DWARFContext *CTX)
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:736
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Definition: DWARFContext.h:59
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:326