28 using namespace dwarf;
33 auto Begin = Ranges.begin();
34 auto End = Ranges.end();
38 if (Pos->intersects(R))
42 if (Iter->intersects(R))
47 Ranges.insert(Pos, R);
53 auto End = Children.end();
54 auto Iter = Children.begin();
56 if (Iter->intersects(RI))
61 return Children.end();
67 if (Ranges.empty() || RHS.
Ranges.empty())
72 auto End = Ranges.end();
73 auto Iter = findRange(RHS.
Ranges.front());
77 for (
const auto &R : RHS.
Ranges) {
79 if (Iter->contains(R))
90 if (Ranges.empty() || RHS.
Ranges.empty())
93 auto End = Ranges.end();
94 auto Iter = findRange(RHS.
Ranges.front());
95 for (
const auto &R : RHS.
Ranges) {
98 if (R.HighPC <= Iter->LowPC)
100 while (Iter != End) {
101 if (Iter->intersects(R))
112 uint8_t &
UnitType,
bool &isUnitDWARF64) {
114 uint8_t AddrSize = 0;
118 bool ValidLength =
false;
119 bool ValidVersion =
false;
120 bool ValidAddrSize =
false;
121 bool ValidType =
true;
122 bool ValidAbbrevOffset =
true;
125 Length = DebugInfoData.
getU32(Offset);
126 if (Length == UINT32_MAX) {
127 isUnitDWARF64 =
true;
129 "Unit[%d] is in 64-bit DWARF format; cannot verify from this point.\n",
133 Version = DebugInfoData.
getU16(Offset);
137 AddrSize = DebugInfoData.
getU8(Offset);
138 AbbrOffset = DebugInfoData.
getU32(Offset);
142 AbbrOffset = DebugInfoData.
getU32(Offset);
143 AddrSize = DebugInfoData.
getU8(Offset);
146 if (!DCtx.getDebugAbbrev()->getAbbreviationDeclarationSet(AbbrOffset))
147 ValidAbbrevOffset =
false;
149 ValidLength = DebugInfoData.
isValidOffset(OffsetStart + Length + 3);
151 ValidAddrSize = AddrSize == 4 || AddrSize == 8;
152 if (!ValidLength || !ValidVersion || !ValidAddrSize || !ValidAbbrevOffset ||
155 error() <<
format(
"Units[%d] - start offset: 0x%08x \n", UnitIndex,
158 note() <<
"The length for this unit is too " 159 "large for the .debug_info provided.\n";
161 note() <<
"The 16 bit unit header version is not valid.\n";
163 note() <<
"The unit type encoding is not valid.\n";
164 if (!ValidAbbrevOffset)
165 note() <<
"The offset into the .debug_abbrev section is " 168 note() <<
"The address size is unsupported.\n";
170 *Offset = OffsetStart + Length + 4;
177 for (
unsigned I = 0;
I < NumDies; ++
I) {
179 if (Die.getTag() == DW_TAG_null)
181 for (
auto AttrValue : Die.attributes()) {
182 NumUnitErrors += verifyDebugInfoAttribute(Die, AttrValue);
183 NumUnitErrors += verifyDebugInfoForm(Die, AttrValue);
189 error() <<
"Compilation unit without DIE.\n";
191 return NumUnitErrors == 0;
195 error() <<
"Compilation unit root DIE is not a unit DIE: " 204 <<
") do not match.\n";
209 NumUnitErrors += verifyDieRanges(Die, RI);
211 return NumUnitErrors == 0;
214 unsigned DWARFVerifier::verifyAbbrevSection(
const DWARFDebugAbbrev *Abbrev) {
215 unsigned NumErrors = 0;
219 for (
auto AbbrDecl : *AbbrDecls) {
221 for (
auto Attribute : AbbrDecl.attributes()) {
224 error() <<
"Abbreviation declaration contains multiple " 236 OS <<
"Verifying .debug_abbrev...\n";
242 if (noDebugAbbrev && noDebugAbbrevDWO) {
246 unsigned NumErrors = 0;
248 NumErrors += verifyAbbrevSection(DCtx.getDebugAbbrev());
250 if (!noDebugAbbrevDWO)
251 NumErrors += verifyAbbrevSection(DCtx.getDebugAbbrevDWO());
252 return NumErrors == 0;
256 OS <<
"Verifying .debug_info Unit Header Chain...\n";
260 DCtx.isLittleEndian(), 0);
262 uint32_t OffsetStart = 0, Offset = 0, UnitIdx = 0;
264 bool isUnitDWARF64 =
false;
265 bool isHeaderChainValid =
true;
271 if (!verifyUnitHeader(DebugInfoData, &Offset, UnitIdx, UnitType,
273 isHeaderChainValid =
false;
278 Header.
extract(DCtx, DebugInfoData, &OffsetStart);
279 std::unique_ptr<DWARFUnit> Unit;
281 case dwarf::DW_UT_type:
282 case dwarf::DW_UT_split_type: {
290 case dwarf::DW_UT_skeleton:
291 case dwarf::DW_UT_split_compile:
292 case dwarf::DW_UT_compile:
293 case dwarf::DW_UT_partial:
306 if (!verifyUnitContents(*Unit, UnitType))
307 ++NumDebugInfoErrors;
312 if (UnitIdx == 0 && !hasDIE) {
313 warn() <<
".debug_info is empty.\n";
314 isHeaderChainValid =
true;
316 NumDebugInfoErrors += verifyDebugInfoReferences();
317 return (isHeaderChainValid && NumDebugInfoErrors == 0);
320 unsigned DWARFVerifier::verifyDieRanges(
const DWARFDie &Die,
322 unsigned NumErrors = 0;
328 if (!RangesOrError) {
339 for (
auto Range : Ranges) {
340 if (!Range.valid()) {
342 error() <<
"Invalid address range " << Range <<
"\n";
347 const auto IntersectingRange = RI.
insert(Range);
348 if (IntersectingRange != RI.
Ranges.end()) {
350 error() <<
"DIE has overlapping address ranges: " << Range <<
" and " 351 << *IntersectingRange <<
"\n";
357 const auto IntersectingChild = ParentRI.
insert(RI);
358 if (IntersectingChild != ParentRI.
Children.end()) {
360 error() <<
"DIEs have overlapping address ranges:";
362 IntersectingChild->Die.dump(OS, 0);
367 bool ShouldBeContained = !Ranges.empty() && !ParentRI.
Ranges.empty() &&
368 !(Die.
getTag() == DW_TAG_subprogram &&
369 ParentRI.
Die.
getTag() == DW_TAG_subprogram);
370 if (ShouldBeContained && !ParentRI.
contains(RI)) {
372 error() <<
"DIE address ranges are not contained in its parent's ranges:";
380 NumErrors += verifyDieRanges(Child, RI);
385 unsigned DWARFVerifier::verifyDebugInfoAttribute(
const DWARFDie &Die,
387 unsigned NumErrors = 0;
390 error() << TitleMsg <<
'\n';
391 Die.
dump(OS, 0, DumpOpts);
396 const auto Attr = AttrValue.
Attr;
402 ReportError(
"DW_AT_ranges offset is beyond .debug_ranges bounds:");
405 ReportError(
"DIE has invalid DW_AT_ranges encoding:");
407 case DW_AT_stmt_list:
411 ReportError(
"DW_AT_stmt_list offset is beyond .debug_line bounds: " +
415 ReportError(
"DIE has invalid DW_AT_stmt_list encoding:");
417 case DW_AT_location: {
427 ReportError(
"DIE contains invalid DWARF expression:");
434 if (
auto DebugLoc = DCtx.getDebugLoc())
435 if (
auto LocList =
DebugLoc->getLocationListAtOffset(*LocOffset))
436 for (
const auto &Entry : LocList->Entries)
437 VerifyLocationExpr({Entry.Loc.data(), Entry.Loc.size()});
448 unsigned DWARFVerifier::verifyDebugInfoForm(
const DWARFDie &Die,
451 unsigned NumErrors = 0;
458 case DW_FORM_ref_udata: {
466 if (CUOffset >= CUSize) {
469 <<
format(
"0x%08" PRIx64, CUOffset)
470 <<
" is invalid (must be less than CU size of " 471 <<
format(
"0x%08" PRIx32, CUSize) <<
"):\n";
472 Die.
dump(OS, 0, DumpOpts);
477 ReferenceToDIEOffsets[*RefVal].insert(Die.
getOffset());
482 case DW_FORM_ref_addr: {
490 error() <<
"DW_FORM_ref_addr offset beyond .debug_info " 492 Die.
dump(OS, 0, DumpOpts);
497 ReferenceToDIEOffsets[*RefVal].insert(Die.
getOffset());
507 error() <<
"DW_FORM_strp offset beyond .debug_str bounds:\n";
508 Die.
dump(OS, 0, DumpOpts);
519 unsigned DWARFVerifier::verifyDebugInfoReferences() {
522 OS <<
"Verifying .debug_info references...\n";
523 unsigned NumErrors = 0;
524 for (
auto Pair : ReferenceToDIEOffsets) {
525 auto Die = DCtx.getDIEForOffset(Pair.first);
529 error() <<
"invalid DIE reference " <<
format(
"0x%08" PRIx64, Pair.first)
530 <<
". Offset is in between DIEs:\n";
531 for (
auto Offset : Pair.second) {
532 auto ReferencingDie = DCtx.getDIEForOffset(Offset);
533 ReferencingDie.dump(OS, 0, DumpOpts);
541 void DWARFVerifier::verifyDebugLineStmtOffsets() {
542 std::map<uint64_t, DWARFDie> StmtListToDie;
543 for (
const auto &
CU : DCtx.compile_units()) {
544 auto Die =
CU->getUnitDIE();
549 if (!StmtSectionOffset)
551 const uint32_t LineTableOffset = *StmtSectionOffset;
552 auto LineTable = DCtx.getLineTableForUnit(
CU.get());
553 if (LineTableOffset < DCtx.getDWARFObj().getLineSection().Data.size()) {
555 ++NumDebugLineErrors;
556 error() <<
".debug_line[" <<
format(
"0x%08" PRIx32, LineTableOffset)
557 <<
"] was not able to be parsed for CU:\n";
558 Die.
dump(OS, 0, DumpOpts);
564 assert(LineTable ==
nullptr);
569 auto Iter = StmtListToDie.find(LineTableOffset);
570 if (Iter != StmtListToDie.end()) {
571 ++NumDebugLineErrors;
572 error() <<
"two compile unit DIEs, " 573 <<
format(
"0x%08" PRIx32, Iter->second.getOffset()) <<
" and " 575 <<
", have the same DW_AT_stmt_list section offset:\n";
576 Iter->second.dump(OS, 0, DumpOpts);
577 Die.
dump(OS, 0, DumpOpts);
582 StmtListToDie[LineTableOffset] = Die;
586 void DWARFVerifier::verifyDebugLineRows() {
587 for (
const auto &
CU : DCtx.compile_units()) {
588 auto Die =
CU->getUnitDIE();
589 auto LineTable = DCtx.getLineTableForUnit(
CU.get());
596 uint32_t MaxFileIndex = LineTable->Prologue.FileNames.size();
597 uint32_t MaxDirIndex = LineTable->Prologue.IncludeDirectories.size();
600 for (
const auto &FileName : LineTable->Prologue.FileNames) {
602 if (FileName.DirIdx > MaxDirIndex) {
603 ++NumDebugLineErrors;
604 error() <<
".debug_line[" 607 <<
"].prologue.file_names[" << FileIndex
608 <<
"].dir_idx contains an invalid index: " << FileName.DirIdx
613 std::string FullPath;
614 const bool HasFullPath = LineTable->getFileNameByIndex(
615 FileIndex,
CU->getCompilationDir(),
617 assert(HasFullPath &&
"Invalid index?");
619 auto It = FullPathMap.
find(FullPath);
620 if (It == FullPathMap.
end())
621 FullPathMap[FullPath] = FileIndex;
622 else if (It->second != FileIndex) {
623 warn() <<
".debug_line[" 626 <<
"].prologue.file_names[" << FileIndex
627 <<
"] is a duplicate of file_names[" << It->second <<
"]\n";
634 uint64_t PrevAddress = 0;
636 for (
const auto &Row : LineTable->Rows) {
638 if (Row.Address < PrevAddress) {
639 ++NumDebugLineErrors;
640 error() <<
".debug_line[" 643 <<
"] row[" << RowIndex
644 <<
"] decreases in address from previous row:\n";
648 LineTable->Rows[RowIndex - 1].dump(OS);
654 if (Row.File > MaxFileIndex) {
655 ++NumDebugLineErrors;
656 error() <<
".debug_line[" 659 <<
"][" << RowIndex <<
"] has invalid file index " << Row.File
660 <<
" (valid values are [1," << MaxFileIndex <<
"]):\n";
668 PrevAddress = Row.Address;
675 NumDebugLineErrors = 0;
676 OS <<
"Verifying .debug_line...\n";
677 verifyDebugLineStmtOffsets();
678 verifyDebugLineRows();
679 return NumDebugLineErrors == 0;
682 unsigned DWARFVerifier::verifyAppleAccelTable(
const DWARFSection *AccelSection,
685 unsigned NumErrors = 0;
687 DCtx.isLittleEndian(), 0);
690 OS <<
"Verifying " << SectionName <<
"...\n";
693 if (!AccelSectionData.isValidOffset(AccelTable.getSizeHdr())) {
694 error() <<
"Section is too small to fit a section header.\n";
699 if (
Error E = AccelTable.extract()) {
705 uint32_t NumBuckets = AccelTable.getNumBuckets();
706 uint32_t NumHashes = AccelTable.getNumHashes();
709 AccelTable.getSizeHdr() + AccelTable.getHeaderDataLength();
710 uint32_t HashesBase = BucketsOffset + NumBuckets * 4;
711 uint32_t OffsetsBase = HashesBase + NumHashes * 4;
712 for (
uint32_t BucketIdx = 0; BucketIdx < NumBuckets; ++BucketIdx) {
713 uint32_t HashIdx = AccelSectionData.getU32(&BucketsOffset);
714 if (HashIdx >= NumHashes && HashIdx != UINT32_MAX) {
715 error() <<
format(
"Bucket[%d] has invalid hash index: %u.\n", BucketIdx,
720 uint32_t NumAtoms = AccelTable.getAtomsDesc().size();
722 error() <<
"No atoms: failed to read HashData.\n";
725 if (!AccelTable.validateForms()) {
726 error() <<
"Unsupported form: failed to read HashData.\n";
730 for (
uint32_t HashIdx = 0; HashIdx < NumHashes; ++HashIdx) {
731 uint32_t HashOffset = HashesBase + 4 * HashIdx;
732 uint32_t DataOffset = OffsetsBase + 4 * HashIdx;
733 uint32_t Hash = AccelSectionData.getU32(&HashOffset);
734 uint32_t HashDataOffset = AccelSectionData.getU32(&DataOffset);
735 if (!AccelSectionData.isValidOffsetForDataOfSize(HashDataOffset,
737 error() <<
format(
"Hash[%d] has invalid HashData offset: 0x%08x.\n",
738 HashIdx, HashDataOffset);
747 while ((StrpOffset = AccelSectionData.getU32(&HashDataOffset)) != 0) {
749 AccelSectionData.getU32(&HashDataOffset);
750 for (
uint32_t HashDataIdx = 0; HashDataIdx < NumHashDataObjects;
752 std::tie(Offset, Tag) = AccelTable.readAtoms(HashDataOffset);
753 auto Die = DCtx.getDIEForOffset(Offset);
756 NumBuckets ? (Hash % NumBuckets) : UINT32_MAX;
757 StringOffset = StrpOffset;
758 const char *
Name = StrData->
getCStr(&StringOffset);
763 "%s Bucket[%d] Hash[%d] = 0x%08x " 765 "DIE[%d] = 0x%08x is not a valid DIE offset for \"%s\".\n",
766 SectionName, BucketIdx, HashIdx, Hash, StringCount, StrpOffset,
767 HashDataIdx, Offset, Name);
772 if ((Tag != dwarf::DW_TAG_null) && (Die.
getTag() !=
Tag)) {
774 <<
" in accelerator table does not match Tag " 793 CUMap.
reserve(DCtx.getNumCompileUnits());
794 for (
const auto &
CU : DCtx.compile_units())
795 CUMap[
CU->getOffset()] = NotIndexed;
797 unsigned NumErrors = 0;
799 if (NI.getCUCount() == 0) {
800 error() <<
formatv(
"Name Index @ {0:x} does not index any CU\n",
807 auto Iter = CUMap.
find(Offset);
809 if (Iter == CUMap.
end()) {
811 "Name Index @ {0:x} references a non-existing CU @ {1:x}\n",
812 NI.getUnitOffset(),
Offset);
817 if (Iter->second != NotIndexed) {
818 error() <<
formatv(
"Name Index @ {0:x} references a CU @ {1:x}, but " 819 "this CU is already indexed by Name Index @ {2:x}\n",
820 NI.getUnitOffset(),
Offset, Iter->second);
823 Iter->second = NI.getUnitOffset();
827 for (
const auto &KV : CUMap) {
828 if (KV.second == NotIndexed)
829 warn() <<
formatv(
"CU @ {0:x} not covered by any Name Index\n", KV.first);
843 : Bucket(Bucket),
Index(Index) {}
844 bool operator<(
const BucketInfo &RHS)
const {
return Index < RHS.Index; };
849 warn() <<
formatv(
"Name Index @ {0:x} does not contain a hash table.\n",
856 std::vector<BucketInfo> BucketStarts;
861 error() <<
formatv(
"Bucket {0} of Name Index @ {1:x} contains invalid " 862 "value {2}. Valid range is [0, {3}].\n",
868 BucketStarts.emplace_back(Bucket, Index);
888 for (
const BucketInfo &
B : BucketStarts) {
895 if (
B.Index > NextUncovered) {
896 error() <<
formatv(
"Name Index @ {0:x}: Name table entries [{1}, {2}] " 897 "are not covered by the hash table.\n",
915 "Name Index @ {0:x}: Bucket {1} is not empty but points to a " 916 "mismatched hash value {2:x} (belonging to bucket {3}).\n",
932 error() <<
formatv(
"Name Index @ {0:x}: String ({1}) at index {2} " 933 "hashes to {3:x}, but " 934 "the Name Index hash is {4:x}\n",
942 NextUncovered =
std::max(NextUncovered, Idx);
947 unsigned DWARFVerifier::verifyNameIndexAttribute(
951 if (FormName.
empty()) {
952 error() <<
formatv(
"NameIndex @ {0:x}: Abbreviation {1:x}: {2} uses an " 953 "unknown form: {3}.\n",
959 if (AttrEnc.
Index == DW_IDX_type_hash) {
960 if (AttrEnc.
Form != dwarf::DW_FORM_data8) {
962 "NameIndex @ {0:x}: Abbreviation {1:x}: DW_IDX_type_hash " 963 "uses an unexpected form {2} (should be {3}).\n",
972 struct FormClassTable {
977 static constexpr FormClassTable Table[] = {
985 auto Iter =
find_if(TableRef, [AttrEnc](
const FormClassTable &
T) {
986 return T.Index == AttrEnc.
Index;
988 if (Iter == TableRef.
end()) {
989 warn() <<
formatv(
"NameIndex @ {0:x}: Abbreviation {1:x} contains an " 990 "unknown index attribute: {2}.\n",
996 error() <<
formatv(
"NameIndex @ {0:x}: Abbreviation {1:x}: {2} uses an " 997 "unexpected form {3} (expected form class {4}).\n",
999 AttrEnc.
Form, Iter->ClassName);
1008 warn() <<
formatv(
"Name Index @ {0:x}: Verifying indexes of type units is " 1009 "not currently supported.\n",
1014 unsigned NumErrors = 0;
1017 if (TagName.
empty()) {
1018 warn() <<
formatv(
"NameIndex @ {0:x}: Abbreviation {1:x} references an " 1019 "unknown tag: {2}.\n",
1023 for (
const auto &AttrEnc : Abbrev.Attributes) {
1024 if (!Attributes.insert(AttrEnc.
Index).second) {
1025 error() <<
formatv(
"NameIndex @ {0:x}: Abbreviation {1:x} contains " 1026 "multiple {2} attributes.\n",
1031 NumErrors += verifyNameIndexAttribute(NI, Abbrev, AttrEnc);
1034 if (NI.
getCUCount() > 1 && !Attributes.count(dwarf::DW_IDX_compile_unit)) {
1035 error() <<
formatv(
"NameIndex @ {0:x}: Indexing multiple compile units " 1036 "and abbreviation {1:x} has no {2} attribute.\n",
1038 dwarf::DW_IDX_compile_unit);
1041 if (!Attributes.count(dwarf::DW_IDX_die_offset)) {
1043 "NameIndex @ {0:x}: Abbreviation {1:x} has no {2} attribute.\n",
1055 else if (DIE.
getTag() == dwarf::DW_TAG_namespace)
1059 if (Result.
empty() || Result[0] != Str)
1066 unsigned DWARFVerifier::verifyNameIndexEntries(
1076 "Name Index @ {0:x}: Unable to get string associated with name {1}.\n",
1082 unsigned NumErrors = 0;
1083 unsigned NumEntries = 0;
1087 for (; EntryOr; ++NumEntries, EntryID = NextEntryID,
1088 EntryOr = NI.
getEntry(&NextEntryID)) {
1089 uint32_t CUIndex = *EntryOr->getCUIndex();
1091 error() <<
formatv(
"Name Index @ {0:x}: Entry @ {1:x} contains an " 1092 "invalid CU index ({2}).\n",
1098 uint64_t DIEOffset = CUOffset + *EntryOr->getDIEUnitOffset();
1101 error() <<
formatv(
"Name Index @ {0:x}: Entry @ {1:x} references a " 1102 "non-existing DIE @ {2:x}.\n",
1108 error() <<
formatv(
"Name Index @ {0:x}: Entry @ {1:x}: mismatched CU of " 1109 "DIE @ {2:x}: index - {3:x}; debug_info - {4:x}.\n",
1114 if (DIE.
getTag() != EntryOr->tag()) {
1115 error() <<
formatv(
"Name Index @ {0:x}: Entry @ {1:x}: mismatched Tag of " 1116 "DIE @ {2:x}: index - {3}; debug_info - {4}.\n",
1124 error() <<
formatv(
"Name Index @ {0:x}: Entry @ {1:x}: mismatched Name " 1125 "of DIE @ {2:x}: index - {3}; debug_info - {4}.\n",
1127 make_range(EntryNames.begin(), EntryNames.end()));
1135 error() <<
formatv(
"Name Index @ {0:x}: Name {1} ({2}) is " 1136 "not associated with any entries.\n",
1142 <<
formatv(
"Name Index @ {0:x}: Name {1} ({2}): {3}\n",
1155 auto ContainsInterestingOperators = [&](
StringRef D) {
1161 Op.
getCode() == DW_OP_form_tls_address ||
1162 Op.
getCode() == DW_OP_GNU_push_tls_address);
1168 if (ContainsInterestingOperators(
toStringRef(*Expr)))
1174 DebugLoc->getLocationListAtOffset(*Offset)) {
1176 return ContainsInterestingOperators({E.Loc.data(), E.Loc.size()});
1185 unsigned DWARFVerifier::verifyNameIndexCompleteness(
1193 if (Die.
find(DW_AT_declaration))
1204 if (EntryNames.empty())
1216 case DW_TAG_compile_unit:
1221 case DW_TAG_formal_parameter:
1222 case DW_TAG_template_value_parameter:
1223 case DW_TAG_template_type_parameter:
1224 case DW_TAG_GNU_template_parameter_pack:
1225 case DW_TAG_GNU_template_template_param:
1235 case DW_TAG_enumerator:
1240 case DW_TAG_imported_declaration:
1246 case DW_TAG_subprogram:
1247 case DW_TAG_inlined_subroutine:
1250 {DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_entry_pc}))
1259 case DW_TAG_variable:
1270 unsigned NumErrors = 0;
1274 return E.getDIEUnitOffset() == DieUnitOffset;
1276 error() <<
formatv(
"Name Index @ {0:x}: Entry for DIE @ {1:x} ({2}) with " 1277 "name {3} missing.\n",
1286 unsigned DWARFVerifier::verifyDebugNames(
const DWARFSection &AccelSection,
1288 unsigned NumErrors = 0;
1290 DCtx.isLittleEndian(), 0);
1293 OS <<
"Verifying .debug_names...\n";
1297 if (
Error E = AccelTable.extract()) {
1302 NumErrors += verifyDebugNamesCULists(AccelTable);
1303 for (
const auto &NI : AccelTable)
1304 NumErrors += verifyNameIndexBuckets(NI, StrData);
1305 for (
const auto &NI : AccelTable)
1306 NumErrors += verifyNameIndexAbbrevs(NI);
1311 for (
const auto &NI : AccelTable)
1313 NumErrors += verifyNameIndexEntries(NI, NTE);
1318 for (
const std::unique_ptr<DWARFCompileUnit> &
CU : DCtx.compile_units()) {
1320 AccelTable.getCUNameIndex(
CU->getOffset())) {
1322 NumErrors += verifyNameIndexCompleteness(
DWARFDie(
CU.get(), &Die), *NI);
1331 unsigned NumErrors = 0;
1340 ".apple_namespaces");
1347 return NumErrors == 0;
A list of locations that contain one variable.
static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag)
static SmallVector< StringRef, 2 > getNames(const DWARFDie &DIE)
DWARFUnit * getDwarfUnit() const
uint32_t getEntryOffset() const
Returns the offset of the first Entry in the list.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
dwarf::Attribute Attr
The attribute enumeration of this attribute.
Compute iterated dominance frontiers using a linear time algorithm.
const DWARFDebugLoc * getDebugLoc()
Get a pointer to the parsed DebugLoc object.
virtual StringRef getAbbrevSection() const
uint32_t getUnitOffset() const
bool isUnitType(uint8_t UnitType)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
static raw_ostream & error()
Convenience method for printing "error: " to stderr.
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
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.
iterator find(StringRef Key)
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
static raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
This class represents an Operation in the Expression.
Base class for error info classes.
void dump(raw_ostream &OS, unsigned indent=0, DIDumpOptions DumpOpts=DIDumpOptions()) const
Dump the DIE and all of its attributes to the supplied stream.
virtual StringRef getAbbrevDWOSection() const
Abbreviation describing the encoding of Name Index entries.
virtual const DWARFSection & getAppleTypesSection() const
bool handleDebugInfo()
Verify the information in the .debug_info section.
DWARFFormValue Value
The form and value for this attribute.
uint32_t getNextUnitOffset() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
StringRef FormEncodingString(unsigned Encoding)
static bool isVariableIndexable(const DWARFDie &Die, DWARFContext &DCtx)
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
A single location within a location list.
static raw_ostream & note()
Convenience method for printing "note: " to stderr.
Tagged union holding either a T or a Error.
Index attribute and its encoding.
uint32_t getOffset() const
Get the absolute offset into the debug info or types section.
uint8_t getAddressByteSize() const
std::set< DieRangeInfo > Children
Sorted DWARFAddressRangeInfo.
unsigned getNumDIEs()
Returns the number of DIEs in the unit.
uint32_t getLocalTUCount() const
std::vector< DWARFAddressRange > Ranges
Sorted DWARFAddressRanges.
Encapsulates a DWARF attribute value and all of the data required to describe the attribute value...
StringRef AttributeString(unsigned Attribute)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
const DenseSet< Abbrev, AbbrevMapInfo > & getAbbrevs() const
auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
Represents a single accelerator table within the Dwarf 5 .debug_names section.
uint32_t getBucketArrayEntry(uint32_t Bucket) const
Reads an entry in the Bucket Array for the given Bucket.
uint16_t getVersion() const
uint32_t getNameCount() const
iterator find(const_arg_type_t< KeyT > Val)
Optional< uint64_t > toSectionOffset(const Optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an section offset.
virtual const DWARFSection & getAppleObjCSection() const
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
Utility class that carries the DWARF compile/type unit and the debug info entry in an object...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
DWARF v5-specific implementation of an Accelerator Entry.
This implements the Apple accelerator table format, a precursor of the DWARF 5 accelerator table form...
uint32_t getForeignTUCount() const
virtual const DWARFSection & getStringOffsetSection() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
A structured debug information entry.
std::pair< iterator, bool > insert(const ValueT &V)
Optional< DWARFFormValue > findRecursively(ArrayRef< dwarf::Attribute > Attrs) const
Extract the first value of any attribute in Attrs from this DIE and recurse into any DW_AT_specificat...
bool handleDebugAbbrev()
Verify the information in any of the following sections, if available: .debug_abbrev, debug_abbrev.dwo.
NameTableEntry getNameTableEntry(uint32_t Index) const
Reads an entry in the Name Table for the given Index.
A class that keeps the address range information for a single DIE.
const DWARFAbbreviationDeclarationSet * getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const
bool any_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
uint32_t getHashArrayEntry(uint32_t Index) const
Reads an entry in the Hash Array for the given Index.
bool contains(const DieRangeInfo &RHS) const
Return true if ranges in this object contains all ranges within RHS.
virtual StringRef getStringSection() const
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again...
uint32_t getBucketCount() const
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
Expected< Entry > getEntry(uint32_t *Offset) const
std::vector< DWARFAddressRange >::const_iterator address_range_iterator
StringRef toStringRef(bool B)
Construct a string ref from a boolean.
void consumeError(Error Err)
Consume a Error without doing anything.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
UnitType
Constants for unit types in DWARF v5.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
const char * getString() const
Return the string referenced by this name table entry or nullptr if the string offset is not valid...
.debug_names section consists of one or more units.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
const char * getName(DINameKind Kind) const
Return the DIE name resolving DW_AT_sepcification or DW_AT_abstract_origin references if necessary...
A single entry in the Name Table (Dwarf 5 sect.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
uint32_t caseFoldingDjbHash(StringRef Buffer, uint32_t H=5381)
Computes the Bernstein hash after folding the input according to the Dwarf 5 standard case folding ru...
Concrete instance of DWARFUnitSection, specialized for one Unit type.
address_range_iterator insert(const DWARFAddressRange &R)
Inserts the address range.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
uint32_t getIndex() const
Return the index of this name in the parent Name Index.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static void dumpTableHeader(raw_ostream &OS)
Optional< const char * > toString(const Optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
Implements a dense probed hash-table based set with some number of buckets stored inline...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
StringRef UnitTypeString(unsigned)
Error returned by NameIndex::getEntry to report it has reached the end of the entry list...
virtual const DWARFSection & getAppleNamespacesSection() const
virtual const DWARFSection & getInfoSection() const
virtual const DWARFSection & getLineSection() const
bool intersects(const DieRangeInfo &RHS) const
Return true if any range in this object intersects with any range in RHS.
StringRef TagString(unsigned Tag)
virtual const DWARFSection & getDebugNamesSection() const
static bool isSupportedVersion(unsigned version)
DWARFDie getDIEAtIndex(unsigned Index)
Return the DIE object at the given index.
void emplace_back(ArgTypes &&... Args)
dwarf::Tag getTag() const
LLVM_NODISCARD bool empty() const
bool handleAccelTables()
Verify the information in accelerator tables, if they exist.
virtual const DWARFSection & getAppleNamesSection() const
uint32_t getOffset() const
Expected< DWARFAddressRangesVector > getAddressRanges() const
Get the address ranges for this DIE.
std::set< DieRangeInfo >::const_iterator die_range_info_iterator
bool isLittleEndian() const
virtual const DWARFSection & getRangeSection() const
uint32_t getCUCount() const
uint32_t Code
Abbreviation code.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator<(int64_t V1, const APSInt &V2)
Optional< DWARFFormValue > find(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE.
std::vector< DWARFAddressRange > DWARFAddressRangesVector
DWARFAddressRangesVector - represents a set of absolute address ranges.
DWARFDebugInfoEntry - A DIE with only the minimum required data.
Lightweight error class with error context and mandatory checking.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
static void LLVM_ATTRIBUTE_NORETURN ReportError(uint32_t StartOffset, const char *ErrorMsg)
uint32_t getCUOffset(uint32_t CU) const
Reads offset of compilation unit CU. CU is 0-based.
iterator_range< ValueIterator > equal_range(StringRef Key) const
Look up all entries in this Name Index matching Key.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.