Fix: check for event class/instance prototype mismatch
[lttng-ust.git] / include / lttng / ust-tracepoint-event.h
CommitLineData
1c324e59 1/*
e92f3e28 2 * Copyright (c) 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
1c324e59 3 *
e92f3e28
MD
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:
1c324e59 10 *
e92f3e28
MD
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
d2428e87
MD
13 *
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
20 * SOFTWARE.
1c324e59
MD
21 */
22
23#include <stdio.h>
7d381d6e 24#include <stdlib.h>
1c324e59 25#include <urcu/compiler.h>
f488575f 26#include <urcu/rculist.h>
1c324e59 27#include <lttng/ust-events.h>
1c324e59 28#include <lttng/ringbuffer-config.h>
a8909ba5 29#include <lttng/ust-compiler.h>
000b8662 30#include <lttng/tracepoint.h>
39ad74cf 31#include <byteswap.h>
44c72f10 32#include <string.h>
1c324e59 33
24a39530
PP
34#define __LTTNG_UST_NULL_STRING "(null)"
35
000b8662
MD
36#undef tp_list_for_each_entry_rcu
37#define tp_list_for_each_entry_rcu(pos, head, member) \
38 for (pos = cds_list_entry(tp_rcu_dereference_bp((head)->next), __typeof__(*pos), member); \
39 &pos->member != (head); \
40 pos = cds_list_entry(tp_rcu_dereference_bp(pos->member.next), __typeof__(*pos), member))
41
1c324e59
MD
42/*
43 * TRACEPOINT_EVENT_CLASS declares a class of tracepoints receiving the
44 * same arguments and having the same field layout.
45 *
46 * TRACEPOINT_EVENT_INSTANCE declares an instance of a tracepoint, with
47 * its own provider and name. It refers to a class (template).
48 *
49 * TRACEPOINT_EVENT declared both a class and an instance and does a
50 * direct mapping from the instance to the class.
51 */
52
53#undef TRACEPOINT_EVENT
54#define TRACEPOINT_EVENT(_provider, _name, _args, _fields) \
55 TRACEPOINT_EVENT_CLASS(_provider, _name, \
56 _TP_PARAMS(_args), \
57 _TP_PARAMS(_fields)) \
58 TRACEPOINT_EVENT_INSTANCE(_provider, _name, _name, \
68755429 59 _TP_PARAMS(_args))
1c324e59
MD
60
61/* Helpers */
62#define _TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
63
64#define _tp_max_t(type, x, y) \
65 ({ \
66 type __max1 = (x); \
67 type __max2 = (y); \
68 __max1 > __max2 ? __max1: __max2; \
69 })
70
71/*
72 * Stage 0 of tracepoint event generation.
73 *
74 * Check that each TRACEPOINT_EVENT provider argument match the
75 * TRACEPOINT_PROVIDER by creating dummy callbacks.
76 */
77
78/* Reset all macros within TRACEPOINT_EVENT */
79#include <lttng/ust-tracepoint-event-reset.h>
80
7ce6b21d
PW
81static inline lttng_ust_notrace
82void _TP_COMBINE_TOKENS(__tracepoint_provider_mismatch_, TRACEPOINT_PROVIDER)(void);
1c324e59
MD
83static inline
84void _TP_COMBINE_TOKENS(__tracepoint_provider_mismatch_, TRACEPOINT_PROVIDER)(void)
85{
86}
87
88#undef TRACEPOINT_EVENT_CLASS
89#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
90 __tracepoint_provider_mismatch_##_provider();
91
92#undef TRACEPOINT_EVENT_INSTANCE
93#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
94 __tracepoint_provider_mismatch_##_provider();
95
7ce6b21d
PW
96static inline lttng_ust_notrace
97void _TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)(void);
e8bd1da7 98static inline
1c324e59
MD
99void _TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)(void)
100{
101#include TRACEPOINT_INCLUDE
102}
103
f56cd1d5
MD
104/*
105 * Stage 0.1 of tracepoint event generation.
106 *
107 * Check that each TRACEPOINT_EVENT provider:name does not exceed the
108 * tracepoint name length limit.
109 */
110
111/* Reset all macros within TRACEPOINT_EVENT */
112#include <lttng/ust-tracepoint-event-reset.h>
113
114#undef TRACEPOINT_EVENT_INSTANCE
115#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
116static const char \
117 __tp_name_len_check##_provider##___##_name[LTTNG_UST_SYM_NAME_LEN] \
118 __attribute__((unused)) = \
119 #_provider ":" #_name;
120
121#include TRACEPOINT_INCLUDE
122
c75c0422
MD
123/*
124 * Stage 0.2 of tracepoint event generation.
125 *
126 * Create dummy trace prototypes for each event class, and for each used
127 * template. This will allow checking whether the prototypes from the
128 * class and the instance using the class actually match.
129 */
130
131/* Reset all macros within TRACEPOINT_EVENT */
132#include <lttng/ust-tracepoint-event-reset.h>
133
134#undef TP_ARGS
135#define TP_ARGS(...) __VA_ARGS__
136
137#undef TRACEPOINT_EVENT_INSTANCE
138#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
139void __event_template_proto___##_provider##___##_template(_TP_ARGS_DATA_PROTO(_args));
140
141#undef TRACEPOINT_EVENT_CLASS
142#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
143void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
144
145#include TRACEPOINT_INCLUDE
146
c785c634
MD
147/*
148 * Stage 0.9 of tracepoint event generation
149 *
150 * Unfolding the enums
151 */
152#include <lttng/ust-tracepoint-event-reset.h>
153
154/* Enumeration entry (single value) */
155#undef ctf_enum_value
156#define ctf_enum_value(_string, _value) \
a6f80644
MD
157 { \
158 .start = { \
a6f80644
MD
159 .value = lttng_is_signed_type(__typeof__(_value)) ? \
160 (long long) (_value) : (_value), \
2c3f4c28 161 .signedness = lttng_is_signed_type(__typeof__(_value)), \
a6f80644
MD
162 }, \
163 .end = { \
a6f80644
MD
164 .value = lttng_is_signed_type(__typeof__(_value)) ? \
165 (long long) (_value) : (_value), \
2c3f4c28 166 .signedness = lttng_is_signed_type(__typeof__(_value)), \
a6f80644
MD
167 }, \
168 .string = (_string), \
169 },
c785c634
MD
170
171/* Enumeration entry (range) */
172#undef ctf_enum_range
173#define ctf_enum_range(_string, _range_start, _range_end) \
a6f80644
MD
174 { \
175 .start = { \
a6f80644
MD
176 .value = lttng_is_signed_type(__typeof__(_range_start)) ? \
177 (long long) (_range_start) : (_range_start), \
2c3f4c28 178 .signedness = lttng_is_signed_type(__typeof__(_range_start)), \
a6f80644
MD
179 }, \
180 .end = { \
a6f80644
MD
181 .value = lttng_is_signed_type(__typeof__(_range_end)) ? \
182 (long long) (_range_end) : (_range_end), \
2c3f4c28 183 .signedness = lttng_is_signed_type(__typeof__(_range_end)), \
a6f80644
MD
184 }, \
185 .string = (_string), \
186 },
c785c634 187
3e762260
PP
188/* Enumeration entry (automatic value; follows the rules of CTF) */
189#undef ctf_enum_auto
190#define ctf_enum_auto(_string) \
191 { \
192 .start = { \
193 .value = -1ULL, \
194 .signedness = 0, \
195 }, \
196 .end = { \
197 .value = -1ULL, \
198 .signedness = 0, \
199 }, \
200 .string = (_string), \
201 .u = { \
202 .extra = { \
203 .options = LTTNG_ENUM_ENTRY_OPTION_IS_AUTO, \
204 }, \
205 }, \
206 },
207
c785c634
MD
208#undef TP_ENUM_VALUES
209#define TP_ENUM_VALUES(...) \
210 __VA_ARGS__
211
212#undef TRACEPOINT_ENUM
213#define TRACEPOINT_ENUM(_provider, _name, _values) \
214 const struct lttng_enum_entry __enum_values__##_provider##_##_name[] = { \
215 _values \
1c80c909 216 ctf_enum_value("", 0) /* Dummy, 0-len array forbidden by C99. */ \
c785c634
MD
217 };
218
219#include TRACEPOINT_INCLUDE
220
1c324e59
MD
221/*
222 * Stage 1 of tracepoint event generation.
223 *
224 * Create event field type metadata section.
225 * Each event produce an array of fields.
226 */
227
228/* Reset all macros within TRACEPOINT_EVENT */
229#include <lttng/ust-tracepoint-event-reset.h>
4774c8f3
MD
230#include <lttng/ust-tracepoint-event-write.h>
231#include <lttng/ust-tracepoint-event-nowrite.h>
1c324e59 232
4774c8f3 233#undef _ctf_integer_ext
180901e6 234#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
1c324e59
MD
235 { \
236 .name = #_item, \
237 .type = __type_integer(_type, _byte_order, _base, none),\
180901e6 238 .nowrite = _nowrite, \
1c324e59
MD
239 },
240
4774c8f3 241#undef _ctf_float
180901e6 242#define _ctf_float(_type, _item, _src, _nowrite) \
1c324e59
MD
243 { \
244 .name = #_item, \
245 .type = __type_float(_type), \
180901e6 246 .nowrite = _nowrite, \
1c324e59
MD
247 },
248
4774c8f3 249#undef _ctf_array_encoded
f3ec4cb5
MD
250#define _ctf_array_encoded(_type, _item, _src, _byte_order, \
251 _length, _encoding, _nowrite, \
252 _elem_type_base) \
1c324e59
MD
253 { \
254 .name = #_item, \
255 .type = \
256 { \
257 .atype = atype_array, \
46d52200 258 .u = \
1c324e59 259 { \
46d52200
ZT
260 .array = \
261 { \
f3ec4cb5 262 .elem_type = __type_integer(_type, _byte_order, _elem_type_base, _encoding), \
46d52200
ZT
263 .length = _length, \
264 } \
265 } \
1c324e59 266 }, \
180901e6 267 .nowrite = _nowrite, \
1c324e59
MD
268 },
269
4774c8f3 270#undef _ctf_sequence_encoded
48d660d1 271#define _ctf_sequence_encoded(_type, _item, _src, _byte_order, \
f968510a
PP
272 _length_type, _src_length, _encoding, _nowrite, \
273 _elem_type_base) \
1c324e59
MD
274 { \
275 .name = #_item, \
276 .type = \
277 { \
278 .atype = atype_sequence, \
46d52200 279 .u = \
1c324e59 280 { \
46d52200
ZT
281 .sequence = \
282 { \
283 .length_type = __type_integer(_length_type, BYTE_ORDER, 10, none), \
48d660d1 284 .elem_type = __type_integer(_type, _byte_order, _elem_type_base, _encoding), \
46d52200 285 }, \
1c324e59
MD
286 }, \
287 }, \
180901e6 288 .nowrite = _nowrite, \
1c324e59
MD
289 },
290
4774c8f3 291#undef _ctf_string
180901e6 292#define _ctf_string(_item, _src, _nowrite) \
1c324e59
MD
293 { \
294 .name = #_item, \
295 .type = \
296 { \
297 .atype = atype_string, \
46d52200
ZT
298 .u = \
299 { \
300 .basic = { .string = { .encoding = lttng_encode_UTF8 } } \
301 }, \
1c324e59 302 }, \
180901e6 303 .nowrite = _nowrite, \
1c324e59
MD
304 },
305
c785c634
MD
306#undef _ctf_enum
307#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \
308 { \
309 .name = #_item, \
310 .type = { \
311 .atype = atype_enum, \
312 .u = { \
313 .basic = { \
314 .enumeration = { \
315 .desc = &__enum_##_provider##_##_name, \
316 .container_type = { \
317 .size = sizeof(_type) * CHAR_BIT, \
318 .alignment = lttng_alignof(_type) * CHAR_BIT, \
319 .signedness = lttng_is_signed_type(_type), \
320 .reverse_byte_order = 0, \
321 .base = 10, \
322 .encoding = lttng_encode_none, \
323 }, \
324 }, \
325 }, \
326 }, \
327 }, \
328 .nowrite = _nowrite, \
329 },
330
1c324e59 331#undef TP_FIELDS
2eda209b 332#define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
1c324e59
MD
333
334#undef TRACEPOINT_EVENT_CLASS
335#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
336 static const struct lttng_event_field __event_fields___##_provider##___##_name[] = { \
337 _fields \
1c80c909 338 ctf_integer(int, dummy, 0) /* Dummy, C99 forbids 0-len array. */ \
1c324e59
MD
339 };
340
c785c634
MD
341#undef TRACEPOINT_ENUM
342#define TRACEPOINT_ENUM(_provider, _name, _values) \
343 static const struct lttng_enum_desc __enum_##_provider##_##_name = { \
344 .name = #_provider "_" #_name, \
345 .entries = __enum_values__##_provider##_##_name, \
1c80c909 346 .nr_entries = _TP_ARRAY_SIZE(__enum_values__##_provider##_##_name) - 1, \
c785c634
MD
347 };
348
1c324e59
MD
349#include TRACEPOINT_INCLUDE
350
351/*
352 * Stage 2 of tracepoint event generation.
353 *
354 * Create probe callback prototypes.
355 */
356
357/* Reset all macros within TRACEPOINT_EVENT */
358#include <lttng/ust-tracepoint-event-reset.h>
359
360#undef TP_ARGS
2eda209b 361#define TP_ARGS(...) __VA_ARGS__
1c324e59
MD
362
363#undef TRACEPOINT_EVENT_CLASS
364#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
365static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
366
367#include TRACEPOINT_INCLUDE
368
369/*
c785c634 370 * Stage 3.0 of tracepoint event generation.
1c324e59 371 *
1c324e59
MD
372 * Create static inline function that calculates event size.
373 */
374
375/* Reset all macros within TRACEPOINT_EVENT */
376#include <lttng/ust-tracepoint-event-reset.h>
4774c8f3 377#include <lttng/ust-tracepoint-event-write.h>
1c324e59 378
4774c8f3 379#undef _ctf_integer_ext
180901e6 380#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
1c324e59
MD
381 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
382 __event_len += sizeof(_type);
383
4774c8f3 384#undef _ctf_float
180901e6 385#define _ctf_float(_type, _item, _src, _nowrite) \
1c324e59
MD
386 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
387 __event_len += sizeof(_type);
388
4774c8f3 389#undef _ctf_array_encoded
f3ec4cb5
MD
390#define _ctf_array_encoded(_type, _item, _src, _byte_order, _length, _encoding, \
391 _nowrite, _elem_type_base) \
1c324e59
MD
392 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
393 __event_len += sizeof(_type) * (_length);
394
4774c8f3 395#undef _ctf_sequence_encoded
48d660d1 396#define _ctf_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \
f968510a 397 _src_length, _encoding, _nowrite, _elem_type_base) \
1c324e59
MD
398 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
399 __event_len += sizeof(_length_type); \
400 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
401 __dynamic_len[__dynamic_len_idx] = (_src_length); \
402 __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \
403 __dynamic_len_idx++;
404
4774c8f3 405#undef _ctf_string
180901e6 406#define _ctf_string(_item, _src, _nowrite) \
24a39530
PP
407 __event_len += __dynamic_len[__dynamic_len_idx++] = \
408 strlen((_src) ? (_src) : __LTTNG_UST_NULL_STRING) + 1;
1c324e59 409
c785c634
MD
410#undef _ctf_enum
411#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \
412 _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, _nowrite)
413
1c324e59 414#undef TP_ARGS
2eda209b 415#define TP_ARGS(...) __VA_ARGS__
1c324e59
MD
416
417#undef TP_FIELDS
2eda209b 418#define TP_FIELDS(...) __VA_ARGS__
1c324e59
MD
419
420#undef TRACEPOINT_EVENT_CLASS
a8909ba5
PW
421#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
422static inline lttng_ust_notrace \
423size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)); \
424static inline \
425size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
1c324e59
MD
426{ \
427 size_t __event_len = 0; \
428 unsigned int __dynamic_len_idx = 0; \
429 \
430 if (0) \
431 (void) __dynamic_len_idx; /* don't warn if unused */ \
432 _fields \
433 return __event_len; \
434}
435
436#include TRACEPOINT_INCLUDE
437
1ddfd641
MD
438/*
439 * Stage 3.1 of tracepoint event generation.
440 *
441 * Create static inline function that layout the filter stack data.
4774c8f3 442 * We make both write and nowrite data available to the filter.
1ddfd641
MD
443 */
444
445/* Reset all macros within TRACEPOINT_EVENT */
446#include <lttng/ust-tracepoint-event-reset.h>
4774c8f3
MD
447#include <lttng/ust-tracepoint-event-write.h>
448#include <lttng/ust-tracepoint-event-nowrite.h>
1ddfd641 449
4774c8f3 450#undef _ctf_integer_ext
180901e6 451#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
fa099471 452 if (lttng_is_signed_type(_type)) { \
3ebeea0d
MD
453 int64_t __ctf_tmp_int64; \
454 switch (sizeof(_type)) { \
455 case 1: \
456 { \
457 union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
458 __ctf_tmp_int64 = (int64_t) __tmp.v; \
459 break; \
460 } \
461 case 2: \
462 { \
463 union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
39ad74cf
MD
464 if (_byte_order != BYTE_ORDER) \
465 __tmp.v = bswap_16(__tmp.v); \
3ebeea0d
MD
466 __ctf_tmp_int64 = (int64_t) __tmp.v; \
467 break; \
468 } \
469 case 4: \
470 { \
471 union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
39ad74cf
MD
472 if (_byte_order != BYTE_ORDER) \
473 __tmp.v = bswap_32(__tmp.v); \
3ebeea0d
MD
474 __ctf_tmp_int64 = (int64_t) __tmp.v; \
475 break; \
476 } \
477 case 8: \
478 { \
479 union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
39ad74cf
MD
480 if (_byte_order != BYTE_ORDER) \
481 __tmp.v = bswap_64(__tmp.v); \
3ebeea0d
MD
482 __ctf_tmp_int64 = (int64_t) __tmp.v; \
483 break; \
484 } \
485 default: \
486 abort(); \
487 }; \
fa099471
MD
488 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
489 } else { \
3ebeea0d
MD
490 uint64_t __ctf_tmp_uint64; \
491 switch (sizeof(_type)) { \
492 case 1: \
493 { \
494 union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
495 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
496 break; \
497 } \
498 case 2: \
499 { \
500 union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
39ad74cf
MD
501 if (_byte_order != BYTE_ORDER) \
502 __tmp.v = bswap_16(__tmp.v); \
3ebeea0d
MD
503 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
504 break; \
505 } \
506 case 4: \
507 { \
508 union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
39ad74cf
MD
509 if (_byte_order != BYTE_ORDER) \
510 __tmp.v = bswap_32(__tmp.v); \
3ebeea0d
MD
511 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
512 break; \
513 } \
514 case 8: \
515 { \
516 union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
39ad74cf
MD
517 if (_byte_order != BYTE_ORDER) \
518 __tmp.v = bswap_64(__tmp.v); \
3ebeea0d
MD
519 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
520 break; \
521 } \
522 default: \
523 abort(); \
524 }; \
fa099471
MD
525 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
526 } \
1ddfd641
MD
527 __stack_data += sizeof(int64_t);
528
4774c8f3 529#undef _ctf_float
180901e6 530#define _ctf_float(_type, _item, _src, _nowrite) \
fa099471
MD
531 { \
532 double __ctf_tmp_double = (double) (_type) (_src); \
533 memcpy(__stack_data, &__ctf_tmp_double, sizeof(double)); \
534 __stack_data += sizeof(double); \
535 }
1ddfd641 536
4774c8f3 537#undef _ctf_array_encoded
f3ec4cb5
MD
538#define _ctf_array_encoded(_type, _item, _src, _byte_order, _length, \
539 _encoding, _nowrite, _elem_type_base) \
fa099471
MD
540 { \
541 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
59034aab 542 const void *__ctf_tmp_ptr = (_src); \
fa099471
MD
543 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
544 __stack_data += sizeof(unsigned long); \
b1239ad6
MD
545 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
546 __stack_data += sizeof(void *); \
fa099471 547 }
1ddfd641 548
4774c8f3 549#undef _ctf_sequence_encoded
48d660d1 550#define _ctf_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \
f968510a 551 _src_length, _encoding, _nowrite, _elem_type_base) \
fa099471
MD
552 { \
553 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
59034aab 554 const void *__ctf_tmp_ptr = (_src); \
fa099471
MD
555 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
556 __stack_data += sizeof(unsigned long); \
b1239ad6
MD
557 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
558 __stack_data += sizeof(void *); \
fa099471 559 }
1ddfd641 560
4774c8f3 561#undef _ctf_string
180901e6 562#define _ctf_string(_item, _src, _nowrite) \
fa099471 563 { \
24a39530
PP
564 const void *__ctf_tmp_ptr = \
565 ((_src) ? (_src) : __LTTNG_UST_NULL_STRING); \
b1239ad6
MD
566 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
567 __stack_data += sizeof(void *); \
fa099471 568 }
1ddfd641 569
c785c634
MD
570#undef _ctf_enum
571#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \
572 _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, _nowrite)
573
1ddfd641
MD
574#undef TP_ARGS
575#define TP_ARGS(...) __VA_ARGS__
576
577#undef TP_FIELDS
578#define TP_FIELDS(...) __VA_ARGS__
579
580#undef TRACEPOINT_EVENT_CLASS
581#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
582static inline \
583void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
584 _TP_ARGS_DATA_PROTO(_args)) \
585{ \
586 _fields \
587}
588
589#include TRACEPOINT_INCLUDE
590
1c324e59 591/*
df854e41 592 * Stage 4 of tracepoint event generation.
1c324e59
MD
593 *
594 * Create static inline function that calculates event payload alignment.
595 */
596
597/* Reset all macros within TRACEPOINT_EVENT */
598#include <lttng/ust-tracepoint-event-reset.h>
4774c8f3 599#include <lttng/ust-tracepoint-event-write.h>
1c324e59 600
4774c8f3 601#undef _ctf_integer_ext
180901e6 602#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
1c324e59
MD
603 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
604
4774c8f3 605#undef _ctf_float
180901e6 606#define _ctf_float(_type, _item, _src, _nowrite) \
1c324e59
MD
607 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
608
4774c8f3 609#undef _ctf_array_encoded
f3ec4cb5
MD
610#define _ctf_array_encoded(_type, _item, _src, _byte_order, _length, \
611 _encoding, _nowrite, _elem_type_base) \
1c324e59
MD
612 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
613
4774c8f3 614#undef _ctf_sequence_encoded
48d660d1 615#define _ctf_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \
f968510a 616 _src_length, _encoding, _nowrite, _elem_type_base) \
1c324e59
MD
617 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_length_type)); \
618 __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type));
619
4774c8f3 620#undef _ctf_string
180901e6 621#define _ctf_string(_item, _src, _nowrite)
1c324e59 622
c785c634
MD
623#undef _ctf_enum
624#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \
625 _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, _nowrite)
626
1c324e59 627#undef TP_ARGS
2eda209b 628#define TP_ARGS(...) __VA_ARGS__
1c324e59
MD
629
630#undef TP_FIELDS
2eda209b 631#define TP_FIELDS(...) __VA_ARGS__
1c324e59
MD
632
633#undef TRACEPOINT_EVENT_CLASS
634#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
a8909ba5
PW
635static inline lttng_ust_notrace \
636size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)); \
1c324e59
MD
637static inline \
638size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \
639{ \
640 size_t __event_align = 1; \
641 _fields \
642 return __event_align; \
643}
644
645#include TRACEPOINT_INCLUDE
646
647
648/*
df854e41 649 * Stage 5 of tracepoint event generation.
1c324e59
MD
650 *
651 * Create the probe function. This function calls event size calculation
652 * and writes event data into the buffer.
653 */
654
655/* Reset all macros within TRACEPOINT_EVENT */
656#include <lttng/ust-tracepoint-event-reset.h>
4774c8f3 657#include <lttng/ust-tracepoint-event-write.h>
1c324e59 658
4774c8f3 659#undef _ctf_integer_ext
180901e6 660#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
1c324e59
MD
661 { \
662 _type __tmp = (_src); \
663 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
664 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
665 }
666
4774c8f3 667#undef _ctf_float
180901e6 668#define _ctf_float(_type, _item, _src, _nowrite) \
1c324e59
MD
669 { \
670 _type __tmp = (_src); \
671 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
672 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
673 }
674
4774c8f3 675#undef _ctf_array_encoded
f3ec4cb5
MD
676#define _ctf_array_encoded(_type, _item, _src, _byte_order, _length, \
677 _encoding, _nowrite, _elem_type_base) \
1c324e59
MD
678 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
679 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length));
680
4774c8f3 681#undef _ctf_sequence_encoded
48d660d1 682#define _ctf_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \
f968510a 683 _src_length, _encoding, _nowrite, _elem_type_base) \
1c324e59 684 { \
d71b57b9 685 _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx]; \
1c324e59
MD
686 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
687 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
688 } \
689 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
690 __chan->ops->event_write(&__ctx, _src, \
691 sizeof(_type) * __get_dynamic_len(dest));
692
a44c74d9
MD
693/*
694 * __chan->ops->u.has_strcpy is a flag letting us know if the LTTng-UST
695 * tracepoint provider ABI implements event_strcpy. This dynamic check
696 * can be removed when the tracepoint provider ABI moves to 2.
697 */
698#if (LTTNG_UST_PROVIDER_MAJOR > 1)
699#error "Tracepoint probe provider major version has changed. Please remove dynamic check for has_strcpy."
700#endif
701
4774c8f3 702#undef _ctf_string
180901e6 703#define _ctf_string(_item, _src, _nowrite) \
24a39530
PP
704 { \
705 const char *__ctf_tmp_string = \
706 ((_src) ? (_src) : __LTTNG_UST_NULL_STRING); \
707 lib_ring_buffer_align_ctx(&__ctx, \
708 lttng_alignof(*__ctf_tmp_string)); \
709 if (__chan->ops->u.has_strcpy) \
710 __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
711 __get_dynamic_len(dest)); \
712 else \
713 __chan->ops->event_write(&__ctx, __ctf_tmp_string, \
714 __get_dynamic_len(dest)); \
715 }
716
1c324e59 717
c785c634
MD
718#undef _ctf_enum
719#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \
720 _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, _nowrite)
721
1c324e59
MD
722/* Beware: this get len actually consumes the len value */
723#undef __get_dynamic_len
d71b57b9 724#define __get_dynamic_len(field) __stackvar.__dynamic_len[__dynamic_len_idx++]
1c324e59
MD
725
726#undef TP_ARGS
2eda209b 727#define TP_ARGS(...) __VA_ARGS__
1c324e59
MD
728
729#undef TP_FIELDS
2eda209b 730#define TP_FIELDS(...) __VA_ARGS__
1c324e59 731
95c25348
PW
732/*
733 * For state dump, check that "session" argument (mandatory) matches the
734 * session this event belongs to. Ensures that we write state dump data only
735 * into the started session, not into all sessions.
736 */
737#undef _TP_SESSION_CHECK
738#ifdef TP_SESSION_CHECK
739#define _TP_SESSION_CHECK(session, csession) (session == csession)
740#else /* TP_SESSION_CHECK */
741#define _TP_SESSION_CHECK(session, csession) 1
742#endif /* TP_SESSION_CHECK */
743
97904b41
MD
744/*
745 * Use of __builtin_return_address(0) sometimes seems to cause stack
746 * corruption on 32-bit PowerPC. Disable this feature on that
747 * architecture for now by always using the NULL value for the ip
748 * context.
749 */
5dadb547
MD
750#undef _TP_IP_PARAM
751#ifdef TP_IP_PARAM
e1d09f9e 752#define _TP_IP_PARAM(x) (x)
5dadb547 753#else /* TP_IP_PARAM */
97904b41
MD
754
755#if defined(__PPC__) && !defined(__PPC64__)
756#define _TP_IP_PARAM(x) NULL
757#else /* #if defined(__PPC__) && !defined(__PPC64__) */
e1d09f9e 758#define _TP_IP_PARAM(x) __builtin_return_address(0)
97904b41
MD
759#endif /* #else #if defined(__PPC__) && !defined(__PPC64__) */
760
5dadb547
MD
761#endif /* TP_IP_PARAM */
762
1ddfd641
MD
763/*
764 * Using twice size for filter stack data to hold size and pointer for
765 * each field (worse case). For integers, max size required is 64-bit.
766 * Same for double-precision floats. Those fit within
767 * 2*sizeof(unsigned long) for all supported architectures.
61ce3223 768 * Perform UNION (||) of filter runtime list.
1ddfd641 769 */
1c324e59
MD
770#undef TRACEPOINT_EVENT_CLASS
771#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
a8909ba5
PW
772static lttng_ust_notrace \
773void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)); \
774static \
775void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) \
1c324e59 776{ \
53569322 777 struct lttng_event *__event = (struct lttng_event *) __tp_data; \
7dd08bec 778 struct lttng_channel *__chan = __event->chan; \
f280cb51 779 struct lttng_ust_lib_ring_buffer_ctx __ctx; \
53569322 780 struct lttng_stack_ctx __lttng_ctx; \
1c324e59
MD
781 size_t __event_len, __event_align; \
782 size_t __dynamic_len_idx = 0; \
d71b57b9 783 union { \
1c80c909
MD
784 size_t __dynamic_len[_TP_ARRAY_SIZE(__event_fields___##_provider##___##_name) - 1]; \
785 char __filter_stack_data[2 * sizeof(unsigned long) * (_TP_ARRAY_SIZE(__event_fields___##_provider##___##_name) - 1)]; \
d71b57b9 786 } __stackvar; \
1c324e59
MD
787 int __ret; \
788 \
789 if (0) \
790 (void) __dynamic_len_idx; /* don't warn if unused */ \
95c25348
PW
791 if (!_TP_SESSION_CHECK(session, __chan->session)) \
792 return; \
1c324e59
MD
793 if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->session->active))) \
794 return; \
795 if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->enabled))) \
796 return; \
797 if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \
798 return; \
1b436e01
MD
799 if (caa_unlikely(!TP_RCU_LINK_TEST())) \
800 return; \
e58095ef 801 if (caa_unlikely(!cds_list_empty(&__event->bytecode_runtime_head))) { \
f488575f 802 struct lttng_bytecode_runtime *bc_runtime; \
dcdeaff0 803 int __filter_record = __event->has_enablers_without_bytecode; \
f488575f 804 \
1ddfd641 805 __event_prepare_filter_stack__##_provider##___##_name(__stackvar.__filter_stack_data, \
f488575f 806 _TP_ARGS_DATA_VAR(_args)); \
000b8662 807 tp_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
61ce3223 808 if (caa_unlikely(bc_runtime->filter(bc_runtime, \
8a92ed2a
MD
809 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
810 __filter_record = 1; \
f488575f 811 } \
8a92ed2a 812 if (caa_likely(!__filter_record)) \
61ce3223 813 return; \
1ddfd641
MD
814 } \
815 __event_len = __event_get_size__##_provider##___##_name(__stackvar.__dynamic_len, \
1c324e59
MD
816 _TP_ARGS_DATA_VAR(_args)); \
817 __event_align = __event_get_align__##_provider##___##_name(_TP_ARGS_VAR(_args)); \
53569322
MD
818 memset(&__lttng_ctx, 0, sizeof(__lttng_ctx)); \
819 __lttng_ctx.event = __event; \
820 __lttng_ctx.chan_ctx = tp_rcu_dereference_bp(__chan->ctx); \
821 __lttng_ctx.event_ctx = tp_rcu_dereference_bp(__event->ctx); \
1c324e59 822 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \
53569322 823 __event_align, -1, __chan->handle, &__lttng_ctx); \
e1d09f9e 824 __ctx.ip = _TP_IP_PARAM(TP_IP_PARAM); \
1c324e59
MD
825 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
826 if (__ret < 0) \
827 return; \
828 _fields \
829 __chan->ops->event_commit(&__ctx); \
830}
831
832#include TRACEPOINT_INCLUDE
833
834#undef __get_dynamic_len
835
68755429
MD
836/*
837 * Stage 5.1 of tracepoint event generation.
838 *
839 * Create probe signature
840 */
841
842/* Reset all macros within TRACEPOINT_EVENT */
843#include <lttng/ust-tracepoint-event-reset.h>
844
845#undef TP_ARGS
2eda209b 846#define TP_ARGS(...) __VA_ARGS__
9eb06182
MD
847
848#define _TP_EXTRACT_STRING2(...) #__VA_ARGS__
68755429
MD
849
850#undef TRACEPOINT_EVENT_CLASS
851#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
ff82b7c1 852static const char __tp_event_signature___##_provider##___##_name[] = \
9eb06182 853 _TP_EXTRACT_STRING2(_args);
68755429
MD
854
855#include TRACEPOINT_INCLUDE
856
9eb06182
MD
857#undef _TP_EXTRACT_STRING2
858
05ceaafd 859/*
882a56d7 860 * Stage 6 of tracepoint event generation.
1c324e59 861 *
df854e41
MD
862 * Tracepoint loglevel mapping definition generation. We generate a
863 * symbol for each mapping for a provider/event to ensure at most a 1 to
864 * 1 mapping between events and loglevels. If the symbol is repeated,
865 * the compiler will complain.
05ceaafd
MD
866 */
867
868/* Reset all macros within TRACEPOINT_EVENT */
869#include <lttng/ust-tracepoint-event-reset.h>
870
4ea4f80e
MD
871/*
872 * Declare _loglevel___##__provider##___##__name as non-static, with
873 * hidden visibility for c++ handling of weakref. We do a weakref to the
874 * symbol in a later stage, which requires that the symbol is not
875 * mangled.
876 */
877#ifdef __cplusplus
878#define LTTNG_TP_EXTERN_C extern "C"
879#else
880#define LTTNG_TP_EXTERN_C
881#endif
882
05ceaafd 883#undef TRACEPOINT_LOGLEVEL
457a6b58
MD
884#define TRACEPOINT_LOGLEVEL(__provider, __name, __loglevel) \
885static const int _loglevel_value___##__provider##___##__name = __loglevel; \
4ea4f80e
MD
886LTTNG_TP_EXTERN_C const int *_loglevel___##__provider##___##__name \
887 __attribute__((visibility("hidden"))) = \
457a6b58 888 &_loglevel_value___##__provider##___##__name;
df854e41
MD
889
890#include TRACEPOINT_INCLUDE
891
4ea4f80e 892#undef LTTNG_TP_EXTERN_C
4ea4f80e 893
6ddc916d
MD
894/*
895 * Stage 6.1 of tracepoint event generation.
896 *
897 * Tracepoint UML URI info.
898 */
899
900/* Reset all macros within TRACEPOINT_EVENT */
901#include <lttng/ust-tracepoint-event-reset.h>
902
4ea4f80e
MD
903/*
904 * Declare _model_emf_uri___##__provider##___##__name as non-static,
905 * with hidden visibility for c++ handling of weakref. We do a weakref
906 * to the symbol in a later stage, which requires that the symbol is not
907 * mangled.
908 */
909#ifdef __cplusplus
910#define LTTNG_TP_EXTERN_C extern "C"
911#else
912#define LTTNG_TP_EXTERN_C
913#endif
914
6ddc916d
MD
915#undef TRACEPOINT_MODEL_EMF_URI
916#define TRACEPOINT_MODEL_EMF_URI(__provider, __name, __uri) \
4ea4f80e 917LTTNG_TP_EXTERN_C const char *_model_emf_uri___##__provider##___##__name \
082802f9 918 __attribute__((visibility("hidden"))) = __uri; \
6ddc916d
MD
919
920#include TRACEPOINT_INCLUDE
921
4ea4f80e 922#undef LTTNG_TP_EXTERN_C
4ea4f80e 923
df854e41 924/*
882a56d7 925 * Stage 7.1 of tracepoint event generation.
df854e41
MD
926 *
927 * Create events description structures. We use a weakref because
928 * loglevels are optional. If not declared, the event will point to the
929 * a loglevel that contains NULL.
930 */
931
932/* Reset all macros within TRACEPOINT_EVENT */
933#include <lttng/ust-tracepoint-event-reset.h>
934
935#undef TRACEPOINT_EVENT_INSTANCE
936#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
882a56d7
MD
937static const int * \
938 __ref_loglevel___##_provider##___##_name \
939 __attribute__((weakref ("_loglevel___" #_provider "___" #_name))); \
6ddc916d
MD
940static const char * \
941 __ref_model_emf_uri___##_provider##___##_name \
942 __attribute__((weakref ("_model_emf_uri___" #_provider "___" #_name)));\
ff82b7c1 943static const struct lttng_event_desc __event_desc___##_provider##_##_name = { \
df854e41 944 .name = #_provider ":" #_name, \
fbdeb5ec 945 .probe_callback = (void (*)(void)) &__event_probe__##_provider##___##_template,\
46d52200
ZT
946 .ctx = NULL, \
947 .fields = __event_fields___##_provider##___##_template, \
1c80c909 948 .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template) - 1, \
882a56d7 949 .loglevel = &__ref_loglevel___##_provider##___##_name, \
68755429 950 .signature = __tp_event_signature___##_provider##___##_template, \
c785c634
MD
951 .u = { \
952 .ext = { \
953 .model_emf_uri = &__ref_model_emf_uri___##_provider##___##_name, \
954 }, \
955 }, \
df854e41
MD
956};
957
958#include TRACEPOINT_INCLUDE
05ceaafd 959
df854e41 960/*
882a56d7 961 * Stage 7.2 of tracepoint event generation.
df854e41
MD
962 *
963 * Create array of events.
964 */
965
966/* Reset all macros within TRACEPOINT_EVENT */
967#include <lttng/ust-tracepoint-event-reset.h>
968
969#undef TRACEPOINT_EVENT_INSTANCE
970#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
971 &__event_desc___##_provider##_##_name,
972
973static const struct lttng_event_desc *_TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)[] = {
05ceaafd 974#include TRACEPOINT_INCLUDE
1c80c909 975 NULL, /* Dummy, C99 forbids 0-len array. */
05ceaafd
MD
976};
977
df854e41 978
05ceaafd 979/*
882a56d7 980 * Stage 8 of tracepoint event generation.
05ceaafd
MD
981 *
982 * Create a toplevel descriptor for the whole probe.
983 */
984
985/* non-const because list head will be modified when registered. */
986static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER) = {
df854e41 987 .provider = __tp_stringify(TRACEPOINT_PROVIDER),
05ceaafd 988 .event_desc = _TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER),
1c80c909 989 .nr_events = _TP_ARRAY_SIZE(_TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)) - 1,
46d52200
ZT
990 .head = { NULL, NULL },
991 .lazy_init_head = { NULL, NULL },
992 .lazy = 0,
71d31690
MD
993 .major = LTTNG_UST_PROVIDER_MAJOR,
994 .minor = LTTNG_UST_PROVIDER_MINOR,
05ceaafd
MD
995};
996
f0cc794d
MD
997static int _TP_COMBINE_TOKENS(__probe_register_refcount___, TRACEPOINT_PROVIDER);
998
05ceaafd 999/*
882a56d7 1000 * Stage 9 of tracepoint event generation.
05ceaafd 1001 *
1c324e59 1002 * Register/unregister probes at module load/unload.
628e1d81
MD
1003 *
1004 * Generate the constructor as an externally visible symbol for use when
1005 * linking the probe statically.
f0cc794d
MD
1006 *
1007 * Register refcount is protected by libc dynamic loader mutex.
1c324e59
MD
1008 */
1009
1010/* Reset all macros within TRACEPOINT_EVENT */
1011#include <lttng/ust-tracepoint-event-reset.h>
a8909ba5
PW
1012static void lttng_ust_notrace __attribute__((constructor))
1013_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void);
1014static void
1c324e59
MD
1015_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
1016{
1017 int ret;
1018
f0cc794d
MD
1019 if (_TP_COMBINE_TOKENS(__probe_register_refcount___,
1020 TRACEPOINT_PROVIDER)++) {
1021 return;
1022 }
e8bd1da7
MD
1023 /*
1024 * __tracepoint_provider_check_ ## TRACEPOINT_PROVIDER() is a
1025 * static inline function that ensures every probe PROVIDER
1026 * argument match the provider within which they appear. It
1027 * calls empty static inline functions, and therefore has no
1028 * runtime effect. However, if it detects an error, a linker
1029 * error will appear.
1030 */
1031 _TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)();
7dd08bec 1032 ret = lttng_probe_register(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
7d381d6e 1033 if (ret) {
0fdd0b89 1034 fprintf(stderr, "LTTng-UST: Error (%d) while registering tracepoint probe.\n", ret);
7d381d6e
MD
1035 abort();
1036 }
1c324e59
MD
1037}
1038
a8909ba5
PW
1039static void lttng_ust_notrace __attribute__((destructor))
1040_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void);
1041static void
1c324e59
MD
1042_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
1043{
f0cc794d
MD
1044 if (--_TP_COMBINE_TOKENS(__probe_register_refcount___,
1045 TRACEPOINT_PROVIDER)) {
1046 return;
1047 }
7dd08bec 1048 lttng_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
1c324e59 1049}
628e1d81
MD
1050
1051int _TP_COMBINE_TOKENS(__tracepoint_provider_, TRACEPOINT_PROVIDER);
This page took 0.080809 seconds and 4 git commands to generate.