Skip to content

Commit b04925b

Browse files
committed
Add tests and correct error messages
1 parent 31c1593 commit b04925b

File tree

4 files changed

+121
-3
lines changed

4 files changed

+121
-3
lines changed

llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ Error DWARFUnitHeader::applyIndexEntry(const DWARFUnitIndex::Entry *Entry) {
344344
IndexEntry = Entry;
345345
if (AbbrOffset)
346346
return createStringError(errc::invalid_argument,
347-
"DWARF package unit from offset 0x%8.8" PRIx64
347+
"DWARF package unit at offset 0x%8.8" PRIx64
348348
" has a non-zero abbreviation offset",
349349
Offset);
350350

@@ -353,7 +353,7 @@ Error DWARFUnitHeader::applyIndexEntry(const DWARFUnitIndex::Entry *Entry) {
353353
UnitContrib->getLength() != (getLength() + getUnitLengthFieldByteSize()))
354354
return createStringError(errc::invalid_argument,
355355
"DWARF package unit at offset 0x%8.8" PRIx64
356-
"has an inconsistent index",
356+
" has an inconsistent index",
357357
Offset);
358358

359359
auto *AbbrEntry = IndexEntry->getContribution(DW_SECT_ABBREV);
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
2+
# RUN: llvm-dwarfdump -debug-info - 2>&1 | FileCheck %s
3+
4+
# CHECK: warning: DWARF package unit at offset 0x00000000 mising abbreviation column
5+
6+
.section .debug_abbrev.dwo, "e", @progbits
7+
.LAbbrBegin:
8+
.uleb128 1 # Abbreviation Code
9+
.uleb128 17 # DW_TAG_compile_unit
10+
.byte 0 # DW_CHILDREN_no
11+
.uleb128 3 # DW_AT_name
12+
.uleb128 8 # DW_FORM_string
13+
.uleb128 0x2131 # DW_AT_GNU_dwo_id
14+
.uleb128 7 # DW_FORM_data8
15+
.byte 0 # EOM(1)
16+
.byte 0 # EOM(2)
17+
.byte 0 # EOM(3)
18+
.LAbbrEnd:
19+
20+
.section .debug_info.dwo, "e", @progbits
21+
.LCUBegin:
22+
.long .LCUEnd-.LCUVersion # Length
23+
.LCUVersion:
24+
.short 4 # Version
25+
.long 0 # Abbrev offset
26+
.byte 4 # Address size
27+
.uleb128 1 # Abbrev [1] DW_TAG_compile_unit
28+
.asciz "a.c" # DW_AT_name
29+
.quad 0x1100001122222222 # DW_AT_GNU_dwo_id
30+
.LCUEnd:
31+
32+
.section .debug_cu_index, "", @progbits
33+
## Header:
34+
.short 2 # Version
35+
.space 2 # Padding
36+
.long 1 # Section count (Invalid, should be 2)
37+
.long 1 # Unit count
38+
.long 4 # Slot count
39+
## Hash Table of Signatures:
40+
.quad 0
41+
.quad 0
42+
.quad 0x1100001122222222
43+
.quad 0
44+
## Parallel Table of Indexes:
45+
.long 0
46+
.long 0
47+
.long 1
48+
.long 0
49+
## Table of Section Offsets:
50+
## Row 0:
51+
.long 1 # DW_SECT_INFO
52+
# .long 3 # DW_SECT_ABBREV (Intentionally omitted)
53+
## Row 1:
54+
.long .LCUBegin-.debug_info.dwo # Offset in .debug_info.dwo
55+
# .long .LAbbrBegin-.debug_abbrev.dwo # Offset in .debug_abbrev.dwo (Intentionally omitted)
56+
## Table of Section Sizes:
57+
.long .LCUEnd-.LCUBegin # Size of the contribution in .debug_info.dwo
58+
.long .LAbbrEnd-.LAbbrBegin # Size of the contribution in .debug_abbrev.dwo (Intentionally omitted)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
2+
# RUN: llvm-dwarfdump -debug-info - 2>&1 | FileCheck %s
3+
4+
# CHECK: warning: DWARF package unit at offset 0x00000000 has a non-zero abbreviation offset
5+
6+
.section .debug_abbrev.dwo, "e", @progbits
7+
.LAbbrBegin:
8+
.uleb128 1 # Abbreviation Code
9+
.uleb128 17 # DW_TAG_compile_unit
10+
.byte 0 # DW_CHILDREN_no
11+
.uleb128 3 # DW_AT_name
12+
.uleb128 8 # DW_FORM_string
13+
.uleb128 0x2131 # DW_AT_GNU_dwo_id
14+
.uleb128 7 # DW_FORM_data8
15+
.byte 0 # EOM(1)
16+
.byte 0 # EOM(2)
17+
.byte 0 # EOM(3)
18+
.LAbbrEnd:
19+
20+
.section .debug_info.dwo, "e", @progbits
21+
.LCUBegin:
22+
.long .LCUEnd-.LCUVersion # Length
23+
.LCUVersion:
24+
.short 4 # Version
25+
.long 1 # Abbrev offset (Invalid, should be 0)
26+
.byte 4 # Address size
27+
.uleb128 1 # Abbrev [1] DW_TAG_compile_unit
28+
.asciz "a.c" # DW_AT_name
29+
.quad 0x1100001122222222 # DW_AT_GNU_dwo_id
30+
.LCUEnd:
31+
32+
.section .debug_cu_index, "", @progbits
33+
## Header:
34+
.short 2 # Version
35+
.space 2 # Padding
36+
.long 2 # Section count
37+
.long 1 # Unit count
38+
.long 4 # Slot count
39+
## Hash Table of Signatures:
40+
.quad 0
41+
.quad 0
42+
.quad 0x1100001122222222
43+
.quad 0
44+
## Parallel Table of Indexes:
45+
.long 0
46+
.long 0
47+
.long 1
48+
.long 0
49+
## Table of Section Offsets:
50+
## Row 0:
51+
.long 1 # DW_SECT_INFO
52+
.long 3 # DW_SECT_ABBREV
53+
## Row 1:
54+
.long .LCUBegin-.debug_info.dwo # Offset in .debug_info.dwo
55+
.long .LAbbrBegin-.debug_abbrev.dwo # Offset in .debug_abbrev.dwo
56+
## Table of Section Sizes:
57+
.long .LCUEnd-.LCUBegin
58+
.long .LAbbrEnd-.LAbbrBegin

llvm/test/DebugInfo/X86/invalid-cu-length-dwp.s

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
2-
# RUN: llvm-dwarfdump -debug-info -
2+
# RUN: llvm-dwarfdump -debug-info - 2>&1 | FileCheck %s
33

44
## llvm-dwarfdump used to crash with this input because of an invalid size
55
## of the compilation unit contribution in the .debug_cu_index section.
66

7+
# CHECK: warning: DWARF package unit at offset 0x00000000 has an inconsistent index
8+
79
.section .debug_abbrev.dwo, "e", @progbits
810
.LAbbrBegin:
911
.uleb128 1 # Abbreviation Code

0 commit comments

Comments
 (0)