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>
38 #define __LTTNG_NULL_STRING "(null)"
41 * Macro declarations used for all stages.
45 * LTTng name mapping macros. LTTng remaps some of the kernel events to
46 * enforce name-spacing.
48 #undef LTTNG_TRACEPOINT_EVENT_MAP
49 #define LTTNG_TRACEPOINT_EVENT_MAP(name, map, proto, args, fields) \
50 LTTNG_TRACEPOINT_EVENT_CLASS(map, \
54 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
56 #undef LTTNG_TRACEPOINT_EVENT_MAP_NOARGS
57 #define LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, map, fields) \
58 LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(map, \
60 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(map, name, map)
62 #undef LTTNG_TRACEPOINT_EVENT_CODE_MAP
63 #define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code_pre, fields, _code_post) \
64 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(map, \
71 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
73 #undef LTTNG_TRACEPOINT_EVENT_CODE
74 #define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code_pre, fields, _code_post) \
75 LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, name, \
84 * LTTNG_TRACEPOINT_EVENT_CLASS can be used to add a generic function
85 * handlers for events. That is, if all events have the same parameters
86 * and just have distinct trace points. Each tracepoint can be defined
87 * with LTTNG_TRACEPOINT_EVENT_INSTANCE and that will map the
88 * LTTNG_TRACEPOINT_EVENT_CLASS to the tracepoint.
90 * LTTNG_TRACEPOINT_EVENT is a one to one mapping between tracepoint and
94 #undef LTTNG_TRACEPOINT_EVENT
95 #define LTTNG_TRACEPOINT_EVENT(name, proto, args, fields) \
96 LTTNG_TRACEPOINT_EVENT_MAP(name, name, \
101 #undef LTTNG_TRACEPOINT_EVENT_NOARGS
102 #define LTTNG_TRACEPOINT_EVENT_NOARGS(name, fields) \
103 LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, name, PARAMS(fields))
105 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE
106 #define LTTNG_TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \
107 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(template, name, name, PARAMS(proto), PARAMS(args))
109 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
110 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \
111 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(template, name, name)
113 #undef LTTNG_TRACEPOINT_EVENT_CLASS
114 #define LTTNG_TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \
115 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(_proto), PARAMS(_args), , , \
118 #undef LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
119 #define LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
120 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, , , PARAMS(_fields), )
124 * Stage 1 of the trace events.
126 * Create dummy trace calls for each events, verifying that the LTTng module
127 * instrumentation headers match the kernel arguments. Will be optimized
128 * out by the compiler.
131 /* Reset all macros within TRACEPOINT_EVENT */
132 #include <probes/lttng-events-reset.h>
135 #define TP_PROTO(...) __VA_ARGS__
138 #define TP_ARGS(...) __VA_ARGS__
140 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
141 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
142 void trace_##_name(_proto);
144 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
145 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
146 void trace_##_name(void);
148 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
151 * Stage 1.1 of the trace events.
153 * Create dummy trace prototypes for each event class, and for each used
154 * template. This will allow checking whether the prototypes from the
155 * class and the instance using the class actually match.
158 #include <probes/lttng-events-reset.h> /* Reset all macros within TRACE_EVENT */
161 #define TP_PROTO(...) __VA_ARGS__
164 #define TP_ARGS(...) __VA_ARGS__
166 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
167 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
168 void __event_template_proto___##_template(_proto);
170 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
171 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
172 void __event_template_proto___##_template(void);
174 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
175 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
176 void __event_template_proto___##_name(_proto);
178 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
179 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
180 void __event_template_proto___##_name(void);
182 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
185 * Stage 1.2 of tracepoint event generation
187 * Unfolding the enums
189 #include <probes/lttng-events-reset.h> /* Reset all macros within TRACE_EVENT */
191 /* Enumeration entry (single value) */
192 #undef ctf_enum_value
193 #define ctf_enum_value(_string, _value) \
196 .signedness = lttng_is_signed_type(__typeof__(_value)), \
197 .value = lttng_is_signed_type(__typeof__(_value)) ? \
198 (long long) (_value) : (_value), \
201 .signedness = lttng_is_signed_type(__typeof__(_value)), \
202 .value = lttng_is_signed_type(__typeof__(_value)) ? \
203 (long long) (_value) : (_value), \
205 .string = (_string), \
208 /* Enumeration entry (range) */
209 #undef ctf_enum_range
210 #define ctf_enum_range(_string, _range_start, _range_end) \
213 .signedness = lttng_is_signed_type(__typeof__(_range_start)), \
214 .value = lttng_is_signed_type(__typeof__(_range_start)) ? \
215 (long long) (_range_start) : (_range_start), \
218 .signedness = lttng_is_signed_type(__typeof__(_range_end)), \
219 .value = lttng_is_signed_type(__typeof__(_range_end)) ? \
220 (long long) (_range_end) : (_range_end), \
222 .string = (_string), \
225 /* Enumeration entry (automatic value; follows the rules of CTF) */
227 #define ctf_enum_auto(_string) \
237 .string = (_string), \
243 #undef TP_ENUM_VALUES
244 #define TP_ENUM_VALUES(...) \
247 #undef LTTNG_TRACEPOINT_ENUM
248 #define LTTNG_TRACEPOINT_ENUM(_name, _values) \
249 const struct lttng_enum_entry __enum_values__##_name[] = { \
253 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
256 * Stage 2 of the trace events.
258 * Create event field type metadata section.
259 * Each event produce an array of fields.
262 /* Reset all macros within TRACEPOINT_EVENT */
263 #include <probes/lttng-events-reset.h>
264 #include <probes/lttng-events-write.h>
265 #include <probes/lttng-events-nowrite.h>
267 #undef _ctf_integer_ext
268 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
271 .type = __type_integer(_type, 0, 0, -1, _byte_order, _base, none),\
272 .nowrite = _nowrite, \
276 #undef _ctf_array_encoded
277 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
282 .atype = atype_array, \
287 .elem_type = __type_integer(_type, 0, 0, 0, __BYTE_ORDER, 10, _encoding), \
292 .nowrite = _nowrite, \
296 #undef _ctf_array_bitfield
297 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
302 .atype = atype_array, \
307 .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \
308 .length = (_length) * sizeof(_type) * CHAR_BIT, \
309 .elem_alignment = lttng_alignof(_type), \
313 .nowrite = _nowrite, \
318 #undef _ctf_sequence_encoded
319 #define _ctf_sequence_encoded(_type, _item, _src, \
320 _length_type, _src_length, _encoding, \
321 _byte_order, _base, _user, _nowrite) \
326 .atype = atype_sequence, \
331 .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \
332 .elem_type = __type_integer(_type, 0, 0, -1, _byte_order, _base, _encoding), \
336 .nowrite = _nowrite, \
340 #undef _ctf_sequence_bitfield
341 #define _ctf_sequence_bitfield(_type, _item, _src, \
342 _length_type, _src_length, \
348 .atype = atype_sequence, \
353 .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \
354 .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \
355 .elem_alignment = lttng_alignof(_type), \
359 .nowrite = _nowrite, \
364 #define _ctf_string(_item, _src, _user, _nowrite) \
369 .atype = atype_string, \
372 .basic = { .string = { .encoding = lttng_encode_UTF8 } } \
375 .nowrite = _nowrite, \
380 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
384 .atype = atype_enum, \
388 .desc = &__enum_##_name, \
389 .container_type = { \
390 .size = sizeof(_type) * CHAR_BIT, \
391 .alignment = lttng_alignof(_type) * CHAR_BIT, \
392 .signedness = lttng_is_signed_type(_type), \
393 .reverse_byte_order = 0, \
395 .encoding = lttng_encode_none, \
401 .nowrite = _nowrite, \
405 #undef ctf_custom_field
406 #define ctf_custom_field(_type, _item, _code) \
414 #undef ctf_custom_type
415 #define ctf_custom_type(...) __VA_ARGS__
418 #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
420 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
421 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
422 static const struct lttng_event_field __event_fields___##_name[] = { \
426 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
427 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
428 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post)
430 #undef LTTNG_TRACEPOINT_ENUM
431 #define LTTNG_TRACEPOINT_ENUM(_name, _values) \
432 static const struct lttng_enum_desc __enum_##_name = { \
434 .entries = __enum_values__##_name, \
435 .nr_entries = ARRAY_SIZE(__enum_values__##_name), \
438 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
441 * Stage 3 of the trace events.
443 * Create probe callback prototypes.
446 /* Reset all macros within TRACEPOINT_EVENT */
447 #include <probes/lttng-events-reset.h>
450 #define TP_PROTO(...) __VA_ARGS__
452 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
453 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
454 static void __event_probe__##_name(void *__data, _proto);
456 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
457 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
458 static void __event_probe__##_name(void *__data);
460 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
463 * Stage 4 of the trace events.
465 * Create static inline function that calculates event size.
468 /* Reset all macros within TRACEPOINT_EVENT */
469 #include <probes/lttng-events-reset.h>
470 #include <probes/lttng-events-write.h>
472 #undef _ctf_integer_ext
473 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
474 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
475 __event_len += sizeof(_type);
477 #undef _ctf_array_encoded
478 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
479 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
480 __event_len += sizeof(_type) * (_length);
482 #undef _ctf_array_bitfield
483 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
484 _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
486 #undef _ctf_sequence_encoded
487 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
488 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
489 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
490 __event_len += sizeof(_length_type); \
491 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
493 size_t __seqlen = (_src_length); \
495 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
497 barrier(); /* reserve before use. */ \
498 this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = __seqlen; \
499 __event_len += sizeof(_type) * __seqlen; \
502 #undef _ctf_sequence_bitfield
503 #define _ctf_sequence_bitfield(_type, _item, _src, \
504 _length_type, _src_length, \
506 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
507 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
510 * ctf_user_string includes \0. If returns 0, it faulted, so we set size to
514 #define _ctf_string(_item, _src, _user, _nowrite) \
515 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
517 barrier(); /* reserve before use. */ \
519 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
520 max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \
522 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
523 strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1; \
527 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
528 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
531 #define ctf_align(_type) \
532 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type));
534 #undef ctf_custom_field
535 #define ctf_custom_field(_type, _item, _code) \
540 #undef ctf_custom_code
541 #define ctf_custom_code(...) __VA_ARGS__
544 #define TP_PROTO(...) __VA_ARGS__
547 #define TP_FIELDS(...) __VA_ARGS__
550 #define TP_locvar(...) __VA_ARGS__
552 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
553 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
554 static inline ssize_t __event_get_size__##_name(void *__tp_locvar, _proto) \
556 size_t __event_len = 0; \
557 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
558 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
561 return __event_len; \
564 __attribute__((unused)); \
568 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
569 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
570 static inline ssize_t __event_get_size__##_name(void *__tp_locvar) \
572 size_t __event_len = 0; \
573 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
574 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
577 return __event_len; \
580 __attribute__((unused)); \
584 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
588 * Stage 4.1 of tracepoint event generation.
590 * Create static inline function that layout the filter stack data.
591 * We make both write and nowrite data available to the filter.
594 /* Reset all macros within TRACEPOINT_EVENT */
595 #include <probes/lttng-events-reset.h>
596 #include <probes/lttng-events-write.h>
597 #include <probes/lttng-events-nowrite.h>
599 #undef _ctf_integer_ext_fetched
600 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
601 if (lttng_is_signed_type(_type)) { \
602 int64_t __ctf_tmp_int64; \
603 switch (sizeof(_type)) { \
606 union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
607 __ctf_tmp_int64 = (int64_t) __tmp.v; \
612 union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
613 if (_byte_order != __BYTE_ORDER) \
614 __swab16s(&__tmp.v); \
615 __ctf_tmp_int64 = (int64_t) __tmp.v; \
620 union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
621 if (_byte_order != __BYTE_ORDER) \
622 __swab32s(&__tmp.v); \
623 __ctf_tmp_int64 = (int64_t) __tmp.v; \
628 union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
629 if (_byte_order != __BYTE_ORDER) \
630 __swab64s(&__tmp.v); \
631 __ctf_tmp_int64 = (int64_t) __tmp.v; \
637 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
639 uint64_t __ctf_tmp_uint64; \
640 switch (sizeof(_type)) { \
643 union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
644 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
649 union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
650 if (_byte_order != __BYTE_ORDER) \
651 __swab16s(&__tmp.v); \
652 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
657 union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
658 if (_byte_order != __BYTE_ORDER) \
659 __swab32s(&__tmp.v); \
660 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
665 union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
666 if (_byte_order != __BYTE_ORDER) \
667 __swab64s(&__tmp.v); \
668 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
674 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
676 __stack_data += sizeof(int64_t);
678 #undef _ctf_integer_ext_isuser0
679 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
680 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
682 #undef _ctf_integer_ext_isuser1
683 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
686 char __array[sizeof(_user_src)]; \
687 __typeof__(_user_src) __v; \
689 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
690 &(_user_src), sizeof(_user_src))) \
691 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
692 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
695 #undef _ctf_integer_ext
696 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
697 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
699 #undef _ctf_array_encoded
700 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
702 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
703 const void *__ctf_tmp_ptr = (_src); \
704 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
705 __stack_data += sizeof(unsigned long); \
706 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
707 __stack_data += sizeof(void *); \
710 #undef _ctf_array_bitfield
711 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
712 _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
714 #undef _ctf_sequence_encoded
715 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
716 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
718 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
719 const void *__ctf_tmp_ptr = (_src); \
720 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
721 __stack_data += sizeof(unsigned long); \
722 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
723 __stack_data += sizeof(void *); \
726 #undef _ctf_sequence_bitfield
727 #define _ctf_sequence_bitfield(_type, _item, _src, \
728 _length_type, _src_length, \
730 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
731 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
734 #define _ctf_string(_item, _src, _user, _nowrite) \
736 const void *__ctf_tmp_ptr = \
737 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
738 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
739 __stack_data += sizeof(void *); \
743 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
744 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
747 #define TP_PROTO(...) __VA_ARGS__
750 #define TP_FIELDS(...) __VA_ARGS__
753 #define TP_locvar(...) __VA_ARGS__
755 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
756 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
758 void __event_prepare_filter_stack__##_name(char *__stack_data, \
761 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
766 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
767 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
769 void __event_prepare_filter_stack__##_name(char *__stack_data, \
770 void *__tp_locvar, _proto) \
772 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
777 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
780 * Stage 5 of the trace events.
782 * Create static inline function that calculates event payload alignment.
785 /* Reset all macros within TRACEPOINT_EVENT */
786 #include <probes/lttng-events-reset.h>
787 #include <probes/lttng-events-write.h>
789 #undef _ctf_integer_ext
790 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
791 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
793 #undef _ctf_array_encoded
794 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
795 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
797 #undef _ctf_array_bitfield
798 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
799 _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
801 #undef _ctf_sequence_encoded
802 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
803 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
804 __event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \
805 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
807 #undef _ctf_sequence_bitfield
808 #define _ctf_sequence_bitfield(_type, _item, _src, \
809 _length_type, _src_length, \
811 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
812 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
815 #define _ctf_string(_item, _src, _user, _nowrite)
818 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
819 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
822 #define ctf_align(_type) \
823 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
826 #define TP_PROTO(...) __VA_ARGS__
829 #define TP_FIELDS(...) __VA_ARGS__
832 #define TP_locvar(...) __VA_ARGS__
834 #undef ctf_custom_field
835 #define ctf_custom_field(_type, _item, _code) _code
837 #undef ctf_custom_code
838 #define ctf_custom_code(...) \
843 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
844 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
845 static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \
847 size_t __event_align = 1; \
848 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
851 return __event_align; \
854 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
855 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
856 static inline size_t __event_get_align__##_name(void *__tp_locvar) \
858 size_t __event_align = 1; \
859 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
862 return __event_align; \
865 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
868 * Stage 6 of tracepoint event generation.
870 * Create the probe function. This function calls event size calculation
871 * and writes event data into the buffer.
874 /* Reset all macros within TRACEPOINT_EVENT */
875 #include <probes/lttng-events-reset.h>
876 #include <probes/lttng-events-write.h>
878 #undef _ctf_integer_ext_fetched
879 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
881 _type __tmp = _src; \
882 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
883 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
886 #undef _ctf_integer_ext_isuser0
887 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
888 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
890 #undef _ctf_integer_ext_isuser1
891 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
894 char __array[sizeof(_user_src)]; \
895 __typeof__(_user_src) __v; \
897 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
898 &(_user_src), sizeof(_user_src))) \
899 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
900 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
903 #undef _ctf_integer_ext
904 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
905 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
907 #undef _ctf_array_encoded
908 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
909 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
911 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
913 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
916 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
917 #undef _ctf_array_bitfield
918 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
919 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
921 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
923 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
925 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
927 * For big endian, we need to byteswap into little endian.
929 #undef _ctf_array_bitfield
930 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
931 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
935 for (_i = 0; _i < (_length); _i++) { \
939 if (get_user(_tmp, (_type *) _src + _i)) \
942 _tmp = ((_type *) _src)[_i]; \
944 switch (sizeof(_type)) { \
948 _tmp = cpu_to_le16(_tmp); \
951 _tmp = cpu_to_le32(_tmp); \
954 _tmp = cpu_to_le64(_tmp); \
959 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
962 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
964 #undef _ctf_sequence_encoded
965 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
966 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
968 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx]; \
969 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
970 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
972 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
974 __chan->ops->event_write_from_user(&__ctx, _src, \
975 sizeof(_type) * __get_dynamic_len(dest)); \
977 __chan->ops->event_write(&__ctx, _src, \
978 sizeof(_type) * __get_dynamic_len(dest)); \
981 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
982 #undef _ctf_sequence_bitfield
983 #define _ctf_sequence_bitfield(_type, _item, _src, \
984 _length_type, _src_length, \
987 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
988 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
989 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
991 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
993 __chan->ops->event_write_from_user(&__ctx, _src, \
994 sizeof(_type) * __get_dynamic_len(dest)); \
996 __chan->ops->event_write(&__ctx, _src, \
997 sizeof(_type) * __get_dynamic_len(dest)); \
999 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
1001 * For big endian, we need to byteswap into little endian.
1003 #undef _ctf_sequence_bitfield
1004 #define _ctf_sequence_bitfield(_type, _item, _src, \
1005 _length_type, _src_length, \
1008 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
1009 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
1010 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
1012 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
1014 size_t _i, _length; \
1016 _length = __get_dynamic_len(dest); \
1017 for (_i = 0; _i < _length; _i++) { \
1021 if (get_user(_tmp, (_type *) _src + _i)) \
1024 _tmp = ((_type *) _src)[_i]; \
1026 switch (sizeof(_type)) { \
1030 _tmp = cpu_to_le16(_tmp); \
1033 _tmp = cpu_to_le32(_tmp); \
1036 _tmp = cpu_to_le64(_tmp); \
1041 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
1044 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
1047 #define _ctf_string(_item, _src, _user, _nowrite) \
1049 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
1050 __chan->ops->event_strcpy_from_user(&__ctx, _src, \
1051 __get_dynamic_len(dest)); \
1053 const char *__ctf_tmp_string = \
1054 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
1055 lib_ring_buffer_align_ctx(&__ctx, \
1056 lttng_alignof(*__ctf_tmp_string)); \
1057 __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
1058 __get_dynamic_len(dest)); \
1062 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
1063 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
1066 #define ctf_align(_type) \
1067 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));
1069 #undef ctf_custom_field
1070 #define ctf_custom_field(_type, _item, _code) _code
1072 #undef ctf_custom_code
1073 #define ctf_custom_code(...) \
1078 /* Beware: this get len actually consumes the len value */
1079 #undef __get_dynamic_len
1080 #define __get_dynamic_len(field) this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx++]
1083 #define TP_PROTO(...) __VA_ARGS__
1086 #define TP_ARGS(...) __VA_ARGS__
1089 #define TP_FIELDS(...) __VA_ARGS__
1092 #define TP_locvar(...) __VA_ARGS__
1095 #define TP_code_pre(...) __VA_ARGS__
1098 #define TP_code_post(...) __VA_ARGS__
1101 * For state dump, check that "session" argument (mandatory) matches the
1102 * session this event belongs to. Ensures that we write state dump data only
1103 * into the started session, not into all sessions.
1105 #ifdef TP_SESSION_CHECK
1106 #define _TP_SESSION_CHECK(session, csession) (session == csession)
1107 #else /* TP_SESSION_CHECK */
1108 #define _TP_SESSION_CHECK(session, csession) 1
1109 #endif /* TP_SESSION_CHECK */
1112 * Using twice size for filter stack data to hold size and pointer for
1113 * each field (worse case). For integers, max size required is 64-bit.
1114 * Same for double-precision floats. Those fit within
1115 * 2*sizeof(unsigned long) for all supported architectures.
1116 * Perform UNION (||) of filter runtime list.
1118 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
1119 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
1120 static void __event_probe__##_name(void *__data, _proto) \
1122 struct probe_local_vars { _locvar }; \
1123 struct lttng_event *__event = __data; \
1124 struct lttng_probe_ctx __lttng_probe_ctx = { \
1126 .interruptible = !irqs_disabled(), \
1128 struct lttng_channel *__chan = __event->chan; \
1129 struct lttng_session *__session = __chan->session; \
1130 struct lib_ring_buffer_ctx __ctx; \
1131 ssize_t __event_len; \
1132 size_t __event_align; \
1133 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1135 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1136 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1139 struct probe_local_vars __tp_locvar; \
1140 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1142 struct lttng_pid_tracker *__lpf; \
1144 if (!_TP_SESSION_CHECK(session, __session)) \
1146 if (unlikely(!ACCESS_ONCE(__session->active))) \
1148 if (unlikely(!ACCESS_ONCE(__chan->enabled))) \
1150 if (unlikely(!ACCESS_ONCE(__event->enabled))) \
1152 __lpf = lttng_rcu_dereference(__session->pid_tracker); \
1153 if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->tgid))) \
1155 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1156 __dynamic_len_idx = __orig_dynamic_len_offset; \
1158 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1159 struct lttng_bytecode_runtime *bc_runtime; \
1160 int __filter_record = __event->has_enablers_without_bytecode; \
1162 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1163 tp_locvar, _args); \
1164 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1165 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1166 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
1167 __filter_record = 1; \
1169 if (likely(!__filter_record)) \
1172 __event_len = __event_get_size__##_name(tp_locvar, _args); \
1173 if (unlikely(__event_len < 0)) { \
1174 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1177 __event_align = __event_get_align__##_name(tp_locvar, _args); \
1178 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1179 __event_align, -1); \
1180 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1184 __chan->ops->event_commit(&__ctx); \
1187 barrier(); /* use before un-reserve. */ \
1188 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1192 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
1193 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
1194 static void __event_probe__##_name(void *__data) \
1196 struct probe_local_vars { _locvar }; \
1197 struct lttng_event *__event = __data; \
1198 struct lttng_probe_ctx __lttng_probe_ctx = { \
1200 .interruptible = !irqs_disabled(), \
1202 struct lttng_channel *__chan = __event->chan; \
1203 struct lttng_session *__session = __chan->session; \
1204 struct lib_ring_buffer_ctx __ctx; \
1205 ssize_t __event_len; \
1206 size_t __event_align; \
1207 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1209 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1210 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1213 struct probe_local_vars __tp_locvar; \
1214 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1216 struct lttng_pid_tracker *__lpf; \
1218 if (!_TP_SESSION_CHECK(session, __session)) \
1220 if (unlikely(!ACCESS_ONCE(__session->active))) \
1222 if (unlikely(!ACCESS_ONCE(__chan->enabled))) \
1224 if (unlikely(!ACCESS_ONCE(__event->enabled))) \
1226 __lpf = lttng_rcu_dereference(__session->pid_tracker); \
1227 if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->pid))) \
1229 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1230 __dynamic_len_idx = __orig_dynamic_len_offset; \
1232 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1233 struct lttng_bytecode_runtime *bc_runtime; \
1234 int __filter_record = __event->has_enablers_without_bytecode; \
1236 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1238 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1239 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1240 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
1241 __filter_record = 1; \
1243 if (likely(!__filter_record)) \
1246 __event_len = __event_get_size__##_name(tp_locvar); \
1247 if (unlikely(__event_len < 0)) { \
1248 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1251 __event_align = __event_get_align__##_name(tp_locvar); \
1252 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1253 __event_align, -1); \
1254 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1258 __chan->ops->event_commit(&__ctx); \
1261 barrier(); /* use before un-reserve. */ \
1262 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1266 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1268 #undef __get_dynamic_len
1271 * Stage 7 of the trace events.
1273 * Create event descriptions.
1276 /* Named field types must be defined in lttng-types.h */
1278 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1281 #define TP_PROBE_CB(_template) &__event_probe__##_template
1284 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1285 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1286 static const struct lttng_event_desc __event_desc___##_map = { \
1287 .fields = __event_fields___##_template, \
1290 .probe_callback = (void *) TP_PROBE_CB(_template), \
1291 .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
1292 .owner = THIS_MODULE, \
1295 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1296 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1297 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1299 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1302 * Stage 8 of the trace events.
1304 * Create an array of event description pointers.
1307 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1309 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1310 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1311 &__event_desc___##_map,
1313 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1314 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1315 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1317 #define TP_ID1(_token, _system) _token##_system
1318 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1320 static const struct lttng_event_desc
*TP_ID(__event_desc___
, TRACE_SYSTEM
)[] = {
1321 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1328 * Stage 9 of the trace events.
1330 * Create a toplevel descriptor for the whole probe.
1333 #define TP_ID1(_token, _system) _token##_system
1334 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1336 /* non-const because list head will be modified when registered. */
1337 static __used
struct lttng_probe_desc
TP_ID(__probe_desc___
, TRACE_SYSTEM
) = {
1338 .provider
= __stringify(TRACE_SYSTEM
),
1339 .event_desc
= TP_ID(__event_desc___
, TRACE_SYSTEM
),
1340 .nr_events
= ARRAY_SIZE(TP_ID(__event_desc___
, TRACE_SYSTEM
)),
1341 .head
= { NULL
, NULL
},
1342 .lazy_init_head
= { NULL
, NULL
},
1350 * Stage 10 of the trace events.
1352 * Register/unregister probes at module load/unload.
1355 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1357 #define TP_ID1(_token, _system) _token##_system
1358 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1359 #define module_init_eval1(_token, _system) module_init(_token##_system)
1360 #define module_init_eval(_token, _system) module_init_eval1(_token, _system)
1361 #define module_exit_eval1(_token, _system) module_exit(_token##_system)
1362 #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system)
1364 #ifndef TP_MODULE_NOINIT
1365 static int TP_ID(__lttng_events_init__
, TRACE_SYSTEM
)(void)
1367 wrapper_vmalloc_sync_all();
1368 return lttng_probe_register(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1371 static void TP_ID(__lttng_events_exit__
, TRACE_SYSTEM
)(void)
1373 lttng_probe_unregister(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1376 #ifndef TP_MODULE_NOAUTOLOAD
1377 module_init_eval(__lttng_events_init__
, TRACE_SYSTEM
);
1378 module_exit_eval(__lttng_events_exit__
, TRACE_SYSTEM
);
1383 #undef module_init_eval
1384 #undef module_exit_eval
This page took 0.0562 seconds and 5 git commands to generate.