X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/743345f9a4b36f7e2f9ba37691e70c50baecb56e..d190cdc3f5544636abb56dc1874be391d3e1b148:/bsd/sys/dtrace.h?ds=sidebyside diff --git a/bsd/sys/dtrace.h b/bsd/sys/dtrace.h index ede1f7ac3..b44140030 100644 --- a/bsd/sys/dtrace.h +++ b/bsd/sys/dtrace.h @@ -1042,14 +1042,21 @@ typedef struct dtrace_actdesc { int dtad_refcnt; /* reference count */ } dtrace_actdesc_t; + typedef struct dtrace_ecbdesc { dtrace_actdesc_t *dted_action; /* action description(s) */ dtrace_preddesc_t dted_pred; /* predicate description */ dtrace_probedesc_t dted_probe; /* probe description */ uint64_t dted_uarg; /* library argument */ int dted_refcnt; /* reference count */ + uint64_t dted_probegen; /* matched probe generation */ } dtrace_ecbdesc_t; +/* + * APPLE NOTE: The kernel always rebuild dtrace_ecbdesc structures + * coming from userspace, so there is no dted_probegen manipulation risk + */ + /* * DTrace Metadata Description Structures * @@ -2326,8 +2333,8 @@ extern void dtrace_probe(dtrace_id_t, uint64_t arg0, uint64_t arg1, * a meta provider. This structure consists of the following members: * * dtms_create_probe() <-- Add a new probe to a created provider - * dtms_provide_pid() <-- Create a new provider for a given process - * dtms_remove_pid() <-- Remove a previously created provider + * dtms_provide_proc() <-- Create a new provider for a given process + * dtms_remove_proc() <-- Remove a previously created provider * * 1.2 void dtms_create_probe(void *arg, void *parg, * dtrace_helper_probedesc_t *probedesc); @@ -2341,7 +2348,7 @@ extern void dtrace_probe(dtrace_id_t, uint64_t arg0, uint64_t arg1, * * The first argument is the cookie as passed to dtrace_meta_register(). * The second argument is the provider cookie for the associated provider; - * this is obtained from the return value of dtms_provide_pid(). The third + * this is obtained from the return value of dtms_provide_proc(). The third * argument is the helper probe description. * * 1.2.3 Return value @@ -2357,8 +2364,8 @@ extern void dtrace_probe(dtrace_id_t, uint64_t arg0, uint64_t arg1, * such that the provider may (and is expected to) call provider-related * DTrace provider APIs including dtrace_probe_create(). * - * 1.3 void *dtms_provide_pid(void *arg, dtrace_meta_provider_t *mprov, - * pid_t pid) + * 1.3 void *dtms_provide_proc(void *arg, dtrace_meta_provider_t *mprov, + * proc_t *proc) * * 1.3.1 Overview * @@ -2384,15 +2391,15 @@ extern void dtrace_probe(dtrace_id_t, uint64_t arg0, uint64_t arg1, * * 1.3.4 Caller's context * - * dtms_provide_pid() is called from either ioctl() or module load context. + * dtms_provide_proc() is called from either ioctl() or module load context. * The DTrace framework is locked in such a way that meta providers may not * register or unregister. This means that the meta provider cannot call * dtrace_meta_register() or dtrace_meta_unregister(). However, the context * is such that the provider may -- and is expected to -- call * provider-related DTrace provider APIs including dtrace_register(). * - * 1.4 void dtms_remove_pid(void *arg, dtrace_meta_provider_t *mprov, - * pid_t pid) + * 1.4 void dtms_remove_proc(void *arg, dtrace_meta_provider_t *mprov, + * proc_t proc) * * 1.4.1 Overview * @@ -2415,7 +2422,7 @@ extern void dtrace_probe(dtrace_id_t, uint64_t arg0, uint64_t arg1, * * 1.4.4 Caller's context * - * dtms_remove_pid() is called from either ioctl() or exit() context. + * dtms_remove_proc() is called from either ioctl() or exit() context. * The DTrace framework is locked in such a way that meta providers may not * register or unregister. This means that the meta provider cannot call * dtrace_meta_register() or dtrace_meta_unregister(). However, the context @@ -2448,10 +2455,18 @@ typedef struct dtrace_helper_provdesc { dtrace_pattr_t dthpv_pattr; /* stability attributes */ } dtrace_helper_provdesc_t; +/* + * APPLE NOTE: dtms_provide_pid and dtms_remove_pid are replaced with + * dtms_provide_proc on Darwin, and a proc reference need to be held + * for the duration of the call. + * + * This is due to the fact that proc_find is not re-entrant on Darwin. + */ + typedef struct dtrace_mops { void (*dtms_create_probe)(void *, void *, dtrace_helper_probedesc_t *); - void *(*dtms_provide_pid)(void *, dtrace_helper_provdesc_t *, pid_t); - void (*dtms_remove_pid)(void *, dtrace_helper_provdesc_t *, pid_t); + void *(*dtms_provide_proc)(void *, dtrace_helper_provdesc_t *, proc_t*); + void (*dtms_remove_proc)(void *, dtrace_helper_provdesc_t *, proc_t*); char* (*dtms_provider_name)(void *); } dtrace_mops_t;