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