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