Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/dev/dtrace/dtrace_test.c
Show All 29 Lines | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/conf.h> | #include <sys/conf.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/sdt.h> | #include <sys/sdt.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/time.h> | |||||
#include <sys/vnode.h> | #include <sys/vnode.h> | ||||
SDT_PROVIDER_DEFINE(test); | SDT_PROVIDER_DEFINE(test); | ||||
SDT_PROBE_DEFINE7(test, , , sdttest, "int", "int", "int", "int", "int", | SDT_PROBE_DEFINE7(test, , , sdttest, "int", "int", "int", "int", "int", | ||||
"int", "int"); | "int", "int"); | ||||
/* | /* | ||||
Show All 24 Lines | dtrace_test_sdttest(SYSCTL_HANDLER_ARGS) | ||||
else if (val == 0) | else if (val == 0) | ||||
return (0); | return (0); | ||||
SDT_PROBE7(test, , , sdttest, 1, 2, 3, 4, 5, 6, 7); | SDT_PROBE7(test, , , sdttest, 1, 2, 3, 4, 5, 6, 7); | ||||
return (error); | return (error); | ||||
} | } | ||||
static __always_inline void | |||||
kinst_test_inline(void) | |||||
{ | |||||
struct timeval tv; | |||||
size_t len; | |||||
/* | |||||
* TODO Modify the code so that the function is splitted into multiple | |||||
* DW_AT_ranges. | |||||
*/ | |||||
christos: @markj do you have a good idea for this? | |||||
len = sizeof(struct timeval); | |||||
if (kernel_sysctlbyname(curthread, "kern.boottime", &tv, &len, | |||||
NULL, 0, NULL, 0) != 0) | |||||
return; | |||||
} | |||||
static __noinline void | |||||
kinst_test_fbtconvert(void) | |||||
{ | |||||
struct timeval tv; | |||||
size_t len; | |||||
len = sizeof(struct timeval); | |||||
(void) kernel_sysctlbyname(curthread, "kern.boottime", &tv, &len, | |||||
NULL, 0, NULL, 0); | |||||
} | |||||
static int | |||||
kinst_test(SYSCTL_HANDLER_ARGS) | |||||
{ | |||||
int val, error; | |||||
val = 0; | |||||
error = sysctl_handle_int(oidp, &val, 0, req); | |||||
if (error || req->newptr == NULL) | |||||
return (error); | |||||
switch (val) { | |||||
case 1: | |||||
kinst_test_inline(); | |||||
break; | |||||
case 2: | |||||
kinst_test_fbtconvert(); | |||||
break; | |||||
default: | |||||
return (0); | |||||
} | |||||
return (error); | |||||
} | |||||
static SYSCTL_NODE(_debug, OID_AUTO, dtracetest, | static SYSCTL_NODE(_debug, OID_AUTO, dtracetest, | ||||
CTLFLAG_RD | CTLFLAG_MPSAFE, 0, | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, | ||||
""); | ""); | ||||
SYSCTL_PROC(_debug_dtracetest, OID_AUTO, sdttest, | SYSCTL_PROC(_debug_dtracetest, OID_AUTO, sdttest, | ||||
CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, dtrace_test_sdttest, | CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, dtrace_test_sdttest, | ||||
"I", "Trigger the SDT test probe"); | "I", "Trigger the SDT test probe"); | ||||
SYSCTL_PROC(_debug_dtracetest, OID_AUTO, kinst, | |||||
CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, kinst_test, | |||||
"I", "Trigger the kinst test functions"); | |||||
static int | static int | ||||
dtrace_test_modevent(module_t mod, int type, void *data) | dtrace_test_modevent(module_t mod, int type, void *data) | ||||
{ | { | ||||
int error = 0; | int error = 0; | ||||
switch (type) { | switch (type) { | ||||
case MOD_LOAD: | case MOD_LOAD: | ||||
Show All 19 Lines |
@markj do you have a good idea for this?