Commit | Line | Data |
---|---|---|
b7cdc182 | 1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
9f36eaed | 2 | * |
3b4aafcb | 3 | * lttng/tracepoint-event-impl.h |
17baffe2 MD |
4 | * |
5 | * Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org> | |
f127e61e | 6 | * Copyright (C) 2009-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
17baffe2 | 7 | */ |
f127e61e | 8 | |
d28686c1 | 9 | #include <linux/uaccess.h> |
d0dd2ecb | 10 | #include <linux/debugfs.h> |
f127e61e | 11 | #include <linux/rculist.h> |
43803cf2 | 12 | #include <asm/byteorder.h> |
bf1a9179 | 13 | #include <linux/swab.h> |
8d43abb7 | 14 | |
263b6c88 | 15 | #include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */ |
24591303 MD |
16 | #include <ringbuffer/frontend_types.h> |
17 | #include <ringbuffer/backend.h> | |
8d43abb7 | 18 | #include <wrapper/rcu.h> |
608416e1 | 19 | #include <wrapper/user_namespace.h> |
2df37e95 MD |
20 | #include <lttng/types.h> |
21 | #include <lttng/probe-user.h> | |
22 | #include <lttng/events.h> | |
23 | #include <lttng/tracer-core.h> | |
24 | #include <lttng/tp-mempool.h> | |
40652b65 | 25 | |
1d84e8e7 MD |
26 | #define __LTTNG_NULL_STRING "(null)" |
27 | ||
3b4aafcb MD |
28 | #undef PARAMS |
29 | #define PARAMS(args...) args | |
30 | ||
40652b65 | 31 | /* |
6db3d13b | 32 | * Macro declarations used for all stages. |
40652b65 MD |
33 | */ |
34 | ||
76e4f017 MD |
35 | /* |
36 | * LTTng name mapping macros. LTTng remaps some of the kernel events to | |
37 | * enforce name-spacing. | |
38 | */ | |
3bc29f0a | 39 | #undef LTTNG_TRACEPOINT_EVENT_MAP |
f127e61e | 40 | #define LTTNG_TRACEPOINT_EVENT_MAP(name, map, proto, args, fields) \ |
3bc29f0a | 41 | LTTNG_TRACEPOINT_EVENT_CLASS(map, \ |
76e4f017 MD |
42 | PARAMS(proto), \ |
43 | PARAMS(args), \ | |
f127e61e | 44 | PARAMS(fields)) \ |
3bc29f0a | 45 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args)) |
76e4f017 | 46 | |
3bc29f0a | 47 | #undef LTTNG_TRACEPOINT_EVENT_MAP_NOARGS |
f127e61e | 48 | #define LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, map, fields) \ |
3bc29f0a | 49 | LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(map, \ |
f127e61e | 50 | PARAMS(fields)) \ |
3bc29f0a | 51 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(map, name, map) |
76e4f017 | 52 | |
f127e61e | 53 | #undef LTTNG_TRACEPOINT_EVENT_CODE_MAP |
265822ae | 54 | #define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code_pre, fields, _code_post) \ |
f127e61e MD |
55 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE(map, \ |
56 | PARAMS(proto), \ | |
57 | PARAMS(args), \ | |
58 | PARAMS(_locvar), \ | |
265822ae MD |
59 | PARAMS(_code_pre), \ |
60 | PARAMS(fields), \ | |
61 | PARAMS(_code_post)) \ | |
f127e61e MD |
62 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args)) |
63 | ||
3bc29f0a | 64 | #undef LTTNG_TRACEPOINT_EVENT_CODE |
265822ae | 65 | #define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code_pre, fields, _code_post) \ |
f127e61e | 66 | LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, name, \ |
7ca580f8 MD |
67 | PARAMS(proto), \ |
68 | PARAMS(args), \ | |
69 | PARAMS(_locvar), \ | |
265822ae MD |
70 | PARAMS(_code_pre), \ |
71 | PARAMS(fields), \ | |
72 | PARAMS(_code_post)) | |
fcf7fa33 | 73 | |
40652b65 | 74 | /* |
3bc29f0a MD |
75 | * LTTNG_TRACEPOINT_EVENT_CLASS can be used to add a generic function |
76 | * handlers for events. That is, if all events have the same parameters | |
77 | * and just have distinct trace points. Each tracepoint can be defined | |
78 | * with LTTNG_TRACEPOINT_EVENT_INSTANCE and that will map the | |
79 | * LTTNG_TRACEPOINT_EVENT_CLASS to the tracepoint. | |
40652b65 | 80 | * |
3bc29f0a MD |
81 | * LTTNG_TRACEPOINT_EVENT is a one to one mapping between tracepoint and |
82 | * template. | |
40652b65 | 83 | */ |
6db3d13b | 84 | |
3bc29f0a | 85 | #undef LTTNG_TRACEPOINT_EVENT |
f127e61e | 86 | #define LTTNG_TRACEPOINT_EVENT(name, proto, args, fields) \ |
3bc29f0a MD |
87 | LTTNG_TRACEPOINT_EVENT_MAP(name, name, \ |
88 | PARAMS(proto), \ | |
89 | PARAMS(args), \ | |
f127e61e | 90 | PARAMS(fields)) |
40652b65 | 91 | |
3bc29f0a | 92 | #undef LTTNG_TRACEPOINT_EVENT_NOARGS |
f127e61e MD |
93 | #define LTTNG_TRACEPOINT_EVENT_NOARGS(name, fields) \ |
94 | LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, name, PARAMS(fields)) | |
76e4f017 | 95 | |
3bc29f0a MD |
96 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE |
97 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \ | |
98 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(template, name, name, PARAMS(proto), PARAMS(args)) | |
76e4f017 | 99 | |
3bc29f0a MD |
100 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS |
101 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \ | |
102 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(template, name, name) | |
76e4f017 | 103 | |
3bc29f0a | 104 | #undef LTTNG_TRACEPOINT_EVENT_CLASS |
f127e61e | 105 | #define LTTNG_TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ |
3bc29f0a | 106 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(_proto), PARAMS(_args), , , \ |
265822ae | 107 | PARAMS(_fields), ) |
7ca580f8 | 108 | |
3bc29f0a | 109 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS |
f127e61e | 110 | #define LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \ |
265822ae | 111 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, , , PARAMS(_fields), ) |
7ca580f8 MD |
112 | |
113 | ||
f62b389e | 114 | /* |
c099397a | 115 | * Stage 1 of the trace events. |
f62b389e MD |
116 | * |
117 | * Create dummy trace calls for each events, verifying that the LTTng module | |
3bc29f0a MD |
118 | * instrumentation headers match the kernel arguments. Will be optimized |
119 | * out by the compiler. | |
f62b389e MD |
120 | */ |
121 | ||
f127e61e | 122 | /* Reset all macros within TRACEPOINT_EVENT */ |
3b4aafcb | 123 | #include <lttng/events-reset.h> |
f62b389e MD |
124 | |
125 | #undef TP_PROTO | |
f127e61e | 126 | #define TP_PROTO(...) __VA_ARGS__ |
f62b389e MD |
127 | |
128 | #undef TP_ARGS | |
f127e61e | 129 | #define TP_ARGS(...) __VA_ARGS__ |
f62b389e | 130 | |
3bc29f0a MD |
131 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP |
132 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \ | |
7eb827f2 | 133 | void trace_##_name(_proto); |
f62b389e | 134 | |
3bc29f0a MD |
135 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS |
136 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \ | |
cb1aa0c7 | 137 | void trace_##_name(void); |
f7bdf4db | 138 | |
f62b389e MD |
139 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
140 | ||
d0558de2 MD |
141 | /* |
142 | * Stage 1.1 of the trace events. | |
143 | * | |
144 | * Create dummy trace prototypes for each event class, and for each used | |
145 | * template. This will allow checking whether the prototypes from the | |
146 | * class and the instance using the class actually match. | |
147 | */ | |
148 | ||
3b4aafcb | 149 | #include <lttng/events-reset.h> /* Reset all macros within TRACE_EVENT */ |
d0558de2 MD |
150 | |
151 | #undef TP_PROTO | |
152 | #define TP_PROTO(...) __VA_ARGS__ | |
153 | ||
154 | #undef TP_ARGS | |
155 | #define TP_ARGS(...) __VA_ARGS__ | |
156 | ||
157 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP | |
158 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \ | |
159 | void __event_template_proto___##_template(_proto); | |
160 | ||
161 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS | |
162 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \ | |
163 | void __event_template_proto___##_template(void); | |
164 | ||
165 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE | |
265822ae | 166 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
d0558de2 MD |
167 | void __event_template_proto___##_name(_proto); |
168 | ||
169 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS | |
265822ae | 170 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
d0558de2 MD |
171 | void __event_template_proto___##_name(void); |
172 | ||
173 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
174 | ||
7fad9b39 FD |
175 | /* |
176 | * Stage 1.2 of the trace event_notifier. | |
177 | * | |
178 | * Create dummy trace prototypes for each event class, and for each used | |
179 | * template. This will allow checking whether the prototypes from the | |
180 | * class and the instance using the class actually match. | |
181 | */ | |
182 | ||
183 | #include <lttng/events-reset.h> /* Reset all macros within TRACE_EVENT */ | |
184 | ||
185 | #undef TP_PROTO | |
186 | #define TP_PROTO(...) __VA_ARGS__ | |
187 | ||
188 | #undef TP_ARGS | |
189 | #define TP_ARGS(...) __VA_ARGS__ | |
190 | ||
191 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP | |
192 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \ | |
193 | void __event_notifier_template_proto___##_template(_proto); | |
194 | ||
195 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS | |
196 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \ | |
197 | void __event_notifier_template_proto___##_template(void); | |
198 | ||
199 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE | |
200 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ | |
201 | void __event_notifier_template_proto___##_name(_proto); | |
202 | ||
203 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS | |
204 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ | |
205 | void __event_notifier_template_proto___##_name(void); | |
206 | ||
207 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
208 | ||
209 | ||
141ddf28 MD |
210 | /* |
211 | * Stage 1.2 of tracepoint event generation | |
212 | * | |
213 | * Unfolding the enums | |
214 | */ | |
3b4aafcb | 215 | #include <lttng/events-reset.h> /* Reset all macros within TRACE_EVENT */ |
141ddf28 MD |
216 | |
217 | /* Enumeration entry (single value) */ | |
218 | #undef ctf_enum_value | |
219 | #define ctf_enum_value(_string, _value) \ | |
220 | { \ | |
221 | .start = { \ | |
222 | .signedness = lttng_is_signed_type(__typeof__(_value)), \ | |
223 | .value = lttng_is_signed_type(__typeof__(_value)) ? \ | |
224 | (long long) (_value) : (_value), \ | |
225 | }, \ | |
226 | .end = { \ | |
227 | .signedness = lttng_is_signed_type(__typeof__(_value)), \ | |
228 | .value = lttng_is_signed_type(__typeof__(_value)) ? \ | |
229 | (long long) (_value) : (_value), \ | |
230 | }, \ | |
231 | .string = (_string), \ | |
232 | }, | |
233 | ||
234 | /* Enumeration entry (range) */ | |
235 | #undef ctf_enum_range | |
236 | #define ctf_enum_range(_string, _range_start, _range_end) \ | |
237 | { \ | |
238 | .start = { \ | |
239 | .signedness = lttng_is_signed_type(__typeof__(_range_start)), \ | |
240 | .value = lttng_is_signed_type(__typeof__(_range_start)) ? \ | |
241 | (long long) (_range_start) : (_range_start), \ | |
242 | }, \ | |
243 | .end = { \ | |
244 | .signedness = lttng_is_signed_type(__typeof__(_range_end)), \ | |
245 | .value = lttng_is_signed_type(__typeof__(_range_end)) ? \ | |
246 | (long long) (_range_end) : (_range_end), \ | |
247 | }, \ | |
248 | .string = (_string), \ | |
249 | }, | |
250 | ||
08ad1061 PP |
251 | /* Enumeration entry (automatic value; follows the rules of CTF) */ |
252 | #undef ctf_enum_auto | |
253 | #define ctf_enum_auto(_string) \ | |
254 | { \ | |
255 | .start = { \ | |
256 | .signedness = -1, \ | |
257 | .value = -1, \ | |
258 | }, \ | |
259 | .end = { \ | |
260 | .signedness = -1, \ | |
261 | .value = -1, \ | |
262 | }, \ | |
263 | .string = (_string), \ | |
264 | .options = { \ | |
265 | .is_auto = 1, \ | |
266 | } \ | |
267 | }, | |
268 | ||
141ddf28 MD |
269 | #undef TP_ENUM_VALUES |
270 | #define TP_ENUM_VALUES(...) \ | |
271 | __VA_ARGS__ | |
272 | ||
273 | #undef LTTNG_TRACEPOINT_ENUM | |
274 | #define LTTNG_TRACEPOINT_ENUM(_name, _values) \ | |
275 | const struct lttng_enum_entry __enum_values__##_name[] = { \ | |
276 | _values \ | |
277 | }; | |
278 | ||
279 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
280 | ||
6db3d13b | 281 | /* |
c099397a | 282 | * Stage 2 of the trace events. |
6db3d13b MD |
283 | * |
284 | * Create event field type metadata section. | |
285 | * Each event produce an array of fields. | |
286 | */ | |
287 | ||
f127e61e | 288 | /* Reset all macros within TRACEPOINT_EVENT */ |
3b4aafcb MD |
289 | #include <lttng/events-reset.h> |
290 | #include <lttng/events-write.h> | |
291 | #include <lttng/events-nowrite.h> | |
6db3d13b | 292 | |
f127e61e MD |
293 | #undef _ctf_integer_ext |
294 | #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \ | |
c099397a MD |
295 | { \ |
296 | .name = #_item, \ | |
ceabb767 | 297 | .type = __type_integer(_type, 0, 0, -1, _byte_order, _base, none), \ |
f127e61e MD |
298 | .nowrite = _nowrite, \ |
299 | .user = _user, \ | |
ceabb767 | 300 | .nofilter = 0, \ |
c099397a | 301 | }, |
40652b65 | 302 | |
f127e61e | 303 | #undef _ctf_array_encoded |
ceabb767 MD |
304 | #define _ctf_array_encoded(_type, _item, _src, _length, \ |
305 | _encoding, _byte_order, _elem_type_base, _user, _nowrite) \ | |
299338c8 | 306 | { \ |
c099397a MD |
307 | .name = #_item, \ |
308 | .type = \ | |
309 | { \ | |
ceabb767 | 310 | .atype = atype_array_nestable, \ |
f127e61e | 311 | .u = \ |
c099397a | 312 | { \ |
ceabb767 | 313 | .array_nestable = \ |
f127e61e | 314 | { \ |
ceabb767 MD |
315 | .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \ |
316 | __type_integer(_type, 0, 0, -1, _byte_order, _elem_type_base, _encoding)), \ | |
f127e61e | 317 | .length = _length, \ |
ceabb767 | 318 | .alignment = 0, \ |
f127e61e MD |
319 | } \ |
320 | } \ | |
299338c8 | 321 | }, \ |
f127e61e MD |
322 | .nowrite = _nowrite, \ |
323 | .user = _user, \ | |
ceabb767 | 324 | .nofilter = 0, \ |
299338c8 | 325 | }, |
40652b65 | 326 | |
43803cf2 MD |
327 | #undef _ctf_array_bitfield |
328 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ | |
329 | { \ | |
330 | .name = #_item, \ | |
331 | .type = \ | |
332 | { \ | |
ceabb767 | 333 | .atype = atype_array_nestable, \ |
43803cf2 MD |
334 | .u = \ |
335 | { \ | |
ceabb767 | 336 | .array_nestable = \ |
43803cf2 | 337 | { \ |
ceabb767 MD |
338 | .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \ |
339 | __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none)), \ | |
43803cf2 | 340 | .length = (_length) * sizeof(_type) * CHAR_BIT, \ |
ceabb767 | 341 | .alignment = lttng_alignof(_type), \ |
43803cf2 MD |
342 | } \ |
343 | } \ | |
344 | }, \ | |
345 | .nowrite = _nowrite, \ | |
346 | .user = _user, \ | |
ceabb767 | 347 | .nofilter = 0, \ |
43803cf2 MD |
348 | }, |
349 | ||
350 | ||
f127e61e MD |
351 | #undef _ctf_sequence_encoded |
352 | #define _ctf_sequence_encoded(_type, _item, _src, \ | |
353 | _length_type, _src_length, _encoding, \ | |
ceabb767 MD |
354 | _byte_order, _elem_type_base, _user, _nowrite) \ |
355 | { \ | |
356 | .name = "_" #_item "_length", \ | |
357 | .type = __type_integer(_length_type, 0, 0, -1, __BYTE_ORDER, 10, none), \ | |
358 | .nowrite = _nowrite, \ | |
359 | .nofilter = 1, \ | |
360 | }, \ | |
299338c8 | 361 | { \ |
c099397a MD |
362 | .name = #_item, \ |
363 | .type = \ | |
364 | { \ | |
ceabb767 | 365 | .atype = atype_sequence_nestable, \ |
f127e61e | 366 | .u = \ |
c099397a | 367 | { \ |
ceabb767 | 368 | .sequence_nestable = \ |
f127e61e | 369 | { \ |
ceabb767 MD |
370 | .length_name = "_" #_item "_length", \ |
371 | .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \ | |
372 | __type_integer(_type, 0, 0, -1, _byte_order, _elem_type_base, _encoding)), \ | |
373 | .alignment = 0, \ | |
43803cf2 MD |
374 | }, \ |
375 | }, \ | |
376 | }, \ | |
377 | .nowrite = _nowrite, \ | |
378 | .user = _user, \ | |
ceabb767 | 379 | .nofilter = 0, \ |
43803cf2 MD |
380 | }, |
381 | ||
382 | #undef _ctf_sequence_bitfield | |
383 | #define _ctf_sequence_bitfield(_type, _item, _src, \ | |
384 | _length_type, _src_length, \ | |
385 | _user, _nowrite) \ | |
ceabb767 MD |
386 | { \ |
387 | .name = "_" #_item "_length", \ | |
388 | .type = __type_integer(_length_type, 0, 0, -1, __BYTE_ORDER, 10, none), \ | |
389 | .nowrite = _nowrite, \ | |
390 | .nofilter = 1, \ | |
391 | }, \ | |
43803cf2 MD |
392 | { \ |
393 | .name = #_item, \ | |
394 | .type = \ | |
395 | { \ | |
ceabb767 | 396 | .atype = atype_sequence_nestable, \ |
43803cf2 MD |
397 | .u = \ |
398 | { \ | |
ceabb767 | 399 | .sequence_nestable = \ |
43803cf2 | 400 | { \ |
ceabb767 MD |
401 | .length_name = "_" #_item "_length", \ |
402 | .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \ | |
403 | __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none)), \ | |
404 | .alignment = lttng_alignof(_type), \ | |
f127e61e | 405 | }, \ |
c099397a | 406 | }, \ |
299338c8 | 407 | }, \ |
f127e61e MD |
408 | .nowrite = _nowrite, \ |
409 | .user = _user, \ | |
ceabb767 | 410 | .nofilter = 0, \ |
299338c8 | 411 | }, |
40652b65 | 412 | |
f127e61e MD |
413 | #undef _ctf_string |
414 | #define _ctf_string(_item, _src, _user, _nowrite) \ | |
299338c8 | 415 | { \ |
c099397a MD |
416 | .name = #_item, \ |
417 | .type = \ | |
418 | { \ | |
299338c8 | 419 | .atype = atype_string, \ |
f127e61e MD |
420 | .u = \ |
421 | { \ | |
ceabb767 | 422 | .string = { .encoding = lttng_encode_UTF8 }, \ |
f127e61e | 423 | }, \ |
299338c8 | 424 | }, \ |
f127e61e MD |
425 | .nowrite = _nowrite, \ |
426 | .user = _user, \ | |
ceabb767 | 427 | .nofilter = 0, \ |
299338c8 | 428 | }, |
1d12cebd | 429 | |
141ddf28 MD |
430 | #undef _ctf_enum |
431 | #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \ | |
432 | { \ | |
433 | .name = #_item, \ | |
434 | .type = { \ | |
ceabb767 | 435 | .atype = atype_enum_nestable, \ |
141ddf28 | 436 | .u = { \ |
ceabb767 MD |
437 | .enum_nestable = { \ |
438 | .desc = &__enum_##_name, \ | |
439 | .container_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \ | |
440 | __type_integer(_type, 0, 0, -1, __BYTE_ORDER, 10, none)), \ | |
441 | }, \ | |
141ddf28 MD |
442 | }, \ |
443 | }, \ | |
444 | .nowrite = _nowrite, \ | |
445 | .user = _user, \ | |
ceabb767 | 446 | .nofilter = 0, \ |
141ddf28 | 447 | }, |
f64dd4be MD |
448 | |
449 | #undef ctf_custom_field | |
450 | #define ctf_custom_field(_type, _item, _code) \ | |
451 | { \ | |
452 | .name = #_item, \ | |
ceabb767 | 453 | .type = _type, \ |
f64dd4be MD |
454 | .nowrite = 0, \ |
455 | .user = 0, \ | |
ceabb767 | 456 | .nofilter = 1, \ |
f64dd4be MD |
457 | }, |
458 | ||
459 | #undef ctf_custom_type | |
460 | #define ctf_custom_type(...) __VA_ARGS__ | |
461 | ||
f127e61e MD |
462 | #undef TP_FIELDS |
463 | #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */ | |
1d12cebd | 464 | |
3bc29f0a | 465 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
265822ae | 466 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
0d1d4002 | 467 | static const struct lttng_event_field __event_fields___##_name[] = { \ |
f127e61e | 468 | _fields \ |
299338c8 MD |
469 | }; |
470 | ||
3bc29f0a | 471 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
265822ae MD |
472 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
473 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post) | |
f7bdf4db | 474 | |
141ddf28 MD |
475 | #undef LTTNG_TRACEPOINT_ENUM |
476 | #define LTTNG_TRACEPOINT_ENUM(_name, _values) \ | |
477 | static const struct lttng_enum_desc __enum_##_name = { \ | |
478 | .name = #_name, \ | |
479 | .entries = __enum_values__##_name, \ | |
480 | .nr_entries = ARRAY_SIZE(__enum_values__##_name), \ | |
481 | }; | |
482 | ||
299338c8 MD |
483 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
484 | ||
19c57fbf | 485 | /* |
c099397a | 486 | * Stage 3 of the trace events. |
19c57fbf MD |
487 | * |
488 | * Create probe callback prototypes. | |
489 | */ | |
490 | ||
f127e61e | 491 | /* Reset all macros within TRACEPOINT_EVENT */ |
3b4aafcb | 492 | #include <lttng/events-reset.h> |
19c57fbf MD |
493 | |
494 | #undef TP_PROTO | |
f127e61e | 495 | #define TP_PROTO(...) __VA_ARGS__ |
19c57fbf | 496 | |
3bc29f0a | 497 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
265822ae | 498 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
0c023c01 | 499 | static void __event_probe__##_name(void *__data, _proto); \ |
7fad9b39 FD |
500 | static void __event_notifier_probe__##_name(void *__data, _proto); |
501 | ||
502 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS | |
503 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ | |
0c023c01 | 504 | static void __event_probe__##_name(void *__data); \ |
7fad9b39 FD |
505 | static void __event_notifier_probe__##_name(void *__data); |
506 | ||
507 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
508 | ||
f7bdf4db MD |
509 | /* |
510 | * Stage 4 of the trace events. | |
511 | * | |
40652b65 MD |
512 | * Create static inline function that calculates event size. |
513 | */ | |
514 | ||
f127e61e | 515 | /* Reset all macros within TRACEPOINT_EVENT */ |
3b4aafcb MD |
516 | #include <lttng/events-reset.h> |
517 | #include <lttng/events-write.h> | |
6db3d13b | 518 | |
f127e61e MD |
519 | #undef _ctf_integer_ext |
520 | #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \ | |
a90917c3 | 521 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
0d1d4002 | 522 | __event_len += sizeof(_type); |
6db3d13b | 523 | |
f127e61e | 524 | #undef _ctf_array_encoded |
3834b99f | 525 | #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \ |
a90917c3 | 526 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
0d1d4002 | 527 | __event_len += sizeof(_type) * (_length); |
6db3d13b | 528 | |
43803cf2 MD |
529 | #undef _ctf_array_bitfield |
530 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ | |
3834b99f | 531 | _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite) |
43803cf2 | 532 | |
f127e61e MD |
533 | #undef _ctf_sequence_encoded |
534 | #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ | |
57ede728 | 535 | _src_length, _encoding, _byte_order, _base, _user, _nowrite) \ |
f127e61e MD |
536 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \ |
537 | __event_len += sizeof(_length_type); \ | |
a90917c3 | 538 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
114667d5 MD |
539 | { \ |
540 | size_t __seqlen = (_src_length); \ | |
541 | \ | |
542 | if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \ | |
543 | goto error; \ | |
544 | barrier(); /* reserve before use. */ \ | |
545 | this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = __seqlen; \ | |
546 | __event_len += sizeof(_type) * __seqlen; \ | |
547 | } | |
6db3d13b | 548 | |
43803cf2 MD |
549 | #undef _ctf_sequence_bitfield |
550 | #define _ctf_sequence_bitfield(_type, _item, _src, \ | |
551 | _length_type, _src_length, \ | |
552 | _user, _nowrite) \ | |
553 | _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \ | |
554 | none, __LITTLE_ENDIAN, 10, _user, _nowrite) | |
555 | ||
d0255731 | 556 | /* |
f127e61e | 557 | * ctf_user_string includes \0. If returns 0, it faulted, so we set size to |
786b8312 | 558 | * 1 (\0 only). |
d0255731 | 559 | */ |
f127e61e MD |
560 | #undef _ctf_string |
561 | #define _ctf_string(_item, _src, _user, _nowrite) \ | |
114667d5 MD |
562 | if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \ |
563 | goto error; \ | |
564 | barrier(); /* reserve before use. */ \ | |
565 | if (_user) { \ | |
566 | __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \ | |
96d0248a | 567 | max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \ |
114667d5 MD |
568 | } else { \ |
569 | __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \ | |
1d84e8e7 | 570 | strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1; \ |
114667d5 | 571 | } |
c6e3f225 | 572 | |
141ddf28 MD |
573 | #undef _ctf_enum |
574 | #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \ | |
575 | _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite) | |
576 | ||
f64dd4be MD |
577 | #undef ctf_align |
578 | #define ctf_align(_type) \ | |
579 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); | |
580 | ||
581 | #undef ctf_custom_field | |
582 | #define ctf_custom_field(_type, _item, _code) \ | |
583 | { \ | |
584 | _code \ | |
585 | } | |
586 | ||
587 | #undef ctf_custom_code | |
588 | #define ctf_custom_code(...) __VA_ARGS__ | |
589 | ||
0d1d4002 | 590 | #undef TP_PROTO |
f127e61e | 591 | #define TP_PROTO(...) __VA_ARGS__ |
6db3d13b | 592 | |
f127e61e MD |
593 | #undef TP_FIELDS |
594 | #define TP_FIELDS(...) __VA_ARGS__ | |
6db3d13b | 595 | |
7ca580f8 MD |
596 | #undef TP_locvar |
597 | #define TP_locvar(...) __VA_ARGS__ | |
598 | ||
3bc29f0a | 599 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
265822ae | 600 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
114667d5 | 601 | static inline ssize_t __event_get_size__##_name(void *__tp_locvar, _proto) \ |
0d1d4002 MD |
602 | { \ |
603 | size_t __event_len = 0; \ | |
d3de7f14 | 604 | unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \ |
7ca580f8 | 605 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
d3de7f14 | 606 | \ |
f127e61e | 607 | _fields \ |
d3de7f14 | 608 | return __event_len; \ |
114667d5 MD |
609 | \ |
610 | error: \ | |
611 | __attribute__((unused)); \ | |
612 | return -1; \ | |
d3de7f14 MD |
613 | } |
614 | ||
3bc29f0a | 615 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
265822ae | 616 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
114667d5 | 617 | static inline ssize_t __event_get_size__##_name(void *__tp_locvar) \ |
d3de7f14 MD |
618 | { \ |
619 | size_t __event_len = 0; \ | |
620 | unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \ | |
7ca580f8 | 621 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
0d1d4002 | 622 | \ |
f127e61e | 623 | _fields \ |
0d1d4002 | 624 | return __event_len; \ |
114667d5 MD |
625 | \ |
626 | error: \ | |
627 | __attribute__((unused)); \ | |
628 | return -1; \ | |
6db3d13b | 629 | } |
40652b65 MD |
630 | |
631 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
632 | ||
f127e61e | 633 | |
40652b65 | 634 | /* |
f127e61e | 635 | * Stage 4.1 of tracepoint event generation. |
e763dbf5 | 636 | * |
f127e61e MD |
637 | * Create static inline function that layout the filter stack data. |
638 | * We make both write and nowrite data available to the filter. | |
e763dbf5 MD |
639 | */ |
640 | ||
f127e61e | 641 | /* Reset all macros within TRACEPOINT_EVENT */ |
3b4aafcb MD |
642 | #include <lttng/events-reset.h> |
643 | #include <lttng/events-write.h> | |
644 | #include <lttng/events-nowrite.h> | |
f127e61e MD |
645 | |
646 | #undef _ctf_integer_ext_fetched | |
647 | #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \ | |
648 | if (lttng_is_signed_type(_type)) { \ | |
649 | int64_t __ctf_tmp_int64; \ | |
650 | switch (sizeof(_type)) { \ | |
651 | case 1: \ | |
652 | { \ | |
653 | union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \ | |
654 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ | |
655 | break; \ | |
656 | } \ | |
657 | case 2: \ | |
658 | { \ | |
659 | union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \ | |
bf1a9179 MD |
660 | if (_byte_order != __BYTE_ORDER) \ |
661 | __swab16s(&__tmp.v); \ | |
f127e61e MD |
662 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ |
663 | break; \ | |
664 | } \ | |
665 | case 4: \ | |
666 | { \ | |
667 | union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \ | |
bf1a9179 MD |
668 | if (_byte_order != __BYTE_ORDER) \ |
669 | __swab32s(&__tmp.v); \ | |
f127e61e MD |
670 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ |
671 | break; \ | |
672 | } \ | |
673 | case 8: \ | |
674 | { \ | |
675 | union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \ | |
bf1a9179 MD |
676 | if (_byte_order != __BYTE_ORDER) \ |
677 | __swab64s(&__tmp.v); \ | |
f127e61e MD |
678 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ |
679 | break; \ | |
680 | } \ | |
681 | default: \ | |
682 | BUG_ON(1); \ | |
683 | }; \ | |
684 | memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \ | |
685 | } else { \ | |
686 | uint64_t __ctf_tmp_uint64; \ | |
687 | switch (sizeof(_type)) { \ | |
688 | case 1: \ | |
689 | { \ | |
690 | union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \ | |
691 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ | |
692 | break; \ | |
693 | } \ | |
694 | case 2: \ | |
695 | { \ | |
696 | union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \ | |
bf1a9179 MD |
697 | if (_byte_order != __BYTE_ORDER) \ |
698 | __swab16s(&__tmp.v); \ | |
f127e61e MD |
699 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ |
700 | break; \ | |
701 | } \ | |
702 | case 4: \ | |
703 | { \ | |
704 | union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \ | |
bf1a9179 MD |
705 | if (_byte_order != __BYTE_ORDER) \ |
706 | __swab32s(&__tmp.v); \ | |
f127e61e MD |
707 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ |
708 | break; \ | |
709 | } \ | |
710 | case 8: \ | |
711 | { \ | |
712 | union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \ | |
bf1a9179 MD |
713 | if (_byte_order != __BYTE_ORDER) \ |
714 | __swab64s(&__tmp.v); \ | |
f127e61e MD |
715 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ |
716 | break; \ | |
717 | } \ | |
718 | default: \ | |
719 | BUG_ON(1); \ | |
720 | }; \ | |
721 | memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \ | |
722 | } \ | |
723 | __stack_data += sizeof(int64_t); | |
724 | ||
725 | #undef _ctf_integer_ext_isuser0 | |
726 | #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \ | |
727 | _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) | |
728 | ||
729 | #undef _ctf_integer_ext_isuser1 | |
730 | #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \ | |
3c8ebbc8 MD |
731 | { \ |
732 | union { \ | |
733 | char __array[sizeof(_user_src)]; \ | |
734 | __typeof__(_user_src) __v; \ | |
735 | } __tmp_fetch; \ | |
736 | if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \ | |
737 | &(_user_src), sizeof(_user_src))) \ | |
738 | memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \ | |
739 | _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \ | |
f127e61e | 740 | } |
e763dbf5 | 741 | |
f127e61e MD |
742 | #undef _ctf_integer_ext |
743 | #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \ | |
744 | _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite) | |
745 | ||
746 | #undef _ctf_array_encoded | |
3834b99f | 747 | #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \ |
f127e61e MD |
748 | { \ |
749 | unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \ | |
750 | const void *__ctf_tmp_ptr = (_src); \ | |
751 | memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \ | |
752 | __stack_data += sizeof(unsigned long); \ | |
6b272cda MD |
753 | memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \ |
754 | __stack_data += sizeof(void *); \ | |
f127e61e MD |
755 | } |
756 | ||
43803cf2 MD |
757 | #undef _ctf_array_bitfield |
758 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ | |
3834b99f | 759 | _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite) |
43803cf2 | 760 | |
f127e61e MD |
761 | #undef _ctf_sequence_encoded |
762 | #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ | |
57ede728 | 763 | _src_length, _encoding, _byte_order, _base, _user, _nowrite) \ |
f127e61e MD |
764 | { \ |
765 | unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \ | |
766 | const void *__ctf_tmp_ptr = (_src); \ | |
767 | memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \ | |
768 | __stack_data += sizeof(unsigned long); \ | |
6b272cda MD |
769 | memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \ |
770 | __stack_data += sizeof(void *); \ | |
f127e61e MD |
771 | } |
772 | ||
43803cf2 MD |
773 | #undef _ctf_sequence_bitfield |
774 | #define _ctf_sequence_bitfield(_type, _item, _src, \ | |
775 | _length_type, _src_length, \ | |
776 | _user, _nowrite) \ | |
777 | _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \ | |
778 | none, __LITTLE_ENDIAN, 10, _user, _nowrite) | |
779 | ||
f127e61e MD |
780 | #undef _ctf_string |
781 | #define _ctf_string(_item, _src, _user, _nowrite) \ | |
782 | { \ | |
1d84e8e7 MD |
783 | const void *__ctf_tmp_ptr = \ |
784 | ((_src) ? (_src) : __LTTNG_NULL_STRING); \ | |
6b272cda MD |
785 | memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \ |
786 | __stack_data += sizeof(void *); \ | |
f127e61e | 787 | } |
c6e3f225 | 788 | |
141ddf28 MD |
789 | #undef _ctf_enum |
790 | #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \ | |
791 | _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite) | |
792 | ||
e763dbf5 | 793 | #undef TP_PROTO |
f127e61e | 794 | #define TP_PROTO(...) __VA_ARGS__ |
e763dbf5 | 795 | |
f127e61e MD |
796 | #undef TP_FIELDS |
797 | #define TP_FIELDS(...) __VA_ARGS__ | |
e763dbf5 | 798 | |
7ca580f8 MD |
799 | #undef TP_locvar |
800 | #define TP_locvar(...) __VA_ARGS__ | |
801 | ||
f127e61e | 802 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
265822ae | 803 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
f127e61e | 804 | static inline \ |
99d223ad | 805 | void __event_prepare_interpreter_stack__##_name(char *__stack_data, \ |
f127e61e | 806 | void *__tp_locvar) \ |
e763dbf5 | 807 | { \ |
7ca580f8 MD |
808 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
809 | \ | |
f127e61e | 810 | _fields \ |
e763dbf5 MD |
811 | } |
812 | ||
f127e61e | 813 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
265822ae | 814 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
f127e61e | 815 | static inline \ |
99d223ad | 816 | void __event_prepare_interpreter_stack__##_name(char *__stack_data, \ |
f127e61e | 817 | void *__tp_locvar, _proto) \ |
d3de7f14 | 818 | { \ |
7ca580f8 MD |
819 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
820 | \ | |
f127e61e | 821 | _fields \ |
d3de7f14 MD |
822 | } |
823 | ||
e763dbf5 MD |
824 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
825 | ||
e763dbf5 | 826 | /* |
f127e61e | 827 | * Stage 5 of the trace events. |
40652b65 | 828 | * |
f127e61e | 829 | * Create static inline function that calculates event payload alignment. |
3c4ffab9 MD |
830 | */ |
831 | ||
f127e61e | 832 | /* Reset all macros within TRACEPOINT_EVENT */ |
3b4aafcb MD |
833 | #include <lttng/events-reset.h> |
834 | #include <lttng/events-write.h> | |
3c4ffab9 | 835 | |
f127e61e MD |
836 | #undef _ctf_integer_ext |
837 | #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \ | |
838 | __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); | |
3c4ffab9 | 839 | |
f127e61e | 840 | #undef _ctf_array_encoded |
3834b99f | 841 | #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \ |
f127e61e | 842 | __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); |
3c4ffab9 | 843 | |
43803cf2 MD |
844 | #undef _ctf_array_bitfield |
845 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ | |
3834b99f | 846 | _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite) |
43803cf2 | 847 | |
f127e61e MD |
848 | #undef _ctf_sequence_encoded |
849 | #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ | |
57ede728 | 850 | _src_length, _encoding, _byte_order, _base, _user, _nowrite) \ |
f127e61e MD |
851 | __event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \ |
852 | __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); | |
64c796d8 | 853 | |
43803cf2 MD |
854 | #undef _ctf_sequence_bitfield |
855 | #define _ctf_sequence_bitfield(_type, _item, _src, \ | |
856 | _length_type, _src_length, \ | |
857 | _user, _nowrite) \ | |
858 | _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \ | |
859 | none, __LITTLE_ENDIAN, 10, _user, _nowrite) | |
860 | ||
f127e61e MD |
861 | #undef _ctf_string |
862 | #define _ctf_string(_item, _src, _user, _nowrite) | |
64c796d8 | 863 | |
141ddf28 MD |
864 | #undef _ctf_enum |
865 | #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \ | |
866 | _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite) | |
867 | ||
f64dd4be MD |
868 | #undef ctf_align |
869 | #define ctf_align(_type) \ | |
870 | __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); | |
871 | ||
f127e61e MD |
872 | #undef TP_PROTO |
873 | #define TP_PROTO(...) __VA_ARGS__ | |
84da5206 | 874 | |
f127e61e MD |
875 | #undef TP_FIELDS |
876 | #define TP_FIELDS(...) __VA_ARGS__ | |
c6e3f225 | 877 | |
f127e61e MD |
878 | #undef TP_locvar |
879 | #define TP_locvar(...) __VA_ARGS__ | |
3c4ffab9 | 880 | |
f64dd4be MD |
881 | #undef ctf_custom_field |
882 | #define ctf_custom_field(_type, _item, _code) _code | |
883 | ||
884 | #undef ctf_custom_code | |
885 | #define ctf_custom_code(...) \ | |
886 | { \ | |
887 | __VA_ARGS__ \ | |
888 | } | |
889 | ||
f127e61e | 890 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
265822ae | 891 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
f127e61e MD |
892 | static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \ |
893 | { \ | |
894 | size_t __event_align = 1; \ | |
895 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ | |
896 | \ | |
897 | _fields \ | |
898 | return __event_align; \ | |
899 | } | |
3c4ffab9 | 900 | |
3bc29f0a | 901 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
265822ae | 902 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
f127e61e MD |
903 | static inline size_t __event_get_align__##_name(void *__tp_locvar) \ |
904 | { \ | |
905 | size_t __event_align = 1; \ | |
906 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ | |
907 | \ | |
908 | _fields \ | |
909 | return __event_align; \ | |
910 | } | |
d3de7f14 | 911 | |
3c4ffab9 MD |
912 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
913 | ||
3c4ffab9 | 914 | /* |
f127e61e | 915 | * Stage 6 of tracepoint event generation. |
e763dbf5 | 916 | * |
f127e61e MD |
917 | * Create the probe function. This function calls event size calculation |
918 | * and writes event data into the buffer. | |
40652b65 MD |
919 | */ |
920 | ||
f127e61e | 921 | /* Reset all macros within TRACEPOINT_EVENT */ |
3b4aafcb MD |
922 | #include <lttng/events-reset.h> |
923 | #include <lttng/events-write.h> | |
c6e3f225 | 924 | |
f127e61e MD |
925 | #undef _ctf_integer_ext_fetched |
926 | #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \ | |
e763dbf5 | 927 | { \ |
f127e61e MD |
928 | _type __tmp = _src; \ |
929 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\ | |
aaa4004a | 930 | __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\ |
f127e61e MD |
931 | } |
932 | ||
933 | #undef _ctf_integer_ext_isuser0 | |
934 | #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \ | |
935 | _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) | |
936 | ||
937 | #undef _ctf_integer_ext_isuser1 | |
938 | #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \ | |
939 | { \ | |
3c8ebbc8 MD |
940 | union { \ |
941 | char __array[sizeof(_user_src)]; \ | |
942 | __typeof__(_user_src) __v; \ | |
943 | } __tmp_fetch; \ | |
944 | if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \ | |
945 | &(_user_src), sizeof(_user_src))) \ | |
946 | memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \ | |
947 | _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \ | |
f127e61e MD |
948 | } |
949 | ||
950 | #undef _ctf_integer_ext | |
951 | #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \ | |
952 | _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite) | |
953 | ||
954 | #undef _ctf_array_encoded | |
3834b99f | 955 | #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \ |
f127e61e MD |
956 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ |
957 | if (_user) { \ | |
958 | __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \ | |
959 | } else { \ | |
960 | __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \ | |
961 | } | |
962 | ||
43803cf2 MD |
963 | #if (__BYTE_ORDER == __LITTLE_ENDIAN) |
964 | #undef _ctf_array_bitfield | |
965 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ | |
966 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ | |
967 | if (_user) { \ | |
968 | __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \ | |
969 | } else { \ | |
970 | __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \ | |
971 | } | |
972 | #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ | |
973 | /* | |
974 | * For big endian, we need to byteswap into little endian. | |
975 | */ | |
976 | #undef _ctf_array_bitfield | |
977 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ | |
978 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ | |
979 | { \ | |
980 | size_t _i; \ | |
981 | \ | |
982 | for (_i = 0; _i < (_length); _i++) { \ | |
983 | _type _tmp; \ | |
984 | \ | |
985 | if (_user) { \ | |
986 | if (get_user(_tmp, (_type *) _src + _i)) \ | |
987 | _tmp = 0; \ | |
988 | } else { \ | |
989 | _tmp = ((_type *) _src)[_i]; \ | |
990 | } \ | |
991 | switch (sizeof(_type)) { \ | |
992 | case 1: \ | |
993 | break; \ | |
994 | case 2: \ | |
995 | _tmp = cpu_to_le16(_tmp); \ | |
996 | break; \ | |
997 | case 4: \ | |
998 | _tmp = cpu_to_le32(_tmp); \ | |
999 | break; \ | |
1000 | case 8: \ | |
1001 | _tmp = cpu_to_le64(_tmp); \ | |
1002 | break; \ | |
1003 | default: \ | |
1004 | BUG_ON(1); \ | |
1005 | } \ | |
1006 | __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \ | |
1007 | } \ | |
1008 | } | |
1009 | #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ | |
1010 | ||
f127e61e MD |
1011 | #undef _ctf_sequence_encoded |
1012 | #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ | |
57ede728 | 1013 | _src_length, _encoding, _byte_order, _base, _user, _nowrite) \ |
84da5206 | 1014 | { \ |
114667d5 | 1015 | _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx]; \ |
f127e61e MD |
1016 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ |
1017 | __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\ | |
84da5206 | 1018 | } \ |
f127e61e MD |
1019 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ |
1020 | if (_user) { \ | |
1021 | __chan->ops->event_write_from_user(&__ctx, _src, \ | |
1022 | sizeof(_type) * __get_dynamic_len(dest)); \ | |
1023 | } else { \ | |
1024 | __chan->ops->event_write(&__ctx, _src, \ | |
1025 | sizeof(_type) * __get_dynamic_len(dest)); \ | |
1026 | } | |
1027 | ||
43803cf2 MD |
1028 | #if (__BYTE_ORDER == __LITTLE_ENDIAN) |
1029 | #undef _ctf_sequence_bitfield | |
1030 | #define _ctf_sequence_bitfield(_type, _item, _src, \ | |
1031 | _length_type, _src_length, \ | |
1032 | _user, _nowrite) \ | |
1033 | { \ | |
114667d5 | 1034 | _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \ |
43803cf2 MD |
1035 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ |
1036 | __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\ | |
1037 | } \ | |
1038 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ | |
1039 | if (_user) { \ | |
1040 | __chan->ops->event_write_from_user(&__ctx, _src, \ | |
1041 | sizeof(_type) * __get_dynamic_len(dest)); \ | |
1042 | } else { \ | |
1043 | __chan->ops->event_write(&__ctx, _src, \ | |
1044 | sizeof(_type) * __get_dynamic_len(dest)); \ | |
1045 | } | |
1046 | #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ | |
1047 | /* | |
1048 | * For big endian, we need to byteswap into little endian. | |
1049 | */ | |
1050 | #undef _ctf_sequence_bitfield | |
1051 | #define _ctf_sequence_bitfield(_type, _item, _src, \ | |
1052 | _length_type, _src_length, \ | |
1053 | _user, _nowrite) \ | |
1054 | { \ | |
114667d5 | 1055 | _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \ |
43803cf2 MD |
1056 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ |
1057 | __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\ | |
1058 | } \ | |
1059 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ | |
1060 | { \ | |
1061 | size_t _i, _length; \ | |
1062 | \ | |
1063 | _length = __get_dynamic_len(dest); \ | |
1064 | for (_i = 0; _i < _length; _i++) { \ | |
1065 | _type _tmp; \ | |
1066 | \ | |
1067 | if (_user) { \ | |
1068 | if (get_user(_tmp, (_type *) _src + _i)) \ | |
1069 | _tmp = 0; \ | |
1070 | } else { \ | |
1071 | _tmp = ((_type *) _src)[_i]; \ | |
1072 | } \ | |
1073 | switch (sizeof(_type)) { \ | |
1074 | case 1: \ | |
1075 | break; \ | |
1076 | case 2: \ | |
1077 | _tmp = cpu_to_le16(_tmp); \ | |
1078 | break; \ | |
1079 | case 4: \ | |
1080 | _tmp = cpu_to_le32(_tmp); \ | |
1081 | break; \ | |
1082 | case 8: \ | |
1083 | _tmp = cpu_to_le64(_tmp); \ | |
1084 | break; \ | |
1085 | default: \ | |
1086 | BUG_ON(1); \ | |
1087 | } \ | |
1088 | __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \ | |
1089 | } \ | |
1090 | } | |
1091 | #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ | |
1092 | ||
f127e61e MD |
1093 | #undef _ctf_string |
1094 | #define _ctf_string(_item, _src, _user, _nowrite) \ | |
f127e61e | 1095 | if (_user) { \ |
1d84e8e7 | 1096 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \ |
f127e61e MD |
1097 | __chan->ops->event_strcpy_from_user(&__ctx, _src, \ |
1098 | __get_dynamic_len(dest)); \ | |
1099 | } else { \ | |
1d84e8e7 MD |
1100 | const char *__ctf_tmp_string = \ |
1101 | ((_src) ? (_src) : __LTTNG_NULL_STRING); \ | |
1102 | lib_ring_buffer_align_ctx(&__ctx, \ | |
1103 | lttng_alignof(*__ctf_tmp_string)); \ | |
1104 | __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \ | |
f127e61e MD |
1105 | __get_dynamic_len(dest)); \ |
1106 | } | |
e763dbf5 | 1107 | |
141ddf28 MD |
1108 | #undef _ctf_enum |
1109 | #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \ | |
1110 | _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite) | |
f64dd4be MD |
1111 | |
1112 | #undef ctf_align | |
1113 | #define ctf_align(_type) \ | |
1114 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); | |
1115 | ||
1116 | #undef ctf_custom_field | |
1117 | #define ctf_custom_field(_type, _item, _code) _code | |
1118 | ||
1119 | #undef ctf_custom_code | |
1120 | #define ctf_custom_code(...) \ | |
1121 | { \ | |
1122 | __VA_ARGS__ \ | |
1123 | } | |
1124 | ||
e763dbf5 | 1125 | /* Beware: this get len actually consumes the len value */ |
f127e61e | 1126 | #undef __get_dynamic_len |
114667d5 | 1127 | #define __get_dynamic_len(field) this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx++] |
e763dbf5 MD |
1128 | |
1129 | #undef TP_PROTO | |
f127e61e | 1130 | #define TP_PROTO(...) __VA_ARGS__ |
e763dbf5 MD |
1131 | |
1132 | #undef TP_ARGS | |
f127e61e | 1133 | #define TP_ARGS(...) __VA_ARGS__ |
e763dbf5 | 1134 | |
f127e61e MD |
1135 | #undef TP_FIELDS |
1136 | #define TP_FIELDS(...) __VA_ARGS__ | |
e763dbf5 | 1137 | |
7ca580f8 MD |
1138 | #undef TP_locvar |
1139 | #define TP_locvar(...) __VA_ARGS__ | |
1140 | ||
265822ae MD |
1141 | #undef TP_code_pre |
1142 | #define TP_code_pre(...) __VA_ARGS__ | |
1143 | ||
1144 | #undef TP_code_post | |
1145 | #define TP_code_post(...) __VA_ARGS__ | |
7ca580f8 | 1146 | |
c337ddc2 MD |
1147 | /* |
1148 | * For state dump, check that "session" argument (mandatory) matches the | |
1149 | * session this event belongs to. Ensures that we write state dump data only | |
1150 | * into the started session, not into all sessions. | |
1151 | */ | |
1152 | #ifdef TP_SESSION_CHECK | |
1153 | #define _TP_SESSION_CHECK(session, csession) (session == csession) | |
1154 | #else /* TP_SESSION_CHECK */ | |
1155 | #define _TP_SESSION_CHECK(session, csession) 1 | |
1156 | #endif /* TP_SESSION_CHECK */ | |
1157 | ||
f9771d39 | 1158 | /* |
f127e61e MD |
1159 | * Using twice size for filter stack data to hold size and pointer for |
1160 | * each field (worse case). For integers, max size required is 64-bit. | |
1161 | * Same for double-precision floats. Those fit within | |
1162 | * 2*sizeof(unsigned long) for all supported architectures. | |
1163 | * Perform UNION (||) of filter runtime list. | |
f9771d39 | 1164 | */ |
3bc29f0a | 1165 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
265822ae | 1166 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
e763dbf5 MD |
1167 | static void __event_probe__##_name(void *__data, _proto) \ |
1168 | { \ | |
7ca580f8 | 1169 | struct probe_local_vars { _locvar }; \ |
a90917c3 | 1170 | struct lttng_event *__event = __data; \ |
7fad9b39 | 1171 | struct lttng_probe_ctx __lttng_probe_ctx = { \ |
79150a49 | 1172 | .event = __event, \ |
7fad9b39 | 1173 | .event_notifier = NULL, \ |
ccecf3fb | 1174 | .interruptible = !irqs_disabled(), \ |
79150a49 | 1175 | }; \ |
0c023c01 MD |
1176 | struct lttng_event_container *__container = __event->container; \ |
1177 | struct lttng_session *__session = __container->session; \ | |
aaa4004a | 1178 | struct lib_ring_buffer_ctx __ctx; \ |
ec0a7fba | 1179 | size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \ |
f127e61e | 1180 | union { \ |
114667d5 | 1181 | size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \ |
f127e61e MD |
1182 | char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \ |
1183 | } __stackvar; \ | |
e763dbf5 | 1184 | int __ret; \ |
7ca580f8 MD |
1185 | struct probe_local_vars __tp_locvar; \ |
1186 | struct probe_local_vars *tp_locvar __attribute__((unused)) = \ | |
1187 | &__tp_locvar; \ | |
d1f652f8 | 1188 | struct lttng_id_tracker_rcu *__lf; \ |
e763dbf5 | 1189 | \ |
e0130fab | 1190 | if (!_TP_SESSION_CHECK(session, __session)) \ |
c337ddc2 | 1191 | return; \ |
585e5dcc | 1192 | if (unlikely(!LTTNG_READ_ONCE(__session->active))) \ |
e64957da | 1193 | return; \ |
0c023c01 | 1194 | if (unlikely(!LTTNG_READ_ONCE(__container->enabled))) \ |
e64957da | 1195 | return; \ |
585e5dcc | 1196 | if (unlikely(!LTTNG_READ_ONCE(__event->enabled))) \ |
52fc2e1f | 1197 | return; \ |
d1f652f8 MD |
1198 | __lf = lttng_rcu_dereference(__session->pid_tracker.p); \ |
1199 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \ | |
1200 | return; \ | |
1201 | __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \ | |
1202 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \ | |
1203 | return; \ | |
1204 | __lf = lttng_rcu_dereference(__session->uid_tracker.p); \ | |
1205 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, \ | |
608416e1 | 1206 | lttng_current_uid()))) \ |
d1f652f8 MD |
1207 | return; \ |
1208 | __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \ | |
1209 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, \ | |
608416e1 | 1210 | lttng_current_vuid()))) \ |
d1f652f8 MD |
1211 | return; \ |
1212 | __lf = lttng_rcu_dereference(__session->gid_tracker.p); \ | |
1213 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, \ | |
608416e1 | 1214 | lttng_current_gid()))) \ |
d1f652f8 MD |
1215 | return; \ |
1216 | __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \ | |
1217 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, \ | |
608416e1 | 1218 | lttng_current_vgid()))) \ |
e0130fab | 1219 | return; \ |
114667d5 MD |
1220 | __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \ |
1221 | __dynamic_len_idx = __orig_dynamic_len_offset; \ | |
265822ae | 1222 | _code_pre \ |
183e8b3a | 1223 | if (unlikely(!list_empty(&__event->filter_bytecode_runtime_head))) { \ |
f127e61e MD |
1224 | struct lttng_bytecode_runtime *bc_runtime; \ |
1225 | int __filter_record = __event->has_enablers_without_bytecode; \ | |
1226 | \ | |
99d223ad | 1227 | __event_prepare_interpreter_stack__##_name(__stackvar.__filter_stack_data, \ |
f127e61e | 1228 | tp_locvar, _args); \ |
183e8b3a | 1229 | lttng_list_for_each_entry_rcu(bc_runtime, &__event->filter_bytecode_runtime_head, node) { \ |
3d650c7b | 1230 | if (unlikely(bc_runtime->interpreter_funcs.filter(bc_runtime, &__lttng_probe_ctx, \ |
80c2a69a | 1231 | __stackvar.__filter_stack_data) & LTTNG_INTERPRETER_RECORD_FLAG)) { \ |
f127e61e | 1232 | __filter_record = 1; \ |
8904bcfa FD |
1233 | break; \ |
1234 | } \ | |
f127e61e MD |
1235 | } \ |
1236 | if (likely(!__filter_record)) \ | |
265822ae | 1237 | goto __post; \ |
f127e61e | 1238 | } \ |
0c023c01 MD |
1239 | switch (__container->type) { \ |
1240 | case LTTNG_EVENT_CONTAINER_CHANNEL: \ | |
1241 | { \ | |
1242 | struct lttng_channel *__chan = lttng_event_container_get_channel(__container); \ | |
1243 | ssize_t __event_len; \ | |
1244 | size_t __event_align; \ | |
1245 | \ | |
1246 | __event_len = __event_get_size__##_name(tp_locvar, _args); \ | |
1247 | if (unlikely(__event_len < 0)) { \ | |
1248 | lib_ring_buffer_lost_event_too_big(__chan->chan); \ | |
1249 | goto __post; \ | |
1250 | } \ | |
1251 | __event_align = __event_get_align__##_name(tp_locvar, _args); \ | |
1252 | lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \ | |
1253 | __event_align, -1); \ | |
1254 | __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ | |
1255 | if (__ret < 0) \ | |
1256 | goto __post; \ | |
1257 | _fields \ | |
1258 | __chan->ops->event_commit(&__ctx); \ | |
1259 | break; \ | |
1260 | } \ | |
1261 | case LTTNG_EVENT_CONTAINER_COUNTER: \ | |
1262 | { \ | |
1263 | struct lttng_counter *__counter = lttng_event_container_get_counter(__container); \ | |
1264 | size_t __index = __event->id; \ | |
1265 | \ | |
1266 | (void) __counter->ops->counter_add(__counter->counter, &__index, 1); \ | |
1267 | break; \ | |
1268 | } \ | |
114667d5 | 1269 | } \ |
265822ae MD |
1270 | __post: \ |
1271 | _code_post \ | |
114667d5 MD |
1272 | barrier(); /* use before un-reserve. */ \ |
1273 | this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \ | |
265822ae | 1274 | return; \ |
e763dbf5 MD |
1275 | } |
1276 | ||
3bc29f0a | 1277 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
265822ae | 1278 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
f7bdf4db MD |
1279 | static void __event_probe__##_name(void *__data) \ |
1280 | { \ | |
7ca580f8 | 1281 | struct probe_local_vars { _locvar }; \ |
a90917c3 | 1282 | struct lttng_event *__event = __data; \ |
7fad9b39 | 1283 | struct lttng_probe_ctx __lttng_probe_ctx = { \ |
79150a49 | 1284 | .event = __event, \ |
7fad9b39 | 1285 | .event_notifier = NULL, \ |
ccecf3fb | 1286 | .interruptible = !irqs_disabled(), \ |
79150a49 | 1287 | }; \ |
0c023c01 MD |
1288 | struct lttng_event_container *__container = __event->container; \ |
1289 | struct lttng_session *__session = __container->session; \ | |
ec0a7fba | 1290 | size_t __orig_dynamic_len_offset, __dynamic_len_idx __attribute__((unused)); \ |
f127e61e | 1291 | union { \ |
114667d5 | 1292 | size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \ |
f127e61e MD |
1293 | char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \ |
1294 | } __stackvar; \ | |
f7bdf4db | 1295 | int __ret; \ |
7ca580f8 MD |
1296 | struct probe_local_vars __tp_locvar; \ |
1297 | struct probe_local_vars *tp_locvar __attribute__((unused)) = \ | |
1298 | &__tp_locvar; \ | |
d1f652f8 | 1299 | struct lttng_id_tracker_rcu *__lf; \ |
f7bdf4db | 1300 | \ |
e0130fab | 1301 | if (!_TP_SESSION_CHECK(session, __session)) \ |
c337ddc2 | 1302 | return; \ |
585e5dcc | 1303 | if (unlikely(!LTTNG_READ_ONCE(__session->active))) \ |
f7bdf4db | 1304 | return; \ |
0c023c01 | 1305 | if (unlikely(!LTTNG_READ_ONCE(__container->enabled))) \ |
f7bdf4db | 1306 | return; \ |
585e5dcc | 1307 | if (unlikely(!LTTNG_READ_ONCE(__event->enabled))) \ |
f7bdf4db | 1308 | return; \ |
d1f652f8 MD |
1309 | __lf = lttng_rcu_dereference(__session->pid_tracker.p); \ |
1310 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \ | |
1311 | return; \ | |
1312 | __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \ | |
1313 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \ | |
1314 | return; \ | |
1315 | __lf = lttng_rcu_dereference(__session->uid_tracker.p); \ | |
1316 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, \ | |
608416e1 | 1317 | lttng_current_uid()))) \ |
d1f652f8 MD |
1318 | return; \ |
1319 | __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \ | |
1320 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, \ | |
608416e1 | 1321 | lttng_current_vuid()))) \ |
d1f652f8 MD |
1322 | return; \ |
1323 | __lf = lttng_rcu_dereference(__session->gid_tracker.p); \ | |
1324 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, \ | |
608416e1 | 1325 | lttng_current_gid()))) \ |
d1f652f8 MD |
1326 | return; \ |
1327 | __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \ | |
1328 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, \ | |
608416e1 | 1329 | lttng_current_vgid()))) \ |
e0130fab | 1330 | return; \ |
114667d5 MD |
1331 | __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \ |
1332 | __dynamic_len_idx = __orig_dynamic_len_offset; \ | |
265822ae | 1333 | _code_pre \ |
0c023c01 | 1334 | if (unlikely(!list_empty(&__event->filter_bytecode_runtime_head))) { \ |
f127e61e MD |
1335 | struct lttng_bytecode_runtime *bc_runtime; \ |
1336 | int __filter_record = __event->has_enablers_without_bytecode; \ | |
1337 | \ | |
99d223ad | 1338 | __event_prepare_interpreter_stack__##_name(__stackvar.__filter_stack_data, \ |
f127e61e | 1339 | tp_locvar); \ |
183e8b3a | 1340 | lttng_list_for_each_entry_rcu(bc_runtime, &__event->filter_bytecode_runtime_head, node) { \ |
3d650c7b | 1341 | if (unlikely(bc_runtime->interpreter_funcs.filter(bc_runtime, &__lttng_probe_ctx, \ |
80c2a69a | 1342 | __stackvar.__filter_stack_data) & LTTNG_INTERPRETER_RECORD_FLAG)) { \ |
f127e61e | 1343 | __filter_record = 1; \ |
8904bcfa FD |
1344 | break; \ |
1345 | } \ | |
f127e61e MD |
1346 | } \ |
1347 | if (likely(!__filter_record)) \ | |
265822ae | 1348 | goto __post; \ |
f127e61e | 1349 | } \ |
0c023c01 MD |
1350 | switch (__container->type) { \ |
1351 | case LTTNG_EVENT_CONTAINER_CHANNEL: \ | |
1352 | { \ | |
1353 | struct lttng_channel *__chan = lttng_event_container_get_channel(__container); \ | |
1354 | struct lib_ring_buffer_ctx __ctx; \ | |
1355 | ssize_t __event_len; \ | |
1356 | size_t __event_align; \ | |
1357 | \ | |
1358 | __event_len = __event_get_size__##_name(tp_locvar); \ | |
1359 | if (unlikely(__event_len < 0)) { \ | |
1360 | lib_ring_buffer_lost_event_too_big(__chan->chan); \ | |
1361 | goto __post; \ | |
1362 | } \ | |
1363 | __event_align = __event_get_align__##_name(tp_locvar); \ | |
1364 | lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \ | |
1365 | __event_align, -1); \ | |
1366 | __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ | |
1367 | if (__ret < 0) \ | |
1368 | goto __post; \ | |
1369 | _fields \ | |
1370 | __chan->ops->event_commit(&__ctx); \ | |
1371 | break; \ | |
1372 | } \ | |
1373 | case LTTNG_EVENT_CONTAINER_COUNTER: \ | |
1374 | { \ | |
1375 | struct lttng_counter *__counter = lttng_event_container_get_counter(__container); \ | |
1376 | size_t __index = __event->id; \ | |
1377 | \ | |
1378 | (void) __counter->ops->counter_add(__counter->counter, &__index, 1); \ | |
1379 | break; \ | |
1380 | } \ | |
114667d5 | 1381 | } \ |
265822ae MD |
1382 | __post: \ |
1383 | _code_post \ | |
114667d5 MD |
1384 | barrier(); /* use before un-reserve. */ \ |
1385 | this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \ | |
265822ae | 1386 | return; \ |
f7bdf4db MD |
1387 | } |
1388 | ||
e763dbf5 MD |
1389 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
1390 | ||
f127e61e MD |
1391 | #undef __get_dynamic_len |
1392 | ||
0c023c01 | 1393 | |
7fad9b39 FD |
1394 | /* |
1395 | * Stage 6.1 of tracepoint generation: generate event notifier probes | |
1396 | * | |
1397 | * Create the probe function. This function evaluates the filter bytecode and | |
1398 | * queue a notification to be sent to userspace. | |
1399 | */ | |
1400 | ||
1401 | #include <lttng/events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */ | |
1402 | ||
1403 | #undef TP_PROTO | |
1404 | #define TP_PROTO(...) __VA_ARGS__ | |
1405 | ||
1406 | #undef TP_ARGS | |
1407 | #define TP_ARGS(...) __VA_ARGS__ | |
1408 | ||
1409 | #undef TP_FIELDS | |
1410 | #define TP_FIELDS(...) __VA_ARGS__ | |
1411 | ||
1412 | #undef TP_locvar | |
1413 | #define TP_locvar(...) __VA_ARGS__ | |
1414 | ||
1415 | #undef TP_code_pre | |
1416 | #define TP_code_pre(...) __VA_ARGS__ | |
1417 | ||
1418 | #undef TP_code_post | |
1419 | #define TP_code_post(...) __VA_ARGS__ | |
1420 | ||
1421 | /* | |
1422 | * Using twice size for filter stack data to hold size and pointer for | |
1423 | * each field (worse case). For integers, max size required is 64-bit. | |
1424 | * Same for double-precision floats. Those fit within | |
1425 | * 2*sizeof(unsigned long) for all supported architectures. | |
1426 | * Perform UNION (||) of filter runtime list. | |
1427 | */ | |
1428 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE | |
1429 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ | |
1430 | static void __event_notifier_probe__##_name(void *__data, _proto) \ | |
1431 | { \ | |
1432 | struct probe_local_vars { _locvar }; \ | |
1433 | struct lttng_event_notifier *__event_notifier = __data; \ | |
1434 | struct lttng_probe_ctx __lttng_probe_ctx = { \ | |
1435 | .event = NULL, \ | |
1436 | .event_notifier = __event_notifier, \ | |
1437 | .interruptible = !irqs_disabled(), \ | |
1438 | }; \ | |
1439 | union { \ | |
1440 | size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \ | |
99d223ad | 1441 | char __interpreter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \ |
7fad9b39 FD |
1442 | } __stackvar; \ |
1443 | struct probe_local_vars __tp_locvar; \ | |
1444 | struct probe_local_vars *tp_locvar __attribute__((unused)) = \ | |
1445 | &__tp_locvar; \ | |
0c023c01 MD |
1446 | struct lttng_kernel_notifier_ctx __notif_ctx; \ |
1447 | bool __interpreter_stack_prepared = false; \ | |
7fad9b39 FD |
1448 | \ |
1449 | if (unlikely(!READ_ONCE(__event_notifier->enabled))) \ | |
1450 | return; \ | |
1451 | _code_pre \ | |
183e8b3a | 1452 | if (unlikely(!list_empty(&__event_notifier->filter_bytecode_runtime_head))) { \ |
99d223ad | 1453 | struct lttng_bytecode_runtime *bc_runtime; \ |
7fad9b39 | 1454 | int __filter_record = __event_notifier->has_enablers_without_bytecode; \ |
99d223ad FD |
1455 | \ |
1456 | __event_prepare_interpreter_stack__##_name(__stackvar.__interpreter_stack_data, \ | |
1457 | tp_locvar, _args); \ | |
0c023c01 | 1458 | __interpreter_stack_prepared = true; \ |
183e8b3a | 1459 | lttng_list_for_each_entry_rcu(bc_runtime, &__event_notifier->filter_bytecode_runtime_head, node) { \ |
99d223ad FD |
1460 | if (unlikely(bc_runtime->interpreter_funcs.filter(bc_runtime, &__lttng_probe_ctx, \ |
1461 | __stackvar.__interpreter_stack_data) & LTTNG_INTERPRETER_RECORD_FLAG)) \ | |
7fad9b39 FD |
1462 | __filter_record = 1; \ |
1463 | } \ | |
1464 | if (likely(!__filter_record)) \ | |
1465 | goto __post; \ | |
1466 | } \ | |
1467 | \ | |
0c023c01 MD |
1468 | __notif_ctx.eval_capture = LTTNG_READ_ONCE(__event_notifier->eval_capture); \ |
1469 | if (unlikely(!__interpreter_stack_prepared && __notif_ctx.eval_capture)) \ | |
99d223ad FD |
1470 | __event_prepare_interpreter_stack__##_name( \ |
1471 | __stackvar.__interpreter_stack_data, \ | |
1472 | tp_locvar, _args); \ | |
1473 | \ | |
1474 | __event_notifier->send_notification(__event_notifier, \ | |
1475 | &__lttng_probe_ctx, \ | |
0c023c01 MD |
1476 | __stackvar.__interpreter_stack_data, \ |
1477 | &__notif_ctx); \ | |
99d223ad | 1478 | \ |
7fad9b39 FD |
1479 | __post: \ |
1480 | _code_post \ | |
1481 | return; \ | |
1482 | } | |
1483 | ||
1484 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS | |
1485 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ | |
1486 | static void __event_notifier_probe__##_name(void *__data) \ | |
1487 | { \ | |
1488 | struct probe_local_vars { _locvar }; \ | |
1489 | struct lttng_event_notifier *__event_notifier = __data; \ | |
1490 | struct lttng_probe_ctx __lttng_probe_ctx = { \ | |
1491 | .event = NULL, \ | |
1492 | .event_notifier = __event_notifier, \ | |
1493 | .interruptible = !irqs_disabled(), \ | |
1494 | }; \ | |
1495 | union { \ | |
1496 | size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \ | |
99d223ad | 1497 | char __interpreter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \ |
7fad9b39 FD |
1498 | } __stackvar; \ |
1499 | struct probe_local_vars __tp_locvar; \ | |
1500 | struct probe_local_vars *tp_locvar __attribute__((unused)) = \ | |
1501 | &__tp_locvar; \ | |
0c023c01 MD |
1502 | struct lttng_kernel_notifier_ctx __notif_ctx; \ |
1503 | bool __interpreter_stack_prepared = false; \ | |
7fad9b39 FD |
1504 | \ |
1505 | if (unlikely(!READ_ONCE(__event_notifier->enabled))) \ | |
1506 | return; \ | |
1507 | _code_pre \ | |
99d223ad FD |
1508 | if (unlikely(!list_empty(&__event_notifier->filter_bytecode_runtime_head))) { \ |
1509 | struct lttng_bytecode_runtime *bc_runtime; \ | |
1510 | int __filter_record = __event_notifier->has_enablers_without_bytecode; \ | |
1511 | \ | |
1512 | __event_prepare_interpreter_stack__##_name(__stackvar.__interpreter_stack_data, \ | |
1513 | tp_locvar); \ | |
0c023c01 | 1514 | __interpreter_stack_prepared = true; \ |
183e8b3a | 1515 | lttng_list_for_each_entry_rcu(bc_runtime, &__event_notifier->filter_bytecode_runtime_head, node) { \ |
99d223ad FD |
1516 | if (unlikely(bc_runtime->interpreter_funcs.filter(bc_runtime, &__lttng_probe_ctx, \ |
1517 | __stackvar.__interpreter_stack_data) & LTTNG_INTERPRETER_RECORD_FLAG)) \ | |
7fad9b39 FD |
1518 | __filter_record = 1; \ |
1519 | } \ | |
1520 | if (likely(!__filter_record)) \ | |
1521 | goto __post; \ | |
1522 | } \ | |
1523 | \ | |
0c023c01 MD |
1524 | __notif_ctx.eval_capture = LTTNG_READ_ONCE(__event_notifier->eval_capture); \ |
1525 | if (unlikely(!__interpreter_stack_prepared && __notif_ctx.eval_capture)) \ | |
99d223ad FD |
1526 | __event_prepare_interpreter_stack__##_name( \ |
1527 | __stackvar.__interpreter_stack_data, \ | |
1528 | tp_locvar); \ | |
1529 | \ | |
1530 | __event_notifier->send_notification(__event_notifier, \ | |
1531 | &__lttng_probe_ctx, \ | |
0c023c01 MD |
1532 | __stackvar.__interpreter_stack_data, \ |
1533 | &__notif_ctx); \ | |
7fad9b39 FD |
1534 | __post: \ |
1535 | _code_post \ | |
1536 | return; \ | |
1537 | } | |
1538 | ||
1539 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
f127e61e MD |
1540 | /* |
1541 | * Stage 7 of the trace events. | |
1542 | * | |
1543 | * Create event descriptions. | |
1544 | */ | |
1545 | ||
1546 | /* Named field types must be defined in lttng-types.h */ | |
1547 | ||
3b4aafcb | 1548 | #include <lttng/events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */ |
f127e61e MD |
1549 | |
1550 | #ifndef TP_PROBE_CB | |
1551 | #define TP_PROBE_CB(_template) &__event_probe__##_template | |
1552 | #endif | |
1553 | ||
7fad9b39 FD |
1554 | #ifndef TP_EVENT_NOTIFIER_PROBE_CB |
1555 | #define TP_EVENT_NOTIFIER_PROBE_CB(_template) &__event_notifier_probe__##_template | |
1556 | #endif | |
1557 | ||
f127e61e MD |
1558 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS |
1559 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \ | |
1560 | static const struct lttng_event_desc __event_desc___##_map = { \ | |
1561 | .fields = __event_fields___##_template, \ | |
1562 | .name = #_map, \ | |
1563 | .kname = #_name, \ | |
1564 | .probe_callback = (void *) TP_PROBE_CB(_template), \ | |
1565 | .nr_fields = ARRAY_SIZE(__event_fields___##_template), \ | |
1566 | .owner = THIS_MODULE, \ | |
7fad9b39 | 1567 | .event_notifier_callback = (void *) TP_EVENT_NOTIFIER_PROBE_CB(_template), \ |
f127e61e MD |
1568 | }; |
1569 | ||
1570 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP | |
1571 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \ | |
1572 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) | |
1573 | ||
1574 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
1575 | ||
1576 | /* | |
1577 | * Stage 8 of the trace events. | |
1578 | * | |
1579 | * Create an array of event description pointers. | |
1580 | */ | |
1581 | ||
3b4aafcb | 1582 | #include <lttng/events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */ |
f127e61e MD |
1583 | |
1584 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS | |
1585 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \ | |
1586 | &__event_desc___##_map, | |
1587 | ||
1588 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP | |
1589 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \ | |
1590 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) | |
1591 | ||
1592 | #define TP_ID1(_token, _system) _token##_system | |
1593 | #define TP_ID(_token, _system) TP_ID1(_token, _system) | |
1594 | ||
1595 | static const struct lttng_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = { | |
1596 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
1597 | }; | |
1598 | ||
1599 | #undef TP_ID1 | |
1600 | #undef TP_ID | |
1601 | ||
1602 | /* | |
1603 | * Stage 9 of the trace events. | |
1604 | * | |
1605 | * Create a toplevel descriptor for the whole probe. | |
1606 | */ | |
1607 | ||
1608 | #define TP_ID1(_token, _system) _token##_system | |
1609 | #define TP_ID(_token, _system) TP_ID1(_token, _system) | |
1610 | ||
1611 | /* non-const because list head will be modified when registered. */ | |
1612 | static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = { | |
1613 | .provider = __stringify(TRACE_SYSTEM), | |
1614 | .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM), | |
1615 | .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)), | |
1616 | .head = { NULL, NULL }, | |
1617 | .lazy_init_head = { NULL, NULL }, | |
1618 | .lazy = 0, | |
1619 | }; | |
1620 | ||
1621 | #undef TP_ID1 | |
1622 | #undef TP_ID | |
1623 | ||
3afe7aac | 1624 | /* |
c099397a | 1625 | * Stage 10 of the trace events. |
3afe7aac MD |
1626 | * |
1627 | * Register/unregister probes at module load/unload. | |
1628 | */ | |
1629 | ||
3b4aafcb | 1630 | #include <lttng/events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */ |
3afe7aac MD |
1631 | |
1632 | #define TP_ID1(_token, _system) _token##_system | |
1633 | #define TP_ID(_token, _system) TP_ID1(_token, _system) | |
1634 | #define module_init_eval1(_token, _system) module_init(_token##_system) | |
1635 | #define module_init_eval(_token, _system) module_init_eval1(_token, _system) | |
1636 | #define module_exit_eval1(_token, _system) module_exit(_token##_system) | |
1637 | #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system) | |
1638 | ||
2655f9ad | 1639 | #ifndef TP_MODULE_NOINIT |
3afe7aac MD |
1640 | static int TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void) |
1641 | { | |
263b6c88 | 1642 | wrapper_vmalloc_sync_mappings(); |
a90917c3 | 1643 | return lttng_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM)); |
3afe7aac MD |
1644 | } |
1645 | ||
3afe7aac MD |
1646 | static void TP_ID(__lttng_events_exit__, TRACE_SYSTEM)(void) |
1647 | { | |
a90917c3 | 1648 | lttng_probe_unregister(&TP_ID(__probe_desc___, TRACE_SYSTEM)); |
3afe7aac MD |
1649 | } |
1650 | ||
2655f9ad MD |
1651 | #ifndef TP_MODULE_NOAUTOLOAD |
1652 | module_init_eval(__lttng_events_init__, TRACE_SYSTEM); | |
3afe7aac | 1653 | module_exit_eval(__lttng_events_exit__, TRACE_SYSTEM); |
259b6cb3 | 1654 | #endif |
3afe7aac | 1655 | |
2655f9ad MD |
1656 | #endif |
1657 | ||
3afe7aac MD |
1658 | #undef module_init_eval |
1659 | #undef module_exit_eval | |
1660 | #undef TP_ID1 | |
1661 | #undef TP_ID | |
177b3692 MD |
1662 | |
1663 | #undef TP_PROTO | |
1664 | #undef TP_ARGS |