59 using namespace dwarf;
62 #define DEBUG_TYPE "dwarf" 70 :
DIContext(CK_DWARF), DWPName(
std::move(DWPName)), DObj(
std::move(DObj)) {}
76 auto *MachO =
dyn_cast<MachOObjectFile>(&Obj);
79 for (
auto LC : MachO->load_commands()) {
81 if (LC.C.cmd == MachO::LC_UUID) {
82 if (LC.C.cmdsize <
sizeof(UUID) +
sizeof(LC.C)) {
83 OS <<
"error: UUID load command is too short.\n";
87 memcpy(&UUID, LC.Ptr+
sizeof(LC.C),
sizeof(UUID));
89 Triple T = MachO->getArchTriple();
91 OS <<
' ' << MachO->getFileName() <<
'\n';
97 std::vector<Optional<StrOffsetsContributionDescriptor>>;
104 for (
const auto &U : Units)
105 if (
const auto &
C = U->getStringOffsetsTableContribution())
106 Contributions.push_back(
C);
122 std::unique(Contributions.begin(), Contributions.end(),
129 Contributions.end());
130 return Contributions;
142 for (
auto &Contribution : Contributions) {
145 OS <<
"error: invalid contribution to string offsets table in section ." 146 << SectionName <<
".\n";
152 uint64_t ContributionHeader = Contribution->Base;
158 ContributionHeader -= Format ==
DWARF32 ? 8 : 16;
161 if (Offset > ContributionHeader) {
163 <<
"overlapping contributions to string offsets table in section ." 164 << SectionName <<
".\n";
168 if (Offset < ContributionHeader) {
169 OS <<
format(
"0x%8.8" PRIx64
": Gap, length = ", Offset);
170 OS << (ContributionHeader -
Offset) <<
"\n";
172 OS <<
format(
"0x%8.8" PRIx64
": ", ContributionHeader);
177 OS <<
"Contribution size = " << (Contribution->Size + (Version < 5 ? 0 : 4))
178 <<
", Format = " << (Format ==
DWARF32 ?
"DWARF32" :
"DWARF64")
179 <<
", Version = " << Version <<
"\n";
181 Offset = Contribution->Base;
182 unsigned EntrySize = Contribution->getDwarfOffsetByteSize();
183 while (Offset - Contribution->Base < Contribution->Size) {
184 OS <<
format(
"0x%8.8" PRIx64
": ", Offset);
185 uint64_t StringOffset =
187 OS <<
format(
"%8.8" PRIx64
" ", StringOffset);
188 const char *S = StrData.
getCStr(&StringOffset);
190 OS <<
format(
"\"%s\"", S);
195 if (Offset < SectionSize) {
196 OS <<
format(
"0x%8.8" PRIx64
": Gap, length = ", Offset);
197 OS << (SectionSize -
Offset) <<
"\n";
212 bool LittleEndian,
unsigned MaxVersion) {
218 StringSection, Units, LittleEndian);
224 if (size & ((uint64_t)(
sizeof(
uint32_t) - 1))) {
225 OS <<
"error: size of ." << SectionName <<
" is not a multiple of " 227 size &= -(uint64_t)
sizeof(
uint32_t);
230 while (offset < size) {
231 OS <<
format(
"0x%8.8" PRIx64
": ", offset);
232 uint64_t StringOffset = strOffsetExt.
getU32(&offset);
233 OS <<
format(
"%8.8" PRIx64
" ", StringOffset);
234 const char *S = StrData.
getCStr(&StringOffset);
236 OS <<
format(
"\"%s\"", S);
249 uint64_t TableOffset =
Offset;
250 if (
Error Err = AddrTable.
extract(AddrData, &Offset, Version, AddrSize,
257 Offset = TableOffset + AddrTable.
getLength();
259 AddrTable.
dump(OS, DumpOpts);
273 uint64_t TableOffset =
Offset;
274 if (
Error Err = Rnglists.
extract(rnglistData, &Offset)) {
276 uint64_t Length = Rnglists.
length();
281 Offset = TableOffset + Length;
283 Rnglists.
dump(OS, LookupPooledAddress, DumpOpts);
302 Header.
dump(OS, DumpOpts);
308 if (DumpOffset >= Offset && DumpOffset < EndOffset) {
309 Offset = *DumpOffset;
310 Loc.dumpLocationList(&Offset, OS,
None, MRI, Obj,
nullptr,
316 Loc.dumpRange(Offset, EndOffset - Offset, OS, MRI, Obj, DumpOpts);
326 uint64_t DumpType = DumpOpts.
DumpType;
329 bool IsDWO = (Extension ==
".dwo") || (Extension ==
".dwp");
332 const auto *ObjFile = DObj->getFile();
339 bool Explicit = DumpType !=
DIDT_All && !IsDWO;
340 bool ExplicitDWO = Explicit && IsDWO;
341 auto shouldDump = [&](
bool Explicit,
const char *
Name,
unsigned ID,
344 bool Should = (DumpType &
Mask) && (Explicit || !
Section.empty());
347 OS <<
"\n" << Name <<
" contents:\n";
348 return &DumpOffsets[
ID];
352 if (shouldDump(Explicit,
".debug_abbrev", DIDT_ID_DebugAbbrev,
353 DObj->getAbbrevSection()))
355 if (shouldDump(ExplicitDWO,
".debug_abbrev.dwo", DIDT_ID_DebugAbbrev,
356 DObj->getAbbrevDWOSection()))
360 OS <<
'\n' << Name <<
" contents:\n";
361 if (
auto DumpOffset = DumpOffsets[DIDT_ID_DebugInfo])
362 for (
const auto &U : Units)
363 U->getDIEForOffset(DumpOffset.getValue())
366 for (
const auto &U : Units)
367 U->dump(OS, DumpOpts);
369 if ((DumpType & DIDT_DebugInfo)) {
377 OS <<
'\n' << Name <<
" contents:\n";
378 for (
const auto &U : Units)
379 if (
auto DumpOffset = DumpOffsets[DIDT_ID_DebugTypes])
380 U->getDIEForOffset(*DumpOffset)
383 U->dump(OS, DumpOpts);
385 if ((DumpType & DIDT_DebugTypes)) {
396 if (
const auto *Off = shouldDump(Explicit,
".debug_loc", DIDT_ID_DebugLoc,
397 DObj->getLocSection().Data)) {
400 if (
const auto *Off =
401 shouldDump(Explicit,
".debug_loclists", DIDT_ID_DebugLoclists,
402 DObj->getLoclistsSection().Data)) {
407 if (
const auto *Off =
408 shouldDump(ExplicitDWO,
".debug_loclists.dwo", DIDT_ID_DebugLoclists,
409 DObj->getLoclistsDWOSection().Data)) {
415 if (
const auto *Off =
416 shouldDump(ExplicitDWO,
".debug_loc.dwo", DIDT_ID_DebugLoc,
417 DObj->getLocDWOSection().Data)) {
423 Loc.dumpLocationList(&Offset, OS,
433 if (
const auto *Off = shouldDump(Explicit,
".debug_frame", DIDT_ID_DebugFrame,
434 DObj->getFrameSection().Data))
437 if (
const auto *Off = shouldDump(Explicit,
".eh_frame", DIDT_ID_DebugFrame,
438 DObj->getEHFrameSection().Data))
441 if (DumpType & DIDT_DebugMacro) {
443 OS <<
"\n.debug_macinfo contents:\n";
446 OS <<
"\n.debug_macinfo.dwo contents:\n";
451 if (shouldDump(Explicit,
".debug_aranges", DIDT_ID_DebugAranges,
452 DObj->getArangesSection())) {
456 while (
set.
extract(arangesData, &offset))
463 while (!Parser.
done()) {
464 if (DumpOffset && Parser.
getOffset() != *DumpOffset) {
470 if (DumpOpts.Verbose) {
475 LineTable.
dump(OS, DumpOpts);
480 if (
const auto *Off = shouldDump(Explicit,
".debug_line", DIDT_ID_DebugLine,
481 DObj->getLineSection().Data)) {
486 DumpLineSection(Parser, DumpOpts, *Off);
489 if (
const auto *Off =
490 shouldDump(ExplicitDWO,
".debug_line.dwo", DIDT_ID_DebugLine,
491 DObj->getLineDWOSection().Data)) {
496 DumpLineSection(Parser, DumpOpts, *Off);
499 if (shouldDump(Explicit,
".debug_cu_index", DIDT_ID_DebugCUIndex,
500 DObj->getCUIndexSection())) {
504 if (shouldDump(Explicit,
".debug_tu_index", DIDT_ID_DebugTUIndex,
505 DObj->getTUIndexSection())) {
509 if (shouldDump(Explicit,
".debug_str", DIDT_ID_DebugStr,
510 DObj->getStrSection())) {
513 uint64_t strOffset = 0;
514 while (
const char *s = strData.getCStr(&offset)) {
515 OS <<
format(
"0x%8.8" PRIx64
": \"%s\"\n", strOffset, s);
519 if (shouldDump(ExplicitDWO,
".debug_str.dwo", DIDT_ID_DebugStr,
520 DObj->getStrDWOSection())) {
523 uint64_t strDWOOffset = 0;
524 while (
const char *s = strDWOData.getCStr(&offset)) {
525 OS <<
format(
"0x%8.8" PRIx64
": \"%s\"\n", strDWOOffset, s);
526 strDWOOffset = offset;
529 if (shouldDump(Explicit,
".debug_line_str", DIDT_ID_DebugLineStr,
530 DObj->getLineStrSection())) {
533 uint64_t strOffset = 0;
534 while (
const char *s = strData.getCStr(&offset)) {
535 OS <<
format(
"0x%8.8" PRIx64
": \"", strOffset);
542 if (shouldDump(Explicit,
".debug_addr", DIDT_ID_DebugAddr,
543 DObj->getAddrSection().Data)) {
549 if (shouldDump(Explicit,
".debug_ranges", DIDT_ID_DebugRanges,
550 DObj->getRangesSection().Data)) {
556 while (rangesData.isValidOffset(offset)) {
567 auto I = CUs.begin();
570 return (*I)->getAddrOffsetSectionItem(
Index);
573 if (shouldDump(Explicit,
".debug_rnglists", DIDT_ID_DebugRnglists,
574 DObj->getRnglistsSection().Data)) {
580 if (shouldDump(ExplicitDWO,
".debug_rnglists.dwo", DIDT_ID_DebugRnglists,
581 DObj->getRnglistsDWOSection().Data)) {
587 if (shouldDump(Explicit,
".debug_pubnames", DIDT_ID_DebugPubnames,
588 DObj->getPubnamesSection().Data))
592 if (shouldDump(Explicit,
".debug_pubtypes", DIDT_ID_DebugPubtypes,
593 DObj->getPubtypesSection().Data))
597 if (shouldDump(Explicit,
".debug_gnu_pubnames", DIDT_ID_DebugGnuPubnames,
598 DObj->getGnuPubnamesSection().Data))
603 if (shouldDump(Explicit,
".debug_gnu_pubtypes", DIDT_ID_DebugGnuPubtypes,
604 DObj->getGnuPubtypesSection().Data))
609 if (shouldDump(Explicit,
".debug_str_offsets", DIDT_ID_DebugStrOffsets,
610 DObj->getStrOffsetsSection().Data))
612 DObj->getStrOffsetsSection(),
615 if (shouldDump(ExplicitDWO,
".debug_str_offsets.dwo", DIDT_ID_DebugStrOffsets,
616 DObj->getStrOffsetsDWOSection().Data))
618 DObj->getStrOffsetsDWOSection(),
622 if (shouldDump(Explicit,
".gdb_index", DIDT_ID_GdbIndex,
623 DObj->getGdbIndexSection())) {
627 if (shouldDump(Explicit,
".apple_names", DIDT_ID_AppleNames,
628 DObj->getAppleNamesSection().Data))
631 if (shouldDump(Explicit,
".apple_types", DIDT_ID_AppleTypes,
632 DObj->getAppleTypesSection().Data))
635 if (shouldDump(Explicit,
".apple_namespaces", DIDT_ID_AppleNamespaces,
636 DObj->getAppleNamespacesSection().Data))
639 if (shouldDump(Explicit,
".apple_objc", DIDT_ID_AppleObjC,
640 DObj->getAppleObjCSection().Data))
642 if (shouldDump(Explicit,
".debug_names", DIDT_ID_DebugNames,
643 DObj->getNamesSection().Data))
648 parseDWOUnits(LazyParse);
651 if (
const auto *R = CUI.getFromHash(Hash))
652 return dyn_cast_or_null<DWARFCompileUnit>(
663 if (!DWOCU->getDWOId()) {
665 toUnsigned(DWOCU->getUnitDIE().find(DW_AT_GNU_dwo_id)))
666 DWOCU->setDWOId(*DWOId);
671 if (DWOCU->getDWOId() == Hash)
672 return dyn_cast<DWARFCompileUnit>(DWOCU.get());
680 return CU->getDIEForOffset(Offset);
689 if (DumpOpts.
DumpType & DIDT_DebugInfo)
691 if (DumpOpts.
DumpType & DIDT_DebugLine)
703 CUIndex = std::make_unique<DWARFUnitIndex>(
DW_SECT_INFO);
704 CUIndex->parse(CUIndexData);
715 TUIndex->parse(TUIndexData);
723 DataExtractor GdbIndexData(DObj->getGdbIndexSection(),
true , 0);
724 GdbIndex = std::make_unique<DWARFGdbIndex>();
725 GdbIndex->parse(GdbIndexData);
736 Abbrev->extract(abbrData);
742 return AbbrevDWO.get();
746 AbbrevDWO->extract(abbrData);
747 return AbbrevDWO.get();
766 return Aranges.get();
769 Aranges->generate(
this);
770 return Aranges.get();
775 return DebugFrame.get();
789 DebugFrame->parse(debugFrameData);
790 return DebugFrame.get();
795 return EHFrame.get();
800 DebugFrame->parse(debugFrameData);
801 return DebugFrame.get();
806 return MacroDWO.get();
811 MacroDWO->parse(MacinfoDWOData);
812 return MacroDWO.get();
821 Macro->parse(MacinfoData);
825 template <
typename T>
828 bool IsLittleEndian) {
833 Cache.reset(
new T(AccelSection, StrData));
834 if (
Error E = Cache->extract())
845 return getAccelTable(AppleNames, *DObj, DObj->getAppleNamesSection(),
850 return getAccelTable(AppleTypes, *DObj, DObj->getAppleTypesSection(),
856 DObj->getAppleNamespacesSection(),
861 return getAccelTable(AppleObjC, *DObj, DObj->getAppleObjCSection(),
869 if (!ExpectedLineTable) {
873 return *ExpectedLineTable;
901 return Line->getOrParseLineTable(lineData, stmtOffset, *
this, U,
902 RecoverableErrorCallback);
905 void DWARFContext::parseNormalUnits() {
906 if (!NormalUnits.
empty())
917 void DWARFContext::parseDWOUnits(
bool Lazy) {
918 if (!DWOUnits.
empty())
920 DObj->forEachInfoDWOSections([&](
const DWARFSection &S) {
924 DObj->forEachTypesDWOSections([&](
const DWARFSection &S) {
931 return dyn_cast_or_null<DWARFCompileUnit>(
952 std::vector<DWARFDie> Worklist;
954 while (!Worklist.empty()) {
961 if (DIE.
getTag() == DW_TAG_lexical_block &&
967 for (
auto Child : DIE)
968 Worklist.push_back(Child);
979 std::string &FunctionName,
986 if (InlinedChain.
empty())
990 bool FoundResult =
false;
991 const char *
Name =
nullptr;
997 StartLine = DeclLineResult;
1005 if (
auto SizeAttr = Type.
find(DW_AT_byte_size))
1010 case DW_TAG_pointer_type:
1011 case DW_TAG_reference_type:
1012 case DW_TAG_rvalue_reference_type:
1014 case DW_TAG_ptr_to_member_type: {
1016 if (
BaseType.getTag() == DW_TAG_subroutine_type)
1017 return 2 * PointerSize;
1020 case DW_TAG_const_type:
1021 case DW_TAG_volatile_type:
1022 case DW_TAG_restrict_type:
1023 case DW_TAG_typedef: {
1028 case DW_TAG_array_type: {
1035 uint64_t
Size = *BaseSize;
1037 if (Child.getTag() != DW_TAG_subrange_type)
1040 if (
auto ElemCountAttr = Child.find(DW_AT_count))
1042 ElemCountAttr->getAsUnsignedConstant())
1044 if (
auto UpperBoundAttr = Child.find(DW_AT_upper_bound))
1046 UpperBoundAttr->getAsSignedConstant()) {
1047 int64_t LowerBound = 0;
1048 if (
auto LowerBoundAttr = Child.find(DW_AT_lower_bound))
1049 LowerBound = LowerBoundAttr->getAsSignedConstant().
getValueOr(0);
1050 Size *= *UpperBound - LowerBound + 1;
1064 if (!Expr.
empty() &&
1065 (Expr[0] == DW_OP_fbreg ||
1066 (FrameBaseReg && Expr[0] == DW_OP_breg0 + *FrameBaseReg))) {
1070 if (Expr.size() == Count + 1)
1073 if (Expr.size() == Count + 2 && Expr[Count + 1] == DW_OP_deref)
1081 DWARFDie Die, std::vector<DILocal> &Result) {
1082 if (Die.
getTag() == DW_TAG_variable ||
1083 Die.
getTag() == DW_TAG_formal_parameter) {
1089 if (
auto FrameBase = Subprogram.
find(DW_AT_frame_base))
1091 if (!Expr->empty() && (*Expr)[0] >= DW_OP_reg0 &&
1092 (*Expr)[0] <= DW_OP_reg31) {
1093 FrameBaseReg = (*Expr)[0] - DW_OP_reg0;
1096 if (
Expected<std::vector<DWARFLocationExpression>> Loc =
1098 for (
const auto &
Entry : *Loc) {
1111 if (
auto TagOffsetAttr = Die.
find(DW_AT_LLVM_tag_offset))
1112 Local.
TagOffset = TagOffsetAttr->getAsUnsignedConstant();
1117 if (
auto NameAttr = Die.
find(DW_AT_name))
1122 if (
auto DeclFileAttr = Die.
find(DW_AT_decl_file)) {
1124 LT->getFileNameByIndex(
1125 DeclFileAttr->getAsUnsignedConstant().getValue(),
1130 if (
auto DeclLineAttr = Die.
find(DW_AT_decl_line))
1131 Local.
DeclLine = DeclLineAttr->getAsUnsignedConstant().getValue();
1133 Result.push_back(Local);
1137 if (Die.
getTag() == DW_TAG_inlined_subroutine)
1140 Subprogram = Origin;
1142 for (
auto Child : Die)
1143 addLocalsForDie(CU, Subprogram, Child, Result);
1146 std::vector<DILocal>
1148 std::vector<DILocal> Result;
1155 addLocalsForDie(CU, Subprogram, Subprogram, Result);
1171 LineTable->getFileLineInfoForAddress(
1189 FunctionName, StartLine);
1204 std::vector<uint32_t> RowVector;
1210 for (
uint32_t RowIndex : RowVector) {
1233 return InliningInfo;
1238 if (InlinedChain.
size() == 0) {
1245 {Address.Address, Address.SectionIndex},
1249 return InliningInfo;
1252 uint32_t CallFile = 0, CallLine = 0, CallColumn = 0, CallDiscriminator = 0;
1253 for (
uint32_t i = 0, n = InlinedChain.
size(); i != n; i++) {
1254 DWARFDie &FunctionDIE = InlinedChain[i];
1277 Frame.
Line = CallLine;
1278 Frame.
Column = CallColumn;
1289 return InliningInfo;
1292 std::shared_ptr<DWARFContext>
1294 if (
auto S = DWP.lock()) {
1296 return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
1299 std::weak_ptr<DWOFile> *
Entry = &DWOFiles[AbsolutePath];
1301 if (
auto S = Entry->lock()) {
1303 return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
1307 if (!CheckedForDWP) {
1310 this->DWPName.
empty()
1311 ? (DObj->getFileName() +
".dwp").
toStringRef(DWPName)
1317 CheckedForDWP =
true;
1333 auto S = std::make_shared<DWOFile>();
1334 S->File = std::move(Obj.get());
1337 auto *Ctxt = S->Context.get();
1338 return std::shared_ptr<DWARFContext>(std::move(S), Ctxt);
1342 return make_error<StringError>(Reason +
toString(std::move(E)),
1356 const RelocationRef &Reloc,
1358 std::map<SymbolRef, SymInfo> &Cache) {
1363 std::map<SymbolRef, SymInfo>::iterator CacheIt = Cache.end();
1368 std::tie(CacheIt, New) = Cache.insert({*Sym, {0, 0}});
1370 return CacheIt->second;
1374 return createError(
"failed to compute symbol address: ",
1380 return createError(
"failed to get symbol section: ",
1381 SectOrErr.takeError());
1385 }
else if (
auto *MObj = dyn_cast<MachOObjectFile>(&Obj)) {
1386 RSec = MObj->getRelocationSection(Reloc.getRawDataRefImpl());
1387 Ret.
Address = RSec->getAddress();
1402 Ret.
Address += SectionLoadAddress - RSec->getAddress();
1404 if (CacheIt != Cache.end())
1405 CacheIt->second = Ret;
1411 const RelocationRef &Reloc) {
1412 const MachOObjectFile *MachObj =
dyn_cast<MachOObjectFile>(&Obj);
1417 auto RelocInfo = MachObj->getRelocation(Reloc.getRawDataRefImpl());
1418 return MachObj->isRelocationScattered(RelocInfo);
1431 class DWARFObjInMemory final :
public DWARFObject {
1432 bool IsLittleEndian;
1433 uint8_t AddressSize;
1436 std::vector<SectionName> SectionNames;
1439 std::map<object::SectionRef, unsigned>>;
1441 InfoSectionMap InfoSections;
1442 InfoSectionMap TypesSections;
1443 InfoSectionMap InfoDWOSections;
1444 InfoSectionMap TypesDWOSections;
1446 DWARFSectionMap LocSection;
1447 DWARFSectionMap LoclistsSection;
1448 DWARFSectionMap LoclistsDWOSection;
1449 DWARFSectionMap LineSection;
1450 DWARFSectionMap RangesSection;
1451 DWARFSectionMap RnglistsSection;
1452 DWARFSectionMap StrOffsetsSection;
1453 DWARFSectionMap LineDWOSection;
1454 DWARFSectionMap FrameSection;
1455 DWARFSectionMap EHFrameSection;
1456 DWARFSectionMap LocDWOSection;
1457 DWARFSectionMap StrOffsetsDWOSection;
1458 DWARFSectionMap RangesDWOSection;
1459 DWARFSectionMap RnglistsDWOSection;
1460 DWARFSectionMap AddrSection;
1461 DWARFSectionMap AppleNamesSection;
1462 DWARFSectionMap AppleTypesSection;
1463 DWARFSectionMap AppleNamespacesSection;
1464 DWARFSectionMap AppleObjCSection;
1465 DWARFSectionMap NamesSection;
1466 DWARFSectionMap PubnamesSection;
1467 DWARFSectionMap PubtypesSection;
1468 DWARFSectionMap GnuPubnamesSection;
1469 DWARFSectionMap GnuPubtypesSection;
1473 .Case(
"debug_loc", &LocSection)
1474 .
Case(
"debug_loclists", &LoclistsSection)
1475 .
Case(
"debug_loclists.dwo", &LoclistsDWOSection)
1476 .
Case(
"debug_line", &LineSection)
1477 .
Case(
"debug_frame", &FrameSection)
1478 .
Case(
"eh_frame", &EHFrameSection)
1479 .
Case(
"debug_str_offsets", &StrOffsetsSection)
1480 .
Case(
"debug_ranges", &RangesSection)
1481 .
Case(
"debug_rnglists", &RnglistsSection)
1482 .
Case(
"debug_loc.dwo", &LocDWOSection)
1483 .
Case(
"debug_line.dwo", &LineDWOSection)
1484 .
Case(
"debug_names", &NamesSection)
1485 .
Case(
"debug_rnglists.dwo", &RnglistsDWOSection)
1486 .
Case(
"debug_str_offsets.dwo", &StrOffsetsDWOSection)
1487 .
Case(
"debug_addr", &AddrSection)
1488 .
Case(
"apple_names", &AppleNamesSection)
1489 .
Case(
"debug_pubnames", &PubnamesSection)
1490 .
Case(
"debug_pubtypes", &PubtypesSection)
1491 .
Case(
"debug_gnu_pubnames", &GnuPubnamesSection)
1492 .
Case(
"debug_gnu_pubtypes", &GnuPubtypesSection)
1493 .
Case(
"apple_types", &AppleTypesSection)
1494 .
Case(
"apple_namespaces", &AppleNamespacesSection)
1495 .
Case(
"apple_namespac", &AppleNamespacesSection)
1496 .
Case(
"apple_objc", &AppleObjCSection)
1514 std::deque<SmallString<0>> UncompressedSections;
1520 .Case(
"debug_abbrev", &AbbrevSection)
1521 .
Case(
"debug_aranges", &ArangesSection)
1522 .
Case(
"debug_str", &StrSection)
1523 .
Case(
"debug_macinfo", &MacinfoSection)
1524 .
Case(
"debug_macinfo.dwo", &MacinfoDWOSection)
1525 .
Case(
"debug_abbrev.dwo", &AbbrevDWOSection)
1526 .
Case(
"debug_str.dwo", &StrDWOSection)
1527 .
Case(
"debug_cu_index", &CUIndexSection)
1528 .
Case(
"debug_tu_index", &TUIndexSection)
1529 .
Case(
"gdb_index", &GdbIndexSection)
1530 .
Case(
"debug_line_str", &LineStrSection)
1537 Error maybeDecompress(
const object::SectionRef &Sec,
StringRef Name,
1539 if (!Decompressor::isCompressed(Sec))
1543 Decompressor::create(Name, Data, IsLittleEndian, AddressSize == 8);
1548 if (
auto Err = Decompressor->resizeAndDecompress(Out))
1551 UncompressedSections.push_back(std::move(Out));
1552 Data = UncompressedSections.
back();
1558 DWARFObjInMemory(
const StringMap<std::unique_ptr<MemoryBuffer>> &Sections,
1559 uint8_t AddrSize,
bool IsLittleEndian)
1560 : IsLittleEndian(IsLittleEndian) {
1561 for (
const auto &SecIt : Sections) {
1562 if (
StringRef *SectionData = mapSectionToMember(SecIt.first()))
1563 *SectionData = SecIt.second->getBuffer();
1564 else if (SecIt.first() ==
"debug_info")
1567 InfoSections[SectionRef()].Data = SecIt.second->getBuffer();
1568 else if (SecIt.first() ==
"debug_info.dwo")
1569 InfoDWOSections[SectionRef()].Data = SecIt.second->getBuffer();
1570 else if (SecIt.first() ==
"debug_types")
1571 TypesSections[SectionRef()].Data = SecIt.second->getBuffer();
1572 else if (SecIt.first() ==
"debug_types.dwo")
1573 TypesDWOSections[SectionRef()].Data = SecIt.second->getBuffer();
1585 if (
auto NameOrErr =
Section.getName())
1590 ++SectionAmountMap[
Name];
1591 SectionNames.push_back({
Name,
true });
1605 "failed to get relocated section: ", SecOrErr.
takeError()));
1624 if (
auto Err = maybeDecompress(
Section, Name, Data)) {
1626 "failed to decompress '" + Name +
"', ", std::move(Err)));
1641 if (
StringRef *SectionData = mapSectionToMember(Name)) {
1642 *SectionData =
Data;
1643 if (Name ==
"debug_ranges") {
1645 RangesDWOSection.Data =
Data;
1647 }
else if (Name ==
"debug_info") {
1651 }
else if (Name ==
"debug_info.dwo") {
1653 }
else if (Name ==
"debug_types") {
1655 }
else if (Name ==
"debug_types.dwo") {
1663 if (
auto NameOrErr = RelocatedSection->getName())
1664 RelSecName = *NameOrErr;
1680 if (!L && isa<MachOObjectFile>(&Obj))
1683 RelSecName = RelSecName.
substr(
1688 DWARFSectionMap *Sec = mapNameToDWARFSection(RelSecName);
1693 if (RelSecName ==
"debug_info")
1694 Map = &
static_cast<DWARFSectionMap &
>(InfoSections[*RelocatedSection])
1696 else if (RelSecName ==
"debug_info.dwo")
1697 Map = &
static_cast<DWARFSectionMap &
>(
1698 InfoDWOSections[*RelocatedSection])
1700 else if (RelSecName ==
"debug_types")
1702 &
static_cast<DWARFSectionMap &
>(TypesSections[*RelocatedSection])
1704 else if (RelSecName ==
"debug_types.dwo")
1705 Map = &
static_cast<DWARFSectionMap &
>(
1706 TypesDWOSections[*RelocatedSection])
1716 std::map<SymbolRef, SymInfo> AddrCache;
1717 bool (*Supports)(uint64_t);
1720 for (
const RelocationRef &Reloc :
Section.relocations()) {
1728 if (!SymInfoOrErr) {
1738 if (Supports && Supports(Reloc.getType())) {
1742 SymInfoOrErr->Address,
1751 "At most two relocations per offset are supported"));
1760 Reloc.getTypeName(Type);
1762 createError(
"failed to compute relocation: " + Type +
", ",
1771 if (SectionAmountMap[S.Name] > 1)
1772 S.IsNameUnique =
false;
1776 uint64_t Pos)
const override {
1777 auto &Sec =
static_cast<const DWARFSectionMap &
>(S);
1779 if (AI == Sec.Relocs.end())
1787 return SectionNames;
1791 StringRef getAbbrevDWOSection()
const override {
return AbbrevDWOSection; }
1792 const DWARFSection &getLineDWOSection()
const override {
1793 return LineDWOSection;
1795 const DWARFSection &getLocDWOSection()
const override {
1796 return LocDWOSection;
1798 StringRef getStrDWOSection()
const override {
return StrDWOSection; }
1799 const DWARFSection &getStrOffsetsDWOSection()
const override {
1800 return StrOffsetsDWOSection;
1802 const DWARFSection &getRangesDWOSection()
const override {
1803 return RangesDWOSection;
1805 const DWARFSection &getRnglistsDWOSection()
const override {
1806 return RnglistsDWOSection;
1808 const DWARFSection &getLoclistsDWOSection()
const override {
1809 return LoclistsDWOSection;
1811 const DWARFSection &getAddrSection()
const override {
return AddrSection; }
1812 StringRef getCUIndexSection()
const override {
return CUIndexSection; }
1813 StringRef getGdbIndexSection()
const override {
return GdbIndexSection; }
1814 StringRef getTUIndexSection()
const override {
return TUIndexSection; }
1817 const DWARFSection &getStrOffsetsSection()
const override {
1818 return StrOffsetsSection;
1820 StringRef getLineStrSection()
const override {
return LineStrSection; }
1823 void forEachInfoDWOSections(
1825 for (
auto &
P : InfoDWOSections)
1828 void forEachTypesDWOSections(
1830 for (
auto &
P : TypesDWOSections)
1834 StringRef getAbbrevSection()
const override {
return AbbrevSection; }
1835 const DWARFSection &getLocSection()
const override {
return LocSection; }
1836 const DWARFSection &getLoclistsSection()
const override {
return LoclistsSection; }
1837 StringRef getArangesSection()
const override {
return ArangesSection; }
1839 return FrameSection;
1841 const DWARFSection &getEHFrameSection()
const override {
1842 return EHFrameSection;
1844 const DWARFSection &getLineSection()
const override {
return LineSection; }
1845 StringRef getStrSection()
const override {
return StrSection; }
1846 const DWARFSection &getRangesSection()
const override {
return RangesSection; }
1847 const DWARFSection &getRnglistsSection()
const override {
1848 return RnglistsSection;
1850 StringRef getMacinfoSection()
const override {
return MacinfoSection; }
1851 StringRef getMacinfoDWOSection()
const override {
return MacinfoDWOSection; }
1852 const DWARFSection &getPubnamesSection()
const override {
return PubnamesSection; }
1853 const DWARFSection &getPubtypesSection()
const override {
return PubtypesSection; }
1854 const DWARFSection &getGnuPubnamesSection()
const override {
1855 return GnuPubnamesSection;
1857 const DWARFSection &getGnuPubtypesSection()
const override {
1858 return GnuPubtypesSection;
1860 const DWARFSection &getAppleNamesSection()
const override {
1861 return AppleNamesSection;
1863 const DWARFSection &getAppleTypesSection()
const override {
1864 return AppleTypesSection;
1866 const DWARFSection &getAppleNamespacesSection()
const override {
1867 return AppleNamespacesSection;
1869 const DWARFSection &getAppleObjCSection()
const override {
1870 return AppleObjCSection;
1873 return NamesSection;
1877 uint8_t getAddressSize()
const override {
return AddressSize; }
1878 void forEachInfoSections(
1880 for (
auto &
P : InfoSections)
1883 void forEachTypesSections(
1885 for (
auto &
P : TypesSections)
1891 std::unique_ptr<DWARFContext>
1894 std::string DWPName) {
1895 auto DObj = std::make_unique<DWARFObjInMemory>(Obj, L, HandleError);
1896 return std::make_unique<DWARFContext>(std::move(DObj), std::move(DWPName));
1899 std::unique_ptr<DWARFContext>
1903 std::make_unique<DWARFObjInMemory>(Sections, AddrSize,
isLittleEndian);
1904 return std::make_unique<DWARFContext>(std::move(DObj),
"");
1914 std::string TargetLookupError;
1915 const Target *TheTarget =
1917 if (!TargetLookupError.empty())
1919 TargetLookupError.c_str());
const DWARFUnitIndex & getTUIndex()
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
void getInlinedChainForAddress(uint64_t Address, SmallVectorImpl< DWARFDie > &InlinedChain)
getInlinedChainForAddress - fetches inlined chain for a given address.
const DWARFDebugFrame * getEHFrame()
Get a pointer to the parsed eh frame information object.
const DWARFDebugFrame * getDebugFrame()
Get a pointer to the parsed frame information object.
unsigned getMaxDWOVersion()
static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName, const DWARFObject &Obj, const DWARFSection &StringOffsetsSection, StringRef StringSection, DWARFContext::unit_iterator_range Units, bool LittleEndian, unsigned MaxVersion)
uint8_t[16] uuid_t
Output a formatted UUID with dash separators.
Optional< int64_t > FrameOffset
unit_iterator_range dwo_type_units()
Get type units in the DWO context.
DWARFUnit * getUnitForOffset(uint64_t Offset) const
A parsed .debug_frame or .eh_frame section.
This class represents lattice values for constants.
Represents structure for holding and parsing .debug_pub* tables.
const DWARFDebugLoc * getDebugLoc()
Get a pointer to the parsed DebugLoc object.
virtual bool getLoadedSectionContents(const object::SectionRef &Sec, StringRef &Data) const
If conveniently available, return the content of the given Section.
std::pair< bool(*)(uint64_t), RelocationResolver > getRelocationResolver(const ObjectFile &Obj)
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
ErrorPolicy
Used as a return value for a error callback passed to DWARF context.
bool addressRangeContainsAddress(const uint64_t Address) const
void setVendor(VendorType Kind)
setVendor - Set the vendor (second) component of the triple to a known type.
StringRef getFileName() const
const AppleAcceleratorTable & getAppleNamespaces()
Get a reference to the parsed accelerator table object.
void dump(raw_ostream &OS) const
void push_back(const T &Elt)
DWARFGdbIndex & getGdbIndex()
std::shared_ptr< DWARFContext > getDWOContext(StringRef AbsolutePath)
static raw_ostream & error()
Convenience method for printing "error: " to stderr.
unsigned getNumDWOCompileUnits()
Get the number of compile units in the DWO context.
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
bool handleDebugLine()
Verify the information in the .debug_line section.
An efficient, type-erasing, non-owning reference to a callable.
uint8_t getCUAddrSize()
Get address size from CUs.
uint32_t Line
An unsigned integer indicating a source line number.
DIEsForAddress getDIEsForAddress(uint64_t Address)
Get the compilation unit, the function DIE and lexical block DIE for the given address where applicab...
bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, DILineInfoSpecifier::FileLineInfoKind Kind, std::string &Result) const
Extracts filename by its index in filename table in prologue.
This class is the base class for all object file types.
virtual std::string message() const
Return the error message as a string.
static raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
This class implements a map that also provides access to all stored values in a deterministic order...
Optional< uint64_t > TagOffset
const DWARFDebugLine::LineTable * getLineTableForUnit(DWARFUnit *U)
Get a pointer to a parsed line table corresponding to a compile unit.
DWARFDie getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE as the referenced DIE.
unsigned getNumTypeUnits()
Get the number of type units in this context.
unit_iterator_range dwo_info_section_units()
Get units from .debug_info..dwo in the DWO context.
void setOS(OSType Kind)
setOS - Set the operating system (third) component of the triple to a known type. ...
void addFrame(const DILineInfo &Frame)
const DWARFDebugAbbrev * getDebugAbbrevDWO()
Get a pointer to the parsed dwo abbreviations object.
DINameKind
A DINameKind is passed to name search methods to specify a preference regarding the type of name reso...
static void dumpRnglistsSection(raw_ostream &OS, DWARFDataExtractor &rnglistData, llvm::function_ref< Optional< object::SectionedAddress >(uint32_t)> LookupPooledAddress, DIDumpOptions DumpOpts)
Error takeError()
Take ownership of the stored error.
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
static void dumpLoclistsSection(raw_ostream &OS, DIDumpOptions DumpOpts, DWARFDataExtractor Data, const MCRegisterInfo *MRI, const DWARFObject &Obj, Optional< uint64_t > DumpOffset)
bool getFileLineInfoForAddress(object::SectionedAddress Address, const char *CompDir, DILineInfoSpecifier::FileLineInfoKind Kind, DILineInfo &Result) const
Fills the Result argument with the file and line information corresponding to Address.
Base class for error info classes.
void addUnitsForSection(DWARFContext &C, const DWARFSection &Section, DWARFSectionKind SectionKind)
Read units from a .debug_info or .debug_types section.
Optional< object::RelocationRef > Reloc2
StringSwitch & Case(StringLiteral S, T Value)
bool handleDebugInfo()
Verify the information in the .debug_info and .debug_types sections.
uint64_t getOffset() const
Get the offset the parser has reached.
raw_ostream & write_uuid(const uuid_t UUID)
A format-neutral container for source line information.
DWARFDie getSubroutineForAddress(uint64_t Address)
Returns subprogram DIE with address range encompassing the provided address.
object::SectionedAddress Address
The program-counter value corresponding to a machine instruction generated by the compiler and sectio...
Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr)
Extract an entire table, including all list entries.
static Error createError(const Twine &Err)
std::string toString(Error E)
Write all error messages (if any) in E to a string.
bool lookupAddressRange(object::SectionedAddress Address, uint64_t Size, std::vector< uint32_t > &Result) const
static bool getFunctionNameAndStartLineForAddress(DWARFCompileUnit *CU, uint64_t Address, FunctionNameKind Kind, std::string &FunctionName, uint32_t &StartLine)
TODO: change input parameter from "uint64_t Address" into "SectionedAddress Address".
Triple::ArchType getArch() const
static T & getAccelTable(std::unique_ptr< T > &Cache, const DWARFObject &Obj, const DWARFSection &Section, StringRef StringSection, bool IsLittleEndian)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
unit_iterator_range normal_units()
Get all normal compile/type units in this context.
const char * getCompilationDir()
A class representing an address table as specified in DWARF v5.
unsigned getNumCompileUnits()
Get the number of compile units in this context.
const DWARFSection & getLineSection() const
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.
unit_iterator_range compile_units()
Get compile units in this context.
LLVM_NODISCARD R Default(T Value)
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...
virtual uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const
Obtain the Load Address of a section by SectionRef.
Tagged union holding either a T or a Error.
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
uint64_t Size
The contribution size not including the header.
const MCRegisterInfo * getRegisterInfo() const
unsigned getNumDWOTypeUnits()
Get the number of type units in the DWO context.
uint8_t getAddressByteSize() const
DWARFDie getDIEForOffset(uint64_t Offset)
Get a DIE given an exact offset.
content_iterator< SectionRef > section_iterator
bool verify(raw_ostream &OS, DIDumpOptions DumpOpts={}) override
const DWARFDebugAranges * getDebugAranges()
Get a pointer to the parsed DebugAranges object.
Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr, uint16_t Version, uint8_t AddrSize, std::function< void(Error)> WarnCallback)
Extract an entire table, including all addresses.
LLVM_NODISCARD size_t size() const
size - Get the string size.
const DWARFDebugAbbrev * getDebugAbbrev()
Get a pointer to the parsed DebugAbbrev object.
section_iterator_range sections() const
static Optional< int64_t > getExpressionFrameOffset(ArrayRef< uint8_t > Expr, Optional< unsigned > FrameBaseReg)
static Optional< uint64_t > getTypeSize(DWARFDie Type, uint64_t PointerSize)
const std::string & str() const
Analysis containing CSE Info
uint64_t getDeclLine() const
Returns the declaration line (start line) for a DIE, assuming it specifies a subprogram.
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
void dump(raw_ostream &OS, const MCRegisterInfo *MRI, Optional< uint64_t > Offset) const
Dump the section data into the given stream.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Error loadRegisterInfo(const object::ObjectFile &Obj)
Loads register info for the architecture of the provided object file.
Container for dump options that control which debug information will be dumped.
unit_iterator_range info_section_units()
Get units from .debug_info in this context.
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
static Expected< StringRef > getFileName(const DebugStringTableSubsectionRef &Strings, const DebugChecksumsSubsectionRef &Checksums, uint32_t FileID)
Optional< uint64_t > toSectionOffset(const Optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an section offset.
A switch()-like statement whose cases are string literals.
Utility class that carries the DWARF compile/type unit and the debug info entry in an object...
This implements the Apple accelerator table format, a precursor of the DWARF 5 accelerator table form...
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
unit_iterator_range dwo_types_section_units()
Get units from .debug_types.dwo in the DWO context.
unsigned const MachineRegisterInfo * MRI
virtual uint8_t getBytesInAddress() const =0
The number of bytes used to represent an address in this object file format.
The instances of the Type class are immutable: once they are created, they are never changed...
Controls which fields of DILineInfo container should be filled with data.
DIDumpOptions noImplicitRecursion() const
Return the options with RecurseDepth set to 0 unless explicitly required.
static void dumpAddrSection(raw_ostream &OS, DWARFDataExtractor &AddrData, DIDumpOptions DumpOpts, uint16_t Version, uint8_t AddrSize)
LineTable parseNext(function_ref< void(Error)> RecoverableErrorCallback, function_ref< void(Error)> UnrecoverableErrorCallback, raw_ostream *OS=nullptr)
Get the next line table from the section.
uint16_t File
An unsigned integer indicating the identity of the source file corresponding to a machine instruction...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Expected< DWARFLocationExpressionsVector > getLocations(dwarf::Attribute Attr) const
const DWARFDebugMacro * getDebugMacro()
Get a pointer to the parsed DebugMacro object.
A format-neutral container for inlined code description.
A structured debug information entry.
LLVM_NODISCARD size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
void dump(raw_ostream &OS) const
bool handleDebugAbbrev()
Verify the information in any of the following sections, if available: .debug_abbrev, debug_abbrev.dwo.
static void dumpWarning(Error Warning)
Dump Error as warning message to stderr.
static ErrorPolicy defaultErrorHandler(Error E)
Function used to handle default error reporting policy.
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
void dump(raw_ostream &OS)
DWARFContext & getContext() const
Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr)
virtual basic_symbol_iterator symbol_end() const =0
static void dumpDWARFv5StringOffsetsSection(raw_ostream &OS, StringRef SectionName, const DWARFObject &Obj, const DWARFSection &StringOffsetsSection, StringRef StringSection, DWARFContext::unit_iterator_range Units, bool LittleEndian)
static void dumpUUID(raw_ostream &OS, const ObjectFile &Obj)
Dump the UUID load command.
static bool isRelocScattered(const object::ObjectFile &Obj, const RelocationRef &Reloc)
void dump(raw_ostream &OS) const
Print the macro list found within the debug_macinfo section.
static constexpr const char *const BadString
StringRef toStringRef(bool B)
Construct a string ref from a boolean.
const DWARFDebugMacro * getDebugMacroDWO()
Get a pointer to the parsed DebugMacroDWO object.
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
void consumeError(Error Err)
Consume a Error without doing anything.
LLVM_NODISCARD char back() const
back - Get the last character in the string.
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const
bool isLittleEndian() const
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&... Args)
void dump(raw_ostream &OS, const MCRegisterInfo *RegInfo, const DWARFObject &Obj, DIDumpOptions DumpOpts, Optional< uint64_t > Offset) const
Print the location lists found within the debug_loc section.
const AppleAcceleratorTable & getAppleObjC()
Get a reference to the parsed accelerator table object.
Triple - Helper class for working with autoconf configuration names.
Standard .debug_line state machine structure.
const AppleAcceleratorTable & getAppleTypes()
Get a reference to the parsed accelerator table object.
static std::unique_ptr< DWARFContext > create(const object::ObjectFile &Obj, const LoadedObjectInfo *L=nullptr, function_ref< ErrorPolicy(Error)> HandleError=defaultErrorHandler, std::string DWPName="")
void sort(IteratorTy Start, IteratorTy End)
DWARFUnit * getUnitForIndexEntry(const DWARFUnitIndex::Entry &E)
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
unit_iterator_range dwo_compile_units()
Get compile units in the DWO context.
std::vector< DILocal > getLocalsForAddress(object::SectionedAddress Address) override
.debug_names section consists of one or more units.
DWARFCompileUnit * getDWOCompileUnitForHash(uint64_t Hash)
void dump(raw_ostream &OS, DIDumpOptions DumpOpts={}) const
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
DIInliningInfo getInliningInfoForAddress(object::SectionedAddress Address, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
uint16_t Column
An unsigned integer indicating a column number within a source line.
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
StringRef getArchName() const
getArchName - Get the architecture (first) component of the triple.
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an escape...
static ErrorSuccess success()
Create a success value.
unit_iterator_range type_units()
Get type units in this context.
uint32_t getLength() const
Returns the length of this table, including the length field, or 0 if the length has not been determi...
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
void addUnitsForDWOSection(DWARFContext &C, const DWARFSection &DWOSection, DWARFSectionKind SectionKind, bool Lazy=false)
Read units from a .debug_info.dwo or .debug_types.dwo section.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
DWARFCompileUnit * CompileUnit
void dump(raw_ostream &OS) const override
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.
virtual Triple::ArchType getArch() const =0
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
std::pair< llvm::MachO::Target, std::string > UUID
A range adaptor for a pair of iterators.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
This file contains constants used for implementing Dwarf debug support.
Target - Wrapper for Target specific information.
An inferface for inquiring the load address of a loaded object file to be used by the DIContext imple...
void dump(raw_ostream &OS, llvm::function_ref< Optional< object::SectionedAddress >(uint32_t)> LookupPooledAddress, DIDumpOptions DumpOpts={}) const
void dump(raw_ostream &OS) const
unit_iterator_range types_section_units()
Get units from .debug_types in this context.
RelocAddrEntry contains relocated value and section index.
void finishedInfoUnits()
Indicate that parsing .debug_info[.dwo] is done, and remaining units will be from ...
const DWARFDebugNames & getDebugNames()
Get a reference to the parsed accelerator table object.
A class that verifies DWARF debug information given a DWARF Context.
virtual section_iterator section_end() const =0
dwarf::Tag getTag() const
LLVM_NODISCARD bool empty() const
const AppleAcceleratorTable & getAppleNames()
Get a reference to the parsed accelerator table object.
Wraps the returned DIEs for a given address.
Optional< uint64_t > Size
bool handleAccelTables()
Verify the information in accelerator tables, if they exist.
static ContributionCollection collectContributionData(DWARFContext::unit_iterator_range Units)
unit_iterator_range dwo_units()
Get all units in the DWO context.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
DWARFUnit * getUnitAtIndex(unsigned index)
Get the unit at the specified index.
DILineInfo getLineInfoForAddress(object::SectionedAddress Address, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, std::array< Optional< uint64_t >, DIDT_ID_Count > DumpOffsets)
Dump a textual representation to OS.
DWARFContext(std::unique_ptr< const DWARFObject > DObj, std::string DWPName="")
DILineInfoTable getLineInfoForAddressRange(object::SectionedAddress Address, uint64_t Size, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
bool isLittleEndian() const
const DWARFUnitIndex & getCUIndex()
void dump(raw_ostream &OS) const override
SymInfo contains information about symbol: it's address and section index which is -1LL for absolute ...
DINameKind FunctionNameKind
uint64_t(*)(RelocationRef R, uint64_t S, uint64_t A) RelocationResolver
Optional< DWARFFormValue > find(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE.
Lightweight error class with error context and mandatory checking.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
This class implements an extremely fast bulk output stream that can only output to a stream...
print Instructions which execute on loop entry
StringRef - Represent a constant reference to a string, i.e.
bool hasValidLength() const
Verify that the given length is valid for this table.
void skip(function_ref< void(Error)> ErrorCallback)
Skip the current line table and go to the following line table (if present) immediately.
DWARFCompileUnit * getCompileUnitForOffset(uint64_t Offset)
Return the compile unit that includes an offset (relative to .debug_info).
Helper to allow for parsing of an entire .debug_line section in sequence.
bool done() const
Indicates if the parser has parsed as much as possible.
uint32_t getLineTableOffset() const
const char * getSubroutineName(DINameKind Kind) const
If a DIE represents a subprogram (or inlined subroutine), returns its mangled name (or short name...
void setArch(ArchType Kind)
setArch - Set the architecture (first) component of the triple to a known type.
Optional< uint64_t > toUnsigned(const Optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an unsigned constant.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
bool empty() const
empty - Check if the array is empty.
This is a value type class that represents a single section in the list of sections in the object fil...
std::vector< Optional< StrOffsetsContributionDescriptor > > ContributionCollection
StringRef extension(StringRef path, Style style=Style::native)
Get extension.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
uint64_t findAddress(uint64_t Address) const