| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 5 | * |
| 6 | * Holds LTTng per-session event registry. |
| 7 | */ |
| 8 | |
| 9 | #ifndef _LTTNG_UST_EVENTS_H |
| 10 | #define _LTTNG_UST_EVENTS_H |
| 11 | |
| 12 | #include <urcu/list.h> |
| 13 | #include <urcu/hlist.h> |
| 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
| 16 | #include <lttng/ust-abi.h> |
| 17 | #include <lttng/ust-tracer.h> |
| 18 | #include <lttng/ust-endian.h> |
| 19 | #include <float.h> |
| 20 | #include <errno.h> |
| 21 | #include <urcu/ref.h> |
| 22 | #include <pthread.h> |
| 23 | |
| 24 | #ifndef LTTNG_PACKED |
| 25 | #error "LTTNG_PACKED should be defined" |
| 26 | #endif |
| 27 | |
| 28 | #ifdef __cplusplus |
| 29 | extern "C" { |
| 30 | #endif |
| 31 | |
| 32 | #define LTTNG_UST_UUID_LEN 16 |
| 33 | |
| 34 | /* |
| 35 | * Tracepoint provider version. Compatibility based on the major number. |
| 36 | * Older tracepoint providers can always register to newer lttng-ust |
| 37 | * library, but the opposite is rejected: a newer tracepoint provider is |
| 38 | * rejected by an older lttng-ust library. |
| 39 | */ |
| 40 | #define LTTNG_UST_PROVIDER_MAJOR 2 |
| 41 | #define LTTNG_UST_PROVIDER_MINOR 0 |
| 42 | |
| 43 | struct lttng_channel; |
| 44 | struct lttng_session; |
| 45 | struct lttng_ust_lib_ring_buffer_ctx; |
| 46 | struct lttng_ust_event_field; |
| 47 | struct lttng_event_notifier_group; |
| 48 | |
| 49 | /* |
| 50 | * Data structures used by tracepoint event declarations, and by the |
| 51 | * tracer. Those structures have padding for future extension. |
| 52 | */ |
| 53 | |
| 54 | /* Type description */ |
| 55 | |
| 56 | /* Update the astract_types name table in lttng-types.c along with this enum */ |
| 57 | enum lttng_abstract_types { |
| 58 | atype_integer, |
| 59 | atype_string, |
| 60 | atype_float, |
| 61 | atype_dynamic, |
| 62 | atype_enum_nestable, |
| 63 | atype_array_nestable, |
| 64 | atype_sequence_nestable, |
| 65 | atype_struct_nestable, |
| 66 | NR_ABSTRACT_TYPES, |
| 67 | }; |
| 68 | |
| 69 | /* Update the string_encodings name table in lttng-types.c along with this enum */ |
| 70 | enum lttng_string_encodings { |
| 71 | lttng_encode_none = 0, |
| 72 | lttng_encode_UTF8 = 1, |
| 73 | lttng_encode_ASCII = 2, |
| 74 | NR_STRING_ENCODINGS, |
| 75 | }; |
| 76 | |
| 77 | struct lttng_enum_value { |
| 78 | unsigned long long value; |
| 79 | unsigned int signedness:1; |
| 80 | }; |
| 81 | |
| 82 | enum lttng_enum_entry_options { |
| 83 | LTTNG_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0, |
| 84 | }; |
| 85 | |
| 86 | /* |
| 87 | * Enumeration entry description |
| 88 | * |
| 89 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 90 | * UST. Fields need to be only added at the end, never reordered, never |
| 91 | * removed. |
| 92 | * |
| 93 | * The field @struct_size should be used to determine the size of the |
| 94 | * structure. It should be queried before using additional fields added |
| 95 | * at the end of the structure. |
| 96 | */ |
| 97 | |
| 98 | struct lttng_ust_enum_entry { |
| 99 | uint32_t struct_size; |
| 100 | |
| 101 | struct lttng_enum_value start, end; /* start and end are inclusive */ |
| 102 | const char *string; |
| 103 | unsigned int options; |
| 104 | |
| 105 | /* End of base ABI. Fields below should be used after checking struct_size. */ |
| 106 | }; |
| 107 | |
| 108 | #define __type_integer(_type, _byte_order, _base, _encoding) \ |
| 109 | { \ |
| 110 | .atype = atype_integer, \ |
| 111 | .u = \ |
| 112 | { \ |
| 113 | .integer = \ |
| 114 | { \ |
| 115 | .size = sizeof(_type) * CHAR_BIT, \ |
| 116 | .alignment = lttng_alignof(_type) * CHAR_BIT, \ |
| 117 | .signedness = lttng_is_signed_type(_type), \ |
| 118 | .reverse_byte_order = _byte_order != BYTE_ORDER, \ |
| 119 | .base = _base, \ |
| 120 | .encoding = lttng_encode_##_encoding, \ |
| 121 | } \ |
| 122 | }, \ |
| 123 | } \ |
| 124 | |
| 125 | #define LTTNG_UST_INTEGER_TYPE_PADDING 24 |
| 126 | struct lttng_integer_type { |
| 127 | unsigned int size; /* in bits */ |
| 128 | unsigned short alignment; /* in bits */ |
| 129 | unsigned int signedness:1; |
| 130 | unsigned int reverse_byte_order:1; |
| 131 | unsigned int base; /* 2, 8, 10, 16, for pretty print */ |
| 132 | enum lttng_string_encodings encoding; |
| 133 | char padding[LTTNG_UST_INTEGER_TYPE_PADDING]; |
| 134 | }; |
| 135 | |
| 136 | /* |
| 137 | * Only float and double are supported. long double is not supported at |
| 138 | * the moment. |
| 139 | */ |
| 140 | #define _float_mant_dig(_type) \ |
| 141 | (sizeof(_type) == sizeof(float) ? FLT_MANT_DIG \ |
| 142 | : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG \ |
| 143 | : 0)) |
| 144 | |
| 145 | #define __type_float(_type) \ |
| 146 | { \ |
| 147 | .atype = atype_float, \ |
| 148 | .u = \ |
| 149 | { \ |
| 150 | ._float = \ |
| 151 | { \ |
| 152 | .exp_dig = sizeof(_type) * CHAR_BIT \ |
| 153 | - _float_mant_dig(_type), \ |
| 154 | .mant_dig = _float_mant_dig(_type), \ |
| 155 | .alignment = lttng_alignof(_type) * CHAR_BIT, \ |
| 156 | .reverse_byte_order = BYTE_ORDER != FLOAT_WORD_ORDER, \ |
| 157 | } \ |
| 158 | } \ |
| 159 | } \ |
| 160 | |
| 161 | #define LTTNG_UST_FLOAT_TYPE_PADDING 24 |
| 162 | struct lttng_float_type { |
| 163 | unsigned int exp_dig; /* exponent digits, in bits */ |
| 164 | unsigned int mant_dig; /* mantissa digits, in bits */ |
| 165 | unsigned short alignment; /* in bits */ |
| 166 | unsigned int reverse_byte_order:1; |
| 167 | char padding[LTTNG_UST_FLOAT_TYPE_PADDING]; |
| 168 | }; |
| 169 | |
| 170 | #define LTTNG_UST_TYPE_PADDING 128 |
| 171 | struct lttng_type { |
| 172 | enum lttng_abstract_types atype; |
| 173 | union { |
| 174 | /* provider ABI 2.0 */ |
| 175 | struct lttng_integer_type integer; |
| 176 | struct lttng_float_type _float; |
| 177 | struct { |
| 178 | enum lttng_string_encodings encoding; |
| 179 | } string; |
| 180 | struct { |
| 181 | const struct lttng_ust_enum_desc *desc; /* Enumeration mapping */ |
| 182 | struct lttng_type *container_type; |
| 183 | } enum_nestable; |
| 184 | struct { |
| 185 | const struct lttng_type *elem_type; |
| 186 | unsigned int length; /* Num. elems. */ |
| 187 | unsigned int alignment; |
| 188 | } array_nestable; |
| 189 | struct { |
| 190 | const char *length_name; /* Length field name. */ |
| 191 | const struct lttng_type *elem_type; |
| 192 | unsigned int alignment; /* Alignment before elements. */ |
| 193 | } sequence_nestable; |
| 194 | struct { |
| 195 | unsigned int nr_fields; |
| 196 | const struct lttng_ust_event_field **fields; /* Array of pointers to fields. */ |
| 197 | unsigned int alignment; |
| 198 | } struct_nestable; |
| 199 | |
| 200 | char padding[LTTNG_UST_TYPE_PADDING]; |
| 201 | } u; |
| 202 | }; |
| 203 | |
| 204 | /* |
| 205 | * Enumeration description |
| 206 | * |
| 207 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 208 | * UST. Fields need to be only added at the end, never reordered, never |
| 209 | * removed. |
| 210 | * |
| 211 | * The field @struct_size should be used to determine the size of the |
| 212 | * structure. It should be queried before using additional fields added |
| 213 | * at the end of the structure. |
| 214 | */ |
| 215 | |
| 216 | struct lttng_ust_enum_desc { |
| 217 | uint32_t struct_size; |
| 218 | |
| 219 | const char *name; |
| 220 | const struct lttng_ust_enum_entry **entries; |
| 221 | unsigned int nr_entries; |
| 222 | |
| 223 | /* End of base ABI. Fields below should be used after checking struct_size. */ |
| 224 | }; |
| 225 | |
| 226 | /* |
| 227 | * Event field description |
| 228 | * |
| 229 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 230 | * UST. Fields need to be only added at the end, never reordered, never |
| 231 | * removed. |
| 232 | * |
| 233 | * The field @struct_size should be used to determine the size of the |
| 234 | * structure. It should be queried before using additional fields added |
| 235 | * at the end of the structure. |
| 236 | */ |
| 237 | |
| 238 | struct lttng_ust_event_field { |
| 239 | uint32_t struct_size; |
| 240 | |
| 241 | const char *name; |
| 242 | struct lttng_type type; |
| 243 | unsigned int nowrite:1, /* do not write into trace */ |
| 244 | nofilter:1; /* do not consider for filter */ |
| 245 | |
| 246 | /* End of base ABI. Fields below should be used after checking struct_size. */ |
| 247 | }; |
| 248 | |
| 249 | enum lttng_ust_dynamic_type { |
| 250 | LTTNG_UST_DYNAMIC_TYPE_NONE, |
| 251 | LTTNG_UST_DYNAMIC_TYPE_S8, |
| 252 | LTTNG_UST_DYNAMIC_TYPE_S16, |
| 253 | LTTNG_UST_DYNAMIC_TYPE_S32, |
| 254 | LTTNG_UST_DYNAMIC_TYPE_S64, |
| 255 | LTTNG_UST_DYNAMIC_TYPE_U8, |
| 256 | LTTNG_UST_DYNAMIC_TYPE_U16, |
| 257 | LTTNG_UST_DYNAMIC_TYPE_U32, |
| 258 | LTTNG_UST_DYNAMIC_TYPE_U64, |
| 259 | LTTNG_UST_DYNAMIC_TYPE_FLOAT, |
| 260 | LTTNG_UST_DYNAMIC_TYPE_DOUBLE, |
| 261 | LTTNG_UST_DYNAMIC_TYPE_STRING, |
| 262 | _NR_LTTNG_UST_DYNAMIC_TYPES, |
| 263 | }; |
| 264 | |
| 265 | struct lttng_ctx_value { |
| 266 | enum lttng_ust_dynamic_type sel; |
| 267 | union { |
| 268 | int64_t s64; |
| 269 | uint64_t u64; |
| 270 | const char *str; |
| 271 | double d; |
| 272 | } u; |
| 273 | }; |
| 274 | |
| 275 | struct lttng_perf_counter_field; |
| 276 | |
| 277 | #define LTTNG_UST_CTX_FIELD_PADDING 40 |
| 278 | struct lttng_ctx_field { |
| 279 | struct lttng_ust_event_field event_field; |
| 280 | size_t (*get_size)(struct lttng_ctx_field *field, size_t offset); |
| 281 | void (*record)(struct lttng_ctx_field *field, |
| 282 | struct lttng_ust_lib_ring_buffer_ctx *ctx, |
| 283 | struct lttng_channel *chan); |
| 284 | void (*get_value)(struct lttng_ctx_field *field, |
| 285 | struct lttng_ctx_value *value); |
| 286 | union { |
| 287 | struct lttng_perf_counter_field *perf_counter; |
| 288 | char padding[LTTNG_UST_CTX_FIELD_PADDING]; |
| 289 | } u; |
| 290 | void (*destroy)(struct lttng_ctx_field *field); |
| 291 | char *field_name; /* Has ownership, dynamically allocated. */ |
| 292 | }; |
| 293 | |
| 294 | #define LTTNG_UST_CTX_PADDING 20 |
| 295 | struct lttng_ctx { |
| 296 | struct lttng_ctx_field *fields; |
| 297 | unsigned int nr_fields; |
| 298 | unsigned int allocated_fields; |
| 299 | unsigned int largest_align; |
| 300 | char padding[LTTNG_UST_CTX_PADDING]; |
| 301 | }; |
| 302 | |
| 303 | /* |
| 304 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 305 | * UST. Fields need to be only added at the end, never reordered, never |
| 306 | * removed. |
| 307 | * |
| 308 | * The field @struct_size should be used to determine the size of the |
| 309 | * structure. It should be queried before using additional fields added |
| 310 | * at the end of the structure. |
| 311 | */ |
| 312 | struct lttng_ust_event_desc { |
| 313 | uint32_t struct_size; /* Size of this structure. */ |
| 314 | const char *name; |
| 315 | void (*probe_callback)(void); |
| 316 | const struct lttng_event_ctx *ctx; /* context */ |
| 317 | const struct lttng_ust_event_field **fields; /* event payload */ |
| 318 | unsigned int nr_fields; |
| 319 | const int **loglevel; |
| 320 | const char *signature; /* Argument types/names received */ |
| 321 | const char **model_emf_uri; |
| 322 | |
| 323 | /* End of base ABI. Fields below should be used after checking struct_size. */ |
| 324 | }; |
| 325 | |
| 326 | /* |
| 327 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 328 | * UST. Fields need to be only added at the end, never reordered, never |
| 329 | * removed. |
| 330 | * |
| 331 | * The field @struct_size should be used to determine the size of the |
| 332 | * structure. It should be queried before using additional fields added |
| 333 | * at the end of the structure. |
| 334 | */ |
| 335 | struct lttng_ust_probe_desc { |
| 336 | uint32_t struct_size; /* Size of this structure. */ |
| 337 | |
| 338 | const char *provider; |
| 339 | const struct lttng_ust_event_desc **event_desc; |
| 340 | unsigned int nr_events; |
| 341 | struct cds_list_head head; /* chain registered probes */ |
| 342 | struct cds_list_head lazy_init_head; |
| 343 | int lazy; /* lazy registration */ |
| 344 | uint32_t major; |
| 345 | uint32_t minor; |
| 346 | |
| 347 | /* End of base ABI. Fields below should be used after checking struct_size. */ |
| 348 | }; |
| 349 | |
| 350 | /* Data structures used by the tracer. */ |
| 351 | |
| 352 | /* |
| 353 | * Bytecode interpreter return value masks. |
| 354 | */ |
| 355 | enum lttng_bytecode_interpreter_ret { |
| 356 | LTTNG_INTERPRETER_DISCARD = 0, |
| 357 | LTTNG_INTERPRETER_RECORD_FLAG = (1ULL << 0), |
| 358 | /* Other bits are kept for future use. */ |
| 359 | }; |
| 360 | |
| 361 | struct lttng_interpreter_output; |
| 362 | struct lttng_ust_bytecode_runtime_private; |
| 363 | |
| 364 | /* |
| 365 | * This structure is used in the probes. More specifically, the |
| 366 | * `interpreter_funcs` and `node` fields are explicity used in the |
| 367 | * probes. When modifying this structure we must not change the layout |
| 368 | * of these two fields as it is considered ABI. |
| 369 | */ |
| 370 | struct lttng_bytecode_runtime { |
| 371 | struct lttng_ust_bytecode_runtime_private *priv; |
| 372 | |
| 373 | /* Associated bytecode */ |
| 374 | union { |
| 375 | uint64_t (*filter)(void *interpreter_data, |
| 376 | const char *interpreter_stack_data); |
| 377 | uint64_t (*capture)(void *interpreter_data, |
| 378 | const char *interpreter_stack_data, |
| 379 | struct lttng_interpreter_output *interpreter_output); |
| 380 | } interpreter_funcs; |
| 381 | struct cds_list_head node; /* list of bytecode runtime in event */ |
| 382 | }; |
| 383 | |
| 384 | /* |
| 385 | * lttng_event structure is referred to by the tracing fast path. It |
| 386 | * must be kept small. |
| 387 | * |
| 388 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 389 | * UST. Fields need to be only added at the end, never reordered, never |
| 390 | * removed. |
| 391 | */ |
| 392 | |
| 393 | struct lttng_ust_event_common_private; |
| 394 | |
| 395 | enum lttng_ust_event_type { |
| 396 | LTTNG_UST_EVENT_TYPE_RECORDER = 0, |
| 397 | LTTNG_UST_EVENT_TYPE_NOTIFIER = 1, |
| 398 | }; |
| 399 | |
| 400 | /* |
| 401 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 402 | * UST. Fields need to be only added at the end, never reordered, never |
| 403 | * removed. |
| 404 | * |
| 405 | * struct lttng_ust_event_common is the common ancestor of the various |
| 406 | * public event actions. Inheritance is done by composition: The parent |
| 407 | * has a pointer to its child, and the child has a pointer to its |
| 408 | * parent. Inheritance of those public structures is done by composition |
| 409 | * to ensure both parent and child structures can be extended. |
| 410 | * |
| 411 | * The field @struct_size should be used to determine the size of the |
| 412 | * structure. It should be queried before using additional fields added |
| 413 | * at the end of the structure. |
| 414 | */ |
| 415 | struct lttng_ust_event_common { |
| 416 | uint32_t struct_size; /* Size of this structure. */ |
| 417 | struct lttng_ust_event_common_private *priv; /* Private event interface */ |
| 418 | |
| 419 | enum lttng_ust_event_type type; |
| 420 | void *child; /* Pointer to child, for inheritance by aggregation. */ |
| 421 | |
| 422 | int enabled; |
| 423 | int has_enablers_without_bytecode; |
| 424 | /* list of struct lttng_bytecode_runtime, sorted by seqnum */ |
| 425 | struct cds_list_head filter_bytecode_runtime_head; |
| 426 | |
| 427 | /* End of base ABI. Fields below should be used after checking struct_size. */ |
| 428 | }; |
| 429 | |
| 430 | struct lttng_ust_event_recorder_private; |
| 431 | |
| 432 | /* |
| 433 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 434 | * UST. Fields need to be only added at the end, never reordered, never |
| 435 | * removed. |
| 436 | * |
| 437 | * struct lttng_ust_event_recorder is the action for recording events |
| 438 | * into a ring buffer. It inherits from struct lttng_ust_event_common |
| 439 | * by composition to ensure both parent and child structure are |
| 440 | * extensible. |
| 441 | * |
| 442 | * The field @struct_size should be used to determine the size of the |
| 443 | * structure. It should be queried before using additional fields added |
| 444 | * at the end of the structure. |
| 445 | */ |
| 446 | struct lttng_ust_event_recorder { |
| 447 | uint32_t struct_size; /* Size of this structure. */ |
| 448 | struct lttng_ust_event_common *parent; /* Inheritance by aggregation. */ |
| 449 | struct lttng_ust_event_recorder_private *priv; /* Private event record interface */ |
| 450 | |
| 451 | unsigned int id; |
| 452 | struct lttng_channel *chan; |
| 453 | struct lttng_ctx *ctx; |
| 454 | |
| 455 | /* End of base ABI. Fields below should be used after checking struct_size. */ |
| 456 | }; |
| 457 | |
| 458 | struct lttng_ust_event_notifier_private; |
| 459 | |
| 460 | /* |
| 461 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 462 | * UST. Fields need to be only added at the end, never reordered, never |
| 463 | * removed. |
| 464 | * |
| 465 | * struct lttng_ust_event_notifier is the action for sending |
| 466 | * notifications. It inherits from struct lttng_ust_event_common |
| 467 | * by composition to ensure both parent and child structure are |
| 468 | * extensible. |
| 469 | * |
| 470 | * The field @struct_size should be used to determine the size of the |
| 471 | * structure. It should be queried before using additional fields added |
| 472 | * at the end of the structure. |
| 473 | */ |
| 474 | struct lttng_ust_event_notifier { |
| 475 | uint32_t struct_size; /* Size of this structure. */ |
| 476 | |
| 477 | struct lttng_ust_event_common *parent; /* Inheritance by aggregation. */ |
| 478 | struct lttng_ust_event_notifier_private *priv; /* Private event notifier interface */ |
| 479 | |
| 480 | void (*notification_send)(struct lttng_ust_event_notifier *event_notifier, |
| 481 | const char *stack_data); |
| 482 | struct cds_list_head capture_bytecode_runtime_head; |
| 483 | |
| 484 | /* End of base ABI. Fields below should be used after checking struct_size. */ |
| 485 | }; |
| 486 | |
| 487 | struct channel; |
| 488 | struct lttng_ust_shm_handle; |
| 489 | |
| 490 | /* |
| 491 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 492 | * UST. Fields need to be only added at the end, never reordered, never |
| 493 | * removed. |
| 494 | * |
| 495 | * The field @struct_size should be used to determine the size of the |
| 496 | * structure. It should be queried before using additional fields added |
| 497 | * at the end of the structure. |
| 498 | */ |
| 499 | struct lttng_ust_channel_ops { |
| 500 | uint32_t struct_size; |
| 501 | |
| 502 | struct lttng_channel *(*channel_create)(const char *name, |
| 503 | void *buf_addr, |
| 504 | size_t subbuf_size, size_t num_subbuf, |
| 505 | unsigned int switch_timer_interval, |
| 506 | unsigned int read_timer_interval, |
| 507 | unsigned char *uuid, |
| 508 | uint32_t chan_id, |
| 509 | const int *stream_fds, int nr_stream_fds, |
| 510 | int64_t blocking_timeout); |
| 511 | void (*channel_destroy)(struct lttng_channel *chan); |
| 512 | int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
| 513 | uint32_t event_id); |
| 514 | void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx); |
| 515 | void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
| 516 | const void *src, size_t len); |
| 517 | /* |
| 518 | * packet_avail_size returns the available size in the current |
| 519 | * packet. Note that the size returned is only a hint, since it |
| 520 | * may change due to concurrent writes. |
| 521 | */ |
| 522 | size_t (*packet_avail_size)(struct channel *chan, |
| 523 | struct lttng_ust_shm_handle *handle); |
| 524 | int (*is_finalized)(struct channel *chan); |
| 525 | int (*is_disabled)(struct channel *chan); |
| 526 | int (*flush_buffer)(struct channel *chan, struct lttng_ust_shm_handle *handle); |
| 527 | void (*event_strcpy)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
| 528 | const char *src, size_t len); |
| 529 | |
| 530 | /* End of base ABI. Fields below should be used after checking struct_size. */ |
| 531 | }; |
| 532 | |
| 533 | /* |
| 534 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 535 | * UST. Fields need to be only added at the end, never reordered, never |
| 536 | * removed. |
| 537 | */ |
| 538 | struct lttng_channel { |
| 539 | /* |
| 540 | * The pointers located in this private data are NOT safe to be |
| 541 | * dereferenced by the consumer. The only operations the |
| 542 | * consumer process is designed to be allowed to do is to read |
| 543 | * and perform subbuffer flush. |
| 544 | */ |
| 545 | struct channel *chan; /* Channel buffers */ |
| 546 | int enabled; |
| 547 | struct lttng_ctx *ctx; |
| 548 | /* Event ID management */ |
| 549 | struct lttng_session *session; |
| 550 | int objd; /* Object associated to channel */ |
| 551 | struct cds_list_head node; /* Channel list in session */ |
| 552 | const struct lttng_ust_channel_ops *ops; |
| 553 | int header_type; /* 0: unset, 1: compact, 2: large */ |
| 554 | struct lttng_ust_shm_handle *handle; /* shared-memory handle */ |
| 555 | |
| 556 | /* Channel ID */ |
| 557 | unsigned int id; |
| 558 | enum lttng_ust_abi_chan_type type; |
| 559 | unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ |
| 560 | int tstate:1; /* Transient enable state */ |
| 561 | }; |
| 562 | |
| 563 | #define LTTNG_UST_STACK_CTX_PADDING 32 |
| 564 | struct lttng_stack_ctx { |
| 565 | struct lttng_ust_event_recorder *event_recorder; |
| 566 | struct lttng_ctx *chan_ctx; /* RCU dereferenced. */ |
| 567 | struct lttng_ctx *event_ctx; /* RCU dereferenced. */ |
| 568 | char padding[LTTNG_UST_STACK_CTX_PADDING]; |
| 569 | }; |
| 570 | |
| 571 | #define LTTNG_UST_EVENT_HT_BITS 12 |
| 572 | #define LTTNG_UST_EVENT_HT_SIZE (1U << LTTNG_UST_EVENT_HT_BITS) |
| 573 | |
| 574 | struct lttng_ust_event_ht { |
| 575 | struct cds_hlist_head table[LTTNG_UST_EVENT_HT_SIZE]; |
| 576 | }; |
| 577 | |
| 578 | #define LTTNG_UST_EVENT_NOTIFIER_HT_BITS 12 |
| 579 | #define LTTNG_UST_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_UST_EVENT_NOTIFIER_HT_BITS) |
| 580 | struct lttng_ust_event_notifier_ht { |
| 581 | struct cds_hlist_head table[LTTNG_UST_EVENT_NOTIFIER_HT_SIZE]; |
| 582 | }; |
| 583 | |
| 584 | #define LTTNG_UST_ENUM_HT_BITS 12 |
| 585 | #define LTTNG_UST_ENUM_HT_SIZE (1U << LTTNG_UST_ENUM_HT_BITS) |
| 586 | |
| 587 | struct lttng_ust_enum_ht { |
| 588 | struct cds_hlist_head table[LTTNG_UST_ENUM_HT_SIZE]; |
| 589 | }; |
| 590 | |
| 591 | struct lttng_ust_session_private; |
| 592 | |
| 593 | /* |
| 594 | * IMPORTANT: this structure is part of the ABI between the probe and |
| 595 | * UST. Fields need to be only added at the end, never reordered, never |
| 596 | * removed. |
| 597 | * |
| 598 | * The field @struct_size should be used to determine the size of the |
| 599 | * structure. It should be queried before using additional fields added |
| 600 | * at the end of the structure. |
| 601 | */ |
| 602 | struct lttng_session { |
| 603 | uint32_t struct_size; /* Size of this structure */ |
| 604 | struct lttng_ust_session_private *priv; /* Private session interface */ |
| 605 | |
| 606 | int active; /* Is trace session active ? */ |
| 607 | |
| 608 | /* End of base ABI. Fields below should be used after checking struct_size. */ |
| 609 | }; |
| 610 | |
| 611 | int lttng_ust_probe_register(struct lttng_ust_probe_desc *desc); |
| 612 | void lttng_ust_probe_unregister(struct lttng_ust_probe_desc *desc); |
| 613 | |
| 614 | /* |
| 615 | * Can be used by applications that change their procname to clear the ust cached value. |
| 616 | */ |
| 617 | void lttng_context_procname_reset(void); |
| 618 | |
| 619 | struct lttng_transport *lttng_transport_find(const char *name); |
| 620 | |
| 621 | int lttng_session_active(void); |
| 622 | |
| 623 | void lttng_ust_dl_update(void *ip); |
| 624 | |
| 625 | #ifdef __cplusplus |
| 626 | } |
| 627 | #endif |
| 628 | |
| 629 | #endif /* _LTTNG_UST_EVENTS_H */ |