c++ - 如何将 gdb 的完整堆栈跟踪传输到文件?

标签 c++ multithreading debugging gdb stack-trace

当我的服务陷入僵局时,我正在尝试获取堆栈跟踪。 我正在使用

gdb <binary> core.dump
gdb> set logging on
gdb> thread apply all bt full
... Here now i have to keep pressing ENTER till i get to end of all the thread trace. It takes around 5 mins for me to get all these traces? 

有什么技巧可以在单个命令中获取所有线程的堆栈跟踪以通过管道传输到文件?

最佳答案

你应该像这样关闭长输出的分页:

$ gdb <binary> core.dump
(gdb) set logging on
(gdb) set pagination off
(gdb) thread apply all bt full

请参阅 gdb 常见问题解答和文档:

关于c++ - 如何将 gdb 的完整堆栈跟踪传输到文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26805197/

相关文章:

c++ - 我可以使用转换将构造(或分配) move 到不同类型值的 map 吗?

c++ - 对模板类成员的 undefined reference

c++ - 为什么 ValGrind 找不到我的符号?

c++ - 在 C++ 中复制带有流的文件

c++ - 与 std::inserter 相比,std::back_inserter 有什么好处?

multithreading - 如何为每个线程自动全局初始化/取消初始化某些内容?

c++ - g++ - 为什么在使用 std::thread 时必须传递 "-pthread"选项?

使用剪贴板的 C# 多线程应用程序

c# - 调试版本和发布版本之间的性能差异

c++ - 调试串行轮询的方法