X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/2d21ac55c334faf3a56e5634905ed6987fc787d4..39236c6e673c41db228275375ab7fdb0f837b292:/bsd/sys/dtrace.h diff --git a/bsd/sys/dtrace.h b/bsd/sys/dtrace.h index 7785b9b34..5267d5019 100644 --- a/bsd/sys/dtrace.h +++ b/bsd/sys/dtrace.h @@ -20,14 +20,18 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Portions copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _SYS_DTRACE_H #define _SYS_DTRACE_H -/* #pragma ident "@(#)dtrace.h 1.32 06/08/07 SMI" */ +/* #pragma ident "@(#)dtrace.h 1.37 07/06/05 SMI" */ #ifdef __cplusplus extern "C" { @@ -56,6 +60,16 @@ extern "C" { #include #else /* is Apple Mac OS X */ +#if defined(__LP64__) +#if !defined(_LP64) +#define _LP64 /* Solaris vs. Darwin */ +#endif +#else +#if !defined(_ILP32) +#define _ILP32 /* Solaris vs. Darwin */ +#endif +#endif + #ifdef KERNEL #ifndef _KERNEL #define _KERNEL /* Solaris vs. Darwin */ @@ -90,12 +104,17 @@ extern "C" { #define P2ROUNDUP(x, align) (-(-(x) & -(align))) #define CTF_MODEL_ILP32 1 /* object data model is ILP32 */ +#define CTF_MODEL_LP64 2 /* object data model is LP64 */ +#ifdef __LP64__ +#define CTF_MODEL_NATIVE CTF_MODEL_LP64 +#else #define CTF_MODEL_NATIVE CTF_MODEL_ILP32 +#endif typedef uint8_t uchar_t; typedef uint16_t ushort_t; typedef uint32_t uint_t; -typedef uint32_t ulong_t; +typedef unsigned long ulong_t; typedef uint64_t u_longlong_t; typedef int64_t longlong_t; typedef int64_t off64_t; @@ -104,6 +123,8 @@ typedef int64_t hrtime_t; typedef enum { B_FALSE = 0, B_TRUE = 1 } _dtrace_boolean; +typedef uint8_t UUID[16]; /* For modctl use in dtrace.h */ + struct modctl; /* In lieu of Solaris */ /* NOTHING */ /* In lieu of Solaris */ #include /* In lieu of Solaris */ @@ -124,7 +145,8 @@ typedef uint32_t zoneid_t; #include typedef va_list __va_list; -#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 */ #endif /* __APPLE__ */ /* @@ -310,6 +332,10 @@ typedef enum dtrace_probespec { #define DIF_VAR_UID 0x011e /* process user ID */ #define DIF_VAR_GID 0x011f /* process group ID */ #define DIF_VAR_ERRNO 0x0120 /* thread errno */ +#if defined(__APPLE__) +#define DIF_VAR_PTHREAD_SELF 0x0200 /* Apple specific PTHREAD_SELF (Not currently supported!) */ +#define DIF_VAR_DISPATCHQADDR 0x0201 /* Apple specific dispatch queue addr */ +#endif /* __APPLE __ */ #define DIF_SUBR_RAND 0 #define DIF_SUBR_MUTEX_OWNED 1 @@ -346,9 +372,23 @@ typedef enum dtrace_probespec { #define DIF_SUBR_SUBSTR 32 #define DIF_SUBR_INDEX 33 #define DIF_SUBR_RINDEX 34 -#define DIF_SUBR_CHUD 35 +#define DIF_SUBR_HTONS 35 +#define DIF_SUBR_HTONL 36 +#define DIF_SUBR_HTONLL 37 +#define DIF_SUBR_NTOHS 38 +#define DIF_SUBR_NTOHL 39 +#define DIF_SUBR_NTOHLL 40 +#define DIF_SUBR_INET_NTOP 41 +#define DIF_SUBR_INET_NTOA 42 +#define DIF_SUBR_INET_NTOA6 43 +#if !defined(__APPLE__) + +#define DIF_SUBR_MAX 43 /* max subroutine value */ +#else +#define DIF_SUBR_COREPROFILE 44 -#define DIF_SUBR_MAX 35 /* max subroutine value */ +#define DIF_SUBR_MAX 44 /* max subroutine value */ +#endif /* __APPLE__ */ typedef uint32_t dif_instr_t; @@ -458,6 +498,10 @@ typedef struct dtrace_difv { #define DTRACEACT_PRINTA 4 /* printa() action */ #define DTRACEACT_LIBACT 5 /* library-controlled action */ +#if defined(__APPLE__) +#define DTRACEACT_APPLEBINARY 50 /* Apple DT perf. tool action */ +#endif /* __APPLE__ */ + #define DTRACEACT_PROC 0x0100 #define DTRACEACT_USTACK (DTRACEACT_PROC + 1) #define DTRACEACT_JSTACK (DTRACEACT_PROC + 2) @@ -470,6 +514,15 @@ typedef struct dtrace_difv { #define DTRACEACT_RAISE (DTRACEACT_PROC_DESTRUCTIVE + 2) #define DTRACEACT_SYSTEM (DTRACEACT_PROC_DESTRUCTIVE + 3) #define DTRACEACT_FREOPEN (DTRACEACT_PROC_DESTRUCTIVE + 4) + +#if defined(__APPLE__) +/* + * Dtrace stop() will task_suspend the currently running process. + * Dtrace pidresume(pid) will task_resume it. + */ + +#define DTRACEACT_PIDRESUME (DTRACEACT_PROC_DESTRUCTIVE + 50) +#endif /* __APPLE__ */ #define DTRACEACT_PROC_CONTROL 0x0300 @@ -522,14 +575,22 @@ typedef struct dtrace_difv { #define DTRACEAGG_STDDEV (DTRACEACT_AGGREGATION + 6) #define DTRACEAGG_QUANTIZE (DTRACEACT_AGGREGATION + 7) #define DTRACEAGG_LQUANTIZE (DTRACEACT_AGGREGATION + 8) +#define DTRACEAGG_LLQUANTIZE (DTRACEACT_AGGREGATION + 9) #define DTRACEACT_ISAGG(x) \ (DTRACEACT_CLASS(x) == DTRACEACT_AGGREGATION) +#if !defined(__APPLE__) /* Quiet compiler warning. */ #define DTRACE_QUANTIZE_NBUCKETS \ (((sizeof (uint64_t) * NBBY) - 1) * 2 + 1) #define DTRACE_QUANTIZE_ZEROBUCKET ((sizeof (uint64_t) * NBBY) - 1) +#else +#define DTRACE_QUANTIZE_NBUCKETS \ + (int)(((sizeof (uint64_t) * NBBY) - 1) * 2 + 1) + +#define DTRACE_QUANTIZE_ZEROBUCKET (int64_t)((sizeof (uint64_t) * NBBY) - 1) +#endif /* __APPLE __*/ #define DTRACE_QUANTIZE_BUCKETVAL(buck) \ (int64_t)((buck) < DTRACE_QUANTIZE_ZEROBUCKET ? \ @@ -556,11 +617,38 @@ typedef struct dtrace_difv { (int32_t)(((x) & DTRACE_LQUANTIZE_BASEMASK) >> \ DTRACE_LQUANTIZE_BASESHIFT) +#define DTRACE_LLQUANTIZE_FACTORSHIFT 48 +#define DTRACE_LLQUANTIZE_FACTORMASK ((uint64_t)UINT16_MAX << 48) +#define DTRACE_LLQUANTIZE_LOWSHIFT 32 +#define DTRACE_LLQUANTIZE_LOWMASK ((uint64_t)UINT16_MAX << 32) +#define DTRACE_LLQUANTIZE_HIGHSHIFT 16 +#define DTRACE_LLQUANTIZE_HIGHMASK ((uint64_t)UINT16_MAX << 16) +#define DTRACE_LLQUANTIZE_NSTEPSHIFT 0 +#define DTRACE_LLQUANTIZE_NSTEPMASK UINT16_MAX + +#define DTRACE_LLQUANTIZE_FACTOR(x) \ + (uint16_t)(((x) & DTRACE_LLQUANTIZE_FACTORMASK) >> \ + DTRACE_LLQUANTIZE_FACTORSHIFT) + +#define DTRACE_LLQUANTIZE_LOW(x) \ + (uint16_t)(((x) & DTRACE_LLQUANTIZE_LOWMASK) >> \ + DTRACE_LLQUANTIZE_LOWSHIFT) + +#define DTRACE_LLQUANTIZE_HIGH(x) \ + (uint16_t)(((x) & DTRACE_LLQUANTIZE_HIGHMASK) >> \ + DTRACE_LLQUANTIZE_HIGHSHIFT) + +#define DTRACE_LLQUANTIZE_NSTEPS(x) \ + (uint16_t)(((x) & DTRACE_LLQUANTIZE_NSTEPMASK) >> \ + DTRACE_LLQUANTIZE_NSTEPSHIFT) + #define DTRACE_USTACK_NFRAMES(x) (uint32_t)((x) & UINT32_MAX) #define DTRACE_USTACK_STRSIZE(x) (uint32_t)((x) >> 32) #define DTRACE_USTACK_ARG(x, y) \ ((((uint64_t)(y)) << 32) | ((x) & UINT32_MAX)) +#if !defined(__APPLE__) + #ifndef _LP64 #ifndef _LITTLE_ENDIAN #define DTRACE_PTR(type, name) uint32_t name##pad; type *name @@ -571,6 +659,16 @@ typedef struct dtrace_difv { #define DTRACE_PTR(type, name) type *name #endif +#else + +#ifndef _LP64 +#define DTRACE_PTR(type, name) user_addr_t name +#else +#define DTRACE_PTR(type, name) type *name +#endif + +#endif /* __APPLE__ */ + /* * DTrace Object Format (DOF) * @@ -680,8 +778,12 @@ typedef struct dof_hdr { #define DOF_VERSION_1 1 /* DOF version 1: Solaris 10 FCS */ #define DOF_VERSION_2 2 /* DOF version 2: Solaris Express 6/06 */ +#if !defined(__APPLE__) +#define DOF_VERSION DOF_VERSION_2 /* Latest DOF version */ +#else #define DOF_VERSION_3 3 /* DOF version 3: Minimum version for Leopard */ #define DOF_VERSION DOF_VERSION_3 /* Latest DOF version */ +#endif /* __APPLE__ */ #define DOF_FL_VALID 0 /* mask of all valid dofh_flags bits */ @@ -1036,12 +1138,12 @@ typedef struct dtrace_fmtdesc { #define DTRACEOPT_AGGSORTREV 24 /* reverse-sort aggregations */ #define DTRACEOPT_AGGSORTPOS 25 /* agg. position to sort on */ #define DTRACEOPT_AGGSORTKEYPOS 26 /* agg. key position to sort on */ -#if defined(__APPLE__) +#if !defined(__APPLE__) +#define DTRACEOPT_MAX 27 /* number of options */ +#else #define DTRACEOPT_STACKSYMBOLS 27 /* clear to prevent stack symbolication */ #define DTRACEOPT_MAX 28 /* number of options */ -#else -#define DTRACEOPT_MAX 27 /* number of options */ -#endif +#endif /* __APPLE__ */ #define DTRACEOPT_UNSET (dtrace_optval_t)-2 /* unset option */ @@ -1141,6 +1243,7 @@ typedef struct dtrace_conf { #define DTRACEFLT_KPRIV 6 /* Illegal kernel access */ #define DTRACEFLT_UPRIV 7 /* Illegal user access */ #define DTRACEFLT_TUPOFLOW 8 /* Tuple stack overflow */ +#define DTRACEFLT_BADSTACK 9 /* Bad stack */ #define DTRACEFLT_LIBRARY 1000 /* Library-level fault */ @@ -1278,6 +1381,34 @@ typedef struct dtrace_providerdesc { #define DTRACEIOC_FORMAT (DTRACEIOC | 16) /* get format str */ #define DTRACEIOC_DOFGET (DTRACEIOC | 17) /* get DOF */ #define DTRACEIOC_REPLICATE (DTRACEIOC | 18) /* replicate enab */ +#define DTRACEIOC_MODUUIDSLIST (DTRACEIOC | 30) /* APPLE ONLY, query for modules with missing symbols */ +#define DTRACEIOC_PROVMODSYMS (DTRACEIOC | 31) /* APPLE ONLY, provide missing symbols for a given module */ + +/* + * The following structs are used to provide symbol information to the kernel from userspace. + */ + +typedef struct dtrace_symbol { + uint64_t dtsym_addr; /* address of the symbol */ + uint64_t dtsym_size; /* size of the symbol, must be uint64_t to maintain alignment when called by 64b uproc in i386 kernel */ + char dtsym_name[DTRACE_FUNCNAMELEN]; /* symbol name */ +} dtrace_symbol_t; + +typedef struct dtrace_module_symbols { + UUID dtmodsyms_uuid; + uint64_t dtmodsyms_count; + dtrace_symbol_t dtmodsyms_symbols[1]; +} dtrace_module_symbols_t; + +#define DTRACE_MODULE_SYMBOLS_SIZE(count) (sizeof(dtrace_module_symbols_t) + ((count - 1) * sizeof(dtrace_symbol_t))) + +typedef struct dtrace_module_uuids_list { + uint64_t dtmul_count; + UUID dtmul_uuid[1]; +} dtrace_module_uuids_list_t; + +#define DTRACE_MODULE_UUIDS_LIST_SIZE(count) (sizeof(dtrace_module_uuids_list_t) + ((count - 1) * sizeof(UUID))) + #endif /* __APPLE__ */ /* @@ -1393,7 +1524,11 @@ typedef struct dof_ioctl_data { #endif #define DTRACEMNR_DTRACE "dtrace" /* node for DTrace ops */ +#if !defined(__APPLE__) +#define DTRACEMNR_HELPER "helper" /* node for helpers */ +#else #define DTRACEMNR_HELPER "dtracehelper" /* node for helpers */ +#endif /* __APPLE__ */ #define DTRACEMNRN_DTRACE 0 /* minor for DTrace ops */ #define DTRACEMNRN_HELPER 1 /* minor for helpers */ #define DTRACEMNRN_CLONE 2 /* first clone minor */ @@ -1500,7 +1635,7 @@ typedef struct dof_ioctl_data { * dtps_provide_module(); see "Arguments and Notes" for dtrace_register(), * below. * - * 1.4 void dtps_enable(void *arg, dtrace_id_t id, void *parg) + * 1.4 int dtps_enable(void *arg, dtrace_id_t id, void *parg) * * 1.4.1 Overview * @@ -1521,7 +1656,8 @@ typedef struct dof_ioctl_data { * * 1.4.3 Return value * - * None. + * On success, dtps_enable() should return 0. On failure, -1 should be + * returned. * * 1.4.4 Caller's context * @@ -2075,7 +2211,7 @@ typedef struct dof_ioctl_data { typedef struct dtrace_pops { void (*dtps_provide)(void *arg, const dtrace_probedesc_t *spec); void (*dtps_provide_module)(void *arg, struct modctl *mp); - void (*dtps_enable)(void *arg, dtrace_id_t id, void *parg); + int (*dtps_enable)(void *arg, dtrace_id_t id, void *parg); void (*dtps_disable)(void *arg, dtrace_id_t id, void *parg); void (*dtps_suspend)(void *arg, dtrace_id_t id, void *parg); void (*dtps_resume)(void *arg, dtrace_id_t id, void *parg); @@ -2285,19 +2421,19 @@ extern void dtrace_vtime_disable_tnf(void); extern void dtrace_vtime_enable(void); extern void dtrace_vtime_disable(void); -#if defined (__ppc__) || defined (__ppc64__) -extern int (*dtrace_pid_probe_ptr)(ppc_saved_state_t *regs); -extern int (*dtrace_return_probe_ptr)(ppc_saved_state_t* regs); -#elif defined (__i386__) || defined(__x86_64__) +#if !defined(__APPLE__) +struct regs; + +extern int (*dtrace_pid_probe_ptr)(struct regs *); +extern int (*dtrace_return_probe_ptr)(struct regs *); +#else +#if defined (__i386__) || defined(__x86_64__) extern int (*dtrace_pid_probe_ptr)(x86_saved_state_t *regs); extern int (*dtrace_return_probe_ptr)(x86_saved_state_t* regs); -#elif defined (__arm__) -extern int (*dtrace_pid_probe_ptr)(struct arm_saved_state *regs); -extern int (*dtrace_return_probe_ptr)(struct arm_saved_state* regs); #else #error architecture not supported #endif - +#endif /* __APPLE__ */ extern void (*dtrace_fasttrap_fork_ptr)(proc_t *, proc_t *); extern void (*dtrace_fasttrap_exec_ptr)(proc_t *); extern void (*dtrace_fasttrap_exit_ptr)(proc_t *); @@ -2313,8 +2449,13 @@ extern void dtrace_membar_producer(void); extern void dtrace_membar_consumer(void); extern void (*dtrace_cpu_init)(processorid_t); +#if !defined(__APPLE__) extern void (*dtrace_modload)(struct modctl *); extern void (*dtrace_modunload)(struct modctl *); +#else +extern int (*dtrace_modload)(struct kmod_info *, uint32_t); +extern int (*dtrace_modunload)(struct kmod_info *); +#endif /* __APPLE__ */ extern void (*dtrace_helpers_cleanup)(proc_t*); extern void (*dtrace_helpers_fork)(proc_t *parent, proc_t *child); extern void (*dtrace_cpustart_init)(void); @@ -2331,13 +2472,14 @@ extern hrtime_t dtrace_gethrtime(void); extern void dtrace_sync(void); extern void dtrace_toxic_ranges(void (*)(uintptr_t, uintptr_t)); extern void dtrace_xcall(processorid_t, dtrace_xcall_t, void *); -extern void dtrace_vpanic(const char *, __va_list); -extern void dtrace_panic(const char *, ...); extern int dtrace_safe_defer_signal(void); extern void dtrace_safe_synchronous_signal(void); -#if defined(__i386__) || defined(__x86_64__) +extern int dtrace_mach_aframes(void); + +#if !defined(__APPLE__) +#if defined(__i386) || defined(__amd64) extern int dtrace_instr_size(uchar_t *instr); extern int dtrace_instr_size_isa(uchar_t *, model_t, int *); extern void dtrace_invop_add(int (*)(uintptr_t, uintptr_t *, uintptr_t)); @@ -2349,12 +2491,17 @@ extern void dtrace_invop_callsite(void); extern int dtrace_blksuword32(uintptr_t, uint32_t *, int); extern void dtrace_getfsr(uint64_t *); #endif - -#if defined(__APPLE__) -#if defined (__ppc__) || defined (__ppc64__) +#else +#if defined(__i386__) || defined(__x86_64__) +extern int dtrace_instr_size(uchar_t *instr); +extern int dtrace_instr_size_isa(uchar_t *, model_t, int *); extern void dtrace_invop_add(int (*)(uintptr_t, uintptr_t *, uintptr_t)); extern void dtrace_invop_remove(int (*)(uintptr_t, uintptr_t *, uintptr_t)); +extern void *dtrace_invop_callsite_pre; +extern void *dtrace_invop_callsite_post; #endif + + #undef proc_t #endif /* __APPLE__ */ @@ -2371,6 +2518,17 @@ extern void dtrace_invop_remove(int (*)(uintptr_t, uintptr_t *, uintptr_t)); #endif /* _ASM */ +#if !defined(__APPLE__) +#if defined(__i386) || defined(__amd64) + +#define DTRACE_INVOP_PUSHL_EBP 1 +#define DTRACE_INVOP_POPL_EBP 2 +#define DTRACE_INVOP_LEAVE 3 +#define DTRACE_INVOP_NOP 4 +#define DTRACE_INVOP_RET 5 + +#endif +#else #if defined(__i386__) || defined(__x86_64__) #define DTRACE_INVOP_PUSHL_EBP 1 @@ -2381,13 +2539,7 @@ extern void dtrace_invop_remove(int (*)(uintptr_t, uintptr_t *, uintptr_t)); #endif -#if defined(__APPLE__) -#if defined (__ppc__) || defined (__ppc64__) -#define DTRACE_INVOP_NOP 4 -#define DTRACE_INVOP_RET 5 -#define DTRACE_INVOP_BCTR 6 -#define DTRACE_INVOP_TAILJUMP 7 -#endif + #endif /* __APPLE__ */ #ifdef __cplusplus