Revert "Documentation: lttng-modules 2.8 supports Linux < 4.10"
[lttng-modules.git] / probes / lttng-tracepoint-event-impl.h
1 /*
2 * lttng-tracepoint-event-impl.h
3 *
4 * Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org>
5 * Copyright (C) 2009-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 *
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.
11 *
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.
16 *
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
20 */
21
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>
27
28 #include <probes/lttng.h>
29 #include <probes/lttng-types.h>
30 #include <probes/lttng-probe-user.h>
31 #include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
32 #include <wrapper/ringbuffer/frontend_types.h>
33 #include <wrapper/ringbuffer/backend.h>
34 #include <wrapper/rcu.h>
35 #include <lttng-events.h>
36 #include <lttng-tracer-core.h>
37
38 #define __LTTNG_NULL_STRING "(null)"
39
40 /*
41 * Macro declarations used for all stages.
42 */
43
44 /*
45 * LTTng name mapping macros. LTTng remaps some of the kernel events to
46 * enforce name-spacing.
47 */
48 #undef LTTNG_TRACEPOINT_EVENT_MAP
49 #define LTTNG_TRACEPOINT_EVENT_MAP(name, map, proto, args, fields) \
50 LTTNG_TRACEPOINT_EVENT_CLASS(map, \
51 PARAMS(proto), \
52 PARAMS(args), \
53 PARAMS(fields)) \
54 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
55
56 #undef LTTNG_TRACEPOINT_EVENT_MAP_NOARGS
57 #define LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, map, fields) \
58 LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(map, \
59 PARAMS(fields)) \
60 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(map, name, map)
61
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, \
65 PARAMS(proto), \
66 PARAMS(args), \
67 PARAMS(_locvar), \
68 PARAMS(_code_pre), \
69 PARAMS(fields), \
70 PARAMS(_code_post)) \
71 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args))
72
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, \
76 PARAMS(proto), \
77 PARAMS(args), \
78 PARAMS(_locvar), \
79 PARAMS(_code_pre), \
80 PARAMS(fields), \
81 PARAMS(_code_post))
82
83 /*
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.
89 *
90 * LTTNG_TRACEPOINT_EVENT is a one to one mapping between tracepoint and
91 * template.
92 */
93
94 #undef LTTNG_TRACEPOINT_EVENT
95 #define LTTNG_TRACEPOINT_EVENT(name, proto, args, fields) \
96 LTTNG_TRACEPOINT_EVENT_MAP(name, name, \
97 PARAMS(proto), \
98 PARAMS(args), \
99 PARAMS(fields))
100
101 #undef LTTNG_TRACEPOINT_EVENT_NOARGS
102 #define LTTNG_TRACEPOINT_EVENT_NOARGS(name, fields) \
103 LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, name, PARAMS(fields))
104
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))
108
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)
112
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), , , \
116 PARAMS(_fields), )
117
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), )
121
122
123 /*
124 * Stage 1 of the trace events.
125 *
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.
129 */
130
131 /* Reset all macros within TRACEPOINT_EVENT */
132 #include <probes/lttng-events-reset.h>
133
134 #undef TP_PROTO
135 #define TP_PROTO(...) __VA_ARGS__
136
137 #undef TP_ARGS
138 #define TP_ARGS(...) __VA_ARGS__
139
140 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
141 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
142 void trace_##_name(_proto);
143
144 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
145 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
146 void trace_##_name(void);
147
148 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
149
150 /*
151 * Stage 1.1 of the trace events.
152 *
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.
156 */
157
158 #include <probes/lttng-events-reset.h> /* Reset all macros within TRACE_EVENT */
159
160 #undef TP_PROTO
161 #define TP_PROTO(...) __VA_ARGS__
162
163 #undef TP_ARGS
164 #define TP_ARGS(...) __VA_ARGS__
165
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);
169
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);
173
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);
177
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);
181
182 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
183
184 /*
185 * Stage 2 of the trace events.
186 *
187 * Create event field type metadata section.
188 * Each event produce an array of fields.
189 */
190
191 /* Reset all macros within TRACEPOINT_EVENT */
192 #include <probes/lttng-events-reset.h>
193 #include <probes/lttng-events-write.h>
194 #include <probes/lttng-events-nowrite.h>
195
196 #undef _ctf_integer_ext
197 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
198 { \
199 .name = #_item, \
200 .type = __type_integer(_type, 0, 0, -1, _byte_order, _base, none),\
201 .nowrite = _nowrite, \
202 .user = _user, \
203 },
204
205 #undef _ctf_array_encoded
206 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
207 { \
208 .name = #_item, \
209 .type = \
210 { \
211 .atype = atype_array, \
212 .u = \
213 { \
214 .array = \
215 { \
216 .elem_type = __type_integer(_type, 0, 0, 0, __BYTE_ORDER, 10, _encoding), \
217 .length = _length, \
218 } \
219 } \
220 }, \
221 .nowrite = _nowrite, \
222 .user = _user, \
223 },
224
225 #undef _ctf_array_bitfield
226 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
227 { \
228 .name = #_item, \
229 .type = \
230 { \
231 .atype = atype_array, \
232 .u = \
233 { \
234 .array = \
235 { \
236 .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \
237 .length = (_length) * sizeof(_type) * CHAR_BIT, \
238 .elem_alignment = lttng_alignof(_type), \
239 } \
240 } \
241 }, \
242 .nowrite = _nowrite, \
243 .user = _user, \
244 },
245
246
247 #undef _ctf_sequence_encoded
248 #define _ctf_sequence_encoded(_type, _item, _src, \
249 _length_type, _src_length, _encoding, \
250 _byte_order, _base, _user, _nowrite) \
251 { \
252 .name = #_item, \
253 .type = \
254 { \
255 .atype = atype_sequence, \
256 .u = \
257 { \
258 .sequence = \
259 { \
260 .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \
261 .elem_type = __type_integer(_type, 0, 0, -1, _byte_order, _base, _encoding), \
262 }, \
263 }, \
264 }, \
265 .nowrite = _nowrite, \
266 .user = _user, \
267 },
268
269 #undef _ctf_sequence_bitfield
270 #define _ctf_sequence_bitfield(_type, _item, _src, \
271 _length_type, _src_length, \
272 _user, _nowrite) \
273 { \
274 .name = #_item, \
275 .type = \
276 { \
277 .atype = atype_sequence, \
278 .u = \
279 { \
280 .sequence = \
281 { \
282 .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \
283 .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \
284 .elem_alignment = lttng_alignof(_type), \
285 }, \
286 }, \
287 }, \
288 .nowrite = _nowrite, \
289 .user = _user, \
290 },
291
292 #undef _ctf_string
293 #define _ctf_string(_item, _src, _user, _nowrite) \
294 { \
295 .name = #_item, \
296 .type = \
297 { \
298 .atype = atype_string, \
299 .u = \
300 { \
301 .basic = { .string = { .encoding = lttng_encode_UTF8 } } \
302 }, \
303 }, \
304 .nowrite = _nowrite, \
305 .user = _user, \
306 },
307
308 #undef TP_FIELDS
309 #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
310
311 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
312 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
313 static const struct lttng_event_field __event_fields___##_name[] = { \
314 _fields \
315 };
316
317 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
318 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
319 LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post)
320
321 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
322
323 /*
324 * Stage 3 of the trace events.
325 *
326 * Create probe callback prototypes.
327 */
328
329 /* Reset all macros within TRACEPOINT_EVENT */
330 #include <probes/lttng-events-reset.h>
331
332 #undef TP_PROTO
333 #define TP_PROTO(...) __VA_ARGS__
334
335 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
336 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
337 static void __event_probe__##_name(void *__data, _proto);
338
339 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
340 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
341 static void __event_probe__##_name(void *__data);
342
343 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
344
345 /*
346 * Stage 4 of the trace events.
347 *
348 * Create static inline function that calculates event size.
349 */
350
351 /* Reset all macros within TRACEPOINT_EVENT */
352 #include <probes/lttng-events-reset.h>
353 #include <probes/lttng-events-write.h>
354
355 #undef _ctf_integer_ext
356 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
357 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
358 __event_len += sizeof(_type);
359
360 #undef _ctf_array_encoded
361 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
362 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
363 __event_len += sizeof(_type) * (_length);
364
365 #undef _ctf_array_bitfield
366 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
367 _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
368
369 #undef _ctf_sequence_encoded
370 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
371 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
372 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \
373 __event_len += sizeof(_length_type); \
374 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
375 __dynamic_len[__dynamic_len_idx] = (_src_length); \
376 __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \
377 __dynamic_len_idx++;
378
379 #undef _ctf_sequence_bitfield
380 #define _ctf_sequence_bitfield(_type, _item, _src, \
381 _length_type, _src_length, \
382 _user, _nowrite) \
383 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
384 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
385
386 /*
387 * ctf_user_string includes \0. If returns 0, it faulted, so we set size to
388 * 1 (\0 only).
389 */
390 #undef _ctf_string
391 #define _ctf_string(_item, _src, _user, _nowrite) \
392 if (_user) \
393 __event_len += __dynamic_len[__dynamic_len_idx++] = \
394 max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \
395 else \
396 __event_len += __dynamic_len[__dynamic_len_idx++] = \
397 strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1;
398
399 #undef TP_PROTO
400 #define TP_PROTO(...) __VA_ARGS__
401
402 #undef TP_FIELDS
403 #define TP_FIELDS(...) __VA_ARGS__
404
405 #undef TP_locvar
406 #define TP_locvar(...) __VA_ARGS__
407
408 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
409 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
410 static inline size_t __event_get_size__##_name(size_t *__dynamic_len, \
411 void *__tp_locvar, _proto) \
412 { \
413 size_t __event_len = 0; \
414 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
415 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
416 \
417 _fields \
418 return __event_len; \
419 }
420
421 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
422 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
423 static inline size_t __event_get_size__##_name(size_t *__dynamic_len, \
424 void *__tp_locvar) \
425 { \
426 size_t __event_len = 0; \
427 unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \
428 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
429 \
430 _fields \
431 return __event_len; \
432 }
433
434 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
435
436
437 /*
438 * Stage 4.1 of tracepoint event generation.
439 *
440 * Create static inline function that layout the filter stack data.
441 * We make both write and nowrite data available to the filter.
442 */
443
444 /* Reset all macros within TRACEPOINT_EVENT */
445 #include <probes/lttng-events-reset.h>
446 #include <probes/lttng-events-write.h>
447 #include <probes/lttng-events-nowrite.h>
448
449 #undef _ctf_integer_ext_fetched
450 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
451 if (lttng_is_signed_type(_type)) { \
452 int64_t __ctf_tmp_int64; \
453 switch (sizeof(_type)) { \
454 case 1: \
455 { \
456 union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
457 __ctf_tmp_int64 = (int64_t) __tmp.v; \
458 break; \
459 } \
460 case 2: \
461 { \
462 union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
463 if (_byte_order != __BYTE_ORDER) \
464 __swab16s(&__tmp.v); \
465 __ctf_tmp_int64 = (int64_t) __tmp.v; \
466 break; \
467 } \
468 case 4: \
469 { \
470 union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
471 if (_byte_order != __BYTE_ORDER) \
472 __swab32s(&__tmp.v); \
473 __ctf_tmp_int64 = (int64_t) __tmp.v; \
474 break; \
475 } \
476 case 8: \
477 { \
478 union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
479 if (_byte_order != __BYTE_ORDER) \
480 __swab64s(&__tmp.v); \
481 __ctf_tmp_int64 = (int64_t) __tmp.v; \
482 break; \
483 } \
484 default: \
485 BUG_ON(1); \
486 }; \
487 memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
488 } else { \
489 uint64_t __ctf_tmp_uint64; \
490 switch (sizeof(_type)) { \
491 case 1: \
492 { \
493 union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
494 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
495 break; \
496 } \
497 case 2: \
498 { \
499 union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
500 if (_byte_order != __BYTE_ORDER) \
501 __swab16s(&__tmp.v); \
502 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
503 break; \
504 } \
505 case 4: \
506 { \
507 union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
508 if (_byte_order != __BYTE_ORDER) \
509 __swab32s(&__tmp.v); \
510 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
511 break; \
512 } \
513 case 8: \
514 { \
515 union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
516 if (_byte_order != __BYTE_ORDER) \
517 __swab64s(&__tmp.v); \
518 __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
519 break; \
520 } \
521 default: \
522 BUG_ON(1); \
523 }; \
524 memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
525 } \
526 __stack_data += sizeof(int64_t);
527
528 #undef _ctf_integer_ext_isuser0
529 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
530 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
531
532 #undef _ctf_integer_ext_isuser1
533 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
534 { \
535 union { \
536 char __array[sizeof(_user_src)]; \
537 __typeof__(_user_src) __v; \
538 } __tmp_fetch; \
539 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
540 &(_user_src), sizeof(_user_src))) \
541 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
542 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
543 }
544
545 #undef _ctf_integer_ext
546 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
547 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
548
549 #undef _ctf_array_encoded
550 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
551 { \
552 unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
553 const void *__ctf_tmp_ptr = (_src); \
554 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
555 __stack_data += sizeof(unsigned long); \
556 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
557 __stack_data += sizeof(void *); \
558 }
559
560 #undef _ctf_array_bitfield
561 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
562 _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
563
564 #undef _ctf_sequence_encoded
565 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
566 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
567 { \
568 unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \
569 const void *__ctf_tmp_ptr = (_src); \
570 memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \
571 __stack_data += sizeof(unsigned long); \
572 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
573 __stack_data += sizeof(void *); \
574 }
575
576 #undef _ctf_sequence_bitfield
577 #define _ctf_sequence_bitfield(_type, _item, _src, \
578 _length_type, _src_length, \
579 _user, _nowrite) \
580 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
581 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
582
583 #undef _ctf_string
584 #define _ctf_string(_item, _src, _user, _nowrite) \
585 { \
586 const void *__ctf_tmp_ptr = \
587 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
588 memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
589 __stack_data += sizeof(void *); \
590 }
591
592 #undef TP_PROTO
593 #define TP_PROTO(...) __VA_ARGS__
594
595 #undef TP_FIELDS
596 #define TP_FIELDS(...) __VA_ARGS__
597
598 #undef TP_locvar
599 #define TP_locvar(...) __VA_ARGS__
600
601 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
602 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
603 static inline \
604 void __event_prepare_filter_stack__##_name(char *__stack_data, \
605 void *__tp_locvar) \
606 { \
607 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
608 \
609 _fields \
610 }
611
612 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
613 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
614 static inline \
615 void __event_prepare_filter_stack__##_name(char *__stack_data, \
616 void *__tp_locvar, _proto) \
617 { \
618 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
619 \
620 _fields \
621 }
622
623 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
624
625 /*
626 * Stage 5 of the trace events.
627 *
628 * Create static inline function that calculates event payload alignment.
629 */
630
631 /* Reset all macros within TRACEPOINT_EVENT */
632 #include <probes/lttng-events-reset.h>
633 #include <probes/lttng-events-write.h>
634
635 #undef _ctf_integer_ext
636 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
637 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
638
639 #undef _ctf_array_encoded
640 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
641 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
642
643 #undef _ctf_array_bitfield
644 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
645 _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
646
647 #undef _ctf_sequence_encoded
648 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
649 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
650 __event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \
651 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
652
653 #undef _ctf_sequence_bitfield
654 #define _ctf_sequence_bitfield(_type, _item, _src, \
655 _length_type, _src_length, \
656 _user, _nowrite) \
657 _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
658 none, __LITTLE_ENDIAN, 10, _user, _nowrite)
659
660 #undef _ctf_string
661 #define _ctf_string(_item, _src, _user, _nowrite)
662
663 #undef TP_PROTO
664 #define TP_PROTO(...) __VA_ARGS__
665
666 #undef TP_FIELDS
667 #define TP_FIELDS(...) __VA_ARGS__
668
669 #undef TP_locvar
670 #define TP_locvar(...) __VA_ARGS__
671
672 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
673 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
674 static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \
675 { \
676 size_t __event_align = 1; \
677 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
678 \
679 _fields \
680 return __event_align; \
681 }
682
683 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
684 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
685 static inline size_t __event_get_align__##_name(void *__tp_locvar) \
686 { \
687 size_t __event_align = 1; \
688 struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \
689 \
690 _fields \
691 return __event_align; \
692 }
693
694 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
695
696 /*
697 * Stage 6 of tracepoint event generation.
698 *
699 * Create the probe function. This function calls event size calculation
700 * and writes event data into the buffer.
701 */
702
703 /* Reset all macros within TRACEPOINT_EVENT */
704 #include <probes/lttng-events-reset.h>
705 #include <probes/lttng-events-write.h>
706
707 #undef _ctf_integer_ext_fetched
708 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
709 { \
710 _type __tmp = _src; \
711 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
712 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
713 }
714
715 #undef _ctf_integer_ext_isuser0
716 #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \
717 _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite)
718
719 #undef _ctf_integer_ext_isuser1
720 #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \
721 { \
722 union { \
723 char __array[sizeof(_user_src)]; \
724 __typeof__(_user_src) __v; \
725 } __tmp_fetch; \
726 if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \
727 &(_user_src), sizeof(_user_src))) \
728 memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \
729 _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \
730 }
731
732 #undef _ctf_integer_ext
733 #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \
734 _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
735
736 #undef _ctf_array_encoded
737 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
738 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
739 if (_user) { \
740 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
741 } else { \
742 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
743 }
744
745 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
746 #undef _ctf_array_bitfield
747 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
748 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
749 if (_user) { \
750 __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
751 } else { \
752 __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
753 }
754 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
755 /*
756 * For big endian, we need to byteswap into little endian.
757 */
758 #undef _ctf_array_bitfield
759 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
760 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
761 { \
762 size_t _i; \
763 \
764 for (_i = 0; _i < (_length); _i++) { \
765 _type _tmp; \
766 \
767 if (_user) { \
768 if (get_user(_tmp, (_type *) _src + _i)) \
769 _tmp = 0; \
770 } else { \
771 _tmp = ((_type *) _src)[_i]; \
772 } \
773 switch (sizeof(_type)) { \
774 case 1: \
775 break; \
776 case 2: \
777 _tmp = cpu_to_le16(_tmp); \
778 break; \
779 case 4: \
780 _tmp = cpu_to_le32(_tmp); \
781 break; \
782 case 8: \
783 _tmp = cpu_to_le64(_tmp); \
784 break; \
785 default: \
786 BUG_ON(1); \
787 } \
788 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
789 } \
790 }
791 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
792
793 #undef _ctf_sequence_encoded
794 #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
795 _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
796 { \
797 _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx]; \
798 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
799 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
800 } \
801 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
802 if (_user) { \
803 __chan->ops->event_write_from_user(&__ctx, _src, \
804 sizeof(_type) * __get_dynamic_len(dest)); \
805 } else { \
806 __chan->ops->event_write(&__ctx, _src, \
807 sizeof(_type) * __get_dynamic_len(dest)); \
808 }
809
810 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
811 #undef _ctf_sequence_bitfield
812 #define _ctf_sequence_bitfield(_type, _item, _src, \
813 _length_type, _src_length, \
814 _user, _nowrite) \
815 { \
816 _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
817 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
818 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
819 } \
820 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
821 if (_user) { \
822 __chan->ops->event_write_from_user(&__ctx, _src, \
823 sizeof(_type) * __get_dynamic_len(dest)); \
824 } else { \
825 __chan->ops->event_write(&__ctx, _src, \
826 sizeof(_type) * __get_dynamic_len(dest)); \
827 }
828 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
829 /*
830 * For big endian, we need to byteswap into little endian.
831 */
832 #undef _ctf_sequence_bitfield
833 #define _ctf_sequence_bitfield(_type, _item, _src, \
834 _length_type, _src_length, \
835 _user, _nowrite) \
836 { \
837 _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
838 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
839 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
840 } \
841 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
842 { \
843 size_t _i, _length; \
844 \
845 _length = __get_dynamic_len(dest); \
846 for (_i = 0; _i < _length; _i++) { \
847 _type _tmp; \
848 \
849 if (_user) { \
850 if (get_user(_tmp, (_type *) _src + _i)) \
851 _tmp = 0; \
852 } else { \
853 _tmp = ((_type *) _src)[_i]; \
854 } \
855 switch (sizeof(_type)) { \
856 case 1: \
857 break; \
858 case 2: \
859 _tmp = cpu_to_le16(_tmp); \
860 break; \
861 case 4: \
862 _tmp = cpu_to_le32(_tmp); \
863 break; \
864 case 8: \
865 _tmp = cpu_to_le64(_tmp); \
866 break; \
867 default: \
868 BUG_ON(1); \
869 } \
870 __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
871 } \
872 }
873 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
874
875 #undef _ctf_string
876 #define _ctf_string(_item, _src, _user, _nowrite) \
877 if (_user) { \
878 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
879 __chan->ops->event_strcpy_from_user(&__ctx, _src, \
880 __get_dynamic_len(dest)); \
881 } else { \
882 const char *__ctf_tmp_string = \
883 ((_src) ? (_src) : __LTTNG_NULL_STRING); \
884 lib_ring_buffer_align_ctx(&__ctx, \
885 lttng_alignof(*__ctf_tmp_string)); \
886 __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
887 __get_dynamic_len(dest)); \
888 }
889
890 /* Beware: this get len actually consumes the len value */
891 #undef __get_dynamic_len
892 #define __get_dynamic_len(field) __stackvar.__dynamic_len[__dynamic_len_idx++]
893
894 #undef TP_PROTO
895 #define TP_PROTO(...) __VA_ARGS__
896
897 #undef TP_ARGS
898 #define TP_ARGS(...) __VA_ARGS__
899
900 #undef TP_FIELDS
901 #define TP_FIELDS(...) __VA_ARGS__
902
903 #undef TP_locvar
904 #define TP_locvar(...) __VA_ARGS__
905
906 #undef TP_code_pre
907 #define TP_code_pre(...) __VA_ARGS__
908
909 #undef TP_code_post
910 #define TP_code_post(...) __VA_ARGS__
911
912 /*
913 * For state dump, check that "session" argument (mandatory) matches the
914 * session this event belongs to. Ensures that we write state dump data only
915 * into the started session, not into all sessions.
916 */
917 #ifdef TP_SESSION_CHECK
918 #define _TP_SESSION_CHECK(session, csession) (session == csession)
919 #else /* TP_SESSION_CHECK */
920 #define _TP_SESSION_CHECK(session, csession) 1
921 #endif /* TP_SESSION_CHECK */
922
923 /*
924 * Using twice size for filter stack data to hold size and pointer for
925 * each field (worse case). For integers, max size required is 64-bit.
926 * Same for double-precision floats. Those fit within
927 * 2*sizeof(unsigned long) for all supported architectures.
928 * Perform UNION (||) of filter runtime list.
929 */
930 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
931 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
932 static void __event_probe__##_name(void *__data, _proto) \
933 { \
934 struct probe_local_vars { _locvar }; \
935 struct lttng_event *__event = __data; \
936 struct lttng_probe_ctx __lttng_probe_ctx = { \
937 .event = __event, \
938 .interruptible = !irqs_disabled(), \
939 }; \
940 struct lttng_channel *__chan = __event->chan; \
941 struct lttng_session *__session = __chan->session; \
942 struct lib_ring_buffer_ctx __ctx; \
943 size_t __event_len, __event_align; \
944 size_t __dynamic_len_idx __attribute__((unused)) = 0; \
945 union { \
946 size_t __dynamic_len[ARRAY_SIZE(__event_fields___##_name)]; \
947 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
948 } __stackvar; \
949 int __ret; \
950 struct probe_local_vars __tp_locvar; \
951 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
952 &__tp_locvar; \
953 struct lttng_pid_tracker *__lpf; \
954 \
955 if (!_TP_SESSION_CHECK(session, __session)) \
956 return; \
957 if (unlikely(!ACCESS_ONCE(__session->active))) \
958 return; \
959 if (unlikely(!ACCESS_ONCE(__chan->enabled))) \
960 return; \
961 if (unlikely(!ACCESS_ONCE(__event->enabled))) \
962 return; \
963 __lpf = lttng_rcu_dereference(__session->pid_tracker); \
964 if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->pid))) \
965 return; \
966 _code_pre \
967 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
968 struct lttng_bytecode_runtime *bc_runtime; \
969 int __filter_record = __event->has_enablers_without_bytecode; \
970 \
971 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
972 tp_locvar, _args); \
973 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
974 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
975 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
976 __filter_record = 1; \
977 } \
978 if (likely(!__filter_record)) \
979 goto __post; \
980 } \
981 __event_len = __event_get_size__##_name(__stackvar.__dynamic_len, \
982 tp_locvar, _args); \
983 __event_align = __event_get_align__##_name(tp_locvar, _args); \
984 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
985 __event_align, -1); \
986 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
987 if (__ret < 0) \
988 goto __post; \
989 _fields \
990 __chan->ops->event_commit(&__ctx); \
991 __post: \
992 _code_post \
993 return; \
994 }
995
996 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
997 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
998 static void __event_probe__##_name(void *__data) \
999 { \
1000 struct probe_local_vars { _locvar }; \
1001 struct lttng_event *__event = __data; \
1002 struct lttng_probe_ctx __lttng_probe_ctx = { \
1003 .event = __event, \
1004 .interruptible = !irqs_disabled(), \
1005 }; \
1006 struct lttng_channel *__chan = __event->chan; \
1007 struct lttng_session *__session = __chan->session; \
1008 struct lib_ring_buffer_ctx __ctx; \
1009 size_t __event_len, __event_align; \
1010 size_t __dynamic_len_idx __attribute__((unused)) = 0; \
1011 union { \
1012 size_t __dynamic_len[ARRAY_SIZE(__event_fields___##_name)]; \
1013 char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \
1014 } __stackvar; \
1015 int __ret; \
1016 struct probe_local_vars __tp_locvar; \
1017 struct probe_local_vars *tp_locvar __attribute__((unused)) = \
1018 &__tp_locvar; \
1019 struct lttng_pid_tracker *__lpf; \
1020 \
1021 if (!_TP_SESSION_CHECK(session, __session)) \
1022 return; \
1023 if (unlikely(!ACCESS_ONCE(__session->active))) \
1024 return; \
1025 if (unlikely(!ACCESS_ONCE(__chan->enabled))) \
1026 return; \
1027 if (unlikely(!ACCESS_ONCE(__event->enabled))) \
1028 return; \
1029 __lpf = lttng_rcu_dereference(__session->pid_tracker); \
1030 if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->pid))) \
1031 return; \
1032 _code_pre \
1033 if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \
1034 struct lttng_bytecode_runtime *bc_runtime; \
1035 int __filter_record = __event->has_enablers_without_bytecode; \
1036 \
1037 __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \
1038 tp_locvar); \
1039 lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
1040 if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
1041 __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
1042 __filter_record = 1; \
1043 } \
1044 if (likely(!__filter_record)) \
1045 goto __post; \
1046 } \
1047 __event_len = __event_get_size__##_name(__stackvar.__dynamic_len, tp_locvar); \
1048 __event_align = __event_get_align__##_name(tp_locvar); \
1049 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \
1050 __event_align, -1); \
1051 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
1052 if (__ret < 0) \
1053 goto __post; \
1054 _fields \
1055 __chan->ops->event_commit(&__ctx); \
1056 __post: \
1057 _code_post \
1058 return; \
1059 }
1060
1061 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1062
1063 #undef __get_dynamic_len
1064
1065 /*
1066 * Stage 7 of the trace events.
1067 *
1068 * Create event descriptions.
1069 */
1070
1071 /* Named field types must be defined in lttng-types.h */
1072
1073 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1074
1075 #ifndef TP_PROBE_CB
1076 #define TP_PROBE_CB(_template) &__event_probe__##_template
1077 #endif
1078
1079 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1080 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1081 static const struct lttng_event_desc __event_desc___##_map = { \
1082 .fields = __event_fields___##_template, \
1083 .name = #_map, \
1084 .kname = #_name, \
1085 .probe_callback = (void *) TP_PROBE_CB(_template), \
1086 .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
1087 .owner = THIS_MODULE, \
1088 };
1089
1090 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1091 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1092 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1093
1094 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1095
1096 /*
1097 * Stage 8 of the trace events.
1098 *
1099 * Create an array of event description pointers.
1100 */
1101
1102 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1103
1104 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
1105 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \
1106 &__event_desc___##_map,
1107
1108 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
1109 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \
1110 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)
1111
1112 #define TP_ID1(_token, _system) _token##_system
1113 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1114
1115 static const struct lttng_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
1116 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
1117 };
1118
1119 #undef TP_ID1
1120 #undef TP_ID
1121
1122 /*
1123 * Stage 9 of the trace events.
1124 *
1125 * Create a toplevel descriptor for the whole probe.
1126 */
1127
1128 #define TP_ID1(_token, _system) _token##_system
1129 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1130
1131 /* non-const because list head will be modified when registered. */
1132 static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
1133 .provider = __stringify(TRACE_SYSTEM),
1134 .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM),
1135 .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)),
1136 .head = { NULL, NULL },
1137 .lazy_init_head = { NULL, NULL },
1138 .lazy = 0,
1139 };
1140
1141 #undef TP_ID1
1142 #undef TP_ID
1143
1144 /*
1145 * Stage 10 of the trace events.
1146 *
1147 * Register/unregister probes at module load/unload.
1148 */
1149
1150 #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
1151
1152 #define TP_ID1(_token, _system) _token##_system
1153 #define TP_ID(_token, _system) TP_ID1(_token, _system)
1154 #define module_init_eval1(_token, _system) module_init(_token##_system)
1155 #define module_init_eval(_token, _system) module_init_eval1(_token, _system)
1156 #define module_exit_eval1(_token, _system) module_exit(_token##_system)
1157 #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system)
1158
1159 #ifndef TP_MODULE_NOINIT
1160 static int TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void)
1161 {
1162 wrapper_vmalloc_sync_all();
1163 return lttng_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM));
1164 }
1165
1166 static void TP_ID(__lttng_events_exit__, TRACE_SYSTEM)(void)
1167 {
1168 lttng_probe_unregister(&TP_ID(__probe_desc___, TRACE_SYSTEM));
1169 }
1170
1171 #ifndef TP_MODULE_NOAUTOLOAD
1172 module_init_eval(__lttng_events_init__, TRACE_SYSTEM);
1173 module_exit_eval(__lttng_events_exit__, TRACE_SYSTEM);
1174 #endif
1175
1176 #endif
1177
1178 #undef module_init_eval
1179 #undef module_exit_eval
1180 #undef TP_ID1
1181 #undef TP_ID
1182
1183 #undef TP_PROTO
1184 #undef TP_ARGS
This page took 0.053864 seconds and 4 git commands to generate.