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
*
* 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);
*
* 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
* 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
*
*
* 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
*
*
* 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
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;