| 1 | /* |
| 2 | * lttng-events.h |
| 3 | * |
| 4 | * Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org> |
| 5 | * Copyright (C) 2009-2012 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 | #include <linux/uaccess.h> |
| 22 | #include <linux/debugfs.h> |
| 23 | #include "lttng.h" |
| 24 | #include "lttng-types.h" |
| 25 | #include "lttng-probe-user.h" |
| 26 | #include "../wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */ |
| 27 | #include "../wrapper/ringbuffer/frontend_types.h" |
| 28 | #include "../lttng-events.h" |
| 29 | #include "../lttng-tracer-core.h" |
| 30 | |
| 31 | /* |
| 32 | * Macro declarations used for all stages. |
| 33 | */ |
| 34 | |
| 35 | /* |
| 36 | * LTTng name mapping macros. LTTng remaps some of the kernel events to |
| 37 | * enforce name-spacing. |
| 38 | */ |
| 39 | #undef TRACE_EVENT_MAP |
| 40 | #define TRACE_EVENT_MAP(name, map, proto, args, tstruct, assign, print) \ |
| 41 | DECLARE_EVENT_CLASS(map, \ |
| 42 | PARAMS(proto), \ |
| 43 | PARAMS(args), \ |
| 44 | PARAMS(tstruct), \ |
| 45 | PARAMS(assign), \ |
| 46 | PARAMS(print)) \ |
| 47 | DEFINE_EVENT_MAP(map, name, map, PARAMS(proto), PARAMS(args)) |
| 48 | |
| 49 | #undef TRACE_EVENT_MAP_NOARGS |
| 50 | #define TRACE_EVENT_MAP_NOARGS(name, map, tstruct, assign, print) \ |
| 51 | DECLARE_EVENT_CLASS_NOARGS(map, \ |
| 52 | PARAMS(tstruct), \ |
| 53 | PARAMS(assign), \ |
| 54 | PARAMS(print)) \ |
| 55 | DEFINE_EVENT_MAP_NOARGS(map, name, map) |
| 56 | |
| 57 | #undef LTTNG_TRACE_EVENT |
| 58 | #define LTTNG_TRACE_EVENT(name, proto, args, _locvar, _code, tstruct, assign, print) \ |
| 59 | LTTNG_DECLARE_EVENT_CLASS(name, \ |
| 60 | PARAMS(proto), \ |
| 61 | PARAMS(args), \ |
| 62 | PARAMS(_locvar), \ |
| 63 | PARAMS(_code), \ |
| 64 | PARAMS(tstruct), \ |
| 65 | PARAMS(assign), \ |
| 66 | PARAMS(print)) \ |
| 67 | DEFINE_EVENT_MAP(name, name, name, PARAMS(proto), PARAMS(args)) |
| 68 | |
| 69 | #undef DEFINE_EVENT_PRINT_MAP |
| 70 | #define DEFINE_EVENT_PRINT_MAP(template, name, map, proto, args, print) \ |
| 71 | DEFINE_EVENT_MAP(template, name, map, PARAMS(proto), PARAMS(args)) |
| 72 | |
| 73 | /* Callbacks are meaningless to LTTng. */ |
| 74 | #undef TRACE_EVENT_FN_MAP |
| 75 | #define TRACE_EVENT_FN_MAP(name, map, proto, args, tstruct, \ |
| 76 | assign, print, reg, unreg) \ |
| 77 | TRACE_EVENT_MAP(name, map, PARAMS(proto), PARAMS(args), \ |
| 78 | PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \ |
| 79 | |
| 80 | #undef TRACE_EVENT_CONDITION_MAP |
| 81 | #define TRACE_EVENT_CONDITION_MAP(name, map, proto, args, cond, tstruct, assign, print) \ |
| 82 | TRACE_EVENT_MAP(name, map, \ |
| 83 | PARAMS(proto), \ |
| 84 | PARAMS(args), \ |
| 85 | PARAMS(tstruct), \ |
| 86 | PARAMS(assign), \ |
| 87 | PARAMS(print)) |
| 88 | |
| 89 | /* |
| 90 | * DECLARE_EVENT_CLASS can be used to add a generic function |
| 91 | * handlers for events. That is, if all events have the same |
| 92 | * parameters and just have distinct trace points. |
| 93 | * Each tracepoint can be defined with DEFINE_EVENT and that |
| 94 | * will map the DECLARE_EVENT_CLASS to the tracepoint. |
| 95 | * |
| 96 | * TRACE_EVENT is a one to one mapping between tracepoint and template. |
| 97 | */ |
| 98 | |
| 99 | #undef TRACE_EVENT |
| 100 | #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ |
| 101 | TRACE_EVENT_MAP(name, name, \ |
| 102 | PARAMS(proto), \ |
| 103 | PARAMS(args), \ |
| 104 | PARAMS(tstruct), \ |
| 105 | PARAMS(assign), \ |
| 106 | PARAMS(print)) |
| 107 | |
| 108 | #undef TRACE_EVENT_NOARGS |
| 109 | #define TRACE_EVENT_NOARGS(name, tstruct, assign, print) \ |
| 110 | TRACE_EVENT_MAP_NOARGS(name, name, \ |
| 111 | PARAMS(tstruct), \ |
| 112 | PARAMS(assign), \ |
| 113 | PARAMS(print)) |
| 114 | |
| 115 | #undef DEFINE_EVENT_PRINT |
| 116 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 117 | DEFINE_EVENT_PRINT_MAP(template, name, name, \ |
| 118 | PARAMS(proto), PARAMS(args), PARAMS(print_)) |
| 119 | |
| 120 | #undef TRACE_EVENT_FN |
| 121 | #define TRACE_EVENT_FN(name, proto, args, tstruct, \ |
| 122 | assign, print, reg, unreg) \ |
| 123 | TRACE_EVENT_FN_MAP(name, name, PARAMS(proto), PARAMS(args), \ |
| 124 | PARAMS(tstruct), PARAMS(assign), PARAMS(print), \ |
| 125 | PARAMS(reg), PARAMS(unreg)) \ |
| 126 | |
| 127 | #undef DEFINE_EVENT |
| 128 | #define DEFINE_EVENT(template, name, proto, args) \ |
| 129 | DEFINE_EVENT_MAP(template, name, name, PARAMS(proto), PARAMS(args)) |
| 130 | |
| 131 | #undef DEFINE_EVENT_NOARGS |
| 132 | #define DEFINE_EVENT_NOARGS(template, name) \ |
| 133 | DEFINE_EVENT_MAP_NOARGS(template, name, name) |
| 134 | |
| 135 | #undef TRACE_EVENT_CONDITION |
| 136 | #define TRACE_EVENT_CONDITION(name, proto, args, cond, tstruct, assign, print) \ |
| 137 | TRACE_EVENT_CONDITION_MAP(name, name, \ |
| 138 | PARAMS(proto), \ |
| 139 | PARAMS(args), \ |
| 140 | PARAMS(cond), \ |
| 141 | PARAMS(tstruct), \ |
| 142 | PARAMS(assign), \ |
| 143 | PARAMS(print)) |
| 144 | |
| 145 | #undef DECLARE_EVENT_CLASS |
| 146 | #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \ |
| 147 | LTTNG_DECLARE_EVENT_CLASS(_name, PARAMS(_proto), PARAMS(_args), , , \ |
| 148 | PARAMS(_tstruct), PARAMS(_assign), PARAMS(_print)) |
| 149 | |
| 150 | #undef DECLARE_EVENT_CLASS_NOARGS |
| 151 | #define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print) \ |
| 152 | LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, , , PARAMS(_tstruct), \ |
| 153 | PARAMS(_assign), PARAMS(_print)) |
| 154 | |
| 155 | |
| 156 | /* |
| 157 | * Stage 1 of the trace events. |
| 158 | * |
| 159 | * Create dummy trace calls for each events, verifying that the LTTng module |
| 160 | * TRACE_EVENT headers match the kernel arguments. Will be optimized out by the |
| 161 | * compiler. |
| 162 | */ |
| 163 | |
| 164 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
| 165 | |
| 166 | #undef TP_PROTO |
| 167 | #define TP_PROTO(args...) args |
| 168 | |
| 169 | #undef TP_ARGS |
| 170 | #define TP_ARGS(args...) args |
| 171 | |
| 172 | #undef DEFINE_EVENT_MAP |
| 173 | #define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args) \ |
| 174 | void trace_##_name(_proto); |
| 175 | |
| 176 | #undef DEFINE_EVENT_MAP_NOARGS |
| 177 | #define DEFINE_EVENT_MAP_NOARGS(_template, _name, _map) \ |
| 178 | void trace_##_name(void *__data); |
| 179 | |
| 180 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 181 | |
| 182 | /* |
| 183 | * Stage 2 of the trace events. |
| 184 | * |
| 185 | * Create event field type metadata section. |
| 186 | * Each event produce an array of fields. |
| 187 | */ |
| 188 | |
| 189 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
| 190 | |
| 191 | /* Named field types must be defined in lttng-types.h */ |
| 192 | |
| 193 | #undef __field_full |
| 194 | #define __field_full(_type, _item, _order, _base) \ |
| 195 | { \ |
| 196 | .name = #_item, \ |
| 197 | .type = __type_integer(_type, _order, _base, none), \ |
| 198 | }, |
| 199 | |
| 200 | #undef __field |
| 201 | #define __field(_type, _item) \ |
| 202 | __field_full(_type, _item, __BYTE_ORDER, 10) |
| 203 | |
| 204 | #undef __field_ext |
| 205 | #define __field_ext(_type, _item, _filter_type) \ |
| 206 | __field(_type, _item) |
| 207 | |
| 208 | #undef __field_hex |
| 209 | #define __field_hex(_type, _item) \ |
| 210 | __field_full(_type, _item, __BYTE_ORDER, 16) |
| 211 | |
| 212 | #undef __field_oct |
| 213 | #define __field_oct(_type, _item) \ |
| 214 | __field_full(_type, _item, __BYTE_ORDER, 8) |
| 215 | |
| 216 | #undef __field_network |
| 217 | #define __field_network(_type, _item) \ |
| 218 | __field_full(_type, _item, __BIG_ENDIAN, 10) |
| 219 | |
| 220 | #undef __field_network_hex |
| 221 | #define __field_network_hex(_type, _item) \ |
| 222 | __field_full(_type, _item, __BIG_ENDIAN, 16) |
| 223 | |
| 224 | #undef __array_enc_ext |
| 225 | #define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)\ |
| 226 | { \ |
| 227 | .name = #_item, \ |
| 228 | .type = \ |
| 229 | { \ |
| 230 | .atype = atype_array, \ |
| 231 | .u.array = \ |
| 232 | { \ |
| 233 | .length = _length, \ |
| 234 | .elem_type = __type_integer(_type, _order, _base, _encoding), \ |
| 235 | }, \ |
| 236 | }, \ |
| 237 | }, |
| 238 | |
| 239 | #undef __array |
| 240 | #define __array(_type, _item, _length) \ |
| 241 | __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, none) |
| 242 | |
| 243 | #undef __array_text |
| 244 | #define __array_text(_type, _item, _length) \ |
| 245 | __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, UTF8) |
| 246 | |
| 247 | #undef __array_hex |
| 248 | #define __array_hex(_type, _item, _length) \ |
| 249 | __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 16, none) |
| 250 | |
| 251 | #undef __dynamic_array_enc_ext |
| 252 | #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding) \ |
| 253 | { \ |
| 254 | .name = #_item, \ |
| 255 | .type = \ |
| 256 | { \ |
| 257 | .atype = atype_sequence, \ |
| 258 | .u.sequence = \ |
| 259 | { \ |
| 260 | .length_type = __type_integer(u32, __BYTE_ORDER, 10, none), \ |
| 261 | .elem_type = __type_integer(_type, _order, _base, _encoding), \ |
| 262 | }, \ |
| 263 | }, \ |
| 264 | }, |
| 265 | |
| 266 | #undef __dynamic_array_enc_ext_2 |
| 267 | #define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding) \ |
| 268 | __dynamic_array_enc_ext(_type, _item, _length1 + _length2, _order, _base, _encoding) |
| 269 | |
| 270 | #undef __dynamic_array |
| 271 | #define __dynamic_array(_type, _item, _length) \ |
| 272 | __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, none) |
| 273 | |
| 274 | #undef __dynamic_array_text |
| 275 | #define __dynamic_array_text(_type, _item, _length) \ |
| 276 | __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, UTF8) |
| 277 | |
| 278 | #undef __dynamic_array_hex |
| 279 | #define __dynamic_array_hex(_type, _item, _length) \ |
| 280 | __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 16, none) |
| 281 | |
| 282 | #undef __dynamic_array_network_hex |
| 283 | #define __dynamic_array_network_hex(_type, _item, _length) \ |
| 284 | __dynamic_array_enc_ext(_type, _item, _length, __BIG_ENDIAN, 16, none) |
| 285 | |
| 286 | #undef __dynamic_array_network |
| 287 | #define __dynamic_array_network(_type, _item, _length) \ |
| 288 | __dynamic_array_enc_ext(_type, _item, _length, __BIG_ENDIAN, 10, none) |
| 289 | |
| 290 | #undef __dynamic_array_text_2 |
| 291 | #define __dynamic_array_text_2(_type, _item, _length1, _length2) \ |
| 292 | __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, __BYTE_ORDER, 10, UTF8) |
| 293 | |
| 294 | #undef __string |
| 295 | #define __string(_item, _src) \ |
| 296 | { \ |
| 297 | .name = #_item, \ |
| 298 | .type = \ |
| 299 | { \ |
| 300 | .atype = atype_string, \ |
| 301 | .u.basic.string.encoding = lttng_encode_UTF8, \ |
| 302 | }, \ |
| 303 | }, |
| 304 | |
| 305 | #undef __string_from_user |
| 306 | #define __string_from_user(_item, _src) \ |
| 307 | __string(_item, _src) |
| 308 | |
| 309 | #undef TP_STRUCT__entry |
| 310 | #define TP_STRUCT__entry(args...) args /* Only one used in this phase */ |
| 311 | |
| 312 | #undef LTTNG_DECLARE_EVENT_CLASS_NOARGS |
| 313 | #define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print) \ |
| 314 | static const struct lttng_event_field __event_fields___##_name[] = { \ |
| 315 | _tstruct \ |
| 316 | }; |
| 317 | |
| 318 | #undef LTTNG_DECLARE_EVENT_CLASS |
| 319 | #define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print) \ |
| 320 | LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, PARAMS(_tstruct), PARAMS(_assign), \ |
| 321 | PARAMS(_print)) |
| 322 | |
| 323 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 324 | |
| 325 | /* |
| 326 | * Stage 3 of the trace events. |
| 327 | * |
| 328 | * Create probe callback prototypes. |
| 329 | */ |
| 330 | |
| 331 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
| 332 | |
| 333 | #undef TP_PROTO |
| 334 | #define TP_PROTO(args...) args |
| 335 | |
| 336 | #undef LTTNG_DECLARE_EVENT_CLASS |
| 337 | #define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print) \ |
| 338 | static void __event_probe__##_name(void *__data, _proto); |
| 339 | |
| 340 | #undef LTTNG_DECLARE_EVENT_CLASS_NOARGS |
| 341 | #define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print) \ |
| 342 | static void __event_probe__##_name(void *__data); |
| 343 | |
| 344 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 345 | |
| 346 | /* |
| 347 | * Stage 3.9 of the trace events. |
| 348 | * |
| 349 | * Create event descriptions. |
| 350 | */ |
| 351 | |
| 352 | /* Named field types must be defined in lttng-types.h */ |
| 353 | |
| 354 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
| 355 | |
| 356 | #ifndef TP_PROBE_CB |
| 357 | #define TP_PROBE_CB(_template) &__event_probe__##_template |
| 358 | #endif |
| 359 | |
| 360 | #undef DEFINE_EVENT_MAP_NOARGS |
| 361 | #define DEFINE_EVENT_MAP_NOARGS(_template, _name, _map) \ |
| 362 | static const struct lttng_event_desc __event_desc___##_map = { \ |
| 363 | .fields = __event_fields___##_template, \ |
| 364 | .name = #_map, \ |
| 365 | .kname = #_name, \ |
| 366 | .probe_callback = (void *) TP_PROBE_CB(_template), \ |
| 367 | .nr_fields = ARRAY_SIZE(__event_fields___##_template), \ |
| 368 | .owner = THIS_MODULE, \ |
| 369 | }; |
| 370 | |
| 371 | #undef DEFINE_EVENT_MAP |
| 372 | #define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args) \ |
| 373 | DEFINE_EVENT_MAP_NOARGS(_template, _name, _map) |
| 374 | |
| 375 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 376 | |
| 377 | |
| 378 | /* |
| 379 | * Stage 4 of the trace events. |
| 380 | * |
| 381 | * Create an array of event description pointers. |
| 382 | */ |
| 383 | |
| 384 | /* Named field types must be defined in lttng-types.h */ |
| 385 | |
| 386 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
| 387 | |
| 388 | #undef DEFINE_EVENT_MAP_NOARGS |
| 389 | #define DEFINE_EVENT_MAP_NOARGS(_template, _name, _map) \ |
| 390 | &__event_desc___##_map, |
| 391 | |
| 392 | #undef DEFINE_EVENT_MAP |
| 393 | #define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args) \ |
| 394 | DEFINE_EVENT_MAP_NOARGS(_template, _name, _map) |
| 395 | |
| 396 | #define TP_ID1(_token, _system) _token##_system |
| 397 | #define TP_ID(_token, _system) TP_ID1(_token, _system) |
| 398 | |
| 399 | static const struct lttng_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = { |
| 400 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 401 | }; |
| 402 | |
| 403 | #undef TP_ID1 |
| 404 | #undef TP_ID |
| 405 | |
| 406 | |
| 407 | /* |
| 408 | * Stage 5 of the trace events. |
| 409 | * |
| 410 | * Create a toplevel descriptor for the whole probe. |
| 411 | */ |
| 412 | |
| 413 | #define TP_ID1(_token, _system) _token##_system |
| 414 | #define TP_ID(_token, _system) TP_ID1(_token, _system) |
| 415 | |
| 416 | /* non-const because list head will be modified when registered. */ |
| 417 | static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = { |
| 418 | .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM), |
| 419 | .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)), |
| 420 | }; |
| 421 | |
| 422 | #undef TP_ID1 |
| 423 | #undef TP_ID |
| 424 | |
| 425 | /* |
| 426 | * Stage 6 of the trace events. |
| 427 | * |
| 428 | * Create static inline function that calculates event size. |
| 429 | */ |
| 430 | |
| 431 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
| 432 | |
| 433 | /* Named field types must be defined in lttng-types.h */ |
| 434 | |
| 435 | #undef __field_full |
| 436 | #define __field_full(_type, _item, _order, _base) \ |
| 437 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
| 438 | __event_len += sizeof(_type); |
| 439 | |
| 440 | #undef __array_enc_ext |
| 441 | #define __array_enc_ext(_type, _item, _length, _order, _base, _encoding) \ |
| 442 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
| 443 | __event_len += sizeof(_type) * (_length); |
| 444 | |
| 445 | #undef __dynamic_array_enc_ext |
| 446 | #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\ |
| 447 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(u32)); \ |
| 448 | __event_len += sizeof(u32); \ |
| 449 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
| 450 | __dynamic_len[__dynamic_len_idx] = (_length); \ |
| 451 | __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ |
| 452 | __dynamic_len_idx++; |
| 453 | |
| 454 | #undef __dynamic_array_enc_ext_2 |
| 455 | #define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding)\ |
| 456 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(u32)); \ |
| 457 | __event_len += sizeof(u32); \ |
| 458 | __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ |
| 459 | __dynamic_len[__dynamic_len_idx] = (_length1); \ |
| 460 | __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ |
| 461 | __dynamic_len_idx++; \ |
| 462 | __dynamic_len[__dynamic_len_idx] = (_length2); \ |
| 463 | __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ |
| 464 | __dynamic_len_idx++; |
| 465 | |
| 466 | #undef __string |
| 467 | #define __string(_item, _src) \ |
| 468 | __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1; |
| 469 | |
| 470 | /* |
| 471 | * strlen_user includes \0. If returns 0, it faulted, so we set size to |
| 472 | * 1 (\0 only). |
| 473 | */ |
| 474 | #undef __string_from_user |
| 475 | #define __string_from_user(_item, _src) \ |
| 476 | __event_len += __dynamic_len[__dynamic_len_idx++] = \ |
| 477 | max_t(size_t, lttng_strlen_user_inatomic(_src), 1); |
| 478 | |
| 479 | #undef TP_PROTO |
| 480 | #define TP_PROTO(args...) args |
| 481 | |
| 482 | #undef TP_STRUCT__entry |
| 483 | #define TP_STRUCT__entry(args...) args |
| 484 | |
| 485 | #undef TP_locvar |
| 486 | #define TP_locvar(...) __VA_ARGS__ |
| 487 | |
| 488 | #undef LTTNG_DECLARE_EVENT_CLASS |
| 489 | #define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print) \ |
| 490 | static inline size_t __event_get_size__##_name(size_t *__dynamic_len, \ |
| 491 | void *__tp_locvar, _proto) \ |
| 492 | { \ |
| 493 | size_t __event_len = 0; \ |
| 494 | unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \ |
| 495 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
| 496 | \ |
| 497 | _tstruct \ |
| 498 | return __event_len; \ |
| 499 | } |
| 500 | |
| 501 | #undef LTTNG_DECLARE_EVENT_CLASS_NOARGS |
| 502 | #define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print) \ |
| 503 | static inline size_t __event_get_size__##_name(size_t *__dynamic_len, \ |
| 504 | void *__tp_locvar) \ |
| 505 | { \ |
| 506 | size_t __event_len = 0; \ |
| 507 | unsigned int __dynamic_len_idx __attribute__((unused)) = 0; \ |
| 508 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
| 509 | \ |
| 510 | _tstruct \ |
| 511 | return __event_len; \ |
| 512 | } |
| 513 | |
| 514 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 515 | |
| 516 | /* |
| 517 | * Stage 7 of the trace events. |
| 518 | * |
| 519 | * Create static inline function that calculates event payload alignment. |
| 520 | */ |
| 521 | |
| 522 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
| 523 | |
| 524 | /* Named field types must be defined in lttng-types.h */ |
| 525 | |
| 526 | #undef __field_full |
| 527 | #define __field_full(_type, _item, _order, _base) \ |
| 528 | __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); |
| 529 | |
| 530 | #undef __array_enc_ext |
| 531 | #define __array_enc_ext(_type, _item, _length, _order, _base, _encoding) \ |
| 532 | __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); |
| 533 | |
| 534 | #undef __dynamic_array_enc_ext |
| 535 | #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\ |
| 536 | __event_align = max_t(size_t, __event_align, lttng_alignof(u32)); \ |
| 537 | __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); |
| 538 | |
| 539 | #undef __dynamic_array_enc_ext_2 |
| 540 | #define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding)\ |
| 541 | __dynamic_array_enc_ext(_type, _item, _length1 + _length2, _order, _base, _encoding) |
| 542 | |
| 543 | #undef __string |
| 544 | #define __string(_item, _src) |
| 545 | |
| 546 | #undef __string_from_user |
| 547 | #define __string_from_user(_item, _src) |
| 548 | |
| 549 | #undef TP_PROTO |
| 550 | #define TP_PROTO(args...) args |
| 551 | |
| 552 | #undef TP_STRUCT__entry |
| 553 | #define TP_STRUCT__entry(args...) args |
| 554 | |
| 555 | #undef TP_locvar |
| 556 | #define TP_locvar(...) __VA_ARGS__ |
| 557 | |
| 558 | #undef LTTNG_DECLARE_EVENT_CLASS |
| 559 | #define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print) \ |
| 560 | static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \ |
| 561 | { \ |
| 562 | size_t __event_align = 1; \ |
| 563 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
| 564 | \ |
| 565 | _tstruct \ |
| 566 | return __event_align; \ |
| 567 | } |
| 568 | |
| 569 | #undef LTTNG_DECLARE_EVENT_CLASS_NOARGS |
| 570 | #define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print) \ |
| 571 | static inline size_t __event_get_align__##_name(void *__tp_locvar) \ |
| 572 | { \ |
| 573 | size_t __event_align = 1; \ |
| 574 | struct { _locvar } *tp_locvar __attribute__((unused)) = __tp_locvar; \ |
| 575 | \ |
| 576 | _tstruct \ |
| 577 | return __event_align; \ |
| 578 | } |
| 579 | |
| 580 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 581 | |
| 582 | /* |
| 583 | * Stage 8 of the trace events. |
| 584 | * |
| 585 | * Create structure declaration that allows the "assign" macros to access the |
| 586 | * field types. |
| 587 | */ |
| 588 | |
| 589 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
| 590 | |
| 591 | /* Named field types must be defined in lttng-types.h */ |
| 592 | |
| 593 | #undef __field_full |
| 594 | #define __field_full(_type, _item, _order, _base) _type _item; |
| 595 | |
| 596 | #undef __array_enc_ext |
| 597 | #define __array_enc_ext(_type, _item, _length, _order, _base, _encoding) \ |
| 598 | _type _item; |
| 599 | |
| 600 | #undef __dynamic_array_enc_ext |
| 601 | #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\ |
| 602 | _type _item; |
| 603 | |
| 604 | #undef __dynamic_array_enc_ext_2 |
| 605 | #define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding)\ |
| 606 | __dynamic_array_enc_ext(_type, _item, _length1 + _length2, _order, _base, _encoding) |
| 607 | |
| 608 | #undef __string |
| 609 | #define __string(_item, _src) char _item; |
| 610 | |
| 611 | #undef __string_from_user |
| 612 | #define __string_from_user(_item, _src) \ |
| 613 | __string(_item, _src) |
| 614 | |
| 615 | #undef TP_STRUCT__entry |
| 616 | #define TP_STRUCT__entry(args...) args |
| 617 | |
| 618 | #undef LTTNG_DECLARE_EVENT_CLASS_NOARGS |
| 619 | #define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print) \ |
| 620 | struct __event_typemap__##_name { \ |
| 621 | _tstruct \ |
| 622 | }; |
| 623 | |
| 624 | #undef LTTNG_DECLARE_EVENT_CLASS |
| 625 | #define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print) \ |
| 626 | LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print) |
| 627 | |
| 628 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 629 | |
| 630 | |
| 631 | /* |
| 632 | * Stage 9 of the trace events. |
| 633 | * |
| 634 | * Create the probe function : call even size calculation and write event data |
| 635 | * into the buffer. |
| 636 | * |
| 637 | * We use both the field and assignment macros to write the fields in the order |
| 638 | * defined in the field declaration. The field declarations control the |
| 639 | * execution order, jumping to the appropriate assignment block. |
| 640 | */ |
| 641 | |
| 642 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
| 643 | |
| 644 | #undef __field_full |
| 645 | #define __field_full(_type, _item, _order, _base) \ |
| 646 | goto __assign_##_item; \ |
| 647 | __end_field_##_item: |
| 648 | |
| 649 | #undef __array_enc_ext |
| 650 | #define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)\ |
| 651 | goto __assign_##_item; \ |
| 652 | __end_field_##_item: |
| 653 | |
| 654 | #undef __dynamic_array_enc_ext |
| 655 | #define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\ |
| 656 | goto __assign_##_item##_1; \ |
| 657 | __end_field_##_item##_1: \ |
| 658 | goto __assign_##_item##_2; \ |
| 659 | __end_field_##_item##_2: |
| 660 | |
| 661 | #undef __dynamic_array_enc_ext_2 |
| 662 | #define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding)\ |
| 663 | goto __assign_##_item##_1; \ |
| 664 | __end_field_##_item##_1: \ |
| 665 | goto __assign_##_item##_2; \ |
| 666 | __end_field_##_item##_2: \ |
| 667 | goto __assign_##_item##_3; \ |
| 668 | __end_field_##_item##_3: |
| 669 | |
| 670 | #undef __string |
| 671 | #define __string(_item, _src) \ |
| 672 | goto __assign_##_item; \ |
| 673 | __end_field_##_item: |
| 674 | |
| 675 | #undef __string_from_user |
| 676 | #define __string_from_user(_item, _src) \ |
| 677 | __string(_item, _src) |
| 678 | |
| 679 | /* |
| 680 | * Macros mapping tp_assign() to "=", tp_memcpy() to memcpy() and tp_strcpy() to |
| 681 | * strcpy(). |
| 682 | */ |
| 683 | #undef tp_assign |
| 684 | #define tp_assign(dest, src) \ |
| 685 | __assign_##dest: \ |
| 686 | { \ |
| 687 | __typeof__(__typemap.dest) __tmp = (src); \ |
| 688 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp)); \ |
| 689 | __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\ |
| 690 | } \ |
| 691 | goto __end_field_##dest; |
| 692 | |
| 693 | /* fixed length array memcpy */ |
| 694 | #undef tp_memcpy_gen |
| 695 | #define tp_memcpy_gen(write_ops, dest, src, len) \ |
| 696 | __assign_##dest: \ |
| 697 | if (0) \ |
| 698 | (void) __typemap.dest; \ |
| 699 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest)); \ |
| 700 | __chan->ops->write_ops(&__ctx, src, len); \ |
| 701 | goto __end_field_##dest; |
| 702 | |
| 703 | #undef tp_memcpy |
| 704 | #define tp_memcpy(dest, src, len) \ |
| 705 | tp_memcpy_gen(event_write, dest, src, len) |
| 706 | |
| 707 | #undef tp_memcpy_from_user |
| 708 | #define tp_memcpy_from_user(dest, src, len) \ |
| 709 | tp_memcpy_gen(event_write_from_user, dest, src, len) |
| 710 | |
| 711 | /* variable length sequence memcpy */ |
| 712 | #undef tp_memcpy_dyn_gen |
| 713 | #define tp_memcpy_dyn_gen(write_ops, dest, src) \ |
| 714 | __assign_##dest##_1: \ |
| 715 | { \ |
| 716 | u32 __tmpl = __dynamic_len[__dynamic_len_idx]; \ |
| 717 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(u32)); \ |
| 718 | __chan->ops->event_write(&__ctx, &__tmpl, sizeof(u32)); \ |
| 719 | } \ |
| 720 | goto __end_field_##dest##_1; \ |
| 721 | __assign_##dest##_2: \ |
| 722 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest)); \ |
| 723 | __chan->ops->write_ops(&__ctx, src, \ |
| 724 | sizeof(__typemap.dest) * __get_dynamic_array_len(dest));\ |
| 725 | goto __end_field_##dest##_2; |
| 726 | |
| 727 | #undef tp_memcpy_dyn_gen_2 |
| 728 | #define tp_memcpy_dyn_gen_2(write_ops, dest, src1, src2) \ |
| 729 | __assign_##dest##_1: \ |
| 730 | { \ |
| 731 | u32 __tmpl = __dynamic_len[__dynamic_len_idx] \ |
| 732 | + __dynamic_len[__dynamic_len_idx + 1]; \ |
| 733 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(u32)); \ |
| 734 | __chan->ops->event_write(&__ctx, &__tmpl, sizeof(u32)); \ |
| 735 | } \ |
| 736 | goto __end_field_##dest##_1; \ |
| 737 | __assign_##dest##_2: \ |
| 738 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest)); \ |
| 739 | __chan->ops->write_ops(&__ctx, src1, \ |
| 740 | sizeof(__typemap.dest) * __get_dynamic_array_len(dest));\ |
| 741 | goto __end_field_##dest##_2; \ |
| 742 | __assign_##dest##_3: \ |
| 743 | __chan->ops->write_ops(&__ctx, src2, \ |
| 744 | sizeof(__typemap.dest) * __get_dynamic_array_len(dest));\ |
| 745 | goto __end_field_##dest##_3; |
| 746 | |
| 747 | #undef tp_memcpy_dyn |
| 748 | #define tp_memcpy_dyn(dest, src) \ |
| 749 | tp_memcpy_dyn_gen(event_write, dest, src) |
| 750 | |
| 751 | #undef tp_memcpy_dyn_2 |
| 752 | #define tp_memcpy_dyn_2(dest, src1, src2) \ |
| 753 | tp_memcpy_dyn_gen_2(event_write, dest, src1, src2) |
| 754 | |
| 755 | #undef tp_memcpy_dyn_from_user |
| 756 | #define tp_memcpy_dyn_from_user(dest, src) \ |
| 757 | tp_memcpy_dyn_gen(event_write_from_user, dest, src) |
| 758 | |
| 759 | /* |
| 760 | * The string length including the final \0. |
| 761 | */ |
| 762 | #undef tp_copy_string_from_user |
| 763 | #define tp_copy_string_from_user(dest, src) \ |
| 764 | __assign_##dest: \ |
| 765 | if (0) \ |
| 766 | (void) __typemap.dest; \ |
| 767 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest)); \ |
| 768 | __chan->ops->event_strcpy_from_user(&__ctx, src, \ |
| 769 | __get_dynamic_array_len(dest)); \ |
| 770 | goto __end_field_##dest; |
| 771 | |
| 772 | #undef tp_strcpy |
| 773 | #define tp_strcpy(dest, src) \ |
| 774 | __assign_##dest: \ |
| 775 | if (0) \ |
| 776 | (void) __typemap.dest; \ |
| 777 | lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest)); \ |
| 778 | __chan->ops->event_strcpy(&__ctx, src, __get_dynamic_array_len(dest)); \ |
| 779 | goto __end_field_##dest; |
| 780 | |
| 781 | /* Named field types must be defined in lttng-types.h */ |
| 782 | |
| 783 | #undef __get_str |
| 784 | #define __get_str(field) field |
| 785 | |
| 786 | #undef __get_dynamic_array |
| 787 | #define __get_dynamic_array(field) field |
| 788 | |
| 789 | /* Beware: this get len actually consumes the len value */ |
| 790 | #undef __get_dynamic_array_len |
| 791 | #define __get_dynamic_array_len(field) __dynamic_len[__dynamic_len_idx++] |
| 792 | |
| 793 | #undef TP_PROTO |
| 794 | #define TP_PROTO(args...) args |
| 795 | |
| 796 | #undef TP_ARGS |
| 797 | #define TP_ARGS(args...) args |
| 798 | |
| 799 | #undef TP_STRUCT__entry |
| 800 | #define TP_STRUCT__entry(args...) args |
| 801 | |
| 802 | #undef TP_fast_assign |
| 803 | #define TP_fast_assign(args...) args |
| 804 | |
| 805 | #undef TP_locvar |
| 806 | #define TP_locvar(...) __VA_ARGS__ |
| 807 | |
| 808 | #undef TP_code |
| 809 | #define TP_code(...) __VA_ARGS__ |
| 810 | |
| 811 | /* |
| 812 | * For state dump, check that "session" argument (mandatory) matches the |
| 813 | * session this event belongs to. Ensures that we write state dump data only |
| 814 | * into the started session, not into all sessions. |
| 815 | */ |
| 816 | #ifdef TP_SESSION_CHECK |
| 817 | #define _TP_SESSION_CHECK(session, csession) (session == csession) |
| 818 | #else /* TP_SESSION_CHECK */ |
| 819 | #define _TP_SESSION_CHECK(session, csession) 1 |
| 820 | #endif /* TP_SESSION_CHECK */ |
| 821 | |
| 822 | /* |
| 823 | * __dynamic_len array length is twice the number of fields due to |
| 824 | * __dynamic_array_enc_ext_2() and tp_memcpy_dyn_2(), which are the |
| 825 | * worse case, needing 2 entries per field. |
| 826 | */ |
| 827 | #undef LTTNG_DECLARE_EVENT_CLASS |
| 828 | #define LTTNG_DECLARE_EVENT_CLASS(_name, _proto, _args, _locvar, _code, _tstruct, _assign, _print) \ |
| 829 | static void __event_probe__##_name(void *__data, _proto) \ |
| 830 | { \ |
| 831 | struct probe_local_vars { _locvar }; \ |
| 832 | struct lttng_event *__event = __data; \ |
| 833 | struct lttng_channel *__chan = __event->chan; \ |
| 834 | struct lib_ring_buffer_ctx __ctx; \ |
| 835 | size_t __event_len, __event_align; \ |
| 836 | size_t __dynamic_len_idx __attribute__((unused)) = 0; \ |
| 837 | size_t __dynamic_len[2 * ARRAY_SIZE(__event_fields___##_name)] __attribute__((unused)); \ |
| 838 | struct __event_typemap__##_name __typemap __attribute__((unused)); \ |
| 839 | int __ret; \ |
| 840 | struct probe_local_vars __tp_locvar; \ |
| 841 | struct probe_local_vars *tp_locvar __attribute__((unused)) = \ |
| 842 | &__tp_locvar; \ |
| 843 | \ |
| 844 | if (!_TP_SESSION_CHECK(session, __chan->session)) \ |
| 845 | return; \ |
| 846 | if (unlikely(!ACCESS_ONCE(__chan->session->active))) \ |
| 847 | return; \ |
| 848 | if (unlikely(!ACCESS_ONCE(__chan->enabled))) \ |
| 849 | return; \ |
| 850 | if (unlikely(!ACCESS_ONCE(__event->enabled))) \ |
| 851 | return; \ |
| 852 | _code \ |
| 853 | __event_len = __event_get_size__##_name(__dynamic_len, tp_locvar, \ |
| 854 | _args); \ |
| 855 | __event_align = __event_get_align__##_name(tp_locvar, _args); \ |
| 856 | lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \ |
| 857 | __event_align, -1); \ |
| 858 | __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ |
| 859 | if (__ret < 0) \ |
| 860 | return; \ |
| 861 | /* Control code (field ordering) */ \ |
| 862 | _tstruct \ |
| 863 | __chan->ops->event_commit(&__ctx); \ |
| 864 | return; \ |
| 865 | /* Copy code, steered by control code */ \ |
| 866 | _assign \ |
| 867 | } |
| 868 | |
| 869 | #undef LTTNG_DECLARE_EVENT_CLASS_NOARGS |
| 870 | #define LTTNG_DECLARE_EVENT_CLASS_NOARGS(_name, _locvar, _code, _tstruct, _assign, _print) \ |
| 871 | static void __event_probe__##_name(void *__data) \ |
| 872 | { \ |
| 873 | struct probe_local_vars { _locvar }; \ |
| 874 | struct lttng_event *__event = __data; \ |
| 875 | struct lttng_channel *__chan = __event->chan; \ |
| 876 | struct lib_ring_buffer_ctx __ctx; \ |
| 877 | size_t __event_len, __event_align; \ |
| 878 | size_t __dynamic_len_idx __attribute__((unused)) = 0; \ |
| 879 | size_t __dynamic_len[2 * ARRAY_SIZE(__event_fields___##_name)] __attribute__((unused)); \ |
| 880 | struct __event_typemap__##_name __typemap __attribute__((unused)); \ |
| 881 | int __ret; \ |
| 882 | struct probe_local_vars __tp_locvar; \ |
| 883 | struct probe_local_vars *tp_locvar __attribute__((unused)) = \ |
| 884 | &__tp_locvar; \ |
| 885 | \ |
| 886 | if (!_TP_SESSION_CHECK(session, __chan->session)) \ |
| 887 | return; \ |
| 888 | if (unlikely(!ACCESS_ONCE(__chan->session->active))) \ |
| 889 | return; \ |
| 890 | if (unlikely(!ACCESS_ONCE(__chan->enabled))) \ |
| 891 | return; \ |
| 892 | if (unlikely(!ACCESS_ONCE(__event->enabled))) \ |
| 893 | return; \ |
| 894 | _code \ |
| 895 | __event_len = __event_get_size__##_name(__dynamic_len, tp_locvar); \ |
| 896 | __event_align = __event_get_align__##_name(tp_locvar); \ |
| 897 | lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \ |
| 898 | __event_align, -1); \ |
| 899 | __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ |
| 900 | if (__ret < 0) \ |
| 901 | return; \ |
| 902 | /* Control code (field ordering) */ \ |
| 903 | _tstruct \ |
| 904 | __chan->ops->event_commit(&__ctx); \ |
| 905 | return; \ |
| 906 | /* Copy code, steered by control code */ \ |
| 907 | _assign \ |
| 908 | } |
| 909 | |
| 910 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 911 | |
| 912 | /* |
| 913 | * Stage 10 of the trace events. |
| 914 | * |
| 915 | * Register/unregister probes at module load/unload. |
| 916 | */ |
| 917 | |
| 918 | #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ |
| 919 | |
| 920 | #define TP_ID1(_token, _system) _token##_system |
| 921 | #define TP_ID(_token, _system) TP_ID1(_token, _system) |
| 922 | #define module_init_eval1(_token, _system) module_init(_token##_system) |
| 923 | #define module_init_eval(_token, _system) module_init_eval1(_token, _system) |
| 924 | #define module_exit_eval1(_token, _system) module_exit(_token##_system) |
| 925 | #define module_exit_eval(_token, _system) module_exit_eval1(_token, _system) |
| 926 | |
| 927 | #ifndef TP_MODULE_NOINIT |
| 928 | static int TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void) |
| 929 | { |
| 930 | wrapper_vmalloc_sync_all(); |
| 931 | return lttng_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM)); |
| 932 | } |
| 933 | |
| 934 | static void TP_ID(__lttng_events_exit__, TRACE_SYSTEM)(void) |
| 935 | { |
| 936 | lttng_probe_unregister(&TP_ID(__probe_desc___, TRACE_SYSTEM)); |
| 937 | } |
| 938 | |
| 939 | #ifndef TP_MODULE_NOAUTOLOAD |
| 940 | module_init_eval(__lttng_events_init__, TRACE_SYSTEM); |
| 941 | module_exit_eval(__lttng_events_exit__, TRACE_SYSTEM); |
| 942 | #endif |
| 943 | |
| 944 | #endif |
| 945 | |
| 946 | #undef module_init_eval |
| 947 | #undef module_exit_eval |
| 948 | #undef TP_ID1 |
| 949 | #undef TP_ID |
| 950 | |
| 951 | #undef TP_PROTO |
| 952 | #undef TP_ARGS |
| 953 | #undef TRACE_EVENT_FLAGS |