[llvm] Add support for verifying .debug_names in split DWARF for CUs and TUs. (PR #101775)
Greg Clayton via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 7 17:25:01 PDT 2024
================
@@ -1626,8 +1626,56 @@ unsigned DWARFVerifier::verifyNameIndexEntries(
UnitOffset = NI.getCUOffset(*CUIndex);
if (!UnitOffset)
continue;
- uint64_t DIEOffset = *UnitOffset + *EntryOr->getDIEUnitOffset();
- DWARFDie DIE = DCtx.getDIEForOffset(DIEOffset);
+ // For split DWARF entries we need to make sure we find the non skeleton
+ // DWARF unit that is needed and use that's DWARF unit offset as the
+ // DIE offset to add the DW_IDX_die_offset to.
+ DWARFUnit *DU = DCtx.getUnitForOffset(*UnitOffset);
+ if (DU == nullptr || DU->getOffset() != *UnitOffset) {
+ // If we didn't find a DWARF Unit from the UnitOffset, or if the offset
+ // of the unit doesn't match exactly, report an error.
+ ErrorCategory.Report(
+ "Name Index entry contains invalid CU or TU offset", [&]() {
+ error() << formatv("Name Index @ {0:x}: Entry @ {1:x} contains an "
+ "invalid CU or TU offset {1:x}.\n",
+ NI.getUnitOffset(), EntryID, *UnitOffset);
+ });
+ ++NumErrors;
+ continue;
+ }
+ // This function will try to get the non skeleton unit DIE, but if it is
+ // unable to load the .dwo file from the .dwo or .dwp, it will return the
+ // unit DIE of the DWARFUnit in "DU". So we need to check if the DWARFUnit
+ // has a .dwo file, but we couldn't load it.
+ DWARFDie NonSkeletonUnitDie = DU->getNonSkeletonUnitDIE();
+ if (DU->getDWOId() && DU->getUnitDIE() == NonSkeletonUnitDie) {
----------------
clayborg wrote:
If the .dwo file isn't found, `DU->getNonSkeletonUnitDIE()` returns the skeleton compile unit, and then NonSkeletonUnitDie would say that it isn't a DWO file. We need to ask the skeleton unit if it has a DWO ID, and if it does _and_ the DIEs are the same, then we know we didn't find the .dwo file (in a .dwo or .dwp). So for a normal `DW_TAG_compile_unit` the `DU->getNonSkeletonUnitDIE()` will return the same DIE and DU won't have a DWO ID.
https://github.com/llvm/llvm-project/pull/101775
More information about the llvm-commits
mailing list