Commit | Line | Data |
---|---|---|
17baffe2 MD |
1 | /* |
2 | * lttng-events.h | |
3 | * | |
4 | * Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org> | |
5 | * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
6 | * | |
7 | * Dual LGPL v2.1/GPL v2 license. | |
8 | */ | |
9 | ||
d0dd2ecb | 10 | #include <linux/debugfs.h> |
c0edae1d MD |
11 | #include "lttng.h" |
12 | #include "lttng-types.h" | |
b13f3ebe | 13 | #include "../wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */ |
f3bc08c5 | 14 | #include "../wrapper/ringbuffer/frontend_types.h" |
e763dbf5 | 15 | #include "../ltt-events.h" |
6db3d13b | 16 | #include "../ltt-tracer-core.h" |
40652b65 | 17 | |
40652b65 | 18 | /* |
6db3d13b | 19 | * Macro declarations used for all stages. |
40652b65 MD |
20 | */ |
21 | ||
22 | /* | |
23 | * DECLARE_EVENT_CLASS can be used to add a generic function | |
24 | * handlers for events. That is, if all events have the same | |
25 | * parameters and just have distinct trace points. | |
26 | * Each tracepoint can be defined with DEFINE_EVENT and that | |
27 | * will map the DECLARE_EVENT_CLASS to the tracepoint. | |
28 | * | |
29 | * TRACE_EVENT is a one to one mapping between tracepoint and template. | |
30 | */ | |
6db3d13b | 31 | |
40652b65 MD |
32 | #undef TRACE_EVENT |
33 | #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ | |
34 | DECLARE_EVENT_CLASS(name, \ | |
35 | PARAMS(proto), \ | |
36 | PARAMS(args), \ | |
37 | PARAMS(tstruct), \ | |
38 | PARAMS(assign), \ | |
299338c8 MD |
39 | PARAMS(print)) \ |
40 | DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args)) | |
40652b65 | 41 | |
6db3d13b MD |
42 | #undef DEFINE_EVENT_PRINT |
43 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ | |
44 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) | |
45 | ||
46 | /* Callbacks are meaningless to LTTng. */ | |
47 | #undef TRACE_EVENT_FN | |
48 | #define TRACE_EVENT_FN(name, proto, args, tstruct, \ | |
49 | assign, print, reg, unreg) \ | |
50 | TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \ | |
51 | PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \ | |
52 | ||
f62b389e | 53 | /* |
c099397a | 54 | * Stage 1 of the trace events. |
f62b389e MD |
55 | * |
56 | * Create dummy trace calls for each events, verifying that the LTTng module | |
57 | * TRACE_EVENT headers match the kernel arguments. Will be optimized out by the | |
58 | * compiler. | |
59 | */ | |
60 | ||
61 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ | |
62 | ||
63 | #undef TP_PROTO | |
64 | #define TP_PROTO(args...) args | |
65 | ||
66 | #undef TP_ARGS | |
67 | #define TP_ARGS(args...) args | |
68 | ||
69 | #undef DEFINE_EVENT | |
70 | #define DEFINE_EVENT(_template, _name, _proto, _args) \ | |
7eb827f2 | 71 | void trace_##_name(_proto); |
f62b389e MD |
72 | |
73 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
74 | ||
6db3d13b | 75 | /* |
c099397a | 76 | * Stage 2 of the trace events. |
6db3d13b MD |
77 | * |
78 | * Create event field type metadata section. | |
79 | * Each event produce an array of fields. | |
80 | */ | |
81 | ||
82 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ | |
83 | ||
1d12cebd MD |
84 | /* Named field types must be defined in lttng-types.h */ |
85 | ||
40652b65 | 86 | #undef __field |
299338c8 | 87 | #define __field(_type, _item) \ |
c099397a MD |
88 | { \ |
89 | .name = #_item, \ | |
64c796d8 | 90 | .type = __type_integer(_type, __BYTE_ORDER, 10, none),\ |
c099397a | 91 | }, |
40652b65 MD |
92 | |
93 | #undef __field_ext | |
6db3d13b | 94 | #define __field_ext(_type, _item, _filter_type) __field(_type, _item) |
40652b65 | 95 | |
c099397a MD |
96 | #undef __field_network |
97 | #define __field_network(_type, _item) \ | |
98 | { \ | |
99 | .name = #_item, \ | |
64c796d8 | 100 | .type = __type_integer(_type, __BIG_ENDIAN, 10, none),\ |
c099397a MD |
101 | }, |
102 | ||
64c796d8 MD |
103 | #undef __array_enc |
104 | #define __array_enc(_type, _item, _length, _encoding) \ | |
299338c8 | 105 | { \ |
c099397a MD |
106 | .name = #_item, \ |
107 | .type = \ | |
108 | { \ | |
299338c8 | 109 | .atype = atype_array, \ |
c099397a MD |
110 | .u.array = \ |
111 | { \ | |
112 | .length = _length, \ | |
64c796d8 | 113 | .elem_type = __type_integer(_type, __BYTE_ORDER, 10, _encoding), \ |
c099397a | 114 | }, \ |
299338c8 MD |
115 | }, \ |
116 | }, | |
40652b65 | 117 | |
64c796d8 MD |
118 | #undef __array |
119 | #define __array(_type, _item, _length) \ | |
120 | __array_enc(_type, _item, _length, none) | |
121 | ||
122 | #undef __array_text | |
123 | #define __array_text(_type, _item, _length) \ | |
124 | __array_enc(_type, _item, _length, UTF8) | |
125 | ||
126 | #undef __dynamic_array_enc | |
127 | #define __dynamic_array_enc(_type, _item, _length, _encoding) \ | |
299338c8 | 128 | { \ |
c099397a MD |
129 | .name = #_item, \ |
130 | .type = \ | |
131 | { \ | |
299338c8 | 132 | .atype = atype_sequence, \ |
c099397a MD |
133 | .u.sequence = \ |
134 | { \ | |
64c796d8 MD |
135 | .length_type = __type_integer(u32, __BYTE_ORDER, 10, none), \ |
136 | .elem_type = __type_integer(_type, __BYTE_ORDER, 10, _encoding), \ | |
c099397a | 137 | }, \ |
299338c8 MD |
138 | }, \ |
139 | }, | |
40652b65 | 140 | |
64c796d8 MD |
141 | #undef __dynamic_array |
142 | #define __dynamic_array(_type, _item, _length) \ | |
143 | __dynamic_array_enc(_type, _item, _length, none) | |
144 | ||
145 | #undef __dynamic_array_text | |
146 | #define __dynamic_array_text(_type, _item, _length) \ | |
147 | __dynamic_array_enc(_type, _item, _length, UTF8) | |
148 | ||
40652b65 | 149 | #undef __string |
1d12cebd | 150 | #define __string(_item, _src) \ |
299338c8 | 151 | { \ |
c099397a MD |
152 | .name = #_item, \ |
153 | .type = \ | |
154 | { \ | |
299338c8 | 155 | .atype = atype_string, \ |
c099397a | 156 | .u.basic.string.encoding = lttng_encode_UTF8, \ |
299338c8 MD |
157 | }, \ |
158 | }, | |
1d12cebd | 159 | |
40652b65 | 160 | #undef TP_STRUCT__entry |
1d12cebd MD |
161 | #define TP_STRUCT__entry(args...) args /* Only one used in this phase */ |
162 | ||
40652b65 | 163 | #undef DECLARE_EVENT_CLASS |
0d1d4002 MD |
164 | #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \ |
165 | static const struct lttng_event_field __event_fields___##_name[] = { \ | |
166 | _tstruct \ | |
299338c8 MD |
167 | }; |
168 | ||
299338c8 MD |
169 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
170 | ||
c099397a MD |
171 | #undef __type_integer |
172 | ||
19c57fbf | 173 | /* |
c099397a | 174 | * Stage 3 of the trace events. |
19c57fbf MD |
175 | * |
176 | * Create probe callback prototypes. | |
177 | */ | |
178 | ||
179 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ | |
180 | ||
181 | #undef TP_PROTO | |
182 | #define TP_PROTO(args...) args | |
183 | ||
184 | #undef DECLARE_EVENT_CLASS | |
185 | #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \ | |
186 | static void __event_probe__##_name(void *__data, _proto); | |
187 | ||
188 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
189 | ||
299338c8 | 190 | /* |
c099397a | 191 | * Stage 4 of the trace events. |
299338c8 MD |
192 | * |
193 | * Create an array of events. | |
194 | */ | |
195 | ||
299338c8 MD |
196 | /* Named field types must be defined in lttng-types.h */ |
197 | ||
6db3d13b | 198 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
299338c8 | 199 | |
d32a57a2 MD |
200 | #undef DEFINE_EVENT |
201 | #define DEFINE_EVENT(_template, _name, _proto, _args) \ | |
202 | { \ | |
203 | .fields = __event_fields___##_template, \ | |
204 | .name = #_name, \ | |
19c57fbf | 205 | .probe_callback = (void *) &__event_probe__##_template,\ |
d32a57a2 | 206 | .nr_fields = ARRAY_SIZE(__event_fields___##_template), \ |
dc7f600a | 207 | .owner = THIS_MODULE, \ |
6db3d13b | 208 | }, |
40652b65 | 209 | |
d0dd2ecb MD |
210 | #define TP_ID1(_token, _system) _token##_system |
211 | #define TP_ID(_token, _system) TP_ID1(_token, _system) | |
40652b65 | 212 | |
d0dd2ecb | 213 | static const struct lttng_event_desc TP_ID(__event_desc___, TRACE_SYSTEM)[] = { |
40652b65 | 214 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
299338c8 MD |
215 | }; |
216 | ||
d0dd2ecb MD |
217 | #undef TP_ID1 |
218 | #undef TP_ID | |
219 | ||
85a9ca7f MD |
220 | |
221 | /* | |
c099397a | 222 | * Stage 5 of the trace events. |
85a9ca7f MD |
223 | * |
224 | * Create a toplevel descriptor for the whole probe. | |
225 | */ | |
226 | ||
227 | #define TP_ID1(_token, _system) _token##_system | |
228 | #define TP_ID(_token, _system) TP_ID1(_token, _system) | |
229 | ||
230 | /* non-const because list head will be modified when registered. */ | |
231 | static struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = { | |
232 | .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM), | |
233 | .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)), | |
234 | }; | |
235 | ||
236 | #undef TP_ID1 | |
237 | #undef TP_ID | |
238 | ||
d0dd2ecb | 239 | /* |
c099397a | 240 | * Stage 6 of the trace events. |
40652b65 MD |
241 | * |
242 | * Create static inline function that calculates event size. | |
243 | */ | |
244 | ||
6db3d13b | 245 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
40652b65 | 246 | |
6db3d13b MD |
247 | /* Named field types must be defined in lttng-types.h */ |
248 | ||
249 | #undef __field | |
85a80742 | 250 | #define __field(_type, _item) \ |
d793d5e1 | 251 | __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \ |
0d1d4002 | 252 | __event_len += sizeof(_type); |
6db3d13b MD |
253 | |
254 | #undef __field_ext | |
255 | #define __field_ext(_type, _item, _filter_type) __field(_type, _item) | |
256 | ||
257 | #undef __array | |
85a80742 | 258 | #define __array(_type, _item, _length) \ |
d793d5e1 | 259 | __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \ |
0d1d4002 | 260 | __event_len += sizeof(_type) * (_length); |
6db3d13b | 261 | |
64c796d8 MD |
262 | #undef __array_text |
263 | #define __array_text(_type, _item, _length) \ | |
264 | __array(_type, _item, _length) | |
265 | ||
6db3d13b | 266 | #undef __dynamic_array |
85a80742 | 267 | #define __dynamic_array(_type, _item, _length) \ |
d793d5e1 | 268 | __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(u32)); \ |
85a80742 | 269 | __event_len += sizeof(u32); \ |
d793d5e1 | 270 | __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \ |
41b59694 MD |
271 | __dynamic_len[__dynamic_len_idx] = (_length); \ |
272 | __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ | |
273 | __dynamic_len_idx++; | |
6db3d13b | 274 | |
64c796d8 MD |
275 | #undef __dynamic_array_text |
276 | #define __dynamic_array_text(_type, _item, _length) \ | |
277 | __dynamic_array(_type, _item, _length) | |
278 | ||
6db3d13b | 279 | #undef __string |
85a80742 | 280 | #define __string(_item, _src) \ |
0d1d4002 MD |
281 | __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1; |
282 | ||
283 | #undef TP_PROTO | |
284 | #define TP_PROTO(args...) args | |
6db3d13b MD |
285 | |
286 | #undef TP_STRUCT__entry | |
0d1d4002 | 287 | #define TP_STRUCT__entry(args...) args |
6db3d13b MD |
288 | |
289 | #undef DECLARE_EVENT_CLASS | |
0d1d4002 MD |
290 | #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \ |
291 | static inline size_t __event_get_size__##_name(size_t *__dynamic_len, _proto) \ | |
292 | { \ | |
293 | size_t __event_len = 0; \ | |
294 | unsigned int __dynamic_len_idx = 0; \ | |
295 | \ | |
296 | if (0) \ | |
297 | (void) __dynamic_len_idx; /* don't warn if unused */ \ | |
298 | _tstruct \ | |
299 | return __event_len; \ | |
6db3d13b | 300 | } |
40652b65 MD |
301 | |
302 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
303 | ||
304 | /* | |
c099397a | 305 | * Stage 7 of the trace events. |
e763dbf5 MD |
306 | * |
307 | * Create static inline function that calculates event payload alignment. | |
308 | */ | |
309 | ||
310 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ | |
311 | ||
312 | /* Named field types must be defined in lttng-types.h */ | |
313 | ||
314 | #undef __field | |
315 | #define __field(_type, _item) \ | |
d793d5e1 | 316 | __event_align = max_t(size_t, __event_align, ltt_alignof(_type)); |
e763dbf5 MD |
317 | |
318 | #undef __field_ext | |
319 | #define __field_ext(_type, _item, _filter_type) __field(_type, _item) | |
320 | ||
321 | #undef __array | |
322 | #define __array(_type, _item, _length) \ | |
d793d5e1 | 323 | __event_align = max_t(size_t, __event_align, ltt_alignof(_type)); |
e763dbf5 | 324 | |
64c796d8 MD |
325 | #undef __array_text |
326 | #define __array_text(_type, _item, _length) \ | |
327 | __array(_type, _item, _length) | |
328 | ||
e763dbf5 MD |
329 | #undef __dynamic_array |
330 | #define __dynamic_array(_type, _item, _length) \ | |
d793d5e1 MD |
331 | __event_align = max_t(size_t, __event_align, ltt_alignof(u32)); \ |
332 | __event_align = max_t(size_t, __event_align, ltt_alignof(_type)); | |
e763dbf5 | 333 | |
64c796d8 MD |
334 | #undef __dynamic_array_text |
335 | #define __dynamic_array_text(_type, _item, _length) \ | |
336 | __dynamic_array(_type, _item, _length) | |
337 | ||
e763dbf5 MD |
338 | #undef __string |
339 | #define __string(_item, _src) | |
340 | ||
341 | #undef TP_PROTO | |
342 | #define TP_PROTO(args...) args | |
343 | ||
344 | #undef TP_STRUCT__entry | |
345 | #define TP_STRUCT__entry(args...) args | |
346 | ||
347 | #undef DECLARE_EVENT_CLASS | |
348 | #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \ | |
349 | static inline size_t __event_get_align__##_name(_proto) \ | |
350 | { \ | |
351 | size_t __event_align = 1; \ | |
352 | _tstruct \ | |
353 | return __event_align; \ | |
354 | } | |
355 | ||
356 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
357 | ||
358 | ||
e763dbf5 | 359 | /* |
c099397a | 360 | * Stage 8 of the trace events. |
40652b65 | 361 | * |
3c4ffab9 MD |
362 | * Create structure declaration that allows the "assign" macros to access the |
363 | * field types. | |
364 | */ | |
365 | ||
366 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ | |
367 | ||
368 | /* Named field types must be defined in lttng-types.h */ | |
369 | ||
370 | #undef __field | |
371 | #define __field(_type, _item) _type _item; | |
372 | ||
373 | #undef __field_ext | |
374 | #define __field_ext(_type, _item, _filter_type) __field(_type, _item) | |
375 | ||
376 | #undef __array | |
377 | #define __array(_type, _item, _length) _type _item; | |
378 | ||
64c796d8 MD |
379 | #undef __array_text |
380 | #define __array_text(_type, _item, _length) \ | |
381 | __array(_type, _item, _length) | |
382 | ||
3c4ffab9 MD |
383 | #undef __dynamic_array |
384 | #define __dynamic_array(_type, _item, _length) _type _item; | |
385 | ||
64c796d8 MD |
386 | #undef __dynamic_array_text |
387 | #define __dynamic_array_text(_type, _item, _length) \ | |
388 | __dynamic_array(_type, _item, _length) | |
389 | ||
3c4ffab9 MD |
390 | #undef __string |
391 | #define __string(_item, _src) char _item; | |
392 | ||
393 | #undef TP_STRUCT__entry | |
394 | #define TP_STRUCT__entry(args...) args | |
395 | ||
396 | #undef DECLARE_EVENT_CLASS | |
397 | #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \ | |
398 | struct __event_typemap__##_name { \ | |
399 | _tstruct \ | |
400 | }; | |
401 | ||
402 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
403 | ||
404 | ||
405 | /* | |
c099397a | 406 | * Stage 9 of the trace events. |
3c4ffab9 | 407 | * |
40652b65 MD |
408 | * Create the probe function : call even size calculation and write event data |
409 | * into the buffer. | |
e763dbf5 | 410 | * |
67e5e60c MD |
411 | * We use both the field and assignment macros to write the fields in the order |
412 | * defined in the field declaration. The field declarations control the | |
413 | * execution order, jumping to the appropriate assignment block. | |
40652b65 MD |
414 | */ |
415 | ||
e763dbf5 MD |
416 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
417 | ||
418 | #undef __field | |
419 | #define __field(_type, _item) \ | |
e763dbf5 MD |
420 | goto __assign_##_item; \ |
421 | __end_field_##_item: | |
40652b65 | 422 | |
e763dbf5 MD |
423 | #undef __field_ext |
424 | #define __field_ext(_type, _item, _filter_type) __field(_type, _item) | |
40652b65 | 425 | |
e763dbf5 MD |
426 | #undef __array |
427 | #define __array(_type, _item, _length) \ | |
e763dbf5 MD |
428 | goto __assign_##_item; \ |
429 | __end_field_##_item: | |
40652b65 | 430 | |
64c796d8 MD |
431 | #undef __array_text |
432 | #define __array_text(_type, _item, _length) \ | |
433 | __array(_type, _item, _length) | |
434 | ||
e763dbf5 MD |
435 | #undef __dynamic_array |
436 | #define __dynamic_array(_type, _item, _length) \ | |
e763dbf5 MD |
437 | goto __assign_##_item##_1; \ |
438 | __end_field_##_item##_1: \ | |
e763dbf5 MD |
439 | goto __assign_##_item##_2; \ |
440 | __end_field_##_item##_2: | |
40652b65 | 441 | |
64c796d8 MD |
442 | #undef __dynamic_array_text |
443 | #define __dynamic_array_text(_type, _item, _length) \ | |
444 | __dynamic_array(_type, _item, _length) | |
445 | ||
e763dbf5 MD |
446 | #undef __string |
447 | #define __string(_item, _src) \ | |
448 | goto __assign_##_item; \ | |
449 | __end_field_##_item: | |
450 | ||
451 | /* | |
452 | * Macros mapping tp_assign() to "=", tp_memcpy() to memcpy() and tp_strcpy() to | |
453 | * strcpy(). | |
454 | */ | |
455 | #undef tp_assign | |
456 | #define tp_assign(dest, src) \ | |
457 | __assign_##dest: \ | |
458 | { \ | |
3c4ffab9 | 459 | __typeof__(__typemap.dest) __tmp = (src); \ |
d793d5e1 | 460 | lib_ring_buffer_align_ctx(&ctx, ltt_alignof(__tmp)); \ |
3c4ffab9 | 461 | __chan->ops->event_write(&ctx, &__tmp, sizeof(__tmp)); \ |
e763dbf5 MD |
462 | } \ |
463 | goto __end_field_##dest; | |
464 | ||
465 | #undef tp_memcpy | |
466 | #define tp_memcpy(dest, src, len) \ | |
467 | __assign_##dest: \ | |
d793d5e1 MD |
468 | if (0) \ |
469 | (void) __typemap.dest; \ | |
470 | lib_ring_buffer_align_ctx(&ctx, ltt_alignof(__typemap.dest)); \ | |
e763dbf5 MD |
471 | __chan->ops->event_write(&ctx, src, len); \ |
472 | goto __end_field_##dest; | |
473 | ||
474 | #undef tp_memcpy_dyn | |
41b59694 | 475 | #define tp_memcpy_dyn(dest, src) \ |
e763dbf5 MD |
476 | __assign_##dest##_1: \ |
477 | { \ | |
41b59694 | 478 | u32 __tmpl = __dynamic_len[__dynamic_len_idx]; \ |
d793d5e1 | 479 | lib_ring_buffer_align_ctx(&ctx, ltt_alignof(u32)); \ |
e763dbf5 MD |
480 | __chan->ops->event_write(&ctx, &__tmpl, sizeof(u32)); \ |
481 | } \ | |
482 | goto __end_field_##dest##_1; \ | |
483 | __assign_##dest##_2: \ | |
d793d5e1 | 484 | lib_ring_buffer_align_ctx(&ctx, ltt_alignof(__typemap.dest)); \ |
41b59694 MD |
485 | __chan->ops->event_write(&ctx, src, \ |
486 | sizeof(__typemap.dest) * __get_dynamic_array_len(dest));\ | |
e763dbf5 MD |
487 | goto __end_field_##dest##_2; |
488 | ||
489 | #undef tp_strcpy | |
490 | #define tp_strcpy(dest, src) \ | |
3c4ffab9 | 491 | tp_memcpy(dest, src, __get_dynamic_array_len(dest)) |
40652b65 | 492 | |
e763dbf5 MD |
493 | /* Named field types must be defined in lttng-types.h */ |
494 | ||
495 | #undef __get_str | |
496 | #define __get_str(field) field | |
497 | ||
498 | #undef __get_dynamic_array | |
499 | #define __get_dynamic_array(field) field | |
500 | ||
501 | /* Beware: this get len actually consumes the len value */ | |
502 | #undef __get_dynamic_array_len | |
503 | #define __get_dynamic_array_len(field) __dynamic_len[__dynamic_len_idx++] | |
504 | ||
505 | #undef TP_PROTO | |
506 | #define TP_PROTO(args...) args | |
507 | ||
508 | #undef TP_ARGS | |
509 | #define TP_ARGS(args...) args | |
510 | ||
511 | #undef TP_STRUCT__entry | |
512 | #define TP_STRUCT__entry(args...) args | |
513 | ||
514 | #undef TP_fast_assign | |
515 | #define TP_fast_assign(args...) args | |
516 | ||
517 | #undef DECLARE_EVENT_CLASS | |
518 | #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \ | |
519 | static void __event_probe__##_name(void *__data, _proto) \ | |
520 | { \ | |
521 | struct ltt_event *__event = __data; \ | |
522 | struct ltt_channel *__chan = __event->chan; \ | |
523 | struct lib_ring_buffer_ctx ctx; \ | |
524 | size_t __event_len, __event_align; \ | |
525 | size_t __dynamic_len_idx = 0; \ | |
526 | size_t __dynamic_len[ARRAY_SIZE(__event_fields___##_name)]; \ | |
3c4ffab9 | 527 | struct __event_typemap__##_name __typemap; \ |
e763dbf5 MD |
528 | int __ret; \ |
529 | \ | |
530 | if (0) \ | |
531 | (void) __dynamic_len_idx; /* don't warn if unused */ \ | |
e64957da MD |
532 | if (unlikely(!ACCESS_ONCE(__chan->session->active))) \ |
533 | return; \ | |
534 | if (unlikely(!ACCESS_ONCE(__chan->enabled))) \ | |
535 | return; \ | |
536 | if (unlikely(!ACCESS_ONCE(__event->enabled))) \ | |
52fc2e1f | 537 | return; \ |
e763dbf5 MD |
538 | __event_len = __event_get_size__##_name(__dynamic_len, _args); \ |
539 | __event_align = __event_get_align__##_name(_args); \ | |
f1676205 | 540 | lib_ring_buffer_ctx_init(&ctx, __chan->chan, __event, __event_len, \ |
e763dbf5 | 541 | __event_align, -1); \ |
4e1f08f4 | 542 | __ret = __chan->ops->event_reserve(&ctx, __event->id); \ |
e763dbf5 MD |
543 | if (__ret < 0) \ |
544 | return; \ | |
545 | /* Control code (field ordering) */ \ | |
546 | _tstruct \ | |
547 | __chan->ops->event_commit(&ctx); \ | |
548 | return; \ | |
549 | /* Copy code, steered by control code */ \ | |
550 | _assign \ | |
551 | } | |
552 | ||
553 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
554 | ||
3afe7aac | 555 | /* |
c099397a | 556 | * Stage 10 of the trace events. |
3afe7aac MD |
557 | * |
558 | * Register/unregister probes at module load/unload. | |
559 | */ | |
560 | ||
561 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ | |
562 | ||
563 | #define TP_ID1(_token, _system) _token##_system | |
564 | #define TP_ID(_token, _system) TP_ID1(_token, _system) | |
565 | #define module_init_eval1(_token, _system) module_init(_token##_system) | |
566 | #define module_init_eval(_token, _system) module_init_eval1(_token, _system) | |
567 | #define module_exit_eval1(_token, _system) module_exit(_token##_system) | |
568 | #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system) | |
569 | ||
3afe7aac MD |
570 | static int TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void) |
571 | { | |
6d2a620c | 572 | wrapper_vmalloc_sync_all(); |
85a9ca7f | 573 | return ltt_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM)); |
3afe7aac MD |
574 | } |
575 | ||
576 | module_init_eval(__lttng_events_init__, TRACE_SYSTEM); | |
577 | ||
3afe7aac MD |
578 | static void TP_ID(__lttng_events_exit__, TRACE_SYSTEM)(void) |
579 | { | |
85a9ca7f | 580 | ltt_probe_unregister(&TP_ID(__probe_desc___, TRACE_SYSTEM)); |
3afe7aac MD |
581 | } |
582 | ||
583 | module_exit_eval(__lttng_events_exit__, TRACE_SYSTEM); | |
584 | ||
585 | #undef module_init_eval | |
586 | #undef module_exit_eval | |
587 | #undef TP_ID1 | |
588 | #undef TP_ID |