]> granicus.if.org Git - llvm/commit
[llvm] Reapply "Prevent duplicate files in debug line header in dwarf 5."
authorAli Tamur <tamur@google.com>
Tue, 26 Mar 2019 18:53:23 +0000 (18:53 +0000)
committerAli Tamur <tamur@google.com>
Tue, 26 Mar 2019 18:53:23 +0000 (18:53 +0000)
commitd42f155408bfea0ff23d2408725753c5778bf544
tree26fedf83e2b55fea0063079ac0b1eaa2b0e5d4e1
parentdca7346ad9a92ca8ef1947e1bb00b9f2c2cd0835
[llvm] Reapply "Prevent duplicate files in debug line header in dwarf 5."

Reapply rL356941 after regenerating the object file in the failing test
llvm/test/tools/llvm-objdump/embedded-source.test from source.

Original commit message:

[llvm] Prevent duplicate files in debug line header in dwarf 5.

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.

Tags: #llvm, #debug-info

Differential Revision: https://reviews.llvm.org/D59515

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357018 91177308-0d34-0410-b5e6-96231b3b80d8
14 files changed:
include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
include/llvm/MC/MCContext.h
include/llvm/MC/MCDwarf.h
lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
lib/DebugInfo/DWARF/DWARFDebugLine.cpp
lib/MC/MCContext.cpp
lib/MC/MCDwarf.cpp
test/MC/ARM/dwarf-asm-multiple-sections.s
test/MC/ELF/debug-mixed-md5.ll
test/MC/ELF/dwarf-file0.s
test/tools/llvm-objdump/Inputs/embedded-source
test/tools/llvm-objdump/X86/function-sections-line-numbers.s