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