Skip to content

Commit 5296149

Browse files
[DWARFDump] Make --verify handle all sections by default (#81559)
The current behavior of --verify is that it only verifies debug_info, debug_abbrev and debug_names. This seems fairly arbitrary and might have been unintentional, as originally the absence of any section flags implied "all". This patch changes the behavior so that the verifier now verifies everything by default. It revealed two tests that had potentially invalid DWARF: 1. dwarfdump-str-offsets.s is adding padding between two debug_str_offset contributions. The standard does not explicitly allow this behavior. See issue #81558 2. dwarf5-macro.test uses a checked-in binary that has invalid debug_str_offsets. One of its entries points to the _middle_ of the string section: error: .debug_str_offsets: contribution 0x0: index 0x4: invalid string offset *0x18 == 0x455D, is neither zero nor immediately following a null character If we look at the closest offset to 0x455D in debug_str: ``` 0x0000454e: "__SLONG32_TYPE int" ``` 0x455D points to "int".
1 parent 2400f70 commit 5296149

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
22
# RUN: llvm-dwarfdump -v %t.o 2> %t.err | FileCheck --check-prefixes=COMMON,SPLIT,OFFSETS %s
3-
# RUN: llvm-dwarfdump -verify %t.o | FileCheck --check-prefix=VERIFY %s
3+
4+
# FIXME: the verifier does not accept padding between debug-str-offset
5+
# sections, which this test uses.
6+
# RUN: llvm-dwarfdump -verify --debug-info %t.o | FileCheck --check-prefix=VERIFY %s
47
# RUN: llvm-dwarfdump -debug-str-offsets %t.o | FileCheck --check-prefix=OFFSETS %s
58
#
69
# Check that we don't report an error on a non-existent range list table.

llvm/test/DebugInfo/X86/skeleton-unit-verify.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# CHECK-NEXT: DW_TAG_skeleton_unit
1212
# CHECK-NEXT: error: Skeleton compilation unit has children.
1313
# CHECK-NEXT: Verifying dwo Units...
14+
# CHECK-NEXT: Verifying .debug_line...
15+
# CHECK-NEXT: Verifying .debug_str_offsets...
1416
# CHECK-NEXT: Errors detected.
1517

1618
.section .debug_abbrev,"",@progbits

llvm/test/tools/llvm-dwarfdump/X86/verify_file_encoding.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
# CHECK-NEXT: DW_AT_call_file [DW_FORM_sdata] (4)
5252
# CHECK-NEXT: DW_AT_call_line [DW_FORM_sdata] (5){{[[:space:]]}}
5353
# CHECK-NEXT: Verifying dwo Units...
54+
# CHECK-NEXT: Verifying .debug_line...
55+
# CHECK-NEXT: Verifying .debug_str_offsets...
5456
# CHECK-NEXT: error: Aggregated error counts:
5557
# CHECK-NEXT: error: Invalid encoding in DW_AT_decl_file occurred 4 time(s).
5658
# CHECK-NEXT: error: Invalid file index in DW_AT_call_line occurred 1 time(s).

llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-macro.test

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@
4545

4646
## Check that macro table preserved during simple copying.
4747
#
48+
# FIXME: the input of this test is itself invalid w.r.t. debug_str_offsets,
49+
# which also causes the next two calls to --verify to fail, so we only verify
50+
# debug_info on those.
4851
#RUN: llvm-dwarfutil --no-garbage-collection %p/Inputs/dwarf5-macro.out %t1
49-
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
52+
#RUN: llvm-dwarfdump -verify --debug-info %t1 | FileCheck %s
5053
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefix=MACRO
5154

5255
#RUN: llvm-dwarfutil --linker parallel --no-garbage-collection %p/Inputs/dwarf5-macro.out %t1
53-
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
56+
#RUN: llvm-dwarfdump -verify %t1 --debug-info | FileCheck %s
5457
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefix=MACRO
5558

5659
## Check that macro table preserved during updating accelerator tables.

llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ int main(int argc, char **argv) {
863863
if (DumpAll)
864864
DumpType = DIDT_All;
865865
if (DumpType == DIDT_Null) {
866-
if (Verbose)
866+
if (Verbose || Verify)
867867
DumpType = DIDT_All;
868868
else
869869
DumpType = DIDT_DebugInfo;

0 commit comments

Comments
 (0)