How to determine the thread holding a mutex?
Philippe Waroquiers
philippe.waroquiers@skynet.be
Tue Jan 10 17:09:00 GMT 2017
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
More information about the Gdb
mailing list