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, _base, none),\
261 .nowrite = _nowrite, \
265 #undef _ctf_array_encoded
266 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
271 .atype = atype_array, \
276 .elem_type = __type_integer(_type, 0, 0, 0, _byte_order, _base, _encoding), \
281 .nowrite = _nowrite, \
285 #undef _ctf_array_bitfield
286 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
291 .atype = atype_array_bitfield, \
296 .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \
297 .length = (_length) * sizeof(_type) * CHAR_BIT, \
298 .elem_alignment = lttng_alignof(_type), \
302 .nowrite = _nowrite, \
307 #undef _ctf_sequence_encoded
308 #define _ctf_sequence_encoded(_type, _item, _src, \
309 _length_type, _src_length, _encoding, \
310 _byte_order, _base, _user, _nowrite) \
315 .atype = atype_sequence, \
320 .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \
321 .elem_type = __type_integer(_type, 0, 0, -1, _byte_order, _base, _encoding), \
325 .nowrite = _nowrite, \
329 #undef _ctf_sequence_bitfield
330 #define _ctf_sequence_bitfield(_type, _item, _src, \
331 _length_type, _src_length, \
337 .atype = atype_sequence_bitfield, \
342 .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \
343 .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \
344 .elem_alignment = lttng_alignof(_type), \
348 .nowrite = _nowrite, \
353 #define _ctf_string(_item, _src, _user, _nowrite) \
358 .atype = atype_string, \
361 .basic = { .string = { .encoding = lttng_encode_UTF8 } } \
364 .nowrite = _nowrite, \
369 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
373 .atype = atype_enum, \
377 .desc = &__enum_##_name, \
378 .container_type = { \
379 .size = sizeof(_type) * CHAR_BIT, \
380 .alignment = lttng_alignof(_type) * CHAR_BIT, \
381 .signedness = lttng_is_signed_type(_type), \
382 .reverse_byte_order = 0, \
384 .encoding = lttng_encode_none, \
390 .nowrite = _nowrite, \
394 #undef ctf_custom_field
395 #define ctf_custom_field(_type, _item, _code) \
403 #undef ctf_custom_type
404 #define ctf_custom_type(...) __VA_ARGS__
407 #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
409 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
410 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
411 static const struct lttng_event_field __event_fields___##_name[] = { \
415 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
416 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
417 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post)
419 #undef LTTNG_TRACEPOINT_ENUM
420 #define LTTNG_TRACEPOINT_ENUM(_name, _values) \
421 static const struct lttng_enum_desc __enum_##_name = { \
423 .entries = __enum_values__##_name, \
424 .nr_entries = ARRAY_SIZE(__enum_values__##_name), \
427 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
430 * Stage 3 of the trace events.
432 * Create probe callback prototypes.
435 /* Reset all macros within TRACEPOINT_EVENT */
436 #include <probes/lttng-events-reset.h>
439 #define TP_PROTO(...) __VA_ARGS__
441 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
442 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
443 static void __event_probe__##_name(void *__data, _proto);
445 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
446 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
447 static void __event_probe__##_name(void *__data);
449 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
452 * Stage 4 of the trace events.
454 * Create static inline function that calculates event size.
457 /* Reset all macros within TRACEPOINT_EVENT */
458 #include <probes/lttng-events-reset.h>
459 #include <probes/lttng-events-write.h>
461 #undef _ctf_integer_ext
462 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
463 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
464 __event_len += sizeof(_type);
466 #undef _ctf_array_encoded
467 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
468 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
469 __event_len += sizeof(_type) * (_length);
471 #undef _ctf_array_bitfield
472 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
473 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
475 #undef _ctf_sequence_encoded
476 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
477 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
478 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
479 __event_len += sizeof(_length_type); \
480 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
482 size_t __seqlen = (_src_length); \
484 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
486 barrier(); /* reserve before use. */ \
487 this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = __seqlen; \
488 __event_len += sizeof(_type) * __seqlen; \
491 #undef _ctf_sequence_bitfield
492 #define _ctf_sequence_bitfield(_type, _item, _src, \
493 _length_type, _src_length, \
495 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
496 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
499 * ctf_user_string includes \0. If returns 0, it faulted, so we set size to
503 #define _ctf_string(_item, _src, _user, _nowrite) \
504 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
506 barrier(); /* reserve before use. */ \
508 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
509 max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \
511 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
512 strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1; \
516 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
517 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
520 #define ctf_align(_type) \
521 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type));
523 #undef ctf_custom_field
524 #define ctf_custom_field(_type, _item, _code) \
529 #undef ctf_custom_code
530 #define ctf_custom_code(...) __VA_ARGS__
533 #define TP_PROTO(...) __VA_ARGS__
536 #define TP_FIELDS(...) __VA_ARGS__
539 #define TP_locvar(...) __VA_ARGS__
541 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
542 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
543 static inline ssize_t __event_get_size__##_name(void *__tp_locvar, _proto) \
545 size_t __event_len = 0; \
546 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
547 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
550 return __event_len; \
553 __attribute__((unused)); \
557 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
558 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
559 static inline ssize_t __event_get_size__##_name(void *__tp_locvar) \
561 size_t __event_len = 0; \
562 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
563 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
566 return __event_len; \
569 __attribute__((unused)); \
573 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
577 * Stage 4.1 of tracepoint event generation.
579 * Create static inline function that layout the filter stack data.
580 * We make both write and nowrite data available to the filter.
583 /* Reset all macros within TRACEPOINT_EVENT */
584 #include <probes/lttng-events-reset.h>
585 #include <probes/lttng-events-write.h>
586 #include <probes/lttng-events-nowrite.h>
588 #undef _ctf_integer_ext_fetched
589 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
590 if (lttng_is_signed_type(_type)) { \
591 int64_t __ctf_tmp_int64; \
592 switch (sizeof(_type)) { \
595 union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
596 __ctf_tmp_int64 = (int64_t) __tmp.v; \
601 union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
602 if (_byte_order != __BYTE_ORDER) \
603 __swab16s(&__tmp.v); \
604 __ctf_tmp_int64 = (int64_t) __tmp.v; \
609 union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
610 if (_byte_order != __BYTE_ORDER) \
611 __swab32s(&__tmp.v); \
612 __ctf_tmp_int64 = (int64_t) __tmp.v; \
617 union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
618 if (_byte_order != __BYTE_ORDER) \
619 __swab64s(&__tmp.v); \
620 __ctf_tmp_int64 = (int64_t) __tmp.v; \
626 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
628 uint64_t __ctf_tmp_uint64; \
629 switch (sizeof(_type)) { \
632 union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
633 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
638 union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
639 if (_byte_order != __BYTE_ORDER) \
640 __swab16s(&__tmp.v); \
641 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
646 union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
647 if (_byte_order != __BYTE_ORDER) \
648 __swab32s(&__tmp.v); \
649 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
654 union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
655 if (_byte_order != __BYTE_ORDER) \
656 __swab64s(&__tmp.v); \
657 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
663 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
665 __stack_data += sizeof(int64_t);
667 #undef _ctf_integer_ext_isuser0
668 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
669 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
671 #undef _ctf_integer_ext_isuser1
672 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
675 char __array[sizeof(_user_src)]; \
676 __typeof__(_user_src) __v; \
678 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
679 &(_user_src), sizeof(_user_src))) \
680 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
681 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
684 #undef _ctf_integer_ext
685 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
686 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
688 #undef _ctf_array_encoded
689 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
691 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
692 const void *__ctf_tmp_ptr = (_src); \
693 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
694 __stack_data += sizeof(unsigned long); \
695 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
696 __stack_data += sizeof(void *); \
699 #undef _ctf_array_bitfield
700 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
701 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
703 #undef _ctf_sequence_encoded
704 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
705 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
707 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
708 const void *__ctf_tmp_ptr = (_src); \
709 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
710 __stack_data += sizeof(unsigned long); \
711 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
712 __stack_data += sizeof(void *); \
715 #undef _ctf_sequence_bitfield
716 #define _ctf_sequence_bitfield(_type, _item, _src, \
717 _length_type, _src_length, \
719 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
720 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
723 #define _ctf_string(_item, _src, _user, _nowrite) \
725 const void *__ctf_tmp_ptr = \
726 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
727 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
728 __stack_data += sizeof(void *); \
732 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
733 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
736 #define TP_PROTO(...) __VA_ARGS__
739 #define TP_FIELDS(...) __VA_ARGS__
742 #define TP_locvar(...) __VA_ARGS__
744 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
745 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
747 void __event_prepare_filter_stack__##_name(char *__stack_data, \
750 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
755 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
756 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
758 void __event_prepare_filter_stack__##_name(char *__stack_data, \
759 void *__tp_locvar, _proto) \
761 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
766 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
769 * Stage 5 of the trace events.
771 * Create static inline function that calculates event payload alignment.
774 /* Reset all macros within TRACEPOINT_EVENT */
775 #include <probes/lttng-events-reset.h>
776 #include <probes/lttng-events-write.h>
778 #undef _ctf_integer_ext
779 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
780 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
782 #undef _ctf_array_encoded
783 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
784 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
786 #undef _ctf_array_bitfield
787 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
788 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
790 #undef _ctf_sequence_encoded
791 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
792 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
793 __event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \
794 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
796 #undef _ctf_sequence_bitfield
797 #define _ctf_sequence_bitfield(_type, _item, _src, \
798 _length_type, _src_length, \
800 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
801 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
804 #define _ctf_string(_item, _src, _user, _nowrite)
807 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
808 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
811 #define ctf_align(_type) \
812 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
815 #define TP_PROTO(...) __VA_ARGS__
818 #define TP_FIELDS(...) __VA_ARGS__
821 #define TP_locvar(...) __VA_ARGS__
823 #undef ctf_custom_field
824 #define ctf_custom_field(_type, _item, _code) _code
826 #undef ctf_custom_code
827 #define ctf_custom_code(...) \
832 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
833 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
834 static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \
836 size_t __event_align = 1; \
837 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
840 return __event_align; \
843 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
844 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
845 static inline size_t __event_get_align__##_name(void *__tp_locvar) \
847 size_t __event_align = 1; \
848 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
851 return __event_align; \
854 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
857 * Stage 6 of tracepoint event generation.
859 * Create the probe function. This function calls event size calculation
860 * and writes event data into the buffer.
863 /* Reset all macros within TRACEPOINT_EVENT */
864 #include <probes/lttng-events-reset.h>
865 #include <probes/lttng-events-write.h>
867 #undef _ctf_integer_ext_fetched
868 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
870 _type __tmp = _src; \
871 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
872 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
875 #undef _ctf_integer_ext_isuser0
876 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
877 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
879 #undef _ctf_integer_ext_isuser1
880 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
883 char __array[sizeof(_user_src)]; \
884 __typeof__(_user_src) __v; \
886 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
887 &(_user_src), sizeof(_user_src))) \
888 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
889 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
892 #undef _ctf_integer_ext
893 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
894 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
896 #undef _ctf_array_encoded
897 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
898 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
900 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
902 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
905 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
906 #undef _ctf_array_bitfield
907 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
908 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
910 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
912 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
914 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
916 * For big endian, we need to byteswap into little endian.
918 #undef _ctf_array_bitfield
919 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
920 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
924 for (_i = 0; _i < (_length); _i++) { \
928 if (get_user(_tmp, (_type *) _src + _i)) \
931 _tmp = ((_type *) _src)[_i]; \
933 switch (sizeof(_type)) { \
937 _tmp = cpu_to_le16(_tmp); \
940 _tmp = cpu_to_le32(_tmp); \
943 _tmp = cpu_to_le64(_tmp); \
948 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
951 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
953 #undef _ctf_sequence_encoded
954 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
955 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
957 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx]; \
958 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
959 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
961 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
963 __chan->ops->event_write_from_user(&__ctx, _src, \
964 sizeof(_type) * __get_dynamic_len(dest)); \
966 __chan->ops->event_write(&__ctx, _src, \
967 sizeof(_type) * __get_dynamic_len(dest)); \
970 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
971 #undef _ctf_sequence_bitfield
972 #define _ctf_sequence_bitfield(_type, _item, _src, \
973 _length_type, _src_length, \
976 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
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)); \
988 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
990 * For big endian, we need to byteswap into little endian.
992 #undef _ctf_sequence_bitfield
993 #define _ctf_sequence_bitfield(_type, _item, _src, \
994 _length_type, _src_length, \
997 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
998 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
999 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
1001 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
1003 size_t _i, _length; \
1005 _length = __get_dynamic_len(dest); \
1006 for (_i = 0; _i < _length; _i++) { \
1010 if (get_user(_tmp, (_type *) _src + _i)) \
1013 _tmp = ((_type *) _src)[_i]; \
1015 switch (sizeof(_type)) { \
1019 _tmp = cpu_to_le16(_tmp); \
1022 _tmp = cpu_to_le32(_tmp); \
1025 _tmp = cpu_to_le64(_tmp); \
1030 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
1033 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
1036 #define _ctf_string(_item, _src, _user, _nowrite) \
1038 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
1039 __chan->ops->event_strcpy_from_user(&__ctx, _src, \
1040 __get_dynamic_len(dest)); \
1042 const char *__ctf_tmp_string = \
1043 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
1044 lib_ring_buffer_align_ctx(&__ctx, \
1045 lttng_alignof(*__ctf_tmp_string)); \
1046 __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
1047 __get_dynamic_len(dest)); \
1051 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
1052 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
1055 #define ctf_align(_type) \
1056 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));
1058 #undef ctf_custom_field
1059 #define ctf_custom_field(_type, _item, _code) _code
1061 #undef ctf_custom_code
1062 #define ctf_custom_code(...) \
1067 /* Beware: this get len actually consumes the len value */
1068 #undef __get_dynamic_len
1069 #define __get_dynamic_len(field) this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx++]
1072 #define TP_PROTO(...) __VA_ARGS__
1075 #define TP_ARGS(...) __VA_ARGS__
1078 #define TP_FIELDS(...) __VA_ARGS__
1081 #define TP_locvar(...) __VA_ARGS__
1084 #define TP_code_pre(...) __VA_ARGS__
1087 #define TP_code_post(...) __VA_ARGS__
1090 * For state dump, check that "session" argument (mandatory) matches the
1091 * session this event belongs to. Ensures that we write state dump data only
1092 * into the started session, not into all sessions.
1094 #ifdef TP_SESSION_CHECK
1095 #define _TP_SESSION_CHECK(session, csession) (session == csession)
1096 #else /* TP_SESSION_CHECK */
1097 #define _TP_SESSION_CHECK(session, csession) 1
1098 #endif /* TP_SESSION_CHECK */
1101 * Using twice size for filter stack data to hold size and pointer for
1102 * each field (worse case). For integers, max size required is 64-bit.
1103 * Same for double-precision floats. Those fit within
1104 * 2*sizeof(unsigned long) for all supported architectures.
1105 * Perform UNION (||) of filter runtime list.
1107 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
1108 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
1109 static void __event_probe__##_name(void *__data, _proto) \
1111 struct probe_local_vars { _locvar }; \
1112 struct lttng_event *__event = __data; \
1113 struct lttng_probe_ctx __lttng_probe_ctx = { \
1115 .interruptible = !irqs_disabled(), \
1117 struct lttng_channel *__chan = __event->chan; \
1118 struct lttng_session *__session = __chan->session; \
1119 struct lib_ring_buffer_ctx __ctx; \
1120 ssize_t __event_len; \
1121 size_t __event_align; \
1122 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1124 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1125 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1128 struct probe_local_vars __tp_locvar; \
1129 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1131 struct lttng_id_tracker_rcu *__lf; \
1133 if (!_TP_SESSION_CHECK(session, __session)) \
1135 if (unlikely(!LTTNG_READ_ONCE(__session->active))) \
1137 if (unlikely(!LTTNG_READ_ONCE(__chan->enabled))) \
1139 if (unlikely(!LTTNG_READ_ONCE(__event->enabled))) \
1141 __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
1142 if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
1144 __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
1145 if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
1147 __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
1148 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1149 lttng_current_uid()))) \
1151 __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
1152 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1153 lttng_current_vuid()))) \
1155 __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
1156 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1157 lttng_current_gid()))) \
1159 __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
1160 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1161 lttng_current_vgid()))) \
1163 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1164 __dynamic_len_idx = __orig_dynamic_len_offset; \
1166 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1167 struct lttng_bytecode_runtime *bc_runtime; \
1168 int __filter_record = __event->has_enablers_without_bytecode; \
1170 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1171 tp_locvar, _args); \
1172 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1173 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1174 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
1175 __filter_record = 1; \
1177 if (likely(!__filter_record)) \
1180 __event_len = __event_get_size__##_name(tp_locvar, _args); \
1181 if (unlikely(__event_len < 0)) { \
1182 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1185 __event_align = __event_get_align__##_name(tp_locvar, _args); \
1186 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1187 __event_align, -1); \
1188 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1192 __chan->ops->event_commit(&__ctx); \
1195 barrier(); /* use before un-reserve. */ \
1196 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1200 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
1201 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
1202 static void __event_probe__##_name(void *__data) \
1204 struct probe_local_vars { _locvar }; \
1205 struct lttng_event *__event = __data; \
1206 struct lttng_probe_ctx __lttng_probe_ctx = { \
1208 .interruptible = !irqs_disabled(), \
1210 struct lttng_channel *__chan = __event->chan; \
1211 struct lttng_session *__session = __chan->session; \
1212 struct lib_ring_buffer_ctx __ctx; \
1213 ssize_t __event_len; \
1214 size_t __event_align; \
1215 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1217 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1218 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1221 struct probe_local_vars __tp_locvar; \
1222 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1224 struct lttng_id_tracker_rcu *__lf; \
1226 if (!_TP_SESSION_CHECK(session, __session)) \
1228 if (unlikely(!LTTNG_READ_ONCE(__session->active))) \
1230 if (unlikely(!LTTNG_READ_ONCE(__chan->enabled))) \
1232 if (unlikely(!LTTNG_READ_ONCE(__event->enabled))) \
1234 __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
1235 if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
1237 __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
1238 if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
1240 __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
1241 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1242 lttng_current_uid()))) \
1244 __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
1245 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1246 lttng_current_vuid()))) \
1248 __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
1249 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1250 lttng_current_gid()))) \
1252 __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
1253 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1254 lttng_current_vgid()))) \
1256 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1257 __dynamic_len_idx = __orig_dynamic_len_offset; \
1259 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1260 struct lttng_bytecode_runtime *bc_runtime; \
1261 int __filter_record = __event->has_enablers_without_bytecode; \
1263 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1265 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1266 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1267 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
1268 __filter_record = 1; \
1270 if (likely(!__filter_record)) \
1273 __event_len = __event_get_size__##_name(tp_locvar); \
1274 if (unlikely(__event_len < 0)) { \
1275 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1278 __event_align = __event_get_align__##_name(tp_locvar); \
1279 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1280 __event_align, -1); \
1281 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1285 __chan->ops->event_commit(&__ctx); \
1288 barrier(); /* use before un-reserve. */ \
1289 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1293 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1295 #undef __get_dynamic_len
1298 * Stage 7 of the trace events.
1300 * Create event descriptions.
1303 /* Named field types must be defined in lttng-types.h */
1305 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1308 #define TP_PROBE_CB(_template) &__event_probe__##_template
1311 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1312 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1313 static const struct lttng_event_desc __event_desc___##_map = { \
1314 .fields = __event_fields___##_template, \
1317 .probe_callback = (void *) TP_PROBE_CB(_template), \
1318 .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
1319 .owner = THIS_MODULE, \
1322 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1323 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1324 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1326 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1329 * Stage 8 of the trace events.
1331 * Create an array of event description pointers.
1334 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1336 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1337 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1338 &__event_desc___##_map,
1340 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1341 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1342 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1344 #define TP_ID1(_token, _system) _token##_system
1345 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1347 static const struct lttng_event_desc
*TP_ID(__event_desc___
, TRACE_SYSTEM
)[] = {
1348 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1355 * Stage 9 of the trace events.
1357 * Create a toplevel descriptor for the whole probe.
1360 #define TP_ID1(_token, _system) _token##_system
1361 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1363 /* non-const because list head will be modified when registered. */
1364 static __used
struct lttng_probe_desc
TP_ID(__probe_desc___
, TRACE_SYSTEM
) = {
1365 .provider
= __stringify(TRACE_SYSTEM
),
1366 .event_desc
= TP_ID(__event_desc___
, TRACE_SYSTEM
),
1367 .nr_events
= ARRAY_SIZE(TP_ID(__event_desc___
, TRACE_SYSTEM
)),
1368 .head
= { NULL
, NULL
},
1369 .lazy_init_head
= { NULL
, NULL
},
1377 * Stage 10 of the trace events.
1379 * Register/unregister probes at module load/unload.
1382 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1384 #define TP_ID1(_token, _system) _token##_system
1385 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1386 #define module_init_eval1(_token, _system) module_init(_token##_system)
1387 #define module_init_eval(_token, _system) module_init_eval1(_token, _system)
1388 #define module_exit_eval1(_token, _system) module_exit(_token##_system)
1389 #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system)
1391 #ifndef TP_MODULE_NOINIT
1392 static int TP_ID(__lttng_events_init__
, TRACE_SYSTEM
)(void)
1394 wrapper_vmalloc_sync_mappings();
1395 return lttng_probe_register(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1398 static void TP_ID(__lttng_events_exit__
, TRACE_SYSTEM
)(void)
1400 lttng_probe_unregister(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1403 #ifndef TP_MODULE_NOAUTOLOAD
1404 module_init_eval(__lttng_events_init__
, TRACE_SYSTEM
);
1405 module_exit_eval(__lttng_events_exit__
, TRACE_SYSTEM
);
1410 #undef module_init_eval
1411 #undef module_exit_eval
This page took 0.05721 seconds and 5 git commands to generate.