Tests: Fix: Use '.logfile' instead of '.log' for test app output
[lttng-tools.git] / src / common / mi-lttng.hpp
CommitLineData
c7e35b03 1/*
4b2b86f2 2 * Copyright (C) 2014 EfficiOS Inc.
ab5be9fa 3 * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
c7e35b03 4 *
c922647d 5 * SPDX-License-Identifier: LGPL-2.1-only
c7e35b03 6 *
c7e35b03
JR
7 */
8
9#ifndef _MI_LTTNG_H
10#define _MI_LTTNG_H
11
28f23191 12#include <common/config/session-config.hpp>
c9e313bc
SM
13#include <common/error.hpp>
14#include <common/macros.hpp>
28f23191 15
c7e35b03
JR
16#include <lttng/lttng.h>
17
28f23191
JG
18#include <stdint.h>
19
50534d6f
JRJ
20/* Don't want to reference snapshot-internal.h here */
21struct lttng_snapshot_output;
22
c7e35b03
JR
23/* Instance of a machine interface writer. */
24struct mi_writer {
25 struct config_writer *writer;
26 enum lttng_mi_output_type type;
27};
28
29/*
30 * Version information for the machine interface.
31 */
48a40005 32struct mi_lttng_version_data {
36d2e35d 33 char version[LTTNG_NAME_MAX]; /* Version number of package */
c7e35b03
JR
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 */
36d2e35d
MJ
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. */
c7e35b03
JR
40};
41
6a751b95 42/* Error query callbacks. */
e665dfbc
JG
43using mi_lttng_error_query_trigger_cb = enum lttng_error_code (*)(
44 const struct lttng_trigger *, struct lttng_error_query_results **);
45using mi_lttng_error_query_condition_cb = enum lttng_error_code (*)(
46 const struct lttng_trigger *, struct lttng_error_query_results **);
47using 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 **);
6a751b95
JR
51
52struct 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;
56};
57
c7e35b03 58/* Strings related to command */
28f23191
JG
59LTTNG_EXPORT extern const char *const mi_lttng_element_command;
60LTTNG_EXPORT extern const char *const mi_lttng_element_command_action;
61LTTNG_EXPORT extern const char *const mi_lttng_element_command_add_context;
62extern const char *const mi_lttng_element_command_add_trigger;
63LTTNG_EXPORT extern const char *const mi_lttng_element_command_create;
64LTTNG_EXPORT extern const char *const mi_lttng_element_command_destroy;
65LTTNG_EXPORT extern const char *const mi_lttng_element_command_disable_channel;
66LTTNG_EXPORT extern const char *const mi_lttng_element_command_disable_event;
67LTTNG_EXPORT extern const char *const mi_lttng_element_command_enable_channels;
68LTTNG_EXPORT extern const char *const mi_lttng_element_command_enable_event;
69LTTNG_EXPORT extern const char *const mi_lttng_element_command_list;
70extern const char *const mi_lttng_element_command_list_trigger;
71LTTNG_EXPORT extern const char *const mi_lttng_element_command_load;
72extern const char *const mi_lttng_element_command_metadata;
73extern const char *const mi_lttng_element_command_metadata_action;
74extern const char *const mi_lttng_element_command_regenerate;
75extern const char *const mi_lttng_element_command_regenerate_action;
76LTTNG_EXPORT extern const char *const mi_lttng_element_command_name;
77LTTNG_EXPORT extern const char *const mi_lttng_element_command_output;
78extern const char *const mi_lttng_element_command_remove_trigger;
79LTTNG_EXPORT extern const char *const mi_lttng_element_command_save;
80LTTNG_EXPORT extern const char *const mi_lttng_element_command_set_session;
81LTTNG_EXPORT extern const char *const mi_lttng_element_command_snapshot;
82LTTNG_EXPORT extern const char *const mi_lttng_element_command_snapshot_add;
83LTTNG_EXPORT extern const char *const mi_lttng_element_command_snapshot_del;
84LTTNG_EXPORT extern const char *const mi_lttng_element_command_snapshot_list;
85LTTNG_EXPORT extern const char *const mi_lttng_element_command_snapshot_record;
86LTTNG_EXPORT extern const char *const mi_lttng_element_command_start;
87LTTNG_EXPORT extern const char *const mi_lttng_element_command_stop;
88LTTNG_EXPORT extern const char *const mi_lttng_element_command_success;
89LTTNG_EXPORT extern const char *const mi_lttng_element_command_track;
90LTTNG_EXPORT extern const char *const mi_lttng_element_command_untrack;
91LTTNG_EXPORT extern const char *const mi_lttng_element_command_version;
92extern const char *const mi_lttng_element_command_rotate;
93extern const char *const mi_lttng_element_command_enable_rotation;
94extern const char *const mi_lttng_element_command_disable_rotation;
95extern const char *const mi_lttng_element_command_clear;
c7e35b03 96
1734c658 97/* Strings related to version command */
28f23191
JG
98LTTNG_EXPORT extern const char *const mi_lttng_element_version;
99LTTNG_EXPORT extern const char *const mi_lttng_element_version_commit;
100LTTNG_EXPORT extern const char *const mi_lttng_element_version_description;
101LTTNG_EXPORT extern const char *const mi_lttng_element_version_license;
102LTTNG_EXPORT extern const char *const mi_lttng_element_version_major;
103LTTNG_EXPORT extern const char *const mi_lttng_element_version_minor;
104LTTNG_EXPORT extern const char *const mi_lttng_element_version_patch_level;
105LTTNG_EXPORT extern const char *const mi_lttng_element_version_str;
106LTTNG_EXPORT extern const char *const mi_lttng_element_version_web;
c7e35b03 107
5e18ec73 108/* String related to a lttng_event_field */
28f23191
JG
109LTTNG_EXPORT extern const char *const mi_lttng_element_event_field;
110LTTNG_EXPORT extern const char *const mi_lttng_element_event_fields;
5e18ec73 111
89b72577 112/* String related to lttng_event_perf_counter_ctx */
28f23191 113LTTNG_EXPORT extern const char *const mi_lttng_element_perf_counter_context;
89b72577 114
5e18ec73 115/* Strings related to pid */
28f23191 116LTTNG_EXPORT extern const char *const mi_lttng_element_pid_id;
5e18ec73 117
1734c658 118/* Strings related to save command */
28f23191 119LTTNG_EXPORT extern const char *const mi_lttng_element_save;
1734c658
JRJ
120
121/* Strings related to load command */
28f23191
JG
122LTTNG_EXPORT extern const char *const mi_lttng_element_load;
123extern const char *const mi_lttng_element_load_overrides;
124extern const char *const mi_lttng_element_load_override_url;
1734c658 125
5e18ec73 126/* General element of mi_lttng */
28f23191
JG
127LTTNG_EXPORT extern const char *const mi_lttng_element_empty;
128LTTNG_EXPORT extern const char *const mi_lttng_element_id;
129LTTNG_EXPORT extern const char *const mi_lttng_element_nowrite;
130LTTNG_EXPORT extern const char *const mi_lttng_element_success;
131LTTNG_EXPORT extern const char *const mi_lttng_element_type_enum;
132LTTNG_EXPORT extern const char *const mi_lttng_element_type_float;
133LTTNG_EXPORT extern const char *const mi_lttng_element_type_integer;
134LTTNG_EXPORT extern const char *const mi_lttng_element_type_other;
135LTTNG_EXPORT extern const char *const mi_lttng_element_type_string;
5e18ec73
JR
136
137/* String related to loglevel */
28f23191
JG
138LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_alert;
139LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_crit;
140LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug;
141LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_function;
142LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_line;
143LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_module;
144LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_process;
145LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_program;
146LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_system;
147LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_debug_unit;
148LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_emerg;
149LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_err;
150LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_info;
151LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_notice;
152LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_unknown;
153LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_warning;
5e18ec73 154
136f2f81 155/* String related to loglevel JUL */
28f23191
JG
156LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_all;
157LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_config;
158LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_fine;
159LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_finer;
160LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_finest;
161LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_info;
162LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_off;
163LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_severe;
164LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_jul_warning;
136f2f81 165
970d848b 166/* String related to loglevel Log4j */
28f23191
JG
167LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_off;
168LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_fatal;
169LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_error;
170LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_warn;
171LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_info;
172LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_debug;
173LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_trace;
174LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_log4j_all;
970d848b 175
47abf22b
MJ
176/* String related to loglevel Log4j2 */
177extern const char *const mi_lttng_loglevel_str_log4j2_off;
178extern const char *const mi_lttng_loglevel_str_log4j2_fatal;
179extern const char *const mi_lttng_loglevel_str_log4j2_error;
180extern const char *const mi_lttng_loglevel_str_log4j2_warn;
181extern const char *const mi_lttng_loglevel_str_log4j2_info;
182extern const char *const mi_lttng_loglevel_str_log4j2_debug;
183extern const char *const mi_lttng_loglevel_str_log4j2_trace;
184extern const char *const mi_lttng_loglevel_str_log4j2_all;
185
0e115563 186/* String related to loglevel Python */
28f23191
JG
187LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_critical;
188LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_error;
189LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_warning;
190LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_info;
191LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_debug;
192LTTNG_EXPORT extern const char *const mi_lttng_loglevel_str_python_notset;
0e115563 193
1734c658 194/* String related to loglevel type */
28f23191
JG
195LTTNG_EXPORT extern const char *const mi_lttng_loglevel_type_all;
196LTTNG_EXPORT extern const char *const mi_lttng_loglevel_type_range;
197LTTNG_EXPORT extern const char *const mi_lttng_loglevel_type_single;
198LTTNG_EXPORT extern const char *const mi_lttng_loglevel_type_unknown;
5e18ec73 199
136f2f81 200/* String related to a lttng_snapshot */
28f23191
JG
201LTTNG_EXPORT extern const char *const mi_lttng_element_snapshot_ctrl_url;
202LTTNG_EXPORT extern const char *const mi_lttng_element_snapshot_data_url;
203LTTNG_EXPORT extern const char *const mi_lttng_element_snapshot_max_size;
204LTTNG_EXPORT extern const char *const mi_lttng_element_snapshot_n_ptr;
205LTTNG_EXPORT extern const char *const mi_lttng_element_snapshot_session_name;
206LTTNG_EXPORT extern const char *const mi_lttng_element_snapshots;
50534d6f 207
a23cb78a 208/* String related to track/untrack command */
28f23191 209LTTNG_EXPORT extern const char *const mi_lttng_element_track_untrack_all_wildcard;
a23cb78a 210
28f23191 211extern const char *const mi_lttng_element_session_name;
d68c9a04
JD
212
213/* String related to rotate command */
28f23191
JG
214extern const char *const mi_lttng_element_rotation;
215extern const char *const mi_lttng_element_rotate_status;
216extern const char *const mi_lttng_element_rotation_schedule;
217extern const char *const mi_lttng_element_rotation_schedules;
218extern const char *const mi_lttng_element_rotation_schedule_periodic;
219extern const char *const mi_lttng_element_rotation_schedule_periodic_time_us;
220extern const char *const mi_lttng_element_rotation_schedule_size_threshold;
221extern const char *const mi_lttng_element_rotation_schedule_size_threshold_bytes;
222extern const char *const mi_lttng_element_rotation_schedule_result;
223extern const char *const mi_lttng_element_rotation_schedule_results;
224extern const char *const mi_lttng_element_rotation_state;
225extern const char *const mi_lttng_element_rotation_location;
226extern const char *const mi_lttng_element_rotation_location_local;
227extern const char *const mi_lttng_element_rotation_location_local_absolute_path;
228extern const char *const mi_lttng_element_rotation_location_relay;
229extern const char *const mi_lttng_element_rotation_location_relay_host;
230extern const char *const mi_lttng_element_rotation_location_relay_control_port;
231extern const char *const mi_lttng_element_rotation_location_relay_data_port;
232extern const char *const mi_lttng_element_rotation_location_relay_protocol;
233extern const char *const mi_lttng_element_rotation_location_relay_relative_path;
91c4d516
JG
234
235/* String related to enum lttng_rotation_state */
28f23191
JG
236extern const char *const mi_lttng_rotation_state_str_ongoing;
237extern const char *const mi_lttng_rotation_state_str_completed;
238extern const char *const mi_lttng_rotation_state_str_expired;
239extern const char *const mi_lttng_rotation_state_str_error;
91c4d516
JG
240
241/* String related to enum lttng_trace_archive_location_relay_protocol_type */
28f23191 242extern const char *const mi_lttng_rotation_location_relay_protocol_str_tcp;
d68c9a04 243
6a751b95 244/* String related to rate_policy elements */
ca806b0b
SM
245extern const char *const mi_lttng_element_rate_policy;
246extern const char *const mi_lttng_element_rate_policy_every_n;
247extern const char *const mi_lttng_element_rate_policy_once_after_n;
6a751b95 248
28f23191
JG
249extern const char *const mi_lttng_element_rate_policy_every_n_interval;
250extern const char *const mi_lttng_element_rate_policy_once_after_n_threshold;
6a751b95
JR
251
252/* String related to action elements */
ca806b0b
SM
253extern const char *const mi_lttng_element_action;
254extern const char *const mi_lttng_element_action_list;
255extern const char *const mi_lttng_element_action_notify;
256extern const char *const mi_lttng_element_action_start_session;
257extern const char *const mi_lttng_element_action_stop_session;
258extern const char *const mi_lttng_element_action_rotate_session;
259extern const char *const mi_lttng_element_action_snapshot_session;
28f23191 260extern const char *const mi_lttng_element_action_snapshot_session_output;
6a751b95
JR
261
262/* String related to condition */
ca806b0b 263extern const char *const mi_lttng_element_condition;
28f23191
JG
264extern const char *const mi_lttng_element_condition_buffer_usage_high;
265extern const char *const mi_lttng_element_condition_buffer_usage_low;
266extern const char *const mi_lttng_element_condition_event_rule_matches;
267extern const char *const mi_lttng_element_condition_session_consumed_size;
268extern const char *const mi_lttng_element_condition_session_rotation;
269extern const char *const mi_lttng_element_condition_session_rotation_completed;
270extern const char *const mi_lttng_element_condition_session_rotation_ongoing;
ca806b0b
SM
271extern const char *const mi_lttng_element_condition_channel_name;
272extern const char *const mi_lttng_element_condition_threshold_ratio;
273extern const char *const mi_lttng_element_condition_threshold_bytes;
6a751b95
JR
274
275/* String related to capture descriptor */
ca806b0b
SM
276extern const char *const mi_lttng_element_capture_descriptor;
277extern const char *const mi_lttng_element_capture_descriptors;
6a751b95
JR
278
279/* String related to event expression */
ca806b0b
SM
280extern const char *const mi_lttng_element_event_expr;
281extern const char *const mi_lttng_element_event_expr_payload_field;
28f23191
JG
282extern const char *const mi_lttng_element_event_expr_channel_context_field;
283extern const char *const mi_lttng_element_event_expr_app_specific_context_field;
284extern const char *const mi_lttng_element_event_expr_array_field_element;
6a751b95 285
ca806b0b
SM
286extern const char *const mi_lttng_element_event_expr_provider_name;
287extern const char *const mi_lttng_element_event_expr_type_name;
288extern const char *const mi_lttng_element_event_expr_index;
6a751b95
JR
289
290/* String related to event rule */
ca806b0b 291extern const char *const mi_lttng_element_event_rule;
6a751b95
JR
292
293/* String related to lttng_event_rule */
ca806b0b
SM
294extern const char *const mi_lttng_element_event_rule_event_name;
295extern const char *const mi_lttng_element_event_rule_name_pattern;
28f23191 296extern const char *const mi_lttng_element_event_rule_filter_expression;
ca806b0b
SM
297extern const char *const mi_lttng_element_event_rule_jul_logging;
298extern const char *const mi_lttng_element_event_rule_kernel_kprobe;
299extern const char *const mi_lttng_element_event_rule_kernel_syscall;
28f23191 300extern const char *const mi_lttng_element_event_rule_kernel_tracepoint;
ca806b0b
SM
301extern const char *const mi_lttng_element_event_rule_kernel_uprobe;
302extern const char *const mi_lttng_element_event_rule_log4j_logging;
47abf22b 303extern const char *const mi_lttng_element_event_rule_log4j2_logging;
ca806b0b 304extern const char *const mi_lttng_element_event_rule_python_logging;
28f23191 305extern const char *const mi_lttng_element_event_rule_user_tracepoint;
6a751b95
JR
306
307/* String related to lttng_event_rule_kernel_syscall. */
28f23191 308extern const char *const mi_lttng_element_event_rule_kernel_syscall_emission_site;
6a751b95
JR
309
310/* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
28f23191
JG
311extern const char *const mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit;
312extern const char *const mi_lttng_event_rule_kernel_syscall_emission_site_entry;
313extern const char *const mi_lttng_event_rule_kernel_syscall_emission_site_exit;
314
315extern const char *const mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions;
316extern const char *const mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion;
6a751b95
JR
317
318/* String related to log level rule. */
ca806b0b
SM
319extern const char *const mi_lttng_element_log_level_rule;
320extern const char *const mi_lttng_element_log_level_rule_exactly;
28f23191
JG
321extern const char *const mi_lttng_element_log_level_rule_at_least_as_severe_as;
322extern const char *const mi_lttng_element_log_level_rule_at_least_as_severe_as_thre;
ca806b0b 323extern const char *const mi_lttng_element_log_level_rule_level;
6a751b95
JR
324
325/* String related to kernel probe location. */
ca806b0b 326extern const char *const mi_lttng_element_kernel_probe_location;
28f23191
JG
327extern const char *const mi_lttng_element_kernel_probe_location_symbol_offset;
328extern const char *const mi_lttng_element_kernel_probe_location_symbol_offset_name;
329extern const char *const mi_lttng_element_kernel_probe_location_symbol_offset_offset;
330extern const char *const mi_lttng_element_kernel_probe_location_address;
331extern const char *const mi_lttng_element_kernel_probe_location_address_address;
6a751b95
JR
332
333/* String related to userspace probe location. */
ca806b0b 334extern const char *const mi_lttng_element_userspace_probe_location;
28f23191
JG
335extern const char *const mi_lttng_element_userspace_probe_location_binary_path;
336extern const char *const mi_lttng_element_userspace_probe_location_function;
337extern const char *const mi_lttng_element_userspace_probe_location_function_name;
338extern const char *const mi_lttng_element_userspace_probe_location_lookup_method;
339extern const char *const mi_lttng_element_userspace_probe_location_lookup_method_function_default;
340extern const char *const mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
341extern const char *const mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
342extern const char *const mi_lttng_element_userspace_probe_location_tracepoint;
343extern const char *const mi_lttng_element_userspace_probe_location_tracepoint_probe_name;
344extern const char *const mi_lttng_element_userspace_probe_location_tracepoint_provider_name;
6a751b95
JR
345
346/* String related to enum
347 * lttng_userspace_probe_location_function_instrumentation_type */
28f23191
JG
348extern const char *const mi_lttng_element_userspace_probe_location_function_instrumentation_type;
349extern const char *const mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
6a751b95
JR
350
351/* String related to trigger */
ca806b0b
SM
352extern const char *const mi_lttng_element_triggers;
353extern const char *const mi_lttng_element_trigger;
354extern const char *const mi_lttng_element_trigger_owner_uid;
6a751b95
JR
355
356/* String related to error_query. */
ca806b0b 357extern const char *const mi_lttng_element_error_query_result;
28f23191
JG
358extern const char *const mi_lttng_element_error_query_result_counter;
359extern const char *const mi_lttng_element_error_query_result_counter_value;
360extern const char *const mi_lttng_element_error_query_result_description;
ca806b0b
SM
361extern const char *const mi_lttng_element_error_query_result_name;
362extern const char *const mi_lttng_element_error_query_result_type;
363extern const char *const mi_lttng_element_error_query_results;
6a751b95 364
59deec0c 365/* String related to add-context command */
28f23191 366extern const char *const mi_lttng_element_context_symbol;
59deec0c 367
5e18ec73 368/* Utility string function */
970d848b 369const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
5e18ec73
JR
370const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value);
371const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value);
372const char *mi_lttng_domaintype_string(enum lttng_domain_type value);
373const char *mi_lttng_buffertype_string(enum lttng_buffer_type value);
91c4d516
JG
374const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value);
375const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
28f23191 376 enum lttng_trace_archive_location_relay_protocol_type value);
5e18ec73 377
c7e35b03
JR
378/*
379 * Create an instance of a machine interface writer.
380 *
381 * fd_output File to which the XML content must be written. The file will be
382 * closed once the mi_writer has been destroyed.
383 *
384 * Returns an instance of a machine interface writer on success, NULL on
385 * error.
386 */
387struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);
388
389/*
390 * Destroy an instance of a machine interface writer.
391 *
392 * writer An instance of a machine interface writer.
393 *
394 * Returns zero if the XML document could be closed cleanly. Negative values
395 * indicate an error.
396 */
397int mi_lttng_writer_destroy(struct mi_writer *writer);
398
399/*
400 * Open a command tag and add it's name node.
401 *
402 * writer An instance of a machine interface writer.
c7e35b03
JR
403 * command The command name.
404 *
405 * Returns zero if the XML document could be closed cleanly.
406 * Negative values indicate an error.
407 */
408int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);
409
410/*
411 * Close a command tag.
412 *
413 * writer An instance of a machine interface writer.
414 *
415 * Returns zero if the XML document could be closed cleanly.
416 * Negative values indicate an error.
417 */
418int mi_lttng_writer_command_close(struct mi_writer *writer);
419
420/*
421 * Open an element tag.
422 *
423 * writer An instance of a machine interface writer.
c7e35b03
JR
424 * element_name Element tag name.
425 *
426 * Returns zero if the XML document could be closed cleanly.
427 * Negative values indicate an error.
428 */
28f23191 429int mi_lttng_writer_open_element(struct mi_writer *writer, const char *element_name);
c7e35b03
JR
430
431/*
432 * Close the current element tag.
433 *
434 * writer An instance of a machine interface writer.
435 *
436 * Returns zero if the XML document could be closed cleanly.
437 * Negative values indicate an error.
438 */
439int mi_lttng_writer_close_element(struct mi_writer *writer);
440
441/*
5e18ec73 442 * Close multiple element.
c7e35b03
JR
443 *
444 * writer An instance of a machine interface writer.
5e18ec73 445 * nb_element Number of elements.
c7e35b03 446 *
5e18ec73
JR
447 * Returns zero if the XML document could be closed cleanly.
448 * Negative values indicate an error.
449 */
28f23191 450int mi_lttng_close_multi_element(struct mi_writer *writer, unsigned int nb_element);
5e18ec73
JR
451
452/*
453 * Write an element of type unsigned int.
c7e35b03 454 *
5e18ec73
JR
455 * writer An instance of a machine interface writer.
456 * element_name Element name.
c7e35b03
JR
457 * value Unsigned int value of the element
458 *
459 * Returns zero if the element's value could be written.
460 * Negative values indicate an error.
461 */
462int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
28f23191
JG
463 const char *element_name,
464 uint64_t value);
c7e35b03
JR
465
466/*
467 * Write an element of type signed int.
468 *
469 * writer An instance of a machine interface writer.
c7e35b03 470 * element_name Element name.
5e18ec73 471 * value Signed int value of the element.
c7e35b03
JR
472 *
473 * Returns zero if the element's value could be written.
474 * Negative values indicate an error.
475 */
476int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
28f23191
JG
477 const char *element_name,
478 int64_t value);
c7e35b03
JR
479
480/*
481 * Write an element of type boolean.
482 *
483 * writer An instance of a machine interface writer.
c7e35b03 484 * element_name Element name.
5e18ec73 485 * value Boolean value of the element.
c7e35b03
JR
486 *
487 * Returns zero if the element's value could be written.
488 * Negative values indicate an error.
489 */
490int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
28f23191
JG
491 const char *element_name,
492 int value);
c7e35b03
JR
493
494/*
495 * Write an element of type string.
496 *
497 * writer An instance of a machine interface writer.
c7e35b03 498 * element_name Element name.
5e18ec73 499 * value String value of the element.
c7e35b03
JR
500 *
501 * Returns zero if the element's value could be written.
502 * Negative values indicate an error.
503 */
504int mi_lttng_writer_write_element_string(struct mi_writer *writer,
28f23191
JG
505 const char *element_name,
506 const char *value);
c7e35b03 507
2b166400
JR
508/*
509 * Write an element of type double.
510 *
511 * writer An instance of a machine interface writer.
512 * element_name Element name.
513 * value Double value of the element.
514 *
515 * Returns zero if the element's value could be written.
516 * Negative values indicate an error.
517 */
518int mi_lttng_writer_write_element_double(struct mi_writer *writer,
28f23191
JG
519 const char *element_name,
520 double value);
2b166400 521
c7e35b03
JR
522/*
523 * Machine interface of struct version.
524 *
525 * writer An instance of a machine interface writer.
c7e35b03 526 * version Version struct.
c7e35b03 527 * lttng_description String value of the version description.
c7e35b03
JR
528 * lttng_license String value of the version license.
529 *
530 * Returns zero if the element's value could be written.
531 * Negative values indicate an error.
532 */
28f23191
JG
533int mi_lttng_version(struct mi_writer *writer,
534 struct mi_lttng_version_data *version,
535 const char *lttng_description,
536 const char *lttng_license);
c7e35b03
JR
537
538/*
5e18ec73 539 * Machine interface: open a sessions element.
c7e35b03 540 *
5e18ec73 541 * writer An instance of a machine interface writer.
c7e35b03 542 *
5e18ec73
JR
543 * Returns zero if the element's value could be written.
544 * Negative values indicate an error.
545 */
546int mi_lttng_sessions_open(struct mi_writer *writer);
547
548/*
549 * Machine interface of struct session.
c7e35b03 550 *
5e18ec73
JR
551 * writer An instance of a machine interface writer.
552 * session An instance of a session.
553 * is_open Defines whether or not the session element shall be closed.
554 * This should be used carefully and the client
555 * must close the session element.
136f2f81 556 * Use case: nested additional information on a session
c7e35b03 557 * ex: domain,channel event.
c7e35b03
JR
558 *
559 * Returns zero if the element's value could be written.
560 * Negative values indicate an error.
561 */
7a96a40b 562int mi_lttng_session(struct mi_writer *writer, const struct lttng_session *session, int is_open);
5e18ec73
JR
563
564/*
565 * Machine interface: open a domains element.
566 *
567 * writer An instance of a machine interface writer.
568 *
569 * Returns zero if the element's value could be written.
570 * Negative values indicate an error.
571 */
572int mi_lttng_domains_open(struct mi_writer *writer);
573
574/*
575 * Machine interface of struct domain.
576 *
577 * writer An instance of a machine interface writer.
578 * domain An instance of a domain.
579 *
580 * is_open Defines whether or not the session element shall be closed.
581 * This should be used carefully and the client
582 * must close the domain element.
583 * Use case: nested addition information on a domain
584 * ex: channel event.
585 *
586 * Returns zero if the element's value could be written.
587 * Negative values indicate an error.
588 */
28f23191 589int mi_lttng_domain(struct mi_writer *writer, struct lttng_domain *domain, int is_open);
5e18ec73
JR
590
591/*
592 * Machine interface: open a channels element.
593 *
594 * writer An instance of a machine interface writer.
595 *
596 * Returns zero if the element's value could be written.
597 * Negative values indicate an error.
598 */
599int mi_lttng_channels_open(struct mi_writer *writer);
600
601/*
602 * Machine interface of struct channel.
603 *
604 * writer An instance of a machine interface writer.
605 * channel An instance of a channel.
606 *
607 * is_open Defines whether or not the session element shall be closed.
608 * This should be used carefully and the client
609 * must close the channel element.
610 * Use case: nested addition information on a channel.
611 * ex: channel event.
612 *
613 * Returns zero if the element's value could be written.
614 * Negative values indicate an error.
615 */
28f23191 616int mi_lttng_channel(struct mi_writer *writer, struct lttng_channel *channel, int is_open);
5e18ec73
JR
617
618/*
619 * Machine interface of struct channel_attr.
620 *
621 * writer An instance of a machine interface writer.
622 * attr An instance of a channel_attr struct.
623 *
624 * Returns zero if the element's value could be written.
625 * Negative values indicate an error.
626 */
28f23191 627int mi_lttng_channel_attr(struct mi_writer *writer, struct lttng_channel_attr *attr);
5e18ec73
JR
628
629/*
28f23191
JG
630 * Machine interface for event common attributes.
631 *
632 * writer An instance of a mi writer.
633 * event single trace event.
634 *
635 * The common attribute are:
636 * - mi event element
637 * - event name
638 * - event type
639 * - enabled tag
640 * - event filter
641 *
642 * Returns zero if the element's value could be written.
643 * Negative values indicate an error.
644 */
645int mi_lttng_event_common_attributes(struct mi_writer *writer, struct lttng_event *event);
5e18ec73
JR
646
647/*
648 * Machine interface for kernel tracepoint event with a loglevel.
649 *
650 * writer An instance of a mi writer.
651 * event single trace event.
970d848b 652 * domain Event's domain
5e18ec73
JR
653 *
654 * Returns zero if the element's value could be written.
655 * Negative values indicate an error.
656 */
657int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
28f23191
JG
658 struct lttng_event *event,
659 enum lttng_domain_type domain);
5e18ec73
JR
660
661/*
662 * Machine interface for kernel tracepoint event with no loglevel.
663 *
664 * writer An instance of a mi writer.
665 * event single trace event.
666 *
667 * Returns zero if the element's value could be written.
668 * Negative values indicate an error.
669 */
28f23191 670int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer, struct lttng_event *event);
5e18ec73
JR
671
672/*
673 * Machine interface for kernel function and probe event.
674 *
675 * writer An instance of a mi writer.
676 * event single trace event.
677 *
678 * Returns zero if the element's value could be written.
679 * Negative values indicate an error.
680 */
28f23191 681int mi_lttng_event_function_probe(struct mi_writer *writer, struct lttng_event *event);
5e18ec73
JR
682
683/*
684 * Machine interface for kernel function entry event.
685 *
686 * writer An instance of a mi writer.
687 * event single trace event.
688 *
689 * Returns zero if the element's value could be written.
690 * Negative values indicate an error.
691 */
28f23191 692int mi_lttng_event_function_entry(struct mi_writer *writer, struct lttng_event *event);
5e18ec73
JR
693
694/*
695 * Machine interface: open an events element.
696 *
697 * writer An instance of a machine interface writer.
698 *
699 * Returns zero if the element's value could be written.
700 * Negative values indicate an error.
701 */
702int mi_lttng_events_open(struct mi_writer *writer);
703
704/*
705 * Machine interface for printing an event.
706 * The trace event type currently supported are:
707 * TRACEPOINT,
708 * PROBE,
709 * FUNCTION,
710 * FUNCTION_ENTRY,
711 * SYSCALL
712 *
713 * writer An instance of a mi writer.
714 * event single trace event.
715 * is_open Defines whether or not the session element shall be closed.
716 * This should be used carefully and the client
717 * must close the event element.
718 * Use case: nested additional information
970d848b 719 * domain Event's domain
5e18ec73
JR
720 *
721 * Returns zero if the element's value could be written.
722 * Negative values indicate an error.
723 */
28f23191
JG
724int mi_lttng_event(struct mi_writer *writer,
725 struct lttng_event *event,
726 int is_open,
727 enum lttng_domain_type domain);
5e18ec73
JR
728
729/*
730 * Machine interface for struct lttng_event_field.
731 *
732 * writer An instance of a mi writer.
733 * field An event_field instance.
734 *
735 * Returns zero if the element's value could be written.
736 * Negative values indicate an error.
737 */
28f23191 738int mi_lttng_event_field(struct mi_writer *writer, struct lttng_event_field *field);
5e18ec73
JR
739
740/*
741 * Machine interface: open a event_fields element.
742 *
743 * writer An instance of a machine interface writer.
744 *
e4d484a5 745 * Returns zero if the element have be written.
5e18ec73
JR
746 * Negative values indicate an error.
747 */
748int mi_lttng_event_fields_open(struct mi_writer *writer);
749
ebbf5ab7
JR
750/*
751 * Machine interface: open a trackers element.
752 *
753 * writer An instance of a machine interface writer.
754 *
755 * Returns zero if the element's value could be written.
756 * Negative values indicate an error.
757 */
758int mi_lttng_trackers_open(struct mi_writer *writer);
759
760/*
159b042f 761 * Machine interface: open a process attribute tracker element.
ebbf5ab7
JR
762 *
763 * writer An instance of a machine interface writer.
764 *
765 * Returns zero if the element's value could be written.
766 * Negative values indicate an error.
767 *
768 * Note: A targets element is also opened for each tracker definition
769 */
28f23191
JG
770int mi_lttng_process_attribute_tracker_open(struct mi_writer *writer,
771 enum lttng_process_attr process_attr);
ebbf5ab7 772
5e18ec73
JR
773/*
774 * Machine interface: open a PIDs element.
775 *
776 * writer An instance of a machine interface writer.
777 *
778 * Returns zero if the element's value could be written.
779 * Negative values indicate an error.
780 */
781int mi_lttng_pids_open(struct mi_writer *writer);
782
783/*
ebbf5ab7
JR
784 * Machine interface: open a processes element.
785 *
786 * writer An instance of a machine interface writer.
787 *
788 * Returns zero if the element's value could be written.
789 * Negative values indicate an error.
790 */
791int mi_lttng_processes_open(struct mi_writer *writer);
792
793/*
794 * Machine interface of a Process.
5e18ec73
JR
795 *
796 * writer An instance of a machine interface writer.
797 * pid A PID.
798 *
799 * is_open Defines whether or not the session element shall be closed.
800 * This should be used carefully and the client
801 * must close the pid element.
802 * Use case: nested addition information on a domain
803 * ex: channel event.
804 *
805 * Returns zero if the element's value could be written.
806 * Negative values indicate an error.
807 */
28f23191 808int mi_lttng_process(struct mi_writer *writer, pid_t pid, const char *name, int is_open);
bf239d4c
JR
809
810/*
811 * TODO: move pid of lttng list -u to process semantic on mi api bump
812 * Machine interface of a Process.
813 *
814 * writer An instance of a machine interface writer.
815 * pid A PID.
816 *
817 * is_open Defines whether or not the session element shall be closed.
818 * This should be used carefully and the client
819 * must close the pid element.
820 * Use case: nested addition information on a domain
821 * ex: channel event.
822 *
823 * Returns zero if the element's value could be written.
824 * Negative values indicate an error.
825 */
28f23191 826int mi_lttng_pid(struct mi_writer *writer, pid_t pid, const char *name, int is_open);
159b042f 827
ebbf5ab7 828/*
159b042f 829 * Machine interface: open a process attribute values element.
ebbf5ab7
JR
830 *
831 * writer An instance of a machine interface writer.
832 *
833 * Returns zero if the element's value could be written.
834 * Negative values indicate an error.
835 */
159b042f 836int mi_lttng_process_attr_values_open(struct mi_writer *writer);
ebbf5ab7
JR
837
838/*
159b042f 839 * Machine interface for track/untrack of all process attribute values.
ebbf5ab7
JR
840 *
841 * writer An instance of a machine interface writer.
842 *
843 * Returns zero if the element's value could be written.
844 * Negative values indicate an error.
845 */
159b042f 846int mi_lttng_all_process_attribute_value(struct mi_writer *writer,
28f23191
JG
847 enum lttng_process_attr process_attr,
848 bool is_open);
159b042f
JG
849
850/*
851 * Machine interface for track/untrack of an integral process attribute value.
852 *
853 * writer An instance of a machine interface writer.
854 *
855 * Returns zero if the element's value could be written.
856 * Negative values indicate an error.
857 */
858int mi_lttng_integral_process_attribute_value(struct mi_writer *writer,
28f23191
JG
859 enum lttng_process_attr process_attr,
860 int64_t value,
861 bool is_open);
159b042f
JG
862
863/*
864 * Machine interface for track/untrack of a string process attribute value.
865 *
866 * writer An instance of a machine interface writer.
867 *
868 * Returns zero if the element's value could be written.
869 * Negative values indicate an error.
870 */
871int mi_lttng_string_process_attribute_value(struct mi_writer *writer,
28f23191
JG
872 enum lttng_process_attr process_attr,
873 const char *value,
874 bool is_open);
c7e35b03 875
89b72577
JRJ
876/*
877 * Machine interface of a context.
878 *
879 * writer An instance of a machine interface writer
880 *
881 * context An instance of a lttng_event_context
882 *
883 * is_open Define if we close the context element
884 * This should be used carefully and the client
885 * need to close the context element.
89b72577
JRJ
886 * Returns zero if the element's value could be written.
887 * Negative values indicate an error.
888 */
28f23191 889int mi_lttng_context(struct mi_writer *writer, struct lttng_event_context *context, int is_open);
89b72577
JRJ
890
891/*
892 * Machine interface of a perf_counter_context.
893 *
894 * writer An instance of a machine interface writer
895 *
896 * contest An instance of a lttng_event_perf_counter_ctx
897 *
898 * Returns zero if the element's value could be written.
899 * Negative values indicate an error.
900 */
901int mi_lttng_perf_counter_context(struct mi_writer *writer,
28f23191 902 struct lttng_event_perf_counter_ctx *perf_context);
89b72577 903
50534d6f
JRJ
904/*
905 * Machine interface of the snapshot list_output.
906 * It specifies the session for which we are listing snapshots,
907 * and it opens a snapshots element to list a sequence
908 * of snapshots.
909 *
910 * writer An instance of a machine interface writer.
911 *
912 * session_name: Snapshot output for session "session_name".
913 *
914 * Note: The client has to close the session and the snapshots elements after
915 * having listed every lttng_snapshot_output.
916 *
917 * Returns zero if the element's value could be written.
918 * Negative values indicate an error.
919 */
28f23191 920int mi_lttng_snapshot_output_session_name(struct mi_writer *writer, const char *session_name);
50534d6f
JRJ
921
922/*
923 * Machine interface of the snapshot output.
924 * The machine interface serializes the following attributes:
925 * - id: ID of the snapshot output.
926 * - name: Name of the output.
927 * - data_url : Destination of the output.
928 * - ctrl_url: Destination of the output.
929 * - max_size: total size of all stream combined.
930 *
931 * writer An instance of a machine interface writer.
932 *
933 * output: A list of snapshot_output.
934 *
935 * Returns zero if the element's value could be written.
936 * Negative values indicate an error.
937 */
938int mi_lttng_snapshot_list_output(struct mi_writer *writer,
28f23191 939 const struct lttng_snapshot_output *output);
50534d6f
JRJ
940
941/*
942 * Machine interface of the output of the command snapshot del output
943 * when deleting a snapshot either by id or by name.
944 * If the snapshot was found and successfully deleted using its id,
945 * it return the id of the snapshot and the current session name on which it
946 * was attached.
947 *
948 * Otherwise, it do the same process with the name of the snapshot, if the
949 * snapshot output id is undefined.
950 *
951 * writer An instance of a machine interface writer.
952 *
953 * id: ID of the snapshot output.
954 *
955 * name: Name of the snapshot.
956 *
957 * current_session_name: Session to which the snapshot belongs.
958 *
959 * Returns zero if the element's value could be written.
960 * Negative values indicate an error.
961 */
28f23191
JG
962int mi_lttng_snapshot_del_output(struct mi_writer *writer,
963 int id,
964 const char *name,
965 const char *current_session_name);
50534d6f
JRJ
966
967/*
968 * Machine interface of the output of the command snapshot add output
969 * when adding a snapshot from a user URL.
970 *
971 * If the snapshot was successfully added, the machine interface lists
972 * these information:
973 * - id: ID of the newly add snapshot output.
974 * - current_session_name: Name of the session to which the output was added.
975 * - ctrl_url: Destination of the output.
976 * - max_size: total size of all stream combined.
977 *
978 * writer An instance of a machine interface writer.
979 *
980 * current_session_name: Session to which the snapshot belongs.
981 *
982 * n_ptr:
983 *
984 * output: iterator over a lttng_snapshot_output_list which contain
985 * the snapshot output informations.
986 *
987 * Returns zero if the element's value could be written.
988 * Negative values indicate an error.
989 */
990int mi_lttng_snapshot_add_output(struct mi_writer *writer,
28f23191
JG
991 const char *current_session_name,
992 const char *n_ptr,
993 struct lttng_snapshot_output *output);
50534d6f
JRJ
994
995/*
996 * Machine interface of the output of the command snapshot
997 * record from a URL (if given).
998 *
999 * If the snapshot is successfully recorded from a url, the machine interface
1000 * output the following information:
1001 * - url: Destination of the output stored in the snapshot.
1002 *
1003 * Otherwise, the machine interface output the data and ctrl url received
1004 * from the command-line.
1005 *
1006 * writer An instance of a machine interface writer.
1007 *
50534d6f
JRJ
1008 * ctrl_url, data_url: Destination of the output receive from the command-line.
1009 *
1010 * Returns zero if the element's value could be written.
1011 * Negative values indicate an error.
1012 */
28f23191
JG
1013int mi_lttng_snapshot_record(struct mi_writer *writer,
1014 const char *url,
1015 const char *cmdline_ctrl_url,
1016 const char *cmdline_data_url);
50534d6f 1017
66ea93b1
JG
1018/*
1019 * Machine interface representation of a session rotation schedule.
1020 *
1021 * The machine interface serializes the provided schedule as one of the choices
1022 * from 'rotation_schedule_type'.
1023 *
1024 * writer: An instance of a machine interface writer.
1025 *
1026 * schedule: An lttng rotation schedule descriptor object.
1027 *
1028 * Returns zero if the element's value could be written.
1029 * Negative values indicate an error.
1030 */
1031int mi_lttng_rotation_schedule(struct mi_writer *writer,
28f23191 1032 const struct lttng_rotation_schedule *schedule);
66ea93b1
JG
1033
1034/*
1035 * Machine interface of a session rotation schedule result.
1036 * This is an element that is part of the output of the enable-rotation and
1037 * disable-rotation commands.
1038 *
1039 * The machine interface provides the following information:
1040 * - schedule: the session rotation schedule descriptor.
1041 * - success: whether the sub-command succeeded.
1042 *
1043 * writer: An instance of a machine interface writer.
1044 *
66ea93b1
JG
1045 * schedule: An lttng rotation schedule descriptor object.
1046 *
1047 * success: Whether the sub-command suceeded.
1048 *
1049 * Returns zero if the element's value could be written.
1050 * Negative values indicate an error.
1051 */
1052int mi_lttng_rotation_schedule_result(struct mi_writer *writer,
28f23191
JG
1053 const struct lttng_rotation_schedule *schedule,
1054 bool success);
66ea93b1 1055
91c4d516
JG
1056/*
1057 * Machine interface of a session rotation result.
1058 * This is an element that is part of the output of the rotate command.
1059 *
1060 * The machine interface provides the following information:
1061 * - session_name: the session to be rotated.
1062 * - state: the session rotation state.
1063 * - location: the location of the completed chunk archive.
1064 *
1065 * writer: An instance of a machine interface writer.
1066 *
1067 * session_name: The session to which the rotate command applies.
1068 *
1069 * location: A location descriptor object.
1070 *
1071 * success: Whether the sub-command suceeded.
1072 *
1073 * Returns zero if the element's value could be written.
1074 * Negative values indicate an error.
1075 */
1076int mi_lttng_rotate(struct mi_writer *writer,
28f23191
JG
1077 const char *session_name,
1078 enum lttng_rotation_state rotation_state,
1079 const struct lttng_trace_archive_location *location);
91c4d516 1080
c7e35b03 1081#endif /* _MI_LTTNG_H */
This page took 0.1341 seconds and 4 git commands to generate.