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/ringbuffer/frontend_types.h>
19 #include <wrapper/ringbuffer/backend.h>
20 #include <wrapper/rcu.h>
21 #include <wrapper/user_namespace.h>
22 #include <lttng-events.h>
23 #include <lttng-tracer-core.h>
24 #include <lttng-tp-mempool.h>
26 #define __LTTNG_NULL_STRING "(null)"
29 * Macro declarations used for all stages.
33 * LTTng name mapping macros. LTTng remaps some of the kernel events to
34 * enforce name-spacing.
36 #undef LTTNG_TRACEPOINT_EVENT_MAP
37 #define LTTNG_TRACEPOINT_EVENT_MAP(name, map, proto, args, fields) \
38 LTTNG_TRACEPOINT_EVENT_CLASS(map, \
42 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
44 #undef LTTNG_TRACEPOINT_EVENT_MAP_NOARGS
45 #define LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, map, fields) \
46 LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(map, \
48 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(map, name, map)
50 #undef LTTNG_TRACEPOINT_EVENT_CODE_MAP
51 #define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code_pre, fields, _code_post) \
52 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(map, \
59 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
61 #undef LTTNG_TRACEPOINT_EVENT_CODE
62 #define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code_pre, fields, _code_post) \
63 LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, name, \
72 * LTTNG_TRACEPOINT_EVENT_CLASS can be used to add a generic function
73 * handlers for events. That is, if all events have the same parameters
74 * and just have distinct trace points. Each tracepoint can be defined
75 * with LTTNG_TRACEPOINT_EVENT_INSTANCE and that will map the
76 * LTTNG_TRACEPOINT_EVENT_CLASS to the tracepoint.
78 * LTTNG_TRACEPOINT_EVENT is a one to one mapping between tracepoint and
82 #undef LTTNG_TRACEPOINT_EVENT
83 #define LTTNG_TRACEPOINT_EVENT(name, proto, args, fields) \
84 LTTNG_TRACEPOINT_EVENT_MAP(name, name, \
89 #undef LTTNG_TRACEPOINT_EVENT_NOARGS
90 #define LTTNG_TRACEPOINT_EVENT_NOARGS(name, fields) \
91 LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, name, PARAMS(fields))
93 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE
94 #define LTTNG_TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \
95 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(template, name, name, PARAMS(proto), PARAMS(args))
97 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
98 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \
99 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(template, name, name)
101 #undef LTTNG_TRACEPOINT_EVENT_CLASS
102 #define LTTNG_TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \
103 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(_proto), PARAMS(_args), , , \
106 #undef LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
107 #define LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
108 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, , , PARAMS(_fields), )
112 * Stage 1 of the trace events.
114 * Create dummy trace calls for each events, verifying that the LTTng module
115 * instrumentation headers match the kernel arguments. Will be optimized
116 * out by the compiler.
119 /* Reset all macros within TRACEPOINT_EVENT */
120 #include <probes/lttng-events-reset.h>
123 #define TP_PROTO(...) __VA_ARGS__
126 #define TP_ARGS(...) __VA_ARGS__
128 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
129 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
130 void trace_##_name(_proto);
132 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
133 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
134 void trace_##_name(void);
136 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
139 * Stage 1.1 of the trace events.
141 * Create dummy trace prototypes for each event class, and for each used
142 * template. This will allow checking whether the prototypes from the
143 * class and the instance using the class actually match.
146 #include <probes/lttng-events-reset.h> /* Reset all macros within TRACE_EVENT */
149 #define TP_PROTO(...) __VA_ARGS__
152 #define TP_ARGS(...) __VA_ARGS__
154 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
155 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
156 void __event_template_proto___##_template(_proto);
158 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
159 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
160 void __event_template_proto___##_template(void);
162 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
163 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
164 void __event_template_proto___##_name(_proto);
166 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
167 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
168 void __event_template_proto___##_name(void);
170 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
173 * Stage 1.2 of tracepoint event generation
175 * Unfolding the enums
177 #include <probes/lttng-events-reset.h> /* Reset all macros within TRACE_EVENT */
179 /* Enumeration entry (single value) */
180 #undef ctf_enum_value
181 #define ctf_enum_value(_string, _value) \
184 .signedness = lttng_is_signed_type(__typeof__(_value)), \
185 .value = lttng_is_signed_type(__typeof__(_value)) ? \
186 (long long) (_value) : (_value), \
189 .signedness = lttng_is_signed_type(__typeof__(_value)), \
190 .value = lttng_is_signed_type(__typeof__(_value)) ? \
191 (long long) (_value) : (_value), \
193 .string = (_string), \
196 /* Enumeration entry (range) */
197 #undef ctf_enum_range
198 #define ctf_enum_range(_string, _range_start, _range_end) \
201 .signedness = lttng_is_signed_type(__typeof__(_range_start)), \
202 .value = lttng_is_signed_type(__typeof__(_range_start)) ? \
203 (long long) (_range_start) : (_range_start), \
206 .signedness = lttng_is_signed_type(__typeof__(_range_end)), \
207 .value = lttng_is_signed_type(__typeof__(_range_end)) ? \
208 (long long) (_range_end) : (_range_end), \
210 .string = (_string), \
213 /* Enumeration entry (automatic value; follows the rules of CTF) */
215 #define ctf_enum_auto(_string) \
225 .string = (_string), \
231 #undef TP_ENUM_VALUES
232 #define TP_ENUM_VALUES(...) \
235 #undef LTTNG_TRACEPOINT_ENUM
236 #define LTTNG_TRACEPOINT_ENUM(_name, _values) \
237 const struct lttng_enum_entry __enum_values__##_name[] = { \
241 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
244 * Stage 2 of the trace events.
246 * Create event field type metadata section.
247 * Each event produce an array of fields.
250 /* Reset all macros within TRACEPOINT_EVENT */
251 #include <probes/lttng-events-reset.h>
252 #include <probes/lttng-events-write.h>
253 #include <probes/lttng-events-nowrite.h>
255 #undef _ctf_integer_ext
256 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
259 .type = __type_integer(_type, 0, 0, -1, _byte_order, _base, none), \
260 .nowrite = _nowrite, \
265 #undef _ctf_array_encoded
266 #define _ctf_array_encoded(_type, _item, _src, _length, \
267 _encoding, _byte_order, _elem_type_base, _user, _nowrite) \
272 .atype = atype_array_nestable, \
277 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
278 __type_integer(_type, 0, 0, -1, _byte_order, _elem_type_base, _encoding)), \
284 .nowrite = _nowrite, \
289 #undef _ctf_array_bitfield
290 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
295 .atype = atype_array_nestable, \
300 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
301 __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none)), \
302 .length = (_length) * sizeof(_type) * CHAR_BIT, \
303 .alignment = lttng_alignof(_type), \
307 .nowrite = _nowrite, \
313 #undef _ctf_sequence_encoded
314 #define _ctf_sequence_encoded(_type, _item, _src, \
315 _length_type, _src_length, _encoding, \
316 _byte_order, _elem_type_base, _user, _nowrite) \
318 .name = "_" #_item "_length", \
319 .type = __type_integer(_length_type, 0, 0, -1, __BYTE_ORDER, 10, none), \
320 .nowrite = _nowrite, \
327 .atype = atype_sequence_nestable, \
330 .sequence_nestable = \
332 .length_name = "_" #_item "_length", \
333 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
334 __type_integer(_type, 0, 0, -1, _byte_order, _elem_type_base, _encoding)), \
339 .nowrite = _nowrite, \
344 #undef _ctf_sequence_bitfield
345 #define _ctf_sequence_bitfield(_type, _item, _src, \
346 _length_type, _src_length, \
349 .name = "_" #_item "_length", \
350 .type = __type_integer(_length_type, 0, 0, -1, __BYTE_ORDER, 10, none), \
351 .nowrite = _nowrite, \
358 .atype = atype_sequence_nestable, \
361 .sequence_nestable = \
363 .length_name = "_" #_item "_length", \
364 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
365 __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none)), \
366 .alignment = lttng_alignof(_type), \
370 .nowrite = _nowrite, \
376 #define _ctf_string(_item, _src, _user, _nowrite) \
381 .atype = atype_string, \
384 .string = { .encoding = lttng_encode_UTF8 }, \
387 .nowrite = _nowrite, \
393 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
397 .atype = atype_enum_nestable, \
400 .desc = &__enum_##_name, \
401 .container_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
402 __type_integer(_type, 0, 0, -1, __BYTE_ORDER, 10, none)), \
406 .nowrite = _nowrite, \
411 #undef ctf_custom_field
412 #define ctf_custom_field(_type, _item, _code) \
421 #undef ctf_custom_type
422 #define ctf_custom_type(...) __VA_ARGS__
425 #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
427 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
428 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
429 static const struct lttng_event_field __event_fields___##_name[] = { \
433 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
434 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
435 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post)
437 #undef LTTNG_TRACEPOINT_ENUM
438 #define LTTNG_TRACEPOINT_ENUM(_name, _values) \
439 static const struct lttng_enum_desc __enum_##_name = { \
441 .entries = __enum_values__##_name, \
442 .nr_entries = ARRAY_SIZE(__enum_values__##_name), \
445 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
448 * Stage 3 of the trace events.
450 * Create probe callback prototypes.
453 /* Reset all macros within TRACEPOINT_EVENT */
454 #include <probes/lttng-events-reset.h>
457 #define TP_PROTO(...) __VA_ARGS__
459 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
460 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
461 static void __event_probe__##_name(void *__data, _proto);
463 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
464 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
465 static void __event_probe__##_name(void *__data);
467 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
470 * Stage 4 of the trace events.
472 * Create static inline function that calculates event size.
475 /* Reset all macros within TRACEPOINT_EVENT */
476 #include <probes/lttng-events-reset.h>
477 #include <probes/lttng-events-write.h>
479 #undef _ctf_integer_ext
480 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
481 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
482 __event_len += sizeof(_type);
484 #undef _ctf_array_encoded
485 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
486 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
487 __event_len += sizeof(_type) * (_length);
489 #undef _ctf_array_bitfield
490 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
491 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
493 #undef _ctf_sequence_encoded
494 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
495 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
496 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
497 __event_len += sizeof(_length_type); \
498 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
500 size_t __seqlen = (_src_length); \
502 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
504 barrier(); /* reserve before use. */ \
505 this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = __seqlen; \
506 __event_len += sizeof(_type) * __seqlen; \
509 #undef _ctf_sequence_bitfield
510 #define _ctf_sequence_bitfield(_type, _item, _src, \
511 _length_type, _src_length, \
513 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
514 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
517 * ctf_user_string includes \0. If returns 0, it faulted, so we set size to
521 #define _ctf_string(_item, _src, _user, _nowrite) \
522 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
524 barrier(); /* reserve before use. */ \
526 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
527 max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \
529 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
530 strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1; \
534 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
535 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
538 #define ctf_align(_type) \
539 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type));
541 #undef ctf_custom_field
542 #define ctf_custom_field(_type, _item, _code) \
547 #undef ctf_custom_code
548 #define ctf_custom_code(...) __VA_ARGS__
551 #define TP_PROTO(...) __VA_ARGS__
554 #define TP_FIELDS(...) __VA_ARGS__
557 #define TP_locvar(...) __VA_ARGS__
559 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
560 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
561 static inline ssize_t __event_get_size__##_name(void *__tp_locvar, _proto) \
563 size_t __event_len = 0; \
564 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
565 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
568 return __event_len; \
571 __attribute__((unused)); \
575 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
576 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
577 static inline ssize_t __event_get_size__##_name(void *__tp_locvar) \
579 size_t __event_len = 0; \
580 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
581 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
584 return __event_len; \
587 __attribute__((unused)); \
591 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
595 * Stage 4.1 of tracepoint event generation.
597 * Create static inline function that layout the filter stack data.
598 * We make both write and nowrite data available to the filter.
601 /* Reset all macros within TRACEPOINT_EVENT */
602 #include <probes/lttng-events-reset.h>
603 #include <probes/lttng-events-write.h>
604 #include <probes/lttng-events-nowrite.h>
606 #undef _ctf_integer_ext_fetched
607 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
608 if (lttng_is_signed_type(_type)) { \
609 int64_t __ctf_tmp_int64; \
610 switch (sizeof(_type)) { \
613 union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
614 __ctf_tmp_int64 = (int64_t) __tmp.v; \
619 union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
620 if (_byte_order != __BYTE_ORDER) \
621 __swab16s(&__tmp.v); \
622 __ctf_tmp_int64 = (int64_t) __tmp.v; \
627 union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
628 if (_byte_order != __BYTE_ORDER) \
629 __swab32s(&__tmp.v); \
630 __ctf_tmp_int64 = (int64_t) __tmp.v; \
635 union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
636 if (_byte_order != __BYTE_ORDER) \
637 __swab64s(&__tmp.v); \
638 __ctf_tmp_int64 = (int64_t) __tmp.v; \
644 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
646 uint64_t __ctf_tmp_uint64; \
647 switch (sizeof(_type)) { \
650 union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
651 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
656 union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
657 if (_byte_order != __BYTE_ORDER) \
658 __swab16s(&__tmp.v); \
659 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
664 union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
665 if (_byte_order != __BYTE_ORDER) \
666 __swab32s(&__tmp.v); \
667 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
672 union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
673 if (_byte_order != __BYTE_ORDER) \
674 __swab64s(&__tmp.v); \
675 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
681 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
683 __stack_data += sizeof(int64_t);
685 #undef _ctf_integer_ext_isuser0
686 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
687 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
689 #undef _ctf_integer_ext_isuser1
690 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
693 char __array[sizeof(_user_src)]; \
694 __typeof__(_user_src) __v; \
696 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
697 &(_user_src), sizeof(_user_src))) \
698 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
699 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
702 #undef _ctf_integer_ext
703 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
704 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
706 #undef _ctf_array_encoded
707 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
709 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
710 const void *__ctf_tmp_ptr = (_src); \
711 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
712 __stack_data += sizeof(unsigned long); \
713 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
714 __stack_data += sizeof(void *); \
717 #undef _ctf_array_bitfield
718 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
719 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
721 #undef _ctf_sequence_encoded
722 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
723 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
725 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
726 const void *__ctf_tmp_ptr = (_src); \
727 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
728 __stack_data += sizeof(unsigned long); \
729 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
730 __stack_data += sizeof(void *); \
733 #undef _ctf_sequence_bitfield
734 #define _ctf_sequence_bitfield(_type, _item, _src, \
735 _length_type, _src_length, \
737 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
738 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
741 #define _ctf_string(_item, _src, _user, _nowrite) \
743 const void *__ctf_tmp_ptr = \
744 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
745 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
746 __stack_data += sizeof(void *); \
750 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
751 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
754 #define TP_PROTO(...) __VA_ARGS__
757 #define TP_FIELDS(...) __VA_ARGS__
760 #define TP_locvar(...) __VA_ARGS__
762 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
763 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
765 void __event_prepare_filter_stack__##_name(char *__stack_data, \
768 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
773 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
774 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
776 void __event_prepare_filter_stack__##_name(char *__stack_data, \
777 void *__tp_locvar, _proto) \
779 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
784 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
787 * Stage 5 of the trace events.
789 * Create static inline function that calculates event payload alignment.
792 /* Reset all macros within TRACEPOINT_EVENT */
793 #include <probes/lttng-events-reset.h>
794 #include <probes/lttng-events-write.h>
796 #undef _ctf_integer_ext
797 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
798 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
800 #undef _ctf_array_encoded
801 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
802 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
804 #undef _ctf_array_bitfield
805 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
806 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
808 #undef _ctf_sequence_encoded
809 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
810 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
811 __event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \
812 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
814 #undef _ctf_sequence_bitfield
815 #define _ctf_sequence_bitfield(_type, _item, _src, \
816 _length_type, _src_length, \
818 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
819 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
822 #define _ctf_string(_item, _src, _user, _nowrite)
825 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
826 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
829 #define ctf_align(_type) \
830 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
833 #define TP_PROTO(...) __VA_ARGS__
836 #define TP_FIELDS(...) __VA_ARGS__
839 #define TP_locvar(...) __VA_ARGS__
841 #undef ctf_custom_field
842 #define ctf_custom_field(_type, _item, _code) _code
844 #undef ctf_custom_code
845 #define ctf_custom_code(...) \
850 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
851 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
852 static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \
854 size_t __event_align = 1; \
855 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
858 return __event_align; \
861 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
862 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
863 static inline size_t __event_get_align__##_name(void *__tp_locvar) \
865 size_t __event_align = 1; \
866 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
869 return __event_align; \
872 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
875 * Stage 6 of tracepoint event generation.
877 * Create the probe function. This function calls event size calculation
878 * and writes event data into the buffer.
881 /* Reset all macros within TRACEPOINT_EVENT */
882 #include <probes/lttng-events-reset.h>
883 #include <probes/lttng-events-write.h>
885 #undef _ctf_integer_ext_fetched
886 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
888 _type __tmp = _src; \
889 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
890 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
893 #undef _ctf_integer_ext_isuser0
894 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
895 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
897 #undef _ctf_integer_ext_isuser1
898 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
901 char __array[sizeof(_user_src)]; \
902 __typeof__(_user_src) __v; \
904 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
905 &(_user_src), sizeof(_user_src))) \
906 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
907 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
910 #undef _ctf_integer_ext
911 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
912 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
914 #undef _ctf_array_encoded
915 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
916 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
918 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
920 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
923 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
924 #undef _ctf_array_bitfield
925 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
926 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
928 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
930 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
932 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
934 * For big endian, we need to byteswap into little endian.
936 #undef _ctf_array_bitfield
937 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
938 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
942 for (_i = 0; _i < (_length); _i++) { \
946 if (get_user(_tmp, (_type *) _src + _i)) \
949 _tmp = ((_type *) _src)[_i]; \
951 switch (sizeof(_type)) { \
955 _tmp = cpu_to_le16(_tmp); \
958 _tmp = cpu_to_le32(_tmp); \
961 _tmp = cpu_to_le64(_tmp); \
966 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
969 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
971 #undef _ctf_sequence_encoded
972 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
973 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
975 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx]; \
976 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
977 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
979 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
981 __chan->ops->event_write_from_user(&__ctx, _src, \
982 sizeof(_type) * __get_dynamic_len(dest)); \
984 __chan->ops->event_write(&__ctx, _src, \
985 sizeof(_type) * __get_dynamic_len(dest)); \
988 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
989 #undef _ctf_sequence_bitfield
990 #define _ctf_sequence_bitfield(_type, _item, _src, \
991 _length_type, _src_length, \
994 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
995 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
996 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
998 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
1000 __chan->ops->event_write_from_user(&__ctx, _src, \
1001 sizeof(_type) * __get_dynamic_len(dest)); \
1003 __chan->ops->event_write(&__ctx, _src, \
1004 sizeof(_type) * __get_dynamic_len(dest)); \
1006 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
1008 * For big endian, we need to byteswap into little endian.
1010 #undef _ctf_sequence_bitfield
1011 #define _ctf_sequence_bitfield(_type, _item, _src, \
1012 _length_type, _src_length, \
1015 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
1016 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
1017 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
1019 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
1021 size_t _i, _length; \
1023 _length = __get_dynamic_len(dest); \
1024 for (_i = 0; _i < _length; _i++) { \
1028 if (get_user(_tmp, (_type *) _src + _i)) \
1031 _tmp = ((_type *) _src)[_i]; \
1033 switch (sizeof(_type)) { \
1037 _tmp = cpu_to_le16(_tmp); \
1040 _tmp = cpu_to_le32(_tmp); \
1043 _tmp = cpu_to_le64(_tmp); \
1048 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
1051 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
1054 #define _ctf_string(_item, _src, _user, _nowrite) \
1056 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
1057 __chan->ops->event_strcpy_from_user(&__ctx, _src, \
1058 __get_dynamic_len(dest)); \
1060 const char *__ctf_tmp_string = \
1061 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
1062 lib_ring_buffer_align_ctx(&__ctx, \
1063 lttng_alignof(*__ctf_tmp_string)); \
1064 __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
1065 __get_dynamic_len(dest)); \
1069 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
1070 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
1073 #define ctf_align(_type) \
1074 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));
1076 #undef ctf_custom_field
1077 #define ctf_custom_field(_type, _item, _code) _code
1079 #undef ctf_custom_code
1080 #define ctf_custom_code(...) \
1085 /* Beware: this get len actually consumes the len value */
1086 #undef __get_dynamic_len
1087 #define __get_dynamic_len(field) this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx++]
1090 #define TP_PROTO(...) __VA_ARGS__
1093 #define TP_ARGS(...) __VA_ARGS__
1096 #define TP_FIELDS(...) __VA_ARGS__
1099 #define TP_locvar(...) __VA_ARGS__
1102 #define TP_code_pre(...) __VA_ARGS__
1105 #define TP_code_post(...) __VA_ARGS__
1108 * For state dump, check that "session" argument (mandatory) matches the
1109 * session this event belongs to. Ensures that we write state dump data only
1110 * into the started session, not into all sessions.
1112 #ifdef TP_SESSION_CHECK
1113 #define _TP_SESSION_CHECK(session, csession) (session == csession)
1114 #else /* TP_SESSION_CHECK */
1115 #define _TP_SESSION_CHECK(session, csession) 1
1116 #endif /* TP_SESSION_CHECK */
1119 * Using twice size for filter stack data to hold size and pointer for
1120 * each field (worse case). For integers, max size required is 64-bit.
1121 * Same for double-precision floats. Those fit within
1122 * 2*sizeof(unsigned long) for all supported architectures.
1123 * Perform UNION (||) of filter runtime list.
1125 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
1126 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
1127 static void __event_probe__##_name(void *__data, _proto) \
1129 struct probe_local_vars { _locvar }; \
1130 struct lttng_event *__event = __data; \
1131 struct lttng_probe_ctx __lttng_probe_ctx = { \
1133 .interruptible = !irqs_disabled(), \
1135 struct lttng_channel *__chan = __event->chan; \
1136 struct lttng_session *__session = __chan->session; \
1137 struct lib_ring_buffer_ctx __ctx; \
1138 ssize_t __event_len; \
1139 size_t __event_align; \
1140 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1142 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1143 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1146 struct probe_local_vars __tp_locvar; \
1147 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1149 struct lttng_id_tracker_rcu *__lf; \
1151 if (!_TP_SESSION_CHECK(session, __session)) \
1153 if (unlikely(!READ_ONCE(__session->active))) \
1155 if (unlikely(!READ_ONCE(__chan->enabled))) \
1157 if (unlikely(!READ_ONCE(__event->enabled))) \
1159 __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
1160 if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
1162 __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
1163 if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
1165 __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
1166 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1167 lttng_current_uid()))) \
1169 __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
1170 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1171 lttng_current_vuid()))) \
1173 __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
1174 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1175 lttng_current_gid()))) \
1177 __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
1178 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1179 lttng_current_vgid()))) \
1181 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1182 __dynamic_len_idx = __orig_dynamic_len_offset; \
1184 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1185 struct lttng_bytecode_runtime *bc_runtime; \
1186 int __filter_record = __event->has_enablers_without_bytecode; \
1188 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1189 tp_locvar, _args); \
1190 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1191 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1192 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) { \
1193 __filter_record = 1; \
1197 if (likely(!__filter_record)) \
1200 __event_len = __event_get_size__##_name(tp_locvar, _args); \
1201 if (unlikely(__event_len < 0)) { \
1202 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1205 __event_align = __event_get_align__##_name(tp_locvar, _args); \
1206 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1207 __event_align, -1); \
1208 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1212 __chan->ops->event_commit(&__ctx); \
1215 barrier(); /* use before un-reserve. */ \
1216 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1220 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
1221 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
1222 static void __event_probe__##_name(void *__data) \
1224 struct probe_local_vars { _locvar }; \
1225 struct lttng_event *__event = __data; \
1226 struct lttng_probe_ctx __lttng_probe_ctx = { \
1228 .interruptible = !irqs_disabled(), \
1230 struct lttng_channel *__chan = __event->chan; \
1231 struct lttng_session *__session = __chan->session; \
1232 struct lib_ring_buffer_ctx __ctx; \
1233 ssize_t __event_len; \
1234 size_t __event_align; \
1235 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1237 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1238 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1241 struct probe_local_vars __tp_locvar; \
1242 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1244 struct lttng_id_tracker_rcu *__lf; \
1246 if (!_TP_SESSION_CHECK(session, __session)) \
1248 if (unlikely(!READ_ONCE(__session->active))) \
1250 if (unlikely(!READ_ONCE(__chan->enabled))) \
1252 if (unlikely(!READ_ONCE(__event->enabled))) \
1254 __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
1255 if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
1257 __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
1258 if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
1260 __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
1261 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1262 lttng_current_uid()))) \
1264 __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
1265 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1266 lttng_current_vuid()))) \
1268 __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
1269 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1270 lttng_current_gid()))) \
1272 __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
1273 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1274 lttng_current_vgid()))) \
1276 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1277 __dynamic_len_idx = __orig_dynamic_len_offset; \
1279 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1280 struct lttng_bytecode_runtime *bc_runtime; \
1281 int __filter_record = __event->has_enablers_without_bytecode; \
1283 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1285 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1286 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1287 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) { \
1288 __filter_record = 1; \
1292 if (likely(!__filter_record)) \
1295 __event_len = __event_get_size__##_name(tp_locvar); \
1296 if (unlikely(__event_len < 0)) { \
1297 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1300 __event_align = __event_get_align__##_name(tp_locvar); \
1301 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1302 __event_align, -1); \
1303 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1307 __chan->ops->event_commit(&__ctx); \
1310 barrier(); /* use before un-reserve. */ \
1311 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1315 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1317 #undef __get_dynamic_len
1320 * Stage 7 of the trace events.
1322 * Create event descriptions.
1325 /* Named field types must be defined in lttng-types.h */
1327 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1330 #define TP_PROBE_CB(_template) &__event_probe__##_template
1333 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1334 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1335 static const struct lttng_event_desc __event_desc___##_map = { \
1336 .fields = __event_fields___##_template, \
1339 .probe_callback = (void *) TP_PROBE_CB(_template), \
1340 .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
1341 .owner = THIS_MODULE, \
1344 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1345 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1346 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1348 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1351 * Stage 8 of the trace events.
1353 * Create an array of event description pointers.
1356 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1358 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1359 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1360 &__event_desc___##_map,
1362 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1363 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1364 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1366 #define TP_ID1(_token, _system) _token##_system
1367 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1369 static const struct lttng_event_desc
*TP_ID(__event_desc___
, TRACE_SYSTEM
)[] = {
1370 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1377 * Stage 9 of the trace events.
1379 * Create a toplevel descriptor for the whole probe.
1382 #define TP_ID1(_token, _system) _token##_system
1383 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1385 /* non-const because list head will be modified when registered. */
1386 static __used
struct lttng_probe_desc
TP_ID(__probe_desc___
, TRACE_SYSTEM
) = {
1387 .provider
= __stringify(TRACE_SYSTEM
),
1388 .event_desc
= TP_ID(__event_desc___
, TRACE_SYSTEM
),
1389 .nr_events
= ARRAY_SIZE(TP_ID(__event_desc___
, TRACE_SYSTEM
)),
1390 .head
= { NULL
, NULL
},
1391 .lazy_init_head
= { NULL
, NULL
},
1399 * Stage 10 of the trace events.
1401 * Register/unregister probes at module load/unload.
1404 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1406 #define TP_ID1(_token, _system) _token##_system
1407 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1408 #define module_init_eval1(_token, _system) module_init(_token##_system)
1409 #define module_init_eval(_token, _system) module_init_eval1(_token, _system)
1410 #define module_exit_eval1(_token, _system) module_exit(_token##_system)
1411 #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system)
1413 #ifndef TP_MODULE_NOINIT
1414 static int TP_ID(__lttng_events_init__
, TRACE_SYSTEM
)(void)
1416 return lttng_probe_register(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1419 static void TP_ID(__lttng_events_exit__
, TRACE_SYSTEM
)(void)
1421 lttng_probe_unregister(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1424 #ifndef TP_MODULE_NOAUTOLOAD
1425 module_init_eval(__lttng_events_init__
, TRACE_SYSTEM
);
1426 module_exit_eval(__lttng_events_exit__
, TRACE_SYSTEM
);
1431 #undef module_init_eval
1432 #undef module_exit_eval
This page took 0.057942 seconds and 4 git commands to generate.