*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#define _FASTTRAP_IMPL_H
/*
- * #pragma ident "@(#)fasttrap_impl.h 1.12 06/06/12 SMI"
+ * #pragma ident "@(#)fasttrap_impl.h 1.14 08/04/09 SMI"
*/
#include <sys/types.h>
#include <sys/fasttrap.h>
#include <sys/fasttrap_isa.h>
-#define proc_t struct proc
+/* Solaris proc_t is the struct. Darwin's proc_t is a pointer to it. */
+#define proc_t struct proc /* Steer clear of the Darwin typedef for proc_t */
#ifdef __cplusplus
extern "C" {
* providers. Those providers are each represented by a fasttrap_provider_t.
* All providers for a given process have a pointer to a shared
* fasttrap_proc_t. The fasttrap_proc_t has two states: active or defunct.
- * It becomes defunct when the process performs an exit or an exec.
+ * When the count of active providers goes to zero it becomes defunct; a
+ * provider drops its active count when it is removed individually or as part
+ * of a mass removal when a process exits or performs an exec.
*
* Each probe is represented by a fasttrap_probe_t which has a pointer to
* its associated provider as well as a list of fasttrap_id_tp_t structures
* and it contains two lists of fasttrap_id_t structures (to be fired pre-
* and post-instruction emulation) that identify the probes attached to the
* tracepoint. Tracepoints also have a pointer to the fasttrap_proc_t for the
- * process they trace which is used when looking up a tracepoint both at
- * probe fire time and when enabling and disabling probes.
+ * process they trace which is used when looking up a tracepoint both when a
+ * probe fires and when enabling and disabling probes.
*
* It's important to note that probes are preallocated with the necessary
* number of tracepoints, but that tracepoints can be shared by probes and
typedef struct fasttrap_proc {
pid_t ftpc_pid; /* process ID for this proc */
- uint_t ftpc_defunct; /* denotes a lame duck proc */
- uint64_t ftpc_count; /* reference count */
- lck_mtx_t ftpc_mtx; /* proc lock */
+ uint64_t ftpc_acount; /* count of active providers */
+ uint64_t ftpc_rcount; /* count of extant providers */
+ lck_mtx_t ftpc_mtx; /* lock on all but acount */
struct fasttrap_proc *ftpc_next; /* next proc in hash chain */
} fasttrap_proc_t;
#define fasttrap_fuword32 fuword32
#define fasttrap_suword32 suword32
-#if defined __APPLE__
/*
- * xnu runs in 32 bit mode even when supporting 64 bit processes. We need
- * to make size explicit.
+ * APPLE NOTE: xnu supports both 32bit and 64bit user processes.
+ * We need to make size explicit.
*/
#define fasttrap_fuword64 fuword64
#define fasttrap_suword64 suword64
#define fasttrap_fuword64_noerr fuword64_noerr
#define fasttrap_fuword32_noerr fuword32_noerr
-#else
-#define fasttrap_fulword fulword
-#define fasttrap_sulword sulword
-#endif
extern void fasttrap_sigtrap(proc_t *, uthread_t, user_addr_t);
extern int fasttrap_tracepoint_install(proc_t *, fasttrap_tracepoint_t *);
extern int fasttrap_tracepoint_remove(proc_t *, fasttrap_tracepoint_t *);
-#if defined (__ppc__) || defined (__ppc64__)
-extern int fasttrap_pid_probe(ppc_saved_state_t *regs);
-extern int fasttrap_return_probe(ppc_saved_state_t* regs);
-#elif defined (__i386__) || defined(__x86_64__)
+#if defined(__x86_64__)
extern int fasttrap_pid_probe(x86_saved_state_t *regs);
extern int fasttrap_return_probe(x86_saved_state_t* regs);
#else