2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 #include <urcu/compiler.h>
11 #include <urcu/rculist.h>
12 #include <lttng/ust-events.h>
13 #include <lttng/ust-ringbuffer-context.h>
14 #include <lttng/ust-arch.h>
15 #include <lttng/ust-compiler.h>
16 #include <lttng/tracepoint.h>
17 #include <lttng/ust-endian.h>
18 #include <lttng/ust-api-compat.h>
21 #define LTTNG_UST__NULL_STRING "(null)"
24 * LTTNG_UST_TRACEPOINT_EVENT_CLASS declares a class of tracepoints receiving the
25 * same arguments and having the same field layout.
27 * LTTNG_UST_TRACEPOINT_EVENT_INSTANCE declares an instance of a tracepoint, with
28 * its own provider and name. It refers to a class (template).
30 * LTTNG_UST_TRACEPOINT_EVENT declared both a class and an instance and does a
31 * direct mapping from the instance to the class.
34 #undef LTTNG_UST_TRACEPOINT_EVENT
35 #define LTTNG_UST_TRACEPOINT_EVENT(_provider, _name, _args, _fields) \
36 LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, \
37 LTTNG_UST__TP_PARAMS(_args), \
38 LTTNG_UST__TP_PARAMS(_fields)) \
39 LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _name, _name, \
40 LTTNG_UST__TP_PARAMS(_args))
42 #undef LTTNG_UST_TRACEPOINT_EVENT_CLASS
43 #define LTTNG_UST_TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
44 LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, LTTNG_UST__TP_PARAMS(_args), LTTNG_UST__TP_PARAMS(_fields))
46 #undef LTTNG_UST_TRACEPOINT_EVENT_INSTANCE
47 #define LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
48 LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, LTTNG_UST__TP_PARAMS(_args))
51 #define LTTNG_UST__TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
53 #define lttng_ust__tp_max_t(type, x, y) \
55 type lttng_ust__max1 = (x); \
56 type lttng_ust__max2 = (y); \
57 lttng_ust__max1 > lttng_ust__max2 ? lttng_ust__max1: lttng_ust__max2; \
61 * Stage 0 of tracepoint event generation.
63 * Check that each LTTNG_UST_TRACEPOINT_EVENT provider argument match the
64 * LTTNG_UST_TRACEPOINT_PROVIDER by creating dummy callbacks.
67 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
68 #include <lttng/ust-tracepoint-event-reset.h>
71 void LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_mismatch_
, LTTNG_UST_TRACEPOINT_PROVIDER
)(void)
74 void LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_mismatch_
, LTTNG_UST_TRACEPOINT_PROVIDER
)(void)
78 #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS
79 #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
80 lttng_ust_tracepoint_provider_mismatch_##_provider();
82 #undef LTTNG_UST__TRACEPOINT_EVENT_INSTANCE
83 #define LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
84 lttng_ust_tracepoint_provider_mismatch_##_provider();
87 void LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_check_
, LTTNG_UST_TRACEPOINT_PROVIDER
)(void)
90 void LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_check_
, LTTNG_UST_TRACEPOINT_PROVIDER
)(void)
92 #include LTTNG_UST_TRACEPOINT_INCLUDE
96 * Stage 0.1 of tracepoint event generation.
98 * Check that each LTTNG_UST_TRACEPOINT_EVENT provider:name does not exceed the
99 * tracepoint name length limit.
102 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
103 #include <lttng/ust-tracepoint-event-reset.h>
105 #undef LTTNG_UST__TRACEPOINT_EVENT_INSTANCE
106 #define LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
107 lttng_ust_tracepoint_validate_name_len(_provider, _name);
109 #include LTTNG_UST_TRACEPOINT_INCLUDE
112 * Stage 0.2 of tracepoint event generation.
114 * Create dummy trace prototypes for each event class, and for each used
115 * template. This will allow checking whether the prototypes from the
116 * class and the instance using the class actually match.
119 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
120 #include <lttng/ust-tracepoint-event-reset.h>
122 #undef LTTNG_UST_TP_ARGS
123 #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__
125 #undef LTTNG_UST__TRACEPOINT_EVENT_INSTANCE
126 #define LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
127 void lttng_ust__event_template_proto___##_provider##___##_template(LTTNG_UST__TP_ARGS_DATA_PROTO(_args));
129 #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS
130 #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
131 void lttng_ust__event_template_proto___##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args));
133 #include LTTNG_UST_TRACEPOINT_INCLUDE
136 * Stage 0.9 of tracepoint event generation
138 * Unfolding the enums
140 #include <lttng/ust-tracepoint-event-reset.h>
142 /* Enumeration entry (single value) */
143 #undef lttng_ust_field_enum_value
144 #define lttng_ust_field_enum_value(_string, _value) \
145 LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_enum_entry, { \
146 .struct_size = sizeof(struct lttng_ust_enum_entry), \
148 .value = lttng_ust_is_signed_type(__typeof__(_value)) ? \
149 (long long) (_value) : (_value), \
150 .signedness = lttng_ust_is_signed_type(__typeof__(_value)), \
153 .value = lttng_ust_is_signed_type(__typeof__(_value)) ? \
154 (long long) (_value) : (_value), \
155 .signedness = lttng_ust_is_signed_type(__typeof__(_value)), \
157 .string = (_string), \
160 /* Enumeration entry (range) */
161 #undef lttng_ust_field_enum_range
162 #define lttng_ust_field_enum_range(_string, _range_start, _range_end) \
163 LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_enum_entry, { \
164 .struct_size = sizeof(struct lttng_ust_enum_entry), \
166 .value = lttng_ust_is_signed_type(__typeof__(_range_start)) ? \
167 (long long) (_range_start) : (_range_start), \
168 .signedness = lttng_ust_is_signed_type(__typeof__(_range_start)), \
171 .value = lttng_ust_is_signed_type(__typeof__(_range_end)) ? \
172 (long long) (_range_end) : (_range_end), \
173 .signedness = lttng_ust_is_signed_type(__typeof__(_range_end)), \
175 .string = (_string), \
178 /* Enumeration entry (automatic value; follows the rules of CTF) */
179 #undef lttng_ust_field_enum_auto
180 #define lttng_ust_field_enum_auto(_string) \
181 LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_enum_entry, { \
182 .struct_size = sizeof(struct lttng_ust_enum_entry), \
191 .string = (_string), \
192 .options = LTTNG_UST_ENUM_ENTRY_OPTION_IS_AUTO, \
195 #undef LTTNG_UST_TP_ENUM_VALUES
196 #define LTTNG_UST_TP_ENUM_VALUES(...) \
199 #if LTTNG_UST_COMPAT_API(0)
200 # undef TP_ENUM_VALUES
201 # define TP_ENUM_VALUES LTTNG_UST_TP_ENUM_VALUES
202 #endif /* #if LTTNG_UST_COMPAT_API(0) */
204 #undef LTTNG_UST_TRACEPOINT_ENUM
205 #define LTTNG_UST_TRACEPOINT_ENUM(_provider, _name, _values) \
206 const struct lttng_ust_enum_entry * const __enum_values__##_provider##_##_name[] = { \
208 lttng_ust_field_enum_value("", 0) /* Dummy, 0-len array forbidden by C99. */ \
210 #include LTTNG_UST_TRACEPOINT_INCLUDE
214 * Verifying array and sequence elements are of an integer type.
217 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
218 #include <lttng/ust-tracepoint-event-reset.h>
219 #include <lttng/ust-tracepoint-event-write.h>
220 #include <lttng/ust-tracepoint-event-nowrite.h>
222 #undef lttng_ust__field_array_encoded
223 #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, \
224 _length, _encoding, _nowrite, \
226 lttng_ust_field_array_element_type_is_supported(_type, _item);
228 #undef lttng_ust__field_sequence_encoded
229 #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, \
230 _length_type, _src_length, _encoding, _nowrite, \
232 lttng_ust_field_array_element_type_is_supported(_type, _item);
234 #undef LTTNG_UST_TP_FIELDS
235 #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
237 #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS
238 #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
241 #include LTTNG_UST_TRACEPOINT_INCLUDE
244 * Stage 1 of tracepoint event generation.
246 * Create event field type metadata section.
247 * Each event produce an array of fields.
250 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
251 #include <lttng/ust-tracepoint-event-reset.h>
252 #include <lttng/ust-tracepoint-event-write.h>
253 #include <lttng/ust-tracepoint-event-nowrite.h>
255 #undef lttng_ust__field_integer_ext
256 #define lttng_ust__field_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
257 LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \
258 .struct_size = sizeof(struct lttng_ust_event_field), \
260 .type = lttng_ust_type_integer_define(_type, _byte_order, _base), \
261 .nowrite = _nowrite, \
265 #undef lttng_ust__field_float
266 #define lttng_ust__field_float(_type, _item, _src, _nowrite) \
267 LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \
268 .struct_size = sizeof(struct lttng_ust_event_field), \
270 .type = lttng_ust_type_float_define(_type), \
271 .nowrite = _nowrite, \
275 #undef lttng_ust__field_array_encoded
276 #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, \
277 _length, _encoding, _nowrite, \
279 LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \
280 .struct_size = sizeof(struct lttng_ust_event_field), \
282 .type = (const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_array, { \
284 .type = lttng_ust_type_array, \
286 .struct_size = sizeof(struct lttng_ust_type_array), \
287 .elem_type = lttng_ust_type_integer_define(_type, _byte_order, _elem_type_base), \
290 .encoding = lttng_ust_string_encoding_##_encoding, \
292 .nowrite = _nowrite, \
296 #undef lttng_ust__field_sequence_encoded
297 #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, \
298 _length_type, _src_length, _encoding, _nowrite, \
300 LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \
301 .struct_size = sizeof(struct lttng_ust_event_field), \
302 .name = "_" #_item "_length", \
303 .type = lttng_ust_type_integer_define(_length_type, LTTNG_UST_BYTE_ORDER, 10), \
304 .nowrite = _nowrite, \
307 LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \
308 .struct_size = sizeof(struct lttng_ust_event_field), \
310 .type = (const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_sequence, { \
312 .type = lttng_ust_type_sequence, \
314 .struct_size = sizeof(struct lttng_ust_type_sequence), \
315 .length_name = "_" #_item "_length", \
316 .elem_type = lttng_ust_type_integer_define(_type, _byte_order, _elem_type_base), \
318 .encoding = lttng_ust_string_encoding_##_encoding, \
320 .nowrite = _nowrite, \
324 #undef lttng_ust__field_string
325 #define lttng_ust__field_string(_item, _src, _nowrite) \
326 LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \
327 .struct_size = sizeof(struct lttng_ust_event_field), \
329 .type = (const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_string, { \
331 .type = lttng_ust_type_string, \
333 .struct_size = sizeof(struct lttng_ust_type_string), \
334 .encoding = lttng_ust_string_encoding_UTF8, \
336 .nowrite = _nowrite, \
340 #undef lttng_ust__field_unused
341 #define lttng_ust__field_unused(_src)
343 #undef lttng_ust__field_enum
344 #define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \
345 LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \
346 .struct_size = sizeof(struct lttng_ust_event_field), \
348 .type = (const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_enum, { \
350 .type = lttng_ust_type_enum, \
352 .struct_size = sizeof(struct lttng_ust_type_enum), \
353 .desc = &__enum_##_provider##_##_name, \
354 .container_type = lttng_ust_type_integer_define(_type, LTTNG_UST_BYTE_ORDER, 10), \
356 .nowrite = _nowrite, \
360 #undef LTTNG_UST_TP_FIELDS
361 #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
363 #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS
364 #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
365 static const struct lttng_ust_event_field * const lttng_ust__event_fields___##_provider##___##_name[] = { \
367 lttng_ust_field_integer(int, dummy, 0) /* Dummy, C99 forbids 0-len array. */ \
370 #undef LTTNG_UST_TRACEPOINT_ENUM
371 #define LTTNG_UST_TRACEPOINT_ENUM(_provider, _name, _values) \
372 static const struct lttng_ust_enum_desc __enum_##_provider##_##_name = { \
373 .struct_size = sizeof(struct lttng_ust_enum_desc), \
374 .name = #_provider "_" #_name, \
375 .entries = __enum_values__##_provider##_##_name, \
376 .nr_entries = LTTNG_UST__TP_ARRAY_SIZE(__enum_values__##_provider##_##_name) - 1, \
379 #include LTTNG_UST_TRACEPOINT_INCLUDE
382 * Stage 2 of tracepoint event generation.
384 * Create probe callback prototypes.
387 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
388 #include <lttng/ust-tracepoint-event-reset.h>
390 #undef LTTNG_UST_TP_ARGS
391 #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__
393 #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS
394 #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
395 static void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args));
397 #include LTTNG_UST_TRACEPOINT_INCLUDE
400 * Stage 3.0 of tracepoint event generation.
402 * Create static inline function that calculates event size.
405 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
406 #include <lttng/ust-tracepoint-event-reset.h>
407 #include <lttng/ust-tracepoint-event-write.h>
409 #undef lttng_ust__field_integer_ext
410 #define lttng_ust__field_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
412 (void) (_src); /* Unused */ \
413 __event_len += lttng_ust_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \
414 __event_len += sizeof(_type);
416 #undef lttng_ust__field_float
417 #define lttng_ust__field_float(_type, _item, _src, _nowrite) \
419 (void) (_src); /* Unused */ \
420 __event_len += lttng_ust_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \
421 __event_len += sizeof(_type);
423 #undef lttng_ust__field_array_encoded
424 #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, _length, _encoding, \
425 _nowrite, _elem_type_base) \
427 (void) (_src); /* Unused */ \
428 __event_len += lttng_ust_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \
429 __event_len += sizeof(_type) * (_length);
431 #undef lttng_ust__field_sequence_encoded
432 #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \
433 _src_length, _encoding, _nowrite, _elem_type_base) \
435 (void) (_src); /* Unused */ \
436 __event_len += lttng_ust_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_length_type)); \
437 __event_len += sizeof(_length_type); \
438 __event_len += lttng_ust_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \
439 __dynamic_len[__dynamic_len_idx] = (_src_length); \
440 __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \
443 #undef lttng_ust__field_string
444 #define lttng_ust__field_string(_item, _src, _nowrite) \
445 __event_len += __dynamic_len[__dynamic_len_idx++] = \
446 strlen((_src) ? (_src) : LTTNG_UST__NULL_STRING) + 1;
448 #undef lttng_ust__field_unused
449 #define lttng_ust__field_unused(_src) \
451 (void) (_src); /* Unused */
453 #undef lttng_ust__field_enum
454 #define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \
455 lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite)
457 #undef LTTNG_UST_TP_ARGS
458 #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__
460 #undef LTTNG_UST_TP_FIELDS
461 #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__
463 #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS
464 #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
466 size_t lttng_ust__event_get_size__##_provider##___##_name(size_t *__dynamic_len, LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \
469 size_t lttng_ust__event_get_size__##_provider##___##_name( \
470 size_t *__dynamic_len __attribute__((__unused__)), \
471 LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \
473 size_t __event_len = 0; \
474 unsigned int __dynamic_len_idx __attribute__((__unused__)) = 0; \
477 (void) __tp_data; /* don't warn if unused */ \
480 return __event_len; \
483 #include LTTNG_UST_TRACEPOINT_INCLUDE
486 * Stage 3.1 of tracepoint event generation.
488 * Create static inline function that layout the filter stack data.
489 * We make both write and nowrite data available to the filter.
492 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
493 #include <lttng/ust-tracepoint-event-reset.h>
494 #include <lttng/ust-tracepoint-event-write.h>
495 #include <lttng/ust-tracepoint-event-nowrite.h>
497 #undef lttng_ust__field_integer_ext
498 #define lttng_ust__field_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
499 if (lttng_ust_is_signed_type(_type)) { \
500 int64_t __ctf_tmp_int64; \
501 switch (sizeof(_type)) { \
504 union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
505 __ctf_tmp_int64 = (int64_t) __tmp.v; \
510 union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
511 if (_byte_order != LTTNG_UST_BYTE_ORDER) \
512 __tmp.v = lttng_ust_bswap_16(__tmp.v); \
513 __ctf_tmp_int64 = (int64_t) __tmp.v; \
518 union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
519 if (_byte_order != LTTNG_UST_BYTE_ORDER) \
520 __tmp.v = lttng_ust_bswap_32(__tmp.v); \
521 __ctf_tmp_int64 = (int64_t) __tmp.v; \
526 union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
527 if (_byte_order != LTTNG_UST_BYTE_ORDER) \
528 __tmp.v = lttng_ust_bswap_64(__tmp.v); \
529 __ctf_tmp_int64 = (int64_t) __tmp.v; \
535 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
537 uint64_t __ctf_tmp_uint64; \
538 switch (sizeof(_type)) { \
541 union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
542 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
547 union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
548 if (_byte_order != LTTNG_UST_BYTE_ORDER) \
549 __tmp.v = lttng_ust_bswap_16(__tmp.v); \
550 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
555 union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
556 if (_byte_order != LTTNG_UST_BYTE_ORDER) \
557 __tmp.v = lttng_ust_bswap_32(__tmp.v); \
558 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
563 union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
564 if (_byte_order != LTTNG_UST_BYTE_ORDER) \
565 __tmp.v = lttng_ust_bswap_64(__tmp.v); \
566 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
572 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
574 __stack_data += sizeof(int64_t);
576 #undef lttng_ust__field_float
577 #define lttng_ust__field_float(_type, _item, _src, _nowrite) \
579 double __ctf_tmp_double = (double) (_type) (_src); \
580 memcpy(__stack_data, &__ctf_tmp_double, sizeof(double)); \
581 __stack_data += sizeof(double); \
584 #undef lttng_ust__field_array_encoded
585 #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, _length, \
586 _encoding, _nowrite, _elem_type_base) \
588 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
589 const void *__ctf_tmp_ptr = (_src); \
590 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
591 __stack_data += sizeof(unsigned long); \
592 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
593 __stack_data += sizeof(void *); \
596 #undef lttng_ust__field_sequence_encoded
597 #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \
598 _src_length, _encoding, _nowrite, _elem_type_base) \
600 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
601 const void *__ctf_tmp_ptr = (_src); \
602 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
603 __stack_data += sizeof(unsigned long); \
604 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
605 __stack_data += sizeof(void *); \
608 #undef lttng_ust__field_string
609 #define lttng_ust__field_string(_item, _src, _nowrite) \
611 const void *__ctf_tmp_ptr = \
612 ((_src) ? (_src) : LTTNG_UST__NULL_STRING); \
613 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
614 __stack_data += sizeof(void *); \
617 #undef lttng_ust__field_unused
618 #define lttng_ust__field_unused(_src) \
622 #undef lttng_ust__field_enum
623 #define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \
624 lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite)
626 #undef LTTNG_UST_TP_ARGS
627 #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__
629 #undef LTTNG_UST_TP_FIELDS
630 #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__
632 #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS
633 #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
635 void lttng_ust__event_prepare_interpreter_stack__##_provider##___##_name(char *__stack_data,\
636 LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \
639 (void) __tp_data; /* don't warn if unused */ \
640 (void) __stack_data; /* don't warn if unused */ \
646 #include LTTNG_UST_TRACEPOINT_INCLUDE
649 * Stage 4 of tracepoint event generation.
651 * Create static inline function that calculates event payload alignment.
654 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
655 #include <lttng/ust-tracepoint-event-reset.h>
656 #include <lttng/ust-tracepoint-event-write.h>
658 #undef lttng_ust__field_integer_ext
659 #define lttng_ust__field_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
661 (void) (_src); /* Unused */ \
662 lttng_ust__event_align = lttng_ust__tp_max_t(size_t, lttng_ust__event_align, lttng_ust_rb_alignof(_type));
664 #undef lttng_ust__field_float
665 #define lttng_ust__field_float(_type, _item, _src, _nowrite) \
667 (void) (_src); /* Unused */ \
668 lttng_ust__event_align = lttng_ust__tp_max_t(size_t, lttng_ust__event_align, lttng_ust_rb_alignof(_type));
670 #undef lttng_ust__field_array_encoded
671 #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, _length, \
672 _encoding, _nowrite, _elem_type_base) \
674 (void) (_src); /* Unused */ \
675 lttng_ust__event_align = lttng_ust__tp_max_t(size_t, lttng_ust__event_align, lttng_ust_rb_alignof(_type));
677 #undef lttng_ust__field_sequence_encoded
678 #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \
679 _src_length, _encoding, _nowrite, _elem_type_base) \
681 (void) (_src); /* Unused */ \
683 (void) (_src_length); /* Unused */ \
684 lttng_ust__event_align = lttng_ust__tp_max_t(size_t, lttng_ust__event_align, lttng_ust_rb_alignof(_length_type)); \
685 lttng_ust__event_align = lttng_ust__tp_max_t(size_t, lttng_ust__event_align, lttng_ust_rb_alignof(_type));
687 #undef lttng_ust__field_string
688 #define lttng_ust__field_string(_item, _src, _nowrite) \
690 (void) (_src); /* Unused */
692 #undef lttng_ust__field_unused
693 #define lttng_ust__field_unused(_src) \
695 (void) (_src); /* Unused */
697 #undef lttng_ust__field_enum
698 #define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \
699 lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite)
701 #undef LTTNG_UST_TP_ARGS
702 #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__
704 #undef LTTNG_UST_TP_FIELDS
705 #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__
707 #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS
708 #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
710 size_t lttng_ust__event_get_align__##_provider##___##_name(LTTNG_UST__TP_ARGS_PROTO(_args)) \
713 size_t lttng_ust__event_get_align__##_provider##___##_name(LTTNG_UST__TP_ARGS_PROTO(_args)) \
715 size_t lttng_ust__event_align = 1; \
717 return lttng_ust__event_align; \
720 #include LTTNG_UST_TRACEPOINT_INCLUDE
724 * Stage 5 of tracepoint event generation.
726 * Create the probe function. This function calls event size calculation
727 * and writes event data into the buffer.
730 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
731 #include <lttng/ust-tracepoint-event-reset.h>
732 #include <lttng/ust-tracepoint-event-write.h>
734 #undef lttng_ust__field_integer_ext
735 #define lttng_ust__field_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
737 _type __tmp = (_src); \
738 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp), lttng_ust_rb_alignof(__tmp));\
741 #undef lttng_ust__field_float
742 #define lttng_ust__field_float(_type, _item, _src, _nowrite) \
744 _type __tmp = (_src); \
745 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp), lttng_ust_rb_alignof(__tmp));\
748 #undef lttng_ust__field_array_encoded
749 #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, _length, \
750 _encoding, _nowrite, _elem_type_base) \
751 if (lttng_ust_string_encoding_##_encoding == lttng_ust_string_encoding_none) \
752 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length), lttng_ust_rb_alignof(_type)); \
754 __chan->ops->event_pstrcpy_pad(&__ctx, (const char *) (_src), _length); \
756 #undef lttng_ust__field_sequence_encoded
757 #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \
758 _src_length, _encoding, _nowrite, _elem_type_base) \
760 _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx]; \
761 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type), lttng_ust_rb_alignof(_length_type));\
763 if (lttng_ust_string_encoding_##_encoding == lttng_ust_string_encoding_none) \
764 __chan->ops->event_write(&__ctx, _src, \
765 sizeof(_type) * lttng_ust__get_dynamic_len(dest), lttng_ust_rb_alignof(_type)); \
767 __chan->ops->event_pstrcpy_pad(&__ctx, (const char *) (_src), lttng_ust__get_dynamic_len(dest)); \
769 #undef lttng_ust__field_string
770 #define lttng_ust__field_string(_item, _src, _nowrite) \
772 const char *__ctf_tmp_string = \
773 ((_src) ? (_src) : LTTNG_UST__NULL_STRING); \
774 __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
775 lttng_ust__get_dynamic_len(dest)); \
778 #undef lttng_ust__field_unused
779 #define lttng_ust__field_unused(_src)
781 #undef lttng_ust__field_enum
782 #define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \
783 lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite)
785 /* Beware: this get len actually consumes the len value */
786 #undef lttng_ust__get_dynamic_len
787 #define lttng_ust__get_dynamic_len(field) __stackvar.__dynamic_len[__dynamic_len_idx++]
789 #undef LTTNG_UST_TP_ARGS
790 #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__
792 #undef LTTNG_UST_TP_FIELDS
793 #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__
796 * For state dump, check that "session" argument (mandatory) matches the
797 * session this event belongs to. Ensures that we write state dump data only
798 * into the started session, not into all sessions.
800 #undef LTTNG_UST__TP_SESSION_CHECK
801 #ifdef LTTNG_UST_TP_SESSION_CHECK
802 #define LTTNG_UST__TP_SESSION_CHECK(session, csession) (session == csession)
803 #else /* TP_SESSION_CHECK */
804 #define LTTNG_UST__TP_SESSION_CHECK(session, csession) 1
805 #endif /* TP_SESSION_CHECK */
808 * Use of __builtin_return_address(0) sometimes seems to cause stack
809 * corruption on 32-bit PowerPC. Disable this feature on that
810 * architecture for now by always using the NULL value for the ip
813 #undef LTTNG_UST__TP_IP_PARAM
815 #ifdef LTTNG_UST_TP_IP_PARAM
816 #define LTTNG_UST__TP_IP_PARAM(x) (x)
817 #else /* TP_IP_PARAM */
819 #if defined(LTTNG_UST_ARCH_PPC) && !defined(LTTNG_UST_ARCH_PPC64)
820 #define LTTNG_UST__TP_IP_PARAM(x) NULL
822 #define LTTNG_UST__TP_IP_PARAM(x) __builtin_return_address(0)
825 #endif /* TP_IP_PARAM */
828 * Using twice size for filter stack data to hold size and pointer for
829 * each field (worse case). For integers, max size required is 64-bit.
830 * Same for double-precision floats. Those fit within
831 * 2*sizeof(unsigned long) for all supported architectures.
832 * Perform UNION (||) of filter runtime list.
834 #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS
835 #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
837 void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \
840 void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \
842 struct lttng_ust_event_common *__event = (struct lttng_ust_event_common *) __tp_data; \
843 size_t __dynamic_len_idx = 0; \
844 const size_t __num_fields = LTTNG_UST__TP_ARRAY_SIZE(lttng_ust__event_fields___##_provider##___##_name) - 1; \
846 size_t __dynamic_len[__num_fields]; \
847 char __interpreter_stack_data[2 * sizeof(unsigned long) * __num_fields]; \
850 bool __interpreter_stack_prepared = false; \
853 (void) __dynamic_len_idx; /* don't warn if unused */ \
854 switch (__event->type) { \
855 case LTTNG_UST_EVENT_TYPE_RECORDER: \
857 struct lttng_ust_event_recorder *lttng_ust__event_recorder = (struct lttng_ust_event_recorder *) __event->child; \
858 struct lttng_ust_channel_buffer *__chan = lttng_ust__event_recorder->chan; \
859 struct lttng_ust_channel_common *__chan_common = __chan->parent; \
861 if (!LTTNG_UST__TP_SESSION_CHECK(session, __chan_common->session)) \
863 if (caa_unlikely(!CMM_ACCESS_ONCE(__chan_common->session->active))) \
865 if (caa_unlikely(!CMM_ACCESS_ONCE(__chan_common->enabled))) \
869 case LTTNG_UST_EVENT_TYPE_NOTIFIER: \
872 if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \
874 if (caa_unlikely(!LTTNG_UST_TP_RCU_LINK_TEST())) \
876 if (caa_unlikely(CMM_ACCESS_ONCE(__event->eval_filter))) { \
877 lttng_ust__event_prepare_interpreter_stack__##_provider##___##_name(__stackvar.__interpreter_stack_data, \
878 LTTNG_UST__TP_ARGS_DATA_VAR(_args)); \
879 __interpreter_stack_prepared = true; \
880 if (caa_likely(__event->run_filter(__event, \
881 __stackvar.__interpreter_stack_data, NULL) != LTTNG_UST_EVENT_FILTER_ACCEPT)) \
884 switch (__event->type) { \
885 case LTTNG_UST_EVENT_TYPE_RECORDER: \
887 size_t __event_len, lttng_ust__event_align; \
888 struct lttng_ust_event_recorder *lttng_ust__event_recorder = (struct lttng_ust_event_recorder *) __event->child; \
889 struct lttng_ust_channel_buffer *__chan = lttng_ust__event_recorder->chan; \
890 struct lttng_ust_ring_buffer_ctx __ctx; \
892 __event_len = lttng_ust__event_get_size__##_provider##___##_name(__stackvar.__dynamic_len, \
893 LTTNG_UST__TP_ARGS_DATA_VAR(_args)); \
894 lttng_ust__event_align = lttng_ust__event_get_align__##_provider##___##_name(LTTNG_UST__TP_ARGS_VAR(_args)); \
895 lttng_ust_ring_buffer_ctx_init(&__ctx, lttng_ust__event_recorder, __event_len, lttng_ust__event_align, \
896 LTTNG_UST__TP_IP_PARAM(LTTNG_UST_TP_IP_PARAM)); \
897 __ret = __chan->ops->event_reserve(&__ctx); \
901 __chan->ops->event_commit(&__ctx); \
904 case LTTNG_UST_EVENT_TYPE_NOTIFIER: \
906 struct lttng_ust_event_notifier *lttng_ust__event_notifier = (struct lttng_ust_event_notifier *) __event->child; \
907 struct lttng_ust_notification_ctx __notif_ctx; \
909 __notif_ctx.struct_size = sizeof(struct lttng_ust_notification_ctx); \
910 __notif_ctx.eval_capture = CMM_ACCESS_ONCE(lttng_ust__event_notifier->eval_capture); \
912 if (caa_unlikely(!__interpreter_stack_prepared && __notif_ctx.eval_capture)) \
913 lttng_ust__event_prepare_interpreter_stack__##_provider##___##_name(__stackvar.__interpreter_stack_data, \
914 LTTNG_UST__TP_ARGS_DATA_VAR(_args)); \
916 lttng_ust__event_notifier->notification_send(lttng_ust__event_notifier, \
917 __stackvar.__interpreter_stack_data, \
924 #include LTTNG_UST_TRACEPOINT_INCLUDE
926 #undef lttng_ust__get_dynamic_len
929 * Stage 5.1 of tracepoint event generation.
931 * Create probe signature
934 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
935 #include <lttng/ust-tracepoint-event-reset.h>
937 #undef LTTNG_UST_TP_ARGS
938 #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__
940 #define LTTNG_UST__TP_EXTRACT_STRING2(...) #__VA_ARGS__
942 #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS
943 #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
944 static const char __tp_event_signature___##_provider##___##_name[] = \
945 LTTNG_UST__TP_EXTRACT_STRING2(_args);
947 #include LTTNG_UST_TRACEPOINT_INCLUDE
949 #undef LTTNG_UST__TP_EXTRACT_STRING2
952 * Stage 6 of tracepoint event generation.
954 * Tracepoint loglevel mapping definition generation. We generate a
955 * symbol for each mapping for a provider/event to ensure at most a 1 to
956 * 1 mapping between events and loglevels. If the symbol is repeated,
957 * the compiler will complain.
960 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
961 #include <lttng/ust-tracepoint-event-reset.h>
964 * Declare _loglevel___##__provider##___##__name as non-static, with
965 * hidden visibility for c++ handling of weakref. We do a weakref to the
966 * symbol in a later stage, which requires that the symbol is not
970 #define LTTNG_UST_TP_EXTERN_C extern "C"
972 #define LTTNG_UST_TP_EXTERN_C
975 #undef LTTNG_UST_TRACEPOINT_LOGLEVEL
976 #define LTTNG_UST_TRACEPOINT_LOGLEVEL(__provider, __name, __loglevel) \
977 static const int _loglevel_value___##__provider##___##__name = __loglevel; \
978 LTTNG_UST_TP_EXTERN_C const int * const _loglevel___##__provider##___##__name \
979 __attribute__((visibility("hidden"))) = \
980 &_loglevel_value___##__provider##___##__name;
982 #include LTTNG_UST_TRACEPOINT_INCLUDE
984 #undef LTTNG_UST_TP_EXTERN_C
987 * Stage 6.1 of tracepoint event generation.
989 * Tracepoint UML URI info.
992 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
993 #include <lttng/ust-tracepoint-event-reset.h>
996 * Declare _model_emf_uri___##__provider##___##__name as non-static,
997 * with hidden visibility for c++ handling of weakref. We do a weakref
998 * to the symbol in a later stage, which requires that the symbol is not
1002 #define LTTNG_UST_TP_EXTERN_C extern "C"
1004 #define LTTNG_UST_TP_EXTERN_C
1007 #undef LTTNG_UST_TRACEPOINT_MODEL_EMF_URI
1008 #define LTTNG_UST_TRACEPOINT_MODEL_EMF_URI(__provider, __name, __uri) \
1009 LTTNG_UST_TP_EXTERN_C const char * const _model_emf_uri___##__provider##___##__name \
1010 __attribute__((visibility("hidden"))) = __uri; \
1012 #include LTTNG_UST_TRACEPOINT_INCLUDE
1014 #undef LTTNG_UST_TP_EXTERN_C
1017 * Stage 7.0 of tracepoint event generation.
1019 * Declare toplevel descriptor for the whole probe.
1020 * Unlike C, C++ does not allow tentative definitions. Therefore, we
1021 * need to explicitly declare the variable with "extern", using hidden
1022 * visibility to keep this symbol from being exported to the global
1026 extern const struct lttng_ust_probe_desc
LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_desc___
, LTTNG_UST_TRACEPOINT_PROVIDER
)
1027 __attribute__((visibility("hidden")));
1030 * Stage 7.1 of tracepoint event generation.
1032 * Create events description structures. We use a weakref because
1033 * loglevels are optional. If not declared, the event will point to
1034 * a loglevel that contains NULL.
1036 * C++ requires that const objects have a user-declared default
1037 * constructor. However, in both C++ and C, weakref cannot be
1038 * initialized because it causes the weakref attribute to be ignored.
1039 * Therefore, the loglevel and model_emf_uri pointers are not const
1040 * to ensure C++ compilers default-initialize them.
1043 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
1044 #include <lttng/ust-tracepoint-event-reset.h>
1046 #undef LTTNG_UST__TRACEPOINT_EVENT_INSTANCE
1047 #define LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
1048 static const int * \
1049 __ref_loglevel___##_provider##___##_name \
1050 __attribute__((weakref ("_loglevel___" #_provider "___" #_name))); \
1051 static const char * \
1052 __ref_model_emf_uri___##_provider##___##_name \
1053 __attribute__((weakref ("_model_emf_uri___" #_provider "___" #_name)));\
1054 static const struct lttng_ust_event_desc lttng_ust__event_desc___##_provider##_##_name = { \
1055 .struct_size = sizeof(struct lttng_ust_event_desc), \
1056 .event_name = #_name, \
1057 .probe_desc = <tng_ust__probe_desc___##_provider, \
1058 .probe_callback = (void (*)(void)) <tng_ust__event_probe__##_provider##___##_template, \
1059 .fields = lttng_ust__event_fields___##_provider##___##_template, \
1060 .nr_fields = LTTNG_UST__TP_ARRAY_SIZE(lttng_ust__event_fields___##_provider##___##_template) - 1, \
1061 .loglevel = &__ref_loglevel___##_provider##___##_name, \
1062 .signature = __tp_event_signature___##_provider##___##_template, \
1063 .model_emf_uri = &__ref_model_emf_uri___##_provider##___##_name, \
1066 #include LTTNG_UST_TRACEPOINT_INCLUDE
1069 * Stage 7.2 of tracepoint event generation.
1071 * Create array of events.
1074 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
1075 #include <lttng/ust-tracepoint-event-reset.h>
1077 #undef LTTNG_UST__TRACEPOINT_EVENT_INSTANCE
1078 #define LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
1079 <tng_ust__event_desc___##_provider##_##_name,
1081 static const struct lttng_ust_event_desc
* const LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__event_desc___
, LTTNG_UST_TRACEPOINT_PROVIDER
)[] = {
1082 #include LTTNG_UST_TRACEPOINT_INCLUDE
1083 NULL
, /* Dummy, C99 forbids 0-len array. */
1088 * Stage 8 of tracepoint event generation.
1090 * Create a toplevel descriptor for the whole probe.
1093 const struct lttng_ust_probe_desc
LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_desc___
, LTTNG_UST_TRACEPOINT_PROVIDER
) = {
1094 .struct_size
= sizeof(struct lttng_ust_probe_desc
),
1095 .provider_name
= lttng_ust__tp_stringify(LTTNG_UST_TRACEPOINT_PROVIDER
),
1096 .event_desc
= LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__event_desc___
, LTTNG_UST_TRACEPOINT_PROVIDER
),
1097 .nr_events
= LTTNG_UST__TP_ARRAY_SIZE(LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__event_desc___
, LTTNG_UST_TRACEPOINT_PROVIDER
)) - 1,
1098 .major
= LTTNG_UST_PROVIDER_MAJOR
,
1099 .minor
= LTTNG_UST_PROVIDER_MINOR
,
1102 static int LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_refcount___
, LTTNG_UST_TRACEPOINT_PROVIDER
);
1103 static struct lttng_ust_registered_probe
*LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___
, LTTNG_UST_TRACEPOINT_PROVIDER
);
1106 * Stage 9 of tracepoint event generation.
1108 * Register/unregister probes at module load/unload.
1110 * Generate the constructor as an externally visible symbol for use when
1111 * linking the probe statically.
1113 * Register refcount is protected by libc dynamic loader mutex.
1116 /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */
1117 #include <lttng/ust-tracepoint-event-reset.h>
1119 LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_init__
, LTTNG_UST_TRACEPOINT_PROVIDER
)(void)
1120 lttng_ust_notrace
__attribute__((constructor
));
1122 LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_init__
, LTTNG_UST_TRACEPOINT_PROVIDER
)(void)
1124 struct lttng_ust_registered_probe
*reg_probe
;
1126 if (LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_refcount___
,
1127 LTTNG_UST_TRACEPOINT_PROVIDER
)++) {
1131 * lttng_ust_tracepoint_provider_check_ ## LTTNG_UST_TRACEPOINT_PROVIDER() is a
1132 * static inline function that ensures every probe PROVIDER
1133 * argument match the provider within which they appear. It
1134 * calls empty static inline functions, and therefore has no
1135 * runtime effect. However, if it detects an error, a linker
1136 * error will appear.
1138 LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_check_
, LTTNG_UST_TRACEPOINT_PROVIDER
)();
1139 assert(!LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___
, LTTNG_UST_TRACEPOINT_PROVIDER
));
1140 reg_probe
= lttng_ust_probe_register(<TNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_desc___
, LTTNG_UST_TRACEPOINT_PROVIDER
));
1142 fprintf(stderr
, "LTTng-UST: Error while registering tracepoint probe.\n");
1145 LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___
, LTTNG_UST_TRACEPOINT_PROVIDER
) = reg_probe
;
1149 LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_exit__
, LTTNG_UST_TRACEPOINT_PROVIDER
)(void)
1150 lttng_ust_notrace
__attribute__((destructor
));
1152 LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_exit__
, LTTNG_UST_TRACEPOINT_PROVIDER
)(void)
1154 if (--LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_refcount___
,
1155 LTTNG_UST_TRACEPOINT_PROVIDER
)) {
1158 lttng_ust_probe_unregister(LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___
, LTTNG_UST_TRACEPOINT_PROVIDER
));
1159 LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___
, LTTNG_UST_TRACEPOINT_PROVIDER
) = NULL
;
1162 int LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_
, LTTNG_UST_TRACEPOINT_PROVIDER
)
1163 __attribute__((visibility("default")));