8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * Copyright (c) 2011, Joyent, Inc. All rights reserved.
29 * Copyright (c) 2012 by Delphix. All rights reserved.
30 */
31
32 #ifndef _SYS_DTRACE_H
33 #define _SYS_DTRACE_H
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /*
40 * DTrace Dynamic Tracing Software: Kernel Interfaces
41 *
42 * Note: The contents of this file are private to the implementation of the
43 * Solaris system and DTrace subsystem and are subject to change at any time
44 * without notice. Applications and drivers using these interfaces will fail
45 * to run on future releases. These interfaces should not be used for any
46 * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
47 * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
48 */
271 #define DIF_SUBR_DIRNAME 26
272 #define DIF_SUBR_CLEANPATH 27
273 #define DIF_SUBR_STRCHR 28
274 #define DIF_SUBR_STRRCHR 29
275 #define DIF_SUBR_STRSTR 30
276 #define DIF_SUBR_STRTOK 31
277 #define DIF_SUBR_SUBSTR 32
278 #define DIF_SUBR_INDEX 33
279 #define DIF_SUBR_RINDEX 34
280 #define DIF_SUBR_HTONS 35
281 #define DIF_SUBR_HTONL 36
282 #define DIF_SUBR_HTONLL 37
283 #define DIF_SUBR_NTOHS 38
284 #define DIF_SUBR_NTOHL 39
285 #define DIF_SUBR_NTOHLL 40
286 #define DIF_SUBR_INET_NTOP 41
287 #define DIF_SUBR_INET_NTOA 42
288 #define DIF_SUBR_INET_NTOA6 43
289 #define DIF_SUBR_TOUPPER 44
290 #define DIF_SUBR_TOLOWER 45
291
292 #define DIF_SUBR_MAX 45 /* max subroutine value */
293
294 typedef uint32_t dif_instr_t;
295
296 #define DIF_INSTR_OP(i) (((i) >> 24) & 0xff)
297 #define DIF_INSTR_R1(i) (((i) >> 16) & 0xff)
298 #define DIF_INSTR_R2(i) (((i) >> 8) & 0xff)
299 #define DIF_INSTR_RD(i) ((i) & 0xff)
300 #define DIF_INSTR_RS(i) ((i) & 0xff)
301 #define DIF_INSTR_LABEL(i) ((i) & 0xffffff)
302 #define DIF_INSTR_VAR(i) (((i) >> 8) & 0xffff)
303 #define DIF_INSTR_INTEGER(i) (((i) >> 8) & 0xffff)
304 #define DIF_INSTR_STRING(i) (((i) >> 8) & 0xffff)
305 #define DIF_INSTR_SUBR(i) (((i) >> 8) & 0xffff)
306 #define DIF_INSTR_TYPE(i) (((i) >> 16) & 0xff)
307 #define DIF_INSTR_XLREF(i) (((i) >> 8) & 0xffff)
308
309 #define DIF_INSTR_FMT(op, r1, r2, d) \
310 (((op) << 24) | ((r1) << 16) | ((r2) << 8) | (d))
311
312 #define DIF_INSTR_NOT(r1, d) (DIF_INSTR_FMT(DIF_OP_NOT, r1, 0, d))
1632 *
1633 * 1.10 int dtps_mode(void *arg, dtrace_id_t id, void *parg)
1634 *
1635 * 1.10.1 Overview
1636 *
1637 * Called to determine the mode of a fired probe.
1638 *
1639 * 1.10.2 Arguments and notes
1640 *
1641 * The first argument is the cookie as passed to dtrace_register(). The
1642 * second argument is the identifier of the current probe. The third
1643 * argument is the probe argument as passed to dtrace_probe_create(). This
1644 * entry point must not be left NULL for providers whose probes allow for
1645 * mixed mode tracing, that is to say those unanchored probes that can fire
1646 * during kernel- or user-mode execution.
1647 *
1648 * 1.10.3 Return value
1649 *
1650 * A bitwise OR that encapsulates both the mode (either DTRACE_MODE_KERNEL
1651 * or DTRACE_MODE_USER) and the policy when the privilege of the enabling
1652 * is insufficient for that mode (either DTRACE_MODE_NOPRIV_DROP or
1653 * DTRACE_MODE_NOPRIV_RESTRICT). If the policy is DTRACE_MODE_NOPRIV_DROP,
1654 * insufficient privilege will result in the probe firing being silently
1655 * ignored for the enabling; if the policy is DTRACE_NODE_NOPRIV_RESTRICT,
1656 * insufficient privilege will not prevent probe processing for the
1657 * enabling, but restrictions will be in place that induce a UPRIV fault
1658 * upon attempt to examine probe arguments or current process state.
1659 *
1660 * 1.10.4 Caller's context
1661 *
1662 * This is called from within dtrace_probe() meaning that interrupts
1663 * are disabled. No locks should be taken within this entry point.
1664 *
1665 * 1.11 void dtps_destroy(void *arg, dtrace_id_t id, void *parg)
1666 *
1667 * 1.11.1 Overview
1668 *
1669 * Called to destroy the specified probe.
1670 *
1671 * 1.11.2 Arguments and notes
1672 *
1673 * The first argument is the cookie as passed to dtrace_register(). The
1674 * second argument is the identifier of the probe to be destroyed. The third
1675 * argument is the probe argument as passed to dtrace_probe_create(). The
1676 * provider should free all state associated with the probe. The framework
1677 * guarantees that dtps_destroy() is only called for probes that have either
1678 * been disabled via dtps_disable() or were never enabled via dtps_enable().
2037 */
2038 typedef struct dtrace_pops {
2039 void (*dtps_provide)(void *arg, const dtrace_probedesc_t *spec);
2040 void (*dtps_provide_module)(void *arg, struct modctl *mp);
2041 int (*dtps_enable)(void *arg, dtrace_id_t id, void *parg);
2042 void (*dtps_disable)(void *arg, dtrace_id_t id, void *parg);
2043 void (*dtps_suspend)(void *arg, dtrace_id_t id, void *parg);
2044 void (*dtps_resume)(void *arg, dtrace_id_t id, void *parg);
2045 void (*dtps_getargdesc)(void *arg, dtrace_id_t id, void *parg,
2046 dtrace_argdesc_t *desc);
2047 uint64_t (*dtps_getargval)(void *arg, dtrace_id_t id, void *parg,
2048 int argno, int aframes);
2049 int (*dtps_mode)(void *arg, dtrace_id_t id, void *parg);
2050 void (*dtps_destroy)(void *arg, dtrace_id_t id, void *parg);
2051 } dtrace_pops_t;
2052
2053 #define DTRACE_MODE_KERNEL 0x01
2054 #define DTRACE_MODE_USER 0x02
2055 #define DTRACE_MODE_NOPRIV_DROP 0x10
2056 #define DTRACE_MODE_NOPRIV_RESTRICT 0x20
2057
2058 typedef uintptr_t dtrace_provider_id_t;
2059
2060 extern int dtrace_register(const char *, const dtrace_pattr_t *, uint32_t,
2061 cred_t *, const dtrace_pops_t *, void *, dtrace_provider_id_t *);
2062 extern int dtrace_unregister(dtrace_provider_id_t);
2063 extern int dtrace_condense(dtrace_provider_id_t);
2064 extern void dtrace_invalidate(dtrace_provider_id_t);
2065 extern dtrace_id_t dtrace_probe_lookup(dtrace_provider_id_t, const char *,
2066 const char *, const char *);
2067 extern dtrace_id_t dtrace_probe_create(dtrace_provider_id_t, const char *,
2068 const char *, const char *, int, void *);
2069 extern void *dtrace_probe_arg(dtrace_provider_id_t, dtrace_id_t);
2070 extern void dtrace_probe(dtrace_id_t, uintptr_t arg0, uintptr_t arg1,
2071 uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
2072
2073 /*
2074 * DTrace Meta Provider API
2075 *
2076 * The following functions are implemented by the DTrace framework and are
2251 extern void (*dtrace_fasttrap_exec_ptr)(proc_t *);
2252 extern void (*dtrace_fasttrap_exit_ptr)(proc_t *);
2253 extern void dtrace_fasttrap_fork(proc_t *, proc_t *);
2254
2255 typedef uintptr_t dtrace_icookie_t;
2256 typedef void (*dtrace_xcall_t)(void *);
2257
2258 extern dtrace_icookie_t dtrace_interrupt_disable(void);
2259 extern void dtrace_interrupt_enable(dtrace_icookie_t);
2260
2261 extern void dtrace_membar_producer(void);
2262 extern void dtrace_membar_consumer(void);
2263
2264 extern void (*dtrace_cpu_init)(processorid_t);
2265 extern void (*dtrace_modload)(struct modctl *);
2266 extern void (*dtrace_modunload)(struct modctl *);
2267 extern void (*dtrace_helpers_cleanup)();
2268 extern void (*dtrace_helpers_fork)(proc_t *parent, proc_t *child);
2269 extern void (*dtrace_cpustart_init)();
2270 extern void (*dtrace_cpustart_fini)();
2271
2272 extern void (*dtrace_debugger_init)();
2273 extern void (*dtrace_debugger_fini)();
2274 extern dtrace_cacheid_t dtrace_predcache_id;
2275
2276 extern hrtime_t dtrace_gethrtime(void);
2277 extern void dtrace_sync(void);
2278 extern void dtrace_toxic_ranges(void (*)(uintptr_t, uintptr_t));
2279 extern void dtrace_xcall(processorid_t, dtrace_xcall_t, void *);
2280 extern void dtrace_vpanic(const char *, __va_list);
2281 extern void dtrace_panic(const char *, ...);
2282
2283 extern int dtrace_safe_defer_signal(void);
2284 extern void dtrace_safe_synchronous_signal(void);
2285
2286 extern int dtrace_mach_aframes(void);
2287
2288 #if defined(__i386) || defined(__amd64)
2289 extern int dtrace_instr_size(uchar_t *instr);
2290 extern int dtrace_instr_size_isa(uchar_t *, model_t, int *);
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
29 * Copyright (c) 2012 by Delphix. All rights reserved.
30 */
31
32 #ifndef _SYS_DTRACE_H
33 #define _SYS_DTRACE_H
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /*
40 * DTrace Dynamic Tracing Software: Kernel Interfaces
41 *
42 * Note: The contents of this file are private to the implementation of the
43 * Solaris system and DTrace subsystem and are subject to change at any time
44 * without notice. Applications and drivers using these interfaces will fail
45 * to run on future releases. These interfaces should not be used for any
46 * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
47 * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
48 */
271 #define DIF_SUBR_DIRNAME 26
272 #define DIF_SUBR_CLEANPATH 27
273 #define DIF_SUBR_STRCHR 28
274 #define DIF_SUBR_STRRCHR 29
275 #define DIF_SUBR_STRSTR 30
276 #define DIF_SUBR_STRTOK 31
277 #define DIF_SUBR_SUBSTR 32
278 #define DIF_SUBR_INDEX 33
279 #define DIF_SUBR_RINDEX 34
280 #define DIF_SUBR_HTONS 35
281 #define DIF_SUBR_HTONL 36
282 #define DIF_SUBR_HTONLL 37
283 #define DIF_SUBR_NTOHS 38
284 #define DIF_SUBR_NTOHL 39
285 #define DIF_SUBR_NTOHLL 40
286 #define DIF_SUBR_INET_NTOP 41
287 #define DIF_SUBR_INET_NTOA 42
288 #define DIF_SUBR_INET_NTOA6 43
289 #define DIF_SUBR_TOUPPER 44
290 #define DIF_SUBR_TOLOWER 45
291 #define DIF_SUBR_GETF 46
292
293 #define DIF_SUBR_MAX 46 /* max subroutine value */
294
295 typedef uint32_t dif_instr_t;
296
297 #define DIF_INSTR_OP(i) (((i) >> 24) & 0xff)
298 #define DIF_INSTR_R1(i) (((i) >> 16) & 0xff)
299 #define DIF_INSTR_R2(i) (((i) >> 8) & 0xff)
300 #define DIF_INSTR_RD(i) ((i) & 0xff)
301 #define DIF_INSTR_RS(i) ((i) & 0xff)
302 #define DIF_INSTR_LABEL(i) ((i) & 0xffffff)
303 #define DIF_INSTR_VAR(i) (((i) >> 8) & 0xffff)
304 #define DIF_INSTR_INTEGER(i) (((i) >> 8) & 0xffff)
305 #define DIF_INSTR_STRING(i) (((i) >> 8) & 0xffff)
306 #define DIF_INSTR_SUBR(i) (((i) >> 8) & 0xffff)
307 #define DIF_INSTR_TYPE(i) (((i) >> 16) & 0xff)
308 #define DIF_INSTR_XLREF(i) (((i) >> 8) & 0xffff)
309
310 #define DIF_INSTR_FMT(op, r1, r2, d) \
311 (((op) << 24) | ((r1) << 16) | ((r2) << 8) | (d))
312
313 #define DIF_INSTR_NOT(r1, d) (DIF_INSTR_FMT(DIF_OP_NOT, r1, 0, d))
1633 *
1634 * 1.10 int dtps_mode(void *arg, dtrace_id_t id, void *parg)
1635 *
1636 * 1.10.1 Overview
1637 *
1638 * Called to determine the mode of a fired probe.
1639 *
1640 * 1.10.2 Arguments and notes
1641 *
1642 * The first argument is the cookie as passed to dtrace_register(). The
1643 * second argument is the identifier of the current probe. The third
1644 * argument is the probe argument as passed to dtrace_probe_create(). This
1645 * entry point must not be left NULL for providers whose probes allow for
1646 * mixed mode tracing, that is to say those unanchored probes that can fire
1647 * during kernel- or user-mode execution.
1648 *
1649 * 1.10.3 Return value
1650 *
1651 * A bitwise OR that encapsulates both the mode (either DTRACE_MODE_KERNEL
1652 * or DTRACE_MODE_USER) and the policy when the privilege of the enabling
1653 * is insufficient for that mode (a combination of DTRACE_MODE_NOPRIV_DROP,
1654 * DTRACE_MODE_NOPRIV_RESTRICT, and DTRACE_MODE_LIMITEDPRIV_RESTRICT). If
1655 * DTRACE_MODE_NOPRIV_DROP bit is set, insufficient privilege will result
1656 * in the probe firing being silently ignored for the enabling; if the
1657 * DTRACE_NODE_NOPRIV_RESTRICT bit is set, insufficient privilege will not
1658 * prevent probe processing for the enabling, but restrictions will be in
1659 * place that induce a UPRIV fault upon attempt to examine probe arguments
1660 * or current process state. If the DTRACE_MODE_LIMITEDPRIV_RESTRICT bit
1661 * is set, similar restrictions will be placed upon operation if the
1662 * privilege is sufficient to process the enabling, but does not otherwise
1663 * entitle the enabling to all zones. The DTRACE_MODE_NOPRIV_DROP and
1664 * DTRACE_MODE_NOPRIV_RESTRICT are mutually exclusive (and one of these
1665 * two policies must be specified), but either may be combined (or not)
1666 * with DTRACE_MODE_LIMITEDPRIV_RESTRICT.
1667 *
1668 * 1.10.4 Caller's context
1669 *
1670 * This is called from within dtrace_probe() meaning that interrupts
1671 * are disabled. No locks should be taken within this entry point.
1672 *
1673 * 1.11 void dtps_destroy(void *arg, dtrace_id_t id, void *parg)
1674 *
1675 * 1.11.1 Overview
1676 *
1677 * Called to destroy the specified probe.
1678 *
1679 * 1.11.2 Arguments and notes
1680 *
1681 * The first argument is the cookie as passed to dtrace_register(). The
1682 * second argument is the identifier of the probe to be destroyed. The third
1683 * argument is the probe argument as passed to dtrace_probe_create(). The
1684 * provider should free all state associated with the probe. The framework
1685 * guarantees that dtps_destroy() is only called for probes that have either
1686 * been disabled via dtps_disable() or were never enabled via dtps_enable().
2045 */
2046 typedef struct dtrace_pops {
2047 void (*dtps_provide)(void *arg, const dtrace_probedesc_t *spec);
2048 void (*dtps_provide_module)(void *arg, struct modctl *mp);
2049 int (*dtps_enable)(void *arg, dtrace_id_t id, void *parg);
2050 void (*dtps_disable)(void *arg, dtrace_id_t id, void *parg);
2051 void (*dtps_suspend)(void *arg, dtrace_id_t id, void *parg);
2052 void (*dtps_resume)(void *arg, dtrace_id_t id, void *parg);
2053 void (*dtps_getargdesc)(void *arg, dtrace_id_t id, void *parg,
2054 dtrace_argdesc_t *desc);
2055 uint64_t (*dtps_getargval)(void *arg, dtrace_id_t id, void *parg,
2056 int argno, int aframes);
2057 int (*dtps_mode)(void *arg, dtrace_id_t id, void *parg);
2058 void (*dtps_destroy)(void *arg, dtrace_id_t id, void *parg);
2059 } dtrace_pops_t;
2060
2061 #define DTRACE_MODE_KERNEL 0x01
2062 #define DTRACE_MODE_USER 0x02
2063 #define DTRACE_MODE_NOPRIV_DROP 0x10
2064 #define DTRACE_MODE_NOPRIV_RESTRICT 0x20
2065 #define DTRACE_MODE_LIMITEDPRIV_RESTRICT 0x40
2066
2067 typedef uintptr_t dtrace_provider_id_t;
2068
2069 extern int dtrace_register(const char *, const dtrace_pattr_t *, uint32_t,
2070 cred_t *, const dtrace_pops_t *, void *, dtrace_provider_id_t *);
2071 extern int dtrace_unregister(dtrace_provider_id_t);
2072 extern int dtrace_condense(dtrace_provider_id_t);
2073 extern void dtrace_invalidate(dtrace_provider_id_t);
2074 extern dtrace_id_t dtrace_probe_lookup(dtrace_provider_id_t, const char *,
2075 const char *, const char *);
2076 extern dtrace_id_t dtrace_probe_create(dtrace_provider_id_t, const char *,
2077 const char *, const char *, int, void *);
2078 extern void *dtrace_probe_arg(dtrace_provider_id_t, dtrace_id_t);
2079 extern void dtrace_probe(dtrace_id_t, uintptr_t arg0, uintptr_t arg1,
2080 uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
2081
2082 /*
2083 * DTrace Meta Provider API
2084 *
2085 * The following functions are implemented by the DTrace framework and are
2260 extern void (*dtrace_fasttrap_exec_ptr)(proc_t *);
2261 extern void (*dtrace_fasttrap_exit_ptr)(proc_t *);
2262 extern void dtrace_fasttrap_fork(proc_t *, proc_t *);
2263
2264 typedef uintptr_t dtrace_icookie_t;
2265 typedef void (*dtrace_xcall_t)(void *);
2266
2267 extern dtrace_icookie_t dtrace_interrupt_disable(void);
2268 extern void dtrace_interrupt_enable(dtrace_icookie_t);
2269
2270 extern void dtrace_membar_producer(void);
2271 extern void dtrace_membar_consumer(void);
2272
2273 extern void (*dtrace_cpu_init)(processorid_t);
2274 extern void (*dtrace_modload)(struct modctl *);
2275 extern void (*dtrace_modunload)(struct modctl *);
2276 extern void (*dtrace_helpers_cleanup)();
2277 extern void (*dtrace_helpers_fork)(proc_t *parent, proc_t *child);
2278 extern void (*dtrace_cpustart_init)();
2279 extern void (*dtrace_cpustart_fini)();
2280 extern void (*dtrace_closef)();
2281
2282 extern void (*dtrace_debugger_init)();
2283 extern void (*dtrace_debugger_fini)();
2284 extern dtrace_cacheid_t dtrace_predcache_id;
2285
2286 extern hrtime_t dtrace_gethrtime(void);
2287 extern void dtrace_sync(void);
2288 extern void dtrace_toxic_ranges(void (*)(uintptr_t, uintptr_t));
2289 extern void dtrace_xcall(processorid_t, dtrace_xcall_t, void *);
2290 extern void dtrace_vpanic(const char *, __va_list);
2291 extern void dtrace_panic(const char *, ...);
2292
2293 extern int dtrace_safe_defer_signal(void);
2294 extern void dtrace_safe_synchronous_signal(void);
2295
2296 extern int dtrace_mach_aframes(void);
2297
2298 #if defined(__i386) || defined(__amd64)
2299 extern int dtrace_instr_size(uchar_t *instr);
2300 extern int dtrace_instr_size_isa(uchar_t *, model_t, int *);
|