Remove runtime dependency on liburcu shared objects
[lttng-ust.git] / include / lttng / ust-events.h
1 #ifndef _LTTNG_UST_EVENTS_H
2 #define _LTTNG_UST_EVENTS_H
3
4 /*
5 * lttng/ust-events.h
6 *
7 * Copyright 2010-2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * Holds LTTng per-session event registry.
10 *
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:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
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.
28 */
29
30 #include <urcu/list.h>
31 #include <urcu/hlist.h>
32 #include <stddef.h>
33 #include <stdint.h>
34 #include <lttng/ust-config.h>
35 #include <lttng/ust-abi.h>
36 #include <lttng/ust-tracer.h>
37 #include <lttng/ust-endian.h>
38 #include <float.h>
39 #include <errno.h>
40 #include <urcu/ref.h>
41 #include <pthread.h>
42
43 #ifndef LTTNG_PACKED
44 #error "LTTNG_PACKED should be defined"
45 #endif
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 #define LTTNG_UST_UUID_LEN 16
52
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 */
59 #define LTTNG_UST_PROVIDER_MAJOR 2
60 #define LTTNG_UST_PROVIDER_MINOR 0
61
62 struct lttng_channel;
63 struct lttng_session;
64 struct lttng_ust_lib_ring_buffer_ctx;
65 struct lttng_ust_context_app;
66 struct lttng_event_field;
67 struct lttng_event_notifier_group;
68
69 /*
70 * Data structures used by tracepoint event declarations, and by the
71 * tracer. Those structures have padding for future extension.
72 */
73
74 /*
75 * LTTng client type enumeration. Used by the consumer to map the
76 * callbacks from its own address space.
77 */
78 enum lttng_client_types {
79 LTTNG_CLIENT_METADATA = 0,
80 LTTNG_CLIENT_DISCARD = 1,
81 LTTNG_CLIENT_OVERWRITE = 2,
82 LTTNG_CLIENT_DISCARD_RT = 3,
83 LTTNG_CLIENT_OVERWRITE_RT = 4,
84 LTTNG_NR_CLIENT_TYPES,
85 };
86
87 /* Type description */
88
89 /* Update the astract_types name table in lttng-types.c along with this enum */
90 enum lttng_abstract_types {
91 atype_integer,
92 atype_enum, /* legacy */
93 atype_array, /* legacy */
94 atype_sequence, /* legacy */
95 atype_string,
96 atype_float,
97 atype_dynamic,
98 atype_struct, /* legacy */
99 atype_enum_nestable,
100 atype_array_nestable,
101 atype_sequence_nestable,
102 atype_struct_nestable,
103 NR_ABSTRACT_TYPES,
104 };
105
106 /* Update the string_encodings name table in lttng-types.c along with this enum */
107 enum lttng_string_encodings {
108 lttng_encode_none = 0,
109 lttng_encode_UTF8 = 1,
110 lttng_encode_ASCII = 2,
111 NR_STRING_ENCODINGS,
112 };
113
114 struct lttng_enum_value {
115 unsigned long long value;
116 unsigned int signedness:1;
117 };
118
119 enum lttng_enum_entry_options {
120 LTTNG_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
121 };
122
123 #define LTTNG_UST_ENUM_ENTRY_PADDING 16
124 struct lttng_enum_entry {
125 struct lttng_enum_value start, end; /* start and end are inclusive */
126 const char *string;
127 union {
128 struct {
129 unsigned int options;
130 } LTTNG_PACKED extra;
131 char padding[LTTNG_UST_ENUM_ENTRY_PADDING];
132 } u;
133 };
134
135 #define __type_integer(_type, _byte_order, _base, _encoding) \
136 { \
137 .atype = atype_integer, \
138 .u = \
139 { \
140 .integer = \
141 { \
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, \
148 } \
149 }, \
150 } \
151
152 #define LTTNG_UST_INTEGER_TYPE_PADDING 24
153 struct 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;
160 char padding[LTTNG_UST_INTEGER_TYPE_PADDING];
161 };
162
163 /*
164 * Only float and double are supported. long double is not supported at
165 * the moment.
166 */
167 #define _float_mant_dig(_type) \
168 (sizeof(_type) == sizeof(float) ? FLT_MANT_DIG \
169 : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG \
170 : 0))
171
172 #define __type_float(_type) \
173 { \
174 .atype = atype_float, \
175 .u = \
176 { \
177 ._float = \
178 { \
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, \
184 } \
185 } \
186 } \
187
188 #define LTTNG_UST_FLOAT_TYPE_PADDING 24
189 struct 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;
194 char padding[LTTNG_UST_FLOAT_TYPE_PADDING];
195 };
196
197 /* legacy */
198 #define LTTNG_UST_BASIC_TYPE_PADDING 128
199 union _lttng_basic_type {
200 struct lttng_integer_type integer; /* legacy */
201 struct {
202 const struct lttng_enum_desc *desc; /* Enumeration mapping */
203 struct lttng_integer_type container_type;
204 } enumeration; /* legacy */
205 struct {
206 enum lttng_string_encodings encoding;
207 } string; /* legacy */
208 struct lttng_float_type _float; /* legacy */
209 char padding[LTTNG_UST_BASIC_TYPE_PADDING];
210 };
211
212 /* legacy */
213 struct lttng_basic_type {
214 enum lttng_abstract_types atype;
215 union {
216 union _lttng_basic_type basic;
217 } u;
218 };
219
220 #define LTTNG_UST_TYPE_PADDING 128
221 struct lttng_type {
222 enum lttng_abstract_types atype;
223 union {
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;
234 struct {
235 const struct lttng_type *elem_type;
236 unsigned int length; /* Num. elems. */
237 unsigned int alignment;
238 } array_nestable;
239 struct {
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;
244 struct {
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;
266 char padding[LTTNG_UST_TYPE_PADDING];
267 } u;
268 };
269
270 #define LTTNG_UST_ENUM_TYPE_PADDING 24
271 struct lttng_enum_desc {
272 const char *name;
273 const struct lttng_enum_entry *entries;
274 unsigned int nr_entries;
275 char padding[LTTNG_UST_ENUM_TYPE_PADDING];
276 };
277
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 */
285
286 #define LTTNG_UST_EVENT_FIELD_PADDING 28
287 struct lttng_event_field {
288 const char *name;
289 struct lttng_type type;
290 unsigned int nowrite; /* do not write into trace */
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;
297 };
298
299 enum 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
315 struct lttng_ctx_value {
316 enum lttng_ust_dynamic_type sel;
317 union {
318 int64_t s64;
319 uint64_t u64;
320 const char *str;
321 double d;
322 } u;
323 };
324
325 struct lttng_perf_counter_field;
326
327 #define LTTNG_UST_CTX_FIELD_PADDING 40
328 struct lttng_ctx_field {
329 struct lttng_event_field event_field;
330 size_t (*get_size)(struct lttng_ctx_field *field, size_t offset);
331 void (*record)(struct lttng_ctx_field *field,
332 struct lttng_ust_lib_ring_buffer_ctx *ctx,
333 struct lttng_channel *chan);
334 void (*get_value)(struct lttng_ctx_field *field,
335 struct lttng_ctx_value *value);
336 union {
337 struct lttng_perf_counter_field *perf_counter;
338 char padding[LTTNG_UST_CTX_FIELD_PADDING];
339 } u;
340 void (*destroy)(struct lttng_ctx_field *field);
341 char *field_name; /* Has ownership, dynamically allocated. */
342 };
343
344 #define LTTNG_UST_CTX_PADDING 20
345 struct lttng_ctx {
346 struct lttng_ctx_field *fields;
347 unsigned int nr_fields;
348 unsigned int allocated_fields;
349 unsigned int largest_align;
350 char padding[LTTNG_UST_CTX_PADDING];
351 };
352
353 #define LTTNG_UST_EVENT_DESC_PADDING 40
354 struct lttng_event_desc {
355 const char *name;
356 void (*probe_callback)(void);
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;
361 const char *signature; /* Argument types/names received */
362 union {
363 struct {
364 const char **model_emf_uri;
365 void (*event_notifier_callback)(void);
366 } ext;
367 char padding[LTTNG_UST_EVENT_DESC_PADDING];
368 } u;
369 };
370
371 #define LTTNG_UST_PROBE_DESC_PADDING 12
372 struct 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 */
377 struct cds_list_head lazy_init_head;
378 int lazy; /* lazy registration */
379 uint32_t major;
380 uint32_t minor;
381 char padding[LTTNG_UST_PROBE_DESC_PADDING];
382 };
383
384 /* Data structures used by the tracer. */
385
386 enum lttng_enabler_format_type {
387 LTTNG_ENABLER_FORMAT_STAR_GLOB,
388 LTTNG_ENABLER_FORMAT_EVENT,
389 };
390
391 /*
392 * Enabler field, within whatever object is enabling an event. Target of
393 * backward reference.
394 */
395 struct lttng_enabler {
396 enum lttng_enabler_format_type format_type;
397
398 /* head list of struct lttng_ust_filter_bytecode_node */
399 struct cds_list_head filter_bytecode_head;
400 /* head list of struct lttng_ust_excluder_node */
401 struct cds_list_head excluder_head;
402
403 struct lttng_ust_event event_param;
404 unsigned int enabled:1;
405 };
406
407 struct tp_list_entry {
408 struct lttng_ust_tracepoint_iter tp;
409 struct cds_list_head head;
410 };
411
412 struct lttng_ust_tracepoint_list {
413 struct tp_list_entry *iter;
414 struct cds_list_head head;
415 };
416
417 struct tp_field_list_entry {
418 struct lttng_ust_field_iter field;
419 struct cds_list_head head;
420 };
421
422 struct lttng_ust_field_list {
423 struct tp_field_list_entry *iter;
424 struct cds_list_head head;
425 };
426
427 struct ust_pending_probe;
428 struct lttng_event;
429
430 /*
431 * Bytecode interpreter return value masks.
432 */
433 enum lttng_bytecode_interpreter_ret {
434 LTTNG_INTERPRETER_DISCARD = 0,
435 LTTNG_INTERPRETER_RECORD_FLAG = (1ULL << 0),
436 /* Other bits are kept for future use. */
437 };
438
439 struct lttng_interpreter_output;
440
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 */
447 struct lttng_bytecode_runtime {
448 /* Associated bytecode */
449 struct lttng_ust_bytecode_node *bc;
450 union {
451 uint64_t (*filter)(void *interpreter_data,
452 const char *interpreter_stack_data);
453 uint64_t (*capture)(void *interpreter_data,
454 const char *interpreter_stack_data,
455 struct lttng_interpreter_output *interpreter_output);
456 } interpreter_funcs;
457 int link_failed;
458 struct cds_list_head node; /* list of bytecode runtime in event */
459 /*
460 * Pointer to a URCU-protected pointer owned by an `struct
461 * lttng_session`or `struct lttng_event_notifier_group`.
462 */
463 struct lttng_ctx **pctx;
464 };
465
466 /*
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".
474 */
475 struct lttng_enabler_ref {
476 struct cds_list_head node; /* enabler ref list */
477 struct lttng_enabler *ref; /* backward ref */
478 };
479
480 /*
481 * lttng_event structure is referred to by the tracing fast path. It
482 * must be kept small.
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.
487 */
488 struct lttng_event {
489 /* LTTng-UST 2.0 starts here */
490 unsigned int id;
491 struct lttng_channel *chan;
492 int enabled;
493 const struct lttng_event_desc *desc;
494 void *_deprecated1;
495 struct lttng_ctx *ctx;
496 enum lttng_ust_instrumentation instrumentation;
497 struct cds_list_head node; /* Event list in session */
498 struct cds_list_head _deprecated2;
499 void *_deprecated3;
500 unsigned int _deprecated4:1;
501
502 /* LTTng-UST 2.1 starts here */
503 /* list of struct lttng_bytecode_runtime, sorted by seqnum */
504 struct cds_list_head filter_bytecode_runtime_head;
505 int has_enablers_without_bytecode;
506 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
507 struct cds_list_head enablers_ref_head;
508 struct cds_hlist_node hlist; /* session ht of events */
509 int registered; /* has reg'd tracepoint probe */
510 };
511
512 struct lttng_event_notifier {
513 uint64_t user_token;
514 uint64_t error_counter_index;
515 int enabled;
516 int registered; /* has reg'd tracepoint probe */
517 size_t num_captures; /* Needed to allocate the msgpack array. */
518 struct cds_list_head filter_bytecode_runtime_head;
519 struct cds_list_head capture_bytecode_runtime_head;
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
528 struct 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
536 struct channel;
537 struct lttng_ust_shm_handle;
538
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 */
544 struct lttng_channel_ops {
545 struct lttng_channel *(*channel_create)(const char *name,
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,
550 unsigned char *uuid,
551 uint32_t chan_id,
552 const int *stream_fds, int nr_stream_fds,
553 int64_t blocking_timeout);
554 void (*channel_destroy)(struct lttng_channel *chan);
555 union {
556 void *_deprecated1;
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 */
564 unsigned long has_strcpy:1; /* ABI has strcpy */
565 } u;
566 void *_deprecated2;
567 int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
568 uint32_t event_id);
569 void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx);
570 void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
571 const void *src, size_t len);
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 */
577 size_t (*packet_avail_size)(struct channel *chan,
578 struct lttng_ust_shm_handle *handle);
579 //wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan);
580 //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
581 int (*is_finalized)(struct channel *chan);
582 int (*is_disabled)(struct channel *chan);
583 int (*flush_buffer)(struct channel *chan, struct lttng_ust_shm_handle *handle);
584 void (*event_strcpy)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
585 const char *src, size_t len);
586 };
587
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 */
593 struct lttng_channel {
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 */
600 struct channel *chan; /* Channel buffers */
601 int enabled;
602 struct lttng_ctx *ctx;
603 /* Event ID management */
604 struct lttng_session *session;
605 int objd; /* Object associated to channel */
606 unsigned int _deprecated1;
607 unsigned int _deprecated2;
608 struct cds_list_head node; /* Channel list in session */
609 const struct lttng_channel_ops *ops;
610 int header_type; /* 0: unset, 1: compact, 2: large */
611 struct lttng_ust_shm_handle *handle; /* shared-memory handle */
612 unsigned int _deprecated3:1;
613
614 /* Channel ID */
615 unsigned int id;
616 enum lttng_ust_chan_type type;
617 unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
618 int tstate:1; /* Transient enable state */
619 };
620
621 #define LTTNG_COUNTER_DIMENSION_MAX 8
622
623 struct 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
631 struct 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
651 #define LTTNG_UST_STACK_CTX_PADDING 32
652 struct 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
659 #define LTTNG_UST_EVENT_HT_BITS 12
660 #define LTTNG_UST_EVENT_HT_SIZE (1U << LTTNG_UST_EVENT_HT_BITS)
661
662 struct lttng_ust_event_ht {
663 struct cds_hlist_head table[LTTNG_UST_EVENT_HT_SIZE];
664 };
665
666 #define LTTNG_UST_EVENT_NOTIFIER_HT_BITS 12
667 #define LTTNG_UST_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_UST_EVENT_NOTIFIER_HT_BITS)
668 struct lttng_ust_event_notifier_ht {
669 struct cds_hlist_head table[LTTNG_UST_EVENT_NOTIFIER_HT_SIZE];
670 };
671
672 #define LTTNG_UST_ENUM_HT_BITS 12
673 #define LTTNG_UST_ENUM_HT_SIZE (1U << LTTNG_UST_ENUM_HT_BITS)
674
675 struct lttng_ust_enum_ht {
676 struct cds_hlist_head table[LTTNG_UST_ENUM_HT_SIZE];
677 };
678
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 */
684 struct lttng_session {
685 int active; /* Is trace session active ? */
686 int been_active; /* Been active ? */
687 int objd; /* Object associated */
688 void *_deprecated1;
689 struct cds_list_head chan_head; /* Channel list head */
690 struct cds_list_head events_head; /* list of events */
691 struct cds_list_head _deprecated2;
692 struct cds_list_head node; /* Session list */
693 int _deprecated3;
694 unsigned int _deprecated4:1;
695
696 /* New UST 2.1 */
697 /* List of enablers */
698 struct cds_list_head enablers_head;
699 struct lttng_ust_event_ht events_ht; /* ht of events */
700 void *owner; /* object owner */
701 int tstate:1; /* Transient enable state */
702
703 /* New UST 2.4 */
704 int statedump_pending:1;
705
706 /* New UST 2.8 */
707 struct lttng_ust_enum_ht enums_ht; /* ht of enumerations */
708 struct cds_list_head enums_head;
709 struct lttng_ctx *ctx; /* contexts for filters. */
710 };
711
712 struct 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
720 struct 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. */
729
730 struct lttng_counter *error_counter;
731 size_t error_counter_len;
732 };
733
734 struct lttng_transport {
735 char *name;
736 struct cds_list_head node;
737 struct lttng_channel_ops ops;
738 const struct lttng_ust_lib_ring_buffer_config *client_config;
739 };
740
741 struct 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
748 struct lttng_session *lttng_session_create(void);
749 int lttng_session_enable(struct lttng_session *session);
750 int lttng_session_disable(struct lttng_session *session);
751 int lttng_session_statedump(struct lttng_session *session);
752 void lttng_session_destroy(struct lttng_session *session);
753
754 void lttng_event_notifier_notification_send(
755 struct lttng_event_notifier *event_notifier,
756 const char *stack_data);
757
758 struct lttng_channel *lttng_channel_create(struct lttng_session *session,
759 const char *transport_name,
760 void *buf_addr,
761 size_t subbuf_size, size_t num_subbuf,
762 unsigned int switch_timer_interval,
763 unsigned int read_timer_interval,
764 int **shm_fd, int **wait_fd,
765 uint64_t **memory_map_size,
766 struct lttng_channel *chan_priv_init);
767
768 int lttng_channel_enable(struct lttng_channel *channel);
769 int lttng_channel_disable(struct lttng_channel *channel);
770
771 int lttng_attach_context(struct lttng_ust_context *context_param,
772 union ust_args *uargs,
773 struct lttng_ctx **ctx, struct lttng_session *session);
774 void lttng_transport_register(struct lttng_transport *transport);
775 void lttng_transport_unregister(struct lttng_transport *transport);
776
777 void lttng_counter_transport_register(struct lttng_counter_transport *transport);
778 void lttng_counter_transport_unregister(struct lttng_counter_transport *transport);
779
780 struct lttng_counter *lttng_ust_counter_create(
781 const char *counter_transport_name,
782 size_t number_dimensions, const struct lttng_counter_dimension *dimensions);
783
784 int lttng_probe_register(struct lttng_probe_desc *desc);
785 void lttng_probe_unregister(struct lttng_probe_desc *desc);
786 void lttng_probe_provider_unregister_events(struct lttng_probe_desc *desc);
787 int lttng_fix_pending_events(void);
788 int lttng_probes_init(void);
789 void lttng_probes_exit(void);
790 int lttng_find_context(struct lttng_ctx *ctx, const char *name);
791 int lttng_get_context_index(struct lttng_ctx *ctx, const char *name);
792 struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p);
793 void lttng_context_update(struct lttng_ctx *ctx);
794 void lttng_remove_context_field(struct lttng_ctx **ctx_p,
795 struct lttng_ctx_field *field);
796 void lttng_destroy_context(struct lttng_ctx *ctx);
797 int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
798 int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
799 int lttng_add_pthread_id_to_ctx(struct lttng_ctx **ctx);
800 int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
801 int lttng_add_ip_to_ctx(struct lttng_ctx **ctx);
802 int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx);
803 int lttng_add_dyntest_to_ctx(struct lttng_ctx **ctx);
804 int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx);
805 int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx);
806 int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx);
807 int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx);
808 int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx);
809 int lttng_add_time_ns_to_ctx(struct lttng_ctx **ctx);
810 int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx);
811 int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx);
812 int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx);
813 int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx);
814 int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx);
815 int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx);
816 int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx);
817 int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx);
818 void lttng_context_vtid_reset(void);
819 void lttng_context_vpid_reset(void);
820 void lttng_context_procname_reset(void);
821 void lttng_context_cgroup_ns_reset(void);
822 void lttng_context_ipc_ns_reset(void);
823 void lttng_context_mnt_ns_reset(void);
824 void lttng_context_net_ns_reset(void);
825 void lttng_context_pid_ns_reset(void);
826 void lttng_context_time_ns_reset(void);
827 void lttng_context_user_ns_reset(void);
828 void lttng_context_uts_ns_reset(void);
829 void lttng_context_vuid_reset(void);
830 void lttng_context_veuid_reset(void);
831 void lttng_context_vsuid_reset(void);
832 void lttng_context_vgid_reset(void);
833 void lttng_context_vegid_reset(void);
834 void lttng_context_vsgid_reset(void);
835
836 #ifdef LTTNG_UST_HAVE_PERF_EVENT
837 int lttng_add_perf_counter_to_ctx(uint32_t type,
838 uint64_t config,
839 const char *name,
840 struct lttng_ctx **ctx);
841 int lttng_perf_counter_init(void);
842 void lttng_perf_counter_exit(void);
843 #else /* #ifdef LTTNG_UST_HAVE_PERF_EVENT */
844 static inline
845 int 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 }
852 static inline
853 int lttng_perf_counter_init(void)
854 {
855 return 0;
856 }
857 static inline
858 void lttng_perf_counter_exit(void)
859 {
860 }
861 #endif /* #else #ifdef LTTNG_UST_HAVE_PERF_EVENT */
862
863 extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
864 extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
865 extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
866
867 struct lttng_transport *lttng_transport_find(const char *name);
868 struct lttng_counter_transport *lttng_counter_transport_find(const char *name);
869
870 int lttng_probes_get_event_list(struct lttng_ust_tracepoint_list *list);
871 void lttng_probes_prune_event_list(struct lttng_ust_tracepoint_list *list);
872 struct lttng_ust_tracepoint_iter *
873 lttng_ust_tracepoint_list_get_iter_next(struct lttng_ust_tracepoint_list *list);
874 int lttng_probes_get_field_list(struct lttng_ust_field_list *list);
875 void lttng_probes_prune_field_list(struct lttng_ust_field_list *list);
876 struct lttng_ust_field_iter *
877 lttng_ust_field_list_get_iter_next(struct lttng_ust_field_list *list);
878
879 void lttng_free_event_filter_runtime(struct lttng_event *event);
880
881 struct cds_list_head *lttng_get_probe_list_head(void);
882 int lttng_session_active(void);
883
884 typedef int (*t_statedump_func_ptr)(struct lttng_session *session);
885 void lttng_handle_pending_statedump(void *owner);
886 struct cds_list_head *_lttng_get_sessions(void);
887
888 struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
889 const struct lttng_enum_desc *enum_desc);
890
891 void lttng_ust_dl_update(void *ip);
892 void lttng_ust_fixup_fd_tracker_tls(void);
893
894 /* For backward compatibility. Leave those exported symbols in place. */
895 extern struct lttng_ctx *lttng_static_ctx;
896 struct lttng_ust_filter_bytecode_node;
897 struct lttng_ust_excluder_node;
898 void lttng_context_init(void);
899 void lttng_context_exit(void);
900 void lttng_filter_event_link_bytecode(struct lttng_event *event);
901 struct 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);
905 int lttng_enabler_enable(struct lttng_enabler *enabler);
906 int lttng_enabler_disable(struct lttng_enabler *enabler);
907 int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler,
908 struct lttng_ust_filter_bytecode_node *bytecode);
909 int lttng_enabler_attach_context(struct lttng_enabler *enabler,
910 struct lttng_ust_context *ctx);
911 int lttng_enabler_attach_exclusion(struct lttng_enabler *enabler,
912 struct lttng_ust_excluder_node *excluder);
913 void lttng_enabler_event_link_bytecode(struct lttng_event *event,
914 struct lttng_enabler *enabler);
915 void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime);
916 int lttng_session_context_init(struct lttng_ctx **ctx);
917
918
919 #ifdef __cplusplus
920 }
921 #endif
922
923 #endif /* _LTTNG_UST_EVENTS_H */
This page took 0.052838 seconds and 5 git commands to generate.