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