46 addUnitsImpl(
C,
D, Section,
C.getDebugAbbrev(), &
D.getRangesSection(),
47 &
D.getLocSection(),
D.getStrSection(),
48 D.getStrOffsetsSection(), &
D.getAddrSection(),
49 D.getLineSection(),
D.isLittleEndian(),
false,
false,
58 addUnitsImpl(
C,
D, DWOSection,
C.getDebugAbbrevDWO(), &
D.getRangesDWOSection(),
59 &
D.getLocDWOSection(),
D.getStrDWOSection(),
60 D.getStrOffsetsDWOSection(), &
D.getAddrSection(),
61 D.getLineDWOSection(),
C.isLittleEndian(),
true, Lazy,
65void DWARFUnitVector::addUnitsImpl(
74 Parser = [=, &Context, &Obj, &Section, &SOS,
78 -> std::unique_ptr<DWARFUnit> {
79 const DWARFSection &InfoSection = CurSection ? *CurSection : Section;
84 if (
Error ExtractErr =
86 Context.getWarningHandler()(std::move(ExtractErr));
89 if (!IndexEntry && IsDWO) {
93 if (Header.isTypeUnit())
94 IndexEntry =
Index.getFromHash(Header.getTypeHash());
95 else if (
auto DWOId = Header.getDWOId())
96 IndexEntry =
Index.getFromHash(*DWOId);
99 IndexEntry =
Index.getFromOffset(Header.getOffset());
102 if (
Error ApplicationErr = Header.applyIndexEntry(IndexEntry)) {
103 Context.getWarningHandler()(std::move(ApplicationErr));
107 std::unique_ptr<DWARFUnit>
U;
108 if (Header.isTypeUnit())
109 U = std::make_unique<DWARFTypeUnit>(
Context, InfoSection, Header, DA,
110 RS, LocSection, SS, SOS, AOS, LS,
113 U = std::make_unique<DWARFCompileUnit>(
Context, InfoSection, Header,
114 DA, RS, LocSection, SS, SOS,
115 AOS, LS, LE, IsDWO, *
this);
129 if (
I != this->
end() &&
130 (&(*I)->getInfoSection() != &Section || (*I)->getOffset() ==
Offset)) {
134 auto U = Parser(
Offset, SectionKind, &Section,
nullptr);
138 Offset =
U->getNextUnitOffset();
139 I = std::next(this->
insert(
I, std::move(U)));
145 [](
const std::unique_ptr<DWARFUnit> &LHS,
146 const std::unique_ptr<DWARFUnit> &RHS) {
147 return LHS->getOffset() < RHS->getOffset();
149 return this->
insert(
I, std::move(Unit))->get();
156 [](uint64_t LHS,
const std::unique_ptr<DWARFUnit> &RHS) {
157 return LHS < RHS->getNextUnitOffset();
167 const auto *CUOff = E.getContribution(Sec);
171 uint64_t
Offset = CUOff->getOffset();
181 std::upper_bound(
begin,
end, CUOff->getOffset(),
182 [](uint64_t LHS,
const std::unique_ptr<DWARFUnit> &RHS) {
183 return LHS < RHS->getNextUnitOffset();
191 auto U = Parser(
Offset, Sec, Section, &E);
195 auto *NewCU = U.get();
197 if (Sec == DW_SECT_INFO)
208 : Context(DC), InfoSection(Section), Header(Header), Abbrev(DA),
209 RangeSection(RS), LineSection(LS), StringSection(SS),
210 StringOffsetSection(SOS), AddrOffsetSection(AOS), IsLittleEndian(LE),
211 IsDWO(IsDWO), UnitVector(UnitVector) {
222std::optional<object::SectionedAddress>
224 if (!AddrOffsetSectionBase) {
225 auto R = Context.info_section_units();
231 return (*R.begin())->getAddrOffsetSectionItem(
Index);
242 uint64_t
Address = DA.getRelocatedAddress(&
Offset, &Section);
247 if (!StringOffsetsTableContribution)
249 "DW_FORM_strx used without a valid string offsets table",
253 if (StringOffsetSection.Data.size() <
Offset + ItemSize)
255 ", which is too large",
259 return DA.getRelocatedValue(ItemSize, &
Offset);
264 uint64_t *offset_ptr,
266 Offset = *offset_ptr;
268 IndexEntry =
nullptr;
269 std::tie(Length, FormParams.Format) =
271 FormParams.Version = debug_info.
getU16(offset_ptr, &Err);
272 if (FormParams.Version >= 5) {
273 UnitType = debug_info.
getU8(offset_ptr, &Err);
274 FormParams.AddrSize = debug_info.
getU8(offset_ptr, &Err);
276 FormParams.getDwarfOffsetByteSize(), offset_ptr,
nullptr, &Err);
279 FormParams.getDwarfOffsetByteSize(), offset_ptr,
nullptr, &Err);
280 FormParams.AddrSize = debug_info.
getU8(offset_ptr, &Err);
284 UnitType = DW_UT_type;
286 UnitType = DW_UT_compile;
289 TypeHash = debug_info.
getU64(offset_ptr, &Err);
291 offset_ptr, FormParams.getDwarfOffsetByteSize(), &Err);
292 }
else if (UnitType == DW_UT_split_compile || UnitType == DW_UT_skeleton)
293 DWOId = debug_info.
getU64(offset_ptr, &Err);
299 "DWARF unit at 0x%8.8" PRIx64
" cannot be parsed:", Offset),
303 assert(*offset_ptr - Offset <= 255 &&
"unexpected header size");
304 Size =
uint8_t(*offset_ptr - Offset);
309 "DWARF unit from offset 0x%8.8" PRIx64
" incl. "
310 "to offset 0x%8.8" PRIx64
" excl. "
311 "extends past section size 0x%8.8zx",
312 Offset, NextCUOffset, debug_info.
size());
317 "DWARF unit at offset 0x%8.8" PRIx64
" "
318 "has unsupported version %" PRIu16
", supported are 2-%u",
325 "DWARF type unit at offset "
327 "has its relocated type_offset 0x%8.8" PRIx64
" "
328 "pointing inside the header",
329 Offset, Offset + TypeOffset);
334 "DWARF type unit from offset 0x%8.8" PRIx64
" incl. "
335 "to offset 0x%8.8" PRIx64
" excl. has its "
336 "relocated type_offset 0x%8.8" PRIx64
" pointing past the unit end",
337 Offset, NextCUOffset, Offset + TypeOffset);
341 "DWARF unit at offset 0x%8.8" PRIx64, Offset))
355 "DWARF package unit at offset 0x%8.8" PRIx64
356 " has a non-zero abbreviation offset",
359 auto *UnitContrib = IndexEntry->getContribution();
362 "DWARF package unit at offset 0x%8.8" PRIx64
363 " has no contribution index",
367 if (UnitContrib->getLength() != IndexLength)
369 "DWARF package unit at offset 0x%8.8" PRIx64
370 " has an inconsistent index (expected: %" PRIu64
371 ", actual: %" PRIu64
")",
372 Offset, UnitContrib->getLength(), IndexLength);
374 auto *AbbrEntry = IndexEntry->getContribution(DW_SECT_ABBREV);
377 "DWARF package unit at offset 0x%8.8" PRIx64
378 " missing abbreviation column",
381 AbbrOffset = AbbrEntry->getOffset();
388 assert(!DieArray.empty());
391 uint64_t ActualRangeListOffset = RangeSectionBase + RangeListOffset;
392 return RangeList.
extract(RangesData, &ActualRangeListOffset);
398 RangeSectionBase = 0;
400 AddrOffsetSectionBase = std::nullopt;
413void DWARFUnit::extractDIEsToVector(
414 bool AppendCUDie,
bool AppendNonCUDies,
415 std::vector<DWARFDebugInfoEntry> &Dies)
const {
416 if (!AppendCUDie && !AppendNonCUDies)
427 std::vector<uint32_t> Parents;
428 std::vector<uint32_t> PrevSiblings;
432 ((AppendCUDie && Dies.empty()) || (!AppendCUDie && Dies.size() == 1)) &&
433 "Dies array is not empty");
436 Parents.push_back(UINT32_MAX);
438 Parents.push_back(0);
439 PrevSiblings.push_back(0);
443 assert(Parents.size() > 0 &&
"Empty parents stack");
444 assert((Parents.back() == UINT32_MAX || Parents.back() <= Dies.size()) &&
445 "Wrong parent index");
448 if (!
DIE.extractFast(*
this, &DIEOffset, DebugInfoData, NextCUOffset,
453 if (PrevSiblings.back() > 0) {
454 assert(PrevSiblings.back() < Dies.size() &&
455 "Previous sibling index is out of Dies boundaries");
456 Dies[PrevSiblings.back()].setSiblingIdx(Dies.size());
463 if (!AppendNonCUDies)
471 PrevSiblings.back() = Dies.size();
477 if (
const DWARFAbbreviationDeclaration *AbbrDecl =
479 if (AbbrDecl->hasChildren()) {
480 if (AppendCUDie || !IsCUDie) {
481 assert(Dies.size() > 0 &&
"Dies does not contain any die");
482 Parents.push_back(Dies.size() - 1);
483 PrevSiblings.push_back(0);
491 PrevSiblings.pop_back();
499 Dies.shrink_to_fit();
502void DWARFUnit::extractDIEsIfNeeded(
bool CUDieOnly) {
504 Context.getRecoverableErrorHandler()(std::move(e));
508 if ((CUDieOnly && !DieArray.empty()) || DieArray.size() > 1)
514 if (DieArray.size() == 1 && !DieArray.front().hasChildren())
517 bool HasCUDie = !DieArray.empty();
518 extractDIEsToVector(!HasCUDie, !CUDieOnly, DieArray);
520 if (DieArray.empty())
527 DWARFDie UnitDie(
this, &DieArray[0]);
528 if (std::optional<uint64_t> DWOId =
530 Header.setDWOId(*DWOId);
532 assert(AddrOffsetSectionBase == std::nullopt);
533 assert(RangeSectionBase == 0);
534 assert(LocSectionBase == 0);
536 if (!AddrOffsetSectionBase)
537 AddrOffsetSectionBase =
553 auto StringOffsetOrError =
556 if (!StringOffsetOrError)
558 "invalid reference to or invalid content in "
559 ".debug_str_offsets[.dwo]: " +
560 toString(StringOffsetOrError.takeError()));
562 StringOffsetsTableContribution = *StringOffsetOrError;
570 uint64_t ContributionBaseOffset = 0;
571 if (
auto *IndexEntry = Header.getIndexEntry())
572 if (
auto *Contrib = IndexEntry->getContribution(DW_SECT_RNGLISTS))
573 ContributionBaseOffset = Contrib->getOffset();
575 &Context.getDWARFObj().getRnglistsDWOSection(),
576 ContributionBaseOffset +
582 Header.getFormat())));
589 ? Context.getDWARFObj().getLoclistsDWOSection().Data
590 : Context.getDWARFObj().getLocDWOSection().Data;
591 if (
auto *IndexEntry = Header.getIndexEntry())
592 if (
const auto *
C = IndexEntry->getContribution(
594 Data =
Data.substr(
C->getOffset(),
C->getLength());
598 std::make_unique<DWARFDebugLoclists>(DWARFData, Header.getVersion());
601 LocTable = std::make_unique<DWARFDebugLoclists>(
603 Context.getDWARFObj().getLoclistsSection(),
608 Context.getDWARFObj(), Context.getDWARFObj().getLocSection(),
617bool DWARFUnit::parseDWO(
StringRef DWOAlternativeLocation) {
640 auto DWOContext = Context.getDWOContext(AbsolutePath);
643 if (DWOAlternativeLocation.
empty())
648 DWOContext = Context.getDWOContext(DWOAlternativeLocation);
653 DWARFCompileUnit *DWOCU = DWOContext->getDWOCompileUnitForHash(*DWOId);
656 DWO = std::shared_ptr<DWARFCompileUnit>(std::move(DWOContext), DWOCU);
657 DWO->setSkeletonUnit(
this);
659 if (AddrOffsetSectionBase)
660 DWO->setAddrOffsetSection(AddrOffsetSection, *AddrOffsetSectionBase);
663 DWO->setRangesSection(RangeSection, DWORangesBase.value_or(0));
669void DWARFUnit::clearDIEs(
bool KeepCUDie) {
675 DieArray = (KeepCUDie && !DieArray.empty())
676 ? std::vector<DWARFDebugInfoEntry>({DieArray[0]})
677 : std::vector<DWARFDebugInfoEntry>();
689 IsLittleEndian, Header.getAddressByteSize());
691 auto RangeListOrError = RnglistTable.
findList(RangesData,
Offset);
692 if (RangeListOrError)
693 return RangeListOrError.get().getAbsoluteRanges(
getBaseAddress(), *
this);
694 return RangeListOrError.takeError();
703 "invalid range list table index %d (possibly "
704 "missing the entire range list table)",
715 if (!CUDIERangesOrError)
717 "decoding address ranges: %s",
718 toString(CUDIERangesOrError.takeError()).c_str());
719 return *CUDIERangesOrError;
733 Result.push_back(std::move(*L));
735 InterpretationError =
736 joinErrors(L.takeError(), std::move(InterpretationError));
737 return !InterpretationError;
740 if (ParseError || InterpretationError)
741 return joinErrors(std::move(ParseError), std::move(InterpretationError));
749 if (DIERangesOrError) {
750 for (
const auto &R : DIERangesOrError.get()) {
752 if (R.LowPC == R.HighPC)
754 auto B = AddrDieMap.upper_bound(R.LowPC);
755 if (
B != AddrDieMap.begin() && R.LowPC < (--
B)->second.first) {
758 if (R.HighPC <
B->second.first)
759 AddrDieMap[R.HighPC] =
B->second;
760 if (R.LowPC >
B->first)
761 AddrDieMap[
B->first].first = R.LowPC;
763 AddrDieMap[R.LowPC] = std::make_pair(R.HighPC, Die);
778 extractDIEsIfNeeded(
false);
779 if (AddrDieMap.empty())
781 auto R = AddrDieMap.upper_bound(
Address);
782 if (R == AddrDieMap.begin())
786 if (
Address >= R->second.first)
788 return R->second.second;
793 if (
isType(Child.getTag()))
798 if (Die.
getTag() != DW_TAG_variable)
815 auto It = Expr.
begin();
816 if (It == Expr.
end())
825 uint64_t LocationAddr;
826 if (It->getCode() == dwarf::DW_OP_addr) {
827 LocationAddr = It->getRawOperand(0);
828 }
else if (It->getCode() == dwarf::DW_OP_addrx) {
829 uint64_t DebugAddrOffset = It->getRawOperand(0);
831 LocationAddr = Pointer->Address;
838 if (++It != Expr.
end()) {
839 if (It->getCode() != dwarf::DW_OP_plus_uconst)
842 LocationAddr += It->getRawOperand(0);
845 if (++It != Expr.
end())
866 extractDIEsIfNeeded(
false);
870 auto RootLookup = RootsParsedForVariables.insert(RootDie.getOffset());
871 if (RootLookup.second)
874 auto R = VariableDieMap.upper_bound(
Address);
875 if (R == VariableDieMap.begin())
880 if (
Address >= R->second.first)
882 return R->second.second;
896 while (SubroutineDIE) {
901 if (SubroutineDIE.
getTag() == DW_TAG_inlined_subroutine)
903 SubroutineDIE = SubroutineDIE.
getParent();
909 if (Kind == DW_SECT_INFO)
910 return Context.getCUIndex();
912 return Context.getTUIndex();
926 assert(Die >= DieArray.data() && Die < DieArray.data() + DieArray.size());
928 if (std::optional<uint32_t> ParentIdx = Die->
getParentIdx()) {
929 assert(*ParentIdx < DieArray.size() &&
930 "ParentIdx is out of DieArray boundaries");
948 assert(Die >= DieArray.data() && Die < DieArray.data() + DieArray.size());
950 if (std::optional<uint32_t> SiblingIdx = Die->
getSiblingIdx()) {
951 assert(*SiblingIdx < DieArray.size() &&
952 "SiblingIdx is out of DieArray boundaries");
953 return &DieArray[*SiblingIdx];
970 assert(Die >= DieArray.data() && Die < DieArray.data() + DieArray.size());
972 std::optional<uint32_t> ParentIdx = Die->
getParentIdx();
977 assert(*ParentIdx < DieArray.size() &&
978 "ParentIdx is out of DieArray boundaries");
982 if (PrevDieIdx == *ParentIdx)
986 while (DieArray[PrevDieIdx].getParentIdx() != *ParentIdx) {
987 PrevDieIdx = *DieArray[PrevDieIdx].getParentIdx();
989 assert(PrevDieIdx < DieArray.size() &&
990 "PrevDieIdx is out of DieArray boundaries");
991 assert(PrevDieIdx >= *ParentIdx &&
992 "PrevDieIdx is not a child of parent of Die");
995 return &DieArray[PrevDieIdx];
1009 assert(Die >= DieArray.data() && Die < DieArray.data() + DieArray.size());
1018 if (
I >= DieArray.size())
1020 return &DieArray[
I];
1034 assert(Die >= DieArray.data() && Die < DieArray.data() + DieArray.size());
1039 if (std::optional<uint32_t> SiblingIdx = Die->
getSiblingIdx()) {
1040 assert(*SiblingIdx < DieArray.size() &&
1041 "SiblingIdx is out of DieArray boundaries");
1042 assert(DieArray[*SiblingIdx - 1].
getTag() == dwarf::DW_TAG_null &&
1043 "Bad end of children marker");
1044 return &DieArray[*SiblingIdx - 1];
1056 if (
getDIEIndex(Die) == 0 && DieArray.size() > 1 &&
1057 DieArray.back().getTag() == dwarf::DW_TAG_null) {
1062 return &DieArray.back();
1072 if (!AbbrevsOrError) {
1077 Abbrevs = *AbbrevsOrError;
1087 std::optional<DWARFFormValue> PC =
1088 UnitDie.
find({DW_AT_low_pc, DW_AT_entry_pc});
1099 uint64_t ValidationSize =
alignTo(
Size, EntrySize);
1101 if (ValidationSize >=
Size)
1102 if (DA.isValidOffsetForDataOfSize((
uint32_t)
Base, ValidationSize))
1111 if (!DA.isValidOffsetForDataOfSize(
Offset, 16))
1119 (void)DA.getU16(&
Offset);
1129 if (!DA.isValidOffsetForDataOfSize(
Offset, 8))
1137 (void)DA.getU16(&
Offset);
1155 return DescOrError.takeError();
1156 Desc = *DescOrError;
1164 return DescOrError.takeError();
1165 Desc = *DescOrError;
1169 return Desc.validateContributionSize(DA);
1177 return std::nullopt;
1181 return DescOrError.takeError();
1182 return *DescOrError;
1189 auto IndexEntry = Header.getIndexEntry();
1191 IndexEntry ? IndexEntry->getContribution(DW_SECT_STR_OFFSETS) :
nullptr;
1195 if (DA.getData().data() ==
nullptr)
1196 return std::nullopt;
1207 return DescOrError.takeError();
1208 return *DescOrError;
1216 Header.getFormat());
1217 else if (!IndexEntry && !StringOffsetSection.Data.empty())
1219 4, Header.getFormat());
1221 return std::nullopt;
1222 auto DescOrError =
Desc.validateContributionSize(DA);
1224 return DescOrError.takeError();
1225 return *DescOrError;
1229 DataExtractor RangesData(RangeSection->Data, IsLittleEndian);
1234 return *Off + RangeSectionBase;
1235 return std::nullopt;
1241 return *Off + LocSectionBase;
1242 return std::nullopt;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static Expected< StrOffsetsContributionDescriptor > parseDWARF64StringOffsetsTableHeader(DWARFDataExtractor &DA, uint64_t Offset)
static Expected< StrOffsetsContributionDescriptor > parseDWARF32StringOffsetsTableHeader(DWARFDataExtractor &DA, uint64_t Offset)
static Expected< StrOffsetsContributionDescriptor > parseDWARFStringOffsetsTableHeader(DWARFDataExtractor &DA, llvm::dwarf::DwarfFormat Format, uint64_t Offset)
This file contains constants used for implementing Dwarf debug support.
This file defines the SmallString class.
A structured debug information entry.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
static bool isSupportedVersion(unsigned version)
static Error checkAddressSizeSupported(unsigned AddressSize, std::error_code EC, char const *Fmt, const Ts &...Vals)
static unsigned getMaxSupportedVersion()
DWARFDebugInfoEntry - A DIE with only the minimum required data.
std::optional< uint32_t > getSiblingIdx() const
Returns index of the sibling die.
std::optional< uint32_t > getParentIdx() const
Returns index of the parent die.
const DWARFAbbreviationDeclaration * getAbbreviationDeclarationPtr() const
LLVM_ABI Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr)
LLVM_ABI DWARFAddressRangesVector getAbsoluteRanges(std::optional< object::SectionedAddress > BaseAddr) const
getAbsoluteRanges - Returns absolute address ranges defined by this range list.
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
LLVM_ABI Expected< DWARFAddressRangesVector > getAddressRanges() const
Get the address ranges for this DIE.
LLVM_ABI DWARFDie getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE as the referenced DIE.
LLVM_ABI DWARFDie getParent() const
Get the parent of this DIE object.
LLVM_ABI std::optional< DWARFFormValue > find(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE.
LLVM_ABI DWARFDie getSibling() const
Get the sibling of this DIE object.
LLVM_ABI bool isSubroutineDIE() const
Returns true if DIE represents a subprogram or an inlined subroutine.
LLVM_ABI bool isSubprogramDIE() const
Returns true if DIE represents a subprogram (not inlined).
LLVM_ABI std::optional< uint64_t > getTypeSize(uint64_t PointerSize)
Gets the type size (in bytes) for this DIE.
LLVM_ABI DWARFDie getFirstChild() const
Get the first child of this DIE object.
dwarf::Tag getTag() const
LLVM_ABI Expected< DWARFLocationExpressionsVector > getLocations(dwarf::Attribute Attr) const
LLVM_ABI std::optional< uint64_t > getRangesBaseAttribute() const
Extract the range base attribute from this DIE as absolute section offset.
Expected< DWARFListType > findList(DWARFDataExtractor Data, uint64_t Offset) const
Look up a list based on a given offset.
LLVM_ABI Error visitAbsoluteLocationList(uint64_t Offset, std::optional< object::SectionedAddress > BaseAddr, std::function< std::optional< object::SectionedAddress >(uint32_t)> LookupAddr, function_ref< bool(Expected< DWARFLocationExpression >)> Callback) const
Describe a collection of units.
LLVM_ABI DWARFUnit * addUnit(std::unique_ptr< DWARFUnit > Unit)
Add an existing DWARFUnit to this UnitVector.
unsigned getNumInfoUnits() const
Returns number of units from all .debug_info[.dwo] sections.
LLVM_ABI DWARFUnit * getUnitForIndexEntry(const DWARFUnitIndex::Entry &E, DWARFSectionKind Sec, const DWARFSection *Section=nullptr)
Returns the Unit from the .debug_info or .debug_types section by the index entry.
LLVM_ABI void addUnitsForSection(DWARFContext &C, const DWARFSection &Section, DWARFSectionKind SectionKind)
Read units from a .debug_info or .debug_types section.
LLVM_ABI DWARFUnit * getUnitForOffset(uint64_t Offset) const
LLVM_ABI void addUnitsForDWOSection(DWARFContext &C, const DWARFSection &DWOSection, DWARFSectionKind SectionKind, bool Lazy=false)
Read units from a .debug_info.dwo or .debug_types.dwo section.
const DWARFDebugInfoEntry * getDebugInfoEntry(unsigned Index) const
Return DWARFDebugInfoEntry for the specified index Index.
const DWARFDebugInfoEntry * getSiblingEntry(const DWARFDebugInfoEntry *Die) const
std::optional< uint64_t > getDWOId()
uint32_t getHeaderSize() const
Size in bytes of the parsed unit header.
DWARFDie getPreviousSibling(const DWARFDebugInfoEntry *Die)
Expected< std::optional< StrOffsetsContributionDescriptor > > determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA)
Find the unit's contribution to the string offsets table and determine its length and form.
const DWARFLocationTable & getLocationTable()
const DWARFDebugInfoEntry * getParentEntry(const DWARFDebugInfoEntry *Die) const
DWARFDie getFirstChild(const DWARFDebugInfoEntry *Die)
DWARFDataExtractor getDebugInfoExtractor() const
DWARFDie getSibling(const DWARFDebugInfoEntry *Die)
std::optional< uint64_t > getRnglistOffset(uint32_t Index)
Return a rangelist's offset based on an index.
Error tryExtractDIEsIfNeeded(bool CUDieOnly)
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
uint8_t getAddressByteSize() const
DWARFDie getVariableForAddress(uint64_t Address)
Returns variable DIE for the address provided.
void setRangesSection(const DWARFSection *RS, uint64_t Base)
uint8_t getDwarfStringOffsetsByteSize() const
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
DWARFDie getParent(const DWARFDebugInfoEntry *Die)
std::optional< uint64_t > getLoclistOffset(uint32_t Index)
const char * getCompilationDir()
uint64_t getStringOffsetsBase() const
dwarf::DwarfFormat getFormat() const
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)
Expected< std::optional< StrOffsetsContributionDescriptor > > determineStringOffsetsTableContribution(DWARFDataExtractor &DA)
Find the unit's contribution to the string offsets table and determine its length and form.
uint64_t getAbbreviationsOffset() const
uint16_t getVersion() const
void getInlinedChainForAddress(uint64_t Address, SmallVectorImpl< DWARFDie > &InlinedChain)
getInlinedChainForAddress - fetches inlined chain for a given address.
Error extractRangeList(uint64_t RangeListOffset, DWARFDebugRangeList &RangeList) const
Extract the range list referenced by this compile unit from the .debug_ranges section.
Expected< uint64_t > getStringOffsetSectionItem(uint32_t Index) const
uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) const
Return the index of a Die entry inside the unit's DIE vector.
Expected< DWARFLocationExpressionsVector > findLoclistFromOffset(uint64_t Offset)
Expected< DWARFAddressRangesVector > findRnglistFromOffset(uint64_t Offset)
Return a vector of address ranges resulting from a (possibly encoded) range list starting at a given ...
bool isLittleEndian() const
const DWARFDebugInfoEntry * getPreviousSiblingEntry(const DWARFDebugInfoEntry *Die) const
const DWARFDebugInfoEntry * getLastChildEntry(const DWARFDebugInfoEntry *Die) const
void updateVariableDieMap(DWARFDie Die)
Recursively update address to variable Die map.
DWARFDie getSubroutineForAddress(uint64_t Address)
Returns subprogram DIE with address range encompassing the provided address.
const DWARFDebugInfoEntry * getFirstChildEntry(const DWARFDebugInfoEntry *Die) const
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...
uint64_t getNextUnitOffset() const
std::optional< object::SectionedAddress > getBaseAddress()
Expected< DWARFAddressRangesVector > collectAddressRanges()
std::optional< object::SectionedAddress > getAddrOffsetSectionItem(uint32_t Index) const
uint64_t getOffset() const
DWARFDie getLastChild(const DWARFDebugInfoEntry *Die)
void updateAddressDieMap(DWARFDie Die)
Recursively update address to Die map.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
SectionKind - This is a simple POD value that classifies the properties of a section.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
iterator insert(iterator I, std::unique_ptr< DWARFUnit > &&Elt)
void push_back(const T &Elt)
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI unsigned getTag(StringRef TagString)
Calculates the starting offsets for various sections within the .debug_names section.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
std::optional< object::SectionedAddress > toSectionedAddress(const std::optional< DWARFFormValue > &V)
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
std::optional< uint64_t > toSectionOffset(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an section offset.
std::optional< uint64_t > toUnsigned(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an unsigned constant.
@ DW_LENGTH_lo_reserved
Special values for an initial length field.
@ DW_LENGTH_DWARF64
Indicator of 64-bit DWARF format.
LLVM_ABI bool is_relative(const Twine &path, Style style=Style::native)
Is path relative?
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI const DWARFUnitIndex & getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind)
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
DWARFSectionKind
The enum of section identifiers to be used in internal interfaces.
Error joinErrors(Error E1, Error E2)
Concatenate errors.
static uint64_t getDebugInfoSize(DWARFContext &Dwarf)
Compute the total size of the debug info.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
bool hasSingleElement(ContainerTy &&C)
Returns true if the given container only contains a single element.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
void consumeError(Error Err)
Consume a Error without doing anything.
std::vector< DWARFLocationExpression > DWARFLocationExpressionsVector
Represents a set of absolute location expressions.
Represents a single DWARF expression, whose value is location-dependent.
Represents base address of the CU.
LLVM_ABI Expected< StrOffsetsContributionDescriptor > validateContributionSize(DWARFDataExtractor &DA)
Determine whether a contribution to the string offsets table is consistent with the relevant section ...
uint64_t Size
The contribution size not including the header.
uint8_t getDwarfOffsetByteSize() const