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);
441 Expected<const DWARFDebugFrame *> getDebugFrame()
override {
444 const DWARFObject &DObj =
D.getDWARFObj();
456 DWARFDataExtractor
Data(DObj, DS,
D.isLittleEndian(),
459 std::make_unique<DWARFDebugFrame>(
D.getArch(),
false,
468 Expected<const DWARFDebugFrame *> getEHFrame()
override {
470 return EHFrame.get();
471 const DWARFObject &DObj =
D.getDWARFObj();
474 DWARFDataExtractor
Data(DObj, DS,
D.isLittleEndian(),
477 std::make_unique<DWARFDebugFrame>(
D.getArch(),
true,
482 return EHFrame.get();
485 const DWARFDebugMacro *getDebugMacinfo()
override {
487 Macinfo = parseMacroOrMacinfo(MacinfoSection);
488 return Macinfo.get();
490 const DWARFDebugMacro *getDebugMacinfoDWO()
override {
492 MacinfoDWO = parseMacroOrMacinfo(MacinfoDwoSection);
493 return MacinfoDWO.get();
495 const DWARFDebugMacro *getDebugMacro()
override {
497 Macro = parseMacroOrMacinfo(MacroSection);
500 const DWARFDebugMacro *getDebugMacroDWO()
override {
502 MacroDWO = parseMacroOrMacinfo(MacroDwoSection);
503 return MacroDWO.get();
505 const DWARFDebugNames &getDebugNames()
override {
506 const DWARFObject &DObj =
D.getDWARFObj();
510 const AppleAcceleratorTable &getAppleNames()
override {
511 const DWARFObject &DObj =
D.getDWARFObj();
516 const AppleAcceleratorTable &getAppleTypes()
override {
517 const DWARFObject &DObj =
D.getDWARFObj();
522 const AppleAcceleratorTable &getAppleNamespaces()
override {
523 const DWARFObject &DObj =
D.getDWARFObj();
529 const AppleAcceleratorTable &getAppleObjC()
override {
530 const DWARFObject &DObj =
D.getDWARFObj();
535 std::shared_ptr<DWARFContext>
536 getDWOContext(StringRef AbsolutePath)
override {
537 if (
auto S = DWP.lock()) {
538 DWARFContext *Ctxt = S->Context.get();
539 return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
542 std::weak_ptr<DWOFile> *
Entry = &DWOFiles[AbsolutePath];
544 if (
auto S =
Entry->lock()) {
545 DWARFContext *Ctxt = S->Context.get();
546 return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
549 const DWARFObject &DObj =
D.getDWARFObj();
551 Expected<OwningBinary<ObjectFile>>
Obj = [&] {
552 if (!CheckedForDWP) {
553 SmallString<128> DWPName;
555 this->DWPName.
empty()
556 ? (DObj.
getFileName() +
".dwp").toStringRef(DWPName)
557 : StringRef(this->DWPName));
562 CheckedForDWP =
true;
578 auto S = std::make_shared<DWOFile>();
579 S->File = std::move(
Obj.get());
582 bool ThreadSafe = isThreadSafe();
584 *S->File.getBinary(), DWARFContext::ProcessDebugRelocations::Ignore,
588 auto *Ctxt = S->Context.get();
589 return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
592 bool isThreadSafe()
const override {
return false; }
594 const DenseMap<uint64_t, DWARFTypeUnit *> &getNormalTypeUnitMap() {
595 if (!NormalTypeUnits) {
596 NormalTypeUnits.emplace();
597 for (
const auto &U :
D.normal_units()) {
599 (*NormalTypeUnits)[TU->getTypeHash()] = TU;
602 return *NormalTypeUnits;
605 const DenseMap<uint64_t, DWARFTypeUnit *> &getDWOTypeUnitMap() {
607 DWOTypeUnits.emplace();
608 for (
const auto &U :
D.dwo_units()) {
610 (*DWOTypeUnits)[TU->getTypeHash()] = TU;
613 return *DWOTypeUnits;
616 const DenseMap<uint64_t, DWARFTypeUnit *> &
617 getTypeUnitMap(
bool IsDWO)
override {
619 return getDWOTypeUnitMap();
621 return getNormalTypeUnitMap();
625class ThreadSafeState :
public ThreadUnsafeDWARFContextState {
626 std::recursive_mutex
Mutex;
629 ThreadSafeState(DWARFContext &DC, std::string &DWP) :
630 ThreadUnsafeDWARFContextState(DC, DWP) {}
632 DWARFUnitVector &getNormalUnits()
override {
633 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
634 return ThreadUnsafeDWARFContextState::getNormalUnits();
636 DWARFUnitVector &getDWOUnits(
bool Lazy)
override {
637 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
641 return ThreadUnsafeDWARFContextState::getDWOUnits(
false);
643 const DWARFUnitIndex &getCUIndex()
override {
644 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
645 return ThreadUnsafeDWARFContextState::getCUIndex();
647 const DWARFDebugAbbrev *getDebugAbbrevDWO()
override {
648 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
649 return ThreadUnsafeDWARFContextState::getDebugAbbrevDWO();
652 const DWARFUnitIndex &getTUIndex()
override {
653 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
654 return ThreadUnsafeDWARFContextState::getTUIndex();
656 DWARFGdbIndex &getGdbIndex()
override {
657 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
658 return ThreadUnsafeDWARFContextState::getGdbIndex();
660 const DWARFDebugAbbrev *getDebugAbbrev()
override {
661 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
662 return ThreadUnsafeDWARFContextState::getDebugAbbrev();
665 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
666 return ThreadUnsafeDWARFContextState::getDebugLoc();
668 const DWARFDebugAranges *getDebugAranges()
override {
669 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
670 return ThreadUnsafeDWARFContextState::getDebugAranges();
672 Expected<const DWARFDebugLine::LineTable *>
673 getLineTableForUnit(DWARFUnit *U, function_ref<
void(
Error)> RecoverableErrorHandler)
override {
674 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
675 return ThreadUnsafeDWARFContextState::getLineTableForUnit(U, RecoverableErrorHandler);
677 void clearLineTableForUnit(DWARFUnit *U)
override {
678 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
679 return ThreadUnsafeDWARFContextState::clearLineTableForUnit(U);
681 Expected<const DWARFDebugFrame *> getDebugFrame()
override {
682 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
683 return ThreadUnsafeDWARFContextState::getDebugFrame();
685 Expected<const DWARFDebugFrame *> getEHFrame()
override {
686 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
687 return ThreadUnsafeDWARFContextState::getEHFrame();
689 const DWARFDebugMacro *getDebugMacinfo()
override {
690 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
691 return ThreadUnsafeDWARFContextState::getDebugMacinfo();
693 const DWARFDebugMacro *getDebugMacinfoDWO()
override {
694 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
695 return ThreadUnsafeDWARFContextState::getDebugMacinfoDWO();
697 const DWARFDebugMacro *getDebugMacro()
override {
698 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
699 return ThreadUnsafeDWARFContextState::getDebugMacro();
701 const DWARFDebugMacro *getDebugMacroDWO()
override {
702 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
703 return ThreadUnsafeDWARFContextState::getDebugMacroDWO();
705 const DWARFDebugNames &getDebugNames()
override {
706 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
707 return ThreadUnsafeDWARFContextState::getDebugNames();
709 const AppleAcceleratorTable &getAppleNames()
override {
710 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
711 return ThreadUnsafeDWARFContextState::getAppleNames();
713 const AppleAcceleratorTable &getAppleTypes()
override {
714 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
715 return ThreadUnsafeDWARFContextState::getAppleTypes();
717 const AppleAcceleratorTable &getAppleNamespaces()
override {
718 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
719 return ThreadUnsafeDWARFContextState::getAppleNamespaces();
721 const AppleAcceleratorTable &getAppleObjC()
override {
722 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
723 return ThreadUnsafeDWARFContextState::getAppleObjC();
725 std::shared_ptr<DWARFContext>
726 getDWOContext(StringRef AbsolutePath)
override {
727 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
728 return ThreadUnsafeDWARFContextState::getDWOContext(AbsolutePath);
731 bool isThreadSafe()
const override {
return true; }
733 const DenseMap<uint64_t, DWARFTypeUnit *> &
734 getTypeUnitMap(
bool IsDWO)
override {
735 std::unique_lock<std::recursive_mutex> LockGuard(
Mutex);
736 return ThreadUnsafeDWARFContextState::getTypeUnitMap(IsDWO);
743 std::function<
void(
Error)> RecoverableErrorHandler,
744 std::function<
void(
Error)> WarningHandler,
747 RecoverableErrorHandler(RecoverableErrorHandler),
748 WarningHandler(WarningHandler), DObj(
std::
move(DObj)) {
750 State = std::make_unique<ThreadSafeState>(*
this, DWPName);
752 State = std::make_unique<ThreadUnsafeDWARFContextState>(*
this, DWPName);
762 for (
auto LC :
MachO->load_commands()) {
764 if (LC.C.cmd == MachO::LC_UUID) {
765 if (LC.C.cmdsize <
sizeof(
UUID) +
sizeof(LC.C)) {
766 OS <<
"error: UUID load command is too short.\n";
770 memcpy(&
UUID, LC.Ptr+
sizeof(LC.C),
sizeof(
UUID));
773 OS <<
" (" <<
T.getArchName() <<
')';
774 OS <<
' ' <<
MachO->getFileName() <<
'\n';
780 std::vector<std::optional<StrOffsetsContributionDescriptor>>;
787 for (
const auto &U : Units)
788 if (
const auto &
C = U->getStringOffsetsTableContribution())
789 Contributions.push_back(
C);
794 [](
const std::optional<StrOffsetsContributionDescriptor> &L,
795 const std::optional<StrOffsetsContributionDescriptor> &R) {
797 return L->Base < R->Base;
798 return R.has_value();
807 [](
const std::optional<StrOffsetsContributionDescriptor> &L,
808 const std::optional<StrOffsetsContributionDescriptor> &R) {
810 return L->Base == R->Base && L->Size == R->Size;
813 Contributions.end());
814 return Contributions;
837 for (
auto &Contribution : Contributions) {
840 OS <<
"error: invalid contribution to string offsets table in section ."
847 uint16_t Version = Contribution->getVersion();
848 uint64_t ContributionHeader = Contribution->Base;
854 ContributionHeader -= Format ==
DWARF32 ? 8 : 16;
857 if (
Offset > ContributionHeader) {
860 "overlapping contributions to string offsets table in section .%s.",
864 if (
Offset < ContributionHeader) {
866 OS << (ContributionHeader -
Offset) <<
"\n";
868 OS <<
formatv(
"{0:x8}: ", ContributionHeader);
873 OS <<
"Contribution size = " << (Contribution->Size + (Version < 5 ? 0 : 4))
875 <<
", Version = " << Version <<
"\n";
877 Offset = Contribution->Base;
878 unsigned EntrySize = Contribution->getDwarfOffsetByteSize();
879 while (
Offset - Contribution->Base < Contribution->Size) {
884 OffsetDumpWidth,
'0'));
885 const char *S = StrData.
getCStr(&StringOffset);
892 if (
Offset < SectionSize) {
894 OS << (SectionSize -
Offset) <<
"\n";
912 Offset = TableOffset + *TableLength;
917 AddrTable.
dump(OS, DumpOpts);
940 Rnglists.
dump(rnglistData, OS, LookupPooledAddress, DumpOpts);
948 std::optional<uint64_t> DumpOffset) {
958 Header.dump(
Data, OS, DumpOpts);
960 uint64_t EndOffset = Header.length() + Header.getHeaderOffset();
961 Data.setAddressSize(Header.getAddrSize());
964 if (DumpOffset >=
Offset && DumpOffset < EndOffset) {
966 Loc.dumpLocationList(&
Offset, OS, std::nullopt, Obj,
967 nullptr, DumpOpts, 0);
987 std::array<std::optional<uint64_t>,
DIDT_ID_Count> DumpOffsets) {
988 uint64_t DumpType = DumpOpts.
DumpType;
991 bool IsDWO = (Extension ==
".dwo") || (Extension ==
".dwp");
994 const auto *ObjFile = DObj->getFile();
1001 bool Explicit = DumpType !=
DIDT_All && !IsDWO;
1002 bool ExplicitDWO = Explicit && IsDWO;
1003 auto shouldDump = [&](
bool Explicit,
const char *Name,
unsigned ID,
1004 StringRef Section) -> std::optional<uint64_t> * {
1005 unsigned Mask = 1U << ID;
1006 bool Should = (DumpType & Mask) && (Explicit || !Section.empty());
1009 OS <<
"\n" << Name <<
" contents:\n";
1010 return &DumpOffsets[ID];
1014 if (shouldDump(Explicit,
".debug_abbrev", DIDT_ID_DebugAbbrev,
1015 DObj->getAbbrevSection()))
1017 if (shouldDump(ExplicitDWO,
".debug_abbrev.dwo", DIDT_ID_DebugAbbrev,
1018 DObj->getAbbrevDWOSection()))
1022 OS <<
'\n' << Name <<
" contents:\n";
1023 std::optional<uint64_t> DumpOffset = DumpOffsets[DIDT_ID_DebugInfo];
1024 for (
const auto &U : Units) {
1027 bool HadDWO = U->getDWO();
1029 U->getDIEForOffset(*DumpOffset)
1031 DWARFDie CUDie = U->getUnitDIE(
false);
1032 DWARFDie CUNonSkeletonDie = U->getNonSkeletonUnitDIE(
false);
1033 if (CUNonSkeletonDie && CUDie != CUNonSkeletonDie) {
1039 U->dump(OS, DumpOpts);
1051 if ((DumpType & DIDT_DebugInfo)) {
1059 OS <<
'\n' << Name <<
" contents:\n";
1060 for (
const auto &U : Units)
1061 if (
auto DumpOffset = DumpOffsets[DIDT_ID_DebugTypes])
1062 U->getDIEForOffset(*DumpOffset)
1065 U->dump(OS, DumpOpts);
1067 if ((DumpType & DIDT_DebugTypes)) {
1078 if (
const auto *Off = shouldDump(Explicit,
".debug_loc", DIDT_ID_DebugLoc,
1079 DObj->getLocSection().Data)) {
1082 if (
const auto *Off =
1083 shouldDump(Explicit,
".debug_loclists", DIDT_ID_DebugLoclists,
1084 DObj->getLoclistsSection().Data)) {
1089 if (
const auto *Off =
1090 shouldDump(ExplicitDWO,
".debug_loclists.dwo", DIDT_ID_DebugLoclists,
1091 DObj->getLoclistsDWOSection().Data)) {
1097 if (
const auto *Off =
1098 shouldDump(ExplicitDWO,
".debug_loc.dwo", DIDT_ID_DebugLoc,
1099 DObj->getLocDWOSection().Data)) {
1106 std::nullopt, *DObj,
nullptr,
1111 Loc.dumpRange(0,
Data.getData().size(), OS, *DObj, LLDumpOpts);
1115 if (
const std::optional<uint64_t> *Off =
1116 shouldDump(Explicit,
".debug_frame", DIDT_ID_DebugFrame,
1117 DObj->getFrameSection().Data)) {
1119 (*DF)->dump(OS, DumpOpts, *Off);
1121 RecoverableErrorHandler(
DF.takeError());
1124 if (
const std::optional<uint64_t> *Off =
1125 shouldDump(Explicit,
".eh_frame", DIDT_ID_DebugFrame,
1126 DObj->getEHFrameSection().Data)) {
1128 (*DF)->dump(OS, DumpOpts, *Off);
1130 RecoverableErrorHandler(
DF.takeError());
1133 if (shouldDump(Explicit,
".debug_macro", DIDT_ID_DebugMacro,
1134 DObj->getMacroSection().Data)) {
1139 if (shouldDump(Explicit,
".debug_macro.dwo", DIDT_ID_DebugMacro,
1140 DObj->getMacroDWOSection())) {
1145 if (shouldDump(Explicit,
".debug_macinfo", DIDT_ID_DebugMacro,
1146 DObj->getMacinfoSection())) {
1151 if (shouldDump(Explicit,
".debug_macinfo.dwo", DIDT_ID_DebugMacro,
1152 DObj->getMacinfoDWOSection())) {
1154 MacinfoDWO->dump(OS);
1157 if (shouldDump(Explicit,
".debug_aranges", DIDT_ID_DebugAranges,
1158 DObj->getArangesSection())) {
1159 uint64_t offset = 0;
1166 RecoverableErrorHandler(std::move(E));
1175 std::optional<uint64_t> DumpOffset) {
1177 if (DumpOffset &&
Parser.getOffset() != *DumpOffset) {
1181 OS <<
"debug_line[" <<
formatv(
"{0:x8}",
Parser.getOffset()) <<
"]\n";
1187 auto DumpStrSection = [&](
StringRef Section) {
1190 uint64_t StrOffset = 0;
1198 OS <<
formatv(
"{0:x8}: \"", StrOffset);
1205 if (
const auto *Off = shouldDump(Explicit,
".debug_line", DIDT_ID_DebugLine,
1206 DObj->getLineSection().Data)) {
1210 DumpLineSection(
Parser, DumpOpts, *Off);
1213 if (
const auto *Off =
1214 shouldDump(ExplicitDWO,
".debug_line.dwo", DIDT_ID_DebugLine,
1215 DObj->getLineDWOSection().Data)) {
1219 DumpLineSection(
Parser, DumpOpts, *Off);
1222 if (shouldDump(Explicit,
".debug_cu_index", DIDT_ID_DebugCUIndex,
1223 DObj->getCUIndexSection())) {
1227 if (shouldDump(Explicit,
".debug_tu_index", DIDT_ID_DebugTUIndex,
1228 DObj->getTUIndexSection())) {
1232 if (shouldDump(Explicit,
".debug_str", DIDT_ID_DebugStr,
1233 DObj->getStrSection()))
1234 DumpStrSection(DObj->getStrSection());
1236 if (shouldDump(ExplicitDWO,
".debug_str.dwo", DIDT_ID_DebugStr,
1237 DObj->getStrDWOSection()))
1238 DumpStrSection(DObj->getStrDWOSection());
1240 if (shouldDump(Explicit,
".debug_line_str", DIDT_ID_DebugLineStr,
1241 DObj->getLineStrSection()))
1242 DumpStrSection(DObj->getLineStrSection());
1244 if (shouldDump(Explicit,
".debug_addr", DIDT_ID_DebugAddr,
1245 DObj->getAddrSection().Data)) {
1251 if (shouldDump(Explicit,
".debug_ranges", DIDT_ID_DebugRanges,
1252 DObj->getRangesSection().Data)) {
1256 uint64_t offset = 0;
1259 if (
Error E = rangeList.
extract(rangesData, &offset)) {
1267 auto LookupPooledAddress =
1270 auto I = CUs.begin();
1272 return std::nullopt;
1273 return (*I)->getAddrOffsetSectionItem(
Index);
1276 if (shouldDump(Explicit,
".debug_rnglists", DIDT_ID_DebugRnglists,
1277 DObj->getRnglistsSection().Data)) {
1283 if (shouldDump(ExplicitDWO,
".debug_rnglists.dwo", DIDT_ID_DebugRnglists,
1284 DObj->getRnglistsDWOSection().Data)) {
1290 if (shouldDump(Explicit,
".debug_pubnames", DIDT_ID_DebugPubnames,
1291 DObj->getPubnamesSection().Data)) {
1297 if (shouldDump(Explicit,
".debug_pubtypes", DIDT_ID_DebugPubtypes,
1298 DObj->getPubtypesSection().Data)) {
1304 if (shouldDump(Explicit,
".debug_gnu_pubnames", DIDT_ID_DebugGnuPubnames,
1305 DObj->getGnuPubnamesSection().Data)) {
1311 if (shouldDump(Explicit,
".debug_gnu_pubtypes", DIDT_ID_DebugGnuPubtypes,
1312 DObj->getGnuPubtypesSection().Data)) {
1318 if (shouldDump(Explicit,
".debug_str_offsets", DIDT_ID_DebugStrOffsets,
1319 DObj->getStrOffsetsSection().Data))
1321 OS, DumpOpts,
"debug_str_offsets", *DObj, DObj->getStrOffsetsSection(),
1323 if (shouldDump(ExplicitDWO,
".debug_str_offsets.dwo", DIDT_ID_DebugStrOffsets,
1324 DObj->getStrOffsetsDWOSection().Data))
1326 DObj->getStrOffsetsDWOSection(),
1330 if (shouldDump(Explicit,
".gdb_index", DIDT_ID_GdbIndex,
1331 DObj->getGdbIndexSection())) {
1335 if (shouldDump(Explicit,
".apple_names", DIDT_ID_AppleNames,
1336 DObj->getAppleNamesSection().Data))
1339 if (shouldDump(Explicit,
".apple_types", DIDT_ID_AppleTypes,
1340 DObj->getAppleTypesSection().Data))
1343 if (shouldDump(Explicit,
".apple_namespaces", DIDT_ID_AppleNamespaces,
1344 DObj->getAppleNamespacesSection().Data))
1347 if (shouldDump(Explicit,
".apple_objc", DIDT_ID_AppleObjC,
1348 DObj->getAppleObjCSection().Data))
1350 if (shouldDump(Explicit,
".debug_names", DIDT_ID_DebugNames,
1351 DObj->getNamesSection().Data))
1358 if (
const auto *R = TUI.getFromHash(Hash)) {
1359 if (TUI.getVersion() >= 5) {
1374 return State->getTypeUnitMap(IsDWO).lookup(Hash);
1381 if (
const auto *R = CUI.getFromHash(Hash))
1393 if (!DWOCU->getDWOId()) {
1394 if (std::optional<uint64_t> DWOId =
1395 toUnsigned(DWOCU->getUnitDIE().find(DW_AT_GNU_dwo_id)))
1396 DWOCU->setDWOId(*DWOId);
1401 if (DWOCU->getDWOId() == Hash)
1408 if (
auto *
CU = State->getNormalUnits().getUnitForOffset(
Offset))
1409 return CU->getDIEForOffset(
Offset);
1418 if (DumpOpts.
DumpType & DIDT_DebugCUIndex)
1420 if (DumpOpts.
DumpType & DIDT_DebugTUIndex)
1422 if (DumpOpts.
DumpType & DIDT_DebugInfo)
1424 if (DumpOpts.
DumpType & DIDT_DebugLine)
1426 if (DumpOpts.
DumpType & DIDT_DebugStrOffsets)
1434 return State->getCUIndex();
1438 return State->getTUIndex();
1442 return State->getGdbIndex();
1446 return State->getDebugAbbrev();
1450 return State->getDebugAbbrevDWO();
1454 return State->getDebugLoc();
1458 return State->getDebugAranges();
1462 return State->getDebugFrame();
1466 return State->getEHFrame();
1470 return State->getDebugMacro();
1474 return State->getDebugMacroDWO();
1478 return State->getDebugMacinfo();
1482 return State->getDebugMacinfoDWO();
1487 return State->getDebugNames();
1491 return State->getAppleNames();
1495 return State->getAppleTypes();
1499 return State->getAppleNamespaces();
1503 return State->getAppleObjC();
1510 if (!ExpectedLineTable) {
1511 WarningHandler(ExpectedLineTable.
takeError());
1514 return *ExpectedLineTable;
1519 return State->getLineTableForUnit(U, RecoverableErrorHandler);
1523 return State->clearLineTableForUnit(U);
1527 return State->getDWOUnits(Lazy);
1531 return State->getNormalUnits().getUnitForOffset(
Offset);
1559 if (
CU->getVariableForAddress(
Address)) {
1579 DWARFDie CUDwoDie =
CU->getNonSkeletonUnitDIE(
false);
1580 if (CheckDWO && CUDwoDie && CUDie != CUDwoDie) {
1586 if (Result.FunctionDIE)
1587 Result.CompileUnit = CUDwo;
1595 Result.CompileUnit =
CU;
1596 Result.FunctionDIE =
CU->getSubroutineForAddress(
Address);
1599 std::vector<DWARFDie> Worklist;
1600 Worklist.push_back(Result.FunctionDIE);
1601 while (!Worklist.empty()) {
1603 Worklist.pop_back();
1608 if (
DIE.
getTag() == DW_TAG_lexical_block &&
1610 Result.BlockDIE =
DIE;
1625 std::string &FunctionName, std::string &StartFile,
uint32_t &StartLine,
1626 std::optional<uint64_t> &StartAddress) {
1631 CU->getInlinedChainForAddress(Address, InlinedChain);
1632 if (InlinedChain.
empty())
1636 bool FoundResult =
false;
1637 const char *Name =
nullptr;
1638 if (
Kind != FunctionNameKind::None && (Name =
DIE.getSubroutineName(
Kind))) {
1639 FunctionName = Name;
1642 std::string DeclFile =
DIE.getDeclFile(FileNameKind);
1643 if (!DeclFile.empty()) {
1644 StartFile = DeclFile;
1647 if (
auto DeclLineResult =
DIE.getDeclLine()) {
1648 StartLine = DeclLineResult;
1652 StartAddress = LowPcAddr->Address;
1656static std::optional<int64_t>
1658 std::optional<unsigned> FrameBaseReg) {
1659 if (!Expr.
empty() &&
1660 (Expr[0] == DW_OP_fbreg ||
1661 (FrameBaseReg && Expr[0] == DW_OP_breg0 + *FrameBaseReg))) {
1672 return std::nullopt;
1676 DWARFDie Die, std::vector<DILocal> &Result) {
1677 if (Die.
getTag() == DW_TAG_variable ||
1678 Die.
getTag() == DW_TAG_formal_parameter) {
1683 std::optional<unsigned> FrameBaseReg;
1684 if (
auto FrameBase = Subprogram.
find(DW_AT_frame_base))
1685 if (std::optional<ArrayRef<uint8_t>> Expr = FrameBase->getAsBlock())
1686 if (!Expr->empty() && (*Expr)[0] >= DW_OP_reg0 &&
1687 (*Expr)[0] <= DW_OP_reg31) {
1688 FrameBaseReg = (*Expr)[0] - DW_OP_reg0;
1691 if (Expected<std::vector<DWARFLocationExpression>> Loc =
1693 for (
const auto &Entry : *Loc) {
1694 if (std::optional<int64_t> FrameOffset =
1696 Local.FrameOffset = *FrameOffset;
1706 if (
auto TagOffsetAttr = Die.
find(DW_AT_LLVM_tag_offset))
1707 Local.TagOffset = TagOffsetAttr->getAsUnsignedConstant();
1712 if (
auto NameAttr = Die.
find(DW_AT_name))
1717 if (
auto DeclFileAttr = Die.
find(DW_AT_decl_file)) {
1719 LT->getFileNameByIndex(
1724 if (
auto DeclLineAttr = Die.
find(DW_AT_decl_line))
1725 Local.DeclLine = *DeclLineAttr->getAsUnsignedConstant();
1731 if (Die.
getTag() == DW_TAG_inlined_subroutine)
1734 Subprogram = Origin;
1736 for (
auto Child : Die)
1737 addLocalsForDie(CU, Subprogram, Child, Result);
1742 std::vector<DILocal> Result;
1749 addLocalsForDie(
CU, Subprogram, Subprogram, Result);
1753std::optional<DILineInfo>
1758 return std::nullopt;
1763 Result.StartFileName, Result.StartLine, Result.StartAddress);
1764 if (
Spec.FLIKind != FileLineInfoKind::None) {
1766 LineTable->getFileLineInfoForAddress(
1768 CU->getCompilationDir(),
Spec.FLIKind, Result);
1775std::optional<DILineInfo>
1783 Result.FileName = Die.
getDeclFile(FileLineInfoKind::AbsoluteFilePath);
1798 std::string StartFileName;
1800 std::optional<uint64_t> StartAddress;
1802 Spec.FLIKind, FunctionName,
1803 StartFileName, StartLine, StartAddress);
1807 if (
Spec.FLIKind == FileLineInfoKind::None) {
1809 Result.FunctionName = FunctionName;
1810 Result.StartFileName = StartFileName;
1811 Result.StartLine = StartLine;
1812 Result.StartAddress = StartAddress;
1813 Lines.push_back(std::make_pair(
Address.Address, Result));
1820 std::vector<uint32_t> RowVector;
1826 for (
uint32_t RowIndex : RowVector) {
1831 Spec.FLIKind, Result.FileName);
1832 Result.FunctionName = FunctionName;
1833 Result.Line = Row.Line;
1834 Result.Column = Row.Column;
1835 Result.StartFileName = StartFileName;
1836 Result.StartLine = StartLine;
1837 Result.StartAddress = StartAddress;
1838 Lines.push_back(std::make_pair(Row.Address.Address, Result));
1851 return InliningInfo;
1855 CU->getInlinedChainForAddress(
Address.Address, InlinedChain);
1856 if (InlinedChain.
size() == 0) {
1859 if (
Spec.FLIKind != FileLineInfoKind::None) {
1864 {Address.Address, Address.SectionIndex},
Spec.ApproximateLine,
1865 CU->getCompilationDir(),
Spec.FLIKind, Frame))
1868 return InliningInfo;
1871 uint32_t CallFile = 0, CallLine = 0, CallColumn = 0, CallDiscriminator = 0;
1872 for (
uint32_t i = 0, n = InlinedChain.
size(); i != n; i++) {
1873 DWARFDie &FunctionDIE = InlinedChain[i];
1878 if (
auto DeclLineResult = FunctionDIE.
getDeclLine())
1883 if (
Spec.FLIKind != FileLineInfoKind::None) {
1892 CU->getCompilationDir(),
Spec.FLIKind, Frame);
1899 Frame.
Line = CallLine;
1900 Frame.
Column = CallColumn;
1911 return InliningInfo;
1914std::shared_ptr<DWARFContext>
1916 return State->getDWOContext(AbsolutePath);
1936 std::map<SymbolRef, SymInfo> &Cache) {
1941 std::map<SymbolRef, SymInfo>::iterator CacheIt = Cache.end();
1944 if (Sym != Obj.symbol_end()) {
1946 std::tie(CacheIt, New) = Cache.try_emplace(*Sym);
1948 return CacheIt->second;
1952 return createError(
"failed to compute symbol address: ",
1958 return createError(
"failed to get symbol section: ",
1959 SectOrErr.takeError());
1964 RSec = MObj->getRelocationSection(
Reloc.getRawDataRefImpl());
1968 if (RSec != Obj.section_end())
1978 if (L && RSec != Obj.section_end())
1979 if (
uint64_t SectionLoadAddress = L->getSectionLoadAddress(*RSec))
1982 if (CacheIt != Cache.end())
1983 CacheIt->second = Ret;
2004class DWARFObjInMemory final :
public DWARFObject {
2005 bool IsLittleEndian;
2006 uint8_t AddressSize;
2008 const object::ObjectFile *
Obj =
nullptr;
2011 using InfoSectionMap = MapVector<object::SectionRef, DWARFSectionMap,
2012 std::map<object::SectionRef, unsigned>>;
2014 InfoSectionMap InfoSections;
2015 InfoSectionMap TypesSections;
2016 InfoSectionMap InfoDWOSections;
2017 InfoSectionMap TypesDWOSections;
2019 DWARFSectionMap LocSection;
2020 DWARFSectionMap LoclistsSection;
2021 DWARFSectionMap LoclistsDWOSection;
2022 DWARFSectionMap LineSection;
2023 DWARFSectionMap RangesSection;
2024 DWARFSectionMap RnglistsSection;
2025 DWARFSectionMap StrOffsetsSection;
2026 DWARFSectionMap LineDWOSection;
2027 DWARFSectionMap FrameSection;
2028 DWARFSectionMap EHFrameSection;
2029 DWARFSectionMap LocDWOSection;
2030 DWARFSectionMap StrOffsetsDWOSection;
2031 DWARFSectionMap RangesDWOSection;
2032 DWARFSectionMap RnglistsDWOSection;
2033 DWARFSectionMap AddrSection;
2034 DWARFSectionMap AppleNamesSection;
2035 DWARFSectionMap AppleTypesSection;
2036 DWARFSectionMap AppleNamespacesSection;
2037 DWARFSectionMap AppleObjCSection;
2038 DWARFSectionMap NamesSection;
2039 DWARFSectionMap PubnamesSection;
2040 DWARFSectionMap PubtypesSection;
2041 DWARFSectionMap GnuPubnamesSection;
2042 DWARFSectionMap GnuPubtypesSection;
2043 DWARFSectionMap MacroSection;
2045 DWARFSectionMap *mapNameToDWARFSection(StringRef Name) {
2046 return StringSwitch<DWARFSectionMap *>(Name)
2047 .Case(
"debug_loc", &LocSection)
2048 .Case(
"debug_loclists", &LoclistsSection)
2049 .Case(
"debug_loclists.dwo", &LoclistsDWOSection)
2050 .Case(
"debug_line", &LineSection)
2051 .Case(
"debug_frame", &FrameSection)
2052 .Case(
"eh_frame", &EHFrameSection)
2053 .Case(
"debug_str_offsets", &StrOffsetsSection)
2054 .Case(
"debug_ranges", &RangesSection)
2055 .Case(
"debug_rnglists", &RnglistsSection)
2056 .Case(
"debug_loc.dwo", &LocDWOSection)
2057 .Case(
"debug_line.dwo", &LineDWOSection)
2058 .Case(
"debug_names", &NamesSection)
2059 .Case(
"debug_rnglists.dwo", &RnglistsDWOSection)
2060 .Case(
"debug_str_offsets.dwo", &StrOffsetsDWOSection)
2061 .Case(
"debug_addr", &AddrSection)
2062 .Case(
"apple_names", &AppleNamesSection)
2063 .Case(
"debug_pubnames", &PubnamesSection)
2064 .Case(
"debug_pubtypes", &PubtypesSection)
2065 .Case(
"debug_gnu_pubnames", &GnuPubnamesSection)
2066 .Case(
"debug_gnu_pubtypes", &GnuPubtypesSection)
2067 .Case(
"apple_types", &AppleTypesSection)
2068 .Case(
"apple_namespaces", &AppleNamespacesSection)
2069 .Case(
"apple_namespac", &AppleNamespacesSection)
2070 .Case(
"apple_objc", &AppleObjCSection)
2071 .Case(
"debug_macro", &MacroSection)
2075 StringRef AbbrevSection;
2076 StringRef ArangesSection;
2077 StringRef StrSection;
2078 StringRef MacinfoSection;
2079 StringRef MacinfoDWOSection;
2080 StringRef MacroDWOSection;
2081 StringRef AbbrevDWOSection;
2082 StringRef StrDWOSection;
2083 StringRef CUIndexSection;
2084 StringRef GdbIndexSection;
2085 StringRef TUIndexSection;
2086 StringRef LineStrSection;
2090 std::deque<SmallString<0>> UncompressedSections;
2092 StringRef *mapSectionToMember(StringRef Name) {
2093 if (DWARFSection *Sec = mapNameToDWARFSection(Name))
2095 return StringSwitch<StringRef *>(Name)
2096 .Case(
"debug_abbrev", &AbbrevSection)
2097 .Case(
"debug_aranges", &ArangesSection)
2098 .Case(
"debug_str", &StrSection)
2099 .Case(
"debug_macinfo", &MacinfoSection)
2100 .Case(
"debug_macinfo.dwo", &MacinfoDWOSection)
2101 .Case(
"debug_macro.dwo", &MacroDWOSection)
2102 .Case(
"debug_abbrev.dwo", &AbbrevDWOSection)
2103 .Case(
"debug_str.dwo", &StrDWOSection)
2104 .Case(
"debug_cu_index", &CUIndexSection)
2105 .Case(
"debug_tu_index", &TUIndexSection)
2106 .Case(
"gdb_index", &GdbIndexSection)
2107 .Case(
"debug_line_str", &LineStrSection)
2114 Error maybeDecompress(
const object::SectionRef &Sec, StringRef Name,
2119 Expected<Decompressor> Decompressor =
2125 if (
auto Err = Decompressor->resizeAndDecompress(Out))
2128 UncompressedSections.push_back(std::move(Out));
2129 Data = UncompressedSections.back();
2135 DWARFObjInMemory(
const StringMap<std::unique_ptr<MemoryBuffer>> &Sections,
2136 uint8_t AddrSize,
bool IsLittleEndian)
2137 : IsLittleEndian(IsLittleEndian) {
2138 for (
const auto &SecIt : Sections) {
2139 if (StringRef *SectionData = mapSectionToMember(SecIt.first()))
2140 *SectionData = SecIt.second->getBuffer();
2141 else if (SecIt.first() ==
"debug_info")
2144 InfoSections[SectionRef()].Data = SecIt.second->getBuffer();
2145 else if (SecIt.first() ==
"debug_info.dwo")
2146 InfoDWOSections[SectionRef()].Data = SecIt.second->getBuffer();
2147 else if (SecIt.first() ==
"debug_types")
2148 TypesSections[SectionRef()].Data = SecIt.second->getBuffer();
2149 else if (SecIt.first() ==
"debug_types.dwo")
2150 TypesDWOSections[SectionRef()].Data = SecIt.second->getBuffer();
2153 DWARFObjInMemory(
const object::ObjectFile &Obj,
const LoadedObjectInfo *L,
2154 function_ref<
void(
Error)> HandleError,
2155 function_ref<
void(
Error)> HandleWarning,
2157 : IsLittleEndian(
Obj.isLittleEndian()),
2161 StringMap<unsigned> SectionAmountMap;
2162 for (
const SectionRef &Section :
Obj.sections()) {
2164 if (auto NameOrErr = Section.getName())
2167 consumeError(NameOrErr.takeError());
2169 ++SectionAmountMap[Name];
2170 SectionNames.push_back({ Name, true });
2181 Expected<section_iterator> SecOrErr =
Section.getRelocatedSection();
2183 HandleError(
createError(
"failed to get relocated section: ",
2184 SecOrErr.takeError()));
2192 Obj.isRelocatableObject() ? *SecOrErr :
Obj.section_end();
2193 if (!L || !
L->getLoadedSectionContents(*RelocatedSection,
Data)) {
2194 Expected<StringRef> E = Section.getContents();
2199 consumeError(E.takeError());
2202 if (
auto Err = maybeDecompress(Section, Name,
Data)) {
2203 HandleError(
createError(
"failed to decompress '" + Name +
"', ",
2211 Name =
Obj.mapDebugSectionName(Name);
2213 if (StringRef *SectionData = mapSectionToMember(Name)) {
2214 *SectionData =
Data;
2215 if (Name ==
"debug_ranges") {
2217 RangesDWOSection.Data =
Data;
2218 }
else if (Name ==
"debug_frame" || Name ==
"eh_frame") {
2219 if (DWARFSection *S = mapNameToDWARFSection(Name))
2222 }
else if (InfoSectionMap *Sections =
2223 StringSwitch<InfoSectionMap *>(Name)
2224 .Case(
"debug_info", &InfoSections)
2225 .Case(
"debug_info.dwo", &InfoDWOSections)
2226 .Case(
"debug_types", &TypesSections)
2227 .Case(
"debug_types.dwo", &TypesDWOSections)
2231 DWARFSectionMap &S = (*Sections)[
Section];
2235 if (RelocatedSection ==
Obj.section_end() ||
2236 (RelocAction == DWARFContext::ProcessDebugRelocations::Ignore))
2239 StringRef RelSecName;
2240 if (
auto NameOrErr = RelocatedSection->
getName())
2241 RelSecName = *NameOrErr;
2248 StringRef RelSecData;
2249 if (L &&
L->getLoadedSectionContents(*RelocatedSection, RelSecData))
2260 if (!
Section.relocations().empty() &&
Name.ends_with(
".dwo") &&
2261 RelSecName.starts_with(
".debug")) {
2262 HandleWarning(createError(
"unexpected relocations for dwo section '" +
2268 RelSecName = RelSecName.substr(RelSecName.find_first_not_of(
"._"));
2269 DWARFSectionMap *Sec = mapNameToDWARFSection(RelSecName);
2274 if (RelSecName ==
"debug_info")
2275 Map = &
static_cast<DWARFSectionMap &
>(InfoSections[*RelocatedSection])
2277 else if (RelSecName ==
"debug_types")
2279 &
static_cast<DWARFSectionMap &
>(TypesSections[*RelocatedSection])
2285 if (
Section.relocations().empty())
2289 std::map<SymbolRef, SymInfo> AddrCache;
2293 for (
const RelocationRef &Reloc :
Section.relocations()) {
2296 if (isRelocScattered(Obj, Reloc))
2299 Expected<SymInfo> SymInfoOrErr =
2300 getSymbolInfo(Obj, Reloc, L, AddrCache);
2301 if (!SymInfoOrErr) {
2302 HandleError(SymInfoOrErr.takeError());
2310 if (Supports && Supports(Reloc.getType())) {
2311 auto I = Map->try_emplace(
2314 SymInfoOrErr->SectionIndex, Reloc, SymInfoOrErr->Address,
2315 std::optional<object::RelocationRef>(), 0, Resolver});
2320 RelocAddrEntry &entry = I.first->getSecond();
2322 HandleError(createError(
2323 "At most two relocations per offset are supported"));
2325 entry.Reloc2 = Reloc;
2326 entry.SymbolValue2 = SymInfoOrErr->Address;
2340 if (SectionAmountMap[S.Name] > 1)
2341 S.IsNameUnique =
false;
2346 auto &Sec =
static_cast<const DWARFSectionMap &
>(S);
2348 if (AI == Sec.Relocs.end())
2349 return std::nullopt;
2359 bool isLittleEndian()
const override {
return IsLittleEndian; }
2360 StringRef getAbbrevDWOSection()
const override {
return AbbrevDWOSection; }
2361 const DWARFSection &getLineDWOSection()
const override {
2362 return LineDWOSection;
2364 const DWARFSection &getLocDWOSection()
const override {
2365 return LocDWOSection;
2367 StringRef getStrDWOSection()
const override {
return StrDWOSection; }
2368 const DWARFSection &getStrOffsetsDWOSection()
const override {
2369 return StrOffsetsDWOSection;
2371 const DWARFSection &getRangesDWOSection()
const override {
2372 return RangesDWOSection;
2374 const DWARFSection &getRnglistsDWOSection()
const override {
2375 return RnglistsDWOSection;
2377 const DWARFSection &getLoclistsDWOSection()
const override {
2378 return LoclistsDWOSection;
2380 const DWARFSection &getAddrSection()
const override {
return AddrSection; }
2381 StringRef getCUIndexSection()
const override {
return CUIndexSection; }
2382 StringRef getGdbIndexSection()
const override {
return GdbIndexSection; }
2383 StringRef getTUIndexSection()
const override {
return TUIndexSection; }
2386 const DWARFSection &getStrOffsetsSection()
const override {
2387 return StrOffsetsSection;
2389 StringRef getLineStrSection()
const override {
return LineStrSection; }
2392 void forEachInfoDWOSections(
2394 for (
auto &
P : InfoDWOSections)
2397 void forEachTypesDWOSections(
2399 for (
auto &
P : TypesDWOSections)
2403 StringRef getAbbrevSection()
const override {
return AbbrevSection; }
2404 const DWARFSection &getLocSection()
const override {
return LocSection; }
2405 const DWARFSection &getLoclistsSection()
const override {
return LoclistsSection; }
2406 StringRef getArangesSection()
const override {
return ArangesSection; }
2408 return FrameSection;
2411 return EHFrameSection;
2413 const DWARFSection &getLineSection()
const override {
return LineSection; }
2414 StringRef getStrSection()
const override {
return StrSection; }
2415 const DWARFSection &getRangesSection()
const override {
return RangesSection; }
2416 const DWARFSection &getRnglistsSection()
const override {
2417 return RnglistsSection;
2419 const DWARFSection &getMacroSection()
const override {
return MacroSection; }
2420 StringRef getMacroDWOSection()
const override {
return MacroDWOSection; }
2421 StringRef getMacinfoSection()
const override {
return MacinfoSection; }
2422 StringRef getMacinfoDWOSection()
const override {
return MacinfoDWOSection; }
2423 const DWARFSection &getPubnamesSection()
const override {
return PubnamesSection; }
2424 const DWARFSection &getPubtypesSection()
const override {
return PubtypesSection; }
2425 const DWARFSection &getGnuPubnamesSection()
const override {
2426 return GnuPubnamesSection;
2428 const DWARFSection &getGnuPubtypesSection()
const override {
2429 return GnuPubtypesSection;
2431 const DWARFSection &getAppleNamesSection()
const override {
2432 return AppleNamesSection;
2434 const DWARFSection &getAppleTypesSection()
const override {
2435 return AppleTypesSection;
2437 const DWARFSection &getAppleNamespacesSection()
const override {
2438 return AppleNamespacesSection;
2440 const DWARFSection &getAppleObjCSection()
const override {
2441 return AppleObjCSection;
2444 return NamesSection;
2448 uint8_t getAddressSize()
const override {
return AddressSize; }
2449 void forEachInfoSections(
2451 for (
auto &
P : InfoSections)
2454 void forEachTypesSections(
2456 for (
auto &
P : TypesSections)
2462std::unique_ptr<DWARFContext>
2466 std::function<
void(
Error)> RecoverableErrorHandler,
2467 std::function<
void(
Error)> WarningHandler,
2469 auto DObj = std::make_unique<DWARFObjInMemory>(
2470 Obj, L, RecoverableErrorHandler, WarningHandler, RelocAction);
2471 return std::make_unique<DWARFContext>(std::move(DObj),
2473 RecoverableErrorHandler,
2478std::unique_ptr<DWARFContext>
2481 std::function<
void(
Error)> RecoverableErrorHandler,
2482 std::function<
void(
Error)> WarningHandler,
2485 std::make_unique<DWARFObjInMemory>(Sections, AddrSize,
isLittleEndian);
2486 return std::make_unique<DWARFContext>(
2487 std::move(DObj),
"", RecoverableErrorHandler, WarningHandler, ThreadSafe);
2497 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
Expected< const DWARFDebugFrame * > getDebugFrame()
Get a pointer to the parsed frame information object.
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.
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()
Expected< const DWARFDebugFrame * > getEHFrame()
Get a pointer to the parsed eh frame information object.
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.
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.