From nobody Tue Oct 11 22:35:36 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Mn9bY0yShz4fZYH; Tue, 11 Oct 2022 22:35:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Mn9bY0BNvz3ZnQ; Tue, 11 Oct 2022 22:35:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665527737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nDnm97xKcxGU4uvZ2DyHYwKXe8qfbX8M2nrOQdsgiOY=; b=fWHa8QSRbsh3lO76g1PMF3oiDYe0xUA+bCN6cit7AY2Ydgm1LyxR+6WKlcea60J2znHXD2 WNvVfQTUr+RNuet/CrWMV94qeXYgg4qDNHirvU1+UReE6puyRYVDe22e2LlCIIwrpDdXru uSPbFOdutnpfUoX7v0LyODP9B7P1GRdiOCU6fVbTE6BKXjrUDsRW8ZpHdYYq8fssGvFDKV EFhId6k4LFwmLL5EekJZ/N8DdoUoNnjoVWaK7j+Kn5rOs/uVPfblQlQv88EptA5TcpR8hR pas7KDMqiel4aoTyP93E4BYWQNohX9D4Dh7DG85yA7OyvzYQ5tV8WD4MBVuSkA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Mn9bX6MHTz166f; Tue, 11 Oct 2022 22:35:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29BMZaY7048803; Tue, 11 Oct 2022 22:35:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29BMZavn048802; Tue, 11 Oct 2022 22:35:36 GMT (envelope-from git) Date: Tue, 11 Oct 2022 22:35:36 GMT Message-Id: <202210112235.29BMZavn048802@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 2179a159ea93 - main - libdtrace: Add kinst support List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2179a159ea93e37b7fb2126ae0b1627b875f808b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665527737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nDnm97xKcxGU4uvZ2DyHYwKXe8qfbX8M2nrOQdsgiOY=; b=Oj6wQT2YNsr5SrLC6VWLCkXIN9kus01gX+dnVyya8I7opkATsQfZVQOL6MKydSWKS95rYV wI07zGVWTxRMd+QP9Eq1eHf78QmbjmFXCp8zzghMSMr5PAF6+2eH9oPAkm8Etn39NQcYFm vLURYJGrai8URlHt2kprCPknTM+VIBWDMv2Ge8xeIwq8H5WbWI74C23TLfMNvWtmBHIOw0 xfW0bMc/ZP0+Q5A4ivfcvNgKaVis8omU1TpeMpmJFOP5jxuPCLvdfM1KuTjnxNQhPStx7l dsLpU48aLwxAVjTCFsxqcqGMiQgkzSOzo46APbmm5+W8kBd2gi6AvWnEPpTaAQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665527737; a=rsa-sha256; cv=none; b=vKYTa+OrGGkfTI444v0ULgaOXDQcHJQl79SzbrC91trvKRydIp5Rg0+F4QDutMAqzxybLc zlxCik0u4xBgP3vLnrNKhzVjQ0QwEn3weBf3/worTC9pwARa36OlaN2/OElBLGFxUX81Bp 4baimExnLLz+T1bevX8wciXi79QyLeMoOoafAN81o46gwCE9n3/D8WM+WwptllArD8IDUn 6l/5bwr7f8Y1pjSm6cpsy1gjqIlTYYFj+4LDvh2hQiJ0wYB9SH6JykDh90oH7dyGypsmHd 1a3sEeaS58oxQkzi78Kof67n6T+u194aB0FuPeL7J2WlpeXrPeawM/ENUp+fuA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2179a159ea93e37b7fb2126ae0b1627b875f808b commit 2179a159ea93e37b7fb2126ae0b1627b875f808b Author: Christos Margiolis AuthorDate: 2022-10-11 15:33:52 +0000 Commit: Mark Johnston CommitDate: 2022-10-11 22:19:08 +0000 libdtrace: Add kinst support kinst does not instantiate its probes automatically, it only does so on demand via an ioctl interface implemented by /dev/kinst. This change modifies libdtrace to perform that work when the script references the kinst provider, similar to the way pid provider probes are implemented. Reviewed by: markj MFC after: 3 months Sponsored by: Google, Inc. (GSoC 2022) Differential Revision: https://reviews.freebsd.org/D36852 --- .../opensolaris/lib/libdtrace/common/dt_impl.h | 1 + .../opensolaris/lib/libdtrace/common/dt_open.c | 3 +++ .../opensolaris/lib/libdtrace/common/dt_provider.c | 29 ++++++++++++++++++++++ cddl/lib/libdtrace/Makefile | 1 + 4 files changed, 34 insertions(+) diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h index b3f69bb6329d..1e62bd6b21db 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h @@ -323,6 +323,7 @@ struct dtrace_hdl { #endif int dt_fd; /* file descriptor for dtrace pseudo-device */ int dt_ftfd; /* file descriptor for fasttrap pseudo-device */ + int dt_kinstfd; /* file descriptor for kinst pseudo-device */ int dt_fterr; /* saved errno from failed open of dt_ftfd */ int dt_cdefs_fd; /* file descriptor for C CTF debugging cache */ int dt_ddefs_fd; /* file descriptor for D CTF debugging cache */ diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c index 9621a0fcb391..867259b5d77c 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c @@ -1173,6 +1173,7 @@ alloc: dtp->dt_version = version; dtp->dt_fd = dtfd; dtp->dt_ftfd = ftfd; + dtp->dt_kinstfd = -1; dtp->dt_fterr = fterr; dtp->dt_cdefs_fd = -1; dtp->dt_ddefs_fd = -1; @@ -1681,6 +1682,8 @@ dtrace_close(dtrace_hdl_t *dtp) (void) close(dtp->dt_fd); if (dtp->dt_ftfd != -1) (void) close(dtp->dt_ftfd); + if (dtp->dt_kinstfd != -1) + (void) close(dtp->dt_kinstfd); if (dtp->dt_cdefs_fd != -1) (void) close(dtp->dt_cdefs_fd); if (dtp->dt_ddefs_fd != -1) diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c index 7cf352d4d505..2391690afc0b 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c @@ -48,6 +48,7 @@ #include #include #include +#include static dt_provider_t * dt_provider_insert(dtrace_hdl_t *dtp, dt_provider_t *pvp, uint_t h) @@ -699,6 +700,34 @@ dt_probe_info(dtrace_hdl_t *dtp, prp = idp->di_data; else if (pdp->dtpd_id != DTRACE_IDNONE) prp = dt_probe_discover(pvp, pdp); + + if (strcmp(pvp->pv_desc.dtvd_name, "kinst") == 0) { + dtrace_kinst_probedesc_t pd; + + if (dtp->dt_kinstfd == -1) { + int fd; + + fd = open("/dev/dtrace/kinst", O_WRONLY); + if (fd < 0) { + (void) dt_set_errno(dtp, errno); + return (NULL); + } + dtp->dt_kinstfd = fd; + } + memset(&pd, 0, sizeof(pd)); + strlcpy(pd.kpd_func, pdp->dtpd_func, + sizeof (pd.kpd_func)); + + if (n_is_glob) + pd.kpd_off = -1; + else + pd.kpd_off = strtol(pdp->dtpd_name, NULL, 10); + if (ioctl(dtp->dt_kinstfd, KINSTIOC_MAKEPROBE, &pd) != + 0) { + (void) dt_set_errno(dtp, errno); + return (NULL); + } + } } /* diff --git a/cddl/lib/libdtrace/Makefile b/cddl/lib/libdtrace/Makefile index f95517f10ebb..651609409a3a 100644 --- a/cddl/lib/libdtrace/Makefile +++ b/cddl/lib/libdtrace/Makefile @@ -84,6 +84,7 @@ CFLAGS+= -DHAVE_ISSETUGID CFLAGS+= -I${.OBJDIR} -I${.CURDIR} \ -I${SRCTOP}/sys/cddl/dev/dtrace/${MACHINE_ARCH} \ + -I${SRCTOP}/sys/cddl/dev/kinst \ -I${SRCTOP}/sys/cddl/compat/opensolaris \ -I${SRCTOP}/cddl/compat/opensolaris/include \ -I${OPENSOLARIS_USR_DISTDIR}/head \