From owner-freebsd-current@FreeBSD.ORG Tue May 11 03:07:28 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 586F0106564A for ; Tue, 11 May 2010 03:07:28 +0000 (UTC) (envelope-from widawsky@gmail.com) Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.221.181]) by mx1.freebsd.org (Postfix) with ESMTP id 123388FC0C for ; Tue, 11 May 2010 03:07:27 +0000 (UTC) Received: by qyk11 with SMTP id 11so6647576qyk.13 for ; Mon, 10 May 2010 20:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=gCSHI3r0F9PFnAyRsUVaOyiWSEMxsETR9WQonOktAOY=; b=XwbV7ZE2xzv3w+wP1Ax4/434HHP4Fju90vnjXSUzrYsRvdP/rQpTXleI/Q1VlEMRjs sJ1y5Hhpbd3kGyUTNjXF2ICA/OzQ2Xm+Oro+155lnb1waI6kstaFsD5UBF2lv18DQoZE /Ic+BFsT3JRMTUyv/lEjCW5qvdh7Kwh47xNpg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=JOghkpUCyyHlOtlW28uopbYlmNYAvJwKEKYNXT2CJ1FnjkXL+I5ASWcUb7+U9ezif4 /8X4Bcw53iN1tm2w23sHDWfCa6aWOtHqAuRqOoj0Jeygm8f+dwuuo6SreDsAgM/MEe0Q 4uCbt7YnM3V5ax8ucKaVGvUQNuUv6U7uT/Nyk= MIME-Version: 1.0 Received: by 10.224.73.27 with SMTP id o27mr3326381qaj.177.1273547247242; Mon, 10 May 2010 20:07:27 -0700 (PDT) Received: by 10.224.67.84 with HTTP; Mon, 10 May 2010 20:07:27 -0700 (PDT) In-Reply-To: <20100508135031.00fcd71e@ernst.jennejohn.org> References: <20100508135031.00fcd71e@ernst.jennejohn.org> Date: Mon, 10 May 2010 20:07:27 -0700 Message-ID: From: Ben Widawsky To: gljennjohn@googlemail.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-current@freebsd.org Subject: Re: PT_ATTACH resumes suspended process X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2010 03:07:28 -0000 > Looking at the sendsig label in sys_process.c:kern_ptrace() makes it clea= r > what's happening - in your testing the process was already stopped so > the code sets td_xsig to SIGSTOP and wakes it up to send it the signal. > > But td_xsig doesn't seem to be used anywhere to set pending signals. =A0M= aybe > I missed the place where that happens. > > The assumption seems to be that a process being traced will only be > stopped if the debugger is already attached and that any signals being > sent to it are coming from the debugger itself. > > This assumption is wrong if the process being attached to was already > stopped. > > It seems to me that checking for req =3D=3D PT_ATTACH when the process is > already stopped and doing a break; in that case might be a solution. Could you be more specific? It seems to me even if you had a special case i= n kern_ptrace to handle PT_ATTACH when the process is suspended, the code wou= ld end up being almost identical to ptracestop(). Unless I didn't follow you. Because of this, I think what I suggested initially, esentially resuming th= e thread with a pending SIGSTOP (by checking the value of xsig when the threa= d switches back in issignal) would be a better approach. The hack I put in bo= thers me a bit because some of the other threads may resume, and even run for a w= hile, but it's still better than the existing behavior.