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 * const __enum_values__##_name[] = { \
209 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
212 * Stage 1.3 of the trace events.
214 * Create probe callback prototypes.
217 /* Reset all macros within TRACEPOINT_EVENT */
218 #include <lttng/events-reset.h>
221 #define TP_PROTO(...) __VA_ARGS__
223 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
224 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
225 static void __event_probe__##_name(void *__data, _proto);
227 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
228 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
229 static void __event_probe__##_name(void *__data);
231 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
234 * Stage 1.4 of tracepoint event generation.
236 * Declare toplevel descriptor for the whole probe.
239 #define TP_ID1(_token, _system) _token##_system
240 #define TP_ID(_token, _system) TP_ID1(_token, _system)
242 static __used
struct lttng_kernel_probe_desc
TP_ID(__probe_desc___
, TRACE_SYSTEM
);
248 * Stage 2 of the trace events.
250 * Create event field type metadata section.
251 * Each event produce an array of fields.
254 /* Reset all macros within TRACEPOINT_EVENT */
255 #include <lttng/events-reset.h>
256 #include <lttng/events-write.h>
257 #include <lttng/events-nowrite.h>
259 #undef _ctf_integer_ext
260 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
261 lttng_kernel_static_event_field(#_item, \
262 _lttng_kernel_static_type_integer_from_type(_type, _byte_order, _user, _base), \
265 #undef _ctf_array_encoded
266 #define _ctf_array_encoded(_type, _item, _src, _length, \
267 _encoding, _byte_order, _elem_type_base, _user, _nowrite) \
268 lttng_kernel_static_event_field(#_item, \
269 lttng_kernel_static_type_array(_length, \
270 _lttng_kernel_static_type_integer_from_type(_type, _byte_order, _user, _elem_type_base), \
275 #undef _ctf_array_bitfield
276 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
277 lttng_kernel_static_event_field(#_item, \
278 lttng_kernel_static_type_array((_length) * sizeof(_type) * CHAR_BIT, \
279 _lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, _user, 10), \
280 lttng_alignof(_type), \
284 #undef _ctf_sequence_encoded
285 #define _ctf_sequence_encoded(_type, _item, _src, \
286 _length_type, _src_length, _encoding, \
287 _byte_order, _elem_type_base, _user, _nowrite) \
288 lttng_kernel_static_event_field("_" #_item "_length", \
289 lttng_kernel_static_type_integer_from_type(_length_type, __BYTE_ORDER, 10), \
291 lttng_kernel_static_event_field(#_item, \
292 lttng_kernel_static_type_sequence(NULL, /* Use previous field. */ \
293 _lttng_kernel_static_type_integer_from_type(_type, _byte_order, _user, _elem_type_base), \
298 #undef _ctf_sequence_bitfield
299 #define _ctf_sequence_bitfield(_type, _item, _src, \
300 _length_type, _src_length, \
302 lttng_kernel_static_event_field("_" #_item "_length", \
303 lttng_kernel_static_type_integer_from_type(_length_type, __BYTE_ORDER, 10), \
305 lttng_kernel_static_event_field(#_item, \
306 lttng_kernel_static_type_sequence(NULL, /* Use previous field. */ \
307 _lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, _user, 10), \
308 lttng_alignof(_type), \
313 #define _ctf_string(_item, _src, _user, _nowrite) \
314 lttng_kernel_static_event_field(#_item, \
315 lttng_kernel_static_type_string(UTF8, _user), \
319 #define _ctf_unused(_src)
322 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
323 lttng_kernel_static_event_field(#_item, \
324 lttng_kernel_static_type_enum(&__enum_##_name, \
325 _lttng_kernel_static_type_integer_from_type(_type, __BYTE_ORDER, _user, 10)), \
328 #undef ctf_custom_field
329 #define ctf_custom_field(_type, _item, _code) \
330 lttng_kernel_static_event_field(#_item, PARAMS(_type), 0, 1),
332 #undef ctf_custom_type
333 #define ctf_custom_type(...) __VA_ARGS__
336 #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
339 #define TP_PROBE_CB(_template) &__event_probe__##_template
342 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
343 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
344 static const struct lttng_kernel_event_field * const __event_fields___##_name[] = { \
347 static const struct lttng_kernel_tracepoint_class lttng_kernel__event_class___##_name = { \
348 .fields = __event_fields___##_name, \
349 .nr_fields = ARRAY_SIZE(__event_fields___##_name), \
350 .probe_callback = (void (*)(void)) TP_PROBE_CB(_name), \
351 .probe_desc = &TP_ID(__probe_desc___, TRACE_SYSTEM), \
354 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
355 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
356 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post)
358 #ifdef LTTNG_TRACEPOINT_TYPE_EXTERN
359 # undef LTTNG_TRACEPOINT_TYPE
360 # define LTTNG_TRACEPOINT_TYPE(_prototype, _init) \
362 #elif defined (LTTNG_TRACEPOINT_TYPE_DEFINE_EXPORT)
363 # define LTTNG_TRACEPOINT_TYPE_VISIBILITY __attribute__((visibility("hidden")))
365 # define LTTNG_TRACEPOINT_TYPE_VISIBILITY static
368 #ifdef LTTNG_TRACEPOINT_TYPE_VISIBILITY
369 # undef LTTNG_TRACEPOINT_TYPE
370 # define LTTNG_TRACEPOINT_TYPE(_prototype, _init) \
371 LTTNG_TRACEPOINT_TYPE_VISIBILITY _prototype = _init;
374 # undef LTTNG_TRACEPOINT_ENUM
375 # define LTTNG_TRACEPOINT_ENUM(_name, _values) \
376 LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_enum_desc __enum_##_name), \
379 .entries = __enum_values__##_name, \
380 .nr_entries = ARRAY_SIZE(__enum_values__##_name), \
381 .probe_desc = &TP_ID(__probe_desc___, TRACE_SYSTEM), \
384 #define TP_ID1(_token, _system) _token##_system
385 #define TP_ID(_token, _system) TP_ID1(_token, _system)
387 #define LTTNG_CREATE_FIELD_METADATA
388 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
389 #undef LTTNG_CREATE_FIELD_METADATA
391 #undef LTTNG_TRACEPOINT_TYPE_VISIBILITY
397 * Stage 4 of the trace events.
399 * Create static inline function that calculates event size.
402 /* Reset all macros within TRACEPOINT_EVENT */
403 #include <lttng/events-reset.h>
404 #include <lttng/events-write.h>
406 #undef _ctf_integer_ext
407 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
408 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
409 __event_len += sizeof(_type);
411 #undef _ctf_array_encoded
412 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
413 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
414 __event_len += sizeof(_type) * (_length);
416 #undef _ctf_array_bitfield
417 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
418 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
420 #undef _ctf_sequence_encoded
421 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
422 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
423 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
424 __event_len += sizeof(_length_type); \
425 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
427 size_t __seqlen = (_src_length); \
429 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
431 barrier(); /* reserve before use. */ \
432 this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = __seqlen; \
433 __event_len += sizeof(_type) * __seqlen; \
436 #undef _ctf_sequence_bitfield
437 #define _ctf_sequence_bitfield(_type, _item, _src, \
438 _length_type, _src_length, \
440 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
441 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
444 * ctf_user_string includes \0. If returns 0, it faulted, so we set size to
448 #define _ctf_string(_item, _src, _user, _nowrite) \
449 if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \
451 barrier(); /* reserve before use. */ \
453 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
454 max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \
456 __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \
457 strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1; \
461 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
462 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
465 #define ctf_align(_type) \
466 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type));
468 #undef ctf_custom_field
469 #define ctf_custom_field(_type, _item, _code) \
474 #undef ctf_custom_code
475 #define ctf_custom_code(...) __VA_ARGS__
478 #define TP_PROTO(...) __VA_ARGS__
481 #define TP_FIELDS(...) __VA_ARGS__
484 #define TP_locvar(...) __VA_ARGS__
486 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
487 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
488 static inline ssize_t __event_get_size__##_name(void *__tp_locvar, _proto) \
490 size_t __event_len = 0; \
491 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
492 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
495 return __event_len; \
498 __attribute__((unused)); \
502 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
503 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
504 static inline ssize_t __event_get_size__##_name(void *__tp_locvar) \
506 size_t __event_len = 0; \
507 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
508 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
511 return __event_len; \
514 __attribute__((unused)); \
518 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
522 * Stage 4.1 of tracepoint event generation.
524 * Create static inline function that layout the filter stack data.
525 * We make both write and nowrite data available to the filter.
528 /* Reset all macros within TRACEPOINT_EVENT */
529 #include <lttng/events-reset.h>
530 #include <lttng/events-write.h>
531 #include <lttng/events-nowrite.h>
533 #undef _ctf_integer_ext_fetched
534 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
535 if (lttng_is_signed_type(_type)) { \
536 int64_t __ctf_tmp_int64; \
537 switch (sizeof(_type)) { \
540 union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
541 __ctf_tmp_int64 = (int64_t) __tmp.v; \
546 union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
547 if (_byte_order != __BYTE_ORDER) \
548 __swab16s(&__tmp.v); \
549 __ctf_tmp_int64 = (int64_t) __tmp.v; \
554 union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
555 if (_byte_order != __BYTE_ORDER) \
556 __swab32s(&__tmp.v); \
557 __ctf_tmp_int64 = (int64_t) __tmp.v; \
562 union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
563 if (_byte_order != __BYTE_ORDER) \
564 __swab64s(&__tmp.v); \
565 __ctf_tmp_int64 = (int64_t) __tmp.v; \
571 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
573 uint64_t __ctf_tmp_uint64; \
574 switch (sizeof(_type)) { \
577 union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
578 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
583 union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
584 if (_byte_order != __BYTE_ORDER) \
585 __swab16s(&__tmp.v); \
586 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
591 union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
592 if (_byte_order != __BYTE_ORDER) \
593 __swab32s(&__tmp.v); \
594 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
599 union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
600 if (_byte_order != __BYTE_ORDER) \
601 __swab64s(&__tmp.v); \
602 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
608 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
610 __stack_data += sizeof(int64_t);
612 #undef _ctf_integer_ext_isuser0
613 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
614 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
616 #undef _ctf_integer_ext_isuser1
617 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
620 char __array[sizeof(_user_src)]; \
621 __typeof__(_user_src) __v; \
623 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
624 &(_user_src), sizeof(_user_src))) \
625 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
626 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
629 #undef _ctf_integer_ext
630 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
631 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
633 #undef _ctf_array_encoded
634 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
636 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
637 const void *__ctf_tmp_ptr = (_src); \
638 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
639 __stack_data += sizeof(unsigned long); \
640 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
641 __stack_data += sizeof(void *); \
644 #undef _ctf_array_bitfield
645 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
646 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
648 #undef _ctf_sequence_encoded
649 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
650 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
652 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
653 const void *__ctf_tmp_ptr = (_src); \
654 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
655 __stack_data += sizeof(unsigned long); \
656 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
657 __stack_data += sizeof(void *); \
660 #undef _ctf_sequence_bitfield
661 #define _ctf_sequence_bitfield(_type, _item, _src, \
662 _length_type, _src_length, \
664 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
665 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
668 #define _ctf_string(_item, _src, _user, _nowrite) \
670 const void *__ctf_tmp_ptr = \
671 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
672 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
673 __stack_data += sizeof(void *); \
677 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
678 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
681 #define TP_PROTO(...) __VA_ARGS__
684 #define TP_FIELDS(...) __VA_ARGS__
687 #define TP_locvar(...) __VA_ARGS__
689 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
690 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
692 void __event_prepare_interpreter_stack__##_name(char *__stack_data, \
695 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
700 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
701 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
703 void __event_prepare_interpreter_stack__##_name(char *__stack_data, \
704 void *__tp_locvar, _proto) \
706 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
711 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
714 * Stage 5 of the trace events.
716 * Create static inline function that calculates event payload alignment.
719 /* Reset all macros within TRACEPOINT_EVENT */
720 #include <lttng/events-reset.h>
721 #include <lttng/events-write.h>
723 #undef _ctf_integer_ext
724 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
725 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
727 #undef _ctf_array_encoded
728 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
729 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
731 #undef _ctf_array_bitfield
732 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
733 _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
735 #undef _ctf_sequence_encoded
736 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
737 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
738 __event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \
739 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
741 #undef _ctf_sequence_bitfield
742 #define _ctf_sequence_bitfield(_type, _item, _src, \
743 _length_type, _src_length, \
745 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
746 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
749 #define _ctf_string(_item, _src, _user, _nowrite)
752 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
753 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
756 #define ctf_align(_type) \
757 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
760 #define TP_PROTO(...) __VA_ARGS__
763 #define TP_FIELDS(...) __VA_ARGS__
766 #define TP_locvar(...) __VA_ARGS__
768 #undef ctf_custom_field
769 #define ctf_custom_field(_type, _item, _code) _code
771 #undef ctf_custom_code
772 #define ctf_custom_code(...) \
777 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
778 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
779 static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \
781 size_t __event_align = 1; \
782 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
785 return __event_align; \
788 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
789 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
790 static inline size_t __event_get_align__##_name(void *__tp_locvar) \
792 size_t __event_align = 1; \
793 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
796 return __event_align; \
799 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
802 * Stage 6 of tracepoint event generation.
804 * Create the probe function. This function calls event size calculation
805 * and writes event data into the buffer.
808 /* Reset all macros within TRACEPOINT_EVENT */
809 #include <lttng/events-reset.h>
810 #include <lttng/events-write.h>
812 #undef _ctf_integer_ext_fetched
813 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
815 _type __tmp = _src; \
816 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp), lttng_alignof(__tmp)); \
819 #undef _ctf_integer_ext_isuser0
820 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
821 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
823 #undef _ctf_integer_ext_isuser1
824 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
827 char __array[sizeof(_user_src)]; \
828 __typeof__(_user_src) __v; \
830 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
831 &(_user_src), sizeof(_user_src))) \
832 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
833 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
836 #undef _ctf_integer_ext
837 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
838 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
840 #undef _ctf_array_encoded
841 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
842 if (lttng_kernel_string_encoding_##_encoding == lttng_kernel_string_encoding_none) { \
844 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \
846 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \
850 __chan->ops->event_pstrcpy_pad_from_user(&__ctx, (const char __user *) (_src), _length); \
852 __chan->ops->event_pstrcpy_pad(&__ctx, (const char *) (_src), _length); \
856 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
857 #undef _ctf_array_bitfield
858 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
860 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \
862 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \
864 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
866 * For big endian, we need to byteswap into little endian.
868 #undef _ctf_array_bitfield
869 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
870 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
874 for (_i = 0; _i < (_length); _i++) { \
878 if (get_user(_tmp, (_type *) _src + _i)) \
881 _tmp = ((_type *) _src)[_i]; \
883 switch (sizeof(_type)) { \
887 _tmp = cpu_to_le16(_tmp); \
890 _tmp = cpu_to_le32(_tmp); \
893 _tmp = cpu_to_le64(_tmp); \
898 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type), 1); \
901 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
903 #undef _ctf_sequence_encoded
904 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
905 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
907 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx]; \
908 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type), lttng_alignof(_length_type));\
910 if (lttng_kernel_string_encoding_##_encoding == lttng_kernel_string_encoding_none) { \
912 __chan->ops->event_write_from_user(&__ctx, _src, \
913 sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \
915 __chan->ops->event_write(&__ctx, _src, \
916 sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \
920 __chan->ops->event_pstrcpy_pad_from_user(&__ctx, (const char __user *) (_src), \
921 __get_dynamic_len(dest)); \
923 __chan->ops->event_pstrcpy_pad(&__ctx, (const char *) (_src), \
924 __get_dynamic_len(dest)); \
928 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
929 #undef _ctf_sequence_bitfield
930 #define _ctf_sequence_bitfield(_type, _item, _src, \
931 _length_type, _src_length, \
934 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
935 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type), lttng_alignof(_length_type)); \
938 __chan->ops->event_write_from_user(&__ctx, _src, \
939 sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \
941 __chan->ops->event_write(&__ctx, _src, \
942 sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \
944 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
946 * For big endian, we need to byteswap into little endian.
948 #undef _ctf_sequence_bitfield
949 #define _ctf_sequence_bitfield(_type, _item, _src, \
950 _length_type, _src_length, \
953 _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
954 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type), lttng_alignof(_length_type)); \
956 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
958 size_t _i, _length; \
960 _length = __get_dynamic_len(dest); \
961 for (_i = 0; _i < _length; _i++) { \
965 if (get_user(_tmp, (_type *) _src + _i)) \
968 _tmp = ((_type *) _src)[_i]; \
970 switch (sizeof(_type)) { \
974 _tmp = cpu_to_le16(_tmp); \
977 _tmp = cpu_to_le32(_tmp); \
980 _tmp = cpu_to_le64(_tmp); \
985 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type), 1); \
988 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
991 #define _ctf_string(_item, _src, _user, _nowrite) \
993 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
994 __chan->ops->event_strcpy_from_user(&__ctx, _src, \
995 __get_dynamic_len(dest)); \
997 const char *__ctf_tmp_string = \
998 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
999 lib_ring_buffer_align_ctx(&__ctx, \
1000 lttng_alignof(*__ctf_tmp_string)); \
1001 __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
1002 __get_dynamic_len(dest)); \
1006 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \
1007 _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite)
1010 #define ctf_align(_type) \
1011 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));
1013 #undef ctf_custom_field
1014 #define ctf_custom_field(_type, _item, _code) _code
1016 #undef ctf_custom_code
1017 #define ctf_custom_code(...) \
1022 /* Beware: this get len actually consumes the len value */
1023 #undef __get_dynamic_len
1024 #define __get_dynamic_len(field) this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx++]
1027 #define TP_PROTO(...) __VA_ARGS__
1030 #define TP_ARGS(...) __VA_ARGS__
1033 #define TP_FIELDS(...) __VA_ARGS__
1036 #define TP_locvar(...) __VA_ARGS__
1039 #define TP_code_pre(...) __VA_ARGS__
1042 #define TP_code_post(...) __VA_ARGS__
1045 * For state dump, check that "session" argument (mandatory) matches the
1046 * session this event belongs to. Ensures that we write state dump data only
1047 * into the started session, not into all sessions.
1049 #ifdef TP_SESSION_CHECK
1050 #define _TP_SESSION_CHECK(session, csession) (session == csession)
1051 #else /* TP_SESSION_CHECK */
1052 #define _TP_SESSION_CHECK(session, csession) 1
1053 #endif /* TP_SESSION_CHECK */
1056 * Using twice size for filter stack data to hold size and pointer for
1057 * each field (worse case). For integers, max size required is 64-bit.
1058 * Same for double-precision floats. Those fit within
1059 * 2*sizeof(unsigned long) for all supported architectures.
1060 * Perform UNION (||) of filter runtime list.
1062 #undef _LTTNG_TRACEPOINT_EVENT_CLASS_CODE
1063 #define _LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _data_proto, _locvar_args, _locvar, _code_pre, _fields, _code_post) \
1064 static void __event_probe__##_name(_data_proto) \
1066 struct probe_local_vars { _locvar }; \
1067 struct lttng_kernel_event_common *__event = __data; \
1068 struct lttng_kernel_probe_ctx __lttng_probe_ctx = { \
1070 .interruptible = !irqs_disabled(), \
1073 size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \
1074 char __interpreter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1076 size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \
1077 struct probe_local_vars __tp_locvar; \
1078 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1080 bool __interpreter_stack_prepared = false; \
1082 switch (__event->type) { \
1083 case LTTNG_KERNEL_EVENT_TYPE_RECORDER: \
1085 struct lttng_kernel_event_recorder *__event_recorder = \
1086 container_of(__event, struct lttng_kernel_event_recorder, parent); \
1087 struct lttng_kernel_channel_buffer *__chan = __event_recorder->chan; \
1088 struct lttng_kernel_session *__session = __chan->parent.session; \
1089 struct lttng_kernel_id_tracker_rcu *__lf; \
1091 if (!_TP_SESSION_CHECK(session, __session)) \
1093 if (unlikely(!LTTNG_READ_ONCE(__session->active))) \
1095 if (unlikely(!LTTNG_READ_ONCE(__chan->parent.enabled))) \
1097 __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
1098 if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
1100 __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
1101 if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
1103 __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
1104 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1105 lttng_current_uid()))) \
1107 __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
1108 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1109 lttng_current_vuid()))) \
1111 __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
1112 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1113 lttng_current_gid()))) \
1115 __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
1116 if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
1117 lttng_current_vgid()))) \
1121 case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER: \
1126 if (unlikely(!READ_ONCE(__event->enabled))) \
1128 __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
1129 __dynamic_len_idx = __orig_dynamic_len_offset; \
1131 if (unlikely(READ_ONCE(__event->eval_filter))) { \
1132 __event_prepare_interpreter_stack__##_name(__stackvar.__interpreter_stack_data, \
1134 __interpreter_stack_prepared = true; \
1135 if (likely(__event->run_filter(__event, \
1136 __stackvar.__interpreter_stack_data, &__lttng_probe_ctx, NULL) != LTTNG_KERNEL_EVENT_FILTER_ACCEPT)) \
1139 switch (__event->type) { \
1140 case LTTNG_KERNEL_EVENT_TYPE_RECORDER: \
1142 struct lttng_kernel_event_recorder *__event_recorder = \
1143 container_of(__event, struct lttng_kernel_event_recorder, parent); \
1144 struct lttng_kernel_channel_buffer *__chan = __event_recorder->chan; \
1145 struct lttng_kernel_ring_buffer_ctx __ctx; \
1146 ssize_t __event_len; \
1147 size_t __event_align; \
1150 __event_len = __event_get_size__##_name(_locvar_args); \
1151 if (unlikely(__event_len < 0)) { \
1152 __chan->ops->lost_event_too_big(__chan); \
1155 __event_align = __event_get_align__##_name(_locvar_args); \
1156 lib_ring_buffer_ctx_init(&__ctx, __event_recorder, __event_len, \
1157 __event_align, &__lttng_probe_ctx); \
1158 __ret = __chan->ops->event_reserve(&__ctx); \
1162 __chan->ops->event_commit(&__ctx); \
1165 case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER: \
1167 struct lttng_kernel_event_notifier *__event_notifier = \
1168 container_of(__event, struct lttng_kernel_event_notifier, parent); \
1169 struct lttng_kernel_notification_ctx __notif_ctx; \
1171 __notif_ctx.eval_capture = LTTNG_READ_ONCE(__event_notifier->eval_capture); \
1172 if (unlikely(!__interpreter_stack_prepared && __notif_ctx.eval_capture)) \
1173 __event_prepare_interpreter_stack__##_name( \
1174 __stackvar.__interpreter_stack_data, \
1177 __event_notifier->notification_send(__event_notifier, \
1178 __stackvar.__interpreter_stack_data, \
1179 &__lttng_probe_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
1194 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
1195 _LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(void *__data, _proto), PARAMS(tp_locvar, _args), \
1196 PARAMS(_locvar), PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
1198 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
1199 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
1200 _LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(void *__data), PARAMS(tp_locvar), PARAMS(_locvar), \
1201 PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
1203 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1205 #undef __get_dynamic_len
1208 * Stage 7.1 of the trace events.
1210 * Create event descriptions.
1213 /* Named field types must be defined in lttng-types.h */
1215 #include <lttng/events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1217 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1218 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1219 static const struct lttng_kernel_event_desc __event_desc___##_map = { \
1220 .event_name = #_map, \
1221 .event_kname = #_name, \
1222 .tp_class = <tng_kernel__event_class___##_template, \
1223 .probe_desc = &TP_ID(__probe_desc___, TRACE_SYSTEM), \
1224 .owner = THIS_MODULE, \
1227 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1228 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1229 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1231 #define TP_ID1(_token, _system) _token##_system
1232 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1234 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1240 * Stage 8 of the trace events.
1242 * Create an array of event description pointers.
1245 #include <lttng/events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1247 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1248 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1249 &__event_desc___##_map,
1251 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1252 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1253 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1255 #define TP_ID1(_token, _system) _token##_system
1256 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1258 static const struct lttng_kernel_event_desc
* const TP_ID(__provider_event_desc___
, TRACE_SYSTEM
)[] = {
1259 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1266 * Stage 9 of the trace events.
1268 * Create a toplevel descriptor for the whole probe.
1271 #define TP_ID1(_token, _system) _token##_system
1272 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1274 /* non-const because list head will be modified when registered. */
1275 static __used
struct lttng_kernel_probe_desc
TP_ID(__probe_desc___
, TRACE_SYSTEM
) = {
1276 .provider_name
= __stringify(TRACE_SYSTEM
),
1277 .event_desc
= TP_ID(__provider_event_desc___
, TRACE_SYSTEM
),
1278 .nr_events
= ARRAY_SIZE(TP_ID(__provider_event_desc___
, TRACE_SYSTEM
)),
1279 .head
= { NULL
, NULL
},
1280 .lazy_init_head
= { NULL
, NULL
},
1288 * Stage 10 of the trace events.
1290 * Register/unregister probes at module load/unload.
1293 #include <lttng/events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1295 #define TP_ID1(_token, _system) _token##_system
1296 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1297 #define module_init_eval1(_token, _system) module_init(_token##_system)
1298 #define module_init_eval(_token, _system) module_init_eval1(_token, _system)
1299 #define module_exit_eval1(_token, _system) module_exit(_token##_system)
1300 #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system)
1302 #ifndef TP_MODULE_NOINIT
1303 static int TP_ID(__lttng_events_init__
, TRACE_SYSTEM
)(void)
1305 wrapper_vmalloc_sync_mappings();
1306 return lttng_kernel_probe_register(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1309 static void TP_ID(__lttng_events_exit__
, TRACE_SYSTEM
)(void)
1311 lttng_kernel_probe_unregister(&TP_ID(__probe_desc___
, TRACE_SYSTEM
));
1314 #ifndef TP_MODULE_NOAUTOLOAD
1315 module_init_eval(__lttng_events_init__
, TRACE_SYSTEM
);
1316 module_exit_eval(__lttng_events_exit__
, TRACE_SYSTEM
);
1321 #undef module_init_eval
1322 #undef module_exit_eval
This page took 0.0571970000000001 seconds and 4 git commands to generate.