1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
3 * lttng-tracepoint-event-impl.h
5 * Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org>
6 * Copyright (C) 2009-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 #include <linux/uaccess.h>
10 #include <linux/debugfs.h>
11 #include <linux/rculist.h>
12 #include <asm/byteorder.h>
13 #include <linux/swab.h>
15 #include <probes/lttng.h>
16 #include <probes/lttng-types.h>
17 #include <probes/lttng-probe-user.h>
18 #include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
19 #include <wrapper/ringbuffer/frontend_types.h>
20 #include <wrapper/ringbuffer/backend.h>
21 #include <wrapper/rcu.h>
22 #include <wrapper/user_namespace.h>
23 #include <lttng-events.h>
24 #include <lttng-tracer-core.h>
25 #include <lttng-tp-mempool.h>
27 #define __LTTNG_NULL_STRING "(null)"
30 * Macro declarations used for all stages.
34 * LTTng name mapping macros. LTTng remaps some of the kernel events to
35 * enforce name-spacing.
37 #undef LTTNG_TRACEPOINT_EVENT_MAP
38 #define LTTNG_TRACEPOINT_EVENT_MAP(name, map, proto, args, fields) \
39 LTTNG_TRACEPOINT_EVENT_CLASS(map, \
43 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
45 #undef LTTNG_TRACEPOINT_EVENT_MAP_NOARGS
46 #define LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, map, fields) \
47 LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(map, \
49 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(map, name, map)
51 #undef LTTNG_TRACEPOINT_EVENT_CODE_MAP
52 #define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code_pre, fields, _code_post) \
53 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(map, \
60 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
62 #undef LTTNG_TRACEPOINT_EVENT_CODE
63 #define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code_pre, fields, _code_post) \
64 LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, name, \
73 * LTTNG_TRACEPOINT_EVENT_CLASS can be used to add a generic function
74 * handlers for events. That is, if all events have the same parameters
75 * and just have distinct trace points. Each tracepoint can be defined
76 * with LTTNG_TRACEPOINT_EVENT_INSTANCE and that will map the
77 * LTTNG_TRACEPOINT_EVENT_CLASS to the tracepoint.
79 * LTTNG_TRACEPOINT_EVENT is a one to one mapping between tracepoint and
83 #undef LTTNG_TRACEPOINT_EVENT
84 #define LTTNG_TRACEPOINT_EVENT(name, proto, args, fields) \
85 LTTNG_TRACEPOINT_EVENT_MAP(name, name, \
90 #undef LTTNG_TRACEPOINT_EVENT_NOARGS
91 #define LTTNG_TRACEPOINT_EVENT_NOARGS(name, fields) \
92 LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, name, PARAMS(fields))
94 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE
95 #define LTTNG_TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \
96 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(template, name, name, PARAMS(proto), PARAMS(args))
98 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
99 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \
100 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(template, name, name)
102 #undef LTTNG_TRACEPOINT_EVENT_CLASS
103 #define LTTNG_TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \
104 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(_proto), PARAMS(_args), , , \
107 #undef LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
108 #define LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
109 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, , , PARAMS(_fields), )
113 * Stage 1 of the trace events.
115 * Create dummy trace calls for each events, verifying that the LTTng module
116 * instrumentation headers match the kernel arguments. Will be optimized
117 * out by the compiler.
120 /* Reset all macros within TRACEPOINT_EVENT */
121 #include <probes/lttng-events-reset.h>
124 #define TP_PROTO(...) __VA_ARGS__
127 #define TP_ARGS(...) __VA_ARGS__
129 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
130 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
131 void trace_##_name(_proto);
133 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
134 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
135 void trace_##_name(void);
137 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
140 * Stage 1.1 of the trace events.
142 * Create dummy trace prototypes for each event class, and for each used
143 * template. This will allow checking whether the prototypes from the
144 * class and the instance using the class actually match.
147 #include <probes/lttng-events-reset.h> /* Reset all macros within TRACE_EVENT */
150 #define TP_PROTO(...) __VA_ARGS__
153 #define TP_ARGS(...) __VA_ARGS__
155 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
156 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
157 void __event_template_proto___##_template(_proto);
159 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
160 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
161 void __event_template_proto___##_template(void);
163 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
164 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
165 void __event_template_proto___##_name(_proto);
167 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
168 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
169 void __event_template_proto___##_name(void);
171 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
174 * Stage 1.2 of tracepoint event generation
176 * Unfolding the enums
178 #include <probes/lttng-events-reset.h> /* Reset all macros within TRACE_EVENT */
180 /* Enumeration entry (single value) */
181 #undef ctf_enum_value
182 #define ctf_enum_value(_string, _value) \
185 .signedness = lttng_is_signed_type(__typeof__(_value)), \
186 .value = lttng_is_signed_type(__typeof__(_value)) ? \
187 (long long) (_value) : (_value), \
190 .signedness = lttng_is_signed_type(__typeof__(_value)), \
191 .value = lttng_is_signed_type(__typeof__(_value)) ? \
192 (long long) (_value) : (_value), \
194 .string = (_string), \
197 /* Enumeration entry (range) */
198 #undef ctf_enum_range
199 #define ctf_enum_range(_string, _range_start, _range_end) \
202 .signedness = lttng_is_signed_type(__typeof__(_range_start)), \
203 .value = lttng_is_signed_type(__typeof__(_range_start)) ? \
204 (long long) (_range_start) : (_range_start), \
207 .signedness = lttng_is_signed_type(__typeof__(_range_end)), \
208 .value = lttng_is_signed_type(__typeof__(_range_end)) ? \
209 (long long) (_range_end) : (_range_end), \
211 .string = (_string), \
214 /* Enumeration entry (automatic value; follows the rules of CTF) */
216 #define ctf_enum_auto(_string) \
226 .string = (_string), \
232 #undef TP_ENUM_VALUES
233 #define TP_ENUM_VALUES(...) \
236 #undef LTTNG_TRACEPOINT_ENUM
237 #define LTTNG_TRACEPOINT_ENUM(_name, _values) \
238 const struct lttng_enum_entry __enum_values__##_name[] = { \
242 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
245 * Stage 2 of the trace events.
247 * Create event field type metadata section.
248 * Each event produce an array of fields.
251 /* Reset all macros within TRACEPOINT_EVENT */
252 #include <probes/lttng-events-reset.h>
253 #include <probes/lttng-events-write.h>
254 #include <probes/lttng-events-nowrite.h>
256 #undef _ctf_integer_ext
257 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
260 .type = __type_integer(_type, 0, 0, -1, _byte_order, _user, _base, none),\
261 .nowrite = _nowrite, \
264 #undef _ctf_array_encoded
265 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
270 .atype = atype_array, \
275 .elem_type = __type_integer(_type, 0, 0, 0, _byte_order, _user, _base, _encoding), \
280 .nowrite = _nowrite, \
283 #undef _ctf_array_bitfield
284 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
289 .atype = atype_array_bitfield, \
294 .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, _user, 10, none), \
295 .length = (_length) * sizeof(_type) * CHAR_BIT, \
296 .elem_alignment = lttng_alignof(_type), \
300 .nowrite = _nowrite, \
304 #undef _ctf_sequence_encoded
305 #define _ctf_sequence_encoded(_type, _item, _src, \
306 _length_type, _src_length, _encoding, \
307 _byte_order, _base, _user, _nowrite) \
312 .atype = atype_sequence, \
317 .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 0, 10, none), \
318 .elem_type = __type_integer(_type, 0, 0, -1, _byte_order, _user, _base, _encoding), \
322 .nowrite = _nowrite, \
325 #undef _ctf_sequence_bitfield
326 #define _ctf_sequence_bitfield(_type, _item, _src, \
327 _length_type, _src_length, \
333 .atype = atype_sequence_bitfield, \
338 .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 0, 10, none), \
339 .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, _user, 10, none), \
340 .elem_alignment = lttng_alignof(_type), \
344 .nowrite = _nowrite, \
348 #define _ctf_string(_item, _src, _user, _nowrite) \
353 .atype = atype_string, \
356 .basic = { .string = { .encoding = lttng_encode_UTF8, .user = (_user), } } \
359 .nowrite = _nowrite, \
363 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
367 .atype = atype_enum, \
371 .desc = &__enum_##_name, \
372 .container_type = { \
373 .size = sizeof(_type) * CHAR_BIT, \
374 .alignment = lttng_alignof(_type) * CHAR_BIT, \
375 .signedness = lttng_is_signed_type(_type), \
376 .reverse_byte_order = 0, \
379 .encoding = lttng_encode_none, \
385 .nowrite = _nowrite, \
388 #undef ctf_custom_field
389 #define ctf_custom_field(_type, _item, _code) \
396 #undef ctf_custom_type
397 #define ctf_custom_type(...) __VA_ARGS__
400 #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
402 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
403 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
404 static const struct lttng_event_field __event_fields___##_name[] = { \
408 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
409 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
410 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post)
412 #undef LTTNG_TRACEPOINT_ENUM
413 #define LTTNG_TRACEPOINT_ENUM(_name, _values) \
414 static const struct lttng_enum_desc __enum_##_name = { \
416 .entries = __enum_values__##_name, \
417 .nr_entries = ARRAY_SIZE(__enum_values__##_name), \
420 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
423 * Stage 3 of the trace events.
425 * Create probe callback prototypes.
428 /* Reset all macros within TRACEPOINT_EVENT */
429 #include <probes/lttng-events-reset.h>
432 #define TP_PROTO(...) __VA_ARGS__
434 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
435 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
436 static void __event_probe__##_name(void *__data, _proto);
438 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
439 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
440 static void __event_probe__##_name(void *__data);
442 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
445 * Stage 4 of the trace events.
447 * Create static inline function that calculates event size.
450 /* Reset all macros within TRACEPOINT_EVENT */
451 #include <probes/lttng-events-reset.h>
452 #include <probes/lttng-events-write.h>
454 #undef _ctf_integer_ext
455 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
456 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
457 __event_len += sizeof(_type);
459 #undef _ctf_array_encoded
460 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
461 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
462 __event_len += sizeof(_type) * (_length);
464 #undef _ctf_array_bitfield
465 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
466 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
468 #undef _ctf_sequence_encoded
469 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
470 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
471 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
472 __event_len += sizeof(_length_type); \
473 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
475 size_t __seqlen = (_src_length); \
477 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
479 barrier(); /* reserve before use. */ \
480 this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = __seqlen; \
481 __event_len += sizeof(_type) * __seqlen; \
484 #undef _ctf_sequence_bitfield
485 #define _ctf_sequence_bitfield(_type, _item, _src, \
486 _length_type, _src_length, \
488 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
489 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
492 * ctf_user_string includes \0. If returns 0, it faulted, so we set size to
496 #define _ctf_string(_item, _src, _user, _nowrite) \
497 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
499 barrier(); /* reserve before use. */ \
501 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
502 max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \
504 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
505 strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1; \
509 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
510 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
513 #define ctf_align(_type) \
514 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type));
516 #undef ctf_custom_field
517 #define ctf_custom_field(_type, _item, _code) \
522 #undef ctf_custom_code
523 #define ctf_custom_code(...) __VA_ARGS__
526 #define TP_PROTO(...) __VA_ARGS__
529 #define TP_FIELDS(...) __VA_ARGS__
532 #define TP_locvar(...) __VA_ARGS__
534 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
535 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
536 static inline ssize_t __event_get_size__##_name(void *__tp_locvar, _proto) \
538 size_t __event_len = 0; \
539 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
540 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
543 return __event_len; \
546 __attribute__((unused)); \
550 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
551 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
552 static inline ssize_t __event_get_size__##_name(void *__tp_locvar) \
554 size_t __event_len = 0; \
555 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
556 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
559 return __event_len; \
562 __attribute__((unused)); \
566 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
570 * Stage 4.1 of tracepoint event generation.
572 * Create static inline function that layout the filter stack data.
573 * We make both write and nowrite data available to the filter.
576 /* Reset all macros within TRACEPOINT_EVENT */
577 #include <probes/lttng-events-reset.h>
578 #include <probes/lttng-events-write.h>
579 #include <probes/lttng-events-nowrite.h>
581 #undef _ctf_integer_ext_fetched
582 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
583 if (lttng_is_signed_type(_type)) { \
584 int64_t __ctf_tmp_int64; \
585 switch (sizeof(_type)) { \
588 union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
589 __ctf_tmp_int64 = (int64_t) __tmp.v; \
594 union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
595 if (_byte_order != __BYTE_ORDER) \
596 __swab16s(&__tmp.v); \
597 __ctf_tmp_int64 = (int64_t) __tmp.v; \
602 union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
603 if (_byte_order != __BYTE_ORDER) \
604 __swab32s(&__tmp.v); \
605 __ctf_tmp_int64 = (int64_t) __tmp.v; \
610 union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
611 if (_byte_order != __BYTE_ORDER) \
612 __swab64s(&__tmp.v); \
613 __ctf_tmp_int64 = (int64_t) __tmp.v; \
619 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
621 uint64_t __ctf_tmp_uint64; \
622 switch (sizeof(_type)) { \
625 union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
626 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
631 union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
632 if (_byte_order != __BYTE_ORDER) \
633 __swab16s(&__tmp.v); \
634 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
639 union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
640 if (_byte_order != __BYTE_ORDER) \
641 __swab32s(&__tmp.v); \
642 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
647 union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
648 if (_byte_order != __BYTE_ORDER) \
649 __swab64s(&__tmp.v); \
650 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
656 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
658 __stack_data += sizeof(int64_t);
660 #undef _ctf_integer_ext_isuser0
661 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
662 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
664 #undef _ctf_integer_ext_isuser1
665 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
668 char __array[sizeof(_user_src)]; \
669 __typeof__(_user_src) __v; \
671 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
672 &(_user_src), sizeof(_user_src))) \
673 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
674 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
677 #undef _ctf_integer_ext
678 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
679 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
681 #undef _ctf_array_encoded
682 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
684 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
685 const void *__ctf_tmp_ptr = (_src); \
686 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
687 __stack_data += sizeof(unsigned long); \
688 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
689 __stack_data += sizeof(void *); \
692 #undef _ctf_array_bitfield
693 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
694 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
696 #undef _ctf_sequence_encoded
697 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
698 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
700 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
701 const void *__ctf_tmp_ptr = (_src); \
702 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
703 __stack_data += sizeof(unsigned long); \
704 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
705 __stack_data += sizeof(void *); \
708 #undef _ctf_sequence_bitfield
709 #define _ctf_sequence_bitfield(_type, _item, _src, \
710 _length_type, _src_length, \
712 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
713 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
716 #define _ctf_string(_item, _src, _user, _nowrite) \
718 const void *__ctf_tmp_ptr = \
719 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
720 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
721 __stack_data += sizeof(void *); \
725 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
726 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
729 #define TP_PROTO(...) __VA_ARGS__
732 #define TP_FIELDS(...) __VA_ARGS__
735 #define TP_locvar(...) __VA_ARGS__
737 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
738 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
740 void __event_prepare_filter_stack__##_name(char *__stack_data, \
743 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
748 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
749 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
751 void __event_prepare_filter_stack__##_name(char *__stack_data, \
752 void *__tp_locvar, _proto) \
754 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
759 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
762 * Stage 5 of the trace events.
764 * Create static inline function that calculates event payload alignment.
767 /* Reset all macros within TRACEPOINT_EVENT */
768 #include <probes/lttng-events-reset.h>
769 #include <probes/lttng-events-write.h>
771 #undef _ctf_integer_ext
772 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
773 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
775 #undef _ctf_array_encoded
776 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
777 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
779 #undef _ctf_array_bitfield
780 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
781 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
783 #undef _ctf_sequence_encoded
784 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
785 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
786 __event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \
787 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
789 #undef _ctf_sequence_bitfield
790 #define _ctf_sequence_bitfield(_type, _item, _src, \
791 _length_type, _src_length, \
793 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
794 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
797 #define _ctf_string(_item, _src, _user, _nowrite)
800 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
801 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
804 #define ctf_align(_type) \
805 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
808 #define TP_PROTO(...) __VA_ARGS__
811 #define TP_FIELDS(...) __VA_ARGS__
814 #define TP_locvar(...) __VA_ARGS__
816 #undef ctf_custom_field
817 #define ctf_custom_field(_type, _item, _code) _code
819 #undef ctf_custom_code
820 #define ctf_custom_code(...) \
825 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
826 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
827 static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \
829 size_t __event_align = 1; \
830 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
833 return __event_align; \
836 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
837 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
838 static inline size_t __event_get_align__##_name(void *__tp_locvar) \
840 size_t __event_align = 1; \
841 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
844 return __event_align; \
847 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
850 * Stage 6 of tracepoint event generation.
852 * Create the probe function. This function calls event size calculation
853 * and writes event data into the buffer.
856 /* Reset all macros within TRACEPOINT_EVENT */
857 #include <probes/lttng-events-reset.h>
858 #include <probes/lttng-events-write.h>
860 #undef _ctf_integer_ext_fetched
861 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
863 _type __tmp = _src; \
864 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
865 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
868 #undef _ctf_integer_ext_isuser0
869 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
870 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
872 #undef _ctf_integer_ext_isuser1
873 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
876 char __array[sizeof(_user_src)]; \
877 __typeof__(_user_src) __v; \
879 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
880 &(_user_src), sizeof(_user_src))) \
881 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
882 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
885 #undef _ctf_integer_ext
886 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
887 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
889 #undef _ctf_array_encoded
890 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
891 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
893 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
895 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
898 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
899 #undef _ctf_array_bitfield
900 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
901 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
903 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
905 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
907 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
909 * For big endian, we need to byteswap into little endian.
911 #undef _ctf_array_bitfield
912 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
913 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
917 for (_i = 0; _i < (_length); _i++) { \
921 if (get_user(_tmp, (_type *) _src + _i)) \
924 _tmp = ((_type *) _src)[_i]; \
926 switch (sizeof(_type)) { \
930 _tmp = cpu_to_le16(_tmp); \
933 _tmp = cpu_to_le32(_tmp); \
936 _tmp = cpu_to_le64(_tmp); \
941 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
944 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
946 #undef _ctf_sequence_encoded
947 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
948 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
950 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx]; \
951 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
952 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
954 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
956 __chan->ops->event_write_from_user(&__ctx, _src, \
957 sizeof(_type) * __get_dynamic_len(dest)); \
959 __chan->ops->event_write(&__ctx, _src, \
960 sizeof(_type) * __get_dynamic_len(dest)); \
963 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
964 #undef _ctf_sequence_bitfield
965 #define _ctf_sequence_bitfield(_type, _item, _src, \
966 _length_type, _src_length, \
969 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
970 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
971 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
973 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
975 __chan->ops->event_write_from_user(&__ctx, _src, \
976 sizeof(_type) * __get_dynamic_len(dest)); \
978 __chan->ops->event_write(&__ctx, _src, \
979 sizeof(_type) * __get_dynamic_len(dest)); \
981 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
983 * For big endian, we need to byteswap into little endian.
985 #undef _ctf_sequence_bitfield
986 #define _ctf_sequence_bitfield(_type, _item, _src, \
987 _length_type, _src_length, \
990 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
991 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
992 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
994 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
996 size_t _i, _length; \
998 _length = __get_dynamic_len(dest); \
999 for (_i = 0; _i < _length; _i++) { \
1003 if (get_user(_tmp, (_type *) _src + _i)) \
1006 _tmp = ((_type *) _src)[_i]; \
1008 switch (sizeof(_type)) { \
1012 _tmp = cpu_to_le16(_tmp); \
1015 _tmp = cpu_to_le32(_tmp); \
1018 _tmp = cpu_to_le64(_tmp); \
1023 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
1026 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
1029 #define _ctf_string(_item, _src, _user, _nowrite) \
1031 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
1032 __chan->ops->event_strcpy_from_user(&__ctx, _src, \
1033 __get_dynamic_len(dest)); \
1035 const char *__ctf_tmp_string = \
1036 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
1037 lib_ring_buffer_align_ctx(&__ctx, \
1038 lttng_alignof(*__ctf_tmp_string)); \
1039 __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
1040 __get_dynamic_len(dest)); \
1044 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
1045 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
1048 #define ctf_align(_type) \
1049 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));
1051 #undef ctf_custom_field
1052 #define ctf_custom_field(_type, _item, _code) _code
1054 #undef ctf_custom_code
1055 #define ctf_custom_code(...) \
1060 /* Beware: this get len actually consumes the len value */
1061 #undef __get_dynamic_len
1062 #define __get_dynamic_len(field) this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx++]
1065 #define TP_PROTO(...) __VA_ARGS__
1068 #define TP_ARGS(...) __VA_ARGS__
1071 #define TP_FIELDS(...) __VA_ARGS__
1074 #define TP_locvar(...) __VA_ARGS__
1077 #define TP_code_pre(...) __VA_ARGS__
1080 #define TP_code_post(...) __VA_ARGS__
1083 * For state dump, check that "session" argument (mandatory) matches the
1084 * session this event belongs to. Ensures that we write state dump data only
1085 * into the started session, not into all sessions.
1087 #ifdef TP_SESSION_CHECK
1088 #define _TP_SESSION_CHECK(session, csession) (session == csession)
1089 #else /* TP_SESSION_CHECK */
1090 #define _TP_SESSION_CHECK(session, csession) 1
1091 #endif /* TP_SESSION_CHECK */
1094 * Using twice size for filter stack data to hold size and pointer for
1095 * each field (worse case). For integers, max size required is 64-bit.
1096 * Same for double-precision floats. Those fit within
1097 * 2*sizeof(unsigned long) for all supported architectures.
1098 * Perform UNION (||) of filter runtime list.
1100 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
1101 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
1102 static void __event_probe__##_name(void *__data, _proto) \
1104 struct probe_local_vars { _locvar }; \
1105 struct lttng_event *__event = __data; \
1106 struct lttng_probe_ctx __lttng_probe_ctx = { \
1108 .interruptible = !irqs_disabled(), \
1110 struct lttng_channel *__chan = __event->chan; \
1111 struct lttng_session *__session = __chan->session; \
1112 struct lib_ring_buffer_ctx __ctx; \
1113 ssize_t __event_len; \
1114 size_t __event_align; \
1115 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1117 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1118 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1121 struct probe_local_vars __tp_locvar; \
1122 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1124 struct lttng_id_tracker_rcu *__lf; \
1126 if (!_TP_SESSION_CHECK(session, __session)) \
1128 if (unlikely(!LTTNG_READ_ONCE(__session->active))) \
1130 if (unlikely(!LTTNG_READ_ONCE(__chan->enabled))) \
1132 if (unlikely(!LTTNG_READ_ONCE(__event->enabled))) \
1134 __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
1135 if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
1137 __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
1138 if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
1140 __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
1141 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1142 lttng_current_uid()))) \
1144 __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
1145 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1146 lttng_current_vuid()))) \
1148 __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
1149 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1150 lttng_current_gid()))) \
1152 __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
1153 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1154 lttng_current_vgid()))) \
1156 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1157 __dynamic_len_idx = __orig_dynamic_len_offset; \
1159 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1160 struct lttng_bytecode_runtime *bc_runtime; \
1161 int __filter_record = __event->has_enablers_without_bytecode; \
1163 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1164 tp_locvar, _args); \
1165 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1166 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1167 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
1168 __filter_record = 1; \
1170 if (likely(!__filter_record)) \
1173 __event_len = __event_get_size__##_name(tp_locvar, _args); \
1174 if (unlikely(__event_len < 0)) { \
1175 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1178 __event_align = __event_get_align__##_name(tp_locvar, _args); \
1179 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1180 __event_align, -1); \
1181 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1185 __chan->ops->event_commit(&__ctx); \
1188 barrier(); /* use before un-reserve. */ \
1189 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1193 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
1194 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
1195 static void __event_probe__##_name(void *__data) \
1197 struct probe_local_vars { _locvar }; \
1198 struct lttng_event *__event = __data; \
1199 struct lttng_probe_ctx __lttng_probe_ctx = { \
1201 .interruptible = !irqs_disabled(), \
1203 struct lttng_channel *__chan = __event->chan; \
1204 struct lttng_session *__session = __chan->session; \
1205 struct lib_ring_buffer_ctx __ctx; \
1206 ssize_t __event_len; \
1207 size_t __event_align; \
1208 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1210 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1211 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1214 struct probe_local_vars __tp_locvar; \
1215 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1217 struct lttng_id_tracker_rcu *__lf; \
1219 if (!_TP_SESSION_CHECK(session, __session)) \
1221 if (unlikely(!LTTNG_READ_ONCE(__session->active))) \
1223 if (unlikely(!LTTNG_READ_ONCE(__chan->enabled))) \
1225 if (unlikely(!LTTNG_READ_ONCE(__event->enabled))) \
1227 __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
1228 if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
1230 __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
1231 if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
1233 __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
1234 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1235 lttng_current_uid()))) \
1237 __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
1238 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1239 lttng_current_vuid()))) \
1241 __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
1242 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1243 lttng_current_gid()))) \
1245 __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
1246 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1247 lttng_current_vgid()))) \
1249 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1250 __dynamic_len_idx = __orig_dynamic_len_offset; \
1252 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1253 struct lttng_bytecode_runtime *bc_runtime; \
1254 int __filter_record = __event->has_enablers_without_bytecode; \
1256 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1258 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1259 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1260 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
1261 __filter_record = 1; \
1263 if (likely(!__filter_record)) \
1266 __event_len = __event_get_size__##_name(tp_locvar); \
1267 if (unlikely(__event_len < 0)) { \
1268 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1271 __event_align = __event_get_align__##_name(tp_locvar); \
1272 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1273 __event_align, -1); \
1274 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1278 __chan->ops->event_commit(&__ctx); \
1281 barrier(); /* use before un-reserve. */ \
1282 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1286 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1288 #undef __get_dynamic_len
1291 * Stage 7 of the trace events.
1293 * Create event descriptions.
1296 /* Named field types must be defined in lttng-types.h */
1298 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1301 #define TP_PROBE_CB(_template) &__event_probe__##_template
1304 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1305 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1306 static const struct lttng_event_desc __event_desc___##_map = { \
1307 .fields = __event_fields___##_template, \
1310 .probe_callback = (void *) TP_PROBE_CB(_template), \
1311 .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
1312 .owner = THIS_MODULE, \
1315 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1316 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1317 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1319 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1322 * Stage 8 of the trace events.
1324 * Create an array of event description pointers.
1327 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1329 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1330 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1331 &__event_desc___##_map,
1333 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1334 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1335 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1337 #define TP_ID1(_token, _system) _token##_system
1338 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1340 static const struct lttng_event_desc
*TP_ID(__provider_event_desc___
, TRACE_SYSTEM
)[] = {
1341 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1348 * Stage 9 of the trace events.
1350 * Create a toplevel descriptor for the whole probe.
1353 #define TP_ID1(_token, _system) _token##_system
1354 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1356 /* non-const because list head will be modified when registered. */
1357 static __used
struct lttng_probe_desc
TP_ID(__probe_desc___
, TRACE_SYSTEM
) = {
1358 .provider
= __stringify(TRACE_SYSTEM
),
1359 .event_desc
= TP_ID(__provider_event_desc___
, TRACE_SYSTEM
),
1360 .nr_events
= ARRAY_SIZE(TP_ID(__provider_event_desc___
, TRACE_SYSTEM
)),
1361 .head
= { NULL
, NULL
},
1362 .lazy_init_head
= { NULL
, NULL
},
1370 * Stage 10 of the trace events.
1372 * Register/unregister probes at module load/unload.
1375 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1377 #define TP_ID1(_token, _system) _token##_system
1378 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1379 #define module_init_eval1(_token, _system) module_init(_token##_system)
1380 #define module_init_eval(_token, _system) module_init_eval1(_token, _system)
1381 #define module_exit_eval1(_token, _system) module_exit(_token##_system)
1382 #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system)
1384 #ifndef TP_MODULE_NOINIT
1385 static int TP_ID(__lttng_events_init__
, TRACE_SYSTEM
)(void)
1387 wrapper_vmalloc_sync_mappings();
1388 return lttng_probe_register(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1391 static void TP_ID(__lttng_events_exit__
, TRACE_SYSTEM
)(void)
1393 lttng_probe_unregister(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1396 #ifndef TP_MODULE_NOAUTOLOAD
1397 module_init_eval(__lttng_events_init__
, TRACE_SYSTEM
);
1398 module_exit_eval(__lttng_events_exit__
, TRACE_SYSTEM
);
1403 #undef module_init_eval
1404 #undef module_exit_eval
This page took 0.059889 seconds and 4 git commands to generate.