2 * lttng-tracepoint-event-impl.h
4 * Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org>
5 * Copyright (C) 2009-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; only
10 * version 2.1 of the License.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <linux/uaccess.h>
23 #include <linux/debugfs.h>
24 #include <linux/rculist.h>
25 #include <asm/byteorder.h>
26 #include <linux/swab.h>
28 #include <probes/lttng.h>
29 #include <probes/lttng-types.h>
30 #include <probes/lttng-probe-user.h>
31 #include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
32 #include <wrapper/ringbuffer/frontend_types.h>
33 #include <wrapper/ringbuffer/backend.h>
34 #include <wrapper/rcu.h>
35 #include <lttng-events.h>
36 #include <lttng-tracer-core.h>
37 #include <lttng-tp-mempool.h>
39 #define __LTTNG_NULL_STRING "(null)"
42 * Macro declarations used for all stages.
46 * LTTng name mapping macros. LTTng remaps some of the kernel events to
47 * enforce name-spacing.
49 #undef LTTNG_TRACEPOINT_EVENT_MAP
50 #define LTTNG_TRACEPOINT_EVENT_MAP(name, map, proto, args, fields) \
51 LTTNG_TRACEPOINT_EVENT_CLASS(map, \
55 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
57 #undef LTTNG_TRACEPOINT_EVENT_MAP_NOARGS
58 #define LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, map, fields) \
59 LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(map, \
61 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(map, name, map)
63 #undef LTTNG_TRACEPOINT_EVENT_CODE_MAP
64 #define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code_pre, fields, _code_post) \
65 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(map, \
72 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
74 #undef LTTNG_TRACEPOINT_EVENT_CODE
75 #define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code_pre, fields, _code_post) \
76 LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, name, \
85 * LTTNG_TRACEPOINT_EVENT_CLASS can be used to add a generic function
86 * handlers for events. That is, if all events have the same parameters
87 * and just have distinct trace points. Each tracepoint can be defined
88 * with LTTNG_TRACEPOINT_EVENT_INSTANCE and that will map the
89 * LTTNG_TRACEPOINT_EVENT_CLASS to the tracepoint.
91 * LTTNG_TRACEPOINT_EVENT is a one to one mapping between tracepoint and
95 #undef LTTNG_TRACEPOINT_EVENT
96 #define LTTNG_TRACEPOINT_EVENT(name, proto, args, fields) \
97 LTTNG_TRACEPOINT_EVENT_MAP(name, name, \
102 #undef LTTNG_TRACEPOINT_EVENT_NOARGS
103 #define LTTNG_TRACEPOINT_EVENT_NOARGS(name, fields) \
104 LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, name, PARAMS(fields))
106 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE
107 #define LTTNG_TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \
108 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(template, name, name, PARAMS(proto), PARAMS(args))
110 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
111 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \
112 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(template, name, name)
114 #undef LTTNG_TRACEPOINT_EVENT_CLASS
115 #define LTTNG_TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \
116 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(_proto), PARAMS(_args), , , \
119 #undef LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
120 #define LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
121 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, , , PARAMS(_fields), )
125 * Stage 1 of the trace events.
127 * Create dummy trace calls for each events, verifying that the LTTng module
128 * instrumentation headers match the kernel arguments. Will be optimized
129 * out by the compiler.
132 /* Reset all macros within TRACEPOINT_EVENT */
133 #include <probes/lttng-events-reset.h>
136 #define TP_PROTO(...) __VA_ARGS__
139 #define TP_ARGS(...) __VA_ARGS__
141 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
142 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
143 void trace_##_name(_proto);
145 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
146 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
147 void trace_##_name(void);
149 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
152 * Stage 1.1 of the trace events.
154 * Create dummy trace prototypes for each event class, and for each used
155 * template. This will allow checking whether the prototypes from the
156 * class and the instance using the class actually match.
159 #include <probes/lttng-events-reset.h> /* Reset all macros within TRACE_EVENT */
162 #define TP_PROTO(...) __VA_ARGS__
165 #define TP_ARGS(...) __VA_ARGS__
167 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
168 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
169 void __event_template_proto___##_template(_proto);
171 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
172 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
173 void __event_template_proto___##_template(void);
175 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
176 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
177 void __event_template_proto___##_name(_proto);
179 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
180 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
181 void __event_template_proto___##_name(void);
183 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
186 * Stage 1.2 of tracepoint event generation
188 * Unfolding the enums
190 #include <probes/lttng-events-reset.h> /* Reset all macros within TRACE_EVENT */
192 /* Enumeration entry (single value) */
193 #undef ctf_enum_value
194 #define ctf_enum_value(_string, _value) \
197 .signedness = lttng_is_signed_type(__typeof__(_value)), \
198 .value = lttng_is_signed_type(__typeof__(_value)) ? \
199 (long long) (_value) : (_value), \
202 .signedness = lttng_is_signed_type(__typeof__(_value)), \
203 .value = lttng_is_signed_type(__typeof__(_value)) ? \
204 (long long) (_value) : (_value), \
206 .string = (_string), \
209 /* Enumeration entry (range) */
210 #undef ctf_enum_range
211 #define ctf_enum_range(_string, _range_start, _range_end) \
214 .signedness = lttng_is_signed_type(__typeof__(_range_start)), \
215 .value = lttng_is_signed_type(__typeof__(_range_start)) ? \
216 (long long) (_range_start) : (_range_start), \
219 .signedness = lttng_is_signed_type(__typeof__(_range_end)), \
220 .value = lttng_is_signed_type(__typeof__(_range_end)) ? \
221 (long long) (_range_end) : (_range_end), \
223 .string = (_string), \
226 /* Enumeration entry (automatic value; follows the rules of CTF) */
228 #define ctf_enum_auto(_string) \
238 .string = (_string), \
244 #undef TP_ENUM_VALUES
245 #define TP_ENUM_VALUES(...) \
248 #undef LTTNG_TRACEPOINT_ENUM
249 #define LTTNG_TRACEPOINT_ENUM(_name, _values) \
250 const struct lttng_enum_entry __enum_values__##_name[] = { \
254 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
257 * Stage 2 of the trace events.
259 * Create event field type metadata section.
260 * Each event produce an array of fields.
263 /* Reset all macros within TRACEPOINT_EVENT */
264 #include <probes/lttng-events-reset.h>
265 #include <probes/lttng-events-write.h>
266 #include <probes/lttng-events-nowrite.h>
268 #undef _ctf_integer_ext
269 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
272 .type = __type_integer(_type, 0, 0, -1, _byte_order, _base, none),\
273 .nowrite = _nowrite, \
277 #undef _ctf_array_encoded
278 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
283 .atype = atype_array, \
288 .elem_type = __type_integer(_type, 0, 0, 0, __BYTE_ORDER, 10, _encoding), \
293 .nowrite = _nowrite, \
297 #undef _ctf_array_bitfield
298 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
303 .atype = atype_array, \
308 .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \
309 .length = (_length) * sizeof(_type) * CHAR_BIT, \
310 .elem_alignment = lttng_alignof(_type), \
314 .nowrite = _nowrite, \
319 #undef _ctf_sequence_encoded
320 #define _ctf_sequence_encoded(_type, _item, _src, \
321 _length_type, _src_length, _encoding, \
322 _byte_order, _base, _user, _nowrite) \
327 .atype = atype_sequence, \
332 .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \
333 .elem_type = __type_integer(_type, 0, 0, -1, _byte_order, _base, _encoding), \
337 .nowrite = _nowrite, \
341 #undef _ctf_sequence_bitfield
342 #define _ctf_sequence_bitfield(_type, _item, _src, \
343 _length_type, _src_length, \
349 .atype = atype_sequence, \
354 .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \
355 .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \
356 .elem_alignment = lttng_alignof(_type), \
360 .nowrite = _nowrite, \
365 #define _ctf_string(_item, _src, _user, _nowrite) \
370 .atype = atype_string, \
373 .basic = { .string = { .encoding = lttng_encode_UTF8 } } \
376 .nowrite = _nowrite, \
381 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
385 .atype = atype_enum, \
389 .desc = &__enum_##_name, \
390 .container_type = { \
391 .size = sizeof(_type) * CHAR_BIT, \
392 .alignment = lttng_alignof(_type) * CHAR_BIT, \
393 .signedness = lttng_is_signed_type(_type), \
394 .reverse_byte_order = 0, \
396 .encoding = lttng_encode_none, \
402 .nowrite = _nowrite, \
406 #undef ctf_custom_field
407 #define ctf_custom_field(_type, _item, _code) \
415 #undef ctf_custom_type
416 #define ctf_custom_type(...) __VA_ARGS__
419 #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
421 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
422 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
423 static const struct lttng_event_field __event_fields___##_name[] = { \
427 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
428 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
429 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post)
431 #undef LTTNG_TRACEPOINT_ENUM
432 #define LTTNG_TRACEPOINT_ENUM(_name, _values) \
433 static const struct lttng_enum_desc __enum_##_name = { \
435 .entries = __enum_values__##_name, \
436 .nr_entries = ARRAY_SIZE(__enum_values__##_name), \
439 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
442 * Stage 3 of the trace events.
444 * Create probe callback prototypes.
447 /* Reset all macros within TRACEPOINT_EVENT */
448 #include <probes/lttng-events-reset.h>
451 #define TP_PROTO(...) __VA_ARGS__
453 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
454 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
455 static void __event_probe__##_name(void *__data, _proto);
457 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
458 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
459 static void __event_probe__##_name(void *__data);
461 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
464 * Stage 4 of the trace events.
466 * Create static inline function that calculates event size.
469 /* Reset all macros within TRACEPOINT_EVENT */
470 #include <probes/lttng-events-reset.h>
471 #include <probes/lttng-events-write.h>
473 #undef _ctf_integer_ext
474 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
475 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
476 __event_len += sizeof(_type);
478 #undef _ctf_array_encoded
479 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
480 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
481 __event_len += sizeof(_type) * (_length);
483 #undef _ctf_array_bitfield
484 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
485 _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
487 #undef _ctf_sequence_encoded
488 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
489 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
490 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
491 __event_len += sizeof(_length_type); \
492 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
494 size_t __seqlen = (_src_length); \
496 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
498 barrier(); /* reserve before use. */ \
499 this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = __seqlen; \
500 __event_len += sizeof(_type) * __seqlen; \
503 #undef _ctf_sequence_bitfield
504 #define _ctf_sequence_bitfield(_type, _item, _src, \
505 _length_type, _src_length, \
507 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
508 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
511 * ctf_user_string includes \0. If returns 0, it faulted, so we set size to
515 #define _ctf_string(_item, _src, _user, _nowrite) \
516 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
518 barrier(); /* reserve before use. */ \
520 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
521 max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \
523 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
524 strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1; \
528 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
529 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
532 #define ctf_align(_type) \
533 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type));
535 #undef ctf_custom_field
536 #define ctf_custom_field(_type, _item, _code) \
541 #undef ctf_custom_code
542 #define ctf_custom_code(...) __VA_ARGS__
545 #define TP_PROTO(...) __VA_ARGS__
548 #define TP_FIELDS(...) __VA_ARGS__
551 #define TP_locvar(...) __VA_ARGS__
553 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
554 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
555 static inline ssize_t __event_get_size__##_name(void *__tp_locvar, _proto) \
557 size_t __event_len = 0; \
558 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
559 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
562 return __event_len; \
565 __attribute__((unused)); \
569 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
570 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
571 static inline ssize_t __event_get_size__##_name(void *__tp_locvar) \
573 size_t __event_len = 0; \
574 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
575 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
578 return __event_len; \
581 __attribute__((unused)); \
585 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
589 * Stage 4.1 of tracepoint event generation.
591 * Create static inline function that layout the filter stack data.
592 * We make both write and nowrite data available to the filter.
595 /* Reset all macros within TRACEPOINT_EVENT */
596 #include <probes/lttng-events-reset.h>
597 #include <probes/lttng-events-write.h>
598 #include <probes/lttng-events-nowrite.h>
600 #undef _ctf_integer_ext_fetched
601 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
602 if (lttng_is_signed_type(_type)) { \
603 int64_t __ctf_tmp_int64; \
604 switch (sizeof(_type)) { \
607 union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
608 __ctf_tmp_int64 = (int64_t) __tmp.v; \
613 union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
614 if (_byte_order != __BYTE_ORDER) \
615 __swab16s(&__tmp.v); \
616 __ctf_tmp_int64 = (int64_t) __tmp.v; \
621 union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
622 if (_byte_order != __BYTE_ORDER) \
623 __swab32s(&__tmp.v); \
624 __ctf_tmp_int64 = (int64_t) __tmp.v; \
629 union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
630 if (_byte_order != __BYTE_ORDER) \
631 __swab64s(&__tmp.v); \
632 __ctf_tmp_int64 = (int64_t) __tmp.v; \
638 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
640 uint64_t __ctf_tmp_uint64; \
641 switch (sizeof(_type)) { \
644 union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
645 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
650 union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
651 if (_byte_order != __BYTE_ORDER) \
652 __swab16s(&__tmp.v); \
653 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
658 union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
659 if (_byte_order != __BYTE_ORDER) \
660 __swab32s(&__tmp.v); \
661 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
666 union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
667 if (_byte_order != __BYTE_ORDER) \
668 __swab64s(&__tmp.v); \
669 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
675 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
677 __stack_data += sizeof(int64_t);
679 #undef _ctf_integer_ext_isuser0
680 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
681 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
683 #undef _ctf_integer_ext_isuser1
684 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
687 char __array[sizeof(_user_src)]; \
688 __typeof__(_user_src) __v; \
690 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
691 &(_user_src), sizeof(_user_src))) \
692 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
693 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
696 #undef _ctf_integer_ext
697 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
698 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
700 #undef _ctf_array_encoded
701 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
703 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
704 const void *__ctf_tmp_ptr = (_src); \
705 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
706 __stack_data += sizeof(unsigned long); \
707 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
708 __stack_data += sizeof(void *); \
711 #undef _ctf_array_bitfield
712 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
713 _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
715 #undef _ctf_sequence_encoded
716 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
717 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
719 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
720 const void *__ctf_tmp_ptr = (_src); \
721 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
722 __stack_data += sizeof(unsigned long); \
723 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
724 __stack_data += sizeof(void *); \
727 #undef _ctf_sequence_bitfield
728 #define _ctf_sequence_bitfield(_type, _item, _src, \
729 _length_type, _src_length, \
731 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
732 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
735 #define _ctf_string(_item, _src, _user, _nowrite) \
737 const void *__ctf_tmp_ptr = \
738 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
739 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
740 __stack_data += sizeof(void *); \
744 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
745 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
748 #define TP_PROTO(...) __VA_ARGS__
751 #define TP_FIELDS(...) __VA_ARGS__
754 #define TP_locvar(...) __VA_ARGS__
756 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
757 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
759 void __event_prepare_filter_stack__##_name(char *__stack_data, \
762 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
767 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
768 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
770 void __event_prepare_filter_stack__##_name(char *__stack_data, \
771 void *__tp_locvar, _proto) \
773 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
778 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
781 * Stage 5 of the trace events.
783 * Create static inline function that calculates event payload alignment.
786 /* Reset all macros within TRACEPOINT_EVENT */
787 #include <probes/lttng-events-reset.h>
788 #include <probes/lttng-events-write.h>
790 #undef _ctf_integer_ext
791 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
792 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
794 #undef _ctf_array_encoded
795 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
796 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
798 #undef _ctf_array_bitfield
799 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
800 _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
802 #undef _ctf_sequence_encoded
803 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
804 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
805 __event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \
806 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
808 #undef _ctf_sequence_bitfield
809 #define _ctf_sequence_bitfield(_type, _item, _src, \
810 _length_type, _src_length, \
812 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
813 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
816 #define _ctf_string(_item, _src, _user, _nowrite)
819 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
820 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
823 #define ctf_align(_type) \
824 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
827 #define TP_PROTO(...) __VA_ARGS__
830 #define TP_FIELDS(...) __VA_ARGS__
833 #define TP_locvar(...) __VA_ARGS__
835 #undef ctf_custom_field
836 #define ctf_custom_field(_type, _item, _code) _code
838 #undef ctf_custom_code
839 #define ctf_custom_code(...) \
844 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
845 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
846 static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \
848 size_t __event_align = 1; \
849 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
852 return __event_align; \
855 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
856 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
857 static inline size_t __event_get_align__##_name(void *__tp_locvar) \
859 size_t __event_align = 1; \
860 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
863 return __event_align; \
866 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
869 * Stage 6 of tracepoint event generation.
871 * Create the probe function. This function calls event size calculation
872 * and writes event data into the buffer.
875 /* Reset all macros within TRACEPOINT_EVENT */
876 #include <probes/lttng-events-reset.h>
877 #include <probes/lttng-events-write.h>
879 #undef _ctf_integer_ext_fetched
880 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
882 _type __tmp = _src; \
883 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
884 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
887 #undef _ctf_integer_ext_isuser0
888 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
889 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
891 #undef _ctf_integer_ext_isuser1
892 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
895 char __array[sizeof(_user_src)]; \
896 __typeof__(_user_src) __v; \
898 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
899 &(_user_src), sizeof(_user_src))) \
900 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
901 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
904 #undef _ctf_integer_ext
905 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
906 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
908 #undef _ctf_array_encoded
909 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
910 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
912 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
914 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
917 #if (__BYTE_ORDER == __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)); \
922 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
924 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
926 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
928 * For big endian, we need to byteswap into little endian.
930 #undef _ctf_array_bitfield
931 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
932 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
936 for (_i = 0; _i < (_length); _i++) { \
940 if (get_user(_tmp, (_type *) _src + _i)) \
943 _tmp = ((_type *) _src)[_i]; \
945 switch (sizeof(_type)) { \
949 _tmp = cpu_to_le16(_tmp); \
952 _tmp = cpu_to_le32(_tmp); \
955 _tmp = cpu_to_le64(_tmp); \
960 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
963 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
965 #undef _ctf_sequence_encoded
966 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
967 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
969 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx]; \
970 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
971 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
973 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
975 __chan->ops->event_write_from_user(&__ctx, _src, \
976 sizeof(_type) * __get_dynamic_len(dest)); \
978 __chan->ops->event_write(&__ctx, _src, \
979 sizeof(_type) * __get_dynamic_len(dest)); \
982 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
983 #undef _ctf_sequence_bitfield
984 #define _ctf_sequence_bitfield(_type, _item, _src, \
985 _length_type, _src_length, \
988 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
989 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
990 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
992 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
994 __chan->ops->event_write_from_user(&__ctx, _src, \
995 sizeof(_type) * __get_dynamic_len(dest)); \
997 __chan->ops->event_write(&__ctx, _src, \
998 sizeof(_type) * __get_dynamic_len(dest)); \
1000 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
1002 * For big endian, we need to byteswap into little endian.
1004 #undef _ctf_sequence_bitfield
1005 #define _ctf_sequence_bitfield(_type, _item, _src, \
1006 _length_type, _src_length, \
1009 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
1010 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
1011 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
1013 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
1015 size_t _i, _length; \
1017 _length = __get_dynamic_len(dest); \
1018 for (_i = 0; _i < _length; _i++) { \
1022 if (get_user(_tmp, (_type *) _src + _i)) \
1025 _tmp = ((_type *) _src)[_i]; \
1027 switch (sizeof(_type)) { \
1031 _tmp = cpu_to_le16(_tmp); \
1034 _tmp = cpu_to_le32(_tmp); \
1037 _tmp = cpu_to_le64(_tmp); \
1042 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
1045 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
1048 #define _ctf_string(_item, _src, _user, _nowrite) \
1050 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
1051 __chan->ops->event_strcpy_from_user(&__ctx, _src, \
1052 __get_dynamic_len(dest)); \
1054 const char *__ctf_tmp_string = \
1055 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
1056 lib_ring_buffer_align_ctx(&__ctx, \
1057 lttng_alignof(*__ctf_tmp_string)); \
1058 __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
1059 __get_dynamic_len(dest)); \
1063 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
1064 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
1067 #define ctf_align(_type) \
1068 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));
1070 #undef ctf_custom_field
1071 #define ctf_custom_field(_type, _item, _code) _code
1073 #undef ctf_custom_code
1074 #define ctf_custom_code(...) \
1079 /* Beware: this get len actually consumes the len value */
1080 #undef __get_dynamic_len
1081 #define __get_dynamic_len(field) this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx++]
1084 #define TP_PROTO(...) __VA_ARGS__
1087 #define TP_ARGS(...) __VA_ARGS__
1090 #define TP_FIELDS(...) __VA_ARGS__
1093 #define TP_locvar(...) __VA_ARGS__
1096 #define TP_code_pre(...) __VA_ARGS__
1099 #define TP_code_post(...) __VA_ARGS__
1102 * For state dump, check that "session" argument (mandatory) matches the
1103 * session this event belongs to. Ensures that we write state dump data only
1104 * into the started session, not into all sessions.
1106 #ifdef TP_SESSION_CHECK
1107 #define _TP_SESSION_CHECK(session, csession) (session == csession)
1108 #else /* TP_SESSION_CHECK */
1109 #define _TP_SESSION_CHECK(session, csession) 1
1110 #endif /* TP_SESSION_CHECK */
1113 * Using twice size for filter stack data to hold size and pointer for
1114 * each field (worse case). For integers, max size required is 64-bit.
1115 * Same for double-precision floats. Those fit within
1116 * 2*sizeof(unsigned long) for all supported architectures.
1117 * Perform UNION (||) of filter runtime list.
1119 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
1120 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
1121 static void __event_probe__##_name(void *__data, _proto) \
1123 struct probe_local_vars { _locvar }; \
1124 struct lttng_event *__event = __data; \
1125 struct lttng_probe_ctx __lttng_probe_ctx = { \
1127 .interruptible = !irqs_disabled(), \
1129 struct lttng_channel *__chan = __event->chan; \
1130 struct lttng_session *__session = __chan->session; \
1131 struct lib_ring_buffer_ctx __ctx; \
1132 ssize_t __event_len; \
1133 size_t __event_align; \
1134 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1136 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1137 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1140 struct probe_local_vars __tp_locvar; \
1141 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1143 struct lttng_pid_tracker *__lpf; \
1145 if (!_TP_SESSION_CHECK(session, __session)) \
1147 if (unlikely(!READ_ONCE(__session->active))) \
1149 if (unlikely(!READ_ONCE(__chan->enabled))) \
1151 if (unlikely(!READ_ONCE(__event->enabled))) \
1153 __lpf = lttng_rcu_dereference(__session->pid_tracker); \
1154 if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->tgid))) \
1156 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1157 __dynamic_len_idx = __orig_dynamic_len_offset; \
1159 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1160 struct lttng_bytecode_runtime *bc_runtime; \
1161 int __filter_record = __event->has_enablers_without_bytecode; \
1163 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1164 tp_locvar, _args); \
1165 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1166 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1167 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
1168 __filter_record = 1; \
1170 if (likely(!__filter_record)) \
1173 __event_len = __event_get_size__##_name(tp_locvar, _args); \
1174 if (unlikely(__event_len < 0)) { \
1175 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1178 __event_align = __event_get_align__##_name(tp_locvar, _args); \
1179 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1180 __event_align, -1); \
1181 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1185 __chan->ops->event_commit(&__ctx); \
1188 barrier(); /* use before un-reserve. */ \
1189 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1193 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
1194 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
1195 static void __event_probe__##_name(void *__data) \
1197 struct probe_local_vars { _locvar }; \
1198 struct lttng_event *__event = __data; \
1199 struct lttng_probe_ctx __lttng_probe_ctx = { \
1201 .interruptible = !irqs_disabled(), \
1203 struct lttng_channel *__chan = __event->chan; \
1204 struct lttng_session *__session = __chan->session; \
1205 struct lib_ring_buffer_ctx __ctx; \
1206 ssize_t __event_len; \
1207 size_t __event_align; \
1208 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1210 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1211 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1214 struct probe_local_vars __tp_locvar; \
1215 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1217 struct lttng_pid_tracker *__lpf; \
1219 if (!_TP_SESSION_CHECK(session, __session)) \
1221 if (unlikely(!READ_ONCE(__session->active))) \
1223 if (unlikely(!READ_ONCE(__chan->enabled))) \
1225 if (unlikely(!READ_ONCE(__event->enabled))) \
1227 __lpf = lttng_rcu_dereference(__session->pid_tracker); \
1228 if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->tgid))) \
1230 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1231 __dynamic_len_idx = __orig_dynamic_len_offset; \
1233 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1234 struct lttng_bytecode_runtime *bc_runtime; \
1235 int __filter_record = __event->has_enablers_without_bytecode; \
1237 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1239 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1240 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1241 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
1242 __filter_record = 1; \
1244 if (likely(!__filter_record)) \
1247 __event_len = __event_get_size__##_name(tp_locvar); \
1248 if (unlikely(__event_len < 0)) { \
1249 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1252 __event_align = __event_get_align__##_name(tp_locvar); \
1253 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1254 __event_align, -1); \
1255 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1259 __chan->ops->event_commit(&__ctx); \
1262 barrier(); /* use before un-reserve. */ \
1263 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1267 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1269 #undef __get_dynamic_len
1272 * Stage 7 of the trace events.
1274 * Create event descriptions.
1277 /* Named field types must be defined in lttng-types.h */
1279 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1282 #define TP_PROBE_CB(_template) &__event_probe__##_template
1285 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1286 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1287 static const struct lttng_event_desc __event_desc___##_map = { \
1288 .fields = __event_fields___##_template, \
1291 .probe_callback = (void *) TP_PROBE_CB(_template), \
1292 .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
1293 .owner = THIS_MODULE, \
1296 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1297 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1298 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1300 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1303 * Stage 8 of the trace events.
1305 * Create an array of event description pointers.
1308 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1310 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1311 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1312 &__event_desc___##_map,
1314 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1315 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1316 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1318 #define TP_ID1(_token, _system) _token##_system
1319 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1321 static const struct lttng_event_desc
*TP_ID(__event_desc___
, TRACE_SYSTEM
)[] = {
1322 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1329 * Stage 9 of the trace events.
1331 * Create a toplevel descriptor for the whole probe.
1334 #define TP_ID1(_token, _system) _token##_system
1335 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1337 /* non-const because list head will be modified when registered. */
1338 static __used
struct lttng_probe_desc
TP_ID(__probe_desc___
, TRACE_SYSTEM
) = {
1339 .provider
= __stringify(TRACE_SYSTEM
),
1340 .event_desc
= TP_ID(__event_desc___
, TRACE_SYSTEM
),
1341 .nr_events
= ARRAY_SIZE(TP_ID(__event_desc___
, TRACE_SYSTEM
)),
1342 .head
= { NULL
, NULL
},
1343 .lazy_init_head
= { NULL
, NULL
},
1351 * Stage 10 of the trace events.
1353 * Register/unregister probes at module load/unload.
1356 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1358 #define TP_ID1(_token, _system) _token##_system
1359 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1360 #define module_init_eval1(_token, _system) module_init(_token##_system)
1361 #define module_init_eval(_token, _system) module_init_eval1(_token, _system)
1362 #define module_exit_eval1(_token, _system) module_exit(_token##_system)
1363 #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system)
1365 #ifndef TP_MODULE_NOINIT
1366 static int TP_ID(__lttng_events_init__
, TRACE_SYSTEM
)(void)
1368 wrapper_vmalloc_sync_all();
1369 return lttng_probe_register(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1372 static void TP_ID(__lttng_events_exit__
, TRACE_SYSTEM
)(void)
1374 lttng_probe_unregister(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1377 #ifndef TP_MODULE_NOAUTOLOAD
1378 module_init_eval(__lttng_events_init__
, TRACE_SYSTEM
);
1379 module_exit_eval(__lttng_events_exit__
, TRACE_SYSTEM
);
1384 #undef module_init_eval
1385 #undef module_exit_eval
This page took 0.057917 seconds and 5 git commands to generate.