LLVM  7.0.0svn
DWARFUnit.h
Go to the documentation of this file.
1 //===- DWARFUnit.h ----------------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
11 #define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
12 
13 #include "llvm/ADT/Optional.h"
14 #include "llvm/ADT/STLExtras.h"
15 #include "llvm/ADT/SmallVector.h"
16 #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  uint32_t Offset = 0;
50  // Version, address size, and DWARF format.
51  dwarf::FormParams FormParams;
52  uint32_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  uint32_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  bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info,
75  const DWARFUnitIndex *Index = nullptr);
76  uint32_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  uint32_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  uint32_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  // FIXME: Support DWARF64.
101  uint32_t getNextUnitOffset() const { return Offset + Length + 4; }
102 };
103 
104 /// Base class for all DWARFUnitSection classes. This provides the
105 /// functionality common to all unit types.
107 public:
108  /// Returns the Unit that contains the given section offset in the
109  /// same section this Unit originated from.
110  virtual DWARFUnit *getUnitForOffset(uint32_t Offset) const = 0;
111  virtual DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) = 0;
112 
113  void parse(DWARFContext &C, const DWARFSection &Section);
114  void parseDWO(DWARFContext &C, const DWARFSection &DWOSection,
115  bool Lazy = false);
116 
117 protected:
118  ~DWARFUnitSectionBase() = default;
119 
120  virtual void parseImpl(DWARFContext &Context, const DWARFObject &Obj,
121  const DWARFSection &Section,
122  const DWARFDebugAbbrev *DA, const DWARFSection *RS,
123  StringRef SS, const DWARFSection &SOS,
124  const DWARFSection *AOS, const DWARFSection &LS,
125  bool isLittleEndian, bool isDWO, bool Lazy) = 0;
126 };
127 
130 
131 /// Concrete instance of DWARFUnitSection, specialized for one Unit type.
132 template<typename UnitType>
133 class DWARFUnitSection final : public SmallVector<std::unique_ptr<UnitType>, 1>,
134  public DWARFUnitSectionBase {
135  bool Parsed = false;
136  std::function<std::unique_ptr<UnitType>(uint32_t)> Parser;
137 
138 public:
140  using iterator = typename UnitVector::iterator;
142 
143  UnitType *getUnitForOffset(uint32_t Offset) const override {
144  auto *CU = std::upper_bound(
145  this->begin(), this->end(), Offset,
146  [](uint32_t LHS, const std::unique_ptr<UnitType> &RHS) {
147  return LHS < RHS->getNextUnitOffset();
148  });
149  if (CU != this->end() && (*CU)->getOffset() <= Offset)
150  return CU->get();
151  return nullptr;
152  }
153  UnitType *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) override {
154  const auto *CUOff = E.getOffset(DW_SECT_INFO);
155  if (!CUOff)
156  return nullptr;
157 
158  auto Offset = CUOff->Offset;
159 
160  auto *CU = std::upper_bound(
161  this->begin(), this->end(), CUOff->Offset,
162  [](uint32_t LHS, const std::unique_ptr<UnitType> &RHS) {
163  return LHS < RHS->getNextUnitOffset();
164  });
165  if (CU != this->end() && (*CU)->getOffset() <= Offset)
166  return CU->get();
167 
168  if (!Parser)
169  return nullptr;
170 
171  auto U = Parser(Offset);
172  if (!U)
173  U = nullptr;
174 
175  auto *NewCU = U.get();
176  this->insert(CU, std::move(U));
177  return NewCU;
178  }
179 
180 private:
181  void parseImpl(DWARFContext &Context, const DWARFObject &Obj,
182  const DWARFSection &Section, const DWARFDebugAbbrev *DA,
183  const DWARFSection *RS, StringRef SS, const DWARFSection &SOS,
184  const DWARFSection *AOS, const DWARFSection &LS, bool LE,
185  bool IsDWO, bool Lazy) override {
186  if (Parsed)
187  return;
188  DWARFDataExtractor Data(Obj, Section, LE, 0);
189  if (!Parser) {
190  const DWARFUnitIndex *Index = nullptr;
191  if (IsDWO)
192  Index = &getDWARFUnitIndex(Context, UnitType::Section);
193  Parser = [=, &Context, &Section, &SOS,
194  &LS](uint32_t Offset) -> std::unique_ptr<UnitType> {
195  if (!Data.isValidOffset(Offset))
196  return nullptr;
197  DWARFUnitHeader Header;
198  if (!Header.extract(Context, Data, &Offset, UnitType::Section, Index))
199  return nullptr;
200  auto U = llvm::make_unique<UnitType>(
201  Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
202  *this);
203  return U;
204  };
205  }
206  if (Lazy)
207  return;
208  auto I = this->begin();
209  uint32_t Offset = 0;
210  while (Data.isValidOffset(Offset)) {
211  if (I != this->end() && (*I)->getOffset() == Offset) {
212  ++I;
213  continue;
214  }
215  auto U = Parser(Offset);
216  if (!U)
217  break;
218  Offset = U->getNextUnitOffset();
219  I = std::next(this->insert(I, std::move(U)));
220  }
221  Parsed = true;
222  }
223 };
224 
225 /// Represents base address of the CU.
226 struct BaseAddress {
227  uint64_t Address;
228  uint64_t SectionIndex;
229 };
230 
231 /// Represents a unit's contribution to the string offsets table.
233  uint64_t Base = 0;
234  /// The contribution size not including the header.
235  uint64_t Size = 0;
236  /// Format and version.
238 
239  StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size,
241  : Base(Base), Size(Size), FormParams({Version, 0, Format}) {}
242 
243  uint8_t getVersion() const { return FormParams.Version; }
244  dwarf::DwarfFormat getFormat() const { return FormParams.Format; }
245  uint8_t getDwarfOffsetByteSize() const {
246  return FormParams.getDwarfOffsetByteSize();
247  }
248  /// Determine whether a contribution to the string offsets table is
249  /// consistent with the relevant section size and that its length is
250  /// a multiple of the size of one of its entries.
252  validateContributionSize(DWARFDataExtractor &DA);
253 };
254 
255 class DWARFUnit {
257  /// Section containing this DWARFUnit.
258  const DWARFSection &InfoSection;
259 
260  DWARFUnitHeader Header;
261  const DWARFDebugAbbrev *Abbrev;
262  const DWARFSection *RangeSection;
263  uint32_t RangeSectionBase;
264  const DWARFSection &LineSection;
265  StringRef StringSection;
266  const DWARFSection &StringOffsetSection;
267  const DWARFSection *AddrOffsetSection;
268  uint32_t AddrOffsetSectionBase = 0;
269  bool isLittleEndian;
270  bool isDWO;
271  const DWARFUnitSectionBase &UnitSection;
272 
273  /// Start, length, and DWARF format of the unit's contribution to the string
274  /// offsets table (DWARF v5).
275  Optional<StrOffsetsContributionDescriptor> StringOffsetsTableContribution;
276 
277  /// A table of range lists (DWARF v5 and later).
279 
280  mutable const DWARFAbbreviationDeclarationSet *Abbrevs;
282  /// The compile unit debug information entry items.
283  std::vector<DWARFDebugInfoEntry> DieArray;
284 
285  /// Map from range's start address to end address and corresponding DIE.
286  /// IntervalMap does not support range removal, as a result, we use the
287  /// std::map::upper_bound for address range lookup.
288  std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
289 
290  using die_iterator_range =
292 
293  std::shared_ptr<DWARFUnit> DWO;
294 
295  uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) {
296  auto First = DieArray.data();
297  assert(Die >= First && Die < First + DieArray.size());
298  return Die - First;
299  }
300 
301 protected:
302  const DWARFUnitHeader &getHeader() const { return Header; }
303 
304  /// Size in bytes of the parsed unit header.
305  uint32_t getHeaderSize() const { return Header.getSize(); }
306 
307  /// Find the unit's contribution to the string offsets table and determine its
308  /// length and form. The given offset is expected to be derived from the unit
309  /// DIE's DW_AT_str_offsets_base attribute.
311  determineStringOffsetsTableContribution(DWARFDataExtractor &DA,
312  uint64_t Offset);
313 
314  /// Find the unit's contribution to the string offsets table and determine its
315  /// length and form. The given offset is expected to be 0 in a dwo file or,
316  /// in a dwp file, the start of the unit's contribution to the string offsets
317  /// table section (as determined by the index table).
319  determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA,
320  uint64_t Offset);
321 
322 public:
323  DWARFUnit(DWARFContext &Context, const DWARFSection &Section,
324  const DWARFUnitHeader &Header,
325  const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS,
326  const DWARFSection &SOS, const DWARFSection *AOS,
327  const DWARFSection &LS, bool LE, bool IsDWO,
328  const DWARFUnitSectionBase &UnitSection);
329 
330  virtual ~DWARFUnit();
331 
332  DWARFContext& getContext() const { return Context; }
333  uint32_t getOffset() const { return Header.getOffset(); }
335  return Header.getFormParams();
336  }
337  uint16_t getVersion() const { return Header.getVersion(); }
338  uint8_t getAddressByteSize() const { return Header.getAddressByteSize(); }
339  uint8_t getRefAddrByteSize() const { return Header.getRefAddrByteSize(); }
340  uint8_t getDwarfOffsetByteSize() const {
341  return Header.getDwarfOffsetByteSize();
342  }
343  uint32_t getLength() const { return Header.getLength(); }
344  uint8_t getUnitType() const { return Header.getUnitType(); }
345  uint32_t getNextUnitOffset() const { return Header.getNextUnitOffset(); }
346  const DWARFSection &getLineSection() const { return LineSection; }
347  StringRef getStringSection() const { return StringSection; }
349  return StringOffsetSection;
350  }
351 
353  AddrOffsetSection = AOS;
354  AddrOffsetSectionBase = Base;
355  }
356 
357  /// Recursively update address to Die map.
358  void updateAddressDieMap(DWARFDie Die);
359 
361  RangeSection = RS;
362  RangeSectionBase = Base;
363  }
364 
365  bool getAddrOffsetSectionItem(uint32_t Index, uint64_t &Result) const;
366  bool getStringOffsetSectionItem(uint32_t Index, uint64_t &Result) const;
367 
368  DWARFDataExtractor getDebugInfoExtractor() const;
369 
371  return DataExtractor(StringSection, false, 0);
372  }
373 
374  /// Extract the range list referenced by this compile unit from the
375  /// .debug_ranges section. If the extraction is unsuccessful, an error
376  /// is returned. Successful extraction requires that the compile unit
377  /// has already been extracted.
378  Error extractRangeList(uint32_t RangeListOffset,
379  DWARFDebugRangeList &RangeList) const;
380  void clear();
381 
384  return StringOffsetsTableContribution;
385  }
386 
388  assert(StringOffsetsTableContribution);
389  return StringOffsetsTableContribution->getDwarfOffsetByteSize();
390  }
391 
392  uint64_t getStringOffsetsBase() const {
393  assert(StringOffsetsTableContribution);
394  return StringOffsetsTableContribution->Base;
395  }
396 
397  const DWARFAbbreviationDeclarationSet *getAbbreviations() const;
398 
399  static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag) {
400  switch (UnitType) {
401  case dwarf::DW_UT_compile:
402  return Tag == dwarf::DW_TAG_compile_unit;
403  case dwarf::DW_UT_type:
404  return Tag == dwarf::DW_TAG_type_unit;
405  case dwarf::DW_UT_partial:
406  return Tag == dwarf::DW_TAG_partial_unit;
407  case dwarf::DW_UT_skeleton:
408  return Tag == dwarf::DW_TAG_skeleton_unit;
409  case dwarf::DW_UT_split_compile:
410  case dwarf::DW_UT_split_type:
411  return dwarf::isUnitType(Tag);
412  }
413  return false;
414  }
415 
416  /// Return the number of bytes for the header of a unit of
417  /// UnitType type.
418  ///
419  /// This function must be called with a valid unit type which in
420  /// DWARF5 is defined as one of the following six types.
421  static uint32_t getDWARF5HeaderSize(uint8_t UnitType) {
422  switch (UnitType) {
423  case dwarf::DW_UT_compile:
424  case dwarf::DW_UT_partial:
425  return 12;
426  case dwarf::DW_UT_skeleton:
427  case dwarf::DW_UT_split_compile:
428  return 20;
429  case dwarf::DW_UT_type:
430  case dwarf::DW_UT_split_type:
431  return 24;
432  }
433  llvm_unreachable("Invalid UnitType.");
434  }
435 
436  llvm::Optional<BaseAddress> getBaseAddress();
437 
438  DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) {
439  extractDIEsIfNeeded(ExtractUnitDIEOnly);
440  if (DieArray.empty())
441  return DWARFDie();
442  return DWARFDie(this, &DieArray[0]);
443  }
444 
445  const char *getCompilationDir();
447  extractDIEsIfNeeded(/*CUDieOnly*/ true);
448  return getHeader().getDWOId();
449  }
450  void setDWOId(uint64_t NewID) { Header.setDWOId(NewID); }
451 
452  /// Return a vector of address ranges resulting from a (possibly encoded)
453  /// range list starting at a given offset in the appropriate ranges section.
454  Expected<DWARFAddressRangesVector> findRnglistFromOffset(uint32_t Offset);
455 
456  /// Return a vector of address ranges retrieved from an encoded range
457  /// list whose offset is found via a table lookup given an index (DWARF v5
458  /// and later).
459  Expected<DWARFAddressRangesVector> findRnglistFromIndex(uint32_t Index);
460 
461  /// Return a rangelist's offset based on an index. The index designates
462  /// an entry in the rangelist table's offset array and is supplied by
463  /// DW_FORM_rnglistx.
465  if (RngListTable)
466  return RngListTable->getOffsetEntry(Index);
467  return None;
468  }
469 
470  void collectAddressRanges(DWARFAddressRangesVector &CURanges);
471 
472  /// Returns subprogram DIE with address range encompassing the provided
473  /// address. The pointer is alive as long as parsed compile unit DIEs are not
474  /// cleared.
475  DWARFDie getSubroutineForAddress(uint64_t Address);
476 
477  /// getInlinedChainForAddress - fetches inlined chain for a given address.
478  /// Returns empty chain if there is no subprogram containing address. The
479  /// chain is valid as long as parsed compile unit DIEs are not cleared.
480  void getInlinedChainForAddress(uint64_t Address,
481  SmallVectorImpl<DWARFDie> &InlinedChain);
482 
483  /// getUnitSection - Return the DWARFUnitSection containing this unit.
484  const DWARFUnitSectionBase &getUnitSection() const { return UnitSection; }
485 
486  /// Returns the number of DIEs in the unit. Parses the unit
487  /// if necessary.
488  unsigned getNumDIEs() {
489  extractDIEsIfNeeded(false);
490  return DieArray.size();
491  }
492 
493  /// Return the index of a DIE inside the unit's DIE vector.
494  ///
495  /// It is illegal to call this method with a DIE that hasn't be
496  /// created by this unit. In other word, it's illegal to call this
497  /// method on a DIE that isn't accessible by following
498  /// children/sibling links starting from this unit's getUnitDIE().
500  return getDIEIndex(D.getDebugInfoEntry());
501  }
502 
503  /// Return the DIE object at the given index.
504  DWARFDie getDIEAtIndex(unsigned Index) {
505  assert(Index < DieArray.size());
506  return DWARFDie(this, &DieArray[Index]);
507  }
508 
510  DWARFDie getSibling(const DWARFDebugInfoEntry *Die);
511  DWARFDie getPreviousSibling(const DWARFDebugInfoEntry *Die);
512  DWARFDie getFirstChild(const DWARFDebugInfoEntry *Die);
513  DWARFDie getLastChild(const DWARFDebugInfoEntry *Die);
514 
515  /// Return the DIE object for a given offset inside the
516  /// unit's DIE vector.
517  ///
518  /// The unit needs to have its DIEs extracted for this method to work.
520  extractDIEsIfNeeded(false);
521  assert(!DieArray.empty());
522  auto it = std::lower_bound(
523  DieArray.begin(), DieArray.end(), Offset,
524  [](const DWARFDebugInfoEntry &LHS, uint32_t Offset) {
525  return LHS.getOffset() < Offset;
526  });
527  if (it != DieArray.end() && it->getOffset() == Offset)
528  return DWARFDie(this, &*it);
529  return DWARFDie();
530  }
531 
533  if (auto IndexEntry = Header.getIndexEntry())
534  if (const auto *Contrib = IndexEntry->getOffset(DW_SECT_LINE))
535  return Contrib->Offset;
536  return 0;
537  }
538 
540  extractDIEsIfNeeded(false);
541  return die_iterator_range(DieArray.begin(), DieArray.end());
542  }
543 
544 private:
545  /// Size in bytes of the .debug_info data associated with this compile unit.
546  size_t getDebugInfoSize() const {
547  return Header.getLength() + 4 - getHeaderSize();
548  }
549 
550  /// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it
551  /// hasn't already been done. Returns the number of DIEs parsed at this call.
552  size_t extractDIEsIfNeeded(bool CUDieOnly);
553 
554  /// extractDIEsToVector - Appends all parsed DIEs to a vector.
555  void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs,
556  std::vector<DWARFDebugInfoEntry> &DIEs) const;
557 
558  /// clearDIEs - Clear parsed DIEs to keep memory usage low.
559  void clearDIEs(bool KeepCUDie);
560 
561  /// parseDWO - Parses .dwo file for current compile unit. Returns true if
562  /// it was actually constructed.
563  bool parseDWO();
564 };
565 
566 } // end namespace llvm
567 
568 #endif // LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag)
Definition: DWARFUnit.h:399
uint64_t CallInst * C
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:250
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition: Dwarf.h:495
LLVMContext & Context
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:241
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Represents a unit&#39;s contribution to the string offsets table.
Definition: DWARFUnit.h:232
bool isUnitType(uint8_t UnitType)
Definition: Dwarf.h:342
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:503
void setAddrOffsetSection(const DWARFSection *AOS, uint32_t Base)
Definition: DWARFUnit.h:352
const Optional< StrOffsetsContributionDescriptor > & getStringOffsetsTableContribution() const
Definition: DWARFUnit.h:383
uint8_t getRefAddrByteSize() const
Definition: DWARFUnit.h:339
dwarf::DwarfFormat getFormat() const
Definition: DWARFUnit.h:244
uint8_t getDwarfStringOffsetsByteSize() const
Definition: DWARFUnit.h:387
UnitType * getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) override
Definition: DWARFUnit.h:153
const dwarf::FormParams & getFormParams() const
Definition: DWARFUnit.h:334
uint32_t getOffset() const
Definition: DWARFUnit.h:76
uint32_t getNextUnitOffset() const
Definition: DWARFUnit.h:345
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:65
uint64_t getAbbrOffset() const
Definition: DWARFUnit.h:86
const DWARFSection & getLineSection() const
Definition: DWARFUnit.h:346
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
const DWARFDebugInfoEntry * getDebugInfoEntry() const
Definition: DWARFDie.h:53
bool isTypeUnit() const
Definition: DWARFUnit.h:96
uint8_t getAddressByteSize() const
Definition: DWARFUnit.h:338
UnitType * getUnitForOffset(uint32_t Offset) const override
Returns the Unit that contains the given section offset in the same section this Unit originated from...
Definition: DWARFUnit.h:143
unsigned getNumDIEs()
Returns the number of DIEs in the unit.
Definition: DWARFUnit.h:488
uint64_t Address
Definition: DWARFUnit.h:227
uint32_t getTypeOffset() const
Definition: DWARFUnit.h:94
auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1004
void setDWOId(uint64_t NewID)
Definition: DWARFUnit.h:450
const DWARFSection & getStringOffsetSection() const
Definition: DWARFUnit.h:348
uint16_t getVersion() const
Definition: DWARFUnit.h:337
die_iterator_range dies()
Definition: DWARFUnit.h:539
Utility class that carries the DWARF compile/type unit and the debug info entry in an object...
Definition: DWARFDie.h:43
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
DWARFSectionKind
uint8_t getUnitType() const
Definition: DWARFUnit.h:95
Optional< uint64_t > getDWOId()
Definition: DWARFUnit.h:446
static uint32_t getDWARF5HeaderSize(uint8_t UnitType)
Return the number of bytes for the header of a unit of UnitType type.
Definition: DWARFUnit.h:421
uint32_t getLength() const
Definition: DWARFUnit.h:85
StringRef getStringSection() const
Definition: DWARFUnit.h:347
uint32_t getDIEIndex(const DWARFDie &D)
Return the index of a DIE inside the unit&#39;s DIE vector.
Definition: DWARFUnit.h:499
DWARFContext & getContext() const
Definition: DWARFUnit.h:332
void setRangesSection(const DWARFSection *RS, uint32_t Base)
Definition: DWARFUnit.h:360
llvm::Expected< Value > parse(llvm::StringRef JSON)
Parses the provided JSON source, or returns a ParseError.
Definition: JSON.cpp:505
bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info, uint32_t *offset_ptr, DWARFSectionKind Kind=DW_SECT_INFO, const DWARFUnitIndex *Index=nullptr)
Parse a unit header from debug_info starting at offset_ptr.
Definition: DWARFUnit.cpp:96
uint32_t getHeaderSize() const
Size in bytes of the parsed unit header.
Definition: DWARFUnit.h:305
const dwarf::FormParams & getFormParams() const
Definition: DWARFUnit.h:77
const DWARFUnitIndex & getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind)
Definition: DWARFUnit.cpp:540
Base class describing the header of any kind of "unit." Some information is specific to certain unit ...
Definition: DWARFUnit.h:47
StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size, uint8_t Version, dwarf::DwarfFormat Format)
Definition: DWARFUnit.h:239
#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
uint64_t SectionIndex
Definition: DWARFUnit.h:228
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:392
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
Definition: DWARFUnit.h:438
void setDWOId(uint64_t Id)
Definition: DWARFUnit.h:88
const DWARFUnitIndex::Entry * getIndexEntry() const
Definition: DWARFUnit.h:92
Represents base address of the CU.
Definition: DWARFUnit.h:226
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
Concrete instance of DWARFUnitSection, specialized for one Unit type.
Definition: DWARFUnit.h:133
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Definition: DWARFContext.h:59
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
A range adaptor for a pair of iterators.
This file contains constants used for implementing Dwarf debug support.
uint32_t getLength() const
Definition: DWARFUnit.h:343
static void clear(coro::Shape &Shape)
Definition: Coroutines.cpp:211
uint32_t getNextUnitOffset() const
Definition: DWARFUnit.h:101
DataExtractor getStringExtractor() const
Definition: DWARFUnit.h:370
DWARFDie getDIEAtIndex(unsigned Index)
Return the DIE object at the given index.
Definition: DWARFUnit.h:504
uint8_t getRefAddrByteSize() const
Definition: DWARFUnit.h:81
#define I(x, y, z)
Definition: MD5.cpp:58
const DWARFUnitSectionBase & getUnitSection() const
getUnitSection - Return the DWARFUnitSection containing this unit.
Definition: DWARFUnit.h:484
uint32_t getOffset() const
Definition: DWARFUnit.h:333
bool isValidOffset(uint32_t offset) const
Test the validity of offset.
uint8_t getSize() const
Definition: DWARFUnit.h:99
const unsigned Kind
uint8_t getUnitType() const
Definition: DWARFUnit.h:344
DWARFDie getDIEForOffset(uint32_t Offset)
Return the DIE object for a given offset inside the unit&#39;s DIE vector.
Definition: DWARFUnit.h:519
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
DwarfFormat Format
Definition: Dwarf.h:498
Base class for all DWARFUnitSection classes.
Definition: DWARFUnit.h:106
const DWARFUnitHeader & getHeader() const
Definition: DWARFUnit.h:302
std::vector< DWARFAddressRange > DWARFAddressRangesVector
DWARFAddressRangesVector - represents a set of absolute address ranges.
DWARFDebugInfoEntry - A DIE with only the minimum required data.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
static const Function * getParent(const Value *V)
const SectionContribution * getOffset(DWARFSectionKind Sec) const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
uint8_t getDwarfOffsetByteSize() const
The size of a reference is determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:510
Optional< uint32_t > getRnglistOffset(uint32_t Index)
Return a rangelist&#39;s offset based on an index.
Definition: DWARFUnit.h:464
const uint64_t Version
Definition: InstrProf.h:895
uint8_t getDwarfOffsetByteSize() const
Definition: DWARFUnit.h:340
uint32_t getLineTableOffset() const
Definition: DWARFUnit.h:532