Fix: use negative code for errors in enum
[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;
d68c9a04 204
59deec0c
JR
205/* String related to add-context command */
206LTTNG_HIDDEN extern const char * const mi_lttng_element_context_symbol;
207
5e18ec73 208/* Utility string function */
970d848b 209const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
5e18ec73
JR
210const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value);
211const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value);
212const char *mi_lttng_domaintype_string(enum lttng_domain_type value);
213const char *mi_lttng_buffertype_string(enum lttng_buffer_type value);
214
c7e35b03
JR
215/*
216 * Create an instance of a machine interface writer.
217 *
218 * fd_output File to which the XML content must be written. The file will be
219 * closed once the mi_writer has been destroyed.
220 *
221 * Returns an instance of a machine interface writer on success, NULL on
222 * error.
223 */
224struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);
225
226/*
227 * Destroy an instance of a machine interface writer.
228 *
229 * writer An instance of a machine interface writer.
230 *
231 * Returns zero if the XML document could be closed cleanly. Negative values
232 * indicate an error.
233 */
234int mi_lttng_writer_destroy(struct mi_writer *writer);
235
236/*
237 * Open a command tag and add it's name node.
238 *
239 * writer An instance of a machine interface writer.
c7e35b03
JR
240 * command The command name.
241 *
242 * Returns zero if the XML document could be closed cleanly.
243 * Negative values indicate an error.
244 */
245int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);
246
247/*
248 * Close a command tag.
249 *
250 * writer An instance of a machine interface writer.
251 *
252 * Returns zero if the XML document could be closed cleanly.
253 * Negative values indicate an error.
254 */
255int mi_lttng_writer_command_close(struct mi_writer *writer);
256
257/*
258 * Open an element tag.
259 *
260 * writer An instance of a machine interface writer.
c7e35b03
JR
261 * element_name Element tag name.
262 *
263 * Returns zero if the XML document could be closed cleanly.
264 * Negative values indicate an error.
265 */
266int mi_lttng_writer_open_element(struct mi_writer *writer,
267 const char *element_name);
268
269/*
270 * Close the current element 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_close_element(struct mi_writer *writer);
278
279/*
5e18ec73 280 * Close multiple element.
c7e35b03
JR
281 *
282 * writer An instance of a machine interface writer.
5e18ec73 283 * nb_element Number of elements.
c7e35b03 284 *
5e18ec73
JR
285 * Returns zero if the XML document could be closed cleanly.
286 * Negative values indicate an error.
287 */
288int mi_lttng_close_multi_element(struct mi_writer *writer,
289 unsigned int nb_element);
290
291/*
292 * Write an element of type unsigned int.
c7e35b03 293 *
5e18ec73
JR
294 * writer An instance of a machine interface writer.
295 * element_name Element name.
c7e35b03
JR
296 * value Unsigned int value of the element
297 *
298 * Returns zero if the element's value could be written.
299 * Negative values indicate an error.
300 */
301int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
302 const char *element_name, uint64_t value);
303
304/*
305 * Write an element of type signed int.
306 *
307 * writer An instance of a machine interface writer.
c7e35b03 308 * element_name Element name.
5e18ec73 309 * value Signed int value of the element.
c7e35b03
JR
310 *
311 * Returns zero if the element's value could be written.
312 * Negative values indicate an error.
313 */
314int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
315 const char *element_name, int64_t value);
316
317/*
318 * Write an element of type boolean.
319 *
320 * writer An instance of a machine interface writer.
c7e35b03 321 * element_name Element name.
5e18ec73 322 * value Boolean value of the element.
c7e35b03
JR
323 *
324 * Returns zero if the element's value could be written.
325 * Negative values indicate an error.
326 */
327int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
328 const char *element_name, int value);
329
330/*
331 * Write an element of type string.
332 *
333 * writer An instance of a machine interface writer.
c7e35b03 334 * element_name Element name.
5e18ec73 335 * value String value of the element.
c7e35b03
JR
336 *
337 * Returns zero if the element's value could be written.
338 * Negative values indicate an error.
339 */
340int mi_lttng_writer_write_element_string(struct mi_writer *writer,
341 const char *element_name, const char *value);
342
343/*
344 * Machine interface of struct version.
345 *
346 * writer An instance of a machine interface writer.
c7e35b03 347 * version Version struct.
c7e35b03 348 * lttng_description String value of the version description.
c7e35b03
JR
349 * lttng_license String value of the version license.
350 *
351 * Returns zero if the element's value could be written.
352 * Negative values indicate an error.
353 */
354int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version *version,
355 const char *lttng_description, const char *lttng_license);
356
357/*
5e18ec73 358 * Machine interface: open a sessions element.
c7e35b03 359 *
5e18ec73 360 * writer An instance of a machine interface writer.
c7e35b03 361 *
5e18ec73
JR
362 * Returns zero if the element's value could be written.
363 * Negative values indicate an error.
364 */
365int mi_lttng_sessions_open(struct mi_writer *writer);
366
367/*
368 * Machine interface of struct session.
c7e35b03 369 *
5e18ec73
JR
370 * writer An instance of a machine interface writer.
371 * session An instance of a session.
372 * is_open Defines whether or not the session element shall be closed.
373 * This should be used carefully and the client
374 * must close the session element.
136f2f81 375 * Use case: nested additional information on a session
c7e35b03 376 * ex: domain,channel event.
c7e35b03
JR
377 *
378 * Returns zero if the element's value could be written.
379 * Negative values indicate an error.
380 */
381int mi_lttng_session(struct mi_writer *writer,
5e18ec73
JR
382 struct lttng_session *session, int is_open);
383
384/*
385 * Machine interface: open a domains element.
386 *
387 * writer An instance of a machine interface writer.
388 *
389 * Returns zero if the element's value could be written.
390 * Negative values indicate an error.
391 */
392int mi_lttng_domains_open(struct mi_writer *writer);
393
394/*
395 * Machine interface of struct domain.
396 *
397 * writer An instance of a machine interface writer.
398 * domain An instance of a domain.
399 *
400 * is_open Defines whether or not the session element shall be closed.
401 * This should be used carefully and the client
402 * must close the domain element.
403 * Use case: nested addition information on a domain
404 * ex: channel event.
405 *
406 * Returns zero if the element's value could be written.
407 * Negative values indicate an error.
408 */
409int mi_lttng_domain(struct mi_writer *writer,
410 struct lttng_domain *domain, int is_open);
411
412/*
413 * Machine interface: open a channels element.
414 *
415 * writer An instance of a machine interface writer.
416 *
417 * Returns zero if the element's value could be written.
418 * Negative values indicate an error.
419 */
420int mi_lttng_channels_open(struct mi_writer *writer);
421
422/*
423 * Machine interface of struct channel.
424 *
425 * writer An instance of a machine interface writer.
426 * channel An instance of a channel.
427 *
428 * is_open Defines whether or not the session element shall be closed.
429 * This should be used carefully and the client
430 * must close the channel element.
431 * Use case: nested addition information on a channel.
432 * ex: channel event.
433 *
434 * Returns zero if the element's value could be written.
435 * Negative values indicate an error.
436 */
437int mi_lttng_channel(struct mi_writer *writer,
438 struct lttng_channel *channel, int is_open);
439
440/*
441 * Machine interface of struct channel_attr.
442 *
443 * writer An instance of a machine interface writer.
444 * attr An instance of a channel_attr struct.
445 *
446 * Returns zero if the element's value could be written.
447 * Negative values indicate an error.
448 */
449int mi_lttng_channel_attr(struct mi_writer *writer,
450 struct lttng_channel_attr *attr);
451
452/*
453* Machine interface for event common attributes.
454*
455* writer An instance of a mi writer.
456* event single trace event.
457*
458* The common attribute are:
459* - mi event element
460* - event name
461* - event type
462* - enabled tag
463* - event filter
464*
465* Returns zero if the element's value could be written.
466* Negative values indicate an error.
467*/
468int mi_lttng_event_common_attributes(struct mi_writer *writer,
469 struct lttng_event *event);
470
471/*
472 * Machine interface for kernel tracepoint event with a loglevel.
473 *
474 * writer An instance of a mi writer.
475 * event single trace event.
970d848b 476 * domain Event's domain
5e18ec73
JR
477 *
478 * Returns zero if the element's value could be written.
479 * Negative values indicate an error.
480 */
481int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
970d848b 482 struct lttng_event *event, enum lttng_domain_type domain);
5e18ec73
JR
483
484/*
485 * Machine interface for kernel tracepoint event with no loglevel.
486 *
487 * writer An instance of a mi writer.
488 * event single trace event.
489 *
490 * Returns zero if the element's value could be written.
491 * Negative values indicate an error.
492 */
493int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer,
494 struct lttng_event *event);
495
496/*
497 * Machine interface for kernel function and probe event.
498 *
499 * writer An instance of a mi writer.
500 * event single trace event.
501 *
502 * Returns zero if the element's value could be written.
503 * Negative values indicate an error.
504 */
505int mi_lttng_event_function_probe(struct mi_writer *writer,
506 struct lttng_event *event);
507
508/*
509 * Machine interface for kernel function entry event.
510 *
511 * writer An instance of a mi writer.
512 * event single trace event.
513 *
514 * Returns zero if the element's value could be written.
515 * Negative values indicate an error.
516 */
517int mi_lttng_event_function_entry(struct mi_writer *writer,
518 struct lttng_event *event);
519
520/*
521 * Machine interface: open an events element.
522 *
523 * writer An instance of a machine interface writer.
524 *
525 * Returns zero if the element's value could be written.
526 * Negative values indicate an error.
527 */
528int mi_lttng_events_open(struct mi_writer *writer);
529
530/*
531 * Machine interface for printing an event.
532 * The trace event type currently supported are:
533 * TRACEPOINT,
534 * PROBE,
535 * FUNCTION,
536 * FUNCTION_ENTRY,
537 * SYSCALL
538 *
539 * writer An instance of a mi writer.
540 * event single trace event.
541 * is_open Defines whether or not the session element shall be closed.
542 * This should be used carefully and the client
543 * must close the event element.
544 * Use case: nested additional information
970d848b 545 * domain Event's domain
5e18ec73
JR
546 *
547 * Returns zero if the element's value could be written.
548 * Negative values indicate an error.
549 */
550int mi_lttng_event(struct mi_writer *writer, struct lttng_event *event,
970d848b 551 int is_open, enum lttng_domain_type domain);
5e18ec73
JR
552
553/*
554 * Machine interface for struct lttng_event_field.
555 *
556 * writer An instance of a mi writer.
557 * field An event_field instance.
558 *
559 * Returns zero if the element's value could be written.
560 * Negative values indicate an error.
561 */
562int mi_lttng_event_field(struct mi_writer *writer,
563 struct lttng_event_field *field);
564
565/*
566 * Machine interface: open a event_fields element.
567 *
568 * writer An instance of a machine interface writer.
569 *
e4d484a5 570 * Returns zero if the element have be written.
5e18ec73
JR
571 * Negative values indicate an error.
572 */
573int mi_lttng_event_fields_open(struct mi_writer *writer);
574
ebbf5ab7
JR
575/*
576 * Machine interface: open a trackers element.
577 *
578 * writer An instance of a machine interface writer.
579 *
580 * Returns zero if the element's value could be written.
581 * Negative values indicate an error.
582 */
583int mi_lttng_trackers_open(struct mi_writer *writer);
584
585/*
586 * Machine interface: open a pid_tracker element.
587 *
588 * writer An instance of a machine interface writer.
589 *
590 * Returns zero if the element's value could be written.
591 * Negative values indicate an error.
592 *
593 * Note: A targets element is also opened for each tracker definition
594 */
595int mi_lttng_pid_tracker_open(struct mi_writer *writer);
596
5e18ec73
JR
597/*
598 * Machine interface: open a PIDs 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_pids_open(struct mi_writer *writer);
606
607/*
ebbf5ab7
JR
608 * Machine interface: open a processes 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 */
615int mi_lttng_processes_open(struct mi_writer *writer);
616
617/*
618 * Machine interface of a Process.
5e18ec73
JR
619 *
620 * writer An instance of a machine interface writer.
621 * pid A PID.
622 *
623 * is_open Defines whether or not the session element shall be closed.
624 * This should be used carefully and the client
625 * must close the pid element.
626 * Use case: nested addition information on a domain
627 * ex: channel event.
628 *
629 * Returns zero if the element's value could be written.
630 * Negative values indicate an error.
631 */
ebbf5ab7 632int mi_lttng_process(struct mi_writer *writer, pid_t pid , const char *name,
5e18ec73 633 int is_open);
bf239d4c
JR
634
635/*
636 * TODO: move pid of lttng list -u to process semantic on mi api bump
637 * Machine interface of a Process.
638 *
639 * writer An instance of a machine interface writer.
640 * pid A PID.
641 *
642 * is_open Defines whether or not the session element shall be closed.
643 * This should be used carefully and the client
644 * must close the pid element.
645 * Use case: nested addition information on a domain
646 * ex: channel event.
647 *
648 * Returns zero if the element's value could be written.
649 * Negative values indicate an error.
650 */
651int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *name,
652 int is_open);
ebbf5ab7
JR
653/*
654 * Machine interface: open a targets element.
655 *
656 * writer An instance of a machine interface writer.
657 *
658 * Returns zero if the element's value could be written.
659 * Negative values indicate an error.
660 */
661int mi_lttng_targets_open(struct mi_writer *writer);
662
663/*
664 * Machine interface for track/untrack a pid_target
665 *
666 * writer An instance of a machine interface writer.
667 *
668 * Returns zero if the element's value could be written.
669 * Negative values indicate an error.
670 */
671int mi_lttng_pid_target(struct mi_writer *writer, pid_t pid, int is_open);
c7e35b03 672
89b72577
JRJ
673/*
674 * Machine interface of a context.
675 *
676 * writer An instance of a machine interface writer
677 *
678 * context An instance of a lttng_event_context
679 *
680 * is_open Define if we close the context element
681 * This should be used carefully and the client
682 * need to close the context element.
89b72577
JRJ
683 * Returns zero if the element's value could be written.
684 * Negative values indicate an error.
685 */
686int mi_lttng_context(struct mi_writer *writer,
687 struct lttng_event_context *context, int is_open);
688
689/*
690 * Machine interface of a perf_counter_context.
691 *
692 * writer An instance of a machine interface writer
693 *
694 * contest An instance of a lttng_event_perf_counter_ctx
695 *
696 * Returns zero if the element's value could be written.
697 * Negative values indicate an error.
698 */
699int mi_lttng_perf_counter_context(struct mi_writer *writer,
700 struct lttng_event_perf_counter_ctx *perf_context);
701
50534d6f
JRJ
702/*
703 * Machine interface of the snapshot list_output.
704 * It specifies the session for which we are listing snapshots,
705 * and it opens a snapshots element to list a sequence
706 * of snapshots.
707 *
708 * writer An instance of a machine interface writer.
709 *
710 * session_name: Snapshot output for session "session_name".
711 *
712 * Note: The client has to close the session and the snapshots elements after
713 * having listed every lttng_snapshot_output.
714 *
715 * Returns zero if the element's value could be written.
716 * Negative values indicate an error.
717 */
718int mi_lttng_snapshot_output_session_name(struct mi_writer *writer,
719 const char *session_name);
720
721/*
722 * Machine interface of the snapshot output.
723 * The machine interface serializes the following attributes:
724 * - id: ID of the snapshot output.
725 * - name: Name of the output.
726 * - data_url : Destination of the output.
727 * - ctrl_url: Destination of the output.
728 * - max_size: total size of all stream combined.
729 *
730 * writer An instance of a machine interface writer.
731 *
732 * output: A list of snapshot_output.
733 *
734 * Returns zero if the element's value could be written.
735 * Negative values indicate an error.
736 */
737int mi_lttng_snapshot_list_output(struct mi_writer *writer,
738 struct lttng_snapshot_output *output);
739
740/*
741 * Machine interface of the output of the command snapshot del output
742 * when deleting a snapshot either by id or by name.
743 * If the snapshot was found and successfully deleted using its id,
744 * it return the id of the snapshot and the current session name on which it
745 * was attached.
746 *
747 * Otherwise, it do the same process with the name of the snapshot, if the
748 * snapshot output id is undefined.
749 *
750 * writer An instance of a machine interface writer.
751 *
752 * id: ID of the snapshot output.
753 *
754 * name: Name of the snapshot.
755 *
756 * current_session_name: Session to which the snapshot belongs.
757 *
758 * Returns zero if the element's value could be written.
759 * Negative values indicate an error.
760 */
761int mi_lttng_snapshot_del_output(struct mi_writer *writer, int id,
762 const char *name, const char *current_session_name);
763
764/*
765 * Machine interface of the output of the command snapshot add output
766 * when adding a snapshot from a user URL.
767 *
768 * If the snapshot was successfully added, the machine interface lists
769 * these information:
770 * - id: ID of the newly add snapshot output.
771 * - current_session_name: Name of the session to which the output was added.
772 * - ctrl_url: Destination of the output.
773 * - max_size: total size of all stream combined.
774 *
775 * writer An instance of a machine interface writer.
776 *
777 * current_session_name: Session to which the snapshot belongs.
778 *
779 * n_ptr:
780 *
781 * output: iterator over a lttng_snapshot_output_list which contain
782 * the snapshot output informations.
783 *
784 * Returns zero if the element's value could be written.
785 * Negative values indicate an error.
786 */
787int mi_lttng_snapshot_add_output(struct mi_writer *writer,
788 const char *current_session_name, const char *n_ptr,
789 struct lttng_snapshot_output *output);
790
791/*
792 * Machine interface of the output of the command snapshot
793 * record from a URL (if given).
794 *
795 * If the snapshot is successfully recorded from a url, the machine interface
796 * output the following information:
797 * - url: Destination of the output stored in the snapshot.
798 *
799 * Otherwise, the machine interface output the data and ctrl url received
800 * from the command-line.
801 *
802 * writer An instance of a machine interface writer.
803 *
804 * current_session_name: Snapshot record for session "current_session_name".
805 *
806 * ctrl_url, data_url: Destination of the output receive from the command-line.
807 *
808 * Returns zero if the element's value could be written.
809 * Negative values indicate an error.
810 */
811int mi_lttng_snapshot_record(struct mi_writer *writer,
812 const char *current_session_name, const char *url,
813 const char *cmdline_ctrl_url, const char *cmdline_data_url);
814
66ea93b1
JG
815/*
816 * Machine interface representation of a session rotation schedule.
817 *
818 * The machine interface serializes the provided schedule as one of the choices
819 * from 'rotation_schedule_type'.
820 *
821 * writer: An instance of a machine interface writer.
822 *
823 * schedule: An lttng rotation schedule descriptor object.
824 *
825 * Returns zero if the element's value could be written.
826 * Negative values indicate an error.
827 */
828int mi_lttng_rotation_schedule(struct mi_writer *writer,
829 const struct lttng_rotation_schedule *schedule);
830
831/*
832 * Machine interface of a session rotation schedule result.
833 * This is an element that is part of the output of the enable-rotation and
834 * disable-rotation commands.
835 *
836 * The machine interface provides the following information:
837 * - schedule: the session rotation schedule descriptor.
838 * - success: whether the sub-command succeeded.
839 *
840 * writer: An instance of a machine interface writer.
841 *
842 * session_name: The session to which the command applies.
843 *
844 * schedule: An lttng rotation schedule descriptor object.
845 *
846 * success: Whether the sub-command suceeded.
847 *
848 * Returns zero if the element's value could be written.
849 * Negative values indicate an error.
850 */
851int mi_lttng_rotation_schedule_result(struct mi_writer *writer,
852 const struct lttng_rotation_schedule *schedule,
853 bool success);
854
c7e35b03 855#endif /* _MI_LTTNG_H */
This page took 0.109699 seconds and 4 git commands to generate.