LLVM 20.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
17namespace llvm {
18class DWARFDataExtractor;
19class Error;
20
21class DWARFContext;
22
24public:
25 void generate(DWARFContext *CTX);
27
28private:
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
This file defines the DenseSet and SmallDenseSet classes.
loop extract
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Definition: DWARFContext.h:48
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
void generate(DWARFContext *CTX)
uint64_t findAddress(uint64_t Address) const
Implements a dense probed hash-table based set.
Definition: DenseSet.h:271
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Length
Definition: DWP.cpp:480
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:361
@ Other
Any other memory.