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