[llvm] r322884 - [DWARFv5] Number the line-table's directory array correctly.

Paul Robinson via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 12:33:35 PST 2018


Author: probinson
Date: Thu Jan 18 12:33:35 2018
New Revision: 322884

URL: http://llvm.org/viewvc/llvm-project?rev=322884&view=rev
Log:
[DWARFv5] Number the line-table's directory array correctly.

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.

Modified:
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
    llvm/trunk/test/DebugInfo/X86/dwarfdump-header-64.s
    llvm/trunk/test/DebugInfo/X86/dwarfdump-header.s
    llvm/trunk/test/DebugInfo/X86/dwarfdump-line-only.s
    llvm/trunk/test/MC/ARM/dwarf-asm-multiple-sections.s
    llvm/trunk/test/MC/ELF/debug-md5.s

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp?rev=322884&r1=322883&r2=322884&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp Thu Jan 18 12:33:35 2018
@@ -73,10 +73,13 @@ void DWARFDebugLine::Prologue::dump(raw_
     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)

Modified: llvm/trunk/test/DebugInfo/X86/dwarfdump-header-64.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dwarfdump-header-64.s?rev=322884&r1=322883&r2=322884&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/dwarfdump-header-64.s (original)
+++ llvm/trunk/test/DebugInfo/X86/dwarfdump-header-64.s Thu Jan 18 12:33:35 2018
@@ -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:
@@ -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

Modified: llvm/trunk/test/DebugInfo/X86/dwarfdump-header.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dwarfdump-header.s?rev=322884&r1=322883&r2=322884&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/dwarfdump-header.s (original)
+++ llvm/trunk/test/DebugInfo/X86/dwarfdump-header.s Thu Jan 18 12:33:35 2018
@@ -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:
@@ -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,"", at progbits
@@ -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:
@@ -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

Modified: llvm/trunk/test/DebugInfo/X86/dwarfdump-line-only.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dwarfdump-line-only.s?rev=322884&r1=322883&r2=322884&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/dwarfdump-line-only.s (original)
+++ llvm/trunk/test/DebugInfo/X86/dwarfdump-line-only.s Thu Jan 18 12:33:35 2018
@@ -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
@@ -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

Modified: llvm/trunk/test/MC/ARM/dwarf-asm-multiple-sections.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/dwarf-asm-multiple-sections.s?rev=322884&r1=322883&r2=322884&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/dwarf-asm-multiple-sections.s (original)
+++ llvm/trunk/test/MC/ARM/dwarf-asm-multiple-sections.s Thu Jan 18 12:33:35 2018
@@ -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

Modified: llvm/trunk/test/MC/ELF/debug-md5.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/debug-md5.s?rev=322884&r1=322883&r2=322884&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/debug-md5.s (original)
+++ llvm/trunk/test/MC/ELF/debug-md5.s Thu Jan 18 12:33:35 2018
@@ -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




More information about the llvm-commits mailing list