Skip to content

Commit

Permalink
[DWARFv5] Number the line-table's directory array correctly.
Browse files Browse the repository at this point in the history
The compilation directory has always been #0, but as of DWARF v5 it is
explicitly listed in the line-table section instead of implicitly
being a reference to the compile_unit DIE's DW_AT_comp_dir attribute.
This means the dumper should number the dumped array starting with 0
or 1 depending on the DWARF version of the line table.

References in the generated DWARF are correct, it's just the dumper
that was wrong.  Also some assembler-coded tests were similarly
confused about directory numbers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322884 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
pogo59 committed Jan 18, 2018
1 parent cee6e0a commit dca3ef1
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 30 deletions.
7 changes: 5 additions & 2 deletions lib/DebugInfo/DWARF/DWARFDebugLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ void DWARFDebugLine::Prologue::dump(raw_ostream &OS) const {
OS << format("standard_opcode_lengths[%s] = %u\n",
LNStandardString(I + 1).data(), StandardOpcodeLengths[I]);

if (!IncludeDirectories.empty())
if (!IncludeDirectories.empty()) {
// DWARF v5 starts directory indexes at 0.
uint32_t DirBase = getVersion() >= 5 ? 0 : 1;
for (uint32_t I = 0; I != IncludeDirectories.size(); ++I)
OS << format("include_directories[%3u] = '", I + 1)
OS << format("include_directories[%3u] = '", I + DirBase)
<< IncludeDirectories[I] << "'\n";
}

if (!FileNames.empty()) {
if (HasMD5)
Expand Down
12 changes: 6 additions & 6 deletions test/DebugInfo/X86/dwarfdump-header-64.s
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ LH_5_params:
# File table entries
.byte 2 # Two files
.asciz "File5a"
.byte 1
.byte 0
.byte 0x51
.byte 0x52
.asciz "File5b"
.byte 2
.byte 1
.byte 0x53
.byte 0x54
LH_5_header_end:
Expand All @@ -141,9 +141,9 @@ LH_5_end:
# CHECK: seg_select_size: 0
# CHECK: prologue_length: 0x00000044
# CHECK: max_ops_per_inst: 1
# CHECK: include_directories[ 1] = 'Directory5a'
# CHECK: include_directories[ 2] = 'Directory5b'
# CHECK: include_directories[ 0] = 'Directory5a'
# CHECK: include_directories[ 1] = 'Directory5b'
# CHECK-NOT: include_directories
# CHECK: file_names[ 1] 1 0x00000051 0x00000052 File5a{{$}}
# CHECK: file_names[ 2] 2 0x00000053 0x00000054 File5b{{$}}
# CHECK: file_names[ 1] 0 0x00000051 0x00000052 File5a{{$}}
# CHECK: file_names[ 2] 1 0x00000053 0x00000054 File5b{{$}}
# CHECK-NOT: file_names
24 changes: 12 additions & 12 deletions test/DebugInfo/X86/dwarfdump-header.s
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ LH_5_params:
# File table entries
.byte 2 # Two files
.asciz "File5a"
.byte 1
.byte 0
.quad 0x7766554433221100
.quad 0xffeeddccbbaa9988
.asciz "File5b"
.byte 2
.byte 1
.quad 0x8899aabbccddeeff
.quad 0x0011223344556677
LH_5_header_end:
Expand All @@ -324,12 +324,12 @@ LH_5_end:
# CHECK: address_size: 8
# CHECK: seg_select_size: 0
# CHECK: max_ops_per_inst: 1
# CHECK: include_directories[ 1] = 'Directory5a'
# CHECK: include_directories[ 2] = 'Directory5b'
# CHECK: include_directories[ 0] = 'Directory5a'
# CHECK: include_directories[ 1] = 'Directory5b'
# CHECK-NOT: include_directories
# CHECK: MD5 Checksum
# CHECK: file_names[ 1] 1 00112233445566778899aabbccddeeff File5a{{$}}
# CHECK: file_names[ 2] 2 ffeeddccbbaa99887766554433221100 File5b{{$}}
# CHECK: file_names[ 1] 0 00112233445566778899aabbccddeeff File5a{{$}}
# CHECK: file_names[ 2] 1 ffeeddccbbaa99887766554433221100 File5b{{$}}
# CHECK-NOT: file_names

.section .debug_line.dwo,"",@progbits
Expand Down Expand Up @@ -383,11 +383,11 @@ dwo_LH_5_params:
# File table entries
.byte 2 # Two files
.asciz "DWOFile5a"
.byte 1
.byte 0
.byte 0x15
.byte 0x25
.asciz "DWOFile5b"
.byte 2
.byte 1
.byte 0x35
.byte 0x45
dwo_LH_5_header_end:
Expand All @@ -399,9 +399,9 @@ dwo_LH_5_end:
# CHECK: address_size: 8
# CHECK: seg_select_size: 0
# CHECK: max_ops_per_inst: 1
# CHECK: include_directories[ 1] = 'DWODirectory5a'
# CHECK: include_directories[ 2] = 'DWODirectory5b'
# CHECK: include_directories[ 0] = 'DWODirectory5a'
# CHECK: include_directories[ 1] = 'DWODirectory5b'
# CHECK-NOT: include_directories
# CHECK: file_names[ 1] 1 0x00000015 0x00000025 DWOFile5a{{$}}
# CHECK: file_names[ 2] 2 0x00000035 0x00000045 DWOFile5b{{$}}
# CHECK: file_names[ 1] 0 0x00000015 0x00000025 DWOFile5a{{$}}
# CHECK: file_names[ 2] 1 0x00000035 0x00000045 DWOFile5b{{$}}
# CHECK-NOT: file_names
12 changes: 6 additions & 6 deletions test/DebugInfo/X86/dwarfdump-line-only.s
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ LH_5_params:
.byte 0x0f # DW_FORM_udata
# File table entries
.byte 2 # Two file entries
.byte 2
.byte 1
.asciz "File1"
.byte 0x51
.byte 0x52
.byte 1
.byte 0
.asciz "File2"
.byte 0x53
.byte 0x54
Expand All @@ -84,10 +84,10 @@ LH_5_end:
# CHECK: address_size: 8
# CHECK: seg_select_size: 0
# CHECK: max_ops_per_inst: 1
# CHECK: include_directories[ 1] = 'Directory1'
# CHECK: include_directories[ 2] = 'Directory2'
# CHECK: include_directories[ 0] = 'Directory1'
# CHECK: include_directories[ 1] = 'Directory2'
# CHECK-NOT: include_directories
# CHECK: file_names[ 1] 2 0x00000051 0x00000052 File1{{$}}
# CHECK: file_names[ 2] 1 0x00000053 0x00000054 File2{{$}}
# CHECK: file_names[ 1] 1 0x00000051 0x00000052 File1{{$}}
# CHECK: file_names[ 2] 0 0x00000053 0x00000054 File2{{$}}
# CHECK-NOT: file_names
# CHECK: 0x0000000000000000 {{.*}} is_stmt end_sequence
2 changes: 1 addition & 1 deletion test/MC/ARM/dwarf-asm-multiple-sections.s
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ b:
// DWARF-DL: .debug_line contents:
// DWARF-DL: version: [[DWVER]]
// DWARF-DL-5: address_size: 4
// DWARF-DL-5: include_directories[ 1] = ''
// DWARF-DL-5: include_directories[ 0] = ''
// DWARF-DL: file_names[ 1] {{.*}} <stdin>
// DWARF-DL: 0x0000000000000000 17 0 1 0 0 is_stmt
// DWARF-DL-NEXT: 0x0000000000000004 17 0 1 0 0 is_stmt end_sequence
Expand Down
6 changes: 3 additions & 3 deletions test/MC/ELF/debug-md5.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

# CHECK: debug_line[0x00000000]
# CHECK: version: 5
# CHECK: include_directories[ 1] = ''
# CHECK: include_directories[ 2] = 'dir1'
# CHECK: include_directories[ 3] = 'dir2'
# CHECK: include_directories[ 0] = ''
# CHECK: include_directories[ 1] = 'dir1'
# CHECK: include_directories[ 2] = 'dir2'
# CHECK-NOT: include_directories
# CHECK: Dir MD5 Checksum File Name
# CHECK: file_names[ 1] 1 00112233445566778899aabbccddeeff foo
Expand Down

0 comments on commit dca3ef1

Please sign in to comment.