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