Fix: 3.9.0 block layer instrumentation build
[lttng-modules.git] / probes / lttng-events.h
1 /*
2 * lttng-events.h
3 *
4 * Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org>
5 * Copyright (C) 2009-2012 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 #include <linux/uaccess.h>
22 #include <linux/debugfs.h>
23 #include "lttng.h"
24 #include "lttng-types.h"
25 #include "lttng-probe-user.h"
26 #include "../wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */
27 #include "../wrapper/ringbuffer/frontend_types.h"
28 #include "../lttng-events.h"
29 #include "../lttng-tracer-core.h"
30
31 /*
32 * Macro declarations used for all stages.
33 */
34
35 /*
36 * DECLARE_EVENT_CLASS can be used to add a generic function
37 * handlers for events. That is, if all events have the same
38 * parameters and just have distinct trace points.
39 * Each tracepoint can be defined with DEFINE_EVENT and that
40 * will map the DECLARE_EVENT_CLASS to the tracepoint.
41 *
42 * TRACE_EVENT is a one to one mapping between tracepoint and template.
43 */
44
45 #undef TRACE_EVENT
46 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
47 DECLARE_EVENT_CLASS(name, \
48 PARAMS(proto), \
49 PARAMS(args), \
50 PARAMS(tstruct), \
51 PARAMS(assign), \
52 PARAMS(print)) \
53 DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args))
54
55 #undef TRACE_EVENT_NOARGS
56 #define TRACE_EVENT_NOARGS(name, tstruct, assign, print) \
57 DECLARE_EVENT_CLASS_NOARGS(name, \
58 PARAMS(tstruct), \
59 PARAMS(assign), \
60 PARAMS(print)) \
61 DEFINE_EVENT_NOARGS(name, name)
62
63
64 #undef DEFINE_EVENT_PRINT
65 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
66 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
67
68 /* Callbacks are meaningless to LTTng. */
69 #undef TRACE_EVENT_FN
70 #define TRACE_EVENT_FN(name, proto, args, tstruct, \
71 assign, print, reg, unreg) \
72 TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \
73 PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \
74
75 /*
76 * Stage 1 of the trace events.
77 *
78 * Create dummy trace calls for each events, verifying that the LTTng module
79 * TRACE_EVENT headers match the kernel arguments. Will be optimized out by the
80 * compiler.
81 */
82
83 #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */
84
85 #undef TP_PROTO
86 #define TP_PROTO(args...) args
87
88 #undef TP_ARGS
89 #define TP_ARGS(args...) args
90
91 #undef DEFINE_EVENT
92 #define DEFINE_EVENT(_template, _name, _proto, _args) \
93 void trace_##_name(_proto);
94
95 #undef DEFINE_EVENT_NOARGS
96 #define DEFINE_EVENT_NOARGS(_template, _name) \
97 void trace_##_name(void *__data);
98
99 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
100
101 /*
102 * Stage 2 of the trace events.
103 *
104 * Create event field type metadata section.
105 * Each event produce an array of fields.
106 */
107
108 #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */
109
110 /* Named field types must be defined in lttng-types.h */
111
112 #undef __field_full
113 #define __field_full(_type, _item, _order, _base) \
114 { \
115 .name = #_item, \
116 .type = __type_integer(_type, _order, _base, none), \
117 },
118
119 #undef __field
120 #define __field(_type, _item) \
121 __field_full(_type, _item, __BYTE_ORDER, 10)
122
123 #undef __field_ext
124 #define __field_ext(_type, _item, _filter_type) \
125 __field(_type, _item)
126
127 #undef __field_hex
128 #define __field_hex(_type, _item) \
129 __field_full(_type, _item, __BYTE_ORDER, 16)
130
131 #undef __field_network
132 #define __field_network(_type, _item) \
133 __field_full(_type, _item, __BIG_ENDIAN, 10)
134
135 #undef __field_network_hex
136 #define __field_network_hex(_type, _item) \
137 __field_full(_type, _item, __BIG_ENDIAN, 16)
138
139 #undef __array_enc_ext
140 #define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
141 { \
142 .name = #_item, \
143 .type = \
144 { \
145 .atype = atype_array, \
146 .u.array = \
147 { \
148 .length = _length, \
149 .elem_type = __type_integer(_type, _order, _base, _encoding), \
150 }, \
151 }, \
152 },
153
154 #undef __array
155 #define __array(_type, _item, _length) \
156 __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, none)
157
158 #undef __array_text
159 #define __array_text(_type, _item, _length) \
160 __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, UTF8)
161
162 #undef __array_hex
163 #define __array_hex(_type, _item, _length) \
164 __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 16, none)
165
166 #undef __dynamic_array_enc_ext
167 #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding) \
168 { \
169 .name = #_item, \
170 .type = \
171 { \
172 .atype = atype_sequence, \
173 .u.sequence = \
174 { \
175 .length_type = __type_integer(u32, __BYTE_ORDER, 10, none), \
176 .elem_type = __type_integer(_type, _order, _base, _encoding), \
177 }, \
178 }, \
179 },
180
181 #undef __dynamic_array
182 #define __dynamic_array(_type, _item, _length) \
183 __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, none)
184
185 #undef __dynamic_array_text
186 #define __dynamic_array_text(_type, _item, _length) \
187 __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, UTF8)
188
189 #undef __dynamic_array_hex
190 #define __dynamic_array_hex(_type, _item, _length) \
191 __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 16, none)
192
193 #undef __string
194 #define __string(_item, _src) \
195 { \
196 .name = #_item, \
197 .type = \
198 { \
199 .atype = atype_string, \
200 .u.basic.string.encoding = lttng_encode_UTF8, \
201 }, \
202 },
203
204 #undef __string_from_user
205 #define __string_from_user(_item, _src) \
206 __string(_item, _src)
207
208 #undef TP_STRUCT__entry
209 #define TP_STRUCT__entry(args...) args /* Only one used in this phase */
210
211 #undef DECLARE_EVENT_CLASS_NOARGS
212 #define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print) \
213 static const struct lttng_event_field __event_fields___##_name[] = { \
214 _tstruct \
215 };
216
217 #undef DECLARE_EVENT_CLASS
218 #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
219 DECLARE_EVENT_CLASS_NOARGS(_name, PARAMS(_tstruct), PARAMS(_assign), \
220 PARAMS(_print))
221
222 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
223
224 /*
225 * Stage 3 of the trace events.
226 *
227 * Create probe callback prototypes.
228 */
229
230 #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */
231
232 #undef TP_PROTO
233 #define TP_PROTO(args...) args
234
235 #undef DECLARE_EVENT_CLASS
236 #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
237 static void __event_probe__##_name(void *__data, _proto);
238
239 #undef DECLARE_EVENT_CLASS_NOARGS
240 #define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print) \
241 static void __event_probe__##_name(void *__data);
242
243 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
244
245 /*
246 * Stage 3.9 of the trace events.
247 *
248 * Create event descriptions.
249 */
250
251 /* Named field types must be defined in lttng-types.h */
252
253 #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */
254
255 #ifndef TP_PROBE_CB
256 #define TP_PROBE_CB(_template) &__event_probe__##_template
257 #endif
258
259 #undef DEFINE_EVENT_NOARGS
260 #define DEFINE_EVENT_NOARGS(_template, _name) \
261 static const struct lttng_event_desc __event_desc___##_name = { \
262 .fields = __event_fields___##_template, \
263 .name = #_name, \
264 .probe_callback = (void *) TP_PROBE_CB(_template), \
265 .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
266 .owner = THIS_MODULE, \
267 };
268
269 #undef DEFINE_EVENT
270 #define DEFINE_EVENT(_template, _name, _proto, _args) \
271 DEFINE_EVENT_NOARGS(_template, _name)
272
273 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
274
275
276 /*
277 * Stage 4 of the trace events.
278 *
279 * Create an array of event description pointers.
280 */
281
282 /* Named field types must be defined in lttng-types.h */
283
284 #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */
285
286 #undef DEFINE_EVENT_NOARGS
287 #define DEFINE_EVENT_NOARGS(_template, _name) \
288 &__event_desc___##_name,
289
290 #undef DEFINE_EVENT
291 #define DEFINE_EVENT(_template, _name, _proto, _args) \
292 DEFINE_EVENT_NOARGS(_template, _name)
293
294 #define TP_ID1(_token, _system) _token##_system
295 #define TP_ID(_token, _system) TP_ID1(_token, _system)
296
297 static const struct lttng_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
298 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
299 };
300
301 #undef TP_ID1
302 #undef TP_ID
303
304
305 /*
306 * Stage 5 of the trace events.
307 *
308 * Create a toplevel descriptor for the whole probe.
309 */
310
311 #define TP_ID1(_token, _system) _token##_system
312 #define TP_ID(_token, _system) TP_ID1(_token, _system)
313
314 /* non-const because list head will be modified when registered. */
315 static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
316 .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM),
317 .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)),
318 };
319
320 #undef TP_ID1
321 #undef TP_ID
322
323 /*
324 * Stage 6 of the trace events.
325 *
326 * Create static inline function that calculates event size.
327 */
328
329 #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */
330
331 /* Named field types must be defined in lttng-types.h */
332
333 #undef __field_full
334 #define __field_full(_type, _item, _order, _base) \
335 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
336 __event_len += sizeof(_type);
337
338 #undef __array_enc_ext
339 #define __array_enc_ext(_type, _item, _length, _order, _base, _encoding) \
340 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
341 __event_len += sizeof(_type) * (_length);
342
343 #undef __dynamic_array_enc_ext
344 #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
345 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(u32)); \
346 __event_len += sizeof(u32); \
347 __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
348 __dynamic_len[__dynamic_len_idx] = (_length); \
349 __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \
350 __dynamic_len_idx++;
351
352 #undef __string
353 #define __string(_item, _src) \
354 __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1;
355
356 /*
357 * strlen_user includes \0. If returns 0, it faulted, so we set size to
358 * 1 (\0 only).
359 */
360 #undef __string_from_user
361 #define __string_from_user(_item, _src) \
362 __event_len += __dynamic_len[__dynamic_len_idx++] = \
363 max_t(size_t, lttng_strlen_user_inatomic(_src), 1);
364
365 #undef TP_PROTO
366 #define TP_PROTO(args...) args
367
368 #undef TP_STRUCT__entry
369 #define TP_STRUCT__entry(args...) args
370
371 #undef DECLARE_EVENT_CLASS
372 #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
373 static inline size_t __event_get_size__##_name(size_t *__dynamic_len, _proto) \
374 { \
375 size_t __event_len = 0; \
376 unsigned int __dynamic_len_idx = 0; \
377 \
378 if (0) \
379 (void) __dynamic_len_idx; /* don't warn if unused */ \
380 _tstruct \
381 return __event_len; \
382 }
383
384 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
385
386 /*
387 * Stage 7 of the trace events.
388 *
389 * Create static inline function that calculates event payload alignment.
390 */
391
392 #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */
393
394 /* Named field types must be defined in lttng-types.h */
395
396 #undef __field_full
397 #define __field_full(_type, _item, _order, _base) \
398 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
399
400 #undef __array_enc_ext
401 #define __array_enc_ext(_type, _item, _length, _order, _base, _encoding) \
402 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
403
404 #undef __dynamic_array_enc_ext
405 #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
406 __event_align = max_t(size_t, __event_align, lttng_alignof(u32)); \
407 __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
408
409 #undef __string
410 #define __string(_item, _src)
411
412 #undef __string_from_user
413 #define __string_from_user(_item, _src)
414
415 #undef TP_PROTO
416 #define TP_PROTO(args...) args
417
418 #undef TP_STRUCT__entry
419 #define TP_STRUCT__entry(args...) args
420
421 #undef DECLARE_EVENT_CLASS
422 #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
423 static inline size_t __event_get_align__##_name(_proto) \
424 { \
425 size_t __event_align = 1; \
426 _tstruct \
427 return __event_align; \
428 }
429
430 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
431
432
433 /*
434 * Stage 8 of the trace events.
435 *
436 * Create structure declaration that allows the "assign" macros to access the
437 * field types.
438 */
439
440 #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */
441
442 /* Named field types must be defined in lttng-types.h */
443
444 #undef __field_full
445 #define __field_full(_type, _item, _order, _base) _type _item;
446
447 #undef __array_enc_ext
448 #define __array_enc_ext(_type, _item, _length, _order, _base, _encoding) \
449 _type _item;
450
451 #undef __dynamic_array_enc_ext
452 #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
453 _type _item;
454
455 #undef __string
456 #define __string(_item, _src) char _item;
457
458 #undef __string_from_user
459 #define __string_from_user(_item, _src) \
460 __string(_item, _src)
461
462 #undef TP_STRUCT__entry
463 #define TP_STRUCT__entry(args...) args
464
465 #undef DECLARE_EVENT_CLASS
466 #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
467 struct __event_typemap__##_name { \
468 _tstruct \
469 };
470
471 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
472
473
474 /*
475 * Stage 9 of the trace events.
476 *
477 * Create the probe function : call even size calculation and write event data
478 * into the buffer.
479 *
480 * We use both the field and assignment macros to write the fields in the order
481 * defined in the field declaration. The field declarations control the
482 * execution order, jumping to the appropriate assignment block.
483 */
484
485 #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */
486
487 #undef __field_full
488 #define __field_full(_type, _item, _order, _base) \
489 goto __assign_##_item; \
490 __end_field_##_item:
491
492 #undef __array_enc_ext
493 #define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
494 goto __assign_##_item; \
495 __end_field_##_item:
496
497 #undef __dynamic_array_enc_ext
498 #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
499 goto __assign_##_item##_1; \
500 __end_field_##_item##_1: \
501 goto __assign_##_item##_2; \
502 __end_field_##_item##_2:
503
504 #undef __string
505 #define __string(_item, _src) \
506 goto __assign_##_item; \
507 __end_field_##_item:
508
509 #undef __string_from_user
510 #define __string_from_user(_item, _src) \
511 __string(_item, _src)
512
513 /*
514 * Macros mapping tp_assign() to "=", tp_memcpy() to memcpy() and tp_strcpy() to
515 * strcpy().
516 */
517 #undef tp_assign
518 #define tp_assign(dest, src) \
519 __assign_##dest: \
520 { \
521 __typeof__(__typemap.dest) __tmp = (src); \
522 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp)); \
523 __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
524 } \
525 goto __end_field_##dest;
526
527 /* fixed length array memcpy */
528 #undef tp_memcpy_gen
529 #define tp_memcpy_gen(write_ops, dest, src, len) \
530 __assign_##dest: \
531 if (0) \
532 (void) __typemap.dest; \
533 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest)); \
534 __chan->ops->write_ops(&__ctx, src, len); \
535 goto __end_field_##dest;
536
537 #undef tp_memcpy
538 #define tp_memcpy(dest, src, len) \
539 tp_memcpy_gen(event_write, dest, src, len)
540
541 #undef tp_memcpy_from_user
542 #define tp_memcpy_from_user(dest, src, len) \
543 tp_memcpy_gen(event_write_from_user, dest, src, len)
544
545 /* variable length sequence memcpy */
546 #undef tp_memcpy_dyn_gen
547 #define tp_memcpy_dyn_gen(write_ops, dest, src) \
548 __assign_##dest##_1: \
549 { \
550 u32 __tmpl = __dynamic_len[__dynamic_len_idx]; \
551 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(u32)); \
552 __chan->ops->event_write(&__ctx, &__tmpl, sizeof(u32)); \
553 } \
554 goto __end_field_##dest##_1; \
555 __assign_##dest##_2: \
556 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest)); \
557 __chan->ops->write_ops(&__ctx, src, \
558 sizeof(__typemap.dest) * __get_dynamic_array_len(dest));\
559 goto __end_field_##dest##_2;
560
561 #undef tp_memcpy_dyn
562 #define tp_memcpy_dyn(dest, src) \
563 tp_memcpy_dyn_gen(event_write, dest, src)
564
565 #undef tp_memcpy_dyn_from_user
566 #define tp_memcpy_dyn_from_user(dest, src) \
567 tp_memcpy_dyn_gen(event_write_from_user, dest, src)
568
569 /*
570 * The string length including the final \0.
571 */
572 #undef tp_copy_string_from_user
573 #define tp_copy_string_from_user(dest, src) \
574 __assign_##dest: \
575 { \
576 size_t __ustrlen; \
577 \
578 if (0) \
579 (void) __typemap.dest; \
580 lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));\
581 __ustrlen = __get_dynamic_array_len(dest); \
582 if (likely(__ustrlen > 1)) { \
583 __chan->ops->event_write_from_user(&__ctx, src, \
584 __ustrlen - 1); \
585 } \
586 __chan->ops->event_memset(&__ctx, 0, 1); \
587 } \
588 goto __end_field_##dest;
589 #undef tp_strcpy
590 #define tp_strcpy(dest, src) \
591 tp_memcpy(dest, src, __get_dynamic_array_len(dest))
592
593 /* Named field types must be defined in lttng-types.h */
594
595 #undef __get_str
596 #define __get_str(field) field
597
598 #undef __get_dynamic_array
599 #define __get_dynamic_array(field) field
600
601 /* Beware: this get len actually consumes the len value */
602 #undef __get_dynamic_array_len
603 #define __get_dynamic_array_len(field) __dynamic_len[__dynamic_len_idx++]
604
605 #undef TP_PROTO
606 #define TP_PROTO(args...) args
607
608 #undef TP_ARGS
609 #define TP_ARGS(args...) args
610
611 #undef TP_STRUCT__entry
612 #define TP_STRUCT__entry(args...) args
613
614 #undef TP_fast_assign
615 #define TP_fast_assign(args...) args
616
617 /*
618 * For state dump, check that "session" argument (mandatory) matches the
619 * session this event belongs to. Ensures that we write state dump data only
620 * into the started session, not into all sessions.
621 */
622 #ifdef TP_SESSION_CHECK
623 #define _TP_SESSION_CHECK(session, csession) (session == csession)
624 #else /* TP_SESSION_CHECK */
625 #define _TP_SESSION_CHECK(session, csession) 1
626 #endif /* TP_SESSION_CHECK */
627
628 #undef DECLARE_EVENT_CLASS
629 #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
630 static void __event_probe__##_name(void *__data, _proto) \
631 { \
632 struct lttng_event *__event = __data; \
633 struct lttng_channel *__chan = __event->chan; \
634 struct lib_ring_buffer_ctx __ctx; \
635 size_t __event_len, __event_align; \
636 size_t __dynamic_len_idx = 0; \
637 size_t __dynamic_len[ARRAY_SIZE(__event_fields___##_name)]; \
638 struct __event_typemap__##_name __typemap; \
639 int __ret; \
640 \
641 if (0) { \
642 (void) __dynamic_len_idx; /* don't warn if unused */ \
643 (void) __typemap; /* don't warn if unused */ \
644 } \
645 if (!_TP_SESSION_CHECK(session, __chan->session)) \
646 return; \
647 if (unlikely(!ACCESS_ONCE(__chan->session->active))) \
648 return; \
649 if (unlikely(!ACCESS_ONCE(__chan->enabled))) \
650 return; \
651 if (unlikely(!ACCESS_ONCE(__event->enabled))) \
652 return; \
653 __event_len = __event_get_size__##_name(__dynamic_len, _args); \
654 __event_align = __event_get_align__##_name(_args); \
655 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \
656 __event_align, -1); \
657 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
658 if (__ret < 0) \
659 return; \
660 /* Control code (field ordering) */ \
661 _tstruct \
662 __chan->ops->event_commit(&__ctx); \
663 return; \
664 /* Copy code, steered by control code */ \
665 _assign \
666 }
667
668 #undef DECLARE_EVENT_CLASS_NOARGS
669 #define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print) \
670 static void __event_probe__##_name(void *__data) \
671 { \
672 struct lttng_event *__event = __data; \
673 struct lttng_channel *__chan = __event->chan; \
674 struct lib_ring_buffer_ctx __ctx; \
675 size_t __event_len, __event_align; \
676 int __ret; \
677 \
678 if (!_TP_SESSION_CHECK(session, __chan->session)) \
679 return; \
680 if (unlikely(!ACCESS_ONCE(__chan->session->active))) \
681 return; \
682 if (unlikely(!ACCESS_ONCE(__chan->enabled))) \
683 return; \
684 if (unlikely(!ACCESS_ONCE(__event->enabled))) \
685 return; \
686 __event_len = 0; \
687 __event_align = 1; \
688 lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \
689 __event_align, -1); \
690 __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
691 if (__ret < 0) \
692 return; \
693 /* Control code (field ordering) */ \
694 _tstruct \
695 __chan->ops->event_commit(&__ctx); \
696 return; \
697 /* Copy code, steered by control code */ \
698 _assign \
699 }
700
701 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
702
703 /*
704 * Stage 10 of the trace events.
705 *
706 * Register/unregister probes at module load/unload.
707 */
708
709 #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */
710
711 #define TP_ID1(_token, _system) _token##_system
712 #define TP_ID(_token, _system) TP_ID1(_token, _system)
713 #define module_init_eval1(_token, _system) module_init(_token##_system)
714 #define module_init_eval(_token, _system) module_init_eval1(_token, _system)
715 #define module_exit_eval1(_token, _system) module_exit(_token##_system)
716 #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system)
717
718 #ifndef TP_MODULE_NOINIT
719 static int TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void)
720 {
721 wrapper_vmalloc_sync_all();
722 return lttng_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM));
723 }
724
725 static void TP_ID(__lttng_events_exit__, TRACE_SYSTEM)(void)
726 {
727 lttng_probe_unregister(&TP_ID(__probe_desc___, TRACE_SYSTEM));
728 }
729
730 #ifndef TP_MODULE_NOAUTOLOAD
731 module_init_eval(__lttng_events_init__, TRACE_SYSTEM);
732 module_exit_eval(__lttng_events_exit__, TRACE_SYSTEM);
733 #endif
734
735 #endif
736
737 #undef module_init_eval
738 #undef module_exit_eval
739 #undef TP_ID1
740 #undef TP_ID
741
742 #undef TP_PROTO
743 #undef TP_ARGS
744 #undef TRACE_EVENT_FLAGS
This page took 0.064086 seconds and 4 git commands to generate.