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