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)
# 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:
# 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
# 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:
# 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
# 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:
# 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
.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
# 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
// 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
# 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