在GDB中调试多线程程序时,如何一次继续一个线程? [英] How to continue one thread at a time when debugging a multithreaded program in GDB?

查看:73
本文介绍了在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屋!

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