From 8d070bc9dfb48d7dd083f53c3e00388b5ab984ac Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Thu, 8 Feb 2018 23:08:02 +0000 Subject: [PATCH] [DWARFv5] Fix dumper to show the file table starts at index 0. Emitting the correct (root of compilation) file at index 0 will be posted for review later; I wanted to get this minor change out of the way first. llvm-svn: 324669 --- lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 5 ++++- test/CodeGen/Generic/dwarf-md5.ll | 4 ++-- test/DebugInfo/X86/dwarfdump-header-64.s | 4 ++-- test/DebugInfo/X86/dwarfdump-header.s | 8 ++++---- test/DebugInfo/X86/dwarfdump-line-only.s | 4 ++-- test/MC/ARM/dwarf-asm-multiple-sections.s | 8 ++++---- test/MC/ELF/debug-md5.s | 4 ++-- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index 38272b6afdf..8986af26c03 100644 --- a/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -93,9 +93,12 @@ void DWARFDebugLine::Prologue::dump(raw_ostream &OS, OS << " Dir Mod Time File Len File Name\n" << " ---- ---------- ---------- -----------" "----------------\n"; + // DWARF v5 starts file indexes at 0. + uint32_t FileBase = getVersion() >= 5 ? 0 : 1; for (uint32_t I = 0; I != FileNames.size(); ++I) { const FileNameEntry &FileEntry = FileNames[I]; - OS << format("file_names[%3u] %4" PRIu64 " ", I + 1, FileEntry.DirIdx); + OS << format("file_names[%3u] %4" PRIu64 " ", I + FileBase, + FileEntry.DirIdx); if (HasMD5) OS << FileEntry.Checksum.digest(); else diff --git a/test/CodeGen/Generic/dwarf-md5.ll b/test/CodeGen/Generic/dwarf-md5.ll index 6793bf1cfb2..001a67e90ea 100644 --- a/test/CodeGen/Generic/dwarf-md5.ll +++ b/test/CodeGen/Generic/dwarf-md5.ll @@ -21,8 +21,8 @@ ; OBJ-4: file_names[ 2] 1 0x00000000 0x00000000 "t2.h" ; OBJ-5: Dir MD5 Checksum File Name -; OBJ-5: file_names[ 1] 1 11111111111111111111111111111111 "t1.h" -; OBJ-5: file_names[ 2] 1 22222222222222222222222222222222 "t2.h" +; OBJ-5: file_names[ 0] 1 11111111111111111111111111111111 "t1.h" +; OBJ-5: file_names[ 1] 1 22222222222222222222222222222222 "t2.h" ; ModuleID = 't.c' source_filename = "t.c" diff --git a/test/DebugInfo/X86/dwarfdump-header-64.s b/test/DebugInfo/X86/dwarfdump-header-64.s index 3b047cd641d..b0be6f359af 100644 --- a/test/DebugInfo/X86/dwarfdump-header-64.s +++ b/test/DebugInfo/X86/dwarfdump-header-64.s @@ -144,6 +144,6 @@ LH_5_end: # CHECK: include_directories[ 0] = .debug_str[0x00000028] = "Directory5a" # CHECK: include_directories[ 1] = .debug_str[0x00000034] = "Directory5b" # CHECK-NOT: include_directories -# CHECK: file_names[ 1] 0 0x00000051 0x00000052 "File5a" -# CHECK: file_names[ 2] 1 0x00000053 0x00000054 "File5b" +# CHECK: file_names[ 0] 0 0x00000051 0x00000052 "File5a" +# CHECK: file_names[ 1] 1 0x00000053 0x00000054 "File5b" # CHECK-NOT: file_names diff --git a/test/DebugInfo/X86/dwarfdump-header.s b/test/DebugInfo/X86/dwarfdump-header.s index 350beb37481..87178945082 100644 --- a/test/DebugInfo/X86/dwarfdump-header.s +++ b/test/DebugInfo/X86/dwarfdump-header.s @@ -330,8 +330,8 @@ LH_5_end: # CHECK: include_directories[ 1] = .debug_str[0x00000051] = "Directory5b" # CHECK-NOT: include_directories # CHECK: MD5 Checksum -# CHECK: file_names[ 1] 0 00112233445566778899aabbccddeeff .debug_line_str[0x00000000] = "File5a" -# CHECK: file_names[ 2] 1 ffeeddccbbaa99887766554433221100 .debug_line_str[0x00000007] = "File5b" +# CHECK: file_names[ 0] 0 00112233445566778899aabbccddeeff .debug_line_str[0x00000000] = "File5a" +# CHECK: file_names[ 1] 1 ffeeddccbbaa99887766554433221100 .debug_line_str[0x00000007] = "File5b" # CHECK-NOT: file_names .section .debug_line_str,"MS",@progbits,1 @@ -410,6 +410,6 @@ dwo_LH_5_end: # CHECK: include_directories[ 0] = .debug_str[0x0000003d] = "DWODirectory5a" # CHECK: include_directories[ 1] = .debug_str[0x0000004c] = "DWODirectory5b" # CHECK-NOT: include_directories -# CHECK: file_names[ 1] 0 0x00000015 0x00000025 "DWOFile5a" -# CHECK: file_names[ 2] 1 0x00000035 0x00000045 "DWOFile5b" +# CHECK: file_names[ 0] 0 0x00000015 0x00000025 "DWOFile5a" +# CHECK: file_names[ 1] 1 0x00000035 0x00000045 "DWOFile5b" # CHECK-NOT: file_names diff --git a/test/DebugInfo/X86/dwarfdump-line-only.s b/test/DebugInfo/X86/dwarfdump-line-only.s index b4d89807f7c..4cd7fb9cb1f 100644 --- a/test/DebugInfo/X86/dwarfdump-line-only.s +++ b/test/DebugInfo/X86/dwarfdump-line-only.s @@ -94,7 +94,7 @@ ls_F2: .asciz "File2" # CHECK: include_directories[ 0] = .debug_str[0x00000000] = "Directory1" # CHECK: include_directories[ 1] = .debug_str[0x0000000b] = "Directory2" # CHECK-NOT: include_directories -# CHECK: file_names[ 1] 1 0x00000051 0x00000052 .debug_line_str[0x00000000] = "File1" -# CHECK: file_names[ 2] 0 0x00000053 0x00000054 .debug_line_str[0x00000006] = "File2" +# CHECK: file_names[ 0] 1 0x00000051 0x00000052 .debug_line_str[0x00000000] = "File1" +# CHECK: file_names[ 1] 0 0x00000053 0x00000054 .debug_line_str[0x00000006] = "File2" # CHECK-NOT: file_names # CHECK: 0x0000000000000000 {{.*}} is_stmt end_sequence diff --git a/test/MC/ARM/dwarf-asm-multiple-sections.s b/test/MC/ARM/dwarf-asm-multiple-sections.s index e51617a1aba..4d8c7d25db3 100644 --- a/test/MC/ARM/dwarf-asm-multiple-sections.s +++ b/test/MC/ARM/dwarf-asm-multiple-sections.s @@ -1,14 +1,14 @@ // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 5 -fdebug-compilation-dir=/tmp // RUN: llvm-dwarfdump -v %t | FileCheck -check-prefix DWARF -check-prefix DWARF45 %s -// RUN: llvm-dwarfdump --debug-line %t | FileCheck -check-prefix DWARF-DL -check-prefix DWARF-DL-5 -DDWVER=5 %s +// RUN: llvm-dwarfdump --debug-line %t | FileCheck -check-prefix DWARF-DL -check-prefix DWARF-DL-5 -DDWVER=5 -DDWFILE=0 %s // RUN: llvm-objdump -r %t | FileCheck -check-prefix RELOC -check-prefix RELOC5 %s // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -fdebug-compilation-dir=/tmp // RUN: llvm-dwarfdump -v %t | FileCheck -check-prefix DWARF -check-prefix DWARF45 %s -// RUN: llvm-dwarfdump --debug-line %t | FileCheck -check-prefix DWARF-DL -DDWVER=4 %s +// RUN: llvm-dwarfdump --debug-line %t | FileCheck -check-prefix DWARF-DL -DDWVER=4 -DDWFILE=1 %s // RUN: llvm-objdump -r %t | FileCheck -check-prefix RELOC -check-prefix RELOC4 %s // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 3 -fdebug-compilation-dir=/tmp // RUN: llvm-dwarfdump -v %t | FileCheck -check-prefix DWARF -check-prefix DWARF3 %s -// RUN: llvm-dwarfdump --debug-line %t | FileCheck -check-prefix DWARF-DL -DDWVER=3 %s +// RUN: llvm-dwarfdump --debug-line %t | FileCheck -check-prefix DWARF-DL -DDWVER=3 -DDWFILE=1 %s // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 2 2>&1 | FileCheck -check-prefix VERSION %s // RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 1 2>&1 | FileCheck -check-prefix DWARF1 %s // RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 6 2>&1 | FileCheck -check-prefix DWARF6 %s @@ -55,7 +55,7 @@ b: // DWARF-DL: version: [[DWVER]] // DWARF-DL-5: address_size: 4 // DWARF-DL-5: include_directories[ 0] = "" -// DWARF-DL: file_names[ 1] {{.*}} "" +// DWARF-DL: file_names[ [[DWFILE]]] {{.*}} "" // DWARF-DL: 0x0000000000000000 17 0 1 0 0 is_stmt // DWARF-DL-NEXT: 0x0000000000000004 17 0 1 0 0 is_stmt end_sequence // DWARF-DL-NEXT: 0x0000000000000000 21 0 1 0 0 is_stmt diff --git a/test/MC/ELF/debug-md5.s b/test/MC/ELF/debug-md5.s index 7caf6bad84c..1a228ea671e 100644 --- a/test/MC/ELF/debug-md5.s +++ b/test/MC/ELF/debug-md5.s @@ -14,8 +14,8 @@ # CHECK: include_directories[ 2] = .debug_line_str[0x[[DIR2:[0-9a-f]+]]] = "dir2" # CHECK-NOT: include_directories # CHECK: Dir MD5 Checksum File Name -# CHECK: file_names[ 1] 1 00112233445566778899aabbccddeeff .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo" -# CHECK: file_names[ 2] 2 ffeeddccbbaa99887766554433221100 .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar" +# CHECK: file_names[ 0] 1 00112233445566778899aabbccddeeff .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo" +# CHECK: file_names[ 1] 2 ffeeddccbbaa99887766554433221100 .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar" # CHECK: .debug_line_str contents: # CHECK-NEXT: 0x[[DIR0]]: ""