3 ms·
The main pain point for me in that domain currently is the wrong results that backtrace() gives when optimizations are enabled. I noticed that clang seems to b
by mabynogy 9y ago
The main pain point for me in that domain currently is the wrong results that backtrace() gives when optimizations are enabled.
I noticed that clang seems to be better at generating correct infos in such modes.
Otherwise I use GDB in "batch mode" to get a callstack triggered by raise(SIGTRAP):
> gdb -quiet --batch -ex run -ex backtrace --args $binary $@
- loeg 9y agobacktrace(3) doesn't use or understand DWARF debug information at all — it's purely a machine stack (doesn't understand tail calls or inlined functions) and can only look up ELF symbols. It's better than nothing, but consider using something like libunwind instead.
- mabynogy 9y agoMany thanks. I'll check it. The ultimate goal is to get a backtrace without debug symbol (in release) but I don't know any method to achieve that without instrumentation.
- loeg 9y agoYou need some debug information to get accurate backtraces. But you can discard the rest of the debug information that you don't need. The article actually mentions this a little bit near the end, starting around: > For example, if you would only like accurate unwinding then you can retain only .debug_frame and .debug_line.