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; |
25cff019 | 46 | struct lttng_ust_event_field; |
ebabbf58 | 47 | struct lttng_event_notifier_group; |
8020ceb5 | 48 | |
37d5e202 MD |
49 | /* |
50 | * Data structures used by tracepoint event declarations, and by the | |
51 | * tracer. Those structures have padding for future extension. | |
52 | */ | |
53 | ||
8020ceb5 MD |
54 | /* Type description */ |
55 | ||
56 | /* Update the astract_types name table in lttng-types.c along with this enum */ | |
7dd08bec | 57 | enum lttng_abstract_types { |
8020ceb5 | 58 | atype_integer, |
8020ceb5 | 59 | atype_string, |
20f1eee7 | 60 | atype_float, |
53569322 | 61 | atype_dynamic, |
218deb69 MD |
62 | atype_enum_nestable, |
63 | atype_array_nestable, | |
64 | atype_sequence_nestable, | |
65 | atype_struct_nestable, | |
8020ceb5 MD |
66 | NR_ABSTRACT_TYPES, |
67 | }; | |
68 | ||
69 | /* Update the string_encodings name table in lttng-types.c along with this enum */ | |
70 | enum lttng_string_encodings { | |
71 | lttng_encode_none = 0, | |
72 | lttng_encode_UTF8 = 1, | |
73 | lttng_encode_ASCII = 2, | |
74 | NR_STRING_ENCODINGS, | |
75 | }; | |
76 | ||
a6f80644 MD |
77 | struct lttng_enum_value { |
78 | unsigned long long value; | |
79 | unsigned int signedness:1; | |
80 | }; | |
81 | ||
3e762260 PP |
82 | enum lttng_enum_entry_options { |
83 | LTTNG_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0, | |
84 | }; | |
85 | ||
37d5e202 | 86 | #define LTTNG_UST_ENUM_ENTRY_PADDING 16 |
8020ceb5 | 87 | struct lttng_enum_entry { |
a6f80644 | 88 | struct lttng_enum_value start, end; /* start and end are inclusive */ |
8020ceb5 | 89 | const char *string; |
3e762260 PP |
90 | union { |
91 | struct { | |
92 | unsigned int options; | |
93 | } LTTNG_PACKED extra; | |
94 | char padding[LTTNG_UST_ENUM_ENTRY_PADDING]; | |
95 | } u; | |
8020ceb5 MD |
96 | }; |
97 | ||
98 | #define __type_integer(_type, _byte_order, _base, _encoding) \ | |
99 | { \ | |
46d52200 ZT |
100 | .atype = atype_integer, \ |
101 | .u = \ | |
8020ceb5 | 102 | { \ |
218deb69 | 103 | .integer = \ |
46d52200 | 104 | { \ |
218deb69 MD |
105 | .size = sizeof(_type) * CHAR_BIT, \ |
106 | .alignment = lttng_alignof(_type) * CHAR_BIT, \ | |
107 | .signedness = lttng_is_signed_type(_type), \ | |
108 | .reverse_byte_order = _byte_order != BYTE_ORDER, \ | |
109 | .base = _base, \ | |
110 | .encoding = lttng_encode_##_encoding, \ | |
46d52200 | 111 | } \ |
8020ceb5 MD |
112 | }, \ |
113 | } \ | |
114 | ||
37d5e202 | 115 | #define LTTNG_UST_INTEGER_TYPE_PADDING 24 |
8020ceb5 MD |
116 | struct lttng_integer_type { |
117 | unsigned int size; /* in bits */ | |
118 | unsigned short alignment; /* in bits */ | |
119 | unsigned int signedness:1; | |
120 | unsigned int reverse_byte_order:1; | |
121 | unsigned int base; /* 2, 8, 10, 16, for pretty print */ | |
122 | enum lttng_string_encodings encoding; | |
37d5e202 | 123 | char padding[LTTNG_UST_INTEGER_TYPE_PADDING]; |
8020ceb5 MD |
124 | }; |
125 | ||
d3ed854b MD |
126 | /* |
127 | * Only float and double are supported. long double is not supported at | |
128 | * the moment. | |
129 | */ | |
20f1eee7 MD |
130 | #define _float_mant_dig(_type) \ |
131 | (sizeof(_type) == sizeof(float) ? FLT_MANT_DIG \ | |
132 | : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG \ | |
d3ed854b | 133 | : 0)) |
20f1eee7 MD |
134 | |
135 | #define __type_float(_type) \ | |
136 | { \ | |
46d52200 ZT |
137 | .atype = atype_float, \ |
138 | .u = \ | |
20f1eee7 | 139 | { \ |
218deb69 | 140 | ._float = \ |
46d52200 | 141 | { \ |
218deb69 MD |
142 | .exp_dig = sizeof(_type) * CHAR_BIT \ |
143 | - _float_mant_dig(_type), \ | |
144 | .mant_dig = _float_mant_dig(_type), \ | |
145 | .alignment = lttng_alignof(_type) * CHAR_BIT, \ | |
146 | .reverse_byte_order = BYTE_ORDER != FLOAT_WORD_ORDER, \ | |
46d52200 | 147 | } \ |
218deb69 | 148 | } \ |
20f1eee7 MD |
149 | } \ |
150 | ||
37d5e202 | 151 | #define LTTNG_UST_FLOAT_TYPE_PADDING 24 |
20f1eee7 MD |
152 | struct lttng_float_type { |
153 | unsigned int exp_dig; /* exponent digits, in bits */ | |
154 | unsigned int mant_dig; /* mantissa digits, in bits */ | |
155 | unsigned short alignment; /* in bits */ | |
156 | unsigned int reverse_byte_order:1; | |
37d5e202 | 157 | char padding[LTTNG_UST_FLOAT_TYPE_PADDING]; |
20f1eee7 MD |
158 | }; |
159 | ||
37d5e202 | 160 | #define LTTNG_UST_TYPE_PADDING 128 |
8020ceb5 | 161 | struct lttng_type { |
7dd08bec | 162 | enum lttng_abstract_types atype; |
8020ceb5 | 163 | union { |
218deb69 MD |
164 | /* provider ABI 2.0 */ |
165 | struct lttng_integer_type integer; | |
166 | struct lttng_float_type _float; | |
167 | struct { | |
168 | enum lttng_string_encodings encoding; | |
169 | } string; | |
170 | struct { | |
171 | const struct lttng_enum_desc *desc; /* Enumeration mapping */ | |
172 | struct lttng_type *container_type; | |
173 | } enum_nestable; | |
8020ceb5 | 174 | struct { |
218deb69 MD |
175 | const struct lttng_type *elem_type; |
176 | unsigned int length; /* Num. elems. */ | |
177 | unsigned int alignment; | |
178 | } array_nestable; | |
8020ceb5 | 179 | struct { |
218deb69 MD |
180 | const char *length_name; /* Length field name. */ |
181 | const struct lttng_type *elem_type; | |
182 | unsigned int alignment; /* Alignment before elements. */ | |
183 | } sequence_nestable; | |
53569322 | 184 | struct { |
218deb69 | 185 | unsigned int nr_fields; |
25cff019 | 186 | const struct lttng_ust_event_field **fields; /* Array of pointers to fields. */ |
218deb69 MD |
187 | unsigned int alignment; |
188 | } struct_nestable; | |
189 | ||
37d5e202 | 190 | char padding[LTTNG_UST_TYPE_PADDING]; |
8020ceb5 MD |
191 | } u; |
192 | }; | |
193 | ||
37d5e202 | 194 | #define LTTNG_UST_ENUM_TYPE_PADDING 24 |
c785c634 | 195 | struct lttng_enum_desc { |
8020ceb5 | 196 | const char *name; |
8020ceb5 | 197 | const struct lttng_enum_entry *entries; |
c785c634 | 198 | unsigned int nr_entries; |
37d5e202 | 199 | char padding[LTTNG_UST_ENUM_TYPE_PADDING]; |
8020ceb5 MD |
200 | }; |
201 | ||
180901e6 MD |
202 | /* |
203 | * Event field description | |
204 | * | |
205 | * IMPORTANT: this structure is part of the ABI between the probe and | |
206 | * UST. Fields need to be only added at the end, never reordered, never | |
207 | * removed. | |
25cff019 MD |
208 | * |
209 | * The field @struct_size should be used to determine the size of the | |
210 | * structure. It should be queried before using additional fields added | |
211 | * at the end of the structure. | |
180901e6 | 212 | */ |
8020ceb5 | 213 | |
25cff019 MD |
214 | struct lttng_ust_event_field { |
215 | uint32_t struct_size; | |
216 | ||
8020ceb5 MD |
217 | const char *name; |
218 | struct lttng_type type; | |
25cff019 MD |
219 | unsigned int nowrite:1, /* do not write into trace */ |
220 | nofilter:1; /* do not consider for filter */ | |
221 | ||
222 | /* End of base ABI. Fields below should be used after checking struct_size. */ | |
8020ceb5 MD |
223 | }; |
224 | ||
53569322 MD |
225 | enum lttng_ust_dynamic_type { |
226 | LTTNG_UST_DYNAMIC_TYPE_NONE, | |
227 | LTTNG_UST_DYNAMIC_TYPE_S8, | |
228 | LTTNG_UST_DYNAMIC_TYPE_S16, | |
229 | LTTNG_UST_DYNAMIC_TYPE_S32, | |
230 | LTTNG_UST_DYNAMIC_TYPE_S64, | |
231 | LTTNG_UST_DYNAMIC_TYPE_U8, | |
232 | LTTNG_UST_DYNAMIC_TYPE_U16, | |
233 | LTTNG_UST_DYNAMIC_TYPE_U32, | |
234 | LTTNG_UST_DYNAMIC_TYPE_U64, | |
235 | LTTNG_UST_DYNAMIC_TYPE_FLOAT, | |
236 | LTTNG_UST_DYNAMIC_TYPE_DOUBLE, | |
237 | LTTNG_UST_DYNAMIC_TYPE_STRING, | |
238 | _NR_LTTNG_UST_DYNAMIC_TYPES, | |
239 | }; | |
240 | ||
241 | struct lttng_ctx_value { | |
242 | enum lttng_ust_dynamic_type sel; | |
243 | union { | |
244 | int64_t s64; | |
86133caf | 245 | uint64_t u64; |
53569322 MD |
246 | const char *str; |
247 | double d; | |
248 | } u; | |
77aa5901 MD |
249 | }; |
250 | ||
d58d1454 MD |
251 | struct lttng_perf_counter_field; |
252 | ||
37d5e202 | 253 | #define LTTNG_UST_CTX_FIELD_PADDING 40 |
8020ceb5 | 254 | struct lttng_ctx_field { |
25cff019 | 255 | struct lttng_ust_event_field event_field; |
53569322 | 256 | size_t (*get_size)(struct lttng_ctx_field *field, size_t offset); |
8020ceb5 | 257 | void (*record)(struct lttng_ctx_field *field, |
4cfec15c | 258 | struct lttng_ust_lib_ring_buffer_ctx *ctx, |
7dd08bec | 259 | struct lttng_channel *chan); |
77aa5901 | 260 | void (*get_value)(struct lttng_ctx_field *field, |
53569322 | 261 | struct lttng_ctx_value *value); |
8020ceb5 | 262 | union { |
d58d1454 | 263 | struct lttng_perf_counter_field *perf_counter; |
37d5e202 | 264 | char padding[LTTNG_UST_CTX_FIELD_PADDING]; |
8020ceb5 MD |
265 | } u; |
266 | void (*destroy)(struct lttng_ctx_field *field); | |
53569322 | 267 | char *field_name; /* Has ownership, dynamically allocated. */ |
8020ceb5 MD |
268 | }; |
269 | ||
b2cc986a | 270 | #define LTTNG_UST_CTX_PADDING 20 |
8020ceb5 MD |
271 | struct lttng_ctx { |
272 | struct lttng_ctx_field *fields; | |
273 | unsigned int nr_fields; | |
274 | unsigned int allocated_fields; | |
b2cc986a | 275 | unsigned int largest_align; |
37d5e202 MD |
276 | char padding[LTTNG_UST_CTX_PADDING]; |
277 | }; | |
278 | ||
dc11f93f MD |
279 | /* |
280 | * IMPORTANT: this structure is part of the ABI between the probe and | |
281 | * UST. Fields need to be only added at the end, never reordered, never | |
282 | * removed. | |
283 | * | |
284 | * The field @struct_size should be used to determine the size of the | |
285 | * structure. It should be queried before using additional fields added | |
286 | * at the end of the structure. | |
287 | */ | |
288 | struct lttng_ust_event_desc { | |
289 | uint32_t struct_size; /* Size of this structure. */ | |
37d5e202 | 290 | const char *name; |
fbdeb5ec | 291 | void (*probe_callback)(void); |
37d5e202 | 292 | const struct lttng_event_ctx *ctx; /* context */ |
25cff019 | 293 | const struct lttng_ust_event_field **fields; /* event payload */ |
37d5e202 MD |
294 | unsigned int nr_fields; |
295 | const int **loglevel; | |
dc11f93f MD |
296 | const char *signature; /* Argument types/names received */ |
297 | const char **model_emf_uri; | |
298 | ||
299 | /* End of base ABI. Fields below should be used after checking struct_size. */ | |
37d5e202 MD |
300 | }; |
301 | ||
dc11f93f MD |
302 | /* |
303 | * IMPORTANT: this structure is part of the ABI between the probe and | |
304 | * UST. Fields need to be only added at the end, never reordered, never | |
305 | * removed. | |
306 | * | |
307 | * The field @struct_size should be used to determine the size of the | |
308 | * structure. It should be queried before using additional fields added | |
309 | * at the end of the structure. | |
310 | */ | |
311 | struct lttng_ust_probe_desc { | |
312 | uint32_t struct_size; /* Size of this structure. */ | |
313 | ||
37d5e202 | 314 | const char *provider; |
dc11f93f | 315 | const struct lttng_ust_event_desc **event_desc; |
37d5e202 MD |
316 | unsigned int nr_events; |
317 | struct cds_list_head head; /* chain registered probes */ | |
6715d7d1 MD |
318 | struct cds_list_head lazy_init_head; |
319 | int lazy; /* lazy registration */ | |
71d31690 MD |
320 | uint32_t major; |
321 | uint32_t minor; | |
dc11f93f MD |
322 | |
323 | /* End of base ABI. Fields below should be used after checking struct_size. */ | |
8020ceb5 MD |
324 | }; |
325 | ||
37d5e202 MD |
326 | /* Data structures used by the tracer. */ |
327 | ||
8a92ed2a | 328 | /* |
04aa13f8 | 329 | * Bytecode interpreter return value masks. |
8a92ed2a | 330 | */ |
04aa13f8 FD |
331 | enum lttng_bytecode_interpreter_ret { |
332 | LTTNG_INTERPRETER_DISCARD = 0, | |
333 | LTTNG_INTERPRETER_RECORD_FLAG = (1ULL << 0), | |
8a92ed2a MD |
334 | /* Other bits are kept for future use. */ |
335 | }; | |
336 | ||
d37ecb3f | 337 | struct lttng_interpreter_output; |
362a65de | 338 | struct lttng_ust_bytecode_runtime_private; |
d37ecb3f | 339 | |
73d37531 | 340 | /* |
362a65de MD |
341 | * This structure is used in the probes. More specifically, the |
342 | * `interpreter_funcs` and `node` fields are explicity used in the | |
343 | * probes. When modifying this structure we must not change the layout | |
344 | * of these two fields as it is considered ABI. | |
73d37531 | 345 | */ |
f488575f | 346 | struct lttng_bytecode_runtime { |
362a65de MD |
347 | struct lttng_ust_bytecode_runtime_private *priv; |
348 | ||
f488575f | 349 | /* Associated bytecode */ |
c42416df FD |
350 | union { |
351 | uint64_t (*filter)(void *interpreter_data, | |
352 | const char *interpreter_stack_data); | |
d37ecb3f FD |
353 | uint64_t (*capture)(void *interpreter_data, |
354 | const char *interpreter_stack_data, | |
355 | struct lttng_interpreter_output *interpreter_output); | |
c42416df | 356 | } interpreter_funcs; |
e58095ef MD |
357 | struct cds_list_head node; /* list of bytecode runtime in event */ |
358 | }; | |
359 | ||
8020ceb5 | 360 | /* |
7dd08bec MD |
361 | * lttng_event structure is referred to by the tracing fast path. It |
362 | * must be kept small. | |
180901e6 MD |
363 | * |
364 | * IMPORTANT: this structure is part of the ABI between the probe and | |
365 | * UST. Fields need to be only added at the end, never reordered, never | |
366 | * removed. | |
8020ceb5 | 367 | */ |
68bb7559 | 368 | |
80333dfa MD |
369 | struct lttng_ust_event_common_private; |
370 | ||
808edfc8 MD |
371 | enum lttng_ust_event_type { |
372 | LTTNG_UST_EVENT_TYPE_RECORDER = 0, | |
373 | LTTNG_UST_EVENT_TYPE_NOTIFIER = 1, | |
374 | }; | |
375 | ||
93cfd247 | 376 | /* |
6d35572a MD |
377 | * IMPORTANT: this structure is part of the ABI between the probe and |
378 | * UST. Fields need to be only added at the end, never reordered, never | |
379 | * removed. | |
380 | * | |
93cfd247 MD |
381 | * struct lttng_ust_event_common is the common ancestor of the various |
382 | * public event actions. Inheritance is done by composition: The parent | |
383 | * has a pointer to its child, and the child has a pointer to its | |
384 | * parent. Inheritance of those public structures is done by composition | |
385 | * to ensure both parent and child structures can be extended. | |
386 | * | |
387 | * The field @struct_size should be used to determine the size of the | |
388 | * structure. It should be queried before using additional fields added | |
389 | * at the end of the structure. | |
390 | */ | |
7ee76145 | 391 | struct lttng_ust_event_common { |
80333dfa MD |
392 | uint32_t struct_size; /* Size of this structure. */ |
393 | struct lttng_ust_event_common_private *priv; /* Private event interface */ | |
394 | ||
808edfc8 | 395 | enum lttng_ust_event_type type; |
ba99fbe2 MD |
396 | void *child; /* Pointer to child, for inheritance by aggregation. */ |
397 | ||
80333dfa MD |
398 | int enabled; |
399 | int has_enablers_without_bytecode; | |
400 | /* list of struct lttng_bytecode_runtime, sorted by seqnum */ | |
401 | struct cds_list_head filter_bytecode_runtime_head; | |
93cfd247 MD |
402 | |
403 | /* End of base ABI. Fields below should be used after checking struct_size. */ | |
80333dfa MD |
404 | }; |
405 | ||
2e70391c | 406 | struct lttng_ust_event_recorder_private; |
68bb7559 | 407 | |
93cfd247 | 408 | /* |
6d35572a MD |
409 | * IMPORTANT: this structure is part of the ABI between the probe and |
410 | * UST. Fields need to be only added at the end, never reordered, never | |
411 | * removed. | |
412 | * | |
93cfd247 MD |
413 | * struct lttng_ust_event_recorder is the action for recording events |
414 | * into a ring buffer. It inherits from struct lttng_ust_event_common | |
415 | * by composition to ensure both parent and child structure are | |
416 | * extensible. | |
417 | * | |
418 | * The field @struct_size should be used to determine the size of the | |
419 | * structure. It should be queried before using additional fields added | |
420 | * at the end of the structure. | |
421 | */ | |
2e70391c MD |
422 | struct lttng_ust_event_recorder { |
423 | uint32_t struct_size; /* Size of this structure. */ | |
ba99fbe2 | 424 | struct lttng_ust_event_common *parent; /* Inheritance by aggregation. */ |
2e70391c | 425 | struct lttng_ust_event_recorder_private *priv; /* Private event record interface */ |
68bb7559 | 426 | |
8020ceb5 | 427 | unsigned int id; |
68bb7559 MD |
428 | struct lttng_channel *chan; |
429 | struct lttng_ctx *ctx; | |
93cfd247 MD |
430 | |
431 | /* End of base ABI. Fields below should be used after checking struct_size. */ | |
8020ceb5 MD |
432 | }; |
433 | ||
115db533 MD |
434 | struct lttng_ust_event_notifier_private; |
435 | ||
93cfd247 | 436 | /* |
6d35572a MD |
437 | * IMPORTANT: this structure is part of the ABI between the probe and |
438 | * UST. Fields need to be only added at the end, never reordered, never | |
439 | * removed. | |
440 | * | |
93cfd247 MD |
441 | * struct lttng_ust_event_notifier is the action for sending |
442 | * notifications. It inherits from struct lttng_ust_event_common | |
443 | * by composition to ensure both parent and child structure are | |
444 | * extensible. | |
445 | * | |
446 | * The field @struct_size should be used to determine the size of the | |
447 | * structure. It should be queried before using additional fields added | |
448 | * at the end of the structure. | |
449 | */ | |
d7d45c0d | 450 | struct lttng_ust_event_notifier { |
115db533 | 451 | uint32_t struct_size; /* Size of this structure. */ |
ba99fbe2 | 452 | struct lttng_ust_event_common *parent; /* Inheritance by aggregation. */ |
115db533 MD |
453 | struct lttng_ust_event_notifier_private *priv; /* Private event notifier interface */ |
454 | ||
d7d45c0d | 455 | void (*notification_send)(struct lttng_ust_event_notifier *event_notifier, |
cab88ff8 | 456 | const char *stack_data); |
d37ecb3f | 457 | struct cds_list_head capture_bytecode_runtime_head; |
93cfd247 MD |
458 | |
459 | /* End of base ABI. Fields below should be used after checking struct_size. */ | |
d8d2416d FD |
460 | }; |
461 | ||
c785c634 MD |
462 | struct lttng_enum { |
463 | const struct lttng_enum_desc *desc; | |
464 | struct lttng_session *session; | |
465 | struct cds_list_head node; /* Enum list in session */ | |
466 | struct cds_hlist_node hlist; /* Session ht of enums */ | |
467 | uint64_t id; /* Enumeration ID in sessiond */ | |
468 | }; | |
469 | ||
8d8a24c8 | 470 | struct channel; |
38fae1d3 | 471 | struct lttng_ust_shm_handle; |
8d8a24c8 | 472 | |
180901e6 MD |
473 | /* |
474 | * IMPORTANT: this structure is part of the ABI between the probe and | |
475 | * UST. Fields need to be only added at the end, never reordered, never | |
476 | * removed. | |
477 | */ | |
7dd08bec MD |
478 | struct lttng_channel_ops { |
479 | struct lttng_channel *(*channel_create)(const char *name, | |
74d81a6c MD |
480 | void *buf_addr, |
481 | size_t subbuf_size, size_t num_subbuf, | |
482 | unsigned int switch_timer_interval, | |
483 | unsigned int read_timer_interval, | |
6ca18e66 | 484 | unsigned char *uuid, |
a9ff648c | 485 | uint32_t chan_id, |
b2c5f61a MD |
486 | const int *stream_fds, int nr_stream_fds, |
487 | int64_t blocking_timeout); | |
74d81a6c | 488 | void (*channel_destroy)(struct lttng_channel *chan); |
4cfec15c | 489 | int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
8020ceb5 | 490 | uint32_t event_id); |
4cfec15c | 491 | void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx); |
74d81a6c MD |
492 | void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
493 | const void *src, size_t len); | |
8020ceb5 MD |
494 | /* |
495 | * packet_avail_size returns the available size in the current | |
496 | * packet. Note that the size returned is only a hint, since it | |
497 | * may change due to concurrent writes. | |
498 | */ | |
1d498196 | 499 | size_t (*packet_avail_size)(struct channel *chan, |
38fae1d3 | 500 | struct lttng_ust_shm_handle *handle); |
8020ceb5 MD |
501 | int (*is_finalized)(struct channel *chan); |
502 | int (*is_disabled)(struct channel *chan); | |
38fae1d3 | 503 | int (*flush_buffer)(struct channel *chan, struct lttng_ust_shm_handle *handle); |
a44c74d9 MD |
504 | void (*event_strcpy)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
505 | const char *src, size_t len); | |
8020ceb5 MD |
506 | }; |
507 | ||
180901e6 MD |
508 | /* |
509 | * IMPORTANT: this structure is part of the ABI between the probe and | |
510 | * UST. Fields need to be only added at the end, never reordered, never | |
511 | * removed. | |
512 | */ | |
7dd08bec | 513 | struct lttng_channel { |
a3f61e7f MD |
514 | /* |
515 | * The pointers located in this private data are NOT safe to be | |
516 | * dereferenced by the consumer. The only operations the | |
517 | * consumer process is designed to be allowed to do is to read | |
518 | * and perform subbuffer flush. | |
519 | */ | |
8020ceb5 | 520 | struct channel *chan; /* Channel buffers */ |
976fe9ea | 521 | int enabled; |
8020ceb5 MD |
522 | struct lttng_ctx *ctx; |
523 | /* Event ID management */ | |
7dd08bec | 524 | struct lttng_session *session; |
0a42beb6 | 525 | int objd; /* Object associated to channel */ |
e58095ef | 526 | struct cds_list_head node; /* Channel list in session */ |
74d81a6c | 527 | const struct lttng_channel_ops *ops; |
8020ceb5 | 528 | int header_type; /* 0: unset, 1: compact, 2: large */ |
38fae1d3 | 529 | struct lttng_ust_shm_handle *handle; /* shared-memory handle */ |
a3f61e7f | 530 | |
74d81a6c | 531 | /* Channel ID */ |
a3f61e7f | 532 | unsigned int id; |
fd17d7ce | 533 | enum lttng_ust_abi_chan_type type; |
19d8b1b3 | 534 | unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ |
ac6b4ac6 | 535 | int tstate:1; /* Transient enable state */ |
8020ceb5 MD |
536 | }; |
537 | ||
bb7ad29d | 538 | struct lttng_counter_dimension; |
ebabbf58 MD |
539 | |
540 | struct lttng_counter_ops { | |
541 | struct lib_counter *(*counter_create)(size_t nr_dimensions, | |
542 | const struct lttng_counter_dimension *dimensions, | |
543 | int64_t global_sum_step, | |
544 | int global_counter_fd, | |
545 | int nr_counter_cpu_fds, | |
546 | const int *counter_cpu_fds, | |
547 | bool is_daemon); | |
548 | void (*counter_destroy)(struct lib_counter *counter); | |
549 | int (*counter_add)(struct lib_counter *counter, | |
550 | const size_t *dimension_indexes, int64_t v); | |
551 | int (*counter_read)(struct lib_counter *counter, | |
552 | const size_t *dimension_indexes, int cpu, | |
553 | int64_t *value, bool *overflow, bool *underflow); | |
554 | int (*counter_aggregate)(struct lib_counter *counter, | |
555 | const size_t *dimension_indexes, int64_t *value, | |
556 | bool *overflow, bool *underflow); | |
557 | int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes); | |
558 | }; | |
559 | ||
53569322 MD |
560 | #define LTTNG_UST_STACK_CTX_PADDING 32 |
561 | struct lttng_stack_ctx { | |
2e70391c | 562 | struct lttng_ust_event_recorder *event_recorder; |
53569322 MD |
563 | struct lttng_ctx *chan_ctx; /* RCU dereferenced. */ |
564 | struct lttng_ctx *event_ctx; /* RCU dereferenced. */ | |
565 | char padding[LTTNG_UST_STACK_CTX_PADDING]; | |
566 | }; | |
567 | ||
71a9d034 | 568 | #define LTTNG_UST_EVENT_HT_BITS 12 |
e58095ef MD |
569 | #define LTTNG_UST_EVENT_HT_SIZE (1U << LTTNG_UST_EVENT_HT_BITS) |
570 | ||
571 | struct lttng_ust_event_ht { | |
572 | struct cds_hlist_head table[LTTNG_UST_EVENT_HT_SIZE]; | |
573 | }; | |
574 | ||
d8d2416d FD |
575 | #define LTTNG_UST_EVENT_NOTIFIER_HT_BITS 12 |
576 | #define LTTNG_UST_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_UST_EVENT_NOTIFIER_HT_BITS) | |
577 | struct lttng_ust_event_notifier_ht { | |
578 | struct cds_hlist_head table[LTTNG_UST_EVENT_NOTIFIER_HT_SIZE]; | |
579 | }; | |
580 | ||
c785c634 MD |
581 | #define LTTNG_UST_ENUM_HT_BITS 12 |
582 | #define LTTNG_UST_ENUM_HT_SIZE (1U << LTTNG_UST_ENUM_HT_BITS) | |
583 | ||
584 | struct lttng_ust_enum_ht { | |
585 | struct cds_hlist_head table[LTTNG_UST_ENUM_HT_SIZE]; | |
586 | }; | |
587 | ||
bdb12629 MD |
588 | struct lttng_ust_session_private; |
589 | ||
180901e6 MD |
590 | /* |
591 | * IMPORTANT: this structure is part of the ABI between the probe and | |
592 | * UST. Fields need to be only added at the end, never reordered, never | |
593 | * removed. | |
6d35572a MD |
594 | * |
595 | * The field @struct_size should be used to determine the size of the | |
596 | * structure. It should be queried before using additional fields added | |
597 | * at the end of the structure. | |
180901e6 | 598 | */ |
7dd08bec | 599 | struct lttng_session { |
bd640d74 | 600 | uint32_t struct_size; /* Size of this structure */ |
bdb12629 MD |
601 | struct lttng_ust_session_private *priv; /* Private session interface */ |
602 | ||
e58095ef | 603 | int active; /* Is trace session active ? */ |
6d35572a MD |
604 | |
605 | /* End of base ABI. Fields below should be used after checking struct_size. */ | |
8020ceb5 MD |
606 | }; |
607 | ||
dc11f93f MD |
608 | int lttng_ust_probe_register(struct lttng_ust_probe_desc *desc); |
609 | void lttng_ust_probe_unregister(struct lttng_ust_probe_desc *desc); | |
9f3fdbc6 | 610 | |
fc80554e MJ |
611 | /* |
612 | * Can be used by applications that change their procname to clear the ust cached value. | |
613 | */ | |
614 | void lttng_context_procname_reset(void); | |
d58d1454 | 615 | |
7dd08bec | 616 | struct lttng_transport *lttng_transport_find(const char *name); |
c1fca457 | 617 | |
6715d7d1 | 618 | int lttng_session_active(void); |
e6c12e3d | 619 | |
97c7c238 MD |
620 | void lttng_ust_dl_update(void *ip); |
621 | ||
6453d237 MD |
622 | #ifdef __cplusplus |
623 | } | |
624 | #endif | |
625 | ||
51489cad | 626 | #endif /* _LTTNG_UST_EVENTS_H */ |