LLVM: lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
17
18using namespace llvm;
19
23
24
26 "not enough space to extract a rangelist encoding");
28
30 switch (Encoding) {
31 case dwarf::DW_RLE_end_of_list:
33 break;
34
35 case dwarf::DW_RLE_base_addressx: {
37 break;
38 }
39 case dwarf::DW_RLE_startx_endx:
42 break;
43 case dwarf::DW_RLE_startx_length: {
46 break;
47 }
48 case dwarf::DW_RLE_offset_pair: {
51 break;
52 }
53 case dwarf::DW_RLE_base_address: {
55 break;
56 }
57 case dwarf::DW_RLE_start_end: {
60 break;
61 }
62 case dwarf::DW_RLE_start_length: {
65 break;
66 }
67 default:
70 "unknown rnglists encoding 0x%" PRIx32
71 " at offset 0x%" PRIx64,
73 }
74
75 if () {
79 "read past end of table when reading %s encoding at offset 0x%" PRIx64,
81 }
82
83 *OffsetPtr = C.tell();
86}
87
89 std::optionalobject::SectionedAddress BaseAddr, DWARFUnit &U) const {
91 BaseAddr, U.getAddressByteSize(),
92 [&](uint32_t Index) { return U.getAddrOffsetSectionItem(Index); });
93}
94
96 std::optionalobject::SectionedAddress BaseAddr, uint8_t AddressByteSize,
98 LookupPooledAddress) const {
102 if (RLE.EntryKind == dwarf::DW_RLE_end_of_list)
103 break;
104 if (RLE.EntryKind == dwarf::DW_RLE_base_addressx) {
105 BaseAddr = LookupPooledAddress(RLE.Value0);
106 if (!BaseAddr)
107 BaseAddr = {RLE.Value0, -1ULL};
108 continue;
109 }
110 if (RLE.EntryKind == dwarf::DW_RLE_base_address) {
111 BaseAddr = {RLE.Value0, RLE.SectionIndex};
112 continue;
113 }
114
117 if (BaseAddr && E.SectionIndex == -1ULL)
118 E.SectionIndex = BaseAddr->SectionIndex;
119
120 switch (RLE.EntryKind) {
121 case dwarf::DW_RLE_offset_pair:
122 E.LowPC = RLE.Value0;
124 continue;
125 E.HighPC = RLE.Value1;
126 if (BaseAddr) {
127 if (BaseAddr->Address == Tombstone)
128 continue;
129 E.LowPC += BaseAddr->Address;
130 E.HighPC += BaseAddr->Address;
131 }
132 break;
133 case dwarf::DW_RLE_start_end:
134 E.LowPC = RLE.Value0;
135 E.HighPC = RLE.Value1;
136 break;
137 case dwarf::DW_RLE_start_length:
138 E.LowPC = RLE.Value0;
139 E.HighPC = E.LowPC + RLE.Value1;
140 break;
141 case dwarf::DW_RLE_startx_length: {
142 auto Start = LookupPooledAddress(RLE.Value0);
143 if (!Start)
144 Start = {0, -1ULL};
145 E.SectionIndex = Start->SectionIndex;
146 E.LowPC = Start->Address;
147 E.HighPC = E.LowPC + RLE.Value1;
148 break;
149 }
150 case dwarf::DW_RLE_startx_endx: {
151 auto Start = LookupPooledAddress(RLE.Value0);
152 if (!Start)
153 Start = {0, -1ULL};
154 auto End = LookupPooledAddress(RLE.Value1);
155 if (!End)
156 End = {0, -1ULL};
157
158 E.SectionIndex = Start->SectionIndex;
159 E.LowPC = Start->Address;
160 E.HighPC = End->Address;
161 break;
162 }
163 default:
164
165
167 }
169 continue;
170 Res.push_back(E);
171 }
172 return Res;
173}
174
179 LookupPooledAddress) const {
185 .dump(OS, AddrSize, DumpOpts);
186 OS << " => ";
187 }
188 };
189
191
194
195 assert(!EncodingString.empty() && "Unknown range entry encoding");
196 OS << format(" [%s%*c", EncodingString.data(),
197 MaxEncodingStringLength - EncodingString.size() + 1, ']');
198 if (EntryKind != dwarf::DW_RLE_end_of_list)
199 OS << ": ";
200 }
201
203
205 case dwarf::DW_RLE_end_of_list:
206 OS << (DumpOpts.Verbose ? "" : "");
207 break;
208 case dwarf::DW_RLE_base_addressx: {
209 if (auto SA = LookupPooledAddress(Value0))
210 CurrentBase = SA->Address;
211 else
212 CurrentBase = Value0;
214 return;
216 break;
217 }
218 case dwarf::DW_RLE_base_address:
219
220 CurrentBase = Value0;
222 return;
224 break;
225 case dwarf::DW_RLE_start_length:
226 PrintRawEntry(OS, *this, AddrSize, DumpOpts);
228 break;
229 case dwarf::DW_RLE_offset_pair:
230 PrintRawEntry(OS, *this, AddrSize, DumpOpts);
233 .dump(OS, AddrSize, DumpOpts);
234 else
235 OS << "dead code";
236 break;
237 case dwarf::DW_RLE_start_end:
239 break;
240 case dwarf::DW_RLE_startx_length: {
241 PrintRawEntry(OS, *this, AddrSize, DumpOpts);
243 if (auto SA = LookupPooledAddress(Value0))
244 Start = SA->Address;
246 break;
247 }
248 case dwarf::DW_RLE_startx_endx: {
249 PrintRawEntry(OS, *this, AddrSize, DumpOpts);
251 if (auto SA = LookupPooledAddress(Value0))
252 Start = SA->Address;
254 if (auto SA = LookupPooledAddress(Value1))
255 End = SA->Address;
257 break;
258 }
259 default:
261 }
262 OS << "\n";
263}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains constants used for implementing Dwarf debug support.
LocallyHashedType DenseMapInfo< LocallyHashedType >::Tombstone
LLVM_ABI DWARFAddressRangesVector getAbsoluteRanges(std::optional< object::SectionedAddress > BaseAddr, uint8_t AddressByteSize, function_ref< std::optional< object::SectionedAddress >(uint32_t)> LookupPooledAddress) const
Build a DWARFAddressRangesVector from a rangelist.
Definition DWARFDebugRnglists.cpp:95
LLVM_ABI void dumpAddress(raw_ostream &OS, uint64_t Address) const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
LLVM_ABI StringRef RangeListEncodingString(unsigned Encoding)
LLVM_ABI StringRef RLEString(unsigned RLE)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
uint64_t computeTombstoneAddress(uint8_t AddressByteSize)
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
void consumeError(Error Err)
Consume a Error without doing anything.
std::vector< DWARFAddressRange > DWARFAddressRangesVector
DWARFAddressRangesVector - represents a set of absolute address ranges.
Container for dump options that control which debug information will be dumped.
LLVM_ABI void dump(raw_ostream &OS, uint32_t AddressSize, DIDumpOptions DumpOpts={}, const DWARFObject *Obj=nullptr) const
uint64_t SectionIndex
The index of the section this entry belongs to.
uint8_t EntryKind
The DWARF encoding (DW_RLE_* or DW_LLE_*).
uint64_t Offset
The offset at which the entry is located in the section.
A class representing a single range list entry.
LLVM_ABI Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr)
Definition DWARFDebugRnglists.cpp:20
LLVM_ABI void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength, uint64_t &CurrentBase, DIDumpOptions DumpOpts, llvm::function_ref< std::optional< object::SectionedAddress >(uint32_t)> LookupPooledAddress) const
Definition DWARFDebugRnglists.cpp:175
uint64_t Value0
The values making up the range list entry.