Stack trace for C++ using gcc

Posted by dimba on Stack Overflow See other posts from Stack Overflow or by dimba
Published on 2011-01-08T22:15:56Z Indexed on 2011/01/08 22:54 UTC
Read the original article Hit count: 294

Filed under:
|
|

We use stack traces in proprietary assert like macro to catch developer mistakes - when error is caught, stack trace is printed.

I find gcc's pair backtrace()/backtrace_symbols() methods insufficient:

  1. Names are mangled
  2. No line information

1st problem can be resolved by abi::__cxa_demangle.

However 2nd problem s more tough. I found replacement for backtrace_symbols(). This is better than gcc's backtrace_symbols(), since it can retrieve line numbers (if compiled with -g) and you don't need to compile with -rdynamic.

Hoverer the code is GNU licenced, so IMHO I can't use it in commercial code.

Any proposals?

© Stack Overflow or respective owner

Related posts about c++

Related posts about gcc