[DTrace-devel] [PATCH 01/16] Remove fasttrap references and introduce pid-provider variants
Kris Van Hees
kris.van.hees at oracle.com
Thu Mar 18 21:54:06 PDT 2021
Since the fasttrap provider is no longer necessary, the following
two datatypes are being renamed:
fasttrap_probe_type_t -> pid_probe_type_t
fasttrap_probe_spec_t -> pid_probe_spec_t
Obsolete header files are also cleaned up.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
include/dtrace/fasttrap.h | 54 -------------------
include/dtrace/fasttrap_ioctl.h | 18 -------
include/dtrace/pid.h | 38 ++++++++++++++
libdtrace/dt_pid.c | 56 ++++++++++----------
libdtrace/dt_pid.h | 2 +-
uts/common/sys/fasttrap.h | 24 ---------
uts/intel/sys/fasttrap_isa.h | 92 ---------------------------------
7 files changed, 66 insertions(+), 218 deletions(-)
delete mode 100644 include/dtrace/fasttrap.h
delete mode 100644 include/dtrace/fasttrap_ioctl.h
create mode 100644 include/dtrace/pid.h
delete mode 100644 uts/common/sys/fasttrap.h
delete mode 100644 uts/intel/sys/fasttrap_isa.h
diff --git a/include/dtrace/fasttrap.h b/include/dtrace/fasttrap.h
deleted file mode 100644
index 6654889a..00000000
--- a/include/dtrace/fasttrap.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed under the Universal Permissive License v 1.0 as shown at
- * http://oss.oracle.com/licenses/upl.
- *
- * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
- */
-
-/*
- * Note: The contents of this file are private to the implementation of the
- * DTrace subsystem and are subject to change at any time without notice.
- */
-
-#ifndef _DTRACE_FASTTRAP_H
-#define _DTRACE_FASTTRAP_H
-
-#include <dtrace/universal.h>
-
-typedef enum fasttrap_probe_type {
- DTFTP_NONE = 0,
- DTFTP_ENTRY,
- DTFTP_RETURN,
- DTFTP_OFFSETS,
- DTFTP_POST_OFFSETS,
- DTFTP_IS_ENABLED
-} fasttrap_probe_type_t;
-
-typedef struct fasttrap_probe_spec {
- pid_t ftps_pid; /* task PID */
- fasttrap_probe_type_t ftps_type; /* probe type */
- char ftps_func[DTRACE_FUNCNAMELEN]; /* probe function */
- char *ftps_mod; /* probe module */
- uint64_t ftps_pc; /* probe address */
- uint64_t ftps_size; /* function size (in bytes) */
- uint8_t ftps_glen; /* glob pattern length */
- char ftps_gstr[1]; /* glob pattern string */
-} fasttrap_probe_spec_t;
-
-typedef uint8_t fasttrap_instr_t;
-
-typedef struct fasttrap_instr_query {
- uint64_t ftiq_pc;
- pid_t ftiq_pid;
- fasttrap_instr_t ftiq_instr;
-} fasttrap_instr_query_t;
-
-/*
- * Include after the definitions, to get ioctl()s when fasttrap.h is included.
- * fasttrap_ioctl.h also #includes this header, to get structures when it is
- * included itself, as is done by headers_check.
- */
-
-#include <dtrace/fasttrap_ioctl.h>
-
-#endif /* _DTRACE_FASTTRAP_H */
diff --git a/include/dtrace/fasttrap_ioctl.h b/include/dtrace/fasttrap_ioctl.h
deleted file mode 100644
index be80adc3..00000000
--- a/include/dtrace/fasttrap_ioctl.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Licensed under the Universal Permissive License v 1.0 as shown at
- * http://oss.oracle.com/licenses/upl.
- *
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- */
-
-#ifndef _DTRACE_FASTRRAP_IOCTL_H_
-#define _DTRACE_FASTTRAP_IOCTL_H_
-
-#include <linux/ioctl.h>
-#include <dtrace/fasttrap.h>
-
-#define FASTTRAPIOC 0xf4
-#define FASTTRAPIOC_MAKEPROBE _IOW(FASTTRAPIOC, 1, fasttrap_probe_spec_t)
-#define FASTTRAPIOC_GETINSTR _IOR(FASTTRAPIOC, 2, fasttrap_instr_query_t)
-
-#endif /* _DTRACE_FASTTRAP_IOCTL_H_ */
diff --git a/include/dtrace/pid.h b/include/dtrace/pid.h
new file mode 100644
index 00000000..9fbc07b9
--- /dev/null
+++ b/include/dtrace/pid.h
@@ -0,0 +1,38 @@
+/*
+ * Licensed under the Universal Permissive License v 1.0 as shown at
+ * http://oss.oracle.com/licenses/upl.
+ *
+ * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ * Note: The contents of this file are private to the implementation of the
+ * DTrace subsystem and are subject to change at any time without notice.
+ */
+
+#ifndef _DTRACE_PID_H
+#define _DTRACE_PID_H
+
+#include <dtrace/universal.h>
+
+typedef enum pid_probetype {
+ DTFTP_NONE = 0,
+ DTFTP_ENTRY,
+ DTFTP_RETURN,
+ DTFTP_OFFSETS,
+ DTFTP_POST_OFFSETS,
+ DTFTP_IS_ENABLED
+} pid_probetype_t;
+
+typedef struct pid_probespec {
+ pid_t pps_pid; /* task PID */
+ pid_probetype_t pps_type; /* probe type */
+ char *pps_mod; /* probe module */
+ char pps_fun[DTRACE_FUNCNAMELEN]; /* probe function */
+ uint64_t pps_pc; /* probe address */
+ uint64_t pps_size; /* function size (in bytes) */
+ uint8_t pps_glen; /* glob pattern length */
+ char pps_gstr[1]; /* glob pattern string */
+} pid_probespec_t;
+
+#endif /* _DTRACE_PID_H */
diff --git a/libdtrace/dt_pid.c b/libdtrace/dt_pid.c
index 091108ba..4aa29a64 100644
--- a/libdtrace/dt_pid.c
+++ b/libdtrace/dt_pid.c
@@ -89,32 +89,31 @@ dt_pid_error(dtrace_hdl_t *dtp, dt_pcb_t *pcb, dt_proc_t *dpr,
static int
dt_pid_create_fbt_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
- fasttrap_probe_spec_t *ftp, const GElf_Sym *symp,
- fasttrap_probe_type_t type)
+ pid_probespec_t *psp, const GElf_Sym *symp, pid_probetype_t type)
{
- ftp->ftps_type = type;
- ftp->ftps_pc = (uintptr_t)symp->st_value;
- ftp->ftps_size = (size_t)symp->st_size;
- ftp->ftps_glen = 0; /* no glob pattern */
- ftp->ftps_gstr[0] = '\0';
+ psp->pps_type = type;
+ psp->pps_pc = (uintptr_t)symp->st_value;
+ psp->pps_size = (size_t)symp->st_size;
+ psp->pps_glen = 0; /* no glob pattern */
+ psp->pps_gstr[0] = '\0';
- /* Create a probe using 'ftp'. */
+ /* Create a probe using 'psp'. */
return 1;
}
static int
dt_pid_create_glob_offset_probes(struct ps_prochandle *P, dtrace_hdl_t *dtp,
- fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, const char *pattern)
+ pid_probespec_t *psp, const GElf_Sym *symp, const char *pattern)
{
- ftp->ftps_type = DTFTP_OFFSETS;
- ftp->ftps_pc = (uintptr_t)symp->st_value;
- ftp->ftps_size = (size_t)symp->st_size;
- ftp->ftps_glen = strlen(pattern);
+ psp->pps_type = DTFTP_OFFSETS;
+ psp->pps_pc = (uintptr_t)symp->st_value;
+ psp->pps_size = (size_t)symp->st_size;
+ psp->pps_glen = strlen(pattern);
- strncpy(ftp->ftps_gstr, pattern, ftp->ftps_glen + 1);
+ strncpy(psp->pps_gstr, pattern, psp->pps_glen + 1);
- /* Create a probe using 'ftp'. */
+ /* Create a probe using 'psp'. */
return 1;
}
@@ -125,7 +124,7 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
dtrace_hdl_t *dtp = pp->dpp_dtp;
dt_pcb_t *pcb = pp->dpp_pcb;
dt_proc_t *dpr = pp->dpp_dpr;
- fasttrap_probe_spec_t *ftp;
+ pid_probespec_t *psp;
uint64_t off;
char *end;
uint_t nmatches = 0;
@@ -143,20 +142,19 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
dt_dprintf("creating probe pid%d:%s:%s:%s at %lx\n", (int)pid,
pp->dpp_obj, func, pp->dpp_name, symp->st_value);
- sz = sizeof(fasttrap_probe_spec_t) + strlen(pp->dpp_name);
-
- if ((ftp = dt_zalloc(dtp, sz)) == NULL) {
+ sz = sizeof(pid_probespec_t) + strlen(pp->dpp_name);
+ psp = dt_zalloc(dtp, sz);
+ if (psp == NULL) {
dt_dprintf("proc_per_sym: dt_alloc(%lu) failed\n", sz);
return 1; /* errno is set for us */
}
- ftp->ftps_pid = pid;
- strcpy_safe(ftp->ftps_func, sizeof(ftp->ftps_func), func);
-
- ftp->ftps_mod = dt_pid_objname(pp->dpp_lmid, pp->dpp_obj);
+ psp->pps_pid = pid;
+ psp->pps_mod = dt_pid_objname(pp->dpp_lmid, pp->dpp_obj);
+ strcpy_safe(psp->pps_fun, sizeof(psp->pps_fun), func);
if (!isdash && gmatch("return", pp->dpp_name)) {
- if (dt_pid_create_fbt_probe(pp->dpp_pr, dtp, ftp, symp,
+ if (dt_pid_create_fbt_probe(pp->dpp_pr, dtp, psp, symp,
DTFTP_RETURN) < 0) {
rc = dt_pid_error(
dtp, pcb, dpr, D_PROC_CREATEFAIL,
@@ -169,7 +167,7 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
}
if (!isdash && gmatch("entry", pp->dpp_name)) {
- if (dt_pid_create_fbt_probe(pp->dpp_pr, dtp, ftp, symp,
+ if (dt_pid_create_fbt_probe(pp->dpp_pr, dtp, psp, symp,
DTFTP_ENTRY) < 0) {
rc = dt_pid_error(
dtp, pcb, dpr, D_PROC_CREATEFAIL,
@@ -200,7 +198,7 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
}
if (dt_pid_create_glob_offset_probes(pp->dpp_pr, pp->dpp_dtp,
- ftp, symp, pp->dpp_name) < 0) {
+ psp, symp, pp->dpp_name) < 0) {
rc = dt_pid_error(
dtp, pcb, dpr, D_PROC_CREATEFAIL,
"failed to create probes at '%s+0x%llx': %s",
@@ -212,7 +210,7 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
nmatches++;
} else if (glob && !isdash) {
if (dt_pid_create_glob_offset_probes(pp->dpp_pr, pp->dpp_dtp,
- ftp, symp, pp->dpp_name) < 0) {
+ psp, symp, pp->dpp_name) < 0) {
rc = dt_pid_error(
dtp, pcb, dpr, D_PROC_CREATEFAIL,
"failed to create offset probes in '%s': %s",
@@ -226,8 +224,8 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
pp->dpp_nmatches += nmatches;
out:
- free(ftp->ftps_mod);
- dt_free(dtp, ftp);
+ free(psp->pps_mod);
+ dt_free(dtp, psp);
return rc;
}
diff --git a/libdtrace/dt_pid.h b/libdtrace/dt_pid.h
index 67dd91af..39d6ebc9 100644
--- a/libdtrace/dt_pid.h
+++ b/libdtrace/dt_pid.h
@@ -9,7 +9,7 @@
#define _DT_PID_H
#include <libproc.h>
-#include <sys/fasttrap.h>
+#include <dtrace/pid.h>
#include <dt_impl.h>
#ifdef __cplusplus
diff --git a/uts/common/sys/fasttrap.h b/uts/common/sys/fasttrap.h
deleted file mode 100644
index 8f3ea03d..00000000
--- a/uts/common/sys/fasttrap.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
- * Licensed under the Universal Permissive License v 1.0 as shown at
- * http://oss.oracle.com/licenses/upl.
- */
-
-#ifndef _SYS_FASTTRAP_H
-#define _SYS_FASTTRAP_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/fasttrap_isa.h>
-#include <sys/dtrace.h>
-#include <sys/types.h>
-#include <dtrace/fasttrap.h>
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SYS_FASTTRAP_H */
diff --git a/uts/intel/sys/fasttrap_isa.h b/uts/intel/sys/fasttrap_isa.h
deleted file mode 100644
index 1c701364..00000000
--- a/uts/intel/sys/fasttrap_isa.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- * Licensed under the Universal Permissive License v 1.0 as shown at
- * http://oss.oracle.com/licenses/upl.
- */
-
-#ifndef _FASTTRAP_ISA_H
-#define _FASTTRAP_ISA_H
-
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define FASTTRAP_MAX_INSTR_SIZE 15
-
-#define FASTTRAP_INSTR 0xcc
-
-#define FASTTRAP_SUNWDTRACE_SIZE 64
-
-typedef struct fasttrap_machtp {
- uint8_t ftmt_instr[FASTTRAP_MAX_INSTR_SIZE]; /* orig. instr. */
- uint8_t ftmt_size; /* instruction size */
-#ifdef __amd64
- uint8_t ftmt_ripmode; /* %rip-relative handling mode */
- uint8_t ftmt_modrm; /* saved modrm byte */
-#endif
- uint8_t ftmt_type; /* emulation type */
- uint8_t ftmt_code; /* branch condition */
- uint8_t ftmt_base; /* branch base */
- uint8_t ftmt_index; /* branch index */
- uint8_t ftmt_scale; /* branch scale */
- uint8_t ftmt_segment; /* segment for memory accesses */
- uintptr_t ftmt_dest; /* destination of control flow */
-} fasttrap_machtp_t;
-
-#define ftt_instr ftt_mtp.ftmt_instr
-#ifdef __amd64
-#define ftt_ripmode ftt_mtp.ftmt_ripmode
-#define ftt_modrm ftt_mtp.ftmt_modrm
-#endif
-#define ftt_size ftt_mtp.ftmt_size
-#define ftt_type ftt_mtp.ftmt_type
-#define ftt_code ftt_mtp.ftmt_code
-#define ftt_base ftt_mtp.ftmt_base
-#define ftt_index ftt_mtp.ftmt_index
-#define ftt_scale ftt_mtp.ftmt_scale
-#define ftt_segment ftt_mtp.ftmt_segment
-#define ftt_dest ftt_mtp.ftmt_dest
-
-#define FASTTRAP_T_COMMON 0x00 /* common case -- no emulation */
-#define FASTTRAP_T_JCC 0x01 /* near and far conditional jumps */
-#define FASTTRAP_T_LOOP 0x02 /* loop instructions */
-#define FASTTRAP_T_JCXZ 0x03 /* jump if %ecx/%rcx is zero */
-#define FASTTRAP_T_JMP 0x04 /* relative jump */
-#define FASTTRAP_T_CALL 0x05 /* near call (and link) */
-#define FASTTRAP_T_RET 0x06 /* ret */
-#define FASTTRAP_T_RET16 0x07 /* ret <imm16> */
-
-/*
- * For performance rather than correctness.
- */
-#define FASTTRAP_T_PUSHL_EBP 0x10 /* pushl %ebp (for function entry) */
-#define FASTTRAP_T_NOP 0x11 /* nop */
-
-#define FASTTRAP_RIP_1 0x1
-#define FASTTRAP_RIP_2 0x2
-#define FASTTRAP_RIP_X 0x4
-
-/*
- * Segment values.
- */
-#define FASTTRAP_SEG_NONE 0
-#define FASTTRAP_SEG_CS 1
-#define FASTTRAP_SEG_DS 2
-#define FASTTRAP_SEG_ES 3
-#define FASTTRAP_SEG_FS 4
-#define FASTTRAP_SEG_GS 5
-#define FASTTRAP_SEG_SS 6
-
-#define FASTTRAP_AFRAMES 3
-#define FASTTRAP_RETURN_AFRAMES 4
-#define FASTTRAP_ENTRY_AFRAMES 3
-#define FASTTRAP_OFFSET_AFRAMES 3
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _FASTTRAP_ISA_H */
--
2.28.0
More information about the DTrace-devel
mailing list