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