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