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