Commit | Line | Data |
---|---|---|
d871c65b | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: MIT |
d871c65b | 3 | * |
c0c0989a | 4 | * Copyright 2019 (c) Francis Deslauriers <francis.deslauriers@efficios.com> |
d871c65b FD |
5 | */ |
6 | ||
36c52fff MJ |
7 | #ifndef _UST_COMMON_UST_EVENTS_H |
8 | #define _UST_COMMON_UST_EVENTS_H | |
c0c0989a | 9 | |
9af5d97a | 10 | #include <limits.h> |
d871c65b FD |
11 | #include <stdint.h> |
12 | ||
13 | #include <urcu/list.h> | |
14 | #include <urcu/hlist.h> | |
15 | ||
d871c65b FD |
16 | #include <lttng/ust-events.h> |
17 | ||
9d315d6d MJ |
18 | #include "common/macros.h" |
19 | #include "common/ust-context-provider.h" | |
fd17d7ce | 20 | |
bff668bf MD |
21 | /* |
22 | * The context procname length is part of the LTTng-UST ABI. | |
23 | * TODO: At the next breaking protocol bump, all users of this macro | |
24 | * should instead use LTTNG_UST_ABI_PROCNAME_LEN. | |
25 | */ | |
26 | #define LTTNG_UST_CONTEXT_PROCNAME_LEN 17 | |
27 | ||
fd17d7ce | 28 | struct lttng_ust_abi_obj; |
06cd86a0 | 29 | struct lttng_event_notifier_group; |
fd17d7ce MD |
30 | |
31 | union lttng_ust_abi_args { | |
32 | struct { | |
33 | void *chan_data; | |
34 | int wakeup_fd; | |
35 | } channel; | |
36 | struct { | |
37 | int shm_fd; | |
38 | int wakeup_fd; | |
39 | } stream; | |
40 | struct { | |
41 | struct lttng_ust_abi_field_iter entry; | |
42 | } field_list; | |
43 | struct { | |
44 | char *ctxname; | |
45 | } app_context; | |
46 | struct { | |
47 | int event_notifier_notif_fd; | |
48 | } event_notifier_handle; | |
49 | struct { | |
50 | void *counter_data; | |
51 | } counter; | |
52 | struct { | |
53 | int shm_fd; | |
54 | } counter_shm; | |
55 | }; | |
56 | ||
57 | struct lttng_ust_abi_objd_ops { | |
58 | long (*cmd)(int objd, unsigned int cmd, unsigned long arg, | |
59 | union lttng_ust_abi_args *args, void *owner); | |
60 | int (*release)(int objd); | |
61 | }; | |
62 | ||
8665f6a4 MJ |
63 | enum lttng_enabler_format_type { |
64 | LTTNG_ENABLER_FORMAT_STAR_GLOB, | |
65 | LTTNG_ENABLER_FORMAT_EVENT, | |
66 | }; | |
67 | ||
68 | /* | |
69 | * Enabler field, within whatever object is enabling an event. Target of | |
70 | * backward reference. | |
71 | */ | |
72 | struct lttng_enabler { | |
73 | enum lttng_enabler_format_type format_type; | |
74 | ||
75 | /* head list of struct lttng_ust_filter_bytecode_node */ | |
76 | struct cds_list_head filter_bytecode_head; | |
77 | /* head list of struct lttng_ust_excluder_node */ | |
78 | struct cds_list_head excluder_head; | |
79 | ||
fd17d7ce | 80 | struct lttng_ust_abi_event event_param; |
8665f6a4 MJ |
81 | unsigned int enabled:1; |
82 | }; | |
83 | ||
d871c65b FD |
84 | struct lttng_event_enabler { |
85 | struct lttng_enabler base; | |
86 | struct cds_list_head node; /* per-session list of enablers */ | |
e7bc0ef6 | 87 | struct lttng_ust_channel_buffer *chan; |
d871c65b FD |
88 | /* |
89 | * Unused, but kept around to make it explicit that the tracer can do | |
90 | * it. | |
91 | */ | |
daacdbfc | 92 | struct lttng_ust_ctx *ctx; |
d871c65b FD |
93 | }; |
94 | ||
d8d2416d FD |
95 | struct lttng_event_notifier_enabler { |
96 | struct lttng_enabler base; | |
6566528b | 97 | uint64_t error_counter_index; |
d37ecb3f FD |
98 | struct cds_list_head node; /* per-app list of event_notifier enablers */ |
99 | struct cds_list_head capture_bytecode_head; | |
d8d2416d FD |
100 | struct lttng_event_notifier_group *group; /* weak ref */ |
101 | uint64_t user_token; /* User-provided token */ | |
d37ecb3f | 102 | uint64_t num_captures; |
d8d2416d FD |
103 | }; |
104 | ||
22c30e27 MD |
105 | enum lttng_ust_bytecode_type { |
106 | LTTNG_UST_BYTECODE_TYPE_FILTER, | |
107 | LTTNG_UST_BYTECODE_TYPE_CAPTURE, | |
ab249ecf FD |
108 | }; |
109 | ||
110 | struct lttng_ust_bytecode_node { | |
22c30e27 | 111 | enum lttng_ust_bytecode_type type; |
92495593 FD |
112 | struct cds_list_head node; |
113 | struct lttng_enabler *enabler; | |
ab249ecf FD |
114 | struct { |
115 | uint32_t len; | |
116 | uint32_t reloc_offset; | |
117 | uint64_t seqnum; | |
118 | char data[]; | |
119 | } bc; | |
92495593 FD |
120 | }; |
121 | ||
a2e4d05e MD |
122 | /* |
123 | * Bytecode interpreter return value. | |
124 | */ | |
125 | enum lttng_ust_bytecode_interpreter_ret { | |
126 | LTTNG_UST_BYTECODE_INTERPRETER_ERROR = -1, | |
127 | LTTNG_UST_BYTECODE_INTERPRETER_OK = 0, | |
128 | }; | |
129 | ||
130 | struct lttng_interpreter_output; | |
131 | struct lttng_ust_bytecode_runtime_private; | |
132 | ||
133 | enum lttng_ust_bytecode_filter_result { | |
134 | LTTNG_UST_BYTECODE_FILTER_ACCEPT = 0, | |
135 | LTTNG_UST_BYTECODE_FILTER_REJECT = 1, | |
136 | }; | |
137 | ||
138 | struct lttng_ust_bytecode_filter_ctx { | |
139 | enum lttng_ust_bytecode_filter_result result; | |
140 | }; | |
141 | ||
92495593 FD |
142 | struct lttng_ust_excluder_node { |
143 | struct cds_list_head node; | |
144 | struct lttng_enabler *enabler; | |
145 | /* | |
146 | * struct lttng_ust_event_exclusion had variable sized array, | |
147 | * must be last field. | |
148 | */ | |
fd17d7ce | 149 | struct lttng_ust_abi_event_exclusion excluder; |
92495593 FD |
150 | }; |
151 | ||
bb7ad29d MJ |
152 | /* Data structures used by the tracer. */ |
153 | ||
154 | struct tp_list_entry { | |
fd17d7ce | 155 | struct lttng_ust_abi_tracepoint_iter tp; |
bb7ad29d MJ |
156 | struct cds_list_head head; |
157 | }; | |
158 | ||
159 | struct lttng_ust_tracepoint_list { | |
160 | struct tp_list_entry *iter; | |
161 | struct cds_list_head head; | |
162 | }; | |
163 | ||
164 | struct tp_field_list_entry { | |
fd17d7ce | 165 | struct lttng_ust_abi_field_iter field; |
bb7ad29d MJ |
166 | struct cds_list_head head; |
167 | }; | |
168 | ||
169 | struct lttng_ust_field_list { | |
170 | struct tp_field_list_entry *iter; | |
171 | struct cds_list_head head; | |
172 | }; | |
173 | ||
174 | /* | |
175 | * Objects in a linked-list of enablers, owned by an event or event_notifier. | |
176 | * This is used because an event (or a event_notifier) can be enabled by more | |
177 | * than one enabler and we want a quick way to iterate over all enablers of an | |
178 | * object. | |
179 | * | |
180 | * For example, event rules "my_app:a*" and "my_app:ab*" will both match the | |
181 | * event with the name "my_app:abc". | |
182 | */ | |
183 | struct lttng_enabler_ref { | |
184 | struct cds_list_head node; /* enabler ref list */ | |
185 | struct lttng_enabler *ref; /* backward ref */ | |
186 | }; | |
187 | ||
188 | #define LTTNG_COUNTER_DIMENSION_MAX 8 | |
189 | struct lttng_counter_dimension { | |
190 | uint64_t size; | |
191 | uint64_t underflow_index; | |
192 | uint64_t overflow_index; | |
193 | uint8_t has_underflow; | |
194 | uint8_t has_overflow; | |
195 | }; | |
196 | ||
b5863ea7 MD |
197 | struct lttng_counter_ops { |
198 | struct lib_counter *(*counter_create)(size_t nr_dimensions, | |
199 | const struct lttng_counter_dimension *dimensions, | |
200 | int64_t global_sum_step, | |
201 | int global_counter_fd, | |
202 | int nr_counter_cpu_fds, | |
203 | const int *counter_cpu_fds, | |
204 | bool is_daemon); | |
205 | void (*counter_destroy)(struct lib_counter *counter); | |
206 | int (*counter_add)(struct lib_counter *counter, | |
207 | const size_t *dimension_indexes, int64_t v); | |
208 | int (*counter_read)(struct lib_counter *counter, | |
209 | const size_t *dimension_indexes, int cpu, | |
210 | int64_t *value, bool *overflow, bool *underflow); | |
211 | int (*counter_aggregate)(struct lib_counter *counter, | |
212 | const size_t *dimension_indexes, int64_t *value, | |
213 | bool *overflow, bool *underflow); | |
214 | int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes); | |
215 | }; | |
216 | ||
bb7ad29d MJ |
217 | struct lttng_counter { |
218 | int objd; | |
219 | struct lttng_event_notifier_group *event_notifier_group; /* owner */ | |
220 | struct lttng_counter_transport *transport; | |
221 | struct lib_counter *counter; | |
222 | struct lttng_counter_ops *ops; | |
223 | }; | |
224 | ||
681f6001 MD |
225 | #define LTTNG_UST_EVENT_HT_BITS 12 |
226 | #define LTTNG_UST_EVENT_HT_SIZE (1U << LTTNG_UST_EVENT_HT_BITS) | |
227 | ||
228 | struct lttng_ust_event_ht { | |
229 | struct cds_hlist_head table[LTTNG_UST_EVENT_HT_SIZE]; | |
230 | }; | |
231 | ||
232 | #define LTTNG_UST_EVENT_NOTIFIER_HT_BITS 12 | |
233 | #define LTTNG_UST_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_UST_EVENT_NOTIFIER_HT_BITS) | |
234 | struct lttng_ust_event_notifier_ht { | |
235 | struct cds_hlist_head table[LTTNG_UST_EVENT_NOTIFIER_HT_SIZE]; | |
236 | }; | |
237 | ||
238 | #define LTTNG_UST_ENUM_HT_BITS 12 | |
239 | #define LTTNG_UST_ENUM_HT_SIZE (1U << LTTNG_UST_ENUM_HT_BITS) | |
240 | ||
241 | struct lttng_ust_enum_ht { | |
242 | struct cds_hlist_head table[LTTNG_UST_ENUM_HT_SIZE]; | |
243 | }; | |
244 | ||
bb7ad29d MJ |
245 | struct lttng_event_notifier_group { |
246 | int objd; | |
247 | void *owner; | |
248 | int notification_fd; | |
249 | struct cds_list_head node; /* Event notifier group handle list */ | |
250 | struct cds_list_head enablers_head; | |
0c1264b0 | 251 | struct cds_list_head event_notifiers_head; /* list of event_notifiers */ |
bb7ad29d | 252 | struct lttng_ust_event_notifier_ht event_notifiers_ht; /* hashtable of event_notifiers */ |
0c1264b0 | 253 | struct lttng_ust_ctx *ctx; /* contexts for filters. */ |
bb7ad29d MJ |
254 | |
255 | struct lttng_counter *error_counter; | |
256 | size_t error_counter_len; | |
257 | }; | |
258 | ||
259 | struct lttng_transport { | |
74c3f8e2 | 260 | const char *name; |
bb7ad29d | 261 | struct cds_list_head node; |
14b6f891 | 262 | struct lttng_ust_channel_buffer_ops ops; |
b5457df5 | 263 | const struct lttng_ust_ring_buffer_config *client_config; |
bb7ad29d MJ |
264 | }; |
265 | ||
266 | struct lttng_counter_transport { | |
74c3f8e2 | 267 | const char *name; |
bb7ad29d MJ |
268 | struct cds_list_head node; |
269 | struct lttng_counter_ops ops; | |
270 | const struct lib_counter_config *client_config; | |
271 | }; | |
272 | ||
80333dfa | 273 | struct lttng_ust_event_common_private { |
7ee76145 | 274 | struct lttng_ust_event_common *pub; /* Public event interface */ |
68bb7559 | 275 | |
4e48b5d2 | 276 | const struct lttng_ust_event_desc *desc; |
68bb7559 MD |
277 | /* Backward references: list of lttng_enabler_ref (ref to enablers) */ |
278 | struct cds_list_head enablers_ref_head; | |
0c1264b0 | 279 | int registered; /* has reg'd tracepoint probe */ |
115db533 | 280 | uint64_t user_token; |
a2e4d05e MD |
281 | |
282 | int has_enablers_without_filter_bytecode; | |
283 | /* list of struct lttng_ust_bytecode_runtime, sorted by seqnum */ | |
284 | struct cds_list_head filter_bytecode_runtime_head; | |
68bb7559 MD |
285 | }; |
286 | ||
2e70391c | 287 | struct lttng_ust_event_recorder_private { |
80333dfa MD |
288 | struct lttng_ust_event_common_private parent; |
289 | ||
2e70391c | 290 | struct lttng_ust_event_recorder *pub; /* Public event interface */ |
ba99fbe2 MD |
291 | struct cds_list_head node; /* Event recorder list */ |
292 | struct cds_hlist_node hlist; /* Hash table of event recorders */ | |
a40b5b8c | 293 | struct lttng_ust_ctx *ctx; |
8936b6c0 | 294 | unsigned int id; |
80333dfa MD |
295 | }; |
296 | ||
115db533 MD |
297 | struct lttng_ust_event_notifier_private { |
298 | struct lttng_ust_event_common_private parent; | |
299 | ||
d7d45c0d | 300 | struct lttng_ust_event_notifier *pub; /* Public event notifier interface */ |
115db533 MD |
301 | struct lttng_event_notifier_group *group; /* weak ref */ |
302 | size_t num_captures; /* Needed to allocate the msgpack array. */ | |
303 | uint64_t error_counter_index; | |
ba99fbe2 MD |
304 | struct cds_list_head node; /* Event notifier list */ |
305 | struct cds_hlist_node hlist; /* Hash table of event notifiers */ | |
a2e4d05e | 306 | struct cds_list_head capture_bytecode_runtime_head; |
a2e4d05e | 307 | }; |
362a65de | 308 | |
a2e4d05e | 309 | struct lttng_ust_bytecode_runtime { |
22c30e27 | 310 | enum lttng_ust_bytecode_type type; |
362a65de MD |
311 | struct lttng_ust_bytecode_node *bc; |
312 | int link_failed; | |
a2e4d05e MD |
313 | int (*interpreter_func)(struct lttng_ust_bytecode_runtime *bytecode_runtime, |
314 | const char *interpreter_stack_data, | |
b2e37d27 | 315 | struct lttng_ust_probe_ctx *probe_ctx, |
a2e4d05e | 316 | void *ctx); |
0c1264b0 | 317 | struct cds_list_head node; /* list of bytecode runtime in event */ |
362a65de MD |
318 | /* |
319 | * Pointer to a URCU-protected pointer owned by an `struct | |
320 | * lttng_session`or `struct lttng_event_notifier_group`. | |
321 | */ | |
daacdbfc | 322 | struct lttng_ust_ctx **pctx; |
362a65de MD |
323 | }; |
324 | ||
bdb12629 | 325 | struct lttng_ust_session_private { |
f69fe5fb | 326 | struct lttng_ust_session *pub; /* Public session interface */ |
bdb12629 MD |
327 | |
328 | int been_active; /* Been active ? */ | |
329 | int objd; /* Object associated */ | |
330 | struct cds_list_head chan_head; /* Channel list head */ | |
331 | struct cds_list_head events_head; /* list of events */ | |
332 | struct cds_list_head node; /* Session list */ | |
333 | ||
bdb12629 MD |
334 | /* List of enablers */ |
335 | struct cds_list_head enablers_head; | |
336 | struct lttng_ust_event_ht events_ht; /* ht of events */ | |
337 | void *owner; /* object owner */ | |
338 | int tstate:1; /* Transient enable state */ | |
339 | ||
bdb12629 MD |
340 | int statedump_pending:1; |
341 | ||
bdb12629 MD |
342 | struct lttng_ust_enum_ht enums_ht; /* ht of enumerations */ |
343 | struct cds_list_head enums_head; | |
0c1264b0 | 344 | struct lttng_ust_ctx *ctx; /* contexts for filters. */ |
9daacd1a MD |
345 | |
346 | unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ | |
347 | bool uuid_set; /* Is uuid set ? */ | |
bdb12629 MD |
348 | }; |
349 | ||
036d17fb | 350 | struct lttng_enum { |
4e48b5d2 | 351 | const struct lttng_ust_enum_desc *desc; |
f69fe5fb | 352 | struct lttng_ust_session *session; |
0c1264b0 MD |
353 | struct cds_list_head node; /* Enum list in session */ |
354 | struct cds_hlist_node hlist; /* Session ht of enums */ | |
355 | uint64_t id; /* Enumeration ID in sessiond */ | |
036d17fb MD |
356 | }; |
357 | ||
e7bc0ef6 MD |
358 | struct lttng_ust_shm_handle; |
359 | ||
14b6f891 MD |
360 | struct lttng_ust_channel_buffer_ops_private { |
361 | struct lttng_ust_channel_buffer_ops *pub; /* Public channel buffer ops interface */ | |
a880bae5 | 362 | |
e7bc0ef6 | 363 | struct lttng_ust_channel_buffer *(*channel_create)(const char *name, |
a880bae5 MD |
364 | void *buf_addr, |
365 | size_t subbuf_size, size_t num_subbuf, | |
366 | unsigned int switch_timer_interval, | |
367 | unsigned int read_timer_interval, | |
368 | unsigned char *uuid, | |
369 | uint32_t chan_id, | |
370 | const int *stream_fds, int nr_stream_fds, | |
371 | int64_t blocking_timeout); | |
e7bc0ef6 | 372 | void (*channel_destroy)(struct lttng_ust_channel_buffer *chan); |
a880bae5 MD |
373 | /* |
374 | * packet_avail_size returns the available size in the current | |
375 | * packet. Note that the size returned is only a hint, since it | |
376 | * may change due to concurrent writes. | |
377 | */ | |
07539b34 MD |
378 | size_t (*packet_avail_size)(struct lttng_ust_channel_buffer *chan); |
379 | int (*is_finalized)(struct lttng_ust_channel_buffer *chan); | |
380 | int (*is_disabled)(struct lttng_ust_channel_buffer *chan); | |
381 | int (*flush_buffer)(struct lttng_ust_channel_buffer *chan); | |
a880bae5 MD |
382 | }; |
383 | ||
e7bc0ef6 MD |
384 | struct lttng_ust_channel_common_private { |
385 | struct lttng_ust_channel_common *pub; /* Public channel interface */ | |
386 | ||
0c1264b0 MD |
387 | int objd; /* Object associated with channel. */ |
388 | int tstate:1; /* Transient enable state */ | |
e7bc0ef6 MD |
389 | }; |
390 | ||
391 | struct lttng_ust_channel_buffer_private { | |
392 | struct lttng_ust_channel_common_private parent; | |
393 | ||
394 | struct lttng_ust_channel_buffer *pub; /* Public channel buffer interface */ | |
0c1264b0 MD |
395 | struct cds_list_head node; /* Channel list in session */ |
396 | int header_type; /* 0: unset, 1: compact, 2: large */ | |
397 | unsigned int id; /* Channel ID */ | |
e7bc0ef6 | 398 | enum lttng_ust_abi_chan_type type; |
0950190a | 399 | struct lttng_ust_ctx *ctx; |
b5457df5 | 400 | struct lttng_ust_ring_buffer_channel *rb_chan; /* Ring buffer channel */ |
e7bc0ef6 MD |
401 | unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ |
402 | }; | |
403 | ||
f0fde1c3 MD |
404 | /* |
405 | * IMPORTANT: this structure is part of the ABI between the consumer | |
406 | * daemon and the UST library within traced applications. Changing it | |
407 | * breaks the UST communication protocol. | |
408 | * | |
409 | * TODO: remove unused fields on next UST communication protocol | |
410 | * breaking update. | |
411 | */ | |
412 | struct lttng_ust_abi_channel_config { | |
413 | void *unused1; | |
414 | int unused2; | |
415 | void *unused3; | |
416 | void *unused4; | |
417 | int unused5; | |
da52433d MD |
418 | unsigned int _deprecated1; |
419 | unsigned int _deprecated2; | |
f0fde1c3 MD |
420 | struct cds_list_head unused6; |
421 | void *unused7; | |
422 | int unused8; | |
423 | void *unused9; | |
da52433d | 424 | unsigned int _deprecated3:1; |
f0fde1c3 MD |
425 | |
426 | /* Channel ID */ | |
427 | unsigned int id; | |
428 | enum lttng_ust_abi_chan_type unused10; | |
429 | unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ | |
430 | int unused11:1; | |
431 | }; | |
432 | ||
4e48b5d2 MD |
433 | /* Global (filter), event and channel contexts. */ |
434 | struct lttng_ust_ctx { | |
435 | struct lttng_ust_ctx_field *fields; | |
436 | unsigned int nr_fields; | |
437 | unsigned int allocated_fields; | |
438 | unsigned int largest_align; | |
439 | }; | |
440 | ||
441 | struct lttng_ust_registered_probe { | |
442 | const struct lttng_ust_probe_desc *desc; | |
443 | ||
444 | struct cds_list_head head; /* chain registered probes */ | |
445 | struct cds_list_head lazy_init_head; | |
446 | int lazy; /* lazy registration */ | |
447 | }; | |
448 | ||
449 | /* | |
450 | * Context field | |
451 | */ | |
452 | ||
453 | struct lttng_ust_ctx_field { | |
454 | const struct lttng_ust_event_field *event_field; | |
b2e37d27 MD |
455 | size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, |
456 | size_t offset); | |
457 | void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, | |
458 | struct lttng_ust_ring_buffer_ctx *ctx, | |
459 | struct lttng_ust_channel_buffer *chan); | |
460 | void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, | |
461 | struct lttng_ust_ctx_value *value); | |
4e48b5d2 MD |
462 | void (*destroy)(void *priv); |
463 | void *priv; | |
464 | }; | |
465 | ||
a084756d | 466 | static inline |
4e48b5d2 | 467 | const struct lttng_ust_type_integer *lttng_ust_get_type_integer(const struct lttng_ust_type_common *type) |
a084756d MD |
468 | { |
469 | if (type->type != lttng_ust_type_integer) | |
470 | return NULL; | |
4e48b5d2 | 471 | return caa_container_of(type, const struct lttng_ust_type_integer, parent); |
a084756d MD |
472 | } |
473 | ||
474 | static inline | |
4e48b5d2 | 475 | const struct lttng_ust_type_float *lttng_ust_get_type_float(const struct lttng_ust_type_common *type) |
a084756d MD |
476 | { |
477 | if (type->type != lttng_ust_type_float) | |
478 | return NULL; | |
4e48b5d2 | 479 | return caa_container_of(type, const struct lttng_ust_type_float, parent); |
a084756d MD |
480 | } |
481 | ||
482 | static inline | |
4e48b5d2 | 483 | const struct lttng_ust_type_string *lttng_ust_get_type_string(const struct lttng_ust_type_common *type) |
a084756d MD |
484 | { |
485 | if (type->type != lttng_ust_type_string) | |
486 | return NULL; | |
4e48b5d2 | 487 | return caa_container_of(type, const struct lttng_ust_type_string, parent); |
a084756d MD |
488 | } |
489 | ||
490 | static inline | |
4e48b5d2 | 491 | const struct lttng_ust_type_enum *lttng_ust_get_type_enum(const struct lttng_ust_type_common *type) |
a084756d MD |
492 | { |
493 | if (type->type != lttng_ust_type_enum) | |
494 | return NULL; | |
4e48b5d2 | 495 | return caa_container_of(type, const struct lttng_ust_type_enum, parent); |
a084756d MD |
496 | } |
497 | ||
498 | static inline | |
4e48b5d2 | 499 | const struct lttng_ust_type_array *lttng_ust_get_type_array(const struct lttng_ust_type_common *type) |
a084756d MD |
500 | { |
501 | if (type->type != lttng_ust_type_array) | |
502 | return NULL; | |
4e48b5d2 | 503 | return caa_container_of(type, const struct lttng_ust_type_array, parent); |
a084756d MD |
504 | } |
505 | ||
506 | static inline | |
4e48b5d2 | 507 | const struct lttng_ust_type_sequence *lttng_ust_get_type_sequence(const struct lttng_ust_type_common *type) |
a084756d MD |
508 | { |
509 | if (type->type != lttng_ust_type_sequence) | |
510 | return NULL; | |
4e48b5d2 | 511 | return caa_container_of(type, const struct lttng_ust_type_sequence, parent); |
a084756d MD |
512 | } |
513 | ||
514 | static inline | |
4e48b5d2 | 515 | const struct lttng_ust_type_struct *lttng_ust_get_type_struct(const struct lttng_ust_type_common *type) |
a084756d MD |
516 | { |
517 | if (type->type != lttng_ust_type_struct) | |
518 | return NULL; | |
4e48b5d2 | 519 | return caa_container_of(type, const struct lttng_ust_type_struct, parent); |
a084756d MD |
520 | } |
521 | ||
4e48b5d2 | 522 | #define lttng_ust_static_type_integer(_size, _alignment, _signedness, _byte_order, _base) \ |
5defa774 | 523 | ((const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_integer, { \ |
4e48b5d2 MD |
524 | .parent = { \ |
525 | .type = lttng_ust_type_integer, \ | |
526 | }, \ | |
527 | .struct_size = sizeof(struct lttng_ust_type_integer), \ | |
528 | .size = (_size), \ | |
529 | .alignment = (_alignment), \ | |
530 | .signedness = (_signedness), \ | |
baa8acf3 | 531 | .reverse_byte_order = (_byte_order) != LTTNG_UST_BYTE_ORDER, \ |
4e48b5d2 MD |
532 | .base = (_base), \ |
533 | })) | |
534 | ||
535 | #define lttng_ust_static_type_array_text(_length) \ | |
5defa774 | 536 | ((const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_array, { \ |
4e48b5d2 MD |
537 | .parent = { \ |
538 | .type = lttng_ust_type_array, \ | |
539 | }, \ | |
540 | .struct_size = sizeof(struct lttng_ust_type_array), \ | |
541 | .length = (_length), \ | |
542 | .alignment = 0, \ | |
543 | .encoding = lttng_ust_string_encoding_UTF8, \ | |
544 | .elem_type = lttng_ust_static_type_integer(sizeof(char) * CHAR_BIT, \ | |
545 | lttng_ust_rb_alignof(char) * CHAR_BIT, lttng_ust_is_signed_type(char), \ | |
baa8acf3 | 546 | LTTNG_UST_BYTE_ORDER, 10), \ |
4e48b5d2 MD |
547 | })) |
548 | ||
549 | #define lttng_ust_static_event_field(_name, _type, _nowrite, _nofilter) \ | |
5defa774 | 550 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \ |
4e48b5d2 MD |
551 | .struct_size = sizeof(struct lttng_ust_event_field), \ |
552 | .name = (_name), \ | |
553 | .type = (_type), \ | |
554 | .nowrite = (_nowrite), \ | |
555 | .nofilter = (_nofilter), \ | |
556 | }) | |
557 | ||
558 | #define lttng_ust_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv) \ | |
5defa774 | 559 | LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_ctx_field, { \ |
4e48b5d2 MD |
560 | .event_field = (_event_field), \ |
561 | .get_size = (_get_size), \ | |
562 | .record = (_record), \ | |
563 | .get_value = (_get_value), \ | |
564 | .destroy = (_destroy), \ | |
565 | .priv = (_priv), \ | |
566 | }) | |
a084756d | 567 | |
d871c65b FD |
568 | static inline |
569 | struct lttng_enabler *lttng_event_enabler_as_enabler( | |
570 | struct lttng_event_enabler *event_enabler) | |
571 | { | |
572 | return &event_enabler->base; | |
573 | } | |
574 | ||
d8d2416d FD |
575 | static inline |
576 | struct lttng_enabler *lttng_event_notifier_enabler_as_enabler( | |
577 | struct lttng_event_notifier_enabler *event_notifier_enabler) | |
578 | { | |
579 | return &event_notifier_enabler->base; | |
580 | } | |
d871c65b | 581 | |
d8d2416d | 582 | |
7753d283 | 583 | |
cbba5e04 MJ |
584 | /* This is ABI between liblttng-ust and liblttng-ust-dl */ |
585 | void lttng_ust_dl_update(void *ip); | |
586 | ||
f69fe5fb | 587 | struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_ust_session *session, |
4e48b5d2 | 588 | const struct lttng_ust_enum_desc *enum_desc) |
1d18d519 | 589 | __attribute__((visibility("hidden"))); |
7753d283 | 590 | |
4e48b5d2 | 591 | |
36c52fff | 592 | #endif /* _UST_COMMON_UST_EVENTS_H */ |