在Linux中调试期间是否可以停止单个线程? [英] Is it possible to stop a single thread during debug in Linux?

查看:63
本文介绍了在Linux中调试期间是否可以停止单个线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道的是,是否有可能在Linux的调试会话中(阅读:gdb :))停止单个线程的执行,而让其他线程继续运行.

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.

如果有人想知道为什么继续阅读:我写了一个软件看门狗C ++类(使用Qt).我使用一个简单的多线程程序对其进行了测试,但是一旦将其集成到实际应用程序中,我也想对其进行测试.如果我可以停止调试器中的线程,那将简化此测试阶段.:)

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. :)

欢呼塞尔吉奥

推荐答案

在运行或附加到程序之前,请使用以下命令序列:

Use this sequence of commands before you run or attach to your program:

  • 启用异步接口:
    设置target-async 1

  • Enable the async interface:
    set target-async 1

如果使用CLI,则分页会不停地中断:
取消分页

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

参考文献:
http://sourceware.org/gdb/onlinedocs/gdb/Non_002dStop-Mode.html#Non_002d停止模式

这篇关于在Linux中调试期间是否可以停止单个线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆