diff --git a/llvm/test/tools/llvm-dwarfdump/X86/Inputs/debug_line_malformed.s b/llvm/test/tools/llvm-dwarfdump/X86/Inputs/debug_line_malformed.s --- a/llvm/test/tools/llvm-dwarfdump/X86/Inputs/debug_line_malformed.s +++ b/llvm/test/tools/llvm-dwarfdump/X86/Inputs/debug_line_malformed.s @@ -55,6 +55,9 @@ .byte 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 # Standard Opcode Lengths .byte 0 # directory table (invalid as no path component) .Lprologue_v5_end: +.byte 0, 9, 2 # DW_LNE_set_address +.quad 0x8877665544332211 +.byte 0, 1, 1 # DW_LNE_end_sequence .Lunit_v5_end: # Short prologue. @@ -76,9 +79,12 @@ .asciz "file1" # File table .byte 0, 0, 0 .asciz "file2" -.byte 1, 0, 0 +.byte 1, 2, 3 .byte 0 .Lprologue_short_prologue_end: +.byte 0, 9, 2 # DW_LNE_set_address +.quad 0x1122334455667788 +.byte 0, 1, 1 # DW_LNE_end_sequence .Lunit_short_prologue_end: # Over-long prologue. @@ -100,9 +106,12 @@ .asciz "file1" # File table .byte 0, 0, 0 .asciz "file2" -.byte 1, 0, 0 +.byte 1, 2, 3 .byte 0 .Lprologue_long_prologue_end: +.byte 0, 9, 2 # DW_LNE_set_address +.quad 0x1111222233334444 +.byte 0, 1, 1 # DW_LNE_end_sequence .Lunit_long_prologue_end: # Over-long extended opcode. @@ -193,12 +202,11 @@ # File table entries .byte 1 # 1 file .asciz "a.c" -.byte 0 +.byte 1 .Linvalid_description_header_end0: -.byte 0,2,4,1 # DW_LNE_set_discriminator 1 -.byte 1 # DW_LNS_copy -.byte 33 # address += 1, line += 1 -.byte 0,1,1 # DW_LNE_end_sequence +.byte 0, 9, 2 # DW_LNE_set_address +.quad 0xbabb1ebabb1e +.byte 0, 1, 1 # DW_LNE_end_sequence .Linvalid_description_end0: # V5 prologue ends during file table. @@ -232,12 +240,11 @@ # File table entries .byte 1 # 1 file .asciz "a.c" -.byte 0 +.byte 1 .Linvalid_file_header_end0: -.byte 0,2,4,1 # DW_LNE_set_discriminator 1 -.byte 1 # DW_LNS_copy -.byte 33 # address += 1, line += 1 -.byte 0,1,1 # DW_LNE_end_sequence +.byte 0, 9, 2 # DW_LNE_set_address +.quad 0xab4acadab4a +.byte 0, 1, 1 # DW_LNE_end_sequence .Linvalid_file_end0: # V5 prologue ends during directory table. @@ -271,12 +278,11 @@ # File table entries .byte 1 # 1 file .asciz "a.c" -.byte 0 +.byte 1 .Linvalid_dir_header_end0: -.byte 0,2,4,1 # DW_LNE_set_discriminator 1 -.byte 1 # DW_LNS_copy -.byte 33 # address += 1, line += 1 -.byte 0,1,1 # DW_LNE_end_sequence +.byte 0, 9, 2 # DW_LNE_set_address +.quad 0x4444333322221111 +.byte 0, 1, 1 # DW_LNE_end_sequence .Linvalid_dir_end0: # Invalid MD5 hash. @@ -314,10 +320,9 @@ .asciz "a.c" .byte 0 .Linvalid_md5_header_end0: -.byte 0,2,4,1 # DW_LNE_set_discriminator 1 -.byte 1 # DW_LNS_copy -.byte 33 # address += 1, line += 1 -.byte 0,1,1 # DW_LNE_end_sequence +.byte 0, 9, 2 # DW_LNE_set_address +.quad 0x1234123412341234 +.byte 0, 1, 1 # DW_LNE_end_sequence .Linvalid_md5_end0: # Trailing good section. diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test b/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test --- a/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test @@ -1,150 +1,171 @@ -## Test the different error cases in the debug line parsing and how they prevent -## or don't prevent further dumping of section contents. - -## Show that a bad length stops parsing of the section. -# RUN: llvm-mc -triple x86_64-pc-linux %S/Inputs/debug_line_reserved_length.s -filetype=obj -o %t-reserved.o -# RUN: llvm-dwarfdump -debug-line %t-reserved.o 2> %t-reserved.err \ -# RUN: | FileCheck %s --check-prefixes=FIRST,FATAL -# RUN: FileCheck %s --input-file=%t-reserved.err --check-prefix=RESERVED -# RUN: llvm-dwarfdump -debug-line %t-reserved.o -verbose 2> %t-reserved-verbose.err \ -# RUN: | FileCheck %s --check-prefixes=FIRST,FATAL -# RUN: FileCheck %s --input-file=%t-reserved-verbose.err --check-prefix=RESERVED - -## We only produce warnings for malformed tables after the specified unit if -## parsing can continue. -# RUN: llvm-dwarfdump -debug-line=0 %t-reserved.o 2> %t-reserved-off-first.err \ -# RUN: | FileCheck %s --check-prefixes=FIRST,NOLATER -# RUN: FileCheck %s --input-file=%t-reserved-off-first.err --check-prefix=RESERVED - -## Stop looking for the specified unit, if a fatally-bad prologue is detected. -# RUN: llvm-dwarfdump -debug-line=0x4b %t-reserved.o 2> %t-reserved-off-last.err \ -# RUN: | FileCheck %s --check-prefixes=NOFIRST,NOLATER -# RUN: FileCheck %s --input-file=%t-reserved-off-last.err --check-prefix=RESERVED - -## Show that non-fatal errors do not prevent parsing the rest of the section. -# RUN: llvm-mc -triple x86_64-pc-linux %S/Inputs/debug_line_malformed.s -filetype=obj -o %t-malformed.o -# RUN: llvm-dwarfdump -debug-line %t-malformed.o 2> %t-malformed.err \ -# RUN: | FileCheck %s --check-prefixes=FIRST,NONFATAL -# RUN: FileCheck %s --input-file=%t-malformed.err --check-prefixes=ALL,OTHER -# RUN: llvm-dwarfdump -debug-line %t-malformed.o -verbose 2> %t-malformed-verbose.err \ -# RUN: | FileCheck %s --check-prefixes=FIRST,NONFATAL -# RUN: FileCheck %s --input-file=%t-malformed-verbose.err --check-prefixes=ALL,OTHER - -## We should still produce warnings for malformed tables after the specified unit. -# RUN: llvm-dwarfdump -debug-line=0 %t-malformed.o 2> %t-malformed-off-first.err \ -# RUN: | FileCheck %s --check-prefixes=FIRST,NOLATER -# RUN: FileCheck %s --input-file=%t-malformed-off-first.err --check-prefix=ALL - -## Don't stop looking for the later unit if non-fatal issues are found. -# RUN: llvm-dwarfdump -debug-line=0x271 %t-malformed.o 2> %t-malformed-off-last.err \ -# RUN: | FileCheck %s --check-prefixes=LASTONLY -# RUN: FileCheck %s --input-file=%t-malformed-off-last.err --check-prefix=ALL - -# FIRST: debug_line[0x00000000] -# FIRST: 0x000000000badbeef {{.*}} end_sequence -# NOFIRST-NOT: debug_line[0x00000000] -# NOFIRST-NOT: 0x000000000badbeef {{.*}} end_sequence -# NOLATER-NOT: debug_line[{{.*}}] -# NOLATER-NOT: end_sequence - -## For fatal issues, the following table(s) should not be dumped. -# FATAL: debug_line[0x00000048] -# FATAL-NEXT: Line table prologue -# FATAL-NEXT: total_length: 0xfffffffe -# FATAL-NOT: debug_line - -## For non-fatal prologue issues, the table prologue should be dumped, and any -## subsequent tables should also be. -## Case 1: Version 0 table. -# NONFATAL: debug_line[0x00000048] -# NONFATAL-NEXT: Line table prologue -# NONFATAL-NOT: Address - -## Case 2: Version 1 table. -# NONFATAL: debug_line[0x0000004e] -# NONFATAL-NEXT: Line table prologue -# NONFATAL-NOT: Address - -## Case 3: Malformed directory format with no path component. -# NONFATAL: debug_line[0x00000054] -# NONFATAL-NEXT: Line table prologue -# NONFATAL-NOT: Address - -## Case 4: Prologue with length shorter than parsed. -# NONFATAL: debug_line[0x00000073] -# NONFATAL-NEXT: Line table prologue -# NONFATAL-NOT: Address - -## Case 5: Prologue with length longer than parsed. -# NONFATAL: debug_line[0x000000ad] -# NONFATAL-NEXT: Line table prologue -# NONFATAL-NOT: Address - -## Case 6: Extended opcode with incorrect length versus expected. -# NONFATAL: debug_line[0x000000e7] -## Dumping prints the line table prologue and any valid operations up to the -## point causing the problem. -# NONFATAL-NEXT: Line table prologue -# NONFATAL: 0x00000000abbadaba {{.*}} end_sequence -# NONFATAL-NOT: is_stmt - -## For minor issues, we can dump the whole table. -## Case 7: No end of sequence. -# NONFATAL: debug_line[0x0000013d] -# NONFATAL-NEXT: Line table prologue -# NONFATAL-NOT: debug_line[{{.*}}] -# NONFATAL: 0x00000000deadfade {{.*}} - -## Case 8: Very short prologue length for V5 (ends during parameters). -# NONFATAL: debug_line[0x00000183] -# NONFATAL-NEXT: Line table prologue -# NONFATAL-NOT: Address - -## Case 9: V5 prologue ends during file table. -# NONFATAL: debug_line[0x000001be] -# NONFATAL-NEXT: Line table prologue -# NONFATAL-NOT: Address - -## Case 10: V5 prologue ends during directory table. -# NONFATAL: debug_line[0x000001f9] -# NONFATAL-NEXT: Line table prologue -# NONFATAL-NOT: Address - -## Case 11: V5 invalid MD5 hash form. -# NONFATAL: debug_line[0x00000234] -# NONFATAL-NEXT: Line table prologue -# NONFATAL-NOT: Address - -# NONFATAL: debug_line[0x00000271] -# NONFATAL-NOT: debug_line[{{.*}}] -# NONFATAL: 0x00000000cafebabe {{.*}} end_sequence -# NONFATAL-NOT: debug_line[{{.*}}] - -# LASTONLY-NOT: debug_line[{{.*}}] -# LASTONLY: debug_line[0x00000271] -# LASTONLY: 0x00000000cafebabe {{.*}} end_sequence - -# RESERVED: warning: parsing line table prologue at offset 0x00000048 unsupported reserved unit length found of value 0xfffffffe - -# MD5: warning: parsing line table prologue at 0x00000000 found an invalid directory or file table description at 0x0000003b -# MD5-NEXT: warning: failed to parse file entry because the MD5 hash is invalid - -# ALL-NOT: warning: -# ALL: warning: parsing line table prologue at offset 0x00000048 found unsupported version 0x00 -# ALL-NEXT: warning: parsing line table prologue at offset 0x0000004e found unsupported version 0x01 -# ALL-NEXT: warning: parsing line table prologue at 0x00000054 found an invalid directory or file table description at 0x00000073 -# ALL-NEXT: warning: failed to parse entry content descriptions because no path was found -# FIXME - The latter offset in the next line should be 0xad. The filename parsing code does not notice a missing terminating byte. -# ALL-NEXT: warning: parsing line table prologue at 0x00000073 should have ended at 0x000000ab but it ended at 0x000000ac -# ALL-NEXT: warning: parsing line table prologue at 0x000000ad should have ended at 0x000000e8 but it ended at 0x000000e7 -# OTHER-NEXT: warning: unexpected line op length at offset 0x0000012e expected 0x02 found 0x01 -# OTHER-NEXT: warning: last sequence in debug line table is not terminated! -# ALL-NEXT: warning: parsing line table prologue at 0x00000183 found an invalid directory or file table description at 0x000001a2 -# ALL-NEXT: warning: failed to parse entry content descriptions at offset 0x000001a2 because offset extends beyond the prologue end at offset 0x0000019e -# ALL-NEXT: warning: parsing line table prologue at 0x000001be found an invalid directory or file table description at 0x000001eb -# ALL-NEXT: warning: failed to parse file entry at offset 0x000001eb because offset extends beyond the prologue end at offset 0x000001e9 -# ALL-NEXT: warning: parsing line table prologue at 0x000001f9 found an invalid directory or file table description at 0x0000021b -# ALL-NEXT: warning: failed to parse directory entry at offset 0x0000021b because offset extends beyond the prologue end at offset 0x0000021b -# ALL-NEXT: warning: parsing line table prologue at 0x00000234 found an invalid directory or file table description at 0x00000269 -# ALL-NEXT: warning: failed to parse file entry because the MD5 hash is invalid -# ALL-NOT: warning: +## Test the different error cases in the debug line parsing and how they prevent +## or don't prevent further dumping of section contents. + +## Show that a bad length stops parsing of the section. +# RUN: llvm-mc -triple x86_64-pc-linux %S/Inputs/debug_line_reserved_length.s -filetype=obj -o %t-reserved.o +# RUN: llvm-dwarfdump -debug-line %t-reserved.o 2> %t-reserved.err \ +# RUN: | FileCheck %s --check-prefixes=FIRST,FATAL +# RUN: FileCheck %s --input-file=%t-reserved.err --check-prefix=RESERVED +# RUN: llvm-dwarfdump -debug-line %t-reserved.o -verbose 2> %t-reserved-verbose.err \ +# RUN: | FileCheck %s --check-prefixes=FIRST,FATAL +# RUN: FileCheck %s --input-file=%t-reserved-verbose.err --check-prefix=RESERVED + +## We only produce warnings for malformed tables after the specified unit if +## parsing can continue. +# RUN: llvm-dwarfdump -debug-line=0 %t-reserved.o 2> %t-reserved-off-first.err \ +# RUN: | FileCheck %s --check-prefixes=FIRST,NOLATER +# RUN: FileCheck %s --input-file=%t-reserved-off-first.err --check-prefix=RESERVED + +## Stop looking for the specified unit, if a fatally-bad prologue is detected. +# RUN: llvm-dwarfdump -debug-line=0x4b %t-reserved.o 2> %t-reserved-off-last.err \ +# RUN: | FileCheck %s --check-prefixes=NOFIRST,NOLATER +# RUN: FileCheck %s --input-file=%t-reserved-off-last.err --check-prefix=RESERVED + +## Show that non-fatal errors do not prevent parsing the rest of the section. +# RUN: llvm-mc -triple x86_64-pc-linux %S/Inputs/debug_line_malformed.s -filetype=obj -o %t-malformed.o +# RUN: llvm-dwarfdump -debug-line %t-malformed.o 2> %t-malformed.err \ +# RUN: | FileCheck %s --check-prefixes=FIRST,NONFATAL +# RUN: FileCheck %s --input-file=%t-malformed.err --check-prefixes=ALL,OTHER +# RUN: llvm-dwarfdump -debug-line %t-malformed.o -verbose 2> %t-malformed-verbose.err \ +# RUN: | FileCheck %s --check-prefixes=FIRST,NONFATAL +# RUN: FileCheck %s --input-file=%t-malformed-verbose.err --check-prefixes=ALL,OTHER + +## We should still produce warnings for malformed tables after the specified unit. +# RUN: llvm-dwarfdump -debug-line=0 %t-malformed.o 2> %t-malformed-off-first.err \ +# RUN: | FileCheck %s --check-prefixes=FIRST,NOLATER +# RUN: FileCheck %s --input-file=%t-malformed-off-first.err --check-prefix=ALL + +## Don't stop looking for the later unit if non-fatal issues are found. +# RUN: llvm-dwarfdump -debug-line=0x2af %t-malformed.o 2> %t-malformed-off-last.err \ +# RUN: | FileCheck %s --check-prefixes=LASTONLY +# RUN: FileCheck %s --input-file=%t-malformed-off-last.err --check-prefix=ALL + +# FIRST: debug_line[0x00000000] +# FIRST: 0x000000000badbeef {{.*}} end_sequence +# NOFIRST-NOT: debug_line[0x00000000] +# NOFIRST-NOT: 0x000000000badbeef {{.*}} end_sequence +# NOLATER-NOT: debug_line[{{.*}}] +# NOLATER-NOT: end_sequence + +## For fatal issues, the following table(s) should not be dumped. +# FATAL: debug_line[0x00000048] +# FATAL-NEXT: Line table prologue +# FATAL-NEXT: total_length: 0xfffffffe +# FATAL-NOT: debug_line + +## For non-fatal prologue issues, the table prologue should be dumped, and any +## subsequent tables should also be. +## Case 1: Version 0 table. +# NONFATAL: debug_line[0x00000048] +# NONFATAL-NEXT: Line table prologue +# NONFATAL-NOT: Address + +## Case 2: Version 1 table. +# NONFATAL: debug_line[0x0000004e] +# NONFATAL-NEXT: Line table prologue +# NONFATAL-NOT: Address + +## Case 3: Malformed directory format with no path component. +# NONFATAL: debug_line[0x00000054] +# NONFATAL-NEXT: Line table prologue +# NONFATAL-NOT: include_directories +# NONFATAL-NOT: file_names +# NONFATAL-NOT: Address + +## Case 4: Prologue with length shorter than parsed. +# NONFATAL: debug_line[0x00000081] +# NONFATAL-NEXT: Line table prologue +# NONFATAL: file_names[ 2]: +# NONFATAL-NEXT: name: "file2" +# NONFATAL-NEXT: dir_index: 1 +# NONFATAL-NEXT: mod_time: 0x00000002 +# NONFATAL-NEXT: length: 0x00000003 +# NONFATAL-NOT: file_names +# NONFATAL-NOT: Address + +## Case 5: Prologue with length longer than parsed. +# NONFATAL: debug_line[0x000000c9] +# NONFATAL-NEXT: Line table prologue +# NONFATAL: file_names[ 2]: +# NONFATAL-NEXT: name: "file2" +# NONFATAL-NEXT: dir_index: 1 +# NONFATAL-NEXT: mod_time: 0x00000002 +# NONFATAL-NEXT: length: 0x00000003 +# NONFATAL-NOT: file_names +# NONFATAL-NOT: Address + +## Case 6: Extended opcode with incorrect length versus expected. +# NONFATAL: debug_line[0x00000111] +## Dumping prints the line table prologue and any valid operations up to the +## point causing the problem. +# NONFATAL-NEXT: Line table prologue +# NONFATAL: 0x00000000abbadaba {{.*}} end_sequence +# NONFATAL-NOT: is_stmt + +## For minor issues, we can dump the whole table. +## Case 7: No end of sequence. +# NONFATAL: debug_line[0x00000167] +# NONFATAL-NEXT: Line table prologue +# NONFATAL: 0x00000000deadfade {{.*}} is_stmt +# NONFATAL-NOT: end_sequence + +## Case 8: Very short prologue length for V5 (ends during parameters). +# NONFATAL: debug_line[0x000001ad] +# NONFATAL-NEXT: Line table prologue +# NONFATAL: standard_opcode_lengths[DW_LNS_set_isa] = 1 +# NONFATAL-NOT: include_directories +# NONFATAL-NOT: file_names +# NONFATAL-NOT: Address + +## Case 9: V5 prologue ends during file table. +# NONFATAL: debug_line[0x000001ed] +# NONFATAL-NEXT: Line table prologue +# NONFATAL: include_directories[ 0] = "/tmp" +# NONFATAL-NOT: file_names +# NONFATAL-NOT: Address + +## Case 10: V5 prologue ends during directory table. +# NONFATAL: debug_line[0x0000022d] +# NONFATAL-NEXT: Line table prologue +# NONFATAL-NOT: include_directories +# NONFATAL-NOT: file_names +# NONFATAL-NOT: Address + +## Case 11: V5 invalid MD5 hash form. +# NONFATAL: debug_line[0x0000026d] +# NONFATAL-NEXT: Line table prologue +# NONFATAL-NOT: Address + +# NONFATAL: debug_line[0x000002af] +# NONFATAL-NOT: debug_line[{{.*}}] +# NONFATAL: 0x00000000cafebabe {{.*}} end_sequence +# NONFATAL-NOT: debug_line[{{.*}}] + +# LASTONLY-NOT: debug_line[{{.*}}] +# LASTONLY: debug_line[0x000002af] +# LASTONLY: 0x00000000cafebabe {{.*}} end_sequence + +# RESERVED: warning: parsing line table prologue at offset 0x00000048 unsupported reserved unit length found of value 0xfffffffe + +# MD5: warning: parsing line table prologue at 0x00000000 found an invalid directory or file table description at 0x0000003b +# MD5-NEXT: warning: failed to parse file entry because the MD5 hash is invalid + +# ALL-NOT: warning: +# ALL: warning: parsing line table prologue at offset 0x00000048 found unsupported version 0x00 +# ALL-NEXT: warning: parsing line table prologue at offset 0x0000004e found unsupported version 0x01 +# ALL-NEXT: warning: parsing line table prologue at 0x00000054 found an invalid directory or file table description at 0x00000073 +# ALL-NEXT: warning: failed to parse entry content descriptions because no path was found +# FIXME - The latter offset in the next line should be 0xad. The filename parsing code does not notice a missing terminating byte. +# ALL-NEXT: warning: parsing line table prologue at 0x00000081 should have ended at 0x000000b9 but it ended at 0x000000ba +# ALL-NEXT: warning: parsing line table prologue at 0x000000c9 should have ended at 0x00000104 but it ended at 0x00000103 +# OTHER-NEXT: warning: unexpected line op length at offset 0x00000158 expected 0x02 found 0x01 +# OTHER-NEXT: warning: last sequence in debug line table is not terminated! +# ALL-NEXT: warning: parsing line table prologue at 0x000001ad found an invalid directory or file table description at 0x000001cc +# ALL-NEXT: warning: failed to parse entry content descriptions at offset 0x000001cc because offset extends beyond the prologue end at offset 0x000001c8 +# ALL-NEXT: warning: parsing line table prologue at 0x000001ed found an invalid directory or file table description at 0x0000021a +# ALL-NEXT: warning: failed to parse file entry at offset 0x0000021a because offset extends beyond the prologue end at offset 0x00000218 +# ALL-NEXT: warning: parsing line table prologue at 0x0000022d found an invalid directory or file table description at 0x0000024f +# ALL-NEXT: warning: failed to parse directory entry at offset 0x0000024f because offset extends beyond the prologue end at offset 0x0000024f +# ALL-NEXT: warning: parsing line table prologue at 0x0000026d found an invalid directory or file table description at 0x000002a2 +# ALL-NEXT: warning: failed to parse file entry because the MD5 hash is invalid +# ALL-NOT: warning: