在c ++中打印完整的backtrace [英] Printing full backtrace in c++

查看:332
本文介绍了在c ++中打印完整的backtrace的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个C ++程序在Linux中转储一个类似于gdb中的格式的回溯。我试图使用backtrace()和backtrace_symbols()函数为此目的。这些返回的函数名和偏移量。我可以使用__cxa_demangle()函数来获取可读的函数名。

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.

有没有办法获取文件/行位置,就像gdb做的?

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

推荐答案

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

Methode#4,显示了获取文件名和行的方法。但使用extern程序..

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

这篇关于在c ++中打印完整的backtrace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆