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
12 #include <common/config/session-config.hpp>
13 #include <common/error.hpp>
14 #include <common/macros.hpp>
16 #include <lttng/lttng.h>
20 /* Don't want to reference snapshot-internal.h here */
21 struct lttng_snapshot_output;
23 /* Instance of a machine interface writer. */
25 struct config_writer *writer;
26 enum lttng_mi_output_type type;
30 * Version information for the machine interface.
32 struct mi_lttng_version_data {
33 char version[LTTNG_NAME_MAX]; /* Version number of package */
34 uint32_t version_major; /* LTTng-Tools major version number */
35 uint32_t version_minor; /* LTTng-Tools minor version number */
36 uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */
37 char version_commit[LTTNG_NAME_MAX]; /* Commit hash of the current version */
38 char version_name[LTTNG_NAME_MAX];
39 char package_url[LTTNG_NAME_MAX]; /* Define to the home page for this package. */
42 /* Error query callbacks. */
43 using mi_lttng_error_query_trigger_cb = enum lttng_error_code (*)(
44 const struct lttng_trigger *, struct lttng_error_query_results **);
45 using mi_lttng_error_query_condition_cb = enum lttng_error_code (*)(
46 const struct lttng_trigger *, struct lttng_error_query_results **);
47 using mi_lttng_error_query_action_cb =
48 enum lttng_error_code (*)(const struct lttng_trigger *,
49 const struct lttng_action_path *,
50 struct lttng_error_query_results **);
52 struct mi_lttng_error_query_callbacks {
53 mi_lttng_error_query_trigger_cb trigger_cb;
54 mi_lttng_error_query_condition_cb condition_cb;
55 mi_lttng_error_query_action_cb action_cb;
58 /* Strings related to command */
59 LTTNG_EXPORT extern const char *const mi_lttng_element_command;
60 LTTNG_EXPORT extern const char *const mi_lttng_element_command_action;
61 LTTNG_EXPORT extern const char *const mi_lttng_element_command_add_context;
62 extern const char *const mi_lttng_element_command_add_trigger;
63 LTTNG_EXPORT extern const char *const mi_lttng_element_command_create;
64 LTTNG_EXPORT extern const char *const mi_lttng_element_command_destroy;
65 LTTNG_EXPORT extern const char *const mi_lttng_element_command_disable_channel;
66 LTTNG_EXPORT extern const char *const mi_lttng_element_command_disable_event;
67 LTTNG_EXPORT extern const char *const mi_lttng_element_command_enable_channels;
68 LTTNG_EXPORT extern const char *const mi_lttng_element_command_enable_event;
69 LTTNG_EXPORT extern const char *const mi_lttng_element_command_list;
70 extern const char *const mi_lttng_element_command_list_trigger;
71 LTTNG_EXPORT extern const char *const mi_lttng_element_command_load;
72 extern const char *const mi_lttng_element_command_metadata;
73 extern const char *const mi_lttng_element_command_metadata_action;
74 extern const char *const mi_lttng_element_command_regenerate;
75 extern const char *const mi_lttng_element_command_regenerate_action;
76 LTTNG_EXPORT extern const char *const mi_lttng_element_command_name;
77 LTTNG_EXPORT extern const char *const mi_lttng_element_command_output;
78 extern const char *const mi_lttng_element_command_remove_trigger;
79 LTTNG_EXPORT extern const char *const mi_lttng_element_command_save;
80 LTTNG_EXPORT extern const char *const mi_lttng_element_command_set_session;
81 LTTNG_EXPORT extern const char *const mi_lttng_element_command_snapshot;
82 LTTNG_EXPORT extern const char *const mi_lttng_element_command_snapshot_add;
83 LTTNG_EXPORT extern const char *const mi_lttng_element_command_snapshot_del;
84 LTTNG_EXPORT extern const char *const mi_lttng_element_command_snapshot_list;
85 LTTNG_EXPORT extern const char *const mi_lttng_element_command_snapshot_record;
86 LTTNG_EXPORT extern const char *const mi_lttng_element_command_start;
87 LTTNG_EXPORT extern const char *const mi_lttng_element_command_stop;
88 LTTNG_EXPORT extern const char *const mi_lttng_element_command_success;
89 LTTNG_EXPORT extern const char *const mi_lttng_element_command_track;
90 LTTNG_EXPORT extern const char *const mi_lttng_element_command_untrack;
91 LTTNG_EXPORT extern const char *const mi_lttng_element_command_version;
92 extern const char *const mi_lttng_element_command_rotate;
93 extern const char *const mi_lttng_element_command_enable_rotation;
94 extern const char *const mi_lttng_element_command_disable_rotation;
95 extern const char *const mi_lttng_element_command_clear;
97 /* Strings related to version command */
98 LTTNG_EXPORT extern const char *const mi_lttng_element_version;
99 LTTNG_EXPORT extern const char *const mi_lttng_element_version_commit;
100 LTTNG_EXPORT extern const char *const mi_lttng_element_version_description;
101 LTTNG_EXPORT extern const char *const mi_lttng_element_version_license;
102 LTTNG_EXPORT extern const char *const mi_lttng_element_version_major;
103 LTTNG_EXPORT extern const char *const mi_lttng_element_version_minor;
104 LTTNG_EXPORT extern const char *const mi_lttng_element_version_patch_level;
105 LTTNG_EXPORT extern const char *const mi_lttng_element_version_str;
106 LTTNG_EXPORT extern const char *const mi_lttng_element_version_web;
108 /* String related to a lttng_event_field */
109 LTTNG_EXPORT extern const char *const mi_lttng_element_event_field;
110 LTTNG_EXPORT extern const char *const mi_lttng_element_event_fields;
112 /* String related to lttng_event_perf_counter_ctx */
113 LTTNG_EXPORT extern const char *const mi_lttng_element_perf_counter_context;
115 /* Strings related to pid */
116 LTTNG_EXPORT extern const char *const mi_lttng_element_pid_id;
118 /* Strings related to save command */
119 LTTNG_EXPORT extern const char *const mi_lttng_element_save;
121 /* Strings related to load command */
122 LTTNG_EXPORT extern const char *const mi_lttng_element_load;
123 extern const char *const mi_lttng_element_load_overrides;
124 extern const char *const mi_lttng_element_load_override_url;
126 /* General element of mi_lttng */
127 LTTNG_EXPORT extern const char *const mi_lttng_element_empty;
128 LTTNG_EXPORT extern const char *const mi_lttng_element_id;
129 LTTNG_EXPORT extern const char *const mi_lttng_element_nowrite;
130 LTTNG_EXPORT extern const char *const mi_lttng_element_success;
131 LTTNG_EXPORT extern const char *const mi_lttng_element_type_enum;
132 LTTNG_EXPORT extern const char *const mi_lttng_element_type_float;
133 LTTNG_EXPORT extern const char *const mi_lttng_element_type_integer;
134 LTTNG_EXPORT extern const char *const mi_lttng_element_type_other;
135 LTTNG_EXPORT extern const char *const mi_lttng_element_type_string;
137 /* String related to loglevel */
138 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_alert;
139 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_crit;
140 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug;
141 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_function;
142 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_line;
143 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_module;
144 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_process;
145 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_program;
146 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_system;
147 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_unit;
148 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_emerg;
149 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_err;
150 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_info;
151 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_notice;
152 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_unknown;
153 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_warning;
155 /* String related to loglevel JUL */
156 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_all;
157 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_config;
158 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_fine;
159 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_finer;
160 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_finest;
161 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_info;
162 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_off;
163 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_severe;
164 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_warning;
166 /* String related to loglevel Log4j */
167 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_off;
168 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_fatal;
169 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_error;
170 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_warn;
171 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_info;
172 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_debug;
173 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_trace;
174 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_all;
176 /* String related to loglevel Python */
177 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_critical;
178 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_error;
179 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_warning;
180 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_info;
181 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_debug;
182 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_notset;
184 /* String related to loglevel type */
185 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_type_all;
186 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_type_range;
187 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_type_single;
188 LTTNG_EXPORT extern const char *const mi_lttng_loglevel_type_unknown;
190 /* String related to a lttng_snapshot */
191 LTTNG_EXPORT extern const char *const mi_lttng_element_snapshot_ctrl_url;
192 LTTNG_EXPORT extern const char *const mi_lttng_element_snapshot_data_url;
193 LTTNG_EXPORT extern const char *const mi_lttng_element_snapshot_max_size;
194 LTTNG_EXPORT extern const char *const mi_lttng_element_snapshot_n_ptr;
195 LTTNG_EXPORT extern const char *const mi_lttng_element_snapshot_session_name;
196 LTTNG_EXPORT extern const char *const mi_lttng_element_snapshots;
198 /* String related to track/untrack command */
199 LTTNG_EXPORT extern const char *const mi_lttng_element_track_untrack_all_wildcard;
201 extern const char *const mi_lttng_element_session_name;
203 /* String related to rotate command */
204 extern const char *const mi_lttng_element_rotation;
205 extern const char *const mi_lttng_element_rotate_status;
206 extern const char *const mi_lttng_element_rotation_schedule;
207 extern const char *const mi_lttng_element_rotation_schedules;
208 extern const char *const mi_lttng_element_rotation_schedule_periodic;
209 extern const char *const mi_lttng_element_rotation_schedule_periodic_time_us;
210 extern const char *const mi_lttng_element_rotation_schedule_size_threshold;
211 extern const char *const mi_lttng_element_rotation_schedule_size_threshold_bytes;
212 extern const char *const mi_lttng_element_rotation_schedule_result;
213 extern const char *const mi_lttng_element_rotation_schedule_results;
214 extern const char *const mi_lttng_element_rotation_state;
215 extern const char *const mi_lttng_element_rotation_location;
216 extern const char *const mi_lttng_element_rotation_location_local;
217 extern const char *const mi_lttng_element_rotation_location_local_absolute_path;
218 extern const char *const mi_lttng_element_rotation_location_relay;
219 extern const char *const mi_lttng_element_rotation_location_relay_host;
220 extern const char *const mi_lttng_element_rotation_location_relay_control_port;
221 extern const char *const mi_lttng_element_rotation_location_relay_data_port;
222 extern const char *const mi_lttng_element_rotation_location_relay_protocol;
223 extern const char *const mi_lttng_element_rotation_location_relay_relative_path;
225 /* String related to enum lttng_rotation_state */
226 extern const char *const mi_lttng_rotation_state_str_ongoing;
227 extern const char *const mi_lttng_rotation_state_str_completed;
228 extern const char *const mi_lttng_rotation_state_str_expired;
229 extern const char *const mi_lttng_rotation_state_str_error;
231 /* String related to enum lttng_trace_archive_location_relay_protocol_type */
232 extern const char *const mi_lttng_rotation_location_relay_protocol_str_tcp;
234 /* String related to rate_policy elements */
235 extern const char *const mi_lttng_element_rate_policy;
236 extern const char *const mi_lttng_element_rate_policy_every_n;
237 extern const char *const mi_lttng_element_rate_policy_once_after_n;
239 extern const char *const mi_lttng_element_rate_policy_every_n_interval;
240 extern const char *const mi_lttng_element_rate_policy_once_after_n_threshold;
242 /* String related to action elements */
243 extern const char *const mi_lttng_element_action;
244 extern const char *const mi_lttng_element_action_list;
245 extern const char *const mi_lttng_element_action_notify;
246 extern const char *const mi_lttng_element_action_start_session;
247 extern const char *const mi_lttng_element_action_stop_session;
248 extern const char *const mi_lttng_element_action_rotate_session;
249 extern const char *const mi_lttng_element_action_snapshot_session;
250 extern const char *const mi_lttng_element_action_snapshot_session_output;
252 /* String related to condition */
253 extern const char *const mi_lttng_element_condition;
254 extern const char *const mi_lttng_element_condition_buffer_usage_high;
255 extern const char *const mi_lttng_element_condition_buffer_usage_low;
256 extern const char *const mi_lttng_element_condition_event_rule_matches;
257 extern const char *const mi_lttng_element_condition_session_consumed_size;
258 extern const char *const mi_lttng_element_condition_session_rotation;
259 extern const char *const mi_lttng_element_condition_session_rotation_completed;
260 extern const char *const mi_lttng_element_condition_session_rotation_ongoing;
261 extern const char *const mi_lttng_element_condition_channel_name;
262 extern const char *const mi_lttng_element_condition_threshold_ratio;
263 extern const char *const mi_lttng_element_condition_threshold_bytes;
265 /* String related to capture descriptor */
266 extern const char *const mi_lttng_element_capture_descriptor;
267 extern const char *const mi_lttng_element_capture_descriptors;
269 /* String related to event expression */
270 extern const char *const mi_lttng_element_event_expr;
271 extern const char *const mi_lttng_element_event_expr_payload_field;
272 extern const char *const mi_lttng_element_event_expr_channel_context_field;
273 extern const char *const mi_lttng_element_event_expr_app_specific_context_field;
274 extern const char *const mi_lttng_element_event_expr_array_field_element;
276 extern const char *const mi_lttng_element_event_expr_provider_name;
277 extern const char *const mi_lttng_element_event_expr_type_name;
278 extern const char *const mi_lttng_element_event_expr_index;
280 /* String related to event rule */
281 extern const char *const mi_lttng_element_event_rule;
283 /* String related to lttng_event_rule */
284 extern const char *const mi_lttng_element_event_rule_event_name;
285 extern const char *const mi_lttng_element_event_rule_name_pattern;
286 extern const char *const mi_lttng_element_event_rule_filter_expression;
287 extern const char *const mi_lttng_element_event_rule_jul_logging;
288 extern const char *const mi_lttng_element_event_rule_kernel_kprobe;
289 extern const char *const mi_lttng_element_event_rule_kernel_syscall;
290 extern const char *const mi_lttng_element_event_rule_kernel_tracepoint;
291 extern const char *const mi_lttng_element_event_rule_kernel_uprobe;
292 extern const char *const mi_lttng_element_event_rule_log4j_logging;
293 extern const char *const mi_lttng_element_event_rule_python_logging;
294 extern const char *const mi_lttng_element_event_rule_user_tracepoint;
296 /* String related to lttng_event_rule_kernel_syscall. */
297 extern const char *const mi_lttng_element_event_rule_kernel_syscall_emission_site;
299 /* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
300 extern const char *const mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit;
301 extern const char *const mi_lttng_event_rule_kernel_syscall_emission_site_entry;
302 extern const char *const mi_lttng_event_rule_kernel_syscall_emission_site_exit;
304 extern const char *const mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions;
305 extern const char *const mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion;
307 /* String related to log level rule. */
308 extern const char *const mi_lttng_element_log_level_rule;
309 extern const char *const mi_lttng_element_log_level_rule_exactly;
310 extern const char *const mi_lttng_element_log_level_rule_at_least_as_severe_as;
311 extern const char *const mi_lttng_element_log_level_rule_at_least_as_severe_as_thre;
312 extern const char *const mi_lttng_element_log_level_rule_level;
314 /* String related to kernel probe location. */
315 extern const char *const mi_lttng_element_kernel_probe_location;
316 extern const char *const mi_lttng_element_kernel_probe_location_symbol_offset;
317 extern const char *const mi_lttng_element_kernel_probe_location_symbol_offset_name;
318 extern const char *const mi_lttng_element_kernel_probe_location_symbol_offset_offset;
319 extern const char *const mi_lttng_element_kernel_probe_location_address;
320 extern const char *const mi_lttng_element_kernel_probe_location_address_address;
322 /* String related to userspace probe location. */
323 extern const char *const mi_lttng_element_userspace_probe_location;
324 extern const char *const mi_lttng_element_userspace_probe_location_binary_path;
325 extern const char *const mi_lttng_element_userspace_probe_location_function;
326 extern const char *const mi_lttng_element_userspace_probe_location_function_name;
327 extern const char *const mi_lttng_element_userspace_probe_location_lookup_method;
328 extern const char *const mi_lttng_element_userspace_probe_location_lookup_method_function_default;
329 extern const char *const mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
330 extern const char *const mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
331 extern const char *const mi_lttng_element_userspace_probe_location_tracepoint;
332 extern const char *const mi_lttng_element_userspace_probe_location_tracepoint_probe_name;
333 extern const char *const mi_lttng_element_userspace_probe_location_tracepoint_provider_name;
335 /* String related to enum
336 * lttng_userspace_probe_location_function_instrumentation_type */
337 extern const char *const mi_lttng_element_userspace_probe_location_function_instrumentation_type;
338 extern const char *const mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
340 /* String related to trigger */
341 extern const char *const mi_lttng_element_triggers;
342 extern const char *const mi_lttng_element_trigger;
343 extern const char *const mi_lttng_element_trigger_owner_uid;
345 /* String related to error_query. */
346 extern const char *const mi_lttng_element_error_query_result;
347 extern const char *const mi_lttng_element_error_query_result_counter;
348 extern const char *const mi_lttng_element_error_query_result_counter_value;
349 extern const char *const mi_lttng_element_error_query_result_description;
350 extern const char *const mi_lttng_element_error_query_result_name;
351 extern const char *const mi_lttng_element_error_query_result_type;
352 extern const char *const mi_lttng_element_error_query_results;
354 /* String related to add-context command */
355 extern const char *const mi_lttng_element_context_symbol;
357 /* Utility string function */
358 const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
359 const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value);
360 const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value);
361 const char *mi_lttng_domaintype_string(enum lttng_domain_type value);
362 const char *mi_lttng_buffertype_string(enum lttng_buffer_type value);
363 const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value);
364 const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
365 enum lttng_trace_archive_location_relay_protocol_type value);
368 * Create an instance of a machine interface writer.
370 * fd_output File to which the XML content must be written. The file will be
371 * closed once the mi_writer has been destroyed.
373 * Returns an instance of a machine interface writer on success, NULL on
376 struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);
379 * Destroy an instance of a machine interface writer.
381 * writer An instance of a machine interface writer.
383 * Returns zero if the XML document could be closed cleanly. Negative values
386 int mi_lttng_writer_destroy(struct mi_writer *writer);
389 * Open a command tag and add it's name node.
391 * writer An instance of a machine interface writer.
392 * command The command name.
394 * Returns zero if the XML document could be closed cleanly.
395 * Negative values indicate an error.
397 int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);
400 * Close a command tag.
402 * writer An instance of a machine interface writer.
404 * Returns zero if the XML document could be closed cleanly.
405 * Negative values indicate an error.
407 int mi_lttng_writer_command_close(struct mi_writer *writer);
410 * Open an element tag.
412 * writer An instance of a machine interface writer.
413 * element_name Element tag name.
415 * Returns zero if the XML document could be closed cleanly.
416 * Negative values indicate an error.
418 int mi_lttng_writer_open_element(struct mi_writer *writer, const char *element_name);
421 * Close the current element tag.
423 * writer An instance of a machine interface writer.
425 * Returns zero if the XML document could be closed cleanly.
426 * Negative values indicate an error.
428 int mi_lttng_writer_close_element(struct mi_writer *writer);
431 * Close multiple element.
433 * writer An instance of a machine interface writer.
434 * nb_element Number of elements.
436 * Returns zero if the XML document could be closed cleanly.
437 * Negative values indicate an error.
439 int mi_lttng_close_multi_element(struct mi_writer *writer, unsigned int nb_element);
442 * Write an element of type unsigned int.
444 * writer An instance of a machine interface writer.
445 * element_name Element name.
446 * value Unsigned int value of the element
448 * Returns zero if the element's value could be written.
449 * Negative values indicate an error.
451 int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
452 const char *element_name,
456 * Write an element of type signed int.
458 * writer An instance of a machine interface writer.
459 * element_name Element name.
460 * value Signed int value of the element.
462 * Returns zero if the element's value could be written.
463 * Negative values indicate an error.
465 int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
466 const char *element_name,
470 * Write an element of type boolean.
472 * writer An instance of a machine interface writer.
473 * element_name Element name.
474 * value Boolean value of the element.
476 * Returns zero if the element's value could be written.
477 * Negative values indicate an error.
479 int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
480 const char *element_name,
484 * Write an element of type string.
486 * writer An instance of a machine interface writer.
487 * element_name Element name.
488 * value String value of the element.
490 * Returns zero if the element's value could be written.
491 * Negative values indicate an error.
493 int mi_lttng_writer_write_element_string(struct mi_writer *writer,
494 const char *element_name,
498 * Write an element of type double.
500 * writer An instance of a machine interface writer.
501 * element_name Element name.
502 * value Double value of the element.
504 * Returns zero if the element's value could be written.
505 * Negative values indicate an error.
507 int mi_lttng_writer_write_element_double(struct mi_writer *writer,
508 const char *element_name,
512 * Machine interface of struct version.
514 * writer An instance of a machine interface writer.
515 * version Version struct.
516 * lttng_description String value of the version description.
517 * lttng_license String value of the version license.
519 * Returns zero if the element's value could be written.
520 * Negative values indicate an error.
522 int mi_lttng_version(struct mi_writer *writer,
523 struct mi_lttng_version_data *version,
524 const char *lttng_description,
525 const char *lttng_license);
528 * Machine interface: open a sessions element.
530 * writer An instance of a machine interface writer.
532 * Returns zero if the element's value could be written.
533 * Negative values indicate an error.
535 int mi_lttng_sessions_open(struct mi_writer *writer);
538 * Machine interface of struct session.
540 * writer An instance of a machine interface writer.
541 * session An instance of a session.
542 * is_open Defines whether or not the session element shall be closed.
543 * This should be used carefully and the client
544 * must close the session element.
545 * Use case: nested additional information on a session
546 * ex: domain,channel event.
548 * Returns zero if the element's value could be written.
549 * Negative values indicate an error.
551 int mi_lttng_session(struct mi_writer *writer, struct lttng_session *session, int is_open);
554 * Machine interface: open a domains element.
556 * writer An instance of a machine interface writer.
558 * Returns zero if the element's value could be written.
559 * Negative values indicate an error.
561 int mi_lttng_domains_open(struct mi_writer *writer);
564 * Machine interface of struct domain.
566 * writer An instance of a machine interface writer.
567 * domain An instance of a domain.
569 * is_open Defines whether or not the session element shall be closed.
570 * This should be used carefully and the client
571 * must close the domain element.
572 * Use case: nested addition information on a domain
575 * Returns zero if the element's value could be written.
576 * Negative values indicate an error.
578 int mi_lttng_domain(struct mi_writer *writer, struct lttng_domain *domain, int is_open);
581 * Machine interface: open a channels element.
583 * writer An instance of a machine interface writer.
585 * Returns zero if the element's value could be written.
586 * Negative values indicate an error.
588 int mi_lttng_channels_open(struct mi_writer *writer);
591 * Machine interface of struct channel.
593 * writer An instance of a machine interface writer.
594 * channel An instance of a channel.
596 * is_open Defines whether or not the session element shall be closed.
597 * This should be used carefully and the client
598 * must close the channel element.
599 * Use case: nested addition information on a channel.
602 * Returns zero if the element's value could be written.
603 * Negative values indicate an error.
605 int mi_lttng_channel(struct mi_writer *writer, struct lttng_channel *channel, int is_open);
608 * Machine interface of struct channel_attr.
610 * writer An instance of a machine interface writer.
611 * attr An instance of a channel_attr struct.
613 * Returns zero if the element's value could be written.
614 * Negative values indicate an error.
616 int mi_lttng_channel_attr(struct mi_writer *writer, struct lttng_channel_attr *attr);
619 * Machine interface for event common attributes.
621 * writer An instance of a mi writer.
622 * event single trace event.
624 * The common attribute are:
631 * Returns zero if the element's value could be written.
632 * Negative values indicate an error.
634 int mi_lttng_event_common_attributes(struct mi_writer *writer, struct lttng_event *event);
637 * Machine interface for kernel tracepoint event with a loglevel.
639 * writer An instance of a mi writer.
640 * event single trace event.
641 * domain Event's domain
643 * Returns zero if the element's value could be written.
644 * Negative values indicate an error.
646 int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
647 struct lttng_event *event,
648 enum lttng_domain_type domain);
651 * Machine interface for kernel tracepoint event with no loglevel.
653 * writer An instance of a mi writer.
654 * event single trace event.
656 * Returns zero if the element's value could be written.
657 * Negative values indicate an error.
659 int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer, struct lttng_event *event);
662 * Machine interface for kernel function and probe event.
664 * writer An instance of a mi writer.
665 * event single trace event.
667 * Returns zero if the element's value could be written.
668 * Negative values indicate an error.
670 int mi_lttng_event_function_probe(struct mi_writer *writer, struct lttng_event *event);
673 * Machine interface for kernel function entry event.
675 * writer An instance of a mi writer.
676 * event single trace event.
678 * Returns zero if the element's value could be written.
679 * Negative values indicate an error.
681 int mi_lttng_event_function_entry(struct mi_writer *writer, struct lttng_event *event);
684 * Machine interface: open an events element.
686 * writer An instance of a machine interface writer.
688 * Returns zero if the element's value could be written.
689 * Negative values indicate an error.
691 int mi_lttng_events_open(struct mi_writer *writer);
694 * Machine interface for printing an event.
695 * The trace event type currently supported are:
702 * writer An instance of a mi writer.
703 * event single trace event.
704 * is_open Defines whether or not the session element shall be closed.
705 * This should be used carefully and the client
706 * must close the event element.
707 * Use case: nested additional information
708 * domain Event's domain
710 * Returns zero if the element's value could be written.
711 * Negative values indicate an error.
713 int mi_lttng_event(struct mi_writer *writer,
714 struct lttng_event *event,
716 enum lttng_domain_type domain);
719 * Machine interface for struct lttng_event_field.
721 * writer An instance of a mi writer.
722 * field An event_field instance.
724 * Returns zero if the element's value could be written.
725 * Negative values indicate an error.
727 int mi_lttng_event_field(struct mi_writer *writer, struct lttng_event_field *field);
730 * Machine interface: open a event_fields element.
732 * writer An instance of a machine interface writer.
734 * Returns zero if the element have be written.
735 * Negative values indicate an error.
737 int mi_lttng_event_fields_open(struct mi_writer *writer);
740 * Machine interface: open a trackers element.
742 * writer An instance of a machine interface writer.
744 * Returns zero if the element's value could be written.
745 * Negative values indicate an error.
747 int mi_lttng_trackers_open(struct mi_writer *writer);
750 * Machine interface: open a process attribute tracker element.
752 * writer An instance of a machine interface writer.
754 * Returns zero if the element's value could be written.
755 * Negative values indicate an error.
757 * Note: A targets element is also opened for each tracker definition
759 int mi_lttng_process_attribute_tracker_open(struct mi_writer *writer,
760 enum lttng_process_attr process_attr);
763 * Machine interface: open a PIDs element.
765 * writer An instance of a machine interface writer.
767 * Returns zero if the element's value could be written.
768 * Negative values indicate an error.
770 int mi_lttng_pids_open(struct mi_writer *writer);
773 * Machine interface: open a processes element.
775 * writer An instance of a machine interface writer.
777 * Returns zero if the element's value could be written.
778 * Negative values indicate an error.
780 int mi_lttng_processes_open(struct mi_writer *writer);
783 * Machine interface of a Process.
785 * writer An instance of a machine interface writer.
788 * is_open Defines whether or not the session element shall be closed.
789 * This should be used carefully and the client
790 * must close the pid element.
791 * Use case: nested addition information on a domain
794 * Returns zero if the element's value could be written.
795 * Negative values indicate an error.
797 int mi_lttng_process(struct mi_writer *writer, pid_t pid, const char *name, int is_open);
800 * TODO: move pid of lttng list -u to process semantic on mi api bump
801 * Machine interface of a Process.
803 * writer An instance of a machine interface writer.
806 * is_open Defines whether or not the session element shall be closed.
807 * This should be used carefully and the client
808 * must close the pid element.
809 * Use case: nested addition information on a domain
812 * Returns zero if the element's value could be written.
813 * Negative values indicate an error.
815 int mi_lttng_pid(struct mi_writer *writer, pid_t pid, const char *name, int is_open);
818 * Machine interface: open a process attribute values element.
820 * writer An instance of a machine interface writer.
822 * Returns zero if the element's value could be written.
823 * Negative values indicate an error.
825 int mi_lttng_process_attr_values_open(struct mi_writer *writer);
828 * Machine interface for track/untrack of all process attribute values.
830 * writer An instance of a machine interface writer.
832 * Returns zero if the element's value could be written.
833 * Negative values indicate an error.
835 int mi_lttng_all_process_attribute_value(struct mi_writer *writer,
836 enum lttng_process_attr process_attr,
840 * Machine interface for track/untrack of an integral process attribute value.
842 * writer An instance of a machine interface writer.
844 * Returns zero if the element's value could be written.
845 * Negative values indicate an error.
847 int mi_lttng_integral_process_attribute_value(struct mi_writer *writer,
848 enum lttng_process_attr process_attr,
853 * Machine interface for track/untrack of a string process attribute value.
855 * writer An instance of a machine interface writer.
857 * Returns zero if the element's value could be written.
858 * Negative values indicate an error.
860 int mi_lttng_string_process_attribute_value(struct mi_writer *writer,
861 enum lttng_process_attr process_attr,
866 * Machine interface of a context.
868 * writer An instance of a machine interface writer
870 * context An instance of a lttng_event_context
872 * is_open Define if we close the context element
873 * This should be used carefully and the client
874 * need to close the context element.
875 * Returns zero if the element's value could be written.
876 * Negative values indicate an error.
878 int mi_lttng_context(struct mi_writer *writer, struct lttng_event_context *context, int is_open);
881 * Machine interface of a perf_counter_context.
883 * writer An instance of a machine interface writer
885 * contest An instance of a lttng_event_perf_counter_ctx
887 * Returns zero if the element's value could be written.
888 * Negative values indicate an error.
890 int mi_lttng_perf_counter_context(struct mi_writer *writer,
891 struct lttng_event_perf_counter_ctx *perf_context);
894 * Machine interface of the snapshot list_output.
895 * It specifies the session for which we are listing snapshots,
896 * and it opens a snapshots element to list a sequence
899 * writer An instance of a machine interface writer.
901 * session_name: Snapshot output for session "session_name".
903 * Note: The client has to close the session and the snapshots elements after
904 * having listed every lttng_snapshot_output.
906 * Returns zero if the element's value could be written.
907 * Negative values indicate an error.
909 int mi_lttng_snapshot_output_session_name(struct mi_writer *writer, const char *session_name);
912 * Machine interface of the snapshot output.
913 * The machine interface serializes the following attributes:
914 * - id: ID of the snapshot output.
915 * - name: Name of the output.
916 * - data_url : Destination of the output.
917 * - ctrl_url: Destination of the output.
918 * - max_size: total size of all stream combined.
920 * writer An instance of a machine interface writer.
922 * output: A list of snapshot_output.
924 * Returns zero if the element's value could be written.
925 * Negative values indicate an error.
927 int mi_lttng_snapshot_list_output(struct mi_writer *writer,
928 const struct lttng_snapshot_output *output);
931 * Machine interface of the output of the command snapshot del output
932 * when deleting a snapshot either by id or by name.
933 * If the snapshot was found and successfully deleted using its id,
934 * it return the id of the snapshot and the current session name on which it
937 * Otherwise, it do the same process with the name of the snapshot, if the
938 * snapshot output id is undefined.
940 * writer An instance of a machine interface writer.
942 * id: ID of the snapshot output.
944 * name: Name of the snapshot.
946 * current_session_name: Session to which the snapshot belongs.
948 * Returns zero if the element's value could be written.
949 * Negative values indicate an error.
951 int mi_lttng_snapshot_del_output(struct mi_writer *writer,
954 const char *current_session_name);
957 * Machine interface of the output of the command snapshot add output
958 * when adding a snapshot from a user URL.
960 * If the snapshot was successfully added, the machine interface lists
962 * - id: ID of the newly add snapshot output.
963 * - current_session_name: Name of the session to which the output was added.
964 * - ctrl_url: Destination of the output.
965 * - max_size: total size of all stream combined.
967 * writer An instance of a machine interface writer.
969 * current_session_name: Session to which the snapshot belongs.
973 * output: iterator over a lttng_snapshot_output_list which contain
974 * the snapshot output informations.
976 * Returns zero if the element's value could be written.
977 * Negative values indicate an error.
979 int mi_lttng_snapshot_add_output(struct mi_writer *writer,
980 const char *current_session_name,
982 struct lttng_snapshot_output *output);
985 * Machine interface of the output of the command snapshot
986 * record from a URL (if given).
988 * If the snapshot is successfully recorded from a url, the machine interface
989 * output the following information:
990 * - url: Destination of the output stored in the snapshot.
992 * Otherwise, the machine interface output the data and ctrl url received
993 * from the command-line.
995 * writer An instance of a machine interface writer.
997 * ctrl_url, data_url: Destination of the output receive from the command-line.
999 * Returns zero if the element's value could be written.
1000 * Negative values indicate an error.
1002 int mi_lttng_snapshot_record(struct mi_writer *writer,
1004 const char *cmdline_ctrl_url,
1005 const char *cmdline_data_url);
1008 * Machine interface representation of a session rotation schedule.
1010 * The machine interface serializes the provided schedule as one of the choices
1011 * from 'rotation_schedule_type'.
1013 * writer: An instance of a machine interface writer.
1015 * schedule: An lttng rotation schedule descriptor object.
1017 * Returns zero if the element's value could be written.
1018 * Negative values indicate an error.
1020 int mi_lttng_rotation_schedule(struct mi_writer *writer,
1021 const struct lttng_rotation_schedule *schedule);
1024 * Machine interface of a session rotation schedule result.
1025 * This is an element that is part of the output of the enable-rotation and
1026 * disable-rotation commands.
1028 * The machine interface provides the following information:
1029 * - schedule: the session rotation schedule descriptor.
1030 * - success: whether the sub-command succeeded.
1032 * writer: An instance of a machine interface writer.
1034 * schedule: An lttng rotation schedule descriptor object.
1036 * success: Whether the sub-command suceeded.
1038 * Returns zero if the element's value could be written.
1039 * Negative values indicate an error.
1041 int mi_lttng_rotation_schedule_result(struct mi_writer *writer,
1042 const struct lttng_rotation_schedule *schedule,
1046 * Machine interface of a session rotation result.
1047 * This is an element that is part of the output of the rotate command.
1049 * The machine interface provides the following information:
1050 * - session_name: the session to be rotated.
1051 * - state: the session rotation state.
1052 * - location: the location of the completed chunk archive.
1054 * writer: An instance of a machine interface writer.
1056 * session_name: The session to which the rotate command applies.
1058 * location: A location descriptor object.
1060 * success: Whether the sub-command suceeded.
1062 * Returns zero if the element's value could be written.
1063 * Negative values indicate an error.
1065 int mi_lttng_rotate(struct mi_writer *writer,
1066 const char *session_name,
1067 enum lttng_rotation_state rotation_state,
1068 const struct lttng_trace_archive_location *location);
1070 #endif /* _MI_LTTNG_H */