| 1 | /* |
| 2 | * lttng-tracepoint-event-impl.h |
| 3 | * |
| 4 | * Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org> |
| 5 | * Copyright (C) 2009-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; only |
| 10 | * version 2.1 of the License. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #include <linux/uaccess.h> |
| 23 | #include <linux/debugfs.h> |
| 24 | #include <linux/rculist.h> |
| 25 | #include <asm/byteorder.h> |
| 26 | #include <linux/swab.h> |
| 27 | |
| 28 | #include <probes/lttng.h> |
| 29 | #include <probes/lttng-types.h> |
| 30 | #include <probes/lttng-probe-user.h> |
| 31 | #include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */ |
| 32 | #include <wrapper/ringbuffer/frontend_types.h> |
| 33 | #include <wrapper/ringbuffer/backend.h> |
| 34 | #include <wrapper/rcu.h> |
| 35 | #include <lttng-events.h> |
| 36 | #include <lttng-tracer-core.h> |
| 37 | |
| 38 | #define __LTTNG_NULL_STRING "(null)" |
| 39 | |
| 40 | /* |
| 41 | * Macro declarations used for all stages. |
| 42 | */ |
| 43 | |
| 44 | /* |
| 45 | * LTTng name mapping macros. LTTng remaps some of the kernel events to |
| 46 | * enforce name-spacing. |
| 47 | */ |
| 48 | #undef LTTNG_TRACEPOINT_EVENT_MAP |
| 49 | #define LTTNG_TRACEPOINT_EVENT_MAP(name, map, proto, args, fields) \ |
| 50 | LTTNG_TRACEPOINT_EVENT_CLASS(map, \ |
| 51 | PARAMS(proto), \ |
| 52 | PARAMS(args), \ |
| 53 | PARAMS(fields)) \ |
| 54 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args)) |
| 55 | |
| 56 | #undef LTTNG_TRACEPOINT_EVENT_MAP_NOARGS |
| 57 | #define LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, map, fields) \ |
| 58 | LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(map, \ |
| 59 | PARAMS(fields)) \ |
| 60 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(map, name, map) |
| 61 | |
| 62 | #undef LTTNG_TRACEPOINT_EVENT_CODE_MAP |
| 63 | #define LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, map, proto, args, _locvar, _code_pre, fields, _code_post) \ |
| 64 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE(map, \ |
| 65 | PARAMS(proto), \ |
| 66 | PARAMS(args), \ |
| 67 | PARAMS(_locvar), \ |
| 68 | PARAMS(_code_pre), \ |
| 69 | PARAMS(fields), \ |
| 70 | PARAMS(_code_post)) \ |
| 71 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(map, name, map, PARAMS(proto), PARAMS(args)) |
| 72 | |
| 73 | #undef LTTNG_TRACEPOINT_EVENT_CODE |
| 74 | #define LTTNG_TRACEPOINT_EVENT_CODE(name, proto, args, _locvar, _code_pre, fields, _code_post) \ |
| 75 | LTTNG_TRACEPOINT_EVENT_CODE_MAP(name, name, \ |
| 76 | PARAMS(proto), \ |
| 77 | PARAMS(args), \ |
| 78 | PARAMS(_locvar), \ |
| 79 | PARAMS(_code_pre), \ |
| 80 | PARAMS(fields), \ |
| 81 | PARAMS(_code_post)) |
| 82 | |
| 83 | /* |
| 84 | * LTTNG_TRACEPOINT_EVENT_CLASS can be used to add a generic function |
| 85 | * handlers for events. That is, if all events have the same parameters |
| 86 | * and just have distinct trace points. Each tracepoint can be defined |
| 87 | * with LTTNG_TRACEPOINT_EVENT_INSTANCE and that will map the |
| 88 | * LTTNG_TRACEPOINT_EVENT_CLASS to the tracepoint. |
| 89 | * |
| 90 | * LTTNG_TRACEPOINT_EVENT is a one to one mapping between tracepoint and |
| 91 | * template. |
| 92 | */ |
| 93 | |
| 94 | #undef LTTNG_TRACEPOINT_EVENT |
| 95 | #define LTTNG_TRACEPOINT_EVENT(name, proto, args, fields) \ |
| 96 | LTTNG_TRACEPOINT_EVENT_MAP(name, name, \ |
| 97 | PARAMS(proto), \ |
| 98 | PARAMS(args), \ |
| 99 | PARAMS(fields)) |
| 100 | |
| 101 | #undef LTTNG_TRACEPOINT_EVENT_NOARGS |
| 102 | #define LTTNG_TRACEPOINT_EVENT_NOARGS(name, fields) \ |
| 103 | LTTNG_TRACEPOINT_EVENT_MAP_NOARGS(name, name, PARAMS(fields)) |
| 104 | |
| 105 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE |
| 106 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \ |
| 107 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(template, name, name, PARAMS(proto), PARAMS(args)) |
| 108 | |
| 109 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS |
| 110 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \ |
| 111 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(template, name, name) |
| 112 | |
| 113 | #undef LTTNG_TRACEPOINT_EVENT_CLASS |
| 114 | #define LTTNG_TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ |
| 115 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, PARAMS(_proto), PARAMS(_args), , , \ |
| 116 | PARAMS(_fields), ) |
| 117 | |
| 118 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS |
| 119 | #define LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \ |
| 120 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, , , PARAMS(_fields), ) |
| 121 | |
| 122 | |
| 123 | /* |
| 124 | * Stage 1 of the trace events. |
| 125 | * |
| 126 | * Create dummy trace calls for each events, verifying that the LTTng module |
| 127 | * instrumentation headers match the kernel arguments. Will be optimized |
| 128 | * out by the compiler. |
| 129 | */ |
| 130 | |
| 131 | /* Reset all macros within TRACEPOINT_EVENT */ |
| 132 | #include <probes/lttng-events-reset.h> |
| 133 | |
| 134 | #undef TP_PROTO |
| 135 | #define TP_PROTO(...) __VA_ARGS__ |
| 136 | |
| 137 | #undef TP_ARGS |
| 138 | #define TP_ARGS(...) __VA_ARGS__ |
| 139 | |
| 140 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP |
| 141 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \ |
| 142 | void trace_##_name(_proto); |
| 143 | |
| 144 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS |
| 145 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \ |
| 146 | void trace_##_name(void); |
| 147 | |
| 148 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 149 | |
| 150 | /* |
| 151 | * Stage 1.1 of the trace events. |
| 152 | * |
| 153 | * Create dummy trace prototypes for each event class, and for each used |
| 154 | * template. This will allow checking whether the prototypes from the |
| 155 | * class and the instance using the class actually match. |
| 156 | */ |
| 157 | |
| 158 | #include <probes/lttng-events-reset.h> /* Reset all macros within TRACE_EVENT */ |
| 159 | |
| 160 | #undef TP_PROTO |
| 161 | #define TP_PROTO(...) __VA_ARGS__ |
| 162 | |
| 163 | #undef TP_ARGS |
| 164 | #define TP_ARGS(...) __VA_ARGS__ |
| 165 | |
| 166 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP |
| 167 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \ |
| 168 | void __event_template_proto___##_template(_proto); |
| 169 | |
| 170 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS |
| 171 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \ |
| 172 | void __event_template_proto___##_template(void); |
| 173 | |
| 174 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
| 175 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
| 176 | void __event_template_proto___##_name(_proto); |
| 177 | |
| 178 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
| 179 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
| 180 | void __event_template_proto___##_name(void); |
| 181 | |
| 182 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 183 | |
| 184 | /* |
| 185 | * Stage 1.2 of tracepoint event generation |
| 186 | * |
| 187 | * Unfolding the enums |
| 188 | */ |
| 189 | #include <probes/lttng-events-reset.h> /* Reset all macros within TRACE_EVENT */ |
| 190 | |
| 191 | /* Enumeration entry (single value) */ |
| 192 | #undef ctf_enum_value |
| 193 | #define ctf_enum_value(_string, _value) \ |
| 194 | { \ |
| 195 | .start = { \ |
| 196 | .signedness = lttng_is_signed_type(__typeof__(_value)), \ |
| 197 | .value = lttng_is_signed_type(__typeof__(_value)) ? \ |
| 198 | (long long) (_value) : (_value), \ |
| 199 | }, \ |
| 200 | .end = { \ |
| 201 | .signedness = lttng_is_signed_type(__typeof__(_value)), \ |
| 202 | .value = lttng_is_signed_type(__typeof__(_value)) ? \ |
| 203 | (long long) (_value) : (_value), \ |
| 204 | }, \ |
| 205 | .string = (_string), \ |
| 206 | }, |
| 207 | |
| 208 | /* Enumeration entry (range) */ |
| 209 | #undef ctf_enum_range |
| 210 | #define ctf_enum_range(_string, _range_start, _range_end) \ |
| 211 | { \ |
| 212 | .start = { \ |
| 213 | .signedness = lttng_is_signed_type(__typeof__(_range_start)), \ |
| 214 | .value = lttng_is_signed_type(__typeof__(_range_start)) ? \ |
| 215 | (long long) (_range_start) : (_range_start), \ |
| 216 | }, \ |
| 217 | .end = { \ |
| 218 | .signedness = lttng_is_signed_type(__typeof__(_range_end)), \ |
| 219 | .value = lttng_is_signed_type(__typeof__(_range_end)) ? \ |
| 220 | (long long) (_range_end) : (_range_end), \ |
| 221 | }, \ |
| 222 | .string = (_string), \ |
| 223 | }, |
| 224 | |
| 225 | /* Enumeration entry (automatic value; follows the rules of CTF) */ |
| 226 | #undef ctf_enum_auto |
| 227 | #define ctf_enum_auto(_string) \ |
| 228 | { \ |
| 229 | .start = { \ |
| 230 | .signedness = -1, \ |
| 231 | .value = -1, \ |
| 232 | }, \ |
| 233 | .end = { \ |
| 234 | .signedness = -1, \ |
| 235 | .value = -1, \ |
| 236 | }, \ |
| 237 | .string = (_string), \ |
| 238 | .options = { \ |
| 239 | .is_auto = 1, \ |
| 240 | } \ |
| 241 | }, |
| 242 | |
| 243 | #undef TP_ENUM_VALUES |
| 244 | #define TP_ENUM_VALUES(...) \ |
| 245 | __VA_ARGS__ |
| 246 | |
| 247 | #undef LTTNG_TRACEPOINT_ENUM |
| 248 | #define LTTNG_TRACEPOINT_ENUM(_name, _values) \ |
| 249 | const struct lttng_enum_entry __enum_values__##_name[] = { \ |
| 250 | _values \ |
| 251 | }; |
| 252 | |
| 253 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 254 | |
| 255 | /* |
| 256 | * Stage 2 of the trace events. |
| 257 | * |
| 258 | * Create event field type metadata section. |
| 259 | * Each event produce an array of fields. |
| 260 | */ |
| 261 | |
| 262 | /* Reset all macros within TRACEPOINT_EVENT */ |
| 263 | #include <probes/lttng-events-reset.h> |
| 264 | #include <probes/lttng-events-write.h> |
| 265 | #include <probes/lttng-events-nowrite.h> |
| 266 | |
| 267 | #undef _ctf_integer_ext |
| 268 | #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \ |
| 269 | { \ |
| 270 | .name = #_item, \ |
| 271 | .type = __type_integer(_type, 0, 0, -1, _byte_order, _base, none),\ |
| 272 | .nowrite = _nowrite, \ |
| 273 | .user = _user, \ |
| 274 | }, |
| 275 | |
| 276 | #undef _ctf_array_encoded |
| 277 | #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \ |
| 278 | { \ |
| 279 | .name = #_item, \ |
| 280 | .type = \ |
| 281 | { \ |
| 282 | .atype = atype_array, \ |
| 283 | .u = \ |
| 284 | { \ |
| 285 | .array = \ |
| 286 | { \ |
| 287 | .elem_type = __type_integer(_type, 0, 0, 0, __BYTE_ORDER, 10, _encoding), \ |
| 288 | .length = _length, \ |
| 289 | } \ |
| 290 | } \ |
| 291 | }, \ |
| 292 | .nowrite = _nowrite, \ |
| 293 | .user = _user, \ |
| 294 | }, |
| 295 | |
| 296 | #undef _ctf_array_bitfield |
| 297 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ |
| 298 | { \ |
| 299 | .name = #_item, \ |
| 300 | .type = \ |
| 301 | { \ |
| 302 | .atype = atype_array, \ |
| 303 | .u = \ |
| 304 | { \ |
| 305 | .array = \ |
| 306 | { \ |
| 307 | .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \ |
| 308 | .length = (_length) * sizeof(_type) * CHAR_BIT, \ |
| 309 | .elem_alignment = lttng_alignof(_type), \ |
| 310 | } \ |
| 311 | } \ |
| 312 | }, \ |
| 313 | .nowrite = _nowrite, \ |
| 314 | .user = _user, \ |
| 315 | }, |
| 316 | |
| 317 | |
| 318 | #undef _ctf_sequence_encoded |
| 319 | #define _ctf_sequence_encoded(_type, _item, _src, \ |
| 320 | _length_type, _src_length, _encoding, \ |
| 321 | _byte_order, _base, _user, _nowrite) \ |
| 322 | { \ |
| 323 | .name = #_item, \ |
| 324 | .type = \ |
| 325 | { \ |
| 326 | .atype = atype_sequence, \ |
| 327 | .u = \ |
| 328 | { \ |
| 329 | .sequence = \ |
| 330 | { \ |
| 331 | .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \ |
| 332 | .elem_type = __type_integer(_type, 0, 0, -1, _byte_order, _base, _encoding), \ |
| 333 | }, \ |
| 334 | }, \ |
| 335 | }, \ |
| 336 | .nowrite = _nowrite, \ |
| 337 | .user = _user, \ |
| 338 | }, |
| 339 | |
| 340 | #undef _ctf_sequence_bitfield |
| 341 | #define _ctf_sequence_bitfield(_type, _item, _src, \ |
| 342 | _length_type, _src_length, \ |
| 343 | _user, _nowrite) \ |
| 344 | { \ |
| 345 | .name = #_item, \ |
| 346 | .type = \ |
| 347 | { \ |
| 348 | .atype = atype_sequence, \ |
| 349 | .u = \ |
| 350 | { \ |
| 351 | .sequence = \ |
| 352 | { \ |
| 353 | .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \ |
| 354 | .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \ |
| 355 | .elem_alignment = lttng_alignof(_type), \ |
| 356 | }, \ |
| 357 | }, \ |
| 358 | }, \ |
| 359 | .nowrite = _nowrite, \ |
| 360 | .user = _user, \ |
| 361 | }, |
| 362 | |
| 363 | #undef _ctf_string |
| 364 | #define _ctf_string(_item, _src, _user, _nowrite) \ |
| 365 | { \ |
| 366 | .name = #_item, \ |
| 367 | .type = \ |
| 368 | { \ |
| 369 | .atype = atype_string, \ |
| 370 | .u = \ |
| 371 | { \ |
| 372 | .basic = { .string = { .encoding = lttng_encode_UTF8 } } \ |
| 373 | }, \ |
| 374 | }, \ |
| 375 | .nowrite = _nowrite, \ |
| 376 | .user = _user, \ |
| 377 | }, |
| 378 | |
| 379 | #undef _ctf_enum |
| 380 | #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \ |
| 381 | { \ |
| 382 | .name = #_item, \ |
| 383 | .type = { \ |
| 384 | .atype = atype_enum, \ |
| 385 | .u = { \ |
| 386 | .basic = { \ |
| 387 | .enumeration = { \ |
| 388 | .desc = &__enum_##_name, \ |
| 389 | .container_type = { \ |
| 390 | .size = sizeof(_type) * CHAR_BIT, \ |
| 391 | .alignment = lttng_alignof(_type) * CHAR_BIT, \ |
| 392 | .signedness = lttng_is_signed_type(_type), \ |
| 393 | .reverse_byte_order = 0, \ |
| 394 | .base = 10, \ |
| 395 | .encoding = lttng_encode_none, \ |
| 396 | }, \ |
| 397 | }, \ |
| 398 | }, \ |
| 399 | }, \ |
| 400 | }, \ |
| 401 | .nowrite = _nowrite, \ |
| 402 | .user = _user, \ |
| 403 | }, |
| 404 | |
| 405 | #undef ctf_custom_field |
| 406 | #define ctf_custom_field(_type, _item, _code) \ |
| 407 | { \ |
| 408 | .name = #_item, \ |
| 409 | .type = { _type }, \ |
| 410 | .nowrite = 0, \ |
| 411 | .user = 0, \ |
| 412 | }, |
| 413 | |
| 414 | #undef ctf_custom_type |
| 415 | #define ctf_custom_type(...) __VA_ARGS__ |
| 416 | |
| 417 | #undef TP_FIELDS |
| 418 | #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */ |
| 419 | |
| 420 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
| 421 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
| 422 | static const struct lttng_event_field __event_fields___##_name[] = { \ |
| 423 | _fields \ |
| 424 | }; |
| 425 | |
| 426 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
| 427 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
| 428 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, PARAMS(_fields), _code_post) |
| 429 | |
| 430 | #undef LTTNG_TRACEPOINT_ENUM |
| 431 | #define LTTNG_TRACEPOINT_ENUM(_name, _values) \ |
| 432 | static const struct lttng_enum_desc __enum_##_name = { \ |
| 433 | .name = #_name, \ |
| 434 | .entries = __enum_values__##_name, \ |
| 435 | .nr_entries = ARRAY_SIZE(__enum_values__##_name), \ |
| 436 | }; |
| 437 | |
| 438 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 439 | |
| 440 | /* |
| 441 | * Stage 3 of the trace events. |
| 442 | * |
| 443 | * Create probe callback prototypes. |
| 444 | */ |
| 445 | |
| 446 | /* Reset all macros within TRACEPOINT_EVENT */ |
| 447 | #include <probes/lttng-events-reset.h> |
| 448 | |
| 449 | #undef TP_PROTO |
| 450 | #define TP_PROTO(...) __VA_ARGS__ |
| 451 | |
| 452 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
| 453 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
| 454 | static void __event_probe__##_name(void *__data, _proto); |
| 455 | |
| 456 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
| 457 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
| 458 | static void __event_probe__##_name(void *__data); |
| 459 | |
| 460 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 461 | |
| 462 | /* |
| 463 | * Stage 4 of the trace events. |
| 464 | * |
| 465 | * Create static inline function that calculates event size. |
| 466 | */ |
| 467 | |
| 468 | /* Reset all macros within TRACEPOINT_EVENT */ |
| 469 | #include <probes/lttng-events-reset.h> |
| 470 | #include <probes/lttng-events-write.h> |
| 471 | |
| 472 | #undef _ctf_integer_ext |
| 473 | #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \ |
| 474 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
| 475 | __event_len += sizeof(_type); |
| 476 | |
| 477 | #undef _ctf_array_encoded |
| 478 | #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \ |
| 479 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
| 480 | __event_len += sizeof(_type) * (_length); |
| 481 | |
| 482 | #undef _ctf_array_bitfield |
| 483 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ |
| 484 | _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite) |
| 485 | |
| 486 | #undef _ctf_sequence_encoded |
| 487 | #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ |
| 488 | _src_length, _encoding, _byte_order, _base, _user, _nowrite) \ |
| 489 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \ |
| 490 | __event_len += sizeof(_length_type); \ |
| 491 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
| 492 | { \ |
| 493 | size_t __seqlen = (_src_length); \ |
| 494 | \ |
| 495 | if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \ |
| 496 | goto error; \ |
| 497 | barrier(); /* reserve before use. */ \ |
| 498 | this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = __seqlen; \ |
| 499 | __event_len += sizeof(_type) * __seqlen; \ |
| 500 | } |
| 501 | |
| 502 | #undef _ctf_sequence_bitfield |
| 503 | #define _ctf_sequence_bitfield(_type, _item, _src, \ |
| 504 | _length_type, _src_length, \ |
| 505 | _user, _nowrite) \ |
| 506 | _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \ |
| 507 | none, __LITTLE_ENDIAN, 10, _user, _nowrite) |
| 508 | |
| 509 | /* |
| 510 | * ctf_user_string includes \0. If returns 0, it faulted, so we set size to |
| 511 | * 1 (\0 only). |
| 512 | */ |
| 513 | #undef _ctf_string |
| 514 | #define _ctf_string(_item, _src, _user, _nowrite) \ |
| 515 | if (unlikely(++this_cpu_ptr(<tng_dynamic_len_stack)->offset >= LTTNG_DYNAMIC_LEN_STACK_SIZE)) \ |
| 516 | goto error; \ |
| 517 | barrier(); /* reserve before use. */ \ |
| 518 | if (_user) { \ |
| 519 | __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \ |
| 520 | max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \ |
| 521 | } else { \ |
| 522 | __event_len += this_cpu_ptr(<tng_dynamic_len_stack)->stack[this_cpu_ptr(<tng_dynamic_len_stack)->offset - 1] = \ |
| 523 | strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1; \ |
| 524 | } |
| 525 | |
| 526 | #undef _ctf_enum |
| 527 | #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \ |
| 528 | _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite) |
| 529 | |
| 530 | #undef ctf_align |
| 531 | #define ctf_align(_type) \ |
| 532 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); |
| 533 | |
| 534 | #undef ctf_custom_field |
| 535 | #define ctf_custom_field(_type, _item, _code) \ |
| 536 | { \ |
| 537 | _code \ |
| 538 | } |
| 539 | |
| 540 | #undef ctf_custom_code |
| 541 | #define ctf_custom_code(...) __VA_ARGS__ |
| 542 | |
| 543 | #undef TP_PROTO |
| 544 | #define TP_PROTO(...) __VA_ARGS__ |
| 545 | |
| 546 | #undef TP_FIELDS |
| 547 | #define TP_FIELDS(...) __VA_ARGS__ |
| 548 | |
| 549 | #undef TP_locvar |
| 550 | #define TP_locvar(...) __VA_ARGS__ |
| 551 | |
| 552 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
| 553 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
| 554 | static inline ssize_t __event_get_size__##_name(void *__tp_locvar, _proto) \ |
| 555 | { \ |
| 556 | size_t __event_len = 0; \ |
| 557 | unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \ |
| 558 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
| 559 | \ |
| 560 | _fields \ |
| 561 | return __event_len; \ |
| 562 | \ |
| 563 | error: \ |
| 564 | __attribute__((unused)); \ |
| 565 | return -1; \ |
| 566 | } |
| 567 | |
| 568 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
| 569 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
| 570 | static inline ssize_t __event_get_size__##_name(void *__tp_locvar) \ |
| 571 | { \ |
| 572 | size_t __event_len = 0; \ |
| 573 | unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \ |
| 574 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
| 575 | \ |
| 576 | _fields \ |
| 577 | return __event_len; \ |
| 578 | \ |
| 579 | error: \ |
| 580 | __attribute__((unused)); \ |
| 581 | return -1; \ |
| 582 | } |
| 583 | |
| 584 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 585 | |
| 586 | |
| 587 | /* |
| 588 | * Stage 4.1 of tracepoint event generation. |
| 589 | * |
| 590 | * Create static inline function that layout the filter stack data. |
| 591 | * We make both write and nowrite data available to the filter. |
| 592 | */ |
| 593 | |
| 594 | /* Reset all macros within TRACEPOINT_EVENT */ |
| 595 | #include <probes/lttng-events-reset.h> |
| 596 | #include <probes/lttng-events-write.h> |
| 597 | #include <probes/lttng-events-nowrite.h> |
| 598 | |
| 599 | #undef _ctf_integer_ext_fetched |
| 600 | #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \ |
| 601 | if (lttng_is_signed_type(_type)) { \ |
| 602 | int64_t __ctf_tmp_int64; \ |
| 603 | switch (sizeof(_type)) { \ |
| 604 | case 1: \ |
| 605 | { \ |
| 606 | union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \ |
| 607 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ |
| 608 | break; \ |
| 609 | } \ |
| 610 | case 2: \ |
| 611 | { \ |
| 612 | union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \ |
| 613 | if (_byte_order != __BYTE_ORDER) \ |
| 614 | __swab16s(&__tmp.v); \ |
| 615 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ |
| 616 | break; \ |
| 617 | } \ |
| 618 | case 4: \ |
| 619 | { \ |
| 620 | union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \ |
| 621 | if (_byte_order != __BYTE_ORDER) \ |
| 622 | __swab32s(&__tmp.v); \ |
| 623 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ |
| 624 | break; \ |
| 625 | } \ |
| 626 | case 8: \ |
| 627 | { \ |
| 628 | union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \ |
| 629 | if (_byte_order != __BYTE_ORDER) \ |
| 630 | __swab64s(&__tmp.v); \ |
| 631 | __ctf_tmp_int64 = (int64_t) __tmp.v; \ |
| 632 | break; \ |
| 633 | } \ |
| 634 | default: \ |
| 635 | BUG_ON(1); \ |
| 636 | }; \ |
| 637 | memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \ |
| 638 | } else { \ |
| 639 | uint64_t __ctf_tmp_uint64; \ |
| 640 | switch (sizeof(_type)) { \ |
| 641 | case 1: \ |
| 642 | { \ |
| 643 | union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \ |
| 644 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ |
| 645 | break; \ |
| 646 | } \ |
| 647 | case 2: \ |
| 648 | { \ |
| 649 | union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \ |
| 650 | if (_byte_order != __BYTE_ORDER) \ |
| 651 | __swab16s(&__tmp.v); \ |
| 652 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ |
| 653 | break; \ |
| 654 | } \ |
| 655 | case 4: \ |
| 656 | { \ |
| 657 | union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \ |
| 658 | if (_byte_order != __BYTE_ORDER) \ |
| 659 | __swab32s(&__tmp.v); \ |
| 660 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ |
| 661 | break; \ |
| 662 | } \ |
| 663 | case 8: \ |
| 664 | { \ |
| 665 | union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \ |
| 666 | if (_byte_order != __BYTE_ORDER) \ |
| 667 | __swab64s(&__tmp.v); \ |
| 668 | __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ |
| 669 | break; \ |
| 670 | } \ |
| 671 | default: \ |
| 672 | BUG_ON(1); \ |
| 673 | }; \ |
| 674 | memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \ |
| 675 | } \ |
| 676 | __stack_data += sizeof(int64_t); |
| 677 | |
| 678 | #undef _ctf_integer_ext_isuser0 |
| 679 | #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \ |
| 680 | _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) |
| 681 | |
| 682 | #undef _ctf_integer_ext_isuser1 |
| 683 | #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \ |
| 684 | { \ |
| 685 | union { \ |
| 686 | char __array[sizeof(_user_src)]; \ |
| 687 | __typeof__(_user_src) __v; \ |
| 688 | } __tmp_fetch; \ |
| 689 | if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \ |
| 690 | &(_user_src), sizeof(_user_src))) \ |
| 691 | memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \ |
| 692 | _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \ |
| 693 | } |
| 694 | |
| 695 | #undef _ctf_integer_ext |
| 696 | #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \ |
| 697 | _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite) |
| 698 | |
| 699 | #undef _ctf_array_encoded |
| 700 | #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \ |
| 701 | { \ |
| 702 | unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \ |
| 703 | const void *__ctf_tmp_ptr = (_src); \ |
| 704 | memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \ |
| 705 | __stack_data += sizeof(unsigned long); \ |
| 706 | memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \ |
| 707 | __stack_data += sizeof(void *); \ |
| 708 | } |
| 709 | |
| 710 | #undef _ctf_array_bitfield |
| 711 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ |
| 712 | _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite) |
| 713 | |
| 714 | #undef _ctf_sequence_encoded |
| 715 | #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ |
| 716 | _src_length, _encoding, _byte_order, _base, _user, _nowrite) \ |
| 717 | { \ |
| 718 | unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \ |
| 719 | const void *__ctf_tmp_ptr = (_src); \ |
| 720 | memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \ |
| 721 | __stack_data += sizeof(unsigned long); \ |
| 722 | memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \ |
| 723 | __stack_data += sizeof(void *); \ |
| 724 | } |
| 725 | |
| 726 | #undef _ctf_sequence_bitfield |
| 727 | #define _ctf_sequence_bitfield(_type, _item, _src, \ |
| 728 | _length_type, _src_length, \ |
| 729 | _user, _nowrite) \ |
| 730 | _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \ |
| 731 | none, __LITTLE_ENDIAN, 10, _user, _nowrite) |
| 732 | |
| 733 | #undef _ctf_string |
| 734 | #define _ctf_string(_item, _src, _user, _nowrite) \ |
| 735 | { \ |
| 736 | const void *__ctf_tmp_ptr = \ |
| 737 | ((_src) ? (_src) : __LTTNG_NULL_STRING); \ |
| 738 | memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \ |
| 739 | __stack_data += sizeof(void *); \ |
| 740 | } |
| 741 | |
| 742 | #undef _ctf_enum |
| 743 | #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \ |
| 744 | _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite) |
| 745 | |
| 746 | #undef TP_PROTO |
| 747 | #define TP_PROTO(...) __VA_ARGS__ |
| 748 | |
| 749 | #undef TP_FIELDS |
| 750 | #define TP_FIELDS(...) __VA_ARGS__ |
| 751 | |
| 752 | #undef TP_locvar |
| 753 | #define TP_locvar(...) __VA_ARGS__ |
| 754 | |
| 755 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
| 756 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
| 757 | static inline \ |
| 758 | void __event_prepare_filter_stack__##_name(char *__stack_data, \ |
| 759 | void *__tp_locvar) \ |
| 760 | { \ |
| 761 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
| 762 | \ |
| 763 | _fields \ |
| 764 | } |
| 765 | |
| 766 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
| 767 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
| 768 | static inline \ |
| 769 | void __event_prepare_filter_stack__##_name(char *__stack_data, \ |
| 770 | void *__tp_locvar, _proto) \ |
| 771 | { \ |
| 772 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
| 773 | \ |
| 774 | _fields \ |
| 775 | } |
| 776 | |
| 777 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 778 | |
| 779 | /* |
| 780 | * Stage 5 of the trace events. |
| 781 | * |
| 782 | * Create static inline function that calculates event payload alignment. |
| 783 | */ |
| 784 | |
| 785 | /* Reset all macros within TRACEPOINT_EVENT */ |
| 786 | #include <probes/lttng-events-reset.h> |
| 787 | #include <probes/lttng-events-write.h> |
| 788 | |
| 789 | #undef _ctf_integer_ext |
| 790 | #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \ |
| 791 | __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); |
| 792 | |
| 793 | #undef _ctf_array_encoded |
| 794 | #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \ |
| 795 | __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); |
| 796 | |
| 797 | #undef _ctf_array_bitfield |
| 798 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ |
| 799 | _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite) |
| 800 | |
| 801 | #undef _ctf_sequence_encoded |
| 802 | #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ |
| 803 | _src_length, _encoding, _byte_order, _base, _user, _nowrite) \ |
| 804 | __event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \ |
| 805 | __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); |
| 806 | |
| 807 | #undef _ctf_sequence_bitfield |
| 808 | #define _ctf_sequence_bitfield(_type, _item, _src, \ |
| 809 | _length_type, _src_length, \ |
| 810 | _user, _nowrite) \ |
| 811 | _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \ |
| 812 | none, __LITTLE_ENDIAN, 10, _user, _nowrite) |
| 813 | |
| 814 | #undef _ctf_string |
| 815 | #define _ctf_string(_item, _src, _user, _nowrite) |
| 816 | |
| 817 | #undef _ctf_enum |
| 818 | #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \ |
| 819 | _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite) |
| 820 | |
| 821 | #undef ctf_align |
| 822 | #define ctf_align(_type) \ |
| 823 | __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); |
| 824 | |
| 825 | #undef TP_PROTO |
| 826 | #define TP_PROTO(...) __VA_ARGS__ |
| 827 | |
| 828 | #undef TP_FIELDS |
| 829 | #define TP_FIELDS(...) __VA_ARGS__ |
| 830 | |
| 831 | #undef TP_locvar |
| 832 | #define TP_locvar(...) __VA_ARGS__ |
| 833 | |
| 834 | #undef ctf_custom_field |
| 835 | #define ctf_custom_field(_type, _item, _code) _code |
| 836 | |
| 837 | #undef ctf_custom_code |
| 838 | #define ctf_custom_code(...) \ |
| 839 | { \ |
| 840 | __VA_ARGS__ \ |
| 841 | } |
| 842 | |
| 843 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
| 844 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
| 845 | static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \ |
| 846 | { \ |
| 847 | size_t __event_align = 1; \ |
| 848 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
| 849 | \ |
| 850 | _fields \ |
| 851 | return __event_align; \ |
| 852 | } |
| 853 | |
| 854 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
| 855 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
| 856 | static inline size_t __event_get_align__##_name(void *__tp_locvar) \ |
| 857 | { \ |
| 858 | size_t __event_align = 1; \ |
| 859 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
| 860 | \ |
| 861 | _fields \ |
| 862 | return __event_align; \ |
| 863 | } |
| 864 | |
| 865 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 866 | |
| 867 | /* |
| 868 | * Stage 6 of tracepoint event generation. |
| 869 | * |
| 870 | * Create the probe function. This function calls event size calculation |
| 871 | * and writes event data into the buffer. |
| 872 | */ |
| 873 | |
| 874 | /* Reset all macros within TRACEPOINT_EVENT */ |
| 875 | #include <probes/lttng-events-reset.h> |
| 876 | #include <probes/lttng-events-write.h> |
| 877 | |
| 878 | #undef _ctf_integer_ext_fetched |
| 879 | #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \ |
| 880 | { \ |
| 881 | _type __tmp = _src; \ |
| 882 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\ |
| 883 | __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\ |
| 884 | } |
| 885 | |
| 886 | #undef _ctf_integer_ext_isuser0 |
| 887 | #define _ctf_integer_ext_isuser0(_type, _item, _src, _byte_order, _base, _nowrite) \ |
| 888 | _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) |
| 889 | |
| 890 | #undef _ctf_integer_ext_isuser1 |
| 891 | #define _ctf_integer_ext_isuser1(_type, _item, _user_src, _byte_order, _base, _nowrite) \ |
| 892 | { \ |
| 893 | union { \ |
| 894 | char __array[sizeof(_user_src)]; \ |
| 895 | __typeof__(_user_src) __v; \ |
| 896 | } __tmp_fetch; \ |
| 897 | if (lib_ring_buffer_copy_from_user_check_nofault(__tmp_fetch.__array, \ |
| 898 | &(_user_src), sizeof(_user_src))) \ |
| 899 | memset(__tmp_fetch.__array, 0, sizeof(__tmp_fetch.__array)); \ |
| 900 | _ctf_integer_ext_fetched(_type, _item, __tmp_fetch.__v, _byte_order, _base, _nowrite) \ |
| 901 | } |
| 902 | |
| 903 | #undef _ctf_integer_ext |
| 904 | #define _ctf_integer_ext(_type, _item, _user_src, _byte_order, _base, _user, _nowrite) \ |
| 905 | _ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite) |
| 906 | |
| 907 | #undef _ctf_array_encoded |
| 908 | #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \ |
| 909 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ |
| 910 | if (_user) { \ |
| 911 | __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \ |
| 912 | } else { \ |
| 913 | __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \ |
| 914 | } |
| 915 | |
| 916 | #if (__BYTE_ORDER == __LITTLE_ENDIAN) |
| 917 | #undef _ctf_array_bitfield |
| 918 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ |
| 919 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ |
| 920 | if (_user) { \ |
| 921 | __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \ |
| 922 | } else { \ |
| 923 | __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \ |
| 924 | } |
| 925 | #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ |
| 926 | /* |
| 927 | * For big endian, we need to byteswap into little endian. |
| 928 | */ |
| 929 | #undef _ctf_array_bitfield |
| 930 | #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \ |
| 931 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ |
| 932 | { \ |
| 933 | size_t _i; \ |
| 934 | \ |
| 935 | for (_i = 0; _i < (_length); _i++) { \ |
| 936 | _type _tmp; \ |
| 937 | \ |
| 938 | if (_user) { \ |
| 939 | if (get_user(_tmp, (_type *) _src + _i)) \ |
| 940 | _tmp = 0; \ |
| 941 | } else { \ |
| 942 | _tmp = ((_type *) _src)[_i]; \ |
| 943 | } \ |
| 944 | switch (sizeof(_type)) { \ |
| 945 | case 1: \ |
| 946 | break; \ |
| 947 | case 2: \ |
| 948 | _tmp = cpu_to_le16(_tmp); \ |
| 949 | break; \ |
| 950 | case 4: \ |
| 951 | _tmp = cpu_to_le32(_tmp); \ |
| 952 | break; \ |
| 953 | case 8: \ |
| 954 | _tmp = cpu_to_le64(_tmp); \ |
| 955 | break; \ |
| 956 | default: \ |
| 957 | BUG_ON(1); \ |
| 958 | } \ |
| 959 | __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \ |
| 960 | } \ |
| 961 | } |
| 962 | #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ |
| 963 | |
| 964 | #undef _ctf_sequence_encoded |
| 965 | #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ |
| 966 | _src_length, _encoding, _byte_order, _base, _user, _nowrite) \ |
| 967 | { \ |
| 968 | _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx]; \ |
| 969 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ |
| 970 | __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\ |
| 971 | } \ |
| 972 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ |
| 973 | if (_user) { \ |
| 974 | __chan->ops->event_write_from_user(&__ctx, _src, \ |
| 975 | sizeof(_type) * __get_dynamic_len(dest)); \ |
| 976 | } else { \ |
| 977 | __chan->ops->event_write(&__ctx, _src, \ |
| 978 | sizeof(_type) * __get_dynamic_len(dest)); \ |
| 979 | } |
| 980 | |
| 981 | #if (__BYTE_ORDER == __LITTLE_ENDIAN) |
| 982 | #undef _ctf_sequence_bitfield |
| 983 | #define _ctf_sequence_bitfield(_type, _item, _src, \ |
| 984 | _length_type, _src_length, \ |
| 985 | _user, _nowrite) \ |
| 986 | { \ |
| 987 | _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \ |
| 988 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ |
| 989 | __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\ |
| 990 | } \ |
| 991 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ |
| 992 | if (_user) { \ |
| 993 | __chan->ops->event_write_from_user(&__ctx, _src, \ |
| 994 | sizeof(_type) * __get_dynamic_len(dest)); \ |
| 995 | } else { \ |
| 996 | __chan->ops->event_write(&__ctx, _src, \ |
| 997 | sizeof(_type) * __get_dynamic_len(dest)); \ |
| 998 | } |
| 999 | #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ |
| 1000 | /* |
| 1001 | * For big endian, we need to byteswap into little endian. |
| 1002 | */ |
| 1003 | #undef _ctf_sequence_bitfield |
| 1004 | #define _ctf_sequence_bitfield(_type, _item, _src, \ |
| 1005 | _length_type, _src_length, \ |
| 1006 | _user, _nowrite) \ |
| 1007 | { \ |
| 1008 | _length_type __tmpl = this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \ |
| 1009 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ |
| 1010 | __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\ |
| 1011 | } \ |
| 1012 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ |
| 1013 | { \ |
| 1014 | size_t _i, _length; \ |
| 1015 | \ |
| 1016 | _length = __get_dynamic_len(dest); \ |
| 1017 | for (_i = 0; _i < _length; _i++) { \ |
| 1018 | _type _tmp; \ |
| 1019 | \ |
| 1020 | if (_user) { \ |
| 1021 | if (get_user(_tmp, (_type *) _src + _i)) \ |
| 1022 | _tmp = 0; \ |
| 1023 | } else { \ |
| 1024 | _tmp = ((_type *) _src)[_i]; \ |
| 1025 | } \ |
| 1026 | switch (sizeof(_type)) { \ |
| 1027 | case 1: \ |
| 1028 | break; \ |
| 1029 | case 2: \ |
| 1030 | _tmp = cpu_to_le16(_tmp); \ |
| 1031 | break; \ |
| 1032 | case 4: \ |
| 1033 | _tmp = cpu_to_le32(_tmp); \ |
| 1034 | break; \ |
| 1035 | case 8: \ |
| 1036 | _tmp = cpu_to_le64(_tmp); \ |
| 1037 | break; \ |
| 1038 | default: \ |
| 1039 | BUG_ON(1); \ |
| 1040 | } \ |
| 1041 | __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \ |
| 1042 | } \ |
| 1043 | } |
| 1044 | #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */ |
| 1045 | |
| 1046 | #undef _ctf_string |
| 1047 | #define _ctf_string(_item, _src, _user, _nowrite) \ |
| 1048 | if (_user) { \ |
| 1049 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \ |
| 1050 | __chan->ops->event_strcpy_from_user(&__ctx, _src, \ |
| 1051 | __get_dynamic_len(dest)); \ |
| 1052 | } else { \ |
| 1053 | const char *__ctf_tmp_string = \ |
| 1054 | ((_src) ? (_src) : __LTTNG_NULL_STRING); \ |
| 1055 | lib_ring_buffer_align_ctx(&__ctx, \ |
| 1056 | lttng_alignof(*__ctf_tmp_string)); \ |
| 1057 | __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \ |
| 1058 | __get_dynamic_len(dest)); \ |
| 1059 | } |
| 1060 | |
| 1061 | #undef _ctf_enum |
| 1062 | #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite) \ |
| 1063 | _ctf_integer_ext(_type, _item, _src, __BYTE_ORDER, 10, _user, _nowrite) |
| 1064 | |
| 1065 | #undef ctf_align |
| 1066 | #define ctf_align(_type) \ |
| 1067 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); |
| 1068 | |
| 1069 | #undef ctf_custom_field |
| 1070 | #define ctf_custom_field(_type, _item, _code) _code |
| 1071 | |
| 1072 | #undef ctf_custom_code |
| 1073 | #define ctf_custom_code(...) \ |
| 1074 | { \ |
| 1075 | __VA_ARGS__ \ |
| 1076 | } |
| 1077 | |
| 1078 | /* Beware: this get len actually consumes the len value */ |
| 1079 | #undef __get_dynamic_len |
| 1080 | #define __get_dynamic_len(field) this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx++] |
| 1081 | |
| 1082 | #undef TP_PROTO |
| 1083 | #define TP_PROTO(...) __VA_ARGS__ |
| 1084 | |
| 1085 | #undef TP_ARGS |
| 1086 | #define TP_ARGS(...) __VA_ARGS__ |
| 1087 | |
| 1088 | #undef TP_FIELDS |
| 1089 | #define TP_FIELDS(...) __VA_ARGS__ |
| 1090 | |
| 1091 | #undef TP_locvar |
| 1092 | #define TP_locvar(...) __VA_ARGS__ |
| 1093 | |
| 1094 | #undef TP_code_pre |
| 1095 | #define TP_code_pre(...) __VA_ARGS__ |
| 1096 | |
| 1097 | #undef TP_code_post |
| 1098 | #define TP_code_post(...) __VA_ARGS__ |
| 1099 | |
| 1100 | /* |
| 1101 | * For state dump, check that "session" argument (mandatory) matches the |
| 1102 | * session this event belongs to. Ensures that we write state dump data only |
| 1103 | * into the started session, not into all sessions. |
| 1104 | */ |
| 1105 | #ifdef TP_SESSION_CHECK |
| 1106 | #define _TP_SESSION_CHECK(session, csession) (session == csession) |
| 1107 | #else /* TP_SESSION_CHECK */ |
| 1108 | #define _TP_SESSION_CHECK(session, csession) 1 |
| 1109 | #endif /* TP_SESSION_CHECK */ |
| 1110 | |
| 1111 | /* |
| 1112 | * Using twice size for filter stack data to hold size and pointer for |
| 1113 | * each field (worse case). For integers, max size required is 64-bit. |
| 1114 | * Same for double-precision floats. Those fit within |
| 1115 | * 2*sizeof(unsigned long) for all supported architectures. |
| 1116 | * Perform UNION (||) of filter runtime list. |
| 1117 | */ |
| 1118 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE |
| 1119 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ |
| 1120 | static void __event_probe__##_name(void *__data, _proto) \ |
| 1121 | { \ |
| 1122 | struct probe_local_vars { _locvar }; \ |
| 1123 | struct lttng_event *__event = __data; \ |
| 1124 | struct lttng_probe_ctx __lttng_probe_ctx = { \ |
| 1125 | .event = __event, \ |
| 1126 | .interruptible = !irqs_disabled(), \ |
| 1127 | }; \ |
| 1128 | struct lttng_channel *__chan = __event->chan; \ |
| 1129 | struct lttng_session *__session = __chan->session; \ |
| 1130 | struct lib_ring_buffer_ctx __ctx; \ |
| 1131 | ssize_t __event_len; \ |
| 1132 | size_t __event_align; \ |
| 1133 | size_t __orig_dynamic_len_offset, __dynamic_len_idx; \ |
| 1134 | union { \ |
| 1135 | size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \ |
| 1136 | char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \ |
| 1137 | } __stackvar; \ |
| 1138 | int __ret; \ |
| 1139 | struct probe_local_vars __tp_locvar; \ |
| 1140 | struct probe_local_vars *tp_locvar __attribute__((unused)) = \ |
| 1141 | &__tp_locvar; \ |
| 1142 | struct lttng_pid_tracker *__lpf; \ |
| 1143 | \ |
| 1144 | if (!_TP_SESSION_CHECK(session, __session)) \ |
| 1145 | return; \ |
| 1146 | if (unlikely(!ACCESS_ONCE(__session->active))) \ |
| 1147 | return; \ |
| 1148 | if (unlikely(!ACCESS_ONCE(__chan->enabled))) \ |
| 1149 | return; \ |
| 1150 | if (unlikely(!ACCESS_ONCE(__event->enabled))) \ |
| 1151 | return; \ |
| 1152 | __lpf = lttng_rcu_dereference(__session->pid_tracker); \ |
| 1153 | if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->pid))) \ |
| 1154 | return; \ |
| 1155 | __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \ |
| 1156 | __dynamic_len_idx = __orig_dynamic_len_offset; \ |
| 1157 | _code_pre \ |
| 1158 | if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \ |
| 1159 | struct lttng_bytecode_runtime *bc_runtime; \ |
| 1160 | int __filter_record = __event->has_enablers_without_bytecode; \ |
| 1161 | \ |
| 1162 | __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \ |
| 1163 | tp_locvar, _args); \ |
| 1164 | lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \ |
| 1165 | if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \ |
| 1166 | __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \ |
| 1167 | __filter_record = 1; \ |
| 1168 | } \ |
| 1169 | if (likely(!__filter_record)) \ |
| 1170 | goto __post; \ |
| 1171 | } \ |
| 1172 | __event_len = __event_get_size__##_name(tp_locvar, _args); \ |
| 1173 | if (unlikely(__event_len < 0)) { \ |
| 1174 | lib_ring_buffer_lost_event_too_big(__chan->chan); \ |
| 1175 | goto __post; \ |
| 1176 | } \ |
| 1177 | __event_align = __event_get_align__##_name(tp_locvar, _args); \ |
| 1178 | lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \ |
| 1179 | __event_align, -1); \ |
| 1180 | __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ |
| 1181 | if (__ret < 0) \ |
| 1182 | goto __post; \ |
| 1183 | _fields \ |
| 1184 | __chan->ops->event_commit(&__ctx); \ |
| 1185 | __post: \ |
| 1186 | _code_post \ |
| 1187 | barrier(); /* use before un-reserve. */ \ |
| 1188 | this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \ |
| 1189 | return; \ |
| 1190 | } |
| 1191 | |
| 1192 | #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS |
| 1193 | #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \ |
| 1194 | static void __event_probe__##_name(void *__data) \ |
| 1195 | { \ |
| 1196 | struct probe_local_vars { _locvar }; \ |
| 1197 | struct lttng_event *__event = __data; \ |
| 1198 | struct lttng_probe_ctx __lttng_probe_ctx = { \ |
| 1199 | .event = __event, \ |
| 1200 | .interruptible = !irqs_disabled(), \ |
| 1201 | }; \ |
| 1202 | struct lttng_channel *__chan = __event->chan; \ |
| 1203 | struct lttng_session *__session = __chan->session; \ |
| 1204 | struct lib_ring_buffer_ctx __ctx; \ |
| 1205 | ssize_t __event_len; \ |
| 1206 | size_t __event_align; \ |
| 1207 | size_t __orig_dynamic_len_offset, __dynamic_len_idx; \ |
| 1208 | union { \ |
| 1209 | size_t __dynamic_len_removed[ARRAY_SIZE(__event_fields___##_name)]; \ |
| 1210 | char __filter_stack_data[2 * sizeof(unsigned long) * ARRAY_SIZE(__event_fields___##_name)]; \ |
| 1211 | } __stackvar; \ |
| 1212 | int __ret; \ |
| 1213 | struct probe_local_vars __tp_locvar; \ |
| 1214 | struct probe_local_vars *tp_locvar __attribute__((unused)) = \ |
| 1215 | &__tp_locvar; \ |
| 1216 | struct lttng_pid_tracker *__lpf; \ |
| 1217 | \ |
| 1218 | if (!_TP_SESSION_CHECK(session, __session)) \ |
| 1219 | return; \ |
| 1220 | if (unlikely(!ACCESS_ONCE(__session->active))) \ |
| 1221 | return; \ |
| 1222 | if (unlikely(!ACCESS_ONCE(__chan->enabled))) \ |
| 1223 | return; \ |
| 1224 | if (unlikely(!ACCESS_ONCE(__event->enabled))) \ |
| 1225 | return; \ |
| 1226 | __lpf = lttng_rcu_dereference(__session->pid_tracker); \ |
| 1227 | if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->pid))) \ |
| 1228 | return; \ |
| 1229 | __orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \ |
| 1230 | __dynamic_len_idx = __orig_dynamic_len_offset; \ |
| 1231 | _code_pre \ |
| 1232 | if (unlikely(!list_empty(&__event->bytecode_runtime_head))) { \ |
| 1233 | struct lttng_bytecode_runtime *bc_runtime; \ |
| 1234 | int __filter_record = __event->has_enablers_without_bytecode; \ |
| 1235 | \ |
| 1236 | __event_prepare_filter_stack__##_name(__stackvar.__filter_stack_data, \ |
| 1237 | tp_locvar); \ |
| 1238 | lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \ |
| 1239 | if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \ |
| 1240 | __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \ |
| 1241 | __filter_record = 1; \ |
| 1242 | } \ |
| 1243 | if (likely(!__filter_record)) \ |
| 1244 | goto __post; \ |
| 1245 | } \ |
| 1246 | __event_len = __event_get_size__##_name(tp_locvar); \ |
| 1247 | if (unlikely(__event_len < 0)) { \ |
| 1248 | lib_ring_buffer_lost_event_too_big(__chan->chan); \ |
| 1249 | goto __post; \ |
| 1250 | } \ |
| 1251 | __event_align = __event_get_align__##_name(tp_locvar); \ |
| 1252 | lib_ring_buffer_ctx_init(&__ctx, __chan->chan, &__lttng_probe_ctx, __event_len, \ |
| 1253 | __event_align, -1); \ |
| 1254 | __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ |
| 1255 | if (__ret < 0) \ |
| 1256 | goto __post; \ |
| 1257 | _fields \ |
| 1258 | __chan->ops->event_commit(&__ctx); \ |
| 1259 | __post: \ |
| 1260 | _code_post \ |
| 1261 | barrier(); /* use before un-reserve. */ \ |
| 1262 | this_cpu_ptr(<tng_dynamic_len_stack)->offset = __orig_dynamic_len_offset; \ |
| 1263 | return; \ |
| 1264 | } |
| 1265 | |
| 1266 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 1267 | |
| 1268 | #undef __get_dynamic_len |
| 1269 | |
| 1270 | /* |
| 1271 | * Stage 7 of the trace events. |
| 1272 | * |
| 1273 | * Create event descriptions. |
| 1274 | */ |
| 1275 | |
| 1276 | /* Named field types must be defined in lttng-types.h */ |
| 1277 | |
| 1278 | #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */ |
| 1279 | |
| 1280 | #ifndef TP_PROBE_CB |
| 1281 | #define TP_PROBE_CB(_template) &__event_probe__##_template |
| 1282 | #endif |
| 1283 | |
| 1284 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS |
| 1285 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \ |
| 1286 | static const struct lttng_event_desc __event_desc___##_map = { \ |
| 1287 | .fields = __event_fields___##_template, \ |
| 1288 | .name = #_map, \ |
| 1289 | .kname = #_name, \ |
| 1290 | .probe_callback = (void *) TP_PROBE_CB(_template), \ |
| 1291 | .nr_fields = ARRAY_SIZE(__event_fields___##_template), \ |
| 1292 | .owner = THIS_MODULE, \ |
| 1293 | }; |
| 1294 | |
| 1295 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP |
| 1296 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \ |
| 1297 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) |
| 1298 | |
| 1299 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 1300 | |
| 1301 | /* |
| 1302 | * Stage 8 of the trace events. |
| 1303 | * |
| 1304 | * Create an array of event description pointers. |
| 1305 | */ |
| 1306 | |
| 1307 | #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */ |
| 1308 | |
| 1309 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS |
| 1310 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) \ |
| 1311 | &__event_desc___##_map, |
| 1312 | |
| 1313 | #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP |
| 1314 | #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(_template, _name, _map, _proto, _args) \ |
| 1315 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map) |
| 1316 | |
| 1317 | #define TP_ID1(_token, _system) _token##_system |
| 1318 | #define TP_ID(_token, _system) TP_ID1(_token, _system) |
| 1319 | |
| 1320 | static const struct lttng_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = { |
| 1321 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 1322 | }; |
| 1323 | |
| 1324 | #undef TP_ID1 |
| 1325 | #undef TP_ID |
| 1326 | |
| 1327 | /* |
| 1328 | * Stage 9 of the trace events. |
| 1329 | * |
| 1330 | * Create a toplevel descriptor for the whole probe. |
| 1331 | */ |
| 1332 | |
| 1333 | #define TP_ID1(_token, _system) _token##_system |
| 1334 | #define TP_ID(_token, _system) TP_ID1(_token, _system) |
| 1335 | |
| 1336 | /* non-const because list head will be modified when registered. */ |
| 1337 | static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = { |
| 1338 | .provider = __stringify(TRACE_SYSTEM), |
| 1339 | .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM), |
| 1340 | .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)), |
| 1341 | .head = { NULL, NULL }, |
| 1342 | .lazy_init_head = { NULL, NULL }, |
| 1343 | .lazy = 0, |
| 1344 | }; |
| 1345 | |
| 1346 | #undef TP_ID1 |
| 1347 | #undef TP_ID |
| 1348 | |
| 1349 | /* |
| 1350 | * Stage 10 of the trace events. |
| 1351 | * |
| 1352 | * Register/unregister probes at module load/unload. |
| 1353 | */ |
| 1354 | |
| 1355 | #include <probes/lttng-events-reset.h> /* Reset all macros within LTTNG_TRACEPOINT_EVENT */ |
| 1356 | |
| 1357 | #define TP_ID1(_token, _system) _token##_system |
| 1358 | #define TP_ID(_token, _system) TP_ID1(_token, _system) |
| 1359 | #define module_init_eval1(_token, _system) module_init(_token##_system) |
| 1360 | #define module_init_eval(_token, _system) module_init_eval1(_token, _system) |
| 1361 | #define module_exit_eval1(_token, _system) module_exit(_token##_system) |
| 1362 | #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system) |
| 1363 | |
| 1364 | #ifndef TP_MODULE_NOINIT |
| 1365 | static int TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void) |
| 1366 | { |
| 1367 | wrapper_vmalloc_sync_all(); |
| 1368 | return lttng_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM)); |
| 1369 | } |
| 1370 | |
| 1371 | static void TP_ID(__lttng_events_exit__, TRACE_SYSTEM)(void) |
| 1372 | { |
| 1373 | lttng_probe_unregister(&TP_ID(__probe_desc___, TRACE_SYSTEM)); |
| 1374 | } |
| 1375 | |
| 1376 | #ifndef TP_MODULE_NOAUTOLOAD |
| 1377 | module_init_eval(__lttng_events_init__, TRACE_SYSTEM); |
| 1378 | module_exit_eval(__lttng_events_exit__, TRACE_SYSTEM); |
| 1379 | #endif |
| 1380 | |
| 1381 | #endif |
| 1382 | |
| 1383 | #undef module_init_eval |
| 1384 | #undef module_exit_eval |
| 1385 | #undef TP_ID1 |
| 1386 | #undef TP_ID |
| 1387 | |
| 1388 | #undef TP_PROTO |
| 1389 | #undef TP_ARGS |