Fix: streaming and snapshot backward compat for relayd < 2.11
[lttng-tools.git] / src / common / mi-lttng.h
CommitLineData
c7e35b03
JR
1/*
2 * Copyright (C) 2014 - Jonathan Rajotte <jonathan.r.julien@gmail.com>
3 * - Olivier Cotte <olivier.cotte@polymtl.ca>
a23cb78a 4 * Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
c7e35b03
JR
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License, version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#ifndef _MI_LTTNG_H
21#define _MI_LTTNG_H
22
23#include <stdint.h>
24
25#include <common/error.h>
26#include <common/macros.h>
f40ef1d5 27#include <common/config/session-config.h>
c7e35b03
JR
28#include <lttng/lttng.h>
29
50534d6f
JRJ
30/* Don't want to reference snapshot-internal.h here */
31struct lttng_snapshot_output;
32
c7e35b03
JR
33/* Instance of a machine interface writer. */
34struct mi_writer {
35 struct config_writer *writer;
36 enum lttng_mi_output_type type;
37};
38
39/*
40 * Version information for the machine interface.
41 */
42struct mi_lttng_version {
36d2e35d 43 char version[LTTNG_NAME_MAX]; /* Version number of package */
c7e35b03
JR
44 uint32_t version_major; /* LTTng-Tools major version number */
45 uint32_t version_minor; /* LTTng-Tools minor version number */
46 uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */
36d2e35d
MJ
47 char version_commit[LTTNG_NAME_MAX]; /* Commit hash of the current version */
48 char version_name[LTTNG_NAME_MAX];
49 char package_url[LTTNG_NAME_MAX]; /* Define to the home page for this package. */
c7e35b03
JR
50};
51
52/* Strings related to command */
4965f956
JG
53extern const char * const mi_lttng_element_command;
54extern const char * const mi_lttng_element_command_action;
55extern const char * const mi_lttng_element_command_add_context;
4965f956
JG
56extern const char * const mi_lttng_element_command_create;
57extern const char * const mi_lttng_element_command_destroy;
58extern const char * const mi_lttng_element_command_disable_channel;
59extern const char * const mi_lttng_element_command_disable_event;
60extern const char * const mi_lttng_element_command_enable_channels;
61extern const char * const mi_lttng_element_command_enable_event;
62extern const char * const mi_lttng_element_command_list;
63extern const char * const mi_lttng_element_command_load;
54897b57
JD
64extern const char * const mi_lttng_element_command_metadata;
65extern const char * const mi_lttng_element_command_metadata_action;
eded6438
JD
66extern const char * const mi_lttng_element_command_regenerate;
67extern const char * const mi_lttng_element_command_regenerate_action;
4965f956
JG
68extern const char * const mi_lttng_element_command_name;
69extern const char * const mi_lttng_element_command_output;
70extern const char * const mi_lttng_element_command_save;
71extern const char * const mi_lttng_element_command_set_session;
72extern const char * const mi_lttng_element_command_snapshot;
73extern const char * const mi_lttng_element_command_snapshot_add;
74extern const char * const mi_lttng_element_command_snapshot_del;
75extern const char * const mi_lttng_element_command_snapshot_list;
76extern const char * const mi_lttng_element_command_snapshot_record;
77extern const char * const mi_lttng_element_command_start;
78extern const char * const mi_lttng_element_command_stop;
79extern const char * const mi_lttng_element_command_success;
80extern const char * const mi_lttng_element_command_track;
81extern const char * const mi_lttng_element_command_untrack;
82extern const char * const mi_lttng_element_command_version;
d68c9a04 83extern const char * const mi_lttng_element_command_rotate;
259c2674
JD
84extern const char * const mi_lttng_element_command_enable_rotation;
85extern const char * const mi_lttng_element_command_disable_rotation;
c7e35b03 86
1734c658 87/* Strings related to version command */
4965f956
JG
88extern const char * const mi_lttng_element_version;
89extern const char * const mi_lttng_element_version_commit;
90extern const char * const mi_lttng_element_version_description;
91extern const char * const mi_lttng_element_version_license;
92extern const char * const mi_lttng_element_version_major;
93extern const char * const mi_lttng_element_version_minor;
94extern const char * const mi_lttng_element_version_patch_level;
95extern const char * const mi_lttng_element_version_str;
96extern const char * const mi_lttng_element_version_web;
c7e35b03 97
5e18ec73 98/* String related to a lttng_event_field */
4965f956
JG
99extern const char * const mi_lttng_element_event_field;
100extern const char * const mi_lttng_element_event_fields;
5e18ec73 101
89b72577 102/* String related to lttng_event_perf_counter_ctx */
4965f956 103extern const char * const mi_lttng_element_perf_counter_context;
89b72577 104
5e18ec73 105/* Strings related to pid */
4965f956 106extern const char * const mi_lttng_element_pid_id;
5e18ec73 107
1734c658 108/* Strings related to save command */
4965f956 109extern const char * const mi_lttng_element_save;
1734c658
JRJ
110
111/* Strings related to load command */
4965f956 112extern const char * const mi_lttng_element_load;
23cb2d55
JR
113LTTNG_HIDDEN const char * const mi_lttng_element_load_overrides;
114LTTNG_HIDDEN const char * const mi_lttng_element_load_override_url;
1734c658 115
5e18ec73 116/* General element of mi_lttng */
4965f956
JG
117extern const char * const mi_lttng_element_empty;
118extern const char * const mi_lttng_element_id;
119extern const char * const mi_lttng_element_nowrite;
120extern const char * const mi_lttng_element_success;
121extern const char * const mi_lttng_element_type_enum;
122extern const char * const mi_lttng_element_type_float;
123extern const char * const mi_lttng_element_type_integer;
124extern const char * const mi_lttng_element_type_other;
125extern const char * const mi_lttng_element_type_string;
5e18ec73
JR
126
127/* String related to loglevel */
4965f956
JG
128extern const char * const mi_lttng_loglevel_str_alert;
129extern const char * const mi_lttng_loglevel_str_crit;
130extern const char * const mi_lttng_loglevel_str_debug;
131extern const char * const mi_lttng_loglevel_str_debug_function;
132extern const char * const mi_lttng_loglevel_str_debug_line;
133extern const char * const mi_lttng_loglevel_str_debug_module;
134extern const char * const mi_lttng_loglevel_str_debug_process;
135extern const char * const mi_lttng_loglevel_str_debug_program;
136extern const char * const mi_lttng_loglevel_str_debug_system;
137extern const char * const mi_lttng_loglevel_str_debug_unit;
138extern const char * const mi_lttng_loglevel_str_emerg;
139extern const char * const mi_lttng_loglevel_str_err;
140extern const char * const mi_lttng_loglevel_str_info;
141extern const char * const mi_lttng_loglevel_str_notice;
142extern const char * const mi_lttng_loglevel_str_unknown;
143extern const char * const mi_lttng_loglevel_str_warning;
5e18ec73 144
136f2f81 145/* String related to loglevel JUL */
4965f956
JG
146extern const char * const mi_lttng_loglevel_str_jul_all;
147extern const char * const mi_lttng_loglevel_str_jul_config;
148extern const char * const mi_lttng_loglevel_str_jul_fine;
149extern const char * const mi_lttng_loglevel_str_jul_finer;
150extern const char * const mi_lttng_loglevel_str_jul_finest;
151extern const char * const mi_lttng_loglevel_str_jul_info;
152extern const char * const mi_lttng_loglevel_str_jul_off;
153extern const char * const mi_lttng_loglevel_str_jul_severe;
154extern const char * const mi_lttng_loglevel_str_jul_warning;
136f2f81 155
970d848b 156/* String related to loglevel Log4j */
4965f956
JG
157extern const char * const mi_lttng_loglevel_str_log4j_off;
158extern const char * const mi_lttng_loglevel_str_log4j_fatal;
159extern const char * const mi_lttng_loglevel_str_log4j_error;
160extern const char * const mi_lttng_loglevel_str_log4j_warn;
161extern const char * const mi_lttng_loglevel_str_log4j_info;
162extern const char * const mi_lttng_loglevel_str_log4j_debug;
163extern const char * const mi_lttng_loglevel_str_log4j_trace;
164extern const char * const mi_lttng_loglevel_str_log4j_all;
970d848b 165
0e115563 166/* String related to loglevel Python */
4965f956
JG
167extern const char * const mi_lttng_loglevel_str_python_critical;
168extern const char * const mi_lttng_loglevel_str_python_error;
169extern const char * const mi_lttng_loglevel_str_python_warning;
170extern const char * const mi_lttng_loglevel_str_python_info;
171extern const char * const mi_lttng_loglevel_str_python_debug;
172extern const char * const mi_lttng_loglevel_str_python_notset;
0e115563 173
1734c658 174/* String related to loglevel type */
4965f956
JG
175extern const char * const mi_lttng_loglevel_type_all;
176extern const char * const mi_lttng_loglevel_type_range;
177extern const char * const mi_lttng_loglevel_type_single;
178extern const char * const mi_lttng_loglevel_type_unknown;
5e18ec73 179
136f2f81 180/* String related to a lttng_snapshot */
4965f956
JG
181extern const char * const mi_lttng_element_snapshot_ctrl_url;
182extern const char * const mi_lttng_element_snapshot_data_url;
183extern const char * const mi_lttng_element_snapshot_max_size;
184extern const char * const mi_lttng_element_snapshot_n_ptr;
185extern const char * const mi_lttng_element_snapshot_session_name;
186extern const char * const mi_lttng_element_snapshots;
50534d6f 187
a23cb78a
JG
188/* String related to track/untrack command */
189const char * const mi_lttng_element_track_untrack_all_wildcard;
190
d68c9a04
JD
191LTTNG_HIDDEN const char * const mi_lttng_element_session_name;
192
193/* String related to rotate command */
194LTTNG_HIDDEN const char * const mi_lttng_element_rotation;
d68c9a04 195LTTNG_HIDDEN const char * const mi_lttng_element_rotate_status;
259c2674 196LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule;
66ea93b1
JG
197LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedules;
198LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_periodic;
199LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_periodic_time_us;
200LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_size_threshold;
201LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes;
202LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_result;
203LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_results;
91c4d516
JG
204LTTNG_HIDDEN const char * const mi_lttng_element_rotation_state;
205LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location;
206LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_local;
207LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_local_absolute_path;
208LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay;
209LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay_host;
210LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay_control_port;
211LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay_data_port;
212LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay_protocol;
213LTTNG_HIDDEN const char * const mi_lttng_element_rotation_location_relay_relative_path;
214
215/* String related to enum lttng_rotation_state */
216LTTNG_HIDDEN const char * const mi_lttng_rotation_state_str_ongoing;
217LTTNG_HIDDEN const char * const mi_lttng_rotation_state_str_completed;
218LTTNG_HIDDEN const char * const mi_lttng_rotation_state_str_expired;
219LTTNG_HIDDEN const char * const mi_lttng_rotation_state_str_error;
220
221/* String related to enum lttng_trace_archive_location_relay_protocol_type */
222LTTNG_HIDDEN const char * const mi_lttng_rotation_location_relay_protocol_str_tcp;
d68c9a04 223
59deec0c
JR
224/* String related to add-context command */
225LTTNG_HIDDEN extern const char * const mi_lttng_element_context_symbol;
226
5e18ec73 227/* Utility string function */
970d848b 228const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
5e18ec73
JR
229const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value);
230const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value);
231const char *mi_lttng_domaintype_string(enum lttng_domain_type value);
232const char *mi_lttng_buffertype_string(enum lttng_buffer_type value);
91c4d516
JG
233const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value);
234const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
235 enum lttng_trace_archive_location_relay_protocol_type value);
5e18ec73 236
c7e35b03
JR
237/*
238 * Create an instance of a machine interface writer.
239 *
240 * fd_output File to which the XML content must be written. The file will be
241 * closed once the mi_writer has been destroyed.
242 *
243 * Returns an instance of a machine interface writer on success, NULL on
244 * error.
245 */
246struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);
247
248/*
249 * Destroy an instance of a machine interface writer.
250 *
251 * writer An instance of a machine interface writer.
252 *
253 * Returns zero if the XML document could be closed cleanly. Negative values
254 * indicate an error.
255 */
256int mi_lttng_writer_destroy(struct mi_writer *writer);
257
258/*
259 * Open a command tag and add it's name node.
260 *
261 * writer An instance of a machine interface writer.
c7e35b03
JR
262 * command The command name.
263 *
264 * Returns zero if the XML document could be closed cleanly.
265 * Negative values indicate an error.
266 */
267int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);
268
269/*
270 * Close a command tag.
271 *
272 * writer An instance of a machine interface writer.
273 *
274 * Returns zero if the XML document could be closed cleanly.
275 * Negative values indicate an error.
276 */
277int mi_lttng_writer_command_close(struct mi_writer *writer);
278
279/*
280 * Open an element tag.
281 *
282 * writer An instance of a machine interface writer.
c7e35b03
JR
283 * element_name Element tag name.
284 *
285 * Returns zero if the XML document could be closed cleanly.
286 * Negative values indicate an error.
287 */
288int mi_lttng_writer_open_element(struct mi_writer *writer,
289 const char *element_name);
290
291/*
292 * Close the current element tag.
293 *
294 * writer An instance of a machine interface writer.
295 *
296 * Returns zero if the XML document could be closed cleanly.
297 * Negative values indicate an error.
298 */
299int mi_lttng_writer_close_element(struct mi_writer *writer);
300
301/*
5e18ec73 302 * Close multiple element.
c7e35b03
JR
303 *
304 * writer An instance of a machine interface writer.
5e18ec73 305 * nb_element Number of elements.
c7e35b03 306 *
5e18ec73
JR
307 * Returns zero if the XML document could be closed cleanly.
308 * Negative values indicate an error.
309 */
310int mi_lttng_close_multi_element(struct mi_writer *writer,
311 unsigned int nb_element);
312
313/*
314 * Write an element of type unsigned int.
c7e35b03 315 *
5e18ec73
JR
316 * writer An instance of a machine interface writer.
317 * element_name Element name.
c7e35b03
JR
318 * value Unsigned int value of the element
319 *
320 * Returns zero if the element's value could be written.
321 * Negative values indicate an error.
322 */
323int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
324 const char *element_name, uint64_t value);
325
326/*
327 * Write an element of type signed int.
328 *
329 * writer An instance of a machine interface writer.
c7e35b03 330 * element_name Element name.
5e18ec73 331 * value Signed int value of the element.
c7e35b03
JR
332 *
333 * Returns zero if the element's value could be written.
334 * Negative values indicate an error.
335 */
336int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
337 const char *element_name, int64_t value);
338
339/*
340 * Write an element of type boolean.
341 *
342 * writer An instance of a machine interface writer.
c7e35b03 343 * element_name Element name.
5e18ec73 344 * value Boolean value of the element.
c7e35b03
JR
345 *
346 * Returns zero if the element's value could be written.
347 * Negative values indicate an error.
348 */
349int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
350 const char *element_name, int value);
351
352/*
353 * Write an element of type string.
354 *
355 * writer An instance of a machine interface writer.
c7e35b03 356 * element_name Element name.
5e18ec73 357 * value String value of the element.
c7e35b03
JR
358 *
359 * Returns zero if the element's value could be written.
360 * Negative values indicate an error.
361 */
362int mi_lttng_writer_write_element_string(struct mi_writer *writer,
363 const char *element_name, const char *value);
364
365/*
366 * Machine interface of struct version.
367 *
368 * writer An instance of a machine interface writer.
c7e35b03 369 * version Version struct.
c7e35b03 370 * lttng_description String value of the version description.
c7e35b03
JR
371 * lttng_license String value of the version license.
372 *
373 * Returns zero if the element's value could be written.
374 * Negative values indicate an error.
375 */
376int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version *version,
377 const char *lttng_description, const char *lttng_license);
378
379/*
5e18ec73 380 * Machine interface: open a sessions element.
c7e35b03 381 *
5e18ec73 382 * writer An instance of a machine interface writer.
c7e35b03 383 *
5e18ec73
JR
384 * Returns zero if the element's value could be written.
385 * Negative values indicate an error.
386 */
387int mi_lttng_sessions_open(struct mi_writer *writer);
388
389/*
390 * Machine interface of struct session.
c7e35b03 391 *
5e18ec73
JR
392 * writer An instance of a machine interface writer.
393 * session An instance of a session.
394 * is_open Defines whether or not the session element shall be closed.
395 * This should be used carefully and the client
396 * must close the session element.
136f2f81 397 * Use case: nested additional information on a session
c7e35b03 398 * ex: domain,channel event.
c7e35b03
JR
399 *
400 * Returns zero if the element's value could be written.
401 * Negative values indicate an error.
402 */
403int mi_lttng_session(struct mi_writer *writer,
5e18ec73
JR
404 struct lttng_session *session, int is_open);
405
406/*
407 * Machine interface: open a domains element.
408 *
409 * writer An instance of a machine interface writer.
410 *
411 * Returns zero if the element's value could be written.
412 * Negative values indicate an error.
413 */
414int mi_lttng_domains_open(struct mi_writer *writer);
415
416/*
417 * Machine interface of struct domain.
418 *
419 * writer An instance of a machine interface writer.
420 * domain An instance of a domain.
421 *
422 * is_open Defines whether or not the session element shall be closed.
423 * This should be used carefully and the client
424 * must close the domain element.
425 * Use case: nested addition information on a domain
426 * ex: channel event.
427 *
428 * Returns zero if the element's value could be written.
429 * Negative values indicate an error.
430 */
431int mi_lttng_domain(struct mi_writer *writer,
432 struct lttng_domain *domain, int is_open);
433
434/*
435 * Machine interface: open a channels element.
436 *
437 * writer An instance of a machine interface writer.
438 *
439 * Returns zero if the element's value could be written.
440 * Negative values indicate an error.
441 */
442int mi_lttng_channels_open(struct mi_writer *writer);
443
444/*
445 * Machine interface of struct channel.
446 *
447 * writer An instance of a machine interface writer.
448 * channel An instance of a channel.
449 *
450 * is_open Defines whether or not the session element shall be closed.
451 * This should be used carefully and the client
452 * must close the channel element.
453 * Use case: nested addition information on a channel.
454 * ex: channel event.
455 *
456 * Returns zero if the element's value could be written.
457 * Negative values indicate an error.
458 */
459int mi_lttng_channel(struct mi_writer *writer,
460 struct lttng_channel *channel, int is_open);
461
462/*
463 * Machine interface of struct channel_attr.
464 *
465 * writer An instance of a machine interface writer.
466 * attr An instance of a channel_attr struct.
467 *
468 * Returns zero if the element's value could be written.
469 * Negative values indicate an error.
470 */
471int mi_lttng_channel_attr(struct mi_writer *writer,
472 struct lttng_channel_attr *attr);
473
474/*
475* Machine interface for event common attributes.
476*
477* writer An instance of a mi writer.
478* event single trace event.
479*
480* The common attribute are:
481* - mi event element
482* - event name
483* - event type
484* - enabled tag
485* - event filter
486*
487* Returns zero if the element's value could be written.
488* Negative values indicate an error.
489*/
490int mi_lttng_event_common_attributes(struct mi_writer *writer,
491 struct lttng_event *event);
492
493/*
494 * Machine interface for kernel tracepoint event with a loglevel.
495 *
496 * writer An instance of a mi writer.
497 * event single trace event.
970d848b 498 * domain Event's domain
5e18ec73
JR
499 *
500 * Returns zero if the element's value could be written.
501 * Negative values indicate an error.
502 */
503int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
970d848b 504 struct lttng_event *event, enum lttng_domain_type domain);
5e18ec73
JR
505
506/*
507 * Machine interface for kernel tracepoint event with no loglevel.
508 *
509 * writer An instance of a mi writer.
510 * event single trace event.
511 *
512 * Returns zero if the element's value could be written.
513 * Negative values indicate an error.
514 */
515int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer,
516 struct lttng_event *event);
517
518/*
519 * Machine interface for kernel function and probe event.
520 *
521 * writer An instance of a mi writer.
522 * event single trace event.
523 *
524 * Returns zero if the element's value could be written.
525 * Negative values indicate an error.
526 */
527int mi_lttng_event_function_probe(struct mi_writer *writer,
528 struct lttng_event *event);
529
530/*
531 * Machine interface for kernel function entry event.
532 *
533 * writer An instance of a mi writer.
534 * event single trace event.
535 *
536 * Returns zero if the element's value could be written.
537 * Negative values indicate an error.
538 */
539int mi_lttng_event_function_entry(struct mi_writer *writer,
540 struct lttng_event *event);
541
542/*
543 * Machine interface: open an events element.
544 *
545 * writer An instance of a machine interface writer.
546 *
547 * Returns zero if the element's value could be written.
548 * Negative values indicate an error.
549 */
550int mi_lttng_events_open(struct mi_writer *writer);
551
552/*
553 * Machine interface for printing an event.
554 * The trace event type currently supported are:
555 * TRACEPOINT,
556 * PROBE,
557 * FUNCTION,
558 * FUNCTION_ENTRY,
559 * SYSCALL
560 *
561 * writer An instance of a mi writer.
562 * event single trace event.
563 * is_open Defines whether or not the session element shall be closed.
564 * This should be used carefully and the client
565 * must close the event element.
566 * Use case: nested additional information
970d848b 567 * domain Event's domain
5e18ec73
JR
568 *
569 * Returns zero if the element's value could be written.
570 * Negative values indicate an error.
571 */
572int mi_lttng_event(struct mi_writer *writer, struct lttng_event *event,
970d848b 573 int is_open, enum lttng_domain_type domain);
5e18ec73
JR
574
575/*
576 * Machine interface for struct lttng_event_field.
577 *
578 * writer An instance of a mi writer.
579 * field An event_field instance.
580 *
581 * Returns zero if the element's value could be written.
582 * Negative values indicate an error.
583 */
584int mi_lttng_event_field(struct mi_writer *writer,
585 struct lttng_event_field *field);
586
587/*
588 * Machine interface: open a event_fields element.
589 *
590 * writer An instance of a machine interface writer.
591 *
e4d484a5 592 * Returns zero if the element have be written.
5e18ec73
JR
593 * Negative values indicate an error.
594 */
595int mi_lttng_event_fields_open(struct mi_writer *writer);
596
ebbf5ab7
JR
597/*
598 * Machine interface: open a trackers element.
599 *
600 * writer An instance of a machine interface writer.
601 *
602 * Returns zero if the element's value could be written.
603 * Negative values indicate an error.
604 */
605int mi_lttng_trackers_open(struct mi_writer *writer);
606
607/*
608 * Machine interface: open a pid_tracker element.
609 *
610 * writer An instance of a machine interface writer.
611 *
612 * Returns zero if the element's value could be written.
613 * Negative values indicate an error.
614 *
615 * Note: A targets element is also opened for each tracker definition
616 */
617int mi_lttng_pid_tracker_open(struct mi_writer *writer);
618
5e18ec73
JR
619/*
620 * Machine interface: open a PIDs element.
621 *
622 * writer An instance of a machine interface writer.
623 *
624 * Returns zero if the element's value could be written.
625 * Negative values indicate an error.
626 */
627int mi_lttng_pids_open(struct mi_writer *writer);
628
629/*
ebbf5ab7
JR
630 * Machine interface: open a processes element.
631 *
632 * writer An instance of a machine interface writer.
633 *
634 * Returns zero if the element's value could be written.
635 * Negative values indicate an error.
636 */
637int mi_lttng_processes_open(struct mi_writer *writer);
638
639/*
640 * Machine interface of a Process.
5e18ec73
JR
641 *
642 * writer An instance of a machine interface writer.
643 * pid A PID.
644 *
645 * is_open Defines whether or not the session element shall be closed.
646 * This should be used carefully and the client
647 * must close the pid element.
648 * Use case: nested addition information on a domain
649 * ex: channel event.
650 *
651 * Returns zero if the element's value could be written.
652 * Negative values indicate an error.
653 */
ebbf5ab7 654int mi_lttng_process(struct mi_writer *writer, pid_t pid , const char *name,
5e18ec73 655 int is_open);
bf239d4c
JR
656
657/*
658 * TODO: move pid of lttng list -u to process semantic on mi api bump
659 * Machine interface of a Process.
660 *
661 * writer An instance of a machine interface writer.
662 * pid A PID.
663 *
664 * is_open Defines whether or not the session element shall be closed.
665 * This should be used carefully and the client
666 * must close the pid element.
667 * Use case: nested addition information on a domain
668 * ex: channel event.
669 *
670 * Returns zero if the element's value could be written.
671 * Negative values indicate an error.
672 */
673int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *name,
674 int is_open);
ebbf5ab7
JR
675/*
676 * Machine interface: open a targets element.
677 *
678 * writer An instance of a machine interface writer.
679 *
680 * Returns zero if the element's value could be written.
681 * Negative values indicate an error.
682 */
683int mi_lttng_targets_open(struct mi_writer *writer);
684
685/*
686 * Machine interface for track/untrack a pid_target
687 *
688 * writer An instance of a machine interface writer.
689 *
690 * Returns zero if the element's value could be written.
691 * Negative values indicate an error.
692 */
693int mi_lttng_pid_target(struct mi_writer *writer, pid_t pid, int is_open);
c7e35b03 694
89b72577
JRJ
695/*
696 * Machine interface of a context.
697 *
698 * writer An instance of a machine interface writer
699 *
700 * context An instance of a lttng_event_context
701 *
702 * is_open Define if we close the context element
703 * This should be used carefully and the client
704 * need to close the context element.
89b72577
JRJ
705 * Returns zero if the element's value could be written.
706 * Negative values indicate an error.
707 */
708int mi_lttng_context(struct mi_writer *writer,
709 struct lttng_event_context *context, int is_open);
710
711/*
712 * Machine interface of a perf_counter_context.
713 *
714 * writer An instance of a machine interface writer
715 *
716 * contest An instance of a lttng_event_perf_counter_ctx
717 *
718 * Returns zero if the element's value could be written.
719 * Negative values indicate an error.
720 */
721int mi_lttng_perf_counter_context(struct mi_writer *writer,
722 struct lttng_event_perf_counter_ctx *perf_context);
723
50534d6f
JRJ
724/*
725 * Machine interface of the snapshot list_output.
726 * It specifies the session for which we are listing snapshots,
727 * and it opens a snapshots element to list a sequence
728 * of snapshots.
729 *
730 * writer An instance of a machine interface writer.
731 *
732 * session_name: Snapshot output for session "session_name".
733 *
734 * Note: The client has to close the session and the snapshots elements after
735 * having listed every lttng_snapshot_output.
736 *
737 * Returns zero if the element's value could be written.
738 * Negative values indicate an error.
739 */
740int mi_lttng_snapshot_output_session_name(struct mi_writer *writer,
741 const char *session_name);
742
743/*
744 * Machine interface of the snapshot output.
745 * The machine interface serializes the following attributes:
746 * - id: ID of the snapshot output.
747 * - name: Name of the output.
748 * - data_url : Destination of the output.
749 * - ctrl_url: Destination of the output.
750 * - max_size: total size of all stream combined.
751 *
752 * writer An instance of a machine interface writer.
753 *
754 * output: A list of snapshot_output.
755 *
756 * Returns zero if the element's value could be written.
757 * Negative values indicate an error.
758 */
759int mi_lttng_snapshot_list_output(struct mi_writer *writer,
760 struct lttng_snapshot_output *output);
761
762/*
763 * Machine interface of the output of the command snapshot del output
764 * when deleting a snapshot either by id or by name.
765 * If the snapshot was found and successfully deleted using its id,
766 * it return the id of the snapshot and the current session name on which it
767 * was attached.
768 *
769 * Otherwise, it do the same process with the name of the snapshot, if the
770 * snapshot output id is undefined.
771 *
772 * writer An instance of a machine interface writer.
773 *
774 * id: ID of the snapshot output.
775 *
776 * name: Name of the snapshot.
777 *
778 * current_session_name: Session to which the snapshot belongs.
779 *
780 * Returns zero if the element's value could be written.
781 * Negative values indicate an error.
782 */
783int mi_lttng_snapshot_del_output(struct mi_writer *writer, int id,
784 const char *name, const char *current_session_name);
785
786/*
787 * Machine interface of the output of the command snapshot add output
788 * when adding a snapshot from a user URL.
789 *
790 * If the snapshot was successfully added, the machine interface lists
791 * these information:
792 * - id: ID of the newly add snapshot output.
793 * - current_session_name: Name of the session to which the output was added.
794 * - ctrl_url: Destination of the output.
795 * - max_size: total size of all stream combined.
796 *
797 * writer An instance of a machine interface writer.
798 *
799 * current_session_name: Session to which the snapshot belongs.
800 *
801 * n_ptr:
802 *
803 * output: iterator over a lttng_snapshot_output_list which contain
804 * the snapshot output informations.
805 *
806 * Returns zero if the element's value could be written.
807 * Negative values indicate an error.
808 */
809int mi_lttng_snapshot_add_output(struct mi_writer *writer,
810 const char *current_session_name, const char *n_ptr,
811 struct lttng_snapshot_output *output);
812
813/*
814 * Machine interface of the output of the command snapshot
815 * record from a URL (if given).
816 *
817 * If the snapshot is successfully recorded from a url, the machine interface
818 * output the following information:
819 * - url: Destination of the output stored in the snapshot.
820 *
821 * Otherwise, the machine interface output the data and ctrl url received
822 * from the command-line.
823 *
824 * writer An instance of a machine interface writer.
825 *
826 * current_session_name: Snapshot record for session "current_session_name".
827 *
828 * ctrl_url, data_url: Destination of the output receive from the command-line.
829 *
830 * Returns zero if the element's value could be written.
831 * Negative values indicate an error.
832 */
833int mi_lttng_snapshot_record(struct mi_writer *writer,
834 const char *current_session_name, const char *url,
835 const char *cmdline_ctrl_url, const char *cmdline_data_url);
836
66ea93b1
JG
837/*
838 * Machine interface representation of a session rotation schedule.
839 *
840 * The machine interface serializes the provided schedule as one of the choices
841 * from 'rotation_schedule_type'.
842 *
843 * writer: An instance of a machine interface writer.
844 *
845 * schedule: An lttng rotation schedule descriptor object.
846 *
847 * Returns zero if the element's value could be written.
848 * Negative values indicate an error.
849 */
850int mi_lttng_rotation_schedule(struct mi_writer *writer,
851 const struct lttng_rotation_schedule *schedule);
852
853/*
854 * Machine interface of a session rotation schedule result.
855 * This is an element that is part of the output of the enable-rotation and
856 * disable-rotation commands.
857 *
858 * The machine interface provides the following information:
859 * - schedule: the session rotation schedule descriptor.
860 * - success: whether the sub-command succeeded.
861 *
862 * writer: An instance of a machine interface writer.
863 *
66ea93b1
JG
864 * schedule: An lttng rotation schedule descriptor object.
865 *
866 * success: Whether the sub-command suceeded.
867 *
868 * Returns zero if the element's value could be written.
869 * Negative values indicate an error.
870 */
871int mi_lttng_rotation_schedule_result(struct mi_writer *writer,
872 const struct lttng_rotation_schedule *schedule,
873 bool success);
874
91c4d516
JG
875/*
876 * Machine interface of a session rotation result.
877 * This is an element that is part of the output of the rotate command.
878 *
879 * The machine interface provides the following information:
880 * - session_name: the session to be rotated.
881 * - state: the session rotation state.
882 * - location: the location of the completed chunk archive.
883 *
884 * writer: An instance of a machine interface writer.
885 *
886 * session_name: The session to which the rotate command applies.
887 *
888 * location: A location descriptor object.
889 *
890 * success: Whether the sub-command suceeded.
891 *
892 * Returns zero if the element's value could be written.
893 * Negative values indicate an error.
894 */
895int mi_lttng_rotate(struct mi_writer *writer,
896 const char *session_name,
897 enum lttng_rotation_state rotation_state,
898 const struct lttng_trace_archive_location *location);
899
c7e35b03 900#endif /* _MI_LTTNG_H */
This page took 0.084259 seconds and 4 git commands to generate.