www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20510] New: Make backtrace code read the dSYM data

https://issues.dlang.org/show_bug.cgi?id=20510

          Issue ID: 20510
           Summary: Make backtrace code read the dSYM data
           Product: D
           Version: D2
          Hardware: All
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

Currently, on Mac OSX, the linker will strip debug informations to speed up
linkage and reduce binary size. Links to the object files are created, and can
be read by the debugger. It's also possible to create a .dSYM bundle to
distribute alongside the binary.

This leads to the unfortunate consequence that the backtrace code in Druntime,
which relies on the `.debug_lines` DWARF section, will not print file/line
information in a stack trace, even when compiled with `-g`.

There are workarounds for this:
- DMD preserves the `__debug_line` by marking it as a regular section:
https://github.com/dlang/dmd/commit/2bf7d0db29416eacbb01a91e6502140e354ee0ef
- LDC does the same, but had to patch LLVM for that:
https://github.com/ldc-developers/llvm-project/commit/110deda1bc1cf195983fea8c1107886057987955

However, this is a hack and has drawbacks. DMD emits fairly poor debug
informations but will show file/line on Exceptions stack traces on OSX, while
LDC emits proper information but has to be linked against a patched LLVM.

The requirement for a patched LLVM might throw off packagers, e.g. the Homebrew
package of LDC does *not* link against that custom LLVM, hence the workaround
does not work: https://github.com/ldc-developers/ldc/issues/3280

What would be best, long term, would be for Druntime to read the same `.dSym`
data.

--
Jan 16