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