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