From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 7 11:59:46 2013 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 9236C202; Thu, 7 Mar 2013 11:59:46 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id A230D3E0; Thu, 7 Mar 2013 11:59:45 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id NAA17964; Thu, 07 Mar 2013 13:59:43 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1UDZU7-0009rf-09; Thu, 07 Mar 2013 13:59:43 +0200 Message-ID: <5138812D.5060304@FreeBSD.org> Date: Thu, 07 Mar 2013 13:59:41 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130220 Thunderbird/17.0.3 MIME-Version: 1.0 To: freebsd-hackers@FreeBSD.org Subject: dtrace -c patch X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=X-VIET-VPS Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Mar 2013 11:59:46 -0000 $ dtrace -n 'blah blah' -c 'touch /' dtrace: failed to control pid 16473: process exited with status 0 I think that we need the following change: --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c @@ -1115,7 +1115,7 @@ alloc: #if defined(sun) dtp->dt_prcmode = DT_PROC_STOP_PREINIT; #else - dtp->dt_prcmode = DT_PROC_STOP_MAIN; + dtp->dt_prcmode = DT_PROC_STOP_POSTINIT; #endif dtp->dt_linkmode = DT_LINK_KERNEL; dtp->dt_linktype = DT_LTYP_ELF; Rationale: - we don't use DT_PROC_STOP_PREINIT like solaris does, because for some reason that I haven't investigated we the following line ifdef-ed out in dt_proc_attach: dt_proc_rdwatch(dpr, RD_PREINIT, "RD_PREINIT"); - 'main' symbol can't always be reliably resolved: $ readelf -a -W /usr/bin/touch | fgrep main $ So, it seems that "postinit" is where we can reliable catch a process. What do you think? -- Andriy Gapon