Fix: perform volatile load of tracepoint state
[lttng-ust.git] / include / lttng / tracepoint.h
1 #ifndef _LTTNG_TRACEPOINT_H
2 #define _LTTNG_TRACEPOINT_H
3
4 /*
5 * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <lttng/tracepoint-types.h>
29 #include <lttng/tracepoint-rcu.h>
30 #include <urcu/compiler.h>
31 #include <urcu/system.h>
32 #include <dlfcn.h> /* for dlopen */
33 #include <string.h> /* for memset */
34 #include <lttng/ust-config.h> /* for sdt */
35 #include <lttng/ust-compiler.h>
36
37 #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION
38 #define SDT_USE_VARIADIC
39 #include <sys/sdt.h>
40 #else
41 #define STAP_PROBEV(...)
42 #endif
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 #define tracepoint(provider, name, ...) \
49 do { \
50 STAP_PROBEV(provider, name, ## __VA_ARGS__); \
51 if (caa_unlikely(CMM_LOAD_SHARED(__tracepoint_##provider##___##name.state))) \
52 __tracepoint_cb_##provider##___##name(__VA_ARGS__); \
53 } while (0)
54
55 #define TP_ARGS(...) __VA_ARGS__
56
57 /*
58 * TP_ARGS takes tuples of type, argument separated by a comma.
59 * It can take up to 10 tuples (which means that less than 10 tuples is
60 * fine too).
61 * Each tuple is also separated by a comma.
62 */
63 #define __TP_COMBINE_TOKENS(_tokena, _tokenb) \
64 _tokena##_tokenb
65 #define _TP_COMBINE_TOKENS(_tokena, _tokenb) \
66 __TP_COMBINE_TOKENS(_tokena, _tokenb)
67 #define __TP_COMBINE_TOKENS3(_tokena, _tokenb, _tokenc) \
68 _tokena##_tokenb##_tokenc
69 #define _TP_COMBINE_TOKENS3(_tokena, _tokenb, _tokenc) \
70 __TP_COMBINE_TOKENS3(_tokena, _tokenb, _tokenc)
71 #define __TP_COMBINE_TOKENS4(_tokena, _tokenb, _tokenc, _tokend) \
72 _tokena##_tokenb##_tokenc##_tokend
73 #define _TP_COMBINE_TOKENS4(_tokena, _tokenb, _tokenc, _tokend) \
74 __TP_COMBINE_TOKENS4(_tokena, _tokenb, _tokenc, _tokend)
75
76 /*
77 * _TP_EXVAR* extract the var names.
78 * _TP_EXVAR1 and _TP_EXDATA_VAR1 are needed for -std=c99.
79 */
80 #define _TP_EXVAR0()
81 #define _TP_EXVAR1(a)
82 #define _TP_EXVAR2(a,b) b
83 #define _TP_EXVAR4(a,b,c,d) b,d
84 #define _TP_EXVAR6(a,b,c,d,e,f) b,d,f
85 #define _TP_EXVAR8(a,b,c,d,e,f,g,h) b,d,f,h
86 #define _TP_EXVAR10(a,b,c,d,e,f,g,h,i,j) b,d,f,h,j
87 #define _TP_EXVAR12(a,b,c,d,e,f,g,h,i,j,k,l) b,d,f,h,j,l
88 #define _TP_EXVAR14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) b,d,f,h,j,l,n
89 #define _TP_EXVAR16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) b,d,f,h,j,l,n,p
90 #define _TP_EXVAR18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) b,d,f,h,j,l,n,p,r
91 #define _TP_EXVAR20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) b,d,f,h,j,l,n,p,r,t
92
93 #define _TP_EXDATA_VAR0() __tp_data
94 #define _TP_EXDATA_VAR1(a) __tp_data
95 #define _TP_EXDATA_VAR2(a,b) __tp_data,b
96 #define _TP_EXDATA_VAR4(a,b,c,d) __tp_data,b,d
97 #define _TP_EXDATA_VAR6(a,b,c,d,e,f) __tp_data,b,d,f
98 #define _TP_EXDATA_VAR8(a,b,c,d,e,f,g,h) __tp_data,b,d,f,h
99 #define _TP_EXDATA_VAR10(a,b,c,d,e,f,g,h,i,j) __tp_data,b,d,f,h,j
100 #define _TP_EXDATA_VAR12(a,b,c,d,e,f,g,h,i,j,k,l) __tp_data,b,d,f,h,j,l
101 #define _TP_EXDATA_VAR14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) __tp_data,b,d,f,h,j,l,n
102 #define _TP_EXDATA_VAR16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) __tp_data,b,d,f,h,j,l,n,p
103 #define _TP_EXDATA_VAR18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) __tp_data,b,d,f,h,j,l,n,p,r
104 #define _TP_EXDATA_VAR20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) __tp_data,b,d,f,h,j,l,n,p,r,t
105
106 /*
107 * _TP_EXPROTO* extract tuples of type, var.
108 * _TP_EXPROTO1 and _TP_EXDATA_PROTO1 are needed for -std=c99.
109 */
110 #define _TP_EXPROTO0() void
111 #define _TP_EXPROTO1(a) void
112 #define _TP_EXPROTO2(a,b) a b
113 #define _TP_EXPROTO4(a,b,c,d) a b,c d
114 #define _TP_EXPROTO6(a,b,c,d,e,f) a b,c d,e f
115 #define _TP_EXPROTO8(a,b,c,d,e,f,g,h) a b,c d,e f,g h
116 #define _TP_EXPROTO10(a,b,c,d,e,f,g,h,i,j) a b,c d,e f,g h,i j
117 #define _TP_EXPROTO12(a,b,c,d,e,f,g,h,i,j,k,l) a b,c d,e f,g h,i j,k l
118 #define _TP_EXPROTO14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) a b,c d,e f,g h,i j,k l,m n
119 #define _TP_EXPROTO16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) a b,c d,e f,g h,i j,k l,m n,o p
120 #define _TP_EXPROTO18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) a b,c d,e f,g h,i j,k l,m n,o p,q r
121 #define _TP_EXPROTO20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) a b,c d,e f,g h,i j,k l,m n,o p,q r,s t
122
123 #define _TP_EXDATA_PROTO0() void *__tp_data
124 #define _TP_EXDATA_PROTO1(a) void *__tp_data
125 #define _TP_EXDATA_PROTO2(a,b) void *__tp_data,a b
126 #define _TP_EXDATA_PROTO4(a,b,c,d) void *__tp_data,a b,c d
127 #define _TP_EXDATA_PROTO6(a,b,c,d,e,f) void *__tp_data,a b,c d,e f
128 #define _TP_EXDATA_PROTO8(a,b,c,d,e,f,g,h) void *__tp_data,a b,c d,e f,g h
129 #define _TP_EXDATA_PROTO10(a,b,c,d,e,f,g,h,i,j) void *__tp_data,a b,c d,e f,g h,i j
130 #define _TP_EXDATA_PROTO12(a,b,c,d,e,f,g,h,i,j,k,l) void *__tp_data,a b,c d,e f,g h,i j,k l
131 #define _TP_EXDATA_PROTO14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) void *__tp_data,a b,c d,e f,g h,i j,k l,m n
132 #define _TP_EXDATA_PROTO16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) void *__tp_data,a b,c d,e f,g h,i j,k l,m n,o p
133 #define _TP_EXDATA_PROTO18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) void *__tp_data,a b,c d,e f,g h,i j,k l,m n,o p,q r
134 #define _TP_EXDATA_PROTO20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) void *__tp_data,a b,c d,e f,g h,i j,k l,m n,o p,q r,s t
135
136 /* Preprocessor trick to count arguments. Inspired from sdt.h. */
137 #define _TP_NARGS(...) __TP_NARGS(__VA_ARGS__, 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
138 #define __TP_NARGS(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20, N, ...) N
139 #define _TP_PROTO_N(N, ...) _TP_PARAMS(_TP_COMBINE_TOKENS(_TP_EXPROTO, N)(__VA_ARGS__))
140 #define _TP_VAR_N(N, ...) _TP_PARAMS(_TP_COMBINE_TOKENS(_TP_EXVAR, N)(__VA_ARGS__))
141 #define _TP_DATA_PROTO_N(N, ...) _TP_PARAMS(_TP_COMBINE_TOKENS(_TP_EXDATA_PROTO, N)(__VA_ARGS__))
142 #define _TP_DATA_VAR_N(N, ...) _TP_PARAMS(_TP_COMBINE_TOKENS(_TP_EXDATA_VAR, N)(__VA_ARGS__))
143 #define _TP_ARGS_PROTO(...) _TP_PROTO_N(_TP_NARGS(0, ##__VA_ARGS__), ##__VA_ARGS__)
144 #define _TP_ARGS_VAR(...) _TP_VAR_N(_TP_NARGS(0, ##__VA_ARGS__), ##__VA_ARGS__)
145 #define _TP_ARGS_DATA_PROTO(...) _TP_DATA_PROTO_N(_TP_NARGS(0, ##__VA_ARGS__), ##__VA_ARGS__)
146 #define _TP_ARGS_DATA_VAR(...) _TP_DATA_VAR_N(_TP_NARGS(0, ##__VA_ARGS__), ##__VA_ARGS__)
147 #define _TP_PARAMS(...) __VA_ARGS__
148
149 /*
150 * The tracepoint cb is marked always inline so we can distinguish
151 * between caller's ip addresses within the probe using the return
152 * address.
153 */
154 #define _DECLARE_TRACEPOINT(_provider, _name, ...) \
155 extern struct lttng_ust_tracepoint __tracepoint_##_provider##___##_name; \
156 static inline __attribute__((always_inline, unused)) lttng_ust_notrace \
157 void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)); \
158 static \
159 void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) \
160 { \
161 struct lttng_ust_tracepoint_probe *__tp_probe; \
162 \
163 if (caa_unlikely(!TP_RCU_LINK_TEST())) \
164 return; \
165 tp_rcu_read_lock_bp(); \
166 __tp_probe = tp_rcu_dereference_bp(__tracepoint_##_provider##___##_name.probes); \
167 if (caa_unlikely(!__tp_probe)) \
168 goto end; \
169 do { \
170 void (*__tp_cb)(void) = __tp_probe->func; \
171 void *__tp_data = __tp_probe->data; \
172 \
173 URCU_FORCE_CAST(void (*)(_TP_ARGS_DATA_PROTO(__VA_ARGS__)), __tp_cb) \
174 (_TP_ARGS_DATA_VAR(__VA_ARGS__)); \
175 } while ((++__tp_probe)->func); \
176 end: \
177 tp_rcu_read_unlock_bp(); \
178 } \
179 static inline lttng_ust_notrace \
180 void __tracepoint_register_##_provider##___##_name(char *name, \
181 void (*func)(void), void *data); \
182 static inline \
183 void __tracepoint_register_##_provider##___##_name(char *name, \
184 void (*func)(void), void *data) \
185 { \
186 __tracepoint_probe_register(name, func, data, \
187 __tracepoint_##_provider##___##_name.signature); \
188 } \
189 static inline lttng_ust_notrace \
190 void __tracepoint_unregister_##_provider##___##_name(char *name, \
191 void (*func)(void), void *data); \
192 static inline \
193 void __tracepoint_unregister_##_provider##___##_name(char *name, \
194 void (*func)(void), void *data) \
195 { \
196 __tracepoint_probe_unregister(name, func, data); \
197 }
198
199 extern int __tracepoint_probe_register(const char *name, void (*func)(void),
200 void *data, const char *signature);
201 extern int __tracepoint_probe_unregister(const char *name, void (*func)(void),
202 void *data);
203
204 /*
205 * tracepoint dynamic linkage handling (callbacks). Hidden visibility:
206 * shared across objects in a module/main executable.
207 */
208 struct lttng_ust_tracepoint_dlopen {
209 void *liblttngust_handle;
210
211 int (*tracepoint_register_lib)(struct lttng_ust_tracepoint * const *tracepoints_start,
212 int tracepoints_count);
213 int (*tracepoint_unregister_lib)(struct lttng_ust_tracepoint * const *tracepoints_start);
214 #ifndef _LGPL_SOURCE
215 void (*rcu_read_lock_sym_bp)(void);
216 void (*rcu_read_unlock_sym_bp)(void);
217 void *(*rcu_dereference_sym_bp)(void *p);
218 #endif
219 };
220
221 extern struct lttng_ust_tracepoint_dlopen tracepoint_dlopen;
222
223 #if defined(TRACEPOINT_DEFINE) || defined(TRACEPOINT_CREATE_PROBES)
224
225 /*
226 * These weak symbols, the constructor, and destructor take care of
227 * registering only _one_ instance of the tracepoints per shared-ojbect
228 * (or for the whole main program).
229 */
230 int __tracepoint_registered
231 __attribute__((weak, visibility("hidden")));
232 int __tracepoint_ptrs_registered
233 __attribute__((weak, visibility("hidden")));
234 struct lttng_ust_tracepoint_dlopen tracepoint_dlopen
235 __attribute__((weak, visibility("hidden")));
236
237 #ifndef _LGPL_SOURCE
238 static inline void lttng_ust_notrace
239 __tracepoint__init_urcu_sym(void);
240 static inline void
241 __tracepoint__init_urcu_sym(void)
242 {
243 /*
244 * Symbols below are needed by tracepoint call sites and probe
245 * providers.
246 */
247 if (!tracepoint_dlopen.rcu_read_lock_sym_bp)
248 tracepoint_dlopen.rcu_read_lock_sym_bp =
249 URCU_FORCE_CAST(void (*)(void),
250 dlsym(tracepoint_dlopen.liblttngust_handle,
251 "tp_rcu_read_lock_bp"));
252 if (!tracepoint_dlopen.rcu_read_unlock_sym_bp)
253 tracepoint_dlopen.rcu_read_unlock_sym_bp =
254 URCU_FORCE_CAST(void (*)(void),
255 dlsym(tracepoint_dlopen.liblttngust_handle,
256 "tp_rcu_read_unlock_bp"));
257 if (!tracepoint_dlopen.rcu_dereference_sym_bp)
258 tracepoint_dlopen.rcu_dereference_sym_bp =
259 URCU_FORCE_CAST(void *(*)(void *p),
260 dlsym(tracepoint_dlopen.liblttngust_handle,
261 "tp_rcu_dereference_sym_bp"));
262 }
263 #else
264 static inline void lttng_ust_notrace
265 __tracepoint__init_urcu_sym(void);
266 static inline void
267 __tracepoint__init_urcu_sym(void)
268 {
269 }
270 #endif
271
272 static void lttng_ust_notrace __attribute__((constructor))
273 __tracepoints__init(void);
274 static void
275 __tracepoints__init(void)
276 {
277 if (__tracepoint_registered++)
278 return;
279
280 if (!tracepoint_dlopen.liblttngust_handle)
281 tracepoint_dlopen.liblttngust_handle =
282 dlopen("liblttng-ust-tracepoint.so.0", RTLD_NOW | RTLD_GLOBAL);
283 if (!tracepoint_dlopen.liblttngust_handle)
284 return;
285 __tracepoint__init_urcu_sym();
286 }
287
288 static void lttng_ust_notrace __attribute__((destructor))
289 __tracepoints__destroy(void);
290 static void
291 __tracepoints__destroy(void)
292 {
293 int ret;
294
295 if (--__tracepoint_registered)
296 return;
297 if (tracepoint_dlopen.liblttngust_handle && !__tracepoint_ptrs_registered) {
298 ret = dlclose(tracepoint_dlopen.liblttngust_handle);
299 if (ret) {
300 fprintf(stderr, "Error (%d) in dlclose\n", ret);
301 abort();
302 }
303 memset(&tracepoint_dlopen, 0, sizeof(tracepoint_dlopen));
304 }
305 }
306
307 #endif
308
309 #ifdef TRACEPOINT_DEFINE
310
311 /*
312 * These weak symbols, the constructor, and destructor take care of
313 * registering only _one_ instance of the tracepoints per shared-ojbect
314 * (or for the whole main program).
315 */
316 extern struct lttng_ust_tracepoint * const __start___tracepoints_ptrs[]
317 __attribute__((weak, visibility("hidden")));
318 extern struct lttng_ust_tracepoint * const __stop___tracepoints_ptrs[]
319 __attribute__((weak, visibility("hidden")));
320
321 /*
322 * When TRACEPOINT_PROBE_DYNAMIC_LINKAGE is defined, we do not emit a
323 * unresolved symbol that requires the provider to be linked in. When
324 * TRACEPOINT_PROBE_DYNAMIC_LINKAGE is not defined, we emit an
325 * unresolved symbol that depends on having the provider linked in,
326 * otherwise the linker complains. This deals with use of static
327 * libraries, ensuring that the linker does not remove the provider
328 * object from the executable.
329 */
330 #ifdef TRACEPOINT_PROBE_DYNAMIC_LINKAGE
331 #define _TRACEPOINT_UNDEFINED_REF(provider) NULL
332 #else /* TRACEPOINT_PROBE_DYNAMIC_LINKAGE */
333 #define _TRACEPOINT_UNDEFINED_REF(provider) &__tracepoint_provider_##provider
334 #endif /* TRACEPOINT_PROBE_DYNAMIC_LINKAGE */
335
336 /*
337 * Note: to allow PIC code, we need to allow the linker to update the pointers
338 * in the __tracepoints_ptrs section.
339 * Therefore, this section is _not_ const (read-only).
340 */
341 #define _TP_EXTRACT_STRING(...) #__VA_ARGS__
342
343 #define _DEFINE_TRACEPOINT(_provider, _name, _args) \
344 extern int __tracepoint_provider_##_provider; \
345 static const char __tp_strtab_##_provider##___##_name[] \
346 __attribute__((section("__tracepoints_strings"))) = \
347 #_provider ":" #_name; \
348 struct lttng_ust_tracepoint __tracepoint_##_provider##___##_name \
349 __attribute__((section("__tracepoints"))) = \
350 { \
351 __tp_strtab_##_provider##___##_name, \
352 0, \
353 NULL, \
354 _TRACEPOINT_UNDEFINED_REF(_provider), \
355 _TP_EXTRACT_STRING(_args), \
356 { }, \
357 }; \
358 static struct lttng_ust_tracepoint * \
359 __tracepoint_ptr_##_provider##___##_name \
360 __attribute__((used, section("__tracepoints_ptrs"))) = \
361 &__tracepoint_##_provider##___##_name;
362
363 static void lttng_ust_notrace __attribute__((constructor))
364 __tracepoints__ptrs_init(void);
365 static void
366 __tracepoints__ptrs_init(void)
367 {
368 if (__tracepoint_ptrs_registered++)
369 return;
370 if (!tracepoint_dlopen.liblttngust_handle)
371 tracepoint_dlopen.liblttngust_handle =
372 dlopen("liblttng-ust-tracepoint.so.0", RTLD_NOW | RTLD_GLOBAL);
373 if (!tracepoint_dlopen.liblttngust_handle)
374 return;
375 tracepoint_dlopen.tracepoint_register_lib =
376 URCU_FORCE_CAST(int (*)(struct lttng_ust_tracepoint * const *, int),
377 dlsym(tracepoint_dlopen.liblttngust_handle,
378 "tracepoint_register_lib"));
379 tracepoint_dlopen.tracepoint_unregister_lib =
380 URCU_FORCE_CAST(int (*)(struct lttng_ust_tracepoint * const *),
381 dlsym(tracepoint_dlopen.liblttngust_handle,
382 "tracepoint_unregister_lib"));
383 __tracepoint__init_urcu_sym();
384 if (tracepoint_dlopen.tracepoint_register_lib) {
385 tracepoint_dlopen.tracepoint_register_lib(__start___tracepoints_ptrs,
386 __stop___tracepoints_ptrs -
387 __start___tracepoints_ptrs);
388 }
389 }
390
391 static void lttng_ust_notrace __attribute__((destructor))
392 __tracepoints__ptrs_destroy(void);
393 static void
394 __tracepoints__ptrs_destroy(void)
395 {
396 int ret;
397
398 if (--__tracepoint_ptrs_registered)
399 return;
400 if (tracepoint_dlopen.tracepoint_unregister_lib)
401 tracepoint_dlopen.tracepoint_unregister_lib(__start___tracepoints_ptrs);
402 if (tracepoint_dlopen.liblttngust_handle && !__tracepoint_registered) {
403 ret = dlclose(tracepoint_dlopen.liblttngust_handle);
404 if (ret) {
405 fprintf(stderr, "Error (%d) in dlclose\n", ret);
406 abort();
407 }
408 memset(&tracepoint_dlopen, 0, sizeof(tracepoint_dlopen));
409 }
410 }
411
412 #else /* TRACEPOINT_DEFINE */
413
414 #define _DEFINE_TRACEPOINT(_provider, _name, _args)
415
416 #endif /* #else TRACEPOINT_DEFINE */
417
418 #ifdef __cplusplus
419 }
420 #endif
421
422 #endif /* _LTTNG_TRACEPOINT_H */
423
424 /* The following declarations must be outside re-inclusion protection. */
425
426 #ifndef TRACEPOINT_EVENT
427
428 /*
429 * How to use the TRACEPOINT_EVENT macro:
430 *
431 * An example:
432 *
433 * TRACEPOINT_EVENT(someproject_component, event_name,
434 *
435 * * TP_ARGS takes from 0 to 10 "type, field_name" pairs *
436 *
437 * TP_ARGS(int, arg0, void *, arg1, char *, string, size_t, strlen,
438 * long *, arg4, size_t, arg4_len),
439 *
440 * * TP_FIELDS describes the event payload layout in the trace *
441 *
442 * TP_FIELDS(
443 * * Integer, printed in base 10 *
444 * ctf_integer(int, field_a, arg0)
445 *
446 * * Integer, printed with 0x base 16 *
447 * ctf_integer_hex(unsigned long, field_d, arg1)
448 *
449 * * Array Sequence, printed as UTF8-encoded array of bytes *
450 * ctf_array_text(char, field_b, string, FIXED_LEN)
451 * ctf_sequence_text(char, field_c, string, size_t, strlen)
452 *
453 * * String, printed as UTF8-encoded string *
454 * ctf_string(field_e, string)
455 *
456 * * Array sequence of signed integer values *
457 * ctf_array(long, field_f, arg4, FIXED_LEN4)
458 * ctf_sequence(long, field_g, arg4, size_t, arg4_len)
459 * )
460 * )
461 *
462 * More detailed explanation:
463 *
464 * The name of the tracepoint is expressed as a tuple with the provider
465 * and name arguments.
466 *
467 * The provider and name should be a proper C99 identifier.
468 * The "provider" and "name" MUST follow these rules to ensure no
469 * namespace clash occurs:
470 *
471 * For projects (applications and libraries) for which an entity
472 * specific to the project controls the source code and thus its
473 * tracepoints (typically with a scope larger than a single company):
474 *
475 * either:
476 * project_component, event
477 * or:
478 * project, event
479 *
480 * Where "project" is the name of the project,
481 * "component" is the name of the project component (which may
482 * include several levels of sub-components, e.g.
483 * ...component_subcomponent_...) where the tracepoint is located
484 * (optional),
485 * "event" is the name of the tracepoint event.
486 *
487 * For projects issued from a single company wishing to advertise that
488 * the company controls the source code and thus the tracepoints, the
489 * "com_" prefix should be used:
490 *
491 * either:
492 * com_company_project_component, event
493 * or:
494 * com_company_project, event
495 *
496 * Where "company" is the name of the company,
497 * "project" is the name of the project,
498 * "component" is the name of the project component (which may
499 * include several levels of sub-components, e.g.
500 * ...component_subcomponent_...) where the tracepoint is located
501 * (optional),
502 * "event" is the name of the tracepoint event.
503 *
504 * the provider:event identifier is limited to 127 characters.
505 */
506
507 #define TRACEPOINT_EVENT(provider, name, args, fields) \
508 _DECLARE_TRACEPOINT(provider, name, _TP_PARAMS(args)) \
509 _DEFINE_TRACEPOINT(provider, name, _TP_PARAMS(args))
510
511 #define TRACEPOINT_EVENT_CLASS(provider, name, args, fields)
512
513 #define TRACEPOINT_EVENT_INSTANCE(provider, _template, name, args) \
514 _DECLARE_TRACEPOINT(provider, name, _TP_PARAMS(args)) \
515 _DEFINE_TRACEPOINT(provider, name, _TP_PARAMS(args))
516
517 #endif /* #ifndef TRACEPOINT_EVENT */
518
519 #ifndef TRACEPOINT_LOGLEVEL
520
521 /*
522 * Tracepoint Loglevels
523 *
524 * Typical use of these loglevels:
525 *
526 * The loglevels go from 0 to 14. Higher numbers imply the most
527 * verbosity (higher event throughput expected.
528 *
529 * Loglevels 0 through 6, and loglevel 14, match syslog(3) loglevels
530 * semantic. Loglevels 7 through 13 offer more fine-grained selection of
531 * debug information.
532 *
533 * TRACE_EMERG 0
534 * system is unusable
535 *
536 * TRACE_ALERT 1
537 * action must be taken immediately
538 *
539 * TRACE_CRIT 2
540 * critical conditions
541 *
542 * TRACE_ERR 3
543 * error conditions
544 *
545 * TRACE_WARNING 4
546 * warning conditions
547 *
548 * TRACE_NOTICE 5
549 * normal, but significant, condition
550 *
551 * TRACE_INFO 6
552 * informational message
553 *
554 * TRACE_DEBUG_SYSTEM 7
555 * debug information with system-level scope (set of programs)
556 *
557 * TRACE_DEBUG_PROGRAM 8
558 * debug information with program-level scope (set of processes)
559 *
560 * TRACE_DEBUG_PROCESS 9
561 * debug information with process-level scope (set of modules)
562 *
563 * TRACE_DEBUG_MODULE 10
564 * debug information with module (executable/library) scope (set of units)
565 *
566 * TRACE_DEBUG_UNIT 11
567 * debug information with compilation unit scope (set of functions)
568 *
569 * TRACE_DEBUG_FUNCTION 12
570 * debug information with function-level scope
571 *
572 * TRACE_DEBUG_LINE 13
573 * debug information with line-level scope (TRACEPOINT_EVENT default)
574 *
575 * TRACE_DEBUG 14
576 * debug-level message
577 *
578 * Declare tracepoint loglevels for tracepoints. A TRACEPOINT_EVENT
579 * should be declared prior to the the TRACEPOINT_LOGLEVEL for a given
580 * tracepoint name. The first field is the provider name, the second
581 * field is the name of the tracepoint, the third field is the loglevel
582 * name.
583 *
584 * TRACEPOINT_LOGLEVEL(< [com_company_]project[_component] >, < event >,
585 * < loglevel_name >)
586 *
587 * The TRACEPOINT_PROVIDER must be already declared before declaring a
588 * TRACEPOINT_LOGLEVEL.
589 */
590
591 enum {
592 TRACE_EMERG = 0,
593 TRACE_ALERT = 1,
594 TRACE_CRIT = 2,
595 TRACE_ERR = 3,
596 TRACE_WARNING = 4,
597 TRACE_NOTICE = 5,
598 TRACE_INFO = 6,
599 TRACE_DEBUG_SYSTEM = 7,
600 TRACE_DEBUG_PROGRAM = 8,
601 TRACE_DEBUG_PROCESS = 9,
602 TRACE_DEBUG_MODULE = 10,
603 TRACE_DEBUG_UNIT = 11,
604 TRACE_DEBUG_FUNCTION = 12,
605 TRACE_DEBUG_LINE = 13,
606 TRACE_DEBUG = 14,
607 };
608
609 #define TRACEPOINT_LOGLEVEL(provider, name, loglevel)
610
611 #endif /* #ifndef TRACEPOINT_LOGLEVEL */
612
613 #ifndef TRACEPOINT_MODEL_EMF_URI
614
615 #define TRACEPOINT_MODEL_EMF_URI(provider, name, uri)
616
617 #endif /* #ifndef TRACEPOINT_MODEL_EMF_URI */
This page took 0.042651 seconds and 4 git commands to generate.