From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23099 invoked by alias); 11 Apr 2008 22:55:19 -0000 Received: (qmail 23090 invoked by uid 22791); 11 Apr 2008 22:55:19 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 11 Apr 2008 22:54:51 +0000 Received: (qmail 27601 invoked from network); 11 Apr 2008 22:54:49 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Apr 2008 22:54:49 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [patch] Fix Linux attach to signalled/stopped processes Date: Sat, 12 Apr 2008 00:02:00 -0000 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) Cc: Daniel Jacobowitz , Roland McGrath , Jan Kratochvil , Doug Evans , mark.kettenis@xs4all.nl References: <200804112300.38076.pedro@codesourcery.com> <20080411221958.GA21910@caradoc.them.org> In-Reply-To: <20080411221958.GA21910@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200804112354.49254.pedro@codesourcery.com> 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: 2008-04/txt/msg00231.txt.bz2 A Friday 11 April 2008 23:19:58, Daniel Jacobowitz wrote: > On Fri, Apr 11, 2008 at 11:00:37PM +0100, Pedro Alves wrote: > > =A0> + =A0/* Pass on the last signal, if appropriate. =A0*/ > > > > > + =A0if (lp->status =3D=3D 0 && GET_LWP (lp->ptid) =3D=3D GET_LWP (in= ferior_ptid) > > > + =A0 =A0 =A0&& stop_signal !=3D TARGET_SIGNAL_0 && signal_pass_state > > > (stop_signal)) + =A0 =A0lp->status =3D W_STOPCODE (target_signal_to_h= ost > > > (stop_signal)); > > > > You're writing to lp->status of inferior_ptid, which isn't garantied > > to be the main thread or the thread that got the last signal (user > > may have used the "thread" command to switch threads, or we're stopped > > at a breakpoint in some other thread not the main one, for example, or > > the kernel decided to send the signal to some other thread because the > > main one was already stopped?). > > I want the ptid associated with the global variable stop_signal. It's > deliberately not the ptid of the main thread but I hadn't thought > about the thread command. Ok, but the last lwp in detach_command is always the main lwp, not inferior_ptid, even if the user doesn't use the "thread" command. That is, this is the main thread: >+ =A0/* Pass on any pending signal for the last LWP. =A0*/ >+ =A0status =3D lwp_list->status; but back in detach_callback, if the inferior_ptid's lwp is not the main thread, you're writing the lp->status to an lwp that is going to be deleted right afterwards: /* We don't actually detach from the LWP that has an id equal to the overall process id just yet. */ if (GET_LWP (lp->ptid) !=3D GET_PID (lp->ptid)) { (...) delete_lwp (lp->ptid); } > Is that variable context-switched (or should it be)? Not currently. One of my non-stop patches makes it so. Currently, in all-stop mode, if the user switches threads after getting a signal, when resuming, GDB will pass the signal to the current thread, not the one that got it in the first place... > Any idea how to do this?=20=20 Not really. I'm don't think we can context-switch stop_signal in all-stop mode. At least not without more work in infrun.c. I'd have to think and try a bit more. My current patch leaves it global in all-stop mode. Maybe you just need a event_ptid, similar to trap_ptid, or just resend the signal to the main thread. --=20 Pedro Alves