在linux中,如何在gdb中找到哪个线程处于挂起状态?

时间:2010-11-05 04:12:40

标签: linux multithreading debugging gdb backtrace

我有一个多线程程序,在linux上运行~200个线程,我知道它很多。好吧,这是遗产程序:) 这个程序在2.6.29上运行debian OS 我怎样才能轻松找出哪个线程的堆栈帧包含functionA? 我正在使用“thread apply all bt”来显示所有线程的回溯。但是,我需要检查每个堆栈帧以找到包含functionA的正确线程。

谢谢你! questionchild

1 个答案:

答案 0 :(得分:2)

您可以将线程应用所有bt 的输出保存到日志文件中,然后grep或以其他方式检查。此外,禁用分页也很有用。

[root@localhost ~]# gdb
GNU gdb (GDB) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) set logging on
(gdb) set pagination off
(gdb) thread apply all bt