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