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