X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=liblttng-ust%2Fust-events-internal.h;h=bd30e00a258b48b4901d80463ab8fb44a9164d36;hb=221309e3604c231925b2441e41e29c5fed80dc4d;hp=f93305ed057274e82dc479251a9637717438362d;hpb=d871c65bcb2e94c69e0a46e7e0dcd2dae2fce7af;p=lttng-ust.git diff --git a/liblttng-ust/ust-events-internal.h b/liblttng-ust/ust-events-internal.h index f93305ed..bd30e00a 100644 --- a/liblttng-ust/ust-events-internal.h +++ b/liblttng-ust/ust-events-internal.h @@ -1,36 +1,18 @@ -#ifndef _LTTNG_UST_EVENTS_INTERNAL_H -#define _LTTNG_UST_EVENTS_INTERNAL_H - /* - * ust-events-internal.h - * - * Copyright 2019 (c) - Francis Deslauriers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * Copyright 2019 (c) Francis Deslauriers */ +#ifndef _LTTNG_UST_EVENTS_INTERNAL_H +#define _LTTNG_UST_EVENTS_INTERNAL_H + #include #include #include -#include +#include #include struct lttng_event_enabler { @@ -44,6 +26,43 @@ struct lttng_event_enabler { struct lttng_ctx *ctx; }; +struct lttng_event_notifier_enabler { + struct lttng_enabler base; + uint64_t error_counter_index; + struct cds_list_head node; /* per-app list of event_notifier enablers */ + struct cds_list_head capture_bytecode_head; + struct lttng_event_notifier_group *group; /* weak ref */ + uint64_t user_token; /* User-provided token */ + uint64_t num_captures; +}; + +enum lttng_ust_bytecode_node_type { + LTTNG_UST_BYTECODE_NODE_TYPE_FILTER, + LTTNG_UST_BYTECODE_NODE_TYPE_CAPTURE, +}; + +struct lttng_ust_bytecode_node { + enum lttng_ust_bytecode_node_type type; + struct cds_list_head node; + struct lttng_enabler *enabler; + struct { + uint32_t len; + uint32_t reloc_offset; + uint64_t seqnum; + char data[]; + } bc; +}; + +struct lttng_ust_excluder_node { + struct cds_list_head node; + struct lttng_enabler *enabler; + /* + * struct lttng_ust_event_exclusion had variable sized array, + * must be last field. + */ + struct lttng_ust_event_exclusion excluder; +}; + static inline struct lttng_enabler *lttng_event_enabler_as_enabler( struct lttng_event_enabler *event_enabler) @@ -51,6 +70,12 @@ struct lttng_enabler *lttng_event_enabler_as_enabler( return &event_enabler->base; } +static inline +struct lttng_enabler *lttng_event_notifier_enabler_as_enabler( + struct lttng_event_notifier_enabler *event_notifier_enabler) +{ + return &event_notifier_enabler->base; +} /* * Allocate and initialize a `struct lttng_event_enabler` object. @@ -89,8 +114,9 @@ int lttng_event_enabler_disable(struct lttng_event_enabler *enabler); * events related to this enabler. */ LTTNG_HIDDEN -int lttng_event_enabler_attach_bytecode(struct lttng_event_enabler *enabler, - struct lttng_ust_filter_bytecode_node *bytecode); +int lttng_event_enabler_attach_filter_bytecode( + struct lttng_event_enabler *enabler, + struct lttng_ust_bytecode_node **bytecode); /* * Attach an application context to an event enabler. @@ -107,16 +133,113 @@ int lttng_event_enabler_attach_context(struct lttng_event_enabler *enabler, */ LTTNG_HIDDEN int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *enabler, - struct lttng_ust_excluder_node *excluder); + struct lttng_ust_excluder_node **excluder); + +/* + * Synchronize bytecodes for the enabler and the instance (event or + * event_notifier). + * + * This function goes over all bytecode programs of the enabler (event or + * event_notifier enabler) to ensure each is linked to the provided instance. + */ +LTTNG_HIDDEN +void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc, + struct lttng_ctx **ctx, + struct cds_list_head *instance_bytecode_runtime_head, + struct cds_list_head *enabler_bytecode_runtime_head); /* - * Synchronize bytecodes for the enabler and the event. + * Allocate and initialize a `struct lttng_event_notifier_group` object. * - * This function goes over all bytecode programs of the event enabler to ensure - * each is linked to the provided event. + * On success, returns a `struct lttng_triggre_group`, + * on memory error, returns NULL. + */ +LTTNG_HIDDEN +struct lttng_event_notifier_group *lttng_event_notifier_group_create(void); + +/* + * Destroy a `struct lttng_event_notifier_group` object. */ LTTNG_HIDDEN -void lttng_event_enabler_link_bytecode(struct lttng_event *event, - struct lttng_event_enabler *enabler); +void lttng_event_notifier_group_destroy( + struct lttng_event_notifier_group *event_notifier_group); + +/* + * Allocate and initialize a `struct lttng_event_notifier_enabler` object. + * + * On success, returns a `struct lttng_event_notifier_enabler`, + * On memory error, returns NULL. + */ +LTTNG_HIDDEN +struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( + struct lttng_event_notifier_group *event_notifier_group, + enum lttng_enabler_format_type format_type, + struct lttng_ust_event_notifier *event_notifier_param); + +/* + * Destroy a `struct lttng_event_notifier_enabler` object. + */ +LTTNG_HIDDEN +void lttng_event_notifier_enabler_destroy( + struct lttng_event_notifier_enabler *event_notifier_enabler); + +/* + * Enable a `struct lttng_event_notifier_enabler` object and all event + * notifiers related to this enabler. + */ +LTTNG_HIDDEN +int lttng_event_notifier_enabler_enable( + struct lttng_event_notifier_enabler *event_notifier_enabler); + +/* + * Disable a `struct lttng_event_notifier_enabler` object and all event + * notifiers related to this enabler. + */ +LTTNG_HIDDEN +int lttng_event_notifier_enabler_disable( + struct lttng_event_notifier_enabler *event_notifier_enabler); + +/* + * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and + * all event notifiers related to this enabler. + */ +LTTNG_HIDDEN +int lttng_event_notifier_enabler_attach_filter_bytecode( + struct lttng_event_notifier_enabler *event_notifier_enabler, + struct lttng_ust_bytecode_node **bytecode); + +/* + * Attach capture bytecode program to `struct lttng_event_notifier_enabler` and + * all event_notifiers related to this enabler. + */ +LTTNG_HIDDEN +int lttng_event_notifier_enabler_attach_capture_bytecode( + struct lttng_event_notifier_enabler *event_notifier_enabler, + struct lttng_ust_bytecode_node **bytecode); + +/* + * Attach exclusion list to `struct lttng_event_notifier_enabler` and all + * event notifiers related to this enabler. + */ +LTTNG_HIDDEN +int lttng_event_notifier_enabler_attach_exclusion( + struct lttng_event_notifier_enabler *event_notifier_enabler, + struct lttng_ust_excluder_node **excluder); + +LTTNG_HIDDEN +void lttng_free_event_notifier_filter_runtime( + struct lttng_event_notifier *event_notifier); + +/* + * Connect the probe on all enablers matching this event description. + * Called on library load. + */ +LTTNG_HIDDEN +int lttng_fix_pending_event_notifiers(void); + +LTTNG_HIDDEN +struct lttng_counter *lttng_ust_counter_create( + const char *counter_transport_name, + size_t number_dimensions, const struct lttng_counter_dimension *dimensions); #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */