Commit | Line | Data |
---|---|---|
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 | ||
50534d6f JRJ |
29 | /* Don't want to reference snapshot-internal.h here */ |
30 | struct lttng_snapshot_output; | |
31 | ||
c7e35b03 JR |
32 | /* Instance of a machine interface writer. */ |
33 | struct mi_writer { | |
34 | struct config_writer *writer; | |
35 | enum lttng_mi_output_type type; | |
36 | }; | |
37 | ||
38 | /* | |
39 | * Version information for the machine interface. | |
40 | */ | |
41 | struct mi_lttng_version { | |
42 | char version[NAME_MAX]; /* Version number of package */ | |
43 | uint32_t version_major; /* LTTng-Tools major version number */ | |
44 | uint32_t version_minor; /* LTTng-Tools minor version number */ | |
45 | uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */ | |
314d5222 | 46 | char version_commit[NAME_MAX]; /* Commit hash of the current version */ |
c7e35b03 JR |
47 | char version_name[NAME_MAX]; |
48 | char package_url[NAME_MAX]; /* Define to the home page for this package. */ | |
49 | }; | |
50 | ||
51 | /* Strings related to command */ | |
52 | const char * const mi_lttng_element_command; | |
50534d6f | 53 | const char * const mi_lttng_element_command_action; |
f4a088f7 JRJ |
54 | const char * const mi_lttng_element_command_add_context; |
55 | const char * const mi_lttng_element_command_calibrate; | |
37d03ff7 | 56 | const char * const mi_lttng_element_command_create; |
65f25c66 | 57 | const char * const mi_lttng_element_command_destroy; |
f4a088f7 JRJ |
58 | const char * const mi_lttng_element_command_disable_channel; |
59 | const char * const mi_lttng_element_command_disable_event; | |
acc09215 | 60 | const char * const mi_lttng_element_command_enable_channels; |
f4a088f7 JRJ |
61 | const char * const mi_lttng_element_command_enable_event; |
62 | const char * const mi_lttng_element_command_list; | |
63 | const char * const mi_lttng_element_command_load; | |
64 | const char * const mi_lttng_element_command_name; | |
65 | const char * const mi_lttng_element_command_output; | |
66 | const char * const mi_lttng_element_command_save; | |
ce91cd0b | 67 | const char * const mi_lttng_element_command_set_session; |
50534d6f | 68 | const char * const mi_lttng_element_command_snapshot; |
f4a088f7 JRJ |
69 | const char * const mi_lttng_element_command_snapshot_add; |
70 | const char * const mi_lttng_element_command_snapshot_del; | |
71 | const char * const mi_lttng_element_command_snapshot_list; | |
72 | const char * const mi_lttng_element_command_snapshot_record; | |
73 | const char * const mi_lttng_element_command_start; | |
74 | const char * const mi_lttng_element_command_stop; | |
1734c658 | 75 | const char * const mi_lttng_element_command_success; |
f4a088f7 | 76 | const char * const mi_lttng_element_command_version; |
c7e35b03 | 77 | |
1734c658 | 78 | /* Strings related to version command */ |
c7e35b03 | 79 | const char * const mi_lttng_element_version; |
f4a088f7 JRJ |
80 | const char * const mi_lttng_element_version_commit; |
81 | const char * const mi_lttng_element_version_description; | |
82 | const char * const mi_lttng_element_version_license; | |
c7e35b03 JR |
83 | const char * const mi_lttng_element_version_major; |
84 | const char * const mi_lttng_element_version_minor; | |
c7e35b03 | 85 | const char * const mi_lttng_element_version_patch_level; |
f4a088f7 JRJ |
86 | const char * const mi_lttng_element_version_str; |
87 | const char * const mi_lttng_element_version_web; | |
c7e35b03 | 88 | |
5e18ec73 JR |
89 | /* String related to a lttng_event_field */ |
90 | const char * const mi_lttng_element_event_field; | |
91 | const char * const mi_lttng_element_event_fields; | |
92 | ||
89b72577 JRJ |
93 | /* String related to lttng_event_context */ |
94 | const char * const mi_lttng_context_type_perf_counter; | |
95 | const char * const mi_lttng_context_type_perf_cpu_counter; | |
96 | const char * const mi_lttng_context_type_perf_thread_counter; | |
97 | ||
98 | /* String related to lttng_event_perf_counter_ctx */ | |
99 | const char * const mi_lttng_element_perf_counter_context; | |
100 | ||
5e18ec73 JR |
101 | /* Strings related to pid */ |
102 | const char * const mi_lttng_element_pids; | |
103 | const char * const mi_lttng_element_pid; | |
104 | const char * const mi_lttng_element_pid_id; | |
105 | ||
1734c658 JRJ |
106 | /* Strings related to save command */ |
107 | const char * const mi_lttng_element_save; | |
108 | ||
109 | /* Strings related to load command */ | |
110 | const char * const mi_lttng_element_load; | |
111 | ||
5e18ec73 | 112 | /* General element of mi_lttng */ |
f4a088f7 JRJ |
113 | const char * const mi_lttng_element_empty; |
114 | const char * const mi_lttng_element_id; | |
115 | const char * const mi_lttng_element_nowrite; | |
116 | const char * const mi_lttng_element_success; | |
5e18ec73 JR |
117 | const char * const mi_lttng_element_type_enum; |
118 | const char * const mi_lttng_element_type_float; | |
f4a088f7 JRJ |
119 | const char * const mi_lttng_element_type_integer; |
120 | const char * const mi_lttng_element_type_other; | |
5e18ec73 | 121 | const char * const mi_lttng_element_type_string; |
5e18ec73 JR |
122 | |
123 | /* String related to loglevel */ | |
124 | const char * const mi_lttng_loglevel_str_alert; | |
125 | const char * const mi_lttng_loglevel_str_crit; | |
126 | const char * const mi_lttng_loglevel_str_debug; | |
127 | const char * const mi_lttng_loglevel_str_debug_function; | |
128 | const char * const mi_lttng_loglevel_str_debug_line; | |
129 | const char * const mi_lttng_loglevel_str_debug_module; | |
130 | const char * const mi_lttng_loglevel_str_debug_process; | |
131 | const char * const mi_lttng_loglevel_str_debug_program; | |
132 | const char * const mi_lttng_loglevel_str_debug_system; | |
133 | const char * const mi_lttng_loglevel_str_debug_unit; | |
134 | const char * const mi_lttng_loglevel_str_emerg; | |
135 | const char * const mi_lttng_loglevel_str_err; | |
136 | const char * const mi_lttng_loglevel_str_info; | |
137 | const char * const mi_lttng_loglevel_str_notice; | |
138 | const char * const mi_lttng_loglevel_str_unknown; | |
139 | const char * const mi_lttng_loglevel_str_warning; | |
140 | ||
136f2f81 JRJ |
141 | /* String related to loglevel JUL */ |
142 | const char * const mi_lttng_loglevel_str_jul_all; | |
143 | const char * const mi_lttng_loglevel_str_jul_config; | |
144 | const char * const mi_lttng_loglevel_str_jul_fine; | |
145 | const char * const mi_lttng_loglevel_str_jul_finer; | |
146 | const char * const mi_lttng_loglevel_str_jul_finest; | |
147 | const char * const mi_lttng_loglevel_str_jul_info; | |
148 | const char * const mi_lttng_loglevel_str_jul_off; | |
149 | const char * const mi_lttng_loglevel_str_jul_severe; | |
150 | const char * const mi_lttng_loglevel_str_jul_warning; | |
151 | ||
970d848b DG |
152 | /* String related to loglevel Log4j */ |
153 | const char * const mi_lttng_loglevel_str_log4j_off; | |
154 | const char * const mi_lttng_loglevel_str_log4j_fatal; | |
155 | const char * const mi_lttng_loglevel_str_log4j_error; | |
156 | const char * const mi_lttng_loglevel_str_log4j_warn; | |
157 | const char * const mi_lttng_loglevel_str_log4j_info; | |
158 | const char * const mi_lttng_loglevel_str_log4j_debug; | |
159 | const char * const mi_lttng_loglevel_str_log4j_trace; | |
160 | const char * const mi_lttng_loglevel_str_log4j_all; | |
161 | ||
1734c658 | 162 | /* String related to loglevel type */ |
5e18ec73 JR |
163 | const char * const mi_lttng_loglevel_type_all; |
164 | const char * const mi_lttng_loglevel_type_range; | |
165 | const char * const mi_lttng_loglevel_type_single; | |
166 | const char * const mi_lttng_loglevel_type_unknown; | |
167 | ||
7e66b1b0 JRJ |
168 | /* Sting related to lttng_calibrate */ |
169 | const char * const mi_lttng_element_calibrate; | |
170 | const char * const mi_lttng_element_calibrate_function; | |
171 | ||
136f2f81 | 172 | /* String related to a lttng_snapshot */ |
50534d6f | 173 | const char * const mi_lttng_element_snapshot_ctrl_url; |
f4a088f7 | 174 | const char * const mi_lttng_element_snapshot_data_url; |
50534d6f | 175 | const char * const mi_lttng_element_snapshot_max_size; |
f4a088f7 JRJ |
176 | const char * const mi_lttng_element_snapshot_n_ptr; |
177 | const char * const mi_lttng_element_snapshot_session_name; | |
178 | const char * const mi_lttng_element_snapshots; | |
50534d6f | 179 | |
5e18ec73 | 180 | /* Utility string function */ |
970d848b | 181 | const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain); |
5e18ec73 JR |
182 | const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value); |
183 | const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value); | |
184 | const char *mi_lttng_domaintype_string(enum lttng_domain_type value); | |
185 | const char *mi_lttng_buffertype_string(enum lttng_buffer_type value); | |
7e66b1b0 | 186 | const char *mi_lttng_calibratetype_string(enum lttng_calibrate_type val); |
5e18ec73 | 187 | |
c7e35b03 JR |
188 | /* |
189 | * Create an instance of a machine interface writer. | |
190 | * | |
191 | * fd_output File to which the XML content must be written. The file will be | |
192 | * closed once the mi_writer has been destroyed. | |
193 | * | |
194 | * Returns an instance of a machine interface writer on success, NULL on | |
195 | * error. | |
196 | */ | |
197 | struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type); | |
198 | ||
199 | /* | |
200 | * Destroy an instance of a machine interface writer. | |
201 | * | |
202 | * writer An instance of a machine interface writer. | |
203 | * | |
204 | * Returns zero if the XML document could be closed cleanly. Negative values | |
205 | * indicate an error. | |
206 | */ | |
207 | int mi_lttng_writer_destroy(struct mi_writer *writer); | |
208 | ||
209 | /* | |
210 | * Open a command tag and add it's name node. | |
211 | * | |
212 | * writer An instance of a machine interface writer. | |
c7e35b03 JR |
213 | * command The command name. |
214 | * | |
215 | * Returns zero if the XML document could be closed cleanly. | |
216 | * Negative values indicate an error. | |
217 | */ | |
218 | int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command); | |
219 | ||
220 | /* | |
221 | * Close a command tag. | |
222 | * | |
223 | * writer An instance of a machine interface writer. | |
224 | * | |
225 | * Returns zero if the XML document could be closed cleanly. | |
226 | * Negative values indicate an error. | |
227 | */ | |
228 | int mi_lttng_writer_command_close(struct mi_writer *writer); | |
229 | ||
230 | /* | |
231 | * Open an element tag. | |
232 | * | |
233 | * writer An instance of a machine interface writer. | |
c7e35b03 JR |
234 | * element_name Element tag name. |
235 | * | |
236 | * Returns zero if the XML document could be closed cleanly. | |
237 | * Negative values indicate an error. | |
238 | */ | |
239 | int mi_lttng_writer_open_element(struct mi_writer *writer, | |
240 | const char *element_name); | |
241 | ||
242 | /* | |
243 | * Close the current element tag. | |
244 | * | |
245 | * writer An instance of a machine interface writer. | |
246 | * | |
247 | * Returns zero if the XML document could be closed cleanly. | |
248 | * Negative values indicate an error. | |
249 | */ | |
250 | int mi_lttng_writer_close_element(struct mi_writer *writer); | |
251 | ||
252 | /* | |
5e18ec73 | 253 | * Close multiple element. |
c7e35b03 JR |
254 | * |
255 | * writer An instance of a machine interface writer. | |
5e18ec73 | 256 | * nb_element Number of elements. |
c7e35b03 | 257 | * |
5e18ec73 JR |
258 | * Returns zero if the XML document could be closed cleanly. |
259 | * Negative values indicate an error. | |
260 | */ | |
261 | int mi_lttng_close_multi_element(struct mi_writer *writer, | |
262 | unsigned int nb_element); | |
263 | ||
264 | /* | |
265 | * Write an element of type unsigned int. | |
c7e35b03 | 266 | * |
5e18ec73 JR |
267 | * writer An instance of a machine interface writer. |
268 | * element_name Element name. | |
c7e35b03 JR |
269 | * value Unsigned int value of the element |
270 | * | |
271 | * Returns zero if the element's value could be written. | |
272 | * Negative values indicate an error. | |
273 | */ | |
274 | int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer, | |
275 | const char *element_name, uint64_t value); | |
276 | ||
277 | /* | |
278 | * Write an element of type signed int. | |
279 | * | |
280 | * writer An instance of a machine interface writer. | |
c7e35b03 | 281 | * element_name Element name. |
5e18ec73 | 282 | * value Signed int value of the element. |
c7e35b03 JR |
283 | * |
284 | * Returns zero if the element's value could be written. | |
285 | * Negative values indicate an error. | |
286 | */ | |
287 | int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer, | |
288 | const char *element_name, int64_t value); | |
289 | ||
290 | /* | |
291 | * Write an element of type boolean. | |
292 | * | |
293 | * writer An instance of a machine interface writer. | |
c7e35b03 | 294 | * element_name Element name. |
5e18ec73 | 295 | * value Boolean value of the element. |
c7e35b03 JR |
296 | * |
297 | * Returns zero if the element's value could be written. | |
298 | * Negative values indicate an error. | |
299 | */ | |
300 | int mi_lttng_writer_write_element_bool(struct mi_writer *writer, | |
301 | const char *element_name, int value); | |
302 | ||
303 | /* | |
304 | * Write an element of type string. | |
305 | * | |
306 | * writer An instance of a machine interface writer. | |
c7e35b03 | 307 | * element_name Element name. |
5e18ec73 | 308 | * value String value of the element. |
c7e35b03 JR |
309 | * |
310 | * Returns zero if the element's value could be written. | |
311 | * Negative values indicate an error. | |
312 | */ | |
313 | int mi_lttng_writer_write_element_string(struct mi_writer *writer, | |
314 | const char *element_name, const char *value); | |
315 | ||
316 | /* | |
317 | * Machine interface of struct version. | |
318 | * | |
319 | * writer An instance of a machine interface writer. | |
c7e35b03 | 320 | * version Version struct. |
c7e35b03 | 321 | * lttng_description String value of the version description. |
c7e35b03 JR |
322 | * lttng_license String value of the version license. |
323 | * | |
324 | * Returns zero if the element's value could be written. | |
325 | * Negative values indicate an error. | |
326 | */ | |
327 | int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version *version, | |
328 | const char *lttng_description, const char *lttng_license); | |
329 | ||
330 | /* | |
5e18ec73 | 331 | * Machine interface: open a sessions element. |
c7e35b03 | 332 | * |
5e18ec73 | 333 | * writer An instance of a machine interface writer. |
c7e35b03 | 334 | * |
5e18ec73 JR |
335 | * Returns zero if the element's value could be written. |
336 | * Negative values indicate an error. | |
337 | */ | |
338 | int mi_lttng_sessions_open(struct mi_writer *writer); | |
339 | ||
340 | /* | |
341 | * Machine interface of struct session. | |
c7e35b03 | 342 | * |
5e18ec73 JR |
343 | * writer An instance of a machine interface writer. |
344 | * session An instance of a session. | |
345 | * is_open Defines whether or not the session element shall be closed. | |
346 | * This should be used carefully and the client | |
347 | * must close the session element. | |
136f2f81 | 348 | * Use case: nested additional information on a session |
c7e35b03 | 349 | * ex: domain,channel event. |
c7e35b03 JR |
350 | * |
351 | * Returns zero if the element's value could be written. | |
352 | * Negative values indicate an error. | |
353 | */ | |
354 | int mi_lttng_session(struct mi_writer *writer, | |
5e18ec73 JR |
355 | struct lttng_session *session, int is_open); |
356 | ||
357 | /* | |
358 | * Machine interface: open a domains element. | |
359 | * | |
360 | * writer An instance of a machine interface writer. | |
361 | * | |
362 | * Returns zero if the element's value could be written. | |
363 | * Negative values indicate an error. | |
364 | */ | |
365 | int mi_lttng_domains_open(struct mi_writer *writer); | |
366 | ||
367 | /* | |
368 | * Machine interface of struct domain. | |
369 | * | |
370 | * writer An instance of a machine interface writer. | |
371 | * domain An instance of a domain. | |
372 | * | |
373 | * is_open Defines whether or not the session element shall be closed. | |
374 | * This should be used carefully and the client | |
375 | * must close the domain element. | |
376 | * Use case: nested addition information on a domain | |
377 | * ex: channel event. | |
378 | * | |
379 | * Returns zero if the element's value could be written. | |
380 | * Negative values indicate an error. | |
381 | */ | |
382 | int mi_lttng_domain(struct mi_writer *writer, | |
383 | struct lttng_domain *domain, int is_open); | |
384 | ||
385 | /* | |
386 | * Machine interface: open a channels element. | |
387 | * | |
388 | * writer An instance of a machine interface writer. | |
389 | * | |
390 | * Returns zero if the element's value could be written. | |
391 | * Negative values indicate an error. | |
392 | */ | |
393 | int mi_lttng_channels_open(struct mi_writer *writer); | |
394 | ||
395 | /* | |
396 | * Machine interface of struct channel. | |
397 | * | |
398 | * writer An instance of a machine interface writer. | |
399 | * channel An instance of a channel. | |
400 | * | |
401 | * is_open Defines whether or not the session element shall be closed. | |
402 | * This should be used carefully and the client | |
403 | * must close the channel element. | |
404 | * Use case: nested addition information on a channel. | |
405 | * ex: channel event. | |
406 | * | |
407 | * Returns zero if the element's value could be written. | |
408 | * Negative values indicate an error. | |
409 | */ | |
410 | int mi_lttng_channel(struct mi_writer *writer, | |
411 | struct lttng_channel *channel, int is_open); | |
412 | ||
413 | /* | |
414 | * Machine interface of struct channel_attr. | |
415 | * | |
416 | * writer An instance of a machine interface writer. | |
417 | * attr An instance of a channel_attr struct. | |
418 | * | |
419 | * Returns zero if the element's value could be written. | |
420 | * Negative values indicate an error. | |
421 | */ | |
422 | int mi_lttng_channel_attr(struct mi_writer *writer, | |
423 | struct lttng_channel_attr *attr); | |
424 | ||
425 | /* | |
426 | * Machine interface for event common attributes. | |
427 | * | |
428 | * writer An instance of a mi writer. | |
429 | * event single trace event. | |
430 | * | |
431 | * The common attribute are: | |
432 | * - mi event element | |
433 | * - event name | |
434 | * - event type | |
435 | * - enabled tag | |
436 | * - event filter | |
437 | * | |
438 | * Returns zero if the element's value could be written. | |
439 | * Negative values indicate an error. | |
440 | */ | |
441 | int mi_lttng_event_common_attributes(struct mi_writer *writer, | |
442 | struct lttng_event *event); | |
443 | ||
444 | /* | |
445 | * Machine interface for kernel tracepoint event with a loglevel. | |
446 | * | |
447 | * writer An instance of a mi writer. | |
448 | * event single trace event. | |
970d848b | 449 | * domain Event's domain |
5e18ec73 JR |
450 | * |
451 | * Returns zero if the element's value could be written. | |
452 | * Negative values indicate an error. | |
453 | */ | |
454 | int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer, | |
970d848b | 455 | struct lttng_event *event, enum lttng_domain_type domain); |
5e18ec73 JR |
456 | |
457 | /* | |
458 | * Machine interface for kernel tracepoint event with no loglevel. | |
459 | * | |
460 | * writer An instance of a mi writer. | |
461 | * event single trace event. | |
462 | * | |
463 | * Returns zero if the element's value could be written. | |
464 | * Negative values indicate an error. | |
465 | */ | |
466 | int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer, | |
467 | struct lttng_event *event); | |
468 | ||
469 | /* | |
470 | * Machine interface for kernel function and probe event. | |
471 | * | |
472 | * writer An instance of a mi writer. | |
473 | * event single trace event. | |
474 | * | |
475 | * Returns zero if the element's value could be written. | |
476 | * Negative values indicate an error. | |
477 | */ | |
478 | int mi_lttng_event_function_probe(struct mi_writer *writer, | |
479 | struct lttng_event *event); | |
480 | ||
481 | /* | |
482 | * Machine interface for kernel function entry event. | |
483 | * | |
484 | * writer An instance of a mi writer. | |
485 | * event single trace event. | |
486 | * | |
487 | * Returns zero if the element's value could be written. | |
488 | * Negative values indicate an error. | |
489 | */ | |
490 | int mi_lttng_event_function_entry(struct mi_writer *writer, | |
491 | struct lttng_event *event); | |
492 | ||
493 | /* | |
494 | * Machine interface: open an events element. | |
495 | * | |
496 | * writer An instance of a machine interface writer. | |
497 | * | |
498 | * Returns zero if the element's value could be written. | |
499 | * Negative values indicate an error. | |
500 | */ | |
501 | int mi_lttng_events_open(struct mi_writer *writer); | |
502 | ||
503 | /* | |
504 | * Machine interface for printing an event. | |
505 | * The trace event type currently supported are: | |
506 | * TRACEPOINT, | |
507 | * PROBE, | |
508 | * FUNCTION, | |
509 | * FUNCTION_ENTRY, | |
510 | * SYSCALL | |
511 | * | |
512 | * writer An instance of a mi writer. | |
513 | * event single trace event. | |
514 | * is_open Defines whether or not the session element shall be closed. | |
515 | * This should be used carefully and the client | |
516 | * must close the event element. | |
517 | * Use case: nested additional information | |
970d848b | 518 | * domain Event's domain |
5e18ec73 JR |
519 | * |
520 | * Returns zero if the element's value could be written. | |
521 | * Negative values indicate an error. | |
522 | */ | |
523 | int mi_lttng_event(struct mi_writer *writer, struct lttng_event *event, | |
970d848b | 524 | int is_open, enum lttng_domain_type domain); |
5e18ec73 JR |
525 | |
526 | /* | |
527 | * Machine interface for struct lttng_event_field. | |
528 | * | |
529 | * writer An instance of a mi writer. | |
530 | * field An event_field instance. | |
531 | * | |
532 | * Returns zero if the element's value could be written. | |
533 | * Negative values indicate an error. | |
534 | */ | |
535 | int mi_lttng_event_field(struct mi_writer *writer, | |
536 | struct lttng_event_field *field); | |
537 | ||
538 | /* | |
539 | * Machine interface: open a event_fields element. | |
540 | * | |
541 | * writer An instance of a machine interface writer. | |
542 | * | |
e4d484a5 | 543 | * Returns zero if the element have be written. |
5e18ec73 JR |
544 | * Negative values indicate an error. |
545 | */ | |
546 | int mi_lttng_event_fields_open(struct mi_writer *writer); | |
547 | ||
548 | /* | |
549 | * Machine interface: open a PIDs element. | |
550 | * | |
551 | * writer An instance of a machine interface writer. | |
552 | * | |
553 | * Returns zero if the element's value could be written. | |
554 | * Negative values indicate an error. | |
555 | */ | |
556 | int mi_lttng_pids_open(struct mi_writer *writer); | |
557 | ||
558 | /* | |
559 | * Machine interface of a PID. | |
560 | * | |
561 | * writer An instance of a machine interface writer. | |
562 | * pid A PID. | |
563 | * | |
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 pid element. | |
567 | * Use case: nested addition information on a domain | |
568 | * ex: channel event. | |
569 | * | |
570 | * Returns zero if the element's value could be written. | |
571 | * Negative values indicate an error. | |
572 | */ | |
573 | int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *cmdline, | |
574 | int is_open); | |
c7e35b03 | 575 | |
7e66b1b0 JRJ |
576 | /* |
577 | * Machine interface for struct lttng_calibrate. | |
578 | * | |
579 | * writer An instance of a machine interface writer. | |
580 | * | |
581 | * calibrate A lttng_calibrate instance. | |
582 | * | |
583 | * Returns zero if the element's value could be written. | |
584 | * Negative values indicate an error. | |
585 | */ | |
586 | int mi_lttng_calibrate(struct mi_writer *writer, | |
587 | struct lttng_calibrate *calibrate); | |
588 | ||
89b72577 JRJ |
589 | /* |
590 | * Machine interface of a context. | |
591 | * | |
592 | * writer An instance of a machine interface writer | |
593 | * | |
594 | * context An instance of a lttng_event_context | |
595 | * | |
596 | * is_open Define if we close the context element | |
597 | * This should be used carefully and the client | |
598 | * need to close the context element. | |
89b72577 JRJ |
599 | * Returns zero if the element's value could be written. |
600 | * Negative values indicate an error. | |
601 | */ | |
602 | int mi_lttng_context(struct mi_writer *writer, | |
603 | struct lttng_event_context *context, int is_open); | |
604 | ||
605 | /* | |
606 | * Machine interface of a perf_counter_context. | |
607 | * | |
608 | * writer An instance of a machine interface writer | |
609 | * | |
610 | * contest An instance of a lttng_event_perf_counter_ctx | |
611 | * | |
612 | * Returns zero if the element's value could be written. | |
613 | * Negative values indicate an error. | |
614 | */ | |
615 | int mi_lttng_perf_counter_context(struct mi_writer *writer, | |
616 | struct lttng_event_perf_counter_ctx *perf_context); | |
617 | ||
50534d6f JRJ |
618 | /* |
619 | * Machine interface of the snapshot list_output. | |
620 | * It specifies the session for which we are listing snapshots, | |
621 | * and it opens a snapshots element to list a sequence | |
622 | * of snapshots. | |
623 | * | |
624 | * writer An instance of a machine interface writer. | |
625 | * | |
626 | * session_name: Snapshot output for session "session_name". | |
627 | * | |
628 | * Note: The client has to close the session and the snapshots elements after | |
629 | * having listed every lttng_snapshot_output. | |
630 | * | |
631 | * Returns zero if the element's value could be written. | |
632 | * Negative values indicate an error. | |
633 | */ | |
634 | int mi_lttng_snapshot_output_session_name(struct mi_writer *writer, | |
635 | const char *session_name); | |
636 | ||
637 | /* | |
638 | * Machine interface of the snapshot output. | |
639 | * The machine interface serializes the following attributes: | |
640 | * - id: ID of the snapshot output. | |
641 | * - name: Name of the output. | |
642 | * - data_url : Destination of the output. | |
643 | * - ctrl_url: Destination of the output. | |
644 | * - max_size: total size of all stream combined. | |
645 | * | |
646 | * writer An instance of a machine interface writer. | |
647 | * | |
648 | * output: A list of snapshot_output. | |
649 | * | |
650 | * Returns zero if the element's value could be written. | |
651 | * Negative values indicate an error. | |
652 | */ | |
653 | int mi_lttng_snapshot_list_output(struct mi_writer *writer, | |
654 | struct lttng_snapshot_output *output); | |
655 | ||
656 | /* | |
657 | * Machine interface of the output of the command snapshot del output | |
658 | * when deleting a snapshot either by id or by name. | |
659 | * If the snapshot was found and successfully deleted using its id, | |
660 | * it return the id of the snapshot and the current session name on which it | |
661 | * was attached. | |
662 | * | |
663 | * Otherwise, it do the same process with the name of the snapshot, if the | |
664 | * snapshot output id is undefined. | |
665 | * | |
666 | * writer An instance of a machine interface writer. | |
667 | * | |
668 | * id: ID of the snapshot output. | |
669 | * | |
670 | * name: Name of the snapshot. | |
671 | * | |
672 | * current_session_name: Session to which the snapshot belongs. | |
673 | * | |
674 | * Returns zero if the element's value could be written. | |
675 | * Negative values indicate an error. | |
676 | */ | |
677 | int mi_lttng_snapshot_del_output(struct mi_writer *writer, int id, | |
678 | const char *name, const char *current_session_name); | |
679 | ||
680 | /* | |
681 | * Machine interface of the output of the command snapshot add output | |
682 | * when adding a snapshot from a user URL. | |
683 | * | |
684 | * If the snapshot was successfully added, the machine interface lists | |
685 | * these information: | |
686 | * - id: ID of the newly add snapshot output. | |
687 | * - current_session_name: Name of the session to which the output was added. | |
688 | * - ctrl_url: Destination of the output. | |
689 | * - max_size: total size of all stream combined. | |
690 | * | |
691 | * writer An instance of a machine interface writer. | |
692 | * | |
693 | * current_session_name: Session to which the snapshot belongs. | |
694 | * | |
695 | * n_ptr: | |
696 | * | |
697 | * output: iterator over a lttng_snapshot_output_list which contain | |
698 | * the snapshot output informations. | |
699 | * | |
700 | * Returns zero if the element's value could be written. | |
701 | * Negative values indicate an error. | |
702 | */ | |
703 | int mi_lttng_snapshot_add_output(struct mi_writer *writer, | |
704 | const char *current_session_name, const char *n_ptr, | |
705 | struct lttng_snapshot_output *output); | |
706 | ||
707 | /* | |
708 | * Machine interface of the output of the command snapshot | |
709 | * record from a URL (if given). | |
710 | * | |
711 | * If the snapshot is successfully recorded from a url, the machine interface | |
712 | * output the following information: | |
713 | * - url: Destination of the output stored in the snapshot. | |
714 | * | |
715 | * Otherwise, the machine interface output the data and ctrl url received | |
716 | * from the command-line. | |
717 | * | |
718 | * writer An instance of a machine interface writer. | |
719 | * | |
720 | * current_session_name: Snapshot record for session "current_session_name". | |
721 | * | |
722 | * ctrl_url, data_url: Destination of the output receive from the command-line. | |
723 | * | |
724 | * Returns zero if the element's value could be written. | |
725 | * Negative values indicate an error. | |
726 | */ | |
727 | int mi_lttng_snapshot_record(struct mi_writer *writer, | |
728 | const char *current_session_name, const char *url, | |
729 | const char *cmdline_ctrl_url, const char *cmdline_data_url); | |
730 | ||
c7e35b03 | 731 | #endif /* _MI_LTTNG_H */ |