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