Namespace enumeration structures/enum with lttng_ust_ prefix
[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 43struct lttng_channel;
f69fe5fb 44struct lttng_ust_session;
4cfec15c 45struct lttng_ust_lib_ring_buffer_ctx;
25cff019 46struct lttng_ust_event_field;
8020ceb5 47
37d5e202
MD
48/*
49 * Data structures used by tracepoint event declarations, and by the
a084756d 50 * tracer.
37d5e202
MD
51 */
52
8020ceb5
MD
53/* Type description */
54
a084756d
MD
55enum lttng_ust_type {
56 lttng_ust_type_integer,
57 lttng_ust_type_string,
58 lttng_ust_type_float,
59 lttng_ust_type_dynamic,
60 lttng_ust_type_enum,
61 lttng_ust_type_array,
62 lttng_ust_type_sequence,
63 lttng_ust_type_struct,
64 NR_LTTNG_UST_TYPE,
8020ceb5
MD
65};
66
a084756d
MD
67enum lttng_ust_string_encoding {
68 lttng_ust_string_encoding_none = 0,
69 lttng_ust_string_encoding_UTF8 = 1,
70 lttng_ust_string_encoding_ASCII = 2,
71 NR_LTTNG_UST_STRING_ENCODING,
8020ceb5
MD
72};
73
1a37a873 74struct lttng_ust_enum_value {
a6f80644
MD
75 unsigned long long value;
76 unsigned int signedness:1;
77};
78
1a37a873
MD
79enum lttng_ust_enum_entry_option {
80 LTTNG_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
3e762260
PP
81};
82
891d6b55
MD
83/*
84 * Enumeration entry description
85 *
86 * IMPORTANT: this structure is part of the ABI between the probe and
87 * UST. Fields need to be only added at the end, never reordered, never
88 * removed.
89 *
90 * The field @struct_size should be used to determine the size of the
91 * structure. It should be queried before using additional fields added
92 * at the end of the structure.
93 */
94
95struct lttng_ust_enum_entry {
96 uint32_t struct_size;
97
1a37a873 98 struct lttng_ust_enum_value start, end; /* start and end are inclusive */
8020ceb5 99 const char *string;
891d6b55
MD
100 unsigned int options;
101
102 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
103};
104
a084756d
MD
105/*
106 * struct lttng_ust_type_common is fixed-size. Its children inherits
107 * from it by embedding struct lttng_ust_type_common as its first field.
108 */
109struct lttng_ust_type_common {
110 enum lttng_ust_type type;
111};
112
113struct lttng_ust_type_integer {
114 struct lttng_ust_type_common parent;
115 uint32_t struct_size;
8020ceb5
MD
116 unsigned int size; /* in bits */
117 unsigned short alignment; /* in bits */
118 unsigned int signedness:1;
119 unsigned int reverse_byte_order:1;
120 unsigned int base; /* 2, 8, 10, 16, for pretty print */
a084756d
MD
121};
122
123#define lttng_ust_type_integer_define(_type, _byte_order, _base) \
124 ((struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_integer, { \
125 .parent = { \
126 .type = lttng_ust_type_integer, \
127 }, \
128 .struct_size = sizeof(struct lttng_ust_type_integer), \
129 .size = sizeof(_type) * CHAR_BIT, \
130 .alignment = lttng_alignof(_type) * CHAR_BIT, \
131 .signedness = lttng_is_signed_type(_type), \
132 .reverse_byte_order = _byte_order != BYTE_ORDER, \
133 .base = _base, \
134 }))
135
136struct lttng_ust_type_float {
137 struct lttng_ust_type_common parent;
138 uint32_t struct_size;
139 unsigned int exp_dig; /* exponent digits, in bits */
140 unsigned int mant_dig; /* mantissa digits, in bits */
141 unsigned short alignment; /* in bits */
142 unsigned int reverse_byte_order:1;
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 153
a084756d
MD
154#define lttng_ust_type_float_define(_type) \
155 ((struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_float, { \
156 .parent = { \
157 .type = lttng_ust_type_float, \
158 }, \
159 .struct_size = sizeof(struct lttng_ust_type_float), \
160 .exp_dig = sizeof(_type) * CHAR_BIT \
161 - _float_mant_dig(_type), \
162 .mant_dig = _float_mant_dig(_type), \
163 .alignment = lttng_alignof(_type) * CHAR_BIT, \
164 .reverse_byte_order = BYTE_ORDER != FLOAT_WORD_ORDER, \
165 }))
166
167
168struct lttng_ust_type_string {
169 struct lttng_ust_type_common parent;
170 uint32_t struct_size;
171 enum lttng_ust_string_encoding encoding;
20f1eee7
MD
172};
173
a084756d
MD
174struct lttng_ust_type_enum {
175 struct lttng_ust_type_common parent;
176 uint32_t struct_size;
177 struct lttng_ust_enum_desc *desc; /* Enumeration mapping */
178 struct lttng_ust_type_common *container_type;
179};
180
181struct lttng_ust_type_array {
182 struct lttng_ust_type_common parent;
183 uint32_t struct_size;
184 struct lttng_ust_type_common *elem_type;
185 unsigned int length; /* Num. elems. */
186 unsigned int alignment;
187 enum lttng_ust_string_encoding encoding;
188};
189
190struct lttng_ust_type_sequence {
191 struct lttng_ust_type_common parent;
192 uint32_t struct_size;
193 const char *length_name; /* Length field name. */
194 struct lttng_ust_type_common *elem_type;
195 unsigned int alignment; /* Alignment before elements. */
196 enum lttng_ust_string_encoding encoding;
197};
198
199struct lttng_ust_type_struct {
200 struct lttng_ust_type_common parent;
201 uint32_t struct_size;
202 unsigned int nr_fields;
203 struct lttng_ust_event_field **fields; /* Array of pointers to fields. */
204 unsigned int alignment;
8020ceb5
MD
205};
206
891d6b55
MD
207/*
208 * Enumeration description
209 *
210 * IMPORTANT: this structure is part of the ABI between the probe and
211 * UST. Fields need to be only added at the end, never reordered, never
212 * removed.
213 *
214 * The field @struct_size should be used to determine the size of the
215 * structure. It should be queried before using additional fields added
216 * at the end of the structure.
217 */
218
219struct lttng_ust_enum_desc {
220 uint32_t struct_size;
221
8020ceb5 222 const char *name;
a084756d 223 struct lttng_ust_enum_entry **entries;
c785c634 224 unsigned int nr_entries;
891d6b55
MD
225
226 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
227};
228
180901e6
MD
229/*
230 * Event field description
231 *
232 * IMPORTANT: this structure is part of the ABI between the probe and
233 * UST. Fields need to be only added at the end, never reordered, never
234 * removed.
25cff019
MD
235 *
236 * The field @struct_size should be used to determine the size of the
237 * structure. It should be queried before using additional fields added
238 * at the end of the structure.
180901e6 239 */
8020ceb5 240
25cff019
MD
241struct lttng_ust_event_field {
242 uint32_t struct_size;
243
8020ceb5 244 const char *name;
a084756d 245 struct lttng_ust_type_common *type;
25cff019
MD
246 unsigned int nowrite:1, /* do not write into trace */
247 nofilter:1; /* do not consider for filter */
248
249 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
250};
251
37d5e202 252
dc11f93f
MD
253/*
254 * IMPORTANT: this structure is part of the ABI between the probe and
255 * UST. Fields need to be only added at the end, never reordered, never
256 * removed.
257 *
258 * The field @struct_size should be used to determine the size of the
259 * structure. It should be queried before using additional fields added
260 * at the end of the structure.
261 */
262struct lttng_ust_event_desc {
263 uint32_t struct_size; /* Size of this structure. */
dc177d11 264
37d5e202 265 const char *name;
fbdeb5ec 266 void (*probe_callback)(void);
a084756d
MD
267 struct lttng_event_ctx *ctx; /* context */
268 struct lttng_ust_event_field **fields; /* event payload */
37d5e202
MD
269 unsigned int nr_fields;
270 const int **loglevel;
dc11f93f
MD
271 const char *signature; /* Argument types/names received */
272 const char **model_emf_uri;
273
274 /* End of base ABI. Fields below should be used after checking struct_size. */
37d5e202
MD
275};
276
dc11f93f
MD
277/*
278 * IMPORTANT: this structure is part of the ABI between the probe and
279 * UST. Fields need to be only added at the end, never reordered, never
280 * removed.
281 *
282 * The field @struct_size should be used to determine the size of the
283 * structure. It should be queried before using additional fields added
284 * at the end of the structure.
285 */
286struct lttng_ust_probe_desc {
287 uint32_t struct_size; /* Size of this structure. */
288
37d5e202 289 const char *provider;
a084756d 290 struct lttng_ust_event_desc **event_desc;
37d5e202
MD
291 unsigned int nr_events;
292 struct cds_list_head head; /* chain registered probes */
6715d7d1
MD
293 struct cds_list_head lazy_init_head;
294 int lazy; /* lazy registration */
71d31690
MD
295 uint32_t major;
296 uint32_t minor;
dc11f93f
MD
297
298 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
299};
300
37d5e202
MD
301/* Data structures used by the tracer. */
302
8a92ed2a 303/*
04aa13f8 304 * Bytecode interpreter return value masks.
8a92ed2a 305 */
04aa13f8
FD
306enum lttng_bytecode_interpreter_ret {
307 LTTNG_INTERPRETER_DISCARD = 0,
308 LTTNG_INTERPRETER_RECORD_FLAG = (1ULL << 0),
8a92ed2a
MD
309 /* Other bits are kept for future use. */
310};
311
d37ecb3f 312struct lttng_interpreter_output;
362a65de 313struct lttng_ust_bytecode_runtime_private;
d37ecb3f 314
73d37531 315/*
5469a374
MD
316 * IMPORTANT: this structure is part of the ABI between the probe and
317 * UST. Fields need to be only added at the end, never reordered, never
318 * removed.
319 *
320 * The field @struct_size should be used to determine the size of the
321 * structure. It should be queried before using additional fields added
322 * at the end of the structure.
73d37531 323 */
5469a374
MD
324struct lttng_ust_bytecode_runtime {
325 uint32_t struct_size; /* Size of this structure. */
362a65de 326
5469a374 327 struct lttng_ust_bytecode_runtime_private *priv;
f488575f 328 /* Associated bytecode */
c42416df
FD
329 union {
330 uint64_t (*filter)(void *interpreter_data,
331 const char *interpreter_stack_data);
d37ecb3f
FD
332 uint64_t (*capture)(void *interpreter_data,
333 const char *interpreter_stack_data,
334 struct lttng_interpreter_output *interpreter_output);
c42416df 335 } interpreter_funcs;
e58095ef 336 struct cds_list_head node; /* list of bytecode runtime in event */
5469a374
MD
337
338 /* End of base ABI. Fields below should be used after checking struct_size. */
e58095ef
MD
339};
340
8020ceb5 341/*
7dd08bec
MD
342 * lttng_event structure is referred to by the tracing fast path. It
343 * must be kept small.
180901e6
MD
344 *
345 * IMPORTANT: this structure is part of the ABI between the probe and
346 * UST. Fields need to be only added at the end, never reordered, never
347 * removed.
8020ceb5 348 */
68bb7559 349
daacdbfc 350struct lttng_ust_ctx;
80333dfa
MD
351struct lttng_ust_event_common_private;
352
808edfc8
MD
353enum lttng_ust_event_type {
354 LTTNG_UST_EVENT_TYPE_RECORDER = 0,
355 LTTNG_UST_EVENT_TYPE_NOTIFIER = 1,
356};
357
93cfd247 358/*
6d35572a
MD
359 * IMPORTANT: this structure is part of the ABI between the probe and
360 * UST. Fields need to be only added at the end, never reordered, never
361 * removed.
362 *
93cfd247
MD
363 * struct lttng_ust_event_common is the common ancestor of the various
364 * public event actions. Inheritance is done by composition: The parent
365 * has a pointer to its child, and the child has a pointer to its
366 * parent. Inheritance of those public structures is done by composition
367 * to ensure both parent and child structures can be extended.
368 *
369 * The field @struct_size should be used to determine the size of the
370 * structure. It should be queried before using additional fields added
371 * at the end of the structure.
372 */
7ee76145 373struct lttng_ust_event_common {
80333dfa 374 uint32_t struct_size; /* Size of this structure. */
dc177d11 375
80333dfa
MD
376 struct lttng_ust_event_common_private *priv; /* Private event interface */
377
808edfc8 378 enum lttng_ust_event_type type;
ba99fbe2
MD
379 void *child; /* Pointer to child, for inheritance by aggregation. */
380
80333dfa
MD
381 int enabled;
382 int has_enablers_without_bytecode;
5469a374 383 /* list of struct lttng_ust_bytecode_runtime, sorted by seqnum */
80333dfa 384 struct cds_list_head filter_bytecode_runtime_head;
93cfd247
MD
385
386 /* End of base ABI. Fields below should be used after checking struct_size. */
80333dfa
MD
387};
388
2e70391c 389struct lttng_ust_event_recorder_private;
68bb7559 390
93cfd247 391/*
6d35572a
MD
392 * IMPORTANT: this structure is part of the ABI between the probe and
393 * UST. Fields need to be only added at the end, never reordered, never
394 * removed.
395 *
93cfd247
MD
396 * struct lttng_ust_event_recorder is the action for recording events
397 * into a ring buffer. It inherits from struct lttng_ust_event_common
398 * by composition to ensure both parent and child structure are
399 * extensible.
400 *
401 * The field @struct_size should be used to determine the size of the
402 * structure. It should be queried before using additional fields added
403 * at the end of the structure.
404 */
2e70391c
MD
405struct lttng_ust_event_recorder {
406 uint32_t struct_size; /* Size of this structure. */
dc177d11 407
ba99fbe2 408 struct lttng_ust_event_common *parent; /* Inheritance by aggregation. */
2e70391c 409 struct lttng_ust_event_recorder_private *priv; /* Private event record interface */
68bb7559 410
8020ceb5 411 unsigned int id;
68bb7559 412 struct lttng_channel *chan;
daacdbfc 413 struct lttng_ust_ctx *ctx;
93cfd247
MD
414
415 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
416};
417
115db533
MD
418struct lttng_ust_event_notifier_private;
419
93cfd247 420/*
6d35572a
MD
421 * IMPORTANT: this structure is part of the ABI between the probe and
422 * UST. Fields need to be only added at the end, never reordered, never
423 * removed.
424 *
93cfd247
MD
425 * struct lttng_ust_event_notifier is the action for sending
426 * notifications. It inherits from struct lttng_ust_event_common
427 * by composition to ensure both parent and child structure are
428 * extensible.
429 *
430 * The field @struct_size should be used to determine the size of the
431 * structure. It should be queried before using additional fields added
432 * at the end of the structure.
433 */
d7d45c0d 434struct lttng_ust_event_notifier {
115db533 435 uint32_t struct_size; /* Size of this structure. */
105cf2eb 436
ba99fbe2 437 struct lttng_ust_event_common *parent; /* Inheritance by aggregation. */
115db533
MD
438 struct lttng_ust_event_notifier_private *priv; /* Private event notifier interface */
439
d7d45c0d 440 void (*notification_send)(struct lttng_ust_event_notifier *event_notifier,
cab88ff8 441 const char *stack_data);
d37ecb3f 442 struct cds_list_head capture_bytecode_runtime_head;
93cfd247
MD
443
444 /* End of base ABI. Fields below should be used after checking struct_size. */
d8d2416d
FD
445};
446
5198080d 447struct lttng_ust_lib_ring_buffer_channel;
38fae1d3 448struct lttng_ust_shm_handle;
a880bae5 449struct lttng_ust_channel_ops_private;
8d8a24c8 450
180901e6
MD
451/*
452 * IMPORTANT: this structure is part of the ABI between the probe and
453 * UST. Fields need to be only added at the end, never reordered, never
454 * removed.
49926dbd
MD
455 *
456 * The field @struct_size should be used to determine the size of the
457 * structure. It should be queried before using additional fields added
458 * at the end of the structure.
180901e6 459 */
49926dbd
MD
460struct lttng_ust_channel_ops {
461 uint32_t struct_size;
462
a880bae5
MD
463 struct lttng_ust_channel_ops_private *priv; /* Private channel ops interface */
464
4cfec15c 465 int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
8020ceb5 466 uint32_t event_id);
4cfec15c 467 void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx);
74d81a6c
MD
468 void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
469 const void *src, size_t len);
a44c74d9
MD
470 void (*event_strcpy)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
471 const char *src, size_t len);
49926dbd
MD
472
473 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
474};
475
180901e6
MD
476/*
477 * IMPORTANT: this structure is part of the ABI between the probe and
478 * UST. Fields need to be only added at the end, never reordered, never
479 * removed.
480 */
7dd08bec 481struct lttng_channel {
a3f61e7f
MD
482 /*
483 * The pointers located in this private data are NOT safe to be
484 * dereferenced by the consumer. The only operations the
485 * consumer process is designed to be allowed to do is to read
486 * and perform subbuffer flush.
487 */
5198080d 488 struct lttng_ust_lib_ring_buffer_channel *chan; /* Channel buffers */
976fe9ea 489 int enabled;
daacdbfc 490 struct lttng_ust_ctx *ctx;
8020ceb5 491 /* Event ID management */
f69fe5fb 492 struct lttng_ust_session *session;
0a42beb6 493 int objd; /* Object associated to channel */
e58095ef 494 struct cds_list_head node; /* Channel list in session */
a084756d 495 struct lttng_ust_channel_ops *ops;
8020ceb5 496 int header_type; /* 0: unset, 1: compact, 2: large */
38fae1d3 497 struct lttng_ust_shm_handle *handle; /* shared-memory handle */
a3f61e7f 498
74d81a6c 499 /* Channel ID */
a3f61e7f 500 unsigned int id;
fd17d7ce 501 enum lttng_ust_abi_chan_type type;
19d8b1b3 502 unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
ac6b4ac6 503 int tstate:1; /* Transient enable state */
8020ceb5
MD
504};
505
2a9d9339
MD
506/*
507 * IMPORTANT: this structure is part of the ABI between the probe and
508 * UST. Fields need to be only added at the end, never reordered, never
509 * removed.
510 *
511 * The field @struct_size should be used to determine the size of the
512 * structure. It should be queried before using additional fields added
513 * at the end of the structure.
514 */
515struct lttng_ust_stack_ctx {
516 uint32_t struct_size; /* Size of this structure */
517
2e70391c 518 struct lttng_ust_event_recorder *event_recorder;
daacdbfc
MD
519 struct lttng_ust_ctx *chan_ctx; /* RCU dereferenced. */
520 struct lttng_ust_ctx *event_ctx; /* RCU dereferenced. */
2a9d9339
MD
521
522 /* End of base ABI. Fields below should be used after checking struct_size. */
53569322
MD
523};
524
bdb12629
MD
525struct lttng_ust_session_private;
526
180901e6
MD
527/*
528 * IMPORTANT: this structure is part of the ABI between the probe and
529 * UST. Fields need to be only added at the end, never reordered, never
530 * removed.
6d35572a
MD
531 *
532 * The field @struct_size should be used to determine the size of the
533 * structure. It should be queried before using additional fields added
534 * at the end of the structure.
180901e6 535 */
f69fe5fb 536struct lttng_ust_session {
bd640d74 537 uint32_t struct_size; /* Size of this structure */
dc177d11 538
bdb12629
MD
539 struct lttng_ust_session_private *priv; /* Private session interface */
540
e58095ef 541 int active; /* Is trace session active ? */
6d35572a
MD
542
543 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
544};
545
dc11f93f
MD
546int lttng_ust_probe_register(struct lttng_ust_probe_desc *desc);
547void lttng_ust_probe_unregister(struct lttng_ust_probe_desc *desc);
9f3fdbc6 548
fc80554e 549/*
0af0bdb2
MJ
550 * Applications that change their procname and need the new value to be
551 * reflected in the procname event context have to call this function to clear
552 * the internally cached value. This should not be called from a signal
553 * handler.
fc80554e 554 */
0af0bdb2 555void lttng_ust_context_procname_reset(void);
d58d1454 556
6453d237
MD
557#ifdef __cplusplus
558}
559#endif
560
51489cad 561#endif /* _LTTNG_UST_EVENTS_H */
This page took 0.071907 seconds and 4 git commands to generate.