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