GDB调试多线程及死锁

参考文章:http://www.cnblogs.com/zhuyp1015/p/3618863.html

我在这里总结一下:

查看正在执行的所有线程

info threads

切换到指定线程

thread ID //这里的ID是info threads后各线程前面的序号

break thread_test.c:123 thread all //在所有线程中相应的行上设置断点

thread apply all command //让所有被调试线程执行GDB命令command

thread apply ID1 ID2 command //让一个或者多个线程执行GDB命令command

调试死锁流程

打开core文件生成

ulimit -c unlimited

编程源程序加 -g 选项

查看进程号

ps aux | grep a.out

终止进程

kill -11 进程id

查看core文件信息

gdb a.out core


thread apply all bt

然后可以看到线程的栈信息了,显示了各个线程执行到了哪一个函数,是哪一行的函数导致了死锁。

猜你喜欢

转载自blog.csdn.net/lyh__521/article/details/50848751