Linux 调试期间是否可以停止单个线程?
我想知道的是,是否有可能在 Linux 的调试会话中(读:gdb :))停止单个线程的执行,而让其他线程运行。
如果有人想知道为什么继续阅读: 我编写了一个软件看门狗 C++ 类(使用 Qt)。我使用一个简单的多线程程序对其进行了测试,但我也想在将其集成到实际应用程序中后对其进行测试。如果我可以停止调试器中的线程,这将简化此测试阶段。 :)
干杯 塞尔吉奥
What I'd like to know is if it is possible, inside a debugging session in Linux, (read: gdb :)) to stop the execution of a single thread, leaving the other threads to run.
If someone is curious to know why keep reading:
I wrote a software watchdog C++ class (using Qt). I tested it with a simple multithreaded program, but I'd like to test the code once I integrate it inside the real application as well. If I could stop a thread from the debugger, that will simplify this testing phase. :)
Cheers
Sergio
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在运行或附加到程序之前使用以下命令序列:
启用异步接口:
set target-async 1
如果使用 CLI,分页会不停地中断:
设置分页关闭
打开它:
设置不间断
使用这些命令来操作不间断模式设置:
启用不间断模式选择:
设置不停止
禁止选择不停止模式:
设置不停机关闭
显示当前不间断启用设置:
显示不间断
参考文献:
http://sourceware.org/gdb/onlinedocs/gdb/Non_002dStop -Mode.html#Non_002dStop-Mode
Use this sequence of commands before you run or attach to your program:
Enable the async interface:
set target-async 1
If using the CLI, pagination breaks non-stop:
set pagination off
Turn it on:
set non-stop on
Use these commands to manipulate the non-stop mode setting:
Enable selection of non-stop mode:
set non-stop on
Disable selection of non-stop mode:
set non-stop off
Show the current non-stop enabled setting:
show non-stop
References:
http://sourceware.org/gdb/onlinedocs/gdb/Non_002dStop-Mode.html#Non_002dStop-Mode
如果这个小变化没问题,您可以向线程发送一个 STOP 信号(不是作为 gdb 命令 - 该变化)并调试其他正在运行的所有内容。信号 CONT 让线程继续。
If that little variation is OK, you could send the thread a STOP signal (not as a gdb command the gdb - that the variation) and debug everything else running. Signal CONT lets the thread continue.
您可以使用totalview调试器来做到这一点
You may use totalview debugger to do that