LLVM  9.0.0svn
DWARFUnit.cpp
Go to the documentation of this file.
1 //===- DWARFUnit.cpp ------------------------------------------------------===//
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 
10 #include "llvm/ADT/SmallString.h"
11 #include "llvm/ADT/StringRef.h"
22 #include "llvm/Support/Errc.h"
23 #include "llvm/Support/Path.h"
24 #include "llvm/Support/WithColor.h"
25 #include <algorithm>
26 #include <cassert>
27 #include <cstddef>
28 #include <cstdint>
29 #include <cstdio>
30 #include <utility>
31 #include <vector>
32 
33 using namespace llvm;
34 using namespace dwarf;
35 
37  const DWARFSection &Section,
39  const DWARFObject &D = C.getDWARFObj();
40  addUnitsImpl(C, D, Section, C.getDebugAbbrev(), &D.getRangeSection(),
43  D.getLineSection(), D.isLittleEndian(), false, false,
44  SectionKind);
45 }
46 
48  const DWARFSection &DWOSection,
50  bool Lazy) {
51  const DWARFObject &D = C.getDWARFObj();
52  addUnitsImpl(C, D, DWOSection, C.getDebugAbbrevDWO(), &D.getRangeDWOSection(),
55  D.getLineDWOSection(), C.isLittleEndian(), true, Lazy,
56  SectionKind);
57 }
58 
59 void DWARFUnitVector::addUnitsImpl(
61  const DWARFDebugAbbrev *DA, const DWARFSection *RS,
62  const DWARFSection *LocSection, StringRef SS, const DWARFSection &SOS,
63  const DWARFSection *AOS, const DWARFSection &LS, bool LE, bool IsDWO,
64  bool Lazy, DWARFSectionKind SectionKind) {
65  DWARFDataExtractor Data(Obj, Section, LE, 0);
66  // Lazy initialization of Parser, now that we have all section info.
67  if (!Parser) {
68  Parser = [=, &Context, &Obj, &Section, &SOS,
69  &LS](uint32_t Offset, DWARFSectionKind SectionKind,
70  const DWARFSection *CurSection,
71  const DWARFUnitIndex::Entry *IndexEntry)
72  -> std::unique_ptr<DWARFUnit> {
73  const DWARFSection &InfoSection = CurSection ? *CurSection : Section;
74  DWARFDataExtractor Data(Obj, InfoSection, LE, 0);
75  if (!Data.isValidOffset(Offset))
76  return nullptr;
77  const DWARFUnitIndex *Index = nullptr;
78  if (IsDWO)
79  Index = &getDWARFUnitIndex(Context, SectionKind);
80  DWARFUnitHeader Header;
81  if (!Header.extract(Context, Data, &Offset, SectionKind, Index,
82  IndexEntry))
83  return nullptr;
84  std::unique_ptr<DWARFUnit> U;
85  if (Header.isTypeUnit())
86  U = llvm::make_unique<DWARFTypeUnit>(Context, InfoSection, Header, DA,
87  RS, LocSection, SS, SOS, AOS, LS,
88  LE, IsDWO, *this);
89  else
90  U = llvm::make_unique<DWARFCompileUnit>(Context, InfoSection, Header,
91  DA, RS, LocSection, SS, SOS,
92  AOS, LS, LE, IsDWO, *this);
93  return U;
94  };
95  }
96  if (Lazy)
97  return;
98  // Find a reasonable insertion point within the vector. We skip over
99  // (a) units from a different section, (b) units from the same section
100  // but with lower offset-within-section. This keeps units in order
101  // within a section, although not necessarily within the object file,
102  // even if we do lazy parsing.
103  auto I = this->begin();
104  uint32_t Offset = 0;
105  while (Data.isValidOffset(Offset)) {
106  if (I != this->end() &&
107  (&(*I)->getInfoSection() != &Section || (*I)->getOffset() == Offset)) {
108  ++I;
109  continue;
110  }
111  auto U = Parser(Offset, SectionKind, &Section, nullptr);
112  // If parsing failed, we're done with this section.
113  if (!U)
114  break;
115  Offset = U->getNextUnitOffset();
116  I = std::next(this->insert(I, std::move(U)));
117  }
118 }
119 
120 DWARFUnit *DWARFUnitVector::addUnit(std::unique_ptr<DWARFUnit> Unit) {
121  auto I = std::upper_bound(begin(), end(), Unit,
122  [](const std::unique_ptr<DWARFUnit> &LHS,
123  const std::unique_ptr<DWARFUnit> &RHS) {
124  return LHS->getOffset() < RHS->getOffset();
125  });
126  return this->insert(I, std::move(Unit))->get();
127 }
128 
130  auto end = begin() + getNumInfoUnits();
131  auto *CU =
132  std::upper_bound(begin(), end, Offset,
133  [](uint32_t LHS, const std::unique_ptr<DWARFUnit> &RHS) {
134  return LHS < RHS->getNextUnitOffset();
135  });
136  if (CU != end && (*CU)->getOffset() <= Offset)
137  return CU->get();
138  return nullptr;
139 }
140 
141 DWARFUnit *
143  const auto *CUOff = E.getOffset(DW_SECT_INFO);
144  if (!CUOff)
145  return nullptr;
146 
147  auto Offset = CUOff->Offset;
148  auto end = begin() + getNumInfoUnits();
149 
150  auto *CU =
151  std::upper_bound(begin(), end, CUOff->Offset,
152  [](uint32_t LHS, const std::unique_ptr<DWARFUnit> &RHS) {
153  return LHS < RHS->getNextUnitOffset();
154  });
155  if (CU != end && (*CU)->getOffset() <= Offset)
156  return CU->get();
157 
158  if (!Parser)
159  return nullptr;
160 
161  auto U = Parser(Offset, DW_SECT_INFO, nullptr, &E);
162  if (!U)
163  U = nullptr;
164 
165  auto *NewCU = U.get();
166  this->insert(CU, std::move(U));
167  ++NumInfoUnits;
168  return NewCU;
169 }
170 
172  const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA,
173  const DWARFSection *RS, const DWARFSection *LocSection,
174  StringRef SS, const DWARFSection &SOS,
175  const DWARFSection *AOS, const DWARFSection &LS, bool LE,
176  bool IsDWO, const DWARFUnitVector &UnitVector)
177  : Context(DC), InfoSection(Section), Header(Header), Abbrev(DA),
178  RangeSection(RS), LocSection(LocSection), LineSection(LS),
179  StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS),
180  isLittleEndian(LE), IsDWO(IsDWO), UnitVector(UnitVector) {
181  clear();
182  // For split DWARF we only need to keep track of the location list section's
183  // data (no relocations), and if we are reading a package file, we need to
184  // adjust the location list data based on the index entries.
185  if (IsDWO) {
186  LocSectionData = LocSection->Data;
187  if (auto *IndexEntry = Header.getIndexEntry())
188  if (const auto *C = IndexEntry->getOffset(DW_SECT_LOC))
189  LocSectionData = LocSectionData.substr(C->Offset, C->Length);
190  }
191 }
192 
193 DWARFUnit::~DWARFUnit() = default;
194 
196  return DWARFDataExtractor(Context.getDWARFObj(), InfoSection, isLittleEndian,
198 }
199 
202  if (IsDWO) {
203  auto R = Context.info_section_units();
204  auto I = R.begin();
205  // Surprising if a DWO file has more than one skeleton unit in it - this
206  // probably shouldn't be valid, but if a use case is found, here's where to
207  // support it (probably have to linearly search for the matching skeleton CU
208  // here)
209  if (I != R.end() && std::next(I) == R.end())
210  return (*I)->getAddrOffsetSectionItem(Index);
211  }
212  uint32_t Offset = AddrOffsetSectionBase + Index * getAddressByteSize();
213  if (AddrOffsetSection->Data.size() < Offset + getAddressByteSize())
214  return None;
215  DWARFDataExtractor DA(Context.getDWARFObj(), *AddrOffsetSection,
216  isLittleEndian, getAddressByteSize());
217  uint64_t Section;
218  uint64_t Address = DA.getRelocatedAddress(&Offset, &Section);
219  return {{Address, Section}};
220 }
221 
223  if (!StringOffsetsTableContribution)
224  return None;
225  unsigned ItemSize = getDwarfStringOffsetsByteSize();
226  uint32_t Offset = getStringOffsetsBase() + Index * ItemSize;
227  if (StringOffsetSection.Data.size() < Offset + ItemSize)
228  return None;
229  DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection,
230  isLittleEndian, 0);
231  return DA.getRelocatedValue(ItemSize, &Offset);
232 }
233 
235  const DWARFDataExtractor &debug_info,
236  uint32_t *offset_ptr,
238  const DWARFUnitIndex *Index,
239  const DWARFUnitIndex::Entry *Entry) {
240  Offset = *offset_ptr;
241  IndexEntry = Entry;
242  if (!IndexEntry && Index)
243  IndexEntry = Index->getFromOffset(*offset_ptr);
244  Length = debug_info.getU32(offset_ptr);
246  unsigned SizeOfLength = 4;
247  if (Length == 0xffffffff) {
248  Length = debug_info.getU64(offset_ptr);
250  SizeOfLength = 8;
251  }
252  FormParams.Version = debug_info.getU16(offset_ptr);
253  if (FormParams.Version >= 5) {
254  UnitType = debug_info.getU8(offset_ptr);
255  FormParams.AddrSize = debug_info.getU8(offset_ptr);
256  AbbrOffset = debug_info.getRelocatedValue(FormParams.getDwarfOffsetByteSize(), offset_ptr);
257  } else {
258  AbbrOffset = debug_info.getRelocatedValue(FormParams.getDwarfOffsetByteSize(), offset_ptr);
259  FormParams.AddrSize = debug_info.getU8(offset_ptr);
260  // Fake a unit type based on the section type. This isn't perfect,
261  // but distinguishing compile and type units is generally enough.
262  if (SectionKind == DW_SECT_TYPES)
263  UnitType = DW_UT_type;
264  else
265  UnitType = DW_UT_compile;
266  }
267  if (IndexEntry) {
268  if (AbbrOffset)
269  return false;
270  auto *UnitContrib = IndexEntry->getOffset();
271  if (!UnitContrib || UnitContrib->Length != (Length + 4))
272  return false;
273  auto *AbbrEntry = IndexEntry->getOffset(DW_SECT_ABBREV);
274  if (!AbbrEntry)
275  return false;
276  AbbrOffset = AbbrEntry->Offset;
277  }
278  if (isTypeUnit()) {
279  TypeHash = debug_info.getU64(offset_ptr);
280  TypeOffset = debug_info.getU32(offset_ptr);
281  } else if (UnitType == DW_UT_split_compile || UnitType == DW_UT_skeleton)
282  DWOId = debug_info.getU64(offset_ptr);
283 
284  // Header fields all parsed, capture the size of this unit header.
285  assert(*offset_ptr - Offset <= 255 && "unexpected header size");
286  Size = uint8_t(*offset_ptr - Offset);
287 
288  // Type offset is unit-relative; should be after the header and before
289  // the end of the current unit.
290  bool TypeOffsetOK =
291  !isTypeUnit()
292  ? true
293  : TypeOffset >= Size && TypeOffset < getLength() + SizeOfLength;
294  bool LengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1);
295  bool VersionOK = DWARFContext::isSupportedVersion(getVersion());
296  bool AddrSizeOK = getAddressByteSize() == 4 || getAddressByteSize() == 8;
297 
298  if (!LengthOK || !VersionOK || !AddrSizeOK || !TypeOffsetOK)
299  return false;
300 
301  // Keep track of the highest DWARF version we encounter across all units.
303  return true;
304 }
305 
306 // Parse the rangelist table header, including the optional array of offsets
307 // following it (DWARF v5 and later).
310  // TODO: Support DWARF64
311  // We are expected to be called with Offset 0 or pointing just past the table
312  // header, which is 12 bytes long for DWARF32.
313  if (Offset > 0) {
314  if (Offset < 12U)
315  return createStringError(errc::invalid_argument, "Did not detect a valid"
316  " range list table with base = 0x%" PRIu32,
317  Offset);
318  Offset -= 12U;
319  }
321  if (Error E = Table.extractHeaderAndOffsets(DA, &Offset))
322  return std::move(E);
323  return Table;
324 }
325 
327  DWARFDebugRangeList &RangeList) const {
328  // Require that compile unit is extracted.
329  assert(!DieArray.empty());
330  DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection,
331  isLittleEndian, getAddressByteSize());
332  uint32_t ActualRangeListOffset = RangeSectionBase + RangeListOffset;
333  return RangeList.extract(RangesData, &ActualRangeListOffset);
334 }
335 
337  Abbrevs = nullptr;
338  BaseAddr.reset();
339  RangeSectionBase = 0;
340  AddrOffsetSectionBase = 0;
341  clearDIEs(false);
342  DWO.reset();
343 }
344 
346  return dwarf::toString(getUnitDIE().find(DW_AT_comp_dir), nullptr);
347 }
348 
349 void DWARFUnit::extractDIEsToVector(
350  bool AppendCUDie, bool AppendNonCUDies,
351  std::vector<DWARFDebugInfoEntry> &Dies) const {
352  if (!AppendCUDie && !AppendNonCUDies)
353  return;
354 
355  // Set the offset to that of the first DIE and calculate the start of the
356  // next compilation unit header.
357  uint32_t DIEOffset = getOffset() + getHeaderSize();
358  uint32_t NextCUOffset = getNextUnitOffset();
360  DWARFDataExtractor DebugInfoData = getDebugInfoExtractor();
361  uint32_t Depth = 0;
362  bool IsCUDie = true;
363 
364  while (DIE.extractFast(*this, &DIEOffset, DebugInfoData, NextCUOffset,
365  Depth)) {
366  if (IsCUDie) {
367  if (AppendCUDie)
368  Dies.push_back(DIE);
369  if (!AppendNonCUDies)
370  break;
371  // The average bytes per DIE entry has been seen to be
372  // around 14-20 so let's pre-reserve the needed memory for
373  // our DIE entries accordingly.
374  Dies.reserve(Dies.size() + getDebugInfoSize() / 14);
375  IsCUDie = false;
376  } else {
377  Dies.push_back(DIE);
378  }
379 
380  if (const DWARFAbbreviationDeclaration *AbbrDecl =
382  // Normal DIE
383  if (AbbrDecl->hasChildren())
384  ++Depth;
385  } else {
386  // NULL DIE.
387  if (Depth > 0)
388  --Depth;
389  if (Depth == 0)
390  break; // We are done with this compile unit!
391  }
392  }
393 
394  // Give a little bit of info if we encounter corrupt DWARF (our offset
395  // should always terminate at or before the start of the next compilation
396  // unit header).
397  if (DIEOffset > NextCUOffset)
398  WithColor::warning() << format("DWARF compile unit extends beyond its "
399  "bounds cu 0x%8.8x at 0x%8.8x\n",
400  getOffset(), DIEOffset);
401 }
402 
403 size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
404  if ((CUDieOnly && !DieArray.empty()) ||
405  DieArray.size() > 1)
406  return 0; // Already parsed.
407 
408  bool HasCUDie = !DieArray.empty();
409  extractDIEsToVector(!HasCUDie, !CUDieOnly, DieArray);
410 
411  if (DieArray.empty())
412  return 0;
413 
414  // If CU DIE was just parsed, copy several attribute values from it.
415  if (!HasCUDie) {
416  DWARFDie UnitDie = getUnitDIE();
417  if (Optional<uint64_t> DWOId = toUnsigned(UnitDie.find(DW_AT_GNU_dwo_id)))
418  Header.setDWOId(*DWOId);
419  if (!IsDWO) {
420  assert(AddrOffsetSectionBase == 0);
421  assert(RangeSectionBase == 0);
422  AddrOffsetSectionBase = toSectionOffset(UnitDie.find(DW_AT_addr_base), 0);
423  if (!AddrOffsetSectionBase)
424  AddrOffsetSectionBase =
425  toSectionOffset(UnitDie.find(DW_AT_GNU_addr_base), 0);
426  RangeSectionBase = toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0);
427  }
428 
429  // In general, in DWARF v5 and beyond we derive the start of the unit's
430  // contribution to the string offsets table from the unit DIE's
431  // DW_AT_str_offsets_base attribute. Split DWARF units do not use this
432  // attribute, so we assume that there is a contribution to the string
433  // offsets table starting at offset 0 of the debug_str_offsets.dwo section.
434  // In both cases we need to determine the format of the contribution,
435  // which may differ from the unit's format.
436  DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection,
437  isLittleEndian, 0);
438  if (IsDWO || getVersion() >= 5) {
439  auto StringOffsetOrError =
442  if (!StringOffsetOrError) {
443  WithColor::error() << "invalid contribution to string offsets table in section .debug_str_offsets[.dwo]: "
444  << toString(StringOffsetOrError.takeError()) << '\n';
445  } else {
446  StringOffsetsTableContribution = *StringOffsetOrError;
447  }
448  }
449 
450  // DWARF v5 uses the .debug_rnglists and .debug_rnglists.dwo sections to
451  // describe address ranges.
452  if (getVersion() >= 5) {
453  if (IsDWO)
455  else
457  toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0));
458  if (RangeSection->Data.size()) {
459  // Parse the range list table header. Individual range lists are
460  // extracted lazily.
461  DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
462  isLittleEndian, 0);
463  if (auto TableOrError =
464  parseRngListTableHeader(RangesDA, RangeSectionBase))
465  RngListTable = TableOrError.get();
466  else
467  WithColor::error() << "parsing a range list table: "
468  << toString(TableOrError.takeError())
469  << '\n';
470 
471  // In a split dwarf unit, there is no DW_AT_rnglists_base attribute.
472  // Adjust RangeSectionBase to point past the table header.
473  if (IsDWO && RngListTable)
474  RangeSectionBase = RngListTable->getHeaderSize();
475  }
476  }
477 
478  // Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for
479  // skeleton CU DIE, so that DWARF users not aware of it are not broken.
480  }
481 
482  return DieArray.size();
483 }
484 
485 bool DWARFUnit::parseDWO() {
486  if (IsDWO)
487  return false;
488  if (DWO.get())
489  return false;
490  DWARFDie UnitDie = getUnitDIE();
491  if (!UnitDie)
492  return false;
493  auto DWOFileName = dwarf::toString(UnitDie.find(DW_AT_GNU_dwo_name));
494  if (!DWOFileName)
495  return false;
496  auto CompilationDir = dwarf::toString(UnitDie.find(DW_AT_comp_dir));
497  SmallString<16> AbsolutePath;
498  if (sys::path::is_relative(*DWOFileName) && CompilationDir &&
499  *CompilationDir) {
500  sys::path::append(AbsolutePath, *CompilationDir);
501  }
502  sys::path::append(AbsolutePath, *DWOFileName);
503  auto DWOId = getDWOId();
504  if (!DWOId)
505  return false;
506  auto DWOContext = Context.getDWOContext(AbsolutePath);
507  if (!DWOContext)
508  return false;
509 
510  DWARFCompileUnit *DWOCU = DWOContext->getDWOCompileUnitForHash(*DWOId);
511  if (!DWOCU)
512  return false;
513  DWO = std::shared_ptr<DWARFCompileUnit>(std::move(DWOContext), DWOCU);
514  // Share .debug_addr and .debug_ranges section with compile unit in .dwo
515  DWO->setAddrOffsetSection(AddrOffsetSection, AddrOffsetSectionBase);
516  if (getVersion() >= 5) {
517  DWO->setRangesSection(&Context.getDWARFObj().getRnglistsDWOSection(), 0);
518  DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
519  isLittleEndian, 0);
520  if (auto TableOrError = parseRngListTableHeader(RangesDA, RangeSectionBase))
521  DWO->RngListTable = TableOrError.get();
522  else
523  WithColor::error() << "parsing a range list table: "
524  << toString(TableOrError.takeError())
525  << '\n';
526  if (DWO->RngListTable)
527  DWO->RangeSectionBase = DWO->RngListTable->getHeaderSize();
528  } else {
529  auto DWORangesBase = UnitDie.getRangesBaseAttribute();
530  DWO->setRangesSection(RangeSection, DWORangesBase ? *DWORangesBase : 0);
531  }
532 
533  return true;
534 }
535 
536 void DWARFUnit::clearDIEs(bool KeepCUDie) {
537  if (DieArray.size() > (unsigned)KeepCUDie) {
538  DieArray.resize((unsigned)KeepCUDie);
539  DieArray.shrink_to_fit();
540  }
541 }
542 
545  if (getVersion() <= 4) {
546  DWARFDebugRangeList RangeList;
547  if (Error E = extractRangeList(Offset, RangeList))
548  return std::move(E);
549  return RangeList.getAbsoluteRanges(getBaseAddress());
550  }
551  if (RngListTable) {
552  DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection,
553  isLittleEndian, RngListTable->getAddrSize());
554  auto RangeListOrError = RngListTable->findList(RangesData, Offset);
555  if (RangeListOrError)
556  return RangeListOrError.get().getAbsoluteRanges(getBaseAddress(), *this);
557  return RangeListOrError.takeError();
558  }
559 
561  "missing or invalid range list table");
562 }
563 
566  if (auto Offset = getRnglistOffset(Index))
567  return findRnglistFromOffset(*Offset + RangeSectionBase);
568 
569  if (RngListTable)
571  "invalid range list table index %d", Index);
572  else
574  "missing or invalid range list table");
575 }
576 
578  DWARFDie UnitDie = getUnitDIE();
579  if (!UnitDie)
580  return createStringError(errc::invalid_argument, "No unit DIE");
581 
582  // First, check if unit DIE describes address ranges for the whole unit.
583  auto CUDIERangesOrError = UnitDie.getAddressRanges();
584  if (!CUDIERangesOrError)
586  "decoding address ranges: %s",
587  toString(CUDIERangesOrError.takeError()).c_str());
588  return *CUDIERangesOrError;
589 }
590 
592  if (Die.isSubroutineDIE()) {
593  auto DIERangesOrError = Die.getAddressRanges();
594  if (DIERangesOrError) {
595  for (const auto &R : DIERangesOrError.get()) {
596  // Ignore 0-sized ranges.
597  if (R.LowPC == R.HighPC)
598  continue;
599  auto B = AddrDieMap.upper_bound(R.LowPC);
600  if (B != AddrDieMap.begin() && R.LowPC < (--B)->second.first) {
601  // The range is a sub-range of existing ranges, we need to split the
602  // existing range.
603  if (R.HighPC < B->second.first)
604  AddrDieMap[R.HighPC] = B->second;
605  if (R.LowPC > B->first)
606  AddrDieMap[B->first].first = R.LowPC;
607  }
608  AddrDieMap[R.LowPC] = std::make_pair(R.HighPC, Die);
609  }
610  } else
611  llvm::consumeError(DIERangesOrError.takeError());
612  }
613  // Parent DIEs are added to the AddrDieMap prior to the Children DIEs to
614  // simplify the logic to update AddrDieMap. The child's range will always
615  // be equal or smaller than the parent's range. With this assumption, when
616  // adding one range into the map, it will at most split a range into 3
617  // sub-ranges.
618  for (DWARFDie Child = Die.getFirstChild(); Child; Child = Child.getSibling())
619  updateAddressDieMap(Child);
620 }
621 
623  extractDIEsIfNeeded(false);
624  if (AddrDieMap.empty())
626  auto R = AddrDieMap.upper_bound(Address);
627  if (R == AddrDieMap.begin())
628  return DWARFDie();
629  // upper_bound's previous item contains Address.
630  --R;
631  if (Address >= R->second.first)
632  return DWARFDie();
633  return R->second.second;
634 }
635 
636 void
638  SmallVectorImpl<DWARFDie> &InlinedChain) {
639  assert(InlinedChain.empty());
640  // Try to look for subprogram DIEs in the DWO file.
641  parseDWO();
642  // First, find the subroutine that contains the given address (the leaf
643  // of inlined chain).
644  DWARFDie SubroutineDIE =
645  (DWO ? *DWO : *this).getSubroutineForAddress(Address);
646 
647  if (!SubroutineDIE)
648  return;
649 
650  while (!SubroutineDIE.isSubprogramDIE()) {
651  if (SubroutineDIE.getTag() == DW_TAG_inlined_subroutine)
652  InlinedChain.push_back(SubroutineDIE);
653  SubroutineDIE = SubroutineDIE.getParent();
654  }
655  InlinedChain.push_back(SubroutineDIE);
656 }
657 
660  if (Kind == DW_SECT_INFO)
661  return Context.getCUIndex();
662  assert(Kind == DW_SECT_TYPES);
663  return Context.getTUIndex();
664 }
665 
667  if (!Die)
668  return DWARFDie();
669  const uint32_t Depth = Die->getDepth();
670  // Unit DIEs always have a depth of zero and never have parents.
671  if (Depth == 0)
672  return DWARFDie();
673  // Depth of 1 always means parent is the compile/type unit.
674  if (Depth == 1)
675  return getUnitDIE();
676  // Look for previous DIE with a depth that is one less than the Die's depth.
677  const uint32_t ParentDepth = Depth - 1;
678  for (uint32_t I = getDIEIndex(Die) - 1; I > 0; --I) {
679  if (DieArray[I].getDepth() == ParentDepth)
680  return DWARFDie(this, &DieArray[I]);
681  }
682  return DWARFDie();
683 }
684 
686  if (!Die)
687  return DWARFDie();
688  uint32_t Depth = Die->getDepth();
689  // Unit DIEs always have a depth of zero and never have siblings.
690  if (Depth == 0)
691  return DWARFDie();
692  // NULL DIEs don't have siblings.
693  if (Die->getAbbreviationDeclarationPtr() == nullptr)
694  return DWARFDie();
695 
696  // Find the next DIE whose depth is the same as the Die's depth.
697  for (size_t I = getDIEIndex(Die) + 1, EndIdx = DieArray.size(); I < EndIdx;
698  ++I) {
699  if (DieArray[I].getDepth() == Depth)
700  return DWARFDie(this, &DieArray[I]);
701  }
702  return DWARFDie();
703 }
704 
706  if (!Die)
707  return DWARFDie();
708  uint32_t Depth = Die->getDepth();
709  // Unit DIEs always have a depth of zero and never have siblings.
710  if (Depth == 0)
711  return DWARFDie();
712 
713  // Find the previous DIE whose depth is the same as the Die's depth.
714  for (size_t I = getDIEIndex(Die); I > 0;) {
715  --I;
716  if (DieArray[I].getDepth() == Depth - 1)
717  return DWARFDie();
718  if (DieArray[I].getDepth() == Depth)
719  return DWARFDie(this, &DieArray[I]);
720  }
721  return DWARFDie();
722 }
723 
725  if (!Die->hasChildren())
726  return DWARFDie();
727 
728  // We do not want access out of bounds when parsing corrupted debug data.
729  size_t I = getDIEIndex(Die) + 1;
730  if (I >= DieArray.size())
731  return DWARFDie();
732  return DWARFDie(this, &DieArray[I]);
733 }
734 
736  if (!Die->hasChildren())
737  return DWARFDie();
738 
739  uint32_t Depth = Die->getDepth();
740  for (size_t I = getDIEIndex(Die) + 1, EndIdx = DieArray.size(); I < EndIdx;
741  ++I) {
742  if (DieArray[I].getDepth() == Depth + 1 &&
743  DieArray[I].getTag() == dwarf::DW_TAG_null)
744  return DWARFDie(this, &DieArray[I]);
745  assert(DieArray[I].getDepth() > Depth && "Not processing children?");
746  }
747  return DWARFDie();
748 }
749 
751  if (!Abbrevs)
752  Abbrevs = Abbrev->getAbbreviationDeclarationSet(Header.getAbbrOffset());
753  return Abbrevs;
754 }
755 
757  if (BaseAddr)
758  return BaseAddr;
759 
760  DWARFDie UnitDie = getUnitDIE();
761  Optional<DWARFFormValue> PC = UnitDie.find({DW_AT_low_pc, DW_AT_entry_pc});
762  BaseAddr = toSectionedAddress(PC);
763  return BaseAddr;
764 }
765 
768  DWARFDataExtractor &DA) {
769  uint8_t EntrySize = getDwarfOffsetByteSize();
770  // In order to ensure that we don't read a partial record at the end of
771  // the section we validate for a multiple of the entry size.
772  uint64_t ValidationSize = alignTo(Size, EntrySize);
773  // Guard against overflow.
774  if (ValidationSize >= Size)
775  if (DA.isValidOffsetForDataOfSize((uint32_t)Base, ValidationSize))
776  return *this;
777  return createStringError(errc::invalid_argument, "length exceeds section size");
778 }
779 
780 // Look for a DWARF64-formatted contribution to the string offsets table
781 // starting at a given offset and record it in a descriptor.
784  if (!DA.isValidOffsetForDataOfSize(Offset, 16))
785  return createStringError(errc::invalid_argument, "section offset exceeds section size");
786 
787  if (DA.getU32(&Offset) != 0xffffffff)
788  return createStringError(errc::invalid_argument, "32 bit contribution referenced from a 64 bit unit");
789 
790  uint64_t Size = DA.getU64(&Offset);
791  uint8_t Version = DA.getU16(&Offset);
792  (void)DA.getU16(&Offset); // padding
793  // The encoded length includes the 2-byte version field and the 2-byte
794  // padding, so we need to subtract them out when we populate the descriptor.
795  return StrOffsetsContributionDescriptor(Offset, Size - 4, Version, DWARF64);
796 }
797 
798 // Look for a DWARF32-formatted contribution to the string offsets table
799 // starting at a given offset and record it in a descriptor.
802  if (!DA.isValidOffsetForDataOfSize(Offset, 8))
803  return createStringError(errc::invalid_argument, "section offset exceeds section size");
804 
805  uint32_t ContributionSize = DA.getU32(&Offset);
806  if (ContributionSize >= 0xfffffff0)
807  return createStringError(errc::invalid_argument, "invalid length");
808 
809  uint8_t Version = DA.getU16(&Offset);
810  (void)DA.getU16(&Offset); // padding
811  // The encoded length includes the 2-byte version field and the 2-byte
812  // padding, so we need to subtract them out when we populate the descriptor.
813  return StrOffsetsContributionDescriptor(Offset, ContributionSize - 4, Version,
814  DWARF32);
815 }
816 
820  uint64_t Offset) {
822  switch (Format) {
824  if (Offset < 16)
825  return createStringError(errc::invalid_argument, "insufficient space for 64 bit header prefix");
826  auto DescOrError = parseDWARF64StringOffsetsTableHeader(DA, (uint32_t)Offset - 16);
827  if (!DescOrError)
828  return DescOrError.takeError();
829  Desc = *DescOrError;
830  break;
831  }
833  if (Offset < 8)
834  return createStringError(errc::invalid_argument, "insufficient space for 32 bit header prefix");
835  auto DescOrError = parseDWARF32StringOffsetsTableHeader(DA, (uint32_t)Offset - 8);
836  if (!DescOrError)
837  return DescOrError.takeError();
838  Desc = *DescOrError;
839  break;
840  }
841  }
842  return Desc.validateContributionSize(DA);
843 }
844 
847  uint64_t Offset;
848  if (IsDWO) {
849  Offset = 0;
850  if (DA.getData().data() == nullptr)
851  return None;
852  } else {
853  auto OptOffset = toSectionOffset(getUnitDIE().find(DW_AT_str_offsets_base));
854  if (!OptOffset)
855  return None;
856  Offset = *OptOffset;
857  }
858  auto DescOrError = parseDWARFStringOffsetsTableHeader(DA, Header.getFormat(), Offset);
859  if (!DescOrError)
860  return DescOrError.takeError();
861  return *DescOrError;
862 }
863 
866  uint64_t Offset = 0;
867  auto IndexEntry = Header.getIndexEntry();
868  const auto *C =
869  IndexEntry ? IndexEntry->getOffset(DW_SECT_STR_OFFSETS) : nullptr;
870  if (C)
871  Offset = C->Offset;
872  if (getVersion() >= 5) {
873  if (DA.getData().data() == nullptr)
874  return None;
875  Offset += Header.getFormat() == dwarf::DwarfFormat::DWARF32 ? 8 : 16;
876  // Look for a valid contribution at the given offset.
877  auto DescOrError = parseDWARFStringOffsetsTableHeader(DA, Header.getFormat(), Offset);
878  if (!DescOrError)
879  return DescOrError.takeError();
880  return *DescOrError;
881  }
882  // Prior to DWARF v5, we derive the contribution size from the
883  // index table (in a package file). In a .dwo file it is simply
884  // the length of the string offsets section.
885  if (!IndexEntry)
886  return {
888  {0, StringOffsetSection.Data.size(), 4, DWARF32})};
889  if (C)
891  {C->Offset, C->Length, 4, DWARF32})};
892  return None;
893 }
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
Definition: DWARFUnit.cpp:750
const DWARFUnitIndex & getTUIndex()
uint64_t CallInst * C
void getInlinedChainForAddress(uint64_t Address, SmallVectorImpl< DWARFDie > &InlinedChain)
getInlinedChainForAddress - fetches inlined chain for a given address.
Definition: DWARFUnit.cpp:637
virtual ~DWARFUnit()
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
virtual const DWARFSection & getAddrSection() const
Definition: DWARFObject.h:69
static Expected< StrOffsetsContributionDescriptor > parseDWARFStringOffsetsTableHeader(DWARFDataExtractor &DA, llvm::dwarf::DwarfFormat Format, uint64_t Offset)
Definition: DWARFUnit.cpp:818
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition: Dwarf.h:500
LLVMContext & Context
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
virtual const DWARFSection & getLocDWOSection() const
Definition: DWARFObject.h:62
Expected< Optional< StrOffsetsContributionDescriptor > > determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA)
Find the unit&#39;s contribution to the string offsets table and determine its length and form...
Definition: DWARFUnit.cpp:865
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Represents base address of the CU.
Definition: DWARFUnit.h:168
bool isSubprogramDIE() const
Returns true if DIE represents a subprogram (not inlined).
Definition: DWARFDie.cpp:359
bool isTypeUnit() const
Definition: DWARFUnit.h:290
std::shared_ptr< DWARFContext > getDWOContext(StringRef AbsolutePath)
static raw_ostream & error()
Convenience method for printing "error: " to stderr.
Definition: WithColor.cpp:60
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:123
virtual const DWARFSection & getLocSection() const
Definition: DWARFObject.h:40
DWARFDie getSibling(const DWARFDebugInfoEntry *Die)
Definition: DWARFUnit.cpp:685
unsigned second
static raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
Definition: WithColor.cpp:62
StringRef getData() const
Get the data pointed to by this extractor.
Definition: DataExtractor.h:54
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Definition: MathExtras.h:684
virtual const DWARFSection & getRnglistsDWOSection() const
Definition: DWARFObject.h:68
block Block Frequency true
Expected< StrOffsetsContributionDescriptor > validateContributionSize(DWARFDataExtractor &DA)
Determine whether a contribution to the string offsets table is consistent with the relevant section ...
Definition: DWARFUnit.cpp:767
const DWARFDebugAbbrev * getDebugAbbrevDWO()
Get a pointer to the parsed dwo abbreviations object.
uint8_t getDwarfStringOffsetsByteSize() const
Definition: DWARFUnit.h:334
uint16_t getU16(uint32_t *offset_ptr) const
Extract a uint16_t value from *offset_ptr.
void addUnitsForSection(DWARFContext &C, const DWARFSection &Section, DWARFSectionKind SectionKind)
Read units from a .debug_info or .debug_types section.
Definition: DWARFUnit.cpp:36
DWARFDie getSubroutineForAddress(uint64_t Address)
Returns subprogram DIE with address range encompassing the provided address.
Definition: DWARFUnit.cpp:622
virtual bool isLittleEndian() const =0
uint32_t getNextUnitOffset() const
Definition: DWARFUnit.h:291
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition: Path.cpp:455
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:171
std::string toString(Error E)
Write all error messages (if any) in E to a string.
Definition: Error.h:966
uint32_t getU32(uint32_t *offset_ptr) const
Extract a uint32_t value from *offset_ptr.
static ManagedStatic< DebugCounter > DC
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition: Dwarf.h:65
const char * getCompilationDir()
Definition: DWARFUnit.cpp:345
Optional< uint64_t > getRangesBaseAttribute() const
Extract the range base attribute from this DIE as absolute section offset.
Definition: DWARFDie.cpp:441
uint64_t getAbbrOffset() const
Definition: DWARFUnit.h:86
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:41
DWARFUnit * addUnit(std::unique_ptr< DWARFUnit > Unit)
Add an existing DWARFUnit to this UnitVector.
Definition: DWARFUnit.cpp:120
Error extractRangeList(uint32_t RangeListOffset, DWARFDebugRangeList &RangeList) const
Extract the range list referenced by this compile unit from the .debug_ranges section.
Definition: DWARFUnit.cpp:326
Tagged union holding either a T or a Error.
Definition: CachePruning.h:22
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:578
bool isTypeUnit() const
Definition: DWARFUnit.h:96
virtual const DWARFSection & getStringOffsetDWOSection() const
Definition: DWARFObject.h:64
uint8_t getAddressByteSize() const
Definition: DWARFUnit.h:283
Optional< object::SectionedAddress > toSectionedAddress(const Optional< DWARFFormValue > &V)
DWARFAddressRangesVector getAbsoluteRanges(llvm::Optional< object::SectionedAddress > BaseAddr) const
getAbsoluteRanges - Returns absolute address ranges defined by this range list.
LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:130
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:25
llvm::Optional< object::SectionedAddress > getBaseAddress()
Definition: DWARFUnit.cpp:756
const DWARFDebugAbbrev * getDebugAbbrev()
Get a pointer to the parsed DebugAbbrev object.
DWARFDie getLastChild(const DWARFDebugInfoEntry *Die)
Definition: DWARFUnit.cpp:735
uint16_t getVersion() const
Definition: DWARFUnit.h:282
DWARFDie getSibling() const
Get the sibling of this DIE object.
Definition: DWARFDie.cpp:636
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:565
DWARFDie getFirstChild(const DWARFDebugInfoEntry *Die)
Definition: DWARFUnit.cpp:724
unit_iterator_range info_section_units()
Get units from .debug_info in this context.
Definition: DWARFContext.h:137
Optional< uint64_t > toSectionOffset(const Optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an section offset.
bool isValidOffsetForDataOfSize(uint32_t offset, uint32_t length) const
Test the availability of length bytes of data from offset.
Utility class that carries the DWARF compile/type unit and the debug info entry in an object...
Definition: DWARFDie.h:42
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
virtual const DWARFSection & getStringOffsetSection() const
Definition: DWARFObject.h:55
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
DWARFSectionKind
A structured debug information entry.
Definition: DIE.h:700
bool isSubroutineDIE() const
Returns true if DIE represents a subprogram or an inlined subroutine.
Definition: DWARFDie.cpp:361
Optional< uint64_t > getDWOId()
Definition: DWARFUnit.h:400
Expected< DWARFAddressRangesVector > collectAddressRanges()
Definition: DWARFUnit.cpp:577
bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info, uint32_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
bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr)
Extracts a debug info entry, which is a child of a given unit, starting at a given offset...
const DWARFAbbreviationDeclarationSet * getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const
DWARFDie getParent(const DWARFDebugInfoEntry *Die)
Definition: DWARFUnit.cpp:666
virtual const DWARFSection & getLineDWOSection() const
Definition: DWARFObject.h:61
uint8_t getU8(uint32_t *offset_ptr) const
Extract a uint8_t value from *offset_ptr.
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
virtual StringRef getStringSection() const
Definition: DWARFObject.h:47
void setRangesSection(const DWARFSection *RS, uint32_t Base)
Definition: DWARFUnit.h:306
virtual StringRef getStringDWOSection() const
Definition: DWARFObject.h:63
uint32_t getHeaderSize() const
Size in bytes of the parsed unit header.
Definition: DWARFUnit.h:248
uint64_t getU64(uint32_t *offset_ptr) const
Extract a uint64_t value from *offset_ptr.
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:981
const DWARFUnitIndex & getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind)
Definition: DWARFUnit.cpp:658
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1213
DWARFUnit * getUnitForOffset(uint32_t Offset) const
Definition: DWARFUnit.cpp:129
Base class describing the header of any kind of "unit." Some information is specific to certain unit ...
Definition: DWARFUnit.h:46
dwarf::DwarfFormat getFormat() const
Definition: DWARFUnit.h:79
uint64_t getRelocatedValue(uint32_t Size, uint32_t *Off, uint64_t *SectionIndex=nullptr) const
Extracts a value and applies a relocation to the result if one exists for the given offset...
UnitType
Constants for unit types in DWARF v5.
Definition: Dwarf.h:331
DWARFUnit * getUnitForIndexEntry(const DWARFUnitIndex::Entry &E)
Definition: DWARFUnit.cpp:142
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:339
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
Definition: DWARFUnit.h:385
const DWARFAbbreviationDeclaration * getAbbreviationDeclarationPtr() const
void setDWOId(uint64_t Id)
Definition: DWARFUnit.h:88
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
const DWARFUnitIndex::Entry * getIndexEntry() const
Definition: DWARFUnit.h:92
static Expected< DWARFDebugRnglistTable > parseRngListTableHeader(DWARFDataExtractor &DA, uint32_t Offset)
Definition: DWARFUnit.cpp:309
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:47
static unsigned getDepth(const SmallVectorImpl< const MachineBasicBlock *> &Stack, const MachineBasicBlock *MBB)
Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint32_t *OffsetPtr)
Extract the table header and the array of offsets.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Definition: DWARFContext.h:58
Expected< Optional< StrOffsetsContributionDescriptor > > determineStringOffsetsTableContribution(DWARFDataExtractor &DA)
Find the unit&#39;s contribution to the string offsets table and determine its length and form...
Definition: DWARFUnit.cpp:846
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Describe a collection of units.
Definition: DWARFUnit.h:112
Optional< const char * > toString(const Optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
virtual const DWARFSection & getRnglistsSection() const
Definition: DWARFObject.h:49
uint32_t getLength() const
Definition: DWARFUnit.h:288
static Expected< StrOffsetsContributionDescriptor > parseDWARF64StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset)
Definition: DWARFUnit.cpp:783
DWARFDataExtractor getDebugInfoExtractor() const
Definition: DWARFUnit.cpp:195
virtual const DWARFSection & getLineSection() const
Definition: DWARFObject.h:45
static bool isSupportedVersion(unsigned version)
Definition: DWARFContext.h:338
virtual const DWARFSection & getRangeDWOSection() const
Definition: DWARFObject.h:67
dwarf::Tag getTag() const
Definition: DWARFDie.h:71
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:55
Expected< DWARFAddressRangesVector > findRnglistFromOffset(uint32_t Offset)
Return a vector of address ranges resulting from a (possibly encoded) range list starting at a given ...
Definition: DWARFUnit.cpp:544
#define I(x, y, z)
Definition: MD5.cpp:58
bool is_relative(const Twine &path, Style style=Style::native)
Is path relative?
Definition: Path.cpp:674
uint32_t getOffset() const
Definition: DWARFUnit.h:278
Expected< DWARFAddressRangesVector > getAddressRanges() const
Get the address ranges for this DIE.
Definition: DWARFDie.cpp:474
DWARFDie getPreviousSibling(const DWARFDebugInfoEntry *Die)
Definition: DWARFUnit.cpp:705
uint32_t Size
Definition: Profile.cpp:46
void updateAddressDieMap(DWARFDie Die)
Recursively update address to Die map.
Definition: DWARFUnit.cpp:591
bool isLittleEndian() const
Definition: DWARFContext.h:337
const DWARFObject & getDWARFObj() const
Definition: DWARFContext.h:116
bool isValidOffset(uint32_t offset) const
Test the validity of offset.
const DWARFUnitIndex & getCUIndex()
virtual const DWARFSection & getRangeSection() const
Definition: DWARFObject.h:48
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:122
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
DwarfFormat Format
Definition: Dwarf.h:503
Optional< DWARFFormValue > find(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE.
Definition: DWARFDie.cpp:366
static Expected< StrOffsetsContributionDescriptor > parseDWARF32StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset)
Definition: DWARFUnit.cpp:801
DWARFDebugInfoEntry - A DIE with only the minimum required data.
DWARFDie getFirstChild() const
Get the first child of this DIE object.
Definition: DWARFDie.cpp:648
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
const Entry * getFromOffset(uint32_t Offset) const
const SectionContribution * getOffset(DWARFSectionKind Sec) const
Optional< object::SectionedAddress > getAddrOffsetSectionItem(uint32_t Index) const
Definition: DWARFUnit.cpp:201
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:515
Optional< uint32_t > getRnglistOffset(uint32_t Index)
Return a rangelist&#39;s offset based on an index.
Definition: DWARFUnit.h:418
const uint64_t Version
Definition: InstrProf.h:984
uint8_t getDwarfOffsetByteSize() const
Definition: DWARFUnit.h:285
void setMaxVersionIfGreater(unsigned Version)
Definition: DWARFContext.h:245
StringRef LocSectionData
Definition: DWARFUnit.h:205
Optional< uint64_t > toUnsigned(const Optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an unsigned constant.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1163
Optional< uint64_t > getStringOffsetSectionItem(uint32_t Index) const
Definition: DWARFUnit.cpp:222
DWARFDie getParent() const
Get the parent of this DIE object.
Definition: DWARFDie.cpp:630
Error extract(const DWARFDataExtractor &data, uint32_t *offset_ptr)
auto upper_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range))
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1303