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