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