How to get a stack trace for C++ using gcc with line number information?

后端 未结 14 2007
长发绾君心
长发绾君心 2020-11-27 09:54

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

14条回答
  •  無奈伤痛
    2020-11-27 10:57

    Use the google glog library for it. It has new BSD licence.

    It contains a GetStackTrace function in the stacktrace.h file.

    EDIT

    I found here http://blog.bigpixel.ro/2010/09/09/stack-unwinding-stack-trace-with-gcc/ that there is an utility called addr2line that translates program addresses into file names and line numbers.

    http://linuxcommand.org/man_pages/addr2line1.html

提交回复
热议问题