Re: How to determine the thread holding a mutex?

Philippe Waroquiers <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.