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