LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 "DWARFDebugArangeSet.h"
14 #include "llvm/ADT/DenseSet.h"
15 #include <list>
16 
17 namespace llvm {
18 
19 class DWARFContext;
20 
22 public:
23  void clear() {
24  Aranges.clear();
25  ParsedCUOffsets.clear();
26  }
27 
28  void generate(DWARFContext *CTX);
29 
30  // Use appendRange multiple times and then call sortAndMinimize.
31  void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
32 
33  uint32_t findAddress(uint64_t Address) const;
34 
35 private:
36  void extract(DataExtractor DebugArangesData);
37  void sortAndMinimize();
38 
39  struct Range {
40  explicit Range(uint64_t LowPC = -1ULL, uint64_t HighPC = -1ULL,
41  uint32_t CUOffset = -1U)
42  : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {}
43 
44  void setHighPC(uint64_t HighPC) {
45  if (HighPC == -1ULL || HighPC <= LowPC)
46  Length = 0;
47  else
48  Length = HighPC - LowPC;
49  }
50  uint64_t HighPC() const {
51  if (Length)
52  return LowPC + Length;
53  return -1ULL;
54  }
55  bool containsAddress(uint64_t Address) const {
56  return LowPC <= Address && Address < HighPC();
57  }
58 
59  bool operator <(const Range &other) const {
60  return LowPC < other.LowPC;
61  }
62 
63  static bool SortedOverlapCheck(const Range &Left, const Range &Right) {
64  if (Left.CUOffset != Right.CUOffset)
65  return false;
66  return Left.HighPC() >= Right.LowPC;
67  }
68 
69  uint64_t LowPC; // Start of address range.
70  uint32_t Length; // End of address range (not including this address).
71  uint32_t CUOffset; // Offset of the compile unit or die.
72  };
73 
74  typedef std::vector<Range> RangeColl;
75  typedef RangeColl::const_iterator RangeCollIterator;
76  typedef DenseSet<uint32_t> ParsedCUOffsetColl;
77 
78  RangeColl Aranges;
79  ParsedCUOffsetColl ParsedCUOffsets;
80 };
81 
82 }
83 
84 #endif
void operator<(const Optional< T > &X, const Optional< U > &Y)
Poison comparison between two Optional objects. Clients needs to explicitly compare the underlying va...
void generate(DWARFContext *CTX)
void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC)
void clear()
Definition: DenseSet.h:41
uint32_t findAddress(uint64_t Address) const