[llvm] ae6961d - DWARFVerifier: Don't try to resolve decl_file in split CUs
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 16 18:13:03 PST 2021
Author: David Blaikie
Date: 2021-12-16T18:12:52-08:00
New Revision: ae6961d407975cc861fc22bedb50fcbc47eb0f8b
URL: https://github.com/llvm/llvm-project/commit/ae6961d407975cc861fc22bedb50fcbc47eb0f8b
DIFF: https://github.com/llvm/llvm-project/commit/ae6961d407975cc861fc22bedb50fcbc47eb0f8b.diff
LOG: DWARFVerifier: Don't try to resolve decl_file in split CUs
Since they refer to the debug_line in the skeleton unit, they can't be
resolved from the dwo CU.
But they can be resolved for split TUs, since those refer to
.debug_line.dwo, which is available in the dwo file.
Added:
Modified:
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
llvm/test/tools/llvm-dwarfdump/X86/verify_split_cu.s
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index 67862200d7a90..4ec0fce3c4432 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -499,6 +499,7 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
};
const DWARFObject &DObj = DCtx.getDWARFObj();
+ DWARFUnit *U = Die.getDwarfUnit();
const auto Attr = AttrValue.Attr;
switch (Attr) {
case DW_AT_ranges:
@@ -520,7 +521,7 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
case DW_AT_stmt_list:
// Make sure the offset in the DW_AT_stmt_list attribute is valid.
if (auto SectionOffset = AttrValue.Value.getAsSectionOffset()) {
- if (*SectionOffset >= DObj.getLineSection().Data.size())
+ if (*SectionOffset >= U->getLineSection().Data.size())
ReportError("DW_AT_stmt_list offset is beyond .debug_line bounds: " +
llvm::formatv("{0:x8}", *SectionOffset));
break;
@@ -579,7 +580,8 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
case DW_AT_call_file:
case DW_AT_decl_file: {
if (auto FileIdx = AttrValue.Value.getAsUnsignedConstant()) {
- DWARFUnit *U = Die.getDwarfUnit();
+ if (U->isDWOUnit() && !U->isTypeUnit())
+ break;
const auto *LT = U->getContext().getLineTableForUnit(U);
if (LT) {
if (!LT->hasFileAtIndex(*FileIdx)) {
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/verify_split_cu.s b/llvm/test/tools/llvm-dwarfdump/X86/verify_split_cu.s
index 14c8da2fcf803..15d97e92bba0b 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/verify_split_cu.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/verify_split_cu.s
@@ -1,10 +1,12 @@
# RUN: llvm-mc %s -filetype obj -triple x86_64-linux-gnu -o - \
-# RUN: | not llvm-dwarfdump -v -verify - \
+# RUN: | not llvm-dwarfdump -v -verify - 2>&1 \
# RUN: | FileCheck %s --implicit-check-not=error --implicit-check-not=warning
# CHECK: Verifying dwo Units...
# CHECK: error: Compilation unit root DIE is not a unit DIE: DW_TAG_null.
# CHECK: error: Compilation unit type (DW_UT_split_compile) and root DIE (DW_TAG_null) do not match.
+# FIXME: This should read "type unit" or just "unit" to be correct for this case/in general
+# CHECK: error: DIE has DW_AT_decl_file that references a file with index 1 and the compile unit has no line table
# CHECK: Errors detected
.section .debug_info.dwo,"e", at progbits
.long .Ldebug_info_dwo_end1-.Ldebug_info_dwo_start1 # Length of Unit
@@ -13,6 +15,113 @@
.byte 5 # DWARF Unit Type
.byte 8 # Address Size (in bytes)
.long 0 # Offset Into Abbrev. Section
- .quad 5527374834836270265
- .byte 0 # End Of Children Mark
+ .quad 1
+ .quad 0
.Ldebug_info_dwo_end1:
+ .long .Ldebug_info_dwo_end2-.Ldebug_info_dwo_start2 # Length of Unit
+.Ldebug_info_dwo_start2:
+ .short 5 # DWARF version number
+ .byte 5 # DWARF Unit Type
+ .byte 8 # Address Size (in bytes)
+ .long 0 # Offset Into Abbrev. Section
+ .quad 2
+ .byte 1 # Abbrev [1] 0xb:0x1b DW_TAG_compile_unit
+ .byte 0 # DW_AT_decl_file
+.Ldebug_info_dwo_end2:
+.Ldebug_info_dwo_prestart3:
+ .long .Ldebug_info_dwo_end3-.Ldebug_info_dwo_start3 # Length of Unit
+.Ldebug_info_dwo_start3:
+ .short 5 # DWARF version number
+ .byte 6 # DWARF Unit Type
+ .byte 8 # Address Size (in bytes)
+ .long 0 # Offset Into Abbrev. Section
+ .quad 3 # Type Signature
+ .long .Ldebug_info_dwo_die3-.Ldebug_info_dwo_prestart3 # Type DIE Offset
+.Ldebug_info_dwo_die3:
+ .byte 3 # Abbrev [1] 0x18:0xe DW_TAG_type_unit
+ .byte 1 # DW_AT_decl_file
+.Ldebug_info_dwo_end3:
+.Ldebug_info_dwo_prestart4:
+ .long .Ldebug_info_dwo_end4-.Ldebug_info_dwo_start4 # Length of Unit
+.Ldebug_info_dwo_start4:
+ .short 5 # DWARF version number
+ .byte 6 # DWARF Unit Type
+ .byte 8 # Address Size (in bytes)
+ .long 0 # Offset Into Abbrev. Section
+ .quad 4 # Type Signature
+ .long .Ldebug_info_dwo_die4-.Ldebug_info_dwo_prestart4 # Type DIE Offset
+.Ldebug_info_dwo_die4:
+ .byte 4 # Abbrev [1] 0x18:0xe DW_TAG_type_unit
+ .long 0 # DW_AT_stmt_list
+ .byte 0 # DW_AT_decl_file
+.Ldebug_info_dwo_end4:
+ .section .debug_abbrev.dwo,"e", at progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 0 # DW_CHILDREN_no
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 2 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 0 # DW_CHILDREN_no
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 3 # Abbreviation Code
+ .byte 65 # DW_TAG_type_unit
+ .byte 0 # DW_CHILDREN_no
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 4 # Abbreviation Code
+ .byte 65 # DW_TAG_type_unit
+ .byte 0 # DW_CHILDREN_no
+ .byte 16 # DW_AT_stmt_list
+ .byte 23 # DW_FORM_sec_offset
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+ .section .debug_line.dwo,"e", at progbits
+.Ltmp2:
+ .long .Ldebug_line_end0-.Ldebug_line_start0 # unit length
+.Ldebug_line_start0:
+ .short 5
+ .byte 8
+ .byte 0
+ .long .Lprologue_end0-.Lprologue_start0
+.Lprologue_start0:
+ .byte 1
+ .byte 1
+ .byte 1
+ .byte -5
+ .byte 14
+ .byte 1
+ .byte 1
+ .byte 1
+ .byte 8
+ .byte 1
+ .ascii "/usr/local/google/home/blaikie/dev/scratch"
+ .byte 0
+ .byte 3
+ .byte 1
+ .byte 8
+ .byte 2
+ .byte 15
+ .byte 5
+ .byte 30
+ .byte 1
+ .ascii "test.cpp"
+ .byte 0
+ .byte 0
+ .byte 0x5e, 0xc4, 0x4d, 0x3b
+ .byte 0x78, 0xd0, 0x2a, 0x57
+ .byte 0xd2, 0x75, 0xc1, 0x22
+ .byte 0x36, 0xb7, 0x17, 0xbf
+.Lprologue_end0:
+.Ldebug_line_end0:
More information about the llvm-commits
mailing list