Skip to content

Commit 6982ea8

Browse files
Merge pull request #8163 from felipepiovezan/felipe/cherry-pick-empty-line-tables
[CherryPick][DWARFVerifier] Fix verification of empty line tables (llvm#81162)
2 parents f1102cf + 8818c87 commit 6982ea8

File tree

2 files changed

+61
-7
lines changed

2 files changed

+61
-7
lines changed

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,11 @@ void DWARFVerifier::verifyDebugLineRows() {
921921
FileIndex++;
922922
}
923923

924+
// Nothing to verify in a line table with a single row containing the end
925+
// sequence.
926+
if (LineTable->Rows.size() == 1 && LineTable->Rows.front().EndSequence)
927+
continue;
928+
924929
// Verify rows.
925930
uint64_t PrevAddress = 0;
926931
uint32_t RowIndex = 0;
@@ -941,13 +946,7 @@ void DWARFVerifier::verifyDebugLineRows() {
941946
OS << '\n';
942947
}
943948

944-
// If the prologue contains no file names and the line table has only one
945-
// row, do not verify the file index, this is a line table of an empty
946-
// file with an end_sequence, but the DWARF standard sets the file number
947-
// to 1 by default, otherwise verify file index.
948-
if ((LineTable->Prologue.FileNames.size() ||
949-
LineTable->Rows.size() != 1) &&
950-
!LineTable->hasFileAtIndex(Row.File)) {
949+
if (!LineTable->hasFileAtIndex(Row.File)) {
951950
++NumDebugLineErrors;
952951
error() << ".debug_line["
953952
<< format("0x%08" PRIx64,
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# RUN: yaml2obj %s -o %t.o
2+
# RUN: llvm-dwarfdump -debug-line -verify %t.o | FileCheck %s
3+
4+
# CHECK: Verifying .debug_line...
5+
# CHECK: No errors
6+
7+
# In a line table like the one below, with no rows (other than the
8+
# end_sequence), we should never verify the file index because the state
9+
# machine initializes the file index to 1, which is invalid in DWARF 5 due to
10+
# its 0-based indexing.
11+
12+
# file_names[ 0]:
13+
# name: "/home/umb/tests_2018/106_rnglists2"
14+
# dir_index: 0
15+
# Address Line Column File ISA Discriminator OpIndex Flags
16+
# ------------------ ------ ------ ------ --- ------------- ------- -------------
17+
# 0x0000000000000000 1 0 1 0 0 0 is_stmt end_sequence
18+
19+
20+
--- !ELF
21+
FileHeader:
22+
Class: ELFCLASS64
23+
Data: ELFDATA2LSB
24+
Type: ET_EXEC
25+
DWARF:
26+
debug_abbrev:
27+
- ID: 0
28+
Table:
29+
- Code: 0x1
30+
Tag: DW_TAG_compile_unit
31+
Children: DW_CHILDREN_no
32+
Attributes:
33+
- Attribute: DW_AT_stmt_list
34+
Form: DW_FORM_sec_offset
35+
debug_info:
36+
- Length: 0xd
37+
Version: 5
38+
UnitType: DW_UT_compile
39+
AbbrevTableID: 0
40+
AbbrOffset: 0x0
41+
AddrSize: 8
42+
Entries:
43+
- AbbrCode: 0x1
44+
Values:
45+
- Value: 0x0
46+
Sections:
47+
- Name: .debug_line
48+
Type: SHT_PROGBITS
49+
AddressAlign: 0x1
50+
Content: 300000000500080025000000010101fb0e0d00010101010000000100000101011f010000000002011f020b010000000000000101
51+
- Name: .debug_line_str
52+
Type: SHT_PROGBITS
53+
Flags: [ SHF_MERGE, SHF_STRINGS ]
54+
AddressAlign: 0x1
55+
Content: 2F686F6D652F756D622F74657374735F323031382F3130365F726E676C697374733200746573742E63707000

0 commit comments

Comments
 (0)