Commit | Line | Data |
---|---|---|
0a42beb6 MD |
1 | /* |
2 | * Copyright (C) 2009 Steven Rostedt <srostedt@redhat.com> | |
3 | * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
4 | * | |
5 | * This library is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU Lesser General Public | |
7 | * License as published by the Free Software Foundation; | |
8 | * version 2.1 of the License. | |
9 | * | |
10 | * This library is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this library; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | */ | |
19 | ||
20 | #include <stdio.h> | |
8d8a24c8 | 21 | #include <urcu/compiler.h> |
4318ae1b MD |
22 | #include <lttng/ust-events.h> |
23 | #include <lttng/usterr-signal-safe.h> | |
24 | #include <lttng/ringbuffer-config.h> | |
0a42beb6 MD |
25 | |
26 | /* | |
27 | * Macro declarations used for all stages. | |
28 | */ | |
29 | ||
30 | #undef ctf_integer | |
31 | #define ctf_integer(_type, _item, _src) \ | |
32 | ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10) | |
33 | ||
34 | #undef ctf_integer_hex | |
35 | #define ctf_integer_hex(_type, _item, _src) \ | |
36 | ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 16) | |
37 | ||
38 | #undef ctf_integer_network | |
39 | #define ctf_integer_network(_type, _item, _src) \ | |
40 | ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 10) | |
41 | ||
42 | #undef ctf_integer_network_hex | |
43 | #define ctf_integer_network_hex(_type, _item, _src) \ | |
44 | ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 16) | |
45 | ||
513fc97e MD |
46 | /* ctf_float is redefined at each step */ |
47 | ||
0a42beb6 MD |
48 | #undef ctf_array |
49 | #define ctf_array(_type, _item, _src, _length) \ | |
50 | ctf_array_encoded(_type, _item, _src, _length, none) | |
51 | ||
52 | #undef ctf_array_text | |
53 | #define ctf_array_text(_type, _item, _src, _length) \ | |
54 | ctf_array_encoded(_type, _item, _src, _length, UTF8) | |
55 | ||
56 | #undef ctf_sequence | |
57 | #define ctf_sequence(_type, _item, _src, _length_type, _src_length) \ | |
58 | ctf_sequence_encoded(_type, _item, _src, \ | |
59 | _length_type, _src_length, none) | |
60 | ||
61 | #undef ctf_sequence_text | |
62 | #define ctf_sequence_text(_type, _item, _src, _length_type, _src_length) \ | |
63 | ctf_sequence_encoded(_type, _item, _src, \ | |
64 | _length_type, _src_length, UTF8) | |
65 | ||
66 | /* ctf_string is redefined at each step */ | |
67 | ||
68 | /* | |
69 | * TRACEPOINT_EVENT_CLASS can be used to add a generic function handlers | |
70 | * for events. That is, if all events have the same parameters and just | |
71 | * have distinct trace points. Each tracepoint can be defined with | |
72 | * TRACEPOINT_EVENT_INSTANCE and that will map the | |
73 | * TRACEPOINT_EVENT_CLASS to the tracepoint. | |
74 | * | |
75 | * TRACEPOINT_EVENT is a one to one mapping between tracepoint and | |
76 | * template. | |
77 | */ | |
78 | ||
79 | #undef TRACEPOINT_EVENT | |
63ef2693 | 80 | #define TRACEPOINT_EVENT(provider, name, args, fields) \ |
7083f0fe | 81 | TRACEPOINT_EVENT_CLASS(provider, name, \ |
0a42beb6 MD |
82 | TP_PARAMS(args), \ |
83 | TP_PARAMS(fields)) \ | |
63ef2693 | 84 | TRACEPOINT_EVENT_INSTANCE(provider, name, name, TP_PARAMS(args)) |
8d8a24c8 MD |
85 | |
86 | /* Helpers */ | |
87 | #define _TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) | |
88 | ||
1dbfff0c MD |
89 | #define _tp_max_t(type, x, y) \ |
90 | ({ \ | |
91 | type __max1 = (x); \ | |
92 | type __max2 = (y); \ | |
93 | __max1 > __max2 ? __max1: __max2; \ | |
94 | }) | |
95 | ||
34a4456d MD |
96 | /* |
97 | * Stage 0 of the trace events. | |
98 | * | |
99 | * Check that each TRACEPOINT_EVENT provider argument match the | |
100 | * TRACEPOINT_PROVIDER by creating dummy callbacks. | |
101 | */ | |
102 | ||
103 | /* Reset all macros within TRACEPOINT_EVENT */ | |
104 | #include <lttng/ust-tracepoint-event-reset.h> | |
105 | ||
106 | #define TP_ID1(_token, _provider) _token##_provider | |
107 | #define TP_ID(_token, _provider) TP_ID1(_token, _provider) | |
108 | ||
109 | static inline | |
110 | void TP_ID(__tracepoint_provider_mismatch_, TRACEPOINT_PROVIDER)(void) | |
111 | { | |
112 | } | |
113 | ||
114 | #undef TRACEPOINT_EVENT_CLASS | |
63ef2693 | 115 | #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ |
34a4456d MD |
116 | __tracepoint_provider_mismatch_##_provider(); |
117 | ||
118 | #undef TRACEPOINT_EVENT_INSTANCE | |
63ef2693 | 119 | #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \ |
34a4456d MD |
120 | __tracepoint_provider_mismatch_##_provider(); |
121 | ||
122 | static __attribute__((unused)) | |
123 | void TP_ID(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)(void) | |
124 | { | |
125 | #include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) | |
126 | } | |
127 | ||
128 | #undef TP_ID1 | |
129 | #undef TP_ID | |
1dbfff0c | 130 | |
0a42beb6 MD |
131 | /* |
132 | * Stage 1 of the trace events. | |
133 | * | |
134 | * Create event field type metadata section. | |
135 | * Each event produce an array of fields. | |
136 | */ | |
137 | ||
8d8a24c8 | 138 | /* Reset all macros within TRACEPOINT_EVENT */ |
4318ae1b | 139 | #include <lttng/ust-tracepoint-event-reset.h> |
0a42beb6 MD |
140 | |
141 | #undef ctf_integer_ext | |
142 | #define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ | |
143 | { \ | |
144 | .name = #_item, \ | |
145 | .type = __type_integer(_type, _byte_order, _base, none),\ | |
146 | }, | |
147 | ||
20f1eee7 MD |
148 | #undef ctf_float |
149 | #define ctf_float(_type, _item, _src) \ | |
150 | { \ | |
151 | .name = #_item, \ | |
152 | .type = __type_float(_type), \ | |
153 | }, | |
154 | ||
0a42beb6 MD |
155 | #undef ctf_array_encoded |
156 | #define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ | |
157 | { \ | |
158 | .name = #_item, \ | |
159 | .type = \ | |
160 | { \ | |
161 | .atype = atype_array, \ | |
162 | .u.array = \ | |
163 | { \ | |
164 | .length = _length, \ | |
165 | .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ | |
166 | }, \ | |
167 | }, \ | |
168 | }, | |
169 | ||
170 | #undef ctf_sequence_encoded | |
171 | #define ctf_sequence_encoded(_type, _item, _src, \ | |
172 | _length_type, _src_length, _encoding) \ | |
173 | { \ | |
174 | .name = #_item, \ | |
175 | .type = \ | |
176 | { \ | |
177 | .atype = atype_sequence, \ | |
178 | .u.sequence = \ | |
179 | { \ | |
180 | .length_type = __type_integer(_length_type, BYTE_ORDER, 10, none), \ | |
181 | .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ | |
182 | }, \ | |
183 | }, \ | |
184 | }, | |
185 | ||
186 | #undef ctf_string | |
187 | #define ctf_string(_item, _src) \ | |
188 | { \ | |
189 | .name = #_item, \ | |
190 | .type = \ | |
191 | { \ | |
192 | .atype = atype_string, \ | |
193 | .u.basic.string.encoding = lttng_encode_UTF8, \ | |
194 | }, \ | |
195 | }, | |
196 | ||
197 | #undef TP_FIELDS | |
198 | #define TP_FIELDS(args...) args /* Only one used in this phase */ | |
199 | ||
63ef2693 MD |
200 | #undef TRACEPOINT_EVENT_CLASS |
201 | #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ | |
7083f0fe | 202 | static const struct lttng_event_field __event_fields___##_provider##___##_name[] = { \ |
63ef2693 | 203 | _fields \ |
0a42beb6 MD |
204 | }; |
205 | ||
8d8a24c8 | 206 | #include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) |
0a42beb6 MD |
207 | |
208 | /* | |
209 | * Stage 2 of the trace events. | |
210 | * | |
211 | * Create probe callback prototypes. | |
212 | */ | |
213 | ||
8d8a24c8 | 214 | /* Reset all macros within TRACEPOINT_EVENT */ |
4318ae1b | 215 | #include <lttng/ust-tracepoint-event-reset.h> |
0a42beb6 | 216 | |
63ef2693 MD |
217 | #undef TP_ARGS |
218 | #define TP_ARGS(args...) args | |
0a42beb6 MD |
219 | |
220 | #undef TRACEPOINT_EVENT_CLASS | |
63ef2693 MD |
221 | #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ |
222 | static void __event_probe__##_provider##___##_name(_TP_ARGS_PROTO_DATA(_args)); | |
8d8a24c8 MD |
223 | |
224 | #include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) | |
0a42beb6 MD |
225 | |
226 | /* | |
227 | * Stage 3 of the trace events. | |
228 | * | |
229 | * Create an array of events. | |
230 | */ | |
231 | ||
8d8a24c8 | 232 | /* Reset all macros within TRACEPOINT_EVENT */ |
4318ae1b | 233 | #include <lttng/ust-tracepoint-event-reset.h> |
0a42beb6 | 234 | |
63ef2693 MD |
235 | #undef TRACEPOINT_EVENT_INSTANCE |
236 | #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \ | |
0a42beb6 | 237 | { \ |
7083f0fe MD |
238 | .fields = __event_fields___##_provider##___##_template,\ |
239 | .name = #_provider ":" #_name, \ | |
240 | .probe_callback = (void *) &__event_probe__##_provider##___##_template,\ | |
241 | .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \ | |
0a42beb6 MD |
242 | }, |
243 | ||
a4ada9b8 MD |
244 | #define TP_ID1(_token, _provider) _token##_provider |
245 | #define TP_ID(_token, _provider) TP_ID1(_token, _provider) | |
0a42beb6 | 246 | |
a4ada9b8 | 247 | static const struct lttng_event_desc TP_ID(__event_desc___, TRACEPOINT_PROVIDER)[] = { |
8d8a24c8 | 248 | #include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) |
0a42beb6 MD |
249 | }; |
250 | ||
251 | #undef TP_ID1 | |
252 | #undef TP_ID | |
253 | ||
254 | ||
255 | /* | |
256 | * Stage 4 of the trace events. | |
257 | * | |
258 | * Create a toplevel descriptor for the whole probe. | |
259 | */ | |
260 | ||
a4ada9b8 MD |
261 | #define TP_ID1(_token, _provider) _token##_provider |
262 | #define TP_ID(_token, _provider) TP_ID1(_token, _provider) | |
0a42beb6 MD |
263 | |
264 | /* non-const because list head will be modified when registered. */ | |
a4ada9b8 MD |
265 | static struct lttng_probe_desc TP_ID(__probe_desc___, TRACEPOINT_PROVIDER) = { |
266 | .event_desc = TP_ID(__event_desc___, TRACEPOINT_PROVIDER), | |
267 | .nr_events = _TP_ARRAY_SIZE(TP_ID(__event_desc___, TRACEPOINT_PROVIDER)), | |
0a42beb6 MD |
268 | }; |
269 | ||
270 | #undef TP_ID1 | |
271 | #undef TP_ID | |
272 | ||
273 | /* | |
274 | * Stage 5 of the trace events. | |
275 | * | |
276 | * Create static inline function that calculates event size. | |
277 | */ | |
278 | ||
8d8a24c8 | 279 | /* Reset all macros within TRACEPOINT_EVENT */ |
4318ae1b | 280 | #include <lttng/ust-tracepoint-event-reset.h> |
0a42beb6 MD |
281 | |
282 | #undef ctf_integer_ext | |
283 | #define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ | |
1dbfff0c | 284 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
0a42beb6 MD |
285 | __event_len += sizeof(_type); |
286 | ||
20f1eee7 MD |
287 | #undef ctf_float |
288 | #define ctf_float(_type, _item, _src) \ | |
1dbfff0c | 289 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
20f1eee7 MD |
290 | __event_len += sizeof(_type); |
291 | ||
0a42beb6 | 292 | #undef ctf_array_encoded |
41aaf8a5 | 293 | #define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ |
1dbfff0c | 294 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
0a42beb6 MD |
295 | __event_len += sizeof(_type) * (_length); |
296 | ||
297 | #undef ctf_sequence_encoded | |
298 | #define ctf_sequence_encoded(_type, _item, _src, _length_type, \ | |
299 | _src_length, _encoding) \ | |
1dbfff0c | 300 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \ |
0a42beb6 | 301 | __event_len += sizeof(_length_type); \ |
1dbfff0c | 302 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
5dba5937 | 303 | __dynamic_len[__dynamic_len_idx] = (_src_length); \ |
0a42beb6 MD |
304 | __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ |
305 | __dynamic_len_idx++; | |
306 | ||
307 | #undef ctf_string | |
308 | #define ctf_string(_item, _src) \ | |
309 | __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1; | |
310 | ||
63ef2693 MD |
311 | #undef TP_ARGS |
312 | #define TP_ARGS(args...) args | |
0a42beb6 MD |
313 | |
314 | #undef TP_FIELDS | |
315 | #define TP_FIELDS(args...) args | |
316 | ||
317 | #undef TRACEPOINT_EVENT_CLASS | |
63ef2693 MD |
318 | #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ |
319 | static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_PROTO_DATA(_args)) \ | |
0a42beb6 MD |
320 | { \ |
321 | size_t __event_len = 0; \ | |
322 | unsigned int __dynamic_len_idx = 0; \ | |
323 | \ | |
324 | if (0) \ | |
325 | (void) __dynamic_len_idx; /* don't warn if unused */ \ | |
326 | _fields \ | |
327 | return __event_len; \ | |
328 | } | |
329 | ||
8d8a24c8 | 330 | #include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) |
0a42beb6 MD |
331 | |
332 | /* | |
333 | * Stage 6 of the trace events. | |
334 | * | |
335 | * Create static inline function that calculates event payload alignment. | |
336 | */ | |
337 | ||
8d8a24c8 | 338 | /* Reset all macros within TRACEPOINT_EVENT */ |
4318ae1b | 339 | #include <lttng/ust-tracepoint-event-reset.h> |
0a42beb6 MD |
340 | |
341 | #undef ctf_integer_ext | |
342 | #define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ | |
1dbfff0c | 343 | __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); |
0a42beb6 | 344 | |
20f1eee7 MD |
345 | #undef ctf_float |
346 | #define ctf_float(_type, _item, _src) \ | |
1dbfff0c | 347 | __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); |
20f1eee7 | 348 | |
0a42beb6 | 349 | #undef ctf_array_encoded |
41aaf8a5 | 350 | #define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ |
1dbfff0c | 351 | __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); |
0a42beb6 MD |
352 | |
353 | #undef ctf_sequence_encoded | |
354 | #define ctf_sequence_encoded(_type, _item, _src, _length_type, \ | |
355 | _src_length, _encoding) \ | |
1dbfff0c MD |
356 | __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_length_type)); \ |
357 | __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); | |
0a42beb6 MD |
358 | |
359 | #undef ctf_string | |
360 | #define ctf_string(_item, _src) | |
361 | ||
63ef2693 MD |
362 | #undef TP_ARGS |
363 | #define TP_ARGS(args...) args | |
0a42beb6 MD |
364 | |
365 | #undef TP_FIELDS | |
366 | #define TP_FIELDS(args...) args | |
367 | ||
368 | #undef TRACEPOINT_EVENT_CLASS | |
63ef2693 MD |
369 | #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ |
370 | static inline \ | |
371 | size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \ | |
0a42beb6 MD |
372 | { \ |
373 | size_t __event_align = 1; \ | |
374 | _fields \ | |
375 | return __event_align; \ | |
376 | } | |
377 | ||
8d8a24c8 | 378 | #include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) |
0a42beb6 MD |
379 | |
380 | ||
381 | /* | |
382 | * Stage 7 of the trace events. | |
383 | * | |
384 | * Create the probe function : call even size calculation and write event data | |
385 | * into the buffer. | |
386 | * | |
387 | * We use both the field and assignment macros to write the fields in the order | |
388 | * defined in the field declaration. The field declarations control the | |
389 | * execution order, jumping to the appropriate assignment block. | |
390 | */ | |
391 | ||
8d8a24c8 | 392 | /* Reset all macros within TRACEPOINT_EVENT */ |
4318ae1b | 393 | #include <lttng/ust-tracepoint-event-reset.h> |
0a42beb6 MD |
394 | |
395 | #undef ctf_integer_ext | |
396 | #define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ | |
397 | { \ | |
398 | _type __tmp = (_src); \ | |
b8b77c00 MD |
399 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\ |
400 | __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\ | |
0a42beb6 MD |
401 | } |
402 | ||
20f1eee7 MD |
403 | #undef ctf_float |
404 | #define ctf_float(_type, _item, _src) \ | |
405 | { \ | |
406 | _type __tmp = (_src); \ | |
b8b77c00 MD |
407 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\ |
408 | __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\ | |
20f1eee7 MD |
409 | } |
410 | ||
0a42beb6 | 411 | #undef ctf_array_encoded |
41aaf8a5 | 412 | #define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ |
b8b77c00 MD |
413 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ |
414 | __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); | |
0a42beb6 MD |
415 | |
416 | #undef ctf_sequence_encoded | |
417 | #define ctf_sequence_encoded(_type, _item, _src, _length_type, \ | |
418 | _src_length, _encoding) \ | |
419 | { \ | |
420 | _length_type __tmpl = __dynamic_len[__dynamic_len_idx]; \ | |
b8b77c00 MD |
421 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ |
422 | __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\ | |
0a42beb6 | 423 | } \ |
b8b77c00 MD |
424 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ |
425 | __chan->ops->event_write(&__ctx, _src, \ | |
5dba5937 | 426 | sizeof(_type) * __get_dynamic_len(dest)); |
0a42beb6 MD |
427 | |
428 | #undef ctf_string | |
429 | #define ctf_string(_item, _src) \ | |
b8b77c00 MD |
430 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \ |
431 | __chan->ops->event_write(&__ctx, _src, __get_dynamic_len(dest)); | |
0a42beb6 MD |
432 | |
433 | /* Beware: this get len actually consumes the len value */ | |
5dba5937 MD |
434 | #undef __get_dynamic_len |
435 | #define __get_dynamic_len(field) __dynamic_len[__dynamic_len_idx++] | |
0a42beb6 | 436 | |
63ef2693 MD |
437 | #undef TP_ARGS |
438 | #define TP_ARGS(args...) args | |
0a42beb6 MD |
439 | |
440 | #undef TP_FIELDS | |
441 | #define TP_FIELDS(args...) args | |
442 | ||
443 | #undef TRACEPOINT_EVENT_CLASS | |
63ef2693 MD |
444 | #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ |
445 | static void __event_probe__##_provider##___##_name(_TP_ARGS_PROTO_DATA(_args))\ | |
0a42beb6 | 446 | { \ |
63ef2693 | 447 | struct ltt_event *__event = __tp_cb_data; \ |
0a42beb6 | 448 | struct ltt_channel *__chan = __event->chan; \ |
4cfec15c | 449 | struct lttng_ust_lib_ring_buffer_ctx __ctx; \ |
0a42beb6 MD |
450 | size_t __event_len, __event_align; \ |
451 | size_t __dynamic_len_idx = 0; \ | |
7083f0fe | 452 | size_t __dynamic_len[_TP_ARRAY_SIZE(__event_fields___##_provider##___##_name)]; \ |
0a42beb6 MD |
453 | int __ret; \ |
454 | \ | |
455 | if (0) \ | |
456 | (void) __dynamic_len_idx; /* don't warn if unused */ \ | |
b5a3dfa5 | 457 | if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->session->active))) \ |
0a42beb6 | 458 | return; \ |
b5a3dfa5 | 459 | if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->enabled))) \ |
0a42beb6 | 460 | return; \ |
b5a3dfa5 | 461 | if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \ |
0a42beb6 | 462 | return; \ |
63ef2693 MD |
463 | __event_len = __event_get_size__##_provider##___##_name(__dynamic_len,\ |
464 | _TP_ARGS_VARS_DATA(_args)); \ | |
465 | __event_align = __event_get_align__##_provider##___##_name(_TP_ARGS_VARS(_args)); \ | |
b8b77c00 | 466 | lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \ |
1d498196 | 467 | __event_align, -1, __chan->handle); \ |
b8b77c00 | 468 | __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ |
8d8a24c8 MD |
469 | if (__ret < 0) \ |
470 | return; \ | |
471 | _fields \ | |
b8b77c00 | 472 | __chan->ops->event_commit(&__ctx); \ |
8d8a24c8 MD |
473 | } |
474 | ||
475 | #include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) | |
0a42beb6 | 476 | |
5dba5937 MD |
477 | #undef __get_dynamic_len |
478 | ||
0a42beb6 MD |
479 | /* |
480 | * Stage 8 of the trace events. | |
481 | * | |
482 | * Register/unregister probes at module load/unload. | |
483 | */ | |
484 | ||
8d8a24c8 | 485 | /* Reset all macros within TRACEPOINT_EVENT */ |
4318ae1b | 486 | #include <lttng/ust-tracepoint-event-reset.h> |
0a42beb6 | 487 | |
a4ada9b8 MD |
488 | #define TP_ID1(_token, _provider) _token##_provider |
489 | #define TP_ID(_token, _provider) TP_ID1(_token, _provider) | |
0a42beb6 MD |
490 | |
491 | static void __attribute__((constructor)) | |
a4ada9b8 | 492 | TP_ID(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) |
0a42beb6 MD |
493 | { |
494 | int ret; | |
495 | ||
a4ada9b8 | 496 | ret = ltt_probe_register(&TP_ID(__probe_desc___, TRACEPOINT_PROVIDER)); |
0a42beb6 MD |
497 | assert(!ret); |
498 | } | |
499 | ||
500 | static void __attribute__((destructor)) | |
a4ada9b8 | 501 | TP_ID(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void) |
0a42beb6 | 502 | { |
a4ada9b8 | 503 | ltt_probe_unregister(&TP_ID(__probe_desc___, TRACEPOINT_PROVIDER)); |
0a42beb6 MD |
504 | } |
505 | ||
506 | #undef TP_ID1 | |
507 | #undef TP_ID |