From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21508 invoked by alias); 23 Sep 2006 17:37:28 -0000 Received: (qmail 21500 invoked by uid 22791); 23 Sep 2006 17:37:28 -0000 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 23 Sep 2006 17:37:26 +0000 Received: from elgar.sibelius.xs4all.nl (root@elgar.sibelius.xs4all.nl [192.168.0.2]) by sibelius.xs4all.nl (8.13.4/8.13.4) with ESMTP id k8NHacd4017096; Sat, 23 Sep 2006 19:36:38 +0200 (CEST) Received: from elgar.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.13.8/8.13.6) with ESMTP id k8NHac76021838; Sat, 23 Sep 2006 19:36:38 +0200 (CEST) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.13.8/8.13.8/Submit) id k8NHabVs010214; Sat, 23 Sep 2006 19:36:37 +0200 (CEST) Date: Sat, 23 Sep 2006 17:37:00 -0000 Message-Id: <200609231736.k8NHabVs010214@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: jan.kratochvil@redhat.com CC: drow@false.org, gdb-patches@sourceware.org In-reply-to: <20060918095331.GA9299@host0.dyn.jankratochvil.net> (message from Jan Kratochvil on Mon, 18 Sep 2006 11:53:31 +0200) Subject: Re: [patch] Fix attaching to Linux stopped processes References: <20060917221228.GA17263@host0.dyn.jankratochvil.net> <20060917222622.GA2150@nevyn.them.org> <20060918095331.GA9299@host0.dyn.jankratochvil.net> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-09/txt/msg00162.txt.bz2 > Date: Mon, 18 Sep 2006 11:53:31 +0200 > From: Jan Kratochvil > > > So I checked. Sure enough, on my 2.6.18-rc4 > > installation, this is _not_ what happens. Instead, the traditional > > thing happens: wait hangs and no new event is returned. > > > > Is this new in kernel.org? Or is it a Red Hat kernel patch? Where > > did it come from? > > Thanks for checking it. > OK, the patch was originally for GDB on Red Hat "kernel-2.6.17-1.2647.fc6". > > Still it is reproducible even on both linux-2.6.17.13 and linux-2.6.18-rc4, you > just need to "kill -CONT $pid" the inferior as gdb(1) will hang during > attaching to it. Screenshot (sorry for graphics): > http://www.jankratochvil.net/priv/gdb.png > gdb is built from the current clean CVS snapshot. > > Also the patch looks right to me - after `PT_ATTACH' it is appropriate that > `WSTOPSIG (status)' will report the original signal that stopped process, > (WSTOPSIG (status) == SIGSTOP) <=> (process was in running/sleeping mode). Whoa stop, the status returned by wait(2) doesn't tell you whether a process is sleeping or running. Traditionally, after invoking ptrace(PT_ATTACH, ...) the kernel will always respond with a SIGSTOP. Any information about any previous signals is lost. This all smells like a race condition in the kernel to me. The linux-nat.c code is quite hairy already. I'd suggest fixing the kernel rather than adding more workarounds. Mark