使用GDB挂起线程的命令 [英] command to suspend a thread with GDB

查看:401
本文介绍了使用GDB挂起线程的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对GDB有点陌生.我希望有人可以帮助我完成一些非常简单的事情,我曾经使用过Google/docs,但我只是想念一些东西.

I'm a little new to GDB. I'm hoping someone can help me with something that should be quite simple, I've used Google/docs but I'm just missing something.

人们使用GDB调试线程化应用程序的正常"方式是什么?我正在使用pthreads.我只想看一个线程-我看到的两个选项是

What is the 'normal' way folks debug threaded apps with GDB? I'm using pthreads. I'm wanting to watch only one thread - the two options I see are

a)告诉调试器以某种方式连接到特定线程,这样单步执行不会导致每个上下文切换上的线程跳动

a) tell the debugger somehow to attach to a particular thread, such that stepping wont result in jumping threads on each context switch

b)告诉调试器暂停/释放任何无趣的"线程

b) tell the debugger to suspend/free any 'uninteresting' threads

我更喜欢走路线b)-阅读有关GDB的帮助,提示,我没有看到命令,

I'd prefer to go route b) - reading the help for GDB I dont see a command for this, tips?

推荐答案

请参见set scheduler-locking on的文档.

当心:如果您暂停其他线程,并且其中一个线程持有锁,并且如果您的有趣的线程在步进时需要某个时间锁,那么您将死锁.

Beware: if you suspend other threads, and if one of them holds a lock, and if your interesting thread needs that lock at some point while stepping, you'll deadlock.

人们调试线程应用程序的正常"方式是什么

What is the 'normal' way folks debug threaded apps

您永远无法调试线程的正确性,只能对其进行设计.根据我的经验,大多数调试线程应用程序的过程是放入断言,并在违反其中一个断言时检查世界状况.

You can never debug thread correctness, you can only design it in. In my experience, most of debugging of threaded apps is putting in assertions, and examining state of the world when one of the assertions is violated.

这篇关于使用GDB挂起线程的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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