1## Test the different error cases in the debug line parsing and how they prevent 2## or don't prevent further dumping of section contents. 3 4## Show that a bad length stops parsing of the section. 5# RUN: llvm-mc -triple x86_64-pc-linux %S/Inputs/debug_line_reserved_length.s -filetype=obj -o %t-reserved.o 6# RUN: llvm-dwarfdump -debug-line %t-reserved.o 2>&1 \ 7# RUN: | FileCheck %s --check-prefixes=HEADER,FIRST,FATAL,RESERVED 8# RUN: llvm-dwarfdump -debug-line %t-reserved.o -verbose 2>&1 \ 9# RUN: | FileCheck %s --check-prefixes=HEADER,FIRST,FATAL,RESERVED 10 11## We only produce warnings for malformed tables after the specified unit if 12## parsing can continue. 13# RUN: llvm-dwarfdump -debug-line=0 %t-reserved.o 2>&1 \ 14# RUN: | FileCheck %s --check-prefixes=HEADER,FIRST,NOLATER,RESERVED 15 16## Stop looking for the specified unit, if a fatally-bad prologue is detected. 17# RUN: llvm-dwarfdump -debug-line=0x4b %t-reserved.o 2>&1 \ 18# RUN: | FileCheck %s --check-prefixes=HEADER,NOFIRST,NOLATER,RESERVED 19 20## Show that non-fatal errors do not prevent parsing the rest of the section. 21# RUN: llvm-mc -triple x86_64-pc-linux %S/Inputs/debug_line_malformed.s -filetype=obj -o %t-malformed.o 22# RUN: llvm-dwarfdump -debug-line %t-malformed.o 2>&1 \ 23# RUN: | FileCheck %s --check-prefixes=HEADER,FIRST,NONFATAL,LAST,SOME-ERR,MORE-ERR \ 24# RUN: --implicit-check-not='debug_line[{{.*}}]' --implicit-check-not='warning:' 25# RUN: llvm-dwarfdump -debug-line %t-malformed.o -verbose 2>&1 \ 26# RUN: | FileCheck %s --check-prefixes=HEADER,FIRST,VERBOSE,NONFATAL,LAST,SOME-ERR,MORE-ERR \ 27# RUN: --implicit-check-not='debug_line[{{.*}}]' --implicit-check-not=' DW_LNS' \ 28# RUN: --implicit-check-not=' DW_LNE' --implicit-check-not='address +=' \ 29# RUN: --implicit-check-not='warning:' 30 31## We should still produce warnings for malformed tables after the specified unit. 32# RUN: llvm-dwarfdump -debug-line=0 %t-malformed.o 2>&1 \ 33# RUN: | FileCheck %s --check-prefixes=HEADER,FIRST,NOLATER,SOME-ERR --implicit-check-not='warning:' 34 35## Don't stop looking for the later unit if non-fatal issues are found. 36# RUN: llvm-dwarfdump -debug-line=0x3ed %t-malformed.o 2>&1 \ 37# RUN: | FileCheck %s --check-prefixes=HEADER,LAST,SOME-ERR --implicit-check-not='debug_line[{{.*}}]' \ 38# RUN: --implicit-check-not='warning:' 39 40# HEADER: .debug_line contents: 41 42# FIRST: debug_line[0x00000000] 43# VERBOSE: Address Line Column File ISA Discriminator OpIndex Flags 44# VERBOSE-NEXT: ------------------ ------ ------ ------ --- ------------- ------- ------------- 45# VERBOSE-NEXT: DW_LNE_set_address (0x000000000badbeef) 46# VERBOSE-NEXT: DW_LNE_end_sequence 47# FIRST: 0x000000000badbeef {{.*}} end_sequence 48# FIRST-EMPTY: 49# NOFIRST-NOT: debug_line[0x00000000] 50# NOFIRST-NOT: 0x000000000badbeef {{.*}} end_sequence 51# NOLATER-NOT: debug_line[{{.*}}] 52# NOLATER-NOT: end_sequence 53 54## For fatal issues, the following table(s) should not be dumped: 55# FATAL: debug_line[0x00000048] 56# RESERVED-NOT: prologue 57# RESERVED: warning: parsing line table prologue at offset 0x00000048: unsupported reserved unit length of value 0xfffffffe 58# RESERVED-NOT: prologue 59# RESERVED-NOT: Address 60# FATAL-NOT: debug_line 61 62## For non-fatal issues, the table data should be dumped: 63 64## Version 0 table. 65# NONFATAL: debug_line[0x00000048] 66# NONFATAL-NEXT: Line table prologue 67# NONFATAL-NEXT: total_length: 0x00000002 68# NONFATAL-NEXT: format: DWARF32 69# NONFATAL-NEXT: version: 0 70# NONFATAL-EMPTY: 71# SOME-ERR-NEXT: warning: parsing line table prologue at offset 0x00000048: unsupported version 0 72 73## Version 1 table. 74# NONFATAL: debug_line[0x0000004e] 75# NONFATAL-NEXT: Line table prologue 76# NONFATAL-NEXT: total_length: 0x00000002 77# NONFATAL-NEXT: format: DWARF32 78# NONFATAL-NEXT: version: 1 79# NONFATAL-EMPTY: 80# SOME-ERR-NEXT: warning: parsing line table prologue at offset 0x0000004e: unsupported version 1 81 82## Malformed directory format with no path component. 83# NONFATAL: debug_line[0x00000054] 84# SOME-ERR-NEXT: warning: parsing line table prologue at 0x00000054 found an invalid directory or file table description at 0x00000073 85# SOME-ERR-NEXT: warning: failed to parse entry content descriptions because no path was found 86# NONFATAL-NEXT: Line table prologue 87# NONFATAL: prologue_length: 0x00000013 88# NONFATAL-NOT: include_directories 89# NONFATAL-NOT: file_names 90# VERBOSE: DW_LNE_set_address (0x8877665544332211) 91# VERBOSE-NEXT: DW_LNE_end_sequence 92 93## Prologue with length shorter than parsed. 94# NONFATAL: debug_line[0x00000081] 95# SOME-ERR-NEXT: warning: parsing line table prologue at 0x00000081 found an invalid directory or file table description at 0x000000b9 96# SOME-ERR-NEXT: warning: file names table was not null terminated before the end of the prologue 97# NONFATAL-NEXT: Line table prologue 98# NONFATAL: file_names[ 1]: 99# NONFATAL-NEXT: name: "file1" 100# NONFATAL-NEXT: dir_index: 1 101# NONFATAL-NEXT: mod_time: 0x00000002 102# NONFATAL-NEXT: length: 0x00000003 103# VERBOSE: DW_LNE_set_address (0x1122334455667788) 104# VERBOSE-NEXT: DW_LNE_end_sequence 105 106## Prologue with length longer than parsed. 107# NONFATAL: debug_line[0x000000c7] 108# SOME-ERR-NEXT: warning: unknown data in line table prologue at offset 0x000000c7: parsing ended (at offset 0x00000101) before reaching the prologue end at offset 0x00000102 109# NONFATAL-NEXT: Line table prologue 110# NONFATAL: file_names[ 2]: 111# NONFATAL-NEXT: name: "file2" 112# NONFATAL-NEXT: dir_index: 1 113# NONFATAL-NEXT: mod_time: 0x00000002 114# NONFATAL-NEXT: length: 0x00000003 115# NONFATAL-NOT: file_names 116# VERBOSE: DW_LNE_set_address (0x1111222233334444) 117# VERBOSE-NEXT: DW_LNE_end_sequence 118 119## Extended opcode with incorrect length versus expected. 120# NONFATAL: debug_line[0x00000110] 121# NONFATAL-NEXT: Line table prologue 122# NONFATAL: prologue_length: 0x00000030 123# VERBOSE: DW_LNE_set_address (0x00000000abbadaba) 124# VERBOSE-NEXT: DW_LNE_end_sequence 125# MORE-ERR: warning: unexpected line op length at offset 0x00000157 expected 0x02 found 0x01 126# VERBOSE: DW_LNE_set_discriminator (10) 127# MORE-ERR: warning: unexpected line op length at offset 0x0000015b expected 0x01 found 0x02 128# VERBOSE: DW_LNS_set_prologue_end 129# VERBOSE-NEXT: DW_LNE_set_address (0x00000000babb1e45) 130# VERBOSE-NEXT: DW_LNE_end_sequence 131 132## No end of sequence. 133# NONFATAL: debug_line[0x0000016b] 134# NONFATAL-NEXT: Line table prologue 135# NONFATAL: prologue_length: 0x00000030 136# VERBOSE: DW_LNE_set_address (0x00000000deadfade) 137# VERBOSE-NEXT: DW_LNS_copy 138# MORE-ERR: warning: last sequence in debug line table at offset 0x0000016b is not terminated 139 140## Very short prologue length for V5 (ends during parameters). 141# NONFATAL: debug_line[0x000001b1] 142# NONFATAL-NEXT: Line table prologue 143# NONFATAL: standard_opcode_lengths[DW_LNS_set_prologue_end] = 1 144# NONFATAL-NEXT: standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0 145# NONFATAL-NEXT: standard_opcode_lengths[DW_LNS_set_isa] = 0 146# NONFATAL-EMPTY: 147# SOME-ERR-NEXT: warning: parsing line table prologue at offset 0x000001b1: unexpected end of data at offset 0x1cd while reading [0x1cd, 0x1ce) 148 149## V5 prologue ends during file table. 150# NONFATAL-NEXT: debug_line[0x000001db] 151# SOME-ERR-NEXT: warning: parsing line table prologue at 0x000001db found an invalid directory or file table description at 0x00000206 152# SOME-ERR-NEXT: warning: failed to parse entry content descriptors: unable to decode LEB128 at offset 0x00000206: malformed uleb128, extends past end 153# NONFATAL-NEXT: Line table prologue 154# NONFATAL: include_directories[ 0] = "/tmp" 155# NONFATAL-NOT: file_names 156# VERBOSE: DW_LNE_set_address (0x00000ab4acadab4a) 157# VERBOSE-NEXT: DW_LNE_end_sequence 158 159## V5 prologue ends during directory table. 160# NONFATAL: debug_line[0x00000214] 161# SOME-ERR-NEXT: warning: parsing line table prologue at 0x00000214 found an invalid directory or file table description at 0x00000236 162# SOME-ERR-NEXT: warning: failed to parse directory entry because extracting the form value failed 163# NONFATAL-NEXT: Line table prologue 164# NONFATAL-NOT: include_directories 165# VERBOSE: DW_LNE_set_address (0x4444333322221111) 166# VERBOSE-NEXT: DW_LNE_end_sequence 167 168## V5 invalid MD5 hash form when there is still data to be read. 169# NONFATAL: debug_line[0x00000244] 170# SOME-ERR-NEXT: warning: parsing line table prologue at 0x00000244 found an invalid directory or file table description at 0x00000277 171# SOME-ERR-NEXT: warning: failed to parse file entry because extracting the form value failed 172# NONFATAL-NEXT: Line table prologue 173# NONFATAL: include_directories[ 0] = "/tmp" 174# NONFATAL-NOT: file_names 175# VERBOSE: DW_LNE_set_address (0x1234123412341234) 176# VERBOSE-NEXT: DW_LNE_end_sequence 177 178## V5 prologue ends while reading an MD5 hash 179# NONFATAL: debug_line[0x00000287] 180# SOME-ERR-NEXT: warning: parsing line table prologue at 0x00000287 found an invalid directory or file table description at 0x000002b2 181# SOME-ERR-NEXT: warning: failed to parse entry content descriptors: unable to decode LEB128 at offset 0x000002b2: malformed uleb128, extends past end 182# NONFATAL-NEXT: Line table prologue 183# NONFATAL: include_directories[ 0] = "/tmp" 184# NONFATAL-NOT: file_names 185# VERBOSE: DW_LNE_set_address (0x4321432143214321) 186# VERBOSE-NEXT: DW_LNE_end_sequence 187 188## V5 invalid directory content description has unsupported form. 189# NONFATAL: debug_line[0x000002c0] 190# SOME-ERR-NEXT: warning: parsing line table prologue at 0x000002c0 found an invalid directory or file table description at 0x000002e9 191# SOME-ERR-NEXT: warning: failed to parse directory entry because skipping the form value failed 192# NONFATAL-NEXT: Line table prologue 193# NONFATAL: include_directories[ 0] = "/foo" 194# NONFATAL-NOT: include_directories 195# NONFATAL-NOT: file_names 196# VERBOSE: DW_LNE_set_address (0xaaaabbbbccccdddd) 197# VERBOSE-NEXT: DW_LNE_end_sequence 198 199## Opcode base field of value zero. 200# NONFATAL: debug_line[0x00000306] 201# SOME-ERR-NEXT: warning: parsing line table prologue at offset 0x00000306 found opcode base of 0. Assuming no standard opcodes 202# NONFATAL-NEXT: Line table prologue 203# NONFATAL: include_directories[ 1] = "dir1" 204# NONFATAL-NEXT: file_names[ 1]: 205# NONFATAL-NEXT: name: "file1" 206# NONFATAL-NEXT: dir_index: 1 207# NONFATAL-NEXT: mod_time: 0x00000002 208# NONFATAL-NEXT: length: 0x00000003 209# VERBOSE: DW_LNE_set_address (0xffffeeeeddddcccc) 210# VERBOSE-NEXT: address += 1, line += 0 211# VERBOSE: DW_LNE_end_sequence 212 213## V4 table with unterminated include directory table. 214# NONFATAL: debug_line[0x00000335] 215# SOME-ERR-NEXT: warning: parsing line table prologue at 0x00000335 found an invalid directory or file table description at 0x00000356 216# SOME-ERR-NEXT: warning: include directories table was not null terminated before the end of the prologue 217# NONFATAL-NEXT: Line table prologue 218# NONFATAL: include_directories[ 1] = "dir1" 219# NONFATAL-NOT: file_names 220# VERBOSE: DW_LNE_set_address (0xabcdef0123456789) 221# VERBOSE-NEXT: DW_LNE_end_sequence 222 223## V4 table with unterminated file name table. 224# NONFATAL: debug_line[0x00000364] 225# SOME-ERR-NEXT: warning: parsing line table prologue at 0x00000364 found an invalid directory or file table description at 0x0000038f 226# SOME-ERR-NEXT: warning: file names table was not null terminated before the end of the prologue 227# NONFATAL-NEXT: Line table prologue 228# NONFATAL: file_names[ 1]: 229# NONFATAL-NEXT: name: "foo.c" 230# NONFATAL-NEXT: dir_index: 1 231# NONFATAL-NEXT: mod_time: 0x00000002 232# NONFATAL-NEXT: length: 0x00000003 233# NONFATAL-NOT: file_names 234# VERBOSE: DW_LNE_set_address (0xababcdcdefef0909) 235# VERBOSE-NEXT: DW_LNE_end_sequence 236 237## Table with extended opcode that overruns table end. 238# NONFATAL: debug_line[0x0000039d] 239# NONFATAL-NEXT: Line table prologue 240# NONFATAL: Address 241# NONFATAL-NEXT: ------------------ 242# VERBOSE-NEXT: DW_LNE_set_address (0x00000000feedfeed) 243# VERBOSE-NEXT: DW_LNS_copy 244# NONFATAL-NEXT: 0x00000000feedfeed 245# VERBOSE-NEXT: DW_LNE_set_address (<parsing error> 00 f0 01 f0 f0 00 01) 246# MORE-ERR-NEXT: warning: unexpected end of data at offset 0x3ed while reading [0x3e6, 0x3ee) 247# MORE-ERR-NEXT: warning: last sequence in debug line table at offset 0x0000039d is not terminated 248 249# LAST: debug_line[0x000003ed] 250# VERBOSE: DW_LNE_set_address (0x00000000cafebabe) 251# VERBOSE-NEXT: DW_LNE_end_sequence 252