| 1 | /* |
| 2 | * Copyright (C) 2014 EfficiOS Inc. |
| 3 | * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 4 | * |
| 5 | * SPDX-License-Identifier: LGPL-2.1-only |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #ifndef _MI_LTTNG_H |
| 10 | #define _MI_LTTNG_H |
| 11 | |
| 12 | #include <stdint.h> |
| 13 | |
| 14 | #include <common/error.h> |
| 15 | #include <common/macros.h> |
| 16 | #include <common/config/session-config.h> |
| 17 | #include <lttng/lttng.h> |
| 18 | |
| 19 | /* Don't want to reference snapshot-internal.h here */ |
| 20 | struct lttng_snapshot_output; |
| 21 | |
| 22 | /* Instance of a machine interface writer. */ |
| 23 | struct mi_writer { |
| 24 | struct config_writer *writer; |
| 25 | enum lttng_mi_output_type type; |
| 26 | }; |
| 27 | |
| 28 | /* |
| 29 | * Version information for the machine interface. |
| 30 | */ |
| 31 | struct mi_lttng_version { |
| 32 | char version[LTTNG_NAME_MAX]; /* Version number of package */ |
| 33 | uint32_t version_major; /* LTTng-Tools major version number */ |
| 34 | uint32_t version_minor; /* LTTng-Tools minor version number */ |
| 35 | uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */ |
| 36 | char version_commit[LTTNG_NAME_MAX]; /* Commit hash of the current version */ |
| 37 | char version_name[LTTNG_NAME_MAX]; |
| 38 | char package_url[LTTNG_NAME_MAX]; /* Define to the home page for this package. */ |
| 39 | }; |
| 40 | |
| 41 | /* Strings related to command */ |
| 42 | extern const char * const mi_lttng_element_command; |
| 43 | extern const char * const mi_lttng_element_command_action; |
| 44 | extern const char * const mi_lttng_element_command_add_context; |
| 45 | extern const char * const mi_lttng_element_command_create; |
| 46 | extern const char * const mi_lttng_element_command_destroy; |
| 47 | extern const char * const mi_lttng_element_command_disable_channel; |
| 48 | extern const char * const mi_lttng_element_command_disable_event; |
| 49 | extern const char * const mi_lttng_element_command_enable_channels; |
| 50 | extern const char * const mi_lttng_element_command_enable_event; |
| 51 | extern const char * const mi_lttng_element_command_list; |
| 52 | extern const char * const mi_lttng_element_command_load; |
| 53 | extern const char * const mi_lttng_element_command_metadata; |
| 54 | extern const char * const mi_lttng_element_command_metadata_action; |
| 55 | extern const char * const mi_lttng_element_command_regenerate; |
| 56 | extern const char * const mi_lttng_element_command_regenerate_action; |
| 57 | extern const char * const mi_lttng_element_command_name; |
| 58 | extern const char * const mi_lttng_element_command_output; |
| 59 | extern const char * const mi_lttng_element_command_save; |
| 60 | extern const char * const mi_lttng_element_command_set_session; |
| 61 | extern const char * const mi_lttng_element_command_snapshot; |
| 62 | extern const char * const mi_lttng_element_command_snapshot_add; |
| 63 | extern const char * const mi_lttng_element_command_snapshot_del; |
| 64 | extern const char * const mi_lttng_element_command_snapshot_list; |
| 65 | extern const char * const mi_lttng_element_command_snapshot_record; |
| 66 | extern const char * const mi_lttng_element_command_start; |
| 67 | extern const char * const mi_lttng_element_command_stop; |
| 68 | extern const char * const mi_lttng_element_command_success; |
| 69 | extern const char * const mi_lttng_element_command_track; |
| 70 | extern const char * const mi_lttng_element_command_untrack; |
| 71 | extern const char * const mi_lttng_element_command_version; |
| 72 | extern const char * const mi_lttng_element_command_rotate; |
| 73 | extern const char * const mi_lttng_element_command_enable_rotation; |
| 74 | extern const char * const mi_lttng_element_command_disable_rotation; |
| 75 | extern const char * const mi_lttng_element_command_clear; |
| 76 | |
| 77 | /* Strings related to version command */ |
| 78 | extern const char * const mi_lttng_element_version; |
| 79 | extern const char * const mi_lttng_element_version_commit; |
| 80 | extern const char * const mi_lttng_element_version_description; |
| 81 | extern const char * const mi_lttng_element_version_license; |
| 82 | extern const char * const mi_lttng_element_version_major; |
| 83 | extern const char * const mi_lttng_element_version_minor; |
| 84 | extern const char * const mi_lttng_element_version_patch_level; |
| 85 | extern const char * const mi_lttng_element_version_str; |
| 86 | extern const char * const mi_lttng_element_version_web; |
| 87 | |
| 88 | /* String related to a lttng_event_field */ |
| 89 | extern const char * const mi_lttng_element_event_field; |
| 90 | extern const char * const mi_lttng_element_event_fields; |
| 91 | |
| 92 | /* String related to lttng_event_perf_counter_ctx */ |
| 93 | extern const char * const mi_lttng_element_perf_counter_context; |
| 94 | |
| 95 | /* Strings related to pid */ |
| 96 | extern const char * const mi_lttng_element_pid_id; |
| 97 | |
| 98 | /* Strings related to save command */ |
| 99 | extern const char * const mi_lttng_element_save; |
| 100 | |
| 101 | /* Strings related to load command */ |
| 102 | extern const char * const mi_lttng_element_load; |
| 103 | LTTNG_HIDDEN extern const char * const mi_lttng_element_load_overrides; |
| 104 | LTTNG_HIDDEN extern const char * const mi_lttng_element_load_override_url; |
| 105 | |
| 106 | /* General element of mi_lttng */ |
| 107 | extern const char * const mi_lttng_element_empty; |
| 108 | extern const char * const mi_lttng_element_id; |
| 109 | extern const char * const mi_lttng_element_nowrite; |
| 110 | extern const char * const mi_lttng_element_success; |
| 111 | extern const char * const mi_lttng_element_type_enum; |
| 112 | extern const char * const mi_lttng_element_type_float; |
| 113 | extern const char * const mi_lttng_element_type_integer; |
| 114 | extern const char * const mi_lttng_element_type_other; |
| 115 | extern const char * const mi_lttng_element_type_string; |
| 116 | |
| 117 | /* String related to loglevel */ |
| 118 | extern const char * const mi_lttng_loglevel_str_alert; |
| 119 | extern const char * const mi_lttng_loglevel_str_crit; |
| 120 | extern const char * const mi_lttng_loglevel_str_debug; |
| 121 | extern const char * const mi_lttng_loglevel_str_debug_function; |
| 122 | extern const char * const mi_lttng_loglevel_str_debug_line; |
| 123 | extern const char * const mi_lttng_loglevel_str_debug_module; |
| 124 | extern const char * const mi_lttng_loglevel_str_debug_process; |
| 125 | extern const char * const mi_lttng_loglevel_str_debug_program; |
| 126 | extern const char * const mi_lttng_loglevel_str_debug_system; |
| 127 | extern const char * const mi_lttng_loglevel_str_debug_unit; |
| 128 | extern const char * const mi_lttng_loglevel_str_emerg; |
| 129 | extern const char * const mi_lttng_loglevel_str_err; |
| 130 | extern const char * const mi_lttng_loglevel_str_info; |
| 131 | extern const char * const mi_lttng_loglevel_str_notice; |
| 132 | extern const char * const mi_lttng_loglevel_str_unknown; |
| 133 | extern const char * const mi_lttng_loglevel_str_warning; |
| 134 | |
| 135 | /* String related to loglevel JUL */ |
| 136 | extern const char * const mi_lttng_loglevel_str_jul_all; |
| 137 | extern const char * const mi_lttng_loglevel_str_jul_config; |
| 138 | extern const char * const mi_lttng_loglevel_str_jul_fine; |
| 139 | extern const char * const mi_lttng_loglevel_str_jul_finer; |
| 140 | extern const char * const mi_lttng_loglevel_str_jul_finest; |
| 141 | extern const char * const mi_lttng_loglevel_str_jul_info; |
| 142 | extern const char * const mi_lttng_loglevel_str_jul_off; |
| 143 | extern const char * const mi_lttng_loglevel_str_jul_severe; |
| 144 | extern const char * const mi_lttng_loglevel_str_jul_warning; |
| 145 | |
| 146 | /* String related to loglevel Log4j */ |
| 147 | extern const char * const mi_lttng_loglevel_str_log4j_off; |
| 148 | extern const char * const mi_lttng_loglevel_str_log4j_fatal; |
| 149 | extern const char * const mi_lttng_loglevel_str_log4j_error; |
| 150 | extern const char * const mi_lttng_loglevel_str_log4j_warn; |
| 151 | extern const char * const mi_lttng_loglevel_str_log4j_info; |
| 152 | extern const char * const mi_lttng_loglevel_str_log4j_debug; |
| 153 | extern const char * const mi_lttng_loglevel_str_log4j_trace; |
| 154 | extern const char * const mi_lttng_loglevel_str_log4j_all; |
| 155 | |
| 156 | /* String related to loglevel Python */ |
| 157 | extern const char * const mi_lttng_loglevel_str_python_critical; |
| 158 | extern const char * const mi_lttng_loglevel_str_python_error; |
| 159 | extern const char * const mi_lttng_loglevel_str_python_warning; |
| 160 | extern const char * const mi_lttng_loglevel_str_python_info; |
| 161 | extern const char * const mi_lttng_loglevel_str_python_debug; |
| 162 | extern const char * const mi_lttng_loglevel_str_python_notset; |
| 163 | |
| 164 | /* String related to loglevel type */ |
| 165 | extern const char * const mi_lttng_loglevel_type_all; |
| 166 | extern const char * const mi_lttng_loglevel_type_range; |
| 167 | extern const char * const mi_lttng_loglevel_type_single; |
| 168 | extern const char * const mi_lttng_loglevel_type_unknown; |
| 169 | |
| 170 | /* String related to a lttng_snapshot */ |
| 171 | extern const char * const mi_lttng_element_snapshot_ctrl_url; |
| 172 | extern const char * const mi_lttng_element_snapshot_data_url; |
| 173 | extern const char * const mi_lttng_element_snapshot_max_size; |
| 174 | extern const char * const mi_lttng_element_snapshot_n_ptr; |
| 175 | extern const char * const mi_lttng_element_snapshot_session_name; |
| 176 | extern const char * const mi_lttng_element_snapshots; |
| 177 | |
| 178 | /* String related to track/untrack command */ |
| 179 | extern const char * const mi_lttng_element_track_untrack_all_wildcard; |
| 180 | |
| 181 | LTTNG_HIDDEN extern const char * const mi_lttng_element_session_name; |
| 182 | |
| 183 | /* String related to rotate command */ |
| 184 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation; |
| 185 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotate_status; |
| 186 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule; |
| 187 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedules; |
| 188 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_periodic; |
| 189 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us; |
| 190 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_size_threshold; |
| 191 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes; |
| 192 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_result; |
| 193 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_results; |
| 194 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_state; |
| 195 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location; |
| 196 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_local; |
| 197 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_local_absolute_path; |
| 198 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay; |
| 199 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_host; |
| 200 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_control_port; |
| 201 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_data_port; |
| 202 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_protocol; |
| 203 | LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_relative_path; |
| 204 | |
| 205 | /* String related to enum lttng_rotation_state */ |
| 206 | LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_ongoing; |
| 207 | LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_completed; |
| 208 | LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_expired; |
| 209 | LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_error; |
| 210 | |
| 211 | /* String related to enum lttng_trace_archive_location_relay_protocol_type */ |
| 212 | LTTNG_HIDDEN extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp; |
| 213 | |
| 214 | /* String related to add-context command */ |
| 215 | LTTNG_HIDDEN extern const char * const mi_lttng_element_context_symbol; |
| 216 | |
| 217 | /* Utility string function */ |
| 218 | const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain); |
| 219 | const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value); |
| 220 | const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value); |
| 221 | const char *mi_lttng_domaintype_string(enum lttng_domain_type value); |
| 222 | const char *mi_lttng_buffertype_string(enum lttng_buffer_type value); |
| 223 | const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value); |
| 224 | const char *mi_lttng_trace_archive_location_relay_protocol_type_string( |
| 225 | enum lttng_trace_archive_location_relay_protocol_type value); |
| 226 | |
| 227 | /* |
| 228 | * Create an instance of a machine interface writer. |
| 229 | * |
| 230 | * fd_output File to which the XML content must be written. The file will be |
| 231 | * closed once the mi_writer has been destroyed. |
| 232 | * |
| 233 | * Returns an instance of a machine interface writer on success, NULL on |
| 234 | * error. |
| 235 | */ |
| 236 | struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type); |
| 237 | |
| 238 | /* |
| 239 | * Destroy an instance of a machine interface writer. |
| 240 | * |
| 241 | * writer An instance of a machine interface writer. |
| 242 | * |
| 243 | * Returns zero if the XML document could be closed cleanly. Negative values |
| 244 | * indicate an error. |
| 245 | */ |
| 246 | int mi_lttng_writer_destroy(struct mi_writer *writer); |
| 247 | |
| 248 | /* |
| 249 | * Open a command tag and add it's name node. |
| 250 | * |
| 251 | * writer An instance of a machine interface writer. |
| 252 | * command The command name. |
| 253 | * |
| 254 | * Returns zero if the XML document could be closed cleanly. |
| 255 | * Negative values indicate an error. |
| 256 | */ |
| 257 | int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command); |
| 258 | |
| 259 | /* |
| 260 | * Close a command tag. |
| 261 | * |
| 262 | * writer An instance of a machine interface writer. |
| 263 | * |
| 264 | * Returns zero if the XML document could be closed cleanly. |
| 265 | * Negative values indicate an error. |
| 266 | */ |
| 267 | int mi_lttng_writer_command_close(struct mi_writer *writer); |
| 268 | |
| 269 | /* |
| 270 | * Open an element tag. |
| 271 | * |
| 272 | * writer An instance of a machine interface writer. |
| 273 | * element_name Element tag name. |
| 274 | * |
| 275 | * Returns zero if the XML document could be closed cleanly. |
| 276 | * Negative values indicate an error. |
| 277 | */ |
| 278 | int mi_lttng_writer_open_element(struct mi_writer *writer, |
| 279 | const char *element_name); |
| 280 | |
| 281 | /* |
| 282 | * Close the current element tag. |
| 283 | * |
| 284 | * writer An instance of a machine interface writer. |
| 285 | * |
| 286 | * Returns zero if the XML document could be closed cleanly. |
| 287 | * Negative values indicate an error. |
| 288 | */ |
| 289 | int mi_lttng_writer_close_element(struct mi_writer *writer); |
| 290 | |
| 291 | /* |
| 292 | * Close multiple element. |
| 293 | * |
| 294 | * writer An instance of a machine interface writer. |
| 295 | * nb_element Number of elements. |
| 296 | * |
| 297 | * Returns zero if the XML document could be closed cleanly. |
| 298 | * Negative values indicate an error. |
| 299 | */ |
| 300 | int mi_lttng_close_multi_element(struct mi_writer *writer, |
| 301 | unsigned int nb_element); |
| 302 | |
| 303 | /* |
| 304 | * Write an element of type unsigned int. |
| 305 | * |
| 306 | * writer An instance of a machine interface writer. |
| 307 | * element_name Element name. |
| 308 | * value Unsigned int value of the element |
| 309 | * |
| 310 | * Returns zero if the element's value could be written. |
| 311 | * Negative values indicate an error. |
| 312 | */ |
| 313 | int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer, |
| 314 | const char *element_name, uint64_t value); |
| 315 | |
| 316 | /* |
| 317 | * Write an element of type signed int. |
| 318 | * |
| 319 | * writer An instance of a machine interface writer. |
| 320 | * element_name Element name. |
| 321 | * value Signed int value of the element. |
| 322 | * |
| 323 | * Returns zero if the element's value could be written. |
| 324 | * Negative values indicate an error. |
| 325 | */ |
| 326 | int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer, |
| 327 | const char *element_name, int64_t value); |
| 328 | |
| 329 | /* |
| 330 | * Write an element of type boolean. |
| 331 | * |
| 332 | * writer An instance of a machine interface writer. |
| 333 | * element_name Element name. |
| 334 | * value Boolean value of the element. |
| 335 | * |
| 336 | * Returns zero if the element's value could be written. |
| 337 | * Negative values indicate an error. |
| 338 | */ |
| 339 | int mi_lttng_writer_write_element_bool(struct mi_writer *writer, |
| 340 | const char *element_name, int value); |
| 341 | |
| 342 | /* |
| 343 | * Write an element of type string. |
| 344 | * |
| 345 | * writer An instance of a machine interface writer. |
| 346 | * element_name Element name. |
| 347 | * value String value of the element. |
| 348 | * |
| 349 | * Returns zero if the element's value could be written. |
| 350 | * Negative values indicate an error. |
| 351 | */ |
| 352 | int mi_lttng_writer_write_element_string(struct mi_writer *writer, |
| 353 | const char *element_name, const char *value); |
| 354 | |
| 355 | /* |
| 356 | * Machine interface of struct version. |
| 357 | * |
| 358 | * writer An instance of a machine interface writer. |
| 359 | * version Version struct. |
| 360 | * lttng_description String value of the version description. |
| 361 | * lttng_license String value of the version license. |
| 362 | * |
| 363 | * Returns zero if the element's value could be written. |
| 364 | * Negative values indicate an error. |
| 365 | */ |
| 366 | int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version *version, |
| 367 | const char *lttng_description, const char *lttng_license); |
| 368 | |
| 369 | /* |
| 370 | * Machine interface: open a sessions element. |
| 371 | * |
| 372 | * writer An instance of a machine interface writer. |
| 373 | * |
| 374 | * Returns zero if the element's value could be written. |
| 375 | * Negative values indicate an error. |
| 376 | */ |
| 377 | int mi_lttng_sessions_open(struct mi_writer *writer); |
| 378 | |
| 379 | /* |
| 380 | * Machine interface of struct session. |
| 381 | * |
| 382 | * writer An instance of a machine interface writer. |
| 383 | * session An instance of a session. |
| 384 | * is_open Defines whether or not the session element shall be closed. |
| 385 | * This should be used carefully and the client |
| 386 | * must close the session element. |
| 387 | * Use case: nested additional information on a session |
| 388 | * ex: domain,channel event. |
| 389 | * |
| 390 | * Returns zero if the element's value could be written. |
| 391 | * Negative values indicate an error. |
| 392 | */ |
| 393 | int mi_lttng_session(struct mi_writer *writer, |
| 394 | struct lttng_session *session, int is_open); |
| 395 | |
| 396 | /* |
| 397 | * Machine interface: open a domains element. |
| 398 | * |
| 399 | * writer An instance of a machine interface writer. |
| 400 | * |
| 401 | * Returns zero if the element's value could be written. |
| 402 | * Negative values indicate an error. |
| 403 | */ |
| 404 | int mi_lttng_domains_open(struct mi_writer *writer); |
| 405 | |
| 406 | /* |
| 407 | * Machine interface of struct domain. |
| 408 | * |
| 409 | * writer An instance of a machine interface writer. |
| 410 | * domain An instance of a domain. |
| 411 | * |
| 412 | * is_open Defines whether or not the session element shall be closed. |
| 413 | * This should be used carefully and the client |
| 414 | * must close the domain element. |
| 415 | * Use case: nested addition information on a domain |
| 416 | * ex: channel event. |
| 417 | * |
| 418 | * Returns zero if the element's value could be written. |
| 419 | * Negative values indicate an error. |
| 420 | */ |
| 421 | int mi_lttng_domain(struct mi_writer *writer, |
| 422 | struct lttng_domain *domain, int is_open); |
| 423 | |
| 424 | /* |
| 425 | * Machine interface: open a channels element. |
| 426 | * |
| 427 | * writer An instance of a machine interface writer. |
| 428 | * |
| 429 | * Returns zero if the element's value could be written. |
| 430 | * Negative values indicate an error. |
| 431 | */ |
| 432 | int mi_lttng_channels_open(struct mi_writer *writer); |
| 433 | |
| 434 | /* |
| 435 | * Machine interface of struct channel. |
| 436 | * |
| 437 | * writer An instance of a machine interface writer. |
| 438 | * channel An instance of a channel. |
| 439 | * |
| 440 | * is_open Defines whether or not the session element shall be closed. |
| 441 | * This should be used carefully and the client |
| 442 | * must close the channel element. |
| 443 | * Use case: nested addition information on a channel. |
| 444 | * ex: channel event. |
| 445 | * |
| 446 | * Returns zero if the element's value could be written. |
| 447 | * Negative values indicate an error. |
| 448 | */ |
| 449 | int mi_lttng_channel(struct mi_writer *writer, |
| 450 | struct lttng_channel *channel, int is_open); |
| 451 | |
| 452 | /* |
| 453 | * Machine interface of struct channel_attr. |
| 454 | * |
| 455 | * writer An instance of a machine interface writer. |
| 456 | * attr An instance of a channel_attr struct. |
| 457 | * |
| 458 | * Returns zero if the element's value could be written. |
| 459 | * Negative values indicate an error. |
| 460 | */ |
| 461 | int mi_lttng_channel_attr(struct mi_writer *writer, |
| 462 | struct lttng_channel_attr *attr); |
| 463 | |
| 464 | /* |
| 465 | * Machine interface for event common attributes. |
| 466 | * |
| 467 | * writer An instance of a mi writer. |
| 468 | * event single trace event. |
| 469 | * |
| 470 | * The common attribute are: |
| 471 | * - mi event element |
| 472 | * - event name |
| 473 | * - event type |
| 474 | * - enabled tag |
| 475 | * - event filter |
| 476 | * |
| 477 | * Returns zero if the element's value could be written. |
| 478 | * Negative values indicate an error. |
| 479 | */ |
| 480 | int mi_lttng_event_common_attributes(struct mi_writer *writer, |
| 481 | struct lttng_event *event); |
| 482 | |
| 483 | /* |
| 484 | * Machine interface for kernel tracepoint event with a loglevel. |
| 485 | * |
| 486 | * writer An instance of a mi writer. |
| 487 | * event single trace event. |
| 488 | * domain Event's domain |
| 489 | * |
| 490 | * Returns zero if the element's value could be written. |
| 491 | * Negative values indicate an error. |
| 492 | */ |
| 493 | int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer, |
| 494 | struct lttng_event *event, enum lttng_domain_type domain); |
| 495 | |
| 496 | /* |
| 497 | * Machine interface for kernel tracepoint event with no loglevel. |
| 498 | * |
| 499 | * writer An instance of a mi writer. |
| 500 | * event single trace event. |
| 501 | * |
| 502 | * Returns zero if the element's value could be written. |
| 503 | * Negative values indicate an error. |
| 504 | */ |
| 505 | int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer, |
| 506 | struct lttng_event *event); |
| 507 | |
| 508 | /* |
| 509 | * Machine interface for kernel function and probe event. |
| 510 | * |
| 511 | * writer An instance of a mi writer. |
| 512 | * event single trace event. |
| 513 | * |
| 514 | * Returns zero if the element's value could be written. |
| 515 | * Negative values indicate an error. |
| 516 | */ |
| 517 | int mi_lttng_event_function_probe(struct mi_writer *writer, |
| 518 | struct lttng_event *event); |
| 519 | |
| 520 | /* |
| 521 | * Machine interface for kernel function entry event. |
| 522 | * |
| 523 | * writer An instance of a mi writer. |
| 524 | * event single trace event. |
| 525 | * |
| 526 | * Returns zero if the element's value could be written. |
| 527 | * Negative values indicate an error. |
| 528 | */ |
| 529 | int mi_lttng_event_function_entry(struct mi_writer *writer, |
| 530 | struct lttng_event *event); |
| 531 | |
| 532 | /* |
| 533 | * Machine interface: open an events element. |
| 534 | * |
| 535 | * writer An instance of a machine interface writer. |
| 536 | * |
| 537 | * Returns zero if the element's value could be written. |
| 538 | * Negative values indicate an error. |
| 539 | */ |
| 540 | int mi_lttng_events_open(struct mi_writer *writer); |
| 541 | |
| 542 | /* |
| 543 | * Machine interface for printing an event. |
| 544 | * The trace event type currently supported are: |
| 545 | * TRACEPOINT, |
| 546 | * PROBE, |
| 547 | * FUNCTION, |
| 548 | * FUNCTION_ENTRY, |
| 549 | * SYSCALL |
| 550 | * |
| 551 | * writer An instance of a mi writer. |
| 552 | * event single trace event. |
| 553 | * is_open Defines whether or not the session element shall be closed. |
| 554 | * This should be used carefully and the client |
| 555 | * must close the event element. |
| 556 | * Use case: nested additional information |
| 557 | * domain Event's domain |
| 558 | * |
| 559 | * Returns zero if the element's value could be written. |
| 560 | * Negative values indicate an error. |
| 561 | */ |
| 562 | int mi_lttng_event(struct mi_writer *writer, struct lttng_event *event, |
| 563 | int is_open, enum lttng_domain_type domain); |
| 564 | |
| 565 | /* |
| 566 | * Machine interface for struct lttng_event_field. |
| 567 | * |
| 568 | * writer An instance of a mi writer. |
| 569 | * field An event_field instance. |
| 570 | * |
| 571 | * Returns zero if the element's value could be written. |
| 572 | * Negative values indicate an error. |
| 573 | */ |
| 574 | int mi_lttng_event_field(struct mi_writer *writer, |
| 575 | struct lttng_event_field *field); |
| 576 | |
| 577 | /* |
| 578 | * Machine interface: open a event_fields element. |
| 579 | * |
| 580 | * writer An instance of a machine interface writer. |
| 581 | * |
| 582 | * Returns zero if the element have be written. |
| 583 | * Negative values indicate an error. |
| 584 | */ |
| 585 | int mi_lttng_event_fields_open(struct mi_writer *writer); |
| 586 | |
| 587 | /* |
| 588 | * Machine interface: open a trackers 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_trackers_open(struct mi_writer *writer); |
| 596 | |
| 597 | /* |
| 598 | * Machine interface: open a process attribute tracker element. |
| 599 | * |
| 600 | * writer An instance of a machine interface writer. |
| 601 | * |
| 602 | * Returns zero if the element's value could be written. |
| 603 | * Negative values indicate an error. |
| 604 | * |
| 605 | * Note: A targets element is also opened for each tracker definition |
| 606 | */ |
| 607 | int mi_lttng_process_attribute_tracker_open( |
| 608 | struct mi_writer *writer, enum lttng_process_attr process_attr); |
| 609 | |
| 610 | /* |
| 611 | * Machine interface: open a PIDs element. |
| 612 | * |
| 613 | * writer An instance of a machine interface writer. |
| 614 | * |
| 615 | * Returns zero if the element's value could be written. |
| 616 | * Negative values indicate an error. |
| 617 | */ |
| 618 | int mi_lttng_pids_open(struct mi_writer *writer); |
| 619 | |
| 620 | /* |
| 621 | * Machine interface: open a processes element. |
| 622 | * |
| 623 | * writer An instance of a machine interface writer. |
| 624 | * |
| 625 | * Returns zero if the element's value could be written. |
| 626 | * Negative values indicate an error. |
| 627 | */ |
| 628 | int mi_lttng_processes_open(struct mi_writer *writer); |
| 629 | |
| 630 | /* |
| 631 | * Machine interface of a Process. |
| 632 | * |
| 633 | * writer An instance of a machine interface writer. |
| 634 | * pid A PID. |
| 635 | * |
| 636 | * is_open Defines whether or not the session element shall be closed. |
| 637 | * This should be used carefully and the client |
| 638 | * must close the pid element. |
| 639 | * Use case: nested addition information on a domain |
| 640 | * ex: channel event. |
| 641 | * |
| 642 | * Returns zero if the element's value could be written. |
| 643 | * Negative values indicate an error. |
| 644 | */ |
| 645 | int mi_lttng_process(struct mi_writer *writer, pid_t pid , const char *name, |
| 646 | int is_open); |
| 647 | |
| 648 | /* |
| 649 | * TODO: move pid of lttng list -u to process semantic on mi api bump |
| 650 | * Machine interface of a Process. |
| 651 | * |
| 652 | * writer An instance of a machine interface writer. |
| 653 | * pid A PID. |
| 654 | * |
| 655 | * is_open Defines whether or not the session element shall be closed. |
| 656 | * This should be used carefully and the client |
| 657 | * must close the pid element. |
| 658 | * Use case: nested addition information on a domain |
| 659 | * ex: channel event. |
| 660 | * |
| 661 | * Returns zero if the element's value could be written. |
| 662 | * Negative values indicate an error. |
| 663 | */ |
| 664 | int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *name, |
| 665 | int is_open); |
| 666 | |
| 667 | /* |
| 668 | * Machine interface: open a process attribute values element. |
| 669 | * |
| 670 | * writer An instance of a machine interface writer. |
| 671 | * |
| 672 | * Returns zero if the element's value could be written. |
| 673 | * Negative values indicate an error. |
| 674 | */ |
| 675 | int mi_lttng_process_attr_values_open(struct mi_writer *writer); |
| 676 | |
| 677 | /* |
| 678 | * Machine interface for track/untrack of all process attribute values. |
| 679 | * |
| 680 | * writer An instance of a machine interface writer. |
| 681 | * |
| 682 | * Returns zero if the element's value could be written. |
| 683 | * Negative values indicate an error. |
| 684 | */ |
| 685 | int mi_lttng_all_process_attribute_value(struct mi_writer *writer, |
| 686 | enum lttng_process_attr process_attr, |
| 687 | bool is_open); |
| 688 | |
| 689 | /* |
| 690 | * Machine interface for track/untrack of an integral process attribute value. |
| 691 | * |
| 692 | * writer An instance of a machine interface writer. |
| 693 | * |
| 694 | * Returns zero if the element's value could be written. |
| 695 | * Negative values indicate an error. |
| 696 | */ |
| 697 | int mi_lttng_integral_process_attribute_value(struct mi_writer *writer, |
| 698 | enum lttng_process_attr process_attr, |
| 699 | int64_t value, |
| 700 | bool is_open); |
| 701 | |
| 702 | /* |
| 703 | * Machine interface for track/untrack of a string process attribute value. |
| 704 | * |
| 705 | * writer An instance of a machine interface writer. |
| 706 | * |
| 707 | * Returns zero if the element's value could be written. |
| 708 | * Negative values indicate an error. |
| 709 | */ |
| 710 | int mi_lttng_string_process_attribute_value(struct mi_writer *writer, |
| 711 | enum lttng_process_attr process_attr, |
| 712 | const char *value, |
| 713 | bool is_open); |
| 714 | |
| 715 | /* |
| 716 | * Machine interface of a context. |
| 717 | * |
| 718 | * writer An instance of a machine interface writer |
| 719 | * |
| 720 | * context An instance of a lttng_event_context |
| 721 | * |
| 722 | * is_open Define if we close the context element |
| 723 | * This should be used carefully and the client |
| 724 | * need to close the context element. |
| 725 | * Returns zero if the element's value could be written. |
| 726 | * Negative values indicate an error. |
| 727 | */ |
| 728 | int mi_lttng_context(struct mi_writer *writer, |
| 729 | struct lttng_event_context *context, int is_open); |
| 730 | |
| 731 | /* |
| 732 | * Machine interface of a perf_counter_context. |
| 733 | * |
| 734 | * writer An instance of a machine interface writer |
| 735 | * |
| 736 | * contest An instance of a lttng_event_perf_counter_ctx |
| 737 | * |
| 738 | * Returns zero if the element's value could be written. |
| 739 | * Negative values indicate an error. |
| 740 | */ |
| 741 | int mi_lttng_perf_counter_context(struct mi_writer *writer, |
| 742 | struct lttng_event_perf_counter_ctx *perf_context); |
| 743 | |
| 744 | /* |
| 745 | * Machine interface of the snapshot list_output. |
| 746 | * It specifies the session for which we are listing snapshots, |
| 747 | * and it opens a snapshots element to list a sequence |
| 748 | * of snapshots. |
| 749 | * |
| 750 | * writer An instance of a machine interface writer. |
| 751 | * |
| 752 | * session_name: Snapshot output for session "session_name". |
| 753 | * |
| 754 | * Note: The client has to close the session and the snapshots elements after |
| 755 | * having listed every lttng_snapshot_output. |
| 756 | * |
| 757 | * Returns zero if the element's value could be written. |
| 758 | * Negative values indicate an error. |
| 759 | */ |
| 760 | int mi_lttng_snapshot_output_session_name(struct mi_writer *writer, |
| 761 | const char *session_name); |
| 762 | |
| 763 | /* |
| 764 | * Machine interface of the snapshot output. |
| 765 | * The machine interface serializes the following attributes: |
| 766 | * - id: ID of the snapshot output. |
| 767 | * - name: Name of the output. |
| 768 | * - data_url : Destination of the output. |
| 769 | * - ctrl_url: Destination of the output. |
| 770 | * - max_size: total size of all stream combined. |
| 771 | * |
| 772 | * writer An instance of a machine interface writer. |
| 773 | * |
| 774 | * output: A list of snapshot_output. |
| 775 | * |
| 776 | * Returns zero if the element's value could be written. |
| 777 | * Negative values indicate an error. |
| 778 | */ |
| 779 | int mi_lttng_snapshot_list_output(struct mi_writer *writer, |
| 780 | struct lttng_snapshot_output *output); |
| 781 | |
| 782 | /* |
| 783 | * Machine interface of the output of the command snapshot del output |
| 784 | * when deleting a snapshot either by id or by name. |
| 785 | * If the snapshot was found and successfully deleted using its id, |
| 786 | * it return the id of the snapshot and the current session name on which it |
| 787 | * was attached. |
| 788 | * |
| 789 | * Otherwise, it do the same process with the name of the snapshot, if the |
| 790 | * snapshot output id is undefined. |
| 791 | * |
| 792 | * writer An instance of a machine interface writer. |
| 793 | * |
| 794 | * id: ID of the snapshot output. |
| 795 | * |
| 796 | * name: Name of the snapshot. |
| 797 | * |
| 798 | * current_session_name: Session to which the snapshot belongs. |
| 799 | * |
| 800 | * Returns zero if the element's value could be written. |
| 801 | * Negative values indicate an error. |
| 802 | */ |
| 803 | int mi_lttng_snapshot_del_output(struct mi_writer *writer, int id, |
| 804 | const char *name, const char *current_session_name); |
| 805 | |
| 806 | /* |
| 807 | * Machine interface of the output of the command snapshot add output |
| 808 | * when adding a snapshot from a user URL. |
| 809 | * |
| 810 | * If the snapshot was successfully added, the machine interface lists |
| 811 | * these information: |
| 812 | * - id: ID of the newly add snapshot output. |
| 813 | * - current_session_name: Name of the session to which the output was added. |
| 814 | * - ctrl_url: Destination of the output. |
| 815 | * - max_size: total size of all stream combined. |
| 816 | * |
| 817 | * writer An instance of a machine interface writer. |
| 818 | * |
| 819 | * current_session_name: Session to which the snapshot belongs. |
| 820 | * |
| 821 | * n_ptr: |
| 822 | * |
| 823 | * output: iterator over a lttng_snapshot_output_list which contain |
| 824 | * the snapshot output informations. |
| 825 | * |
| 826 | * Returns zero if the element's value could be written. |
| 827 | * Negative values indicate an error. |
| 828 | */ |
| 829 | int mi_lttng_snapshot_add_output(struct mi_writer *writer, |
| 830 | const char *current_session_name, const char *n_ptr, |
| 831 | struct lttng_snapshot_output *output); |
| 832 | |
| 833 | /* |
| 834 | * Machine interface of the output of the command snapshot |
| 835 | * record from a URL (if given). |
| 836 | * |
| 837 | * If the snapshot is successfully recorded from a url, the machine interface |
| 838 | * output the following information: |
| 839 | * - url: Destination of the output stored in the snapshot. |
| 840 | * |
| 841 | * Otherwise, the machine interface output the data and ctrl url received |
| 842 | * from the command-line. |
| 843 | * |
| 844 | * writer An instance of a machine interface writer. |
| 845 | * |
| 846 | * current_session_name: Snapshot record for session "current_session_name". |
| 847 | * |
| 848 | * ctrl_url, data_url: Destination of the output receive from the command-line. |
| 849 | * |
| 850 | * Returns zero if the element's value could be written. |
| 851 | * Negative values indicate an error. |
| 852 | */ |
| 853 | int mi_lttng_snapshot_record(struct mi_writer *writer, |
| 854 | const char *current_session_name, const char *url, |
| 855 | const char *cmdline_ctrl_url, const char *cmdline_data_url); |
| 856 | |
| 857 | /* |
| 858 | * Machine interface representation of a session rotation schedule. |
| 859 | * |
| 860 | * The machine interface serializes the provided schedule as one of the choices |
| 861 | * from 'rotation_schedule_type'. |
| 862 | * |
| 863 | * writer: An instance of a machine interface writer. |
| 864 | * |
| 865 | * schedule: An lttng rotation schedule descriptor object. |
| 866 | * |
| 867 | * Returns zero if the element's value could be written. |
| 868 | * Negative values indicate an error. |
| 869 | */ |
| 870 | int mi_lttng_rotation_schedule(struct mi_writer *writer, |
| 871 | const struct lttng_rotation_schedule *schedule); |
| 872 | |
| 873 | /* |
| 874 | * Machine interface of a session rotation schedule result. |
| 875 | * This is an element that is part of the output of the enable-rotation and |
| 876 | * disable-rotation commands. |
| 877 | * |
| 878 | * The machine interface provides the following information: |
| 879 | * - schedule: the session rotation schedule descriptor. |
| 880 | * - success: whether the sub-command succeeded. |
| 881 | * |
| 882 | * writer: An instance of a machine interface writer. |
| 883 | * |
| 884 | * schedule: An lttng rotation schedule descriptor object. |
| 885 | * |
| 886 | * success: Whether the sub-command suceeded. |
| 887 | * |
| 888 | * Returns zero if the element's value could be written. |
| 889 | * Negative values indicate an error. |
| 890 | */ |
| 891 | int mi_lttng_rotation_schedule_result(struct mi_writer *writer, |
| 892 | const struct lttng_rotation_schedule *schedule, |
| 893 | bool success); |
| 894 | |
| 895 | /* |
| 896 | * Machine interface of a session rotation result. |
| 897 | * This is an element that is part of the output of the rotate command. |
| 898 | * |
| 899 | * The machine interface provides the following information: |
| 900 | * - session_name: the session to be rotated. |
| 901 | * - state: the session rotation state. |
| 902 | * - location: the location of the completed chunk archive. |
| 903 | * |
| 904 | * writer: An instance of a machine interface writer. |
| 905 | * |
| 906 | * session_name: The session to which the rotate command applies. |
| 907 | * |
| 908 | * location: A location descriptor object. |
| 909 | * |
| 910 | * success: Whether the sub-command suceeded. |
| 911 | * |
| 912 | * Returns zero if the element's value could be written. |
| 913 | * Negative values indicate an error. |
| 914 | */ |
| 915 | int mi_lttng_rotate(struct mi_writer *writer, |
| 916 | const char *session_name, |
| 917 | enum lttng_rotation_state rotation_state, |
| 918 | const struct lttng_trace_archive_location *location); |
| 919 | |
| 920 | #endif /* _MI_LTTNG_H */ |