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