Mi calibrate command: support and validation
[lttng-tools.git] / src / common / mi-lttng.h
CommitLineData
c7e35b03
JR
1/*
2 * Copyright (C) 2014 - Jonathan Rajotte <jonathan.r.julien@gmail.com>
3 * - Olivier Cotte <olivier.cotte@polymtl.ca>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License, version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#ifndef _MI_LTTNG_H
20#define _MI_LTTNG_H
21
22#include <stdint.h>
23
24#include <common/error.h>
25#include <common/macros.h>
26#include <common/config/config.h>
27#include <lttng/lttng.h>
28
29/* Instance of a machine interface writer. */
30struct mi_writer {
31 struct config_writer *writer;
32 enum lttng_mi_output_type type;
33};
34
35/*
36 * Version information for the machine interface.
37 */
38struct mi_lttng_version {
39 char version[NAME_MAX]; /* Version number of package */
40 uint32_t version_major; /* LTTng-Tools major version number */
41 uint32_t version_minor; /* LTTng-Tools minor version number */
42 uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */
314d5222 43 char version_commit[NAME_MAX]; /* Commit hash of the current version */
c7e35b03
JR
44 char version_name[NAME_MAX];
45 char package_url[NAME_MAX]; /* Define to the home page for this package. */
46};
47
48/* Strings related to command */
49const char * const mi_lttng_element_command;
37d03ff7 50const char * const mi_lttng_element_command_name;
c7e35b03
JR
51const char * const mi_lttng_element_command_version;
52const char * const mi_lttng_element_command_list;
1734c658
JRJ
53const char * const mi_lttng_element_command_save;
54const char * const mi_lttng_element_command_load;
e5b83100 55const char * const mi_lttng_element_command_stop;
1cfc0bc8 56const char * const mi_lttng_element_command_start;
37d03ff7 57const char * const mi_lttng_element_command_create;
65f25c66 58const char * const mi_lttng_element_command_destroy;
7e66b1b0 59const char * const mi_lttng_element_command_calibrate;
c7e35b03 60const char * const mi_lttng_element_command_output;
1734c658 61const char * const mi_lttng_element_command_success;
c7e35b03 62
1734c658 63/* Strings related to version command */
c7e35b03
JR
64const char * const mi_lttng_element_version;
65const char * const mi_lttng_element_version_str;
66const char * const mi_lttng_element_version_web;
67const char * const mi_lttng_element_version_major;
68const char * const mi_lttng_element_version_minor;
69const char * const mi_lttng_element_version_license;
314d5222 70const char * const mi_lttng_element_version_commit;
c7e35b03
JR
71const char * const mi_lttng_element_version_patch_level;
72const char * const mi_lttng_element_version_description;
73
5e18ec73
JR
74/* String related to a lttng_event_field */
75const char * const mi_lttng_element_event_field;
76const char * const mi_lttng_element_event_fields;
77
78/* Strings related to pid */
79const char * const mi_lttng_element_pids;
80const char * const mi_lttng_element_pid;
81const char * const mi_lttng_element_pid_id;
82
1734c658
JRJ
83/* Strings related to save command */
84const char * const mi_lttng_element_save;
85
86/* Strings related to load command */
87const char * const mi_lttng_element_load;
88
5e18ec73
JR
89/* General element of mi_lttng */
90const char * const mi_lttng_element_type_other;
91const char * const mi_lttng_element_type_integer;
92const char * const mi_lttng_element_type_enum;
93const char * const mi_lttng_element_type_float;
94const char * const mi_lttng_element_type_string;
95const char * const mi_lttng_element_nowrite;
96
97/* String related to loglevel */
98const char * const mi_lttng_loglevel_str_alert;
99const char * const mi_lttng_loglevel_str_crit;
100const char * const mi_lttng_loglevel_str_debug;
101const char * const mi_lttng_loglevel_str_debug_function;
102const char * const mi_lttng_loglevel_str_debug_line;
103const char * const mi_lttng_loglevel_str_debug_module;
104const char * const mi_lttng_loglevel_str_debug_process;
105const char * const mi_lttng_loglevel_str_debug_program;
106const char * const mi_lttng_loglevel_str_debug_system;
107const char * const mi_lttng_loglevel_str_debug_unit;
108const char * const mi_lttng_loglevel_str_emerg;
109const char * const mi_lttng_loglevel_str_err;
110const char * const mi_lttng_loglevel_str_info;
111const char * const mi_lttng_loglevel_str_notice;
112const char * const mi_lttng_loglevel_str_unknown;
113const char * const mi_lttng_loglevel_str_warning;
114
1734c658 115/* String related to loglevel type */
5e18ec73
JR
116const char * const mi_lttng_loglevel_type_all;
117const char * const mi_lttng_loglevel_type_range;
118const char * const mi_lttng_loglevel_type_single;
119const char * const mi_lttng_loglevel_type_unknown;
120
7e66b1b0
JRJ
121/* Sting related to lttng_calibrate */
122const char * const mi_lttng_element_calibrate;
123const char * const mi_lttng_element_calibrate_function;
124
5e18ec73
JR
125/* Utility string function */
126const char *mi_lttng_loglevel_string(int value);
127const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value);
128const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value);
129const char *mi_lttng_domaintype_string(enum lttng_domain_type value);
130const char *mi_lttng_buffertype_string(enum lttng_buffer_type value);
7e66b1b0 131const char *mi_lttng_calibratetype_string(enum lttng_calibrate_type val);
5e18ec73 132
c7e35b03
JR
133/*
134 * Create an instance of a machine interface writer.
135 *
136 * fd_output File to which the XML content must be written. The file will be
137 * closed once the mi_writer has been destroyed.
138 *
139 * Returns an instance of a machine interface writer on success, NULL on
140 * error.
141 */
142struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);
143
144/*
145 * Destroy an instance of a machine interface writer.
146 *
147 * writer An instance of a machine interface writer.
148 *
149 * Returns zero if the XML document could be closed cleanly. Negative values
150 * indicate an error.
151 */
152int mi_lttng_writer_destroy(struct mi_writer *writer);
153
154/*
155 * Open a command tag and add it's name node.
156 *
157 * writer An instance of a machine interface writer.
c7e35b03
JR
158 * command The command name.
159 *
160 * Returns zero if the XML document could be closed cleanly.
161 * Negative values indicate an error.
162 */
163int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);
164
165/*
166 * Close a command tag.
167 *
168 * writer An instance of a machine interface writer.
169 *
170 * Returns zero if the XML document could be closed cleanly.
171 * Negative values indicate an error.
172 */
173int mi_lttng_writer_command_close(struct mi_writer *writer);
174
175/*
176 * Open an element tag.
177 *
178 * writer An instance of a machine interface writer.
c7e35b03
JR
179 * element_name Element tag name.
180 *
181 * Returns zero if the XML document could be closed cleanly.
182 * Negative values indicate an error.
183 */
184int mi_lttng_writer_open_element(struct mi_writer *writer,
185 const char *element_name);
186
187/*
188 * Close the current element tag.
189 *
190 * writer An instance of a machine interface writer.
191 *
192 * Returns zero if the XML document could be closed cleanly.
193 * Negative values indicate an error.
194 */
195int mi_lttng_writer_close_element(struct mi_writer *writer);
196
197/*
5e18ec73 198 * Close multiple element.
c7e35b03
JR
199 *
200 * writer An instance of a machine interface writer.
5e18ec73 201 * nb_element Number of elements.
c7e35b03 202 *
5e18ec73
JR
203 * Returns zero if the XML document could be closed cleanly.
204 * Negative values indicate an error.
205 */
206int mi_lttng_close_multi_element(struct mi_writer *writer,
207 unsigned int nb_element);
208
209/*
210 * Write an element of type unsigned int.
c7e35b03 211 *
5e18ec73
JR
212 * writer An instance of a machine interface writer.
213 * element_name Element name.
c7e35b03
JR
214 * value Unsigned int value of the element
215 *
216 * Returns zero if the element's value could be written.
217 * Negative values indicate an error.
218 */
219int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
220 const char *element_name, uint64_t value);
221
222/*
223 * Write an element of type signed int.
224 *
225 * writer An instance of a machine interface writer.
c7e35b03 226 * element_name Element name.
5e18ec73 227 * value Signed int value of the element.
c7e35b03
JR
228 *
229 * Returns zero if the element's value could be written.
230 * Negative values indicate an error.
231 */
232int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
233 const char *element_name, int64_t value);
234
235/*
236 * Write an element of type boolean.
237 *
238 * writer An instance of a machine interface writer.
c7e35b03 239 * element_name Element name.
5e18ec73 240 * value Boolean value of the element.
c7e35b03
JR
241 *
242 * Returns zero if the element's value could be written.
243 * Negative values indicate an error.
244 */
245int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
246 const char *element_name, int value);
247
248/*
249 * Write an element of type string.
250 *
251 * writer An instance of a machine interface writer.
c7e35b03 252 * element_name Element name.
5e18ec73 253 * value String value of the element.
c7e35b03
JR
254 *
255 * Returns zero if the element's value could be written.
256 * Negative values indicate an error.
257 */
258int mi_lttng_writer_write_element_string(struct mi_writer *writer,
259 const char *element_name, const char *value);
260
261/*
262 * Machine interface of struct version.
263 *
264 * writer An instance of a machine interface writer.
c7e35b03 265 * version Version struct.
c7e35b03 266 * lttng_description String value of the version description.
c7e35b03
JR
267 * lttng_license String value of the version license.
268 *
269 * Returns zero if the element's value could be written.
270 * Negative values indicate an error.
271 */
272int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version *version,
273 const char *lttng_description, const char *lttng_license);
274
275/*
5e18ec73 276 * Machine interface: open a sessions element.
c7e35b03 277 *
5e18ec73 278 * writer An instance of a machine interface writer.
c7e35b03 279 *
5e18ec73
JR
280 * Returns zero if the element's value could be written.
281 * Negative values indicate an error.
282 */
283int mi_lttng_sessions_open(struct mi_writer *writer);
284
285/*
286 * Machine interface of struct session.
c7e35b03 287 *
5e18ec73
JR
288 * writer An instance of a machine interface writer.
289 * session An instance of a session.
290 * is_open Defines whether or not the session element shall be closed.
291 * This should be used carefully and the client
292 * must close the session element.
293 * Use case: nested addtionnal information on a session
c7e35b03 294 * ex: domain,channel event.
c7e35b03
JR
295 *
296 * Returns zero if the element's value could be written.
297 * Negative values indicate an error.
298 */
299int mi_lttng_session(struct mi_writer *writer,
5e18ec73
JR
300 struct lttng_session *session, int is_open);
301
302/*
303 * Machine interface: open a domains element.
304 *
305 * writer An instance of a machine interface writer.
306 *
307 * Returns zero if the element's value could be written.
308 * Negative values indicate an error.
309 */
310int mi_lttng_domains_open(struct mi_writer *writer);
311
312/*
313 * Machine interface of struct domain.
314 *
315 * writer An instance of a machine interface writer.
316 * domain An instance of a domain.
317 *
318 * is_open Defines whether or not the session element shall be closed.
319 * This should be used carefully and the client
320 * must close the domain element.
321 * Use case: nested addition information on a domain
322 * ex: channel event.
323 *
324 * Returns zero if the element's value could be written.
325 * Negative values indicate an error.
326 */
327int mi_lttng_domain(struct mi_writer *writer,
328 struct lttng_domain *domain, int is_open);
329
330/*
331 * Machine interface: open a channels element.
332 *
333 * writer An instance of a machine interface writer.
334 *
335 * Returns zero if the element's value could be written.
336 * Negative values indicate an error.
337 */
338int mi_lttng_channels_open(struct mi_writer *writer);
339
340/*
341 * Machine interface of struct channel.
342 *
343 * writer An instance of a machine interface writer.
344 * channel An instance of a channel.
345 *
346 * is_open Defines whether or not the session element shall be closed.
347 * This should be used carefully and the client
348 * must close the channel element.
349 * Use case: nested addition information on a channel.
350 * ex: channel event.
351 *
352 * Returns zero if the element's value could be written.
353 * Negative values indicate an error.
354 */
355int mi_lttng_channel(struct mi_writer *writer,
356 struct lttng_channel *channel, int is_open);
357
358/*
359 * Machine interface of struct channel_attr.
360 *
361 * writer An instance of a machine interface writer.
362 * attr An instance of a channel_attr struct.
363 *
364 * Returns zero if the element's value could be written.
365 * Negative values indicate an error.
366 */
367int mi_lttng_channel_attr(struct mi_writer *writer,
368 struct lttng_channel_attr *attr);
369
370/*
371* Machine interface for event common attributes.
372*
373* writer An instance of a mi writer.
374* event single trace event.
375*
376* The common attribute are:
377* - mi event element
378* - event name
379* - event type
380* - enabled tag
381* - event filter
382*
383* Returns zero if the element's value could be written.
384* Negative values indicate an error.
385*/
386int mi_lttng_event_common_attributes(struct mi_writer *writer,
387 struct lttng_event *event);
388
389/*
390 * Machine interface for kernel tracepoint event with a loglevel.
391 *
392 * writer An instance of a mi writer.
393 * event single trace event.
394 *
395 * Returns zero if the element's value could be written.
396 * Negative values indicate an error.
397 */
398int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
399 struct lttng_event *event);
400
401/*
402 * Machine interface for kernel tracepoint event with no loglevel.
403 *
404 * writer An instance of a mi writer.
405 * event single trace event.
406 *
407 * Returns zero if the element's value could be written.
408 * Negative values indicate an error.
409 */
410int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer,
411 struct lttng_event *event);
412
413/*
414 * Machine interface for kernel function and probe event.
415 *
416 * writer An instance of a mi writer.
417 * event single trace event.
418 *
419 * Returns zero if the element's value could be written.
420 * Negative values indicate an error.
421 */
422int mi_lttng_event_function_probe(struct mi_writer *writer,
423 struct lttng_event *event);
424
425/*
426 * Machine interface for kernel function entry event.
427 *
428 * writer An instance of a mi writer.
429 * event single trace event.
430 *
431 * Returns zero if the element's value could be written.
432 * Negative values indicate an error.
433 */
434int mi_lttng_event_function_entry(struct mi_writer *writer,
435 struct lttng_event *event);
436
437/*
438 * Machine interface: open an events element.
439 *
440 * writer An instance of a machine interface writer.
441 *
442 * Returns zero if the element's value could be written.
443 * Negative values indicate an error.
444 */
445int mi_lttng_events_open(struct mi_writer *writer);
446
447/*
448 * Machine interface for printing an event.
449 * The trace event type currently supported are:
450 * TRACEPOINT,
451 * PROBE,
452 * FUNCTION,
453 * FUNCTION_ENTRY,
454 * SYSCALL
455 *
456 * writer An instance of a mi writer.
457 * event single trace event.
458 * is_open Defines whether or not the session element shall be closed.
459 * This should be used carefully and the client
460 * must close the event element.
461 * Use case: nested additional information
462 *
463 * Returns zero if the element's value could be written.
464 * Negative values indicate an error.
465 */
466int mi_lttng_event(struct mi_writer *writer, struct lttng_event *event,
467 int is_open);
468
469/*
470 * Machine interface for struct lttng_event_field.
471 *
472 * writer An instance of a mi writer.
473 * field An event_field instance.
474 *
475 * Returns zero if the element's value could be written.
476 * Negative values indicate an error.
477 */
478int mi_lttng_event_field(struct mi_writer *writer,
479 struct lttng_event_field *field);
480
481/*
482 * Machine interface: open a event_fields element.
483 *
484 * writer An instance of a machine interface writer.
485 *
486 * Returns zero if the element's value could be written.
487 * Negative values indicate an error.
488 */
489int mi_lttng_event_fields_open(struct mi_writer *writer);
490
491/*
492 * Machine interface: open a PIDs element.
493 *
494 * writer An instance of a machine interface writer.
495 *
496 * Returns zero if the element's value could be written.
497 * Negative values indicate an error.
498 */
499int mi_lttng_pids_open(struct mi_writer *writer);
500
501/*
502 * Machine interface of a PID.
503 *
504 * writer An instance of a machine interface writer.
505 * pid A PID.
506 *
507 * is_open Defines whether or not the session element shall be closed.
508 * This should be used carefully and the client
509 * must close the pid element.
510 * Use case: nested addition information on a domain
511 * ex: channel event.
512 *
513 * Returns zero if the element's value could be written.
514 * Negative values indicate an error.
515 */
516int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *cmdline,
517 int is_open);
c7e35b03 518
7e66b1b0
JRJ
519/*
520 * Machine interface for struct lttng_calibrate.
521 *
522 * writer An instance of a machine interface writer.
523 *
524 * calibrate A lttng_calibrate instance.
525 *
526 * Returns zero if the element's value could be written.
527 * Negative values indicate an error.
528 */
529int mi_lttng_calibrate(struct mi_writer *writer,
530 struct lttng_calibrate *calibrate);
531
c7e35b03 532#endif /* _MI_LTTNG_H */
This page took 0.079314 seconds and 4 git commands to generate.