Commit | Line | Data |
---|---|---|
8020ceb5 | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: MIT |
8020ceb5 | 3 | * |
c0c0989a | 4 | * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
8020ceb5 MD |
5 | * |
6 | * Holds LTTng per-session event registry. | |
8020ceb5 MD |
7 | */ |
8 | ||
c0c0989a MJ |
9 | #ifndef _LTTNG_UST_EVENTS_H |
10 | #define _LTTNG_UST_EVENTS_H | |
11 | ||
9f3fdbc6 | 12 | #include <urcu/list.h> |
1f18504e | 13 | #include <urcu/hlist.h> |
b4051ad8 | 14 | #include <stddef.h> |
9f3fdbc6 | 15 | #include <stdint.h> |
4318ae1b MD |
16 | #include <lttng/ust-abi.h> |
17 | #include <lttng/ust-tracer.h> | |
2ae57758 | 18 | #include <lttng/ust-endian.h> |
20f1eee7 | 19 | #include <float.h> |
d58d1454 MD |
20 | #include <errno.h> |
21 | #include <urcu/ref.h> | |
22 | #include <pthread.h> | |
8020ceb5 | 23 | |
db56acaf MD |
24 | #ifndef LTTNG_PACKED |
25 | #error "LTTNG_PACKED should be defined" | |
26 | #endif | |
27 | ||
6453d237 MD |
28 | #ifdef __cplusplus |
29 | extern "C" { | |
30 | #endif | |
31 | ||
19d8b1b3 MD |
32 | #define LTTNG_UST_UUID_LEN 16 |
33 | ||
71d31690 MD |
34 | /* |
35 | * Tracepoint provider version. Compatibility based on the major number. | |
36 | * Older tracepoint providers can always register to newer lttng-ust | |
37 | * library, but the opposite is rejected: a newer tracepoint provider is | |
38 | * rejected by an older lttng-ust library. | |
39 | */ | |
04f0b55a | 40 | #define LTTNG_UST_PROVIDER_MAJOR 2 |
71d31690 MD |
41 | #define LTTNG_UST_PROVIDER_MINOR 0 |
42 | ||
7dd08bec MD |
43 | struct lttng_channel; |
44 | struct lttng_session; | |
4cfec15c | 45 | struct lttng_ust_lib_ring_buffer_ctx; |
53569322 MD |
46 | struct lttng_ust_context_app; |
47 | struct lttng_event_field; | |
cab88ff8 | 48 | struct lttng_event_notifier; |
ebabbf58 | 49 | struct lttng_event_notifier_group; |
8020ceb5 | 50 | |
37d5e202 MD |
51 | /* |
52 | * Data structures used by tracepoint event declarations, and by the | |
53 | * tracer. Those structures have padding for future extension. | |
54 | */ | |
55 | ||
8020ceb5 MD |
56 | /* Type description */ |
57 | ||
58 | /* Update the astract_types name table in lttng-types.c along with this enum */ | |
7dd08bec | 59 | enum lttng_abstract_types { |
8020ceb5 | 60 | atype_integer, |
218deb69 MD |
61 | atype_enum, /* legacy */ |
62 | atype_array, /* legacy */ | |
63 | atype_sequence, /* legacy */ | |
8020ceb5 | 64 | atype_string, |
20f1eee7 | 65 | atype_float, |
53569322 | 66 | atype_dynamic, |
218deb69 MD |
67 | atype_struct, /* legacy */ |
68 | atype_enum_nestable, | |
69 | atype_array_nestable, | |
70 | atype_sequence_nestable, | |
71 | atype_struct_nestable, | |
8020ceb5 MD |
72 | NR_ABSTRACT_TYPES, |
73 | }; | |
74 | ||
75 | /* Update the string_encodings name table in lttng-types.c along with this enum */ | |
76 | enum lttng_string_encodings { | |
77 | lttng_encode_none = 0, | |
78 | lttng_encode_UTF8 = 1, | |
79 | lttng_encode_ASCII = 2, | |
80 | NR_STRING_ENCODINGS, | |
81 | }; | |
82 | ||
a6f80644 MD |
83 | struct lttng_enum_value { |
84 | unsigned long long value; | |
85 | unsigned int signedness:1; | |
86 | }; | |
87 | ||
3e762260 PP |
88 | enum lttng_enum_entry_options { |
89 | LTTNG_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0, | |
90 | }; | |
91 | ||
37d5e202 | 92 | #define LTTNG_UST_ENUM_ENTRY_PADDING 16 |
8020ceb5 | 93 | struct lttng_enum_entry { |
a6f80644 | 94 | struct lttng_enum_value start, end; /* start and end are inclusive */ |
8020ceb5 | 95 | const char *string; |
3e762260 PP |
96 | union { |
97 | struct { | |
98 | unsigned int options; | |
99 | } LTTNG_PACKED extra; | |
100 | char padding[LTTNG_UST_ENUM_ENTRY_PADDING]; | |
101 | } u; | |
8020ceb5 MD |
102 | }; |
103 | ||
104 | #define __type_integer(_type, _byte_order, _base, _encoding) \ | |
105 | { \ | |
46d52200 ZT |
106 | .atype = atype_integer, \ |
107 | .u = \ | |
8020ceb5 | 108 | { \ |
218deb69 | 109 | .integer = \ |
46d52200 | 110 | { \ |
218deb69 MD |
111 | .size = sizeof(_type) * CHAR_BIT, \ |
112 | .alignment = lttng_alignof(_type) * CHAR_BIT, \ | |
113 | .signedness = lttng_is_signed_type(_type), \ | |
114 | .reverse_byte_order = _byte_order != BYTE_ORDER, \ | |
115 | .base = _base, \ | |
116 | .encoding = lttng_encode_##_encoding, \ | |
46d52200 | 117 | } \ |
8020ceb5 MD |
118 | }, \ |
119 | } \ | |
120 | ||
37d5e202 | 121 | #define LTTNG_UST_INTEGER_TYPE_PADDING 24 |
8020ceb5 MD |
122 | struct lttng_integer_type { |
123 | unsigned int size; /* in bits */ | |
124 | unsigned short alignment; /* in bits */ | |
125 | unsigned int signedness:1; | |
126 | unsigned int reverse_byte_order:1; | |
127 | unsigned int base; /* 2, 8, 10, 16, for pretty print */ | |
128 | enum lttng_string_encodings encoding; | |
37d5e202 | 129 | char padding[LTTNG_UST_INTEGER_TYPE_PADDING]; |
8020ceb5 MD |
130 | }; |
131 | ||
d3ed854b MD |
132 | /* |
133 | * Only float and double are supported. long double is not supported at | |
134 | * the moment. | |
135 | */ | |
20f1eee7 MD |
136 | #define _float_mant_dig(_type) \ |
137 | (sizeof(_type) == sizeof(float) ? FLT_MANT_DIG \ | |
138 | : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG \ | |
d3ed854b | 139 | : 0)) |
20f1eee7 MD |
140 | |
141 | #define __type_float(_type) \ | |
142 | { \ | |
46d52200 ZT |
143 | .atype = atype_float, \ |
144 | .u = \ | |
20f1eee7 | 145 | { \ |
218deb69 | 146 | ._float = \ |
46d52200 | 147 | { \ |
218deb69 MD |
148 | .exp_dig = sizeof(_type) * CHAR_BIT \ |
149 | - _float_mant_dig(_type), \ | |
150 | .mant_dig = _float_mant_dig(_type), \ | |
151 | .alignment = lttng_alignof(_type) * CHAR_BIT, \ | |
152 | .reverse_byte_order = BYTE_ORDER != FLOAT_WORD_ORDER, \ | |
46d52200 | 153 | } \ |
218deb69 | 154 | } \ |
20f1eee7 MD |
155 | } \ |
156 | ||
37d5e202 | 157 | #define LTTNG_UST_FLOAT_TYPE_PADDING 24 |
20f1eee7 MD |
158 | struct lttng_float_type { |
159 | unsigned int exp_dig; /* exponent digits, in bits */ | |
160 | unsigned int mant_dig; /* mantissa digits, in bits */ | |
161 | unsigned short alignment; /* in bits */ | |
162 | unsigned int reverse_byte_order:1; | |
37d5e202 | 163 | char padding[LTTNG_UST_FLOAT_TYPE_PADDING]; |
20f1eee7 MD |
164 | }; |
165 | ||
218deb69 | 166 | /* legacy */ |
37d5e202 | 167 | #define LTTNG_UST_BASIC_TYPE_PADDING 128 |
8020ceb5 | 168 | union _lttng_basic_type { |
218deb69 | 169 | struct lttng_integer_type integer; /* legacy */ |
8020ceb5 | 170 | struct { |
c785c634 MD |
171 | const struct lttng_enum_desc *desc; /* Enumeration mapping */ |
172 | struct lttng_integer_type container_type; | |
218deb69 | 173 | } enumeration; /* legacy */ |
8020ceb5 MD |
174 | struct { |
175 | enum lttng_string_encodings encoding; | |
218deb69 MD |
176 | } string; /* legacy */ |
177 | struct lttng_float_type _float; /* legacy */ | |
37d5e202 | 178 | char padding[LTTNG_UST_BASIC_TYPE_PADDING]; |
8020ceb5 MD |
179 | }; |
180 | ||
218deb69 | 181 | /* legacy */ |
8020ceb5 | 182 | struct lttng_basic_type { |
7dd08bec | 183 | enum lttng_abstract_types atype; |
8020ceb5 MD |
184 | union { |
185 | union _lttng_basic_type basic; | |
186 | } u; | |
187 | }; | |
188 | ||
37d5e202 | 189 | #define LTTNG_UST_TYPE_PADDING 128 |
8020ceb5 | 190 | struct lttng_type { |
7dd08bec | 191 | enum lttng_abstract_types atype; |
8020ceb5 | 192 | union { |
218deb69 MD |
193 | /* provider ABI 2.0 */ |
194 | struct lttng_integer_type integer; | |
195 | struct lttng_float_type _float; | |
196 | struct { | |
197 | enum lttng_string_encodings encoding; | |
198 | } string; | |
199 | struct { | |
200 | const struct lttng_enum_desc *desc; /* Enumeration mapping */ | |
201 | struct lttng_type *container_type; | |
202 | } enum_nestable; | |
8020ceb5 | 203 | struct { |
218deb69 MD |
204 | const struct lttng_type *elem_type; |
205 | unsigned int length; /* Num. elems. */ | |
206 | unsigned int alignment; | |
207 | } array_nestable; | |
8020ceb5 | 208 | struct { |
218deb69 MD |
209 | const char *length_name; /* Length field name. */ |
210 | const struct lttng_type *elem_type; | |
211 | unsigned int alignment; /* Alignment before elements. */ | |
212 | } sequence_nestable; | |
53569322 | 213 | struct { |
218deb69 MD |
214 | unsigned int nr_fields; |
215 | const struct lttng_event_field *fields; /* Array of fields. */ | |
216 | unsigned int alignment; | |
217 | } struct_nestable; | |
218 | ||
219 | union { | |
220 | /* legacy provider ABI 1.0 */ | |
221 | union _lttng_basic_type basic; /* legacy */ | |
222 | struct { | |
223 | struct lttng_basic_type elem_type; | |
224 | unsigned int length; /* Num. elems. */ | |
225 | } array; /* legacy */ | |
226 | struct { | |
227 | struct lttng_basic_type length_type; | |
228 | struct lttng_basic_type elem_type; | |
229 | } sequence; /* legacy */ | |
230 | struct { | |
231 | unsigned int nr_fields; | |
232 | struct lttng_event_field *fields; /* Array of fields. */ | |
233 | } _struct; /* legacy */ | |
234 | } legacy; | |
37d5e202 | 235 | char padding[LTTNG_UST_TYPE_PADDING]; |
8020ceb5 MD |
236 | } u; |
237 | }; | |
238 | ||
37d5e202 | 239 | #define LTTNG_UST_ENUM_TYPE_PADDING 24 |
c785c634 | 240 | struct lttng_enum_desc { |
8020ceb5 | 241 | const char *name; |
8020ceb5 | 242 | const struct lttng_enum_entry *entries; |
c785c634 | 243 | unsigned int nr_entries; |
37d5e202 | 244 | char padding[LTTNG_UST_ENUM_TYPE_PADDING]; |
8020ceb5 MD |
245 | }; |
246 | ||
180901e6 MD |
247 | /* |
248 | * Event field description | |
249 | * | |
250 | * IMPORTANT: this structure is part of the ABI between the probe and | |
251 | * UST. Fields need to be only added at the end, never reordered, never | |
252 | * removed. | |
253 | */ | |
8020ceb5 | 254 | |
4774c8f3 | 255 | #define LTTNG_UST_EVENT_FIELD_PADDING 28 |
8020ceb5 MD |
256 | struct lttng_event_field { |
257 | const char *name; | |
258 | struct lttng_type type; | |
180901e6 | 259 | unsigned int nowrite; /* do not write into trace */ |
218deb69 MD |
260 | union { |
261 | struct { | |
262 | unsigned int nofilter:1; /* do not consider for filter */ | |
263 | } ext; | |
264 | char padding[LTTNG_UST_EVENT_FIELD_PADDING]; | |
265 | } u; | |
8020ceb5 MD |
266 | }; |
267 | ||
53569322 MD |
268 | enum lttng_ust_dynamic_type { |
269 | LTTNG_UST_DYNAMIC_TYPE_NONE, | |
270 | LTTNG_UST_DYNAMIC_TYPE_S8, | |
271 | LTTNG_UST_DYNAMIC_TYPE_S16, | |
272 | LTTNG_UST_DYNAMIC_TYPE_S32, | |
273 | LTTNG_UST_DYNAMIC_TYPE_S64, | |
274 | LTTNG_UST_DYNAMIC_TYPE_U8, | |
275 | LTTNG_UST_DYNAMIC_TYPE_U16, | |
276 | LTTNG_UST_DYNAMIC_TYPE_U32, | |
277 | LTTNG_UST_DYNAMIC_TYPE_U64, | |
278 | LTTNG_UST_DYNAMIC_TYPE_FLOAT, | |
279 | LTTNG_UST_DYNAMIC_TYPE_DOUBLE, | |
280 | LTTNG_UST_DYNAMIC_TYPE_STRING, | |
281 | _NR_LTTNG_UST_DYNAMIC_TYPES, | |
282 | }; | |
283 | ||
284 | struct lttng_ctx_value { | |
285 | enum lttng_ust_dynamic_type sel; | |
286 | union { | |
287 | int64_t s64; | |
86133caf | 288 | uint64_t u64; |
53569322 MD |
289 | const char *str; |
290 | double d; | |
291 | } u; | |
77aa5901 MD |
292 | }; |
293 | ||
d58d1454 MD |
294 | struct lttng_perf_counter_field; |
295 | ||
37d5e202 | 296 | #define LTTNG_UST_CTX_FIELD_PADDING 40 |
8020ceb5 MD |
297 | struct lttng_ctx_field { |
298 | struct lttng_event_field event_field; | |
53569322 | 299 | size_t (*get_size)(struct lttng_ctx_field *field, size_t offset); |
8020ceb5 | 300 | void (*record)(struct lttng_ctx_field *field, |
4cfec15c | 301 | struct lttng_ust_lib_ring_buffer_ctx *ctx, |
7dd08bec | 302 | struct lttng_channel *chan); |
77aa5901 | 303 | void (*get_value)(struct lttng_ctx_field *field, |
53569322 | 304 | struct lttng_ctx_value *value); |
8020ceb5 | 305 | union { |
d58d1454 | 306 | struct lttng_perf_counter_field *perf_counter; |
37d5e202 | 307 | char padding[LTTNG_UST_CTX_FIELD_PADDING]; |
8020ceb5 MD |
308 | } u; |
309 | void (*destroy)(struct lttng_ctx_field *field); | |
53569322 | 310 | char *field_name; /* Has ownership, dynamically allocated. */ |
8020ceb5 MD |
311 | }; |
312 | ||
b2cc986a | 313 | #define LTTNG_UST_CTX_PADDING 20 |
8020ceb5 MD |
314 | struct lttng_ctx { |
315 | struct lttng_ctx_field *fields; | |
316 | unsigned int nr_fields; | |
317 | unsigned int allocated_fields; | |
b2cc986a | 318 | unsigned int largest_align; |
37d5e202 MD |
319 | char padding[LTTNG_UST_CTX_PADDING]; |
320 | }; | |
321 | ||
322 | #define LTTNG_UST_EVENT_DESC_PADDING 40 | |
323 | struct lttng_event_desc { | |
324 | const char *name; | |
fbdeb5ec | 325 | void (*probe_callback)(void); |
37d5e202 MD |
326 | const struct lttng_event_ctx *ctx; /* context */ |
327 | const struct lttng_event_field *fields; /* event payload */ | |
328 | unsigned int nr_fields; | |
329 | const int **loglevel; | |
68755429 | 330 | const char *signature; /* Argument types/names received */ |
6ddc916d MD |
331 | union { |
332 | struct { | |
333 | const char **model_emf_uri; | |
d8d2416d | 334 | void (*event_notifier_callback)(void); |
6ddc916d MD |
335 | } ext; |
336 | char padding[LTTNG_UST_EVENT_DESC_PADDING]; | |
337 | } u; | |
37d5e202 MD |
338 | }; |
339 | ||
71d31690 | 340 | #define LTTNG_UST_PROBE_DESC_PADDING 12 |
37d5e202 MD |
341 | struct lttng_probe_desc { |
342 | const char *provider; | |
343 | const struct lttng_event_desc **event_desc; | |
344 | unsigned int nr_events; | |
345 | struct cds_list_head head; /* chain registered probes */ | |
6715d7d1 MD |
346 | struct cds_list_head lazy_init_head; |
347 | int lazy; /* lazy registration */ | |
71d31690 MD |
348 | uint32_t major; |
349 | uint32_t minor; | |
37d5e202 | 350 | char padding[LTTNG_UST_PROBE_DESC_PADDING]; |
8020ceb5 MD |
351 | }; |
352 | ||
37d5e202 MD |
353 | /* Data structures used by the tracer. */ |
354 | ||
c8fcf224 MD |
355 | struct tp_list_entry { |
356 | struct lttng_ust_tracepoint_iter tp; | |
357 | struct cds_list_head head; | |
358 | }; | |
359 | ||
360 | struct lttng_ust_tracepoint_list { | |
361 | struct tp_list_entry *iter; | |
362 | struct cds_list_head head; | |
8020ceb5 MD |
363 | }; |
364 | ||
06d4f27e MD |
365 | struct tp_field_list_entry { |
366 | struct lttng_ust_field_iter field; | |
367 | struct cds_list_head head; | |
368 | }; | |
369 | ||
370 | struct lttng_ust_field_list { | |
371 | struct tp_field_list_entry *iter; | |
372 | struct cds_list_head head; | |
373 | }; | |
374 | ||
8165c8da | 375 | struct ust_pending_probe; |
7dd08bec | 376 | struct lttng_event; |
f488575f | 377 | |
8a92ed2a | 378 | /* |
04aa13f8 | 379 | * Bytecode interpreter return value masks. |
8a92ed2a | 380 | */ |
04aa13f8 FD |
381 | enum lttng_bytecode_interpreter_ret { |
382 | LTTNG_INTERPRETER_DISCARD = 0, | |
383 | LTTNG_INTERPRETER_RECORD_FLAG = (1ULL << 0), | |
8a92ed2a MD |
384 | /* Other bits are kept for future use. */ |
385 | }; | |
386 | ||
d37ecb3f FD |
387 | struct lttng_interpreter_output; |
388 | ||
73d37531 FD |
389 | /* |
390 | * This structure is used in the probes. More specifically, the `filter` and | |
391 | * `node` fields are explicity used in the probes. When modifying this | |
392 | * structure we must not change the layout of these two fields as it is | |
393 | * considered ABI. | |
394 | */ | |
f488575f MD |
395 | struct lttng_bytecode_runtime { |
396 | /* Associated bytecode */ | |
ab249ecf | 397 | struct lttng_ust_bytecode_node *bc; |
c42416df FD |
398 | union { |
399 | uint64_t (*filter)(void *interpreter_data, | |
400 | const char *interpreter_stack_data); | |
d37ecb3f FD |
401 | uint64_t (*capture)(void *interpreter_data, |
402 | const char *interpreter_stack_data, | |
403 | struct lttng_interpreter_output *interpreter_output); | |
c42416df | 404 | } interpreter_funcs; |
21af05a9 | 405 | int link_failed; |
e58095ef | 406 | struct cds_list_head node; /* list of bytecode runtime in event */ |
b77aaa1b | 407 | /* |
d8d2416d FD |
408 | * Pointer to a URCU-protected pointer owned by an `struct |
409 | * lttng_session`or `struct lttng_event_notifier_group`. | |
b77aaa1b FD |
410 | */ |
411 | struct lttng_ctx **pctx; | |
e58095ef MD |
412 | }; |
413 | ||
414 | /* | |
d8d2416d FD |
415 | * Objects in a linked-list of enablers, owned by an event or event_notifier. |
416 | * This is used because an event (or a event_notifier) can be enabled by more | |
417 | * than one enabler and we want a quick way to iterate over all enablers of an | |
418 | * object. | |
419 | * | |
420 | * For example, event rules "my_app:a*" and "my_app:ab*" will both match the | |
421 | * event with the name "my_app:abc". | |
e58095ef MD |
422 | */ |
423 | struct lttng_enabler_ref { | |
424 | struct cds_list_head node; /* enabler ref list */ | |
425 | struct lttng_enabler *ref; /* backward ref */ | |
f488575f | 426 | }; |
8165c8da | 427 | |
8020ceb5 | 428 | /* |
7dd08bec MD |
429 | * lttng_event structure is referred to by the tracing fast path. It |
430 | * must be kept small. | |
180901e6 MD |
431 | * |
432 | * IMPORTANT: this structure is part of the ABI between the probe and | |
433 | * UST. Fields need to be only added at the end, never reordered, never | |
434 | * removed. | |
8020ceb5 | 435 | */ |
7dd08bec | 436 | struct lttng_event { |
8020ceb5 | 437 | unsigned int id; |
7dd08bec | 438 | struct lttng_channel *chan; |
976fe9ea | 439 | int enabled; |
8020ceb5 | 440 | const struct lttng_event_desc *desc; |
8020ceb5 | 441 | struct lttng_ctx *ctx; |
9f3fdbc6 | 442 | enum lttng_ust_instrumentation instrumentation; |
e58095ef | 443 | struct cds_list_head node; /* Event list in session */ |
e58095ef | 444 | |
e58095ef | 445 | /* list of struct lttng_bytecode_runtime, sorted by seqnum */ |
a56fd376 | 446 | struct cds_list_head filter_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 | ||
d8d2416d FD |
454 | struct lttng_event_notifier { |
455 | uint64_t user_token; | |
6566528b | 456 | uint64_t error_counter_index; |
d8d2416d FD |
457 | int enabled; |
458 | int registered; /* has reg'd tracepoint probe */ | |
d37ecb3f | 459 | size_t num_captures; /* Needed to allocate the msgpack array. */ |
cab88ff8 MD |
460 | void (*notification_send)(struct lttng_event_notifier *event_notifier, |
461 | const char *stack_data); | |
d8d2416d | 462 | struct cds_list_head filter_bytecode_runtime_head; |
d37ecb3f | 463 | struct cds_list_head capture_bytecode_runtime_head; |
d8d2416d FD |
464 | int has_enablers_without_bytecode; |
465 | struct cds_list_head enablers_ref_head; | |
466 | const struct lttng_event_desc *desc; | |
467 | struct cds_hlist_node hlist; /* hashtable of event_notifiers */ | |
468 | struct cds_list_head node; /* event_notifier list in session */ | |
469 | struct lttng_event_notifier_group *group; /* weak ref */ | |
470 | }; | |
471 | ||
c785c634 MD |
472 | struct lttng_enum { |
473 | const struct lttng_enum_desc *desc; | |
474 | struct lttng_session *session; | |
475 | struct cds_list_head node; /* Enum list in session */ | |
476 | struct cds_hlist_node hlist; /* Session ht of enums */ | |
477 | uint64_t id; /* Enumeration ID in sessiond */ | |
478 | }; | |
479 | ||
8d8a24c8 | 480 | struct channel; |
38fae1d3 | 481 | struct lttng_ust_shm_handle; |
8d8a24c8 | 482 | |
180901e6 MD |
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 | */ | |
7dd08bec MD |
488 | struct lttng_channel_ops { |
489 | struct lttng_channel *(*channel_create)(const char *name, | |
74d81a6c MD |
490 | void *buf_addr, |
491 | size_t subbuf_size, size_t num_subbuf, | |
492 | unsigned int switch_timer_interval, | |
493 | unsigned int read_timer_interval, | |
6ca18e66 | 494 | unsigned char *uuid, |
a9ff648c | 495 | uint32_t chan_id, |
b2c5f61a MD |
496 | const int *stream_fds, int nr_stream_fds, |
497 | int64_t blocking_timeout); | |
74d81a6c | 498 | void (*channel_destroy)(struct lttng_channel *chan); |
4cfec15c | 499 | int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
8020ceb5 | 500 | uint32_t event_id); |
4cfec15c | 501 | void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx); |
74d81a6c MD |
502 | void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
503 | const void *src, size_t len); | |
8020ceb5 MD |
504 | /* |
505 | * packet_avail_size returns the available size in the current | |
506 | * packet. Note that the size returned is only a hint, since it | |
507 | * may change due to concurrent writes. | |
508 | */ | |
1d498196 | 509 | size_t (*packet_avail_size)(struct channel *chan, |
38fae1d3 | 510 | struct lttng_ust_shm_handle *handle); |
8020ceb5 MD |
511 | int (*is_finalized)(struct channel *chan); |
512 | int (*is_disabled)(struct channel *chan); | |
38fae1d3 | 513 | int (*flush_buffer)(struct channel *chan, struct lttng_ust_shm_handle *handle); |
a44c74d9 MD |
514 | void (*event_strcpy)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
515 | const char *src, size_t len); | |
8020ceb5 MD |
516 | }; |
517 | ||
180901e6 MD |
518 | /* |
519 | * IMPORTANT: this structure is part of the ABI between the probe and | |
520 | * UST. Fields need to be only added at the end, never reordered, never | |
521 | * removed. | |
522 | */ | |
7dd08bec | 523 | struct lttng_channel { |
a3f61e7f MD |
524 | /* |
525 | * The pointers located in this private data are NOT safe to be | |
526 | * dereferenced by the consumer. The only operations the | |
527 | * consumer process is designed to be allowed to do is to read | |
528 | * and perform subbuffer flush. | |
529 | */ | |
8020ceb5 | 530 | struct channel *chan; /* Channel buffers */ |
976fe9ea | 531 | int enabled; |
8020ceb5 MD |
532 | struct lttng_ctx *ctx; |
533 | /* Event ID management */ | |
7dd08bec | 534 | struct lttng_session *session; |
0a42beb6 | 535 | int objd; /* Object associated to channel */ |
e58095ef | 536 | struct cds_list_head node; /* Channel list in session */ |
74d81a6c | 537 | const struct lttng_channel_ops *ops; |
8020ceb5 | 538 | int header_type; /* 0: unset, 1: compact, 2: large */ |
38fae1d3 | 539 | struct lttng_ust_shm_handle *handle; /* shared-memory handle */ |
a3f61e7f | 540 | |
74d81a6c | 541 | /* Channel ID */ |
a3f61e7f | 542 | unsigned int id; |
74d81a6c | 543 | enum lttng_ust_chan_type type; |
19d8b1b3 | 544 | unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ |
ac6b4ac6 | 545 | int tstate:1; /* Transient enable state */ |
8020ceb5 MD |
546 | }; |
547 | ||
ebabbf58 MD |
548 | #define LTTNG_COUNTER_DIMENSION_MAX 8 |
549 | ||
550 | struct lttng_counter_dimension { | |
551 | uint64_t size; | |
552 | uint64_t underflow_index; | |
553 | uint64_t overflow_index; | |
554 | uint8_t has_underflow; | |
555 | uint8_t has_overflow; | |
556 | }; | |
557 | ||
558 | struct lttng_counter_ops { | |
559 | struct lib_counter *(*counter_create)(size_t nr_dimensions, | |
560 | const struct lttng_counter_dimension *dimensions, | |
561 | int64_t global_sum_step, | |
562 | int global_counter_fd, | |
563 | int nr_counter_cpu_fds, | |
564 | const int *counter_cpu_fds, | |
565 | bool is_daemon); | |
566 | void (*counter_destroy)(struct lib_counter *counter); | |
567 | int (*counter_add)(struct lib_counter *counter, | |
568 | const size_t *dimension_indexes, int64_t v); | |
569 | int (*counter_read)(struct lib_counter *counter, | |
570 | const size_t *dimension_indexes, int cpu, | |
571 | int64_t *value, bool *overflow, bool *underflow); | |
572 | int (*counter_aggregate)(struct lib_counter *counter, | |
573 | const size_t *dimension_indexes, int64_t *value, | |
574 | bool *overflow, bool *underflow); | |
575 | int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes); | |
576 | }; | |
577 | ||
53569322 MD |
578 | #define LTTNG_UST_STACK_CTX_PADDING 32 |
579 | struct lttng_stack_ctx { | |
580 | struct lttng_event *event; | |
581 | struct lttng_ctx *chan_ctx; /* RCU dereferenced. */ | |
582 | struct lttng_ctx *event_ctx; /* RCU dereferenced. */ | |
583 | char padding[LTTNG_UST_STACK_CTX_PADDING]; | |
584 | }; | |
585 | ||
71a9d034 | 586 | #define LTTNG_UST_EVENT_HT_BITS 12 |
e58095ef MD |
587 | #define LTTNG_UST_EVENT_HT_SIZE (1U << LTTNG_UST_EVENT_HT_BITS) |
588 | ||
589 | struct lttng_ust_event_ht { | |
590 | struct cds_hlist_head table[LTTNG_UST_EVENT_HT_SIZE]; | |
591 | }; | |
592 | ||
d8d2416d FD |
593 | #define LTTNG_UST_EVENT_NOTIFIER_HT_BITS 12 |
594 | #define LTTNG_UST_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_UST_EVENT_NOTIFIER_HT_BITS) | |
595 | struct lttng_ust_event_notifier_ht { | |
596 | struct cds_hlist_head table[LTTNG_UST_EVENT_NOTIFIER_HT_SIZE]; | |
597 | }; | |
598 | ||
c785c634 MD |
599 | #define LTTNG_UST_ENUM_HT_BITS 12 |
600 | #define LTTNG_UST_ENUM_HT_SIZE (1U << LTTNG_UST_ENUM_HT_BITS) | |
601 | ||
602 | struct lttng_ust_enum_ht { | |
603 | struct cds_hlist_head table[LTTNG_UST_ENUM_HT_SIZE]; | |
604 | }; | |
605 | ||
180901e6 MD |
606 | /* |
607 | * IMPORTANT: this structure is part of the ABI between the probe and | |
608 | * UST. Fields need to be only added at the end, never reordered, never | |
609 | * removed. | |
610 | */ | |
7dd08bec | 611 | struct lttng_session { |
e58095ef MD |
612 | int active; /* Is trace session active ? */ |
613 | int been_active; /* Been active ? */ | |
614 | int objd; /* Object associated */ | |
e58095ef MD |
615 | struct cds_list_head chan_head; /* Channel list head */ |
616 | struct cds_list_head events_head; /* list of events */ | |
e58095ef | 617 | struct cds_list_head node; /* Session list */ |
e58095ef MD |
618 | |
619 | /* New UST 2.1 */ | |
620 | /* List of enablers */ | |
621 | struct cds_list_head enablers_head; | |
d56fa719 | 622 | struct lttng_ust_event_ht events_ht; /* ht of events */ |
32ce8569 | 623 | void *owner; /* object owner */ |
ac6b4ac6 | 624 | int tstate:1; /* Transient enable state */ |
246be17e PW |
625 | |
626 | /* New UST 2.4 */ | |
627 | int statedump_pending:1; | |
c785c634 MD |
628 | |
629 | /* New UST 2.8 */ | |
630 | struct lttng_ust_enum_ht enums_ht; /* ht of enumerations */ | |
631 | struct cds_list_head enums_head; | |
53569322 | 632 | struct lttng_ctx *ctx; /* contexts for filters. */ |
8020ceb5 MD |
633 | }; |
634 | ||
ebabbf58 MD |
635 | struct lttng_counter { |
636 | int objd; | |
637 | struct lttng_event_notifier_group *event_notifier_group; /* owner */ | |
638 | struct lttng_counter_transport *transport; | |
639 | struct lib_counter *counter; | |
640 | struct lttng_counter_ops *ops; | |
641 | }; | |
642 | ||
d8d2416d FD |
643 | struct lttng_event_notifier_group { |
644 | int objd; | |
645 | void *owner; | |
646 | int notification_fd; | |
647 | struct cds_list_head node; /* Event notifier group handle list */ | |
648 | struct cds_list_head enablers_head; | |
649 | struct cds_list_head event_notifiers_head; /* list of event_notifiers */ | |
650 | struct lttng_ust_event_notifier_ht event_notifiers_ht; /* hashtable of event_notifiers */ | |
651 | struct lttng_ctx *ctx; /* contexts for filters. */ | |
ebabbf58 MD |
652 | |
653 | struct lttng_counter *error_counter; | |
654 | size_t error_counter_len; | |
d8d2416d FD |
655 | }; |
656 | ||
7dd08bec | 657 | struct lttng_transport { |
8020ceb5 | 658 | char *name; |
9f3fdbc6 | 659 | struct cds_list_head node; |
7dd08bec | 660 | struct lttng_channel_ops ops; |
74d81a6c | 661 | const struct lttng_ust_lib_ring_buffer_config *client_config; |
8020ceb5 MD |
662 | }; |
663 | ||
ebabbf58 MD |
664 | struct lttng_counter_transport { |
665 | char *name; | |
666 | struct cds_list_head node; | |
667 | struct lttng_counter_ops ops; | |
668 | const struct lib_counter_config *client_config; | |
669 | }; | |
670 | ||
7dd08bec MD |
671 | struct lttng_session *lttng_session_create(void); |
672 | int lttng_session_enable(struct lttng_session *session); | |
673 | int lttng_session_disable(struct lttng_session *session); | |
710b8ee3 | 674 | int lttng_session_statedump(struct lttng_session *session); |
7dd08bec | 675 | void lttng_session_destroy(struct lttng_session *session); |
8020ceb5 | 676 | |
7dd08bec | 677 | struct lttng_channel *lttng_channel_create(struct lttng_session *session, |
8020ceb5 MD |
678 | const char *transport_name, |
679 | void *buf_addr, | |
680 | size_t subbuf_size, size_t num_subbuf, | |
681 | unsigned int switch_timer_interval, | |
193183fb | 682 | unsigned int read_timer_interval, |
ef9ff354 MD |
683 | int **shm_fd, int **wait_fd, |
684 | uint64_t **memory_map_size, | |
7dd08bec | 685 | struct lttng_channel *chan_priv_init); |
8020ceb5 | 686 | |
7dd08bec MD |
687 | int lttng_channel_enable(struct lttng_channel *channel); |
688 | int lttng_channel_disable(struct lttng_channel *channel); | |
e58095ef | 689 | |
7dd08bec MD |
690 | void lttng_transport_register(struct lttng_transport *transport); |
691 | void lttng_transport_unregister(struct lttng_transport *transport); | |
8020ceb5 | 692 | |
7dd08bec MD |
693 | int lttng_probe_register(struct lttng_probe_desc *desc); |
694 | void lttng_probe_unregister(struct lttng_probe_desc *desc); | |
35ac38cb | 695 | void lttng_probe_provider_unregister_events(struct lttng_probe_desc *desc); |
5f733922 | 696 | int lttng_fix_pending_events(void); |
7dd08bec MD |
697 | int lttng_probes_init(void); |
698 | void lttng_probes_exit(void); | |
9f3fdbc6 | 699 | |
fc80554e MJ |
700 | /* |
701 | * Can be used by applications that change their procname to clear the ust cached value. | |
702 | */ | |
703 | void lttng_context_procname_reset(void); | |
d58d1454 | 704 | |
7dd08bec | 705 | struct lttng_transport *lttng_transport_find(const char *name); |
c1fca457 | 706 | |
7dd08bec MD |
707 | int lttng_probes_get_event_list(struct lttng_ust_tracepoint_list *list); |
708 | void lttng_probes_prune_event_list(struct lttng_ust_tracepoint_list *list); | |
c8fcf224 MD |
709 | struct lttng_ust_tracepoint_iter * |
710 | lttng_ust_tracepoint_list_get_iter_next(struct lttng_ust_tracepoint_list *list); | |
7dd08bec MD |
711 | int lttng_probes_get_field_list(struct lttng_ust_field_list *list); |
712 | void lttng_probes_prune_field_list(struct lttng_ust_field_list *list); | |
06d4f27e MD |
713 | struct lttng_ust_field_iter * |
714 | lttng_ust_field_list_get_iter_next(struct lttng_ust_field_list *list); | |
c8fcf224 | 715 | |
7dd08bec | 716 | void lttng_free_event_filter_runtime(struct lttng_event *event); |
e58095ef MD |
717 | |
718 | struct cds_list_head *lttng_get_probe_list_head(void); | |
6715d7d1 | 719 | int lttng_session_active(void); |
e6c12e3d | 720 | |
246be17e | 721 | typedef int (*t_statedump_func_ptr)(struct lttng_session *session); |
3327ac33 | 722 | void lttng_handle_pending_statedump(void *owner); |
37dddb65 | 723 | struct cds_list_head *_lttng_get_sessions(void); |
b33b46f7 FD |
724 | |
725 | struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session, | |
726 | const struct lttng_enum_desc *enum_desc); | |
246be17e | 727 | |
97c7c238 MD |
728 | void lttng_ust_dl_update(void *ip); |
729 | ||
6453d237 MD |
730 | #ifdef __cplusplus |
731 | } | |
732 | #endif | |
733 | ||
51489cad | 734 | #endif /* _LTTNG_UST_EVENTS_H */ |