-
Notifications
You must be signed in to change notification settings - Fork 10.7k
/
DWARFDebugRangeList.h
95 lines (80 loc) · 3.24 KB
/
DWARFDebugRangeList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//===- DWARFDebugRangeList.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include <cassert>
#include <cstdint>
#include <vector>
namespace llvm {
struct BaseAddress;
class raw_ostream;
struct DWARFAddressRange {
uint64_t LowPC;
uint64_t HighPC;
uint64_t SectionIndex;
};
/// DWARFAddressRangesVector - represents a set of absolute address ranges.
using DWARFAddressRangesVector = std::vector<DWARFAddressRange>;
class DWARFDebugRangeList {
public:
struct RangeListEntry {
/// A beginning address offset. This address offset has the size of an
/// address and is relative to the applicable base address of the
/// compilation unit referencing this range list. It marks the beginning
/// of an address range.
uint64_t StartAddress;
/// An ending address offset. This address offset again has the size of
/// an address and is relative to the applicable base address of the
/// compilation unit referencing this range list. It marks the first
/// address past the end of the address range. The ending address must
/// be greater than or equal to the beginning address.
uint64_t EndAddress;
/// A section index this range belongs to.
uint64_t SectionIndex;
/// The end of any given range list is marked by an end of list entry,
/// which consists of a 0 for the beginning address offset
/// and a 0 for the ending address offset.
bool isEndOfListEntry() const {
return (StartAddress == 0) && (EndAddress == 0);
}
/// A base address selection entry consists of:
/// 1. The value of the largest representable address offset
/// (for example, 0xffffffff when the size of an address is 32 bits).
/// 2. An address, which defines the appropriate base address for
/// use in interpreting the beginning and ending address offsets of
/// subsequent entries of the location list.
bool isBaseAddressSelectionEntry(uint8_t AddressSize) const {
assert(AddressSize == 4 || AddressSize == 8);
if (AddressSize == 4)
return StartAddress == -1U;
else
return StartAddress == -1ULL;
}
};
private:
/// Offset in .debug_ranges section.
uint32_t Offset;
uint8_t AddressSize;
std::vector<RangeListEntry> Entries;
public:
DWARFDebugRangeList() { clear(); }
void clear();
void dump(raw_ostream &OS) const;
bool extract(const DWARFDataExtractor &data, uint32_t *offset_ptr);
const std::vector<RangeListEntry> &getEntries() { return Entries; }
/// getAbsoluteRanges - Returns absolute address ranges defined by this range
/// list. Has to be passed base address of the compile unit referencing this
/// range list.
DWARFAddressRangesVector
getAbsoluteRanges(llvm::Optional<BaseAddress> BaseAddr) const;
};
} // end namespace llvm
#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H