Namespace liblttng-ust-ctl symbols
[lttng-ust.git] / include / lttng / ust-ctl.h
CommitLineData
f3105c67 1/*
c0c0989a 2 * SPDX-License-Identifier: GPL-2.0-only
f3105c67 3 *
c0c0989a
MJ
4 * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
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>
74d81a6c
MD
19
20#ifndef LTTNG_UST_UUID_LEN
21#define LTTNG_UST_UUID_LEN 16
22#endif
23
32ce8569
MD
24/* Default unix socket path */
25#define LTTNG_UST_SOCK_FILENAME \
26 "lttng-ust-sock-" \
eae3c729 27 lttng_ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION)
32ce8569
MD
28
29/*
30 * Shared memory files path are automatically related to shm root, e.g.
31 * /dev/shm under linux.
32 */
33#define LTTNG_UST_WAIT_FILENAME \
34 "lttng-ust-wait-" \
eae3c729 35 lttng_ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION)
32ce8569 36
249cffb5 37struct lttng_ust_ctl_consumer_channel_attr {
fd17d7ce 38 enum lttng_ust_abi_chan_type type;
74d81a6c
MD
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 */
fd17d7ce 44 enum lttng_ust_abi_output output; /* splice, mmap */
6ca18e66 45 uint32_t chan_id; /* channel ID */
74d81a6c 46 unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
b2c5f61a 47 int64_t blocking_timeout; /* Blocking timeout (usec) */
9f5ade14 48} __attribute__((packed));
74d81a6c
MD
49
50/*
51 * API used by sessiond.
52 */
53
53f0df51 54struct lttng_ust_context_attr {
fd17d7ce 55 enum lttng_ust_abi_context_type ctx;
53f0df51 56 union {
fd17d7ce 57 struct lttng_ust_abi_perf_counter_ctx perf_counter;
53f0df51
JG
58 struct {
59 char *provider_name;
60 char *ctx_name;
61 } app_ctx;
62 } u;
63};
64
7bc53e94
MD
65/*
66 * Error values: all the following functions return:
c354a72c 67 * >= 0: Success (LTTNG_UST_OK)
7bc53e94
MD
68 * < 0: error code.
69 */
249cffb5
MJ
70int lttng_ust_ctl_register_done(int sock);
71int lttng_ust_ctl_create_session(int sock);
72int lttng_ust_ctl_create_event(int sock, struct lttng_ust_abi_event *ev,
fd17d7ce
MD
73 struct lttng_ust_abi_object_data *channel_data,
74 struct lttng_ust_abi_object_data **event_data);
249cffb5 75int lttng_ust_ctl_add_context(int sock, struct lttng_ust_context_attr *ctx,
fd17d7ce
MD
76 struct lttng_ust_abi_object_data *obj_data,
77 struct lttng_ust_abi_object_data **context_data);
249cffb5 78int lttng_ust_ctl_set_filter(int sock, struct lttng_ust_abi_filter_bytecode *bytecode,
fd17d7ce 79 struct lttng_ust_abi_object_data *obj_data);
249cffb5 80int lttng_ust_ctl_set_capture(int sock, struct lttng_ust_abi_capture_bytecode *bytecode,
fd17d7ce 81 struct lttng_ust_abi_object_data *obj_data);
249cffb5 82int lttng_ust_ctl_set_exclusion(int sock, struct lttng_ust_abi_event_exclusion *exclusion,
fd17d7ce
MD
83 struct lttng_ust_abi_object_data *obj_data);
84
249cffb5
MJ
85int lttng_ust_ctl_enable(int sock, struct lttng_ust_abi_object_data *object);
86int lttng_ust_ctl_disable(int sock, struct lttng_ust_abi_object_data *object);
87int lttng_ust_ctl_start_session(int sock, int handle);
88int lttng_ust_ctl_stop_session(int sock, int handle);
f3105c67 89
d8d2416d 90/*
249cffb5 91 * lttng_ust_ctl_create_event notifier_group creates a event notifier group. It
d8d2416d
FD
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 */
249cffb5 97int lttng_ust_ctl_create_event_notifier_group(int sock, int pipe_fd,
fd17d7ce 98 struct lttng_ust_abi_object_data **event_notifier_group);
d8d2416d
FD
99
100/*
249cffb5 101 * lttng_ust_ctl_create_event notifier creates a event notifier in a event notifier
d8d2416d
FD
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 */
249cffb5 107int lttng_ust_ctl_create_event_notifier(int sock,
fd17d7ce
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);
d8d2416d 111
b115631f 112/*
249cffb5 113 * lttng_ust_ctl_tracepoint_list returns a tracepoint list handle, or negative
b115631f
MD
114 * error value.
115 */
249cffb5 116int lttng_ust_ctl_tracepoint_list(int sock);
74d81a6c 117
b115631f 118/*
249cffb5 119 * lttng_ust_ctl_tracepoint_list_get is used to iterate on the tp list
7bc53e94
MD
120 * handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
121 * returned.
b115631f 122 */
249cffb5 123int lttng_ust_ctl_tracepoint_list_get(int sock, int tp_list_handle,
fd17d7ce 124 struct lttng_ust_abi_tracepoint_iter *iter);
b115631f 125
40003310 126/*
249cffb5 127 * lttng_ust_ctl_tracepoint_field_list returns a tracepoint field list handle,
40003310
MD
128 * or negative error value.
129 */
249cffb5 130int lttng_ust_ctl_tracepoint_field_list(int sock);
40003310
MD
131
132/*
249cffb5 133 * lttng_ust_ctl_tracepoint_field_list_get is used to iterate on the tp field
7bc53e94
MD
134 * list handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
135 * returned.
40003310 136 */
249cffb5 137int lttng_ust_ctl_tracepoint_field_list_get(int sock, int tp_field_list_handle,
fd17d7ce 138 struct lttng_ust_abi_field_iter *iter);
40003310 139
249cffb5
MJ
140int lttng_ust_ctl_tracer_version(int sock, struct lttng_ust_abi_tracer_version *v);
141int lttng_ust_ctl_wait_quiescent(int sock);
f3105c67 142
249cffb5 143int lttng_ust_ctl_sock_flush_buffer(int sock, struct lttng_ust_abi_object_data *object);
f1fffc57 144
249cffb5 145int lttng_ust_ctl_calibrate(int sock, struct lttng_ust_abi_calibrate *calibrate);
f3105c67 146
74d81a6c 147/* Release object created by members of this API. */
249cffb5 148int lttng_ust_ctl_release_object(int sock, struct lttng_ust_abi_object_data *data);
74d81a6c 149/* Release handle returned by create session. */
249cffb5 150int lttng_ust_ctl_release_handle(int sock, int handle);
74d81a6c 151
249cffb5 152int lttng_ust_ctl_recv_channel_from_consumer(int sock,
fd17d7ce 153 struct lttng_ust_abi_object_data **channel_data);
249cffb5 154int lttng_ust_ctl_recv_stream_from_consumer(int sock,
fd17d7ce 155 struct lttng_ust_abi_object_data **stream_data);
249cffb5 156int lttng_ust_ctl_send_channel_to_ust(int sock, int session_handle,
fd17d7ce 157 struct lttng_ust_abi_object_data *channel_data);
249cffb5 158int lttng_ust_ctl_send_stream_to_ust(int sock,
fd17d7ce
MD
159 struct lttng_ust_abi_object_data *channel_data,
160 struct lttng_ust_abi_object_data *stream_data);
74d81a6c 161
12f3dabc 162/*
249cffb5 163 * lttng_ust_ctl_duplicate_ust_object_data allocated a new object in "dest" if
12f3dabc 164 * it succeeds (returns 0). It must be released using
249cffb5 165 * lttng_ust_ctl_release_object() and then freed with free().
12f3dabc 166 */
249cffb5 167int lttng_ust_ctl_duplicate_ust_object_data(struct lttng_ust_abi_object_data **dest,
fd17d7ce 168 struct lttng_ust_abi_object_data *src);
12f3dabc 169
f3105c67 170/*
74d81a6c 171 * API used by consumer.
f3105c67 172 */
74d81a6c 173
249cffb5
MJ
174struct lttng_ust_ctl_consumer_channel;
175struct lttng_ust_ctl_consumer_stream;
176struct lttng_ust_ctl_consumer_channel_attr;
74d81a6c 177
249cffb5 178int lttng_ust_ctl_get_nr_stream_per_channel(void);
5ea386c3 179
249cffb5
MJ
180struct lttng_ust_ctl_consumer_channel *
181 lttng_ust_ctl_create_channel(struct lttng_ust_ctl_consumer_channel_attr *attr,
5ea386c3 182 const int *stream_fds, int nr_stream_fds);
5224b5c8 183/*
74d81a6c 184 * Each stream created needs to be destroyed before calling
249cffb5 185 * lttng_ust_ctl_destroy_channel().
5224b5c8 186 */
249cffb5 187void lttng_ust_ctl_destroy_channel(struct lttng_ust_ctl_consumer_channel *chan);
f3105c67 188
249cffb5
MJ
189int lttng_ust_ctl_send_channel_to_sessiond(int sock,
190 struct lttng_ust_ctl_consumer_channel *channel);
191int lttng_ust_ctl_channel_close_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
192int lttng_ust_ctl_channel_close_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
193int lttng_ust_ctl_channel_get_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
194int lttng_ust_ctl_channel_get_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
c9023c93 195
249cffb5
MJ
196int lttng_ust_ctl_write_metadata_to_channel(
197 struct lttng_ust_ctl_consumer_channel *channel,
c9023c93
MD
198 const char *metadata_str, /* NOT null-terminated */
199 size_t len); /* metadata length */
249cffb5
MJ
200ssize_t lttng_ust_ctl_write_one_packet_to_channel(
201 struct lttng_ust_ctl_consumer_channel *channel,
3ef94b0e
JD
202 const char *metadata_str, /* NOT null-terminated */
203 size_t len); /* metadata length */
c9023c93 204
74d81a6c
MD
205/*
206 * Send a NULL stream to finish iteration over all streams of a given
207 * channel.
208 */
249cffb5
MJ
209int lttng_ust_ctl_send_stream_to_sessiond(int sock,
210 struct lttng_ust_ctl_consumer_stream *stream);
211int lttng_ust_ctl_stream_close_wait_fd(struct lttng_ust_ctl_consumer_stream *stream);
212int lttng_ust_ctl_stream_close_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream);
213int lttng_ust_ctl_stream_get_wait_fd(struct lttng_ust_ctl_consumer_stream *stream);
214int lttng_ust_ctl_stream_get_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream);
f3105c67 215
74d81a6c 216/* Create/destroy stream buffers for read */
249cffb5
MJ
217struct lttng_ust_ctl_consumer_stream *
218 lttng_ust_ctl_create_stream(struct lttng_ust_ctl_consumer_channel *channel,
74d81a6c 219 int cpu);
249cffb5 220void lttng_ust_ctl_destroy_stream(struct lttng_ust_ctl_consumer_stream *stream);
f3105c67
MD
221
222/* For mmap mode, readable without "get" operation */
249cffb5 223int lttng_ust_ctl_get_mmap_len(struct lttng_ust_ctl_consumer_stream *stream,
f3105c67 224 unsigned long *len);
249cffb5 225int lttng_ust_ctl_get_max_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
f3105c67
MD
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 */
249cffb5
MJ
232void *lttng_ust_ctl_get_mmap_base(struct lttng_ust_ctl_consumer_stream *stream);
233int lttng_ust_ctl_get_mmap_read_offset(struct lttng_ust_ctl_consumer_stream *stream,
74d81a6c 234 unsigned long *off);
249cffb5 235int lttng_ust_ctl_get_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
74d81a6c 236 unsigned long *len);
249cffb5 237int lttng_ust_ctl_get_padded_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
74d81a6c 238 unsigned long *len);
249cffb5
MJ
239int lttng_ust_ctl_get_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
240int lttng_ust_ctl_put_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
f3105c67
MD
241
242/* snapshot */
243
249cffb5
MJ
244int lttng_ust_ctl_snapshot(struct lttng_ust_ctl_consumer_stream *stream);
245int lttng_ust_ctl_snapshot_sample_positions(struct lttng_ust_ctl_consumer_stream *stream);
246int lttng_ust_ctl_snapshot_get_consumed(struct lttng_ust_ctl_consumer_stream *stream,
74d81a6c 247 unsigned long *pos);
249cffb5 248int lttng_ust_ctl_snapshot_get_produced(struct lttng_ust_ctl_consumer_stream *stream,
74d81a6c 249 unsigned long *pos);
249cffb5 250int lttng_ust_ctl_get_subbuf(struct lttng_ust_ctl_consumer_stream *stream,
74d81a6c 251 unsigned long *pos);
249cffb5 252int lttng_ust_ctl_put_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
5f9d3dbc 253
249cffb5 254void lttng_ust_ctl_flush_buffer(struct lttng_ust_ctl_consumer_stream *stream,
74d81a6c 255 int producer_active);
249cffb5 256void lttng_ust_ctl_clear_buffer(struct lttng_ust_ctl_consumer_stream *stream);
f3105c67 257
b2f3252a 258/* index */
82df14e4
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
249cffb5 265int lttng_ust_ctl_get_timestamp_begin(struct lttng_ust_ctl_consumer_stream *stream,
b2f3252a 266 uint64_t *timestamp_begin);
249cffb5 267int lttng_ust_ctl_get_timestamp_end(struct lttng_ust_ctl_consumer_stream *stream,
b2f3252a 268 uint64_t *timestamp_end);
249cffb5 269int lttng_ust_ctl_get_events_discarded(struct lttng_ust_ctl_consumer_stream *stream,
b2f3252a 270 uint64_t *events_discarded);
249cffb5 271int lttng_ust_ctl_get_content_size(struct lttng_ust_ctl_consumer_stream *stream,
b2f3252a 272 uint64_t *content_size);
249cffb5 273int lttng_ust_ctl_get_packet_size(struct lttng_ust_ctl_consumer_stream *stream,
b2f3252a 274 uint64_t *packet_size);
249cffb5 275int lttng_ust_ctl_get_sequence_number(struct lttng_ust_ctl_consumer_stream *stream,
1ff31389 276 uint64_t *seq);
82df14e4
MD
277
278/*
279 * Getter returning state invariant for the stream, which can be used
280 * without "get" operation.
281 */
282
249cffb5 283int lttng_ust_ctl_get_stream_id(struct lttng_ust_ctl_consumer_stream *stream,
82df14e4 284 uint64_t *stream_id);
249cffb5 285int lttng_ust_ctl_get_instance_id(struct lttng_ust_ctl_consumer_stream *stream,
45a00b05 286 uint64_t *id);
b2f3252a 287
82df14e4
MD
288/*
289 * Getter returning the current timestamp as perceived from the
290 * tracer.
291 */
249cffb5 292int lttng_ust_ctl_get_current_timestamp(struct lttng_ust_ctl_consumer_stream *stream,
82df14e4
MD
293 uint64_t *ts);
294
57201bb3 295/* returns whether UST has perf counters support. */
249cffb5 296int lttng_ust_ctl_has_perf_counters(void);
57201bb3 297
f53329f3 298/* Regenerate the statedump. */
249cffb5 299int lttng_ust_ctl_regenerate_statedump(int sock, int handle);
f53329f3 300
32ce8569
MD
301/* event registry management */
302
249cffb5
MJ
303enum lttng_ust_ctl_socket_type {
304 LTTNG_UST_CTL_SOCKET_CMD = 0,
305 LTTNG_UST_CTL_SOCKET_NOTIFY = 1,
32ce8569
MD
306};
307
249cffb5
MJ
308enum 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,
32ce8569
MD
312};
313
249cffb5
MJ
314enum 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,
32ce8569
MD
318};
319
320/* event type structures */
321
249cffb5
MJ
322enum 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,
32ce8569
MD
337};
338
249cffb5
MJ
339enum 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,
32ce8569
MD
344};
345
249cffb5
MJ
346#define LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING 24
347struct lttng_ust_ctl_integer_type {
32ce8569
MD
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 */
249cffb5 352 int32_t encoding; /* enum lttng_ust_ctl_string_encodings */
32ce8569 353 uint16_t alignment; /* in bits */
249cffb5 354 char padding[LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING];
9f5ade14 355} __attribute__((packed));
32ce8569 356
249cffb5
MJ
357#define LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING 24
358struct lttng_ust_ctl_float_type {
32ce8569
MD
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 */
249cffb5 363 char padding[LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING];
9f5ade14 364} __attribute__((packed));
32ce8569 365
249cffb5
MJ
366#define LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING 15
367struct lttng_ust_ctl_enum_value {
a6f80644
MD
368 uint64_t value;
369 uint8_t signedness;
249cffb5 370 char padding[LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING];
9f5ade14 371} __attribute__((packed));
a6f80644 372
249cffb5
MJ
373enum lttng_ust_ctl_ust_enum_entry_options {
374 LTTNG_UST_CTL_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
3e762260
PP
375};
376
249cffb5
MJ
377#define LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING 32
378struct lttng_ust_ctl_enum_entry {
379 struct lttng_ust_ctl_enum_value start, end; /* start and end are inclusive */
fd17d7ce 380 char string[LTTNG_UST_ABI_SYM_NAME_LEN];
3e762260
PP
381 union {
382 struct {
383 uint32_t options;
9f5ade14 384 } __attribute__((packed)) extra;
249cffb5 385 char padding[LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING];
3e762260 386 } u;
9f5ade14 387} __attribute__((packed));
c785c634 388
218deb69 389/* legacy */
249cffb5
MJ
390#define LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING 296
391union _lttng_ust_ctl_basic_type {
392 struct lttng_ust_ctl_integer_type integer;
c785c634 393 struct {
fd17d7ce 394 char name[LTTNG_UST_ABI_SYM_NAME_LEN];
249cffb5 395 struct lttng_ust_ctl_integer_type container_type;
c785c634
MD
396 uint64_t id; /* enum ID in sessiond. */
397 } enumeration;
32ce8569 398 struct {
249cffb5 399 int32_t encoding; /* enum lttng_ust_ctl_string_encodings */
32ce8569 400 } string;
249cffb5
MJ
401 struct lttng_ust_ctl_float_type _float;
402 char padding[LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING];
9f5ade14 403} __attribute__((packed));
32ce8569 404
218deb69 405/* legacy */
249cffb5
MJ
406struct lttng_ust_ctl_basic_type {
407 enum lttng_ust_ctl_abstract_types atype;
32ce8569 408 union {
249cffb5 409 union _lttng_ust_ctl_basic_type basic;
32ce8569 410 } u;
9f5ade14 411} __attribute__((packed));
32ce8569 412
218deb69
MD
413/*
414 * Padding is derived from largest member: u.legacy.sequence which
249cffb5 415 * contains two basic types, each with LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING.
218deb69 416 */
249cffb5
MJ
417#define LTTNG_UST_CTL_UST_TYPE_PADDING (2 * LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING)
418struct lttng_ust_ctl_type {
419 enum lttng_ust_ctl_abstract_types atype;
32ce8569 420 union {
249cffb5
MJ
421 struct lttng_ust_ctl_integer_type integer;
422 struct lttng_ust_ctl_float_type _float;
218deb69 423 struct {
249cffb5 424 int32_t encoding; /* enum lttng_ust_ctl_string_encodings */
218deb69
MD
425 } string;
426 struct {
fd17d7ce 427 char name[LTTNG_UST_ABI_SYM_NAME_LEN];
218deb69 428 uint64_t id; /* enum ID in sessiond. */
249cffb5 429 /* container_type follows after this struct lttng_ust_ctl_field. */
218deb69 430 } enum_nestable;
32ce8569 431 struct {
32ce8569 432 uint32_t length; /* num. elems. */
218deb69 433 uint32_t alignment;
249cffb5 434 /* elem_type follows after this struct lttng_ust_ctl_field. */
218deb69 435 } array_nestable;
32ce8569 436 struct {
fd17d7ce 437 char length_name[LTTNG_UST_ABI_SYM_NAME_LEN];
218deb69
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;
249cffb5 444 /* Followed by nr_fields struct lttng_ust_ctl_field. */
218deb69 445 } struct_nestable;
53569322
MD
446 struct {
447 uint32_t nr_choices;
fd17d7ce 448 char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
218deb69 449 uint32_t alignment;
249cffb5 450 /* Followed by nr_choices struct lttng_ust_ctl_field. */
218deb69
MD
451 } variant_nestable;
452
453 /* Legacy ABI */
454 union {
249cffb5 455 union _lttng_ust_ctl_basic_type basic;
218deb69 456 struct {
249cffb5 457 struct lttng_ust_ctl_basic_type elem_type;
218deb69
MD
458 uint32_t length; /* num. elems. */
459 } array;
460 struct {
249cffb5
MJ
461 struct lttng_ust_ctl_basic_type length_type;
462 struct lttng_ust_ctl_basic_type elem_type;
218deb69
MD
463 } sequence;
464 struct {
465 uint32_t nr_fields;
249cffb5 466 /* Followed by nr_fields struct lttng_ust_ctl_field. */
218deb69
MD
467 } _struct;
468 struct {
469 uint32_t nr_choices;
fd17d7ce 470 char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
249cffb5 471 /* Followed by nr_choices struct lttng_ust_ctl_field. */
218deb69
MD
472 } variant;
473 } legacy;
249cffb5 474 char padding[LTTNG_UST_CTL_UST_TYPE_PADDING];
32ce8569 475 } u;
9f5ade14 476} __attribute__((packed));
32ce8569 477
249cffb5
MJ
478#define LTTNG_UST_CTL_UST_FIELD_PADDING 28
479struct lttng_ust_ctl_field {
fd17d7ce 480 char name[LTTNG_UST_ABI_SYM_NAME_LEN];
249cffb5
MJ
481 struct lttng_ust_ctl_type type;
482 char padding[LTTNG_UST_CTL_UST_FIELD_PADDING];
9f5ade14 483} __attribute__((packed));
32ce8569
MD
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 */
249cffb5
MJ
490int lttng_ust_ctl_recv_reg_msg(int sock,
491 enum lttng_ust_ctl_socket_type *type,
32ce8569
MD
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
249cffb5
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
32ce8569
MD
512 * appropriate.
513 */
249cffb5 514int lttng_ust_ctl_recv_notify(int sock, enum lttng_ust_ctl_notify_cmd *notify_cmd);
32ce8569
MD
515
516/*
517 * Returns 0 on success, negative UST or system error value on error.
518 */
249cffb5 519int lttng_ust_ctl_recv_register_event(int sock,
32ce8569
MD
520 int *session_objd, /* session descriptor (output) */
521 int *channel_objd, /* channel descriptor (output) */
522 char *event_name, /*
523 * event name (output,
fd17d7ce 524 * size LTTNG_UST_ABI_SYM_NAME_LEN)
32ce8569
MD
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,
249cffb5 535 struct lttng_ust_ctl_field **fields,
32ce8569
MD
536 char **model_emf_uri);
537
538/*
539 * Returns 0 on success, negative error value on error.
540 */
249cffb5 541int lttng_ust_ctl_reply_register_event(int sock,
32ce8569
MD
542 uint32_t id, /* event id (input) */
543 int ret_code); /* return code. 0 ok, negative error */
544
c785c634
MD
545/*
546 * Returns 0 on success, negative UST or system error value on error.
547 */
249cffb5 548int lttng_ust_ctl_recv_register_enum(int sock,
c785c634
MD
549 int *session_objd,
550 char *enum_name,
249cffb5 551 struct lttng_ust_ctl_enum_entry **entries,
c785c634
MD
552 size_t *nr_entries);
553
554/*
555 * Returns 0 on success, negative error value on error.
556 */
249cffb5 557int lttng_ust_ctl_reply_register_enum(int sock,
c785c634
MD
558 uint64_t id, /* enum id (input) */
559 int ret_code);
560
32ce8569
MD
561/*
562 * Returns 0 on success, negative UST or system error value on error.
563 */
249cffb5 564int lttng_ust_ctl_recv_register_channel(int sock,
32ce8569
MD
565 int *session_objd, /* session descriptor (output) */
566 int *channel_objd, /* channel descriptor (output) */
567 size_t *nr_fields, /* context fields */
249cffb5 568 struct lttng_ust_ctl_field **fields);
32ce8569
MD
569
570/*
571 * Returns 0 on success, negative error value on error.
572 */
249cffb5 573int lttng_ust_ctl_reply_register_channel(int sock,
32ce8569 574 uint32_t chan_id,
249cffb5 575 enum lttng_ust_ctl_channel_header header_type,
32ce8569
MD
576 int ret_code); /* return code. 0 ok, negative error */
577
ebabbf58
MD
578/*
579 * Counter API.
580 */
581
249cffb5
MJ
582enum lttng_ust_ctl_counter_bitness {
583 LTTNG_UST_CTL_COUNTER_BITNESS_32 = 0,
584 LTTNG_UST_CTL_COUNTER_BITNESS_64 = 1,
ebabbf58
MD
585};
586
249cffb5
MJ
587enum lttng_ust_ctl_counter_arithmetic {
588 LTTNG_UST_CTL_COUNTER_ARITHMETIC_MODULAR = 0,
589 LTTNG_UST_CTL_COUNTER_ARITHMETIC_SATURATION = 1,
ebabbf58
MD
590};
591
592/* Used as alloc flags. */
249cffb5
MJ
593enum lttng_ust_ctl_counter_alloc {
594 LTTNG_UST_CTL_COUNTER_ALLOC_PER_CPU = (1 << 0),
595 LTTNG_UST_CTL_COUNTER_ALLOC_GLOBAL = (1 << 1),
ebabbf58
MD
596};
597
249cffb5 598struct lttng_ust_ctl_daemon_counter;
ebabbf58 599
249cffb5 600int lttng_ust_ctl_get_nr_cpu_per_counter(void);
ebabbf58 601
249cffb5 602struct lttng_ust_ctl_counter_dimension {
ebabbf58
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
249cffb5
MJ
610struct lttng_ust_ctl_daemon_counter *
611 lttng_ust_ctl_create_counter(size_t nr_dimensions,
612 const struct lttng_ust_ctl_counter_dimension *dimensions,
ebabbf58
MD
613 int64_t global_sum_step,
614 int global_counter_fd,
615 int nr_counter_cpu_fds,
616 const int *counter_cpu_fds,
249cffb5
MJ
617 enum lttng_ust_ctl_counter_bitness bitness,
618 enum lttng_ust_ctl_counter_arithmetic arithmetic,
81bc4972
MD
619 uint32_t alloc_flags,
620 bool coalesce_hits);
ebabbf58 621
249cffb5 622int lttng_ust_ctl_create_counter_data(struct lttng_ust_ctl_daemon_counter *counter,
fd17d7ce 623 struct lttng_ust_abi_object_data **counter_data);
ebabbf58 624
249cffb5 625int lttng_ust_ctl_create_counter_global_data(struct lttng_ust_ctl_daemon_counter *counter,
fd17d7ce 626 struct lttng_ust_abi_object_data **counter_global_data);
249cffb5 627int lttng_ust_ctl_create_counter_cpu_data(struct lttng_ust_ctl_daemon_counter *counter, int cpu,
fd17d7ce 628 struct lttng_ust_abi_object_data **counter_cpu_data);
ebabbf58
MD
629
630/*
631 * Each counter data and counter cpu data created need to be destroyed
249cffb5 632 * before calling lttng_ust_ctl_destroy_counter().
ebabbf58 633 */
249cffb5 634void lttng_ust_ctl_destroy_counter(struct lttng_ust_ctl_daemon_counter *counter);
ebabbf58 635
249cffb5 636int lttng_ust_ctl_send_counter_data_to_ust(int sock, int parent_handle,
fd17d7ce 637 struct lttng_ust_abi_object_data *counter_data);
249cffb5 638int lttng_ust_ctl_send_counter_global_data_to_ust(int sock,
fd17d7ce
MD
639 struct lttng_ust_abi_object_data *counter_data,
640 struct lttng_ust_abi_object_data *counter_global_data);
249cffb5 641int lttng_ust_ctl_send_counter_cpu_data_to_ust(int sock,
fd17d7ce
MD
642 struct lttng_ust_abi_object_data *counter_data,
643 struct lttng_ust_abi_object_data *counter_cpu_data);
ebabbf58 644
249cffb5 645int lttng_ust_ctl_counter_read(struct lttng_ust_ctl_daemon_counter *counter,
ebabbf58
MD
646 const size_t *dimension_indexes,
647 int cpu, int64_t *value,
648 bool *overflow, bool *underflow);
249cffb5 649int lttng_ust_ctl_counter_aggregate(struct lttng_ust_ctl_daemon_counter *counter,
ebabbf58
MD
650 const size_t *dimension_indexes,
651 int64_t *value,
652 bool *overflow, bool *underflow);
249cffb5 653int lttng_ust_ctl_counter_clear(struct lttng_ust_ctl_daemon_counter *counter,
ebabbf58
MD
654 const size_t *dimension_indexes);
655
f3105c67 656#endif /* _LTTNG_UST_CTL_H */
This page took 0.066885 seconds and 4 git commands to generate.