1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
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_all() */
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, _base, none), \
261 .nowrite = _nowrite, \
266 #undef _ctf_array_encoded
267 #define _ctf_array_encoded(_type, _item, _src, _length, \
268 _encoding, _byte_order, _elem_type_base, _user, _nowrite) \
273 .atype = atype_array_nestable, \
278 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
279 __type_integer(_type, 0, 0, -1, _byte_order, _elem_type_base, _encoding)), \
285 .nowrite = _nowrite, \
290 #undef _ctf_array_bitfield
291 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
296 .atype = atype_array_nestable, \
301 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
302 __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none)), \
303 .length = (_length) * sizeof(_type) * CHAR_BIT, \
304 .alignment = lttng_alignof(_type), \
308 .nowrite = _nowrite, \
314 #undef _ctf_sequence_encoded
315 #define _ctf_sequence_encoded(_type, _item, _src, \
316 _length_type, _src_length, _encoding, \
317 _byte_order, _elem_type_base, _user, _nowrite) \
319 .name = "_" #_item "_length", \
320 .type = __type_integer(_length_type, 0, 0, -1, __BYTE_ORDER, 10, none), \
321 .nowrite = _nowrite, \
328 .atype = atype_sequence_nestable, \
331 .sequence_nestable = \
333 .length_name = "_" #_item "_length", \
334 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
335 __type_integer(_type, 0, 0, -1, _byte_order, _elem_type_base, _encoding)), \
340 .nowrite = _nowrite, \
345 #undef _ctf_sequence_bitfield
346 #define _ctf_sequence_bitfield(_type, _item, _src, \
347 _length_type, _src_length, \
350 .name = "_" #_item "_length", \
351 .type = __type_integer(_length_type, 0, 0, -1, __BYTE_ORDER, 10, none), \
352 .nowrite = _nowrite, \
359 .atype = atype_sequence_nestable, \
362 .sequence_nestable = \
364 .length_name = "_" #_item "_length", \
365 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
366 __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none)), \
367 .alignment = lttng_alignof(_type), \
371 .nowrite = _nowrite, \
377 #define _ctf_string(_item, _src, _user, _nowrite) \
382 .atype = atype_string, \
385 .string = { .encoding = lttng_encode_UTF8 }, \
388 .nowrite = _nowrite, \
394 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
398 .atype = atype_enum_nestable, \
401 .desc = &__enum_##_name, \
402 .container_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
403 __type_integer(_type, 0, 0, -1, __BYTE_ORDER, 10, none)), \
407 .nowrite = _nowrite, \
412 #undef ctf_custom_field
413 #define ctf_custom_field(_type, _item, _code) \
422 #undef ctf_custom_type
423 #define ctf_custom_type(...) __VA_ARGS__
426 #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
428 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
429 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
430 static const struct lttng_event_field __event_fields___##_name[] = { \
434 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
435 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
436 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post)
438 #undef LTTNG_TRACEPOINT_ENUM
439 #define LTTNG_TRACEPOINT_ENUM(_name, _values) \
440 static const struct lttng_enum_desc __enum_##_name = { \
442 .entries = __enum_values__##_name, \
443 .nr_entries = ARRAY_SIZE(__enum_values__##_name), \
446 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
449 * Stage 3 of the trace events.
451 * Create probe callback prototypes.
454 /* Reset all macros within TRACEPOINT_EVENT */
455 #include <probes/lttng-events-reset.h>
458 #define TP_PROTO(...) __VA_ARGS__
460 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
461 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
462 static void __event_probe__##_name(void *__data, _proto);
464 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
465 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
466 static void __event_probe__##_name(void *__data);
468 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
471 * Stage 4 of the trace events.
473 * Create static inline function that calculates event size.
476 /* Reset all macros within TRACEPOINT_EVENT */
477 #include <probes/lttng-events-reset.h>
478 #include <probes/lttng-events-write.h>
480 #undef _ctf_integer_ext
481 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
482 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
483 __event_len += sizeof(_type);
485 #undef _ctf_array_encoded
486 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
487 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
488 __event_len += sizeof(_type) * (_length);
490 #undef _ctf_array_bitfield
491 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
492 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
494 #undef _ctf_sequence_encoded
495 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
496 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
497 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
498 __event_len += sizeof(_length_type); \
499 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
501 size_t __seqlen = (_src_length); \
503 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
505 barrier(); /* reserve before use. */ \
506 this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = __seqlen; \
507 __event_len += sizeof(_type) * __seqlen; \
510 #undef _ctf_sequence_bitfield
511 #define _ctf_sequence_bitfield(_type, _item, _src, \
512 _length_type, _src_length, \
514 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
515 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
518 * ctf_user_string includes \0. If returns 0, it faulted, so we set size to
522 #define _ctf_string(_item, _src, _user, _nowrite) \
523 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
525 barrier(); /* reserve before use. */ \
527 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
528 max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \
530 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
531 strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1; \
535 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
536 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
539 #define ctf_align(_type) \
540 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type));
542 #undef ctf_custom_field
543 #define ctf_custom_field(_type, _item, _code) \
548 #undef ctf_custom_code
549 #define ctf_custom_code(...) __VA_ARGS__
552 #define TP_PROTO(...) __VA_ARGS__
555 #define TP_FIELDS(...) __VA_ARGS__
558 #define TP_locvar(...) __VA_ARGS__
560 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
561 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
562 static inline ssize_t __event_get_size__##_name(void *__tp_locvar, _proto) \
564 size_t __event_len = 0; \
565 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
566 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
569 return __event_len; \
572 __attribute__((unused)); \
576 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
577 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
578 static inline ssize_t __event_get_size__##_name(void *__tp_locvar) \
580 size_t __event_len = 0; \
581 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
582 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
585 return __event_len; \
588 __attribute__((unused)); \
592 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
596 * Stage 4.1 of tracepoint event generation.
598 * Create static inline function that layout the filter stack data.
599 * We make both write and nowrite data available to the filter.
602 /* Reset all macros within TRACEPOINT_EVENT */
603 #include <probes/lttng-events-reset.h>
604 #include <probes/lttng-events-write.h>
605 #include <probes/lttng-events-nowrite.h>
607 #undef _ctf_integer_ext_fetched
608 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
609 if (lttng_is_signed_type(_type)) { \
610 int64_t __ctf_tmp_int64; \
611 switch (sizeof(_type)) { \
614 union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
615 __ctf_tmp_int64 = (int64_t) __tmp.v; \
620 union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
621 if (_byte_order != __BYTE_ORDER) \
622 __swab16s(&__tmp.v); \
623 __ctf_tmp_int64 = (int64_t) __tmp.v; \
628 union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
629 if (_byte_order != __BYTE_ORDER) \
630 __swab32s(&__tmp.v); \
631 __ctf_tmp_int64 = (int64_t) __tmp.v; \
636 union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
637 if (_byte_order != __BYTE_ORDER) \
638 __swab64s(&__tmp.v); \
639 __ctf_tmp_int64 = (int64_t) __tmp.v; \
645 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
647 uint64_t __ctf_tmp_uint64; \
648 switch (sizeof(_type)) { \
651 union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
652 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
657 union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
658 if (_byte_order != __BYTE_ORDER) \
659 __swab16s(&__tmp.v); \
660 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
665 union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
666 if (_byte_order != __BYTE_ORDER) \
667 __swab32s(&__tmp.v); \
668 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
673 union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
674 if (_byte_order != __BYTE_ORDER) \
675 __swab64s(&__tmp.v); \
676 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
682 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
684 __stack_data += sizeof(int64_t);
686 #undef _ctf_integer_ext_isuser0
687 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
688 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
690 #undef _ctf_integer_ext_isuser1
691 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
694 char __array[sizeof(_user_src)]; \
695 __typeof__(_user_src) __v; \
697 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
698 &(_user_src), sizeof(_user_src))) \
699 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
700 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
703 #undef _ctf_integer_ext
704 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
705 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
707 #undef _ctf_array_encoded
708 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
710 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
711 const void *__ctf_tmp_ptr = (_src); \
712 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
713 __stack_data += sizeof(unsigned long); \
714 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
715 __stack_data += sizeof(void *); \
718 #undef _ctf_array_bitfield
719 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
720 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
722 #undef _ctf_sequence_encoded
723 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
724 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
726 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
727 const void *__ctf_tmp_ptr = (_src); \
728 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
729 __stack_data += sizeof(unsigned long); \
730 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
731 __stack_data += sizeof(void *); \
734 #undef _ctf_sequence_bitfield
735 #define _ctf_sequence_bitfield(_type, _item, _src, \
736 _length_type, _src_length, \
738 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
739 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
742 #define _ctf_string(_item, _src, _user, _nowrite) \
744 const void *__ctf_tmp_ptr = \
745 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
746 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
747 __stack_data += sizeof(void *); \
751 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
752 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
755 #define TP_PROTO(...) __VA_ARGS__
758 #define TP_FIELDS(...) __VA_ARGS__
761 #define TP_locvar(...) __VA_ARGS__
763 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
764 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
766 void __event_prepare_filter_stack__##_name(char *__stack_data, \
769 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
774 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
775 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
777 void __event_prepare_filter_stack__##_name(char *__stack_data, \
778 void *__tp_locvar, _proto) \
780 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
785 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
788 * Stage 5 of the trace events.
790 * Create static inline function that calculates event payload alignment.
793 /* Reset all macros within TRACEPOINT_EVENT */
794 #include <probes/lttng-events-reset.h>
795 #include <probes/lttng-events-write.h>
797 #undef _ctf_integer_ext
798 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
799 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
801 #undef _ctf_array_encoded
802 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
803 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
805 #undef _ctf_array_bitfield
806 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
807 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
809 #undef _ctf_sequence_encoded
810 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
811 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
812 __event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \
813 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
815 #undef _ctf_sequence_bitfield
816 #define _ctf_sequence_bitfield(_type, _item, _src, \
817 _length_type, _src_length, \
819 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
820 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
823 #define _ctf_string(_item, _src, _user, _nowrite)
826 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
827 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
830 #define ctf_align(_type) \
831 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
834 #define TP_PROTO(...) __VA_ARGS__
837 #define TP_FIELDS(...) __VA_ARGS__
840 #define TP_locvar(...) __VA_ARGS__
842 #undef ctf_custom_field
843 #define ctf_custom_field(_type, _item, _code) _code
845 #undef ctf_custom_code
846 #define ctf_custom_code(...) \
851 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
852 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
853 static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \
855 size_t __event_align = 1; \
856 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
859 return __event_align; \
862 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
863 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
864 static inline size_t __event_get_align__##_name(void *__tp_locvar) \
866 size_t __event_align = 1; \
867 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
870 return __event_align; \
873 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
876 * Stage 6 of tracepoint event generation.
878 * Create the probe function. This function calls event size calculation
879 * and writes event data into the buffer.
882 /* Reset all macros within TRACEPOINT_EVENT */
883 #include <probes/lttng-events-reset.h>
884 #include <probes/lttng-events-write.h>
886 #undef _ctf_integer_ext_fetched
887 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
889 _type __tmp = _src; \
890 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
891 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
894 #undef _ctf_integer_ext_isuser0
895 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
896 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
898 #undef _ctf_integer_ext_isuser1
899 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
902 char __array[sizeof(_user_src)]; \
903 __typeof__(_user_src) __v; \
905 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
906 &(_user_src), sizeof(_user_src))) \
907 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
908 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
911 #undef _ctf_integer_ext
912 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
913 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
915 #undef _ctf_array_encoded
916 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
917 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
919 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
921 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
924 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
925 #undef _ctf_array_bitfield
926 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
927 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
929 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
931 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
933 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
935 * For big endian, we need to byteswap into little endian.
937 #undef _ctf_array_bitfield
938 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
939 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
943 for (_i = 0; _i < (_length); _i++) { \
947 if (get_user(_tmp, (_type *) _src + _i)) \
950 _tmp = ((_type *) _src)[_i]; \
952 switch (sizeof(_type)) { \
956 _tmp = cpu_to_le16(_tmp); \
959 _tmp = cpu_to_le32(_tmp); \
962 _tmp = cpu_to_le64(_tmp); \
967 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
970 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
972 #undef _ctf_sequence_encoded
973 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
974 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
976 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx]; \
977 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
978 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
980 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
982 __chan->ops->event_write_from_user(&__ctx, _src, \
983 sizeof(_type) * __get_dynamic_len(dest)); \
985 __chan->ops->event_write(&__ctx, _src, \
986 sizeof(_type) * __get_dynamic_len(dest)); \
989 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
990 #undef _ctf_sequence_bitfield
991 #define _ctf_sequence_bitfield(_type, _item, _src, \
992 _length_type, _src_length, \
995 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
996 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
997 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
999 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
1001 __chan->ops->event_write_from_user(&__ctx, _src, \
1002 sizeof(_type) * __get_dynamic_len(dest)); \
1004 __chan->ops->event_write(&__ctx, _src, \
1005 sizeof(_type) * __get_dynamic_len(dest)); \
1007 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
1009 * For big endian, we need to byteswap into little endian.
1011 #undef _ctf_sequence_bitfield
1012 #define _ctf_sequence_bitfield(_type, _item, _src, \
1013 _length_type, _src_length, \
1016 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
1017 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
1018 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
1020 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
1022 size_t _i, _length; \
1024 _length = __get_dynamic_len(dest); \
1025 for (_i = 0; _i < _length; _i++) { \
1029 if (get_user(_tmp, (_type *) _src + _i)) \
1032 _tmp = ((_type *) _src)[_i]; \
1034 switch (sizeof(_type)) { \
1038 _tmp = cpu_to_le16(_tmp); \
1041 _tmp = cpu_to_le32(_tmp); \
1044 _tmp = cpu_to_le64(_tmp); \
1049 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
1052 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
1055 #define _ctf_string(_item, _src, _user, _nowrite) \
1057 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
1058 __chan->ops->event_strcpy_from_user(&__ctx, _src, \
1059 __get_dynamic_len(dest)); \
1061 const char *__ctf_tmp_string = \
1062 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
1063 lib_ring_buffer_align_ctx(&__ctx, \
1064 lttng_alignof(*__ctf_tmp_string)); \
1065 __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
1066 __get_dynamic_len(dest)); \
1070 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
1071 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
1074 #define ctf_align(_type) \
1075 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));
1077 #undef ctf_custom_field
1078 #define ctf_custom_field(_type, _item, _code) _code
1080 #undef ctf_custom_code
1081 #define ctf_custom_code(...) \
1086 /* Beware: this get len actually consumes the len value */
1087 #undef __get_dynamic_len
1088 #define __get_dynamic_len(field) this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx++]
1091 #define TP_PROTO(...) __VA_ARGS__
1094 #define TP_ARGS(...) __VA_ARGS__
1097 #define TP_FIELDS(...) __VA_ARGS__
1100 #define TP_locvar(...) __VA_ARGS__
1103 #define TP_code_pre(...) __VA_ARGS__
1106 #define TP_code_post(...) __VA_ARGS__
1109 * For state dump, check that "session" argument (mandatory) matches the
1110 * session this event belongs to. Ensures that we write state dump data only
1111 * into the started session, not into all sessions.
1113 #ifdef TP_SESSION_CHECK
1114 #define _TP_SESSION_CHECK(session, csession) (session == csession)
1115 #else /* TP_SESSION_CHECK */
1116 #define _TP_SESSION_CHECK(session, csession) 1
1117 #endif /* TP_SESSION_CHECK */
1120 * Using twice size for filter stack data to hold size and pointer for
1121 * each field (worse case). For integers, max size required is 64-bit.
1122 * Same for double-precision floats. Those fit within
1123 * 2*sizeof(unsigned long) for all supported architectures.
1124 * Perform UNION (||) of filter runtime list.
1126 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
1127 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
1128 static void __event_probe__##_name(void *__data, _proto) \
1130 struct probe_local_vars { _locvar }; \
1131 struct lttng_event *__event = __data; \
1132 struct lttng_probe_ctx __lttng_probe_ctx = { \
1134 .interruptible = !irqs_disabled(), \
1136 struct lttng_channel *__chan = __event->chan; \
1137 struct lttng_session *__session = __chan->session; \
1138 struct lib_ring_buffer_ctx __ctx; \
1139 ssize_t __event_len; \
1140 size_t __event_align; \
1141 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1143 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1144 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1147 struct probe_local_vars __tp_locvar; \
1148 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1150 struct lttng_id_tracker_rcu *__lf; \
1152 if (!_TP_SESSION_CHECK(session, __session)) \
1154 if (unlikely(!READ_ONCE(__session->active))) \
1156 if (unlikely(!READ_ONCE(__chan->enabled))) \
1158 if (unlikely(!READ_ONCE(__event->enabled))) \
1160 __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
1161 if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
1163 __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
1164 if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
1166 __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
1167 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1168 lttng_current_uid()))) \
1170 __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
1171 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1172 lttng_current_vuid()))) \
1174 __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
1175 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1176 lttng_current_gid()))) \
1178 __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
1179 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1180 lttng_current_vgid()))) \
1182 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1183 __dynamic_len_idx = __orig_dynamic_len_offset; \
1185 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1186 struct lttng_bytecode_runtime *bc_runtime; \
1187 int __filter_record = __event->has_enablers_without_bytecode; \
1189 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1190 tp_locvar, _args); \
1191 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1192 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1193 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) { \
1194 __filter_record = 1; \
1198 if (likely(!__filter_record)) \
1201 __event_len = __event_get_size__##_name(tp_locvar, _args); \
1202 if (unlikely(__event_len < 0)) { \
1203 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1206 __event_align = __event_get_align__##_name(tp_locvar, _args); \
1207 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1208 __event_align, -1); \
1209 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1213 __chan->ops->event_commit(&__ctx); \
1216 barrier(); /* use before un-reserve. */ \
1217 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1221 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
1222 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
1223 static void __event_probe__##_name(void *__data) \
1225 struct probe_local_vars { _locvar }; \
1226 struct lttng_event *__event = __data; \
1227 struct lttng_probe_ctx __lttng_probe_ctx = { \
1229 .interruptible = !irqs_disabled(), \
1231 struct lttng_channel *__chan = __event->chan; \
1232 struct lttng_session *__session = __chan->session; \
1233 struct lib_ring_buffer_ctx __ctx; \
1234 ssize_t __event_len; \
1235 size_t __event_align; \
1236 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1238 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1239 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1242 struct probe_local_vars __tp_locvar; \
1243 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1245 struct lttng_id_tracker_rcu *__lf; \
1247 if (!_TP_SESSION_CHECK(session, __session)) \
1249 if (unlikely(!READ_ONCE(__session->active))) \
1251 if (unlikely(!READ_ONCE(__chan->enabled))) \
1253 if (unlikely(!READ_ONCE(__event->enabled))) \
1255 __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
1256 if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
1258 __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
1259 if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
1261 __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
1262 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1263 lttng_current_uid()))) \
1265 __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
1266 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1267 lttng_current_vuid()))) \
1269 __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
1270 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1271 lttng_current_gid()))) \
1273 __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
1274 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1275 lttng_current_vgid()))) \
1277 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1278 __dynamic_len_idx = __orig_dynamic_len_offset; \
1280 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1281 struct lttng_bytecode_runtime *bc_runtime; \
1282 int __filter_record = __event->has_enablers_without_bytecode; \
1284 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1286 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1287 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1288 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) { \
1289 __filter_record = 1; \
1293 if (likely(!__filter_record)) \
1296 __event_len = __event_get_size__##_name(tp_locvar); \
1297 if (unlikely(__event_len < 0)) { \
1298 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1301 __event_align = __event_get_align__##_name(tp_locvar); \
1302 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1303 __event_align, -1); \
1304 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1308 __chan->ops->event_commit(&__ctx); \
1311 barrier(); /* use before un-reserve. */ \
1312 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1316 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1318 #undef __get_dynamic_len
1321 * Stage 7 of the trace events.
1323 * Create event descriptions.
1326 /* Named field types must be defined in lttng-types.h */
1328 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1331 #define TP_PROBE_CB(_template) &__event_probe__##_template
1334 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1335 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1336 static const struct lttng_event_desc __event_desc___##_map = { \
1337 .fields = __event_fields___##_template, \
1340 .probe_callback = (void *) TP_PROBE_CB(_template), \
1341 .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
1342 .owner = THIS_MODULE, \
1345 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1346 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1347 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1349 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1352 * Stage 8 of the trace events.
1354 * Create an array of event description pointers.
1357 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1359 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1360 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1361 &__event_desc___##_map,
1363 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1364 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1365 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1367 #define TP_ID1(_token, _system) _token##_system
1368 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1370 static const struct lttng_event_desc
*TP_ID(__event_desc___
, TRACE_SYSTEM
)[] = {
1371 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1378 * Stage 9 of the trace events.
1380 * Create a toplevel descriptor for the whole probe.
1383 #define TP_ID1(_token, _system) _token##_system
1384 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1386 /* non-const because list head will be modified when registered. */
1387 static __used
struct lttng_probe_desc
TP_ID(__probe_desc___
, TRACE_SYSTEM
) = {
1388 .provider
= __stringify(TRACE_SYSTEM
),
1389 .event_desc
= TP_ID(__event_desc___
, TRACE_SYSTEM
),
1390 .nr_events
= ARRAY_SIZE(TP_ID(__event_desc___
, TRACE_SYSTEM
)),
1391 .head
= { NULL
, NULL
},
1392 .lazy_init_head
= { NULL
, NULL
},
1400 * Stage 10 of the trace events.
1402 * Register/unregister probes at module load/unload.
1405 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1407 #define TP_ID1(_token, _system) _token##_system
1408 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1409 #define module_init_eval1(_token, _system) module_init(_token##_system)
1410 #define module_init_eval(_token, _system) module_init_eval1(_token, _system)
1411 #define module_exit_eval1(_token, _system) module_exit(_token##_system)
1412 #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system)
1414 #ifndef TP_MODULE_NOINIT
1415 static int TP_ID(__lttng_events_init__
, TRACE_SYSTEM
)(void)
1417 wrapper_vmalloc_sync_all();
1418 return lttng_probe_register(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1421 static void TP_ID(__lttng_events_exit__
, TRACE_SYSTEM
)(void)
1423 lttng_probe_unregister(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1426 #ifndef TP_MODULE_NOAUTOLOAD
1427 module_init_eval(__lttng_events_init__
, TRACE_SYSTEM
);
1428 module_exit_eval(__lttng_events_exit__
, TRACE_SYSTEM
);
1433 #undef module_init_eval
1434 #undef module_exit_eval
This page took 0.061414 seconds and 4 git commands to generate.