From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 66856 invoked by alias); 10 Jan 2017 17:09:23 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 66839 invoked by uid 89); 10 Jan 2017 17:09:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Envelope-From:sk:philipp, deadlock, xxhdx1985126, H*f:sk:65e6915 X-HELO: mailsec114.isp.belgacom.be Received: from mailsec114.isp.belgacom.be (HELO mailsec114.isp.belgacom.be) (195.238.20.110) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Jan 2017 17:09:12 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2BMBQAAFXVY/2yb8FFdHAEBBAEBCgEBg?= =?us-ascii?q?zoBAQEBAR8hHx+BDQGDAE6KCHKRNCYBlQCCCyyFcgICAoIBQBQBAgEBAQEBAQF?= =?us-ascii?q?jKIRqAQUjMyMQCAMYAgImAgI5HgYciGsKsEWCJYoVMoELhTqEYYdOgl4FlSOGA?= =?us-ascii?q?IF7j1eQYZJeHziBPVCGLj01AQGIZAEBAQ?= X-IPAS-Result: =?us-ascii?q?A2BMBQAAFXVY/2yb8FFdHAEBBAEBCgEBgzoBAQEBAR8hHx+?= =?us-ascii?q?BDQGDAE6KCHKRNCYBlQCCCyyFcgICAoIBQBQBAgEBAQEBAQFjKIRqAQUjMyMQC?= =?us-ascii?q?AMYAgImAgI5HgYciGsKsEWCJYoVMoELhTqEYYdOgl4FlSOGAIF7j1eQYZJeHzi?= =?us-ascii?q?BPVCGLj01AQGIZAEBAQ?= Received: from 108.155-240-81.adsl-dyn.isp.belgacom.be (HELO md) ([81.240.155.108]) by relay.skynet.be with ESMTP/TLS/AES128-GCM-SHA256; 10 Jan 2017 18:09:02 +0100 Message-ID: <1484068173.14191.5.camel@skynet.be> Subject: Re: How to determine the thread holding a mutex? From: Philippe Waroquiers To: xxhdx1985126 Cc: "gdb@sourceware.org" Date: Tue, 10 Jan 2017 17:09:00 -0000 In-Reply-To: <65e6915e.b19a.15987f1923b.Coremail.xxhdx1985126@163.com> References: <65e6915e.b19a.15987f1923b.Coremail.xxhdx1985126@163.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00003.txt.bz2 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