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