LLVM  16.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 class DWARFDataExtractor;
19 class Error;
20 
21 class DWARFContext;
22 
24 public:
25  void generate(DWARFContext *CTX);
26  uint64_t findAddress(uint64_t Address) const;
27 
28 private:
29  void clear();
30  void extract(DWARFDataExtractor DebugArangesData,
31  function_ref<void(Error)> RecoverableErrorHandler,
32  function_ref<void(Error)> WarningHandler);
33 
34  /// Call appendRange multiple times and then call construct.
35  void appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC);
36  void construct();
37 
38  struct Range {
39  explicit Range(uint64_t LowPC, uint64_t HighPC, uint64_t CUOffset)
40  : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {}
41 
42  void setHighPC(uint64_t HighPC) {
43  if (HighPC == -1ULL || HighPC <= LowPC)
44  Length = 0;
45  else
46  Length = HighPC - LowPC;
47  }
48 
49  uint64_t HighPC() const {
50  if (Length)
51  return LowPC + Length;
52  return -1ULL;
53  }
54 
55  bool operator<(const Range &other) const {
56  return LowPC < other.LowPC;
57  }
58 
59  uint64_t LowPC; /// Start of address range.
60  uint64_t Length; /// End of address range (not including this address).
61  uint64_t CUOffset; /// Offset of the compile unit or die.
62  };
63 
64  struct RangeEndpoint {
65  uint64_t Address;
66  uint64_t CUOffset;
67  bool IsRangeStart;
68 
69  RangeEndpoint(uint64_t Address, uint64_t CUOffset, bool IsRangeStart)
70  : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {}
71 
72  bool operator<(const RangeEndpoint &Other) const {
73  return Address < Other.Address;
74  }
75  };
76 
77  using RangeColl = std::vector<Range>;
78  using RangeCollIterator = RangeColl::const_iterator;
79 
80  std::vector<RangeEndpoint> Endpoints;
81  RangeColl Aranges;
82  DenseSet<uint64_t> ParsedCUOffsets;
83 };
84 
85 } // end namespace llvm
86 
87 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGES_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
llvm::DWARFDebugAranges::findAddress
uint64_t findAddress(uint64_t Address) const
Definition: DWARFDebugAranges.cpp:124
llvm::DWARFContext
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Definition: DWARFContext.h:47
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:47
DenseSet.h
STLFunctionalExtras.h
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::DenseSet< uint64_t >
uint64_t
llvm::operator<
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:347
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::DWARFDebugAranges
Definition: DWARFDebugAranges.h:23
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1251