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