From owner-svn-src-all@freebsd.org Tue Dec 6 04:28:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73C55C69C00; Tue, 6 Dec 2016 04:28:57 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 43285D8E; Tue, 6 Dec 2016 04:28:57 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uB64SuoR068071; Tue, 6 Dec 2016 04:28:56 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uB64Su1x068070; Tue, 6 Dec 2016 04:28:56 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201612060428.uB64Su1x068070@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 6 Dec 2016 04:28:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309599 - head/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2016 04:28:57 -0000 Author: markj Date: Tue Dec 6 04:28:56 2016 New Revision: 309599 URL: https://svnweb.freebsd.org/changeset/base/309599 Log: libdtrace: Don't use a read-only handle for enumerating pid probes. Enumeration of return probes involves disassembling subroutines in the target process, and ptrace(2) is currently used to read from the target process. libproc could read from the backing file instead to avoid this problem, but in the common case libdtrace will have a writeable handle on the process anyway. In particular, a writeable handle is needed to list USDT probes, and libdtrace will cache such a handle for processes that it controls via dtrace -c and -p. Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c Tue Dec 6 04:23:32 2016 (r309598) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c Tue Dec 6 04:28:56 2016 (r309599) @@ -729,8 +729,13 @@ dt_pid_create_probes(dtrace_probedesc_t (void) snprintf(provname, sizeof (provname), "pid%d", (int)pid); if (gmatch(provname, pdp->dtpd_provider) != 0) { +#ifdef __FreeBSD__ + if ((P = dt_proc_grab(dtp, pid, 0, 1)) == NULL) +#else if ((P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE, - 0)) == NULL) { + 0)) == NULL) +#endif + { (void) dt_pid_error(dtp, pcb, NULL, NULL, D_PROC_GRAB, "failed to grab process %d", (int)pid); return (-1);