DebugInfo: Use hash-based unit lookup when available in dwp files
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 27 Apr 2022 21:17:01 +0000 (21:17 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 27 Apr 2022 21:18:14 +0000 (21:18 +0000)
Fix a test case that had a bogus (probably I hand crafted it at some
point) index that didn't point to the right data in the process.

llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
llvm/test/DebugInfo/X86/dwarfdump-str-offsets-dwp.s

index b91e268..3f554e3 100644 (file)
@@ -83,7 +83,14 @@ void DWARFUnitVector::addUnitsImpl(
       if (!IndexEntry && IsDWO) {
         const DWARFUnitIndex &Index = getDWARFUnitIndex(
             Context, Header.isTypeUnit() ? DW_SECT_EXT_TYPES : DW_SECT_INFO);
-        IndexEntry = Index.getFromOffset(Header.getOffset());
+        if (Index) {
+          if (Header.isTypeUnit())
+            IndexEntry = Index.getFromHash(Header.getTypeHash());
+          else if (auto DWOId = Header.getDWOId())
+            IndexEntry = Index.getFromHash(*DWOId);
+        }
+        if (!IndexEntry)
+          IndexEntry = Index.getFromOffset(Header.getOffset());
       }
       if (IndexEntry && !Header.applyIndexEntry(IndexEntry))
         return nullptr;
index 9bbd4d7..c5350a1 100644 (file)
@@ -171,7 +171,7 @@ TU1_5_version:
         .byte 2                # DWARF Unit Type
         .byte 8                # Address Size (in bytes)
         .long .debug_abbrev.dwo    # Offset Into Abbrev. Section
-        .quad 0x0011223344556677 # Type Signature
+        .quad 0xeeaaddbbaabbeedd # Type Signature
         .long TU1_5_type-TU1_5_start # Type offset
 # The type-unit DIE, which has a name.
         .byte 2                # Abbreviation code
@@ -191,7 +191,7 @@ TU2_5_version:
         .byte 2                # DWARF Unit Type
         .byte 8                # Address Size (in bytes)
         .long .debug_abbrev.dwo    # Offset Into Abbrev. Section
-        .quad 0x00aabbccddeeff99 # Type Signature
+        .quad 0x00ffeeffaaff00ff # Type Signature
         .long TU2_5_type-TU2_5_start # Type offset
 # The type-unit DIE, which has a name.
         .byte 2                # Abbreviation code