From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23634 invoked by alias); 16 Jul 2012 19:08:56 -0000 Received: (qmail 23616 invoked by uid 22791); 16 Jul 2012 19:08:54 -0000 X-SWARE-Spam-Status: No, hits=-4.0 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from imr3.ericy.com (HELO imr3.ericy.com) (198.24.6.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 16 Jul 2012 19:08:41 +0000 Received: from eusaamw0707.eamcs.ericsson.se ([147.117.20.32]) by imr3.ericy.com (8.13.8/8.13.8) with ESMTP id q6GJ8buh000763 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Mon, 16 Jul 2012 14:08:39 -0500 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.11]) by eusaamw0707.eamcs.ericsson.se ([147.117.20.32]) with mapi; Mon, 16 Jul 2012 15:08:38 -0400 From: Marc Khouzam To: "'Pedro Alves'" CC: "'gdb-patches@sourceware.org'" Date: Mon, 16 Jul 2012 19:08:00 -0000 Subject: RE: [Patch] Broken multi-process detach Message-ID: References: <50044E25.70301@redhat.com> In-Reply-To: <50044E25.70301@redhat.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-07/txt/msg00219.txt.bz2 > -----Original Message----- > From: Pedro Alves [mailto:palves@redhat.com]=20 > Sent: Monday, July 16, 2012 1:24 PM > To: Marc Khouzam > Cc: 'gdb-patches@sourceware.org' > Subject: Re: [Patch] Broken multi-process detach >=20 > On 07/16/2012 02:54 PM, Marc Khouzam wrote: > > Hi, > >=20 > > Detaching from an inferior in multi-process is broken. > > The problem seems to be that in linux_nat.c:linux_nat_detach() > > GDB first unregisters from the event loop by calling=20 > > linux_nat_async (NULL, 0). In multi-process, further > > events received from running inferiors are missed; breakpoint > > hits are not reported, interrupting a thread is not reported, > > and so on. See below for a broken session example. > >=20 > > We could remove the call to linux_nat_async (NULL, 0) but I didn't > > know if that would have bad side-effects. Here is the patch that > > does that, if it is felt that is the correct solution. >=20 > I'm not thinking of any. Looks like I added it in the first > async mode version of linux-nat.c (which was much rewritten > later on). Let's remove it. >=20 > Remove also the target_async call below: >=20 > if (forks_exist_p ()) > { > /* Multi-fork case. The current inferior_ptid is being detached > from, but there are other viable forks to debug. Detach from > the current fork, and context-switch to the first > available. */ > linux_fork_detach (args, from_tty); >=20 > if (non_stop && target_can_async_p ()) > target_async (inferior_event_handler, 0); >=20 >=20 > as this was re-installing the target on the event loop if there were > other checkpoints (checkpoint/info checkpoint) to debug. It is now > unnecessary if we don't unregister from the event loop in the=20 > first place. >=20 > >=20 > > The testsuite hangs on HEAD so I wasn't able to run it yet. > > But I'll do so once it works again. >=20 > It doesn't hang for me. I've tested the patch on x86_64=20 > Fedora 17, both > sync and async modes. No regressions. Thanks for the help! I checked-in the following: 2012-07-16 Marc Khouzam Pedro Alves * linux-nat.c (linux_nat_detach): Don't unregister from the event loop. ### Eclipse Workspace Patch 1.0 #P src Index: gdb/linux-nat.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/linux-nat.c,v retrieving revision 1.254 diff -u -r1.254 linux-nat.c --- gdb/linux-nat.c 7 Jul 2012 12:13:56 -0000 1.254 +++ gdb/linux-nat.c 16 Jul 2012 19:04:03 -0000 @@ -1848,8 +1848,8 @@ =20 pid =3D GET_PID (inferior_ptid); =20 - if (target_can_async_p ()) - linux_nat_async (NULL, 0); + /* Don't unregister from the event loop, as there may be other + inferiors running. */ =20 /* Stop all threads before detaching. ptrace requires that the thread is stopped to sucessfully detach. */ @@ -1892,9 +1892,6 @@ the current fork, and context-switch to the first available. */ linux_fork_detach (args, from_tty); - - if (non_stop && target_can_async_p ()) - target_async (inferior_event_handler, 0); } else linux_ops->to_detach (ops, args, from_tty);