LLVM 22.0.0git
DWARFUnit.h
Go to the documentation of this file.
1//===- DWARFUnit.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_DWARFUNIT_H
10#define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
11
12#include "llvm/ADT/DenseSet.h"
13#include "llvm/ADT/STLExtras.h"
15#include "llvm/ADT/StringRef.h"
26#include <cassert>
27#include <cstddef>
28#include <cstdint>
29#include <map>
30#include <memory>
31#include <set>
32#include <utility>
33#include <vector>
34
35namespace llvm {
36
37class DWARFAbbreviationDeclarationSet;
38class DWARFContext;
39class DWARFDebugAbbrev;
40class DWARFUnit;
41class DWARFDebugRangeList;
42class DWARFLocationTable;
43class DWARFObject;
44class raw_ostream;
45struct DIDumpOptions;
46struct DWARFSection;
47namespace dwarf_linker {
48namespace parallel {
49class CompileUnit;
50}
51} // namespace dwarf_linker
52
53/// Base class describing the header of any kind of "unit." Some information
54/// is specific to certain unit types. We separate this class out so we can
55/// parse the header before deciding what specific kind of unit to construct.
57 // Offset within section.
58 uint64_t Offset = 0;
59 // Version, address size, and DWARF format.
60 dwarf::FormParams FormParams;
61 uint64_t Length = 0;
62 uint64_t AbbrOffset = 0;
63
64 // For DWO units only.
65 const DWARFUnitIndex::Entry *IndexEntry = nullptr;
66
67 // For type units only.
68 uint64_t TypeHash = 0;
69 uint64_t TypeOffset = 0;
70
71 // For v5 split or skeleton compile units only.
72 std::optional<uint64_t> DWOId;
73
74 // Unit type as parsed, or derived from the section kind.
75 uint8_t UnitType = 0;
76
77 // Size as parsed. uint8_t for compactness.
78 uint8_t Size = 0;
79
80public:
81 /// Parse a unit header from \p debug_info starting at \p offset_ptr.
82 /// Note that \p SectionKind is used as a hint to guess the unit type
83 /// for DWARF formats prior to DWARFv5. In DWARFv5 the unit type is
84 /// explicitly defined in the header and the hint is ignored.
86 const DWARFDataExtractor &debug_info,
88 // For units in DWARF Package File, remember the index entry and update
89 // the abbreviation offset read by extract().
91 uint64_t getOffset() const { return Offset; }
92 const dwarf::FormParams &getFormParams() const { return FormParams; }
93 uint16_t getVersion() const { return FormParams.Version; }
94 dwarf::DwarfFormat getFormat() const { return FormParams.Format; }
95 uint8_t getAddressByteSize() const { return FormParams.AddrSize; }
96 uint8_t getRefAddrByteSize() const { return FormParams.getRefAddrByteSize(); }
98 return FormParams.getDwarfOffsetByteSize();
99 }
100 uint64_t getLength() const { return Length; }
101 uint64_t getAbbrOffset() const { return AbbrOffset; }
102 std::optional<uint64_t> getDWOId() const { return DWOId; }
104 assert((!DWOId || *DWOId == Id) && "setting DWOId to a different value");
105 DWOId = Id;
106 }
107 const DWARFUnitIndex::Entry *getIndexEntry() const { return IndexEntry; }
108 uint64_t getTypeHash() const { return TypeHash; }
109 uint64_t getTypeOffset() const { return TypeOffset; }
110 uint8_t getUnitType() const { return UnitType; }
111 bool isTypeUnit() const {
112 return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type;
113 }
114 uint8_t getSize() const { return Size; }
116 return dwarf::getUnitLengthFieldByteSize(FormParams.Format);
117 }
119 return Offset + Length + getUnitLengthFieldByteSize();
120 }
121};
122
123LLVM_ABI const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,
124 DWARFSectionKind Kind);
125
126bool isCompileUnit(const std::unique_ptr<DWARFUnit> &U);
127
128/// Describe a collection of units. Intended to hold all units either from
129/// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo.
130class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> {
131 std::function<std::unique_ptr<DWARFUnit>(uint64_t, DWARFSectionKind,
132 const DWARFSection *,
133 const DWARFUnitIndex::Entry *)>
134 Parser;
135 int NumInfoUnits = -1;
136
137public:
141
143 decltype(make_filter_range(std::declval<iterator_range>(), isCompileUnit));
144
147
148 /// Read units from a .debug_info or .debug_types section. Calls made
149 /// before finishedInfoUnits() are assumed to be for .debug_info sections,
150 /// calls after finishedInfoUnits() are for .debug_types sections. Caller
151 /// must not mix calls to addUnitsForSection and addUnitsForDWOSection.
154 /// Read units from a .debug_info.dwo or .debug_types.dwo section. Calls
155 /// made before finishedInfoUnits() are assumed to be for .debug_info.dwo
156 /// sections, calls after finishedInfoUnits() are for .debug_types.dwo
157 /// sections. Caller must not mix calls to addUnitsForSection and
158 /// addUnitsForDWOSection.
160 const DWARFSection &DWOSection,
162 bool Lazy = false);
163
164 /// Add an existing DWARFUnit to this UnitVector. This is used by the DWARF
165 /// verifier to process unit separately.
166 LLVM_ABI DWARFUnit *addUnit(std::unique_ptr<DWARFUnit> Unit);
167
168 /// Returns number of all units held by this instance.
169 unsigned getNumUnits() const { return size(); }
170 /// Returns number of units from all .debug_info[.dwo] sections.
171 unsigned getNumInfoUnits() const {
172 return NumInfoUnits == -1 ? size() : NumInfoUnits;
173 }
174 /// Returns number of units from all .debug_types[.dwo] sections.
175 unsigned getNumTypesUnits() const { return size() - NumInfoUnits; }
176 /// Indicate that parsing .debug_info[.dwo] is done, and remaining units
177 /// will be from .debug_types[.dwo].
178 void finishedInfoUnits() { NumInfoUnits = size(); }
179
180private:
181 void addUnitsImpl(DWARFContext &Context, const DWARFObject &Obj,
182 const DWARFSection &Section, const DWARFDebugAbbrev *DA,
183 const DWARFSection *RS, const DWARFSection *LocSection,
184 StringRef SS, const DWARFSection &SOS,
185 const DWARFSection *AOS, const DWARFSection &LS, bool LE,
186 bool IsDWO, bool Lazy, DWARFSectionKind SectionKind);
187};
188
189/// Represents base address of the CU.
190/// Represents a unit's contribution to the string offsets table.
193 /// The contribution size not including the header.
195 /// Format and version.
197
200 : Base(Base), Size(Size), FormParams({Version, 0, Format}) {}
202
207 }
208 /// Determine whether a contribution to the string offsets table is
209 /// consistent with the relevant section size and that its length is
210 /// a multiple of the size of one of its entries.
213};
214
217 /// Section containing this DWARFUnit.
218 const DWARFSection &InfoSection;
219
220 DWARFUnitHeader Header;
221 const DWARFDebugAbbrev *Abbrev;
222 const DWARFSection *RangeSection;
223 uint64_t RangeSectionBase;
224 uint64_t LocSectionBase;
225
226 /// Location table of this unit.
227 std::unique_ptr<DWARFLocationTable> LocTable;
228
229 const DWARFSection &LineSection;
230 StringRef StringSection;
231 const DWARFSection &StringOffsetSection;
232 const DWARFSection *AddrOffsetSection;
233 DWARFUnit *SU;
234 std::optional<uint64_t> AddrOffsetSectionBase;
235 bool IsLittleEndian;
236 bool IsDWO;
237 const DWARFUnitVector &UnitVector;
238
239 /// Start, length, and DWARF format of the unit's contribution to the string
240 /// offsets table (DWARF v5).
241 std::optional<StrOffsetsContributionDescriptor>
242 StringOffsetsTableContribution;
243
244 mutable const DWARFAbbreviationDeclarationSet *Abbrevs;
245 std::optional<object::SectionedAddress> BaseAddr;
246 /// The compile unit debug information entry items.
247 std::vector<DWARFDebugInfoEntry> DieArray;
248
249 /// Map from range's start address to end address and corresponding DIE.
250 /// IntervalMap does not support range removal, as a result, we use the
251 /// std::map::upper_bound for address range lookup.
252 std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
253
254 /// Map from the location (interpreted DW_AT_location) of a DW_TAG_variable,
255 /// to the end address and the corresponding DIE.
256 std::map<uint64_t, std::pair<uint64_t, DWARFDie>> VariableDieMap;
257 DenseSet<uint64_t> RootsParsedForVariables;
258
259 using die_iterator_range =
261
262 std::shared_ptr<DWARFUnit> DWO;
263
264protected:
266
267 /// Return the index of a \p Die entry inside the unit's DIE vector.
268 ///
269 /// It is illegal to call this method with a DIE that hasn't be
270 /// created by this unit. In other word, it's illegal to call this
271 /// method on a DIE that isn't accessible by following
272 /// children/sibling links starting from this unit's getUnitDIE().
274 auto First = DieArray.data();
275 assert(Die >= First && Die < First + DieArray.size());
276 return Die - First;
277 }
278
279 /// Return DWARFDebugInfoEntry for the specified index \p Index.
281 assert(Index < DieArray.size());
282 return &DieArray[Index];
283 }
284
285 const DWARFDebugInfoEntry *
286 getParentEntry(const DWARFDebugInfoEntry *Die) const;
287 const DWARFDebugInfoEntry *
288 getSiblingEntry(const DWARFDebugInfoEntry *Die) const;
289 const DWARFDebugInfoEntry *
290 getPreviousSiblingEntry(const DWARFDebugInfoEntry *Die) const;
291 const DWARFDebugInfoEntry *
292 getFirstChildEntry(const DWARFDebugInfoEntry *Die) const;
293 const DWARFDebugInfoEntry *
294 getLastChildEntry(const DWARFDebugInfoEntry *Die) const;
295
296 const DWARFUnitHeader &getHeader() const { return Header; }
297
298 /// Find the unit's contribution to the string offsets table and determine its
299 /// length and form. The given offset is expected to be derived from the unit
300 /// DIE's DW_AT_str_offsets_base attribute.
302 determineStringOffsetsTableContribution(DWARFDataExtractor &DA);
303
304 /// Find the unit's contribution to the string offsets table and determine its
305 /// length and form. The given offset is expected to be 0 in a dwo file or,
306 /// in a dwp file, the start of the unit's contribution to the string offsets
307 /// table section (as determined by the index table).
309 determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA);
310
311public:
312 DWARFUnit(DWARFContext &Context, const DWARFSection &Section,
313 const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA,
314 const DWARFSection *RS, const DWARFSection *LocSection,
315 StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS,
316 const DWARFSection &LS, bool LE, bool IsDWO,
317 const DWARFUnitVector &UnitVector);
318
319 virtual ~DWARFUnit();
320
321 bool isLittleEndian() const { return IsLittleEndian; }
322 bool isDWOUnit() const { return IsDWO; }
323 DWARFContext& getContext() const { return Context; }
324 const DWARFSection &getInfoSection() const { return InfoSection; }
325 uint64_t getOffset() const { return Header.getOffset(); }
327 return Header.getFormParams();
328 }
329 uint16_t getVersion() const { return Header.getVersion(); }
330 uint8_t getAddressByteSize() const { return Header.getAddressByteSize(); }
331 uint8_t getRefAddrByteSize() const { return Header.getRefAddrByteSize(); }
333 return Header.getDwarfOffsetByteSize();
334 }
335 /// Size in bytes of the parsed unit header.
336 uint32_t getHeaderSize() const { return Header.getSize(); }
337 uint64_t getLength() const { return Header.getLength(); }
338 dwarf::DwarfFormat getFormat() const { return Header.getFormat(); }
339 uint8_t getUnitType() const { return Header.getUnitType(); }
340 bool isTypeUnit() const { return Header.isTypeUnit(); }
341 uint64_t getAbbrOffset() const { return Header.getAbbrOffset(); }
342 uint64_t getNextUnitOffset() const { return Header.getNextUnitOffset(); }
343 const DWARFSection &getLineSection() const { return LineSection; }
344 StringRef getStringSection() const { return StringSection; }
346 return StringOffsetSection;
347 }
348
349 void setSkeletonUnit(DWARFUnit *SU) { this->SU = SU; }
350 // Returns itself if not using Split DWARF, or if the unit is a skeleton unit
351 // - otherwise returns the split full unit's corresponding skeleton, if
352 // available.
353 DWARFUnit *getLinkedUnit() { return IsDWO ? SU : this; }
354
356 AddrOffsetSection = AOS;
357 AddrOffsetSectionBase = Base;
358 }
359
360 std::optional<uint64_t> getAddrOffsetSectionBase() const {
361 return AddrOffsetSectionBase;
362 }
363
364 /// Returns offset to the indexed address value inside .debug_addr section.
365 std::optional<uint64_t> getIndexedAddressOffset(uint64_t Index) {
366 if (std::optional<uint64_t> AddrOffsetSectionBase =
367 getAddrOffsetSectionBase())
368 return *AddrOffsetSectionBase + Index * getAddressByteSize();
369
370 return std::nullopt;
371 }
372
373 /// Recursively update address to Die map.
374 void updateAddressDieMap(DWARFDie Die);
375
376 /// Recursively update address to variable Die map.
377 void updateVariableDieMap(DWARFDie Die);
378
379 void setRangesSection(const DWARFSection *RS, uint64_t Base) {
380 RangeSection = RS;
381 RangeSectionBase = Base;
382 }
383
385 return LocSectionBase;
386 }
387
388 std::optional<object::SectionedAddress>
389 getAddrOffsetSectionItem(uint32_t Index) const;
390 Expected<uint64_t> getStringOffsetSectionItem(uint32_t Index) const;
391
392 DWARFDataExtractor getDebugInfoExtractor() const;
393
395 return DataExtractor(StringSection, false, 0);
396 }
397
398 const DWARFLocationTable &getLocationTable() { return *LocTable; }
399
400 /// Extract the range list referenced by this compile unit from the
401 /// .debug_ranges section. If the extraction is unsuccessful, an error
402 /// is returned. Successful extraction requires that the compile unit
403 /// has already been extracted.
404 Error extractRangeList(uint64_t RangeListOffset,
405 DWARFDebugRangeList &RangeList) const;
406 void clear();
407
408 const std::optional<StrOffsetsContributionDescriptor> &
410 extractDIEsIfNeeded(true /*CUDIeOnly*/);
411 return StringOffsetsTableContribution;
412 }
413
415 assert(StringOffsetsTableContribution);
416 return StringOffsetsTableContribution->getDwarfOffsetByteSize();
417 }
418
420 assert(StringOffsetsTableContribution);
421 return StringOffsetsTableContribution->Base;
422 }
423
424 uint64_t getAbbreviationsOffset() const { return Header.getAbbrOffset(); }
425
426 const DWARFAbbreviationDeclarationSet *getAbbreviations() const;
427
428 static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag) {
429 switch (UnitType) {
430 case dwarf::DW_UT_compile:
431 return Tag == dwarf::DW_TAG_compile_unit;
432 case dwarf::DW_UT_type:
433 return Tag == dwarf::DW_TAG_type_unit;
434 case dwarf::DW_UT_partial:
435 return Tag == dwarf::DW_TAG_partial_unit;
436 case dwarf::DW_UT_skeleton:
437 return Tag == dwarf::DW_TAG_skeleton_unit;
438 case dwarf::DW_UT_split_compile:
439 case dwarf::DW_UT_split_type:
440 return dwarf::isUnitType(Tag);
441 }
442 return false;
443 }
444
445 std::optional<object::SectionedAddress> getBaseAddress();
446
447 DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) {
448 extractDIEsIfNeeded(ExtractUnitDIEOnly);
449 if (DieArray.empty())
450 return DWARFDie();
451 return DWARFDie(this, &DieArray[0]);
452 }
453
454 DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly = true,
455 StringRef DWOAlternativeLocation = {}) {
456 parseDWO(DWOAlternativeLocation);
457 return DWO ? DWO->getUnitDIE(ExtractUnitDIEOnly)
458 : getUnitDIE(ExtractUnitDIEOnly);
459 }
460
461 const char *getCompilationDir();
462 std::optional<uint64_t> getDWOId() {
463 extractDIEsIfNeeded(/*CUDieOnly*/ true);
464 return getHeader().getDWOId();
465 }
466 void setDWOId(uint64_t NewID) { Header.setDWOId(NewID); }
467
468 /// Return a vector of address ranges resulting from a (possibly encoded)
469 /// range list starting at a given offset in the appropriate ranges section.
471
472 /// Return a vector of address ranges retrieved from an encoded range
473 /// list whose offset is found via a table lookup given an index (DWARF v5
474 /// and later).
476
477 /// Return a rangelist's offset based on an index. The index designates
478 /// an entry in the rangelist table's offset array and is supplied by
479 /// DW_FORM_rnglistx.
480 std::optional<uint64_t> getRnglistOffset(uint32_t Index);
481
482 std::optional<uint64_t> getLoclistOffset(uint32_t Index);
483
484 Expected<DWARFAddressRangesVector> collectAddressRanges();
485
487 findLoclistFromOffset(uint64_t Offset);
488
489 /// Returns subprogram DIE with address range encompassing the provided
490 /// address. The pointer is alive as long as parsed compile unit DIEs are not
491 /// cleared.
492 DWARFDie getSubroutineForAddress(uint64_t Address);
493
494 /// Returns variable DIE for the address provided. The pointer is alive as
495 /// long as parsed compile unit DIEs are not cleared.
496 DWARFDie getVariableForAddress(uint64_t Address);
497
498 /// getInlinedChainForAddress - fetches inlined chain for a given address.
499 /// Returns empty chain if there is no subprogram containing address. The
500 /// chain is valid as long as parsed compile unit DIEs are not cleared.
501 void getInlinedChainForAddress(uint64_t Address,
502 SmallVectorImpl<DWARFDie> &InlinedChain);
503
504 /// Return the DWARFUnitVector containing this unit.
505 const DWARFUnitVector &getUnitVector() const { return UnitVector; }
506
507 /// Returns the number of DIEs in the unit. Parses the unit
508 /// if necessary.
509 unsigned getNumDIEs() {
510 extractDIEsIfNeeded(false);
511 return DieArray.size();
512 }
513
514 /// Return the index of a DIE inside the unit's DIE vector.
515 ///
516 /// It is illegal to call this method with a DIE that hasn't be
517 /// created by this unit. In other word, it's illegal to call this
518 /// method on a DIE that isn't accessible by following
519 /// children/sibling links starting from this unit's getUnitDIE().
521 return getDIEIndex(D.getDebugInfoEntry());
522 }
523
524 /// Return the DIE object at the given index \p Index.
526 return DWARFDie(this, getDebugInfoEntry(Index));
527 }
528
530 DWARFDie getSibling(const DWARFDebugInfoEntry *Die);
531 DWARFDie getPreviousSibling(const DWARFDebugInfoEntry *Die);
532 DWARFDie getFirstChild(const DWARFDebugInfoEntry *Die);
533 DWARFDie getLastChild(const DWARFDebugInfoEntry *Die);
534
535 /// Return the DIE object for a given offset \p Offset inside the
536 /// unit's DIE vector.
538 if (std::optional<uint32_t> DieIdx = getDIEIndexForOffset(Offset))
539 return DWARFDie(this, &DieArray[*DieIdx]);
540
541 return DWARFDie();
542 }
543
544 /// Return the DIE index for a given offset \p Offset inside the
545 /// unit's DIE vector.
546 std::optional<uint32_t> getDIEIndexForOffset(uint64_t Offset) {
547 extractDIEsIfNeeded(false);
548 auto It =
549 llvm::partition_point(DieArray, [=](const DWARFDebugInfoEntry &DIE) {
550 return DIE.getOffset() < Offset;
551 });
552 if (It != DieArray.end() && It->getOffset() == Offset)
553 return It - DieArray.begin();
554 return std::nullopt;
555 }
556
558 if (auto IndexEntry = Header.getIndexEntry())
559 if (const auto *Contrib = IndexEntry->getContribution(DW_SECT_LINE))
560 return Contrib->getOffset32();
561 return 0;
562 }
563
565 extractDIEsIfNeeded(false);
566 return die_iterator_range(DieArray.begin(), DieArray.end());
567 }
568
569 virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0;
570
571 Error tryExtractDIEsIfNeeded(bool CUDieOnly);
572
573private:
574 /// Size in bytes of the .debug_info data associated with this compile unit.
575 size_t getDebugInfoSize() const {
576 return Header.getLength() + Header.getUnitLengthFieldByteSize() -
577 getHeaderSize();
578 }
579
580 /// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it
581 /// hasn't already been done
582 void extractDIEsIfNeeded(bool CUDieOnly);
583
584 /// extractDIEsToVector - Appends all parsed DIEs to a vector.
585 void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs,
586 std::vector<DWARFDebugInfoEntry> &DIEs) const;
587
588 /// clearDIEs - Clear parsed DIEs to keep memory usage low.
589 void clearDIEs(bool KeepCUDie);
590
591 /// parseDWO - Parses .dwo file for current compile unit. Returns true if
592 /// it was actually constructed.
593 /// The \p AlternativeLocation specifies an alternative location to get
594 /// the DWARF context for the DWO object; this is the case when it has
595 /// been moved from its original location.
596 bool parseDWO(StringRef AlternativeLocation = {});
597};
598
599inline bool isCompileUnit(const std::unique_ptr<DWARFUnit> &U) {
600 return !U->isTypeUnit();
601}
602
603} // end namespace llvm
604
605#endif // LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static const Function * getParent(const Value *V)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition: Compiler.h:213
This file defines the DenseSet and SmallDenseSet classes.
This file contains constants used for implementing Dwarf debug support.
uint32_t Index
uint64_t Offset
Definition: ELF_riscv.cpp:478
loop extract
This file contains some templates that are useful if you are working with the STL at all.
raw_pwrite_stream & OS
This file defines the SmallVector class.
A structured debug information entry.
Definition: DIE.h:828
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
Definition: DIE.h:866
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Definition: DWARFContext.h:49
A DWARFDataExtractor (typically for an in-memory copy of an object-file section) plus a relocation ma...
DWARFDebugInfoEntry - A DIE with only the minimum required data.
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition: DWARFDie.h:43
An abstract base class for various kinds of location tables (.debug_loc, .debug_loclists,...
Definition: DWARFDebugLoc.h:50
Base class describing the header of any kind of "unit." Some information is specific to certain unit ...
Definition: DWARFUnit.h:56
std::optional< uint64_t > getDWOId() const
Definition: DWARFUnit.h:102
uint64_t getOffset() const
Definition: DWARFUnit.h:91
uint8_t getRefAddrByteSize() const
Definition: DWARFUnit.h:96
uint8_t getUnitType() const
Definition: DWARFUnit.h:110
uint8_t getDwarfOffsetByteSize() const
Definition: DWARFUnit.h:97
uint64_t getAbbrOffset() const
Definition: DWARFUnit.h:101
uint8_t getSize() const
Definition: DWARFUnit.h:114
LLVM_ABI Error applyIndexEntry(const DWARFUnitIndex::Entry *Entry)
Definition: DWARFUnit.cpp:341
dwarf::DwarfFormat getFormat() const
Definition: DWARFUnit.h:94
uint64_t getTypeHash() const
Definition: DWARFUnit.h:108
uint64_t getLength() const
Definition: DWARFUnit.h:100
uint64_t getTypeOffset() const
Definition: DWARFUnit.h:109
uint16_t getVersion() const
Definition: DWARFUnit.h:93
uint8_t getAddressByteSize() const
Definition: DWARFUnit.h:95
uint64_t getNextUnitOffset() const
Definition: DWARFUnit.h:118
uint8_t getUnitLengthFieldByteSize() const
Definition: DWARFUnit.h:115
const DWARFUnitIndex::Entry * getIndexEntry() const
Definition: DWARFUnit.h:107
bool isTypeUnit() const
Definition: DWARFUnit.h:111
void setDWOId(uint64_t Id)
Definition: DWARFUnit.h:103
const dwarf::FormParams & getFormParams() const
Definition: DWARFUnit.h:92
Describe a collection of units.
Definition: DWARFUnit.h:130
LLVM_ABI DWARFUnit * addUnit(std::unique_ptr< DWARFUnit > Unit)
Add an existing DWARFUnit to this UnitVector.
Definition: DWARFUnit.cpp:143
unsigned getNumInfoUnits() const
Returns number of units from all .debug_info[.dwo] sections.
Definition: DWARFUnit.h:171
typename UnitVector::iterator iterator
Definition: DWARFUnit.h:139
void finishedInfoUnits()
Indicate that parsing .debug_info[.dwo] is done, and remaining units will be from ....
Definition: DWARFUnit.h:178
unsigned getNumTypesUnits() const
Returns number of units from all .debug_types[.dwo] sections.
Definition: DWARFUnit.h:175
unsigned getNumUnits() const
Returns number of all units held by this instance.
Definition: DWARFUnit.h:169
LLVM_ABI void addUnitsForSection(DWARFContext &C, const DWARFSection &Section, DWARFSectionKind SectionKind)
Read units from a .debug_info or .debug_types section.
Definition: DWARFUnit.cpp:42
LLVM_ABI DWARFUnit * getUnitForOffset(uint64_t Offset) const
Definition: DWARFUnit.cpp:152
decltype(make_filter_range(std::declval< iterator_range >(), isCompileUnit)) compile_unit_range
Definition: DWARFUnit.h:143
LLVM_ABI void addUnitsForDWOSection(DWARFContext &C, const DWARFSection &DWOSection, DWARFSectionKind SectionKind, bool Lazy=false)
Read units from a .debug_info.dwo or .debug_types.dwo section.
Definition: DWARFUnit.cpp:53
LLVM_ABI DWARFUnit * getUnitForIndexEntry(const DWARFUnitIndex::Entry &E)
Definition: DWARFUnit.cpp:165
const DWARFDebugInfoEntry * getDebugInfoEntry(unsigned Index) const
Return DWARFDebugInfoEntry for the specified index Index.
Definition: DWARFUnit.h:280
std::optional< uint64_t > getDWOId()
Definition: DWARFUnit.h:462
uint32_t getHeaderSize() const
Size in bytes of the parsed unit header.
Definition: DWARFUnit.h:336
const DWARFLocationTable & getLocationTable()
Definition: DWARFUnit.h:398
unsigned getNumDIEs()
Returns the number of DIEs in the unit.
Definition: DWARFUnit.h:509
const dwarf::FormParams & getFormParams() const
Definition: DWARFUnit.h:326
DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly=true, StringRef DWOAlternativeLocation={})
Definition: DWARFUnit.h:454
uint8_t getUnitType() const
Definition: DWARFUnit.h:339
uint64_t getLength() const
Definition: DWARFUnit.h:337
uint8_t getRefAddrByteSize() const
Definition: DWARFUnit.h:331
DataExtractor getStringExtractor() const
Definition: DWARFUnit.h:394
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
Definition: DWARFUnit.h:447
virtual ~DWARFUnit()
DWARFContext & getContext() const
Definition: DWARFUnit.h:323
uint8_t getAddressByteSize() const
Definition: DWARFUnit.h:330
void setSkeletonUnit(DWARFUnit *SU)
Definition: DWARFUnit.h:349
std::optional< uint64_t > getAddrOffsetSectionBase() const
Definition: DWARFUnit.h:360
const DWARFSection & getInfoSection() const
Definition: DWARFUnit.h:324
void setAddrOffsetSection(const DWARFSection *AOS, uint64_t Base)
Definition: DWARFUnit.h:355
void setDWOId(uint64_t NewID)
Definition: DWARFUnit.h:466
uint64_t getLocSectionBase() const
Definition: DWARFUnit.h:384
void setRangesSection(const DWARFSection *RS, uint64_t Base)
Definition: DWARFUnit.h:379
uint8_t getDwarfStringOffsetsByteSize() const
Definition: DWARFUnit.h:414
const DWARFUnitHeader & getHeader() const
Definition: DWARFUnit.h:296
DWARFDie getDIEForOffset(uint64_t Offset)
Return the DIE object for a given offset Offset inside the unit's DIE vector.
Definition: DWARFUnit.h:537
uint32_t getDIEIndex(const DWARFDie &D) const
Return the index of a DIE inside the unit's DIE vector.
Definition: DWARFUnit.h:520
uint32_t getLineTableOffset() const
Definition: DWARFUnit.h:557
uint64_t getStringOffsetsBase() const
Definition: DWARFUnit.h:419
dwarf::DwarfFormat getFormat() const
Definition: DWARFUnit.h:338
std::optional< uint32_t > getDIEIndexForOffset(uint64_t Offset)
Return the DIE index for a given offset Offset inside the unit's DIE vector.
Definition: DWARFUnit.h:546
uint64_t getAbbreviationsOffset() const
Definition: DWARFUnit.h:424
uint16_t getVersion() const
Definition: DWARFUnit.h:329
std::optional< uint64_t > getIndexedAddressOffset(uint64_t Index)
Returns offset to the indexed address value inside .debug_addr section.
Definition: DWARFUnit.h:365
uint64_t getAbbrOffset() const
Definition: DWARFUnit.h:341
uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) const
Return the index of a Die entry inside the unit's DIE vector.
Definition: DWARFUnit.h:273
die_iterator_range dies()
Definition: DWARFUnit.h:564
bool isLittleEndian() const
Definition: DWARFUnit.h:321
virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts)=0
const DWARFUnitVector & getUnitVector() const
Return the DWARFUnitVector containing this unit.
Definition: DWARFUnit.h:505
const DWARFSection & getStringOffsetSection() const
Definition: DWARFUnit.h:345
const DWARFSection & getLineSection() const
Definition: DWARFUnit.h:343
StringRef getStringSection() const
Definition: DWARFUnit.h:344
uint8_t getDwarfOffsetByteSize() const
Definition: DWARFUnit.h:332
static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag)
Definition: DWARFUnit.h:428
uint64_t getNextUnitOffset() const
Definition: DWARFUnit.h:342
const std::optional< StrOffsetsContributionDescriptor > & getStringOffsetsTableContribution()
Definition: DWARFUnit.h:409
DWARFUnit * getLinkedUnit()
Definition: DWARFUnit.h:353
bool isTypeUnit() const
Definition: DWARFUnit.h:340
DWARFDie getDIEAtIndex(unsigned Index)
Return the DIE object at the given index Index.
Definition: DWARFUnit.h:525
uint64_t getOffset() const
Definition: DWARFUnit.h:325
bool isDWOUnit() const
Definition: DWARFUnit.h:322
Implements a dense probed hash-table based set.
Definition: DenseSet.h:263
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
Tagged union holding either a T or a Error.
Definition: Error.h:485
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
Stores all information related to a compile unit, be it in its original instance of the object file o...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
Definition: Dwarf.h:1119
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition: Dwarf.h:92
@ DWARF32
Definition: Dwarf.h:92
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:477
@ Length
Definition: DWP.cpp:477
LLVM_ABI const DWARFUnitIndex & getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind)
Definition: DWARFUnit.cpp:892
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
Definition: STLExtras.h:2090
DWARFSectionKind
The enum of section identifiers to be used in internal interfaces.
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
Definition: STLExtras.h:581
bool isCompileUnit(const std::unique_ptr< DWARFUnit > &U)
Definition: DWARFUnit.h:599
Container for dump options that control which debug information will be dumped.
Definition: DIContext.h:196
Represents base address of the CU.
Definition: DWARFUnit.h:191
LLVM_ABI Expected< StrOffsetsContributionDescriptor > validateContributionSize(DWARFDataExtractor &DA)
Determine whether a contribution to the string offsets table is consistent with the relevant section ...
Definition: DWARFUnit.cpp:1079
dwarf::DwarfFormat getFormat() const
Definition: DWARFUnit.h:204
uint64_t Size
The contribution size not including the header.
Definition: DWARFUnit.h:194
dwarf::FormParams FormParams
Format and version.
Definition: DWARFUnit.h:196
StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size, uint8_t Version, dwarf::DwarfFormat Format)
Definition: DWARFUnit.h:198
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition: Dwarf.h:1093
DwarfFormat Format
Definition: Dwarf.h:1096
uint8_t getDwarfOffsetByteSize() const
The size of a reference is determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:1111
uint8_t getRefAddrByteSize() const
The definition of the size of form DW_FORM_ref_addr depends on the version.
Definition: Dwarf.h:1104