2 * Copyright (C) 2014 EfficiOS Inc.
3 * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 * SPDX-License-Identifier: LGPL-2.1-only
14 #include <common/error.h>
15 #include <common/macros.h>
16 #include <common/config/session-config.h>
17 #include <lttng/lttng.h>
19 /* Don't want to reference snapshot-internal.h here */
20 struct lttng_snapshot_output
;
22 /* Instance of a machine interface writer. */
24 struct config_writer
*writer
;
25 enum lttng_mi_output_type type
;
29 * Version information for the machine interface.
31 struct mi_lttng_version
{
32 char version
[LTTNG_NAME_MAX
]; /* Version number of package */
33 uint32_t version_major
; /* LTTng-Tools major version number */
34 uint32_t version_minor
; /* LTTng-Tools minor version number */
35 uint32_t version_patchlevel
; /* LTTng-Tools patchlevel version number */
36 char version_commit
[LTTNG_NAME_MAX
]; /* Commit hash of the current version */
37 char version_name
[LTTNG_NAME_MAX
];
38 char package_url
[LTTNG_NAME_MAX
]; /* Define to the home page for this package. */
41 /* Strings related to command */
42 extern const char * const mi_lttng_element_command
;
43 extern const char * const mi_lttng_element_command_action
;
44 extern const char * const mi_lttng_element_command_add_context
;
45 extern const char * const mi_lttng_element_command_create
;
46 extern const char * const mi_lttng_element_command_destroy
;
47 extern const char * const mi_lttng_element_command_disable_channel
;
48 extern const char * const mi_lttng_element_command_disable_event
;
49 extern const char * const mi_lttng_element_command_enable_channels
;
50 extern const char * const mi_lttng_element_command_enable_event
;
51 extern const char * const mi_lttng_element_command_list
;
52 extern const char * const mi_lttng_element_command_load
;
53 extern const char * const mi_lttng_element_command_metadata
;
54 extern const char * const mi_lttng_element_command_metadata_action
;
55 extern const char * const mi_lttng_element_command_regenerate
;
56 extern const char * const mi_lttng_element_command_regenerate_action
;
57 extern const char * const mi_lttng_element_command_name
;
58 extern const char * const mi_lttng_element_command_output
;
59 extern const char * const mi_lttng_element_command_save
;
60 extern const char * const mi_lttng_element_command_set_session
;
61 extern const char * const mi_lttng_element_command_snapshot
;
62 extern const char * const mi_lttng_element_command_snapshot_add
;
63 extern const char * const mi_lttng_element_command_snapshot_del
;
64 extern const char * const mi_lttng_element_command_snapshot_list
;
65 extern const char * const mi_lttng_element_command_snapshot_record
;
66 extern const char * const mi_lttng_element_command_start
;
67 extern const char * const mi_lttng_element_command_stop
;
68 extern const char * const mi_lttng_element_command_success
;
69 extern const char * const mi_lttng_element_command_track
;
70 extern const char * const mi_lttng_element_command_untrack
;
71 extern const char * const mi_lttng_element_command_version
;
72 extern const char * const mi_lttng_element_command_rotate
;
73 extern const char * const mi_lttng_element_command_enable_rotation
;
74 extern const char * const mi_lttng_element_command_disable_rotation
;
75 extern const char * const mi_lttng_element_command_clear
;
77 /* Strings related to version command */
78 extern const char * const mi_lttng_element_version
;
79 extern const char * const mi_lttng_element_version_commit
;
80 extern const char * const mi_lttng_element_version_description
;
81 extern const char * const mi_lttng_element_version_license
;
82 extern const char * const mi_lttng_element_version_major
;
83 extern const char * const mi_lttng_element_version_minor
;
84 extern const char * const mi_lttng_element_version_patch_level
;
85 extern const char * const mi_lttng_element_version_str
;
86 extern const char * const mi_lttng_element_version_web
;
88 /* String related to a lttng_event_field */
89 extern const char * const mi_lttng_element_event_field
;
90 extern const char * const mi_lttng_element_event_fields
;
92 /* String related to lttng_event_perf_counter_ctx */
93 extern const char * const mi_lttng_element_perf_counter_context
;
95 /* Strings related to pid */
96 extern const char * const mi_lttng_element_pid_id
;
98 /* Strings related to save command */
99 extern const char * const mi_lttng_element_save
;
101 /* Strings related to load command */
102 extern const char * const mi_lttng_element_load
;
103 LTTNG_HIDDEN
extern const char * const mi_lttng_element_load_overrides
;
104 LTTNG_HIDDEN
extern const char * const mi_lttng_element_load_override_url
;
106 /* General element of mi_lttng */
107 extern const char * const mi_lttng_element_empty
;
108 extern const char * const mi_lttng_element_id
;
109 extern const char * const mi_lttng_element_nowrite
;
110 extern const char * const mi_lttng_element_success
;
111 extern const char * const mi_lttng_element_type_enum
;
112 extern const char * const mi_lttng_element_type_float
;
113 extern const char * const mi_lttng_element_type_integer
;
114 extern const char * const mi_lttng_element_type_other
;
115 extern const char * const mi_lttng_element_type_string
;
117 /* String related to loglevel */
118 extern const char * const mi_lttng_loglevel_str_alert
;
119 extern const char * const mi_lttng_loglevel_str_crit
;
120 extern const char * const mi_lttng_loglevel_str_debug
;
121 extern const char * const mi_lttng_loglevel_str_debug_function
;
122 extern const char * const mi_lttng_loglevel_str_debug_line
;
123 extern const char * const mi_lttng_loglevel_str_debug_module
;
124 extern const char * const mi_lttng_loglevel_str_debug_process
;
125 extern const char * const mi_lttng_loglevel_str_debug_program
;
126 extern const char * const mi_lttng_loglevel_str_debug_system
;
127 extern const char * const mi_lttng_loglevel_str_debug_unit
;
128 extern const char * const mi_lttng_loglevel_str_emerg
;
129 extern const char * const mi_lttng_loglevel_str_err
;
130 extern const char * const mi_lttng_loglevel_str_info
;
131 extern const char * const mi_lttng_loglevel_str_notice
;
132 extern const char * const mi_lttng_loglevel_str_unknown
;
133 extern const char * const mi_lttng_loglevel_str_warning
;
135 /* String related to loglevel JUL */
136 extern const char * const mi_lttng_loglevel_str_jul_all
;
137 extern const char * const mi_lttng_loglevel_str_jul_config
;
138 extern const char * const mi_lttng_loglevel_str_jul_fine
;
139 extern const char * const mi_lttng_loglevel_str_jul_finer
;
140 extern const char * const mi_lttng_loglevel_str_jul_finest
;
141 extern const char * const mi_lttng_loglevel_str_jul_info
;
142 extern const char * const mi_lttng_loglevel_str_jul_off
;
143 extern const char * const mi_lttng_loglevel_str_jul_severe
;
144 extern const char * const mi_lttng_loglevel_str_jul_warning
;
146 /* String related to loglevel Log4j */
147 extern const char * const mi_lttng_loglevel_str_log4j_off
;
148 extern const char * const mi_lttng_loglevel_str_log4j_fatal
;
149 extern const char * const mi_lttng_loglevel_str_log4j_error
;
150 extern const char * const mi_lttng_loglevel_str_log4j_warn
;
151 extern const char * const mi_lttng_loglevel_str_log4j_info
;
152 extern const char * const mi_lttng_loglevel_str_log4j_debug
;
153 extern const char * const mi_lttng_loglevel_str_log4j_trace
;
154 extern const char * const mi_lttng_loglevel_str_log4j_all
;
156 /* String related to loglevel Python */
157 extern const char * const mi_lttng_loglevel_str_python_critical
;
158 extern const char * const mi_lttng_loglevel_str_python_error
;
159 extern const char * const mi_lttng_loglevel_str_python_warning
;
160 extern const char * const mi_lttng_loglevel_str_python_info
;
161 extern const char * const mi_lttng_loglevel_str_python_debug
;
162 extern const char * const mi_lttng_loglevel_str_python_notset
;
164 /* String related to loglevel type */
165 extern const char * const mi_lttng_loglevel_type_all
;
166 extern const char * const mi_lttng_loglevel_type_range
;
167 extern const char * const mi_lttng_loglevel_type_single
;
168 extern const char * const mi_lttng_loglevel_type_unknown
;
170 /* String related to a lttng_snapshot */
171 extern const char * const mi_lttng_element_snapshot_ctrl_url
;
172 extern const char * const mi_lttng_element_snapshot_data_url
;
173 extern const char * const mi_lttng_element_snapshot_max_size
;
174 extern const char * const mi_lttng_element_snapshot_n_ptr
;
175 extern const char * const mi_lttng_element_snapshot_session_name
;
176 extern const char * const mi_lttng_element_snapshots
;
178 /* String related to track/untrack command */
179 extern const char * const mi_lttng_element_track_untrack_all_wildcard
;
181 LTTNG_HIDDEN
extern const char * const mi_lttng_element_session_name
;
183 /* String related to rotate command */
184 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation
;
185 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotate_status
;
186 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule
;
187 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedules
;
188 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_periodic
;
189 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us
;
190 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_size_threshold
;
191 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes
;
192 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_result
;
193 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_results
;
194 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_state
;
195 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location
;
196 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_local
;
197 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_local_absolute_path
;
198 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay
;
199 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_host
;
200 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_control_port
;
201 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_data_port
;
202 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_protocol
;
203 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_relative_path
;
205 /* String related to enum lttng_rotation_state */
206 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_ongoing
;
207 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_completed
;
208 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_expired
;
209 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_error
;
211 /* String related to enum lttng_trace_archive_location_relay_protocol_type */
212 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp
;
214 /* String related to add-context command */
215 LTTNG_HIDDEN
extern const char * const mi_lttng_element_context_symbol
;
217 /* Utility string function */
218 const char *mi_lttng_loglevel_string(int value
, enum lttng_domain_type domain
);
219 const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value
);
220 const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value
);
221 const char *mi_lttng_domaintype_string(enum lttng_domain_type value
);
222 const char *mi_lttng_buffertype_string(enum lttng_buffer_type value
);
223 const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value
);
224 const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
225 enum lttng_trace_archive_location_relay_protocol_type value
);
228 * Create an instance of a machine interface writer.
230 * fd_output File to which the XML content must be written. The file will be
231 * closed once the mi_writer has been destroyed.
233 * Returns an instance of a machine interface writer on success, NULL on
236 struct mi_writer
*mi_lttng_writer_create(int fd_output
, int mi_output_type
);
239 * Destroy an instance of a machine interface writer.
241 * writer An instance of a machine interface writer.
243 * Returns zero if the XML document could be closed cleanly. Negative values
246 int mi_lttng_writer_destroy(struct mi_writer
*writer
);
249 * Open a command tag and add it's name node.
251 * writer An instance of a machine interface writer.
252 * command The command name.
254 * Returns zero if the XML document could be closed cleanly.
255 * Negative values indicate an error.
257 int mi_lttng_writer_command_open(struct mi_writer
*writer
, const char *command
);
260 * Close a command tag.
262 * writer An instance of a machine interface writer.
264 * Returns zero if the XML document could be closed cleanly.
265 * Negative values indicate an error.
267 int mi_lttng_writer_command_close(struct mi_writer
*writer
);
270 * Open an element tag.
272 * writer An instance of a machine interface writer.
273 * element_name Element tag name.
275 * Returns zero if the XML document could be closed cleanly.
276 * Negative values indicate an error.
278 int mi_lttng_writer_open_element(struct mi_writer
*writer
,
279 const char *element_name
);
282 * Close the current element tag.
284 * writer An instance of a machine interface writer.
286 * Returns zero if the XML document could be closed cleanly.
287 * Negative values indicate an error.
289 int mi_lttng_writer_close_element(struct mi_writer
*writer
);
292 * Close multiple element.
294 * writer An instance of a machine interface writer.
295 * nb_element Number of elements.
297 * Returns zero if the XML document could be closed cleanly.
298 * Negative values indicate an error.
300 int mi_lttng_close_multi_element(struct mi_writer
*writer
,
301 unsigned int nb_element
);
304 * Write an element of type unsigned int.
306 * writer An instance of a machine interface writer.
307 * element_name Element name.
308 * value Unsigned int value of the element
310 * Returns zero if the element's value could be written.
311 * Negative values indicate an error.
313 int mi_lttng_writer_write_element_unsigned_int(struct mi_writer
*writer
,
314 const char *element_name
, uint64_t value
);
317 * Write an element of type signed int.
319 * writer An instance of a machine interface writer.
320 * element_name Element name.
321 * value Signed int value of the element.
323 * Returns zero if the element's value could be written.
324 * Negative values indicate an error.
326 int mi_lttng_writer_write_element_signed_int(struct mi_writer
*writer
,
327 const char *element_name
, int64_t value
);
330 * Write an element of type boolean.
332 * writer An instance of a machine interface writer.
333 * element_name Element name.
334 * value Boolean value of the element.
336 * Returns zero if the element's value could be written.
337 * Negative values indicate an error.
339 int mi_lttng_writer_write_element_bool(struct mi_writer
*writer
,
340 const char *element_name
, int value
);
343 * Write an element of type string.
345 * writer An instance of a machine interface writer.
346 * element_name Element name.
347 * value String value of the element.
349 * Returns zero if the element's value could be written.
350 * Negative values indicate an error.
352 int mi_lttng_writer_write_element_string(struct mi_writer
*writer
,
353 const char *element_name
, const char *value
);
356 * Machine interface of struct version.
358 * writer An instance of a machine interface writer.
359 * version Version struct.
360 * lttng_description String value of the version description.
361 * lttng_license String value of the version license.
363 * Returns zero if the element's value could be written.
364 * Negative values indicate an error.
366 int mi_lttng_version(struct mi_writer
*writer
, struct mi_lttng_version
*version
,
367 const char *lttng_description
, const char *lttng_license
);
370 * Machine interface: open a sessions element.
372 * writer An instance of a machine interface writer.
374 * Returns zero if the element's value could be written.
375 * Negative values indicate an error.
377 int mi_lttng_sessions_open(struct mi_writer
*writer
);
380 * Machine interface of struct session.
382 * writer An instance of a machine interface writer.
383 * session An instance of a session.
384 * is_open Defines whether or not the session element shall be closed.
385 * This should be used carefully and the client
386 * must close the session element.
387 * Use case: nested additional information on a session
388 * ex: domain,channel event.
390 * Returns zero if the element's value could be written.
391 * Negative values indicate an error.
393 int mi_lttng_session(struct mi_writer
*writer
,
394 struct lttng_session
*session
, int is_open
);
397 * Machine interface: open a domains element.
399 * writer An instance of a machine interface writer.
401 * Returns zero if the element's value could be written.
402 * Negative values indicate an error.
404 int mi_lttng_domains_open(struct mi_writer
*writer
);
407 * Machine interface of struct domain.
409 * writer An instance of a machine interface writer.
410 * domain An instance of a domain.
412 * is_open Defines whether or not the session element shall be closed.
413 * This should be used carefully and the client
414 * must close the domain element.
415 * Use case: nested addition information on a domain
418 * Returns zero if the element's value could be written.
419 * Negative values indicate an error.
421 int mi_lttng_domain(struct mi_writer
*writer
,
422 struct lttng_domain
*domain
, int is_open
);
425 * Machine interface: open a channels element.
427 * writer An instance of a machine interface writer.
429 * Returns zero if the element's value could be written.
430 * Negative values indicate an error.
432 int mi_lttng_channels_open(struct mi_writer
*writer
);
435 * Machine interface of struct channel.
437 * writer An instance of a machine interface writer.
438 * channel An instance of a channel.
440 * is_open Defines whether or not the session element shall be closed.
441 * This should be used carefully and the client
442 * must close the channel element.
443 * Use case: nested addition information on a channel.
446 * Returns zero if the element's value could be written.
447 * Negative values indicate an error.
449 int mi_lttng_channel(struct mi_writer
*writer
,
450 struct lttng_channel
*channel
, int is_open
);
453 * Machine interface of struct channel_attr.
455 * writer An instance of a machine interface writer.
456 * attr An instance of a channel_attr struct.
458 * Returns zero if the element's value could be written.
459 * Negative values indicate an error.
461 int mi_lttng_channel_attr(struct mi_writer
*writer
,
462 struct lttng_channel_attr
*attr
);
465 * Machine interface for event common attributes.
467 * writer An instance of a mi writer.
468 * event single trace event.
470 * The common attribute are:
477 * Returns zero if the element's value could be written.
478 * Negative values indicate an error.
480 int mi_lttng_event_common_attributes(struct mi_writer
*writer
,
481 struct lttng_event
*event
);
484 * Machine interface for kernel tracepoint event with a loglevel.
486 * writer An instance of a mi writer.
487 * event single trace event.
488 * domain Event's domain
490 * Returns zero if the element's value could be written.
491 * Negative values indicate an error.
493 int mi_lttng_event_tracepoint_loglevel(struct mi_writer
*writer
,
494 struct lttng_event
*event
, enum lttng_domain_type domain
);
497 * Machine interface for kernel tracepoint event with no loglevel.
499 * writer An instance of a mi writer.
500 * event single trace event.
502 * Returns zero if the element's value could be written.
503 * Negative values indicate an error.
505 int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer
*writer
,
506 struct lttng_event
*event
);
509 * Machine interface for kernel function and probe event.
511 * writer An instance of a mi writer.
512 * event single trace event.
514 * Returns zero if the element's value could be written.
515 * Negative values indicate an error.
517 int mi_lttng_event_function_probe(struct mi_writer
*writer
,
518 struct lttng_event
*event
);
521 * Machine interface for kernel function entry event.
523 * writer An instance of a mi writer.
524 * event single trace event.
526 * Returns zero if the element's value could be written.
527 * Negative values indicate an error.
529 int mi_lttng_event_function_entry(struct mi_writer
*writer
,
530 struct lttng_event
*event
);
533 * Machine interface: open an events element.
535 * writer An instance of a machine interface writer.
537 * Returns zero if the element's value could be written.
538 * Negative values indicate an error.
540 int mi_lttng_events_open(struct mi_writer
*writer
);
543 * Machine interface for printing an event.
544 * The trace event type currently supported are:
551 * writer An instance of a mi writer.
552 * event single trace event.
553 * is_open Defines whether or not the session element shall be closed.
554 * This should be used carefully and the client
555 * must close the event element.
556 * Use case: nested additional information
557 * domain Event's domain
559 * Returns zero if the element's value could be written.
560 * Negative values indicate an error.
562 int mi_lttng_event(struct mi_writer
*writer
, struct lttng_event
*event
,
563 int is_open
, enum lttng_domain_type domain
);
566 * Machine interface for struct lttng_event_field.
568 * writer An instance of a mi writer.
569 * field An event_field instance.
571 * Returns zero if the element's value could be written.
572 * Negative values indicate an error.
574 int mi_lttng_event_field(struct mi_writer
*writer
,
575 struct lttng_event_field
*field
);
578 * Machine interface: open a event_fields element.
580 * writer An instance of a machine interface writer.
582 * Returns zero if the element have be written.
583 * Negative values indicate an error.
585 int mi_lttng_event_fields_open(struct mi_writer
*writer
);
588 * Machine interface: open a trackers element.
590 * writer An instance of a machine interface writer.
592 * Returns zero if the element's value could be written.
593 * Negative values indicate an error.
595 int mi_lttng_trackers_open(struct mi_writer
*writer
);
598 * Machine interface: open a process attribute tracker element.
600 * writer An instance of a machine interface writer.
602 * Returns zero if the element's value could be written.
603 * Negative values indicate an error.
605 * Note: A targets element is also opened for each tracker definition
607 int mi_lttng_process_attribute_tracker_open(
608 struct mi_writer
*writer
, enum lttng_process_attr process_attr
);
611 * Machine interface: open a PIDs element.
613 * writer An instance of a machine interface writer.
615 * Returns zero if the element's value could be written.
616 * Negative values indicate an error.
618 int mi_lttng_pids_open(struct mi_writer
*writer
);
621 * Machine interface: open a processes element.
623 * writer An instance of a machine interface writer.
625 * Returns zero if the element's value could be written.
626 * Negative values indicate an error.
628 int mi_lttng_processes_open(struct mi_writer
*writer
);
631 * Machine interface of a Process.
633 * writer An instance of a machine interface writer.
636 * is_open Defines whether or not the session element shall be closed.
637 * This should be used carefully and the client
638 * must close the pid element.
639 * Use case: nested addition information on a domain
642 * Returns zero if the element's value could be written.
643 * Negative values indicate an error.
645 int mi_lttng_process(struct mi_writer
*writer
, pid_t pid
, const char *name
,
649 * TODO: move pid of lttng list -u to process semantic on mi api bump
650 * Machine interface of a Process.
652 * writer An instance of a machine interface writer.
655 * is_open Defines whether or not the session element shall be closed.
656 * This should be used carefully and the client
657 * must close the pid element.
658 * Use case: nested addition information on a domain
661 * Returns zero if the element's value could be written.
662 * Negative values indicate an error.
664 int mi_lttng_pid(struct mi_writer
*writer
, pid_t pid
, const char *name
,
668 * Machine interface: open a process attribute values element.
670 * writer An instance of a machine interface writer.
672 * Returns zero if the element's value could be written.
673 * Negative values indicate an error.
675 int mi_lttng_process_attr_values_open(struct mi_writer
*writer
);
678 * Machine interface for track/untrack of all process attribute values.
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_all_process_attribute_value(struct mi_writer
*writer
,
686 enum lttng_process_attr process_attr
,
690 * Machine interface for track/untrack of an integral process attribute value.
692 * writer An instance of a machine interface writer.
694 * Returns zero if the element's value could be written.
695 * Negative values indicate an error.
697 int mi_lttng_integral_process_attribute_value(struct mi_writer
*writer
,
698 enum lttng_process_attr process_attr
,
703 * Machine interface for track/untrack of a string process attribute value.
705 * writer An instance of a machine interface writer.
707 * Returns zero if the element's value could be written.
708 * Negative values indicate an error.
710 int mi_lttng_string_process_attribute_value(struct mi_writer
*writer
,
711 enum lttng_process_attr process_attr
,
716 * Machine interface of a context.
718 * writer An instance of a machine interface writer
720 * context An instance of a lttng_event_context
722 * is_open Define if we close the context element
723 * This should be used carefully and the client
724 * need to close the context element.
725 * Returns zero if the element's value could be written.
726 * Negative values indicate an error.
728 int mi_lttng_context(struct mi_writer
*writer
,
729 struct lttng_event_context
*context
, int is_open
);
732 * Machine interface of a perf_counter_context.
734 * writer An instance of a machine interface writer
736 * contest An instance of a lttng_event_perf_counter_ctx
738 * Returns zero if the element's value could be written.
739 * Negative values indicate an error.
741 int mi_lttng_perf_counter_context(struct mi_writer
*writer
,
742 struct lttng_event_perf_counter_ctx
*perf_context
);
745 * Machine interface of the snapshot list_output.
746 * It specifies the session for which we are listing snapshots,
747 * and it opens a snapshots element to list a sequence
750 * writer An instance of a machine interface writer.
752 * session_name: Snapshot output for session "session_name".
754 * Note: The client has to close the session and the snapshots elements after
755 * having listed every lttng_snapshot_output.
757 * Returns zero if the element's value could be written.
758 * Negative values indicate an error.
760 int mi_lttng_snapshot_output_session_name(struct mi_writer
*writer
,
761 const char *session_name
);
764 * Machine interface of the snapshot output.
765 * The machine interface serializes the following attributes:
766 * - id: ID of the snapshot output.
767 * - name: Name of the output.
768 * - data_url : Destination of the output.
769 * - ctrl_url: Destination of the output.
770 * - max_size: total size of all stream combined.
772 * writer An instance of a machine interface writer.
774 * output: A list of snapshot_output.
776 * Returns zero if the element's value could be written.
777 * Negative values indicate an error.
779 int mi_lttng_snapshot_list_output(struct mi_writer
*writer
,
780 struct lttng_snapshot_output
*output
);
783 * Machine interface of the output of the command snapshot del output
784 * when deleting a snapshot either by id or by name.
785 * If the snapshot was found and successfully deleted using its id,
786 * it return the id of the snapshot and the current session name on which it
789 * Otherwise, it do the same process with the name of the snapshot, if the
790 * snapshot output id is undefined.
792 * writer An instance of a machine interface writer.
794 * id: ID of the snapshot output.
796 * name: Name of the snapshot.
798 * current_session_name: Session to which the snapshot belongs.
800 * Returns zero if the element's value could be written.
801 * Negative values indicate an error.
803 int mi_lttng_snapshot_del_output(struct mi_writer
*writer
, int id
,
804 const char *name
, const char *current_session_name
);
807 * Machine interface of the output of the command snapshot add output
808 * when adding a snapshot from a user URL.
810 * If the snapshot was successfully added, the machine interface lists
812 * - id: ID of the newly add snapshot output.
813 * - current_session_name: Name of the session to which the output was added.
814 * - ctrl_url: Destination of the output.
815 * - max_size: total size of all stream combined.
817 * writer An instance of a machine interface writer.
819 * current_session_name: Session to which the snapshot belongs.
823 * output: iterator over a lttng_snapshot_output_list which contain
824 * the snapshot output informations.
826 * Returns zero if the element's value could be written.
827 * Negative values indicate an error.
829 int mi_lttng_snapshot_add_output(struct mi_writer
*writer
,
830 const char *current_session_name
, const char *n_ptr
,
831 struct lttng_snapshot_output
*output
);
834 * Machine interface of the output of the command snapshot
835 * record from a URL (if given).
837 * If the snapshot is successfully recorded from a url, the machine interface
838 * output the following information:
839 * - url: Destination of the output stored in the snapshot.
841 * Otherwise, the machine interface output the data and ctrl url received
842 * from the command-line.
844 * writer An instance of a machine interface writer.
846 * current_session_name: Snapshot record for session "current_session_name".
848 * ctrl_url, data_url: Destination of the output receive from the command-line.
850 * Returns zero if the element's value could be written.
851 * Negative values indicate an error.
853 int mi_lttng_snapshot_record(struct mi_writer
*writer
,
854 const char *current_session_name
, const char *url
,
855 const char *cmdline_ctrl_url
, const char *cmdline_data_url
);
858 * Machine interface representation of a session rotation schedule.
860 * The machine interface serializes the provided schedule as one of the choices
861 * from 'rotation_schedule_type'.
863 * writer: An instance of a machine interface writer.
865 * schedule: An lttng rotation schedule descriptor object.
867 * Returns zero if the element's value could be written.
868 * Negative values indicate an error.
870 int mi_lttng_rotation_schedule(struct mi_writer
*writer
,
871 const struct lttng_rotation_schedule
*schedule
);
874 * Machine interface of a session rotation schedule result.
875 * This is an element that is part of the output of the enable-rotation and
876 * disable-rotation commands.
878 * The machine interface provides the following information:
879 * - schedule: the session rotation schedule descriptor.
880 * - success: whether the sub-command succeeded.
882 * writer: An instance of a machine interface writer.
884 * schedule: An lttng rotation schedule descriptor object.
886 * success: Whether the sub-command suceeded.
888 * Returns zero if the element's value could be written.
889 * Negative values indicate an error.
891 int mi_lttng_rotation_schedule_result(struct mi_writer
*writer
,
892 const struct lttng_rotation_schedule
*schedule
,
896 * Machine interface of a session rotation result.
897 * This is an element that is part of the output of the rotate command.
899 * The machine interface provides the following information:
900 * - session_name: the session to be rotated.
901 * - state: the session rotation state.
902 * - location: the location of the completed chunk archive.
904 * writer: An instance of a machine interface writer.
906 * session_name: The session to which the rotate command applies.
908 * location: A location descriptor object.
910 * success: Whether the sub-command suceeded.
912 * Returns zero if the element's value could be written.
913 * Negative values indicate an error.
915 int mi_lttng_rotate(struct mi_writer
*writer
,
916 const char *session_name
,
917 enum lttng_rotation_state rotation_state
,
918 const struct lttng_trace_archive_location
*location
);
920 #endif /* _MI_LTTNG_H */