[llvm] Add verification support for .debug_names with foreign type units. (PR #109011)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 18 17:15:03 PDT 2024


================
@@ -1652,20 +1662,52 @@ unsigned DWARFVerifier::verifyNameIndexEntries(
     // call to properly deal with it. It isn't clear that getNonSkeletonUnitDIE
     // will return the unit DIE of DU if we aren't able to get the .dwo file,
     // but that is what the function currently does.
+    DWARFDie UnitDie = DU->getUnitDIE();
     DWARFDie NonSkeletonUnitDie = DU->getNonSkeletonUnitDIE();
-    if (DU->getDWOId() && DU->getUnitDIE() == NonSkeletonUnitDie) {
+    if (DU->getDWOId() && UnitDie == NonSkeletonUnitDie) {
       ErrorCategory.Report("Unable to get load .dwo file", [&]() {
-        error() << formatv("Name Index @ {0:x}: Entry @ {1:x} unable to load "
-                           ".dwo file \"{2}\" for DWARF unit @ {3:x}.\n",
-                           NI.getUnitOffset(), EntryID,
-                           dwarf::toString(DU->getUnitDIE().find(
-                               {DW_AT_dwo_name, DW_AT_GNU_dwo_name})),
-                           *UnitOffset);
+        error() << formatv(
+            "Name Index @ {0:x}: Entry @ {1:x} unable to load "
+            ".dwo file \"{2}\" for DWARF unit @ {3:x}.\n",
+            NI.getUnitOffset(), EntryID,
+            dwarf::toString(UnitDie.find({DW_AT_dwo_name, DW_AT_GNU_dwo_name})),
+            *UnitOffset);
       });
       ++NumErrors;
       continue;
     }
-    DWARFUnit *NonSkeletonUnit = NonSkeletonUnitDie.getDwarfUnit();
+    DWARFUnit *NonSkeletonUnit = nullptr;
+    if (TUIndex && *TUIndex >= NumLocalTUs) {
+      // We have a foreign TU index, which either means we have a .dwo file
+      // that has one or more type units, or we have a .dwp file with on or
----------------
jeffreytan81 wrote:

Typo: `on or` => `one or`

https://github.com/llvm/llvm-project/pull/109011


More information about the llvm-commits mailing list