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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在gdb中禁用新的线程/线程退出消息?相关的知识,希望对你有一定的参考价值。

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

[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]

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

答案

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

set print thread-events off

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

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

gdb调试多进程多线程程序

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

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

为啥 GDB 会启动一个新的 shell 以及如何禁用这种行为?

使用异步线程的退出代码退出应用程序