Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Apr 2006 22:04:58 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 95835 for review
Message-ID:  <200604212204.k3LM4wKn024601@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=95835

Change 95835 by jb@jb_freebsd2 on 2006/04/21 22:04:33

	Move all my hacks out of here so that this file resembles what it
	will look like long-term.
	
	Sun tests their code with gcc, but they musn't use strict warning
	levels like we do. I had to add a lot of function prototypes to
	satisfy gcc.
	
	There are also a few functions where I had to remove the 'const'
	on some arguments passed because the values got passed from one
	function to another and eventually ended up with a cast that
	tried to ignore the const-ness of the value. In out compile, gcc
	warns about this. What is the point of declaring something
	const if you are going to cast it to remove the const-ness later?!

Affected files ...

.. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace.c#7 edit

Differences ...

==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace.c#7 (text+ko) ====

@@ -46,6 +46,7 @@
 #include <sys/systm.h>
 #include <sys/bus.h>
 #include <sys/conf.h>
+#include <sys/cpuvar.h>
 #include <sys/fcntl.h>
 #include <sys/filio.h>
 #include <sys/kernel.h>
@@ -58,22 +59,15 @@
 #include <sys/poll.h>
 #include <sys/proc.h>
 #include <sys/selinfo.h>
+#include <sys/smp.h>
 #include <sys/sysctl.h>
 #include <sys/uio.h>
 #include <sys/unistd.h>
 #include <machine/stdarg.h>
 
+#include <contrib/opensolaris/uts/common/sys/vmem.h>
 #include <contrib/opensolaris/uts/common/sys/dtrace_impl.h>
-
-/* For compatibility with Solaris code. */
-typedef struct mtx		kmutex_t;
-#define	mutex_enter(_a)		mtx_lock(_a)
-#define	mutex_exit(_a)		mtx_unlock(_a)
-#define KM_SLEEP		M_WAITOK
-#define KM_NOSLEEP		M_NOWAIT
-#define kmem_zalloc(_a,_b)	malloc(_a, M_DTRACE, _b | M_ZERO)
-#define kmem_alloc(_a,_b)	malloc(_a, M_DTRACE, _b)
-#define kmem_free(_a,_b)	free(_a, M_DTRACE)
+#include <cddl/dev/dtrace/dtrace_hacks.h>
 
 #define DTRACE_MINOR	0
 
@@ -159,26 +153,26 @@
  * well-known, zero-filled memory.  While this variable is not documented,
  * it is used by some translators as an implementation detail.
  */
-#ifdef DOODAD
 const char	dtrace_zero[256] = { 0 };	/* zero-filled memory */
-#endif
 
 /*
  * DTrace Internal Variables
  */
 #ifdef DOODAD
 static dev_info_t	*dtrace_devi;		/* device info */
+#endif
 static vmem_t		*dtrace_arena;		/* probe ID arena */
 static vmem_t		*dtrace_minor;		/* minor number arena */
 static taskq_t		*dtrace_taskq;		/* task queue */
-#endif
 static dtrace_probe_t	**dtrace_probes;	/* array of all probes */
 static int		dtrace_nprobes;		/* number of probes */
 static dtrace_provider_t *dtrace_provider;	/* provider list */
 static dtrace_meta_t	*dtrace_meta_pid;	/* user-land meta provider */
 static int		dtrace_opens;		/* number of opens */
 static int		dtrace_helpers;		/* number of helpers */
+#ifdef DOODAD
 static void		*dtrace_softstate;	/* softstate pointer */
+#endif
 static dtrace_hash_t	*dtrace_bymod;		/* probes hashed by module */
 static dtrace_hash_t	*dtrace_byfunc;		/* probes hashed by function */
 static dtrace_hash_t	*dtrace_byname;		/* probes hashed by name */
@@ -186,13 +180,9 @@
 static int		dtrace_toxranges;	/* number of toxic ranges */
 static int		dtrace_toxranges_max;	/* size of toxic range array */
 static dtrace_anon_t	dtrace_anon;		/* anonymous enabling */
-#ifdef DOODAD
 static kmem_cache_t	*dtrace_state_cache;	/* cache for dynamic state */
-#endif
 static uint64_t		dtrace_vtime_references; /* number of vtimestamp refs */
-#ifdef DOODAD
 static kthread_t	*dtrace_panicked;	/* panicking thread */
-#endif
 static dtrace_ecb_t	*dtrace_ecb_create_cache; /* cached created ECB */
 static dtrace_genid_t	dtrace_probegen;	/* current probe generation */
 static dtrace_helpers_t *dtrace_deferred_pid;	/* deferred helper list */
@@ -354,7 +344,6 @@
 #define	DTRACE_STORE(type, tomax, offset, what) \
 	*((type *)((uintptr_t)(tomax) + (uintptr_t)offset)) = (type)(what);
 
-#ifdef DOODAD
 #ifndef __i386
 #define	DTRACE_ALIGNCHECK(addr, size, flags)				\
 	if (addr & (size - 1)) {					\
@@ -408,7 +397,6 @@
 #else
 #define	dtrace_loadptr	dtrace_load32
 #endif
-#endif
 
 #define	DTRACE_DYNHASH_FREE	0
 #define	DTRACE_DYNHASH_SINK	1
@@ -434,59 +422,87 @@
 	((act)->dta_kind == DTRACEACT_DIFEXPR &&			\
 	(act)->dta_difo->dtdo_rtype.dtdt_kind == DIF_TYPE_STRING)
 
-#ifdef DOODAD
-static dtrace_helpers_t *dtrace_helpers_create(proc_t *);
-#endif
-
-dtrace_state_t * dtrace_state_create(dev_t *, cred_t *);
+dtrace_dynvar_t *dtrace_dynvar(dtrace_dstate_t *, uint_t, dtrace_key_t *, size_t, dtrace_dynvar_op_t);
+dtrace_state_t *dtrace_state_create(dev_t *, cred_t *);
 int dtrace_dstate_init(dtrace_dstate_t *, size_t);
 static char *dtrace_strdup(const char *);
-static dof_hdr_t * dtrace_dof_copyin(uintptr_t, int *);
+static dof_hdr_t *dtrace_dof_copyin(uintptr_t, int *);
+static dof_hdr_t *dtrace_dof_create(dtrace_state_t *);
 static dof_hdr_t *dtrace_dof_property(const char *);
 static dof_sec_t *dtrace_dof_sect(dof_hdr_t *, uint32_t, dof_secidx_t);
 static dtrace_action_t *dtrace_ecb_aggregation_create(dtrace_ecb_t *, dtrace_actdesc_t *);
+static dtrace_aggregation_t *dtrace_aggid2agg(dtrace_state_t *, dtrace_aggid_t);
 static dtrace_buffer_t *dtrace_speculation_buffer(dtrace_state_t *, processorid_t, dtrace_specid_t);
 static dtrace_ecb_t *dtrace_ecb_add(dtrace_state_t *, dtrace_probe_t *);
 static dtrace_ecb_t *dtrace_ecb_create(dtrace_state_t *, dtrace_probe_t *, dtrace_enabling_t *);
+static dtrace_ecb_t *dtrace_epid2ecb(dtrace_state_t *, dtrace_epid_t);
 static dtrace_ecbdesc_t *dtrace_dof_ecbdesc(dof_hdr_t *, dof_sec_t *, dtrace_vstate_t *, cred_t *);
 static dtrace_enabling_t *dtrace_enabling_create(dtrace_vstate_t *);
 static dtrace_hash_t *dtrace_hash_create(uintptr_t, uintptr_t, uintptr_t);
+static dtrace_helpers_t *dtrace_helpers_create(proc_t *);
 static dtrace_predicate_t *dtrace_predicate_create(dtrace_difo_t *);
 static dtrace_probe_t *dtrace_hash_lookup(dtrace_hash_t *, dtrace_probe_t *);
 static dtrace_probe_t *dtrace_probe_lookup_id(dtrace_id_t);
 static dtrace_state_t *dtrace_anon_grab(void);
 static int dtrace_badattr(const dtrace_attribute_t *);
 static int dtrace_badname(const char *);
+static int dtrace_bcmp(const void *, const void *, size_t);
+static int dtrace_canstore(uint64_t, size_t, dtrace_mstate_t *, dtrace_vstate_t *);
+static int dtrace_canstore_statvar(uint64_t, size_t, dtrace_statvar_t **, int);
 static int dtrace_dof_options(dof_hdr_t *, dtrace_state_t *);
 static int dtrace_dof_relocate(dof_hdr_t *, dof_sec_t *, uint64_t);
 static int dtrace_dof_slurp(dof_hdr_t *, dtrace_vstate_t *, cred_t *, dtrace_enabling_t **, uint64_t, int);
 static int dtrace_ecb_action_add(dtrace_ecb_t *, dtrace_actdesc_t *);
 static int dtrace_ecb_create_enable(dtrace_probe_t *, void *);
 static int dtrace_enabling_match(dtrace_enabling_t *, int *);
+static int dtrace_enabling_matchstate(dtrace_state_t *, int *);
+static int dtrace_enabling_replicate(dtrace_state_t *, dtrace_probedesc_t *, dtrace_probedesc_t *);
 static int dtrace_enabling_retain(dtrace_enabling_t *);
 static int dtrace_hash_collisions(dtrace_hash_t *, dtrace_probe_t *);
 static int dtrace_helper_destroygen(int);
 static int dtrace_helper_slurp(dof_hdr_t *, dof_helper_t *);
 static int dtrace_helper_validate(dtrace_helper_action_t *);
+static int dtrace_inscratch(uintptr_t, size_t, dtrace_mstate_t *);
+static int dtrace_istoxic(uintptr_t, size_t);
 static int dtrace_match(const dtrace_probekey_t *, uint32_t, uid_t, zoneid_t, int (*)(dtrace_probe_t *, void *), void *);
 static int dtrace_match_priv(const dtrace_probe_t *, uint32_t, uid_t, zoneid_t);
 static int dtrace_match_probe(const dtrace_probe_t *, const dtrace_probekey_t *, uint32_t, uid_t, zoneid_t);
 static int dtrace_match_string(const char *, const char *, int);
-static int dtrace_probe_enable(const dtrace_probedesc_t *, dtrace_enabling_t *);
+static int dtrace_priv_kernel_destructive(dtrace_state_t *);
+static int dtrace_priv_proc_common_nocd(void);
+static int dtrace_priv_proc_control(dtrace_state_t *);
+static int dtrace_priv_proc_destructive(dtrace_state_t *);
+static int dtrace_probe_enable(dtrace_probedesc_t *, dtrace_enabling_t *);
 static int dtrace_speculation(dtrace_state_t *);
 static int dtrace_state_buffer(dtrace_state_t *, dtrace_buffer_t *, int);
 static int dtrace_state_buffers(dtrace_state_t *);
 static int dtrace_state_go(dtrace_state_t *, processorid_t *);
 static int dtrace_state_option(dtrace_state_t *, dtrace_optid_t, dtrace_optval_t);
 static int dtrace_state_stop(dtrace_state_t *, processorid_t *);
+static int dtrace_strncmp(char *, char *, size_t);
 static intptr_t dtrace_buffer_reserve(dtrace_buffer_t *, size_t, size_t, dtrace_state_t *, dtrace_mstate_t *);
+static size_t dtrace_strlen(const char *, size_t);
 static uint16_t dtrace_format_add(dtrace_state_t *, char *);
+static uint64_t dtrace_dif_variable(dtrace_mstate_t *, dtrace_state_t *, uint64_t, uint64_t);
 static uint64_t dtrace_helper(int, dtrace_mstate_t *, dtrace_state_t *, uint64_t, uint64_t);
 static uint_t dtrace_hash_str(char *);
 static void dtrace_actdesc_release(dtrace_actdesc_t *, dtrace_vstate_t *);
+static void dtrace_action_breakpoint(dtrace_ecb_t *);
+static void dtrace_action_chill(dtrace_mstate_t *, hrtime_t);
+static void dtrace_action_panic(dtrace_ecb_t *);
+static void dtrace_action_raise(uint64_t);
+static void dtrace_action_stop(void);
+static void dtrace_action_ustack(dtrace_mstate_t *, dtrace_state_t *, uint64_t *, uint64_t);
+static void dtrace_aggregate(dtrace_aggregation_t *, dtrace_buffer_t *, intptr_t, dtrace_buffer_t *, uint64_t, uint64_t);
 static void dtrace_anon_property(void);
+static void dtrace_bcopy(const void *, void *, size_t);
 static void dtrace_buffer_drop(dtrace_buffer_t *);
+static void dtrace_buffer_polish(dtrace_buffer_t *);
+static void dtrace_buffer_switch(dtrace_buffer_t *);
+static void dtrace_bzero(void *, size_t);
+static void dtrace_cpu_setup_initial(processorid_t);
 static void dtrace_cred2priv(cred_t *, uint32_t *, uid_t *, zoneid_t *);
+static void dtrace_dif_subr(uint_t, uint_t, uint64_t *, dtrace_key_t *, int, dtrace_mstate_t *, dtrace_state_t *);
 static void dtrace_difo_destroy(dtrace_difo_t *, dtrace_vstate_t *);
 static void dtrace_difo_hold(dtrace_difo_t *);
 static void dtrace_difo_release(dtrace_difo_t *, dtrace_vstate_t *);
@@ -503,6 +519,7 @@
 static void dtrace_enabling_destroy(dtrace_enabling_t *);
 static void dtrace_enabling_matchall(void);
 static void dtrace_enabling_provide(dtrace_provider_t *);
+static void dtrace_error(uint32_t *);
 static void dtrace_format_remove(dtrace_state_t *, uint16_t);
 static void dtrace_hash_add(dtrace_hash_t *, dtrace_probe_t *);
 static void dtrace_hash_destroy(dtrace_hash_t *);
@@ -516,11 +533,13 @@
 static void dtrace_helper_trace(dtrace_helper_action_t *r, dtrace_mstate_t *, dtrace_vstate_t *, int);
 static void dtrace_helpers_destroy(void);
 static void dtrace_helpers_duplicate(proc_t *, proc_t *);
+static void dtrace_module_loaded(struct modctl *);
+static void dtrace_module_unloaded(struct modctl *);
 static void dtrace_predicate_hold(dtrace_predicate_t *);
 static void dtrace_predicate_release(dtrace_predicate_t *, dtrace_vstate_t *);
 static void dtrace_probe_description(const dtrace_probe_t *, dtrace_probedesc_t *);
 static void dtrace_probe_provide(dtrace_probedesc_t *, dtrace_provider_t *);
-static void dtrace_probekey(const dtrace_probedesc_t *, dtrace_probekey_t *);
+static void dtrace_probekey(dtrace_probedesc_t *, dtrace_probekey_t *);
 static void dtrace_speculation_clean(dtrace_state_t *);
 static void dtrace_speculation_clean_here(dtrace_state_t *);
 static void dtrace_speculation_commit(dtrace_state_t *, processorid_t, dtrace_specid_t);
@@ -529,31 +548,21 @@
 static void dtrace_state_deadman(dtrace_state_t *);
 static void dtrace_state_destroy(dtrace_state_t *);
 static void dtrace_state_prereserve(dtrace_state_t *);
+static void dtrace_strcpy(const void *, void *, size_t);
+static void dtrace_toxrange_add(uintptr_t, uintptr_t);
+static void dtrace_vcopy(void *, void *, dtrace_diftype_t *);
 static void dtrace_vstate_fini(dtrace_vstate_t *);
+uint16_t dtrace_load16(uintptr_t);
+uint32_t dtrace_load32(uintptr_t);
+uint64_t dtrace_load64(uintptr_t);
+uint8_t dtrace_load8(uintptr_t);
 void dtrace_dstate_fini(dtrace_dstate_t *d);
-void dtrace_vtime_disable(void);
-void dtrace_vtime_enable(void);
+void dtrace_dynvar_clean(dtrace_dstate_t *);
+void dtrace_resume(void);
+void dtrace_suspend(void);
 
-/* XXX Hacks.... */
-void
-dtrace_sync(void)
-{
-#ifdef DOODAD
-        dtrace_xcall(DTRACE_CPUALL, (dtrace_xcall_t)dtrace_sync_func, NULL);
-#endif
-}
-void
-dtrace_membar_producer(void)
-{
-}
-void
-dtrace_vtime_enable(void)
-{
-}
-void
-dtrace_vtime_disable(void)
-{
-}
+/* Temporary hacks during porting this code. */
+#include <cddl/dev/dtrace/dtrace_hacks.c>
 
 /* Common error handler. */
 #include <cddl/dev/dtrace/cmn_err.c>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604212204.k3LM4wKn024601>