LLVM: include/llvm/DebugInfo/DWARF/DWARFDie.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_DEBUGINFO_DWARF_DWARFDIE_H
10#define LLVM_DEBUGINFO_DWARF_DWARFDIE_H
11
22#include
23#include
24#include
25
26namespace llvm {
27
30
31
32
33
34
35
36
37
38
39
40
41
42
46
47public:
51
52 bool isValid() const { return U && Die; }
53 explicit operator bool() const { return isValid(); }
56
57
58
59
61 assert(isValid() && "must check validity prior to calling");
62 return Die->getAbbreviationDeclarationPtr();
63 }
64
65
66
67
69 assert(isValid() && "must check validity prior to calling");
70 return Die->getOffset();
71 }
72
75 if (AbbrevDecl)
76 return AbbrevDecl->getTag();
77 return dwarf::DW_TAG_null;
78 }
79
81 assert(isValid() && "must check validity prior to calling");
82 return Die->hasChildren();
83 }
84
85
87
88
90
91
93
94
95
96
97
99
100
101
102
103
105
106
107
108
109
111
112
113
114
115
117
118
119
120
121
123
124
125
126
127
130
131
133
134
135
136
137
138
139
140
141
142
144
145
146
147
148
149
150
151
152
153
154
155
156 LLVM_ABI std::optional
158
159
160
161
162
163
164
165
166
167
168 LLVM_ABI std::optional
170
171
172
173
174
175
176
177
178
179
180
181
182
183
188
190
193
194
195
196
197
198
201
202
203
204
205
206
207
208
209
210
211
213
214
215
217 uint64_t &SectionIndex) const;
218
219
220
221
222
223
224
225
226
227
228
230
232
234
237
238
239
240
241
243
244
245
246
247
250 std::string *OriginalFullName = nullptr) const;
251
252
253
254
256
257
258
259
261
262
263
264
265
269
270
271
272
273
274
275
276
277
278
279
280
281
284 uint32_t &CallDiscriminator) const;
285
286 class attribute_iterator;
287
288
289
290
292
293
294
295
296
297
299
301
304
305 std::reverse_iterator rbegin() const;
306 std::reverse_iterator rend() const;
307
309};
310
313 const DWARFAttribute> {
314
316
318
320
323
324
325
326
327
328
330
331public:
334
337 explicit operator bool() const { return AttrValue.isValid(); }
339};
340
343 return LHS.Index == RHS.Index;
344}
345
349}
350
352 return LHS.getDebugInfoEntry() == RHS.getDebugInfoEntry() &&
353 LHS.getDwarfUnit() == RHS.getDwarfUnit();
354}
355
358}
359
361 return LHS.getOffset() < RHS.getOffset();
362}
363
366 const DWARFDie> {
368
369 friend std::reverse_iteratorllvm::DWARFDie::iterator;
372
373public:
375
377
379 Die = Die.getSibling();
380 return *this;
381 }
382
384 Die = Die.getPreviousSibling();
385 return *this;
386 }
387
389};
390
393 return LHS.Die == RHS.Die;
394}
395
396
397
401
405
409
410}
411
412namespace std {
413
414template <>
417 reverse_iteratorllvm::DWARFDie::iterator,
418 bidirectional_iterator_tag, const llvm::DWARFDie> {
419
420private:
422 bool AtEnd;
423
424public:
426 : Die(It.Die), AtEnd(!It.Die.getPreviousSibling()) {
427 if (!AtEnd)
428 Die = Die.getPreviousSibling();
429 }
430
434
436 assert(!AtEnd && "Incrementing rend");
438 if (D)
439 Die = D;
440 else
441 AtEnd = true;
442 return *this;
443 }
444
446 if (AtEnd) {
447 AtEnd = false;
448 return *this;
449 }
450 Die = Die.getSibling();
451 assert(!Die.isNULL() && "Decrementing rbegin");
452 return *this;
453 }
454
456 assert(Die.isValid());
457 return Die;
458 }
459
460
461
462
464 return Die == RHS.Die && AtEnd == RHS.AtEnd;
465 }
466};
467
468}
469
470namespace llvm {
471
472inline bool operator==(const std::reverse_iteratorDWARFDie::iterator &LHS,
473 const std::reverse_iteratorDWARFDie::iterator &RHS) {
475}
476
477inline bool operator!=(const std::reverse_iteratorDWARFDie::iterator &LHS,
478 const std::reverse_iteratorDWARFDie::iterator &RHS) {
480}
481
482inline std::reverse_iteratorDWARFDie::iterator DWARFDie::rbegin() const {
483 return std::make_reverse_iterator(end());
484}
485
486inline std::reverse_iteratorDWARFDie::iterator DWARFDie::rend() const {
487 return std::make_reverse_iterator(begin());
488}
489
492 std::string *OriginalFullName = nullptr);
493
494}
495
496#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file contains constants used for implementing Dwarf debug support.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
A structured debug information entry.
DWARFDebugInfoEntry - A DIE with only the minimum required data.
Definition DWARFDie.h:313
const DWARFAttribute & operator*() const
Definition DWARFDie.h:338
LLVM_ABI attribute_iterator & operator++()
attribute_iterator()=delete
friend bool operator==(const attribute_iterator &LHS, const attribute_iterator &RHS)
Definition DWARFDie.h:341
LLVM_ABI attribute_iterator & operator--()
Definition DWARFDie.h:366
iterator & operator--()
Definition DWARFDie.h:383
iterator(DWARFDie D)
Definition DWARFDie.h:376
friend bool operator==(const DWARFDie::iterator &LHS, const DWARFDie::iterator &RHS)
Definition DWARFDie.h:391
iterator & operator++()
Definition DWARFDie.h:378
const DWARFDie & operator*() const
Definition DWARFDie.h:388
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition DWARFDie.h:43
LLVM_ABI void getFullName(raw_string_ostream &, std::string *OriginalFullName=nullptr) const
LLVM_ABI DWARFDie resolveTypeUnitReference() const
LLVM_ABI std::optional< uint64_t > getLocBaseAttribute() const
uint64_t getOffset() const
Get the absolute offset into the debug info or types section.
Definition DWARFDie.h:68
LLVM_ABI const char * getShortName() const
Return the DIE short name resolving DW_AT_specification or DW_AT_abstract_origin references if necess...
DWARFDie(DWARFUnit *Unit, const DWARFDebugInfoEntry *D)
Definition DWARFDie.h:50
LLVM_ABI Expected< DWARFAddressRangesVector > getAddressRanges() const
Get the address ranges for this DIE.
iterator_range< iterator > children() const
Definition DWARFDie.h:406
std::reverse_iterator< iterator > rbegin() const
Definition DWARFDie.h:482
LLVM_ABI DWARFDie getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE as the referenced DIE.
LLVM_ABI DWARFDie getParent() const
Get the parent of this DIE object.
LLVM_ABI std::optional< DWARFFormValue > find(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE.
iterator end() const
Definition DWARFDie.h:402
DWARFUnit * getDwarfUnit() const
Definition DWARFDie.h:55
const DWARFDebugInfoEntry * getDebugInfoEntry() const
Definition DWARFDie.h:54
LLVM_ABI const char * getSubroutineName(DINameKind Kind) const
If a DIE represents a subprogram (or inlined subroutine), returns its mangled name (or short name,...
bool hasChildren() const
Definition DWARFDie.h:80
LLVM_ABI DWARFDie getSibling() const
Get the sibling of this DIE object.
LLVM_ABI bool isSubroutineDIE() const
Returns true if DIE represents a subprogram or an inlined subroutine.
LLVM_ABI bool getLowAndHighPC(uint64_t &LowPC, uint64_t &HighPC, uint64_t &SectionIndex) const
Retrieves DW_AT_low_pc and DW_AT_high_pc from CU.
LLVM_ABI LLVM_DUMP_METHOD void dump() const
Convenience zero-argument overload for debugging.
LLVM_ABI void getCallerFrame(uint32_t &CallFile, uint32_t &CallLine, uint32_t &CallColumn, uint32_t &CallDiscriminator) const
Retrieves values of DW_AT_call_file, DW_AT_call_line and DW_AT_call_column from DIE (or zeroes if the...
LLVM_ABI bool isSubprogramDIE() const
Returns true if DIE represents a subprogram (not inlined).
LLVM_ABI bool addressRangeContainsAddress(const uint64_t Address) const
LLVM_ABI std::optional< DWARFFormValue > findRecursively(ArrayRef< dwarf::Attribute > Attrs) const
Extract the first value of any attribute in Attrs from this DIE and recurse into any DW_AT_specificat...
llvm::DWARFFormValue DWARFFormValue
Definition DWARFDie.h:48
LLVM_ABI std::optional< uint64_t > getHighPC(uint64_t LowPC) const
Get the DW_AT_high_pc attribute value as an address.
LLVM_ABI std::optional< uint64_t > getTypeSize(uint64_t PointerSize)
Gets the type size (in bytes) for this DIE.
LLVM_ABI DWARFDie resolveReferencedType(dwarf::Attribute Attr) const
LLVM_ABI const char * getName(DINameKind Kind) const
Return the DIE name resolving DW_AT_specification or DW_AT_abstract_origin references if necessary.
LLVM_ABI DWARFDie getLastChild() const
Get the last child of this DIE object.
LLVM_ABI DWARFDie getPreviousSibling() const
Get the previous sibling of this DIE object.
const DWARFAbbreviationDeclaration * getAbbreviationDeclarationPtr() const
Get the abbreviation declaration for this DIE.
Definition DWARFDie.h:60
iterator begin() const
Definition DWARFDie.h:398
LLVM_ABI std::string getDeclFile(DILineInfoSpecifier::FileLineInfoKind Kind) const
LLVM_ABI DWARFDie getFirstChild() const
Get the first child of this DIE object.
LLVM_ABI uint64_t getDeclLine() const
Returns the declaration line (start line) for a DIE, assuming it specifies a subprogram.
dwarf::Tag getTag() const
Definition DWARFDie.h:73
LLVM_ABI const char * getLinkageName() const
Return the DIE linkage name resolving DW_AT_specification or DW_AT_abstract_origin references if nece...
LLVM_ABI Expected< DWARFLocationExpressionsVector > getLocations(dwarf::Attribute Attr) const
LLVM_ABI std::optional< uint64_t > getRangesBaseAttribute() const
Extract the range base attribute from this DIE as absolute section offset.
bool isNULL() const
Returns true for a valid DIE that terminates a sibling chain.
Definition DWARFDie.h:86
LLVM_ABI std::optional< uint64_t > getLanguage() const
bool isValid() const
Definition DWARFDie.h:52
LLVM_ABI iterator_range< attribute_iterator > attributes() const
Get an iterator range to all attributes in the current DIE only.
std::reverse_iterator< iterator > rend() const
Definition DWARFDie.h:486
Tagged union holding either a T or a Error.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
reverse_iterator< llvm::DWARFDie::iterator > & operator++()
Definition DWARFDie.h:435
const llvm::DWARFDie & operator*() const
Definition DWARFDie.h:455
bool equals(const reverse_iterator< llvm::DWARFDie::iterator > &RHS) const
Definition DWARFDie.h:463
llvm::DWARFDie::iterator base() const
Definition DWARFDie.h:431
reverse_iterator< llvm::DWARFDie::iterator > & operator--()
Definition DWARFDie.h:445
reverse_iterator(llvm::DWARFDie::iterator It)
Definition DWARFDie.h:425
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
bool operator!=(uint64_t V1, const APInt &V2)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
LLVM_ABI void dumpTypeQualifiedName(const DWARFDie &DIE, raw_ostream &OS)
DINameKind
A DINameKind is passed to name search methods to specify a preference regarding the type of name reso...
LLVM_ABI void dumpTypeUnqualifiedName(const DWARFDie &DIE, raw_ostream &OS, std::string *OriginalFullName=nullptr)
Implement std::hash so that hash_code can be used in STL containers.
Container for dump options that control which debug information will be dumped.
Encapsulates a DWARF attribute value and all of the data required to describe the attribute value.