Add 'ctf_unused' tracepoint field type
[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>
9af5d97a 23#include <limits.h>
8020ceb5 24
6453d237
MD
25#ifdef __cplusplus
26extern "C" {
27#endif
28
19d8b1b3
MD
29#define LTTNG_UST_UUID_LEN 16
30
71d31690
MD
31/*
32 * Tracepoint provider version. Compatibility based on the major number.
33 * Older tracepoint providers can always register to newer lttng-ust
34 * library, but the opposite is rejected: a newer tracepoint provider is
35 * rejected by an older lttng-ust library.
36 */
04f0b55a 37#define LTTNG_UST_PROVIDER_MAJOR 2
71d31690
MD
38#define LTTNG_UST_PROVIDER_MINOR 0
39
e7bc0ef6 40struct lttng_ust_channel_buffer;
f69fe5fb 41struct lttng_ust_session;
4cfec15c 42struct lttng_ust_lib_ring_buffer_ctx;
25cff019 43struct lttng_ust_event_field;
8020ceb5 44
37d5e202
MD
45/*
46 * Data structures used by tracepoint event declarations, and by the
a084756d 47 * tracer.
37d5e202
MD
48 */
49
8020ceb5
MD
50/* Type description */
51
a084756d
MD
52enum lttng_ust_type {
53 lttng_ust_type_integer,
54 lttng_ust_type_string,
55 lttng_ust_type_float,
56 lttng_ust_type_dynamic,
57 lttng_ust_type_enum,
58 lttng_ust_type_array,
59 lttng_ust_type_sequence,
60 lttng_ust_type_struct,
61 NR_LTTNG_UST_TYPE,
8020ceb5
MD
62};
63
a084756d
MD
64enum lttng_ust_string_encoding {
65 lttng_ust_string_encoding_none = 0,
66 lttng_ust_string_encoding_UTF8 = 1,
67 lttng_ust_string_encoding_ASCII = 2,
68 NR_LTTNG_UST_STRING_ENCODING,
8020ceb5
MD
69};
70
1a37a873 71struct lttng_ust_enum_value {
a6f80644
MD
72 unsigned long long value;
73 unsigned int signedness:1;
74};
75
1a37a873
MD
76enum lttng_ust_enum_entry_option {
77 LTTNG_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
3e762260
PP
78};
79
891d6b55
MD
80/*
81 * Enumeration entry description
82 *
83 * IMPORTANT: this structure is part of the ABI between the probe and
84 * UST. Fields need to be only added at the end, never reordered, never
85 * removed.
86 *
87 * The field @struct_size should be used to determine the size of the
88 * structure. It should be queried before using additional fields added
89 * at the end of the structure.
90 */
91
92struct lttng_ust_enum_entry {
93 uint32_t struct_size;
94
1a37a873 95 struct lttng_ust_enum_value start, end; /* start and end are inclusive */
8020ceb5 96 const char *string;
891d6b55
MD
97 unsigned int options;
98
99 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
100};
101
a084756d
MD
102/*
103 * struct lttng_ust_type_common is fixed-size. Its children inherits
104 * from it by embedding struct lttng_ust_type_common as its first field.
105 */
106struct lttng_ust_type_common {
107 enum lttng_ust_type type;
108};
109
110struct lttng_ust_type_integer {
111 struct lttng_ust_type_common parent;
112 uint32_t struct_size;
8020ceb5
MD
113 unsigned int size; /* in bits */
114 unsigned short alignment; /* in bits */
115 unsigned int signedness:1;
116 unsigned int reverse_byte_order:1;
117 unsigned int base; /* 2, 8, 10, 16, for pretty print */
a084756d
MD
118};
119
120#define lttng_ust_type_integer_define(_type, _byte_order, _base) \
121 ((struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_integer, { \
122 .parent = { \
123 .type = lttng_ust_type_integer, \
124 }, \
125 .struct_size = sizeof(struct lttng_ust_type_integer), \
126 .size = sizeof(_type) * CHAR_BIT, \
dc325c1d 127 .alignment = lttng_ust_rb_alignof(_type) * CHAR_BIT, \
eae3c729 128 .signedness = lttng_ust_is_signed_type(_type), \
a084756d
MD
129 .reverse_byte_order = _byte_order != BYTE_ORDER, \
130 .base = _base, \
131 }))
132
133struct lttng_ust_type_float {
134 struct lttng_ust_type_common parent;
135 uint32_t struct_size;
136 unsigned int exp_dig; /* exponent digits, in bits */
137 unsigned int mant_dig; /* mantissa digits, in bits */
138 unsigned short alignment; /* in bits */
139 unsigned int reverse_byte_order:1;
8020ceb5
MD
140};
141
d3ed854b
MD
142/*
143 * Only float and double are supported. long double is not supported at
144 * the moment.
145 */
89080a49 146#define lttng_ust_float_mant_dig(_type) \
20f1eee7
MD
147 (sizeof(_type) == sizeof(float) ? FLT_MANT_DIG \
148 : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG \
d3ed854b 149 : 0))
20f1eee7 150
a084756d
MD
151#define lttng_ust_type_float_define(_type) \
152 ((struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_float, { \
153 .parent = { \
154 .type = lttng_ust_type_float, \
155 }, \
156 .struct_size = sizeof(struct lttng_ust_type_float), \
157 .exp_dig = sizeof(_type) * CHAR_BIT \
89080a49
MD
158 - lttng_ust_float_mant_dig(_type), \
159 .mant_dig = lttng_ust_float_mant_dig(_type), \
dc325c1d 160 .alignment = lttng_ust_rb_alignof(_type) * CHAR_BIT, \
a084756d
MD
161 .reverse_byte_order = BYTE_ORDER != FLOAT_WORD_ORDER, \
162 }))
163
164
165struct lttng_ust_type_string {
166 struct lttng_ust_type_common parent;
167 uint32_t struct_size;
168 enum lttng_ust_string_encoding encoding;
20f1eee7
MD
169};
170
a084756d
MD
171struct lttng_ust_type_enum {
172 struct lttng_ust_type_common parent;
173 uint32_t struct_size;
174 struct lttng_ust_enum_desc *desc; /* Enumeration mapping */
175 struct lttng_ust_type_common *container_type;
176};
177
178struct lttng_ust_type_array {
179 struct lttng_ust_type_common parent;
180 uint32_t struct_size;
181 struct lttng_ust_type_common *elem_type;
182 unsigned int length; /* Num. elems. */
183 unsigned int alignment;
184 enum lttng_ust_string_encoding encoding;
185};
186
187struct lttng_ust_type_sequence {
188 struct lttng_ust_type_common parent;
189 uint32_t struct_size;
190 const char *length_name; /* Length field name. */
191 struct lttng_ust_type_common *elem_type;
192 unsigned int alignment; /* Alignment before elements. */
193 enum lttng_ust_string_encoding encoding;
194};
195
196struct lttng_ust_type_struct {
197 struct lttng_ust_type_common parent;
198 uint32_t struct_size;
199 unsigned int nr_fields;
200 struct lttng_ust_event_field **fields; /* Array of pointers to fields. */
201 unsigned int alignment;
8020ceb5
MD
202};
203
891d6b55
MD
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
216struct lttng_ust_enum_desc {
217 uint32_t struct_size;
218
8020ceb5 219 const char *name;
a084756d 220 struct lttng_ust_enum_entry **entries;
c785c634 221 unsigned int nr_entries;
891d6b55
MD
222
223 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
224};
225
180901e6
MD
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.
25cff019
MD
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.
180901e6 236 */
8020ceb5 237
25cff019
MD
238struct lttng_ust_event_field {
239 uint32_t struct_size;
240
8020ceb5 241 const char *name;
a084756d 242 struct lttng_ust_type_common *type;
25cff019
MD
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. */
8020ceb5
MD
247};
248
37d5e202 249
dc11f93f
MD
250/*
251 * IMPORTANT: this structure is part of the ABI between the probe and
252 * UST. Fields need to be only added at the end, never reordered, never
253 * removed.
254 *
255 * The field @struct_size should be used to determine the size of the
256 * structure. It should be queried before using additional fields added
257 * at the end of the structure.
258 */
259struct lttng_ust_event_desc {
260 uint32_t struct_size; /* Size of this structure. */
dc177d11 261
5b4c6da4
MD
262 const char *event_name;
263 struct lttng_ust_probe_desc *probe_desc;
fbdeb5ec 264 void (*probe_callback)(void);
a084756d
MD
265 struct lttng_event_ctx *ctx; /* context */
266 struct lttng_ust_event_field **fields; /* event payload */
37d5e202
MD
267 unsigned int nr_fields;
268 const int **loglevel;
dc11f93f
MD
269 const char *signature; /* Argument types/names received */
270 const char **model_emf_uri;
271
272 /* End of base ABI. Fields below should be used after checking struct_size. */
37d5e202
MD
273};
274
dc11f93f
MD
275/*
276 * IMPORTANT: this structure is part of the ABI between the probe and
277 * UST. Fields need to be only added at the end, never reordered, never
278 * removed.
279 *
280 * The field @struct_size should be used to determine the size of the
281 * structure. It should be queried before using additional fields added
282 * at the end of the structure.
283 */
284struct lttng_ust_probe_desc {
285 uint32_t struct_size; /* Size of this structure. */
286
5b4c6da4 287 const char *provider_name;
a084756d 288 struct lttng_ust_event_desc **event_desc;
37d5e202
MD
289 unsigned int nr_events;
290 struct cds_list_head head; /* chain registered probes */
6715d7d1
MD
291 struct cds_list_head lazy_init_head;
292 int lazy; /* lazy registration */
71d31690
MD
293 uint32_t major;
294 uint32_t minor;
dc11f93f
MD
295
296 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
297};
298
37d5e202
MD
299/* Data structures used by the tracer. */
300
8020ceb5 301/*
7dd08bec
MD
302 * lttng_event structure is referred to by the tracing fast path. It
303 * must be kept small.
180901e6
MD
304 *
305 * IMPORTANT: this structure is part of the ABI between the probe and
306 * UST. Fields need to be only added at the end, never reordered, never
307 * removed.
8020ceb5 308 */
68bb7559 309
daacdbfc 310struct lttng_ust_ctx;
80333dfa
MD
311struct lttng_ust_event_common_private;
312
808edfc8
MD
313enum lttng_ust_event_type {
314 LTTNG_UST_EVENT_TYPE_RECORDER = 0,
315 LTTNG_UST_EVENT_TYPE_NOTIFIER = 1,
316};
317
a2e4d05e
MD
318/*
319 * Result of the run_filter() callback.
320 */
321enum lttng_ust_event_filter_result {
322 LTTNG_UST_EVENT_FILTER_ACCEPT = 0,
323 LTTNG_UST_EVENT_FILTER_REJECT = 1,
324};
325
93cfd247 326/*
6d35572a
MD
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 *
93cfd247
MD
331 * struct lttng_ust_event_common is the common ancestor of the various
332 * public event actions. Inheritance is done by composition: The parent
333 * has a pointer to its child, and the child has a pointer to its
334 * parent. Inheritance of those public structures is done by composition
335 * to ensure both parent and child structures can be extended.
336 *
337 * The field @struct_size should be used to determine the size of the
338 * structure. It should be queried before using additional fields added
339 * at the end of the structure.
340 */
7ee76145 341struct lttng_ust_event_common {
80333dfa 342 uint32_t struct_size; /* Size of this structure. */
dc177d11 343
80333dfa
MD
344 struct lttng_ust_event_common_private *priv; /* Private event interface */
345
808edfc8 346 enum lttng_ust_event_type type;
ba99fbe2
MD
347 void *child; /* Pointer to child, for inheritance by aggregation. */
348
80333dfa 349 int enabled;
a2e4d05e
MD
350 int eval_filter; /* Need to evaluate filters */
351 int (*run_filter)(struct lttng_ust_event_common *event,
352 const char *stack_data,
353 void *filter_ctx);
93cfd247
MD
354
355 /* End of base ABI. Fields below should be used after checking struct_size. */
80333dfa
MD
356};
357
2e70391c 358struct lttng_ust_event_recorder_private;
68bb7559 359
93cfd247 360/*
6d35572a
MD
361 * IMPORTANT: this structure is part of the ABI between the probe and
362 * UST. Fields need to be only added at the end, never reordered, never
363 * removed.
364 *
93cfd247
MD
365 * struct lttng_ust_event_recorder is the action for recording events
366 * into a ring buffer. It inherits from struct lttng_ust_event_common
367 * by composition to ensure both parent and child structure are
368 * extensible.
369 *
370 * The field @struct_size should be used to determine the size of the
371 * structure. It should be queried before using additional fields added
372 * at the end of the structure.
373 */
2e70391c
MD
374struct lttng_ust_event_recorder {
375 uint32_t struct_size; /* Size of this structure. */
dc177d11 376
ba99fbe2 377 struct lttng_ust_event_common *parent; /* Inheritance by aggregation. */
2e70391c 378 struct lttng_ust_event_recorder_private *priv; /* Private event record interface */
68bb7559 379
e7bc0ef6 380 struct lttng_ust_channel_buffer *chan;
93cfd247
MD
381
382 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
383};
384
a2e4d05e
MD
385/*
386 * IMPORTANT: this structure is part of the ABI between the probe and
387 * UST. Fields need to be only added at the end, never reordered, never
388 * removed.
389 *
390 * The field @struct_size should be used to determine the size of the
391 * structure. It should be queried before using additional fields added
392 * at the end of the structure.
393 */
394struct lttng_ust_notification_ctx {
395 uint32_t struct_size; /* Size of this structure. */
396 int eval_capture; /* Capture evaluation available. */
397
398 /* End of base ABI. Fields below should be used after checking struct_size. */
399};
400
115db533
MD
401struct lttng_ust_event_notifier_private;
402
93cfd247 403/*
6d35572a
MD
404 * IMPORTANT: this structure is part of the ABI between the probe and
405 * UST. Fields need to be only added at the end, never reordered, never
406 * removed.
407 *
93cfd247
MD
408 * struct lttng_ust_event_notifier is the action for sending
409 * notifications. It inherits from struct lttng_ust_event_common
410 * by composition to ensure both parent and child structure are
411 * extensible.
412 *
413 * The field @struct_size should be used to determine the size of the
414 * structure. It should be queried before using additional fields added
415 * at the end of the structure.
416 */
d7d45c0d 417struct lttng_ust_event_notifier {
115db533 418 uint32_t struct_size; /* Size of this structure. */
105cf2eb 419
ba99fbe2 420 struct lttng_ust_event_common *parent; /* Inheritance by aggregation. */
115db533
MD
421 struct lttng_ust_event_notifier_private *priv; /* Private event notifier interface */
422
a2e4d05e 423 int eval_capture; /* Need to evaluate capture */
d7d45c0d 424 void (*notification_send)(struct lttng_ust_event_notifier *event_notifier,
a2e4d05e
MD
425 const char *stack_data,
426 struct lttng_ust_notification_ctx *notif_ctx);
93cfd247
MD
427
428 /* End of base ABI. Fields below should be used after checking struct_size. */
d8d2416d
FD
429};
430
5198080d 431struct lttng_ust_lib_ring_buffer_channel;
14b6f891 432struct lttng_ust_channel_buffer_ops_private;
8d8a24c8 433
180901e6
MD
434/*
435 * IMPORTANT: this structure is part of the ABI between the probe and
436 * UST. Fields need to be only added at the end, never reordered, never
437 * removed.
49926dbd
MD
438 *
439 * The field @struct_size should be used to determine the size of the
440 * structure. It should be queried before using additional fields added
441 * at the end of the structure.
180901e6 442 */
14b6f891 443struct lttng_ust_channel_buffer_ops {
49926dbd
MD
444 uint32_t struct_size;
445
14b6f891 446 struct lttng_ust_channel_buffer_ops_private *priv; /* Private channel buffer ops interface */
a880bae5 447
8936b6c0 448 int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx);
4cfec15c 449 void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx);
74d81a6c 450 void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
8936b6c0 451 const void *src, size_t len, size_t alignment);
a44c74d9
MD
452 void (*event_strcpy)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
453 const char *src, size_t len);
879f9b0a 454 void (*event_pstrcpy_pad)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
27927814 455 const char *src, size_t len);
49926dbd
MD
456
457 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
458};
459
e7bc0ef6
MD
460enum lttng_ust_channel_type {
461 LTTNG_UST_CHANNEL_TYPE_BUFFER = 0,
462};
463
464struct lttng_ust_channel_common_private;
465
180901e6
MD
466/*
467 * IMPORTANT: this structure is part of the ABI between the probe and
468 * UST. Fields need to be only added at the end, never reordered, never
469 * removed.
e7bc0ef6
MD
470 *
471 * The field @struct_size should be used to determine the size of the
472 * structure. It should be queried before using additional fields added
473 * at the end of the structure.
180901e6 474 */
e7bc0ef6
MD
475struct lttng_ust_channel_common {
476 uint32_t struct_size; /* Size of this structure. */
477
478 struct lttng_ust_channel_common_private *priv; /* Private channel interface */
479
480 enum lttng_ust_channel_type type;
481 void *child; /* Pointer to child, for inheritance by aggregation. */
482
976fe9ea 483 int enabled;
f69fe5fb 484 struct lttng_ust_session *session;
e7bc0ef6
MD
485
486 /* End of base ABI. Fields below should be used after checking struct_size. */
487};
488
489struct lttng_ust_channel_buffer_private;
490
491/*
492 * IMPORTANT: this structure is part of the ABI between the probe and
493 * UST. Fields need to be only added at the end, never reordered, never
494 * removed.
495 *
496 * The field @struct_size should be used to determine the size of the
497 * structure. It should be queried before using additional fields added
498 * at the end of the structure.
499 */
500struct lttng_ust_channel_buffer {
501 uint32_t struct_size; /* Size of this structure. */
502
503 struct lttng_ust_channel_common *parent; /* Inheritance by aggregation. */
504 struct lttng_ust_channel_buffer_private *priv; /* Private channel buffer interface */
505
14b6f891 506 struct lttng_ust_channel_buffer_ops *ops;
a3f61e7f 507
e7bc0ef6 508 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
509};
510
2a9d9339
MD
511/*
512 * IMPORTANT: this structure is part of the ABI between the probe and
513 * UST. Fields need to be only added at the end, never reordered, never
514 * removed.
515 *
516 * The field @struct_size should be used to determine the size of the
517 * structure. It should be queried before using additional fields added
518 * at the end of the structure.
519 */
520struct lttng_ust_stack_ctx {
521 uint32_t struct_size; /* Size of this structure */
522
2e70391c 523 struct lttng_ust_event_recorder *event_recorder;
2a9d9339
MD
524
525 /* End of base ABI. Fields below should be used after checking struct_size. */
53569322
MD
526};
527
bdb12629
MD
528struct lttng_ust_session_private;
529
180901e6
MD
530/*
531 * IMPORTANT: this structure is part of the ABI between the probe and
532 * UST. Fields need to be only added at the end, never reordered, never
533 * removed.
6d35572a
MD
534 *
535 * The field @struct_size should be used to determine the size of the
536 * structure. It should be queried before using additional fields added
537 * at the end of the structure.
180901e6 538 */
f69fe5fb 539struct lttng_ust_session {
bd640d74 540 uint32_t struct_size; /* Size of this structure */
dc177d11 541
bdb12629
MD
542 struct lttng_ust_session_private *priv; /* Private session interface */
543
e58095ef 544 int active; /* Is trace session active ? */
6d35572a
MD
545
546 /* End of base ABI. Fields below should be used after checking struct_size. */
8020ceb5
MD
547};
548
dc11f93f
MD
549int lttng_ust_probe_register(struct lttng_ust_probe_desc *desc);
550void lttng_ust_probe_unregister(struct lttng_ust_probe_desc *desc);
9f3fdbc6 551
fc80554e 552/*
0af0bdb2
MJ
553 * Applications that change their procname and need the new value to be
554 * reflected in the procname event context have to call this function to clear
555 * the internally cached value. This should not be called from a signal
556 * handler.
fc80554e 557 */
0af0bdb2 558void lttng_ust_context_procname_reset(void);
d58d1454 559
6453d237
MD
560#ifdef __cplusplus
561}
562#endif
563
51489cad 564#endif /* _LTTNG_UST_EVENTS_H */
This page took 0.072994 seconds and 4 git commands to generate.