Commit | Line | Data |
---|---|---|
1c324e59 | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: MIT |
1c324e59 | 3 | * |
c0c0989a | 4 | * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
1c324e59 MD |
5 | */ |
6 | ||
fb31eb73 | 7 | #include <stdint.h> |
1c324e59 | 8 | #include <stdio.h> |
7d381d6e | 9 | #include <stdlib.h> |
1c324e59 | 10 | #include <urcu/compiler.h> |
f488575f | 11 | #include <urcu/rculist.h> |
1c324e59 | 12 | #include <lttng/ust-events.h> |
0b4b8811 | 13 | #include <lttng/ust-ringbuffer-context.h> |
2eba8e39 | 14 | #include <lttng/ust-arch.h> |
a8909ba5 | 15 | #include <lttng/ust-compiler.h> |
000b8662 | 16 | #include <lttng/tracepoint.h> |
3208818b | 17 | #include <lttng/ust-endian.h> |
4849bc7a | 18 | #include <lttng/ust-api-compat.h> |
44c72f10 | 19 | #include <string.h> |
f3b06377 MD |
20 | #include <lttng/ust-api-compat.h> |
21 | ||
22 | #if LTTNG_UST_COMPAT_API(0) | |
23 | #define TP_FIELDS LTTNG_UST_TP_FIELDS | |
24 | ||
25 | #define ctf_integer lttng_ust_field_integer | |
26 | #define ctf_integer_hex lttng_ust_field_integer_hex | |
27 | #define ctf_integer_network lttng_ust_field_integer_network | |
28 | #define ctf_integer_network_hex lttng_ust_field_integer_network_hex | |
29 | #define ctf_integer_nowrite lttng_ust_field_integer_nowrite | |
30 | ||
31 | #define ctf_float lttng_ust_field_float | |
32 | #define ctf_float_nowrite lttng_ust_field_float_nowrite | |
33 | ||
34 | #define ctf_array lttng_ust_field_array | |
35 | #define ctf_array_hex lttng_ust_field_array_hex | |
36 | #define ctf_array_network lttng_ust_field_array_network | |
37 | #define ctf_array_network_hex lttng_ust_field_array_network_hex | |
38 | #define ctf_array_text lttng_ust_field_array_text | |
39 | #define ctf_array_nowrite lttng_ust_field_array_nowrite | |
40 | #define ctf_array_nowrite_hex lttng_ust_field_array_nowrite_hex | |
41 | #define ctf_array_network_nowrite lttng_ust_field_array_network_nowrite | |
42 | #define ctf_array_network_nowrite_hex lttng_ust_field_array_network_nowrite_hex | |
43 | #define ctf_array_text_nowrite lttng_ust_field_array_text_nowrite | |
44 | ||
45 | #define ctf_sequence lttng_ust_field_sequence | |
46 | #define ctf_sequence_hex lttng_ust_field_sequence_hex | |
47 | #define ctf_sequence_network lttng_ust_field_sequence_network | |
48 | #define ctf_sequence_network_hex lttng_ust_field_sequence_network_hex | |
49 | #define ctf_sequence_text lttng_ust_field_sequence_text | |
50 | #define ctf_sequence_nowrite lttng_ust_field_sequence_nowrite | |
51 | #define ctf_sequence_nowrite_hex lttng_ust_field_sequence_nowrite_hex | |
52 | #define ctf_sequence_network_nowrite lttng_ust_field_sequence_network_nowrite | |
53 | #define ctf_sequence_network_nowrite_hex lttng_ust_field_sequence_network_nowrite_hex | |
54 | #define ctf_sequence_text_nowrite lttng_ust_field_sequence_text_nowrite | |
55 | ||
56 | #define ctf_string lttng_ust_field_string | |
57 | #define ctf_string_nowrite lttng_ust_field_string_nowrite | |
58 | ||
59 | #define ctf_unused lttng_ust_field_unused | |
60 | #define ctf_unused_nowrite lttng_ust_field_unused_nowrite | |
61 | ||
62 | #define ctf_enum lttng_ust_field_enum | |
63 | #define ctf_enum_nowrite lttng_ust_field_enum_nowrite | |
64 | #define ctf_enum_value lttng_ust_field_enum_value | |
65 | #define ctf_enum_range lttng_ust_field_enum_range | |
66 | #define ctf_enum_auto lttng_ust_field_enum_auto | |
67 | #endif /* #if LTTNG_UST_COMPAT_API(0) */ | |
1c324e59 | 68 | |
ee0889a3 | 69 | #define LTTNG_UST__NULL_STRING "(null)" |
24a39530 | 70 | |
1c324e59 | 71 | /* |
7f2f82c3 | 72 | * LTTNG_UST_TRACEPOINT_EVENT_CLASS declares a class of tracepoints receiving the |
1c324e59 MD |
73 | * same arguments and having the same field layout. |
74 | * | |
7f2f82c3 | 75 | * LTTNG_UST_TRACEPOINT_EVENT_INSTANCE declares an instance of a tracepoint, with |
1c324e59 MD |
76 | * its own provider and name. It refers to a class (template). |
77 | * | |
7f2f82c3 | 78 | * LTTNG_UST_TRACEPOINT_EVENT declared both a class and an instance and does a |
1c324e59 MD |
79 | * direct mapping from the instance to the class. |
80 | */ | |
81 | ||
7f2f82c3 MJ |
82 | #undef LTTNG_UST_TRACEPOINT_EVENT |
83 | #define LTTNG_UST_TRACEPOINT_EVENT(_provider, _name, _args, _fields) \ | |
84 | LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, \ | |
6eddcb06 MJ |
85 | LTTNG_UST__TP_PARAMS(_args), \ |
86 | LTTNG_UST__TP_PARAMS(_fields)) \ | |
7f2f82c3 | 87 | LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _name, _name, \ |
6eddcb06 | 88 | LTTNG_UST__TP_PARAMS(_args)) |
1c324e59 | 89 | |
7f2f82c3 MJ |
90 | #undef LTTNG_UST_TRACEPOINT_EVENT_CLASS |
91 | #define LTTNG_UST_TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ | |
6eddcb06 | 92 | LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, LTTNG_UST__TP_PARAMS(_args), LTTNG_UST__TP_PARAMS(_fields)) |
f8021d08 | 93 | |
7f2f82c3 MJ |
94 | #undef LTTNG_UST_TRACEPOINT_EVENT_INSTANCE |
95 | #define LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \ | |
6eddcb06 | 96 | LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, LTTNG_UST__TP_PARAMS(_args)) |
f8021d08 | 97 | |
1c324e59 | 98 | /* Helpers */ |
ca6ed78d | 99 | #define LTTNG_UST__TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) |
1c324e59 | 100 | |
1210ca90 | 101 | #define lttng_ust__tp_max_t(type, x, y) \ |
1c324e59 | 102 | ({ \ |
1210ca90 MJ |
103 | type lttng_ust__max1 = (x); \ |
104 | type lttng_ust__max2 = (y); \ | |
105 | lttng_ust__max1 > lttng_ust__max2 ? lttng_ust__max1: lttng_ust__max2; \ | |
1c324e59 MD |
106 | }) |
107 | ||
108 | /* | |
109 | * Stage 0 of tracepoint event generation. | |
110 | * | |
7f2f82c3 | 111 | * Check that each LTTNG_UST_TRACEPOINT_EVENT provider argument match the |
5b393d64 | 112 | * LTTNG_UST_TRACEPOINT_PROVIDER by creating dummy callbacks. |
1c324e59 MD |
113 | */ |
114 | ||
7f2f82c3 | 115 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
1c324e59 MD |
116 | #include <lttng/ust-tracepoint-event-reset.h> |
117 | ||
106ff4da | 118 | static inline |
5b393d64 | 119 | void LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_mismatch_, LTTNG_UST_TRACEPOINT_PROVIDER)(void) |
106ff4da | 120 | lttng_ust_notrace; |
1c324e59 | 121 | static inline |
5b393d64 | 122 | void LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_mismatch_, LTTNG_UST_TRACEPOINT_PROVIDER)(void) |
1c324e59 MD |
123 | { |
124 | } | |
125 | ||
7f2f82c3 MJ |
126 | #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS |
127 | #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ | |
0274f7f2 | 128 | lttng_ust_tracepoint_provider_mismatch_##_provider(); |
1c324e59 | 129 | |
7f2f82c3 MJ |
130 | #undef LTTNG_UST__TRACEPOINT_EVENT_INSTANCE |
131 | #define LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \ | |
0274f7f2 | 132 | lttng_ust_tracepoint_provider_mismatch_##_provider(); |
1c324e59 | 133 | |
106ff4da | 134 | static inline |
5b393d64 | 135 | void LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_check_, LTTNG_UST_TRACEPOINT_PROVIDER)(void) |
106ff4da | 136 | lttng_ust_notrace; |
e8bd1da7 | 137 | static inline |
5b393d64 | 138 | void LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_check_, LTTNG_UST_TRACEPOINT_PROVIDER)(void) |
1c324e59 | 139 | { |
bb71a8ea | 140 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
1c324e59 MD |
141 | } |
142 | ||
f56cd1d5 MD |
143 | /* |
144 | * Stage 0.1 of tracepoint event generation. | |
145 | * | |
7f2f82c3 | 146 | * Check that each LTTNG_UST_TRACEPOINT_EVENT provider:name does not exceed the |
f56cd1d5 MD |
147 | * tracepoint name length limit. |
148 | */ | |
149 | ||
7f2f82c3 | 150 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
f56cd1d5 MD |
151 | #include <lttng/ust-tracepoint-event-reset.h> |
152 | ||
7f2f82c3 MJ |
153 | #undef LTTNG_UST__TRACEPOINT_EVENT_INSTANCE |
154 | #define LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \ | |
81b16412 | 155 | lttng_ust_tracepoint_validate_name_len(_provider, _name); |
f56cd1d5 | 156 | |
bb71a8ea | 157 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
f56cd1d5 | 158 | |
c75c0422 MD |
159 | /* |
160 | * Stage 0.2 of tracepoint event generation. | |
161 | * | |
162 | * Create dummy trace prototypes for each event class, and for each used | |
163 | * template. This will allow checking whether the prototypes from the | |
164 | * class and the instance using the class actually match. | |
165 | */ | |
166 | ||
7f2f82c3 | 167 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
c75c0422 MD |
168 | #include <lttng/ust-tracepoint-event-reset.h> |
169 | ||
cadfcbfc MJ |
170 | #undef LTTNG_UST_TP_ARGS |
171 | #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__ | |
c75c0422 | 172 | |
7f2f82c3 MJ |
173 | #undef LTTNG_UST__TRACEPOINT_EVENT_INSTANCE |
174 | #define LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \ | |
bfcc2759 | 175 | void lttng_ust__event_template_proto___##_provider##___##_template(LTTNG_UST__TP_ARGS_DATA_PROTO(_args)); |
c75c0422 | 176 | |
7f2f82c3 MJ |
177 | #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS |
178 | #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ | |
bfcc2759 | 179 | void lttng_ust__event_template_proto___##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args)); |
c75c0422 | 180 | |
bb71a8ea | 181 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
c75c0422 | 182 | |
c785c634 MD |
183 | /* |
184 | * Stage 0.9 of tracepoint event generation | |
185 | * | |
186 | * Unfolding the enums | |
187 | */ | |
188 | #include <lttng/ust-tracepoint-event-reset.h> | |
189 | ||
190 | /* Enumeration entry (single value) */ | |
78684808 MJ |
191 | #undef lttng_ust_field_enum_value |
192 | #define lttng_ust_field_enum_value(_string, _value) \ | |
5defa774 | 193 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_enum_entry, { \ |
891d6b55 | 194 | .struct_size = sizeof(struct lttng_ust_enum_entry), \ |
a6f80644 | 195 | .start = { \ |
eae3c729 | 196 | .value = lttng_ust_is_signed_type(__typeof__(_value)) ? \ |
a6f80644 | 197 | (long long) (_value) : (_value), \ |
eae3c729 | 198 | .signedness = lttng_ust_is_signed_type(__typeof__(_value)), \ |
a6f80644 MD |
199 | }, \ |
200 | .end = { \ | |
eae3c729 | 201 | .value = lttng_ust_is_signed_type(__typeof__(_value)) ? \ |
a6f80644 | 202 | (long long) (_value) : (_value), \ |
eae3c729 | 203 | .signedness = lttng_ust_is_signed_type(__typeof__(_value)), \ |
a6f80644 MD |
204 | }, \ |
205 | .string = (_string), \ | |
891d6b55 | 206 | }), |
c785c634 MD |
207 | |
208 | /* Enumeration entry (range) */ | |
78684808 MJ |
209 | #undef lttng_ust_field_enum_range |
210 | #define lttng_ust_field_enum_range(_string, _range_start, _range_end) \ | |
5defa774 | 211 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_enum_entry, { \ |
891d6b55 | 212 | .struct_size = sizeof(struct lttng_ust_enum_entry), \ |
a6f80644 | 213 | .start = { \ |
eae3c729 | 214 | .value = lttng_ust_is_signed_type(__typeof__(_range_start)) ? \ |
a6f80644 | 215 | (long long) (_range_start) : (_range_start), \ |
eae3c729 | 216 | .signedness = lttng_ust_is_signed_type(__typeof__(_range_start)), \ |
a6f80644 MD |
217 | }, \ |
218 | .end = { \ | |
eae3c729 | 219 | .value = lttng_ust_is_signed_type(__typeof__(_range_end)) ? \ |
a6f80644 | 220 | (long long) (_range_end) : (_range_end), \ |
eae3c729 | 221 | .signedness = lttng_ust_is_signed_type(__typeof__(_range_end)), \ |
a6f80644 MD |
222 | }, \ |
223 | .string = (_string), \ | |
891d6b55 | 224 | }), |
c785c634 | 225 | |
3e762260 | 226 | /* Enumeration entry (automatic value; follows the rules of CTF) */ |
78684808 MJ |
227 | #undef lttng_ust_field_enum_auto |
228 | #define lttng_ust_field_enum_auto(_string) \ | |
5defa774 | 229 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_enum_entry, { \ |
891d6b55 | 230 | .struct_size = sizeof(struct lttng_ust_enum_entry), \ |
3e762260 PP |
231 | .start = { \ |
232 | .value = -1ULL, \ | |
233 | .signedness = 0, \ | |
234 | }, \ | |
235 | .end = { \ | |
236 | .value = -1ULL, \ | |
237 | .signedness = 0, \ | |
238 | }, \ | |
239 | .string = (_string), \ | |
1a37a873 | 240 | .options = LTTNG_UST_ENUM_ENTRY_OPTION_IS_AUTO, \ |
891d6b55 | 241 | }), |
3e762260 | 242 | |
4849bc7a MJ |
243 | #undef LTTNG_UST_TP_ENUM_VALUES |
244 | #define LTTNG_UST_TP_ENUM_VALUES(...) \ | |
c785c634 MD |
245 | __VA_ARGS__ |
246 | ||
4849bc7a MJ |
247 | #if LTTNG_UST_COMPAT_API(0) |
248 | # undef TP_ENUM_VALUES | |
249 | # define TP_ENUM_VALUES LTTNG_UST_TP_ENUM_VALUES | |
250 | #endif /* #if LTTNG_UST_COMPAT_API(0) */ | |
251 | ||
2ebf164b MJ |
252 | #undef LTTNG_UST_TRACEPOINT_ENUM |
253 | #define LTTNG_UST_TRACEPOINT_ENUM(_provider, _name, _values) \ | |
3d33ca1d | 254 | const struct lttng_ust_enum_entry * const __enum_values__##_provider##_##_name[] = { \ |
c785c634 | 255 | _values \ |
78684808 | 256 | lttng_ust_field_enum_value("", 0) /* Dummy, 0-len array forbidden by C99. */ \ |
c785c634 | 257 | }; |
bb71a8ea | 258 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
2df82195 FD |
259 | |
260 | /* | |
261 | * Stage 0.9.1 | |
262 | * Verifying array and sequence elements are of an integer type. | |
263 | */ | |
264 | ||
7f2f82c3 | 265 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
2df82195 FD |
266 | #include <lttng/ust-tracepoint-event-reset.h> |
267 | #include <lttng/ust-tracepoint-event-write.h> | |
268 | #include <lttng/ust-tracepoint-event-nowrite.h> | |
269 | ||
10937ee5 MJ |
270 | #undef lttng_ust__field_array_encoded |
271 | #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, \ | |
2df82195 FD |
272 | _length, _encoding, _nowrite, \ |
273 | _elem_type_base) \ | |
10937ee5 | 274 | lttng_ust_field_array_element_type_is_supported(_type, _item); |
2df82195 | 275 | |
1d188af9 MJ |
276 | #undef lttng_ust__field_sequence_encoded |
277 | #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, \ | |
2df82195 FD |
278 | _length_type, _src_length, _encoding, _nowrite, \ |
279 | _elem_type_base) \ | |
10937ee5 | 280 | lttng_ust_field_array_element_type_is_supported(_type, _item); |
2df82195 | 281 | |
efa14d16 MJ |
282 | #undef LTTNG_UST_TP_FIELDS |
283 | #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */ | |
2df82195 | 284 | |
7f2f82c3 MJ |
285 | #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS |
286 | #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ | |
2df82195 | 287 | _fields |
c785c634 | 288 | |
bb71a8ea | 289 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
c785c634 | 290 | |
1c324e59 MD |
291 | /* |
292 | * Stage 1 of tracepoint event generation. | |
293 | * | |
294 | * Create event field type metadata section. | |
295 | * Each event produce an array of fields. | |
296 | */ | |
297 | ||
7f2f82c3 | 298 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
1c324e59 | 299 | #include <lttng/ust-tracepoint-event-reset.h> |
4774c8f3 MD |
300 | #include <lttng/ust-tracepoint-event-write.h> |
301 | #include <lttng/ust-tracepoint-event-nowrite.h> | |
1c324e59 | 302 | |
b4064f28 MJ |
303 | #undef lttng_ust__field_integer_ext |
304 | #define lttng_ust__field_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ | |
5defa774 | 305 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \ |
25cff019 MD |
306 | .struct_size = sizeof(struct lttng_ust_event_field), \ |
307 | .name = #_item, \ | |
a084756d | 308 | .type = lttng_ust_type_integer_define(_type, _byte_order, _base), \ |
25cff019 MD |
309 | .nowrite = _nowrite, \ |
310 | .nofilter = 0, \ | |
311 | }), | |
1c324e59 | 312 | |
891226fc MJ |
313 | #undef lttng_ust__field_float |
314 | #define lttng_ust__field_float(_type, _item, _src, _nowrite) \ | |
5defa774 | 315 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \ |
25cff019 MD |
316 | .struct_size = sizeof(struct lttng_ust_event_field), \ |
317 | .name = #_item, \ | |
a084756d | 318 | .type = lttng_ust_type_float_define(_type), \ |
25cff019 MD |
319 | .nowrite = _nowrite, \ |
320 | .nofilter = 0, \ | |
321 | }), | |
1c324e59 | 322 | |
10937ee5 MJ |
323 | #undef lttng_ust__field_array_encoded |
324 | #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, \ | |
f3ec4cb5 MD |
325 | _length, _encoding, _nowrite, \ |
326 | _elem_type_base) \ | |
5defa774 | 327 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \ |
25cff019 MD |
328 | .struct_size = sizeof(struct lttng_ust_event_field), \ |
329 | .name = #_item, \ | |
5defa774 | 330 | .type = (const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_array, { \ |
a084756d MD |
331 | .parent = { \ |
332 | .type = lttng_ust_type_array, \ | |
333 | }, \ | |
334 | .struct_size = sizeof(struct lttng_ust_type_array), \ | |
335 | .elem_type = lttng_ust_type_integer_define(_type, _byte_order, _elem_type_base), \ | |
336 | .length = _length, \ | |
337 | .alignment = 0, \ | |
338 | .encoding = lttng_ust_string_encoding_##_encoding, \ | |
339 | }), \ | |
25cff019 MD |
340 | .nowrite = _nowrite, \ |
341 | .nofilter = 0, \ | |
342 | }), | |
1c324e59 | 343 | |
1d188af9 MJ |
344 | #undef lttng_ust__field_sequence_encoded |
345 | #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, \ | |
f968510a PP |
346 | _length_type, _src_length, _encoding, _nowrite, \ |
347 | _elem_type_base) \ | |
5defa774 | 348 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \ |
25cff019 MD |
349 | .struct_size = sizeof(struct lttng_ust_event_field), \ |
350 | .name = "_" #_item "_length", \ | |
baa8acf3 | 351 | .type = lttng_ust_type_integer_define(_length_type, LTTNG_UST_BYTE_ORDER, 10), \ |
25cff019 MD |
352 | .nowrite = _nowrite, \ |
353 | .nofilter = 1, \ | |
354 | }), \ | |
5defa774 | 355 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \ |
25cff019 MD |
356 | .struct_size = sizeof(struct lttng_ust_event_field), \ |
357 | .name = #_item, \ | |
5defa774 | 358 | .type = (const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_sequence, { \ |
a084756d MD |
359 | .parent = { \ |
360 | .type = lttng_ust_type_sequence, \ | |
1c324e59 | 361 | }, \ |
a084756d MD |
362 | .struct_size = sizeof(struct lttng_ust_type_sequence), \ |
363 | .length_name = "_" #_item "_length", \ | |
364 | .elem_type = lttng_ust_type_integer_define(_type, _byte_order, _elem_type_base), \ | |
365 | .alignment = 0, \ | |
366 | .encoding = lttng_ust_string_encoding_##_encoding, \ | |
367 | }), \ | |
25cff019 MD |
368 | .nowrite = _nowrite, \ |
369 | .nofilter = 0, \ | |
370 | }), | |
1c324e59 | 371 | |
3202f63a MJ |
372 | #undef lttng_ust__field_string |
373 | #define lttng_ust__field_string(_item, _src, _nowrite) \ | |
5defa774 | 374 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \ |
25cff019 MD |
375 | .struct_size = sizeof(struct lttng_ust_event_field), \ |
376 | .name = #_item, \ | |
5defa774 | 377 | .type = (const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_string, { \ |
a084756d MD |
378 | .parent = { \ |
379 | .type = lttng_ust_type_string, \ | |
46d52200 | 380 | }, \ |
a084756d MD |
381 | .struct_size = sizeof(struct lttng_ust_type_string), \ |
382 | .encoding = lttng_ust_string_encoding_UTF8, \ | |
383 | }), \ | |
25cff019 MD |
384 | .nowrite = _nowrite, \ |
385 | .nofilter = 0, \ | |
386 | }), | |
1c324e59 | 387 | |
ddde62ca MJ |
388 | #undef lttng_ust__field_unused |
389 | #define lttng_ust__field_unused(_src) | |
5152f6df | 390 | |
78684808 MJ |
391 | #undef lttng_ust__field_enum |
392 | #define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \ | |
5defa774 | 393 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \ |
25cff019 | 394 | .struct_size = sizeof(struct lttng_ust_event_field), \ |
c785c634 | 395 | .name = #_item, \ |
5defa774 | 396 | .type = (const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_enum, { \ |
a084756d MD |
397 | .parent = { \ |
398 | .type = lttng_ust_type_enum, \ | |
c785c634 | 399 | }, \ |
a084756d MD |
400 | .struct_size = sizeof(struct lttng_ust_type_enum), \ |
401 | .desc = &__enum_##_provider##_##_name, \ | |
baa8acf3 | 402 | .container_type = lttng_ust_type_integer_define(_type, LTTNG_UST_BYTE_ORDER, 10), \ |
a084756d | 403 | }), \ |
c785c634 | 404 | .nowrite = _nowrite, \ |
25cff019 MD |
405 | .nofilter = 0, \ |
406 | }), | |
c785c634 | 407 | |
efa14d16 MJ |
408 | #undef LTTNG_UST_TP_FIELDS |
409 | #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */ | |
1c324e59 | 410 | |
7f2f82c3 MJ |
411 | #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS |
412 | #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ | |
bfcc2759 | 413 | static const struct lttng_ust_event_field * const lttng_ust__event_fields___##_provider##___##_name[] = { \ |
1c324e59 | 414 | _fields \ |
b4064f28 | 415 | lttng_ust_field_integer(int, dummy, 0) /* Dummy, C99 forbids 0-len array. */ \ |
1c324e59 MD |
416 | }; |
417 | ||
2ebf164b MJ |
418 | #undef LTTNG_UST_TRACEPOINT_ENUM |
419 | #define LTTNG_UST_TRACEPOINT_ENUM(_provider, _name, _values) \ | |
4e48b5d2 | 420 | static const struct lttng_ust_enum_desc __enum_##_provider##_##_name = { \ |
a084756d | 421 | .struct_size = sizeof(struct lttng_ust_enum_desc), \ |
c785c634 MD |
422 | .name = #_provider "_" #_name, \ |
423 | .entries = __enum_values__##_provider##_##_name, \ | |
ca6ed78d | 424 | .nr_entries = LTTNG_UST__TP_ARRAY_SIZE(__enum_values__##_provider##_##_name) - 1, \ |
c785c634 MD |
425 | }; |
426 | ||
bb71a8ea | 427 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
1c324e59 MD |
428 | |
429 | /* | |
430 | * Stage 2 of tracepoint event generation. | |
431 | * | |
432 | * Create probe callback prototypes. | |
433 | */ | |
434 | ||
7f2f82c3 | 435 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
1c324e59 MD |
436 | #include <lttng/ust-tracepoint-event-reset.h> |
437 | ||
cadfcbfc MJ |
438 | #undef LTTNG_UST_TP_ARGS |
439 | #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__ | |
1c324e59 | 440 | |
7f2f82c3 MJ |
441 | #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS |
442 | #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ | |
bfcc2759 | 443 | static void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args)); |
1c324e59 | 444 | |
bb71a8ea | 445 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
1c324e59 MD |
446 | |
447 | /* | |
c785c634 | 448 | * Stage 3.0 of tracepoint event generation. |
1c324e59 | 449 | * |
1c324e59 MD |
450 | * Create static inline function that calculates event size. |
451 | */ | |
452 | ||
7f2f82c3 | 453 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
1c324e59 | 454 | #include <lttng/ust-tracepoint-event-reset.h> |
4774c8f3 | 455 | #include <lttng/ust-tracepoint-event-write.h> |
1c324e59 | 456 | |
b4064f28 MJ |
457 | #undef lttng_ust__field_integer_ext |
458 | #define lttng_ust__field_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ | |
5152f6df MJ |
459 | if (0) \ |
460 | (void) (_src); /* Unused */ \ | |
b5457df5 | 461 | __event_len += lttng_ust_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \ |
1c324e59 MD |
462 | __event_len += sizeof(_type); |
463 | ||
891226fc MJ |
464 | #undef lttng_ust__field_float |
465 | #define lttng_ust__field_float(_type, _item, _src, _nowrite) \ | |
5152f6df MJ |
466 | if (0) \ |
467 | (void) (_src); /* Unused */ \ | |
b5457df5 | 468 | __event_len += lttng_ust_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \ |
1c324e59 MD |
469 | __event_len += sizeof(_type); |
470 | ||
10937ee5 MJ |
471 | #undef lttng_ust__field_array_encoded |
472 | #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, _length, _encoding, \ | |
f3ec4cb5 | 473 | _nowrite, _elem_type_base) \ |
5152f6df MJ |
474 | if (0) \ |
475 | (void) (_src); /* Unused */ \ | |
b5457df5 | 476 | __event_len += lttng_ust_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \ |
1c324e59 MD |
477 | __event_len += sizeof(_type) * (_length); |
478 | ||
1d188af9 MJ |
479 | #undef lttng_ust__field_sequence_encoded |
480 | #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \ | |
f968510a | 481 | _src_length, _encoding, _nowrite, _elem_type_base) \ |
5152f6df MJ |
482 | if (0) \ |
483 | (void) (_src); /* Unused */ \ | |
b5457df5 | 484 | __event_len += lttng_ust_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_length_type)); \ |
1c324e59 | 485 | __event_len += sizeof(_length_type); \ |
b5457df5 | 486 | __event_len += lttng_ust_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \ |
1c324e59 MD |
487 | __dynamic_len[__dynamic_len_idx] = (_src_length); \ |
488 | __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ | |
489 | __dynamic_len_idx++; | |
490 | ||
3202f63a MJ |
491 | #undef lttng_ust__field_string |
492 | #define lttng_ust__field_string(_item, _src, _nowrite) \ | |
24a39530 | 493 | __event_len += __dynamic_len[__dynamic_len_idx++] = \ |
ee0889a3 | 494 | strlen((_src) ? (_src) : LTTNG_UST__NULL_STRING) + 1; |
1c324e59 | 495 | |
ddde62ca MJ |
496 | #undef lttng_ust__field_unused |
497 | #define lttng_ust__field_unused(_src) \ | |
5152f6df MJ |
498 | if (0) \ |
499 | (void) (_src); /* Unused */ | |
500 | ||
78684808 MJ |
501 | #undef lttng_ust__field_enum |
502 | #define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \ | |
b4064f28 | 503 | lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite) |
c785c634 | 504 | |
cadfcbfc MJ |
505 | #undef LTTNG_UST_TP_ARGS |
506 | #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__ | |
1c324e59 | 507 | |
efa14d16 MJ |
508 | #undef LTTNG_UST_TP_FIELDS |
509 | #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__ | |
1c324e59 | 510 | |
7f2f82c3 MJ |
511 | #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS |
512 | #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ | |
106ff4da | 513 | static inline \ |
bfcc2759 | 514 | size_t lttng_ust__event_get_size__##_provider##___##_name(size_t *__dynamic_len, LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \ |
106ff4da | 515 | lttng_ust_notrace; \ |
a8909ba5 | 516 | static inline \ |
bfcc2759 | 517 | size_t lttng_ust__event_get_size__##_provider##___##_name( \ |
5152f6df | 518 | size_t *__dynamic_len __attribute__((__unused__)), \ |
6eddcb06 | 519 | LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \ |
1c324e59 MD |
520 | { \ |
521 | size_t __event_len = 0; \ | |
5152f6df | 522 | unsigned int __dynamic_len_idx __attribute__((__unused__)) = 0; \ |
1c324e59 MD |
523 | \ |
524 | if (0) \ | |
5152f6df MJ |
525 | (void) __tp_data; /* don't warn if unused */ \ |
526 | \ | |
1c324e59 MD |
527 | _fields \ |
528 | return __event_len; \ | |
529 | } | |
530 | ||
bb71a8ea | 531 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
1c324e59 | 532 | |
1ddfd641 MD |
533 | /* |
534 | * Stage 3.1 of tracepoint event generation. | |
535 | * | |
536 | * Create static inline function that layout the filter stack data. | |
4774c8f3 | 537 | * We make both write and nowrite data available to the filter. |
1ddfd641 MD |
538 | */ |
539 | ||
7f2f82c3 | 540 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
1ddfd641 | 541 | #include <lttng/ust-tracepoint-event-reset.h> |
4774c8f3 MD |
542 | #include <lttng/ust-tracepoint-event-write.h> |
543 | #include <lttng/ust-tracepoint-event-nowrite.h> | |
1ddfd641 | 544 | |
b4064f28 MJ |
545 | #undef lttng_ust__field_integer_ext |
546 | #define lttng_ust__field_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ | |
eae3c729 | 547 | if (lttng_ust_is_signed_type(_type)) { \ |
3ebeea0d MD |
548 | int64_t __ctf_tmp_int64; \ |
549 | switch (sizeof(_type)) { \ | |
550 | case 1: \ | |
551 | { \ | |
552 | union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \ | |
553 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ | |
554 | break; \ | |
555 | } \ | |
556 | case 2: \ | |
557 | { \ | |
558 | union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \ | |
baa8acf3 MJ |
559 | if (_byte_order != LTTNG_UST_BYTE_ORDER) \ |
560 | __tmp.v = lttng_ust_bswap_16(__tmp.v); \ | |
3ebeea0d MD |
561 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ |
562 | break; \ | |
563 | } \ | |
564 | case 4: \ | |
565 | { \ | |
566 | union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \ | |
baa8acf3 MJ |
567 | if (_byte_order != LTTNG_UST_BYTE_ORDER) \ |
568 | __tmp.v = lttng_ust_bswap_32(__tmp.v); \ | |
3ebeea0d MD |
569 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ |
570 | break; \ | |
571 | } \ | |
572 | case 8: \ | |
573 | { \ | |
574 | union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \ | |
baa8acf3 MJ |
575 | if (_byte_order != LTTNG_UST_BYTE_ORDER) \ |
576 | __tmp.v = lttng_ust_bswap_64(__tmp.v); \ | |
3ebeea0d MD |
577 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ |
578 | break; \ | |
579 | } \ | |
580 | default: \ | |
581 | abort(); \ | |
582 | }; \ | |
fa099471 MD |
583 | memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \ |
584 | } else { \ | |
3ebeea0d MD |
585 | uint64_t __ctf_tmp_uint64; \ |
586 | switch (sizeof(_type)) { \ | |
587 | case 1: \ | |
588 | { \ | |
589 | union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \ | |
590 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ | |
591 | break; \ | |
592 | } \ | |
593 | case 2: \ | |
594 | { \ | |
595 | union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \ | |
baa8acf3 MJ |
596 | if (_byte_order != LTTNG_UST_BYTE_ORDER) \ |
597 | __tmp.v = lttng_ust_bswap_16(__tmp.v); \ | |
3ebeea0d MD |
598 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ |
599 | break; \ | |
600 | } \ | |
601 | case 4: \ | |
602 | { \ | |
603 | union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \ | |
baa8acf3 MJ |
604 | if (_byte_order != LTTNG_UST_BYTE_ORDER) \ |
605 | __tmp.v = lttng_ust_bswap_32(__tmp.v); \ | |
3ebeea0d MD |
606 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ |
607 | break; \ | |
608 | } \ | |
609 | case 8: \ | |
610 | { \ | |
611 | union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \ | |
baa8acf3 MJ |
612 | if (_byte_order != LTTNG_UST_BYTE_ORDER) \ |
613 | __tmp.v = lttng_ust_bswap_64(__tmp.v); \ | |
3ebeea0d MD |
614 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ |
615 | break; \ | |
616 | } \ | |
617 | default: \ | |
618 | abort(); \ | |
619 | }; \ | |
fa099471 MD |
620 | memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \ |
621 | } \ | |
1ddfd641 MD |
622 | __stack_data += sizeof(int64_t); |
623 | ||
891226fc MJ |
624 | #undef lttng_ust__field_float |
625 | #define lttng_ust__field_float(_type, _item, _src, _nowrite) \ | |
fa099471 MD |
626 | { \ |
627 | double __ctf_tmp_double = (double) (_type) (_src); \ | |
628 | memcpy(__stack_data, &__ctf_tmp_double, sizeof(double)); \ | |
629 | __stack_data += sizeof(double); \ | |
630 | } | |
1ddfd641 | 631 | |
10937ee5 MJ |
632 | #undef lttng_ust__field_array_encoded |
633 | #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, _length, \ | |
f3ec4cb5 | 634 | _encoding, _nowrite, _elem_type_base) \ |
fa099471 MD |
635 | { \ |
636 | unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \ | |
59034aab | 637 | const void *__ctf_tmp_ptr = (_src); \ |
fa099471 MD |
638 | memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \ |
639 | __stack_data += sizeof(unsigned long); \ | |
b1239ad6 MD |
640 | memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \ |
641 | __stack_data += sizeof(void *); \ | |
fa099471 | 642 | } |
1ddfd641 | 643 | |
1d188af9 MJ |
644 | #undef lttng_ust__field_sequence_encoded |
645 | #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \ | |
f968510a | 646 | _src_length, _encoding, _nowrite, _elem_type_base) \ |
fa099471 MD |
647 | { \ |
648 | unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \ | |
59034aab | 649 | const void *__ctf_tmp_ptr = (_src); \ |
fa099471 MD |
650 | memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \ |
651 | __stack_data += sizeof(unsigned long); \ | |
b1239ad6 MD |
652 | memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \ |
653 | __stack_data += sizeof(void *); \ | |
fa099471 | 654 | } |
1ddfd641 | 655 | |
3202f63a MJ |
656 | #undef lttng_ust__field_string |
657 | #define lttng_ust__field_string(_item, _src, _nowrite) \ | |
fa099471 | 658 | { \ |
24a39530 | 659 | const void *__ctf_tmp_ptr = \ |
ee0889a3 | 660 | ((_src) ? (_src) : LTTNG_UST__NULL_STRING); \ |
b1239ad6 MD |
661 | memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \ |
662 | __stack_data += sizeof(void *); \ | |
fa099471 | 663 | } |
1ddfd641 | 664 | |
ddde62ca MJ |
665 | #undef lttng_ust__field_unused |
666 | #define lttng_ust__field_unused(_src) \ | |
5152f6df MJ |
667 | if (0) \ |
668 | (void) (_src); | |
669 | ||
78684808 MJ |
670 | #undef lttng_ust__field_enum |
671 | #define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \ | |
b4064f28 | 672 | lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite) |
c785c634 | 673 | |
cadfcbfc MJ |
674 | #undef LTTNG_UST_TP_ARGS |
675 | #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__ | |
1ddfd641 | 676 | |
efa14d16 MJ |
677 | #undef LTTNG_UST_TP_FIELDS |
678 | #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__ | |
1ddfd641 | 679 | |
7f2f82c3 MJ |
680 | #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS |
681 | #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ | |
1ddfd641 | 682 | static inline \ |
bfcc2759 | 683 | void lttng_ust__event_prepare_interpreter_stack__##_provider##___##_name(char *__stack_data,\ |
6eddcb06 | 684 | LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \ |
1ddfd641 | 685 | { \ |
5152f6df MJ |
686 | if (0) { \ |
687 | (void) __tp_data; /* don't warn if unused */ \ | |
688 | (void) __stack_data; /* don't warn if unused */ \ | |
689 | } \ | |
690 | \ | |
1ddfd641 MD |
691 | _fields \ |
692 | } | |
693 | ||
bb71a8ea | 694 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
1ddfd641 | 695 | |
1c324e59 | 696 | /* |
df854e41 | 697 | * Stage 4 of tracepoint event generation. |
1c324e59 MD |
698 | * |
699 | * Create static inline function that calculates event payload alignment. | |
700 | */ | |
701 | ||
7f2f82c3 | 702 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
1c324e59 | 703 | #include <lttng/ust-tracepoint-event-reset.h> |
4774c8f3 | 704 | #include <lttng/ust-tracepoint-event-write.h> |
1c324e59 | 705 | |
b4064f28 MJ |
706 | #undef lttng_ust__field_integer_ext |
707 | #define lttng_ust__field_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ | |
5152f6df MJ |
708 | if (0) \ |
709 | (void) (_src); /* Unused */ \ | |
26376e52 | 710 | __event_align = lttng_ust__tp_max_t(size_t, __event_align, lttng_ust_rb_alignof(_type)); |
1c324e59 | 711 | |
891226fc MJ |
712 | #undef lttng_ust__field_float |
713 | #define lttng_ust__field_float(_type, _item, _src, _nowrite) \ | |
5152f6df MJ |
714 | if (0) \ |
715 | (void) (_src); /* Unused */ \ | |
26376e52 | 716 | __event_align = lttng_ust__tp_max_t(size_t, __event_align, lttng_ust_rb_alignof(_type)); |
1c324e59 | 717 | |
10937ee5 MJ |
718 | #undef lttng_ust__field_array_encoded |
719 | #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, _length, \ | |
f3ec4cb5 | 720 | _encoding, _nowrite, _elem_type_base) \ |
5152f6df MJ |
721 | if (0) \ |
722 | (void) (_src); /* Unused */ \ | |
26376e52 | 723 | __event_align = lttng_ust__tp_max_t(size_t, __event_align, lttng_ust_rb_alignof(_type)); |
1c324e59 | 724 | |
1d188af9 MJ |
725 | #undef lttng_ust__field_sequence_encoded |
726 | #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \ | |
f968510a | 727 | _src_length, _encoding, _nowrite, _elem_type_base) \ |
5152f6df MJ |
728 | if (0) \ |
729 | (void) (_src); /* Unused */ \ | |
730 | if (0) \ | |
731 | (void) (_src_length); /* Unused */ \ | |
26376e52 MD |
732 | __event_align = lttng_ust__tp_max_t(size_t, __event_align, lttng_ust_rb_alignof(_length_type)); \ |
733 | __event_align = lttng_ust__tp_max_t(size_t, __event_align, lttng_ust_rb_alignof(_type)); | |
1c324e59 | 734 | |
3202f63a MJ |
735 | #undef lttng_ust__field_string |
736 | #define lttng_ust__field_string(_item, _src, _nowrite) \ | |
5152f6df MJ |
737 | if (0) \ |
738 | (void) (_src); /* Unused */ | |
739 | ||
ddde62ca MJ |
740 | #undef lttng_ust__field_unused |
741 | #define lttng_ust__field_unused(_src) \ | |
5152f6df MJ |
742 | if (0) \ |
743 | (void) (_src); /* Unused */ | |
1c324e59 | 744 | |
78684808 MJ |
745 | #undef lttng_ust__field_enum |
746 | #define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \ | |
b4064f28 | 747 | lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite) |
c785c634 | 748 | |
cadfcbfc MJ |
749 | #undef LTTNG_UST_TP_ARGS |
750 | #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__ | |
1c324e59 | 751 | |
efa14d16 MJ |
752 | #undef LTTNG_UST_TP_FIELDS |
753 | #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__ | |
1c324e59 | 754 | |
7f2f82c3 MJ |
755 | #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS |
756 | #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ | |
106ff4da | 757 | static inline \ |
bfcc2759 | 758 | size_t lttng_ust__event_get_align__##_provider##___##_name(LTTNG_UST__TP_ARGS_PROTO(_args)) \ |
106ff4da | 759 | lttng_ust_notrace; \ |
1c324e59 | 760 | static inline \ |
bfcc2759 | 761 | size_t lttng_ust__event_get_align__##_provider##___##_name(LTTNG_UST__TP_ARGS_PROTO(_args)) \ |
1c324e59 | 762 | { \ |
26376e52 | 763 | size_t __event_align = 1; \ |
1c324e59 | 764 | _fields \ |
26376e52 | 765 | return __event_align; \ |
1c324e59 MD |
766 | } |
767 | ||
bb71a8ea | 768 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
1c324e59 MD |
769 | |
770 | ||
771 | /* | |
df854e41 | 772 | * Stage 5 of tracepoint event generation. |
1c324e59 MD |
773 | * |
774 | * Create the probe function. This function calls event size calculation | |
775 | * and writes event data into the buffer. | |
776 | */ | |
777 | ||
7f2f82c3 | 778 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
1c324e59 | 779 | #include <lttng/ust-tracepoint-event-reset.h> |
4774c8f3 | 780 | #include <lttng/ust-tracepoint-event-write.h> |
1c324e59 | 781 | |
b4064f28 MJ |
782 | #undef lttng_ust__field_integer_ext |
783 | #define lttng_ust__field_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ | |
1c324e59 MD |
784 | { \ |
785 | _type __tmp = (_src); \ | |
8936b6c0 | 786 | __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp), lttng_ust_rb_alignof(__tmp));\ |
1c324e59 MD |
787 | } |
788 | ||
891226fc MJ |
789 | #undef lttng_ust__field_float |
790 | #define lttng_ust__field_float(_type, _item, _src, _nowrite) \ | |
1c324e59 MD |
791 | { \ |
792 | _type __tmp = (_src); \ | |
8936b6c0 | 793 | __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp), lttng_ust_rb_alignof(__tmp));\ |
1c324e59 MD |
794 | } |
795 | ||
10937ee5 MJ |
796 | #undef lttng_ust__field_array_encoded |
797 | #define lttng_ust__field_array_encoded(_type, _item, _src, _byte_order, _length, \ | |
f3ec4cb5 | 798 | _encoding, _nowrite, _elem_type_base) \ |
27927814 | 799 | if (lttng_ust_string_encoding_##_encoding == lttng_ust_string_encoding_none) \ |
8936b6c0 | 800 | __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length), lttng_ust_rb_alignof(_type)); \ |
27927814 | 801 | else \ |
879f9b0a | 802 | __chan->ops->event_pstrcpy_pad(&__ctx, (const char *) (_src), _length); \ |
1c324e59 | 803 | |
1d188af9 MJ |
804 | #undef lttng_ust__field_sequence_encoded |
805 | #define lttng_ust__field_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \ | |
f968510a | 806 | _src_length, _encoding, _nowrite, _elem_type_base) \ |
1c324e59 | 807 | { \ |
d71b57b9 | 808 | _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx]; \ |
8936b6c0 | 809 | __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type), lttng_ust_rb_alignof(_length_type));\ |
1c324e59 | 810 | } \ |
27927814 MD |
811 | if (lttng_ust_string_encoding_##_encoding == lttng_ust_string_encoding_none) \ |
812 | __chan->ops->event_write(&__ctx, _src, \ | |
bae1f483 | 813 | sizeof(_type) * lttng_ust__get_dynamic_len(dest), lttng_ust_rb_alignof(_type)); \ |
27927814 | 814 | else \ |
bae1f483 | 815 | __chan->ops->event_pstrcpy_pad(&__ctx, (const char *) (_src), lttng_ust__get_dynamic_len(dest)); \ |
1c324e59 | 816 | |
3202f63a MJ |
817 | #undef lttng_ust__field_string |
818 | #define lttng_ust__field_string(_item, _src, _nowrite) \ | |
24a39530 PP |
819 | { \ |
820 | const char *__ctf_tmp_string = \ | |
ee0889a3 | 821 | ((_src) ? (_src) : LTTNG_UST__NULL_STRING); \ |
f9ec4a97 | 822 | __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \ |
bae1f483 | 823 | lttng_ust__get_dynamic_len(dest)); \ |
24a39530 PP |
824 | } |
825 | ||
ddde62ca MJ |
826 | #undef lttng_ust__field_unused |
827 | #define lttng_ust__field_unused(_src) | |
1c324e59 | 828 | |
78684808 MJ |
829 | #undef lttng_ust__field_enum |
830 | #define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \ | |
b4064f28 | 831 | lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite) |
c785c634 | 832 | |
1c324e59 | 833 | /* Beware: this get len actually consumes the len value */ |
bae1f483 MJ |
834 | #undef lttng_ust__get_dynamic_len |
835 | #define lttng_ust__get_dynamic_len(field) __stackvar.__dynamic_len[__dynamic_len_idx++] | |
1c324e59 | 836 | |
cadfcbfc MJ |
837 | #undef LTTNG_UST_TP_ARGS |
838 | #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__ | |
1c324e59 | 839 | |
efa14d16 MJ |
840 | #undef LTTNG_UST_TP_FIELDS |
841 | #define LTTNG_UST_TP_FIELDS(...) __VA_ARGS__ | |
1c324e59 | 842 | |
95c25348 PW |
843 | /* |
844 | * For state dump, check that "session" argument (mandatory) matches the | |
845 | * session this event belongs to. Ensures that we write state dump data only | |
846 | * into the started session, not into all sessions. | |
847 | */ | |
91fe3e13 MJ |
848 | #undef LTTNG_UST__TP_SESSION_CHECK |
849 | #ifdef LTTNG_UST_TP_SESSION_CHECK | |
850 | #define LTTNG_UST__TP_SESSION_CHECK(session, csession) (session == csession) | |
95c25348 | 851 | #else /* TP_SESSION_CHECK */ |
91fe3e13 | 852 | #define LTTNG_UST__TP_SESSION_CHECK(session, csession) 1 |
95c25348 PW |
853 | #endif /* TP_SESSION_CHECK */ |
854 | ||
97904b41 MD |
855 | /* |
856 | * Use of __builtin_return_address(0) sometimes seems to cause stack | |
857 | * corruption on 32-bit PowerPC. Disable this feature on that | |
858 | * architecture for now by always using the NULL value for the ip | |
859 | * context. | |
860 | */ | |
c28c4a88 MJ |
861 | #undef LTTNG_UST__TP_IP_PARAM |
862 | ||
863 | #ifdef LTTNG_UST_TP_IP_PARAM | |
864 | #define LTTNG_UST__TP_IP_PARAM(x) (x) | |
5dadb547 | 865 | #else /* TP_IP_PARAM */ |
97904b41 | 866 | |
2eba8e39 | 867 | #if defined(LTTNG_UST_ARCH_PPC) && !defined(LTTNG_UST_ARCH_PPC64) |
c28c4a88 | 868 | #define LTTNG_UST__TP_IP_PARAM(x) NULL |
2eba8e39 | 869 | #else |
c28c4a88 | 870 | #define LTTNG_UST__TP_IP_PARAM(x) __builtin_return_address(0) |
2eba8e39 | 871 | #endif |
97904b41 | 872 | |
5dadb547 MD |
873 | #endif /* TP_IP_PARAM */ |
874 | ||
1ddfd641 MD |
875 | /* |
876 | * Using twice size for filter stack data to hold size and pointer for | |
877 | * each field (worse case). For integers, max size required is 64-bit. | |
878 | * Same for double-precision floats. Those fit within | |
879 | * 2*sizeof(unsigned long) for all supported architectures. | |
61ce3223 | 880 | * Perform UNION (||) of filter runtime list. |
1ddfd641 | 881 | */ |
7f2f82c3 | 882 | #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS |
b2e37d27 | 883 | #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ |
106ff4da | 884 | static \ |
b2e37d27 | 885 | void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \ |
106ff4da | 886 | lttng_ust_notrace; \ |
a8909ba5 | 887 | static \ |
b2e37d27 | 888 | void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_DATA_PROTO(_args)) \ |
1c324e59 | 889 | { \ |
ba99fbe2 | 890 | struct lttng_ust_event_common *__event = (struct lttng_ust_event_common *) __tp_data; \ |
1c324e59 | 891 | size_t __dynamic_len_idx = 0; \ |
bfcc2759 | 892 | const size_t __num_fields = LTTNG_UST__TP_ARRAY_SIZE(lttng_ust__event_fields___##_provider##___##_name) - 1; \ |
b2e37d27 | 893 | struct lttng_ust_probe_ctx __probe_ctx; \ |
d71b57b9 | 894 | union { \ |
75026e9f | 895 | size_t __dynamic_len[__num_fields]; \ |
ba99fbe2 | 896 | char __interpreter_stack_data[2 * sizeof(unsigned long) * __num_fields]; \ |
d71b57b9 | 897 | } __stackvar; \ |
1c324e59 | 898 | int __ret; \ |
a2e4d05e | 899 | bool __interpreter_stack_prepared = false; \ |
1c324e59 MD |
900 | \ |
901 | if (0) \ | |
902 | (void) __dynamic_len_idx; /* don't warn if unused */ \ | |
ba99fbe2 MD |
903 | switch (__event->type) { \ |
904 | case LTTNG_UST_EVENT_TYPE_RECORDER: \ | |
905 | { \ | |
26376e52 MD |
906 | struct lttng_ust_event_recorder *__event_recorder = (struct lttng_ust_event_recorder *) __event->child; \ |
907 | struct lttng_ust_channel_buffer *__chan = __event_recorder->chan; \ | |
e7bc0ef6 | 908 | struct lttng_ust_channel_common *__chan_common = __chan->parent; \ |
ba99fbe2 | 909 | \ |
b2e37d27 | 910 | if (!LTTNG_UST__TP_SESSION_CHECK(session, __chan_common->session)) \ |
ba99fbe2 | 911 | return; \ |
e7bc0ef6 | 912 | if (caa_unlikely(!CMM_ACCESS_ONCE(__chan_common->session->active))) \ |
ba99fbe2 | 913 | return; \ |
e7bc0ef6 | 914 | if (caa_unlikely(!CMM_ACCESS_ONCE(__chan_common->enabled))) \ |
ba99fbe2 MD |
915 | return; \ |
916 | break; \ | |
917 | } \ | |
918 | case LTTNG_UST_EVENT_TYPE_NOTIFIER: \ | |
919 | break; \ | |
920 | } \ | |
921 | if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \ | |
1c324e59 | 922 | return; \ |
b2e37d27 | 923 | if (caa_unlikely(!LTTNG_UST_TP_RCU_LINK_TEST())) \ |
1b436e01 | 924 | return; \ |
b2e37d27 MD |
925 | __probe_ctx.struct_size = sizeof(struct lttng_ust_probe_ctx); \ |
926 | __probe_ctx.ip = LTTNG_UST__TP_IP_PARAM(LTTNG_UST_TP_IP_PARAM); \ | |
927 | if (caa_unlikely(CMM_ACCESS_ONCE(__event->eval_filter))) { \ | |
bfcc2759 | 928 | lttng_ust__event_prepare_interpreter_stack__##_provider##___##_name(__stackvar.__interpreter_stack_data, \ |
b2e37d27 | 929 | LTTNG_UST__TP_ARGS_DATA_VAR(_args)); \ |
a2e4d05e | 930 | __interpreter_stack_prepared = true; \ |
b2e37d27 MD |
931 | if (caa_likely(__event->run_filter(__event, \ |
932 | __stackvar.__interpreter_stack_data, &__probe_ctx, NULL) != LTTNG_UST_EVENT_FILTER_ACCEPT)) \ | |
61ce3223 | 933 | return; \ |
1ddfd641 | 934 | } \ |
ba99fbe2 MD |
935 | switch (__event->type) { \ |
936 | case LTTNG_UST_EVENT_TYPE_RECORDER: \ | |
937 | { \ | |
26376e52 MD |
938 | size_t __event_len, __event_align; \ |
939 | struct lttng_ust_event_recorder *__event_recorder = (struct lttng_ust_event_recorder *) __event->child; \ | |
940 | struct lttng_ust_channel_buffer *__chan = __event_recorder->chan; \ | |
b2e37d27 | 941 | struct lttng_ust_ring_buffer_ctx __ctx; \ |
ba99fbe2 | 942 | \ |
bfcc2759 | 943 | __event_len = lttng_ust__event_get_size__##_provider##___##_name(__stackvar.__dynamic_len, \ |
6eddcb06 | 944 | LTTNG_UST__TP_ARGS_DATA_VAR(_args)); \ |
26376e52 MD |
945 | __event_align = lttng_ust__event_get_align__##_provider##___##_name(LTTNG_UST__TP_ARGS_VAR(_args)); \ |
946 | lttng_ust_ring_buffer_ctx_init(&__ctx, __event_recorder, __event_len, __event_align, \ | |
b2e37d27 | 947 | &__probe_ctx); \ |
8936b6c0 | 948 | __ret = __chan->ops->event_reserve(&__ctx); \ |
ba99fbe2 MD |
949 | if (__ret < 0) \ |
950 | return; \ | |
951 | _fields \ | |
952 | __chan->ops->event_commit(&__ctx); \ | |
953 | break; \ | |
954 | } \ | |
955 | case LTTNG_UST_EVENT_TYPE_NOTIFIER: \ | |
956 | { \ | |
26376e52 | 957 | struct lttng_ust_event_notifier *__event_notifier = (struct lttng_ust_event_notifier *) __event->child; \ |
a2e4d05e MD |
958 | struct lttng_ust_notification_ctx __notif_ctx; \ |
959 | \ | |
960 | __notif_ctx.struct_size = sizeof(struct lttng_ust_notification_ctx); \ | |
26376e52 | 961 | __notif_ctx.eval_capture = CMM_ACCESS_ONCE(__event_notifier->eval_capture); \ |
ba99fbe2 | 962 | \ |
a2e4d05e | 963 | if (caa_unlikely(!__interpreter_stack_prepared && __notif_ctx.eval_capture)) \ |
bfcc2759 | 964 | lttng_ust__event_prepare_interpreter_stack__##_provider##___##_name(__stackvar.__interpreter_stack_data, \ |
b2e37d27 | 965 | LTTNG_UST__TP_ARGS_DATA_VAR(_args)); \ |
ba99fbe2 | 966 | \ |
26376e52 | 967 | __event_notifier->notification_send(__event_notifier, \ |
a2e4d05e | 968 | __stackvar.__interpreter_stack_data, \ |
b2e37d27 | 969 | &__probe_ctx, \ |
a2e4d05e | 970 | &__notif_ctx); \ |
ba99fbe2 MD |
971 | break; \ |
972 | } \ | |
973 | } \ | |
1c324e59 MD |
974 | } |
975 | ||
bb71a8ea | 976 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
1c324e59 | 977 | |
bae1f483 | 978 | #undef lttng_ust__get_dynamic_len |
1c324e59 | 979 | |
68755429 MD |
980 | /* |
981 | * Stage 5.1 of tracepoint event generation. | |
982 | * | |
983 | * Create probe signature | |
984 | */ | |
985 | ||
7f2f82c3 | 986 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
68755429 MD |
987 | #include <lttng/ust-tracepoint-event-reset.h> |
988 | ||
cadfcbfc MJ |
989 | #undef LTTNG_UST_TP_ARGS |
990 | #define LTTNG_UST_TP_ARGS(...) __VA_ARGS__ | |
9eb06182 | 991 | |
4a36f0f1 | 992 | #define LTTNG_UST__TP_EXTRACT_STRING2(...) #__VA_ARGS__ |
68755429 | 993 | |
7f2f82c3 MJ |
994 | #undef LTTNG_UST__TRACEPOINT_EVENT_CLASS |
995 | #define LTTNG_UST__TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ | |
ff82b7c1 | 996 | static const char __tp_event_signature___##_provider##___##_name[] = \ |
4a36f0f1 | 997 | LTTNG_UST__TP_EXTRACT_STRING2(_args); |
68755429 | 998 | |
bb71a8ea | 999 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
68755429 | 1000 | |
4a36f0f1 | 1001 | #undef LTTNG_UST__TP_EXTRACT_STRING2 |
9eb06182 | 1002 | |
05ceaafd | 1003 | /* |
882a56d7 | 1004 | * Stage 6 of tracepoint event generation. |
1c324e59 | 1005 | * |
df854e41 MD |
1006 | * Tracepoint loglevel mapping definition generation. We generate a |
1007 | * symbol for each mapping for a provider/event to ensure at most a 1 to | |
1008 | * 1 mapping between events and loglevels. If the symbol is repeated, | |
1009 | * the compiler will complain. | |
05ceaafd MD |
1010 | */ |
1011 | ||
7f2f82c3 | 1012 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
05ceaafd MD |
1013 | #include <lttng/ust-tracepoint-event-reset.h> |
1014 | ||
4ea4f80e MD |
1015 | /* |
1016 | * Declare _loglevel___##__provider##___##__name as non-static, with | |
1017 | * hidden visibility for c++ handling of weakref. We do a weakref to the | |
1018 | * symbol in a later stage, which requires that the symbol is not | |
1019 | * mangled. | |
1020 | */ | |
1021 | #ifdef __cplusplus | |
fc6d7bef | 1022 | #define LTTNG_UST_TP_EXTERN_C extern "C" |
4ea4f80e | 1023 | #else |
fc6d7bef | 1024 | #define LTTNG_UST_TP_EXTERN_C |
4ea4f80e MD |
1025 | #endif |
1026 | ||
612e9ce4 MJ |
1027 | #undef LTTNG_UST_TRACEPOINT_LOGLEVEL |
1028 | #define LTTNG_UST_TRACEPOINT_LOGLEVEL(__provider, __name, __loglevel) \ | |
3d33ca1d MD |
1029 | static const int _loglevel_value___##__provider##___##__name = __loglevel; \ |
1030 | LTTNG_UST_TP_EXTERN_C const int * const _loglevel___##__provider##___##__name \ | |
1031 | __attribute__((visibility("hidden"))) = \ | |
457a6b58 | 1032 | &_loglevel_value___##__provider##___##__name; |
df854e41 | 1033 | |
bb71a8ea | 1034 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
df854e41 | 1035 | |
fc6d7bef | 1036 | #undef LTTNG_UST_TP_EXTERN_C |
4ea4f80e | 1037 | |
6ddc916d MD |
1038 | /* |
1039 | * Stage 6.1 of tracepoint event generation. | |
1040 | * | |
1041 | * Tracepoint UML URI info. | |
1042 | */ | |
1043 | ||
7f2f82c3 | 1044 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
6ddc916d MD |
1045 | #include <lttng/ust-tracepoint-event-reset.h> |
1046 | ||
4ea4f80e MD |
1047 | /* |
1048 | * Declare _model_emf_uri___##__provider##___##__name as non-static, | |
1049 | * with hidden visibility for c++ handling of weakref. We do a weakref | |
1050 | * to the symbol in a later stage, which requires that the symbol is not | |
1051 | * mangled. | |
1052 | */ | |
1053 | #ifdef __cplusplus | |
fc6d7bef | 1054 | #define LTTNG_UST_TP_EXTERN_C extern "C" |
4ea4f80e | 1055 | #else |
fc6d7bef | 1056 | #define LTTNG_UST_TP_EXTERN_C |
4ea4f80e MD |
1057 | #endif |
1058 | ||
dbcc2f92 MJ |
1059 | #undef LTTNG_UST_TRACEPOINT_MODEL_EMF_URI |
1060 | #define LTTNG_UST_TRACEPOINT_MODEL_EMF_URI(__provider, __name, __uri) \ | |
3d33ca1d | 1061 | LTTNG_UST_TP_EXTERN_C const char * const _model_emf_uri___##__provider##___##__name \ |
082802f9 | 1062 | __attribute__((visibility("hidden"))) = __uri; \ |
6ddc916d | 1063 | |
bb71a8ea | 1064 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
6ddc916d | 1065 | |
fc6d7bef | 1066 | #undef LTTNG_UST_TP_EXTERN_C |
4ea4f80e | 1067 | |
5b4c6da4 MD |
1068 | /* |
1069 | * Stage 7.0 of tracepoint event generation. | |
1070 | * | |
1071 | * Declare toplevel descriptor for the whole probe. | |
1072 | * Unlike C, C++ does not allow tentative definitions. Therefore, we | |
1073 | * need to explicitly declare the variable with "extern", using hidden | |
1074 | * visibility to keep this symbol from being exported to the global | |
1075 | * symbol table. | |
1076 | */ | |
1077 | ||
c9201081 | 1078 | extern const struct lttng_ust_probe_desc LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_desc___, LTTNG_UST_TRACEPOINT_PROVIDER) |
5b4c6da4 MD |
1079 | __attribute__((visibility("hidden"))); |
1080 | ||
df854e41 | 1081 | /* |
882a56d7 | 1082 | * Stage 7.1 of tracepoint event generation. |
df854e41 MD |
1083 | * |
1084 | * Create events description structures. We use a weakref because | |
3d33ca1d | 1085 | * loglevels are optional. If not declared, the event will point to |
df854e41 | 1086 | * a loglevel that contains NULL. |
3d33ca1d MD |
1087 | * |
1088 | * C++ requires that const objects have a user-declared default | |
1089 | * constructor. However, in both C++ and C, weakref cannot be | |
1090 | * initialized because it causes the weakref attribute to be ignored. | |
1091 | * Therefore, the loglevel and model_emf_uri pointers are not const | |
1092 | * to ensure C++ compilers default-initialize them. | |
df854e41 MD |
1093 | */ |
1094 | ||
7f2f82c3 | 1095 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
df854e41 MD |
1096 | #include <lttng/ust-tracepoint-event-reset.h> |
1097 | ||
7f2f82c3 MJ |
1098 | #undef LTTNG_UST__TRACEPOINT_EVENT_INSTANCE |
1099 | #define LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \ | |
882a56d7 MD |
1100 | static const int * \ |
1101 | __ref_loglevel___##_provider##___##_name \ | |
1102 | __attribute__((weakref ("_loglevel___" #_provider "___" #_name))); \ | |
6ddc916d MD |
1103 | static const char * \ |
1104 | __ref_model_emf_uri___##_provider##___##_name \ | |
1105 | __attribute__((weakref ("_model_emf_uri___" #_provider "___" #_name)));\ | |
bfcc2759 | 1106 | static const struct lttng_ust_event_desc lttng_ust__event_desc___##_provider##_##_name = { \ |
dc11f93f | 1107 | .struct_size = sizeof(struct lttng_ust_event_desc), \ |
5b4c6da4 | 1108 | .event_name = #_name, \ |
c9201081 | 1109 | .probe_desc = <tng_ust__probe_desc___##_provider, \ |
bfcc2759 MJ |
1110 | .probe_callback = (void (*)(void)) <tng_ust__event_probe__##_provider##___##_template, \ |
1111 | .fields = lttng_ust__event_fields___##_provider##___##_template, \ | |
1112 | .nr_fields = LTTNG_UST__TP_ARRAY_SIZE(lttng_ust__event_fields___##_provider##___##_template) - 1, \ | |
882a56d7 | 1113 | .loglevel = &__ref_loglevel___##_provider##___##_name, \ |
68755429 | 1114 | .signature = __tp_event_signature___##_provider##___##_template, \ |
dc11f93f | 1115 | .model_emf_uri = &__ref_model_emf_uri___##_provider##___##_name, \ |
df854e41 MD |
1116 | }; |
1117 | ||
bb71a8ea | 1118 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
05ceaafd | 1119 | |
df854e41 | 1120 | /* |
882a56d7 | 1121 | * Stage 7.2 of tracepoint event generation. |
df854e41 MD |
1122 | * |
1123 | * Create array of events. | |
1124 | */ | |
1125 | ||
7f2f82c3 | 1126 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
df854e41 MD |
1127 | #include <lttng/ust-tracepoint-event-reset.h> |
1128 | ||
7f2f82c3 MJ |
1129 | #undef LTTNG_UST__TRACEPOINT_EVENT_INSTANCE |
1130 | #define LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \ | |
bfcc2759 | 1131 | <tng_ust__event_desc___##_provider##_##_name, |
df854e41 | 1132 | |
bfcc2759 | 1133 | static const struct lttng_ust_event_desc * const LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__event_desc___, LTTNG_UST_TRACEPOINT_PROVIDER)[] = { |
bb71a8ea | 1134 | #include LTTNG_UST_TRACEPOINT_INCLUDE |
1c80c909 | 1135 | NULL, /* Dummy, C99 forbids 0-len array. */ |
05ceaafd MD |
1136 | }; |
1137 | ||
df854e41 | 1138 | |
05ceaafd | 1139 | /* |
882a56d7 | 1140 | * Stage 8 of tracepoint event generation. |
05ceaafd MD |
1141 | * |
1142 | * Create a toplevel descriptor for the whole probe. | |
1143 | */ | |
1144 | ||
c9201081 | 1145 | const struct lttng_ust_probe_desc LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_desc___, LTTNG_UST_TRACEPOINT_PROVIDER) = { |
dc11f93f | 1146 | .struct_size = sizeof(struct lttng_ust_probe_desc), |
061fc37a | 1147 | .provider_name = lttng_ust__tp_stringify(LTTNG_UST_TRACEPOINT_PROVIDER), |
bfcc2759 MJ |
1148 | .event_desc = LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__event_desc___, LTTNG_UST_TRACEPOINT_PROVIDER), |
1149 | .nr_events = LTTNG_UST__TP_ARRAY_SIZE(LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__event_desc___, LTTNG_UST_TRACEPOINT_PROVIDER)) - 1, | |
71d31690 MD |
1150 | .major = LTTNG_UST_PROVIDER_MAJOR, |
1151 | .minor = LTTNG_UST_PROVIDER_MINOR, | |
05ceaafd MD |
1152 | }; |
1153 | ||
03221919 | 1154 | static int LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_refcount___, LTTNG_UST_TRACEPOINT_PROVIDER); |
f082dde9 | 1155 | static struct lttng_ust_registered_probe *LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___, LTTNG_UST_TRACEPOINT_PROVIDER); |
f0cc794d | 1156 | |
05ceaafd | 1157 | /* |
882a56d7 | 1158 | * Stage 9 of tracepoint event generation. |
05ceaafd | 1159 | * |
1c324e59 | 1160 | * Register/unregister probes at module load/unload. |
628e1d81 MD |
1161 | * |
1162 | * Generate the constructor as an externally visible symbol for use when | |
1163 | * linking the probe statically. | |
f0cc794d MD |
1164 | * |
1165 | * Register refcount is protected by libc dynamic loader mutex. | |
1c324e59 MD |
1166 | */ |
1167 | ||
7f2f82c3 | 1168 | /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ |
1c324e59 | 1169 | #include <lttng/ust-tracepoint-event-reset.h> |
465a0d04 | 1170 | static void |
11bce056 | 1171 | LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_init__, LTTNG_UST_TRACEPOINT_PROVIDER)(void) |
465a0d04 | 1172 | lttng_ust_notrace __attribute__((constructor)); |
a8909ba5 | 1173 | static void |
11bce056 | 1174 | LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_init__, LTTNG_UST_TRACEPOINT_PROVIDER)(void) |
1c324e59 | 1175 | { |
4e48b5d2 | 1176 | struct lttng_ust_registered_probe *reg_probe; |
1c324e59 | 1177 | |
03221919 | 1178 | if (LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_refcount___, |
5b393d64 | 1179 | LTTNG_UST_TRACEPOINT_PROVIDER)++) { |
f0cc794d MD |
1180 | return; |
1181 | } | |
e8bd1da7 | 1182 | /* |
5b393d64 | 1183 | * lttng_ust_tracepoint_provider_check_ ## LTTNG_UST_TRACEPOINT_PROVIDER() is a |
e8bd1da7 MD |
1184 | * static inline function that ensures every probe PROVIDER |
1185 | * argument match the provider within which they appear. It | |
1186 | * calls empty static inline functions, and therefore has no | |
1187 | * runtime effect. However, if it detects an error, a linker | |
1188 | * error will appear. | |
1189 | */ | |
5b393d64 | 1190 | LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_check_, LTTNG_UST_TRACEPOINT_PROVIDER)(); |
f082dde9 | 1191 | assert(!LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___, LTTNG_UST_TRACEPOINT_PROVIDER)); |
c9201081 | 1192 | reg_probe = lttng_ust_probe_register(<TNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_desc___, LTTNG_UST_TRACEPOINT_PROVIDER)); |
4e48b5d2 MD |
1193 | if (!reg_probe) { |
1194 | fprintf(stderr, "LTTng-UST: Error while registering tracepoint probe.\n"); | |
7d381d6e MD |
1195 | abort(); |
1196 | } | |
f082dde9 | 1197 | LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___, LTTNG_UST_TRACEPOINT_PROVIDER) = reg_probe; |
1c324e59 MD |
1198 | } |
1199 | ||
c589eca2 | 1200 | static void |
638ce920 | 1201 | LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_exit__, LTTNG_UST_TRACEPOINT_PROVIDER)(void) |
c589eca2 | 1202 | lttng_ust_notrace __attribute__((destructor)); |
a8909ba5 | 1203 | static void |
638ce920 | 1204 | LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_exit__, LTTNG_UST_TRACEPOINT_PROVIDER)(void) |
1c324e59 | 1205 | { |
03221919 | 1206 | if (--LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_refcount___, |
5b393d64 | 1207 | LTTNG_UST_TRACEPOINT_PROVIDER)) { |
f0cc794d MD |
1208 | return; |
1209 | } | |
f082dde9 MJ |
1210 | lttng_ust_probe_unregister(LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___, LTTNG_UST_TRACEPOINT_PROVIDER)); |
1211 | LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___, LTTNG_UST_TRACEPOINT_PROVIDER) = NULL; | |
1c324e59 | 1212 | } |
628e1d81 | 1213 | |
5b393d64 | 1214 | int LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_, LTTNG_UST_TRACEPOINT_PROVIDER) |
1d18d519 | 1215 | __attribute__((visibility("default"))); |