mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 10:48:02 +00:00
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
This commit is contained in:
parent
f0bc4ed144
commit
2179a159ea
|
@ -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 */
|
||||
|
|
|
@ -1173,6 +1173,7 @@ dt_vopen(int version, int flags, int *errp,
|
|||
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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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 \
|
||||
|
|
Loading…
Reference in a new issue