| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright 2019 (c) Francis Deslauriers <francis.deslauriers@efficios.com> |
| 5 | */ |
| 6 | |
| 7 | #ifndef _LTTNG_UST_EVENTS_INTERNAL_H |
| 8 | #define _LTTNG_UST_EVENTS_INTERNAL_H |
| 9 | |
| 10 | #include "common/events.h" |
| 11 | |
| 12 | /* |
| 13 | * Allocate and initialize a `struct lttng_event_recorder_enabler` object. |
| 14 | * |
| 15 | * On success, returns a `struct lttng_event_recorder_enabler`, |
| 16 | * On memory error, returns NULL. |
| 17 | */ |
| 18 | struct lttng_event_recorder_enabler *lttng_event_recorder_enabler_create( |
| 19 | enum lttng_enabler_format_type format_type, |
| 20 | const struct lttng_ust_abi_event *event_param, |
| 21 | struct lttng_ust_channel_buffer *chan) |
| 22 | __attribute__((visibility("hidden"))); |
| 23 | |
| 24 | /* |
| 25 | * Allocate and initialize a `struct lttng_event_counter_enabler` object. |
| 26 | * |
| 27 | * On success, returns a `struct lttng_event_counter_enabler`, |
| 28 | * On memory error, returns NULL. |
| 29 | */ |
| 30 | struct lttng_event_counter_enabler *lttng_event_counter_enabler_create( |
| 31 | enum lttng_enabler_format_type format_type, |
| 32 | const struct lttng_ust_abi_counter_event *counter_event, |
| 33 | const struct lttng_counter_key *key, |
| 34 | struct lttng_ust_channel_counter *chan) |
| 35 | __attribute__((visibility("hidden"))); |
| 36 | |
| 37 | /* |
| 38 | * Destroy a `struct lttng_event_enabler_common` object. |
| 39 | */ |
| 40 | void lttng_event_enabler_destroy(struct lttng_event_enabler_common *event_enabler) |
| 41 | __attribute__((visibility("hidden"))); |
| 42 | |
| 43 | /* |
| 44 | * Enable a `struct lttng_event_enabler_common` object and all events related to this |
| 45 | * enabler. |
| 46 | */ |
| 47 | int lttng_event_enabler_enable(struct lttng_event_enabler_common *enabler) |
| 48 | __attribute__((visibility("hidden"))); |
| 49 | |
| 50 | /* |
| 51 | * Disable a `struct lttng_event_enabler_common` object and all events related to this |
| 52 | * enabler. |
| 53 | */ |
| 54 | int lttng_event_enabler_disable(struct lttng_event_enabler_common *enabler) |
| 55 | __attribute__((visibility("hidden"))); |
| 56 | |
| 57 | /* |
| 58 | * Attach filter bytecode program to `struct lttng_event_enabler_common` and all |
| 59 | * events related to this enabler. |
| 60 | */ |
| 61 | int lttng_event_enabler_attach_filter_bytecode( |
| 62 | struct lttng_event_enabler_common *enabler, |
| 63 | struct lttng_ust_bytecode_node **bytecode) |
| 64 | __attribute__((visibility("hidden"))); |
| 65 | |
| 66 | /* |
| 67 | * Attach an application context to an event enabler. |
| 68 | * |
| 69 | * Not implemented. |
| 70 | */ |
| 71 | int lttng_event_enabler_attach_context(struct lttng_event_enabler_session_common *enabler, |
| 72 | struct lttng_ust_abi_context *ctx) |
| 73 | __attribute__((visibility("hidden"))); |
| 74 | |
| 75 | /* |
| 76 | * Attach exclusion list to `struct lttng_event_enabler_common` and all |
| 77 | * events related to this enabler. |
| 78 | */ |
| 79 | int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler_common *enabler, |
| 80 | struct lttng_ust_excluder_node **excluder) |
| 81 | __attribute__((visibility("hidden"))); |
| 82 | |
| 83 | /* |
| 84 | * Synchronize bytecodes for the enabler and the instance (event or |
| 85 | * event_notifier). |
| 86 | * |
| 87 | * This function goes over all bytecode programs of the enabler (event or |
| 88 | * event_notifier enabler) to ensure each is linked to the provided instance. |
| 89 | */ |
| 90 | void lttng_enabler_link_bytecode(const struct lttng_ust_event_desc *event_desc, |
| 91 | struct lttng_ust_ctx **ctx, |
| 92 | struct cds_list_head *instance_bytecode_runtime_head, |
| 93 | struct cds_list_head *enabler_bytecode_runtime_head) |
| 94 | __attribute__((visibility("hidden"))); |
| 95 | |
| 96 | /* |
| 97 | * Allocate and initialize a `struct lttng_event_notifier_group` object. |
| 98 | * |
| 99 | * On success, returns a `struct lttng_triggre_group`, |
| 100 | * on memory error, returns NULL. |
| 101 | */ |
| 102 | struct lttng_event_notifier_group *lttng_event_notifier_group_create(void) |
| 103 | __attribute__((visibility("hidden"))); |
| 104 | |
| 105 | /* |
| 106 | * Destroy a `struct lttng_event_notifier_group` object. |
| 107 | */ |
| 108 | void lttng_event_notifier_group_destroy( |
| 109 | struct lttng_event_notifier_group *event_notifier_group) |
| 110 | __attribute__((visibility("hidden"))); |
| 111 | |
| 112 | /* |
| 113 | * Allocate and initialize a `struct lttng_event_notifier_enabler` object. |
| 114 | * |
| 115 | * On success, returns a `struct lttng_event_notifier_enabler`, |
| 116 | * On memory error, returns NULL. |
| 117 | */ |
| 118 | struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( |
| 119 | struct lttng_event_notifier_group *event_notifier_group, |
| 120 | enum lttng_enabler_format_type format_type, |
| 121 | struct lttng_ust_abi_event_notifier *event_notifier_param) |
| 122 | __attribute__((visibility("hidden"))); |
| 123 | |
| 124 | /* |
| 125 | * Attach capture bytecode program to `struct lttng_event_notifier_enabler` and |
| 126 | * all event_notifiers related to this enabler. |
| 127 | */ |
| 128 | int lttng_event_notifier_enabler_attach_capture_bytecode( |
| 129 | struct lttng_event_notifier_enabler *event_notifier_enabler, |
| 130 | struct lttng_ust_bytecode_node **bytecode) |
| 131 | __attribute__((visibility("hidden"))); |
| 132 | |
| 133 | void lttng_free_event_filter_runtime(struct lttng_ust_event_common *event) |
| 134 | __attribute__((visibility("hidden"))); |
| 135 | |
| 136 | /* |
| 137 | * Connect the probe on all enablers matching this event description. |
| 138 | * Called on library load. |
| 139 | */ |
| 140 | int lttng_fix_pending_event_notifiers(void) |
| 141 | __attribute__((visibility("hidden"))); |
| 142 | |
| 143 | struct lttng_ust_channel_counter *lttng_ust_counter_create( |
| 144 | const char *counter_transport_name, |
| 145 | size_t number_dimensions, |
| 146 | const struct lttng_counter_dimension *dimensions, |
| 147 | int64_t global_sum_step, |
| 148 | bool coalesce_hits) |
| 149 | __attribute__((visibility("hidden"))); |
| 150 | |
| 151 | #ifdef HAVE_LINUX_PERF_EVENT_H |
| 152 | |
| 153 | int lttng_add_perf_counter_to_ctx(uint32_t type, |
| 154 | uint64_t config, |
| 155 | const char *name, |
| 156 | struct lttng_ust_ctx **ctx) |
| 157 | __attribute__((visibility("hidden"))); |
| 158 | |
| 159 | int lttng_perf_counter_init(void) |
| 160 | __attribute__((visibility("hidden"))); |
| 161 | |
| 162 | void lttng_perf_counter_exit(void) |
| 163 | __attribute__((visibility("hidden"))); |
| 164 | |
| 165 | #else /* #ifdef HAVE_LINUX_PERF_EVENT_H */ |
| 166 | |
| 167 | static inline |
| 168 | int lttng_add_perf_counter_to_ctx(uint32_t type __attribute__((unused)), |
| 169 | uint64_t config __attribute__((unused)), |
| 170 | const char *name __attribute__((unused)), |
| 171 | struct lttng_ust_ctx **ctx __attribute__((unused))) |
| 172 | { |
| 173 | return -ENOSYS; |
| 174 | } |
| 175 | static inline |
| 176 | int lttng_perf_counter_init(void) |
| 177 | { |
| 178 | return 0; |
| 179 | } |
| 180 | static inline |
| 181 | void lttng_perf_counter_exit(void) |
| 182 | { |
| 183 | } |
| 184 | #endif /* #else #ifdef HAVE_LINUX_PERF_EVENT_H */ |
| 185 | |
| 186 | int lttng_probes_get_event_list(struct lttng_ust_tracepoint_list *list) |
| 187 | __attribute__((visibility("hidden"))); |
| 188 | |
| 189 | void lttng_probes_prune_event_list(struct lttng_ust_tracepoint_list *list) |
| 190 | __attribute__((visibility("hidden"))); |
| 191 | |
| 192 | int lttng_probes_get_field_list(struct lttng_ust_field_list *list) |
| 193 | __attribute__((visibility("hidden"))); |
| 194 | |
| 195 | void lttng_probes_prune_field_list(struct lttng_ust_field_list *list) |
| 196 | __attribute__((visibility("hidden"))); |
| 197 | |
| 198 | struct lttng_ust_abi_tracepoint_iter * |
| 199 | lttng_ust_tracepoint_list_get_iter_next(struct lttng_ust_tracepoint_list *list) |
| 200 | __attribute__((visibility("hidden"))); |
| 201 | |
| 202 | struct lttng_ust_abi_field_iter * |
| 203 | lttng_ust_field_list_get_iter_next(struct lttng_ust_field_list *list) |
| 204 | __attribute__((visibility("hidden"))); |
| 205 | |
| 206 | struct lttng_ust_session *lttng_session_create(void) |
| 207 | __attribute__((visibility("hidden"))); |
| 208 | |
| 209 | int lttng_session_enable(struct lttng_ust_session *session) |
| 210 | __attribute__((visibility("hidden"))); |
| 211 | |
| 212 | int lttng_session_disable(struct lttng_ust_session *session) |
| 213 | __attribute__((visibility("hidden"))); |
| 214 | |
| 215 | int lttng_session_statedump(struct lttng_ust_session *session) |
| 216 | __attribute__((visibility("hidden"))); |
| 217 | |
| 218 | void lttng_session_destroy(struct lttng_ust_session *session) |
| 219 | __attribute__((visibility("hidden"))); |
| 220 | |
| 221 | /* |
| 222 | * Called with ust lock held. |
| 223 | */ |
| 224 | int lttng_session_active(void) |
| 225 | __attribute__((visibility("hidden"))); |
| 226 | |
| 227 | struct cds_list_head *lttng_get_sessions(void) |
| 228 | __attribute__((visibility("hidden"))); |
| 229 | |
| 230 | void lttng_handle_pending_statedump(void *owner) |
| 231 | __attribute__((visibility("hidden"))); |
| 232 | |
| 233 | int lttng_channel_enable(struct lttng_ust_channel_common *lttng_channel) |
| 234 | __attribute__((visibility("hidden"))); |
| 235 | |
| 236 | int lttng_channel_disable(struct lttng_ust_channel_common *lttng_channel) |
| 237 | __attribute__((visibility("hidden"))); |
| 238 | |
| 239 | void lttng_probe_provider_unregister_events(const struct lttng_ust_probe_desc *desc) |
| 240 | __attribute__((visibility("hidden"))); |
| 241 | |
| 242 | int lttng_fix_pending_events(void) |
| 243 | __attribute__((visibility("hidden"))); |
| 244 | |
| 245 | struct cds_list_head *lttng_get_probe_list_head(void) |
| 246 | __attribute__((visibility("hidden"))); |
| 247 | |
| 248 | int lttng_abi_create_root_handle(void) |
| 249 | __attribute__((visibility("hidden"))); |
| 250 | |
| 251 | const struct lttng_ust_abi_objd_ops *lttng_ust_abi_objd_ops(int id) |
| 252 | __attribute__((visibility("hidden"))); |
| 253 | |
| 254 | int lttng_ust_abi_objd_unref(int id, int is_owner) |
| 255 | __attribute__((visibility("hidden"))); |
| 256 | |
| 257 | void lttng_ust_abi_exit(void) |
| 258 | __attribute__((visibility("hidden"))); |
| 259 | |
| 260 | void lttng_ust_abi_events_exit(void) |
| 261 | __attribute__((visibility("hidden"))); |
| 262 | |
| 263 | void lttng_ust_abi_objd_table_owner_cleanup(void *owner) |
| 264 | __attribute__((visibility("hidden"))); |
| 265 | |
| 266 | int lttng_ust_interpret_event_filter(const struct lttng_ust_event_common *event, |
| 267 | const char *interpreter_stack_data, |
| 268 | struct lttng_ust_probe_ctx *probe_ctx, |
| 269 | void *filter_ctx) |
| 270 | __attribute__((visibility("hidden"))); |
| 271 | |
| 272 | int lttng_ust_session_uuid_validate(struct lttng_ust_session *session, |
| 273 | unsigned char *uuid) |
| 274 | __attribute__((visibility("hidden"))); |
| 275 | |
| 276 | bool lttng_ust_validate_event_name(const struct lttng_ust_event_desc *desc) |
| 277 | __attribute__((visibility("hidden"))); |
| 278 | |
| 279 | void lttng_ust_format_event_name(const struct lttng_ust_event_desc *desc, |
| 280 | char *name) |
| 281 | __attribute__((visibility("hidden"))); |
| 282 | |
| 283 | int lttng_ust_add_app_context_to_ctx_rcu(const char *name, struct lttng_ust_ctx **ctx) |
| 284 | __attribute__((visibility("hidden"))); |
| 285 | |
| 286 | int lttng_ust_context_set_provider_rcu(struct lttng_ust_ctx **_ctx, |
| 287 | const char *name, |
| 288 | size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, |
| 289 | size_t offset), |
| 290 | void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, |
| 291 | struct lttng_ust_ring_buffer_ctx *ctx, |
| 292 | struct lttng_ust_channel_buffer *chan), |
| 293 | void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, |
| 294 | struct lttng_ust_ctx_value *value)) |
| 295 | __attribute__((visibility("hidden"))); |
| 296 | |
| 297 | void lttng_ust_context_set_session_provider(const char *name, |
| 298 | size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, |
| 299 | size_t offset), |
| 300 | void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, |
| 301 | struct lttng_ust_ring_buffer_ctx *ctx, |
| 302 | struct lttng_ust_channel_buffer *chan), |
| 303 | void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, |
| 304 | struct lttng_ust_ctx_value *value)) |
| 305 | __attribute__((visibility("hidden"))); |
| 306 | |
| 307 | #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */ |