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