Filter: use only single lower bit of filter return value
[lttng-ust.git] / include / lttng / ust-tracepoint-event.h
1 /*
2 * Copyright (c) 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 */
14
15 #include <stdio.h>
16 #include <urcu/compiler.h>
17 #include <urcu/rculist.h>
18 #include <lttng/ust-events.h>
19 #include <lttng/ringbuffer-config.h>
20 #include <lttng/ust-compiler.h>
21 #include <string.h>
22
23 /*
24 * TRACEPOINT_EVENT_CLASS declares a class of tracepoints receiving the
25 * same arguments and having the same field layout.
26 *
27 * TRACEPOINT_EVENT_INSTANCE declares an instance of a tracepoint, with
28 * its own provider and name. It refers to a class (template).
29 *
30 * TRACEPOINT_EVENT declared both a class and an instance and does a
31 * direct mapping from the instance to the class.
32 */
33
34 #undef TRACEPOINT_EVENT
35 #define TRACEPOINT_EVENT(_provider, _name, _args, _fields) \
36 TRACEPOINT_EVENT_CLASS(_provider, _name, \
37 _TP_PARAMS(_args), \
38 _TP_PARAMS(_fields)) \
39 TRACEPOINT_EVENT_INSTANCE(_provider, _name, _name, \
40 _TP_PARAMS(_args))
41
42 /* Helpers */
43 #define _TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
44
45 #define _tp_max_t(type, x, y) \
46 ({ \
47 type __max1 = (x); \
48 type __max2 = (y); \
49 __max1 > __max2 ? __max1: __max2; \
50 })
51
52 /*
53 * Stage 0 of tracepoint event generation.
54 *
55 * Check that each TRACEPOINT_EVENT provider argument match the
56 * TRACEPOINT_PROVIDER by creating dummy callbacks.
57 */
58
59 /* Reset all macros within TRACEPOINT_EVENT */
60 #include <lttng/ust-tracepoint-event-reset.h>
61
62 static inline
63 void _TP_COMBINE_TOKENS(__tracepoint_provider_mismatch_, TRACEPOINT_PROVIDER)(void)
64 {
65 }
66
67 #undef TRACEPOINT_EVENT_CLASS
68 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
69 __tracepoint_provider_mismatch_##_provider();
70
71 #undef TRACEPOINT_EVENT_INSTANCE
72 #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
73 __tracepoint_provider_mismatch_##_provider();
74
75 static __attribute__((unused))
76 void _TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)(void)
77 {
78 #include TRACEPOINT_INCLUDE
79 }
80
81 /*
82 * Stage 0.1 of tracepoint event generation.
83 *
84 * Check that each TRACEPOINT_EVENT provider:name does not exceed the
85 * tracepoint name length limit.
86 */
87
88 /* Reset all macros within TRACEPOINT_EVENT */
89 #include <lttng/ust-tracepoint-event-reset.h>
90
91 #undef TRACEPOINT_EVENT_INSTANCE
92 #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
93 static const char \
94 __tp_name_len_check##_provider##___##_name[LTTNG_UST_SYM_NAME_LEN] \
95 __attribute__((unused)) = \
96 #_provider ":" #_name;
97
98 #include TRACEPOINT_INCLUDE
99
100 /*
101 * Stage 1 of tracepoint event generation.
102 *
103 * Create event field type metadata section.
104 * Each event produce an array of fields.
105 */
106
107 /* Reset all macros within TRACEPOINT_EVENT */
108 #include <lttng/ust-tracepoint-event-reset.h>
109 #include <lttng/ust-tracepoint-event-write.h>
110 #include <lttng/ust-tracepoint-event-nowrite.h>
111
112 #undef _ctf_integer_ext
113 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
114 { \
115 .name = #_item, \
116 .type = __type_integer(_type, _byte_order, _base, none),\
117 .nowrite = _nowrite, \
118 },
119
120 #undef _ctf_float
121 #define _ctf_float(_type, _item, _src, _nowrite) \
122 { \
123 .name = #_item, \
124 .type = __type_float(_type), \
125 .nowrite = _nowrite, \
126 },
127
128 #undef _ctf_array_encoded
129 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \
130 { \
131 .name = #_item, \
132 .type = \
133 { \
134 .atype = atype_array, \
135 .u.array = \
136 { \
137 .length = _length, \
138 .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \
139 }, \
140 }, \
141 .nowrite = _nowrite, \
142 },
143
144 #undef _ctf_sequence_encoded
145 #define _ctf_sequence_encoded(_type, _item, _src, \
146 _length_type, _src_length, _encoding, _nowrite) \
147 { \
148 .name = #_item, \
149 .type = \
150 { \
151 .atype = atype_sequence, \
152 .u.sequence = \
153 { \
154 .length_type = __type_integer(_length_type, BYTE_ORDER, 10, none), \
155 .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \
156 }, \
157 }, \
158 .nowrite = _nowrite, \
159 },
160
161 #undef _ctf_string
162 #define _ctf_string(_item, _src, _nowrite) \
163 { \
164 .name = #_item, \
165 .type = \
166 { \
167 .atype = atype_string, \
168 .u.basic.string.encoding = lttng_encode_UTF8, \
169 }, \
170 .nowrite = _nowrite, \
171 },
172
173 #undef TP_FIELDS
174 #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
175
176 #undef TRACEPOINT_EVENT_CLASS
177 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
178 static const struct lttng_event_field __event_fields___##_provider##___##_name[] = { \
179 _fields \
180 };
181
182 #include TRACEPOINT_INCLUDE
183
184 /*
185 * Stage 2 of tracepoint event generation.
186 *
187 * Create probe callback prototypes.
188 */
189
190 /* Reset all macros within TRACEPOINT_EVENT */
191 #include <lttng/ust-tracepoint-event-reset.h>
192
193 #undef TP_ARGS
194 #define TP_ARGS(...) __VA_ARGS__
195
196 #undef TRACEPOINT_EVENT_CLASS
197 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
198 static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
199
200 #include TRACEPOINT_INCLUDE
201
202 /*
203 * Stage 3 of tracepoint event generation.
204 *
205 * Create static inline function that calculates event size.
206 */
207
208 /* Reset all macros within TRACEPOINT_EVENT */
209 #include <lttng/ust-tracepoint-event-reset.h>
210 #include <lttng/ust-tracepoint-event-write.h>
211
212 #undef _ctf_integer_ext
213 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
214 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
215 __event_len += sizeof(_type);
216
217 #undef _ctf_float
218 #define _ctf_float(_type, _item, _src, _nowrite) \
219 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
220 __event_len += sizeof(_type);
221
222 #undef _ctf_array_encoded
223 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \
224 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
225 __event_len += sizeof(_type) * (_length);
226
227 #undef _ctf_sequence_encoded
228 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
229 _src_length, _encoding, _nowrite) \
230 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
231 __event_len += sizeof(_length_type); \
232 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
233 __dynamic_len[__dynamic_len_idx] = (_src_length); \
234 __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \
235 __dynamic_len_idx++;
236
237 #undef _ctf_string
238 #define _ctf_string(_item, _src, _nowrite) \
239 __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1;
240
241 #undef TP_ARGS
242 #define TP_ARGS(...) __VA_ARGS__
243
244 #undef TP_FIELDS
245 #define TP_FIELDS(...) __VA_ARGS__
246
247 #undef TRACEPOINT_EVENT_CLASS
248 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
249 static inline lttng_ust_notrace \
250 size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)); \
251 static inline \
252 size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
253 { \
254 size_t __event_len = 0; \
255 unsigned int __dynamic_len_idx = 0; \
256 \
257 if (0) \
258 (void) __dynamic_len_idx; /* don't warn if unused */ \
259 _fields \
260 return __event_len; \
261 }
262
263 #include TRACEPOINT_INCLUDE
264
265 /*
266 * Stage 3.1 of tracepoint event generation.
267 *
268 * Create static inline function that layout the filter stack data.
269 * We make both write and nowrite data available to the filter.
270 */
271
272 /* Reset all macros within TRACEPOINT_EVENT */
273 #include <lttng/ust-tracepoint-event-reset.h>
274 #include <lttng/ust-tracepoint-event-write.h>
275 #include <lttng/ust-tracepoint-event-nowrite.h>
276
277 #undef _ctf_integer_ext
278 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
279 if (lttng_is_signed_type(_type)) { \
280 int64_t __ctf_tmp_int64 = (int64_t) (_type) (_src); \
281 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
282 } else { \
283 uint64_t __ctf_tmp_uint64 = (uint64_t) (_type) (_src); \
284 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
285 } \
286 __stack_data += sizeof(int64_t);
287
288 #undef _ctf_float
289 #define _ctf_float(_type, _item, _src, _nowrite) \
290 { \
291 double __ctf_tmp_double = (double) (_type) (_src); \
292 memcpy(__stack_data, &__ctf_tmp_double, sizeof(double)); \
293 __stack_data += sizeof(double); \
294 }
295
296 #undef _ctf_array_encoded
297 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \
298 { \
299 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
300 const void *__ctf_tmp_ptr = (_src); \
301 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
302 __stack_data += sizeof(unsigned long); \
303 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void **)); \
304 __stack_data += sizeof(void **); \
305 }
306
307 #undef _ctf_sequence_encoded
308 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
309 _src_length, _encoding, _nowrite) \
310 { \
311 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
312 const void *__ctf_tmp_ptr = (_src); \
313 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
314 __stack_data += sizeof(unsigned long); \
315 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void **)); \
316 __stack_data += sizeof(void **); \
317 }
318
319 #undef _ctf_string
320 #define _ctf_string(_item, _src, _nowrite) \
321 { \
322 const void *__ctf_tmp_ptr = (_src); \
323 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void **)); \
324 __stack_data += sizeof(void **); \
325 }
326
327 #undef TP_ARGS
328 #define TP_ARGS(...) __VA_ARGS__
329
330 #undef TP_FIELDS
331 #define TP_FIELDS(...) __VA_ARGS__
332
333 #undef TRACEPOINT_EVENT_CLASS
334 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
335 static inline \
336 void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
337 _TP_ARGS_DATA_PROTO(_args)) \
338 { \
339 _fields \
340 }
341
342 #include TRACEPOINT_INCLUDE
343
344
345
346 /*
347 * Stage 4 of tracepoint event generation.
348 *
349 * Create static inline function that calculates event payload alignment.
350 */
351
352 /* Reset all macros within TRACEPOINT_EVENT */
353 #include <lttng/ust-tracepoint-event-reset.h>
354 #include <lttng/ust-tracepoint-event-write.h>
355
356 #undef _ctf_integer_ext
357 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
358 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
359
360 #undef _ctf_float
361 #define _ctf_float(_type, _item, _src, _nowrite) \
362 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
363
364 #undef _ctf_array_encoded
365 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \
366 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
367
368 #undef _ctf_sequence_encoded
369 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
370 _src_length, _encoding, _nowrite) \
371 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_length_type)); \
372 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
373
374 #undef _ctf_string
375 #define _ctf_string(_item, _src, _nowrite)
376
377 #undef TP_ARGS
378 #define TP_ARGS(...) __VA_ARGS__
379
380 #undef TP_FIELDS
381 #define TP_FIELDS(...) __VA_ARGS__
382
383 #undef TRACEPOINT_EVENT_CLASS
384 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
385 static inline lttng_ust_notrace \
386 size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)); \
387 static inline \
388 size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \
389 { \
390 size_t __event_align = 1; \
391 _fields \
392 return __event_align; \
393 }
394
395 #include TRACEPOINT_INCLUDE
396
397
398 /*
399 * Stage 5 of tracepoint event generation.
400 *
401 * Create the probe function. This function calls event size calculation
402 * and writes event data into the buffer.
403 */
404
405 /* Reset all macros within TRACEPOINT_EVENT */
406 #include <lttng/ust-tracepoint-event-reset.h>
407 #include <lttng/ust-tracepoint-event-write.h>
408
409 #undef _ctf_integer_ext
410 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
411 { \
412 _type __tmp = (_src); \
413 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
414 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
415 }
416
417 #undef _ctf_float
418 #define _ctf_float(_type, _item, _src, _nowrite) \
419 { \
420 _type __tmp = (_src); \
421 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
422 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
423 }
424
425 #undef _ctf_array_encoded
426 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \
427 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
428 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length));
429
430 #undef _ctf_sequence_encoded
431 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
432 _src_length, _encoding, _nowrite) \
433 { \
434 _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx]; \
435 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
436 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
437 } \
438 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
439 __chan->ops->event_write(&__ctx, _src, \
440 sizeof(_type) * __get_dynamic_len(dest));
441
442 #undef _ctf_string
443 #define _ctf_string(_item, _src, _nowrite) \
444 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
445 __chan->ops->event_write(&__ctx, _src, __get_dynamic_len(dest));
446
447 /* Beware: this get len actually consumes the len value */
448 #undef __get_dynamic_len
449 #define __get_dynamic_len(field) __stackvar.__dynamic_len[__dynamic_len_idx++]
450
451 #undef TP_ARGS
452 #define TP_ARGS(...) __VA_ARGS__
453
454 #undef TP_FIELDS
455 #define TP_FIELDS(...) __VA_ARGS__
456
457 /*
458 * Using twice size for filter stack data to hold size and pointer for
459 * each field (worse case). For integers, max size required is 64-bit.
460 * Same for double-precision floats. Those fit within
461 * 2*sizeof(unsigned long) for all supported architectures.
462 * Perform UNION (||) of filter runtime list.
463 */
464 #undef TRACEPOINT_EVENT_CLASS
465 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
466 static lttng_ust_notrace \
467 void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)); \
468 static \
469 void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) \
470 { \
471 struct lttng_event *__event = __tp_data; \
472 struct lttng_channel *__chan = __event->chan; \
473 struct lttng_ust_lib_ring_buffer_ctx __ctx; \
474 size_t __event_len, __event_align; \
475 size_t __dynamic_len_idx = 0; \
476 union { \
477 size_t __dynamic_len[_TP_ARRAY_SIZE(__event_fields___##_provider##___##_name)]; \
478 char __filter_stack_data[2 * sizeof(unsigned long) * _TP_ARRAY_SIZE(__event_fields___##_provider##___##_name)]; \
479 } __stackvar; \
480 int __ret; \
481 \
482 if (0) \
483 (void) __dynamic_len_idx; /* don't warn if unused */ \
484 if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->session->active))) \
485 return; \
486 if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->enabled))) \
487 return; \
488 if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \
489 return; \
490 if (caa_unlikely(!cds_list_empty(&__event->bytecode_runtime_head))) { \
491 struct lttng_bytecode_runtime *bc_runtime; \
492 int __filter_record = 0; \
493 \
494 __event_prepare_filter_stack__##_provider##___##_name(__stackvar.__filter_stack_data, \
495 _TP_ARGS_DATA_VAR(_args)); \
496 cds_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
497 if (caa_unlikely(bc_runtime->filter(bc_runtime, \
498 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
499 __filter_record = 1; \
500 } \
501 if (caa_likely(!__filter_record)) \
502 return; \
503 } \
504 __event_len = __event_get_size__##_provider##___##_name(__stackvar.__dynamic_len, \
505 _TP_ARGS_DATA_VAR(_args)); \
506 __event_align = __event_get_align__##_provider##___##_name(_TP_ARGS_VAR(_args)); \
507 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \
508 __event_align, -1, __chan->handle); \
509 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
510 if (__ret < 0) \
511 return; \
512 _fields \
513 __chan->ops->event_commit(&__ctx); \
514 }
515
516 #include TRACEPOINT_INCLUDE
517
518 #undef __get_dynamic_len
519
520 /*
521 * Stage 5.1 of tracepoint event generation.
522 *
523 * Create probe signature
524 */
525
526 /* Reset all macros within TRACEPOINT_EVENT */
527 #include <lttng/ust-tracepoint-event-reset.h>
528
529 #undef TP_ARGS
530 #define TP_ARGS(...) __VA_ARGS__
531
532 #define _TP_EXTRACT_STRING2(...) #__VA_ARGS__
533
534 #undef TRACEPOINT_EVENT_CLASS
535 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
536 const char __tp_event_signature___##_provider##___##_name[] = \
537 _TP_EXTRACT_STRING2(_args);
538
539 #include TRACEPOINT_INCLUDE
540
541 #undef _TP_EXTRACT_STRING2
542
543 /*
544 * Stage 6 of tracepoint event generation.
545 *
546 * Tracepoint loglevel mapping definition generation. We generate a
547 * symbol for each mapping for a provider/event to ensure at most a 1 to
548 * 1 mapping between events and loglevels. If the symbol is repeated,
549 * the compiler will complain.
550 */
551
552 /* Reset all macros within TRACEPOINT_EVENT */
553 #include <lttng/ust-tracepoint-event-reset.h>
554
555 #undef TRACEPOINT_LOGLEVEL
556 #define TRACEPOINT_LOGLEVEL(__provider, __name, __loglevel) \
557 static const int _loglevel_value___##__provider##___##__name = __loglevel; \
558 static const int *_loglevel___##__provider##___##__name = \
559 &_loglevel_value___##__provider##___##__name;
560
561 #include TRACEPOINT_INCLUDE
562
563 /*
564 * Stage 6.1 of tracepoint event generation.
565 *
566 * Tracepoint UML URI info.
567 */
568
569 /* Reset all macros within TRACEPOINT_EVENT */
570 #include <lttng/ust-tracepoint-event-reset.h>
571
572 #undef TRACEPOINT_MODEL_EMF_URI
573 #define TRACEPOINT_MODEL_EMF_URI(__provider, __name, __uri) \
574 static const char *_model_emf_uri___##__provider##___##__name = __uri;
575
576 #include TRACEPOINT_INCLUDE
577
578 /*
579 * Stage 7.1 of tracepoint event generation.
580 *
581 * Create events description structures. We use a weakref because
582 * loglevels are optional. If not declared, the event will point to the
583 * a loglevel that contains NULL.
584 */
585
586 /* Reset all macros within TRACEPOINT_EVENT */
587 #include <lttng/ust-tracepoint-event-reset.h>
588
589 #undef TRACEPOINT_EVENT_INSTANCE
590 #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
591 static const int * \
592 __ref_loglevel___##_provider##___##_name \
593 __attribute__((weakref ("_loglevel___" #_provider "___" #_name))); \
594 static const char * \
595 __ref_model_emf_uri___##_provider##___##_name \
596 __attribute__((weakref ("_model_emf_uri___" #_provider "___" #_name)));\
597 const struct lttng_event_desc __event_desc___##_provider##_##_name = { \
598 .fields = __event_fields___##_provider##___##_template, \
599 .name = #_provider ":" #_name, \
600 .probe_callback = (void (*)(void)) &__event_probe__##_provider##___##_template,\
601 .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \
602 .loglevel = &__ref_loglevel___##_provider##___##_name, \
603 .signature = __tp_event_signature___##_provider##___##_template, \
604 .u.ext.model_emf_uri = &__ref_model_emf_uri___##_provider##___##_name, \
605 };
606
607 #include TRACEPOINT_INCLUDE
608
609 /*
610 * Stage 7.2 of tracepoint event generation.
611 *
612 * Create array of events.
613 */
614
615 /* Reset all macros within TRACEPOINT_EVENT */
616 #include <lttng/ust-tracepoint-event-reset.h>
617
618 #undef TRACEPOINT_EVENT_INSTANCE
619 #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
620 &__event_desc___##_provider##_##_name,
621
622 static const struct lttng_event_desc *_TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)[] = {
623 #include TRACEPOINT_INCLUDE
624 };
625
626
627 /*
628 * Stage 8 of tracepoint event generation.
629 *
630 * Create a toplevel descriptor for the whole probe.
631 */
632
633 /* non-const because list head will be modified when registered. */
634 static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER) = {
635 .provider = __tp_stringify(TRACEPOINT_PROVIDER),
636 .event_desc = _TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER),
637 .nr_events = _TP_ARRAY_SIZE(_TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)),
638 };
639
640 /*
641 * Stage 9 of tracepoint event generation.
642 *
643 * Register/unregister probes at module load/unload.
644 *
645 * Generate the constructor as an externally visible symbol for use when
646 * linking the probe statically.
647 */
648
649 /* Reset all macros within TRACEPOINT_EVENT */
650 #include <lttng/ust-tracepoint-event-reset.h>
651 static void lttng_ust_notrace __attribute__((constructor))
652 _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void);
653 static void
654 _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
655 {
656 int ret;
657
658 ret = lttng_probe_register(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
659 assert(!ret);
660 }
661
662 static void lttng_ust_notrace __attribute__((destructor))
663 _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void);
664 static void
665 _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
666 {
667 lttng_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
668 }
669
670 int _TP_COMBINE_TOKENS(__tracepoint_provider_, TRACEPOINT_PROVIDER);
This page took 0.048902 seconds and 5 git commands to generate.