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