Currently we rely on the dynamic symbol table to generate stack traces.
This only works with exported functions of an executable (i.e. visibility=default) and requires the -L--export-dynamic argument.
One alternative would be to use DWARF instead. It would also allow to get line numbers, but is only available in debug builds.
A better compromise might be to provide MiniDebugInfo which is a compressed symbol table in .gnu_debugdata.
https://sourceware.org/gdb/onlinedocs/gdb/MiniDebugInfo.html
related:
bug 1001 - print stack trace (in debug mode) when program die
C++ DWARF backtrace library https://github.com/bombela/backward-cpp
I've just pushed an implementation for resolving addresses to lines using DWARFv2/3 debug info that uses no external dependencies.
The implementation is not suitable for druntime, but it can be used as a guide.
https://github.com/yazd/elf-d
Comment #3 by code — 2014-08-01T21:30:56Z
Great, this looks really interesting.
It shouldn't be too hard to make a traceHandler out of this.
*** Issue 7454 has been marked as a duplicate of this issue. ***
Comment #6 by yazan.dabain — 2016-09-28T17:04:10Z
I don't think this should be closed. The implementation only provides file and line information. Function names are still extracted using `backtrace_symbols` which, AFAIR, need `--export-dynamic`.
BTW, the reason that the implementation is not @nogc is `core.demangle.demangle` function only.
Comment #7 by pro.mathias.lang — 2020-05-03T19:21:53Z
Yep, this is not fixed, we still rely on backtrace_symbols, and the whole backtrace code in druntime is quite lacking.
Comment #8 by robert.schadek — 2024-12-07T13:33:17Z