aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/contrib')
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/amd64/kinst/tst.basic.ksh46
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h1
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c5
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c29
4 files changed, 81 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/amd64/kinst/tst.basic.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/amd64/kinst/tst.basic.ksh
new file mode 100644
index 000000000000..23019fb41f41
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/amd64/kinst/tst.basic.ksh
@@ -0,0 +1,46 @@
+#!/usr/bin/ksh
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2022 Mark Johnston <markj@FreeBSD.org>
+#
+
+script()
+{
+ $dtrace -q -s /dev/stdin <<__EOF__
+kinst::vm_fault: {}
+kinst::amd64_syscall: {}
+kinst::exit1: {}
+
+tick-10s {exit(0);}
+__EOF__
+}
+
+spin()
+{
+ while true; do
+ ls -la / >/dev/null 2>&1
+ done
+}
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+spin &
+child=$!
+
+script
+exit $?
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 f55d488f4d91..867259b5d77c 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
@@ -416,6 +416,8 @@ static const dt_ident_t _dtrace_globals[] = {
&dt_idops_func, "void(int)" },
{ "rand", DT_IDENT_FUNC, 0, DIF_SUBR_RAND, DT_ATTR_STABCMN, DT_VERS_1_0,
&dt_idops_func, "int()" },
+{ "regs", DT_IDENT_ARRAY, 0, DIF_VAR_REGS, DT_ATTR_STABCMN, DT_VERS_1_13,
+ &dt_idops_regs, NULL },
{ "rindex", DT_IDENT_FUNC, 0, DIF_SUBR_RINDEX, DT_ATTR_STABCMN, DT_VERS_1_1,
&dt_idops_func, "int(const char *, const char *, [int])" },
#ifdef illumos
@@ -1171,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;
@@ -1679,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 <dt_list.h>
#include <dt_pid.h>
#include <dtrace.h>
+#include <kinst.h>
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);
+ }
+ }
}
/*