1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00
llvm-mirror/test/MC/ELF/dwarf-file0.s
Ali Tamur c283818217 [llvm] Prevent duplicate files in debug line header in dwarf 5: another attempt
Another attempt to land the changes in debug line header to prevent duplicate
files in Dwarf 5. I rolled back my previous commit because of a mistake in
generating the object file in a test. Meanwhile, I addressed some offline
comments and changed the implementation; the largest difference is that
MCDwarfLineTableHeader does not keep DwarfVersion but gets it as a parameter. I
also merged the patch to fix two lld tests that will strt to fail into this
patch.

Original Commit:

https://reviews.llvm.org/D59515

Original Message:
Motivation: In previous dwarf versions, file name indexes started from 1, and
the primary source file was not explicit. Dwarf 5 standard (6.2.4) prescribes
the primary source file to be explicitly given an entry with an index number 0.

The current implementation honors the specification by just duplicating the
main source file, once with index number 0, and later maybe with another
index number. While this is compliant with the letter of the standard, the
duplication causes problems for consumers of this information such as lldb.
(Some files are duplicated, where only some of them have a line table although
all refer to the same file)

With this change, dwarf 5 debug line section files always start from 0, and
the zeroth entry is not duplicated whenever possible. This requires different
handling of dwarf 4 and dwarf 5 during generation (e.g. when a function returns
an index zero for a file name, it signals an error in dwarf 4, but not in dwarf
5) However, I think the minor complication is worth it, because it enables all
consumers (lldb, gdb, dwarfdump, objdump, and so on) to treat all files in the
file name list homogenously.

llvm-svn: 358732
2019-04-19 02:26:56 +00:00

35 lines
1.4 KiB
ArmAsm

# REQUIRES: default_triple
# RUN: llvm-mc -dwarf-version 4 %s -filetype=obj -o - | llvm-dwarfdump -debug-line - | FileCheck %s --check-prefixes=CHECK,CHECK-4
# RUN: llvm-mc -dwarf-version 4 %s -filetype=asm -o - | FileCheck %s --check-prefixes=ASM,ASM-4
# RUN: llvm-mc -dwarf-version 4 %s -filetype=asm -o - 2>&1 | FileCheck %s --check-prefix=WARN
# RUN: llvm-mc -dwarf-version 5 %s -filetype=obj -o - | llvm-dwarfdump -debug-line - | FileCheck %s --check-prefixes=CHECK,CHECK-5
# RUN: llvm-mc -dwarf-version 5 %s -filetype=asm -o - | FileCheck %s --check-prefixes=ASM,ASM-5
.file 0 "/test" "root.cpp"
.file 1 "/include" "header.h"
.file 2 "/test" "root.cpp"
# CHECK-5: include_directories[ 0] = "/test"
# CHECK-4-NOT: include_directories[ 0]
# CHECK: include_directories[ 1] = "/include"
# CHECK-4: include_directories[ 2] = "/test"
# CHECK-NOT: include_directories
# CHECK-4-NOT: file_names[ 0]
# CHECK-5: file_names[ 0]:
# CHECK-5-NEXT: name: "root.cpp"
# CHECK-5-NEXT: dir_index: 0
# CHECK: file_names[ 1]:
# CHECK-NEXT: name: "header.h"
# CHECK-NEXT: dir_index: 1
# CHECK-4: file_names[ 2]:
# CHECK-4-NEXT: name: "root.cpp"
# CHECK-4-NEXT: dir_index: 2
# ASM-NOT: .file
# ASM-5: .file 0 "/test" "root.cpp"
# ASM: .file 1 "/include" "header.h"
# ASM-4: .file 2 "/test" "root.cpp"
# ASM-NOT: .file
# WARN: file 0 not supported prior to DWARF-5
# WARN-NEXT: .file 0
# WARN-NEXT: ^