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