如何禁用 gdb 中的新线程/线程退出消息?

Posted

技术标签:

【中文标题】如何禁用 gdb 中的新线程/线程退出消息?【英文标题】:How can I disable new thread/thread exited messages in gdb? 【发布时间】:2012-06-11 19:56:22 【问题描述】:

我正在调试一个应用程序,我收到很多这样的消息:

[New Thread 0x7fffde152700 (LWP 11142)]
[Thread 0x7fffde152700 (LWP 11142) exited]
[New Thread 0x7fff967fa700 (LWP 11143)]
[Thread 0x7fff967fa700 (LWP 11143) exited]
[New Thread 0x7fff967fa700 (LWP 11144)]
[Thread 0x7fff967fa700 (LWP 11144) exited]
[New Thread 0x7fff967fa700 (LWP 11145)]
[Thread 0x7fff967fa700 (LWP 11145) exited]
[New Thread 0x7fffde152700 (LWP 11146)]
[Thread 0x7fffde152700 (LWP 11146) exited]
[New Thread 0x7fffde152700 (LWP 11147)]
[Thread 0x7fffde152700 (LWP 11147) exited]
[New Thread 0x7fffde152700 (LWP 11148)]
[Thread 0x7fffde152700 (LWP 11148) exited]
[New Thread 0x7fffde152700 (LWP 11149)]
[Thread 0x7fffde152700 (LWP 11149) exited]
[New Thread 0x7fffde152700 (LWP 11150)]
[Thread 0x7fffde152700 (LWP 11150) exited]
[New Thread 0x7fffde152700 (LWP 11151)]
[Thread 0x7fffde152700 (LWP 11151) exited]
[New Thread 0x7fffde152700 (LWP 11152)]
[Thread 0x7fffde152700 (LWP 11152) exited]
[New Thread 0x7fffde152700 (LWP 11153)]
[Thread 0x7fffde152700 (LWP 11153) exited]
[New Thread 0x7fffde152700 (LWP 11154)]
[Thread 0x7fffde152700 (LWP 11154) exited]
[New Thread 0x7fff967fa700 (LWP 11155)]
[Thread 0x7fff967fa700 (LWP 11155) exited]
[New Thread 0x7fffde152700 (LWP 11156)]
[Thread 0x7fffde152700 (LWP 11156) exited]
[New Thread 0x7fffde152700 (LWP 11157)]
[Thread 0x7fffde152700 (LWP 11157) exited]

我几乎从不对此消息感兴趣。它们使阅读其余输出变得更加困难。它们可以改变程序的计时行为,从而难以重现和调试竞态危害。如何禁用这些消息?

【问题讨论】:

【参考方案1】:

您可以在运行 gdb 时关闭线程事件:

set print thread-events off

【讨论】:

提示:将此添加到 ~/.gdbinit 以使其在每个 gdb 会话中自动发生。

以上是关于如何禁用 gdb 中的新线程/线程退出消息?的主要内容,如果未能解决你的问题,请参考以下文章

如何修复 OpenMP 程序的 gdb 运行中的线程数

如何修复自定义消息框以在父 python pyqt5 的新线程中工作

如何在GDB中调试多线程程序时一次继续一个线程?

在linux上使用gdb调试核心转储时如何知道线程的状态?

gdb:在多线程程序中调用函数而不进行线程

在调试输出窗口中禁用噪音消息 - Visual Studio 2012