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 /* 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
{
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 typedef enum lttng_error_code (*mi_lttng_error_query_trigger_cb
)(
44 const struct lttng_trigger
*trigger
,
45 struct lttng_error_query_results
**results
);
46 typedef enum lttng_error_code (*mi_lttng_error_query_condition_cb
)(
47 const struct lttng_trigger
*trigger
,
48 struct lttng_error_query_results
**results
);
49 typedef enum lttng_error_code (*mi_lttng_error_query_action_cb
)(
50 const struct lttng_trigger
*trigger
,
51 const struct lttng_action_path
*action_path
,
52 struct lttng_error_query_results
**results
);
54 struct mi_lttng_error_query_callbacks
{
55 mi_lttng_error_query_trigger_cb trigger_cb
;
56 mi_lttng_error_query_condition_cb condition_cb
;
57 mi_lttng_error_query_action_cb action_cb
;
60 /* Strings related to command */
61 extern const char * const mi_lttng_element_command
;
62 extern const char * const mi_lttng_element_command_action
;
63 extern const char * const mi_lttng_element_command_add_context
;
64 extern const char *const mi_lttng_element_command_add_trigger
;
65 extern const char * const mi_lttng_element_command_create
;
66 extern const char * const mi_lttng_element_command_destroy
;
67 extern const char * const mi_lttng_element_command_disable_channel
;
68 extern const char * const mi_lttng_element_command_disable_event
;
69 extern const char * const mi_lttng_element_command_enable_channels
;
70 extern const char * const mi_lttng_element_command_enable_event
;
71 extern const char * const mi_lttng_element_command_list
;
72 extern const char * const mi_lttng_element_command_load
;
73 extern const char * const mi_lttng_element_command_metadata
;
74 extern const char * const mi_lttng_element_command_metadata_action
;
75 extern const char * const mi_lttng_element_command_regenerate
;
76 extern const char * const mi_lttng_element_command_regenerate_action
;
77 extern const char * const mi_lttng_element_command_name
;
78 extern const char * const mi_lttng_element_command_output
;
79 extern const char *const mi_lttng_element_command_remove_trigger
;
80 extern const char * const mi_lttng_element_command_save
;
81 extern const char * const mi_lttng_element_command_set_session
;
82 extern const char * const mi_lttng_element_command_snapshot
;
83 extern const char * const mi_lttng_element_command_snapshot_add
;
84 extern const char * const mi_lttng_element_command_snapshot_del
;
85 extern const char * const mi_lttng_element_command_snapshot_list
;
86 extern const char * const mi_lttng_element_command_snapshot_record
;
87 extern const char * const mi_lttng_element_command_start
;
88 extern const char * const mi_lttng_element_command_stop
;
89 extern const char * const mi_lttng_element_command_success
;
90 extern const char * const mi_lttng_element_command_track
;
91 extern const char * const mi_lttng_element_command_untrack
;
92 extern const char * const mi_lttng_element_command_version
;
93 extern const char * const mi_lttng_element_command_rotate
;
94 extern const char * const mi_lttng_element_command_enable_rotation
;
95 extern const char * const mi_lttng_element_command_disable_rotation
;
96 extern const char * const mi_lttng_element_command_clear
;
98 /* Strings related to version command */
99 extern const char * const mi_lttng_element_version
;
100 extern const char * const mi_lttng_element_version_commit
;
101 extern const char * const mi_lttng_element_version_description
;
102 extern const char * const mi_lttng_element_version_license
;
103 extern const char * const mi_lttng_element_version_major
;
104 extern const char * const mi_lttng_element_version_minor
;
105 extern const char * const mi_lttng_element_version_patch_level
;
106 extern const char * const mi_lttng_element_version_str
;
107 extern const char * const mi_lttng_element_version_web
;
109 /* String related to a lttng_event_field */
110 extern const char * const mi_lttng_element_event_field
;
111 extern const char * const mi_lttng_element_event_fields
;
113 /* String related to lttng_event_perf_counter_ctx */
114 extern const char * const mi_lttng_element_perf_counter_context
;
116 /* Strings related to pid */
117 extern const char * const mi_lttng_element_pid_id
;
119 /* Strings related to save command */
120 extern const char * const mi_lttng_element_save
;
122 /* Strings related to load command */
123 extern const char * const mi_lttng_element_load
;
124 LTTNG_HIDDEN
extern const char * const mi_lttng_element_load_overrides
;
125 LTTNG_HIDDEN
extern const char * const mi_lttng_element_load_override_url
;
127 /* General element of mi_lttng */
128 extern const char * const mi_lttng_element_empty
;
129 extern const char * const mi_lttng_element_id
;
130 extern const char * const mi_lttng_element_nowrite
;
131 extern const char * const mi_lttng_element_success
;
132 extern const char * const mi_lttng_element_type_enum
;
133 extern const char * const mi_lttng_element_type_float
;
134 extern const char * const mi_lttng_element_type_integer
;
135 extern const char * const mi_lttng_element_type_other
;
136 extern const char * const mi_lttng_element_type_string
;
138 /* String related to loglevel */
139 extern const char * const mi_lttng_loglevel_str_alert
;
140 extern const char * const mi_lttng_loglevel_str_crit
;
141 extern const char * const mi_lttng_loglevel_str_debug
;
142 extern const char * const mi_lttng_loglevel_str_debug_function
;
143 extern const char * const mi_lttng_loglevel_str_debug_line
;
144 extern const char * const mi_lttng_loglevel_str_debug_module
;
145 extern const char * const mi_lttng_loglevel_str_debug_process
;
146 extern const char * const mi_lttng_loglevel_str_debug_program
;
147 extern const char * const mi_lttng_loglevel_str_debug_system
;
148 extern const char * const mi_lttng_loglevel_str_debug_unit
;
149 extern const char * const mi_lttng_loglevel_str_emerg
;
150 extern const char * const mi_lttng_loglevel_str_err
;
151 extern const char * const mi_lttng_loglevel_str_info
;
152 extern const char * const mi_lttng_loglevel_str_notice
;
153 extern const char * const mi_lttng_loglevel_str_unknown
;
154 extern const char * const mi_lttng_loglevel_str_warning
;
156 /* String related to loglevel JUL */
157 extern const char * const mi_lttng_loglevel_str_jul_all
;
158 extern const char * const mi_lttng_loglevel_str_jul_config
;
159 extern const char * const mi_lttng_loglevel_str_jul_fine
;
160 extern const char * const mi_lttng_loglevel_str_jul_finer
;
161 extern const char * const mi_lttng_loglevel_str_jul_finest
;
162 extern const char * const mi_lttng_loglevel_str_jul_info
;
163 extern const char * const mi_lttng_loglevel_str_jul_off
;
164 extern const char * const mi_lttng_loglevel_str_jul_severe
;
165 extern const char * const mi_lttng_loglevel_str_jul_warning
;
167 /* String related to loglevel Log4j */
168 extern const char * const mi_lttng_loglevel_str_log4j_off
;
169 extern const char * const mi_lttng_loglevel_str_log4j_fatal
;
170 extern const char * const mi_lttng_loglevel_str_log4j_error
;
171 extern const char * const mi_lttng_loglevel_str_log4j_warn
;
172 extern const char * const mi_lttng_loglevel_str_log4j_info
;
173 extern const char * const mi_lttng_loglevel_str_log4j_debug
;
174 extern const char * const mi_lttng_loglevel_str_log4j_trace
;
175 extern const char * const mi_lttng_loglevel_str_log4j_all
;
177 /* String related to loglevel Python */
178 extern const char * const mi_lttng_loglevel_str_python_critical
;
179 extern const char * const mi_lttng_loglevel_str_python_error
;
180 extern const char * const mi_lttng_loglevel_str_python_warning
;
181 extern const char * const mi_lttng_loglevel_str_python_info
;
182 extern const char * const mi_lttng_loglevel_str_python_debug
;
183 extern const char * const mi_lttng_loglevel_str_python_notset
;
185 /* String related to loglevel type */
186 extern const char * const mi_lttng_loglevel_type_all
;
187 extern const char * const mi_lttng_loglevel_type_range
;
188 extern const char * const mi_lttng_loglevel_type_single
;
189 extern const char * const mi_lttng_loglevel_type_unknown
;
191 /* String related to a lttng_snapshot */
192 extern const char * const mi_lttng_element_snapshot_ctrl_url
;
193 extern const char * const mi_lttng_element_snapshot_data_url
;
194 extern const char * const mi_lttng_element_snapshot_max_size
;
195 extern const char * const mi_lttng_element_snapshot_n_ptr
;
196 extern const char * const mi_lttng_element_snapshot_session_name
;
197 extern const char * const mi_lttng_element_snapshots
;
199 /* String related to track/untrack command */
200 extern const char * const mi_lttng_element_track_untrack_all_wildcard
;
202 LTTNG_HIDDEN
extern const char * const mi_lttng_element_session_name
;
204 /* String related to rotate command */
205 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation
;
206 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotate_status
;
207 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule
;
208 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedules
;
209 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_periodic
;
210 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us
;
211 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_size_threshold
;
212 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes
;
213 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_result
;
214 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_schedule_results
;
215 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_state
;
216 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location
;
217 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_local
;
218 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_local_absolute_path
;
219 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay
;
220 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_host
;
221 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_control_port
;
222 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_data_port
;
223 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_protocol
;
224 LTTNG_HIDDEN
extern const char * const mi_lttng_element_rotation_location_relay_relative_path
;
226 /* String related to enum lttng_rotation_state */
227 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_ongoing
;
228 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_completed
;
229 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_expired
;
230 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_state_str_error
;
232 /* String related to enum lttng_trace_archive_location_relay_protocol_type */
233 LTTNG_HIDDEN
extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp
;
235 /* String related to rate_policy elements */
236 LTTNG_HIDDEN
extern const char *const mi_lttng_element_rate_policy
;
237 LTTNG_HIDDEN
extern const char *const mi_lttng_element_rate_policy_every_n
;
238 LTTNG_HIDDEN
extern const char *const mi_lttng_element_rate_policy_once_after_n
;
240 LTTNG_HIDDEN
extern const char
241 *const mi_lttng_element_rate_policy_every_n_interval
;
242 LTTNG_HIDDEN
extern const char
243 *const mi_lttng_element_rate_policy_once_after_n_threshold
;
245 /* String related to action elements */
246 LTTNG_HIDDEN
extern const char *const mi_lttng_element_action
;
247 LTTNG_HIDDEN
extern const char *const mi_lttng_element_action_list
;
248 LTTNG_HIDDEN
extern const char *const mi_lttng_element_action_notify
;
249 LTTNG_HIDDEN
extern const char *const mi_lttng_element_action_start_session
;
250 LTTNG_HIDDEN
extern const char *const mi_lttng_element_action_stop_session
;
251 LTTNG_HIDDEN
extern const char *const mi_lttng_element_action_rotate_session
;
252 LTTNG_HIDDEN
extern const char *const mi_lttng_element_action_snapshot_session
;
253 LTTNG_HIDDEN
extern const char
254 *const mi_lttng_element_action_snapshot_session_output
;
256 /* String related to condition */
257 LTTNG_HIDDEN
extern const char *const mi_lttng_element_condition
;
258 LTTNG_HIDDEN
extern const char
259 *const mi_lttng_element_condition_buffer_usage_high
;
260 LTTNG_HIDDEN
extern const char
261 *const mi_lttng_element_condition_buffer_usage_low
;
262 LTTNG_HIDDEN
extern const char
263 *const mi_lttng_element_condition_event_rule_matches
;
264 LTTNG_HIDDEN
extern const char
265 *const mi_lttng_element_condition_session_consumed_size
;
266 LTTNG_HIDDEN
extern const char
267 *const mi_lttng_element_condition_session_rotation
;
268 LTTNG_HIDDEN
extern const char
269 *const mi_lttng_element_condition_session_rotation_completed
;
270 LTTNG_HIDDEN
extern const char
271 *const mi_lttng_element_condition_session_rotation_ongoing
;
272 LTTNG_HIDDEN
extern const char *const mi_lttng_element_condition_channel_name
;
273 LTTNG_HIDDEN
extern const char *const mi_lttng_element_condition_threshold_ratio
;
274 LTTNG_HIDDEN
extern const char *const mi_lttng_element_condition_threshold_bytes
;
276 /* String related to capture descriptor */
277 LTTNG_HIDDEN
extern const char *const mi_lttng_element_capture_descriptor
;
278 LTTNG_HIDDEN
extern const char *const mi_lttng_element_capture_descriptors
;
280 /* String related to event expression */
281 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_expr
;
282 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_expr_payload_field
;
283 LTTNG_HIDDEN
extern const char
284 *const mi_lttng_element_event_expr_channel_context_field
;
285 LTTNG_HIDDEN
extern const char
286 *const mi_lttng_element_event_expr_app_specific_context_field
;
287 LTTNG_HIDDEN
extern const char
288 *const mi_lttng_element_event_expr_array_field_element
;
290 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_expr_provider_name
;
291 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_expr_type_name
;
292 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_expr_index
;
294 /* String related to event rule */
295 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_rule
;
297 /* String related to lttng_event_rule */
298 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_rule_event_name
;
299 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_rule_name_pattern
;
300 LTTNG_HIDDEN
extern const char
301 *const mi_lttng_element_event_rule_filter_expression
;
302 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_rule_jul_logging
;
303 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_rule_kernel_kprobe
;
304 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_rule_kernel_syscall
;
305 LTTNG_HIDDEN
extern const char
306 *const mi_lttng_element_event_rule_kernel_tracepoint
;
307 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_rule_kernel_uprobe
;
308 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_rule_log4j_logging
;
309 LTTNG_HIDDEN
extern const char *const mi_lttng_element_event_rule_python_logging
;
310 LTTNG_HIDDEN
extern const char
311 *const mi_lttng_element_event_rule_user_tracepoint
;
313 /* String related to lttng_event_rule_kernel_syscall. */
314 LTTNG_HIDDEN
extern const char
315 *const mi_lttng_element_event_rule_kernel_syscall_emission_site
;
317 /* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
318 LTTNG_HIDDEN
extern const char *const
319 mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit
;
320 LTTNG_HIDDEN
extern const char
321 *const mi_lttng_event_rule_kernel_syscall_emission_site_entry
;
322 LTTNG_HIDDEN
extern const char
323 *const mi_lttng_event_rule_kernel_syscall_emission_site_exit
;
325 LTTNG_HIDDEN
extern const char *const
326 mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions
;
327 LTTNG_HIDDEN
extern const char *const
328 mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion
;
330 /* String related to log level rule. */
331 LTTNG_HIDDEN
extern const char *const mi_lttng_element_log_level_rule
;
332 LTTNG_HIDDEN
extern const char *const mi_lttng_element_log_level_rule_exactly
;
333 LTTNG_HIDDEN
extern const char
334 *const mi_lttng_element_log_level_rule_at_least_as_severe_as
;
335 LTTNG_HIDDEN
extern const char *const
336 mi_lttng_element_log_level_rule_at_least_as_severe_as_thre
;
337 LTTNG_HIDDEN
extern const char *const mi_lttng_element_log_level_rule_level
;
339 /* String related to kernel probe location. */
340 LTTNG_HIDDEN
extern const char *const mi_lttng_element_kernel_probe_location
;
341 LTTNG_HIDDEN
extern const char
342 *const mi_lttng_element_kernel_probe_location_symbol_offset
;
343 LTTNG_HIDDEN
extern const char *const
344 mi_lttng_element_kernel_probe_location_symbol_offset_name
;
345 LTTNG_HIDDEN
extern const char *const
346 mi_lttng_element_kernel_probe_location_symbol_offset_offset
;
347 LTTNG_HIDDEN
extern const char
348 *const mi_lttng_element_kernel_probe_location_address
;
349 LTTNG_HIDDEN
extern const char
350 *const mi_lttng_element_kernel_probe_location_address_address
;
352 /* String related to userspace probe location. */
353 LTTNG_HIDDEN
extern const char *const mi_lttng_element_userspace_probe_location
;
354 LTTNG_HIDDEN
extern const char
355 *const mi_lttng_element_userspace_probe_location_binary_path
;
356 LTTNG_HIDDEN
extern const char
357 *const mi_lttng_element_userspace_probe_location_function
;
358 LTTNG_HIDDEN
extern const char
359 *const mi_lttng_element_userspace_probe_location_function_name
;
360 LTTNG_HIDDEN
extern const char
361 *const mi_lttng_element_userspace_probe_location_lookup_method
;
362 LTTNG_HIDDEN
extern const char *const
363 mi_lttng_element_userspace_probe_location_lookup_method_function_default
;
364 LTTNG_HIDDEN
extern const char *const
365 mi_lttng_element_userspace_probe_location_lookup_method_function_elf
;
366 LTTNG_HIDDEN
extern const char *const
367 mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt
;
368 LTTNG_HIDDEN
extern const char
369 *const mi_lttng_element_userspace_probe_location_tracepoint
;
370 LTTNG_HIDDEN
extern const char *const
371 mi_lttng_element_userspace_probe_location_tracepoint_probe_name
;
372 LTTNG_HIDDEN
extern const char *const
373 mi_lttng_element_userspace_probe_location_tracepoint_provider_name
;
375 /* String related to enum
376 * lttng_userspace_probe_location_function_instrumentation_type */
377 LTTNG_HIDDEN
extern const char *const
378 mi_lttng_element_userspace_probe_location_function_instrumentation_type
;
379 LTTNG_HIDDEN
extern const char *const
380 mi_lttng_userspace_probe_location_function_instrumentation_type_entry
;
382 /* String related to trigger */
383 LTTNG_HIDDEN
extern const char *const mi_lttng_element_triggers
;
384 LTTNG_HIDDEN
extern const char *const mi_lttng_element_trigger
;
385 LTTNG_HIDDEN
extern const char *const mi_lttng_element_trigger_owner_uid
;
387 /* String related to error_query. */
388 LTTNG_HIDDEN
extern const char *const mi_lttng_element_error_query_result
;
389 LTTNG_HIDDEN
extern const char
390 *const mi_lttng_element_error_query_result_counter
;
391 LTTNG_HIDDEN
extern const char
392 *const mi_lttng_element_error_query_result_counter_value
;
393 LTTNG_HIDDEN
extern const char
394 *const mi_lttng_element_error_query_result_description
;
395 LTTNG_HIDDEN
extern const char *const mi_lttng_element_error_query_result_name
;
396 LTTNG_HIDDEN
extern const char *const mi_lttng_element_error_query_result_type
;
397 LTTNG_HIDDEN
extern const char *const mi_lttng_element_error_query_results
;
399 /* String related to add-context command */
400 LTTNG_HIDDEN
extern const char * const mi_lttng_element_context_symbol
;
402 /* Utility string function */
403 const char *mi_lttng_loglevel_string(int value
, enum lttng_domain_type domain
);
404 const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value
);
405 const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value
);
406 const char *mi_lttng_domaintype_string(enum lttng_domain_type value
);
407 const char *mi_lttng_buffertype_string(enum lttng_buffer_type value
);
408 const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value
);
409 const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
410 enum lttng_trace_archive_location_relay_protocol_type value
);
413 * Create an instance of a machine interface writer.
415 * fd_output File to which the XML content must be written. The file will be
416 * closed once the mi_writer has been destroyed.
418 * Returns an instance of a machine interface writer on success, NULL on
421 struct mi_writer
*mi_lttng_writer_create(int fd_output
, int mi_output_type
);
424 * Destroy an instance of a machine interface writer.
426 * writer An instance of a machine interface writer.
428 * Returns zero if the XML document could be closed cleanly. Negative values
431 int mi_lttng_writer_destroy(struct mi_writer
*writer
);
434 * Open a command tag and add it's name node.
436 * writer An instance of a machine interface writer.
437 * command The command name.
439 * Returns zero if the XML document could be closed cleanly.
440 * Negative values indicate an error.
442 int mi_lttng_writer_command_open(struct mi_writer
*writer
, const char *command
);
445 * Close a command tag.
447 * writer An instance of a machine interface writer.
449 * Returns zero if the XML document could be closed cleanly.
450 * Negative values indicate an error.
452 int mi_lttng_writer_command_close(struct mi_writer
*writer
);
455 * Open an element tag.
457 * writer An instance of a machine interface writer.
458 * element_name Element tag name.
460 * Returns zero if the XML document could be closed cleanly.
461 * Negative values indicate an error.
463 int mi_lttng_writer_open_element(struct mi_writer
*writer
,
464 const char *element_name
);
467 * Close the current element tag.
469 * writer An instance of a machine interface writer.
471 * Returns zero if the XML document could be closed cleanly.
472 * Negative values indicate an error.
474 int mi_lttng_writer_close_element(struct mi_writer
*writer
);
477 * Close multiple element.
479 * writer An instance of a machine interface writer.
480 * nb_element Number of elements.
482 * Returns zero if the XML document could be closed cleanly.
483 * Negative values indicate an error.
485 int mi_lttng_close_multi_element(struct mi_writer
*writer
,
486 unsigned int nb_element
);
489 * Write an element of type unsigned int.
491 * writer An instance of a machine interface writer.
492 * element_name Element name.
493 * value Unsigned int value of the element
495 * Returns zero if the element's value could be written.
496 * Negative values indicate an error.
498 int mi_lttng_writer_write_element_unsigned_int(struct mi_writer
*writer
,
499 const char *element_name
, uint64_t value
);
502 * Write an element of type signed int.
504 * writer An instance of a machine interface writer.
505 * element_name Element name.
506 * value Signed int value of the element.
508 * Returns zero if the element's value could be written.
509 * Negative values indicate an error.
511 int mi_lttng_writer_write_element_signed_int(struct mi_writer
*writer
,
512 const char *element_name
, int64_t value
);
515 * Write an element of type boolean.
517 * writer An instance of a machine interface writer.
518 * element_name Element name.
519 * value Boolean value of the element.
521 * Returns zero if the element's value could be written.
522 * Negative values indicate an error.
524 int mi_lttng_writer_write_element_bool(struct mi_writer
*writer
,
525 const char *element_name
, int value
);
528 * Write an element of type string.
530 * writer An instance of a machine interface writer.
531 * element_name Element name.
532 * value String value of the element.
534 * Returns zero if the element's value could be written.
535 * Negative values indicate an error.
537 int mi_lttng_writer_write_element_string(struct mi_writer
*writer
,
538 const char *element_name
, const char *value
);
541 * Write an element of type double.
543 * writer An instance of a machine interface writer.
544 * element_name Element name.
545 * value Double value of the element.
547 * Returns zero if the element's value could be written.
548 * Negative values indicate an error.
550 int mi_lttng_writer_write_element_double(struct mi_writer
*writer
,
551 const char *element_name
,
555 * Machine interface of struct version.
557 * writer An instance of a machine interface writer.
558 * version Version struct.
559 * lttng_description String value of the version description.
560 * lttng_license String value of the version license.
562 * Returns zero if the element's value could be written.
563 * Negative values indicate an error.
565 int mi_lttng_version(struct mi_writer
*writer
, struct mi_lttng_version
*version
,
566 const char *lttng_description
, const char *lttng_license
);
569 * Machine interface: open a sessions element.
571 * writer An instance of a machine interface writer.
573 * Returns zero if the element's value could be written.
574 * Negative values indicate an error.
576 int mi_lttng_sessions_open(struct mi_writer
*writer
);
579 * Machine interface of struct session.
581 * writer An instance of a machine interface writer.
582 * session An instance of a session.
583 * is_open Defines whether or not the session element shall be closed.
584 * This should be used carefully and the client
585 * must close the session element.
586 * Use case: nested additional information on a session
587 * ex: domain,channel event.
589 * Returns zero if the element's value could be written.
590 * Negative values indicate an error.
592 int mi_lttng_session(struct mi_writer
*writer
,
593 struct lttng_session
*session
, int is_open
);
596 * Machine interface: open a domains element.
598 * writer An instance of a machine interface writer.
600 * Returns zero if the element's value could be written.
601 * Negative values indicate an error.
603 int mi_lttng_domains_open(struct mi_writer
*writer
);
606 * Machine interface of struct domain.
608 * writer An instance of a machine interface writer.
609 * domain An instance of a domain.
611 * is_open Defines whether or not the session element shall be closed.
612 * This should be used carefully and the client
613 * must close the domain element.
614 * Use case: nested addition information on a domain
617 * Returns zero if the element's value could be written.
618 * Negative values indicate an error.
620 int mi_lttng_domain(struct mi_writer
*writer
,
621 struct lttng_domain
*domain
, int is_open
);
624 * Machine interface: open a channels element.
626 * writer An instance of a machine interface writer.
628 * Returns zero if the element's value could be written.
629 * Negative values indicate an error.
631 int mi_lttng_channels_open(struct mi_writer
*writer
);
634 * Machine interface of struct channel.
636 * writer An instance of a machine interface writer.
637 * channel An instance of a channel.
639 * is_open Defines whether or not the session element shall be closed.
640 * This should be used carefully and the client
641 * must close the channel element.
642 * Use case: nested addition information on a channel.
645 * Returns zero if the element's value could be written.
646 * Negative values indicate an error.
648 int mi_lttng_channel(struct mi_writer
*writer
,
649 struct lttng_channel
*channel
, int is_open
);
652 * Machine interface of struct channel_attr.
654 * writer An instance of a machine interface writer.
655 * attr An instance of a channel_attr struct.
657 * Returns zero if the element's value could be written.
658 * Negative values indicate an error.
660 int mi_lttng_channel_attr(struct mi_writer
*writer
,
661 struct lttng_channel_attr
*attr
);
664 * Machine interface for event common attributes.
666 * writer An instance of a mi writer.
667 * event single trace event.
669 * The common attribute are:
676 * Returns zero if the element's value could be written.
677 * Negative values indicate an error.
679 int mi_lttng_event_common_attributes(struct mi_writer
*writer
,
680 struct lttng_event
*event
);
683 * Machine interface for kernel tracepoint event with a loglevel.
685 * writer An instance of a mi writer.
686 * event single trace event.
687 * domain Event's domain
689 * Returns zero if the element's value could be written.
690 * Negative values indicate an error.
692 int mi_lttng_event_tracepoint_loglevel(struct mi_writer
*writer
,
693 struct lttng_event
*event
, enum lttng_domain_type domain
);
696 * Machine interface for kernel tracepoint event with no loglevel.
698 * writer An instance of a mi writer.
699 * event single trace event.
701 * Returns zero if the element's value could be written.
702 * Negative values indicate an error.
704 int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer
*writer
,
705 struct lttng_event
*event
);
708 * Machine interface for kernel function and probe event.
710 * writer An instance of a mi writer.
711 * event single trace event.
713 * Returns zero if the element's value could be written.
714 * Negative values indicate an error.
716 int mi_lttng_event_function_probe(struct mi_writer
*writer
,
717 struct lttng_event
*event
);
720 * Machine interface for kernel function entry event.
722 * writer An instance of a mi writer.
723 * event single trace event.
725 * Returns zero if the element's value could be written.
726 * Negative values indicate an error.
728 int mi_lttng_event_function_entry(struct mi_writer
*writer
,
729 struct lttng_event
*event
);
732 * Machine interface: open an events element.
734 * writer An instance of a machine interface writer.
736 * Returns zero if the element's value could be written.
737 * Negative values indicate an error.
739 int mi_lttng_events_open(struct mi_writer
*writer
);
742 * Machine interface for printing an event.
743 * The trace event type currently supported are:
750 * writer An instance of a mi writer.
751 * event single trace event.
752 * is_open Defines whether or not the session element shall be closed.
753 * This should be used carefully and the client
754 * must close the event element.
755 * Use case: nested additional information
756 * domain Event's domain
758 * Returns zero if the element's value could be written.
759 * Negative values indicate an error.
761 int mi_lttng_event(struct mi_writer
*writer
, struct lttng_event
*event
,
762 int is_open
, enum lttng_domain_type domain
);
765 * Machine interface for struct lttng_event_field.
767 * writer An instance of a mi writer.
768 * field An event_field instance.
770 * Returns zero if the element's value could be written.
771 * Negative values indicate an error.
773 int mi_lttng_event_field(struct mi_writer
*writer
,
774 struct lttng_event_field
*field
);
777 * Machine interface: open a event_fields element.
779 * writer An instance of a machine interface writer.
781 * Returns zero if the element have be written.
782 * Negative values indicate an error.
784 int mi_lttng_event_fields_open(struct mi_writer
*writer
);
787 * Machine interface: open a trackers element.
789 * writer An instance of a machine interface writer.
791 * Returns zero if the element's value could be written.
792 * Negative values indicate an error.
794 int mi_lttng_trackers_open(struct mi_writer
*writer
);
797 * Machine interface: open a process attribute tracker element.
799 * writer An instance of a machine interface writer.
801 * Returns zero if the element's value could be written.
802 * Negative values indicate an error.
804 * Note: A targets element is also opened for each tracker definition
806 int mi_lttng_process_attribute_tracker_open(
807 struct mi_writer
*writer
, enum lttng_process_attr process_attr
);
810 * Machine interface: open a PIDs element.
812 * writer An instance of a machine interface writer.
814 * Returns zero if the element's value could be written.
815 * Negative values indicate an error.
817 int mi_lttng_pids_open(struct mi_writer
*writer
);
820 * Machine interface: open a processes element.
822 * writer An instance of a machine interface writer.
824 * Returns zero if the element's value could be written.
825 * Negative values indicate an error.
827 int mi_lttng_processes_open(struct mi_writer
*writer
);
830 * Machine interface of a Process.
832 * writer An instance of a machine interface writer.
835 * is_open Defines whether or not the session element shall be closed.
836 * This should be used carefully and the client
837 * must close the pid element.
838 * Use case: nested addition information on a domain
841 * Returns zero if the element's value could be written.
842 * Negative values indicate an error.
844 int mi_lttng_process(struct mi_writer
*writer
, pid_t pid
, const char *name
,
848 * TODO: move pid of lttng list -u to process semantic on mi api bump
849 * Machine interface of a Process.
851 * writer An instance of a machine interface writer.
854 * is_open Defines whether or not the session element shall be closed.
855 * This should be used carefully and the client
856 * must close the pid element.
857 * Use case: nested addition information on a domain
860 * Returns zero if the element's value could be written.
861 * Negative values indicate an error.
863 int mi_lttng_pid(struct mi_writer
*writer
, pid_t pid
, const char *name
,
867 * Machine interface: open a process attribute values element.
869 * writer An instance of a machine interface writer.
871 * Returns zero if the element's value could be written.
872 * Negative values indicate an error.
874 int mi_lttng_process_attr_values_open(struct mi_writer
*writer
);
877 * Machine interface for track/untrack of all process attribute values.
879 * writer An instance of a machine interface writer.
881 * Returns zero if the element's value could be written.
882 * Negative values indicate an error.
884 int mi_lttng_all_process_attribute_value(struct mi_writer
*writer
,
885 enum lttng_process_attr process_attr
,
889 * Machine interface for track/untrack of an integral process attribute value.
891 * writer An instance of a machine interface writer.
893 * Returns zero if the element's value could be written.
894 * Negative values indicate an error.
896 int mi_lttng_integral_process_attribute_value(struct mi_writer
*writer
,
897 enum lttng_process_attr process_attr
,
902 * Machine interface for track/untrack of a string process attribute value.
904 * writer An instance of a machine interface writer.
906 * Returns zero if the element's value could be written.
907 * Negative values indicate an error.
909 int mi_lttng_string_process_attribute_value(struct mi_writer
*writer
,
910 enum lttng_process_attr process_attr
,
915 * Machine interface of a context.
917 * writer An instance of a machine interface writer
919 * context An instance of a lttng_event_context
921 * is_open Define if we close the context element
922 * This should be used carefully and the client
923 * need to close the context element.
924 * Returns zero if the element's value could be written.
925 * Negative values indicate an error.
927 int mi_lttng_context(struct mi_writer
*writer
,
928 struct lttng_event_context
*context
, int is_open
);
931 * Machine interface of a perf_counter_context.
933 * writer An instance of a machine interface writer
935 * contest An instance of a lttng_event_perf_counter_ctx
937 * Returns zero if the element's value could be written.
938 * Negative values indicate an error.
940 int mi_lttng_perf_counter_context(struct mi_writer
*writer
,
941 struct lttng_event_perf_counter_ctx
*perf_context
);
944 * Machine interface of the snapshot list_output.
945 * It specifies the session for which we are listing snapshots,
946 * and it opens a snapshots element to list a sequence
949 * writer An instance of a machine interface writer.
951 * session_name: Snapshot output for session "session_name".
953 * Note: The client has to close the session and the snapshots elements after
954 * having listed every lttng_snapshot_output.
956 * Returns zero if the element's value could be written.
957 * Negative values indicate an error.
959 int mi_lttng_snapshot_output_session_name(struct mi_writer
*writer
,
960 const char *session_name
);
963 * Machine interface of the snapshot output.
964 * The machine interface serializes the following attributes:
965 * - id: ID of the snapshot output.
966 * - name: Name of the output.
967 * - data_url : Destination of the output.
968 * - ctrl_url: Destination of the output.
969 * - max_size: total size of all stream combined.
971 * writer An instance of a machine interface writer.
973 * output: A list of snapshot_output.
975 * Returns zero if the element's value could be written.
976 * Negative values indicate an error.
978 int mi_lttng_snapshot_list_output(struct mi_writer
*writer
,
979 const struct lttng_snapshot_output
*output
);
982 * Machine interface of the output of the command snapshot del output
983 * when deleting a snapshot either by id or by name.
984 * If the snapshot was found and successfully deleted using its id,
985 * it return the id of the snapshot and the current session name on which it
988 * Otherwise, it do the same process with the name of the snapshot, if the
989 * snapshot output id is undefined.
991 * writer An instance of a machine interface writer.
993 * id: ID of the snapshot output.
995 * name: Name of the snapshot.
997 * current_session_name: Session to which the snapshot belongs.
999 * Returns zero if the element's value could be written.
1000 * Negative values indicate an error.
1002 int mi_lttng_snapshot_del_output(struct mi_writer
*writer
, int id
,
1003 const char *name
, const char *current_session_name
);
1006 * Machine interface of the output of the command snapshot add output
1007 * when adding a snapshot from a user URL.
1009 * If the snapshot was successfully added, the machine interface lists
1010 * these information:
1011 * - id: ID of the newly add snapshot output.
1012 * - current_session_name: Name of the session to which the output was added.
1013 * - ctrl_url: Destination of the output.
1014 * - max_size: total size of all stream combined.
1016 * writer An instance of a machine interface writer.
1018 * current_session_name: Session to which the snapshot belongs.
1022 * output: iterator over a lttng_snapshot_output_list which contain
1023 * the snapshot output informations.
1025 * Returns zero if the element's value could be written.
1026 * Negative values indicate an error.
1028 int mi_lttng_snapshot_add_output(struct mi_writer
*writer
,
1029 const char *current_session_name
, const char *n_ptr
,
1030 struct lttng_snapshot_output
*output
);
1033 * Machine interface of the output of the command snapshot
1034 * record from a URL (if given).
1036 * If the snapshot is successfully recorded from a url, the machine interface
1037 * output the following information:
1038 * - url: Destination of the output stored in the snapshot.
1040 * Otherwise, the machine interface output the data and ctrl url received
1041 * from the command-line.
1043 * writer An instance of a machine interface writer.
1045 * current_session_name: Snapshot record for session "current_session_name".
1047 * ctrl_url, data_url: Destination of the output receive from the command-line.
1049 * Returns zero if the element's value could be written.
1050 * Negative values indicate an error.
1052 int mi_lttng_snapshot_record(struct mi_writer
*writer
,
1053 const char *current_session_name
, const char *url
,
1054 const char *cmdline_ctrl_url
, const char *cmdline_data_url
);
1057 * Machine interface representation of a session rotation schedule.
1059 * The machine interface serializes the provided schedule as one of the choices
1060 * from 'rotation_schedule_type'.
1062 * writer: An instance of a machine interface writer.
1064 * schedule: An lttng rotation schedule descriptor object.
1066 * Returns zero if the element's value could be written.
1067 * Negative values indicate an error.
1069 int mi_lttng_rotation_schedule(struct mi_writer
*writer
,
1070 const struct lttng_rotation_schedule
*schedule
);
1073 * Machine interface of a session rotation schedule result.
1074 * This is an element that is part of the output of the enable-rotation and
1075 * disable-rotation commands.
1077 * The machine interface provides the following information:
1078 * - schedule: the session rotation schedule descriptor.
1079 * - success: whether the sub-command succeeded.
1081 * writer: An instance of a machine interface writer.
1083 * schedule: An lttng rotation schedule descriptor object.
1085 * success: Whether the sub-command suceeded.
1087 * Returns zero if the element's value could be written.
1088 * Negative values indicate an error.
1090 int mi_lttng_rotation_schedule_result(struct mi_writer
*writer
,
1091 const struct lttng_rotation_schedule
*schedule
,
1095 * Machine interface of a session rotation result.
1096 * This is an element that is part of the output of the rotate command.
1098 * The machine interface provides the following information:
1099 * - session_name: the session to be rotated.
1100 * - state: the session rotation state.
1101 * - location: the location of the completed chunk archive.
1103 * writer: An instance of a machine interface writer.
1105 * session_name: The session to which the rotate command applies.
1107 * location: A location descriptor object.
1109 * success: Whether the sub-command suceeded.
1111 * Returns zero if the element's value could be written.
1112 * Negative values indicate an error.
1114 int mi_lttng_rotate(struct mi_writer
*writer
,
1115 const char *session_name
,
1116 enum lttng_rotation_state rotation_state
,
1117 const struct lttng_trace_archive_location
*location
);
1119 #endif /* _MI_LTTNG_H */