Printing full backtrace in c++

对着背影说爱祢 提交于 2019-12-09 16:26:29

问题


I want to dump a backtrace from a C++ program in Linux in a similar format as it is done in gdb. I tried to use the backtrace() and backtrace_symbols() functions for this purpose. These returned function names and offsets. I can use the __cxa_demangle() function to get a readable function name.

Is there any way to get the file/line positions too, as it is done by gdb?


回答1:


How it's better to invoke gdb from program to print its stacktrace?`

Methode #4, shows a way to get filename and line. But uses a extern program..



来源:https://stackoverflow.com/questions/7979043/printing-full-backtrace-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!