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