Remove leftover symbols from liburcu-bp compat
[lttng-ust.git] / include / lttng / ust-events.h
CommitLineData
8020ceb5 1/*
c0c0989a 2 * SPDX-License-Identifier: MIT
8020ceb5 3 *
c0c0989a 4 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8020ceb5
MD
5 *
6 * Holds LTTng per-session event registry.
8020ceb5
MD
7 */
8
c0c0989a
MJ
9#ifndef _LTTNG_UST_EVENTS_H
10#define _LTTNG_UST_EVENTS_H
11
9f3fdbc6 12#include <urcu/list.h>
1f18504e 13#include <urcu/hlist.h>
b4051ad8 14#include <stddef.h>
9f3fdbc6 15#include <stdint.h>
4318ae1b
MD
16#include <lttng/ust-abi.h>
17#include <lttng/ust-tracer.h>
2ae57758 18#include <lttng/ust-endian.h>
20f1eee7 19#include <float.h>
d58d1454
MD
20#include <errno.h>
21#include <urcu/ref.h>
22#include <pthread.h>
8020ceb5 23
db56acaf
MD
24#ifndef LTTNG_PACKED
25#error "LTTNG_PACKED should be defined"
26#endif
27
6453d237
MD
28#ifdef __cplusplus
29extern "C" {
30#endif
31
19d8b1b3
MD
32#define LTTNG_UST_UUID_LEN 16
33
71d31690
MD
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 */
04f0b55a 40#define LTTNG_UST_PROVIDER_MAJOR 2
71d31690
MD
41#define LTTNG_UST_PROVIDER_MINOR 0
42
7dd08bec
MD
43struct lttng_channel;
44struct lttng_session;
4cfec15c 45struct lttng_ust_lib_ring_buffer_ctx;
53569322
MD
46struct lttng_ust_context_app;
47struct lttng_event_field;
cab88ff8 48struct lttng_event_notifier;
ebabbf58 49struct lttng_event_notifier_group;
8020ceb5 50
37d5e202
MD
51/*
52 * Data structures used by tracepoint event declarations, and by the
53 * tracer. Those structures have padding for future extension.
54 */
55
c1fca457
MD
56/*
57 * LTTng client type enumeration. Used by the consumer to map the
58 * callbacks from its own address space.
59 */
60enum lttng_client_types {
61 LTTNG_CLIENT_METADATA = 0,
62 LTTNG_CLIENT_DISCARD = 1,
63 LTTNG_CLIENT_OVERWRITE = 2,
34a91bdb
MD
64 LTTNG_CLIENT_DISCARD_RT = 3,
65 LTTNG_CLIENT_OVERWRITE_RT = 4,
c1fca457
MD
66 LTTNG_NR_CLIENT_TYPES,
67};
68
8020ceb5
MD
69/* Type description */
70
71/* Update the astract_types name table in lttng-types.c along with this enum */
7dd08bec 72enum lttng_abstract_types {
8020ceb5 73 atype_integer,
218deb69
MD
74 atype_enum, /* legacy */
75 atype_array, /* legacy */
76 atype_sequence, /* legacy */
8020ceb5 77 atype_string,
20f1eee7 78 atype_float,
53569322 79 atype_dynamic,
218deb69
MD
80 atype_struct, /* legacy */
81 atype_enum_nestable,
82 atype_array_nestable,
83 atype_sequence_nestable,
84 atype_struct_nestable,
8020ceb5
MD
85 NR_ABSTRACT_TYPES,
86};
87
88/* Update the string_encodings name table in lttng-types.c along with this enum */
89enum lttng_string_encodings {
90 lttng_encode_none = 0,
91 lttng_encode_UTF8 = 1,
92 lttng_encode_ASCII = 2,
93 NR_STRING_ENCODINGS,
94};
95
a6f80644
MD
96struct lttng_enum_value {
97 unsigned long long value;
98 unsigned int signedness:1;
99};
100
3e762260
PP
101enum lttng_enum_entry_options {
102 LTTNG_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
103};
104
37d5e202 105#define LTTNG_UST_ENUM_ENTRY_PADDING 16
8020ceb5 106struct lttng_enum_entry {
a6f80644 107 struct lttng_enum_value start, end; /* start and end are inclusive */
8020ceb5 108 const char *string;
3e762260
PP
109 union {
110 struct {
111 unsigned int options;
112 } LTTNG_PACKED extra;
113 char padding[LTTNG_UST_ENUM_ENTRY_PADDING];
114 } u;
8020ceb5
MD
115};
116
117#define __type_integer(_type, _byte_order, _base, _encoding) \
118 { \
46d52200
ZT
119 .atype = atype_integer, \
120 .u = \
8020ceb5 121 { \
218deb69 122 .integer = \
46d52200 123 { \
218deb69
MD
124 .size = sizeof(_type) * CHAR_BIT, \
125 .alignment = lttng_alignof(_type) * CHAR_BIT, \
126 .signedness = lttng_is_signed_type(_type), \
127 .reverse_byte_order = _byte_order != BYTE_ORDER, \
128 .base = _base, \
129 .encoding = lttng_encode_##_encoding, \
46d52200 130 } \
8020ceb5
MD
131 }, \
132 } \
133
37d5e202 134#define LTTNG_UST_INTEGER_TYPE_PADDING 24
8020ceb5
MD
135struct lttng_integer_type {
136 unsigned int size; /* in bits */
137 unsigned short alignment; /* in bits */
138 unsigned int signedness:1;
139 unsigned int reverse_byte_order:1;
140 unsigned int base; /* 2, 8, 10, 16, for pretty print */
141 enum lttng_string_encodings encoding;
37d5e202 142 char padding[LTTNG_UST_INTEGER_TYPE_PADDING];
8020ceb5
MD
143};
144
d3ed854b
MD
145/*
146 * Only float and double are supported. long double is not supported at
147 * the moment.
148 */
20f1eee7
MD
149#define _float_mant_dig(_type) \
150 (sizeof(_type) == sizeof(float) ? FLT_MANT_DIG \
151 : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG \
d3ed854b 152 : 0))
20f1eee7
MD
153
154#define __type_float(_type) \
155 { \
46d52200
ZT
156 .atype = atype_float, \
157 .u = \
20f1eee7 158 { \
218deb69 159 ._float = \
46d52200 160 { \
218deb69
MD
161 .exp_dig = sizeof(_type) * CHAR_BIT \
162 - _float_mant_dig(_type), \
163 .mant_dig = _float_mant_dig(_type), \
164 .alignment = lttng_alignof(_type) * CHAR_BIT, \
165 .reverse_byte_order = BYTE_ORDER != FLOAT_WORD_ORDER, \
46d52200 166 } \
218deb69 167 } \
20f1eee7
MD
168 } \
169
37d5e202 170#define LTTNG_UST_FLOAT_TYPE_PADDING 24
20f1eee7
MD
171struct lttng_float_type {
172 unsigned int exp_dig; /* exponent digits, in bits */
173 unsigned int mant_dig; /* mantissa digits, in bits */
174 unsigned short alignment; /* in bits */
175 unsigned int reverse_byte_order:1;
37d5e202 176 char padding[LTTNG_UST_FLOAT_TYPE_PADDING];
20f1eee7
MD
177};
178
218deb69 179/* legacy */
37d5e202 180#define LTTNG_UST_BASIC_TYPE_PADDING 128
8020ceb5 181union _lttng_basic_type {
218deb69 182 struct lttng_integer_type integer; /* legacy */
8020ceb5 183 struct {
c785c634
MD
184 const struct lttng_enum_desc *desc; /* Enumeration mapping */
185 struct lttng_integer_type container_type;
218deb69 186 } enumeration; /* legacy */
8020ceb5
MD
187 struct {
188 enum lttng_string_encodings encoding;
218deb69
MD
189 } string; /* legacy */
190 struct lttng_float_type _float; /* legacy */
37d5e202 191 char padding[LTTNG_UST_BASIC_TYPE_PADDING];
8020ceb5
MD
192};
193
218deb69 194/* legacy */
8020ceb5 195struct lttng_basic_type {
7dd08bec 196 enum lttng_abstract_types atype;
8020ceb5
MD
197 union {
198 union _lttng_basic_type basic;
199 } u;
200};
201
37d5e202 202#define LTTNG_UST_TYPE_PADDING 128
8020ceb5 203struct lttng_type {
7dd08bec 204 enum lttng_abstract_types atype;
8020ceb5 205 union {
218deb69
MD
206 /* provider ABI 2.0 */
207 struct lttng_integer_type integer;
208 struct lttng_float_type _float;
209 struct {
210 enum lttng_string_encodings encoding;
211 } string;
212 struct {
213 const struct lttng_enum_desc *desc; /* Enumeration mapping */
214 struct lttng_type *container_type;
215 } enum_nestable;
8020ceb5 216 struct {
218deb69
MD
217 const struct lttng_type *elem_type;
218 unsigned int length; /* Num. elems. */
219 unsigned int alignment;
220 } array_nestable;
8020ceb5 221 struct {
218deb69
MD
222 const char *length_name; /* Length field name. */
223 const struct lttng_type *elem_type;
224 unsigned int alignment; /* Alignment before elements. */
225 } sequence_nestable;
53569322 226 struct {
218deb69
MD
227 unsigned int nr_fields;
228 const struct lttng_event_field *fields; /* Array of fields. */
229 unsigned int alignment;
230 } struct_nestable;
231
232 union {
233 /* legacy provider ABI 1.0 */
234 union _lttng_basic_type basic; /* legacy */
235 struct {
236 struct lttng_basic_type elem_type;
237 unsigned int length; /* Num. elems. */
238 } array; /* legacy */
239 struct {
240 struct lttng_basic_type length_type;
241 struct lttng_basic_type elem_type;
242 } sequence; /* legacy */
243 struct {
244 unsigned int nr_fields;
245 struct lttng_event_field *fields; /* Array of fields. */
246 } _struct; /* legacy */
247 } legacy;
37d5e202 248 char padding[LTTNG_UST_TYPE_PADDING];
8020ceb5
MD
249 } u;
250};
251
37d5e202 252#define LTTNG_UST_ENUM_TYPE_PADDING 24
c785c634 253struct lttng_enum_desc {
8020ceb5 254 const char *name;
8020ceb5 255 const struct lttng_enum_entry *entries;
c785c634 256 unsigned int nr_entries;
37d5e202 257 char padding[LTTNG_UST_ENUM_TYPE_PADDING];
8020ceb5
MD
258};
259
180901e6
MD
260/*
261 * Event field description
262 *
263 * IMPORTANT: this structure is part of the ABI between the probe and
264 * UST. Fields need to be only added at the end, never reordered, never
265 * removed.
266 */
8020ceb5 267
4774c8f3 268#define LTTNG_UST_EVENT_FIELD_PADDING 28
8020ceb5
MD
269struct lttng_event_field {
270 const char *name;
271 struct lttng_type type;
180901e6 272 unsigned int nowrite; /* do not write into trace */
218deb69
MD
273 union {
274 struct {
275 unsigned int nofilter:1; /* do not consider for filter */
276 } ext;
277 char padding[LTTNG_UST_EVENT_FIELD_PADDING];
278 } u;
8020ceb5
MD
279};
280
53569322
MD
281enum lttng_ust_dynamic_type {
282 LTTNG_UST_DYNAMIC_TYPE_NONE,
283 LTTNG_UST_DYNAMIC_TYPE_S8,
284 LTTNG_UST_DYNAMIC_TYPE_S16,
285 LTTNG_UST_DYNAMIC_TYPE_S32,
286 LTTNG_UST_DYNAMIC_TYPE_S64,
287 LTTNG_UST_DYNAMIC_TYPE_U8,
288 LTTNG_UST_DYNAMIC_TYPE_U16,
289 LTTNG_UST_DYNAMIC_TYPE_U32,
290 LTTNG_UST_DYNAMIC_TYPE_U64,
291 LTTNG_UST_DYNAMIC_TYPE_FLOAT,
292 LTTNG_UST_DYNAMIC_TYPE_DOUBLE,
293 LTTNG_UST_DYNAMIC_TYPE_STRING,
294 _NR_LTTNG_UST_DYNAMIC_TYPES,
295};
296
297struct lttng_ctx_value {
298 enum lttng_ust_dynamic_type sel;
299 union {
300 int64_t s64;
86133caf 301 uint64_t u64;
53569322
MD
302 const char *str;
303 double d;
304 } u;
77aa5901
MD
305};
306
d58d1454
MD
307struct lttng_perf_counter_field;
308
37d5e202 309#define LTTNG_UST_CTX_FIELD_PADDING 40
8020ceb5
MD
310struct lttng_ctx_field {
311 struct lttng_event_field event_field;
53569322 312 size_t (*get_size)(struct lttng_ctx_field *field, size_t offset);
8020ceb5 313 void (*record)(struct lttng_ctx_field *field,
4cfec15c 314 struct lttng_ust_lib_ring_buffer_ctx *ctx,
7dd08bec 315 struct lttng_channel *chan);
77aa5901 316 void (*get_value)(struct lttng_ctx_field *field,
53569322 317 struct lttng_ctx_value *value);
8020ceb5 318 union {
d58d1454 319 struct lttng_perf_counter_field *perf_counter;
37d5e202 320 char padding[LTTNG_UST_CTX_FIELD_PADDING];
8020ceb5
MD
321 } u;
322 void (*destroy)(struct lttng_ctx_field *field);
53569322 323 char *field_name; /* Has ownership, dynamically allocated. */
8020ceb5
MD
324};
325
b2cc986a 326#define LTTNG_UST_CTX_PADDING 20
8020ceb5
MD
327struct lttng_ctx {
328 struct lttng_ctx_field *fields;
329 unsigned int nr_fields;
330 unsigned int allocated_fields;
b2cc986a 331 unsigned int largest_align;
37d5e202
MD
332 char padding[LTTNG_UST_CTX_PADDING];
333};
334
335#define LTTNG_UST_EVENT_DESC_PADDING 40
336struct lttng_event_desc {
337 const char *name;
fbdeb5ec 338 void (*probe_callback)(void);
37d5e202
MD
339 const struct lttng_event_ctx *ctx; /* context */
340 const struct lttng_event_field *fields; /* event payload */
341 unsigned int nr_fields;
342 const int **loglevel;
68755429 343 const char *signature; /* Argument types/names received */
6ddc916d
MD
344 union {
345 struct {
346 const char **model_emf_uri;
d8d2416d 347 void (*event_notifier_callback)(void);
6ddc916d
MD
348 } ext;
349 char padding[LTTNG_UST_EVENT_DESC_PADDING];
350 } u;
37d5e202
MD
351};
352
71d31690 353#define LTTNG_UST_PROBE_DESC_PADDING 12
37d5e202
MD
354struct lttng_probe_desc {
355 const char *provider;
356 const struct lttng_event_desc **event_desc;
357 unsigned int nr_events;
358 struct cds_list_head head; /* chain registered probes */
6715d7d1
MD
359 struct cds_list_head lazy_init_head;
360 int lazy; /* lazy registration */
71d31690
MD
361 uint32_t major;
362 uint32_t minor;
37d5e202 363 char padding[LTTNG_UST_PROBE_DESC_PADDING];
8020ceb5
MD
364};
365
37d5e202
MD
366/* Data structures used by the tracer. */
367
e450e339
FD
368enum lttng_enabler_format_type {
369 LTTNG_ENABLER_FORMAT_STAR_GLOB,
370 LTTNG_ENABLER_FORMAT_EVENT,
e6c12e3d
MD
371};
372
373/*
e58095ef
MD
374 * Enabler field, within whatever object is enabling an event. Target of
375 * backward reference.
e6c12e3d 376 */
e58095ef 377struct lttng_enabler {
e450e339 378 enum lttng_enabler_format_type format_type;
e58095ef
MD
379
380 /* head list of struct lttng_ust_filter_bytecode_node */
381 struct cds_list_head filter_bytecode_head;
0f63324a
JI
382 /* head list of struct lttng_ust_excluder_node */
383 struct cds_list_head excluder_head;
e58095ef
MD
384
385 struct lttng_ust_event event_param;
e58095ef 386 unsigned int enabled:1;
e6c12e3d
MD
387};
388
c8fcf224
MD
389struct tp_list_entry {
390 struct lttng_ust_tracepoint_iter tp;
391 struct cds_list_head head;
392};
393
394struct lttng_ust_tracepoint_list {
395 struct tp_list_entry *iter;
396 struct cds_list_head head;
8020ceb5
MD
397};
398
06d4f27e
MD
399struct tp_field_list_entry {
400 struct lttng_ust_field_iter field;
401 struct cds_list_head head;
402};
403
404struct lttng_ust_field_list {
405 struct tp_field_list_entry *iter;
406 struct cds_list_head head;
407};
408
8165c8da 409struct ust_pending_probe;
7dd08bec 410struct lttng_event;
f488575f 411
8a92ed2a 412/*
04aa13f8 413 * Bytecode interpreter return value masks.
8a92ed2a 414 */
04aa13f8
FD
415enum lttng_bytecode_interpreter_ret {
416 LTTNG_INTERPRETER_DISCARD = 0,
417 LTTNG_INTERPRETER_RECORD_FLAG = (1ULL << 0),
8a92ed2a
MD
418 /* Other bits are kept for future use. */
419};
420
d37ecb3f
FD
421struct lttng_interpreter_output;
422
73d37531
FD
423/*
424 * This structure is used in the probes. More specifically, the `filter` and
425 * `node` fields are explicity used in the probes. When modifying this
426 * structure we must not change the layout of these two fields as it is
427 * considered ABI.
428 */
f488575f
MD
429struct lttng_bytecode_runtime {
430 /* Associated bytecode */
ab249ecf 431 struct lttng_ust_bytecode_node *bc;
c42416df
FD
432 union {
433 uint64_t (*filter)(void *interpreter_data,
434 const char *interpreter_stack_data);
d37ecb3f
FD
435 uint64_t (*capture)(void *interpreter_data,
436 const char *interpreter_stack_data,
437 struct lttng_interpreter_output *interpreter_output);
c42416df 438 } interpreter_funcs;
21af05a9 439 int link_failed;
e58095ef 440 struct cds_list_head node; /* list of bytecode runtime in event */
b77aaa1b 441 /*
d8d2416d
FD
442 * Pointer to a URCU-protected pointer owned by an `struct
443 * lttng_session`or `struct lttng_event_notifier_group`.
b77aaa1b
FD
444 */
445 struct lttng_ctx **pctx;
e58095ef
MD
446};
447
448/*
d8d2416d
FD
449 * Objects in a linked-list of enablers, owned by an event or event_notifier.
450 * This is used because an event (or a event_notifier) can be enabled by more
451 * than one enabler and we want a quick way to iterate over all enablers of an
452 * object.
453 *
454 * For example, event rules "my_app:a*" and "my_app:ab*" will both match the
455 * event with the name "my_app:abc".
e58095ef
MD
456 */
457struct lttng_enabler_ref {
458 struct cds_list_head node; /* enabler ref list */
459 struct lttng_enabler *ref; /* backward ref */
f488575f 460};
8165c8da 461
8020ceb5 462/*
7dd08bec
MD
463 * lttng_event structure is referred to by the tracing fast path. It
464 * must be kept small.
180901e6
MD
465 *
466 * IMPORTANT: this structure is part of the ABI between the probe and
467 * UST. Fields need to be only added at the end, never reordered, never
468 * removed.
8020ceb5 469 */
7dd08bec 470struct lttng_event {
8020ceb5 471 unsigned int id;
7dd08bec 472 struct lttng_channel *chan;
976fe9ea 473 int enabled;
8020ceb5 474 const struct lttng_event_desc *desc;
8020ceb5 475 struct lttng_ctx *ctx;
9f3fdbc6 476 enum lttng_ust_instrumentation instrumentation;
e58095ef 477 struct cds_list_head node; /* Event list in session */
e58095ef 478
e58095ef 479 /* list of struct lttng_bytecode_runtime, sorted by seqnum */
a56fd376 480 struct cds_list_head filter_bytecode_runtime_head;
dcdeaff0 481 int has_enablers_without_bytecode;
e58095ef
MD
482 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
483 struct cds_list_head enablers_ref_head;
d56fa719 484 struct cds_hlist_node hlist; /* session ht of events */
ac6b4ac6 485 int registered; /* has reg'd tracepoint probe */
8020ceb5
MD
486};
487
d8d2416d
FD
488struct lttng_event_notifier {
489 uint64_t user_token;
6566528b 490 uint64_t error_counter_index;
d8d2416d
FD
491 int enabled;
492 int registered; /* has reg'd tracepoint probe */
d37ecb3f 493 size_t num_captures; /* Needed to allocate the msgpack array. */
cab88ff8
MD
494 void (*notification_send)(struct lttng_event_notifier *event_notifier,
495 const char *stack_data);
d8d2416d 496 struct cds_list_head filter_bytecode_runtime_head;
d37ecb3f 497 struct cds_list_head capture_bytecode_runtime_head;
d8d2416d
FD
498 int has_enablers_without_bytecode;
499 struct cds_list_head enablers_ref_head;
500 const struct lttng_event_desc *desc;
501 struct cds_hlist_node hlist; /* hashtable of event_notifiers */
502 struct cds_list_head node; /* event_notifier list in session */
503 struct lttng_event_notifier_group *group; /* weak ref */
504};
505
c785c634
MD
506struct lttng_enum {
507 const struct lttng_enum_desc *desc;
508 struct lttng_session *session;
509 struct cds_list_head node; /* Enum list in session */
510 struct cds_hlist_node hlist; /* Session ht of enums */
511 uint64_t id; /* Enumeration ID in sessiond */
512};
513
8d8a24c8 514struct channel;
38fae1d3 515struct lttng_ust_shm_handle;
8d8a24c8 516
180901e6
MD
517/*
518 * IMPORTANT: this structure is part of the ABI between the probe and
519 * UST. Fields need to be only added at the end, never reordered, never
520 * removed.
521 */
7dd08bec
MD
522struct lttng_channel_ops {
523 struct lttng_channel *(*channel_create)(const char *name,
74d81a6c
MD
524 void *buf_addr,
525 size_t subbuf_size, size_t num_subbuf,
526 unsigned int switch_timer_interval,
527 unsigned int read_timer_interval,
6ca18e66 528 unsigned char *uuid,
a9ff648c 529 uint32_t chan_id,
b2c5f61a
MD
530 const int *stream_fds, int nr_stream_fds,
531 int64_t blocking_timeout);
74d81a6c 532 void (*channel_destroy)(struct lttng_channel *chan);
4cfec15c 533 int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
8020ceb5 534 uint32_t event_id);
4cfec15c 535 void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx);
74d81a6c
MD
536 void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
537 const void *src, size_t len);
8020ceb5
MD
538 /*
539 * packet_avail_size returns the available size in the current
540 * packet. Note that the size returned is only a hint, since it
541 * may change due to concurrent writes.
542 */
1d498196 543 size_t (*packet_avail_size)(struct channel *chan,
38fae1d3 544 struct lttng_ust_shm_handle *handle);
8020ceb5
MD
545 int (*is_finalized)(struct channel *chan);
546 int (*is_disabled)(struct channel *chan);
38fae1d3 547 int (*flush_buffer)(struct channel *chan, struct lttng_ust_shm_handle *handle);
a44c74d9
MD
548 void (*event_strcpy)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
549 const char *src, size_t len);
8020ceb5
MD
550};
551
180901e6
MD
552/*
553 * IMPORTANT: this structure is part of the ABI between the probe and
554 * UST. Fields need to be only added at the end, never reordered, never
555 * removed.
556 */
7dd08bec 557struct lttng_channel {
a3f61e7f
MD
558 /*
559 * The pointers located in this private data are NOT safe to be
560 * dereferenced by the consumer. The only operations the
561 * consumer process is designed to be allowed to do is to read
562 * and perform subbuffer flush.
563 */
8020ceb5 564 struct channel *chan; /* Channel buffers */
976fe9ea 565 int enabled;
8020ceb5
MD
566 struct lttng_ctx *ctx;
567 /* Event ID management */
7dd08bec 568 struct lttng_session *session;
0a42beb6 569 int objd; /* Object associated to channel */
e58095ef 570 struct cds_list_head node; /* Channel list in session */
74d81a6c 571 const struct lttng_channel_ops *ops;
8020ceb5 572 int header_type; /* 0: unset, 1: compact, 2: large */
38fae1d3 573 struct lttng_ust_shm_handle *handle; /* shared-memory handle */
a3f61e7f 574
74d81a6c 575 /* Channel ID */
a3f61e7f 576 unsigned int id;
74d81a6c 577 enum lttng_ust_chan_type type;
19d8b1b3 578 unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
ac6b4ac6 579 int tstate:1; /* Transient enable state */
8020ceb5
MD
580};
581
ebabbf58
MD
582#define LTTNG_COUNTER_DIMENSION_MAX 8
583
584struct lttng_counter_dimension {
585 uint64_t size;
586 uint64_t underflow_index;
587 uint64_t overflow_index;
588 uint8_t has_underflow;
589 uint8_t has_overflow;
590};
591
592struct lttng_counter_ops {
593 struct lib_counter *(*counter_create)(size_t nr_dimensions,
594 const struct lttng_counter_dimension *dimensions,
595 int64_t global_sum_step,
596 int global_counter_fd,
597 int nr_counter_cpu_fds,
598 const int *counter_cpu_fds,
599 bool is_daemon);
600 void (*counter_destroy)(struct lib_counter *counter);
601 int (*counter_add)(struct lib_counter *counter,
602 const size_t *dimension_indexes, int64_t v);
603 int (*counter_read)(struct lib_counter *counter,
604 const size_t *dimension_indexes, int cpu,
605 int64_t *value, bool *overflow, bool *underflow);
606 int (*counter_aggregate)(struct lib_counter *counter,
607 const size_t *dimension_indexes, int64_t *value,
608 bool *overflow, bool *underflow);
609 int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes);
610};
611
53569322
MD
612#define LTTNG_UST_STACK_CTX_PADDING 32
613struct lttng_stack_ctx {
614 struct lttng_event *event;
615 struct lttng_ctx *chan_ctx; /* RCU dereferenced. */
616 struct lttng_ctx *event_ctx; /* RCU dereferenced. */
617 char padding[LTTNG_UST_STACK_CTX_PADDING];
618};
619
71a9d034 620#define LTTNG_UST_EVENT_HT_BITS 12
e58095ef
MD
621#define LTTNG_UST_EVENT_HT_SIZE (1U << LTTNG_UST_EVENT_HT_BITS)
622
623struct lttng_ust_event_ht {
624 struct cds_hlist_head table[LTTNG_UST_EVENT_HT_SIZE];
625};
626
d8d2416d
FD
627#define LTTNG_UST_EVENT_NOTIFIER_HT_BITS 12
628#define LTTNG_UST_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_UST_EVENT_NOTIFIER_HT_BITS)
629struct lttng_ust_event_notifier_ht {
630 struct cds_hlist_head table[LTTNG_UST_EVENT_NOTIFIER_HT_SIZE];
631};
632
c785c634
MD
633#define LTTNG_UST_ENUM_HT_BITS 12
634#define LTTNG_UST_ENUM_HT_SIZE (1U << LTTNG_UST_ENUM_HT_BITS)
635
636struct lttng_ust_enum_ht {
637 struct cds_hlist_head table[LTTNG_UST_ENUM_HT_SIZE];
638};
639
180901e6
MD
640/*
641 * IMPORTANT: this structure is part of the ABI between the probe and
642 * UST. Fields need to be only added at the end, never reordered, never
643 * removed.
644 */
7dd08bec 645struct lttng_session {
e58095ef
MD
646 int active; /* Is trace session active ? */
647 int been_active; /* Been active ? */
648 int objd; /* Object associated */
e58095ef
MD
649 struct cds_list_head chan_head; /* Channel list head */
650 struct cds_list_head events_head; /* list of events */
e58095ef 651 struct cds_list_head node; /* Session list */
e58095ef
MD
652
653 /* New UST 2.1 */
654 /* List of enablers */
655 struct cds_list_head enablers_head;
d56fa719 656 struct lttng_ust_event_ht events_ht; /* ht of events */
32ce8569 657 void *owner; /* object owner */
ac6b4ac6 658 int tstate:1; /* Transient enable state */
246be17e
PW
659
660 /* New UST 2.4 */
661 int statedump_pending:1;
c785c634
MD
662
663 /* New UST 2.8 */
664 struct lttng_ust_enum_ht enums_ht; /* ht of enumerations */
665 struct cds_list_head enums_head;
53569322 666 struct lttng_ctx *ctx; /* contexts for filters. */
8020ceb5
MD
667};
668
ebabbf58
MD
669struct lttng_counter {
670 int objd;
671 struct lttng_event_notifier_group *event_notifier_group; /* owner */
672 struct lttng_counter_transport *transport;
673 struct lib_counter *counter;
674 struct lttng_counter_ops *ops;
675};
676
d8d2416d
FD
677struct lttng_event_notifier_group {
678 int objd;
679 void *owner;
680 int notification_fd;
681 struct cds_list_head node; /* Event notifier group handle list */
682 struct cds_list_head enablers_head;
683 struct cds_list_head event_notifiers_head; /* list of event_notifiers */
684 struct lttng_ust_event_notifier_ht event_notifiers_ht; /* hashtable of event_notifiers */
685 struct lttng_ctx *ctx; /* contexts for filters. */
ebabbf58
MD
686
687 struct lttng_counter *error_counter;
688 size_t error_counter_len;
d8d2416d
FD
689};
690
7dd08bec 691struct lttng_transport {
8020ceb5 692 char *name;
9f3fdbc6 693 struct cds_list_head node;
7dd08bec 694 struct lttng_channel_ops ops;
74d81a6c 695 const struct lttng_ust_lib_ring_buffer_config *client_config;
8020ceb5
MD
696};
697
ebabbf58
MD
698struct lttng_counter_transport {
699 char *name;
700 struct cds_list_head node;
701 struct lttng_counter_ops ops;
702 const struct lib_counter_config *client_config;
703};
704
7dd08bec
MD
705struct lttng_session *lttng_session_create(void);
706int lttng_session_enable(struct lttng_session *session);
707int lttng_session_disable(struct lttng_session *session);
710b8ee3 708int lttng_session_statedump(struct lttng_session *session);
7dd08bec 709void lttng_session_destroy(struct lttng_session *session);
8020ceb5 710
7dd08bec 711struct lttng_channel *lttng_channel_create(struct lttng_session *session,
8020ceb5
MD
712 const char *transport_name,
713 void *buf_addr,
714 size_t subbuf_size, size_t num_subbuf,
715 unsigned int switch_timer_interval,
193183fb 716 unsigned int read_timer_interval,
ef9ff354
MD
717 int **shm_fd, int **wait_fd,
718 uint64_t **memory_map_size,
7dd08bec 719 struct lttng_channel *chan_priv_init);
8020ceb5 720
7dd08bec
MD
721int lttng_channel_enable(struct lttng_channel *channel);
722int lttng_channel_disable(struct lttng_channel *channel);
e58095ef 723
e58095ef 724int lttng_attach_context(struct lttng_ust_context *context_param,
8e696cfa 725 union ust_args *uargs,
e58095ef 726 struct lttng_ctx **ctx, struct lttng_session *session);
7dd08bec
MD
727void lttng_transport_register(struct lttng_transport *transport);
728void lttng_transport_unregister(struct lttng_transport *transport);
8020ceb5 729
7dd08bec
MD
730int lttng_probe_register(struct lttng_probe_desc *desc);
731void lttng_probe_unregister(struct lttng_probe_desc *desc);
35ac38cb 732void lttng_probe_provider_unregister_events(struct lttng_probe_desc *desc);
5f733922 733int lttng_fix_pending_events(void);
7dd08bec
MD
734int lttng_probes_init(void);
735void lttng_probes_exit(void);
8173ec7c 736int lttng_find_context(struct lttng_ctx *ctx, const char *name);
77aa5901 737int lttng_get_context_index(struct lttng_ctx *ctx, const char *name);
8173ec7c 738struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p);
b2cc986a 739void lttng_context_update(struct lttng_ctx *ctx);
8173ec7c 740void lttng_remove_context_field(struct lttng_ctx **ctx_p,
8020ceb5
MD
741 struct lttng_ctx_field *field);
742void lttng_destroy_context(struct lttng_ctx *ctx);
3b402b40 743int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
c1ef86f0 744int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
8173ec7c 745int lttng_add_pthread_id_to_ctx(struct lttng_ctx **ctx);
4847e9bb 746int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
96f85541 747int lttng_add_ip_to_ctx(struct lttng_ctx **ctx);
c7ea8487 748int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx);
53569322 749int lttng_add_dyntest_to_ctx(struct lttng_ctx **ctx);
735bef47
MJ
750int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx);
751int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx);
752int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx);
753int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx);
754int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx);
755int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx);
756int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx);
fca2f191
MJ
757int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx);
758int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx);
759int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx);
760int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx);
761int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx);
762int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx);
a93bfc45 763void lttng_context_vtid_reset(void);
c1ef86f0 764void lttng_context_vpid_reset(void);
46228a6f 765void lttng_context_procname_reset(void);
735bef47
MJ
766void lttng_context_cgroup_ns_reset(void);
767void lttng_context_ipc_ns_reset(void);
768void lttng_context_mnt_ns_reset(void);
769void lttng_context_net_ns_reset(void);
770void lttng_context_pid_ns_reset(void);
771void lttng_context_user_ns_reset(void);
772void lttng_context_uts_ns_reset(void);
fca2f191
MJ
773void lttng_context_vuid_reset(void);
774void lttng_context_veuid_reset(void);
775void lttng_context_vsuid_reset(void);
776void lttng_context_vgid_reset(void);
777void lttng_context_vegid_reset(void);
778void lttng_context_vsgid_reset(void);
9f3fdbc6 779
d58d1454 780
7dd08bec 781struct lttng_transport *lttng_transport_find(const char *name);
c1fca457 782
7dd08bec
MD
783int lttng_probes_get_event_list(struct lttng_ust_tracepoint_list *list);
784void lttng_probes_prune_event_list(struct lttng_ust_tracepoint_list *list);
c8fcf224
MD
785struct lttng_ust_tracepoint_iter *
786 lttng_ust_tracepoint_list_get_iter_next(struct lttng_ust_tracepoint_list *list);
7dd08bec
MD
787int lttng_probes_get_field_list(struct lttng_ust_field_list *list);
788void lttng_probes_prune_field_list(struct lttng_ust_field_list *list);
06d4f27e
MD
789struct lttng_ust_field_iter *
790 lttng_ust_field_list_get_iter_next(struct lttng_ust_field_list *list);
c8fcf224 791
7dd08bec 792void lttng_free_event_filter_runtime(struct lttng_event *event);
e58095ef
MD
793
794struct cds_list_head *lttng_get_probe_list_head(void);
6715d7d1 795int lttng_session_active(void);
e6c12e3d 796
246be17e 797typedef int (*t_statedump_func_ptr)(struct lttng_session *session);
3327ac33 798void lttng_handle_pending_statedump(void *owner);
37dddb65 799struct cds_list_head *_lttng_get_sessions(void);
b33b46f7
FD
800
801struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
802 const struct lttng_enum_desc *enum_desc);
246be17e 803
97c7c238
MD
804void lttng_ust_dl_update(void *ip);
805
6453d237
MD
806#ifdef __cplusplus
807}
808#endif
809
51489cad 810#endif /* _LTTNG_UST_EVENTS_H */
This page took 0.079487 seconds and 4 git commands to generate.