66#define DEBUG_TYPE "dwarf"
77 const auto &DObj =
C.getDWARFObj();
78 if (DObj.getCUIndexSection().empty())
84 if (!(
C.getParseCUTUIndexManually() ||
85 S.
Data.
size() >= std::numeric_limits<uint32_t>::max()))
91 if (
Error ExtractionErr = Header.extract(
92 C,
Data, &
Offset, DWARFSectionKind::DW_SECT_INFO)) {
93 C.getWarningHandler()(
94 createError(
"Failed to parse CU header in DWP file: " +
95 toString(std::move(ExtractionErr))));
100 auto Iter = Map.insert({TruncOffset,
101 {Header.getOffset(), Header.getNextUnitOffset() -
102 Header.getOffset()}});
105 createError(
"Collision occurred between for truncated offset 0x" +
112 Offset = Header.getNextUnitOffset();
125 if (Iter == Map.end()) {
132 CUOff.
setOffset(Iter->second.getOffset());
133 if (CUOff.
getOffset() != Iter->second.getOffset())
135 "match calculated length at offset 0x" +
144 const auto &DObj =
C.getDWARFObj();
145 DObj.forEachInfoDWOSections([&](
const DWARFSection &S) {
146 if (!(
C.getParseCUTUIndexManually() ||
147 S.
Data.
size() >= std::numeric_limits<uint32_t>::max()))
153 if (
Error ExtractionErr = Header.extract(
154 C,
Data, &
Offset, DWARFSectionKind::DW_SECT_INFO)) {
155 C.getWarningHandler()(
156 createError(
"Failed to parse CU header in DWP file: " +
157 toString(std::move(ExtractionErr))));
160 bool CU = Header.getUnitType() == DW_UT_split_compile;
161 uint64_t Sig =
CU ? *Header.getDWOId() : Header.getTypeHash();
162 Map[Sig] = Header.getOffset();
163 Offset = Header.getNextUnitOffset();
172 auto Iter = Map.find(
E.getSignature());
173 if (Iter == Map.end()) {
175 createError(
"Could not find unit with signature 0x" +
185 if (
Index.getVersion() < 5)
194 bool IsLittleEndian) {
199 Cache = std::make_unique<T>(AccelSection, StrData);
200 if (
Error E = Cache->extract())
206std::unique_ptr<DWARFDebugMacro>
208 auto Macro = std::make_unique<DWARFDebugMacro>();
212 :
D.dwo_compile_units(),
214 ?
D.getStringExtractor()
215 :
D.getStringDWOExtractor(),
218 D.getRecoverableErrorHandler()(std::move(Err));
223 switch (SectionType) {
226 ParseAndDump(
Data,
false);
231 ParseAndDump(
Data,
false);
237 ParseAndDump(
Data,
true);
242 ParseAndDump(
Data,
true);
253 std::optional<DenseMap<uint64_t, DWARFTypeUnit *>> NormalTypeUnits;
254 std::unique_ptr<DWARFUnitIndex> CUIndex;
255 std::unique_ptr<DWARFGdbIndex> GdbIndex;
256 std::unique_ptr<DWARFUnitIndex> TUIndex;
257 std::unique_ptr<DWARFDebugAbbrev> Abbrev;
258 std::unique_ptr<DWARFDebugLoc>
Loc;
259 std::unique_ptr<DWARFDebugAranges> Aranges;
260 std::unique_ptr<DWARFDebugLine> Line;
262 std::unique_ptr<DWARFDebugFrame> EHFrame;
263 std::unique_ptr<DWARFDebugMacro>
Macro;
264 std::unique_ptr<DWARFDebugMacro> Macinfo;
265 std::unique_ptr<DWARFDebugNames> Names;
266 std::unique_ptr<AppleAcceleratorTable>
AppleNames;
267 std::unique_ptr<AppleAcceleratorTable>
AppleTypes;
269 std::unique_ptr<AppleAcceleratorTable>
AppleObjC;
271 std::optional<DenseMap<uint64_t, DWARFTypeUnit *>> DWOTypeUnits;
272 std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO;
273 std::unique_ptr<DWARFDebugMacro> MacinfoDWO;
274 std::unique_ptr<DWARFDebugMacro> MacroDWO;
277 std::unique_ptr<DWARFContext> Context;
280 std::weak_ptr<DWOFile> DWP;
281 bool CheckedForDWP =
false;
285 ThreadUnsafeDWARFContextState(
DWARFContext &DC, std::string &DWP) :
290 if (NormalUnits.
empty()) {
303 DWARFUnitVector &getDWOUnits(
bool Lazy)
override {
304 if (DWOUnits.
empty()) {
305 const DWARFObject &DObj =
D.getDWARFObj();
318 const DWARFDebugAbbrev *getDebugAbbrevDWO()
override {
320 return AbbrevDWO.get();
321 const DWARFObject &DObj =
D.getDWARFObj();
323 AbbrevDWO = std::make_unique<DWARFDebugAbbrev>(abbrData);
324 return AbbrevDWO.get();
327 const DWARFUnitIndex &getCUIndex()
override {
331 DataExtractor
Data(
D.getDWARFObj().getCUIndexSection(),
D.isLittleEndian());
332 CUIndex = std::make_unique<DWARFUnitIndex>(DW_SECT_INFO);
333 if (CUIndex->parse(
Data))
337 const DWARFUnitIndex &getTUIndex()
override {
341 DataExtractor
Data(
D.getDWARFObj().getTUIndexSection(),
D.isLittleEndian());
343 bool isParseSuccessful = TUIndex->parse(
Data);
346 if (isParseSuccessful && TUIndex->getVersion() != 2)
351 DWARFGdbIndex &getGdbIndex()
override {
355 DataExtractor
Data(
D.getDWARFObj().getGdbIndexSection(),
357 GdbIndex = std::make_unique<DWARFGdbIndex>();
358 GdbIndex->parse(
Data);
362 const DWARFDebugAbbrev *getDebugAbbrev()
override {
366 DataExtractor
Data(
D.getDWARFObj().getAbbrevSection(),
D.isLittleEndian());
367 Abbrev = std::make_unique<DWARFDebugAbbrev>(
Data);
375 const DWARFObject &DObj =
D.getDWARFObj();
378 D.getNumCompileUnits()
379 ? DWARFDataExtractor(DObj, DObj.
getLocSection(),
D.isLittleEndian(),
380 D.getUnitAtIndex(0)->getAddressByteSize())
381 : DWARFDataExtractor(
"",
D.isLittleEndian(), 0);
382 Loc = std::make_unique<DWARFDebugLoc>(std::move(
Data));
386 const DWARFDebugAranges *getDebugAranges()
override {
388 return Aranges.get();
390 Aranges = std::make_unique<DWARFDebugAranges>();
391 Aranges->generate(&
D);
392 return Aranges.get();
395 Expected<const DWARFDebugLine::LineTable *>
396 getLineTableForUnit(DWARFUnit *U, function_ref<
void(
Error)> RecoverableErrorHandler)
override {
398 Line = std::make_unique<DWARFDebugLine>();
400 auto UnitDIE =
U->getUnitDIE();
414 if (stmtOffset >=
U->getLineSection().Data.size())
418 DWARFDataExtractor
Data(
U->getContext().getDWARFObj(),
U->getLineSection(),
419 U->isLittleEndian(),
U->getAddressByteSize());
420 return Line->getOrParseLineTable(
Data, stmtOffset,
U->getContext(), U,
421 RecoverableErrorHandler);
425 void clearLineTableForUnit(DWARFUnit *U)
override {
429 auto UnitDIE =
U->getUnitDIE();
438 Line->clearLineTable(stmtOffset);
443 static Expected<const DWARFDebugFrame *> useCached(
const DWARFDebugFrame &
DF,
444 bool ParseCFIProgram) {
446 if (
Error E =
DF.parseAllCFIPrograms())
451 Expected<const DWARFDebugFrame *>
452 getDebugFrame(
bool ParseCFIProgram)
override {
454 return useCached(*
DebugFrame, ParseCFIProgram);
455 const DWARFObject &DObj =
D.getDWARFObj();
467 DWARFDataExtractor
Data(DObj, DS,
D.isLittleEndian(),
470 std::make_unique<DWARFDebugFrame>(
D.getArch(),
false,
479 Expected<const DWARFDebugFrame *> getEHFrame(
bool ParseCFIProgram)
override {
481 return useCached(*EHFrame, ParseCFIProgram);
482 const DWARFObject &DObj =
D.getDWARFObj();
485 DWARFDataExtractor
Data(DObj, DS,
D.isLittleEndian(),
488 std::make_unique<DWARFDebugFrame>(
D.getArch(),
true,
493 return EHFrame.get();
496 const DWARFDebugMacro *getDebugMacinfo()
override {
498 Macinfo = parseMacroOrMacinfo(MacinfoSection);
499 return Macinfo.get();
501 const DWARFDebugMacro *getDebugMacinfoDWO()
override {
503 MacinfoDWO = parseMacroOrMacinfo(MacinfoDwoSection);
504 return MacinfoDWO.get();
506 const DWARFDebugMacro *getDebugMacro()
override {
508 Macro = parseMacroOrMacinfo(MacroSection);
511 const DWARFDebugMacro *getDebugMacroDWO()
override {
513 MacroDWO = parseMacroOrMacinfo(MacroDwoSection);
514 return MacroDWO.get();
516 const DWARFDebugNames &getDebugNames()
override {
517 const DWARFObject &DObj =
D.getDWARFObj();
521 const AppleAcceleratorTable &getAppleNames()
override {
522 const DWARFObject &DObj =
D.getDWARFObj();
527 const AppleAcceleratorTable &getAppleTypes()
override {
528 const DWARFObject &DObj =
D.getDWARFObj();
533 const AppleAcceleratorTable &getAppleNamespaces()
override {
534 const DWARFObject &DObj =
D.getDWARFObj();
540 const AppleAcceleratorTable &getAppleObjC()
override {
541 const DWARFObject &DObj =
D.getDWARFObj();
546 std::shared_ptr<DWARFContext>
547 getDWOContext(StringRef AbsolutePath)
override {
548 if (
auto S = DWP.lock()) {
549 DWARFContext *Ctxt = S->Context.get();
550 return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
553 std::weak_ptr<DWOFile> *
Entry = &DWOFiles[AbsolutePath];
555 if (
auto S =
Entry->lock()) {
556 DWARFContext *Ctxt = S->Context.get();
557 return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
560 const DWARFObject &DObj =
D.getDWARFObj();
562 Expected<OwningBinary<ObjectFile>>
Obj = [&] {
563 if (!CheckedForDWP) {
564 SmallString<128> DWPName;
566 this->DWPName.
empty()
567 ? (DObj.
getFileName() +
".dwp").toStringRef(DWPName)
568 : StringRef(this->DWPName));
573 CheckedForDWP =
true;
589 auto S = std::make_shared<DWOFile>();
590 S->File = std::move(
Obj.get());
593 bool ThreadSafe = isThreadSafe();
595 *S->File.getBinary(), DWARFContext::ProcessDebugRelocations::Ignore,
599 auto *Ctxt = S->Context.get();
600 return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
603 bool isThreadSafe()
const override {
return false; }
605 const DenseMap<uint64_t, DWARFTypeUnit *> &getNormalTypeUnitMap() {
606 if (!NormalTypeUnits) {
607 NormalTypeUnits.emplace();
608 for (
const auto &U :
D.normal_units()) {
610 (*NormalTypeUnits)[TU->getTypeHash()] = TU;
613 return *NormalTypeUnits;
616 const DenseMap<uint64_t, DWARFTypeUnit *> &getDWOTypeUnitMap() {
618 DWOTypeUnits.emplace();
619 for (
const auto &U :
D.dwo_units()) {
621 (*DWOTypeUnits)[TU->getTypeHash()] = TU;
624 return *DWOTypeUnits;
627 const DenseMap<uint64_t, DWARFTypeUnit *> &
628 getTypeUnitMap(
bool IsDWO)
override {
630 return getDWOTypeUnitMap();
632 return getNormalTypeUnitMap();
636class ThreadSafeState :
public ThreadUnsafeDWARFContextState {
637 std::recursive_mutex
Mutex;
640 ThreadSafeState(DWARFContext &DC, std::string &DWP) :
641 ThreadUnsafeDWARFContextState(DC, DWP) {}
643 DWARFUnitVector &getNormalUnits()
override {
644 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
645 return ThreadUnsafeDWARFContextState::getNormalUnits();
647 DWARFUnitVector &getDWOUnits(
bool Lazy)
override {
648 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
652 return ThreadUnsafeDWARFContextState::getDWOUnits(
false);
654 const DWARFUnitIndex &getCUIndex()
override {
655 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
656 return ThreadUnsafeDWARFContextState::getCUIndex();
658 const DWARFDebugAbbrev *getDebugAbbrevDWO()
override {
659 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
660 return ThreadUnsafeDWARFContextState::getDebugAbbrevDWO();
663 const DWARFUnitIndex &getTUIndex()
override {
664 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
665 return ThreadUnsafeDWARFContextState::getTUIndex();
667 DWARFGdbIndex &getGdbIndex()
override {
668 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
669 return ThreadUnsafeDWARFContextState::getGdbIndex();
671 const DWARFDebugAbbrev *getDebugAbbrev()
override {
672 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
673 return ThreadUnsafeDWARFContextState::getDebugAbbrev();
676 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
677 return ThreadUnsafeDWARFContextState::getDebugLoc();
679 const DWARFDebugAranges *getDebugAranges()
override {
680 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
681 return ThreadUnsafeDWARFContextState::getDebugAranges();
683 Expected<const DWARFDebugLine::LineTable *>
684 getLineTableForUnit(DWARFUnit *U, function_ref<
void(
Error)> RecoverableErrorHandler)
override {
685 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
686 return ThreadUnsafeDWARFContextState::getLineTableForUnit(U, RecoverableErrorHandler);
688 void clearLineTableForUnit(DWARFUnit *U)
override {
689 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
690 return ThreadUnsafeDWARFContextState::clearLineTableForUnit(U);
692 Expected<const DWARFDebugFrame *>
693 getDebugFrame(
bool ParseCFIProgram)
override {
694 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
695 return ThreadUnsafeDWARFContextState::getDebugFrame(ParseCFIProgram);
697 Expected<const DWARFDebugFrame *> getEHFrame(
bool ParseCFIProgram)
override {
698 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
699 return ThreadUnsafeDWARFContextState::getEHFrame(ParseCFIProgram);
701 const DWARFDebugMacro *getDebugMacinfo()
override {
702 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
703 return ThreadUnsafeDWARFContextState::getDebugMacinfo();
705 const DWARFDebugMacro *getDebugMacinfoDWO()
override {
706 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
707 return ThreadUnsafeDWARFContextState::getDebugMacinfoDWO();
709 const DWARFDebugMacro *getDebugMacro()
override {
710 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
711 return ThreadUnsafeDWARFContextState::getDebugMacro();
713 const DWARFDebugMacro *getDebugMacroDWO()
override {
714 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
715 return ThreadUnsafeDWARFContextState::getDebugMacroDWO();
717 const DWARFDebugNames &getDebugNames()
override {
718 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
719 return ThreadUnsafeDWARFContextState::getDebugNames();
721 const AppleAcceleratorTable &getAppleNames()
override {
722 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
723 return ThreadUnsafeDWARFContextState::getAppleNames();
725 const AppleAcceleratorTable &getAppleTypes()
override {
726 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
727 return ThreadUnsafeDWARFContextState::getAppleTypes();
729 const AppleAcceleratorTable &getAppleNamespaces()
override {
730 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
731 return ThreadUnsafeDWARFContextState::getAppleNamespaces();
733 const AppleAcceleratorTable &getAppleObjC()
override {
734 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
735 return ThreadUnsafeDWARFContextState::getAppleObjC();
737 std::shared_ptr<DWARFContext>
738 getDWOContext(StringRef AbsolutePath)
override {
739 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
740 return ThreadUnsafeDWARFContextState::getDWOContext(AbsolutePath);
743 bool isThreadSafe()
const override {
return true; }
745 const DenseMap<uint64_t, DWARFTypeUnit *> &
746 getTypeUnitMap(
bool IsDWO)
override {
747 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
748 return ThreadUnsafeDWARFContextState::getTypeUnitMap(IsDWO);
755 std::function<
void(
Error)> RecoverableErrorHandler,
756 std::function<
void(
Error)> WarningHandler,
759 RecoverableErrorHandler(RecoverableErrorHandler),
760 WarningHandler(WarningHandler), DObj(
std::
move(DObj)) {
762 State = std::make_unique<ThreadSafeState>(*
this, DWPName);
764 State = std::make_unique<ThreadUnsafeDWARFContextState>(*
this, DWPName);
774 for (
auto LC :
MachO->load_commands()) {
776 if (LC.C.cmd == MachO::LC_UUID) {
777 if (LC.C.cmdsize <
sizeof(
UUID) +
sizeof(LC.C)) {
778 OS <<
"error: UUID load command is too short.\n";
782 memcpy(&
UUID, LC.Ptr+
sizeof(LC.C),
sizeof(
UUID));
785 OS <<
" (" <<
T.getArchName() <<
')';
786 OS <<
' ' <<
MachO->getFileName() <<
'\n';
792 std::vector<std::optional<StrOffsetsContributionDescriptor>>;
799 for (
const auto &U : Units)
800 if (
const auto &
C = U->getStringOffsetsTableContribution())
801 Contributions.push_back(
C);
806 [](
const std::optional<StrOffsetsContributionDescriptor> &L,
807 const std::optional<StrOffsetsContributionDescriptor> &R) {
809 return L->Base < R->Base;
810 return R.has_value();
819 [](
const std::optional<StrOffsetsContributionDescriptor> &L,
820 const std::optional<StrOffsetsContributionDescriptor> &R) {
822 return L->Base == R->Base && L->Size == R->Size;
825 Contributions.end());
826 return Contributions;
849 for (
auto &Contribution : Contributions) {
852 OS <<
"error: invalid contribution to string offsets table in section ."
859 uint16_t Version = Contribution->getVersion();
860 uint64_t ContributionHeader = Contribution->Base;
866 ContributionHeader -= Format ==
DWARF32 ? 8 : 16;
869 if (
Offset > ContributionHeader) {
872 "overlapping contributions to string offsets table in section .%s.",
876 if (
Offset < ContributionHeader) {
878 OS << (ContributionHeader -
Offset) <<
"\n";
880 OS <<
formatv(
"{0:x8}: ", ContributionHeader);
885 OS <<
"Contribution size = " << (Contribution->Size + (Version < 5 ? 0 : 4))
887 <<
", Version = " << Version <<
"\n";
889 Offset = Contribution->Base;
890 unsigned EntrySize = Contribution->getDwarfOffsetByteSize();
891 while (
Offset - Contribution->Base < Contribution->Size) {
896 OffsetDumpWidth,
'0'));
897 const char *S = StrData.
getCStr(&StringOffset);
904 if (
Offset < SectionSize) {
906 OS << (SectionSize -
Offset) <<
"\n";
924 Offset = TableOffset + *TableLength;
929 AddrTable.
dump(OS, DumpOpts);
952 Rnglists.
dump(rnglistData, OS, LookupPooledAddress, DumpOpts);
960 std::optional<uint64_t> DumpOffset) {
970 Header.dump(
Data, OS, DumpOpts);
972 uint64_t EndOffset = Header.length() + Header.getHeaderOffset();
973 Data.setAddressSize(Header.getAddrSize());
976 if (DumpOffset >=
Offset && DumpOffset < EndOffset) {
978 Loc.dumpLocationList(&
Offset, OS, std::nullopt, Obj,
979 nullptr, DumpOpts, 0);
999 std::array<std::optional<uint64_t>,
DIDT_ID_Count> DumpOffsets) {
1000 uint64_t DumpType = DumpOpts.
DumpType;
1003 bool IsDWO = (Extension ==
".dwo") || (Extension ==
".dwp");
1006 const auto *ObjFile = DObj->getFile();
1013 bool Explicit = DumpType !=
DIDT_All && !IsDWO;
1014 bool ExplicitDWO = Explicit && IsDWO;
1015 auto shouldDump = [&](
bool Explicit,
const char *Name,
unsigned ID,
1016 StringRef Section) -> std::optional<uint64_t> * {
1017 unsigned Mask = 1U << ID;
1018 bool Should = (DumpType & Mask) && (Explicit || !Section.empty());
1021 OS <<
"\n" << Name <<
" contents:\n";
1022 return &DumpOffsets[ID];
1026 if (shouldDump(Explicit,
".debug_abbrev", DIDT_ID_DebugAbbrev,
1027 DObj->getAbbrevSection()))
1029 if (shouldDump(ExplicitDWO,
".debug_abbrev.dwo", DIDT_ID_DebugAbbrev,
1030 DObj->getAbbrevDWOSection()))
1034 OS <<
'\n' << Name <<
" contents:\n";
1035 std::optional<uint64_t> DumpOffset = DumpOffsets[DIDT_ID_DebugInfo];
1036 for (
const auto &U : Units) {
1039 bool HadDWO = U->getDWO();
1041 U->getDIEForOffset(*DumpOffset)
1043 DWARFDie CUDie = U->getUnitDIE(
false);
1044 DWARFDie CUNonSkeletonDie = U->getNonSkeletonUnitDIE(
false);
1045 if (CUNonSkeletonDie && CUDie != CUNonSkeletonDie) {
1051 U->dump(OS, DumpOpts);
1063 if ((DumpType & DIDT_DebugInfo)) {
1071 OS <<
'\n' << Name <<
" contents:\n";
1072 for (
const auto &U : Units)
1073 if (
auto DumpOffset = DumpOffsets[DIDT_ID_DebugTypes])
1074 U->getDIEForOffset(*DumpOffset)
1077 U->dump(OS, DumpOpts);
1079 if ((DumpType & DIDT_DebugTypes)) {
1090 if (
const auto *Off = shouldDump(Explicit,
".debug_loc", DIDT_ID_DebugLoc,
1091 DObj->getLocSection().Data)) {
1094 if (
const auto *Off =
1095 shouldDump(Explicit,
".debug_loclists", DIDT_ID_DebugLoclists,
1096 DObj->getLoclistsSection().Data)) {
1101 if (
const auto *Off =
1102 shouldDump(ExplicitDWO,
".debug_loclists.dwo", DIDT_ID_DebugLoclists,
1103 DObj->getLoclistsDWOSection().Data)) {
1109 if (
const auto *Off =
1110 shouldDump(ExplicitDWO,
".debug_loc.dwo", DIDT_ID_DebugLoc,
1111 DObj->getLocDWOSection().Data)) {
1118 std::nullopt, *DObj,
nullptr,
1123 Loc.dumpRange(0,
Data.getData().size(), OS, *DObj, LLDumpOpts);
1127 if (
const std::optional<uint64_t> *Off =
1128 shouldDump(Explicit,
".debug_frame", DIDT_ID_DebugFrame,
1129 DObj->getFrameSection().Data)) {
1135 (*DF)->dump(OS, DumpOpts, *Off);
1137 RecoverableErrorHandler(
DF.takeError());
1140 if (
const std::optional<uint64_t> *Off =
1141 shouldDump(Explicit,
".eh_frame", DIDT_ID_DebugFrame,
1142 DObj->getEHFrameSection().Data)) {
1145 (*DF)->dump(OS, DumpOpts, *Off);
1147 RecoverableErrorHandler(
DF.takeError());
1150 if (shouldDump(Explicit,
".debug_macro", DIDT_ID_DebugMacro,
1151 DObj->getMacroSection().Data)) {
1156 if (shouldDump(Explicit,
".debug_macro.dwo", DIDT_ID_DebugMacro,
1157 DObj->getMacroDWOSection())) {
1162 if (shouldDump(Explicit,
".debug_macinfo", DIDT_ID_DebugMacro,
1163 DObj->getMacinfoSection())) {
1168 if (shouldDump(Explicit,
".debug_macinfo.dwo", DIDT_ID_DebugMacro,
1169 DObj->getMacinfoDWOSection())) {
1171 MacinfoDWO->dump(OS);
1174 if (shouldDump(Explicit,
".debug_aranges", DIDT_ID_DebugAranges,
1175 DObj->getArangesSection())) {
1176 uint64_t offset = 0;
1183 RecoverableErrorHandler(std::move(E));
1192 std::optional<uint64_t> DumpOffset) {
1194 if (DumpOffset &&
Parser.getOffset() != *DumpOffset) {
1198 OS <<
"debug_line[" <<
formatv(
"{0:x8}",
Parser.getOffset()) <<
"]\n";
1204 auto DumpStrSection = [&](
StringRef Section) {
1207 uint64_t StrOffset = 0;
1215 OS <<
formatv(
"{0:x8}: \"", StrOffset);
1222 if (
const auto *Off = shouldDump(Explicit,
".debug_line", DIDT_ID_DebugLine,
1223 DObj->getLineSection().Data)) {
1227 DumpLineSection(
Parser, DumpOpts, *Off);
1230 if (
const auto *Off =
1231 shouldDump(ExplicitDWO,
".debug_line.dwo", DIDT_ID_DebugLine,
1232 DObj->getLineDWOSection().Data)) {
1236 DumpLineSection(
Parser, DumpOpts, *Off);
1239 if (shouldDump(Explicit,
".debug_cu_index", DIDT_ID_DebugCUIndex,
1240 DObj->getCUIndexSection())) {
1244 if (shouldDump(Explicit,
".debug_tu_index", DIDT_ID_DebugTUIndex,
1245 DObj->getTUIndexSection())) {
1249 if (shouldDump(Explicit,
".debug_str", DIDT_ID_DebugStr,
1250 DObj->getStrSection()))
1251 DumpStrSection(DObj->getStrSection());
1253 if (shouldDump(ExplicitDWO,
".debug_str.dwo", DIDT_ID_DebugStr,
1254 DObj->getStrDWOSection()))
1255 DumpStrSection(DObj->getStrDWOSection());
1257 if (shouldDump(Explicit,
".debug_line_str", DIDT_ID_DebugLineStr,
1258 DObj->getLineStrSection()))
1259 DumpStrSection(DObj->getLineStrSection());
1261 if (shouldDump(Explicit,
".debug_addr", DIDT_ID_DebugAddr,
1262 DObj->getAddrSection().Data)) {
1268 if (shouldDump(Explicit,
".debug_ranges", DIDT_ID_DebugRanges,
1269 DObj->getRangesSection().Data)) {
1273 uint64_t offset = 0;
1276 if (
Error E = rangeList.
extract(rangesData, &offset)) {
1284 auto LookupPooledAddress =
1287 auto I = CUs.begin();
1289 return std::nullopt;
1290 return (*I)->getAddrOffsetSectionItem(
Index);
1293 if (shouldDump(Explicit,
".debug_rnglists", DIDT_ID_DebugRnglists,
1294 DObj->getRnglistsSection().Data)) {
1300 if (shouldDump(ExplicitDWO,
".debug_rnglists.dwo", DIDT_ID_DebugRnglists,
1301 DObj->getRnglistsDWOSection().Data)) {
1307 if (shouldDump(Explicit,
".debug_pubnames", DIDT_ID_DebugPubnames,
1308 DObj->getPubnamesSection().Data)) {
1314 if (shouldDump(Explicit,
".debug_pubtypes", DIDT_ID_DebugPubtypes,
1315 DObj->getPubtypesSection().Data)) {
1321 if (shouldDump(Explicit,
".debug_gnu_pubnames", DIDT_ID_DebugGnuPubnames,
1322 DObj->getGnuPubnamesSection().Data)) {
1328 if (shouldDump(Explicit,
".debug_gnu_pubtypes", DIDT_ID_DebugGnuPubtypes,
1329 DObj->getGnuPubtypesSection().Data)) {
1335 if (shouldDump(Explicit,
".debug_str_offsets", DIDT_ID_DebugStrOffsets,
1336 DObj->getStrOffsetsSection().Data))
1338 OS, DumpOpts,
"debug_str_offsets", *DObj, DObj->getStrOffsetsSection(),
1340 if (shouldDump(ExplicitDWO,
".debug_str_offsets.dwo", DIDT_ID_DebugStrOffsets,
1341 DObj->getStrOffsetsDWOSection().Data))
1343 DObj->getStrOffsetsDWOSection(),
1347 if (shouldDump(Explicit,
".gdb_index", DIDT_ID_GdbIndex,
1348 DObj->getGdbIndexSection())) {
1352 if (shouldDump(Explicit,
".apple_names", DIDT_ID_AppleNames,
1353 DObj->getAppleNamesSection().Data))
1356 if (shouldDump(Explicit,
".apple_types", DIDT_ID_AppleTypes,
1357 DObj->getAppleTypesSection().Data))
1360 if (shouldDump(Explicit,
".apple_namespaces", DIDT_ID_AppleNamespaces,
1361 DObj->getAppleNamespacesSection().Data))
1364 if (shouldDump(Explicit,
".apple_objc", DIDT_ID_AppleObjC,
1365 DObj->getAppleObjCSection().Data))
1367 if (shouldDump(Explicit,
".debug_names", DIDT_ID_DebugNames,
1368 DObj->getNamesSection().Data))
1375 if (
const auto *R = TUI.getFromHash(Hash)) {
1376 if (TUI.getVersion() >= 5) {
1391 return State->getTypeUnitMap(IsDWO).lookup(Hash);
1398 if (
const auto *R = CUI.getFromHash(Hash))
1410 if (!DWOCU->getDWOId()) {
1411 if (std::optional<uint64_t> DWOId =
1412 toUnsigned(DWOCU->getUnitDIE().find(DW_AT_GNU_dwo_id)))
1413 DWOCU->setDWOId(*DWOId);
1418 if (DWOCU->getDWOId() == Hash)
1425 if (
auto *
CU = State->getNormalUnits().getUnitForOffset(
Offset))
1426 return CU->getDIEForOffset(
Offset);
1435 if (DumpOpts.
DumpType & DIDT_DebugCUIndex)
1437 if (DumpOpts.
DumpType & DIDT_DebugTUIndex)
1439 if (DumpOpts.
DumpType & DIDT_DebugInfo)
1441 if (DumpOpts.
DumpType & DIDT_DebugLine)
1443 if (DumpOpts.
DumpType & DIDT_DebugStrOffsets)
1451 return State->getCUIndex();
1455 return State->getTUIndex();
1459 return State->getGdbIndex();
1463 return State->getDebugAbbrev();
1467 return State->getDebugAbbrevDWO();
1471 return State->getDebugLoc();
1475 return State->getDebugAranges();
1480 return State->getDebugFrame(ParseCFIProgram);
1485 return State->getEHFrame(ParseCFIProgram);
1489 return State->getDebugMacro();
1493 return State->getDebugMacroDWO();
1497 return State->getDebugMacinfo();
1501 return State->getDebugMacinfoDWO();
1506 return State->getDebugNames();
1510 return State->getAppleNames();
1514 return State->getAppleTypes();
1518 return State->getAppleNamespaces();
1522 return State->getAppleObjC();
1529 if (!ExpectedLineTable) {
1530 WarningHandler(ExpectedLineTable.
takeError());
1533 return *ExpectedLineTable;
1538 return State->getLineTableForUnit(U, RecoverableErrorHandler);
1542 return State->clearLineTableForUnit(U);
1546 return State->getDWOUnits(Lazy);
1550 return State->getNormalUnits().getUnitForOffset(
Offset);
1578 if (
CU->getVariableForAddress(
Address)) {
1598 DWARFDie CUDwoDie =
CU->getNonSkeletonUnitDIE(
false);
1599 if (CheckDWO && CUDwoDie && CUDie != CUDwoDie) {
1605 if (Result.FunctionDIE)
1606 Result.CompileUnit = CUDwo;
1614 Result.CompileUnit =
CU;
1615 Result.FunctionDIE =
CU->getSubroutineForAddress(
Address);
1618 std::vector<DWARFDie> Worklist;
1619 Worklist.push_back(Result.FunctionDIE);
1620 while (!Worklist.empty()) {
1622 Worklist.pop_back();
1627 if (
DIE.
getTag() == DW_TAG_lexical_block &&
1629 Result.BlockDIE =
DIE;
1644 std::string &FunctionName, std::string &StartFile,
uint32_t &StartLine,
1645 std::optional<uint64_t> &StartAddress) {
1650 CU->getInlinedChainForAddress(Address, InlinedChain);
1651 if (InlinedChain.
empty())
1655 bool FoundResult =
false;
1656 const char *Name =
nullptr;
1657 if (
Kind != FunctionNameKind::None && (Name =
DIE.getSubroutineName(
Kind))) {
1658 FunctionName = Name;
1661 std::string DeclFile =
DIE.getDeclFile(FileNameKind);
1662 if (!DeclFile.empty()) {
1663 StartFile = DeclFile;
1666 if (
auto DeclLineResult =
DIE.getDeclLine()) {
1667 StartLine = DeclLineResult;
1671 StartAddress = LowPcAddr->Address;
1675static std::optional<int64_t>
1677 std::optional<unsigned> FrameBaseReg) {
1678 if (!Expr.
empty() &&
1679 (Expr[0] == DW_OP_fbreg ||
1680 (FrameBaseReg && Expr[0] == DW_OP_breg0 + *FrameBaseReg))) {
1691 return std::nullopt;
1695 DWARFDie Die, std::vector<DILocal> &Result) {
1696 if (Die.
getTag() == DW_TAG_variable ||
1697 Die.
getTag() == DW_TAG_formal_parameter) {
1702 std::optional<unsigned> FrameBaseReg;
1703 if (
auto FrameBase = Subprogram.
find(DW_AT_frame_base))
1704 if (std::optional<ArrayRef<uint8_t>> Expr = FrameBase->getAsBlock())
1705 if (!Expr->empty() && (*Expr)[0] >= DW_OP_reg0 &&
1706 (*Expr)[0] <= DW_OP_reg31) {
1707 FrameBaseReg = (*Expr)[0] - DW_OP_reg0;
1710 if (Expected<std::vector<DWARFLocationExpression>> Loc =
1712 for (
const auto &Entry : *Loc) {
1713 if (std::optional<int64_t> FrameOffset =
1715 Local.FrameOffset = *FrameOffset;
1725 if (
auto TagOffsetAttr = Die.
find(DW_AT_LLVM_tag_offset))
1726 Local.TagOffset = TagOffsetAttr->getAsUnsignedConstant();
1731 if (
auto NameAttr = Die.
find(DW_AT_name))
1736 if (
auto DeclFileAttr = Die.
find(DW_AT_decl_file)) {
1738 LT->getFileNameByIndex(
1743 if (
auto DeclLineAttr = Die.
find(DW_AT_decl_line))
1744 Local.DeclLine = *DeclLineAttr->getAsUnsignedConstant();
1750 if (Die.
getTag() == DW_TAG_inlined_subroutine)
1753 Subprogram = Origin;
1755 for (
auto Child : Die)
1756 addLocalsForDie(CU, Subprogram, Child, Result);
1761 std::vector<DILocal> Result;
1768 addLocalsForDie(
CU, Subprogram, Subprogram, Result);
1772std::optional<DILineInfo>
1777 return std::nullopt;
1782 Result.StartFileName, Result.StartLine, Result.StartAddress);
1783 if (
Spec.FLIKind != FileLineInfoKind::None) {
1785 LineTable->getFileLineInfoForAddress(
1787 CU->getCompilationDir(),
Spec.FLIKind, Result);
1794std::optional<DILineInfo>
1802 Result.FileName = Die.
getDeclFile(FileLineInfoKind::AbsoluteFilePath);
1817 std::string StartFileName;
1819 std::optional<uint64_t> StartAddress;
1821 Spec.FLIKind, FunctionName,
1822 StartFileName, StartLine, StartAddress);
1826 if (
Spec.FLIKind == FileLineInfoKind::None) {
1828 Result.FunctionName = FunctionName;
1829 Result.StartFileName = StartFileName;
1830 Result.StartLine = StartLine;
1831 Result.StartAddress = StartAddress;
1832 Lines.push_back(std::make_pair(
Address.Address, Result));
1839 std::vector<uint32_t> RowVector;
1845 for (
uint32_t RowIndex : RowVector) {
1850 Spec.FLIKind, Result.FileName);
1851 Result.FunctionName = FunctionName;
1852 Result.Line = Row.Line;
1853 Result.Column = Row.Column;
1854 Result.StartFileName = StartFileName;
1855 Result.StartLine = StartLine;
1856 Result.StartAddress = StartAddress;
1857 Lines.push_back(std::make_pair(Row.Address.Address, Result));
1870 return InliningInfo;
1874 CU->getInlinedChainForAddress(
Address.Address, InlinedChain);
1875 if (InlinedChain.
size() == 0) {
1878 if (
Spec.FLIKind != FileLineInfoKind::None) {
1883 {Address.Address, Address.SectionIndex},
Spec.ApproximateLine,
1884 CU->getCompilationDir(),
Spec.FLIKind, Frame))
1887 return InliningInfo;
1890 uint32_t CallFile = 0, CallLine = 0, CallColumn = 0, CallDiscriminator = 0;
1891 for (
uint32_t i = 0, n = InlinedChain.
size(); i != n; i++) {
1892 DWARFDie &FunctionDIE = InlinedChain[i];
1897 if (
auto DeclLineResult = FunctionDIE.
getDeclLine())
1902 if (
Spec.FLIKind != FileLineInfoKind::None) {
1911 CU->getCompilationDir(),
Spec.FLIKind, Frame);
1918 Frame.
Line = CallLine;
1919 Frame.
Column = CallColumn;
1930 return InliningInfo;
1933std::shared_ptr<DWARFContext>
1935 return State->getDWOContext(AbsolutePath);
1955 std::map<SymbolRef, SymInfo> &Cache) {
1960 std::map<SymbolRef, SymInfo>::iterator CacheIt = Cache.end();
1963 if (Sym != Obj.symbol_end()) {
1965 std::tie(CacheIt, New) = Cache.try_emplace(*Sym);
1967 return CacheIt->second;
1971 return createError(
"failed to compute symbol address: ",
1977 return createError(
"failed to get symbol section: ",
1978 SectOrErr.takeError());
1983 RSec = MObj->getRelocationSection(
Reloc.getRawDataRefImpl());
1987 if (RSec != Obj.section_end())
1997 if (L && RSec != Obj.section_end())
1998 if (
uint64_t SectionLoadAddress = L->getSectionLoadAddress(*RSec))
2001 if (CacheIt != Cache.end())
2002 CacheIt->second = Ret;
2023class DWARFObjInMemory final :
public DWARFObject {
2024 bool IsLittleEndian;
2025 uint8_t AddressSize;
2027 const object::ObjectFile *
Obj =
nullptr;
2030 using InfoSectionMap = MapVector<object::SectionRef, DWARFSectionMap,
2031 std::map<object::SectionRef, unsigned>>;
2033 InfoSectionMap InfoSections;
2034 InfoSectionMap TypesSections;
2035 InfoSectionMap InfoDWOSections;
2036 InfoSectionMap TypesDWOSections;
2038 DWARFSectionMap LocSection;
2039 DWARFSectionMap LoclistsSection;
2040 DWARFSectionMap LoclistsDWOSection;
2041 DWARFSectionMap LineSection;
2042 DWARFSectionMap RangesSection;
2043 DWARFSectionMap RnglistsSection;
2044 DWARFSectionMap StrOffsetsSection;
2045 DWARFSectionMap LineDWOSection;
2046 DWARFSectionMap FrameSection;
2047 DWARFSectionMap EHFrameSection;
2048 DWARFSectionMap LocDWOSection;
2049 DWARFSectionMap StrOffsetsDWOSection;
2050 DWARFSectionMap RangesDWOSection;
2051 DWARFSectionMap RnglistsDWOSection;
2052 DWARFSectionMap AddrSection;
2053 DWARFSectionMap AppleNamesSection;
2054 DWARFSectionMap AppleTypesSection;
2055 DWARFSectionMap AppleNamespacesSection;
2056 DWARFSectionMap AppleObjCSection;
2057 DWARFSectionMap NamesSection;
2058 DWARFSectionMap PubnamesSection;
2059 DWARFSectionMap PubtypesSection;
2060 DWARFSectionMap GnuPubnamesSection;
2061 DWARFSectionMap GnuPubtypesSection;
2062 DWARFSectionMap MacroSection;
2064 DWARFSectionMap *mapNameToDWARFSection(StringRef Name) {
2065 return StringSwitch<DWARFSectionMap *>(Name)
2066 .Case(
"debug_loc", &LocSection)
2067 .Case(
"debug_loclists", &LoclistsSection)
2068 .Case(
"debug_loclists.dwo", &LoclistsDWOSection)
2069 .Case(
"debug_line", &LineSection)
2070 .Case(
"debug_frame", &FrameSection)
2071 .Case(
"eh_frame", &EHFrameSection)
2072 .Case(
"debug_str_offsets", &StrOffsetsSection)
2073 .Case(
"debug_ranges", &RangesSection)
2074 .Case(
"debug_rnglists", &RnglistsSection)
2075 .Case(
"debug_loc.dwo", &LocDWOSection)
2076 .Case(
"debug_line.dwo", &LineDWOSection)
2077 .Case(
"debug_names", &NamesSection)
2078 .Case(
"debug_rnglists.dwo", &RnglistsDWOSection)
2079 .Case(
"debug_str_offsets.dwo", &StrOffsetsDWOSection)
2080 .Case(
"debug_addr", &AddrSection)
2081 .Case(
"apple_names", &AppleNamesSection)
2082 .Case(
"debug_pubnames", &PubnamesSection)
2083 .Case(
"debug_pubtypes", &PubtypesSection)
2084 .Case(
"debug_gnu_pubnames", &GnuPubnamesSection)
2085 .Case(
"debug_gnu_pubtypes", &GnuPubtypesSection)
2086 .Case(
"apple_types", &AppleTypesSection)
2087 .Case(
"apple_namespaces", &AppleNamespacesSection)
2088 .Case(
"apple_namespac", &AppleNamespacesSection)
2089 .Case(
"apple_objc", &AppleObjCSection)
2090 .Case(
"debug_macro", &MacroSection)
2094 StringRef AbbrevSection;
2095 StringRef ArangesSection;
2096 StringRef StrSection;
2097 StringRef MacinfoSection;
2098 StringRef MacinfoDWOSection;
2099 StringRef MacroDWOSection;
2100 StringRef AbbrevDWOSection;
2101 StringRef StrDWOSection;
2102 StringRef CUIndexSection;
2103 StringRef GdbIndexSection;
2104 StringRef TUIndexSection;
2105 StringRef LineStrSection;
2109 std::deque<SmallString<0>> UncompressedSections;
2111 StringRef *mapSectionToMember(StringRef Name) {
2112 if (DWARFSection *Sec = mapNameToDWARFSection(Name))
2114 return StringSwitch<StringRef *>(Name)
2115 .Case(
"debug_abbrev", &AbbrevSection)
2116 .Case(
"debug_aranges", &ArangesSection)
2117 .Case(
"debug_str", &StrSection)
2118 .Case(
"debug_macinfo", &MacinfoSection)
2119 .Case(
"debug_macinfo.dwo", &MacinfoDWOSection)
2120 .Case(
"debug_macro.dwo", &MacroDWOSection)
2121 .Case(
"debug_abbrev.dwo", &AbbrevDWOSection)
2122 .Case(
"debug_str.dwo", &StrDWOSection)
2123 .Case(
"debug_cu_index", &CUIndexSection)
2124 .Case(
"debug_tu_index", &TUIndexSection)
2125 .Case(
"gdb_index", &GdbIndexSection)
2126 .Case(
"debug_line_str", &LineStrSection)
2133 Error maybeDecompress(
const object::SectionRef &Sec, StringRef Name,
2138 Expected<Decompressor> Decompressor =
2144 if (
auto Err = Decompressor->resizeAndDecompress(Out))
2147 UncompressedSections.push_back(std::move(Out));
2148 Data = UncompressedSections.back();
2154 DWARFObjInMemory(
const StringMap<std::unique_ptr<MemoryBuffer>> &Sections,
2155 uint8_t AddrSize,
bool IsLittleEndian)
2156 : IsLittleEndian(IsLittleEndian) {
2157 for (
const auto &SecIt : Sections) {
2158 if (StringRef *SectionData = mapSectionToMember(SecIt.first()))
2159 *SectionData = SecIt.second->getBuffer();
2160 else if (SecIt.first() ==
"debug_info")
2163 InfoSections[SectionRef()].Data = SecIt.second->getBuffer();
2164 else if (SecIt.first() ==
"debug_info.dwo")
2165 InfoDWOSections[SectionRef()].Data = SecIt.second->getBuffer();
2166 else if (SecIt.first() ==
"debug_types")
2167 TypesSections[SectionRef()].Data = SecIt.second->getBuffer();
2168 else if (SecIt.first() ==
"debug_types.dwo")
2169 TypesDWOSections[SectionRef()].Data = SecIt.second->getBuffer();
2172 DWARFObjInMemory(
const object::ObjectFile &Obj,
const LoadedObjectInfo *L,
2173 function_ref<
void(
Error)> HandleError,
2174 function_ref<
void(
Error)> HandleWarning,
2176 : IsLittleEndian(
Obj.isLittleEndian()),
2180 StringMap<unsigned> SectionAmountMap;
2181 for (
const SectionRef &Section :
Obj.sections()) {
2183 if (auto NameOrErr = Section.getName())
2186 consumeError(NameOrErr.takeError());
2188 ++SectionAmountMap[Name];
2189 SectionNames.push_back({ Name, true });
2200 Expected<section_iterator> SecOrErr =
Section.getRelocatedSection();
2202 HandleError(
createError(
"failed to get relocated section: ",
2203 SecOrErr.takeError()));
2211 Obj.isRelocatableObject() ? *SecOrErr :
Obj.section_end();
2212 if (!L || !
L->getLoadedSectionContents(*RelocatedSection,
Data)) {
2213 Expected<StringRef> E = Section.getContents();
2218 consumeError(E.takeError());
2221 if (
auto Err = maybeDecompress(Section, Name,
Data)) {
2222 HandleError(
createError(
"failed to decompress '" + Name +
"', ",
2230 Name =
Obj.mapDebugSectionName(Name);
2232 if (StringRef *SectionData = mapSectionToMember(Name)) {
2233 *SectionData =
Data;
2234 if (Name ==
"debug_ranges") {
2236 RangesDWOSection.Data =
Data;
2237 }
else if (Name ==
"debug_frame" || Name ==
"eh_frame") {
2238 if (DWARFSection *S = mapNameToDWARFSection(Name))
2241 }
else if (InfoSectionMap *Sections =
2242 StringSwitch<InfoSectionMap *>(Name)
2243 .Case(
"debug_info", &InfoSections)
2244 .Case(
"debug_info.dwo", &InfoDWOSections)
2245 .Case(
"debug_types", &TypesSections)
2246 .Case(
"debug_types.dwo", &TypesDWOSections)
2250 DWARFSectionMap &S = (*Sections)[
Section];
2254 if (RelocatedSection ==
Obj.section_end() ||
2255 (RelocAction == DWARFContext::ProcessDebugRelocations::Ignore))
2258 StringRef RelSecName;
2259 if (
auto NameOrErr = RelocatedSection->
getName())
2260 RelSecName = *NameOrErr;
2267 StringRef RelSecData;
2268 if (L &&
L->getLoadedSectionContents(*RelocatedSection, RelSecData))
2279 if (!
Section.relocations().empty() &&
Name.ends_with(
".dwo") &&
2280 RelSecName.starts_with(
".debug")) {
2281 HandleWarning(createError(
"unexpected relocations for dwo section '" +
2287 RelSecName = RelSecName.substr(RelSecName.find_first_not_of(
"._"));
2288 DWARFSectionMap *Sec = mapNameToDWARFSection(RelSecName);
2293 if (RelSecName ==
"debug_info")
2294 Map = &
static_cast<DWARFSectionMap &
>(InfoSections[*RelocatedSection])
2296 else if (RelSecName ==
"debug_types")
2298 &
static_cast<DWARFSectionMap &
>(TypesSections[*RelocatedSection])
2304 if (
Section.relocations().empty())
2308 std::map<SymbolRef, SymInfo> AddrCache;
2312 for (
const RelocationRef &Reloc :
Section.relocations()) {
2315 if (isRelocScattered(Obj, Reloc))
2318 Expected<SymInfo> SymInfoOrErr =
2319 getSymbolInfo(Obj, Reloc, L, AddrCache);
2320 if (!SymInfoOrErr) {
2321 HandleError(SymInfoOrErr.takeError());
2329 if (Supports && Supports(Reloc.getType())) {
2330 auto I = Map->try_emplace(
2333 SymInfoOrErr->SectionIndex, Reloc, SymInfoOrErr->Address,
2334 std::optional<object::RelocationRef>(), 0, Resolver});
2339 RelocAddrEntry &entry = I.first->getSecond();
2341 HandleError(createError(
2342 "At most two relocations per offset are supported"));
2344 entry.Reloc2 = Reloc;
2345 entry.SymbolValue2 = SymInfoOrErr->Address;
2359 if (SectionAmountMap[S.Name] > 1)
2360 S.IsNameUnique =
false;
2365 auto &Sec =
static_cast<const DWARFSectionMap &
>(S);
2367 if (AI == Sec.Relocs.end())
2368 return std::nullopt;
2378 bool isLittleEndian()
const override {
return IsLittleEndian; }
2379 StringRef getAbbrevDWOSection()
const override {
return AbbrevDWOSection; }
2380 const DWARFSection &getLineDWOSection()
const override {
2381 return LineDWOSection;
2383 const DWARFSection &getLocDWOSection()
const override {
2384 return LocDWOSection;
2386 StringRef getStrDWOSection()
const override {
return StrDWOSection; }
2387 const DWARFSection &getStrOffsetsDWOSection()
const override {
2388 return StrOffsetsDWOSection;
2390 const DWARFSection &getRangesDWOSection()
const override {
2391 return RangesDWOSection;
2393 const DWARFSection &getRnglistsDWOSection()
const override {
2394 return RnglistsDWOSection;
2396 const DWARFSection &getLoclistsDWOSection()
const override {
2397 return LoclistsDWOSection;
2399 const DWARFSection &getAddrSection()
const override {
return AddrSection; }
2400 StringRef getCUIndexSection()
const override {
return CUIndexSection; }
2401 StringRef getGdbIndexSection()
const override {
return GdbIndexSection; }
2402 StringRef getTUIndexSection()
const override {
return TUIndexSection; }
2405 const DWARFSection &getStrOffsetsSection()
const override {
2406 return StrOffsetsSection;
2408 StringRef getLineStrSection()
const override {
return LineStrSection; }
2411 void forEachInfoDWOSections(
2413 for (
auto &
P : InfoDWOSections)
2416 void forEachTypesDWOSections(
2418 for (
auto &
P : TypesDWOSections)
2422 StringRef getAbbrevSection()
const override {
return AbbrevSection; }
2423 const DWARFSection &getLocSection()
const override {
return LocSection; }
2424 const DWARFSection &getLoclistsSection()
const override {
return LoclistsSection; }
2425 StringRef getArangesSection()
const override {
return ArangesSection; }
2427 return FrameSection;
2430 return EHFrameSection;
2432 const DWARFSection &getLineSection()
const override {
return LineSection; }
2433 StringRef getStrSection()
const override {
return StrSection; }
2434 const DWARFSection &getRangesSection()
const override {
return RangesSection; }
2435 const DWARFSection &getRnglistsSection()
const override {
2436 return RnglistsSection;
2438 const DWARFSection &getMacroSection()
const override {
return MacroSection; }
2439 StringRef getMacroDWOSection()
const override {
return MacroDWOSection; }
2440 StringRef getMacinfoSection()
const override {
return MacinfoSection; }
2441 StringRef getMacinfoDWOSection()
const override {
return MacinfoDWOSection; }
2442 const DWARFSection &getPubnamesSection()
const override {
return PubnamesSection; }
2443 const DWARFSection &getPubtypesSection()
const override {
return PubtypesSection; }
2444 const DWARFSection &getGnuPubnamesSection()
const override {
2445 return GnuPubnamesSection;
2447 const DWARFSection &getGnuPubtypesSection()
const override {
2448 return GnuPubtypesSection;
2450 const DWARFSection &getAppleNamesSection()
const override {
2451 return AppleNamesSection;
2453 const DWARFSection &getAppleTypesSection()
const override {
2454 return AppleTypesSection;
2456 const DWARFSection &getAppleNamespacesSection()
const override {
2457 return AppleNamespacesSection;
2459 const DWARFSection &getAppleObjCSection()
const override {
2460 return AppleObjCSection;
2463 return NamesSection;
2467 uint8_t getAddressSize()
const override {
return AddressSize; }
2468 void forEachInfoSections(
2470 for (
auto &
P : InfoSections)
2473 void forEachTypesSections(
2475 for (
auto &
P : TypesSections)
2481std::unique_ptr<DWARFContext>
2485 std::function<
void(
Error)> RecoverableErrorHandler,
2486 std::function<
void(
Error)> WarningHandler,
2488 auto DObj = std::make_unique<DWARFObjInMemory>(
2489 Obj, L, RecoverableErrorHandler, WarningHandler, RelocAction);
2490 return std::make_unique<DWARFContext>(std::move(DObj),
2492 RecoverableErrorHandler,
2497std::unique_ptr<DWARFContext>
2500 std::function<
void(
Error)> RecoverableErrorHandler,
2501 std::function<
void(
Error)> WarningHandler,
2504 std::make_unique<DWARFObjInMemory>(Sections, AddrSize,
isLittleEndian);
2505 return std::make_unique<DWARFContext>(
2506 std::move(DObj),
"", RecoverableErrorHandler, WarningHandler, ThreadSafe);
2516 return CUs.empty() ? 0 : (*CUs.begin())->getAddressByteSize();
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< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static Expected< StringRef > getFileName(const DebugStringTableSubsectionRef &Strings, const DebugChecksumsSubsectionRef &Checksums, uint32_t FileID)
static void dumpLoclistsSection(raw_ostream &OS, DIDumpOptions DumpOpts, DWARFDataExtractor Data, const DWARFObject &Obj, std::optional< uint64_t > DumpOffset)
static void dumpRnglistsSection(raw_ostream &OS, DWARFDataExtractor &rnglistData, llvm::function_ref< std::optional< object::SectionedAddress >(uint32_t)> LookupPooledAddress, DIDumpOptions DumpOpts)
static void dumpUUID(raw_ostream &OS, const ObjectFile &Obj)
Dump the UUID load command.
static bool getFunctionNameAndStartLineForAddress(DWARFCompileUnit *CU, uint64_t Address, FunctionNameKind Kind, DILineInfoSpecifier::FileLineInfoKind FileNameKind, std::string &FunctionName, std::string &StartFile, uint32_t &StartLine, std::optional< uint64_t > &StartAddress)
TODO: change input parameter from "uint64_t Address" into "SectionedAddress Address".
static void dumpPubTableSection(raw_ostream &OS, DIDumpOptions DumpOpts, DWARFDataExtractor Data, bool GnuStyle)
void fixupIndex(DWARFContext &C, DWARFUnitIndex &Index)
static Expected< SymInfo > getSymbolInfo(const object::ObjectFile &Obj, const RelocationRef &Reloc, const LoadedObjectInfo *L, std::map< SymbolRef, SymInfo > &Cache)
Returns the address of symbol relocation used against and a section index.
static void dumpAddrSection(raw_ostream &OS, DWARFDataExtractor &AddrData, DIDumpOptions DumpOpts, uint16_t Version, uint8_t AddrSize)
static T & getAccelTable(std::unique_ptr< T > &Cache, const DWARFObject &Obj, const DWARFSection &Section, StringRef StringSection, bool IsLittleEndian)
void fixupIndexV4(DWARFContext &C, DWARFUnitIndex &Index)
static ContributionCollection collectContributionData(DWARFContext::unit_iterator_range Units)
std::vector< std::optional< StrOffsetsContributionDescriptor > > ContributionCollection
DWARFDebugLine::LineTable DWARFLineTable
static bool isRelocScattered(const object::ObjectFile &Obj, const RelocationRef &Reloc)
static std::optional< int64_t > getExpressionFrameOffset(ArrayRef< uint8_t > Expr, std::optional< unsigned > FrameBaseReg)
void fixupIndexV5(DWARFContext &C, DWARFUnitIndex &Index)
static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts, StringRef SectionName, const DWARFObject &Obj, const DWARFSection &StringOffsetsSection, StringRef StringSection, DWARFContext::unit_iterator_range Units, bool LittleEndian)
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
This file contains constants used for implementing Dwarf debug support.
This file implements a map that provides insertion order iteration.
This file defines the SmallString class.
This file defines the SmallVector class.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
std::pair< llvm::MachO::Target, std::string > UUID
This implements the Apple accelerator table format, a precursor of the DWARF 5 accelerator table form...
void dump(raw_ostream &OS) const override
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
DIContext(DIContextKind K)
A structured debug information entry.
dwarf::Tag getTag() const
A format-neutral container for inlined code description.
void addFrame(const DILineInfo &Frame)
DWARFContextState This structure contains all member variables for DWARFContext that need to be prote...
MacroSecType
Helper enum to distinguish between macro[.dwo] and macinfo[.dwo] section.
LLVM_ABI std::unique_ptr< DWARFDebugMacro > parseMacroOrMacinfo(MacroSecType SectionType)
Parse a macro[.dwo] or macinfo[.dwo] section.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
DWARFCompileUnit * getCompileUnitForCodeAddress(uint64_t Address)
Return the compile unit which contains instruction with provided address.
uint8_t getCUAddrSize()
Get address size from CUs.
std::optional< DILineInfo > getLineInfoForDataAddress(object::SectionedAddress Address) override
DIInliningInfo getInliningInfoForAddress(object::SectionedAddress Address, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
DWARFGdbIndex & getGdbIndex()
unsigned getNumCompileUnits()
Get the number of compile units in this context.
DWARFContext(std::unique_ptr< const DWARFObject > DObj, std::string DWPName="", std::function< void(Error)> RecoverableErrorHandler=WithColor::defaultErrorHandler, std::function< void(Error)> WarningHandler=WithColor::defaultWarningHandler, bool ThreadSafe=false)
DWARFDie getDIEForOffset(uint64_t Offset)
Get a DIE given an exact offset.
unsigned getNumTypeUnits()
Get the number of type units in this context.
DWARFUnitVector::iterator_range unit_iterator_range
const DWARFDebugAbbrev * getDebugAbbrevDWO()
Get a pointer to the parsed dwo abbreviations object.
compile_unit_range compile_units()
Get compile units in this context.
const AppleAcceleratorTable & getAppleObjC()
Get a reference to the parsed accelerator table object.
const DWARFUnitIndex & getTUIndex()
DWARFCompileUnit * getCompileUnitForDataAddress(uint64_t Address)
Return the compile unit which contains data with the provided address.
const DWARFDebugAbbrev * getDebugAbbrev()
Get a pointer to the parsed DebugAbbrev object.
std::vector< DILocal > getLocalsForAddress(object::SectionedAddress Address) override
DWARFCompileUnit * getCompileUnitForOffset(uint64_t Offset)
Return the compile unit that includes an offset (relative to .debug_info).
const DWARFDebugNames & getDebugNames()
Get a reference to the parsed accelerator table object.
unsigned getNumDWOTypeUnits()
Get the number of type units in the DWO context.
const DWARFDebugMacro * getDebugMacroDWO()
Get a pointer to the parsed DebugMacroDWO information object.
DILineInfoTable getLineInfoForAddressRange(object::SectionedAddress Address, uint64_t Size, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
bool isDWP() const
Return true of this DWARF context is a DWP file.
bool isLittleEndian() const
const DWARFDebugLine::LineTable * getLineTableForUnit(DWARFUnit *U)
Get a pointer to a parsed line table corresponding to a compile unit.
void clearLineTableForUnit(DWARFUnit *U)
const AppleAcceleratorTable & getAppleTypes()
Get a reference to the parsed accelerator table object.
const AppleAcceleratorTable & getAppleNames()
Get a reference to the parsed accelerator table object.
DWARFUnit * getUnitForOffset(uint64_t Offset)
Return the DWARF unit that includes an offset (relative to .debug_info).
compile_unit_range dwo_compile_units()
Get compile units in the DWO context.
const DWARFDebugLoc * getDebugLoc()
Get a pointer to the parsed DebugLoc object.
const DWARFDebugMacro * getDebugMacinfoDWO()
Get a pointer to the parsed DebugMacinfoDWO information object.
bool verify(raw_ostream &OS, DIDumpOptions DumpOpts={}) override
unit_iterator_range dwo_types_section_units()
Get units from .debug_types.dwo in the DWO context.
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, std::array< std::optional< uint64_t >, DIDT_ID_Count > DumpOffsets)
Dump a textual representation to OS.
DWARFTypeUnit * getTypeUnitForHash(uint64_t Hash, bool IsDWO)
unit_iterator_range normal_units()
Get all normal compile/type units in this context.
unit_iterator_range types_section_units()
Get units from .debug_types in this context.
Expected< const DWARFDebugFrame * > getEHFrame(bool ParseCFIProgram=true)
Get a pointer to the parsed eh frame information object.
std::shared_ptr< DWARFContext > getDWOContext(StringRef AbsolutePath)
DWARFCompileUnit * getDWOCompileUnitForHash(uint64_t Hash)
unsigned getNumDWOCompileUnits()
Get the number of compile units in the DWO context.
const DWARFDebugAranges * getDebugAranges()
Get a pointer to the parsed DebugAranges object.
const DWARFUnitIndex & getCUIndex()
DIEsForAddress getDIEsForAddress(uint64_t Address, bool CheckDWO=false)
Get the compilation unit, the function DIE and lexical block DIE for the given address where applicab...
unit_iterator_range info_section_units()
Get units from .debug_info in this context.
unit_iterator_range dwo_info_section_units()
Get units from .debug_info..dwo in the DWO context.
const AppleAcceleratorTable & getAppleNamespaces()
Get a reference to the parsed accelerator table object.
Expected< const DWARFDebugFrame * > getDebugFrame(bool ParseCFIProgram=true)
Get a pointer to the parsed frame information object.
const DWARFDebugMacro * getDebugMacro()
Get a pointer to the parsed DebugMacro information object.
static std::unique_ptr< DWARFContext > create(const object::ObjectFile &Obj, ProcessDebugRelocations RelocAction=ProcessDebugRelocations::Process, const LoadedObjectInfo *L=nullptr, std::string DWPName="", std::function< void(Error)> RecoverableErrorHandler=WithColor::defaultErrorHandler, std::function< void(Error)> WarningHandler=WithColor::defaultWarningHandler, bool ThreadSafe=false)
const DWARFDebugMacro * getDebugMacinfo()
Get a pointer to the parsed DebugMacinfo information object.
unit_iterator_range dwo_units()
Get all units in the DWO context.
const DWARFObject & getDWARFObj() const
std::optional< DILineInfo > getLineInfoForAddress(object::SectionedAddress Address, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
LLVM_ABI void dump(raw_ostream &OS) const
A class representing an address table as specified in DWARF v5.
LLVM_ABI void dump(raw_ostream &OS, DIDumpOptions DumpOpts={}) const
LLVM_ABI Error extract(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, uint16_t CUVersion, uint8_t CUAddrSize, std::function< void(Error)> WarnCallback)
Extract the entire table, including all addresses.
LLVM_ABI std::optional< uint64_t > getFullLength() const
Return the full length of this table, including the length field.
LLVM_ABI void dump(raw_ostream &OS) const
LLVM_ABI Error extract(DWARFDataExtractor data, uint64_t *offset_ptr, function_ref< void(Error)> WarningHandler=nullptr)
LLVM_ABI uint64_t findAddress(uint64_t Address) const
Helper to allow for parsing of an entire .debug_line section in sequence.
void dump(raw_ostream &OS, const DWARFObject &Obj, DIDumpOptions DumpOpts, std::optional< uint64_t > Offset) const
Print the location lists found within the debug_loc section.
.debug_names section consists of one or more units.
void dump(raw_ostream &OS) const override
Represents structure for holding and parsing .debug_pub* tables.
LLVM_ABI Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr)
LLVM_ABI void dump(raw_ostream &OS) const
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
LLVM_ABI DWARFDie getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE as the referenced DIE.
LLVM_ABI std::optional< DWARFFormValue > find(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE.
DWARFUnit * getDwarfUnit() const
LLVM_ABI const char * getSubroutineName(DINameKind Kind) const
If a DIE represents a subprogram (or inlined subroutine), returns its mangled name (or short name,...
LLVM_ABI void getCallerFrame(uint32_t &CallFile, uint32_t &CallLine, uint32_t &CallColumn, uint32_t &CallDiscriminator) const
Retrieves values of DW_AT_call_file, DW_AT_call_line and DW_AT_call_column from DIE (or zeroes if the...
LLVM_ABI std::string getDeclFile(DILineInfoSpecifier::FileLineInfoKind Kind) const
LLVM_ABI uint64_t getDeclLine() const
Returns the declaration line (start line) for a DIE, assuming it specifies a subprogram.
dwarf::Tag getTag() const
LLVM_ABI Expected< DWARFLocationExpressionsVector > getLocations(dwarf::Attribute Attr) const
LLVM_ABI void dump(raw_ostream &OS, unsigned indent=0, DIDumpOptions DumpOpts=DIDumpOptions()) const
Dump the DIE and all of its attributes to the supplied stream.
LLVM_ABI void dump(raw_ostream &OS)
Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr)
Extract an entire table, including all list entries.
void dump(DWARFDataExtractor Data, raw_ostream &OS, llvm::function_ref< std::optional< object::SectionedAddress >(uint32_t)> LookupPooledAddress, DIDumpOptions DumpOpts={}) const
virtual StringRef getFileName() const
virtual StringRef getAbbrevDWOSection() const
virtual const DWARFSection & getFrameSection() const
virtual const DWARFSection & getNamesSection() const
virtual const DWARFSection & getAppleNamespacesSection() const
virtual void forEachInfoDWOSections(function_ref< void(const DWARFSection &)> F) const
virtual const DWARFSection & getAppleTypesSection() const
virtual void forEachInfoSections(function_ref< void(const DWARFSection &)> F) const
virtual const DWARFSection & getAppleNamesSection() const
virtual const DWARFSection & getEHFrameSection() const
virtual void forEachTypesSections(function_ref< void(const DWARFSection &)> F) const
virtual const DWARFSection & getLocSection() const
virtual const DWARFSection & getAppleObjCSection() const
virtual void forEachTypesDWOSections(function_ref< void(const DWARFSection &)> F) const
virtual StringRef getStrSection() const
virtual uint8_t getAddressSize() const
void setOffset(uint64_t Value)
uint64_t getOffset() const
LLVM_ABI void dump(raw_ostream &OS) const
Describe a collection of units.
void finishedInfoUnits()
Indicate that parsing .debug_info[.dwo] is done, and remaining units will be from ....
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 void addUnitsForDWOSection(DWARFContext &C, const DWARFSection &DWOSection, DWARFSectionKind SectionKind, bool Lazy=false)
Read units from a .debug_info.dwo or .debug_types.dwo section.
DWARFContext & getContext() const
void clearDWO()
Release the DWO context owned by this skeleton unit, freeing the memory held by its DWARFContext and ...
DWARFDie getDIEForOffset(uint64_t Offset)
Return the DIE object for a given offset Offset inside the unit's DIE vector.
const char * getCompilationDir()
DWARFUnit * getDWO() const
Return the split unit this skeleton unit currently owns, or null if its DWO context is not open.
DWARFDie getSubroutineForAddress(uint64_t Address)
Returns subprogram DIE with address range encompassing the provided address.
A class that verifies DWARF debug information given a DWARF Context.
LLVM_ABI bool handleAccelTables()
Verify the information in accelerator tables, if they exist.
LLVM_ABI bool handleDebugTUIndex()
Verify the information in the .debug_tu_index section.
LLVM_ABI bool handleDebugStrOffsets()
Verify the information in the .debug_str_offsets[.dwo].
LLVM_ABI bool handleDebugCUIndex()
Verify the information in the .debug_cu_index section.
LLVM_ABI bool handleDebugInfo()
Verify the information in the .debug_info and .debug_types sections.
LLVM_ABI bool handleDebugLine()
Verify the information in the .debug_line section.
LLVM_ABI void summarize()
Emits any aggregate information collected, depending on the dump options.
LLVM_ABI bool handleDebugAbbrev()
Verify the information in any of the following sections, if available: .debug_abbrev,...
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT, true > const_iterator
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.
An inferface for inquiring the load address of a loaded object file to be used by the DIContext imple...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Represent a constant reference to a string, i.e.
constexpr size_t size() const
Get the string size.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Twine utohexstr(uint64_t Val)
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI void defaultWarningHandler(Error Warning)
Implement default handling for Warning.
static LLVM_ABI void defaultErrorHandler(Error Err)
Implement default handling for Error.
An efficient, type-erasing, non-owning reference to a callable.
static LLVM_ABI Expected< Decompressor > create(StringRef Name, StringRef Data, bool IsLE, bool Is64Bit)
Create decompressor object.
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const
bool isRelocationScattered(const MachO::any_relocation_info &RE) const
This class is the base class for all object file types.
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
This is a value type class that represents a single relocation in the list of relocations in the obje...
uint64_t getIndex() const
bool isCompressed() const
uint64_t getAddress() const
Expected< StringRef > getName() const
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write_uuid(const uuid_t UUID)
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '\t', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an esca...
uint8_t[16] uuid_t
Output a formatted UUID with dash separators.
LLVM_ABI StringRef FormatString(DwarfFormat Format)
static constexpr StringLiteral SectionNames[SectionKindsNum]
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.
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
std::optional< uint64_t > toUnsigned(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an unsigned constant.
LLVM_ABI Section * getEHFrameSection(LinkGraph &G)
Returns a pointer to the DWARF eh-frame section if the graph contains a non-empty one,...
content_iterator< SectionRef > section_iterator
Error createError(const Twine &Err)
uint64_t(*)(uint64_t Type, uint64_t Offset, uint64_t S, uint64_t LocData, int64_t Addend) RelocationResolver
LLVM_ABI std::pair< SupportsRelocation, RelocationResolver > getRelocationResolver(const ObjectFile &Obj)
bool(*)(uint64_t) SupportsRelocation
LLVM_ABI StringRef extension(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get extension.
SmartMutex< false > Mutex
Mutex - A standard, always enforced mutex.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
SmallVector< std::pair< uint64_t, DILineInfo >, 16 > DILineInfoTable
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
int64_t decodeSLEB128(const uint8_t *p, unsigned *n=nullptr, const uint8_t *end=nullptr, const char **error=nullptr)
Utility function to decode a SLEB128 value.
auto unique(Range &&R, Predicate P)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
auto dyn_cast_or_null(const Y &Val)
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void sort(IteratorTy Start, IteratorTy End)
static Error createError(const Twine &Err)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Success
The lock was released successfully.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
support::detail::AlignAdapter< T > fmt_align(T &&Item, AlignStyle Where, size_t Amount, char Fill=' ')
LLVM_ABI Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
DenseMap< uint64_t, RelocAddrEntry > RelocAddrMap
In place of applying the relocations to the data we've read from disk we use a separate mapping table...
void consumeError(Error Err)
Consume a Error without doing anything.
Implement std::hash so that hash_code can be used in STL containers.
SymInfo contains information about symbol: it's address and section index which is -1LL for absolute ...
Container for dump options that control which debug information will be dumped.
std::function< void(Error)> WarningHandler
std::function< void(Error)> RecoverableErrorHandler
DIDumpOptions noImplicitRecursion() const
Return the options with RecurseDepth set to 0 unless explicitly required.
Controls which fields of DILineInfo container should be filled with data.
DINameKind FunctionNameKind
A format-neutral container for source line information.
static constexpr const char *const BadString
std::optional< uint64_t > StartAddress
std::string StartFileName
Wraps the returned DIEs for a given address.
LLVM_ABI bool getFileLineInfoForAddress(object::SectionedAddress Address, bool Approximate, const char *CompDir, DILineInfoSpecifier::FileLineInfoKind Kind, DILineInfo &Result) const
Fills the Result argument with the file and line information corresponding to Address.
bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, DILineInfoSpecifier::FileLineInfoKind Kind, std::string &Result) const
Extracts filename by its index in filename table in prologue.
LLVM_ABI bool lookupAddressRange(object::SectionedAddress Address, uint64_t Size, std::vector< uint32_t > &Result, std::optional< uint64_t > StmtSequenceOffset=std::nullopt) const
Fills the Result argument with the indices of the rows that correspond to the address range specified...
Standard .debug_line state machine structure.