[PATCH] D59515: Prevent duplicate files in debug line header in dwarf 5.

Ali Tamur via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 18 15:22:16 PDT 2019


tamur created this revision.
Herald added subscribers: llvm-commits, jdoerfert, rupprecht, MaskRay, hiraditya, arichardson, javed.absar, aprantl, nhaehnle, jvesely, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59515

Files:
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCDwarf.h
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDwarf.cpp
  llvm/test/CodeGen/AMDGPU/flat-error-unsupported-gpu-hsa.ll
  llvm/test/MC/ARM/dwarf-asm-multiple-sections.s
  llvm/test/MC/ELF/debug-mixed-md5.ll
  llvm/test/MC/ELF/dwarf-file0.s
  llvm/test/tools/llvm-objdump/Inputs/embedded-source
  llvm/test/tools/llvm-objdump/X86/function-sections-line-numbers.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59515.191187.patch
Type: text/x-patch
Size: 15254 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190318/01b89198/attachment.bin>


More information about the llvm-commits mailing list