Fix: build failure with -fno-common
[lttng-tools.git] / src / common / mi-lttng.h
1 /*
2 * Copyright (C) 2014 - Jonathan Rajotte <jonathan.r.julien@gmail.com>
3 * - Olivier Cotte <olivier.cotte@polymtl.ca>
4 * Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License, version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef _MI_LTTNG_H
21 #define _MI_LTTNG_H
22
23 #include <stdint.h>
24
25 #include <common/error.h>
26 #include <common/macros.h>
27 #include <common/config/session-config.h>
28 #include <lttng/lttng.h>
29
30 /* Don't want to reference snapshot-internal.h here */
31 struct lttng_snapshot_output;
32
33 /* Instance of a machine interface writer. */
34 struct mi_writer {
35 struct config_writer *writer;
36 enum lttng_mi_output_type type;
37 };
38
39 /*
40 * Version information for the machine interface.
41 */
42 struct mi_lttng_version {
43 char version[LTTNG_NAME_MAX]; /* Version number of package */
44 uint32_t version_major; /* LTTng-Tools major version number */
45 uint32_t version_minor; /* LTTng-Tools minor version number */
46 uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */
47 char version_commit[LTTNG_NAME_MAX]; /* Commit hash of the current version */
48 char version_name[LTTNG_NAME_MAX];
49 char package_url[LTTNG_NAME_MAX]; /* Define to the home page for this package. */
50 };
51
52 /* Strings related to command */
53 extern const char * const mi_lttng_element_command;
54 extern const char * const mi_lttng_element_command_action;
55 extern const char * const mi_lttng_element_command_add_context;
56 extern const char * const mi_lttng_element_command_create;
57 extern const char * const mi_lttng_element_command_destroy;
58 extern const char * const mi_lttng_element_command_disable_channel;
59 extern const char * const mi_lttng_element_command_disable_event;
60 extern const char * const mi_lttng_element_command_enable_channels;
61 extern const char * const mi_lttng_element_command_enable_event;
62 extern const char * const mi_lttng_element_command_list;
63 extern const char * const mi_lttng_element_command_load;
64 extern const char * const mi_lttng_element_command_metadata;
65 extern const char * const mi_lttng_element_command_metadata_action;
66 extern const char * const mi_lttng_element_command_regenerate;
67 extern const char * const mi_lttng_element_command_regenerate_action;
68 extern const char * const mi_lttng_element_command_name;
69 extern const char * const mi_lttng_element_command_output;
70 extern const char * const mi_lttng_element_command_save;
71 extern const char * const mi_lttng_element_command_set_session;
72 extern const char * const mi_lttng_element_command_snapshot;
73 extern const char * const mi_lttng_element_command_snapshot_add;
74 extern const char * const mi_lttng_element_command_snapshot_del;
75 extern const char * const mi_lttng_element_command_snapshot_list;
76 extern const char * const mi_lttng_element_command_snapshot_record;
77 extern const char * const mi_lttng_element_command_start;
78 extern const char * const mi_lttng_element_command_stop;
79 extern const char * const mi_lttng_element_command_success;
80 extern const char * const mi_lttng_element_command_track;
81 extern const char * const mi_lttng_element_command_untrack;
82 extern const char * const mi_lttng_element_command_version;
83 extern const char * const mi_lttng_element_command_rotate;
84 extern const char * const mi_lttng_element_command_enable_rotation;
85 extern const char * const mi_lttng_element_command_disable_rotation;
86 extern const char * const mi_lttng_element_command_clear;
87
88 /* Strings related to version command */
89 extern const char * const mi_lttng_element_version;
90 extern const char * const mi_lttng_element_version_commit;
91 extern const char * const mi_lttng_element_version_description;
92 extern const char * const mi_lttng_element_version_license;
93 extern const char * const mi_lttng_element_version_major;
94 extern const char * const mi_lttng_element_version_minor;
95 extern const char * const mi_lttng_element_version_patch_level;
96 extern const char * const mi_lttng_element_version_str;
97 extern const char * const mi_lttng_element_version_web;
98
99 /* String related to a lttng_event_field */
100 extern const char * const mi_lttng_element_event_field;
101 extern const char * const mi_lttng_element_event_fields;
102
103 /* String related to lttng_event_perf_counter_ctx */
104 extern const char * const mi_lttng_element_perf_counter_context;
105
106 /* Strings related to pid */
107 extern const char * const mi_lttng_element_pid_id;
108
109 /* Strings related to save command */
110 extern const char * const mi_lttng_element_save;
111
112 /* Strings related to load command */
113 extern const char * const mi_lttng_element_load;
114 LTTNG_HIDDEN extern const char * const mi_lttng_element_load_overrides;
115 LTTNG_HIDDEN extern const char * const mi_lttng_element_load_override_url;
116
117 /* General element of mi_lttng */
118 extern const char * const mi_lttng_element_empty;
119 extern const char * const mi_lttng_element_id;
120 extern const char * const mi_lttng_element_nowrite;
121 extern const char * const mi_lttng_element_success;
122 extern const char * const mi_lttng_element_type_enum;
123 extern const char * const mi_lttng_element_type_float;
124 extern const char * const mi_lttng_element_type_integer;
125 extern const char * const mi_lttng_element_type_other;
126 extern const char * const mi_lttng_element_type_string;
127
128 /* String related to loglevel */
129 extern const char * const mi_lttng_loglevel_str_alert;
130 extern const char * const mi_lttng_loglevel_str_crit;
131 extern const char * const mi_lttng_loglevel_str_debug;
132 extern const char * const mi_lttng_loglevel_str_debug_function;
133 extern const char * const mi_lttng_loglevel_str_debug_line;
134 extern const char * const mi_lttng_loglevel_str_debug_module;
135 extern const char * const mi_lttng_loglevel_str_debug_process;
136 extern const char * const mi_lttng_loglevel_str_debug_program;
137 extern const char * const mi_lttng_loglevel_str_debug_system;
138 extern const char * const mi_lttng_loglevel_str_debug_unit;
139 extern const char * const mi_lttng_loglevel_str_emerg;
140 extern const char * const mi_lttng_loglevel_str_err;
141 extern const char * const mi_lttng_loglevel_str_info;
142 extern const char * const mi_lttng_loglevel_str_notice;
143 extern const char * const mi_lttng_loglevel_str_unknown;
144 extern const char * const mi_lttng_loglevel_str_warning;
145
146 /* String related to loglevel JUL */
147 extern const char * const mi_lttng_loglevel_str_jul_all;
148 extern const char * const mi_lttng_loglevel_str_jul_config;
149 extern const char * const mi_lttng_loglevel_str_jul_fine;
150 extern const char * const mi_lttng_loglevel_str_jul_finer;
151 extern const char * const mi_lttng_loglevel_str_jul_finest;
152 extern const char * const mi_lttng_loglevel_str_jul_info;
153 extern const char * const mi_lttng_loglevel_str_jul_off;
154 extern const char * const mi_lttng_loglevel_str_jul_severe;
155 extern const char * const mi_lttng_loglevel_str_jul_warning;
156
157 /* String related to loglevel Log4j */
158 extern const char * const mi_lttng_loglevel_str_log4j_off;
159 extern const char * const mi_lttng_loglevel_str_log4j_fatal;
160 extern const char * const mi_lttng_loglevel_str_log4j_error;
161 extern const char * const mi_lttng_loglevel_str_log4j_warn;
162 extern const char * const mi_lttng_loglevel_str_log4j_info;
163 extern const char * const mi_lttng_loglevel_str_log4j_debug;
164 extern const char * const mi_lttng_loglevel_str_log4j_trace;
165 extern const char * const mi_lttng_loglevel_str_log4j_all;
166
167 /* String related to loglevel Python */
168 extern const char * const mi_lttng_loglevel_str_python_critical;
169 extern const char * const mi_lttng_loglevel_str_python_error;
170 extern const char * const mi_lttng_loglevel_str_python_warning;
171 extern const char * const mi_lttng_loglevel_str_python_info;
172 extern const char * const mi_lttng_loglevel_str_python_debug;
173 extern const char * const mi_lttng_loglevel_str_python_notset;
174
175 /* String related to loglevel type */
176 extern const char * const mi_lttng_loglevel_type_all;
177 extern const char * const mi_lttng_loglevel_type_range;
178 extern const char * const mi_lttng_loglevel_type_single;
179 extern const char * const mi_lttng_loglevel_type_unknown;
180
181 /* String related to a lttng_snapshot */
182 extern const char * const mi_lttng_element_snapshot_ctrl_url;
183 extern const char * const mi_lttng_element_snapshot_data_url;
184 extern const char * const mi_lttng_element_snapshot_max_size;
185 extern const char * const mi_lttng_element_snapshot_n_ptr;
186 extern const char * const mi_lttng_element_snapshot_session_name;
187 extern const char * const mi_lttng_element_snapshots;
188
189 /* String related to track/untrack command */
190 extern const char * const mi_lttng_element_track_untrack_all_wildcard;
191
192 LTTNG_HIDDEN extern const char * const mi_lttng_element_session_name;
193
194 /* String related to rotate command */
195 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation;
196 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotate_status;
197 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule;
198 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedules;
199 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_periodic;
200 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us;
201 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_size_threshold;
202 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes;
203 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_result;
204 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_results;
205 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_state;
206 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location;
207 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_local;
208 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_local_absolute_path;
209 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay;
210 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_host;
211 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_control_port;
212 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_data_port;
213 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_protocol;
214 LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_relative_path;
215
216 /* String related to enum lttng_rotation_state */
217 LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_ongoing;
218 LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_completed;
219 LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_expired;
220 LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_error;
221
222 /* String related to enum lttng_trace_archive_location_relay_protocol_type */
223 LTTNG_HIDDEN extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp;
224
225 /* String related to add-context command */
226 LTTNG_HIDDEN extern const char * const mi_lttng_element_context_symbol;
227
228 /* Utility string function */
229 const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
230 const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value);
231 const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value);
232 const char *mi_lttng_domaintype_string(enum lttng_domain_type value);
233 const char *mi_lttng_buffertype_string(enum lttng_buffer_type value);
234 const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value);
235 const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
236 enum lttng_trace_archive_location_relay_protocol_type value);
237
238 /*
239 * Create an instance of a machine interface writer.
240 *
241 * fd_output File to which the XML content must be written. The file will be
242 * closed once the mi_writer has been destroyed.
243 *
244 * Returns an instance of a machine interface writer on success, NULL on
245 * error.
246 */
247 struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);
248
249 /*
250 * Destroy an instance of a machine interface writer.
251 *
252 * writer An instance of a machine interface writer.
253 *
254 * Returns zero if the XML document could be closed cleanly. Negative values
255 * indicate an error.
256 */
257 int mi_lttng_writer_destroy(struct mi_writer *writer);
258
259 /*
260 * Open a command tag and add it's name node.
261 *
262 * writer An instance of a machine interface writer.
263 * command The command name.
264 *
265 * Returns zero if the XML document could be closed cleanly.
266 * Negative values indicate an error.
267 */
268 int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);
269
270 /*
271 * Close a command tag.
272 *
273 * writer An instance of a machine interface writer.
274 *
275 * Returns zero if the XML document could be closed cleanly.
276 * Negative values indicate an error.
277 */
278 int mi_lttng_writer_command_close(struct mi_writer *writer);
279
280 /*
281 * Open an element tag.
282 *
283 * writer An instance of a machine interface writer.
284 * element_name Element tag name.
285 *
286 * Returns zero if the XML document could be closed cleanly.
287 * Negative values indicate an error.
288 */
289 int mi_lttng_writer_open_element(struct mi_writer *writer,
290 const char *element_name);
291
292 /*
293 * Close the current element tag.
294 *
295 * writer An instance of a machine interface writer.
296 *
297 * Returns zero if the XML document could be closed cleanly.
298 * Negative values indicate an error.
299 */
300 int mi_lttng_writer_close_element(struct mi_writer *writer);
301
302 /*
303 * Close multiple element.
304 *
305 * writer An instance of a machine interface writer.
306 * nb_element Number of elements.
307 *
308 * Returns zero if the XML document could be closed cleanly.
309 * Negative values indicate an error.
310 */
311 int mi_lttng_close_multi_element(struct mi_writer *writer,
312 unsigned int nb_element);
313
314 /*
315 * Write an element of type unsigned int.
316 *
317 * writer An instance of a machine interface writer.
318 * element_name Element name.
319 * value Unsigned int value of the element
320 *
321 * Returns zero if the element's value could be written.
322 * Negative values indicate an error.
323 */
324 int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
325 const char *element_name, uint64_t value);
326
327 /*
328 * Write an element of type signed int.
329 *
330 * writer An instance of a machine interface writer.
331 * element_name Element name.
332 * value Signed int value of the element.
333 *
334 * Returns zero if the element's value could be written.
335 * Negative values indicate an error.
336 */
337 int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
338 const char *element_name, int64_t value);
339
340 /*
341 * Write an element of type boolean.
342 *
343 * writer An instance of a machine interface writer.
344 * element_name Element name.
345 * value Boolean value of the element.
346 *
347 * Returns zero if the element's value could be written.
348 * Negative values indicate an error.
349 */
350 int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
351 const char *element_name, int value);
352
353 /*
354 * Write an element of type string.
355 *
356 * writer An instance of a machine interface writer.
357 * element_name Element name.
358 * value String value of the element.
359 *
360 * Returns zero if the element's value could be written.
361 * Negative values indicate an error.
362 */
363 int mi_lttng_writer_write_element_string(struct mi_writer *writer,
364 const char *element_name, const char *value);
365
366 /*
367 * Machine interface of struct version.
368 *
369 * writer An instance of a machine interface writer.
370 * version Version struct.
371 * lttng_description String value of the version description.
372 * lttng_license String value of the version license.
373 *
374 * Returns zero if the element's value could be written.
375 * Negative values indicate an error.
376 */
377 int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version *version,
378 const char *lttng_description, const char *lttng_license);
379
380 /*
381 * Machine interface: open a sessions element.
382 *
383 * writer An instance of a machine interface writer.
384 *
385 * Returns zero if the element's value could be written.
386 * Negative values indicate an error.
387 */
388 int mi_lttng_sessions_open(struct mi_writer *writer);
389
390 /*
391 * Machine interface of struct session.
392 *
393 * writer An instance of a machine interface writer.
394 * session An instance of a session.
395 * is_open Defines whether or not the session element shall be closed.
396 * This should be used carefully and the client
397 * must close the session element.
398 * Use case: nested additional information on a session
399 * ex: domain,channel event.
400 *
401 * Returns zero if the element's value could be written.
402 * Negative values indicate an error.
403 */
404 int mi_lttng_session(struct mi_writer *writer,
405 struct lttng_session *session, int is_open);
406
407 /*
408 * Machine interface: open a domains element.
409 *
410 * writer An instance of a machine interface writer.
411 *
412 * Returns zero if the element's value could be written.
413 * Negative values indicate an error.
414 */
415 int mi_lttng_domains_open(struct mi_writer *writer);
416
417 /*
418 * Machine interface of struct domain.
419 *
420 * writer An instance of a machine interface writer.
421 * domain An instance of a domain.
422 *
423 * is_open Defines whether or not the session element shall be closed.
424 * This should be used carefully and the client
425 * must close the domain element.
426 * Use case: nested addition information on a domain
427 * ex: channel event.
428 *
429 * Returns zero if the element's value could be written.
430 * Negative values indicate an error.
431 */
432 int mi_lttng_domain(struct mi_writer *writer,
433 struct lttng_domain *domain, int is_open);
434
435 /*
436 * Machine interface: open a channels element.
437 *
438 * writer An instance of a machine interface writer.
439 *
440 * Returns zero if the element's value could be written.
441 * Negative values indicate an error.
442 */
443 int mi_lttng_channels_open(struct mi_writer *writer);
444
445 /*
446 * Machine interface of struct channel.
447 *
448 * writer An instance of a machine interface writer.
449 * channel An instance of a channel.
450 *
451 * is_open Defines whether or not the session element shall be closed.
452 * This should be used carefully and the client
453 * must close the channel element.
454 * Use case: nested addition information on a channel.
455 * ex: channel event.
456 *
457 * Returns zero if the element's value could be written.
458 * Negative values indicate an error.
459 */
460 int mi_lttng_channel(struct mi_writer *writer,
461 struct lttng_channel *channel, int is_open);
462
463 /*
464 * Machine interface of struct channel_attr.
465 *
466 * writer An instance of a machine interface writer.
467 * attr An instance of a channel_attr struct.
468 *
469 * Returns zero if the element's value could be written.
470 * Negative values indicate an error.
471 */
472 int mi_lttng_channel_attr(struct mi_writer *writer,
473 struct lttng_channel_attr *attr);
474
475 /*
476 * Machine interface for event common attributes.
477 *
478 * writer An instance of a mi writer.
479 * event single trace event.
480 *
481 * The common attribute are:
482 * - mi event element
483 * - event name
484 * - event type
485 * - enabled tag
486 * - event filter
487 *
488 * Returns zero if the element's value could be written.
489 * Negative values indicate an error.
490 */
491 int mi_lttng_event_common_attributes(struct mi_writer *writer,
492 struct lttng_event *event);
493
494 /*
495 * Machine interface for kernel tracepoint event with a loglevel.
496 *
497 * writer An instance of a mi writer.
498 * event single trace event.
499 * domain Event's domain
500 *
501 * Returns zero if the element's value could be written.
502 * Negative values indicate an error.
503 */
504 int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
505 struct lttng_event *event, enum lttng_domain_type domain);
506
507 /*
508 * Machine interface for kernel tracepoint event with no loglevel.
509 *
510 * writer An instance of a mi writer.
511 * event single trace event.
512 *
513 * Returns zero if the element's value could be written.
514 * Negative values indicate an error.
515 */
516 int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer,
517 struct lttng_event *event);
518
519 /*
520 * Machine interface for kernel function and probe event.
521 *
522 * writer An instance of a mi writer.
523 * event single trace event.
524 *
525 * Returns zero if the element's value could be written.
526 * Negative values indicate an error.
527 */
528 int mi_lttng_event_function_probe(struct mi_writer *writer,
529 struct lttng_event *event);
530
531 /*
532 * Machine interface for kernel function entry event.
533 *
534 * writer An instance of a mi writer.
535 * event single trace event.
536 *
537 * Returns zero if the element's value could be written.
538 * Negative values indicate an error.
539 */
540 int mi_lttng_event_function_entry(struct mi_writer *writer,
541 struct lttng_event *event);
542
543 /*
544 * Machine interface: open an events element.
545 *
546 * writer An instance of a machine interface writer.
547 *
548 * Returns zero if the element's value could be written.
549 * Negative values indicate an error.
550 */
551 int mi_lttng_events_open(struct mi_writer *writer);
552
553 /*
554 * Machine interface for printing an event.
555 * The trace event type currently supported are:
556 * TRACEPOINT,
557 * PROBE,
558 * FUNCTION,
559 * FUNCTION_ENTRY,
560 * SYSCALL
561 *
562 * writer An instance of a mi writer.
563 * event single trace event.
564 * is_open Defines whether or not the session element shall be closed.
565 * This should be used carefully and the client
566 * must close the event element.
567 * Use case: nested additional information
568 * domain Event's domain
569 *
570 * Returns zero if the element's value could be written.
571 * Negative values indicate an error.
572 */
573 int mi_lttng_event(struct mi_writer *writer, struct lttng_event *event,
574 int is_open, enum lttng_domain_type domain);
575
576 /*
577 * Machine interface for struct lttng_event_field.
578 *
579 * writer An instance of a mi writer.
580 * field An event_field instance.
581 *
582 * Returns zero if the element's value could be written.
583 * Negative values indicate an error.
584 */
585 int mi_lttng_event_field(struct mi_writer *writer,
586 struct lttng_event_field *field);
587
588 /*
589 * Machine interface: open a event_fields element.
590 *
591 * writer An instance of a machine interface writer.
592 *
593 * Returns zero if the element have be written.
594 * Negative values indicate an error.
595 */
596 int mi_lttng_event_fields_open(struct mi_writer *writer);
597
598 /*
599 * Machine interface: open a trackers element.
600 *
601 * writer An instance of a machine interface writer.
602 *
603 * Returns zero if the element's value could be written.
604 * Negative values indicate an error.
605 */
606 int mi_lttng_trackers_open(struct mi_writer *writer);
607
608 /*
609 * Machine interface: open a id tracker element.
610 *
611 * writer An instance of a machine interface writer.
612 *
613 * Returns zero if the element's value could be written.
614 * Negative values indicate an error.
615 *
616 * Note: A targets element is also opened for each tracker definition
617 */
618 int mi_lttng_id_tracker_open(
619 struct mi_writer *writer, enum lttng_tracker_type tracker_type);
620
621 /*
622 * Machine interface: open a PIDs 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 */
629 int mi_lttng_pids_open(struct mi_writer *writer);
630
631 /*
632 * Machine interface: open a processes element.
633 *
634 * writer An instance of a machine interface writer.
635 *
636 * Returns zero if the element's value could be written.
637 * Negative values indicate an error.
638 */
639 int mi_lttng_processes_open(struct mi_writer *writer);
640
641 /*
642 * Machine interface of a Process.
643 *
644 * writer An instance of a machine interface writer.
645 * pid A PID.
646 *
647 * is_open Defines whether or not the session element shall be closed.
648 * This should be used carefully and the client
649 * must close the pid element.
650 * Use case: nested addition information on a domain
651 * ex: channel event.
652 *
653 * Returns zero if the element's value could be written.
654 * Negative values indicate an error.
655 */
656 int mi_lttng_process(struct mi_writer *writer, pid_t pid , const char *name,
657 int is_open);
658
659 /*
660 * TODO: move pid of lttng list -u to process semantic on mi api bump
661 * Machine interface of a Process.
662 *
663 * writer An instance of a machine interface writer.
664 * pid A PID.
665 *
666 * is_open Defines whether or not the session element shall be closed.
667 * This should be used carefully and the client
668 * must close the pid element.
669 * Use case: nested addition information on a domain
670 * ex: channel event.
671 *
672 * Returns zero if the element's value could be written.
673 * Negative values indicate an error.
674 */
675 int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *name,
676 int is_open);
677 /*
678 * Machine interface: open a targets element.
679 *
680 * writer An instance of a machine interface writer.
681 *
682 * Returns zero if the element's value could be written.
683 * Negative values indicate an error.
684 */
685 int mi_lttng_targets_open(struct mi_writer *writer);
686
687 /*
688 * Machine interface for track/untrack an id_target
689 *
690 * writer An instance of a machine interface writer.
691 *
692 * Returns zero if the element's value could be written.
693 * Negative values indicate an error.
694 */
695 int mi_lttng_id_target(struct mi_writer *writer,
696 enum lttng_tracker_type tracker_type,
697 const struct lttng_tracker_id *id,
698 int is_open);
699
700 /*
701 * Machine interface of a context.
702 *
703 * writer An instance of a machine interface writer
704 *
705 * context An instance of a lttng_event_context
706 *
707 * is_open Define if we close the context element
708 * This should be used carefully and the client
709 * need to close the context element.
710 * Returns zero if the element's value could be written.
711 * Negative values indicate an error.
712 */
713 int mi_lttng_context(struct mi_writer *writer,
714 struct lttng_event_context *context, int is_open);
715
716 /*
717 * Machine interface of a perf_counter_context.
718 *
719 * writer An instance of a machine interface writer
720 *
721 * contest An instance of a lttng_event_perf_counter_ctx
722 *
723 * Returns zero if the element's value could be written.
724 * Negative values indicate an error.
725 */
726 int mi_lttng_perf_counter_context(struct mi_writer *writer,
727 struct lttng_event_perf_counter_ctx *perf_context);
728
729 /*
730 * Machine interface of the snapshot list_output.
731 * It specifies the session for which we are listing snapshots,
732 * and it opens a snapshots element to list a sequence
733 * of snapshots.
734 *
735 * writer An instance of a machine interface writer.
736 *
737 * session_name: Snapshot output for session "session_name".
738 *
739 * Note: The client has to close the session and the snapshots elements after
740 * having listed every lttng_snapshot_output.
741 *
742 * Returns zero if the element's value could be written.
743 * Negative values indicate an error.
744 */
745 int mi_lttng_snapshot_output_session_name(struct mi_writer *writer,
746 const char *session_name);
747
748 /*
749 * Machine interface of the snapshot output.
750 * The machine interface serializes the following attributes:
751 * - id: ID of the snapshot output.
752 * - name: Name of the output.
753 * - data_url : Destination of the output.
754 * - ctrl_url: Destination of the output.
755 * - max_size: total size of all stream combined.
756 *
757 * writer An instance of a machine interface writer.
758 *
759 * output: A list of snapshot_output.
760 *
761 * Returns zero if the element's value could be written.
762 * Negative values indicate an error.
763 */
764 int mi_lttng_snapshot_list_output(struct mi_writer *writer,
765 struct lttng_snapshot_output *output);
766
767 /*
768 * Machine interface of the output of the command snapshot del output
769 * when deleting a snapshot either by id or by name.
770 * If the snapshot was found and successfully deleted using its id,
771 * it return the id of the snapshot and the current session name on which it
772 * was attached.
773 *
774 * Otherwise, it do the same process with the name of the snapshot, if the
775 * snapshot output id is undefined.
776 *
777 * writer An instance of a machine interface writer.
778 *
779 * id: ID of the snapshot output.
780 *
781 * name: Name of the snapshot.
782 *
783 * current_session_name: Session to which the snapshot belongs.
784 *
785 * Returns zero if the element's value could be written.
786 * Negative values indicate an error.
787 */
788 int mi_lttng_snapshot_del_output(struct mi_writer *writer, int id,
789 const char *name, const char *current_session_name);
790
791 /*
792 * Machine interface of the output of the command snapshot add output
793 * when adding a snapshot from a user URL.
794 *
795 * If the snapshot was successfully added, the machine interface lists
796 * these information:
797 * - id: ID of the newly add snapshot output.
798 * - current_session_name: Name of the session to which the output was added.
799 * - ctrl_url: Destination of the output.
800 * - max_size: total size of all stream combined.
801 *
802 * writer An instance of a machine interface writer.
803 *
804 * current_session_name: Session to which the snapshot belongs.
805 *
806 * n_ptr:
807 *
808 * output: iterator over a lttng_snapshot_output_list which contain
809 * the snapshot output informations.
810 *
811 * Returns zero if the element's value could be written.
812 * Negative values indicate an error.
813 */
814 int mi_lttng_snapshot_add_output(struct mi_writer *writer,
815 const char *current_session_name, const char *n_ptr,
816 struct lttng_snapshot_output *output);
817
818 /*
819 * Machine interface of the output of the command snapshot
820 * record from a URL (if given).
821 *
822 * If the snapshot is successfully recorded from a url, the machine interface
823 * output the following information:
824 * - url: Destination of the output stored in the snapshot.
825 *
826 * Otherwise, the machine interface output the data and ctrl url received
827 * from the command-line.
828 *
829 * writer An instance of a machine interface writer.
830 *
831 * current_session_name: Snapshot record for session "current_session_name".
832 *
833 * ctrl_url, data_url: Destination of the output receive from the command-line.
834 *
835 * Returns zero if the element's value could be written.
836 * Negative values indicate an error.
837 */
838 int mi_lttng_snapshot_record(struct mi_writer *writer,
839 const char *current_session_name, const char *url,
840 const char *cmdline_ctrl_url, const char *cmdline_data_url);
841
842 /*
843 * Machine interface representation of a session rotation schedule.
844 *
845 * The machine interface serializes the provided schedule as one of the choices
846 * from 'rotation_schedule_type'.
847 *
848 * writer: An instance of a machine interface writer.
849 *
850 * schedule: An lttng rotation schedule descriptor object.
851 *
852 * Returns zero if the element's value could be written.
853 * Negative values indicate an error.
854 */
855 int mi_lttng_rotation_schedule(struct mi_writer *writer,
856 const struct lttng_rotation_schedule *schedule);
857
858 /*
859 * Machine interface of a session rotation schedule result.
860 * This is an element that is part of the output of the enable-rotation and
861 * disable-rotation commands.
862 *
863 * The machine interface provides the following information:
864 * - schedule: the session rotation schedule descriptor.
865 * - success: whether the sub-command succeeded.
866 *
867 * writer: An instance of a machine interface writer.
868 *
869 * schedule: An lttng rotation schedule descriptor object.
870 *
871 * success: Whether the sub-command suceeded.
872 *
873 * Returns zero if the element's value could be written.
874 * Negative values indicate an error.
875 */
876 int mi_lttng_rotation_schedule_result(struct mi_writer *writer,
877 const struct lttng_rotation_schedule *schedule,
878 bool success);
879
880 /*
881 * Machine interface of a session rotation result.
882 * This is an element that is part of the output of the rotate command.
883 *
884 * The machine interface provides the following information:
885 * - session_name: the session to be rotated.
886 * - state: the session rotation state.
887 * - location: the location of the completed chunk archive.
888 *
889 * writer: An instance of a machine interface writer.
890 *
891 * session_name: The session to which the rotate command applies.
892 *
893 * location: A location descriptor object.
894 *
895 * success: Whether the sub-command suceeded.
896 *
897 * Returns zero if the element's value could be written.
898 * Negative values indicate an error.
899 */
900 int mi_lttng_rotate(struct mi_writer *writer,
901 const char *session_name,
902 enum lttng_rotation_state rotation_state,
903 const struct lttng_trace_archive_location *location);
904
905 #endif /* _MI_LTTNG_H */
This page took 0.047855 seconds and 5 git commands to generate.