1 //===- DWARFDebugAranges.h --------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
10 #define LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
12 #include "llvm/ADT/DenseSet.h"
13 #include "llvm/Support/DataExtractor.h"
21 class DWARFDebugAranges
{
23 void generate(DWARFContext
*CTX
);
24 uint32_t findAddress(uint64_t Address
) const;
28 void extract(DataExtractor DebugArangesData
);
30 /// Call appendRange multiple times and then call construct.
31 void appendRange(uint64_t CUOffset
, uint64_t LowPC
, uint64_t HighPC
);
35 explicit Range(uint64_t LowPC
= -1ULL, uint64_t HighPC
= -1ULL,
36 uint32_t CUOffset
= -1U)
37 : LowPC(LowPC
), Length(HighPC
- LowPC
), CUOffset(CUOffset
) {}
39 void setHighPC(uint64_t HighPC
) {
40 if (HighPC
== -1ULL || HighPC
<= LowPC
)
43 Length
= HighPC
- LowPC
;
46 uint64_t HighPC() const {
48 return LowPC
+ Length
;
52 bool operator<(const Range
&other
) const {
53 return LowPC
< other
.LowPC
;
56 uint64_t LowPC
; /// Start of address range.
57 uint32_t Length
; /// End of address range (not including this address).
58 uint32_t CUOffset
; /// Offset of the compile unit or die.
61 struct RangeEndpoint
{
66 RangeEndpoint(uint64_t Address
, uint64_t CUOffset
, bool IsRangeStart
)
67 : Address(Address
), CUOffset(CUOffset
), IsRangeStart(IsRangeStart
) {}
69 bool operator<(const RangeEndpoint
&Other
) const {
70 return Address
< Other
.Address
;
74 using RangeColl
= std::vector
<Range
>;
75 using RangeCollIterator
= RangeColl::const_iterator
;
77 std::vector
<RangeEndpoint
> Endpoints
;
79 DenseSet
<uint64_t> ParsedCUOffsets
;
82 } // end namespace llvm
84 #endif // LLVM_DEBUGINFO_DWARFDEBUGARANGES_H