LLVM  14.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/Optional.h"
13 #include "llvm/ADT/STLExtras.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/ADT/StringRef.h"
28 #include <algorithm>
29 #include <cassert>
30 #include <cstddef>
31 #include <cstdint>
32 #include <map>
33 #include <memory>
34 #include <utility>
35 #include <vector>
36 
37 namespace llvm {
38 
39 class DWARFAbbreviationDeclarationSet;
40 class DWARFContext;
41 class DWARFDebugAbbrev;
42 class DWARFUnit;
43 
44 /// Base class describing the header of any kind of "unit." Some information
45 /// is specific to certain unit types. We separate this class out so we can
46 /// parse the header before deciding what specific kind of unit to construct.
48  // Offset within section.
49  uint64_t Offset = 0;
50  // Version, address size, and DWARF format.
51  dwarf::FormParams FormParams;
52  uint64_t Length = 0;
53  uint64_t AbbrOffset = 0;
54 
55  // For DWO units only.
56  const DWARFUnitIndex::Entry *IndexEntry = nullptr;
57 
58  // For type units only.
59  uint64_t TypeHash = 0;
60  uint64_t TypeOffset = 0;
61 
62  // For v5 split or skeleton compile units only.
63  Optional<uint64_t> DWOId;
64 
65  // Unit type as parsed, or derived from the section kind.
66  uint8_t UnitType = 0;
67 
68  // Size as parsed. uint8_t for compactness.
69  uint8_t Size = 0;
70 
71 public:
72  /// Parse a unit header from \p debug_info starting at \p offset_ptr.
73  /// Note that \p SectionKind is used as a hint to guess the unit type
74  /// for DWARF formats prior to DWARFv5. In DWARFv5 the unit type is
75  /// explicitly defined in the header and the hint is ignored.
76  bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info,
78  // For units in DWARF Package File, remember the index entry and update
79  // the abbreviation offset read by extract().
80  bool applyIndexEntry(const DWARFUnitIndex::Entry *Entry);
81  uint64_t getOffset() const { return Offset; }
82  const dwarf::FormParams &getFormParams() const { return FormParams; }
83  uint16_t getVersion() const { return FormParams.Version; }
84  dwarf::DwarfFormat getFormat() const { return FormParams.Format; }
85  uint8_t getAddressByteSize() const { return FormParams.AddrSize; }
86  uint8_t getRefAddrByteSize() const { return FormParams.getRefAddrByteSize(); }
87  uint8_t getDwarfOffsetByteSize() const {
88  return FormParams.getDwarfOffsetByteSize();
89  }
90  uint64_t getLength() const { return Length; }
91  uint64_t getAbbrOffset() const { return AbbrOffset; }
92  Optional<uint64_t> getDWOId() const { return DWOId; }
94  assert((!DWOId || *DWOId == Id) && "setting DWOId to a different value");
95  DWOId = Id;
96  }
97  const DWARFUnitIndex::Entry *getIndexEntry() const { return IndexEntry; }
98  uint64_t getTypeHash() const { return TypeHash; }
99  uint64_t getTypeOffset() const { return TypeOffset; }
100  uint8_t getUnitType() const { return UnitType; }
101  bool isTypeUnit() const {
102  return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type;
103  }
104  uint8_t getSize() const { return Size; }
105  uint8_t getUnitLengthFieldByteSize() const {
106  return dwarf::getUnitLengthFieldByteSize(FormParams.Format);
107  }
109  return Offset + Length + getUnitLengthFieldByteSize();
110  }
111 };
112 
113 const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,
115 
116 bool isCompileUnit(const std::unique_ptr<DWARFUnit> &U);
117 
118 /// Describe a collection of units. Intended to hold all units either from
119 /// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo.
120 class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> {
121  std::function<std::unique_ptr<DWARFUnit>(uint64_t, DWARFSectionKind,
122  const DWARFSection *,
123  const DWARFUnitIndex::Entry *)>
124  Parser;
125  int NumInfoUnits = -1;
126 
127 public:
129  using iterator = typename UnitVector::iterator;
131 
132  using compile_unit_range =
133  decltype(make_filter_range(std::declval<iterator_range>(), isCompileUnit));
134 
137 
138  /// Read units from a .debug_info or .debug_types section. Calls made
139  /// before finishedInfoUnits() are assumed to be for .debug_info sections,
140  /// calls after finishedInfoUnits() are for .debug_types sections. Caller
141  /// must not mix calls to addUnitsForSection and addUnitsForDWOSection.
144  /// Read units from a .debug_info.dwo or .debug_types.dwo section. Calls
145  /// made before finishedInfoUnits() are assumed to be for .debug_info.dwo
146  /// sections, calls after finishedInfoUnits() are for .debug_types.dwo
147  /// sections. Caller must not mix calls to addUnitsForSection and
148  /// addUnitsForDWOSection.
149  void addUnitsForDWOSection(DWARFContext &C, const DWARFSection &DWOSection,
150  DWARFSectionKind SectionKind, bool Lazy = false);
151 
152  /// Add an existing DWARFUnit to this UnitVector. This is used by the DWARF
153  /// verifier to process unit separately.
154  DWARFUnit *addUnit(std::unique_ptr<DWARFUnit> Unit);
155 
156  /// Returns number of all units held by this instance.
157  unsigned getNumUnits() const { return size(); }
158  /// Returns number of units from all .debug_info[.dwo] sections.
159  unsigned getNumInfoUnits() const {
160  return NumInfoUnits == -1 ? size() : NumInfoUnits;
161  }
162  /// Returns number of units from all .debug_types[.dwo] sections.
163  unsigned getNumTypesUnits() const { return size() - NumInfoUnits; }
164  /// Indicate that parsing .debug_info[.dwo] is done, and remaining units
165  /// will be from .debug_types[.dwo].
166  void finishedInfoUnits() { NumInfoUnits = size(); }
167 
168 private:
169  void addUnitsImpl(DWARFContext &Context, const DWARFObject &Obj,
170  const DWARFSection &Section, const DWARFDebugAbbrev *DA,
171  const DWARFSection *RS, const DWARFSection *LocSection,
172  StringRef SS, const DWARFSection &SOS,
173  const DWARFSection *AOS, const DWARFSection &LS, bool LE,
174  bool IsDWO, bool Lazy, DWARFSectionKind SectionKind);
175 };
176 
177 /// Represents base address of the CU.
178 /// Represents a unit's contribution to the string offsets table.
181  /// The contribution size not including the header.
183  /// Format and version.
185 
187  uint8_t Version, dwarf::DwarfFormat Format)
188  : Base(Base), Size(Size), FormParams({Version, 0, Format}) {}
190 
191  uint8_t getVersion() const { return FormParams.Version; }
193  uint8_t getDwarfOffsetByteSize() const {
195  }
196  /// Determine whether a contribution to the string offsets table is
197  /// consistent with the relevant section size and that its length is
198  /// a multiple of the size of one of its entries.
201 };
202 
203 class DWARFUnit {
204  DWARFContext &Context;
205  /// Section containing this DWARFUnit.
206  const DWARFSection &InfoSection;
207 
208  DWARFUnitHeader Header;
209  const DWARFDebugAbbrev *Abbrev;
210  const DWARFSection *RangeSection;
211  uint64_t RangeSectionBase;
212  uint64_t LocSectionBase;
213 
214  /// Location table of this unit.
215  std::unique_ptr<DWARFLocationTable> LocTable;
216 
217  const DWARFSection &LineSection;
218  StringRef StringSection;
219  const DWARFSection &StringOffsetSection;
220  const DWARFSection *AddrOffsetSection;
221  DWARFUnit *SU;
222  Optional<uint64_t> AddrOffsetSectionBase;
223  bool isLittleEndian;
224  bool IsDWO;
225  const DWARFUnitVector &UnitVector;
226 
227  /// Start, length, and DWARF format of the unit's contribution to the string
228  /// offsets table (DWARF v5).
229  Optional<StrOffsetsContributionDescriptor> StringOffsetsTableContribution;
230 
231  mutable const DWARFAbbreviationDeclarationSet *Abbrevs;
233  /// The compile unit debug information entry items.
234  std::vector<DWARFDebugInfoEntry> DieArray;
235 
236  /// Map from range's start address to end address and corresponding DIE.
237  /// IntervalMap does not support range removal, as a result, we use the
238  /// std::map::upper_bound for address range lookup.
239  std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
240 
241  using die_iterator_range =
243 
244  std::shared_ptr<DWARFUnit> DWO;
245 
246  uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) {
247  auto First = DieArray.data();
248  assert(Die >= First && Die < First + DieArray.size());
249  return Die - First;
250  }
251 
252 protected:
253  const DWARFUnitHeader &getHeader() const { return Header; }
254 
255  /// Find the unit's contribution to the string offsets table and determine its
256  /// length and form. The given offset is expected to be derived from the unit
257  /// DIE's DW_AT_str_offsets_base attribute.
260 
261  /// Find the unit's contribution to the string offsets table and determine its
262  /// length and form. The given offset is expected to be 0 in a dwo file or,
263  /// in a dwp file, the start of the unit's contribution to the string offsets
264  /// table section (as determined by the index table).
267 
268 public:
269  DWARFUnit(DWARFContext &Context, const DWARFSection &Section,
270  const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA,
271  const DWARFSection *RS, const DWARFSection *LocSection,
272  StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS,
273  const DWARFSection &LS, bool LE, bool IsDWO,
274  const DWARFUnitVector &UnitVector);
275 
276  virtual ~DWARFUnit();
277 
278  bool isDWOUnit() const { return IsDWO; }
279  DWARFContext& getContext() const { return Context; }
280  const DWARFSection &getInfoSection() const { return InfoSection; }
281  uint64_t getOffset() const { return Header.getOffset(); }
283  return Header.getFormParams();
284  }
285  uint16_t getVersion() const { return Header.getVersion(); }
286  uint8_t getAddressByteSize() const { return Header.getAddressByteSize(); }
287  uint8_t getRefAddrByteSize() const { return Header.getRefAddrByteSize(); }
288  uint8_t getDwarfOffsetByteSize() const {
289  return Header.getDwarfOffsetByteSize();
290  }
291  /// Size in bytes of the parsed unit header.
292  uint32_t getHeaderSize() const { return Header.getSize(); }
293  uint64_t getLength() const { return Header.getLength(); }
294  dwarf::DwarfFormat getFormat() const { return Header.getFormat(); }
295  uint8_t getUnitType() const { return Header.getUnitType(); }
296  bool isTypeUnit() const { return Header.isTypeUnit(); }
297  uint64_t getAbbrOffset() const { return Header.getAbbrOffset(); }
298  uint64_t getNextUnitOffset() const { return Header.getNextUnitOffset(); }
299  const DWARFSection &getLineSection() const { return LineSection; }
300  StringRef getStringSection() const { return StringSection; }
302  return StringOffsetSection;
303  }
304 
305  void setSkeletonUnit(DWARFUnit *SU) { this->SU = SU; }
306  // Returns itself if not using Split DWARF, or if the unit is a skeleton unit
307  // - otherwise returns the split full unit's corresponding skeleton, if
308  // available.
309  DWARFUnit *getLinkedUnit() { return IsDWO ? SU : this; }
310 
312  AddrOffsetSection = AOS;
313  AddrOffsetSectionBase = Base;
314  }
315 
317  return AddrOffsetSectionBase;
318  }
319 
320  /// Recursively update address to Die map.
321  void updateAddressDieMap(DWARFDie Die);
322 
324  RangeSection = RS;
325  RangeSectionBase = Base;
326  }
327 
329  return LocSectionBase;
330  }
331 
335 
337 
339  return DataExtractor(StringSection, false, 0);
340  }
341 
342  const DWARFLocationTable &getLocationTable() { return *LocTable; }
343 
344  /// Extract the range list referenced by this compile unit from the
345  /// .debug_ranges section. If the extraction is unsuccessful, an error
346  /// is returned. Successful extraction requires that the compile unit
347  /// has already been extracted.
348  Error extractRangeList(uint64_t RangeListOffset,
349  DWARFDebugRangeList &RangeList) const;
350  void clear();
351 
354  return StringOffsetsTableContribution;
355  }
356 
358  assert(StringOffsetsTableContribution);
359  return StringOffsetsTableContribution->getDwarfOffsetByteSize();
360  }
361 
363  assert(StringOffsetsTableContribution);
364  return StringOffsetsTableContribution->Base;
365  }
366 
367  uint64_t getAbbreviationsOffset() const { return Header.getAbbrOffset(); }
368 
370 
371  static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag) {
372  switch (UnitType) {
373  case dwarf::DW_UT_compile:
374  return Tag == dwarf::DW_TAG_compile_unit;
375  case dwarf::DW_UT_type:
376  return Tag == dwarf::DW_TAG_type_unit;
377  case dwarf::DW_UT_partial:
378  return Tag == dwarf::DW_TAG_partial_unit;
379  case dwarf::DW_UT_skeleton:
380  return Tag == dwarf::DW_TAG_skeleton_unit;
381  case dwarf::DW_UT_split_compile:
382  case dwarf::DW_UT_split_type:
383  return dwarf::isUnitType(Tag);
384  }
385  return false;
386  }
387 
389 
390  DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) {
391  extractDIEsIfNeeded(ExtractUnitDIEOnly);
392  if (DieArray.empty())
393  return DWARFDie();
394  return DWARFDie(this, &DieArray[0]);
395  }
396 
397  DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly = true) {
398  parseDWO();
399  if (DWO)
400  return DWO->getUnitDIE(ExtractUnitDIEOnly);
401  return getUnitDIE(ExtractUnitDIEOnly);
402  }
403 
404  const char *getCompilationDir();
406  extractDIEsIfNeeded(/*CUDieOnly*/ true);
407  return getHeader().getDWOId();
408  }
409  void setDWOId(uint64_t NewID) { Header.setDWOId(NewID); }
410 
411  /// Return a vector of address ranges resulting from a (possibly encoded)
412  /// range list starting at a given offset in the appropriate ranges section.
414 
415  /// Return a vector of address ranges retrieved from an encoded range
416  /// list whose offset is found via a table lookup given an index (DWARF v5
417  /// and later).
419 
420  /// Return a rangelist's offset based on an index. The index designates
421  /// an entry in the rangelist table's offset array and is supplied by
422  /// DW_FORM_rnglistx.
424 
426 
428 
431 
432  /// Returns subprogram DIE with address range encompassing the provided
433  /// address. The pointer is alive as long as parsed compile unit DIEs are not
434  /// cleared.
436 
437  /// getInlinedChainForAddress - fetches inlined chain for a given address.
438  /// Returns empty chain if there is no subprogram containing address. The
439  /// chain is valid as long as parsed compile unit DIEs are not cleared.
440  void getInlinedChainForAddress(uint64_t Address,
441  SmallVectorImpl<DWARFDie> &InlinedChain);
442 
443  /// Return the DWARFUnitVector containing this unit.
444  const DWARFUnitVector &getUnitVector() const { return UnitVector; }
445 
446  /// Returns the number of DIEs in the unit. Parses the unit
447  /// if necessary.
448  unsigned getNumDIEs() {
449  extractDIEsIfNeeded(false);
450  return DieArray.size();
451  }
452 
453  /// Return the index of a DIE inside the unit's DIE vector.
454  ///
455  /// It is illegal to call this method with a DIE that hasn't be
456  /// created by this unit. In other word, it's illegal to call this
457  /// method on a DIE that isn't accessible by following
458  /// children/sibling links starting from this unit's getUnitDIE().
460  return getDIEIndex(D.getDebugInfoEntry());
461  }
462 
463  /// Return the DIE object at the given index.
465  assert(Index < DieArray.size());
466  return DWARFDie(this, &DieArray[Index]);
467  }
468 
474 
475  /// Return the DIE object for a given offset inside the
476  /// unit's DIE vector.
477  ///
478  /// The unit needs to have its DIEs extracted for this method to work.
480  extractDIEsIfNeeded(false);
481  auto It =
482  llvm::partition_point(DieArray, [=](const DWARFDebugInfoEntry &DIE) {
483  return DIE.getOffset() < Offset;
484  });
485  if (It != DieArray.end() && It->getOffset() == Offset)
486  return DWARFDie(this, &*It);
487  return DWARFDie();
488  }
489 
491  if (auto IndexEntry = Header.getIndexEntry())
492  if (const auto *Contrib = IndexEntry->getContribution(DW_SECT_LINE))
493  return Contrib->Offset;
494  return 0;
495  }
496 
498  extractDIEsIfNeeded(false);
499  return die_iterator_range(DieArray.begin(), DieArray.end());
500  }
501 
502  virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0;
503 
504  Error tryExtractDIEsIfNeeded(bool CUDieOnly);
505 
506 private:
507  /// Size in bytes of the .debug_info data associated with this compile unit.
508  size_t getDebugInfoSize() const {
509  return Header.getLength() + Header.getUnitLengthFieldByteSize() -
510  getHeaderSize();
511  }
512 
513  /// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it
514  /// hasn't already been done
515  void extractDIEsIfNeeded(bool CUDieOnly);
516 
517  /// extractDIEsToVector - Appends all parsed DIEs to a vector.
518  void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs,
519  std::vector<DWARFDebugInfoEntry> &DIEs) const;
520 
521  /// clearDIEs - Clear parsed DIEs to keep memory usage low.
522  void clearDIEs(bool KeepCUDie);
523 
524  /// parseDWO - Parses .dwo file for current compile unit. Returns true if
525  /// it was actually constructed.
526  bool parseDWO();
527 };
528 
529 inline bool isCompileUnit(const std::unique_ptr<DWARFUnit> &U) {
530  return !U->isTypeUnit();
531 }
532 
533 } // end namespace llvm
534 
535 #endif // LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
llvm::DWARFDebugRangeList
Definition: DWARFDebugRangeList.h:22
llvm::DWARFSection
Definition: DWARFSection.h:16
DWARFFormValue.h
llvm::DWARFUnit::getAbbreviations
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
Definition: DWARFUnit.cpp:864
llvm::DWARFUnit::findRnglistFromIndex
Expected< DWARFAddressRangesVector > findRnglistFromIndex(uint32_t Index)
Return a vector of address ranges retrieved from an encoded range list whose offset is found via a ta...
Definition: DWARFUnit.cpp:641
llvm::DWARFUnit::getFirstChild
DWARFDie getFirstChild(const DWARFDebugInfoEntry *Die)
Definition: DWARFUnit.cpp:820
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::DWARFUnitHeader::getLength
uint64_t getLength() const
Definition: DWARFUnit.h:90
llvm::DWARFUnit::getStringSection
StringRef getStringSection() const
Definition: DWARFUnit.h:300
Optional.h
llvm::DWARFUnit::getRnglistOffset
Optional< uint64_t > getRnglistOffset(uint32_t Index)
Return a rangelist's offset based on an index.
Definition: DWARFUnit.cpp:1009
StringRef.h
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::DWARFUnit::getStringExtractor
DataExtractor getStringExtractor() const
Definition: DWARFUnit.h:338
llvm::DWARFLocationTable
An abstract base class for various kinds of location tables (.debug_loc, .debug_loclists,...
Definition: DWARFDebugLoc.h:46
llvm::DWARFUnitVector::addUnitsForSection
void addUnitsForSection(DWARFContext &C, const DWARFSection &Section, DWARFSectionKind SectionKind)
Read units from a .debug_info or .debug_types section.
Definition: DWARFUnit.cpp:35
llvm::DWARFUnitVector::addUnitsForDWOSection
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:46
llvm::DWARFContext
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Definition: DWARFContext.h:53
llvm::StrOffsetsContributionDescriptor::validateContributionSize
Expected< StrOffsetsContributionDescriptor > validateContributionSize(DWARFDataExtractor &DA)
Determine whether a contribution to the string offsets table is consistent with the relevant section ...
Definition: DWARFUnit.cpp:881
llvm::StrOffsetsContributionDescriptor::Base
uint64_t Base
Definition: DWARFUnit.h:180
llvm::dwarf::FormParams::AddrSize
uint8_t AddrSize
Definition: Dwarf.h:650
DWARFRelocMap.h
llvm::DWARFUnitIndex::Entry
Definition: DWARFUnitIndex.h:92
llvm::Optional< uint64_t >
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::DIE
A structured debug information entry.
Definition: DIE.h:739
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::StrOffsetsContributionDescriptor::getVersion
uint8_t getVersion() const
Definition: DWARFUnit.h:191
llvm::DWARFUnit::getUnitVector
const DWARFUnitVector & getUnitVector() const
Return the DWARFUnitVector containing this unit.
Definition: DWARFUnit.h:444
llvm::DWARFDebugInfoEntry
DWARFDebugInfoEntry - A DIE with only the minimum required data.
Definition: DWARFDebugInfoEntry.h:23
STLExtras.h
llvm::DWARFUnit::getFormParams
const dwarf::FormParams & getFormParams() const
Definition: DWARFUnit.h:282
llvm::DWARFUnit::getLength
uint64_t getLength() const
Definition: DWARFUnit.h:293
llvm::DWARFDataExtractor
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
Definition: DWARFDataExtractor.h:21
llvm::dwarf::Tag
Tag
Definition: Dwarf.h:104
llvm::DWARFUnitVector::getNumTypesUnits
unsigned getNumTypesUnits() const
Returns number of units from all .debug_types[.dwo] sections.
Definition: DWARFUnit.h:163
llvm::StrOffsetsContributionDescriptor::Size
uint64_t Size
The contribution size not including the header.
Definition: DWARFUnit.h:182
llvm::dwarf::FormParams::Format
DwarfFormat Format
Definition: Dwarf.h:651
llvm::dwarf::isUnitType
bool isUnitType(uint8_t UnitType)
Definition: Dwarf.h:474
llvm::DWARFUnit::isDWOUnit
bool isDWOUnit() const
Definition: DWARFUnit.h:278
llvm::DWARFUnitHeader::getFormat
dwarf::DwarfFormat getFormat() const
Definition: DWARFUnit.h:84
llvm::DWARFUnit::getAddrOffsetSectionItem
Optional< object::SectionedAddress > getAddrOffsetSectionItem(uint32_t Index) const
Definition: DWARFUnit.cpp:194
llvm::DWARFUnit::getAbbrOffset
uint64_t getAbbrOffset() const
Definition: DWARFUnit.h:297
llvm::DWARFUnit::getUnitType
uint8_t getUnitType() const
Definition: DWARFUnit.h:295
llvm::DWARFUnit::getLoclistOffset
Optional< uint64_t > getLoclistOffset(uint32_t Index)
Definition: DWARFUnit.cpp:1020
llvm::DWARFUnitHeader::getDwarfOffsetByteSize
uint8_t getDwarfOffsetByteSize() const
Definition: DWARFUnit.h:87
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::DWARFUnit::getUnitDIE
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
Definition: DWARFUnit.h:390
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::StrOffsetsContributionDescriptor::getFormat
dwarf::DwarfFormat getFormat() const
Definition: DWARFUnit.h:192
llvm::DWARFUnit::getStringOffsetSectionItem
Optional< uint64_t > getStringOffsetSectionItem(uint32_t Index) const
Definition: DWARFUnit.cpp:217
llvm::DWARFUnit::getNumDIEs
unsigned getNumDIEs()
Returns the number of DIEs in the unit.
Definition: DWARFUnit.h:448
llvm::DWARFUnit::getDWOId
Optional< uint64_t > getDWOId()
Definition: DWARFUnit.h:405
DWARFDebugRangeList.h
llvm::DWARFUnitHeader::getRefAddrByteSize
uint8_t getRefAddrByteSize() const
Definition: DWARFUnit.h:86
llvm::DWARFUnitVector::getNumInfoUnits
unsigned getNumInfoUnits() const
Returns number of units from all .debug_info[.dwo] sections.
Definition: DWARFUnit.h:159
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::DWARFUnit::determineStringOffsetsTableContribution
Expected< Optional< StrOffsetsContributionDescriptor > > determineStringOffsetsTableContribution(DWARFDataExtractor &DA)
Find the unit's contribution to the string offsets table and determine its length and form.
Definition: DWARFUnit.cpp:960
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::DWARFDebugAbbrev
Definition: DWARFDebugAbbrev.h:56
llvm::X86AS::SS
@ SS
Definition: X86.h:189
llvm::StrOffsetsContributionDescriptor
Represents base address of the CU.
Definition: DWARFUnit.h:179
llvm::DWARFSectionKind
DWARFSectionKind
The enum of section identifiers to be used in internal interfaces.
Definition: DWARFUnitIndex.h:56
DWARFSection.h
DWARFDie.h
DWARFDebugLoc.h
First
into llvm powi allowing the code generator to produce balanced multiplication trees First
Definition: README.txt:54
llvm::DWARFUnitHeader::setDWOId
void setDWOId(uint64_t Id)
Definition: DWARFUnit.h:93
llvm::DWARFUnitHeader::isTypeUnit
bool isTypeUnit() const
Definition: DWARFUnit.h:101
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::DWARFUnit::setSkeletonUnit
void setSkeletonUnit(DWARFUnit *SU)
Definition: DWARFUnit.h:305
llvm::DWARFObject
Definition: DWARFObject.h:25
llvm::AArch64CC::LE
@ LE
Definition: AArch64BaseInfo.h:268
llvm::DWARFUnit::dump
virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts)=0
llvm::DWARFUnit::getLineTableOffset
uint32_t getLineTableOffset() const
Definition: DWARFUnit.h:490
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:991
llvm::DWARFUnit::getLineSection
const DWARFSection & getLineSection() const
Definition: DWARFUnit.h:299
llvm::dwarf::DwarfFormat
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition: Dwarf.h:92
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::DWARFUnit::updateAddressDieMap
void updateAddressDieMap(DWARFDie Die)
Recursively update address to Die map.
Definition: DWARFUnit.cpp:689
llvm::DWARFUnit::getParent
DWARFDie getParent(const DWARFDebugInfoEntry *Die)
Definition: DWARFUnit.cpp:764
llvm::DWARFUnit::setDWOId
void setDWOId(uint64_t NewID)
Definition: DWARFUnit.h:409
llvm::DWARFUnit::getSubroutineForAddress
DWARFDie getSubroutineForAddress(uint64_t Address)
Returns subprogram DIE with address range encompassing the provided address.
Definition: DWARFUnit.cpp:720
llvm::DWARFAbbreviationDeclarationSet
Definition: DWARFDebugAbbrev.h:22
llvm::DWARFUnitVector::iterator
typename UnitVector::iterator iterator
Definition: DWARFUnit.h:129
llvm::DWARFUnit::~DWARFUnit
virtual ~DWARFUnit()
llvm::DWARFUnit::getDebugInfoExtractor
DWARFDataExtractor getDebugInfoExtractor() const
Definition: DWARFUnit.cpp:188
llvm::DWARFUnit::isMatchingUnitTypeAndTag
static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag)
Definition: DWARFUnit.h:371
llvm::DWARFUnit::collectAddressRanges
Expected< DWARFAddressRangesVector > collectAddressRanges()
Definition: DWARFUnit.cpp:651
llvm::DWARFUnit::getStringOffsetsTableContribution
const Optional< StrOffsetsContributionDescriptor > & getStringOffsetsTableContribution() const
Definition: DWARFUnit.h:353
llvm::DWARFUnit::findLoclistFromOffset
Expected< DWARFLocationExpressionsVector > findLoclistFromOffset(uint64_t Offset)
Definition: DWARFUnit.cpp:666
llvm::DWARFUnit::getLinkedUnit
DWARFUnit * getLinkedUnit()
Definition: DWARFUnit.h:309
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
uint64_t
llvm::DWARFUnitHeader::getSize
uint8_t getSize() const
Definition: DWARFUnit.h:104
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::DWARFUnit::isTypeUnit
bool isTypeUnit() const
Definition: DWARFUnit.h:296
llvm::DWARFUnitHeader
Base class describing the header of any kind of "unit." Some information is specific to certain unit ...
Definition: DWARFUnit.h:47
llvm::DWARFUnit::getDIEIndex
uint32_t getDIEIndex(const DWARFDie &D)
Return the index of a DIE inside the unit's DIE vector.
Definition: DWARFUnit.h:459
llvm::dwarf::getUnitLengthFieldByteSize
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
Definition: Dwarf.h:671
llvm::DWARFUnit::getSibling
DWARFDie getSibling(const DWARFDebugInfoEntry *Die)
Definition: DWARFUnit.cpp:777
llvm::DWARFUnit::getDwarfStringOffsetsByteSize
uint8_t getDwarfStringOffsetsByteSize() const
Definition: DWARFUnit.h:357
DWARFDebugRnglists.h
llvm::dwarf::FormParams
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition: Dwarf.h:648
llvm::DWARFUnit::DWARFUnit
DWARFUnit(DWARFContext &Context, const DWARFSection &Section, const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA, const DWARFSection *RS, const DWARFSection *LocSection, StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, bool LE, bool IsDWO, const DWARFUnitVector &UnitVector)
Definition: DWARFUnit.cpp:173
llvm::dwarf::UnitType
UnitType
Constants for unit types in DWARF v5.
Definition: Dwarf.h:460
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::DWARFUnitHeader::getFormParams
const dwarf::FormParams & getFormParams() const
Definition: DWARFUnit.h:82
llvm::DWARFUnit::getRefAddrByteSize
uint8_t getRefAddrByteSize() const
Definition: DWARFUnit.h:287
llvm::DWARFUnit::getStringOffsetSection
const DWARFSection & getStringOffsetSection() const
Definition: DWARFUnit.h:301
llvm::DWARFUnitHeader::getTypeOffset
uint64_t getTypeOffset() const
Definition: DWARFUnit.h:99
llvm::DWARFUnit::getFormat
dwarf::DwarfFormat getFormat() const
Definition: DWARFUnit.h:294
iterator_range.h
llvm::dwarf::FormParams::getDwarfOffsetByteSize
uint8_t getDwarfOffsetByteSize() const
The size of a reference is determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:663
llvm::DWARFUnitHeader::getIndexEntry
const DWARFUnitIndex::Entry * getIndexEntry() const
Definition: DWARFUnit.h:97
llvm::DWARFUnit::getNextUnitOffset
uint64_t getNextUnitOffset() const
Definition: DWARFUnit.h:298
llvm::DWARFUnit::clear
void clear()
Definition: DWARFUnit.cpp:357
llvm::DWARFUnit::getDIEAtIndex
DWARFDie getDIEAtIndex(unsigned Index)
Return the DIE object at the given index.
Definition: DWARFUnit.h:464
llvm::size
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1532
llvm::DWARFUnitVector::getUnitForIndexEntry
DWARFUnit * getUnitForIndexEntry(const DWARFUnitIndex::Entry &E)
Definition: DWARFUnit.cpp:144
llvm::DWARFUnit::getCompilationDir
const char * getCompilationDir()
Definition: DWARFUnit.cpp:368
llvm::DWARFUnit::getLocSectionBase
uint64_t getLocSectionBase() const
Definition: DWARFUnit.h:328
llvm::DWARFUnitVector::addUnit
DWARFUnit * addUnit(std::unique_ptr< DWARFUnit > Unit)
Add an existing DWARFUnit to this UnitVector.
Definition: DWARFUnit.cpp:122
llvm::M68kBeads::DA
@ DA
Definition: M68kBaseInfo.h:59
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
Dwarf.h
llvm::DWARFUnit::getContext
DWARFContext & getContext() const
Definition: DWARFUnit.h:279
llvm::DWARFUnitHeader::getAddressByteSize
uint8_t getAddressByteSize() const
Definition: DWARFUnit.h:85
llvm::DWARFUnitVector::compile_unit_range
decltype(make_filter_range(std::declval< iterator_range >(), isCompileUnit)) compile_unit_range
Definition: DWARFUnit.h:133
llvm::DWARFUnitVector::getUnitForOffset
DWARFUnit * getUnitForOffset(uint64_t Offset) const
Definition: DWARFUnit.cpp:131
uint32_t
DWARFDebugInfoEntry.h
llvm::DWARFUnitHeader::extract
bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info, uint64_t *offset_ptr, DWARFSectionKind SectionKind)
Parse a unit header from debug_info starting at offset_ptr.
Definition: DWARFUnit.cpp:229
llvm::DWARFUnit::getDwarfOffsetByteSize
uint8_t getDwarfOffsetByteSize() const
Definition: DWARFUnit.h:288
llvm::DWARFUnitHeader::getAbbrOffset
uint64_t getAbbrOffset() const
Definition: DWARFUnit.h:91
llvm::DWARFUnitHeader::getNextUnitOffset
uint64_t getNextUnitOffset() const
Definition: DWARFUnit.h:108
llvm::DWARFUnit::dies
die_iterator_range dies()
Definition: DWARFUnit.h:497
llvm::make_filter_range
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:490
llvm::StrOffsetsContributionDescriptor::FormParams
dwarf::FormParams FormParams
Format and version.
Definition: DWARFUnit.h:184
llvm::DWARFUnit::getAddrOffsetSectionBase
Optional< uint64_t > getAddrOffsetSectionBase() const
Definition: DWARFUnit.h:316
llvm::DWARFUnit::getNonSkeletonUnitDIE
DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly=true)
Definition: DWARFUnit.h:397
llvm::DWARFUnit::findRnglistFromOffset
Expected< DWARFAddressRangesVector > findRnglistFromOffset(uint64_t Offset)
Return a vector of address ranges resulting from a (possibly encoded) range list starting at a given ...
Definition: DWARFUnit.cpp:624
llvm::DWARFUnitHeader::getVersion
uint16_t getVersion() const
Definition: DWARFUnit.h:83
llvm::DWARFUnit::extractRangeList
Error extractRangeList(uint64_t RangeListOffset, DWARFDebugRangeList &RangeList) const
Extract the range list referenced by this compile unit from the .debug_ranges section.
Definition: DWARFUnit.cpp:347
llvm::DWARFUnitHeader::getDWOId
Optional< uint64_t > getDWOId() const
Definition: DWARFUnit.h:92
llvm::partition_point
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
Definition: STLExtras.h:1699
llvm::DWARFUnit::getAddressByteSize
uint8_t getAddressByteSize() const
Definition: DWARFUnit.h:286
llvm::DWARFUnit::getLastChild
DWARFDie getLastChild(const DWARFDebugInfoEntry *Die)
Definition: DWARFUnit.cpp:833
llvm::SectionKind
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
uint16_t
llvm::StrOffsetsContributionDescriptor::StrOffsetsContributionDescriptor
StrOffsetsContributionDescriptor()=default
llvm::DWARFUnit
Definition: DWARFUnit.h:203
llvm::DWARFUnit::setRangesSection
void setRangesSection(const DWARFSection *RS, uint64_t Base)
Definition: DWARFUnit.h:323
llvm::DWARFUnit::getHeaderSize
uint32_t getHeaderSize() const
Size in bytes of the parsed unit header.
Definition: DWARFUnit.h:292
llvm::DWARFUnit::getPreviousSibling
DWARFDie getPreviousSibling(const DWARFDebugInfoEntry *Die)
Definition: DWARFUnit.cpp:790
llvm::DWARFUnit::tryExtractDIEsIfNeeded
Error tryExtractDIEsIfNeeded(bool CUDieOnly)
Definition: DWARFUnit.cpp:465
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::DWARFUnitHeader::getOffset
uint64_t getOffset() const
Definition: DWARFUnit.h:81
llvm::AArch64CC::LS
@ LS
Definition: AArch64BaseInfo.h:264
DataExtractor.h
llvm::DWARFUnitVector::finishedInfoUnits
void finishedInfoUnits()
Indicate that parsing .debug_info[.dwo] is done, and remaining units will be from ....
Definition: DWARFUnit.h:166
llvm::DWARFUnit::getOffset
uint64_t getOffset() const
Definition: DWARFUnit.h:281
llvm::StrOffsetsContributionDescriptor::getDwarfOffsetByteSize
uint8_t getDwarfOffsetByteSize() const
Definition: DWARFUnit.h:193
llvm::DWARFUnit::getInlinedChainForAddress
void getInlinedChainForAddress(uint64_t Address, SmallVectorImpl< DWARFDie > &InlinedChain)
getInlinedChainForAddress - fetches inlined chain for a given address.
Definition: DWARFUnit.cpp:735
llvm::DWARFUnit::getInfoSection
const DWARFSection & getInfoSection() const
Definition: DWARFUnit.h:280
DWARFUnitIndex.h
llvm::dwarf::FormParams::Version
uint16_t Version
Definition: Dwarf.h:649
llvm::DWARFUnit::getAbbreviationsOffset
uint64_t getAbbreviationsOffset() const
Definition: DWARFUnit.h:367
llvm::DataExtractor
Definition: DataExtractor.h:41
SmallVector.h
llvm::DWARFUnitHeader::getUnitLengthFieldByteSize
uint8_t getUnitLengthFieldByteSize() const
Definition: DWARFUnit.h:105
llvm::DWARFUnitHeader::applyIndexEntry
bool applyIndexEntry(const DWARFUnitIndex::Entry *Entry)
Definition: DWARFUnit.cpp:330
llvm::DWARFUnit::getBaseAddress
llvm::Optional< object::SectionedAddress > getBaseAddress()
Definition: DWARFUnit.cpp:870
llvm::SmallVectorImpl< std::unique_ptr< DWARFUnit > >::iterator
typename SuperClass::iterator iterator
Definition: SmallVector.h:562
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::isCompileUnit
bool isCompileUnit(const std::unique_ptr< DWARFUnit > &U)
Definition: DWARFUnit.h:529
llvm::DWARFUnit::setAddrOffsetSection
void setAddrOffsetSection(const DWARFSection *AOS, uint64_t Base)
Definition: DWARFUnit.h:311
llvm::SmallVectorImpl< std::unique_ptr< DWARFUnit > >
llvm::getDWARFUnitIndex
const DWARFUnitIndex & getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind)
Definition: DWARFUnit.cpp:756
llvm::DWARFDie
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition: DWARFDie.h:43
llvm::DWARFUnit::getDIEForOffset
DWARFDie getDIEForOffset(uint64_t Offset)
Return the DIE object for a given offset inside the unit's DIE vector.
Definition: DWARFUnit.h:479
llvm::DWARFUnitHeader::getUnitType
uint8_t getUnitType() const
Definition: DWARFUnit.h:100
llvm::DIE::getOffset
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
Definition: DIE.h:777
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:231
llvm::DWARFUnit::getLocationTable
const DWARFLocationTable & getLocationTable()
Definition: DWARFUnit.h:342
llvm::StrOffsetsContributionDescriptor::StrOffsetsContributionDescriptor
StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size, uint8_t Version, dwarf::DwarfFormat Format)
Definition: DWARFUnit.h:186
llvm::DWARFUnit::determineStringOffsetsTableContributionDWO
Expected< Optional< StrOffsetsContributionDescriptor > > determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA)
Find the unit's contribution to the string offsets table and determine its length and form.
Definition: DWARFUnit.cpp:973
llvm::DWARFUnit::getHeader
const DWARFUnitHeader & getHeader() const
Definition: DWARFUnit.h:253
llvm::DWARFUnit::getStringOffsetsBase
uint64_t getStringOffsetsBase() const
Definition: DWARFUnit.h:362
llvm::DWARFUnit::getVersion
uint16_t getVersion() const
Definition: DWARFUnit.h:285
llvm::dwarf::DWARF32
@ DWARF32
Definition: Dwarf.h:92
llvm::sampleprof::Base
@ Base
Definition: Discriminator.h:58
llvm::DWARFUnitHeader::getTypeHash
uint64_t getTypeHash() const
Definition: DWARFUnit.h:98
llvm::dwarf::FormParams::getRefAddrByteSize
uint8_t getRefAddrByteSize() const
The definition of the size of form DW_FORM_ref_addr depends on the version.
Definition: Dwarf.h:656
llvm::DIDumpOptions
Container for dump options that control which debug information will be dumped.
Definition: DIContext.h:180
llvm::DWARFUnitVector
Describe a collection of units.
Definition: DWARFUnit.h:120
llvm::DWARFUnitVector::getNumUnits
unsigned getNumUnits() const
Returns number of all units held by this instance.
Definition: DWARFUnit.h:157