Commit | Line | Data |
---|---|---|
51489cad MD |
1 | #ifndef _LTTNG_UST_EVENTS_H |
2 | #define _LTTNG_UST_EVENTS_H | |
8020ceb5 MD |
3 | |
4 | /* | |
51489cad | 5 | * lttng/ust-events.h |
8020ceb5 | 6 | * |
e92f3e28 | 7 | * Copyright 2010-2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
8020ceb5 MD |
8 | * |
9 | * Holds LTTng per-session event registry. | |
10 | * | |
e92f3e28 MD |
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: | |
a60d70e6 | 17 | * |
e92f3e28 MD |
18 | * The above copyright notice and this permission notice shall be included in |
19 | * all copies or substantial portions of the Software. | |
d2428e87 MD |
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. | |
8020ceb5 MD |
28 | */ |
29 | ||
9f3fdbc6 | 30 | #include <urcu/list.h> |
1f18504e | 31 | #include <urcu/hlist.h> |
b4051ad8 | 32 | #include <stddef.h> |
9f3fdbc6 | 33 | #include <stdint.h> |
d58d1454 | 34 | #include <lttng/ust-config.h> |
4318ae1b MD |
35 | #include <lttng/ust-abi.h> |
36 | #include <lttng/ust-tracer.h> | |
2ae57758 | 37 | #include <lttng/ust-endian.h> |
20f1eee7 | 38 | #include <float.h> |
d58d1454 MD |
39 | #include <errno.h> |
40 | #include <urcu/ref.h> | |
41 | #include <pthread.h> | |
8020ceb5 | 42 | |
db56acaf MD |
43 | #ifndef LTTNG_PACKED |
44 | #error "LTTNG_PACKED should be defined" | |
45 | #endif | |
46 | ||
6453d237 MD |
47 | #ifdef __cplusplus |
48 | extern "C" { | |
49 | #endif | |
50 | ||
19d8b1b3 MD |
51 | #define LTTNG_UST_UUID_LEN 16 |
52 | ||
71d31690 MD |
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 1 | |
60 | #define LTTNG_UST_PROVIDER_MINOR 0 | |
61 | ||
7dd08bec MD |
62 | struct lttng_channel; |
63 | struct lttng_session; | |
4cfec15c | 64 | struct lttng_ust_lib_ring_buffer_ctx; |
53569322 MD |
65 | struct lttng_ust_context_app; |
66 | struct lttng_event_field; | |
8020ceb5 | 67 | |
37d5e202 MD |
68 | /* |
69 | * Data structures used by tracepoint event declarations, and by the | |
70 | * tracer. Those structures have padding for future extension. | |
71 | */ | |
72 | ||
c1fca457 MD |
73 | /* |
74 | * LTTng client type enumeration. Used by the consumer to map the | |
75 | * callbacks from its own address space. | |
76 | */ | |
77 | enum lttng_client_types { | |
78 | LTTNG_CLIENT_METADATA = 0, | |
79 | LTTNG_CLIENT_DISCARD = 1, | |
80 | LTTNG_CLIENT_OVERWRITE = 2, | |
34a91bdb MD |
81 | LTTNG_CLIENT_DISCARD_RT = 3, |
82 | LTTNG_CLIENT_OVERWRITE_RT = 4, | |
c1fca457 MD |
83 | LTTNG_NR_CLIENT_TYPES, |
84 | }; | |
85 | ||
8020ceb5 MD |
86 | /* Type description */ |
87 | ||
88 | /* Update the astract_types name table in lttng-types.c along with this enum */ | |
7dd08bec | 89 | enum lttng_abstract_types { |
8020ceb5 MD |
90 | atype_integer, |
91 | atype_enum, | |
92 | atype_array, | |
93 | atype_sequence, | |
94 | atype_string, | |
20f1eee7 | 95 | atype_float, |
53569322 MD |
96 | atype_dynamic, |
97 | atype_struct, | |
8020ceb5 MD |
98 | NR_ABSTRACT_TYPES, |
99 | }; | |
100 | ||
101 | /* Update the string_encodings name table in lttng-types.c along with this enum */ | |
102 | enum lttng_string_encodings { | |
103 | lttng_encode_none = 0, | |
104 | lttng_encode_UTF8 = 1, | |
105 | lttng_encode_ASCII = 2, | |
106 | NR_STRING_ENCODINGS, | |
107 | }; | |
108 | ||
a6f80644 MD |
109 | struct lttng_enum_value { |
110 | unsigned long long value; | |
111 | unsigned int signedness:1; | |
112 | }; | |
113 | ||
3e762260 PP |
114 | enum lttng_enum_entry_options { |
115 | LTTNG_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0, | |
116 | }; | |
117 | ||
37d5e202 | 118 | #define LTTNG_UST_ENUM_ENTRY_PADDING 16 |
8020ceb5 | 119 | struct lttng_enum_entry { |
a6f80644 | 120 | struct lttng_enum_value start, end; /* start and end are inclusive */ |
8020ceb5 | 121 | const char *string; |
3e762260 PP |
122 | union { |
123 | struct { | |
124 | unsigned int options; | |
125 | } LTTNG_PACKED extra; | |
126 | char padding[LTTNG_UST_ENUM_ENTRY_PADDING]; | |
127 | } u; | |
8020ceb5 MD |
128 | }; |
129 | ||
130 | #define __type_integer(_type, _byte_order, _base, _encoding) \ | |
131 | { \ | |
46d52200 ZT |
132 | .atype = atype_integer, \ |
133 | .u = \ | |
8020ceb5 | 134 | { \ |
46d52200 ZT |
135 | .basic = \ |
136 | { \ | |
137 | .integer = \ | |
138 | { \ | |
139 | .size = sizeof(_type) * CHAR_BIT, \ | |
140 | .alignment = lttng_alignof(_type) * CHAR_BIT, \ | |
141 | .signedness = lttng_is_signed_type(_type), \ | |
142 | .reverse_byte_order = _byte_order != BYTE_ORDER, \ | |
143 | .base = _base, \ | |
144 | .encoding = lttng_encode_##_encoding, \ | |
145 | } \ | |
146 | } \ | |
8020ceb5 MD |
147 | }, \ |
148 | } \ | |
149 | ||
37d5e202 | 150 | #define LTTNG_UST_INTEGER_TYPE_PADDING 24 |
8020ceb5 MD |
151 | struct lttng_integer_type { |
152 | unsigned int size; /* in bits */ | |
153 | unsigned short alignment; /* in bits */ | |
154 | unsigned int signedness:1; | |
155 | unsigned int reverse_byte_order:1; | |
156 | unsigned int base; /* 2, 8, 10, 16, for pretty print */ | |
157 | enum lttng_string_encodings encoding; | |
37d5e202 | 158 | char padding[LTTNG_UST_INTEGER_TYPE_PADDING]; |
8020ceb5 MD |
159 | }; |
160 | ||
d3ed854b MD |
161 | /* |
162 | * Only float and double are supported. long double is not supported at | |
163 | * the moment. | |
164 | */ | |
20f1eee7 MD |
165 | #define _float_mant_dig(_type) \ |
166 | (sizeof(_type) == sizeof(float) ? FLT_MANT_DIG \ | |
167 | : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG \ | |
d3ed854b | 168 | : 0)) |
20f1eee7 MD |
169 | |
170 | #define __type_float(_type) \ | |
171 | { \ | |
46d52200 ZT |
172 | .atype = atype_float, \ |
173 | .u = \ | |
20f1eee7 | 174 | { \ |
46d52200 ZT |
175 | .basic = \ |
176 | { \ | |
177 | ._float = \ | |
178 | { \ | |
179 | .exp_dig = sizeof(_type) * CHAR_BIT \ | |
180 | - _float_mant_dig(_type), \ | |
181 | .mant_dig = _float_mant_dig(_type), \ | |
182 | .alignment = lttng_alignof(_type) * CHAR_BIT, \ | |
183 | .reverse_byte_order = BYTE_ORDER != FLOAT_WORD_ORDER, \ | |
184 | } \ | |
185 | } \ | |
20f1eee7 MD |
186 | }, \ |
187 | } \ | |
188 | ||
37d5e202 | 189 | #define LTTNG_UST_FLOAT_TYPE_PADDING 24 |
20f1eee7 MD |
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; | |
37d5e202 | 195 | char padding[LTTNG_UST_FLOAT_TYPE_PADDING]; |
20f1eee7 MD |
196 | }; |
197 | ||
37d5e202 | 198 | #define LTTNG_UST_BASIC_TYPE_PADDING 128 |
8020ceb5 MD |
199 | union _lttng_basic_type { |
200 | struct lttng_integer_type integer; | |
201 | struct { | |
c785c634 MD |
202 | const struct lttng_enum_desc *desc; /* Enumeration mapping */ |
203 | struct lttng_integer_type container_type; | |
8020ceb5 MD |
204 | } enumeration; |
205 | struct { | |
206 | enum lttng_string_encodings encoding; | |
207 | } string; | |
20f1eee7 | 208 | struct lttng_float_type _float; |
37d5e202 | 209 | char padding[LTTNG_UST_BASIC_TYPE_PADDING]; |
8020ceb5 MD |
210 | }; |
211 | ||
212 | struct lttng_basic_type { | |
7dd08bec | 213 | enum lttng_abstract_types atype; |
8020ceb5 MD |
214 | union { |
215 | union _lttng_basic_type basic; | |
216 | } u; | |
217 | }; | |
218 | ||
37d5e202 | 219 | #define LTTNG_UST_TYPE_PADDING 128 |
8020ceb5 | 220 | struct lttng_type { |
7dd08bec | 221 | enum lttng_abstract_types atype; |
8020ceb5 MD |
222 | union { |
223 | union _lttng_basic_type basic; | |
224 | struct { | |
225 | struct lttng_basic_type elem_type; | |
226 | unsigned int length; /* num. elems. */ | |
227 | } array; | |
228 | struct { | |
229 | struct lttng_basic_type length_type; | |
230 | struct lttng_basic_type elem_type; | |
231 | } sequence; | |
53569322 MD |
232 | struct { |
233 | uint32_t nr_fields; | |
234 | struct lttng_event_field *fields; /* Array of fields. */ | |
235 | } _struct; | |
37d5e202 | 236 | char padding[LTTNG_UST_TYPE_PADDING]; |
8020ceb5 MD |
237 | } u; |
238 | }; | |
239 | ||
37d5e202 | 240 | #define LTTNG_UST_ENUM_TYPE_PADDING 24 |
c785c634 | 241 | struct lttng_enum_desc { |
8020ceb5 | 242 | const char *name; |
8020ceb5 | 243 | const struct lttng_enum_entry *entries; |
c785c634 | 244 | unsigned int nr_entries; |
37d5e202 | 245 | char padding[LTTNG_UST_ENUM_TYPE_PADDING]; |
8020ceb5 MD |
246 | }; |
247 | ||
180901e6 MD |
248 | /* |
249 | * Event field description | |
250 | * | |
251 | * IMPORTANT: this structure is part of the ABI between the probe and | |
252 | * UST. Fields need to be only added at the end, never reordered, never | |
253 | * removed. | |
254 | */ | |
8020ceb5 | 255 | |
4774c8f3 | 256 | #define LTTNG_UST_EVENT_FIELD_PADDING 28 |
8020ceb5 MD |
257 | struct lttng_event_field { |
258 | const char *name; | |
259 | struct lttng_type type; | |
180901e6 | 260 | unsigned int nowrite; /* do not write into trace */ |
37d5e202 | 261 | char padding[LTTNG_UST_EVENT_FIELD_PADDING]; |
8020ceb5 MD |
262 | }; |
263 | ||
53569322 MD |
264 | enum lttng_ust_dynamic_type { |
265 | LTTNG_UST_DYNAMIC_TYPE_NONE, | |
266 | LTTNG_UST_DYNAMIC_TYPE_S8, | |
267 | LTTNG_UST_DYNAMIC_TYPE_S16, | |
268 | LTTNG_UST_DYNAMIC_TYPE_S32, | |
269 | LTTNG_UST_DYNAMIC_TYPE_S64, | |
270 | LTTNG_UST_DYNAMIC_TYPE_U8, | |
271 | LTTNG_UST_DYNAMIC_TYPE_U16, | |
272 | LTTNG_UST_DYNAMIC_TYPE_U32, | |
273 | LTTNG_UST_DYNAMIC_TYPE_U64, | |
274 | LTTNG_UST_DYNAMIC_TYPE_FLOAT, | |
275 | LTTNG_UST_DYNAMIC_TYPE_DOUBLE, | |
276 | LTTNG_UST_DYNAMIC_TYPE_STRING, | |
277 | _NR_LTTNG_UST_DYNAMIC_TYPES, | |
278 | }; | |
279 | ||
280 | struct lttng_ctx_value { | |
281 | enum lttng_ust_dynamic_type sel; | |
282 | union { | |
283 | int64_t s64; | |
284 | const char *str; | |
285 | double d; | |
286 | } u; | |
77aa5901 MD |
287 | }; |
288 | ||
d58d1454 MD |
289 | struct lttng_perf_counter_field; |
290 | ||
37d5e202 | 291 | #define LTTNG_UST_CTX_FIELD_PADDING 40 |
8020ceb5 MD |
292 | struct lttng_ctx_field { |
293 | struct lttng_event_field event_field; | |
53569322 | 294 | size_t (*get_size)(struct lttng_ctx_field *field, size_t offset); |
8020ceb5 | 295 | void (*record)(struct lttng_ctx_field *field, |
4cfec15c | 296 | struct lttng_ust_lib_ring_buffer_ctx *ctx, |
7dd08bec | 297 | struct lttng_channel *chan); |
77aa5901 | 298 | void (*get_value)(struct lttng_ctx_field *field, |
53569322 | 299 | struct lttng_ctx_value *value); |
8020ceb5 | 300 | union { |
d58d1454 | 301 | struct lttng_perf_counter_field *perf_counter; |
37d5e202 | 302 | char padding[LTTNG_UST_CTX_FIELD_PADDING]; |
8020ceb5 MD |
303 | } u; |
304 | void (*destroy)(struct lttng_ctx_field *field); | |
53569322 | 305 | char *field_name; /* Has ownership, dynamically allocated. */ |
8020ceb5 MD |
306 | }; |
307 | ||
b2cc986a | 308 | #define LTTNG_UST_CTX_PADDING 20 |
8020ceb5 MD |
309 | struct lttng_ctx { |
310 | struct lttng_ctx_field *fields; | |
311 | unsigned int nr_fields; | |
312 | unsigned int allocated_fields; | |
b2cc986a | 313 | unsigned int largest_align; |
37d5e202 MD |
314 | char padding[LTTNG_UST_CTX_PADDING]; |
315 | }; | |
316 | ||
317 | #define LTTNG_UST_EVENT_DESC_PADDING 40 | |
318 | struct lttng_event_desc { | |
319 | const char *name; | |
fbdeb5ec | 320 | void (*probe_callback)(void); |
37d5e202 MD |
321 | const struct lttng_event_ctx *ctx; /* context */ |
322 | const struct lttng_event_field *fields; /* event payload */ | |
323 | unsigned int nr_fields; | |
324 | const int **loglevel; | |
68755429 | 325 | const char *signature; /* Argument types/names received */ |
6ddc916d MD |
326 | union { |
327 | struct { | |
328 | const char **model_emf_uri; | |
d5fc3224 | 329 | void (*trigger_callback)(void); |
6ddc916d MD |
330 | } ext; |
331 | char padding[LTTNG_UST_EVENT_DESC_PADDING]; | |
332 | } u; | |
37d5e202 MD |
333 | }; |
334 | ||
71d31690 | 335 | #define LTTNG_UST_PROBE_DESC_PADDING 12 |
37d5e202 MD |
336 | struct lttng_probe_desc { |
337 | const char *provider; | |
338 | const struct lttng_event_desc **event_desc; | |
339 | unsigned int nr_events; | |
340 | struct cds_list_head head; /* chain registered probes */ | |
6715d7d1 MD |
341 | struct cds_list_head lazy_init_head; |
342 | int lazy; /* lazy registration */ | |
71d31690 MD |
343 | uint32_t major; |
344 | uint32_t minor; | |
37d5e202 | 345 | char padding[LTTNG_UST_PROBE_DESC_PADDING]; |
8020ceb5 MD |
346 | }; |
347 | ||
37d5e202 MD |
348 | /* Data structures used by the tracer. */ |
349 | ||
d5fc3224 FD |
350 | enum lttng_enabler_format_type { |
351 | LTTNG_ENABLER_FORMAT_STAR_GLOB, | |
352 | LTTNG_ENABLER_FORMAT_EVENT, | |
e6c12e3d MD |
353 | }; |
354 | ||
355 | /* | |
e58095ef MD |
356 | * Enabler field, within whatever object is enabling an event. Target of |
357 | * backward reference. | |
e6c12e3d | 358 | */ |
e58095ef | 359 | struct lttng_enabler { |
d5fc3224 | 360 | enum lttng_enabler_format_type format_type; |
e58095ef MD |
361 | |
362 | /* head list of struct lttng_ust_filter_bytecode_node */ | |
363 | struct cds_list_head filter_bytecode_head; | |
0f63324a JI |
364 | /* head list of struct lttng_ust_excluder_node */ |
365 | struct cds_list_head excluder_head; | |
e58095ef MD |
366 | |
367 | struct lttng_ust_event event_param; | |
e58095ef | 368 | unsigned int enabled:1; |
e6c12e3d MD |
369 | }; |
370 | ||
c8fcf224 MD |
371 | struct tp_list_entry { |
372 | struct lttng_ust_tracepoint_iter tp; | |
373 | struct cds_list_head head; | |
374 | }; | |
375 | ||
376 | struct lttng_ust_tracepoint_list { | |
377 | struct tp_list_entry *iter; | |
378 | struct cds_list_head head; | |
8020ceb5 MD |
379 | }; |
380 | ||
06d4f27e MD |
381 | struct tp_field_list_entry { |
382 | struct lttng_ust_field_iter field; | |
383 | struct cds_list_head head; | |
384 | }; | |
385 | ||
386 | struct lttng_ust_field_list { | |
387 | struct tp_field_list_entry *iter; | |
388 | struct cds_list_head head; | |
389 | }; | |
390 | ||
8165c8da | 391 | struct ust_pending_probe; |
7dd08bec | 392 | struct lttng_event; |
f488575f MD |
393 | |
394 | struct lttng_ust_filter_bytecode_node { | |
395 | struct cds_list_head node; | |
e58095ef | 396 | struct lttng_enabler *enabler; |
a543151c MD |
397 | /* |
398 | * struct lttng_ust_filter_bytecode has var. sized array, must | |
399 | * be last field. | |
400 | */ | |
401 | struct lttng_ust_filter_bytecode bc; | |
f488575f MD |
402 | }; |
403 | ||
0f63324a JI |
404 | struct lttng_ust_excluder_node { |
405 | struct cds_list_head node; | |
406 | struct lttng_enabler *enabler; | |
407 | /* | |
408 | * struct lttng_ust_event_exclusion had variable sized array, | |
409 | * must be last field. | |
410 | */ | |
411 | struct lttng_ust_event_exclusion excluder; | |
412 | }; | |
8a92ed2a MD |
413 | /* |
414 | * Filter return value masks. | |
415 | */ | |
416 | enum lttng_filter_ret { | |
417 | LTTNG_FILTER_DISCARD = 0, | |
418 | LTTNG_FILTER_RECORD_FLAG = (1ULL << 0), | |
419 | /* Other bits are kept for future use. */ | |
420 | }; | |
421 | ||
f488575f MD |
422 | struct lttng_bytecode_runtime { |
423 | /* Associated bytecode */ | |
424 | struct lttng_ust_filter_bytecode_node *bc; | |
8a92ed2a | 425 | uint64_t (*filter)(void *filter_data, const char *filter_stack_data); |
21af05a9 | 426 | int link_failed; |
e58095ef | 427 | struct cds_list_head node; /* list of bytecode runtime in event */ |
d5fc3224 FD |
428 | /* |
429 | * Pointer to a URCU-protected pointer owned by an `struct | |
430 | * lttng_session`or `struct lttng_trigger_group`. | |
431 | */ | |
432 | struct lttng_ctx **ctx; | |
e58095ef MD |
433 | }; |
434 | ||
435 | /* | |
d5fc3224 FD |
436 | * Objects in a linked-list of enablers, owned by an event or trigger. |
437 | * This is used because an event (or a trigger) can be enabled by more than one | |
438 | * enabler and we want a quick way to iterate over all enablers of an object. | |
439 | * | |
440 | * For example, event rules "my_app:a*" and "my_app:ab*" will both match the | |
441 | * event with the name "my_app:abc". | |
e58095ef MD |
442 | */ |
443 | struct lttng_enabler_ref { | |
444 | struct cds_list_head node; /* enabler ref list */ | |
445 | struct lttng_enabler *ref; /* backward ref */ | |
f488575f | 446 | }; |
8165c8da | 447 | |
8020ceb5 | 448 | /* |
7dd08bec MD |
449 | * lttng_event structure is referred to by the tracing fast path. It |
450 | * must be kept small. | |
180901e6 MD |
451 | * |
452 | * IMPORTANT: this structure is part of the ABI between the probe and | |
453 | * UST. Fields need to be only added at the end, never reordered, never | |
454 | * removed. | |
8020ceb5 | 455 | */ |
7dd08bec | 456 | struct lttng_event { |
180901e6 | 457 | /* LTTng-UST 2.0 starts here */ |
8020ceb5 | 458 | unsigned int id; |
7dd08bec | 459 | struct lttng_channel *chan; |
976fe9ea | 460 | int enabled; |
8020ceb5 | 461 | const struct lttng_event_desc *desc; |
e58095ef | 462 | void *_deprecated1; |
8020ceb5 | 463 | struct lttng_ctx *ctx; |
9f3fdbc6 | 464 | enum lttng_ust_instrumentation instrumentation; |
e58095ef MD |
465 | struct cds_list_head node; /* Event list in session */ |
466 | struct cds_list_head _deprecated2; | |
467 | void *_deprecated3; | |
13b21cd6 | 468 | unsigned int _deprecated4:1; |
e58095ef | 469 | |
180901e6 | 470 | /* LTTng-UST 2.1 starts here */ |
e58095ef MD |
471 | /* list of struct lttng_bytecode_runtime, sorted by seqnum */ |
472 | struct cds_list_head bytecode_runtime_head; | |
dcdeaff0 | 473 | int has_enablers_without_bytecode; |
e58095ef MD |
474 | /* Backward references: list of lttng_enabler_ref (ref to enablers) */ |
475 | struct cds_list_head enablers_ref_head; | |
d56fa719 | 476 | struct cds_hlist_node hlist; /* session ht of events */ |
ac6b4ac6 | 477 | int registered; /* has reg'd tracepoint probe */ |
8020ceb5 MD |
478 | }; |
479 | ||
d5fc3224 FD |
480 | struct lttng_trigger { |
481 | uint64_t id; | |
482 | int enabled; | |
483 | int registered; /* has reg'd tracepoint probe */ | |
484 | struct cds_list_head bytecode_runtime_head; | |
485 | int has_enablers_without_bytecode; | |
486 | struct cds_list_head enablers_ref_head; | |
487 | const struct lttng_event_desc *desc; | |
488 | struct cds_hlist_node hlist; /* hashtable of triggers */ | |
489 | struct cds_list_head node; /* Trigger list in session */ | |
490 | struct lttng_trigger_group *group; /* weak ref */ | |
491 | }; | |
492 | ||
c785c634 MD |
493 | struct lttng_enum { |
494 | const struct lttng_enum_desc *desc; | |
495 | struct lttng_session *session; | |
496 | struct cds_list_head node; /* Enum list in session */ | |
497 | struct cds_hlist_node hlist; /* Session ht of enums */ | |
498 | uint64_t id; /* Enumeration ID in sessiond */ | |
499 | }; | |
500 | ||
8d8a24c8 | 501 | struct channel; |
38fae1d3 | 502 | struct lttng_ust_shm_handle; |
8d8a24c8 | 503 | |
180901e6 MD |
504 | /* |
505 | * IMPORTANT: this structure is part of the ABI between the probe and | |
506 | * UST. Fields need to be only added at the end, never reordered, never | |
507 | * removed. | |
508 | */ | |
7dd08bec MD |
509 | struct lttng_channel_ops { |
510 | struct lttng_channel *(*channel_create)(const char *name, | |
74d81a6c MD |
511 | void *buf_addr, |
512 | size_t subbuf_size, size_t num_subbuf, | |
513 | unsigned int switch_timer_interval, | |
514 | unsigned int read_timer_interval, | |
6ca18e66 | 515 | unsigned char *uuid, |
a9ff648c | 516 | uint32_t chan_id, |
b2c5f61a MD |
517 | const int *stream_fds, int nr_stream_fds, |
518 | int64_t blocking_timeout); | |
74d81a6c | 519 | void (*channel_destroy)(struct lttng_channel *chan); |
a44c74d9 MD |
520 | union { |
521 | void *_deprecated1; | |
522 | unsigned long has_strcpy:1; /* ABI has strcpy */ | |
523 | } u; | |
9e917229 | 524 | void *_deprecated2; |
4cfec15c | 525 | int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
8020ceb5 | 526 | uint32_t event_id); |
4cfec15c | 527 | void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx); |
74d81a6c MD |
528 | void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
529 | const void *src, size_t len); | |
8020ceb5 MD |
530 | /* |
531 | * packet_avail_size returns the available size in the current | |
532 | * packet. Note that the size returned is only a hint, since it | |
533 | * may change due to concurrent writes. | |
534 | */ | |
1d498196 | 535 | size_t (*packet_avail_size)(struct channel *chan, |
38fae1d3 | 536 | struct lttng_ust_shm_handle *handle); |
9f3fdbc6 MD |
537 | //wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan); |
538 | //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan); | |
8020ceb5 MD |
539 | int (*is_finalized)(struct channel *chan); |
540 | int (*is_disabled)(struct channel *chan); | |
38fae1d3 | 541 | int (*flush_buffer)(struct channel *chan, struct lttng_ust_shm_handle *handle); |
a44c74d9 MD |
542 | void (*event_strcpy)(struct lttng_ust_lib_ring_buffer_ctx *ctx, |
543 | const char *src, size_t len); | |
8020ceb5 MD |
544 | }; |
545 | ||
180901e6 MD |
546 | /* |
547 | * IMPORTANT: this structure is part of the ABI between the probe and | |
548 | * UST. Fields need to be only added at the end, never reordered, never | |
549 | * removed. | |
550 | */ | |
7dd08bec | 551 | struct lttng_channel { |
a3f61e7f MD |
552 | /* |
553 | * The pointers located in this private data are NOT safe to be | |
554 | * dereferenced by the consumer. The only operations the | |
555 | * consumer process is designed to be allowed to do is to read | |
556 | * and perform subbuffer flush. | |
557 | */ | |
8020ceb5 | 558 | struct channel *chan; /* Channel buffers */ |
976fe9ea | 559 | int enabled; |
8020ceb5 MD |
560 | struct lttng_ctx *ctx; |
561 | /* Event ID management */ | |
7dd08bec | 562 | struct lttng_session *session; |
0a42beb6 | 563 | int objd; /* Object associated to channel */ |
32ce8569 MD |
564 | unsigned int _deprecated1; |
565 | unsigned int _deprecated2; | |
e58095ef | 566 | struct cds_list_head node; /* Channel list in session */ |
74d81a6c | 567 | const struct lttng_channel_ops *ops; |
8020ceb5 | 568 | int header_type; /* 0: unset, 1: compact, 2: large */ |
38fae1d3 | 569 | struct lttng_ust_shm_handle *handle; /* shared-memory handle */ |
13b21cd6 | 570 | unsigned int _deprecated3:1; |
a3f61e7f | 571 | |
74d81a6c | 572 | /* Channel ID */ |
a3f61e7f | 573 | unsigned int id; |
74d81a6c | 574 | enum lttng_ust_chan_type type; |
19d8b1b3 | 575 | unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ |
ac6b4ac6 | 576 | int tstate:1; /* Transient enable state */ |
8020ceb5 MD |
577 | }; |
578 | ||
53569322 MD |
579 | #define LTTNG_UST_STACK_CTX_PADDING 32 |
580 | struct lttng_stack_ctx { | |
581 | struct lttng_event *event; | |
582 | struct lttng_ctx *chan_ctx; /* RCU dereferenced. */ | |
583 | struct lttng_ctx *event_ctx; /* RCU dereferenced. */ | |
584 | char padding[LTTNG_UST_STACK_CTX_PADDING]; | |
585 | }; | |
586 | ||
71a9d034 | 587 | #define LTTNG_UST_EVENT_HT_BITS 12 |
e58095ef MD |
588 | #define LTTNG_UST_EVENT_HT_SIZE (1U << LTTNG_UST_EVENT_HT_BITS) |
589 | ||
590 | struct lttng_ust_event_ht { | |
591 | struct cds_hlist_head table[LTTNG_UST_EVENT_HT_SIZE]; | |
592 | }; | |
593 | ||
d5fc3224 FD |
594 | #define LTTNG_UST_TRIGGER_HT_BITS 12 |
595 | #define LTTNG_UST_TRIGGER_HT_SIZE (1U << LTTNG_UST_TRIGGER_HT_BITS) | |
596 | struct lttng_ust_trigger_ht { | |
597 | struct cds_hlist_head table[LTTNG_UST_TRIGGER_HT_SIZE]; | |
598 | }; | |
599 | ||
c785c634 MD |
600 | #define LTTNG_UST_ENUM_HT_BITS 12 |
601 | #define LTTNG_UST_ENUM_HT_SIZE (1U << LTTNG_UST_ENUM_HT_BITS) | |
602 | ||
603 | struct lttng_ust_enum_ht { | |
604 | struct cds_hlist_head table[LTTNG_UST_ENUM_HT_SIZE]; | |
605 | }; | |
606 | ||
180901e6 MD |
607 | /* |
608 | * IMPORTANT: this structure is part of the ABI between the probe and | |
609 | * UST. Fields need to be only added at the end, never reordered, never | |
610 | * removed. | |
611 | */ | |
7dd08bec | 612 | struct lttng_session { |
e58095ef MD |
613 | int active; /* Is trace session active ? */ |
614 | int been_active; /* Been active ? */ | |
615 | int objd; /* Object associated */ | |
13b21cd6 | 616 | void *_deprecated1; |
e58095ef MD |
617 | struct cds_list_head chan_head; /* Channel list head */ |
618 | struct cds_list_head events_head; /* list of events */ | |
13b21cd6 | 619 | struct cds_list_head _deprecated2; |
e58095ef | 620 | struct cds_list_head node; /* Session list */ |
13b21cd6 MD |
621 | int _deprecated3; |
622 | unsigned int _deprecated4:1; | |
e58095ef MD |
623 | |
624 | /* New UST 2.1 */ | |
625 | /* List of enablers */ | |
626 | struct cds_list_head enablers_head; | |
d56fa719 | 627 | struct lttng_ust_event_ht events_ht; /* ht of events */ |
32ce8569 | 628 | void *owner; /* object owner */ |
ac6b4ac6 | 629 | int tstate:1; /* Transient enable state */ |
246be17e PW |
630 | |
631 | /* New UST 2.4 */ | |
632 | int statedump_pending:1; | |
c785c634 MD |
633 | |
634 | /* New UST 2.8 */ | |
635 | struct lttng_ust_enum_ht enums_ht; /* ht of enumerations */ | |
636 | struct cds_list_head enums_head; | |
53569322 | 637 | struct lttng_ctx *ctx; /* contexts for filters. */ |
8020ceb5 MD |
638 | }; |
639 | ||
d5fc3224 FD |
640 | struct lttng_trigger_group { |
641 | int objd; | |
642 | void *owner; | |
643 | int notification_fd; | |
644 | struct cds_list_head node; /* Trigger group handle list */ | |
645 | struct cds_list_head enablers_head; | |
646 | struct cds_list_head triggers_head; /* list of triggers */ | |
647 | struct lttng_ust_trigger_ht triggers_ht; /* hashtable of triggers */ | |
648 | struct lttng_ctx *ctx; /* contexts for filters. */ | |
649 | }; | |
650 | ||
7dd08bec | 651 | struct lttng_transport { |
8020ceb5 | 652 | char *name; |
9f3fdbc6 | 653 | struct cds_list_head node; |
7dd08bec | 654 | struct lttng_channel_ops ops; |
74d81a6c | 655 | const struct lttng_ust_lib_ring_buffer_config *client_config; |
8020ceb5 MD |
656 | }; |
657 | ||
7dd08bec MD |
658 | struct lttng_session *lttng_session_create(void); |
659 | int lttng_session_enable(struct lttng_session *session); | |
660 | int lttng_session_disable(struct lttng_session *session); | |
710b8ee3 | 661 | int lttng_session_statedump(struct lttng_session *session); |
7dd08bec | 662 | void lttng_session_destroy(struct lttng_session *session); |
8020ceb5 | 663 | |
d5fc3224 FD |
664 | void lttng_trigger_send_notification(struct lttng_trigger *trigger); |
665 | ||
7dd08bec | 666 | struct lttng_channel *lttng_channel_create(struct lttng_session *session, |
8020ceb5 MD |
667 | const char *transport_name, |
668 | void *buf_addr, | |
669 | size_t subbuf_size, size_t num_subbuf, | |
670 | unsigned int switch_timer_interval, | |
193183fb | 671 | unsigned int read_timer_interval, |
ef9ff354 MD |
672 | int **shm_fd, int **wait_fd, |
673 | uint64_t **memory_map_size, | |
7dd08bec | 674 | struct lttng_channel *chan_priv_init); |
8020ceb5 | 675 | |
7dd08bec MD |
676 | int lttng_channel_enable(struct lttng_channel *channel); |
677 | int lttng_channel_disable(struct lttng_channel *channel); | |
e58095ef | 678 | |
e58095ef | 679 | int lttng_attach_context(struct lttng_ust_context *context_param, |
8e696cfa | 680 | union ust_args *uargs, |
e58095ef | 681 | struct lttng_ctx **ctx, struct lttng_session *session); |
53569322 | 682 | int lttng_session_context_init(struct lttng_ctx **ctx); |
976fe9ea | 683 | |
7dd08bec MD |
684 | void lttng_transport_register(struct lttng_transport *transport); |
685 | void lttng_transport_unregister(struct lttng_transport *transport); | |
8020ceb5 | 686 | |
4b4de73e | 687 | void synchronize_trace(void); |
8020ceb5 | 688 | |
7dd08bec MD |
689 | int lttng_probe_register(struct lttng_probe_desc *desc); |
690 | void lttng_probe_unregister(struct lttng_probe_desc *desc); | |
35ac38cb | 691 | void lttng_probe_provider_unregister_events(struct lttng_probe_desc *desc); |
5f733922 | 692 | int lttng_fix_pending_events(void); |
7dd08bec MD |
693 | int lttng_probes_init(void); |
694 | void lttng_probes_exit(void); | |
8173ec7c | 695 | int lttng_find_context(struct lttng_ctx *ctx, const char *name); |
77aa5901 | 696 | int lttng_get_context_index(struct lttng_ctx *ctx, const char *name); |
8173ec7c | 697 | struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p); |
b2cc986a | 698 | void lttng_context_update(struct lttng_ctx *ctx); |
8173ec7c | 699 | void lttng_remove_context_field(struct lttng_ctx **ctx_p, |
8020ceb5 MD |
700 | struct lttng_ctx_field *field); |
701 | void lttng_destroy_context(struct lttng_ctx *ctx); | |
3b402b40 | 702 | int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx); |
c1ef86f0 | 703 | int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx); |
8173ec7c | 704 | int lttng_add_pthread_id_to_ctx(struct lttng_ctx **ctx); |
4847e9bb | 705 | int lttng_add_procname_to_ctx(struct lttng_ctx **ctx); |
96f85541 | 706 | int lttng_add_ip_to_ctx(struct lttng_ctx **ctx); |
c7ea8487 | 707 | int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx); |
53569322 | 708 | int lttng_add_dyntest_to_ctx(struct lttng_ctx **ctx); |
735bef47 MJ |
709 | int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx); |
710 | int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx); | |
711 | int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx); | |
712 | int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx); | |
713 | int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx); | |
714 | int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx); | |
715 | int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx); | |
fca2f191 MJ |
716 | int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx); |
717 | int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx); | |
718 | int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx); | |
719 | int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx); | |
720 | int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx); | |
721 | int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx); | |
a93bfc45 | 722 | void lttng_context_vtid_reset(void); |
c1ef86f0 | 723 | void lttng_context_vpid_reset(void); |
46228a6f | 724 | void lttng_context_procname_reset(void); |
735bef47 MJ |
725 | void lttng_context_cgroup_ns_reset(void); |
726 | void lttng_context_ipc_ns_reset(void); | |
727 | void lttng_context_mnt_ns_reset(void); | |
728 | void lttng_context_net_ns_reset(void); | |
729 | void lttng_context_pid_ns_reset(void); | |
730 | void lttng_context_user_ns_reset(void); | |
731 | void lttng_context_uts_ns_reset(void); | |
fca2f191 MJ |
732 | void lttng_context_vuid_reset(void); |
733 | void lttng_context_veuid_reset(void); | |
734 | void lttng_context_vsuid_reset(void); | |
735 | void lttng_context_vgid_reset(void); | |
736 | void lttng_context_vegid_reset(void); | |
737 | void lttng_context_vsgid_reset(void); | |
9f3fdbc6 | 738 | |
d58d1454 MD |
739 | #ifdef LTTNG_UST_HAVE_PERF_EVENT |
740 | int lttng_add_perf_counter_to_ctx(uint32_t type, | |
741 | uint64_t config, | |
742 | const char *name, | |
743 | struct lttng_ctx **ctx); | |
744 | int lttng_perf_counter_init(void); | |
745 | void lttng_perf_counter_exit(void); | |
746 | #else /* #ifdef LTTNG_UST_HAVE_PERF_EVENT */ | |
747 | static inline | |
748 | int lttng_add_perf_counter_to_ctx(uint32_t type, | |
749 | uint64_t config, | |
750 | const char *name, | |
751 | struct lttng_ctx **ctx) | |
752 | { | |
753 | return -ENOSYS; | |
754 | } | |
755 | static inline | |
756 | int lttng_perf_counter_init(void) | |
757 | { | |
758 | return 0; | |
759 | } | |
760 | static inline | |
761 | void lttng_perf_counter_exit(void) | |
762 | { | |
763 | } | |
764 | #endif /* #else #ifdef LTTNG_UST_HAVE_PERF_EVENT */ | |
765 | ||
82b9bde8 JD |
766 | extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata; |
767 | extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_discard; | |
768 | extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite; | |
c1fca457 | 769 | |
7dd08bec | 770 | struct lttng_transport *lttng_transport_find(const char *name); |
c1fca457 | 771 | |
7dd08bec MD |
772 | int lttng_probes_get_event_list(struct lttng_ust_tracepoint_list *list); |
773 | void lttng_probes_prune_event_list(struct lttng_ust_tracepoint_list *list); | |
c8fcf224 MD |
774 | struct lttng_ust_tracepoint_iter * |
775 | lttng_ust_tracepoint_list_get_iter_next(struct lttng_ust_tracepoint_list *list); | |
7dd08bec MD |
776 | int lttng_probes_get_field_list(struct lttng_ust_field_list *list); |
777 | void lttng_probes_prune_field_list(struct lttng_ust_field_list *list); | |
06d4f27e MD |
778 | struct lttng_ust_field_iter * |
779 | lttng_ust_field_list_get_iter_next(struct lttng_ust_field_list *list); | |
c8fcf224 | 780 | |
7dd08bec | 781 | void lttng_free_event_filter_runtime(struct lttng_event *event); |
e58095ef MD |
782 | void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime); |
783 | ||
784 | struct cds_list_head *lttng_get_probe_list_head(void); | |
6715d7d1 | 785 | int lttng_session_active(void); |
e6c12e3d | 786 | |
246be17e | 787 | typedef int (*t_statedump_func_ptr)(struct lttng_session *session); |
3327ac33 | 788 | void lttng_handle_pending_statedump(void *owner); |
37dddb65 | 789 | struct cds_list_head *_lttng_get_sessions(void); |
b33b46f7 FD |
790 | |
791 | struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session, | |
792 | const struct lttng_enum_desc *enum_desc); | |
246be17e | 793 | |
97c7c238 | 794 | void lttng_ust_dl_update(void *ip); |
6548fca4 | 795 | void lttng_ust_fixup_fd_tracker_tls(void); |
97c7c238 | 796 | |
4a1f7569 MD |
797 | /* For backward compatibility. Leave those exported symbols in place. */ |
798 | extern struct lttng_ctx *lttng_static_ctx; | |
799 | void lttng_context_init(void); | |
800 | void lttng_context_exit(void); | |
a211b293 | 801 | void lttng_filter_event_link_bytecode(struct lttng_event *event); |
d5fc3224 FD |
802 | struct lttng_enabler *lttng_enabler_create( |
803 | enum lttng_enabler_format_type format_type, | |
804 | struct lttng_ust_event *event_param, | |
805 | struct lttng_channel *chan); | |
806 | int lttng_enabler_enable(struct lttng_enabler *enabler); | |
807 | int lttng_enabler_disable(struct lttng_enabler *enabler); | |
808 | int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler, | |
809 | struct lttng_ust_filter_bytecode_node *bytecode); | |
810 | int lttng_enabler_attach_context(struct lttng_enabler *enabler, | |
811 | struct lttng_ust_context *ctx); | |
812 | int lttng_enabler_attach_exclusion(struct lttng_enabler *enabler, | |
813 | struct lttng_ust_excluder_node *excluder); | |
814 | void lttng_enabler_event_link_bytecode(struct lttng_event *event, | |
815 | struct lttng_enabler *enabler); | |
4a1f7569 | 816 | |
6453d237 MD |
817 | #ifdef __cplusplus |
818 | } | |
819 | #endif | |
820 | ||
51489cad | 821 | #endif /* _LTTNG_UST_EVENTS_H */ |