xref: /illumos-gate/usr/src/uts/common/sys/sdt.h (revision 02bc52be7430b2f7fafe1a2c981bff49ef11d6fa)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
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  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_SDT_H
27 #define	_SYS_SDT_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #ifndef _KERNEL
36 
37 #define	DTRACE_PROBE(provider, name) {					\
38 	extern void __dtrace_##provider##___##name(void);		\
39 	__dtrace_##provider##___##name();				\
40 }
41 
42 #define	DTRACE_PROBE1(provider, name, arg1) {				\
43 	extern void __dtrace_##provider##___##name(unsigned long);	\
44 	__dtrace_##provider##___##name((unsigned long)arg1);		\
45 }
46 
47 #define	DTRACE_PROBE2(provider, name, arg1, arg2) {			\
48 	extern void __dtrace_##provider##___##name(unsigned long,	\
49 	    unsigned long);						\
50 	__dtrace_##provider##___##name((unsigned long)arg1,		\
51 	    (unsigned long)arg2);					\
52 }
53 
54 #define	DTRACE_PROBE3(provider, name, arg1, arg2, arg3) {		\
55 	extern void __dtrace_##provider##___##name(unsigned long,	\
56 	    unsigned long, unsigned long);				\
57 	__dtrace_##provider##___##name((unsigned long)arg1,		\
58 	    (unsigned long)arg2, (unsigned long)arg3);			\
59 }
60 
61 #define	DTRACE_PROBE4(provider, name, arg1, arg2, arg3, arg4) {		\
62 	extern void __dtrace_##provider##___##name(unsigned long,	\
63 	    unsigned long, unsigned long, unsigned long);		\
64 	__dtrace_##provider##___##name((unsigned long)arg1,		\
65 	    (unsigned long)arg2, (unsigned long)arg3,			\
66 	    (unsigned long)arg4);					\
67 }
68 
69 #define	DTRACE_PROBE5(provider, name, arg1, arg2, arg3, arg4, arg5) {	\
70 	extern void __dtrace_##provider##___##name(unsigned long,	\
71 	    unsigned long, unsigned long, unsigned long, unsigned long);\
72 	__dtrace_##provider##___##name((unsigned long)arg1,		\
73 	    (unsigned long)arg2, (unsigned long)arg3,			\
74 	    (unsigned long)arg4, (unsigned long)arg5);			\
75 }
76 
77 #else /* _KERNEL */
78 
79 #define	DTRACE_PROBE(name)	{					\
80 	extern void __dtrace_probe_##name(void);			\
81 	__dtrace_probe_##name();					\
82 }
83 
84 #define	DTRACE_PROBE1(name, type1, arg1) {				\
85 	extern void __dtrace_probe_##name(uintptr_t);			\
86 	__dtrace_probe_##name((uintptr_t)(arg1));			\
87 }
88 
89 #define	DTRACE_PROBE2(name, type1, arg1, type2, arg2) {			\
90 	extern void __dtrace_probe_##name(uintptr_t, uintptr_t);	\
91 	__dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2));	\
92 }
93 
94 #define	DTRACE_PROBE3(name, type1, arg1, type2, arg2, type3, arg3) {	\
95 	extern void __dtrace_probe_##name(uintptr_t, uintptr_t, uintptr_t); \
96 	__dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2),	\
97 	    (uintptr_t)(arg3));						\
98 }
99 
100 #define	DTRACE_PROBE4(name, type1, arg1, type2, arg2, 			\
101     type3, arg3, type4, arg4) {						\
102 	extern void __dtrace_probe_##name(uintptr_t, uintptr_t,		\
103 	    uintptr_t, uintptr_t);					\
104 	__dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2),	\
105 	    (uintptr_t)(arg3), (uintptr_t)(arg4));			\
106 }
107 
108 #define	DTRACE_SCHED(name)						\
109 	DTRACE_PROBE(__sched_##name);
110 
111 #define	DTRACE_SCHED1(name, type1, arg1)				\
112 	DTRACE_PROBE1(__sched_##name, type1, arg1);
113 
114 #define	DTRACE_SCHED2(name, type1, arg1, type2, arg2)			\
115 	DTRACE_PROBE2(__sched_##name, type1, arg1, type2, arg2);
116 
117 #define	DTRACE_SCHED3(name, type1, arg1, type2, arg2, type3, arg3)	\
118 	DTRACE_PROBE3(__sched_##name, type1, arg1, type2, arg2, type3, arg3);
119 
120 #define	DTRACE_SCHED4(name, type1, arg1, type2, arg2, 			\
121     type3, arg3, type4, arg4)						\
122 	DTRACE_PROBE4(__sched_##name, type1, arg1, type2, arg2, 	\
123 	    type3, arg3, type4, arg4);
124 
125 #define	DTRACE_PROC(name)						\
126 	DTRACE_PROBE(__proc_##name);
127 
128 #define	DTRACE_PROC1(name, type1, arg1)					\
129 	DTRACE_PROBE1(__proc_##name, type1, arg1);
130 
131 #define	DTRACE_PROC2(name, type1, arg1, type2, arg2)			\
132 	DTRACE_PROBE2(__proc_##name, type1, arg1, type2, arg2);
133 
134 #define	DTRACE_PROC3(name, type1, arg1, type2, arg2, type3, arg3)	\
135 	DTRACE_PROBE3(__proc_##name, type1, arg1, type2, arg2, type3, arg3);
136 
137 #define	DTRACE_PROC4(name, type1, arg1, type2, arg2, 			\
138     type3, arg3, type4, arg4)						\
139 	DTRACE_PROBE4(__proc_##name, type1, arg1, type2, arg2, 		\
140 	    type3, arg3, type4, arg4);
141 
142 #define	DTRACE_IO(name)							\
143 	DTRACE_PROBE(__io_##name);
144 
145 #define	DTRACE_IO1(name, type1, arg1)					\
146 	DTRACE_PROBE1(__io_##name, type1, arg1);
147 
148 #define	DTRACE_IO2(name, type1, arg1, type2, arg2)			\
149 	DTRACE_PROBE2(__io_##name, type1, arg1, type2, arg2);
150 
151 #define	DTRACE_IO3(name, type1, arg1, type2, arg2, type3, arg3)	\
152 	DTRACE_PROBE3(__io_##name, type1, arg1, type2, arg2, type3, arg3);
153 
154 #define	DTRACE_IO4(name, type1, arg1, type2, arg2, 			\
155     type3, arg3, type4, arg4)						\
156 	DTRACE_PROBE4(__io_##name, type1, arg1, type2, arg2, 		\
157 	    type3, arg3, type4, arg4);
158 
159 #define	DTRACE_SYSEVENT2(name, type1, arg1, type2, arg2)		\
160 	DTRACE_PROBE2(__sysevent_##name, type1, arg1, type2, arg2);
161 
162 #define	DTRACE_XPV(name)						\
163 	DTRACE_PROBE(__xpv_##name);
164 
165 #define	DTRACE_XPV1(name, type1, arg1)					\
166 	DTRACE_PROBE1(__xpv_##name, type1, arg1);
167 
168 #define	DTRACE_XPV2(name, type1, arg1, type2, arg2)			\
169 	DTRACE_PROBE2(__xpv_##name, type1, arg1, type2, arg2);
170 
171 #define	DTRACE_XPV3(name, type1, arg1, type2, arg2, type3, arg3)	\
172 	DTRACE_PROBE3(__xpv_##name, type1, arg1, type2, arg2, type3, arg3);
173 
174 #define	DTRACE_XPV4(name, type1, arg1, type2, arg2, type3, arg3,	\
175 	    type4, arg4)						\
176 	DTRACE_PROBE4(__xpv_##name, type1, arg1, type2, arg2, 		\
177 	    type3, arg3, type4, arg4);
178 
179 #endif /* _KERNEL */
180 
181 extern const char *sdt_prefix;
182 
183 typedef struct sdt_probedesc {
184 	char			*sdpd_name;	/* name of this probe */
185 	unsigned long		sdpd_offset;	/* offset of call in text */
186 	struct sdt_probedesc	*sdpd_next;	/* next static probe */
187 } sdt_probedesc_t;
188 
189 #ifdef	__cplusplus
190 }
191 #endif
192 
193 #endif	/* _SYS_SDT_H */
194