| 1 | /* |
| 2 | * lttng.h |
| 3 | * |
| 4 | * Linux Trace Toolkit Control Library Header File |
| 5 | * |
| 6 | * Copyright (C) 2011 EfficiOS Inc. |
| 7 | * |
| 8 | * SPDX-License-Identifier: LGPL-2.1-only |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #ifndef LTTNG_H |
| 13 | #define LTTNG_H |
| 14 | |
| 15 | /* Error codes that can be returned by API calls */ |
| 16 | #include <lttng/lttng-error.h> |
| 17 | |
| 18 | /* Include every LTTng ABI/API available. */ |
| 19 | #include <lttng/action/action.h> |
| 20 | #include <lttng/action/list.h> |
| 21 | #include <lttng/action/notify.h> |
| 22 | #include <lttng/action/path.h> |
| 23 | #include <lttng/action/rate-policy.h> |
| 24 | #include <lttng/action/rotate-session.h> |
| 25 | #include <lttng/action/snapshot-session.h> |
| 26 | #include <lttng/action/start-session.h> |
| 27 | #include <lttng/action/stop-session.h> |
| 28 | #include <lttng/channel.h> |
| 29 | #include <lttng/clear-handle.h> |
| 30 | #include <lttng/clear.h> |
| 31 | #include <lttng/condition/buffer-usage.h> |
| 32 | #include <lttng/condition/condition.h> |
| 33 | #include <lttng/condition/evaluation.h> |
| 34 | #include <lttng/condition/event-rule-matches.h> |
| 35 | #include <lttng/condition/session-consumed-size.h> |
| 36 | #include <lttng/condition/session-rotation.h> |
| 37 | #include <lttng/constant.h> |
| 38 | #include <lttng/destruction-handle.h> |
| 39 | #include <lttng/domain.h> |
| 40 | #include <lttng/endpoint.h> |
| 41 | #include <lttng/error-query.h> |
| 42 | #include <lttng/event-expr.h> |
| 43 | #include <lttng/event-field-value.h> |
| 44 | #include <lttng/event-rule/event-rule.h> |
| 45 | #include <lttng/event-rule/jul-logging.h> |
| 46 | #include <lttng/event-rule/kernel-kprobe.h> |
| 47 | #include <lttng/event-rule/kernel-syscall.h> |
| 48 | #include <lttng/event-rule/kernel-tracepoint.h> |
| 49 | #include <lttng/event-rule/kernel-uprobe.h> |
| 50 | #include <lttng/event-rule/log4j-logging.h> |
| 51 | #include <lttng/event-rule/python-logging.h> |
| 52 | #include <lttng/event-rule/user-tracepoint.h> |
| 53 | #include <lttng/event.h> |
| 54 | #include <lttng/handle.h> |
| 55 | #include <lttng/health.h> |
| 56 | #include <lttng/kernel.h> |
| 57 | #include <lttng/kernel-probe.h> |
| 58 | #include <lttng/load.h> |
| 59 | #include <lttng/location.h> |
| 60 | #include <lttng/log-level-rule.h> |
| 61 | #include <lttng/lttng-error.h> |
| 62 | #include <lttng/lttng-export.h> |
| 63 | #include <lttng/notification/channel.h> |
| 64 | #include <lttng/notification/notification.h> |
| 65 | #include <lttng/rotation.h> |
| 66 | #include <lttng/save.h> |
| 67 | #include <lttng/session-descriptor.h> |
| 68 | #include <lttng/session.h> |
| 69 | #include <lttng/snapshot.h> |
| 70 | #include <lttng/tracker.h> |
| 71 | #include <lttng/trigger/trigger.h> |
| 72 | #include <lttng/userspace-probe.h> |
| 73 | |
| 74 | #ifdef __cplusplus |
| 75 | extern "C" { |
| 76 | #endif |
| 77 | |
| 78 | enum lttng_calibrate_type { |
| 79 | LTTNG_CALIBRATE_FUNCTION = 0, |
| 80 | }; |
| 81 | |
| 82 | /* Machine interface output type */ |
| 83 | enum lttng_mi_output_type { |
| 84 | LTTNG_MI_XML = 1 /* XML output */ |
| 85 | }; |
| 86 | |
| 87 | #define LTTNG_CALIBRATE_PADDING1 16 |
| 88 | struct lttng_calibrate { |
| 89 | enum lttng_calibrate_type type; |
| 90 | |
| 91 | char padding[LTTNG_CALIBRATE_PADDING1]; |
| 92 | }; |
| 93 | |
| 94 | /* |
| 95 | * Check if a session daemon is alive. |
| 96 | * |
| 97 | * Return 1 if alive or 0 if not. On error, returns a negative negative LTTng |
| 98 | * error code. |
| 99 | */ |
| 100 | LTTNG_EXPORT extern int lttng_session_daemon_alive(void); |
| 101 | |
| 102 | /* |
| 103 | * Set the tracing group for the *current* flow of execution. |
| 104 | * |
| 105 | * On success, returns 0 else a negative LTTng error code. |
| 106 | */ |
| 107 | LTTNG_EXPORT extern int lttng_set_tracing_group(const char *name); |
| 108 | |
| 109 | /* |
| 110 | * This call registers an "outside consumer" for a session and an lttng domain. |
| 111 | * No consumer will be spawned and all fds/commands will go through the socket |
| 112 | * path given (socket_path). |
| 113 | * |
| 114 | * NOTE that this is not recommended unless you absolutely know what you are |
| 115 | * doing. |
| 116 | * |
| 117 | * Return 0 on success else a negative LTTng error code. |
| 118 | */ |
| 119 | LTTNG_EXPORT extern int lttng_register_consumer(struct lttng_handle *handle, |
| 120 | const char *socket_path); |
| 121 | |
| 122 | /* |
| 123 | * Start tracing for *all* domain(s) in the session. |
| 124 | * |
| 125 | * Return 0 on success else a negative LTTng error code. |
| 126 | */ |
| 127 | LTTNG_EXPORT extern int lttng_start_tracing(const char *session_name); |
| 128 | |
| 129 | /* |
| 130 | * Stop tracing for *all* domain(s) in the session. |
| 131 | * |
| 132 | * This call will wait for data availability for each domain of the session so |
| 133 | * this can take an abritrary amount of time. However, when returning you have |
| 134 | * the guarantee that the data is ready to be read and analyze. Use the |
| 135 | * _no_wait call below to avoid this behavior. |
| 136 | * |
| 137 | * The session_name can't be NULL. |
| 138 | * |
| 139 | * Return 0 on success else a negative LTTng error code. |
| 140 | */ |
| 141 | LTTNG_EXPORT extern int lttng_stop_tracing(const char *session_name); |
| 142 | |
| 143 | /* |
| 144 | * Behave exactly like lttng_stop_tracing but does not wait for data |
| 145 | * availability. |
| 146 | */ |
| 147 | LTTNG_EXPORT extern int lttng_stop_tracing_no_wait(const char *session_name); |
| 148 | |
| 149 | /* |
| 150 | * Deprecated: As of LTTng 2.9, this function always returns |
| 151 | * -LTTNG_ERR_UND. |
| 152 | */ |
| 153 | #pragma GCC diagnostic push |
| 154 | #pragma GCC diagnostic ignored "-Wshadow" |
| 155 | LTTNG_EXPORT extern int lttng_calibrate(struct lttng_handle *handle, |
| 156 | struct lttng_calibrate *calibrate); |
| 157 | #pragma GCC diagnostic pop |
| 158 | |
| 159 | /* |
| 160 | * Set URL for a consumer for a session and domain. |
| 161 | * |
| 162 | * Both data and control URL must be defined. If both URLs are the same, only |
| 163 | * the control URL is used even for network streaming. |
| 164 | * |
| 165 | * Default port are 5342 and 5343 respectively for control and data which uses |
| 166 | * the TCP protocol. |
| 167 | * |
| 168 | * URL format: proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH] |
| 169 | * |
| 170 | * Possible protocols are: |
| 171 | * > file://... |
| 172 | * Local filesystem full path. |
| 173 | * |
| 174 | * > net[6]://... |
| 175 | * This will use the default network transport layer which is TCP for both |
| 176 | * control (PORT1) and data port (PORT2). |
| 177 | * |
| 178 | * > tcp[6]://... |
| 179 | * TCP only streaming. For this one, both data and control URL must be given. |
| 180 | * |
| 181 | * Return 0 on success else a negative LTTng error code. |
| 182 | */ |
| 183 | LTTNG_EXPORT extern int |
| 184 | lttng_set_consumer_url(struct lttng_handle *handle, const char *control_url, const char *data_url); |
| 185 | |
| 186 | /* |
| 187 | * For a given session name, this call checks if the data is ready to be read |
| 188 | * or is still being extracted by the consumer(s) (pending) hence not ready to |
| 189 | * be used by any readers. |
| 190 | * |
| 191 | * Return 0 if there is _no_ data pending in the buffers thus having a |
| 192 | * guarantee that the data can be read safely. Else, return 1 if there is still |
| 193 | * traced data is pending. On error, a negative value is returned and readable |
| 194 | * by lttng_strerror(). |
| 195 | */ |
| 196 | LTTNG_EXPORT extern int lttng_data_pending(const char *session_name); |
| 197 | |
| 198 | /* |
| 199 | * Gets the status of the kernel tracer. |
| 200 | * |
| 201 | * Sets the value of the argument, which must not be null. |
| 202 | */ |
| 203 | LTTNG_EXPORT extern enum lttng_error_code lttng_get_kernel_tracer_status(enum lttng_kernel_tracer_status *status); |
| 204 | |
| 205 | /* |
| 206 | * Deprecated, replaced by lttng_regenerate_metadata. |
| 207 | */ |
| 208 | LTTNG_DEPRECATED("Use lttng_regenerate_metadata") |
| 209 | LTTNG_EXPORT extern int lttng_metadata_regenerate(const char *session_name); |
| 210 | |
| 211 | /* |
| 212 | * Trigger the regeneration of the metadata for a session. |
| 213 | * The new metadata overwrite the previous one locally or remotely (through |
| 214 | * the lttng-relayd). Only kernel, per-uid and non-live sessions are supported. |
| 215 | * Return 0 on success, a negative LTTng error code on error. |
| 216 | */ |
| 217 | LTTNG_EXPORT extern int lttng_regenerate_metadata(const char *session_name); |
| 218 | |
| 219 | /* |
| 220 | * Trigger the regeneration of the statedump for a session. The new statedump |
| 221 | * information is appended to the currently active trace, the session needs to |
| 222 | * be active. |
| 223 | * |
| 224 | * Return 0 on success, a negative LTTng error code on error. |
| 225 | */ |
| 226 | LTTNG_EXPORT extern int lttng_regenerate_statedump(const char *session_name); |
| 227 | |
| 228 | #ifdef __cplusplus |
| 229 | } |
| 230 | #endif |
| 231 | |
| 232 | #endif /* LTTNG_H */ |