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 <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
16 #include <ringbuffer/frontend_types.h>
17 #include <ringbuffer/backend.h>
18 #include <wrapper/rcu.h>
19 #include <wrapper/user_namespace.h>
20 #include <lttng/types.h>
21 #include <lttng/probe-user.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 #define PARAMS(args...) args
32 * Macro declarations used for all stages.
36 * LTTng name mapping macros. LTTng remaps some of the kernel events to
37 * enforce name-spacing.
39 #undef LTTNG_TRACEPOINT_EVENT_MAP
40 #define LTTNG_TRACEPOINT_EVENT_MAP(name, map, proto, args, fields) \
41 LTTNG_TRACEPOINT_EVENT_CLASS(map, \
45 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
47 #undef LTTNG_TRACEPOINT_EVENT_MAP_NOARGS
48 #define LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, map, fields) \
49 LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(map, \
51 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(map, name, map)
53 #undef LTTNG_TRACEPOINT_EVENT_CODE_MAP
54 #define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code_pre, fields, _code_post) \
55 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(map, \
62 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
64 #undef LTTNG_TRACEPOINT_EVENT_CODE
65 #define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code_pre, fields, _code_post) \
66 LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, name, \
75 * LTTNG_TRACEPOINT_EVENT_CLASS can be used to add a generic function
76 * handlers for events. That is, if all events have the same parameters
77 * and just have distinct trace points. Each tracepoint can be defined
78 * with LTTNG_TRACEPOINT_EVENT_INSTANCE and that will map the
79 * LTTNG_TRACEPOINT_EVENT_CLASS to the tracepoint.
81 * LTTNG_TRACEPOINT_EVENT is a one to one mapping between tracepoint and
85 #undef LTTNG_TRACEPOINT_EVENT
86 #define LTTNG_TRACEPOINT_EVENT(name, proto, args, fields) \
87 LTTNG_TRACEPOINT_EVENT_MAP(name, name, \
92 #undef LTTNG_TRACEPOINT_EVENT_NOARGS
93 #define LTTNG_TRACEPOINT_EVENT_NOARGS(name, fields) \
94 LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, name, PARAMS(fields))
96 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE
97 #define LTTNG_TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \
98 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(template, name, name, PARAMS(proto), PARAMS(args))
100 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
101 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \
102 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(template, name, name)
104 #undef LTTNG_TRACEPOINT_EVENT_CLASS
105 #define LTTNG_TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \
106 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(_proto), PARAMS(_args), , , \
109 #undef LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
110 #define LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
111 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, , , PARAMS(_fields), )
115 * Stage 1 of the trace events.
117 * Create dummy trace calls for each events, verifying that the LTTng module
118 * instrumentation headers match the kernel arguments. Will be optimized
119 * out by the compiler.
122 /* Reset all macros within TRACEPOINT_EVENT */
123 #include <lttng/events-reset.h>
126 #define TP_PROTO(...) __VA_ARGS__
129 #define TP_ARGS(...) __VA_ARGS__
131 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
132 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
133 void trace_##_name(_proto);
135 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
136 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
137 void trace_##_name(void);
139 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
142 * Stage 1.1 of the trace events.
144 * Create dummy trace prototypes for each event class, and for each used
145 * template. This will allow checking whether the prototypes from the
146 * class and the instance using the class actually match.
149 #include <lttng/events-reset.h> /* Reset all macros within TRACE_EVENT */
152 #define TP_PROTO(...) __VA_ARGS__
155 #define TP_ARGS(...) __VA_ARGS__
157 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
158 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
159 void __event_template_proto___##_template(_proto);
161 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
162 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
163 void __event_template_proto___##_template(void);
165 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
166 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
167 void __event_template_proto___##_name(_proto);
169 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
170 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
171 void __event_template_proto___##_name(void);
173 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
176 * Stage 1.2 of tracepoint event generation
178 * Unfolding the enums
180 #include <lttng/events-reset.h> /* Reset all macros within TRACE_EVENT */
182 /* Enumeration entry (single value) */
183 #undef ctf_enum_value
184 #define ctf_enum_value(_string, _value) \
185 lttng_kernel_static_enum_entry_value(_string, _value)
187 /* Enumeration entry (range) */
188 #undef ctf_enum_range
189 #define ctf_enum_range(_string, _range_start, _range_end) \
190 lttng_kernel_static_enum_entry_range(_string, _range_start, _range_end)
192 /* Enumeration entry (automatic value; follows the rules of CTF) */
194 #define ctf_enum_auto(_string) \
195 lttng_kernel_static_enum_entry_auto(_string)
197 #undef TP_ENUM_VALUES
198 #define TP_ENUM_VALUES(...) \
201 #ifndef LTTNG_TRACEPOINT_TYPE_EXTERN
202 # undef LTTNG_TRACEPOINT_ENUM
203 # define LTTNG_TRACEPOINT_ENUM(_name, _values) \
204 static const struct lttng_kernel_enum_entry *__enum_values__##_name[] = { \
209 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
212 * Stage 2 of the trace events.
214 * Create event field type metadata section.
215 * Each event produce an array of fields.
218 /* Reset all macros within TRACEPOINT_EVENT */
219 #include <lttng/events-reset.h>
220 #include <lttng/events-write.h>
221 #include <lttng/events-nowrite.h>
223 #undef _ctf_integer_ext
224 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
225 lttng_kernel_static_event_field(#_item, \
226 lttng_kernel_static_type_integer_from_type(_type, _byte_order, _base), \
229 #undef _ctf_array_encoded
230 #define _ctf_array_encoded(_type, _item, _src, _length, \
231 _encoding, _byte_order, _elem_type_base, _user, _nowrite) \
232 lttng_kernel_static_event_field(#_item, \
233 lttng_kernel_static_type_array(_length, \
234 lttng_kernel_static_type_integer_from_type(_type, _byte_order, _elem_type_base), \
239 #undef _ctf_array_bitfield
240 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
241 lttng_kernel_static_event_field(#_item, \
242 lttng_kernel_static_type_array((_length) * sizeof(_type) * CHAR_BIT, \
243 lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), \
244 lttng_alignof(_type), \
248 #undef _ctf_sequence_encoded
249 #define _ctf_sequence_encoded(_type, _item, _src, \
250 _length_type, _src_length, _encoding, \
251 _byte_order, _elem_type_base, _user, _nowrite) \
252 lttng_kernel_static_event_field("_" #_item "_length", \
253 lttng_kernel_static_type_integer_from_type(_length_type, __BYTE_ORDER, 10), \
255 lttng_kernel_static_event_field(#_item, \
256 lttng_kernel_static_type_sequence(NULL, /* Use previous field. */ \
257 lttng_kernel_static_type_integer_from_type(_type, _byte_order, _elem_type_base), \
262 #undef _ctf_sequence_bitfield
263 #define _ctf_sequence_bitfield(_type, _item, _src, \
264 _length_type, _src_length, \
266 lttng_kernel_static_event_field("_" #_item "_length", \
267 lttng_kernel_static_type_integer_from_type(_length_type, __BYTE_ORDER, 10), \
269 lttng_kernel_static_event_field(#_item, \
270 lttng_kernel_static_type_sequence(NULL, /* Use previous field. */ \
271 lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), \
272 lttng_alignof(_type), \
277 #define _ctf_string(_item, _src, _user, _nowrite) \
278 lttng_kernel_static_event_field(#_item, \
279 lttng_kernel_static_type_string(UTF8), \
283 #define _ctf_unused(_src)
286 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
287 lttng_kernel_static_event_field(#_item, \
288 lttng_kernel_static_type_enum(&__enum_##_name, \
289 lttng_kernel_static_type_integer_from_type(_type, __BYTE_ORDER, 10)), \
292 #undef ctf_custom_field
293 #define ctf_custom_field(_type, _item, _code) \
294 lttng_kernel_static_event_field(#_item, PARAMS(_type), 0, 0, 1),
296 #undef ctf_custom_type
297 #define ctf_custom_type(...) __VA_ARGS__
300 #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
302 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
303 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
304 static const struct lttng_kernel_event_field *__event_fields___##_name[] = { \
308 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
309 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
310 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post)
312 #ifdef LTTNG_TRACEPOINT_TYPE_EXTERN
313 # undef LTTNG_TRACEPOINT_TYPE
314 # define LTTNG_TRACEPOINT_TYPE(_prototype, _init) \
316 #elif defined (LTTNG_TRACEPOINT_TYPE_DEFINE_EXPORT)
317 # define LTTNG_TRACEPOINT_TYPE_VISIBILITY __attribute__((visibility("hidden")))
319 # define LTTNG_TRACEPOINT_TYPE_VISIBILITY static
322 #ifdef LTTNG_TRACEPOINT_TYPE_VISIBILITY
323 # undef LTTNG_TRACEPOINT_TYPE
324 # define LTTNG_TRACEPOINT_TYPE(_prototype, _init) \
325 LTTNG_TRACEPOINT_TYPE_VISIBILITY _prototype = _init;
328 # undef LTTNG_TRACEPOINT_ENUM
329 # define LTTNG_TRACEPOINT_ENUM(_name, _values) \
330 LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_enum_desc __enum_##_name), \
333 .entries = __enum_values__##_name, \
334 .nr_entries = ARRAY_SIZE(__enum_values__##_name), \
337 #define LTTNG_CREATE_FIELD_METADATA
338 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
339 #undef LTTNG_CREATE_FIELD_METADATA
341 #undef LTTNG_TRACEPOINT_TYPE_VISIBILITY
344 * Stage 3 of the trace events.
346 * Create probe callback prototypes.
349 /* Reset all macros within TRACEPOINT_EVENT */
350 #include <lttng/events-reset.h>
353 #define TP_PROTO(...) __VA_ARGS__
355 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
356 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
357 static void __event_probe__##_name(void *__data, _proto);
359 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
360 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
361 static void __event_probe__##_name(void *__data);
363 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
366 * Stage 4 of the trace events.
368 * Create static inline function that calculates event size.
371 /* Reset all macros within TRACEPOINT_EVENT */
372 #include <lttng/events-reset.h>
373 #include <lttng/events-write.h>
375 #undef _ctf_integer_ext
376 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
377 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
378 __event_len += sizeof(_type);
380 #undef _ctf_array_encoded
381 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
382 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
383 __event_len += sizeof(_type) * (_length);
385 #undef _ctf_array_bitfield
386 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
387 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
389 #undef _ctf_sequence_encoded
390 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
391 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
392 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
393 __event_len += sizeof(_length_type); \
394 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
396 size_t __seqlen = (_src_length); \
398 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
400 barrier(); /* reserve before use. */ \
401 this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = __seqlen; \
402 __event_len += sizeof(_type) * __seqlen; \
405 #undef _ctf_sequence_bitfield
406 #define _ctf_sequence_bitfield(_type, _item, _src, \
407 _length_type, _src_length, \
409 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
410 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
413 * ctf_user_string includes \0. If returns 0, it faulted, so we set size to
417 #define _ctf_string(_item, _src, _user, _nowrite) \
418 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
420 barrier(); /* reserve before use. */ \
422 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
423 max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \
425 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
426 strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1; \
430 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
431 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
434 #define ctf_align(_type) \
435 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type));
437 #undef ctf_custom_field
438 #define ctf_custom_field(_type, _item, _code) \
443 #undef ctf_custom_code
444 #define ctf_custom_code(...) __VA_ARGS__
447 #define TP_PROTO(...) __VA_ARGS__
450 #define TP_FIELDS(...) __VA_ARGS__
453 #define TP_locvar(...) __VA_ARGS__
455 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
456 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
457 static inline ssize_t __event_get_size__##_name(void *__tp_locvar, _proto) \
459 size_t __event_len = 0; \
460 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
461 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
464 return __event_len; \
467 __attribute__((unused)); \
471 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
472 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
473 static inline ssize_t __event_get_size__##_name(void *__tp_locvar) \
475 size_t __event_len = 0; \
476 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
477 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
480 return __event_len; \
483 __attribute__((unused)); \
487 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
491 * Stage 4.1 of tracepoint event generation.
493 * Create static inline function that layout the filter stack data.
494 * We make both write and nowrite data available to the filter.
497 /* Reset all macros within TRACEPOINT_EVENT */
498 #include <lttng/events-reset.h>
499 #include <lttng/events-write.h>
500 #include <lttng/events-nowrite.h>
502 #undef _ctf_integer_ext_fetched
503 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
504 if (lttng_is_signed_type(_type)) { \
505 int64_t __ctf_tmp_int64; \
506 switch (sizeof(_type)) { \
509 union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
510 __ctf_tmp_int64 = (int64_t) __tmp.v; \
515 union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
516 if (_byte_order != __BYTE_ORDER) \
517 __swab16s(&__tmp.v); \
518 __ctf_tmp_int64 = (int64_t) __tmp.v; \
523 union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
524 if (_byte_order != __BYTE_ORDER) \
525 __swab32s(&__tmp.v); \
526 __ctf_tmp_int64 = (int64_t) __tmp.v; \
531 union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
532 if (_byte_order != __BYTE_ORDER) \
533 __swab64s(&__tmp.v); \
534 __ctf_tmp_int64 = (int64_t) __tmp.v; \
540 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
542 uint64_t __ctf_tmp_uint64; \
543 switch (sizeof(_type)) { \
546 union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
547 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
552 union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
553 if (_byte_order != __BYTE_ORDER) \
554 __swab16s(&__tmp.v); \
555 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
560 union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
561 if (_byte_order != __BYTE_ORDER) \
562 __swab32s(&__tmp.v); \
563 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
568 union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
569 if (_byte_order != __BYTE_ORDER) \
570 __swab64s(&__tmp.v); \
571 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
577 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
579 __stack_data += sizeof(int64_t);
581 #undef _ctf_integer_ext_isuser0
582 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
583 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
585 #undef _ctf_integer_ext_isuser1
586 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
589 char __array[sizeof(_user_src)]; \
590 __typeof__(_user_src) __v; \
592 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
593 &(_user_src), sizeof(_user_src))) \
594 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
595 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
598 #undef _ctf_integer_ext
599 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
600 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
602 #undef _ctf_array_encoded
603 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
605 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
606 const void *__ctf_tmp_ptr = (_src); \
607 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
608 __stack_data += sizeof(unsigned long); \
609 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
610 __stack_data += sizeof(void *); \
613 #undef _ctf_array_bitfield
614 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
615 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
617 #undef _ctf_sequence_encoded
618 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
619 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
621 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
622 const void *__ctf_tmp_ptr = (_src); \
623 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
624 __stack_data += sizeof(unsigned long); \
625 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
626 __stack_data += sizeof(void *); \
629 #undef _ctf_sequence_bitfield
630 #define _ctf_sequence_bitfield(_type, _item, _src, \
631 _length_type, _src_length, \
633 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
634 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
637 #define _ctf_string(_item, _src, _user, _nowrite) \
639 const void *__ctf_tmp_ptr = \
640 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
641 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
642 __stack_data += sizeof(void *); \
646 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
647 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
650 #define TP_PROTO(...) __VA_ARGS__
653 #define TP_FIELDS(...) __VA_ARGS__
656 #define TP_locvar(...) __VA_ARGS__
658 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
659 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
661 void __event_prepare_interpreter_stack__##_name(char *__stack_data, \
664 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
669 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
670 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
672 void __event_prepare_interpreter_stack__##_name(char *__stack_data, \
673 void *__tp_locvar, _proto) \
675 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
680 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
683 * Stage 5 of the trace events.
685 * Create static inline function that calculates event payload alignment.
688 /* Reset all macros within TRACEPOINT_EVENT */
689 #include <lttng/events-reset.h>
690 #include <lttng/events-write.h>
692 #undef _ctf_integer_ext
693 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
694 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
696 #undef _ctf_array_encoded
697 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
698 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
700 #undef _ctf_array_bitfield
701 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
702 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
704 #undef _ctf_sequence_encoded
705 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
706 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
707 __event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \
708 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
710 #undef _ctf_sequence_bitfield
711 #define _ctf_sequence_bitfield(_type, _item, _src, \
712 _length_type, _src_length, \
714 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
715 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
718 #define _ctf_string(_item, _src, _user, _nowrite)
721 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
722 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
725 #define ctf_align(_type) \
726 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
729 #define TP_PROTO(...) __VA_ARGS__
732 #define TP_FIELDS(...) __VA_ARGS__
735 #define TP_locvar(...) __VA_ARGS__
737 #undef ctf_custom_field
738 #define ctf_custom_field(_type, _item, _code) _code
740 #undef ctf_custom_code
741 #define ctf_custom_code(...) \
746 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
747 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
748 static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \
750 size_t __event_align = 1; \
751 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
754 return __event_align; \
757 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
758 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
759 static inline size_t __event_get_align__##_name(void *__tp_locvar) \
761 size_t __event_align = 1; \
762 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
765 return __event_align; \
768 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
771 * Stage 6 of tracepoint event generation.
773 * Create the probe function. This function calls event size calculation
774 * and writes event data into the buffer.
777 /* Reset all macros within TRACEPOINT_EVENT */
778 #include <lttng/events-reset.h>
779 #include <lttng/events-write.h>
781 #undef _ctf_integer_ext_fetched
782 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
784 _type __tmp = _src; \
785 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
786 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
789 #undef _ctf_integer_ext_isuser0
790 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
791 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
793 #undef _ctf_integer_ext_isuser1
794 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
797 char __array[sizeof(_user_src)]; \
798 __typeof__(_user_src) __v; \
800 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
801 &(_user_src), sizeof(_user_src))) \
802 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
803 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
806 #undef _ctf_integer_ext
807 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
808 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
810 #undef _ctf_array_encoded
811 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
812 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
814 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
816 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
819 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
820 #undef _ctf_array_bitfield
821 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
822 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
824 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
826 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
828 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
830 * For big endian, we need to byteswap into little endian.
832 #undef _ctf_array_bitfield
833 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
834 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
838 for (_i = 0; _i < (_length); _i++) { \
842 if (get_user(_tmp, (_type *) _src + _i)) \
845 _tmp = ((_type *) _src)[_i]; \
847 switch (sizeof(_type)) { \
851 _tmp = cpu_to_le16(_tmp); \
854 _tmp = cpu_to_le32(_tmp); \
857 _tmp = cpu_to_le64(_tmp); \
862 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
865 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
867 #undef _ctf_sequence_encoded
868 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
869 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
871 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx]; \
872 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
873 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
875 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
877 __chan->ops->event_write_from_user(&__ctx, _src, \
878 sizeof(_type) * __get_dynamic_len(dest)); \
880 __chan->ops->event_write(&__ctx, _src, \
881 sizeof(_type) * __get_dynamic_len(dest)); \
884 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
885 #undef _ctf_sequence_bitfield
886 #define _ctf_sequence_bitfield(_type, _item, _src, \
887 _length_type, _src_length, \
890 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
891 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
892 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
894 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
896 __chan->ops->event_write_from_user(&__ctx, _src, \
897 sizeof(_type) * __get_dynamic_len(dest)); \
899 __chan->ops->event_write(&__ctx, _src, \
900 sizeof(_type) * __get_dynamic_len(dest)); \
902 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
904 * For big endian, we need to byteswap into little endian.
906 #undef _ctf_sequence_bitfield
907 #define _ctf_sequence_bitfield(_type, _item, _src, \
908 _length_type, _src_length, \
911 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
912 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
913 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
915 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
917 size_t _i, _length; \
919 _length = __get_dynamic_len(dest); \
920 for (_i = 0; _i < _length; _i++) { \
924 if (get_user(_tmp, (_type *) _src + _i)) \
927 _tmp = ((_type *) _src)[_i]; \
929 switch (sizeof(_type)) { \
933 _tmp = cpu_to_le16(_tmp); \
936 _tmp = cpu_to_le32(_tmp); \
939 _tmp = cpu_to_le64(_tmp); \
944 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
947 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
950 #define _ctf_string(_item, _src, _user, _nowrite) \
952 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
953 __chan->ops->event_strcpy_from_user(&__ctx, _src, \
954 __get_dynamic_len(dest)); \
956 const char *__ctf_tmp_string = \
957 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
958 lib_ring_buffer_align_ctx(&__ctx, \
959 lttng_alignof(*__ctf_tmp_string)); \
960 __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
961 __get_dynamic_len(dest)); \
965 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
966 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
969 #define ctf_align(_type) \
970 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));
972 #undef ctf_custom_field
973 #define ctf_custom_field(_type, _item, _code) _code
975 #undef ctf_custom_code
976 #define ctf_custom_code(...) \
981 /* Beware: this get len actually consumes the len value */
982 #undef __get_dynamic_len
983 #define __get_dynamic_len(field) this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx++]
986 #define TP_PROTO(...) __VA_ARGS__
989 #define TP_ARGS(...) __VA_ARGS__
992 #define TP_FIELDS(...) __VA_ARGS__
995 #define TP_locvar(...) __VA_ARGS__
998 #define TP_code_pre(...) __VA_ARGS__
1001 #define TP_code_post(...) __VA_ARGS__
1004 * For state dump, check that "session" argument (mandatory) matches the
1005 * session this event belongs to. Ensures that we write state dump data only
1006 * into the started session, not into all sessions.
1008 #ifdef TP_SESSION_CHECK
1009 #define _TP_SESSION_CHECK(session, csession) (session == csession)
1010 #else /* TP_SESSION_CHECK */
1011 #define _TP_SESSION_CHECK(session, csession) 1
1012 #endif /* TP_SESSION_CHECK */
1015 * Using twice size for filter stack data to hold size and pointer for
1016 * each field (worse case). For integers, max size required is 64-bit.
1017 * Same for double-precision floats. Those fit within
1018 * 2*sizeof(unsigned long) for all supported architectures.
1019 * Perform UNION (||) of filter runtime list.
1021 #undef _LTTNG_TRACEPOINT_EVENT_CLASS_CODE
1022 #define _LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _data_proto, _locvar_args, _locvar, _code_pre, _fields, _code_post) \
1023 static void __event_probe__##_name(_data_proto) \
1025 struct probe_local_vars { _locvar }; \
1026 struct lttng_kernel_event_common *__event = __data; \
1027 struct lttng_kernel_probe_ctx __lttng_probe_ctx = { \
1029 .interruptible = !irqs_disabled(), \
1032 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1033 char __interpreter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1035 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1036 struct probe_local_vars __tp_locvar; \
1037 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1039 bool __interpreter_stack_prepared = false; \
1041 switch (__event->type) { \
1042 case LTTNG_KERNEL_EVENT_TYPE_RECORDER: \
1044 struct lttng_kernel_event_recorder *__event_recorder = \
1045 container_of(__event, struct lttng_kernel_event_recorder, parent); \
1046 struct lttng_channel *__chan = __event_recorder->chan; \
1047 struct lttng_kernel_session *__session = __chan->session; \
1048 struct lttng_kernel_id_tracker_rcu *__lf; \
1050 if (!_TP_SESSION_CHECK(session, __session)) \
1052 if (unlikely(!LTTNG_READ_ONCE(__session->active))) \
1054 if (unlikely(!LTTNG_READ_ONCE(__chan->enabled))) \
1056 __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
1057 if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
1059 __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
1060 if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
1062 __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
1063 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1064 lttng_current_uid()))) \
1066 __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
1067 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1068 lttng_current_vuid()))) \
1070 __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
1071 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1072 lttng_current_gid()))) \
1074 __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
1075 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1076 lttng_current_vgid()))) \
1080 case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER: \
1085 if (unlikely(!READ_ONCE(__event->enabled))) \
1087 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1088 __dynamic_len_idx = __orig_dynamic_len_offset; \
1090 if (unlikely(READ_ONCE(__event->eval_filter))) { \
1091 __event_prepare_interpreter_stack__##_name(__stackvar.__interpreter_stack_data, \
1093 __interpreter_stack_prepared = true; \
1094 if (likely(__event->run_filter(__event, \
1095 __stackvar.__interpreter_stack_data, &__lttng_probe_ctx, NULL) != LTTNG_KERNEL_EVENT_FILTER_ACCEPT)) \
1098 switch (__event->type) { \
1099 case LTTNG_KERNEL_EVENT_TYPE_RECORDER: \
1101 struct lttng_kernel_event_recorder *__event_recorder = \
1102 container_of(__event, struct lttng_kernel_event_recorder, parent); \
1103 struct lttng_channel *__chan = __event_recorder->chan; \
1104 struct lttng_kernel_ring_buffer_ctx __ctx; \
1105 ssize_t __event_len; \
1106 size_t __event_align; \
1109 __event_len = __event_get_size__##_name(_locvar_args); \
1110 if (unlikely(__event_len < 0)) { \
1111 lib_ring_buffer_lost_event_too_big(__chan->chan); \
1114 __event_align = __event_get_align__##_name(_locvar_args); \
1115 lib_ring_buffer_ctx_init(&__ctx, __event_recorder, __event_len, \
1116 __event_align, &__lttng_probe_ctx); \
1117 __ret = __chan->ops->event_reserve(&__ctx); \
1121 __chan->ops->event_commit(&__ctx); \
1124 case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER: \
1126 struct lttng_kernel_event_notifier *__event_notifier = \
1127 container_of(__event, struct lttng_kernel_event_notifier, parent); \
1128 struct lttng_kernel_notification_ctx __notif_ctx; \
1130 __notif_ctx.eval_capture = LTTNG_READ_ONCE(__event_notifier->eval_capture); \
1131 if (unlikely(!__interpreter_stack_prepared && __notif_ctx.eval_capture)) \
1132 __event_prepare_interpreter_stack__##_name( \
1133 __stackvar.__interpreter_stack_data, \
1136 __event_notifier->notification_send(__event_notifier, \
1137 __stackvar.__interpreter_stack_data, \
1138 &__lttng_probe_ctx, \
1147 barrier(); /* use before un-reserve. */ \
1148 this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \
1152 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
1153 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
1154 _LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(void *__data, _proto), PARAMS(tp_locvar, _args), \
1155 PARAMS(_locvar), PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
1157 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
1158 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
1159 _LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(void *__data), PARAMS(tp_locvar), PARAMS(_locvar), \
1160 PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
1162 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1164 #undef __get_dynamic_len
1167 * Stage 7.0 of tracepoint event generation.
1169 * Declare toplevel descriptor for the whole probe.
1172 #define TP_ID1(_token, _system) _token##_system
1173 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1175 static __used
struct lttng_kernel_probe_desc
TP_ID(__probe_desc___
, TRACE_SYSTEM
);
1181 * Stage 7.1 of the trace events.
1183 * Create event descriptions.
1186 /* Named field types must be defined in lttng-types.h */
1188 #include <lttng/events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1191 #define TP_PROBE_CB(_template) &__event_probe__##_template
1194 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1195 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1196 static const struct lttng_kernel_event_desc __event_desc___##_map = { \
1197 .event_name = #_map, \
1198 .event_kname = #_name, \
1199 .probe_desc = &TP_ID(__probe_desc___, TRACE_SYSTEM), \
1200 .probe_callback = (void (*)(void)) TP_PROBE_CB(_template), \
1201 .fields = __event_fields___##_template, \
1202 .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
1203 .owner = THIS_MODULE, \
1206 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1207 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1208 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1210 #define TP_ID1(_token, _system) _token##_system
1211 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1213 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1219 * Stage 8 of the trace events.
1221 * Create an array of event description pointers.
1224 #include <lttng/events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1226 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1227 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1228 &__event_desc___##_map,
1230 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1231 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1232 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1234 #define TP_ID1(_token, _system) _token##_system
1235 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1237 static const struct lttng_kernel_event_desc
*TP_ID(__event_desc___
, TRACE_SYSTEM
)[] = {
1238 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1245 * Stage 9 of the trace events.
1247 * Create a toplevel descriptor for the whole probe.
1250 #define TP_ID1(_token, _system) _token##_system
1251 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1253 /* non-const because list head will be modified when registered. */
1254 static __used
struct lttng_kernel_probe_desc
TP_ID(__probe_desc___
, TRACE_SYSTEM
) = {
1255 .provider_name
= __stringify(TRACE_SYSTEM
),
1256 .event_desc
= TP_ID(__event_desc___
, TRACE_SYSTEM
),
1257 .nr_events
= ARRAY_SIZE(TP_ID(__event_desc___
, TRACE_SYSTEM
)),
1258 .head
= { NULL
, NULL
},
1259 .lazy_init_head
= { NULL
, NULL
},
1267 * Stage 10 of the trace events.
1269 * Register/unregister probes at module load/unload.
1272 #include <lttng/events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1274 #define TP_ID1(_token, _system) _token##_system
1275 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1276 #define module_init_eval1(_token, _system) module_init(_token##_system)
1277 #define module_init_eval(_token, _system) module_init_eval1(_token, _system)
1278 #define module_exit_eval1(_token, _system) module_exit(_token##_system)
1279 #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system)
1281 #ifndef TP_MODULE_NOINIT
1282 static int TP_ID(__lttng_events_init__
, TRACE_SYSTEM
)(void)
1284 wrapper_vmalloc_sync_mappings();
1285 return lttng_kernel_probe_register(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1288 static void TP_ID(__lttng_events_exit__
, TRACE_SYSTEM
)(void)
1290 lttng_kernel_probe_unregister(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1293 #ifndef TP_MODULE_NOAUTOLOAD
1294 module_init_eval(__lttng_events_init__
, TRACE_SYSTEM
);
1295 module_exit_eval(__lttng_events_exit__
, TRACE_SYSTEM
);
1300 #undef module_init_eval
1301 #undef module_exit_eval
This page took 0.108737 seconds and 4 git commands to generate.