2 * Copyright (C) 2014 - Jonathan Rajotte <jonathan.r.julien@gmail.com>
3 * - Olivier Cotte <olivier.cotte@polymtl.ca>
4 * Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
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.
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
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.
25 #include <common/error.h>
26 #include <common/macros.h>
27 #include <common/config/session-config.h>
28 #include <lttng/lttng.h>
30 /* Don't want to reference snapshot-internal.h here */
31 struct lttng_snapshot_output
;
33 /* Instance of a machine interface writer. */
35 struct config_writer
*writer
;
36 enum lttng_mi_output_type type
;
40 * Version information for the machine interface.
42 struct mi_lttng_version
{
43 char version
[LTTNG_NAME_MAX
]; /* Version number of package */
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 */
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. */
52 /* Strings related to command */
53 extern const char * const mi_lttng_element_command
;
54 extern const char * const mi_lttng_element_command_action
;
55 extern const char * const mi_lttng_element_command_add_context
;
56 extern const char * const mi_lttng_element_command_create
;
57 extern const char * const mi_lttng_element_command_destroy
;
58 extern const char * const mi_lttng_element_command_disable_channel
;
59 extern const char * const mi_lttng_element_command_disable_event
;
60 extern const char * const mi_lttng_element_command_enable_channels
;
61 extern const char * const mi_lttng_element_command_enable_event
;
62 extern const char * const mi_lttng_element_command_list
;
63 extern const char * const mi_lttng_element_command_load
;
64 extern const char * const mi_lttng_element_command_metadata
;
65 extern const char * const mi_lttng_element_command_metadata_action
;
66 extern const char * const mi_lttng_element_command_regenerate
;
67 extern const char * const mi_lttng_element_command_regenerate_action
;
68 extern const char * const mi_lttng_element_command_name
;
69 extern const char * const mi_lttng_element_command_output
;
70 extern const char * const mi_lttng_element_command_save
;
71 extern const char * const mi_lttng_element_command_set_session
;
72 extern const char * const mi_lttng_element_command_snapshot
;
73 extern const char * const mi_lttng_element_command_snapshot_add
;
74 extern const char * const mi_lttng_element_command_snapshot_del
;
75 extern const char * const mi_lttng_element_command_snapshot_list
;
76 extern const char * const mi_lttng_element_command_snapshot_record
;
77 extern const char * const mi_lttng_element_command_start
;
78 extern const char * const mi_lttng_element_command_stop
;
79 extern const char * const mi_lttng_element_command_success
;
80 extern const char * const mi_lttng_element_command_track
;
81 extern const char * const mi_lttng_element_command_untrack
;
82 extern const char * const mi_lttng_element_command_version
;
83 extern const char * const mi_lttng_element_command_rotate
;
84 extern const char * const mi_lttng_element_command_enable_rotation
;
85 extern const char * const mi_lttng_element_command_disable_rotation
;
86 extern const char * const mi_lttng_element_command_clear
;
88 /* Strings related to version command */
89 extern const char * const mi_lttng_element_version
;
90 extern const char * const mi_lttng_element_version_commit
;
91 extern const char * const mi_lttng_element_version_description
;
92 extern const char * const mi_lttng_element_version_license
;
93 extern const char * const mi_lttng_element_version_major
;
94 extern const char * const mi_lttng_element_version_minor
;
95 extern const char * const mi_lttng_element_version_patch_level
;
96 extern const char * const mi_lttng_element_version_str
;
97 extern const char * const mi_lttng_element_version_web
;
99 /* String related to a lttng_event_field */
100 extern const char * const mi_lttng_element_event_field
;
101 extern const char * const mi_lttng_element_event_fields
;
103 /* String related to lttng_event_perf_counter_ctx */
104 extern const char * const mi_lttng_element_perf_counter_context
;
106 /* Strings related to pid */
107 extern const char * const mi_lttng_element_pid_id
;
109 /* Strings related to save command */
110 extern const char * const mi_lttng_element_save
;
112 /* Strings related to load command */
113 extern const char * const mi_lttng_element_load
;
114 LTTNG_HIDDEN
extern const char * const mi_lttng_element_load_overrides
;
115 LTTNG_HIDDEN
extern const char * const mi_lttng_element_load_override_url
;
117 /* General element of mi_lttng */
118 extern const char * const mi_lttng_element_empty
;
119 extern const char * const mi_lttng_element_id
;
120 extern const char * const mi_lttng_element_nowrite
;
121 extern const char * const mi_lttng_element_success
;
122 extern const char * const mi_lttng_element_type_enum
;
123 extern const char * const mi_lttng_element_type_float
;
124 extern const char * const mi_lttng_element_type_integer
;
125 extern const char * const mi_lttng_element_type_other
;
126 extern const char * const mi_lttng_element_type_string
;
128 /* String related to loglevel */
129 extern const char * const mi_lttng_loglevel_str_alert
;
130 extern const char * const mi_lttng_loglevel_str_crit
;
131 extern const char * const mi_lttng_loglevel_str_debug
;
132 extern const char * const mi_lttng_loglevel_str_debug_function
;
133 extern const char * const mi_lttng_loglevel_str_debug_line
;
134 extern const char * const mi_lttng_loglevel_str_debug_module
;
135 extern const char * const mi_lttng_loglevel_str_debug_process
;
136 extern const char * const mi_lttng_loglevel_str_debug_program
;
137 extern const char * const mi_lttng_loglevel_str_debug_system
;
138 extern const char * const mi_lttng_loglevel_str_debug_unit
;
139 extern const char * const mi_lttng_loglevel_str_emerg
;
140 extern const char * const mi_lttng_loglevel_str_err
;
141 extern const char * const mi_lttng_loglevel_str_info
;
142 extern const char * const mi_lttng_loglevel_str_notice
;
143 extern const char * const mi_lttng_loglevel_str_unknown
;
144 extern const char * const mi_lttng_loglevel_str_warning
;
146 /* String related to loglevel JUL */
147 extern const char * const mi_lttng_loglevel_str_jul_all
;
148 extern const char * const mi_lttng_loglevel_str_jul_config
;
149 extern const char * const mi_lttng_loglevel_str_jul_fine
;
150 extern const char * const mi_lttng_loglevel_str_jul_finer
;
151 extern const char * const mi_lttng_loglevel_str_jul_finest
;
152 extern const char * const mi_lttng_loglevel_str_jul_info
;
153 extern const char * const mi_lttng_loglevel_str_jul_off
;
154 extern const char * const mi_lttng_loglevel_str_jul_severe
;
155 extern const char * const mi_lttng_loglevel_str_jul_warning
;
157 /* String related to loglevel Log4j */
158 extern const char * const mi_lttng_loglevel_str_log4j_off
;
159 extern const char * const mi_lttng_loglevel_str_log4j_fatal
;
160 extern const char * const mi_lttng_loglevel_str_log4j_error
;
161 extern const char * const mi_lttng_loglevel_str_log4j_warn
;
162 extern const char * const mi_lttng_loglevel_str_log4j_info
;
163 extern const char * const mi_lttng_loglevel_str_log4j_debug
;
164 extern const char * const mi_lttng_loglevel_str_log4j_trace
;
165 extern const char * const mi_lttng_loglevel_str_log4j_all
;
167 /* String related to loglevel Python */
168 extern const char * const mi_lttng_loglevel_str_python_critical
;
169 extern const char * const mi_lttng_loglevel_str_python_error
;
170 extern const char * const mi_lttng_loglevel_str_python_warning
;
171 extern const char * const mi_lttng_loglevel_str_python_info
;
172 extern const char * const mi_lttng_loglevel_str_python_debug
;
173 extern const char * const mi_lttng_loglevel_str_python_notset
;
175 /* String related to loglevel type */
176 extern const char * const mi_lttng_loglevel_type_all
;
177 extern const char * const mi_lttng_loglevel_type_range
;
178 extern const char * const mi_lttng_loglevel_type_single
;
179 extern const char * const mi_lttng_loglevel_type_unknown
;
181 /* String related to a lttng_snapshot */
182 extern const char * const mi_lttng_element_snapshot_ctrl_url
;
183 extern const char * const mi_lttng_element_snapshot_data_url
;
184 extern const char * const mi_lttng_element_snapshot_max_size
;
185 extern const char * const mi_lttng_element_snapshot_n_ptr
;
186 extern const char * const mi_lttng_element_snapshot_session_name
;
187 extern const char * const mi_lttng_element_snapshots
;
189 /* String related to track/untrack command */
190 extern const char * const mi_lttng_element_track_untrack_all_wildcard
;
192 LTTNG_HIDDEN
extern const char * const mi_lttng_element_session_name
;
194 /* String related to rotate command */
195 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation
;
196 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotate_status
;
197 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule
;
198 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedules
;
199 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_periodic
;
200 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us
;
201 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_size_threshold
;
202 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes
;
203 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_result
;
204 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_results
;
205 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_state
;
206 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location
;
207 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_local
;
208 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_local_absolute_path
;
209 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay
;
210 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_host
;
211 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_control_port
;
212 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_data_port
;
213 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_protocol
;
214 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_relative_path
;
216 /* String related to enum lttng_rotation_state */
217 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_ongoing
;
218 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_completed
;
219 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_expired
;
220 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_error
;
222 /* String related to enum lttng_trace_archive_location_relay_protocol_type */
223 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp
;
225 /* String related to add-context command */
226 LTTNG_HIDDEN
extern const char * const mi_lttng_element_context_symbol
;
228 /* Utility string function */
229 const char *mi_lttng_loglevel_string(int value
, enum lttng_domain_type domain
);
230 const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value
);
231 const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value
);
232 const char *mi_lttng_domaintype_string(enum lttng_domain_type value
);
233 const char *mi_lttng_buffertype_string(enum lttng_buffer_type value
);
234 const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value
);
235 const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
236 enum lttng_trace_archive_location_relay_protocol_type value
);
239 * Create an instance of a machine interface writer.
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.
244 * Returns an instance of a machine interface writer on success, NULL on
247 struct mi_writer
*mi_lttng_writer_create(int fd_output
, int mi_output_type
);
250 * Destroy an instance of a machine interface writer.
252 * writer An instance of a machine interface writer.
254 * Returns zero if the XML document could be closed cleanly. Negative values
257 int mi_lttng_writer_destroy(struct mi_writer
*writer
);
260 * Open a command tag and add it's name node.
262 * writer An instance of a machine interface writer.
263 * command The command name.
265 * Returns zero if the XML document could be closed cleanly.
266 * Negative values indicate an error.
268 int mi_lttng_writer_command_open(struct mi_writer
*writer
, const char *command
);
271 * Close a command tag.
273 * writer An instance of a machine interface writer.
275 * Returns zero if the XML document could be closed cleanly.
276 * Negative values indicate an error.
278 int mi_lttng_writer_command_close(struct mi_writer
*writer
);
281 * Open an element tag.
283 * writer An instance of a machine interface writer.
284 * element_name Element tag name.
286 * Returns zero if the XML document could be closed cleanly.
287 * Negative values indicate an error.
289 int mi_lttng_writer_open_element(struct mi_writer
*writer
,
290 const char *element_name
);
293 * Close the current element tag.
295 * writer An instance of a machine interface writer.
297 * Returns zero if the XML document could be closed cleanly.
298 * Negative values indicate an error.
300 int mi_lttng_writer_close_element(struct mi_writer
*writer
);
303 * Close multiple element.
305 * writer An instance of a machine interface writer.
306 * nb_element Number of elements.
308 * Returns zero if the XML document could be closed cleanly.
309 * Negative values indicate an error.
311 int mi_lttng_close_multi_element(struct mi_writer
*writer
,
312 unsigned int nb_element
);
315 * Write an element of type unsigned int.
317 * writer An instance of a machine interface writer.
318 * element_name Element name.
319 * value Unsigned int value of the element
321 * Returns zero if the element's value could be written.
322 * Negative values indicate an error.
324 int mi_lttng_writer_write_element_unsigned_int(struct mi_writer
*writer
,
325 const char *element_name
, uint64_t value
);
328 * Write an element of type signed int.
330 * writer An instance of a machine interface writer.
331 * element_name Element name.
332 * value Signed int value of the element.
334 * Returns zero if the element's value could be written.
335 * Negative values indicate an error.
337 int mi_lttng_writer_write_element_signed_int(struct mi_writer
*writer
,
338 const char *element_name
, int64_t value
);
341 * Write an element of type boolean.
343 * writer An instance of a machine interface writer.
344 * element_name Element name.
345 * value Boolean value of the element.
347 * Returns zero if the element's value could be written.
348 * Negative values indicate an error.
350 int mi_lttng_writer_write_element_bool(struct mi_writer
*writer
,
351 const char *element_name
, int value
);
354 * Write an element of type string.
356 * writer An instance of a machine interface writer.
357 * element_name Element name.
358 * value String value of the element.
360 * Returns zero if the element's value could be written.
361 * Negative values indicate an error.
363 int mi_lttng_writer_write_element_string(struct mi_writer
*writer
,
364 const char *element_name
, const char *value
);
367 * Machine interface of struct version.
369 * writer An instance of a machine interface writer.
370 * version Version struct.
371 * lttng_description String value of the version description.
372 * lttng_license String value of the version license.
374 * Returns zero if the element's value could be written.
375 * Negative values indicate an error.
377 int mi_lttng_version(struct mi_writer
*writer
, struct mi_lttng_version
*version
,
378 const char *lttng_description
, const char *lttng_license
);
381 * Machine interface: open a sessions element.
383 * writer An instance of a machine interface writer.
385 * Returns zero if the element's value could be written.
386 * Negative values indicate an error.
388 int mi_lttng_sessions_open(struct mi_writer
*writer
);
391 * Machine interface of struct session.
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.
398 * Use case: nested additional information on a session
399 * ex: domain,channel event.
401 * Returns zero if the element's value could be written.
402 * Negative values indicate an error.
404 int mi_lttng_session(struct mi_writer
*writer
,
405 struct lttng_session
*session
, int is_open
);
408 * Machine interface: open a domains element.
410 * writer An instance of a machine interface writer.
412 * Returns zero if the element's value could be written.
413 * Negative values indicate an error.
415 int mi_lttng_domains_open(struct mi_writer
*writer
);
418 * Machine interface of struct domain.
420 * writer An instance of a machine interface writer.
421 * domain An instance of a domain.
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
429 * Returns zero if the element's value could be written.
430 * Negative values indicate an error.
432 int mi_lttng_domain(struct mi_writer
*writer
,
433 struct lttng_domain
*domain
, int is_open
);
436 * Machine interface: open a channels element.
438 * writer An instance of a machine interface writer.
440 * Returns zero if the element's value could be written.
441 * Negative values indicate an error.
443 int mi_lttng_channels_open(struct mi_writer
*writer
);
446 * Machine interface of struct channel.
448 * writer An instance of a machine interface writer.
449 * channel An instance of a channel.
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.
457 * Returns zero if the element's value could be written.
458 * Negative values indicate an error.
460 int mi_lttng_channel(struct mi_writer
*writer
,
461 struct lttng_channel
*channel
, int is_open
);
464 * Machine interface of struct channel_attr.
466 * writer An instance of a machine interface writer.
467 * attr An instance of a channel_attr struct.
469 * Returns zero if the element's value could be written.
470 * Negative values indicate an error.
472 int mi_lttng_channel_attr(struct mi_writer
*writer
,
473 struct lttng_channel_attr
*attr
);
476 * Machine interface for event common attributes.
478 * writer An instance of a mi writer.
479 * event single trace event.
481 * The common attribute are:
488 * Returns zero if the element's value could be written.
489 * Negative values indicate an error.
491 int mi_lttng_event_common_attributes(struct mi_writer
*writer
,
492 struct lttng_event
*event
);
495 * Machine interface for kernel tracepoint event with a loglevel.
497 * writer An instance of a mi writer.
498 * event single trace event.
499 * domain Event's domain
501 * Returns zero if the element's value could be written.
502 * Negative values indicate an error.
504 int mi_lttng_event_tracepoint_loglevel(struct mi_writer
*writer
,
505 struct lttng_event
*event
, enum lttng_domain_type domain
);
508 * Machine interface for kernel tracepoint event with no loglevel.
510 * writer An instance of a mi writer.
511 * event single trace event.
513 * Returns zero if the element's value could be written.
514 * Negative values indicate an error.
516 int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer
*writer
,
517 struct lttng_event
*event
);
520 * Machine interface for kernel function and probe event.
522 * writer An instance of a mi writer.
523 * event single trace event.
525 * Returns zero if the element's value could be written.
526 * Negative values indicate an error.
528 int mi_lttng_event_function_probe(struct mi_writer
*writer
,
529 struct lttng_event
*event
);
532 * Machine interface for kernel function entry event.
534 * writer An instance of a mi writer.
535 * event single trace event.
537 * Returns zero if the element's value could be written.
538 * Negative values indicate an error.
540 int mi_lttng_event_function_entry(struct mi_writer
*writer
,
541 struct lttng_event
*event
);
544 * Machine interface: open an events element.
546 * writer An instance of a machine interface writer.
548 * Returns zero if the element's value could be written.
549 * Negative values indicate an error.
551 int mi_lttng_events_open(struct mi_writer
*writer
);
554 * Machine interface for printing an event.
555 * The trace event type currently supported are:
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
568 * domain Event's domain
570 * Returns zero if the element's value could be written.
571 * Negative values indicate an error.
573 int mi_lttng_event(struct mi_writer
*writer
, struct lttng_event
*event
,
574 int is_open
, enum lttng_domain_type domain
);
577 * Machine interface for struct lttng_event_field.
579 * writer An instance of a mi writer.
580 * field An event_field instance.
582 * Returns zero if the element's value could be written.
583 * Negative values indicate an error.
585 int mi_lttng_event_field(struct mi_writer
*writer
,
586 struct lttng_event_field
*field
);
589 * Machine interface: open a event_fields element.
591 * writer An instance of a machine interface writer.
593 * Returns zero if the element have be written.
594 * Negative values indicate an error.
596 int mi_lttng_event_fields_open(struct mi_writer
*writer
);
599 * Machine interface: open a trackers element.
601 * writer An instance of a machine interface writer.
603 * Returns zero if the element's value could be written.
604 * Negative values indicate an error.
606 int mi_lttng_trackers_open(struct mi_writer
*writer
);
609 * Machine interface: open a id tracker element.
611 * writer An instance of a machine interface writer.
613 * Returns zero if the element's value could be written.
614 * Negative values indicate an error.
616 * Note: A targets element is also opened for each tracker definition
618 int mi_lttng_id_tracker_open(
619 struct mi_writer
*writer
, enum lttng_tracker_type tracker_type
);
622 * Machine interface: open a PIDs element.
624 * writer An instance of a machine interface writer.
626 * Returns zero if the element's value could be written.
627 * Negative values indicate an error.
629 int mi_lttng_pids_open(struct mi_writer
*writer
);
632 * Machine interface: open a processes element.
634 * writer An instance of a machine interface writer.
636 * Returns zero if the element's value could be written.
637 * Negative values indicate an error.
639 int mi_lttng_processes_open(struct mi_writer
*writer
);
642 * Machine interface of a Process.
644 * writer An instance of a machine interface writer.
647 * is_open Defines whether or not the session element shall be closed.
648 * This should be used carefully and the client
649 * must close the pid element.
650 * Use case: nested addition information on a domain
653 * Returns zero if the element's value could be written.
654 * Negative values indicate an error.
656 int mi_lttng_process(struct mi_writer
*writer
, pid_t pid
, const char *name
,
660 * TODO: move pid of lttng list -u to process semantic on mi api bump
661 * Machine interface of a Process.
663 * writer An instance of a machine interface writer.
666 * is_open Defines whether or not the session element shall be closed.
667 * This should be used carefully and the client
668 * must close the pid element.
669 * Use case: nested addition information on a domain
672 * Returns zero if the element's value could be written.
673 * Negative values indicate an error.
675 int mi_lttng_pid(struct mi_writer
*writer
, pid_t pid
, const char *name
,
678 * Machine interface: open a targets element.
680 * writer An instance of a machine interface writer.
682 * Returns zero if the element's value could be written.
683 * Negative values indicate an error.
685 int mi_lttng_targets_open(struct mi_writer
*writer
);
688 * Machine interface for track/untrack an id_target
690 * writer An instance of a machine interface writer.
692 * Returns zero if the element's value could be written.
693 * Negative values indicate an error.
695 int mi_lttng_id_target(struct mi_writer
*writer
,
696 enum lttng_tracker_type tracker_type
,
697 const struct lttng_tracker_id
*id
,
701 * Machine interface of a context.
703 * writer An instance of a machine interface writer
705 * context An instance of a lttng_event_context
707 * is_open Define if we close the context element
708 * This should be used carefully and the client
709 * need to close the context element.
710 * Returns zero if the element's value could be written.
711 * Negative values indicate an error.
713 int mi_lttng_context(struct mi_writer
*writer
,
714 struct lttng_event_context
*context
, int is_open
);
717 * Machine interface of a perf_counter_context.
719 * writer An instance of a machine interface writer
721 * contest An instance of a lttng_event_perf_counter_ctx
723 * Returns zero if the element's value could be written.
724 * Negative values indicate an error.
726 int mi_lttng_perf_counter_context(struct mi_writer
*writer
,
727 struct lttng_event_perf_counter_ctx
*perf_context
);
730 * Machine interface of the snapshot list_output.
731 * It specifies the session for which we are listing snapshots,
732 * and it opens a snapshots element to list a sequence
735 * writer An instance of a machine interface writer.
737 * session_name: Snapshot output for session "session_name".
739 * Note: The client has to close the session and the snapshots elements after
740 * having listed every lttng_snapshot_output.
742 * Returns zero if the element's value could be written.
743 * Negative values indicate an error.
745 int mi_lttng_snapshot_output_session_name(struct mi_writer
*writer
,
746 const char *session_name
);
749 * Machine interface of the snapshot output.
750 * The machine interface serializes the following attributes:
751 * - id: ID of the snapshot output.
752 * - name: Name of the output.
753 * - data_url : Destination of the output.
754 * - ctrl_url: Destination of the output.
755 * - max_size: total size of all stream combined.
757 * writer An instance of a machine interface writer.
759 * output: A list of snapshot_output.
761 * Returns zero if the element's value could be written.
762 * Negative values indicate an error.
764 int mi_lttng_snapshot_list_output(struct mi_writer
*writer
,
765 struct lttng_snapshot_output
*output
);
768 * Machine interface of the output of the command snapshot del output
769 * when deleting a snapshot either by id or by name.
770 * If the snapshot was found and successfully deleted using its id,
771 * it return the id of the snapshot and the current session name on which it
774 * Otherwise, it do the same process with the name of the snapshot, if the
775 * snapshot output id is undefined.
777 * writer An instance of a machine interface writer.
779 * id: ID of the snapshot output.
781 * name: Name of the snapshot.
783 * current_session_name: Session to which the snapshot belongs.
785 * Returns zero if the element's value could be written.
786 * Negative values indicate an error.
788 int mi_lttng_snapshot_del_output(struct mi_writer
*writer
, int id
,
789 const char *name
, const char *current_session_name
);
792 * Machine interface of the output of the command snapshot add output
793 * when adding a snapshot from a user URL.
795 * If the snapshot was successfully added, the machine interface lists
797 * - id: ID of the newly add snapshot output.
798 * - current_session_name: Name of the session to which the output was added.
799 * - ctrl_url: Destination of the output.
800 * - max_size: total size of all stream combined.
802 * writer An instance of a machine interface writer.
804 * current_session_name: Session to which the snapshot belongs.
808 * output: iterator over a lttng_snapshot_output_list which contain
809 * the snapshot output informations.
811 * Returns zero if the element's value could be written.
812 * Negative values indicate an error.
814 int mi_lttng_snapshot_add_output(struct mi_writer
*writer
,
815 const char *current_session_name
, const char *n_ptr
,
816 struct lttng_snapshot_output
*output
);
819 * Machine interface of the output of the command snapshot
820 * record from a URL (if given).
822 * If the snapshot is successfully recorded from a url, the machine interface
823 * output the following information:
824 * - url: Destination of the output stored in the snapshot.
826 * Otherwise, the machine interface output the data and ctrl url received
827 * from the command-line.
829 * writer An instance of a machine interface writer.
831 * current_session_name: Snapshot record for session "current_session_name".
833 * ctrl_url, data_url: Destination of the output receive from the command-line.
835 * Returns zero if the element's value could be written.
836 * Negative values indicate an error.
838 int mi_lttng_snapshot_record(struct mi_writer
*writer
,
839 const char *current_session_name
, const char *url
,
840 const char *cmdline_ctrl_url
, const char *cmdline_data_url
);
843 * Machine interface representation of a session rotation schedule.
845 * The machine interface serializes the provided schedule as one of the choices
846 * from 'rotation_schedule_type'.
848 * writer: An instance of a machine interface writer.
850 * schedule: An lttng rotation schedule descriptor object.
852 * Returns zero if the element's value could be written.
853 * Negative values indicate an error.
855 int mi_lttng_rotation_schedule(struct mi_writer
*writer
,
856 const struct lttng_rotation_schedule
*schedule
);
859 * Machine interface of a session rotation schedule result.
860 * This is an element that is part of the output of the enable-rotation and
861 * disable-rotation commands.
863 * The machine interface provides the following information:
864 * - schedule: the session rotation schedule descriptor.
865 * - success: whether the sub-command succeeded.
867 * writer: An instance of a machine interface writer.
869 * schedule: An lttng rotation schedule descriptor object.
871 * success: Whether the sub-command suceeded.
873 * Returns zero if the element's value could be written.
874 * Negative values indicate an error.
876 int mi_lttng_rotation_schedule_result(struct mi_writer
*writer
,
877 const struct lttng_rotation_schedule
*schedule
,
881 * Machine interface of a session rotation result.
882 * This is an element that is part of the output of the rotate command.
884 * The machine interface provides the following information:
885 * - session_name: the session to be rotated.
886 * - state: the session rotation state.
887 * - location: the location of the completed chunk archive.
889 * writer: An instance of a machine interface writer.
891 * session_name: The session to which the rotate command applies.
893 * location: A location descriptor object.
895 * success: Whether the sub-command suceeded.
897 * Returns zero if the element's value could be written.
898 * Negative values indicate an error.
900 int mi_lttng_rotate(struct mi_writer
*writer
,
901 const char *session_name
,
902 enum lttng_rotation_state rotation_state
,
903 const struct lttng_trace_archive_location
*location
);
905 #endif /* _MI_LTTNG_H */