From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18474 invoked by alias); 16 Jul 2012 13:54:38 -0000 Received: (qmail 18464 invoked by uid 22791); 16 Jul 2012 13:54:36 -0000 X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from imr4.ericy.com (HELO imr4.ericy.com) (198.24.6.9) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 16 Jul 2012 13:54:19 +0000 Received: from eusaamw0711.eamcs.ericsson.se ([147.117.20.178]) by imr4.ericy.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id q6GDsFNi016476 for ; Mon, 16 Jul 2012 08:54:18 -0500 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.11]) by eusaamw0711.eamcs.ericsson.se ([147.117.20.178]) with mapi; Mon, 16 Jul 2012 09:54:16 -0400 From: Marc Khouzam To: "'gdb-patches@sourceware.org'" Date: Mon, 16 Jul 2012 13:54:00 -0000 Subject: [Patch] Broken multi-process detach Message-ID: 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/msg00211.txt.bz2 Hi, 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. 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. The testsuite hangs on HEAD so I wasn't able to run it yet. But I'll do so once it works again. Thanks Marc 2012-07-16 Marc Khouzam * 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 12:44:38 -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. */ Broken session: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > gdb.7.5 GNU gdb (GDB) 7.4.50.20120714-cvs =3D=3D> set non-stop and start two inferiors [...] (gdb) inf thread Id Target Id Frame=20 2 process 23634 (running) * 1 process 23629 main () at loopfirst.noprint.cc:5 (gdb) detach Detaching from program: /home/lmckhou/testing/loopfirst.noprint, process 23= 629 (gdb) inf thread Id Target Id Frame=20 2 process 23634 (running) No selected thread. See `help thread'. (gdb) thread 2 [Switching to thread 2 (process 23634)](running) =3D> interrupt the running thread (gdb) interrupt (gdb) inf thread Id Target Id Frame=20 * 2 process 23634 (running) =3D> event not received, thread still marked running (gdb) c Continuing. Cannot execute this command while the selected thread is running.