2 * Copyright (C) 2014 Jonathan Rajotte <jonathan.r.julien@gmail.com>
3 * Copyright (C) 2014 Olivier Cotte <olivier.cotte@polymtl.ca>
4 * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 * SPDX-License-Identifier: GPL-2.0-only
15 #include <common/error.h>
16 #include <common/macros.h>
17 #include <common/config/session-config.h>
18 #include <lttng/lttng.h>
20 #if defined(__cplusplus)
24 /* Don't want to reference snapshot-internal.h here */
25 struct lttng_snapshot_output
;
27 /* Instance of a machine interface writer. */
29 struct config_writer
*writer
;
30 enum lttng_mi_output_type type
;
34 * Version information for the machine interface.
36 struct mi_lttng_version_data
{
37 char version
[LTTNG_NAME_MAX
]; /* Version number of package */
38 uint32_t version_major
; /* LTTng-Tools major version number */
39 uint32_t version_minor
; /* LTTng-Tools minor version number */
40 uint32_t version_patchlevel
; /* LTTng-Tools patchlevel version number */
41 char version_commit
[LTTNG_NAME_MAX
]; /* Commit hash of the current version */
42 char version_name
[LTTNG_NAME_MAX
];
43 char package_url
[LTTNG_NAME_MAX
]; /* Define to the home page for this package. */
46 /* Error query callbacks. */
47 typedef enum lttng_error_code (*mi_lttng_error_query_trigger_cb
)(
48 const struct lttng_trigger
*trigger
,
49 struct lttng_error_query_results
**results
);
50 typedef enum lttng_error_code (*mi_lttng_error_query_condition_cb
)(
51 const struct lttng_trigger
*trigger
,
52 struct lttng_error_query_results
**results
);
53 typedef enum lttng_error_code (*mi_lttng_error_query_action_cb
)(
54 const struct lttng_trigger
*trigger
,
55 const struct lttng_action_path
*action_path
,
56 struct lttng_error_query_results
**results
);
58 struct mi_lttng_error_query_callbacks
{
59 mi_lttng_error_query_trigger_cb trigger_cb
;
60 mi_lttng_error_query_condition_cb condition_cb
;
61 mi_lttng_error_query_action_cb action_cb
;
64 /* Strings related to command */
65 extern const char * const mi_lttng_element_command
;
66 extern const char * const mi_lttng_element_command_action
;
67 extern const char * const mi_lttng_element_command_add_context
;
68 extern const char * const mi_lttng_element_command_add_trigger
;
69 extern const char * const mi_lttng_element_command_create
;
70 extern const char * const mi_lttng_element_command_destroy
;
71 extern const char * const mi_lttng_element_command_disable_channel
;
72 extern const char * const mi_lttng_element_command_disable_event
;
73 extern const char * const mi_lttng_element_command_enable_channels
;
74 extern const char * const mi_lttng_element_command_enable_event
;
75 extern const char * const mi_lttng_element_command_list
;
76 extern const char * const mi_lttng_element_command_list_trigger
;
77 extern const char * const mi_lttng_element_command_load
;
78 extern const char * const mi_lttng_element_command_metadata
;
79 extern const char * const mi_lttng_element_command_metadata_action
;
80 extern const char * const mi_lttng_element_command_regenerate
;
81 extern const char * const mi_lttng_element_command_regenerate_action
;
82 extern const char * const mi_lttng_element_command_name
;
83 extern const char * const mi_lttng_element_command_output
;
84 extern const char * const mi_lttng_element_command_remove_trigger
;
85 extern const char * const mi_lttng_element_command_save
;
86 extern const char * const mi_lttng_element_command_set_session
;
87 extern const char * const mi_lttng_element_command_snapshot
;
88 extern const char * const mi_lttng_element_command_snapshot_add
;
89 extern const char * const mi_lttng_element_command_snapshot_del
;
90 extern const char * const mi_lttng_element_command_snapshot_list
;
91 extern const char * const mi_lttng_element_command_snapshot_record
;
92 extern const char * const mi_lttng_element_command_start
;
93 extern const char * const mi_lttng_element_command_stop
;
94 extern const char * const mi_lttng_element_command_success
;
95 extern const char * const mi_lttng_element_command_track
;
96 extern const char * const mi_lttng_element_command_untrack
;
97 extern const char * const mi_lttng_element_command_version
;
98 extern const char * const mi_lttng_element_command_rotate
;
99 extern const char * const mi_lttng_element_command_enable_rotation
;
100 extern const char * const mi_lttng_element_command_disable_rotation
;
101 extern const char * const mi_lttng_element_command_clear
;
103 /* Strings related to version command */
104 extern const char * const mi_lttng_element_version
;
105 extern const char * const mi_lttng_element_version_commit
;
106 extern const char * const mi_lttng_element_version_description
;
107 extern const char * const mi_lttng_element_version_license
;
108 extern const char * const mi_lttng_element_version_major
;
109 extern const char * const mi_lttng_element_version_minor
;
110 extern const char * const mi_lttng_element_version_patch_level
;
111 extern const char * const mi_lttng_element_version_str
;
112 extern const char * const mi_lttng_element_version_web
;
114 /* String related to a lttng_event_field */
115 extern const char * const mi_lttng_element_event_field
;
116 extern const char * const mi_lttng_element_event_fields
;
118 /* String related to lttng_event_perf_counter_ctx */
119 extern const char * const mi_lttng_element_perf_counter_context
;
121 /* Strings related to pid */
122 extern const char * const mi_lttng_element_pid_id
;
124 /* Strings related to save command */
125 extern const char * const mi_lttng_element_save
;
127 /* Strings related to load command */
128 extern const char * const mi_lttng_element_load
;
129 extern const char * const mi_lttng_element_load_overrides
;
130 extern const char * const mi_lttng_element_load_override_url
;
132 /* General element of mi_lttng */
133 extern const char * const mi_lttng_element_empty
;
134 extern const char * const mi_lttng_element_id
;
135 extern const char * const mi_lttng_element_nowrite
;
136 extern const char * const mi_lttng_element_success
;
137 extern const char * const mi_lttng_element_type_enum
;
138 extern const char * const mi_lttng_element_type_float
;
139 extern const char * const mi_lttng_element_type_integer
;
140 extern const char * const mi_lttng_element_type_other
;
141 extern const char * const mi_lttng_element_type_string
;
143 /* String related to loglevel */
144 extern const char * const mi_lttng_loglevel_str_alert
;
145 extern const char * const mi_lttng_loglevel_str_crit
;
146 extern const char * const mi_lttng_loglevel_str_debug
;
147 extern const char * const mi_lttng_loglevel_str_debug_function
;
148 extern const char * const mi_lttng_loglevel_str_debug_line
;
149 extern const char * const mi_lttng_loglevel_str_debug_module
;
150 extern const char * const mi_lttng_loglevel_str_debug_process
;
151 extern const char * const mi_lttng_loglevel_str_debug_program
;
152 extern const char * const mi_lttng_loglevel_str_debug_system
;
153 extern const char * const mi_lttng_loglevel_str_debug_unit
;
154 extern const char * const mi_lttng_loglevel_str_emerg
;
155 extern const char * const mi_lttng_loglevel_str_err
;
156 extern const char * const mi_lttng_loglevel_str_info
;
157 extern const char * const mi_lttng_loglevel_str_notice
;
158 extern const char * const mi_lttng_loglevel_str_unknown
;
159 extern const char * const mi_lttng_loglevel_str_warning
;
161 /* String related to loglevel JUL */
162 extern const char * const mi_lttng_loglevel_str_jul_all
;
163 extern const char * const mi_lttng_loglevel_str_jul_config
;
164 extern const char * const mi_lttng_loglevel_str_jul_fine
;
165 extern const char * const mi_lttng_loglevel_str_jul_finer
;
166 extern const char * const mi_lttng_loglevel_str_jul_finest
;
167 extern const char * const mi_lttng_loglevel_str_jul_info
;
168 extern const char * const mi_lttng_loglevel_str_jul_off
;
169 extern const char * const mi_lttng_loglevel_str_jul_severe
;
170 extern const char * const mi_lttng_loglevel_str_jul_warning
;
172 /* String related to loglevel Log4j */
173 extern const char * const mi_lttng_loglevel_str_log4j_off
;
174 extern const char * const mi_lttng_loglevel_str_log4j_fatal
;
175 extern const char * const mi_lttng_loglevel_str_log4j_error
;
176 extern const char * const mi_lttng_loglevel_str_log4j_warn
;
177 extern const char * const mi_lttng_loglevel_str_log4j_info
;
178 extern const char * const mi_lttng_loglevel_str_log4j_debug
;
179 extern const char * const mi_lttng_loglevel_str_log4j_trace
;
180 extern const char * const mi_lttng_loglevel_str_log4j_all
;
182 /* String related to loglevel Python */
183 extern const char * const mi_lttng_loglevel_str_python_critical
;
184 extern const char * const mi_lttng_loglevel_str_python_error
;
185 extern const char * const mi_lttng_loglevel_str_python_warning
;
186 extern const char * const mi_lttng_loglevel_str_python_info
;
187 extern const char * const mi_lttng_loglevel_str_python_debug
;
188 extern const char * const mi_lttng_loglevel_str_python_notset
;
190 /* String related to loglevel type */
191 extern const char * const mi_lttng_loglevel_type_all
;
192 extern const char * const mi_lttng_loglevel_type_range
;
193 extern const char * const mi_lttng_loglevel_type_single
;
194 extern const char * const mi_lttng_loglevel_type_unknown
;
196 /* String related to a lttng_snapshot */
197 extern const char * const mi_lttng_element_snapshot_ctrl_url
;
198 extern const char * const mi_lttng_element_snapshot_data_url
;
199 extern const char * const mi_lttng_element_snapshot_max_size
;
200 extern const char * const mi_lttng_element_snapshot_n_ptr
;
201 extern const char * const mi_lttng_element_snapshot_session_name
;
202 extern const char * const mi_lttng_element_snapshots
;
204 /* String related to track/untrack command */
205 extern const char * const mi_lttng_element_track_untrack_all_wildcard
;
207 extern const char * const mi_lttng_element_session_name
;
209 /* String related to rotate command */
210 extern const char * const mi_lttng_element_rotation
;
211 extern const char * const mi_lttng_element_rotate_status
;
212 extern const char * const mi_lttng_element_rotation_schedule
;
213 extern const char * const mi_lttng_element_rotation_schedules
;
214 extern const char * const mi_lttng_element_rotation_schedule_periodic
;
215 extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us
;
216 extern const char * const mi_lttng_element_rotation_schedule_size_threshold
;
217 extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes
;
218 extern const char * const mi_lttng_element_rotation_schedule_result
;
219 extern const char * const mi_lttng_element_rotation_schedule_results
;
220 extern const char * const mi_lttng_element_rotation_state
;
221 extern const char * const mi_lttng_element_rotation_location
;
222 extern const char * const mi_lttng_element_rotation_location_local
;
223 extern const char * const mi_lttng_element_rotation_location_local_absolute_path
;
224 extern const char * const mi_lttng_element_rotation_location_relay
;
225 extern const char * const mi_lttng_element_rotation_location_relay_host
;
226 extern const char * const mi_lttng_element_rotation_location_relay_control_port
;
227 extern const char * const mi_lttng_element_rotation_location_relay_data_port
;
228 extern const char * const mi_lttng_element_rotation_location_relay_protocol
;
229 extern const char * const mi_lttng_element_rotation_location_relay_relative_path
;
231 /* String related to enum lttng_rotation_state */
232 extern const char * const mi_lttng_rotation_state_str_ongoing
;
233 extern const char * const mi_lttng_rotation_state_str_completed
;
234 extern const char * const mi_lttng_rotation_state_str_expired
;
235 extern const char * const mi_lttng_rotation_state_str_error
;
237 /* String related to enum lttng_trace_archive_location_relay_protocol_type */
238 extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp
;
240 /* String related to rate_policy elements */
241 extern const char *const mi_lttng_element_rate_policy
;
242 extern const char *const mi_lttng_element_rate_policy_every_n
;
243 extern const char *const mi_lttng_element_rate_policy_once_after_n
;
246 *const mi_lttng_element_rate_policy_every_n_interval
;
248 *const mi_lttng_element_rate_policy_once_after_n_threshold
;
250 /* String related to action elements */
251 extern const char *const mi_lttng_element_action
;
252 extern const char *const mi_lttng_element_action_list
;
253 extern const char *const mi_lttng_element_action_notify
;
254 extern const char *const mi_lttng_element_action_start_session
;
255 extern const char *const mi_lttng_element_action_stop_session
;
256 extern const char *const mi_lttng_element_action_rotate_session
;
257 extern const char *const mi_lttng_element_action_snapshot_session
;
259 *const mi_lttng_element_action_snapshot_session_output
;
261 /* String related to condition */
262 extern const char *const mi_lttng_element_condition
;
264 *const mi_lttng_element_condition_buffer_usage_high
;
266 *const mi_lttng_element_condition_buffer_usage_low
;
268 *const mi_lttng_element_condition_event_rule_matches
;
270 *const mi_lttng_element_condition_session_consumed_size
;
272 *const mi_lttng_element_condition_session_rotation
;
274 *const mi_lttng_element_condition_session_rotation_completed
;
276 *const mi_lttng_element_condition_session_rotation_ongoing
;
277 extern const char *const mi_lttng_element_condition_channel_name
;
278 extern const char *const mi_lttng_element_condition_threshold_ratio
;
279 extern const char *const mi_lttng_element_condition_threshold_bytes
;
281 /* String related to capture descriptor */
282 extern const char *const mi_lttng_element_capture_descriptor
;
283 extern const char *const mi_lttng_element_capture_descriptors
;
285 /* String related to event expression */
286 extern const char *const mi_lttng_element_event_expr
;
287 extern const char *const mi_lttng_element_event_expr_payload_field
;
289 *const mi_lttng_element_event_expr_channel_context_field
;
291 *const mi_lttng_element_event_expr_app_specific_context_field
;
293 *const mi_lttng_element_event_expr_array_field_element
;
295 extern const char *const mi_lttng_element_event_expr_provider_name
;
296 extern const char *const mi_lttng_element_event_expr_type_name
;
297 extern const char *const mi_lttng_element_event_expr_index
;
299 /* String related to event rule */
300 extern const char *const mi_lttng_element_event_rule
;
302 /* String related to lttng_event_rule */
303 extern const char *const mi_lttng_element_event_rule_event_name
;
304 extern const char *const mi_lttng_element_event_rule_name_pattern
;
306 *const mi_lttng_element_event_rule_filter_expression
;
307 extern const char *const mi_lttng_element_event_rule_jul_logging
;
308 extern const char *const mi_lttng_element_event_rule_kernel_kprobe
;
309 extern const char *const mi_lttng_element_event_rule_kernel_syscall
;
311 *const mi_lttng_element_event_rule_kernel_tracepoint
;
312 extern const char *const mi_lttng_element_event_rule_kernel_uprobe
;
313 extern const char *const mi_lttng_element_event_rule_log4j_logging
;
314 extern const char *const mi_lttng_element_event_rule_python_logging
;
316 *const mi_lttng_element_event_rule_user_tracepoint
;
318 /* String related to lttng_event_rule_kernel_syscall. */
320 *const mi_lttng_element_event_rule_kernel_syscall_emission_site
;
322 /* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
323 extern const char *const
324 mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit
;
326 *const mi_lttng_event_rule_kernel_syscall_emission_site_entry
;
328 *const mi_lttng_event_rule_kernel_syscall_emission_site_exit
;
330 extern const char *const
331 mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions
;
332 extern const char *const
333 mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion
;
335 /* String related to log level rule. */
336 extern const char *const mi_lttng_element_log_level_rule
;
337 extern const char *const mi_lttng_element_log_level_rule_exactly
;
339 *const mi_lttng_element_log_level_rule_at_least_as_severe_as
;
340 extern const char *const
341 mi_lttng_element_log_level_rule_at_least_as_severe_as_thre
;
342 extern const char *const mi_lttng_element_log_level_rule_level
;
344 /* String related to kernel probe location. */
345 extern const char *const mi_lttng_element_kernel_probe_location
;
347 *const mi_lttng_element_kernel_probe_location_symbol_offset
;
348 extern const char *const
349 mi_lttng_element_kernel_probe_location_symbol_offset_name
;
350 extern const char *const
351 mi_lttng_element_kernel_probe_location_symbol_offset_offset
;
353 *const mi_lttng_element_kernel_probe_location_address
;
355 *const mi_lttng_element_kernel_probe_location_address_address
;
357 /* String related to userspace probe location. */
358 extern const char *const mi_lttng_element_userspace_probe_location
;
360 *const mi_lttng_element_userspace_probe_location_binary_path
;
362 *const mi_lttng_element_userspace_probe_location_function
;
364 *const mi_lttng_element_userspace_probe_location_function_name
;
366 *const mi_lttng_element_userspace_probe_location_lookup_method
;
367 extern const char *const
368 mi_lttng_element_userspace_probe_location_lookup_method_function_default
;
369 extern const char *const
370 mi_lttng_element_userspace_probe_location_lookup_method_function_elf
;
371 extern const char *const
372 mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt
;
374 *const mi_lttng_element_userspace_probe_location_tracepoint
;
375 extern const char *const
376 mi_lttng_element_userspace_probe_location_tracepoint_probe_name
;
377 extern const char *const
378 mi_lttng_element_userspace_probe_location_tracepoint_provider_name
;
380 /* String related to enum
381 * lttng_userspace_probe_location_function_instrumentation_type */
382 extern const char *const
383 mi_lttng_element_userspace_probe_location_function_instrumentation_type
;
384 extern const char *const
385 mi_lttng_userspace_probe_location_function_instrumentation_type_entry
;
387 /* String related to trigger */
388 extern const char *const mi_lttng_element_triggers
;
389 extern const char *const mi_lttng_element_trigger
;
390 extern const char *const mi_lttng_element_trigger_owner_uid
;
392 /* String related to error_query. */
393 extern const char *const mi_lttng_element_error_query_result
;
395 *const mi_lttng_element_error_query_result_counter
;
397 *const mi_lttng_element_error_query_result_counter_value
;
399 *const mi_lttng_element_error_query_result_description
;
400 extern const char *const mi_lttng_element_error_query_result_name
;
401 extern const char *const mi_lttng_element_error_query_result_type
;
402 extern const char *const mi_lttng_element_error_query_results
;
404 /* String related to add-context command */
405 extern const char * const mi_lttng_element_context_symbol
;
407 /* Utility string function */
408 const char *mi_lttng_loglevel_string(int value
, enum lttng_domain_type domain
);
409 const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value
);
410 const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value
);
411 const char *mi_lttng_domaintype_string(enum lttng_domain_type value
);
412 const char *mi_lttng_buffertype_string(enum lttng_buffer_type value
);
413 const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value
);
414 const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
415 enum lttng_trace_archive_location_relay_protocol_type value
);
418 * Create an instance of a machine interface writer.
420 * fd_output File to which the XML content must be written. The file will be
421 * closed once the mi_writer has been destroyed.
423 * Returns an instance of a machine interface writer on success, NULL on
426 struct mi_writer
*mi_lttng_writer_create(int fd_output
, int mi_output_type
);
429 * Destroy an instance of a machine interface writer.
431 * writer An instance of a machine interface writer.
433 * Returns zero if the XML document could be closed cleanly. Negative values
436 int mi_lttng_writer_destroy(struct mi_writer
*writer
);
439 * Open a command tag and add it's name node.
441 * writer An instance of a machine interface writer.
442 * command The command name.
444 * Returns zero if the XML document could be closed cleanly.
445 * Negative values indicate an error.
447 int mi_lttng_writer_command_open(struct mi_writer
*writer
, const char *command
);
450 * Close a command tag.
452 * writer An instance of a machine interface writer.
454 * Returns zero if the XML document could be closed cleanly.
455 * Negative values indicate an error.
457 int mi_lttng_writer_command_close(struct mi_writer
*writer
);
460 * Open an element tag.
462 * writer An instance of a machine interface writer.
463 * element_name Element tag name.
465 * Returns zero if the XML document could be closed cleanly.
466 * Negative values indicate an error.
468 int mi_lttng_writer_open_element(struct mi_writer
*writer
,
469 const char *element_name
);
472 * Close the current element tag.
474 * writer An instance of a machine interface writer.
476 * Returns zero if the XML document could be closed cleanly.
477 * Negative values indicate an error.
479 int mi_lttng_writer_close_element(struct mi_writer
*writer
);
482 * Close multiple element.
484 * writer An instance of a machine interface writer.
485 * nb_element Number of elements.
487 * Returns zero if the XML document could be closed cleanly.
488 * Negative values indicate an error.
490 int mi_lttng_close_multi_element(struct mi_writer
*writer
,
491 unsigned int nb_element
);
494 * Write an element of type unsigned int.
496 * writer An instance of a machine interface writer.
497 * element_name Element name.
498 * value Unsigned int value of the element
500 * Returns zero if the element's value could be written.
501 * Negative values indicate an error.
503 int mi_lttng_writer_write_element_unsigned_int(struct mi_writer
*writer
,
504 const char *element_name
, uint64_t value
);
507 * Write an element of type signed int.
509 * writer An instance of a machine interface writer.
510 * element_name Element name.
511 * value Signed int value of the element.
513 * Returns zero if the element's value could be written.
514 * Negative values indicate an error.
516 int mi_lttng_writer_write_element_signed_int(struct mi_writer
*writer
,
517 const char *element_name
, int64_t value
);
520 * Write an element of type boolean.
522 * writer An instance of a machine interface writer.
523 * element_name Element name.
524 * value Boolean value of the element.
526 * Returns zero if the element's value could be written.
527 * Negative values indicate an error.
529 int mi_lttng_writer_write_element_bool(struct mi_writer
*writer
,
530 const char *element_name
, int value
);
533 * Write an element of type string.
535 * writer An instance of a machine interface writer.
536 * element_name Element name.
537 * value String value of the element.
539 * Returns zero if the element's value could be written.
540 * Negative values indicate an error.
542 int mi_lttng_writer_write_element_string(struct mi_writer
*writer
,
543 const char *element_name
, const char *value
);
546 * Write an element of type double.
548 * writer An instance of a machine interface writer.
549 * element_name Element name.
550 * value Double value of the element.
552 * Returns zero if the element's value could be written.
553 * Negative values indicate an error.
555 int mi_lttng_writer_write_element_double(struct mi_writer
*writer
,
556 const char *element_name
,
560 * Machine interface of struct version.
562 * writer An instance of a machine interface writer.
563 * version Version struct.
564 * lttng_description String value of the version description.
565 * lttng_license String value of the version license.
567 * Returns zero if the element's value could be written.
568 * Negative values indicate an error.
570 int mi_lttng_version(struct mi_writer
*writer
, struct mi_lttng_version_data
*version
,
571 const char *lttng_description
, const char *lttng_license
);
574 * Machine interface: open a sessions element.
576 * writer An instance of a machine interface writer.
578 * Returns zero if the element's value could be written.
579 * Negative values indicate an error.
581 int mi_lttng_sessions_open(struct mi_writer
*writer
);
584 * Machine interface of struct session.
586 * writer An instance of a machine interface writer.
587 * session An instance of a session.
588 * is_open Defines whether or not the session element shall be closed.
589 * This should be used carefully and the client
590 * must close the session element.
591 * Use case: nested additional information on a session
592 * ex: domain,channel event.
594 * Returns zero if the element's value could be written.
595 * Negative values indicate an error.
597 int mi_lttng_session(struct mi_writer
*writer
,
598 struct lttng_session
*session
, int is_open
);
601 * Machine interface: open a domains element.
603 * writer An instance of a machine interface writer.
605 * Returns zero if the element's value could be written.
606 * Negative values indicate an error.
608 int mi_lttng_domains_open(struct mi_writer
*writer
);
611 * Machine interface of struct domain.
613 * writer An instance of a machine interface writer.
614 * domain An instance of a domain.
616 * is_open Defines whether or not the session element shall be closed.
617 * This should be used carefully and the client
618 * must close the domain element.
619 * Use case: nested addition information on a domain
622 * Returns zero if the element's value could be written.
623 * Negative values indicate an error.
625 int mi_lttng_domain(struct mi_writer
*writer
,
626 struct lttng_domain
*domain
, int is_open
);
629 * Machine interface: open a channels element.
631 * writer An instance of a machine interface writer.
633 * Returns zero if the element's value could be written.
634 * Negative values indicate an error.
636 int mi_lttng_channels_open(struct mi_writer
*writer
);
639 * Machine interface of struct channel.
641 * writer An instance of a machine interface writer.
642 * channel An instance of a channel.
644 * is_open Defines whether or not the session element shall be closed.
645 * This should be used carefully and the client
646 * must close the channel element.
647 * Use case: nested addition information on a channel.
650 * Returns zero if the element's value could be written.
651 * Negative values indicate an error.
653 int mi_lttng_channel(struct mi_writer
*writer
,
654 struct lttng_channel
*channel
, int is_open
);
657 * Machine interface of struct channel_attr.
659 * writer An instance of a machine interface writer.
660 * attr An instance of a channel_attr struct.
662 * Returns zero if the element's value could be written.
663 * Negative values indicate an error.
665 int mi_lttng_channel_attr(struct mi_writer
*writer
,
666 struct lttng_channel_attr
*attr
);
669 * Machine interface for event common attributes.
671 * writer An instance of a mi writer.
672 * event single trace event.
674 * The common attribute are:
681 * Returns zero if the element's value could be written.
682 * Negative values indicate an error.
684 int mi_lttng_event_common_attributes(struct mi_writer
*writer
,
685 struct lttng_event
*event
);
688 * Machine interface for kernel tracepoint event with a loglevel.
690 * writer An instance of a mi writer.
691 * event single trace event.
692 * domain Event's domain
694 * Returns zero if the element's value could be written.
695 * Negative values indicate an error.
697 int mi_lttng_event_tracepoint_loglevel(struct mi_writer
*writer
,
698 struct lttng_event
*event
, enum lttng_domain_type domain
);
701 * Machine interface for kernel tracepoint event with no loglevel.
703 * writer An instance of a mi writer.
704 * event single trace event.
706 * Returns zero if the element's value could be written.
707 * Negative values indicate an error.
709 int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer
*writer
,
710 struct lttng_event
*event
);
713 * Machine interface for kernel function and probe event.
715 * writer An instance of a mi writer.
716 * event single trace event.
718 * Returns zero if the element's value could be written.
719 * Negative values indicate an error.
721 int mi_lttng_event_function_probe(struct mi_writer
*writer
,
722 struct lttng_event
*event
);
725 * Machine interface for kernel function entry event.
727 * writer An instance of a mi writer.
728 * event single trace event.
730 * Returns zero if the element's value could be written.
731 * Negative values indicate an error.
733 int mi_lttng_event_function_entry(struct mi_writer
*writer
,
734 struct lttng_event
*event
);
737 * Machine interface: open an events element.
739 * writer An instance of a machine interface writer.
741 * Returns zero if the element's value could be written.
742 * Negative values indicate an error.
744 int mi_lttng_events_open(struct mi_writer
*writer
);
747 * Machine interface for printing an event.
748 * The trace event type currently supported are:
755 * writer An instance of a mi writer.
756 * event single trace event.
757 * is_open Defines whether or not the session element shall be closed.
758 * This should be used carefully and the client
759 * must close the event element.
760 * Use case: nested additional information
761 * domain Event's domain
763 * Returns zero if the element's value could be written.
764 * Negative values indicate an error.
766 int mi_lttng_event(struct mi_writer
*writer
, struct lttng_event
*event
,
767 int is_open
, enum lttng_domain_type domain
);
770 * Machine interface for struct lttng_event_field.
772 * writer An instance of a mi writer.
773 * field An event_field instance.
775 * Returns zero if the element's value could be written.
776 * Negative values indicate an error.
778 int mi_lttng_event_field(struct mi_writer
*writer
,
779 struct lttng_event_field
*field
);
782 * Machine interface: open a event_fields element.
784 * writer An instance of a machine interface writer.
786 * Returns zero if the element have be written.
787 * Negative values indicate an error.
789 int mi_lttng_event_fields_open(struct mi_writer
*writer
);
792 * Machine interface: open a trackers element.
794 * writer An instance of a machine interface writer.
796 * Returns zero if the element's value could be written.
797 * Negative values indicate an error.
799 int mi_lttng_trackers_open(struct mi_writer
*writer
);
802 * Machine interface: open a process attribute tracker element.
804 * writer An instance of a machine interface writer.
806 * Returns zero if the element's value could be written.
807 * Negative values indicate an error.
809 * Note: A targets element is also opened for each tracker definition
811 int mi_lttng_process_attribute_tracker_open(
812 struct mi_writer
*writer
, enum lttng_process_attr process_attr
);
815 * Machine interface: open a PIDs element.
817 * writer An instance of a machine interface writer.
819 * Returns zero if the element's value could be written.
820 * Negative values indicate an error.
822 int mi_lttng_pids_open(struct mi_writer
*writer
);
825 * Machine interface: open a processes element.
827 * writer An instance of a machine interface writer.
829 * Returns zero if the element's value could be written.
830 * Negative values indicate an error.
832 int mi_lttng_processes_open(struct mi_writer
*writer
);
835 * Machine interface of a Process.
837 * writer An instance of a machine interface writer.
840 * is_open Defines whether or not the session element shall be closed.
841 * This should be used carefully and the client
842 * must close the pid element.
843 * Use case: nested addition information on a domain
846 * Returns zero if the element's value could be written.
847 * Negative values indicate an error.
849 int mi_lttng_process(struct mi_writer
*writer
, pid_t pid
, const char *name
,
853 * TODO: move pid of lttng list -u to process semantic on mi api bump
854 * Machine interface of a Process.
856 * writer An instance of a machine interface writer.
859 * is_open Defines whether or not the session element shall be closed.
860 * This should be used carefully and the client
861 * must close the pid element.
862 * Use case: nested addition information on a domain
865 * Returns zero if the element's value could be written.
866 * Negative values indicate an error.
868 int mi_lttng_pid(struct mi_writer
*writer
, pid_t pid
, const char *name
,
872 * Machine interface: open a process attribute values element.
874 * writer An instance of a machine interface writer.
876 * Returns zero if the element's value could be written.
877 * Negative values indicate an error.
879 int mi_lttng_process_attr_values_open(struct mi_writer
*writer
);
882 * Machine interface for track/untrack of all process attribute values.
884 * writer An instance of a machine interface writer.
886 * Returns zero if the element's value could be written.
887 * Negative values indicate an error.
889 int mi_lttng_all_process_attribute_value(struct mi_writer
*writer
,
890 enum lttng_process_attr process_attr
,
894 * Machine interface for track/untrack of an integral process attribute value.
896 * writer An instance of a machine interface writer.
898 * Returns zero if the element's value could be written.
899 * Negative values indicate an error.
901 int mi_lttng_integral_process_attribute_value(struct mi_writer
*writer
,
902 enum lttng_process_attr process_attr
,
907 * Machine interface for track/untrack of a string process attribute value.
909 * writer An instance of a machine interface writer.
911 * Returns zero if the element's value could be written.
912 * Negative values indicate an error.
914 int mi_lttng_string_process_attribute_value(struct mi_writer
*writer
,
915 enum lttng_process_attr process_attr
,
920 * Machine interface of a context.
922 * writer An instance of a machine interface writer
924 * context An instance of a lttng_event_context
926 * is_open Define if we close the context element
927 * This should be used carefully and the client
928 * need to close the context element.
929 * Returns zero if the element's value could be written.
930 * Negative values indicate an error.
932 int mi_lttng_context(struct mi_writer
*writer
,
933 struct lttng_event_context
*context
, int is_open
);
936 * Machine interface of a perf_counter_context.
938 * writer An instance of a machine interface writer
940 * contest An instance of a lttng_event_perf_counter_ctx
942 * Returns zero if the element's value could be written.
943 * Negative values indicate an error.
945 int mi_lttng_perf_counter_context(struct mi_writer
*writer
,
946 struct lttng_event_perf_counter_ctx
*perf_context
);
949 * Machine interface of the snapshot list_output.
950 * It specifies the session for which we are listing snapshots,
951 * and it opens a snapshots element to list a sequence
954 * writer An instance of a machine interface writer.
956 * session_name: Snapshot output for session "session_name".
958 * Note: The client has to close the session and the snapshots elements after
959 * having listed every lttng_snapshot_output.
961 * Returns zero if the element's value could be written.
962 * Negative values indicate an error.
964 int mi_lttng_snapshot_output_session_name(struct mi_writer
*writer
,
965 const char *session_name
);
968 * Machine interface of the snapshot output.
969 * The machine interface serializes the following attributes:
970 * - id: ID of the snapshot output.
971 * - name: Name of the output.
972 * - data_url : Destination of the output.
973 * - ctrl_url: Destination of the output.
974 * - max_size: total size of all stream combined.
976 * writer An instance of a machine interface writer.
978 * output: A list of snapshot_output.
980 * Returns zero if the element's value could be written.
981 * Negative values indicate an error.
983 int mi_lttng_snapshot_list_output(struct mi_writer
*writer
,
984 const struct lttng_snapshot_output
*output
);
987 * Machine interface of the output of the command snapshot del output
988 * when deleting a snapshot either by id or by name.
989 * If the snapshot was found and successfully deleted using its id,
990 * it return the id of the snapshot and the current session name on which it
993 * Otherwise, it do the same process with the name of the snapshot, if the
994 * snapshot output id is undefined.
996 * writer An instance of a machine interface writer.
998 * id: ID of the snapshot output.
1000 * name: Name of the snapshot.
1002 * current_session_name: Session to which the snapshot belongs.
1004 * Returns zero if the element's value could be written.
1005 * Negative values indicate an error.
1007 int mi_lttng_snapshot_del_output(struct mi_writer
*writer
, int id
,
1008 const char *name
, const char *current_session_name
);
1011 * Machine interface of the output of the command snapshot add output
1012 * when adding a snapshot from a user URL.
1014 * If the snapshot was successfully added, the machine interface lists
1015 * these information:
1016 * - id: ID of the newly add snapshot output.
1017 * - current_session_name: Name of the session to which the output was added.
1018 * - ctrl_url: Destination of the output.
1019 * - max_size: total size of all stream combined.
1021 * writer An instance of a machine interface writer.
1023 * current_session_name: Session to which the snapshot belongs.
1027 * output: iterator over a lttng_snapshot_output_list which contain
1028 * the snapshot output informations.
1030 * Returns zero if the element's value could be written.
1031 * Negative values indicate an error.
1033 int mi_lttng_snapshot_add_output(struct mi_writer
*writer
,
1034 const char *current_session_name
, const char *n_ptr
,
1035 struct lttng_snapshot_output
*output
);
1038 * Machine interface of the output of the command snapshot
1039 * record from a URL (if given).
1041 * If the snapshot is successfully recorded from a url, the machine interface
1042 * output the following information:
1043 * - url: Destination of the output stored in the snapshot.
1045 * Otherwise, the machine interface output the data and ctrl url received
1046 * from the command-line.
1048 * writer An instance of a machine interface writer.
1050 * current_session_name: Snapshot record for session "current_session_name".
1052 * ctrl_url, data_url: Destination of the output receive from the command-line.
1054 * Returns zero if the element's value could be written.
1055 * Negative values indicate an error.
1057 int mi_lttng_snapshot_record(struct mi_writer
*writer
,
1058 const char *current_session_name
, const char *url
,
1059 const char *cmdline_ctrl_url
, const char *cmdline_data_url
);
1062 * Machine interface representation of a session rotation schedule.
1064 * The machine interface serializes the provided schedule as one of the choices
1065 * from 'rotation_schedule_type'.
1067 * writer: An instance of a machine interface writer.
1069 * schedule: An lttng rotation schedule descriptor object.
1071 * Returns zero if the element's value could be written.
1072 * Negative values indicate an error.
1074 int mi_lttng_rotation_schedule(struct mi_writer
*writer
,
1075 const struct lttng_rotation_schedule
*schedule
);
1078 * Machine interface of a session rotation schedule result.
1079 * This is an element that is part of the output of the enable-rotation and
1080 * disable-rotation commands.
1082 * The machine interface provides the following information:
1083 * - schedule: the session rotation schedule descriptor.
1084 * - success: whether the sub-command succeeded.
1086 * writer: An instance of a machine interface writer.
1088 * schedule: An lttng rotation schedule descriptor object.
1090 * success: Whether the sub-command suceeded.
1092 * Returns zero if the element's value could be written.
1093 * Negative values indicate an error.
1095 int mi_lttng_rotation_schedule_result(struct mi_writer
*writer
,
1096 const struct lttng_rotation_schedule
*schedule
,
1100 * Machine interface of a session rotation result.
1101 * This is an element that is part of the output of the rotate command.
1103 * The machine interface provides the following information:
1104 * - session_name: the session to be rotated.
1105 * - state: the session rotation state.
1106 * - location: the location of the completed chunk archive.
1108 * writer: An instance of a machine interface writer.
1110 * session_name: The session to which the rotate command applies.
1112 * location: A location descriptor object.
1114 * success: Whether the sub-command suceeded.
1116 * Returns zero if the element's value could be written.
1117 * Negative values indicate an error.
1119 int mi_lttng_rotate(struct mi_writer
*writer
,
1120 const char *session_name
,
1121 enum lttng_rotation_state rotation_state
,
1122 const struct lttng_trace_archive_location
*location
);
1124 #if defined(__cplusplus)
1128 #endif /* _MI_LTTNG_H */