Skip to content

Commit 69da400

Browse files
committed
Revert "[DWARFDebugLine] Avoid dumping prologue members we did not parse"
The changed test started failing on the windows bots. Reverting while I investigate. This reverts commit deb116e.
1 parent c66db21 commit 69da400

File tree

3 files changed

+60
-65
lines changed

3 files changed

+60
-65
lines changed

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,15 +474,13 @@ void DWARFContext::dump(
474474
}
475475
OS << "debug_line[" << format("0x%8.8" PRIx64, Parser.getOffset())
476476
<< "]\n";
477-
OS.flush();
478477
if (DumpOpts.Verbose) {
479478
Parser.parseNext(DumpOpts.WarningHandler, DumpOpts.WarningHandler, &OS);
480479
} else {
481480
DWARFDebugLine::LineTable LineTable =
482481
Parser.parseNext(DumpOpts.WarningHandler, DumpOpts.WarningHandler);
483482
LineTable.dump(OS, DumpOpts);
484483
}
485-
OS.flush();
486484
}
487485
};
488486

llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ using ContentDescriptors = SmallVector<ContentDescriptor, 4>;
4242

4343
} // end anonymous namespace
4444

45-
static bool versionIsSupported(uint16_t Version) {
46-
return Version >= 2 && Version <= 5;
47-
}
48-
4945
void DWARFDebugLine::ContentTypeTracker::trackContentType(
5046
dwarf::LineNumberEntryFormat ContentType) {
5147
switch (ContentType) {
@@ -104,13 +100,9 @@ void DWARFDebugLine::Prologue::clear() {
104100

105101
void DWARFDebugLine::Prologue::dump(raw_ostream &OS,
106102
DIDumpOptions DumpOptions) const {
107-
if (!totalLengthIsValid())
108-
return;
109103
OS << "Line table prologue:\n"
110104
<< format(" total_length: 0x%8.8" PRIx64 "\n", TotalLength)
111105
<< format(" version: %u\n", getVersion());
112-
if (!versionIsSupported(getVersion()))
113-
return;
114106
if (getVersion() >= 5)
115107
OS << format(" address_size: %u\n", getAddressSize())
116108
<< format(" seg_select_size: %u\n", SegSelectorSize);
@@ -353,7 +345,7 @@ Error DWARFDebugLine::Prologue::parse(
353345
PrologueOffset, TotalLength);
354346
}
355347
FormParams.Version = DebugLineData.getU16(OffsetPtr);
356-
if (!versionIsSupported(getVersion()))
348+
if (getVersion() < 2 || getVersion() > 5)
357349
// Treat this error as unrecoverable - we cannot be sure what any of
358350
// the data represents including the length field, so cannot skip it or make
359351
// any reasonable assumptions.

llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test

Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,42 @@
33

44
## Show that a bad length stops parsing of the section.
55
# 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=FIRST,FATAL,RESERVED
8-
# RUN: llvm-dwarfdump -debug-line %t-reserved.o -verbose 2>&1 \
9-
# RUN: | FileCheck %s --check-prefixes=FIRST,FATAL,RESERVED
6+
# RUN: llvm-dwarfdump -debug-line %t-reserved.o 2> %t-reserved.err \
7+
# RUN: | FileCheck %s --check-prefixes=FIRST,FATAL
8+
# RUN: FileCheck %s --input-file=%t-reserved.err --check-prefix=RESERVED
9+
# RUN: llvm-dwarfdump -debug-line %t-reserved.o -verbose 2> %t-reserved-verbose.err \
10+
# RUN: | FileCheck %s --check-prefixes=FIRST,FATAL
11+
# RUN: FileCheck %s --input-file=%t-reserved-verbose.err --check-prefix=RESERVED
1012

1113
## We only produce warnings for malformed tables after the specified unit if
1214
## parsing can continue.
13-
# RUN: llvm-dwarfdump -debug-line=0 %t-reserved.o 2>&1 \
14-
# RUN: | FileCheck %s --check-prefixes=FIRST,NOLATER,RESERVED
15+
# RUN: llvm-dwarfdump -debug-line=0 %t-reserved.o 2> %t-reserved-off-first.err \
16+
# RUN: | FileCheck %s --check-prefixes=FIRST,NOLATER
17+
# RUN: FileCheck %s --input-file=%t-reserved-off-first.err --check-prefix=RESERVED
1518

1619
## 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=NOFIRST,NOLATER,RESERVED
20+
# RUN: llvm-dwarfdump -debug-line=0x4b %t-reserved.o 2> %t-reserved-off-last.err \
21+
# RUN: | FileCheck %s --check-prefixes=NOFIRST,NOLATER
22+
# RUN: FileCheck %s --input-file=%t-reserved-off-last.err --check-prefix=RESERVED
1923

2024
## Show that non-fatal errors do not prevent parsing the rest of the section.
2125
# 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=FIRST,NONFATAL,LAST,ALL,OTHER --implicit-check-not='debug_line[{{.*}}]'
24-
# RUN: llvm-dwarfdump -debug-line %t-malformed.o -verbose 2>&1 \
25-
# RUN: | FileCheck %s --check-prefixes=FIRST,NONFATAL,LAST,ALL,OTHER --implicit-check-not='debug_line[{{.*}}]'
26+
# RUN: llvm-dwarfdump -debug-line %t-malformed.o 2> %t-malformed.err \
27+
# RUN: | FileCheck %s --check-prefixes=FIRST,NONFATAL,LAST --implicit-check-not='debug_line[{{.*}}]'
28+
# RUN: FileCheck %s --input-file=%t-malformed.err --check-prefixes=ALL,OTHER
29+
# RUN: llvm-dwarfdump -debug-line %t-malformed.o -verbose 2> %t-malformed-verbose.err \
30+
# RUN: | FileCheck %s --check-prefixes=FIRST,NONFATAL,LAST --implicit-check-not='debug_line[{{.*}}]'
31+
# RUN: FileCheck %s --input-file=%t-malformed-verbose.err --check-prefixes=ALL,OTHER
2632

2733
## We should still produce warnings for malformed tables after the specified unit.
28-
# RUN: llvm-dwarfdump -debug-line=0 %t-malformed.o 2>&1 \
29-
# RUN: | FileCheck %s --check-prefixes=FIRST,NOLATER,ALL
34+
# RUN: llvm-dwarfdump -debug-line=0 %t-malformed.o 2> %t-malformed-off-first.err \
35+
# RUN: | FileCheck %s --check-prefixes=FIRST,NOLATER
36+
# RUN: FileCheck %s --input-file=%t-malformed-off-first.err --check-prefix=ALL
3037

3138
## Don't stop looking for the later unit if non-fatal issues are found.
32-
# RUN: llvm-dwarfdump -debug-line=0x3c9 %t-malformed.o 2>&1 \
33-
# RUN: | FileCheck %s --check-prefixes=LAST,ALL --implicit-check-not='debug_line[{{.*}}]'
39+
# RUN: llvm-dwarfdump -debug-line=0x3c9 %t-malformed.o 2> %t-malformed-off-last.err \
40+
# RUN: | FileCheck %s --check-prefix=LAST --implicit-check-not='debug_line[{{.*}}]'
41+
# RUN: FileCheck %s --input-file=%t-malformed-off-last.err --check-prefix=ALL
3442

3543
# FIRST: debug_line[0x00000000]
3644
# FIRST: 0x000000000badbeef {{.*}} end_sequence
@@ -41,44 +49,31 @@
4149

4250
## For fatal issues, the following table(s) should not be dumped:
4351
# FATAL: debug_line[0x00000048]
44-
# RESERVED-NOT: prologue
45-
# RESERVED: warning: parsing line table prologue at offset 0x00000048 unsupported reserved unit length found of value 0xfffffffe
46-
# RESERVED-NOT: prologue
52+
# FATAL-NEXT: Line table prologue
53+
# FATAL-NEXT: total_length: 0xfffffffe
4754
# FATAL-NOT: debug_line
4855

4956
## For non-fatal issues, the table data should be dumped:
5057

5158
## Version 0 table.
5259
# NONFATAL: debug_line[0x00000048]
53-
# ALL: warning: parsing line table prologue at offset 0x00000048 found unsupported version 0
5460
# NONFATAL-NEXT: Line table prologue
55-
# NONFATAL-NEXT: total_length: 0x00000002
56-
# NONFATAL-NEXT: version: 0
57-
# NONFATAL-NOT: prologue_length
61+
# NONFATAL-NOT: Address
5862

5963
## Version 1 table.
6064
# NONFATAL: debug_line[0x0000004e]
61-
# ALL-NEXT: warning: parsing line table prologue at offset 0x0000004e found unsupported version 1
6265
# NONFATAL-NEXT: Line table prologue
63-
# NONFATAL-NEXT: total_length: 0x00000002
64-
# NONFATAL-NEXT: version: 1
65-
# NONFATAL-NOT: prologue_length
66+
# NONFATAL-NOT: Address
6667

6768
## Malformed directory format with no path component.
6869
# NONFATAL: debug_line[0x00000054]
69-
# ALL-NEXT: warning: parsing line table prologue at 0x00000054 found an invalid directory or file table description at 0x00000073
70-
# ALL-NEXT: warning: failed to parse entry content descriptions because no path was found
7170
# NONFATAL-NEXT: Line table prologue
72-
# NONFATAL: prologue_length: 0x00000013
7371
# NONFATAL-NOT: include_directories
7472
# NONFATAL-NOT: file_names
7573
# NONFATAL: 0x8877665544332211 {{.*}} end_sequence
7674

7775
## Prologue with length shorter than parsed.
7876
# NONFATAL: debug_line[0x00000081]
79-
# ALL-NEXT: warning: parsing line table prologue at 0x00000081 found an invalid directory or file table description at 0x000000ba
80-
# ALL-NEXT: warning: file names table was not null terminated before the end of the prologue
81-
# ALL-NEXT: warning: parsing line table prologue at 0x00000081 should have ended at 0x000000b9 but it ended at 0x000000ba
8277
# NONFATAL-NEXT: Line table prologue
8378
# NONFATAL: file_names[ 2]:
8479
# NONFATAL-NEXT: name: "file2"
@@ -89,7 +84,6 @@
8984

9085
## Prologue with length longer than parsed.
9186
# NONFATAL: debug_line[0x000000c8]
92-
# ALL-NEXT: warning: parsing line table prologue at 0x000000c8 should have ended at 0x00000103 but it ended at 0x00000102
9387
# NONFATAL-NEXT: Line table prologue
9488
# NONFATAL: file_names[ 2]:
9589
# NONFATAL-NEXT: name: "file2"
@@ -101,24 +95,18 @@
10195

10296
## Extended opcode with incorrect length versus expected.
10397
# NONFATAL: debug_line[0x00000111]
104-
# OTHER-NEXT: warning: unexpected line op length at offset 0x00000158 expected 0x02 found 0x01
105-
# OTHER-NEXT: warning: unexpected line op length at offset 0x0000015c expected 0x01 found 0x02
10698
# NONFATAL-NEXT: Line table prologue
107-
# NONFATAL: prologue_length: 0x00000030
10899
# NONFATAL: 0x00000000abbadaba {{.*}} end_sequence
109100
# NONFATAL: 0x00000000babb1e45 {{.*}} 10 is_stmt prologue_end end_sequence{{$}}
110101

111102
## No end of sequence.
112103
# NONFATAL: debug_line[0x0000016c]
113-
# OTHER-NEXT: warning: last sequence in debug line table at offset 0x0000016c is not terminated
114104
# NONFATAL-NEXT: Line table prologue
115-
# NONFATAL: prologue_length: 0x00000030
116105
# NONFATAL: 0x00000000deadfade {{.*}} is_stmt
117106
# NONFATAL-NOT: end_sequence
118107

119108
## Very short prologue length for V5 (ends during parameters).
120109
# NONFATAL: debug_line[0x000001b2]
121-
# ALL-NEXT: warning: parsing line table prologue at 0x000001b2 should have ended at 0x000001ce but it ended at 0x000001e1
122110
# NONFATAL-NEXT: Line table prologue
123111
# NONFATAL: standard_opcode_lengths[DW_LNS_set_isa] = 1
124112
# NONFATAL-NEXT: include_directories[ 0] = "/tmp"
@@ -129,7 +117,6 @@
129117

130118
## V5 prologue ends during file table.
131119
# NONFATAL: debug_line[0x000001ee]
132-
# ALL-NEXT: warning: parsing line table prologue at 0x000001ee should have ended at 0x00000219 but it ended at 0x00000220
133120
# NONFATAL-NEXT: Line table prologue
134121
# NONFATAL: include_directories[ 0] = "/tmp"
135122
# NONFATAL-NEXT: file_names[ 0]:
@@ -140,7 +127,6 @@
140127

141128
## V5 prologue ends during directory table.
142129
# NONFATAL: debug_line[0x0000022f]
143-
# ALL-NEXT: warning: parsing line table prologue at 0x0000022f should have ended at 0x00000251 but it ended at 0x0000025e
144130
# NONFATAL-NEXT: Line table prologue
145131
# NONFATAL: include_directories[ 0] = "/tmp"
146132
# NONFATAL-NEXT: file_names[ 0]:
@@ -150,8 +136,6 @@
150136

151137
## V5 invalid MD5 hash form when there is still data to be read.
152138
# NONFATAL: debug_line[0x0000026b]
153-
# ALL-NEXT: warning: parsing line table prologue at 0x0000026b found an invalid directory or file table description at 0x0000029f
154-
# ALL-NEXT: warning: failed to parse file entry because the MD5 hash is invalid
155139
# NONFATAL-NEXT: Line table prologue
156140
# NONFATAL: include_directories[ 0] = "/tmp"
157141
# NONFATAL-NOT: file_names
@@ -161,9 +145,6 @@
161145
## V5 invalid MD5 hash form when data beyond the prologue length has
162146
## been read before the MD5 problem is identified.
163147
# NONFATAL: debug_line[0x000002ae]
164-
# ALL-NEXT: warning: parsing line table prologue at 0x000002ae found an invalid directory or file table description at 0x000002e0
165-
# ALL-NEXT: warning: failed to parse file entry because the MD5 hash is invalid
166-
# ALL-NEXT: warning: parsing line table prologue at 0x000002ae should have ended at 0x000002d9 but it ended at 0x000002e0
167148
# NONFATAL-NEXT: Line table prologue
168149
# NONFATAL: include_directories[ 0] = "/tmp"
169150
# NONFATAL-NOT: file_names
@@ -172,8 +153,6 @@
172153

173154
## V5 invalid directory content description has unsupported form.
174155
# NONFATAL: debug_line[0x000002ec]
175-
# ALL-NEXT: warning: parsing line table prologue at 0x000002ec found an invalid directory or file table description at 0x00000315
176-
# ALL-NEXT: warning: failed to parse directory entry because skipping the form value failed.
177156
# NONFATAL-NEXT: Line table prologue
178157
# NONFATAL: include_directories[ 0] = "/foo"
179158
# NONFATAL-NOT: include_directories
@@ -182,7 +161,6 @@
182161

183162
## Opcode base field of value zero.
184163
# NONFATAL: debug_line[0x00000332]
185-
# ALL-NEXT: warning: parsing line table prologue at offset 0x00000332 found opcode base of 0. Assuming no standard opcodes
186164
# NONFATAL-NEXT: Line table prologue
187165
# NONFATAL: include_directories[ 1] = "dir1"
188166
# NONFATAL-NEXT: file_names[ 1]:
@@ -195,17 +173,13 @@
195173

196174
## V4 table with unterminated include directory table.
197175
# NONFATAL: debug_line[0x00000361]
198-
# ALL-NEXT: warning: parsing line table prologue at 0x00000361 found an invalid directory or file table description at 0x00000382
199-
# ALL-NEXT: warning: include directories table was not null terminated before the end of the prologue
200176
# NONFATAL-NEXT: Line table prologue
201177
# NONFATAL: include_directories[ 1] = "dir1"
202178
# NONFATAL-NOT: file_names
203179
# NONFATAL: 0xabcdef0123456789 {{.*}} is_stmt end_sequence
204180

205181
## V4 table with unterminated file name table.
206182
# NONFATAL: debug_line[0x00000390]
207-
# ALL-NEXT: warning: parsing line table prologue at 0x00000390 found an invalid directory or file table description at 0x000003bb
208-
# ALL-NEXT: warning: file names table was not null terminated before the end of the prologue
209183
# NONFATAL-NEXT: Line table prologue
210184
# NONFATAL: file_names[ 1]:
211185
# NONFATAL-NEXT: name: "foo.c"
@@ -217,3 +191,34 @@
217191

218192
# LAST: debug_line[0x000003c9]
219193
# LAST: 0x00000000cafebabe {{.*}} end_sequence
194+
195+
# RESERVED: warning: parsing line table prologue at offset 0x00000048 unsupported reserved unit length found of value 0xfffffffe
196+
197+
# ALL-NOT: warning:
198+
# ALL: warning: parsing line table prologue at offset 0x00000048 found unsupported version 0
199+
# ALL-NEXT: warning: parsing line table prologue at offset 0x0000004e found unsupported version 1
200+
# ALL-NEXT: warning: parsing line table prologue at 0x00000054 found an invalid directory or file table description at 0x00000073
201+
# ALL-NEXT: warning: failed to parse entry content descriptions because no path was found
202+
# ALL-NEXT: warning: parsing line table prologue at 0x00000081 found an invalid directory or file table description at 0x000000ba
203+
# ALL-NEXT: warning: file names table was not null terminated before the end of the prologue
204+
# ALL-NEXT: warning: parsing line table prologue at 0x00000081 should have ended at 0x000000b9 but it ended at 0x000000ba
205+
# ALL-NEXT: warning: parsing line table prologue at 0x000000c8 should have ended at 0x00000103 but it ended at 0x00000102
206+
# OTHER-NEXT: warning: unexpected line op length at offset 0x00000158 expected 0x02 found 0x01
207+
# OTHER-NEXT: warning: unexpected line op length at offset 0x0000015c expected 0x01 found 0x02
208+
# OTHER-NEXT: warning: last sequence in debug line table at offset 0x0000016c is not terminated
209+
# ALL-NEXT: warning: parsing line table prologue at 0x000001b2 should have ended at 0x000001ce but it ended at 0x000001e1
210+
# ALL-NEXT: warning: parsing line table prologue at 0x000001ee should have ended at 0x00000219 but it ended at 0x00000220
211+
# ALL-NEXT: warning: parsing line table prologue at 0x0000022f should have ended at 0x00000251 but it ended at 0x0000025e
212+
# ALL-NEXT: warning: parsing line table prologue at 0x0000026b found an invalid directory or file table description at 0x0000029f
213+
# ALL-NEXT: warning: failed to parse file entry because the MD5 hash is invalid
214+
# ALL-NEXT: warning: parsing line table prologue at 0x000002ae found an invalid directory or file table description at 0x000002e0
215+
# ALL-NEXT: warning: failed to parse file entry because the MD5 hash is invalid
216+
# ALL-NEXT: warning: parsing line table prologue at 0x000002ae should have ended at 0x000002d9 but it ended at 0x000002e0
217+
# ALL-NEXT: warning: parsing line table prologue at 0x000002ec found an invalid directory or file table description at 0x00000315
218+
# ALL-NEXT: warning: failed to parse directory entry because skipping the form value failed.
219+
# ALL-NEXT: warning: parsing line table prologue at offset 0x00000332 found opcode base of 0. Assuming no standard opcodes
220+
# ALL-NEXT: warning: parsing line table prologue at 0x00000361 found an invalid directory or file table description at 0x00000382
221+
# ALL-NEXT: warning: include directories table was not null terminated before the end of the prologue
222+
# ALL-NEXT: warning: parsing line table prologue at 0x00000390 found an invalid directory or file table description at 0x000003bb
223+
# ALL-NEXT: warning: file names table was not null terminated before the end of the prologue
224+
# ALL-NOT: warning:

0 commit comments

Comments
 (0)