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