2 * Copyright (c) 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 #include <urcu/compiler.h>
26 #include <urcu/rculist.h>
27 #include <lttng/ust-events.h>
28 #include <lttng/ringbuffer-config.h>
29 #include <lttng/ust-compiler.h>
30 #include <lttng/tracepoint.h>
33 #undef tp_list_for_each_entry_rcu
34 #define tp_list_for_each_entry_rcu(pos, head, member) \
35 for (pos = cds_list_entry(tp_rcu_dereference_bp((head)->next), __typeof__(*pos), member); \
36 &pos->member != (head); \
37 pos = cds_list_entry(tp_rcu_dereference_bp(pos->member.next), __typeof__(*pos), member))
40 * TRACEPOINT_EVENT_CLASS declares a class of tracepoints receiving the
41 * same arguments and having the same field layout.
43 * TRACEPOINT_EVENT_INSTANCE declares an instance of a tracepoint, with
44 * its own provider and name. It refers to a class (template).
46 * TRACEPOINT_EVENT declared both a class and an instance and does a
47 * direct mapping from the instance to the class.
50 #undef TRACEPOINT_EVENT
51 #define TRACEPOINT_EVENT(_provider, _name, _args, _fields) \
52 TRACEPOINT_EVENT_CLASS(_provider, _name, \
54 _TP_PARAMS(_fields)) \
55 TRACEPOINT_EVENT_INSTANCE(_provider, _name, _name, \
59 #define _TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
61 #define _tp_max_t(type, x, y) \
65 __max1 > __max2 ? __max1: __max2; \
69 * Stage 0 of tracepoint event generation.
71 * Check that each TRACEPOINT_EVENT provider argument match the
72 * TRACEPOINT_PROVIDER by creating dummy callbacks.
75 /* Reset all macros within TRACEPOINT_EVENT */
76 #include <lttng/ust-tracepoint-event-reset.h>
79 void _TP_COMBINE_TOKENS(__tracepoint_provider_mismatch_
, TRACEPOINT_PROVIDER
)(void)
83 #undef TRACEPOINT_EVENT_CLASS
84 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
85 __tracepoint_provider_mismatch_##_provider();
87 #undef TRACEPOINT_EVENT_INSTANCE
88 #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
89 __tracepoint_provider_mismatch_##_provider();
92 void _TP_COMBINE_TOKENS(__tracepoint_provider_check_
, TRACEPOINT_PROVIDER
)(void)
94 #include TRACEPOINT_INCLUDE
98 * Stage 0.1 of tracepoint event generation.
100 * Check that each TRACEPOINT_EVENT provider:name does not exceed the
101 * tracepoint name length limit.
104 /* Reset all macros within TRACEPOINT_EVENT */
105 #include <lttng/ust-tracepoint-event-reset.h>
107 #undef TRACEPOINT_EVENT_INSTANCE
108 #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
110 __tp_name_len_check##_provider##___##_name[LTTNG_UST_SYM_NAME_LEN] \
111 __attribute__((unused)) = \
112 #_provider ":" #_name;
114 #include TRACEPOINT_INCLUDE
117 * Stage 1 of tracepoint event generation.
119 * Create event field type metadata section.
120 * Each event produce an array of fields.
123 /* Reset all macros within TRACEPOINT_EVENT */
124 #include <lttng/ust-tracepoint-event-reset.h>
125 #include <lttng/ust-tracepoint-event-write.h>
126 #include <lttng/ust-tracepoint-event-nowrite.h>
128 #undef _ctf_integer_ext
129 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
132 .type = __type_integer(_type, _byte_order, _base, none),\
133 .nowrite = _nowrite, \
137 #define _ctf_float(_type, _item, _src, _nowrite) \
140 .type = __type_float(_type), \
141 .nowrite = _nowrite, \
144 #undef _ctf_array_encoded
145 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \
150 .atype = atype_array, \
154 .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \
157 .nowrite = _nowrite, \
160 #undef _ctf_sequence_encoded
161 #define _ctf_sequence_encoded(_type, _item, _src, \
162 _length_type, _src_length, _encoding, _nowrite) \
167 .atype = atype_sequence, \
170 .length_type = __type_integer(_length_type, BYTE_ORDER, 10, none), \
171 .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \
174 .nowrite = _nowrite, \
178 #define _ctf_string(_item, _src, _nowrite) \
183 .atype = atype_string, \
184 .u.basic.string.encoding = lttng_encode_UTF8, \
186 .nowrite = _nowrite, \
190 #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
192 #undef TRACEPOINT_EVENT_CLASS
193 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
194 static const struct lttng_event_field __event_fields___##_provider##___##_name[] = { \
198 #include TRACEPOINT_INCLUDE
201 * Stage 2 of tracepoint event generation.
203 * Create probe callback prototypes.
206 /* Reset all macros within TRACEPOINT_EVENT */
207 #include <lttng/ust-tracepoint-event-reset.h>
210 #define TP_ARGS(...) __VA_ARGS__
212 #undef TRACEPOINT_EVENT_CLASS
213 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
214 static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
216 #include TRACEPOINT_INCLUDE
219 * Stage 3 of tracepoint event generation.
221 * Create static inline function that calculates event size.
224 /* Reset all macros within TRACEPOINT_EVENT */
225 #include <lttng/ust-tracepoint-event-reset.h>
226 #include <lttng/ust-tracepoint-event-write.h>
228 #undef _ctf_integer_ext
229 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
230 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
231 __event_len += sizeof(_type);
234 #define _ctf_float(_type, _item, _src, _nowrite) \
235 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
236 __event_len += sizeof(_type);
238 #undef _ctf_array_encoded
239 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \
240 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
241 __event_len += sizeof(_type) * (_length);
243 #undef _ctf_sequence_encoded
244 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
245 _src_length, _encoding, _nowrite) \
246 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
247 __event_len += sizeof(_length_type); \
248 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
249 __dynamic_len[__dynamic_len_idx] = (_src_length); \
250 __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \
254 #define _ctf_string(_item, _src, _nowrite) \
255 __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1;
258 #define TP_ARGS(...) __VA_ARGS__
261 #define TP_FIELDS(...) __VA_ARGS__
263 #undef TRACEPOINT_EVENT_CLASS
264 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
265 static inline lttng_ust_notrace \
266 size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)); \
268 size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
270 size_t __event_len = 0; \
271 unsigned int __dynamic_len_idx = 0; \
274 (void) __dynamic_len_idx; /* don't warn if unused */ \
276 return __event_len; \
279 #include TRACEPOINT_INCLUDE
282 * Stage 3.1 of tracepoint event generation.
284 * Create static inline function that layout the filter stack data.
285 * We make both write and nowrite data available to the filter.
288 /* Reset all macros within TRACEPOINT_EVENT */
289 #include <lttng/ust-tracepoint-event-reset.h>
290 #include <lttng/ust-tracepoint-event-write.h>
291 #include <lttng/ust-tracepoint-event-nowrite.h>
293 #undef _ctf_integer_ext
294 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
295 if (lttng_is_signed_type(_type)) { \
296 int64_t __ctf_tmp_int64 = (int64_t) (_type) (_src); \
297 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
299 uint64_t __ctf_tmp_uint64 = (uint64_t) (_type) (_src); \
300 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
302 __stack_data += sizeof(int64_t);
305 #define _ctf_float(_type, _item, _src, _nowrite) \
307 double __ctf_tmp_double = (double) (_type) (_src); \
308 memcpy(__stack_data, &__ctf_tmp_double, sizeof(double)); \
309 __stack_data += sizeof(double); \
312 #undef _ctf_array_encoded
313 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \
315 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
316 const void *__ctf_tmp_ptr = (_src); \
317 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
318 __stack_data += sizeof(unsigned long); \
319 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void **)); \
320 __stack_data += sizeof(void **); \
323 #undef _ctf_sequence_encoded
324 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
325 _src_length, _encoding, _nowrite) \
327 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
328 const void *__ctf_tmp_ptr = (_src); \
329 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
330 __stack_data += sizeof(unsigned long); \
331 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void **)); \
332 __stack_data += sizeof(void **); \
336 #define _ctf_string(_item, _src, _nowrite) \
338 const void *__ctf_tmp_ptr = (_src); \
339 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void **)); \
340 __stack_data += sizeof(void **); \
344 #define TP_ARGS(...) __VA_ARGS__
347 #define TP_FIELDS(...) __VA_ARGS__
349 #undef TRACEPOINT_EVENT_CLASS
350 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
352 void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
353 _TP_ARGS_DATA_PROTO(_args)) \
358 #include TRACEPOINT_INCLUDE
363 * Stage 4 of tracepoint event generation.
365 * Create static inline function that calculates event payload alignment.
368 /* Reset all macros within TRACEPOINT_EVENT */
369 #include <lttng/ust-tracepoint-event-reset.h>
370 #include <lttng/ust-tracepoint-event-write.h>
372 #undef _ctf_integer_ext
373 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
374 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
377 #define _ctf_float(_type, _item, _src, _nowrite) \
378 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
380 #undef _ctf_array_encoded
381 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \
382 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
384 #undef _ctf_sequence_encoded
385 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
386 _src_length, _encoding, _nowrite) \
387 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_length_type)); \
388 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
391 #define _ctf_string(_item, _src, _nowrite)
394 #define TP_ARGS(...) __VA_ARGS__
397 #define TP_FIELDS(...) __VA_ARGS__
399 #undef TRACEPOINT_EVENT_CLASS
400 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
401 static inline lttng_ust_notrace \
402 size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)); \
404 size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \
406 size_t __event_align = 1; \
408 return __event_align; \
411 #include TRACEPOINT_INCLUDE
415 * Stage 5 of tracepoint event generation.
417 * Create the probe function. This function calls event size calculation
418 * and writes event data into the buffer.
421 /* Reset all macros within TRACEPOINT_EVENT */
422 #include <lttng/ust-tracepoint-event-reset.h>
423 #include <lttng/ust-tracepoint-event-write.h>
425 #undef _ctf_integer_ext
426 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
428 _type __tmp = (_src); \
429 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
430 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
434 #define _ctf_float(_type, _item, _src, _nowrite) \
436 _type __tmp = (_src); \
437 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
438 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
441 #undef _ctf_array_encoded
442 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \
443 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
444 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length));
446 #undef _ctf_sequence_encoded
447 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
448 _src_length, _encoding, _nowrite) \
450 _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx]; \
451 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
452 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
454 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
455 __chan->ops->event_write(&__ctx, _src, \
456 sizeof(_type) * __get_dynamic_len(dest));
459 #define _ctf_string(_item, _src, _nowrite) \
460 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
461 __chan->ops->event_write(&__ctx, _src, __get_dynamic_len(dest));
463 /* Beware: this get len actually consumes the len value */
464 #undef __get_dynamic_len
465 #define __get_dynamic_len(field) __stackvar.__dynamic_len[__dynamic_len_idx++]
468 #define TP_ARGS(...) __VA_ARGS__
471 #define TP_FIELDS(...) __VA_ARGS__
474 * Using twice size for filter stack data to hold size and pointer for
475 * each field (worse case). For integers, max size required is 64-bit.
476 * Same for double-precision floats. Those fit within
477 * 2*sizeof(unsigned long) for all supported architectures.
478 * Perform UNION (||) of filter runtime list.
480 #undef TRACEPOINT_EVENT_CLASS
481 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
482 static lttng_ust_notrace \
483 void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)); \
485 void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) \
487 struct lttng_event *__event = __tp_data; \
488 struct lttng_channel *__chan = __event->chan; \
489 struct lttng_ust_lib_ring_buffer_ctx __ctx; \
490 size_t __event_len, __event_align; \
491 size_t __dynamic_len_idx = 0; \
493 size_t __dynamic_len[_TP_ARRAY_SIZE(__event_fields___##_provider##___##_name)]; \
494 char __filter_stack_data[2 * sizeof(unsigned long) * _TP_ARRAY_SIZE(__event_fields___##_provider##___##_name)]; \
499 (void) __dynamic_len_idx; /* don't warn if unused */ \
500 if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->session->active))) \
502 if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->enabled))) \
504 if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \
506 if (caa_unlikely(!TP_RCU_LINK_TEST())) \
508 if (caa_unlikely(!cds_list_empty(&__event->bytecode_runtime_head))) { \
509 struct lttng_bytecode_runtime *bc_runtime; \
510 int __filter_record = __event->has_enablers_without_bytecode; \
512 __event_prepare_filter_stack__##_provider##___##_name(__stackvar.__filter_stack_data, \
513 _TP_ARGS_DATA_VAR(_args)); \
514 tp_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
515 if (caa_unlikely(bc_runtime->filter(bc_runtime, \
516 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
517 __filter_record = 1; \
519 if (caa_likely(!__filter_record)) \
522 __event_len = __event_get_size__##_provider##___##_name(__stackvar.__dynamic_len, \
523 _TP_ARGS_DATA_VAR(_args)); \
524 __event_align = __event_get_align__##_provider##___##_name(_TP_ARGS_VAR(_args)); \
525 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \
526 __event_align, -1, __chan->handle); \
527 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
531 __chan->ops->event_commit(&__ctx); \
534 #include TRACEPOINT_INCLUDE
536 #undef __get_dynamic_len
539 * Stage 5.1 of tracepoint event generation.
541 * Create probe signature
544 /* Reset all macros within TRACEPOINT_EVENT */
545 #include <lttng/ust-tracepoint-event-reset.h>
548 #define TP_ARGS(...) __VA_ARGS__
550 #define _TP_EXTRACT_STRING2(...) #__VA_ARGS__
552 #undef TRACEPOINT_EVENT_CLASS
553 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
554 const char __tp_event_signature___##_provider##___##_name[] = \
555 _TP_EXTRACT_STRING2(_args);
557 #include TRACEPOINT_INCLUDE
559 #undef _TP_EXTRACT_STRING2
562 * Stage 6 of tracepoint event generation.
564 * Tracepoint loglevel mapping definition generation. We generate a
565 * symbol for each mapping for a provider/event to ensure at most a 1 to
566 * 1 mapping between events and loglevels. If the symbol is repeated,
567 * the compiler will complain.
570 /* Reset all macros within TRACEPOINT_EVENT */
571 #include <lttng/ust-tracepoint-event-reset.h>
573 #undef TRACEPOINT_LOGLEVEL
574 #define TRACEPOINT_LOGLEVEL(__provider, __name, __loglevel) \
575 static const int _loglevel_value___##__provider##___##__name = __loglevel; \
576 static const int *_loglevel___##__provider##___##__name = \
577 &_loglevel_value___##__provider##___##__name;
579 #include TRACEPOINT_INCLUDE
582 * Stage 6.1 of tracepoint event generation.
584 * Tracepoint UML URI info.
587 /* Reset all macros within TRACEPOINT_EVENT */
588 #include <lttng/ust-tracepoint-event-reset.h>
590 #undef TRACEPOINT_MODEL_EMF_URI
591 #define TRACEPOINT_MODEL_EMF_URI(__provider, __name, __uri) \
592 static const char *_model_emf_uri___##__provider##___##__name = __uri;
594 #include TRACEPOINT_INCLUDE
597 * Stage 7.1 of tracepoint event generation.
599 * Create events description structures. We use a weakref because
600 * loglevels are optional. If not declared, the event will point to the
601 * a loglevel that contains NULL.
604 /* Reset all macros within TRACEPOINT_EVENT */
605 #include <lttng/ust-tracepoint-event-reset.h>
607 #undef TRACEPOINT_EVENT_INSTANCE
608 #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
610 __ref_loglevel___##_provider##___##_name \
611 __attribute__((weakref ("_loglevel___" #_provider "___" #_name))); \
612 static const char * \
613 __ref_model_emf_uri___##_provider##___##_name \
614 __attribute__((weakref ("_model_emf_uri___" #_provider "___" #_name)));\
615 const struct lttng_event_desc __event_desc___##_provider##_##_name = { \
616 .fields = __event_fields___##_provider##___##_template, \
617 .name = #_provider ":" #_name, \
618 .probe_callback = (void (*)(void)) &__event_probe__##_provider##___##_template,\
619 .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \
620 .loglevel = &__ref_loglevel___##_provider##___##_name, \
621 .signature = __tp_event_signature___##_provider##___##_template, \
622 .u.ext.model_emf_uri = &__ref_model_emf_uri___##_provider##___##_name, \
625 #include TRACEPOINT_INCLUDE
628 * Stage 7.2 of tracepoint event generation.
630 * Create array of events.
633 /* Reset all macros within TRACEPOINT_EVENT */
634 #include <lttng/ust-tracepoint-event-reset.h>
636 #undef TRACEPOINT_EVENT_INSTANCE
637 #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
638 &__event_desc___##_provider##_##_name,
640 static const struct lttng_event_desc
*_TP_COMBINE_TOKENS(__event_desc___
, TRACEPOINT_PROVIDER
)[] = {
641 #include TRACEPOINT_INCLUDE
646 * Stage 8 of tracepoint event generation.
648 * Create a toplevel descriptor for the whole probe.
651 /* non-const because list head will be modified when registered. */
652 static struct lttng_probe_desc
_TP_COMBINE_TOKENS(__probe_desc___
, TRACEPOINT_PROVIDER
) = {
653 .provider
= __tp_stringify(TRACEPOINT_PROVIDER
),
654 .event_desc
= _TP_COMBINE_TOKENS(__event_desc___
, TRACEPOINT_PROVIDER
),
655 .nr_events
= _TP_ARRAY_SIZE(_TP_COMBINE_TOKENS(__event_desc___
, TRACEPOINT_PROVIDER
)),
656 .major
= LTTNG_UST_PROVIDER_MAJOR
,
657 .minor
= LTTNG_UST_PROVIDER_MINOR
,
661 * Stage 9 of tracepoint event generation.
663 * Register/unregister probes at module load/unload.
665 * Generate the constructor as an externally visible symbol for use when
666 * linking the probe statically.
669 /* Reset all macros within TRACEPOINT_EVENT */
670 #include <lttng/ust-tracepoint-event-reset.h>
671 static void lttng_ust_notrace
__attribute__((constructor
))
672 _TP_COMBINE_TOKENS(__lttng_events_init__
, TRACEPOINT_PROVIDER
)(void);
674 _TP_COMBINE_TOKENS(__lttng_events_init__
, TRACEPOINT_PROVIDER
)(void)
679 * __tracepoint_provider_check_ ## TRACEPOINT_PROVIDER() is a
680 * static inline function that ensures every probe PROVIDER
681 * argument match the provider within which they appear. It
682 * calls empty static inline functions, and therefore has no
683 * runtime effect. However, if it detects an error, a linker
686 _TP_COMBINE_TOKENS(__tracepoint_provider_check_
, TRACEPOINT_PROVIDER
)();
687 ret
= lttng_probe_register(&_TP_COMBINE_TOKENS(__probe_desc___
, TRACEPOINT_PROVIDER
));
689 fprintf(stderr
, "LTTng-UST: Error (%d) while registering tracepoint probe. Duplicate registration of tracepoint probes having the same name is not allowed.\n", ret
);
694 static void lttng_ust_notrace
__attribute__((destructor
))
695 _TP_COMBINE_TOKENS(__lttng_events_exit__
, TRACEPOINT_PROVIDER
)(void);
697 _TP_COMBINE_TOKENS(__lttng_events_exit__
, TRACEPOINT_PROVIDER
)(void)
699 lttng_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___
, TRACEPOINT_PROVIDER
));
702 int _TP_COMBINE_TOKENS(__tracepoint_provider_
, TRACEPOINT_PROVIDER
);