From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28408 invoked by alias); 18 Sep 2006 09:53:58 -0000 Received: (qmail 28203 invoked by uid 22791); 18 Sep 2006 09:53:55 -0000 X-Spam-Check-By: sourceware.org Received: from 195.22.55.53.adsl.nextra.cz (HELO host0.dyn.jankratochvil.net) (195.22.55.53) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 18 Sep 2006 09:53:48 +0000 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.13.8/8.13.8) with ESMTP id k8I9rWZR009557; Mon, 18 Sep 2006 11:53:32 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.13.8/8.13.8/Submit) id k8I9rW6P009556; Mon, 18 Sep 2006 11:53:32 +0200 Date: Mon, 18 Sep 2006 09:53:00 -0000 From: Jan Kratochvil To: Daniel Jacobowitz Cc: gdb-patches@sourceware.org Subject: Re: [patch] Fix attaching to Linux stopped processes Message-ID: <20060918095331.GA9299@host0.dyn.jankratochvil.net> References: <20060917221228.GA17263@host0.dyn.jankratochvil.net> <20060917222622.GA2150@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060917222622.GA2150@nevyn.them.org> User-Agent: Mutt/1.4.2.2i X-IsSubscribed: yes 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/msg00096.txt.bz2 On Mon, 18 Sep 2006 00:26:22 +0200, Daniel Jacobowitz wrote: > On Mon, Sep 18, 2006 at 12:12:28AM +0200, Jan Kratochvil wrote: > > Hi, > > > > sleep 1h& pid=$!; kill -STOP $pid; gdb sleep $pid > > -> > > Attaching to program: /bin/sleep, process 20768 > > ../../gdb/linux-nat.c:1057: internal-error: linux_nat_attach: Assertion `pid == GET_PID (inferior_ptid) && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP' failed. > > > + /* Do not check `WSTOPSIG (status) == SIGSTOP' as the status may be > > + arbitrary - depending on the signal that stopped the processes. > > + If the process was running we get SIGSTOP, if it was already stopped > > + by SIGSTOP we get 0. The value gets used for `PTRACE_CONT'. */ > > 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). Regards, Jan