From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10764 invoked by alias); 27 Jun 2007 06:52:36 -0000 Received: (qmail 10750 invoked by uid 22791); 27 Jun 2007 06:52:35 -0000 X-Spam-Check-By: sourceware.org Received: from pauline.vellum.cz (HELO pauline.vellum.cz) (89.250.243.234) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 27 Jun 2007 06:52:28 +0000 Received: from host0.dyn.jankratochvil.net (localhost.localdomain [127.0.0.1]) by pauline.vellum.cz (8.12.11.20060308/8.12.11) with ESMTP id l5R6q49Z011275; Wed, 27 Jun 2007 08:52:24 +0200 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.1/8.13.8) with ESMTP id l5R6q4OU009573; Wed, 27 Jun 2007 08:52:04 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.1/8.14.1/Submit) id l5R6q3Np009572; Wed, 27 Jun 2007 08:52:03 +0200 Date: Wed, 27 Jun 2007 11:59:00 -0000 From: Jan Kratochvil To: Mark Kettenis Cc: gdb-patches@sourceware.org Subject: Re: [patch] Fix Linux attach to signalled/stopped processes Message-ID: <20070627065203.GA9427@host0.dyn.jankratochvil.net> References: <20070606143432.GA11555@host0.dyn.jankratochvil.net> <200706151801.l5FI1xH6022843@brahms.sibelius.xs4all.nl> <20070626210341.GA1406@host0.dyn.jankratochvil.net> <200706262254.l5QMsrPn007445@brahms.sibelius.xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200706262254.l5QMsrPn007445@brahms.sibelius.xs4all.nl> User-Agent: Mutt/1.5.14 (2007-02-12) 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: 2007-06/txt/msg00479.txt.bz2 On Wed, 27 Jun 2007 00:54:54 +0200, Mark Kettenis wrote: ... > This is what I get on OpenBSD: > > $ ./ptrace-test > .assertion "!WIFSIGNALED (status)" failed: file "ptrace-test.c", line 122, function "main" > Abort trap (core dumped) > > This is sort of odd, Thanks for the test - it is now confirmed the code is not crossplatform and different hacks may be needed on different ptrace(2)-using OSes. OK, going to move it to linux-nat.c. > but then your test program has a serious problem. > It doesn't wait(2) after ptrace(PT_ATTACH, ...). That's asking for trouble. It does wait(2) right after a preventive `PT_CONT (SIGSTOP)' as otherwise wait(2) would hang if the original process was already stopped ... > > How does currently GDB behave there while attaching to a SIGSTOPped process? > > I don't think it matters whether the process is stopped or not. ... the same way the current GDB hangs. SIGSTOP is already delivered before and the new SIGSTOP from PTRACE_ATTACH does not stack as SIGSTOP is already active. If the original SIGSTOP was already wait(2)ed by the pre-ptrace(2) parent the new ptrace(2)-parent (the debugger) will not get the new SIGSTOP caught and thus wait(2) hangs for it. [ Info originally from Roland McGrath. ] Regards, Jan