LLVM  14.0.0git
DWARFDebugAranges.h
Go to the documentation of this file.
1 //===- DWARFDebugAranges.h --------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGES_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGES_H
11 
12 #include "llvm/ADT/DenseSet.h"
14 #include <cstdint>
15 #include <vector>
16 
17 namespace llvm {
18 
19 class DWARFContext;
20 
22 public:
23  void generate(DWARFContext *CTX);
25 
26 private:
27  void clear();
28  void extract(DWARFDataExtractor DebugArangesData,
29  function_ref<void(Error)> RecoverableErrorHandler);
30 
31  /// Call appendRange multiple times and then call construct.
32  void appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC);
33  void construct();
34 
35  struct Range {
36  explicit Range(uint64_t LowPC, uint64_t HighPC, uint64_t CUOffset)
37  : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {}
38 
39  void setHighPC(uint64_t HighPC) {
40  if (HighPC == -1ULL || HighPC <= LowPC)
41  Length = 0;
42  else
43  Length = HighPC - LowPC;
44  }
45 
46  uint64_t HighPC() const {
47  if (Length)
48  return LowPC + Length;
49  return -1ULL;
50  }
51 
52  bool operator<(const Range &other) const {
53  return LowPC < other.LowPC;
54  }
55 
56  uint64_t LowPC; /// Start of address range.
57  uint64_t Length; /// End of address range (not including this address).
58  uint64_t CUOffset; /// Offset of the compile unit or die.
59  };
60 
61  struct RangeEndpoint {
63  uint64_t CUOffset;
64  bool IsRangeStart;
65 
66  RangeEndpoint(uint64_t Address, uint64_t CUOffset, bool IsRangeStart)
67  : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {}
68 
69  bool operator<(const RangeEndpoint &Other) const {
70  return Address < Other.Address;
71  }
72  };
73 
74  using RangeColl = std::vector<Range>;
75  using RangeCollIterator = RangeColl::const_iterator;
76 
77  std::vector<RangeEndpoint> Endpoints;
78  RangeColl Aranges;
79  DenseSet<uint64_t> ParsedCUOffsets;
80 };
81 
82 } // end namespace llvm
83 
84 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGES_H
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::DWARFDebugAranges::findAddress
uint64_t findAddress(uint64_t Address) const
Definition: DWARFDebugAranges.cpp:121
llvm::DWARFContext
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Definition: DWARFContext.h:53
llvm::DWARFDataExtractor
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
Definition: DWARFDataExtractor.h:21
llvm::DWARFDebugAranges::generate
void generate(DWARFContext *CTX)
Definition: DWARFDebugAranges.cpp:45
DenseSet.h
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::DenseSet< uint64_t >
uint64_t
llvm::operator<
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:338
llvm::HighlightColor::Address
@ Address
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::DWARFDebugAranges
Definition: DWARFDebugAranges.h:21
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1172
DWARFDataExtractor.h