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