Commit | Line | Data |
---|---|---|
1c196845 MJ |
1 | // SPDX-FileCopyrightText: 2011 EfficiOS Inc. |
2 | // SPDX-FileCopyrightText: 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
3 | // | |
4 | // SPDX-License-Identifier: GPL-2.0-only | |
f3105c67 MD |
5 | |
6 | #ifndef _LTTNG_UST_CTL_H | |
7 | #define _LTTNG_UST_CTL_H | |
8 | ||
fb31eb73 | 9 | #include <limits.h> |
b4051ad8 | 10 | #include <stddef.h> |
fb31eb73 | 11 | #include <stdint.h> |
ebabbf58 | 12 | #include <stdbool.h> |
32ce8569 | 13 | #include <sys/types.h> |
fb31eb73 FD |
14 | |
15 | #include <lttng/ust-abi.h> | |
eae3c729 | 16 | #include <lttng/ust-utils.h> |
63b3205f | 17 | #include <lttng/ust-sigbus.h> |
74d81a6c | 18 | |
81b2d238 SM |
19 | #ifdef __cplusplus |
20 | extern "C" { | |
21 | #endif | |
22 | ||
74d81a6c MD |
23 | #ifndef LTTNG_UST_UUID_LEN |
24 | #define LTTNG_UST_UUID_LEN 16 | |
25 | #endif | |
26 | ||
32ce8569 MD |
27 | /* Default unix socket path */ |
28 | #define LTTNG_UST_SOCK_FILENAME \ | |
29 | "lttng-ust-sock-" \ | |
6c21eb5a | 30 | lttng_ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE) |
32ce8569 MD |
31 | |
32 | /* | |
33 | * Shared memory files path are automatically related to shm root, e.g. | |
34 | * /dev/shm under linux. | |
35 | */ | |
36 | #define LTTNG_UST_WAIT_FILENAME \ | |
37 | "lttng-ust-wait-" \ | |
6c21eb5a | 38 | lttng_ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE) |
32ce8569 | 39 | |
249cffb5 | 40 | struct lttng_ust_ctl_consumer_channel_attr { |
fd17d7ce | 41 | enum lttng_ust_abi_chan_type type; |
74d81a6c MD |
42 | uint64_t subbuf_size; /* bytes */ |
43 | uint64_t num_subbuf; /* power of 2 */ | |
44 | int overwrite; /* 1: overwrite, 0: discard */ | |
45 | unsigned int switch_timer_interval; /* usec */ | |
46 | unsigned int read_timer_interval; /* usec */ | |
fd17d7ce | 47 | enum lttng_ust_abi_output output; /* splice, mmap */ |
6ca18e66 | 48 | uint32_t chan_id; /* channel ID */ |
74d81a6c | 49 | unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ |
b2c5f61a | 50 | int64_t blocking_timeout; /* Blocking timeout (usec) */ |
9f5ade14 | 51 | } __attribute__((packed)); |
74d81a6c MD |
52 | |
53 | /* | |
54 | * API used by sessiond. | |
55 | */ | |
56 | ||
53f0df51 | 57 | struct lttng_ust_context_attr { |
fd17d7ce | 58 | enum lttng_ust_abi_context_type ctx; |
53f0df51 | 59 | union { |
fd17d7ce | 60 | struct lttng_ust_abi_perf_counter_ctx perf_counter; |
53f0df51 JG |
61 | struct { |
62 | char *provider_name; | |
63 | char *ctx_name; | |
64 | } app_ctx; | |
65 | } u; | |
66 | }; | |
67 | ||
7bc53e94 MD |
68 | /* |
69 | * Error values: all the following functions return: | |
c354a72c | 70 | * >= 0: Success (LTTNG_UST_OK) |
7bc53e94 MD |
71 | * < 0: error code. |
72 | */ | |
249cffb5 MJ |
73 | int lttng_ust_ctl_register_done(int sock); |
74 | int lttng_ust_ctl_create_session(int sock); | |
75 | int lttng_ust_ctl_create_event(int sock, struct lttng_ust_abi_event *ev, | |
fd17d7ce MD |
76 | struct lttng_ust_abi_object_data *channel_data, |
77 | struct lttng_ust_abi_object_data **event_data); | |
249cffb5 | 78 | int lttng_ust_ctl_add_context(int sock, struct lttng_ust_context_attr *ctx, |
fd17d7ce MD |
79 | struct lttng_ust_abi_object_data *obj_data, |
80 | struct lttng_ust_abi_object_data **context_data); | |
249cffb5 | 81 | int lttng_ust_ctl_set_filter(int sock, struct lttng_ust_abi_filter_bytecode *bytecode, |
fd17d7ce | 82 | struct lttng_ust_abi_object_data *obj_data); |
249cffb5 | 83 | int lttng_ust_ctl_set_capture(int sock, struct lttng_ust_abi_capture_bytecode *bytecode, |
fd17d7ce | 84 | struct lttng_ust_abi_object_data *obj_data); |
249cffb5 | 85 | int lttng_ust_ctl_set_exclusion(int sock, struct lttng_ust_abi_event_exclusion *exclusion, |
fd17d7ce MD |
86 | struct lttng_ust_abi_object_data *obj_data); |
87 | ||
249cffb5 MJ |
88 | int lttng_ust_ctl_enable(int sock, struct lttng_ust_abi_object_data *object); |
89 | int lttng_ust_ctl_disable(int sock, struct lttng_ust_abi_object_data *object); | |
90 | int lttng_ust_ctl_start_session(int sock, int handle); | |
91 | int lttng_ust_ctl_stop_session(int sock, int handle); | |
f3105c67 | 92 | |
d8d2416d | 93 | /* |
249cffb5 | 94 | * lttng_ust_ctl_create_event notifier_group creates a event notifier group. It |
d8d2416d FD |
95 | * establishes the connection with the application by providing a file |
96 | * descriptor of the pipe to be used by the application when a event notifier | |
97 | * of that group is fired. It returns a handle to be used when creating event | |
98 | * notifier in that group. | |
99 | */ | |
249cffb5 | 100 | int lttng_ust_ctl_create_event_notifier_group(int sock, int pipe_fd, |
fd17d7ce | 101 | struct lttng_ust_abi_object_data **event_notifier_group); |
d8d2416d FD |
102 | |
103 | /* | |
249cffb5 | 104 | * lttng_ust_ctl_create_event notifier creates a event notifier in a event notifier |
d8d2416d FD |
105 | * group giving a event notifier description and a event notifier group handle. |
106 | * It returns a event notifier handle to be used when enabling the event | |
107 | * notifier, attaching filter, attaching exclusion, and disabling the event | |
108 | * notifier. | |
109 | */ | |
249cffb5 | 110 | int lttng_ust_ctl_create_event_notifier(int sock, |
fd17d7ce MD |
111 | struct lttng_ust_abi_event_notifier *event_notifier, |
112 | struct lttng_ust_abi_object_data *event_notifier_group, | |
113 | struct lttng_ust_abi_object_data **event_notifier_data); | |
d8d2416d | 114 | |
b115631f | 115 | /* |
249cffb5 | 116 | * lttng_ust_ctl_tracepoint_list returns a tracepoint list handle, or negative |
b115631f MD |
117 | * error value. |
118 | */ | |
249cffb5 | 119 | int lttng_ust_ctl_tracepoint_list(int sock); |
74d81a6c | 120 | |
b115631f | 121 | /* |
249cffb5 | 122 | * lttng_ust_ctl_tracepoint_list_get is used to iterate on the tp list |
7bc53e94 MD |
123 | * handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is |
124 | * returned. | |
b115631f | 125 | */ |
249cffb5 | 126 | int lttng_ust_ctl_tracepoint_list_get(int sock, int tp_list_handle, |
fd17d7ce | 127 | struct lttng_ust_abi_tracepoint_iter *iter); |
b115631f | 128 | |
40003310 | 129 | /* |
249cffb5 | 130 | * lttng_ust_ctl_tracepoint_field_list returns a tracepoint field list handle, |
40003310 MD |
131 | * or negative error value. |
132 | */ | |
249cffb5 | 133 | int lttng_ust_ctl_tracepoint_field_list(int sock); |
40003310 MD |
134 | |
135 | /* | |
249cffb5 | 136 | * lttng_ust_ctl_tracepoint_field_list_get is used to iterate on the tp field |
7bc53e94 MD |
137 | * list handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is |
138 | * returned. | |
40003310 | 139 | */ |
249cffb5 | 140 | int lttng_ust_ctl_tracepoint_field_list_get(int sock, int tp_field_list_handle, |
fd17d7ce | 141 | struct lttng_ust_abi_field_iter *iter); |
40003310 | 142 | |
249cffb5 MJ |
143 | int lttng_ust_ctl_tracer_version(int sock, struct lttng_ust_abi_tracer_version *v); |
144 | int lttng_ust_ctl_wait_quiescent(int sock); | |
f3105c67 | 145 | |
249cffb5 | 146 | int lttng_ust_ctl_sock_flush_buffer(int sock, struct lttng_ust_abi_object_data *object); |
f1fffc57 | 147 | |
249cffb5 | 148 | int lttng_ust_ctl_calibrate(int sock, struct lttng_ust_abi_calibrate *calibrate); |
f3105c67 | 149 | |
74d81a6c | 150 | /* Release object created by members of this API. */ |
249cffb5 | 151 | int lttng_ust_ctl_release_object(int sock, struct lttng_ust_abi_object_data *data); |
74d81a6c | 152 | /* Release handle returned by create session. */ |
249cffb5 | 153 | int lttng_ust_ctl_release_handle(int sock, int handle); |
74d81a6c | 154 | |
249cffb5 | 155 | int lttng_ust_ctl_recv_channel_from_consumer(int sock, |
fd17d7ce | 156 | struct lttng_ust_abi_object_data **channel_data); |
249cffb5 | 157 | int lttng_ust_ctl_recv_stream_from_consumer(int sock, |
fd17d7ce | 158 | struct lttng_ust_abi_object_data **stream_data); |
249cffb5 | 159 | int lttng_ust_ctl_send_channel_to_ust(int sock, int session_handle, |
fd17d7ce | 160 | struct lttng_ust_abi_object_data *channel_data); |
249cffb5 | 161 | int lttng_ust_ctl_send_stream_to_ust(int sock, |
fd17d7ce MD |
162 | struct lttng_ust_abi_object_data *channel_data, |
163 | struct lttng_ust_abi_object_data *stream_data); | |
74d81a6c | 164 | |
12f3dabc | 165 | /* |
249cffb5 | 166 | * lttng_ust_ctl_duplicate_ust_object_data allocated a new object in "dest" if |
12f3dabc | 167 | * it succeeds (returns 0). It must be released using |
249cffb5 | 168 | * lttng_ust_ctl_release_object() and then freed with free(). |
12f3dabc | 169 | */ |
249cffb5 | 170 | int lttng_ust_ctl_duplicate_ust_object_data(struct lttng_ust_abi_object_data **dest, |
fd17d7ce | 171 | struct lttng_ust_abi_object_data *src); |
12f3dabc | 172 | |
f3105c67 | 173 | /* |
74d81a6c | 174 | * API used by consumer. |
f3105c67 | 175 | */ |
74d81a6c | 176 | |
249cffb5 MJ |
177 | struct lttng_ust_ctl_consumer_channel; |
178 | struct lttng_ust_ctl_consumer_stream; | |
179 | struct lttng_ust_ctl_consumer_channel_attr; | |
74d81a6c | 180 | |
249cffb5 | 181 | int lttng_ust_ctl_get_nr_stream_per_channel(void); |
5ea386c3 | 182 | |
249cffb5 MJ |
183 | struct lttng_ust_ctl_consumer_channel * |
184 | lttng_ust_ctl_create_channel(struct lttng_ust_ctl_consumer_channel_attr *attr, | |
5ea386c3 | 185 | const int *stream_fds, int nr_stream_fds); |
5224b5c8 | 186 | /* |
74d81a6c | 187 | * Each stream created needs to be destroyed before calling |
249cffb5 | 188 | * lttng_ust_ctl_destroy_channel(). |
5224b5c8 | 189 | */ |
249cffb5 | 190 | void lttng_ust_ctl_destroy_channel(struct lttng_ust_ctl_consumer_channel *chan); |
f3105c67 | 191 | |
249cffb5 MJ |
192 | int lttng_ust_ctl_send_channel_to_sessiond(int sock, |
193 | struct lttng_ust_ctl_consumer_channel *channel); | |
194 | int lttng_ust_ctl_channel_close_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan); | |
195 | int lttng_ust_ctl_channel_close_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan); | |
196 | int lttng_ust_ctl_channel_get_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan); | |
197 | int lttng_ust_ctl_channel_get_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan); | |
c9023c93 | 198 | |
249cffb5 MJ |
199 | int lttng_ust_ctl_write_metadata_to_channel( |
200 | struct lttng_ust_ctl_consumer_channel *channel, | |
c9023c93 MD |
201 | const char *metadata_str, /* NOT null-terminated */ |
202 | size_t len); /* metadata length */ | |
249cffb5 MJ |
203 | ssize_t lttng_ust_ctl_write_one_packet_to_channel( |
204 | struct lttng_ust_ctl_consumer_channel *channel, | |
3ef94b0e JD |
205 | const char *metadata_str, /* NOT null-terminated */ |
206 | size_t len); /* metadata length */ | |
c9023c93 | 207 | |
74d81a6c MD |
208 | /* |
209 | * Send a NULL stream to finish iteration over all streams of a given | |
210 | * channel. | |
211 | */ | |
249cffb5 MJ |
212 | int lttng_ust_ctl_send_stream_to_sessiond(int sock, |
213 | struct lttng_ust_ctl_consumer_stream *stream); | |
214 | int lttng_ust_ctl_stream_close_wait_fd(struct lttng_ust_ctl_consumer_stream *stream); | |
215 | int lttng_ust_ctl_stream_close_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream); | |
216 | int lttng_ust_ctl_stream_get_wait_fd(struct lttng_ust_ctl_consumer_stream *stream); | |
217 | int lttng_ust_ctl_stream_get_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream); | |
f3105c67 | 218 | |
74d81a6c | 219 | /* Create/destroy stream buffers for read */ |
249cffb5 MJ |
220 | struct lttng_ust_ctl_consumer_stream * |
221 | lttng_ust_ctl_create_stream(struct lttng_ust_ctl_consumer_channel *channel, | |
74d81a6c | 222 | int cpu); |
249cffb5 | 223 | void lttng_ust_ctl_destroy_stream(struct lttng_ust_ctl_consumer_stream *stream); |
f3105c67 MD |
224 | |
225 | /* For mmap mode, readable without "get" operation */ | |
249cffb5 | 226 | int lttng_ust_ctl_get_mmap_len(struct lttng_ust_ctl_consumer_stream *stream, |
f3105c67 | 227 | unsigned long *len); |
249cffb5 | 228 | int lttng_ust_ctl_get_max_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream, |
f3105c67 MD |
229 | unsigned long *len); |
230 | ||
231 | /* | |
232 | * For mmap mode, operate on the current packet (between get/put or | |
233 | * get_next/put_next). | |
234 | */ | |
249cffb5 MJ |
235 | void *lttng_ust_ctl_get_mmap_base(struct lttng_ust_ctl_consumer_stream *stream); |
236 | int lttng_ust_ctl_get_mmap_read_offset(struct lttng_ust_ctl_consumer_stream *stream, | |
74d81a6c | 237 | unsigned long *off); |
249cffb5 | 238 | int lttng_ust_ctl_get_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream, |
74d81a6c | 239 | unsigned long *len); |
249cffb5 | 240 | int lttng_ust_ctl_get_padded_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream, |
74d81a6c | 241 | unsigned long *len); |
249cffb5 MJ |
242 | int lttng_ust_ctl_get_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream); |
243 | int lttng_ust_ctl_put_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream); | |
f3105c67 MD |
244 | |
245 | /* snapshot */ | |
246 | ||
249cffb5 MJ |
247 | int lttng_ust_ctl_snapshot(struct lttng_ust_ctl_consumer_stream *stream); |
248 | int lttng_ust_ctl_snapshot_sample_positions(struct lttng_ust_ctl_consumer_stream *stream); | |
249 | int lttng_ust_ctl_snapshot_get_consumed(struct lttng_ust_ctl_consumer_stream *stream, | |
74d81a6c | 250 | unsigned long *pos); |
249cffb5 | 251 | int lttng_ust_ctl_snapshot_get_produced(struct lttng_ust_ctl_consumer_stream *stream, |
74d81a6c | 252 | unsigned long *pos); |
249cffb5 | 253 | int lttng_ust_ctl_get_subbuf(struct lttng_ust_ctl_consumer_stream *stream, |
74d81a6c | 254 | unsigned long *pos); |
249cffb5 | 255 | int lttng_ust_ctl_put_subbuf(struct lttng_ust_ctl_consumer_stream *stream); |
5f9d3dbc | 256 | |
63b3205f | 257 | int lttng_ust_ctl_flush_buffer(struct lttng_ust_ctl_consumer_stream *stream, |
74d81a6c | 258 | int producer_active); |
63b3205f | 259 | int lttng_ust_ctl_clear_buffer(struct lttng_ust_ctl_consumer_stream *stream); |
f3105c67 | 260 | |
b2f3252a | 261 | /* index */ |
82df14e4 MD |
262 | |
263 | /* | |
264 | * Getters which need to be used on the current packet (between get/put | |
265 | * or get_next/put_next. | |
266 | */ | |
267 | ||
249cffb5 | 268 | int lttng_ust_ctl_get_timestamp_begin(struct lttng_ust_ctl_consumer_stream *stream, |
b2f3252a | 269 | uint64_t *timestamp_begin); |
249cffb5 | 270 | int lttng_ust_ctl_get_timestamp_end(struct lttng_ust_ctl_consumer_stream *stream, |
b2f3252a | 271 | uint64_t *timestamp_end); |
249cffb5 | 272 | int lttng_ust_ctl_get_events_discarded(struct lttng_ust_ctl_consumer_stream *stream, |
b2f3252a | 273 | uint64_t *events_discarded); |
249cffb5 | 274 | int lttng_ust_ctl_get_content_size(struct lttng_ust_ctl_consumer_stream *stream, |
b2f3252a | 275 | uint64_t *content_size); |
249cffb5 | 276 | int lttng_ust_ctl_get_packet_size(struct lttng_ust_ctl_consumer_stream *stream, |
b2f3252a | 277 | uint64_t *packet_size); |
249cffb5 | 278 | int lttng_ust_ctl_get_sequence_number(struct lttng_ust_ctl_consumer_stream *stream, |
1ff31389 | 279 | uint64_t *seq); |
82df14e4 MD |
280 | |
281 | /* | |
282 | * Getter returning state invariant for the stream, which can be used | |
283 | * without "get" operation. | |
284 | */ | |
285 | ||
249cffb5 | 286 | int lttng_ust_ctl_get_stream_id(struct lttng_ust_ctl_consumer_stream *stream, |
82df14e4 | 287 | uint64_t *stream_id); |
249cffb5 | 288 | int lttng_ust_ctl_get_instance_id(struct lttng_ust_ctl_consumer_stream *stream, |
45a00b05 | 289 | uint64_t *id); |
b2f3252a | 290 | |
82df14e4 MD |
291 | /* |
292 | * Getter returning the current timestamp as perceived from the | |
293 | * tracer. | |
294 | */ | |
249cffb5 | 295 | int lttng_ust_ctl_get_current_timestamp(struct lttng_ust_ctl_consumer_stream *stream, |
82df14e4 MD |
296 | uint64_t *ts); |
297 | ||
57201bb3 | 298 | /* returns whether UST has perf counters support. */ |
249cffb5 | 299 | int lttng_ust_ctl_has_perf_counters(void); |
57201bb3 | 300 | |
f53329f3 | 301 | /* Regenerate the statedump. */ |
249cffb5 | 302 | int lttng_ust_ctl_regenerate_statedump(int sock, int handle); |
f53329f3 | 303 | |
32ce8569 MD |
304 | /* event registry management */ |
305 | ||
249cffb5 MJ |
306 | enum lttng_ust_ctl_socket_type { |
307 | LTTNG_UST_CTL_SOCKET_CMD = 0, | |
308 | LTTNG_UST_CTL_SOCKET_NOTIFY = 1, | |
32ce8569 MD |
309 | }; |
310 | ||
249cffb5 MJ |
311 | enum lttng_ust_ctl_notify_cmd { |
312 | LTTNG_UST_CTL_NOTIFY_CMD_EVENT = 0, | |
313 | LTTNG_UST_CTL_NOTIFY_CMD_CHANNEL = 1, | |
314 | LTTNG_UST_CTL_NOTIFY_CMD_ENUM = 2, | |
24f7193c | 315 | LTTNG_UST_CTL_NOTIFY_CMD_KEY = 3, |
32ce8569 MD |
316 | }; |
317 | ||
249cffb5 MJ |
318 | enum lttng_ust_ctl_channel_header { |
319 | LTTNG_UST_CTL_CHANNEL_HEADER_UNKNOWN = 0, | |
320 | LTTNG_UST_CTL_CHANNEL_HEADER_COMPACT = 1, | |
321 | LTTNG_UST_CTL_CHANNEL_HEADER_LARGE = 2, | |
32ce8569 MD |
322 | }; |
323 | ||
324 | /* event type structures */ | |
325 | ||
249cffb5 MJ |
326 | enum lttng_ust_ctl_abstract_types { |
327 | lttng_ust_ctl_atype_integer, | |
328 | lttng_ust_ctl_atype_enum, /* legacy */ | |
329 | lttng_ust_ctl_atype_array, /* legacy */ | |
330 | lttng_ust_ctl_atype_sequence, /* legacy */ | |
331 | lttng_ust_ctl_atype_string, | |
332 | lttng_ust_ctl_atype_float, | |
333 | lttng_ust_ctl_atype_variant, /* legacy */ | |
334 | lttng_ust_ctl_atype_struct, /* legacy */ | |
335 | lttng_ust_ctl_atype_enum_nestable, | |
336 | lttng_ust_ctl_atype_array_nestable, | |
337 | lttng_ust_ctl_atype_sequence_nestable, | |
338 | lttng_ust_ctl_atype_struct_nestable, | |
339 | lttng_ust_ctl_atype_variant_nestable, | |
340 | NR_LTTNG_UST_CTL_ABSTRACT_TYPES, | |
32ce8569 MD |
341 | }; |
342 | ||
249cffb5 MJ |
343 | enum lttng_ust_ctl_string_encodings { |
344 | lttng_ust_ctl_encode_none = 0, | |
345 | lttng_ust_ctl_encode_UTF8 = 1, | |
346 | lttng_ust_ctl_encode_ASCII = 2, | |
347 | NR_LTTNG_UST_CTL_STRING_ENCODINGS, | |
32ce8569 MD |
348 | }; |
349 | ||
249cffb5 MJ |
350 | #define LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING 24 |
351 | struct lttng_ust_ctl_integer_type { | |
32ce8569 MD |
352 | uint32_t size; /* in bits */ |
353 | uint32_t signedness; | |
354 | uint32_t reverse_byte_order; | |
355 | uint32_t base; /* 2, 8, 10, 16, for pretty print */ | |
249cffb5 | 356 | int32_t encoding; /* enum lttng_ust_ctl_string_encodings */ |
32ce8569 | 357 | uint16_t alignment; /* in bits */ |
249cffb5 | 358 | char padding[LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING]; |
9f5ade14 | 359 | } __attribute__((packed)); |
32ce8569 | 360 | |
249cffb5 MJ |
361 | #define LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING 24 |
362 | struct lttng_ust_ctl_float_type { | |
32ce8569 MD |
363 | uint32_t exp_dig; /* exponent digits, in bits */ |
364 | uint32_t mant_dig; /* mantissa digits, in bits */ | |
365 | uint32_t reverse_byte_order; | |
366 | uint16_t alignment; /* in bits */ | |
249cffb5 | 367 | char padding[LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING]; |
9f5ade14 | 368 | } __attribute__((packed)); |
32ce8569 | 369 | |
249cffb5 MJ |
370 | #define LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING 15 |
371 | struct lttng_ust_ctl_enum_value { | |
a6f80644 MD |
372 | uint64_t value; |
373 | uint8_t signedness; | |
249cffb5 | 374 | char padding[LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING]; |
9f5ade14 | 375 | } __attribute__((packed)); |
a6f80644 | 376 | |
249cffb5 MJ |
377 | enum lttng_ust_ctl_ust_enum_entry_options { |
378 | LTTNG_UST_CTL_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0, | |
3e762260 PP |
379 | }; |
380 | ||
249cffb5 MJ |
381 | #define LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING 32 |
382 | struct lttng_ust_ctl_enum_entry { | |
383 | struct lttng_ust_ctl_enum_value start, end; /* start and end are inclusive */ | |
fd17d7ce | 384 | char string[LTTNG_UST_ABI_SYM_NAME_LEN]; |
3e762260 PP |
385 | union { |
386 | struct { | |
387 | uint32_t options; | |
9f5ade14 | 388 | } __attribute__((packed)) extra; |
249cffb5 | 389 | char padding[LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING]; |
3e762260 | 390 | } u; |
9f5ade14 | 391 | } __attribute__((packed)); |
c785c634 | 392 | |
218deb69 | 393 | /* legacy */ |
249cffb5 MJ |
394 | #define LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING 296 |
395 | union _lttng_ust_ctl_basic_type { | |
396 | struct lttng_ust_ctl_integer_type integer; | |
c785c634 | 397 | struct { |
fd17d7ce | 398 | char name[LTTNG_UST_ABI_SYM_NAME_LEN]; |
249cffb5 | 399 | struct lttng_ust_ctl_integer_type container_type; |
c785c634 MD |
400 | uint64_t id; /* enum ID in sessiond. */ |
401 | } enumeration; | |
32ce8569 | 402 | struct { |
249cffb5 | 403 | int32_t encoding; /* enum lttng_ust_ctl_string_encodings */ |
32ce8569 | 404 | } string; |
249cffb5 MJ |
405 | struct lttng_ust_ctl_float_type _float; |
406 | char padding[LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING]; | |
9f5ade14 | 407 | } __attribute__((packed)); |
32ce8569 | 408 | |
218deb69 | 409 | /* legacy */ |
249cffb5 MJ |
410 | struct lttng_ust_ctl_basic_type { |
411 | enum lttng_ust_ctl_abstract_types atype; | |
32ce8569 | 412 | union { |
249cffb5 | 413 | union _lttng_ust_ctl_basic_type basic; |
32ce8569 | 414 | } u; |
9f5ade14 | 415 | } __attribute__((packed)); |
32ce8569 | 416 | |
218deb69 MD |
417 | /* |
418 | * Padding is derived from largest member: u.legacy.sequence which | |
249cffb5 | 419 | * contains two basic types, each with LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING. |
218deb69 | 420 | */ |
249cffb5 MJ |
421 | #define LTTNG_UST_CTL_UST_TYPE_PADDING (2 * LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING) |
422 | struct lttng_ust_ctl_type { | |
423 | enum lttng_ust_ctl_abstract_types atype; | |
32ce8569 | 424 | union { |
249cffb5 MJ |
425 | struct lttng_ust_ctl_integer_type integer; |
426 | struct lttng_ust_ctl_float_type _float; | |
218deb69 | 427 | struct { |
249cffb5 | 428 | int32_t encoding; /* enum lttng_ust_ctl_string_encodings */ |
218deb69 MD |
429 | } string; |
430 | struct { | |
fd17d7ce | 431 | char name[LTTNG_UST_ABI_SYM_NAME_LEN]; |
218deb69 | 432 | uint64_t id; /* enum ID in sessiond. */ |
249cffb5 | 433 | /* container_type follows after this struct lttng_ust_ctl_field. */ |
218deb69 | 434 | } enum_nestable; |
32ce8569 | 435 | struct { |
32ce8569 | 436 | uint32_t length; /* num. elems. */ |
218deb69 | 437 | uint32_t alignment; |
249cffb5 | 438 | /* elem_type follows after this struct lttng_ust_ctl_field. */ |
218deb69 | 439 | } array_nestable; |
32ce8569 | 440 | struct { |
fd17d7ce | 441 | char length_name[LTTNG_UST_ABI_SYM_NAME_LEN]; |
218deb69 MD |
442 | uint32_t alignment; /* Alignment before elements. */ |
443 | /* elem_type follows after the length_type. */ | |
444 | } sequence_nestable; | |
445 | struct { | |
446 | uint32_t nr_fields; | |
447 | uint32_t alignment; | |
249cffb5 | 448 | /* Followed by nr_fields struct lttng_ust_ctl_field. */ |
218deb69 | 449 | } struct_nestable; |
53569322 MD |
450 | struct { |
451 | uint32_t nr_choices; | |
fd17d7ce | 452 | char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN]; |
218deb69 | 453 | uint32_t alignment; |
249cffb5 | 454 | /* Followed by nr_choices struct lttng_ust_ctl_field. */ |
218deb69 MD |
455 | } variant_nestable; |
456 | ||
457 | /* Legacy ABI */ | |
458 | union { | |
249cffb5 | 459 | union _lttng_ust_ctl_basic_type basic; |
218deb69 | 460 | struct { |
249cffb5 | 461 | struct lttng_ust_ctl_basic_type elem_type; |
218deb69 MD |
462 | uint32_t length; /* num. elems. */ |
463 | } array; | |
464 | struct { | |
249cffb5 MJ |
465 | struct lttng_ust_ctl_basic_type length_type; |
466 | struct lttng_ust_ctl_basic_type elem_type; | |
218deb69 MD |
467 | } sequence; |
468 | struct { | |
469 | uint32_t nr_fields; | |
249cffb5 | 470 | /* Followed by nr_fields struct lttng_ust_ctl_field. */ |
218deb69 MD |
471 | } _struct; |
472 | struct { | |
473 | uint32_t nr_choices; | |
fd17d7ce | 474 | char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN]; |
249cffb5 | 475 | /* Followed by nr_choices struct lttng_ust_ctl_field. */ |
218deb69 MD |
476 | } variant; |
477 | } legacy; | |
249cffb5 | 478 | char padding[LTTNG_UST_CTL_UST_TYPE_PADDING]; |
32ce8569 | 479 | } u; |
9f5ade14 | 480 | } __attribute__((packed)); |
32ce8569 | 481 | |
249cffb5 MJ |
482 | #define LTTNG_UST_CTL_UST_FIELD_PADDING 28 |
483 | struct lttng_ust_ctl_field { | |
fd17d7ce | 484 | char name[LTTNG_UST_ABI_SYM_NAME_LEN]; |
249cffb5 MJ |
485 | struct lttng_ust_ctl_type type; |
486 | char padding[LTTNG_UST_CTL_UST_FIELD_PADDING]; | |
9f5ade14 | 487 | } __attribute__((packed)); |
32ce8569 MD |
488 | |
489 | /* | |
490 | * Returns 0 on success, negative error value on error. | |
491 | * If an error other than -LTTNG_UST_ERR_UNSUP_MAJOR is returned, | |
492 | * the output fields are not populated. | |
493 | */ | |
249cffb5 MJ |
494 | int lttng_ust_ctl_recv_reg_msg(int sock, |
495 | enum lttng_ust_ctl_socket_type *type, | |
32ce8569 MD |
496 | uint32_t *major, |
497 | uint32_t *minor, | |
498 | uint32_t *pid, | |
499 | uint32_t *ppid, | |
500 | uint32_t *uid, | |
501 | uint32_t *gid, | |
502 | uint32_t *bits_per_long, | |
503 | uint32_t *uint8_t_alignment, | |
504 | uint32_t *uint16_t_alignment, | |
505 | uint32_t *uint32_t_alignment, | |
506 | uint32_t *uint64_t_alignment, | |
507 | uint32_t *long_alignment, | |
508 | int *byte_order, | |
509 | char *name); /* size LTTNG_UST_ABI_PROCNAME_LEN */ | |
510 | ||
511 | /* | |
512 | * Returns 0 on success, negative UST or system error value on error. | |
513 | * Receive the notification command. The "notify_cmd" can then be used | |
249cffb5 MJ |
514 | * by the caller to find out which lttng_ust_ctl_recv_* function should be |
515 | * called to receive the notification, and which lttng_ust_ctl_reply_* is | |
32ce8569 MD |
516 | * appropriate. |
517 | */ | |
249cffb5 | 518 | int lttng_ust_ctl_recv_notify(int sock, enum lttng_ust_ctl_notify_cmd *notify_cmd); |
32ce8569 MD |
519 | |
520 | /* | |
521 | * Returns 0 on success, negative UST or system error value on error. | |
522 | */ | |
249cffb5 | 523 | int lttng_ust_ctl_recv_register_event(int sock, |
32ce8569 MD |
524 | int *session_objd, /* session descriptor (output) */ |
525 | int *channel_objd, /* channel descriptor (output) */ | |
526 | char *event_name, /* | |
527 | * event name (output, | |
fd17d7ce | 528 | * size LTTNG_UST_ABI_SYM_NAME_LEN) |
32ce8569 MD |
529 | */ |
530 | int *loglevel, | |
531 | char **signature, /* | |
532 | * event signature | |
533 | * (output, dynamically | |
534 | * allocated, must be free(3)'d | |
535 | * by the caller if function | |
536 | * returns success.) | |
537 | */ | |
538 | size_t *nr_fields, | |
249cffb5 | 539 | struct lttng_ust_ctl_field **fields, |
b187bcd5 MD |
540 | char **model_emf_uri, |
541 | uint64_t *user_token); | |
32ce8569 MD |
542 | |
543 | /* | |
544 | * Returns 0 on success, negative error value on error. | |
545 | */ | |
249cffb5 | 546 | int lttng_ust_ctl_reply_register_event(int sock, |
24f7193c MD |
547 | uint32_t id, /* id (input) */ |
548 | int ret_code); /* return code. 0 ok, negative error */ | |
549 | ||
550 | /* | |
551 | * Returns 0 on success, negative UST or system error value on error. | |
552 | */ | |
553 | int lttng_ust_ctl_recv_register_key(int sock, | |
554 | int *session_objd, /* session descriptor (output) */ | |
555 | int *map_objd, /* map descriptor (output) */ | |
556 | uint32_t *dimension, /* | |
557 | * Against which dimension is | |
558 | * this key expressed. (output) | |
559 | */ | |
560 | uint64_t **dimension_indexes, /* | |
561 | * Indexes (output, | |
562 | * dynamically | |
563 | * allocated, must be | |
564 | * free(3)'d by the | |
565 | * caller if function | |
566 | * returns success.) | |
567 | * Contains @dimension | |
568 | * elements. | |
569 | */ | |
570 | char **key_string, /* | |
571 | * key string (output, | |
572 | * dynamically allocated, must | |
573 | * be free(3)'d by the caller if | |
574 | * function returns success.) | |
575 | */ | |
576 | uint64_t *user_token); | |
577 | ||
578 | /* | |
579 | * Returns 0 on success, negative error value on error. | |
580 | */ | |
581 | int lttng_ust_ctl_reply_register_key(int sock, | |
582 | uint64_t index, /* Index within dimension (input) */ | |
32ce8569 MD |
583 | int ret_code); /* return code. 0 ok, negative error */ |
584 | ||
c785c634 MD |
585 | /* |
586 | * Returns 0 on success, negative UST or system error value on error. | |
587 | */ | |
249cffb5 | 588 | int lttng_ust_ctl_recv_register_enum(int sock, |
c785c634 MD |
589 | int *session_objd, |
590 | char *enum_name, | |
249cffb5 | 591 | struct lttng_ust_ctl_enum_entry **entries, |
c785c634 MD |
592 | size_t *nr_entries); |
593 | ||
594 | /* | |
595 | * Returns 0 on success, negative error value on error. | |
596 | */ | |
249cffb5 | 597 | int lttng_ust_ctl_reply_register_enum(int sock, |
c785c634 MD |
598 | uint64_t id, /* enum id (input) */ |
599 | int ret_code); | |
600 | ||
32ce8569 MD |
601 | /* |
602 | * Returns 0 on success, negative UST or system error value on error. | |
603 | */ | |
249cffb5 | 604 | int lttng_ust_ctl_recv_register_channel(int sock, |
32ce8569 MD |
605 | int *session_objd, /* session descriptor (output) */ |
606 | int *channel_objd, /* channel descriptor (output) */ | |
607 | size_t *nr_fields, /* context fields */ | |
249cffb5 | 608 | struct lttng_ust_ctl_field **fields); |
32ce8569 MD |
609 | |
610 | /* | |
611 | * Returns 0 on success, negative error value on error. | |
612 | */ | |
249cffb5 | 613 | int lttng_ust_ctl_reply_register_channel(int sock, |
32ce8569 | 614 | uint32_t chan_id, |
249cffb5 | 615 | enum lttng_ust_ctl_channel_header header_type, |
32ce8569 MD |
616 | int ret_code); /* return code. 0 ok, negative error */ |
617 | ||
ebabbf58 MD |
618 | /* |
619 | * Counter API. | |
620 | */ | |
621 | ||
249cffb5 MJ |
622 | enum lttng_ust_ctl_counter_bitness { |
623 | LTTNG_UST_CTL_COUNTER_BITNESS_32 = 0, | |
624 | LTTNG_UST_CTL_COUNTER_BITNESS_64 = 1, | |
ebabbf58 MD |
625 | }; |
626 | ||
249cffb5 MJ |
627 | enum lttng_ust_ctl_counter_arithmetic { |
628 | LTTNG_UST_CTL_COUNTER_ARITHMETIC_MODULAR = 0, | |
629 | LTTNG_UST_CTL_COUNTER_ARITHMETIC_SATURATION = 1, | |
ebabbf58 MD |
630 | }; |
631 | ||
24f7193c MD |
632 | enum lttng_ust_ctl_key_type { |
633 | LTTNG_UST_CTL_KEY_TYPE_TOKENS = 0, | |
634 | LTTNG_UST_CTL_KEY_TYPE_INTEGER = 1, | |
635 | }; | |
636 | ||
ebabbf58 | 637 | /* Used as alloc flags. */ |
249cffb5 MJ |
638 | enum lttng_ust_ctl_counter_alloc { |
639 | LTTNG_UST_CTL_COUNTER_ALLOC_PER_CPU = (1 << 0), | |
640 | LTTNG_UST_CTL_COUNTER_ALLOC_GLOBAL = (1 << 1), | |
ebabbf58 MD |
641 | }; |
642 | ||
249cffb5 | 643 | struct lttng_ust_ctl_daemon_counter; |
ebabbf58 | 644 | |
249cffb5 | 645 | int lttng_ust_ctl_get_nr_cpu_per_counter(void); |
ebabbf58 | 646 | |
249cffb5 | 647 | struct lttng_ust_ctl_counter_dimension { |
ebabbf58 MD |
648 | uint64_t size; |
649 | uint64_t underflow_index; | |
650 | uint64_t overflow_index; | |
24f7193c | 651 | enum lttng_ust_ctl_key_type key_type; |
ebabbf58 MD |
652 | uint8_t has_underflow; |
653 | uint8_t has_overflow; | |
654 | }; | |
655 | ||
249cffb5 MJ |
656 | struct lttng_ust_ctl_daemon_counter * |
657 | lttng_ust_ctl_create_counter(size_t nr_dimensions, | |
658 | const struct lttng_ust_ctl_counter_dimension *dimensions, | |
ebabbf58 MD |
659 | int64_t global_sum_step, |
660 | int global_counter_fd, | |
661 | int nr_counter_cpu_fds, | |
662 | const int *counter_cpu_fds, | |
249cffb5 MJ |
663 | enum lttng_ust_ctl_counter_bitness bitness, |
664 | enum lttng_ust_ctl_counter_arithmetic arithmetic, | |
81bc4972 MD |
665 | uint32_t alloc_flags, |
666 | bool coalesce_hits); | |
ebabbf58 | 667 | |
249cffb5 | 668 | int lttng_ust_ctl_create_counter_data(struct lttng_ust_ctl_daemon_counter *counter, |
fd17d7ce | 669 | struct lttng_ust_abi_object_data **counter_data); |
ebabbf58 | 670 | |
249cffb5 | 671 | int lttng_ust_ctl_create_counter_global_data(struct lttng_ust_ctl_daemon_counter *counter, |
fd17d7ce | 672 | struct lttng_ust_abi_object_data **counter_global_data); |
249cffb5 | 673 | int lttng_ust_ctl_create_counter_cpu_data(struct lttng_ust_ctl_daemon_counter *counter, int cpu, |
fd17d7ce | 674 | struct lttng_ust_abi_object_data **counter_cpu_data); |
ebabbf58 MD |
675 | |
676 | /* | |
677 | * Each counter data and counter cpu data created need to be destroyed | |
249cffb5 | 678 | * before calling lttng_ust_ctl_destroy_counter(). |
ebabbf58 | 679 | */ |
249cffb5 | 680 | void lttng_ust_ctl_destroy_counter(struct lttng_ust_ctl_daemon_counter *counter); |
ebabbf58 | 681 | |
249cffb5 | 682 | int lttng_ust_ctl_send_counter_data_to_ust(int sock, int parent_handle, |
fd17d7ce | 683 | struct lttng_ust_abi_object_data *counter_data); |
249cffb5 | 684 | int lttng_ust_ctl_send_counter_global_data_to_ust(int sock, |
fd17d7ce MD |
685 | struct lttng_ust_abi_object_data *counter_data, |
686 | struct lttng_ust_abi_object_data *counter_global_data); | |
249cffb5 | 687 | int lttng_ust_ctl_send_counter_cpu_data_to_ust(int sock, |
fd17d7ce MD |
688 | struct lttng_ust_abi_object_data *counter_data, |
689 | struct lttng_ust_abi_object_data *counter_cpu_data); | |
ebabbf58 | 690 | |
249cffb5 | 691 | int lttng_ust_ctl_counter_read(struct lttng_ust_ctl_daemon_counter *counter, |
ebabbf58 MD |
692 | const size_t *dimension_indexes, |
693 | int cpu, int64_t *value, | |
694 | bool *overflow, bool *underflow); | |
249cffb5 | 695 | int lttng_ust_ctl_counter_aggregate(struct lttng_ust_ctl_daemon_counter *counter, |
ebabbf58 MD |
696 | const size_t *dimension_indexes, |
697 | int64_t *value, | |
698 | bool *overflow, bool *underflow); | |
249cffb5 | 699 | int lttng_ust_ctl_counter_clear(struct lttng_ust_ctl_daemon_counter *counter, |
ebabbf58 MD |
700 | const size_t *dimension_indexes); |
701 | ||
b187bcd5 MD |
702 | int lttng_ust_ctl_counter_create_event(int sock, |
703 | struct lttng_ust_abi_counter_event *counter_event, | |
2ec133be | 704 | size_t counter_event_len, |
b187bcd5 MD |
705 | struct lttng_ust_abi_object_data *counter_data, |
706 | struct lttng_ust_abi_object_data **counter_event_data); | |
707 | ||
63b3205f MD |
708 | void lttng_ust_ctl_sigbus_handle(void *addr); |
709 | ||
9c96e34c JG |
710 | int lttng_ust_ctl_get_version(uint32_t *major, uint32_t *minor, uint32_t *patchlevel); |
711 | ||
81b2d238 SM |
712 | #ifdef __cplusplus |
713 | } | |
714 | #endif | |
715 | ||
f3105c67 | 716 | #endif /* _LTTNG_UST_CTL_H */ |