This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How to determine the thread holding a mutex?
- From: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- To: xxhdx1985126 <xxhdx1985126 at 163 dot com>
- Cc: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Tue, 10 Jan 2017 18:09:33 +0100
- Subject: Re: How to determine the thread holding a mutex?
- Authentication-results: sourceware.org; auth=none
- References: <65e6915e.b19a.15987f1923b.Coremail.xxhdx1985126@163.com>
On Tue, 2017-01-10 at 18:34 +0800, xxhdx1985126 wrote:
> Hi, everyone.
>
> I'm trying to debug a problem that appears to be a deadlock. I wonder
> if I can use gdb to find out which thread is holding a mutex.
> If so, my work would be much easier, as there are many threads in my program.
What you can do is to use valgrind --tool=helgrind
to first see if valgrind helgrind tool does not point at a possible
culprit for the deadlock.
Assuming helgrind does not explain the bug, and assuming that the
deadlock reproduces under valgrind/helgrind,
you can use the valgrind gdbserver monitor command 'info locks'
to obtain the list of locks
See
http://www.valgrind.org/docs/manual/hg-manual.html#hg-manual.monitor-commands
and
http://www.valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver
for more information.
Philippe