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