www.digitalmars.com         C & C++   DMDScript  

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


          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:
- LDC does the same, but had to patch LLVM for that:

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`

Jan 16 2020