2 * Copyright 2006-2008 John Birrell <jb@FreeBSD.org>
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * Statically Defined Tracing (SDT) definitions.
34 /* Stub these for the time being. */
35 #define DTRACE_PROBE(name)
36 #define DTRACE_PROBE1(name, type1, arg1)
37 #define DTRACE_PROBE2(name, type1, arg1, type2, arg2)
38 #define DTRACE_PROBE3(name, type1, arg1, type2, arg2, type3, arg3)
39 #define DTRACE_PROBE4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4)
43 /* The promise of things to come. Worlds to explore. People to meet. Things to do. */
49 #define SDT_PROVIDER_DEFINE(prov)
50 #define SDT_PROVIDER_DECLARE(prov)
51 #define SDT_PROBE_DEFINE(prov, mod, func, name)
52 #define SDT_PROBE_DECLARE(prov, mod, func, name)
53 #define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
54 #define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type)
56 #define SDT_PROBE_DEFINE1(prov, mod, func, name, arg0)
57 #define SDT_PROBE_DEFINE2(prov, mod, func, name, arg0, arg1)
58 #define SDT_PROBE_DEFINE3(prov, mod, func, name, arg0, arg1, arg2)
59 #define SDT_PROBE_DEFINE4(prov, mod, func, name, arg0, arg1, arg2, arg3)
60 #define SDT_PROBE_DEFINE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
62 #define SDT_PROBE1(prov, mod, func, name, arg0)
63 #define SDT_PROBE2(prov, mod, func, name, arg0, arg1)
64 #define SDT_PROBE3(prov, mod, func, name, arg0, arg1, arg2)
65 #define SDT_PROBE4(prov, mod, func, name, arg0, arg1, arg2, arg3)
66 #define SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
71 * This type definition must match that of dtrace_probe. It is defined this
72 * way to avoid having to rely on CDDL code.
74 typedef void (*sdt_probe_func_t)(u_int32_t, uintptr_t arg0, uintptr_t arg1,
75 uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
78 * The hook for the probe function. See kern_sdt.c which defaults this to
79 * it's own stub. The 'sdt' provider will set it to dtrace_probe when it
82 extern sdt_probe_func_t sdt_probe_func;
93 int ndx; /* Argument index. */
94 const char *type; /* Argument type string. */
95 TAILQ_ENTRY(sdt_argtype)
96 argtype_entry; /* Argument type list entry. */
98 *probe; /* Ptr to the probe structure. */
102 int version; /* Set to sizeof(struct sdt_ref). */
105 *prov; /* Ptr to the provider structure. */
106 TAILQ_ENTRY(sdt_probe)
107 probe_entry; /* SDT probe list entry. */
108 TAILQ_HEAD(argtype_list_head, sdt_argtype) argtype_list;
112 id_t id; /* DTrace probe ID. */
113 int n_args; /* Number of arguments. */
116 struct sdt_provider {
117 const char *name; /* Provider name. */
118 TAILQ_ENTRY(sdt_provider)
119 prov_entry; /* SDT provider list entry. */
120 TAILQ_HEAD(probe_list_head, sdt_probe) probe_list;
121 uintptr_t id; /* DTrace provider ID. */
124 #define SDT_PROVIDER_DEFINE(prov) \
125 struct sdt_provider sdt_provider_##prov[1] = { \
126 { #prov, { NULL, NULL }, { NULL, NULL } } \
128 SYSINIT(sdt_provider_##prov##_init, SI_SUB_KDTRACE, \
129 SI_ORDER_SECOND, sdt_provider_register, \
130 sdt_provider_##prov ); \
131 SYSUNINIT(sdt_provider_##prov##_uninit, SI_SUB_KDTRACE, \
132 SI_ORDER_SECOND, sdt_provider_deregister, \
133 sdt_provider_##prov )
135 #define SDT_PROVIDER_DECLARE(prov) \
136 extern struct sdt_provider sdt_provider_##prov[1]
138 #define SDT_PROBE_DEFINE(prov, mod, func, name) \
139 struct sdt_probe sdt_##prov##_##mod##_##func##_##name[1] = { \
140 { sizeof(struct sdt_probe), 0, sdt_provider_##prov, \
141 { NULL, NULL }, { NULL, NULL }, #mod, #func, #name, 0, 0 } \
143 SYSINIT(sdt_##prov##_##mod##_##func##_##name##_init, SI_SUB_KDTRACE, \
144 SI_ORDER_SECOND + 1, sdt_probe_register, \
145 sdt_##prov##_##mod##_##func##_##name ); \
146 SYSUNINIT(sdt_##prov##_##mod##_##func##_##name##_uninit, \
147 SI_SUB_KDTRACE, SI_ORDER_SECOND + 1, sdt_probe_deregister, \
148 sdt_##prov##_##mod##_##func##_##name )
150 #define SDT_PROBE_DECLARE(prov, mod, func, name) \
151 extern struct sdt_probe sdt_##prov##_##mod##_##func##_##name[1]
153 #define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \
154 if (sdt_##prov##_##mod##_##func##_##name->id) \
155 (*sdt_probe_func)(sdt_##prov##_##mod##_##func##_##name->id, \
156 (uintptr_t) arg0, (uintptr_t) arg1, (uintptr_t) arg2, \
157 (uintptr_t) arg3, (uintptr_t) arg4)
159 #define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type) \
160 struct sdt_argtype sdt_##prov##_##mod##_##func##_##name##num[1] \
161 = { { num, type, { NULL, NULL }, \
162 sdt_##prov##_##mod##_##func##_##name } \
164 SYSINIT(sdt_##prov##_##mod##_##func##_##name##num##_init, \
165 SI_SUB_KDTRACE, SI_ORDER_SECOND + 2, sdt_argtype_register, \
166 sdt_##prov##_##mod##_##func##_##name##num ); \
167 SYSUNINIT(sdt_##prov##_##mod##_##func##_##name##num##_uninit, \
168 SI_SUB_KDTRACE, SI_ORDER_SECOND + 2, sdt_argtype_deregister, \
169 sdt_##prov##_##mod##_##func##_##name##num )
171 #define SDT_PROBE_DEFINE1(prov, mod, func, name, arg0) \
172 SDT_PROBE_DEFINE(prov, mod, func, name); \
173 SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0)
175 #define SDT_PROBE_DEFINE2(prov, mod, func, name, arg0, arg1) \
176 SDT_PROBE_DEFINE(prov, mod, func, name); \
177 SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0); \
178 SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1)
180 #define SDT_PROBE_DEFINE3(prov, mod, func, name, arg0, arg1, arg2) \
181 SDT_PROBE_DEFINE(prov, mod, func, name); \
182 SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0); \
183 SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1); \
184 SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2)
186 #define SDT_PROBE_DEFINE4(prov, mod, func, name, arg0, arg1, arg2, arg3) \
187 SDT_PROBE_DEFINE(prov, mod, func, name); \
188 SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0); \
189 SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1); \
190 SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2); \
191 SDT_PROBE_ARGTYPE(prov, mod, func, name, 3, arg3)
193 #define SDT_PROBE_DEFINE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \
194 SDT_PROBE_DEFINE(prov, mod, func, name); \
195 SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0); \
196 SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1); \
197 SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2); \
198 SDT_PROBE_ARGTYPE(prov, mod, func, name, 3, arg3); \
199 SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4)
201 #define SDT_PROBE1(prov, mod, func, name, arg0) \
202 SDT_PROBE(prov, mod, func, name, arg0, 0, 0, 0, 0)
203 #define SDT_PROBE2(prov, mod, func, name, arg0, arg1) \
204 SDT_PROBE(prov, mod, func, name, arg0, arg1, 0, 0, 0)
205 #define SDT_PROBE3(prov, mod, func, name, arg0, arg1, arg2) \
206 SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, 0, 0)
207 #define SDT_PROBE4(prov, mod, func, name, arg0, arg1, arg2, arg3) \
208 SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, 0)
209 #define SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \
210 SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
212 typedef int (*sdt_argtype_listall_func_t)(struct sdt_argtype *, void *);
213 typedef int (*sdt_probe_listall_func_t)(struct sdt_probe *, void *);
214 typedef int (*sdt_provider_listall_func_t)(struct sdt_provider *, void *);
216 void sdt_argtype_deregister(void *);
217 void sdt_argtype_register(void *);
218 void sdt_probe_deregister(void *);
219 void sdt_probe_register(void *);
220 void sdt_provider_deregister(void *);
221 void sdt_provider_register(void *);
222 void sdt_probe_stub(u_int32_t, uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
223 uintptr_t arg3, uintptr_t arg4);
224 int sdt_argtype_listall(struct sdt_probe *, sdt_argtype_listall_func_t, void *);
225 int sdt_probe_listall(struct sdt_provider *, sdt_probe_listall_func_t, void *);
226 int sdt_provider_listall(sdt_provider_listall_func_t,void *);
228 #endif /* KDTRACE_HOOKS */
232 #endif /* _SYS_SDT_H */