在GDB中调试多线程程序时如何一次继续一个线程? [英] How to continue one thread at a time when debugging a multithreaded program in GDB?
问题描述
我有一个使用两个线程的程序.我在两个线程中都设置了断点.在 gdb 下运行程序时,我想在线程之间切换并使它们运行.(线程 t1 处于活动状态并正在运行,线程 t2;在断点处暂停时.我想停止 T1 运行并运行 T2).
I have a program which uses two threads. I have put the break point in both the threads. While running the program under gdb I want to switch between the threads and make them run. (thread t1 is active and running and thread t2; when paused on the breakpoint. I want to stop T1 running and run the T2).
有什么方法可以在 gdb 中调度线程吗?
Is there any way that I can schedule the threads in gdb?
推荐答案
如果您使用的是 GDB 7 或更高版本,请尝试不间断模式".
If you're using GDB 7 or later, try "non-stop mode".
http://sourceware.org/gdb/current/onlinedocs/gdb/Non_002dStop-Mode.html
前面提到的scheduler-locking on"命令允许您在其他线程停止的情况下单步执行一个线程.不间断模式允许您在其他线程处于活动状态时单步执行一个线程.
The "scheduler-locking on" command previously mentioned allows you step one thread with the others stopped. Non-stop mode allows you to step one thread with the others active.
这篇关于在GDB中调试多线程程序时如何一次继续一个线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!