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