X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-events.c;h=61021f3a696334558654b0990b91415c6aec1670;hb=ed5b5bbd98b60355e8dec0d1e6507b0c6a132b0a;hp=ca8587306c2c37b6c6f93ac7ff7cc39a2bfb13c7;hpb=d970f72ef97cd5f1e5e0152ce48a4c6b28eccfb2;p=lttng-ust.git diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index ca858730..61021f3a 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include "error.h" #include "compat.h" @@ -260,7 +260,7 @@ int lttng_session_enable(struct lttng_session *session) */ cds_list_for_each_entry(chan, &session->chan_head, node) { const struct lttng_ctx *ctx; - const struct lttng_event_field *fields = NULL; + const struct lttng_ctx_field *fields = NULL; size_t nr_fields = 0; uint32_t chan_id; @@ -270,7 +270,7 @@ int lttng_session_enable(struct lttng_session *session) ctx = chan->ctx; if (ctx) { nr_fields = ctx->nr_fields; - fields = &ctx->fields->event_field; + fields = ctx->fields; } ret = ustcomm_register_channel(notify_socket, session->objd, @@ -491,6 +491,31 @@ static int lttng_desc_match_enabler(const struct lttng_event_desc *desc, struct lttng_enabler *enabler) { + struct lttng_ust_excluder_node *excluder; + + /* If event matches with an excluder, return 'does not match' */ + cds_list_for_each_entry(excluder, &enabler->excluder_head, node) { + int count; + + for (count = 0; count < excluder->excluder.count; count++) { + int found, len; + char *excluder_name; + + excluder_name = (char *) (excluder->excluder.names) + + count * LTTNG_UST_SYM_NAME_LEN; + len = strnlen(excluder_name, LTTNG_UST_SYM_NAME_LEN); + if (len > 0 && excluder_name[len - 1] == '*') { + found = !strncmp(desc->name, excluder_name, + len - 1); + } else { + found = !strncmp(desc->name, excluder_name, + LTTNG_UST_SYM_NAME_LEN - 1); + } + if (found) { + return 0; + } + } + } switch (enabler->type) { case LTTNG_ENABLER_WILDCARD: return lttng_desc_match_wildcard_enabler(desc, enabler); @@ -635,12 +660,9 @@ int lttng_enabler_ref_events(struct lttng_enabler *enabler) /* * Called at library load: connect the probe on all enablers matching * this event. - * called with session mutex held. - * TODO: currently, for each desc added, we iterate on all event desc - * (inefficient). We should create specific code that only target the - * added desc. + * Called with session mutex held. */ -int lttng_fix_pending_event_desc(const struct lttng_event_desc *desc) +int lttng_fix_pending_events(void) { struct lttng_session *session; @@ -690,6 +712,7 @@ struct lttng_enabler *lttng_enabler_create(enum lttng_enabler_type type, return NULL; enabler->type = type; CDS_INIT_LIST_HEAD(&enabler->filter_bytecode_head); + CDS_INIT_LIST_HEAD(&enabler->excluder_head); memcpy(&enabler->event_param, event_param, sizeof(enabler->event_param)); enabler->chan = chan; @@ -723,6 +746,15 @@ int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler, return 0; } +int lttng_enabler_attach_exclusion(struct lttng_enabler *enabler, + struct lttng_ust_excluder_node *excluder) +{ + excluder->enabler = enabler; + cds_list_add_tail(&excluder->node, &enabler->excluder_head); + lttng_session_lazy_sync_enablers(enabler->chan->session); + return 0; +} + int lttng_attach_context(struct lttng_ust_context *context_param, struct lttng_ctx **ctx, struct lttng_session *session) { @@ -743,6 +775,8 @@ int lttng_attach_context(struct lttng_ust_context *context_param, return lttng_add_vpid_to_ctx(ctx); case LTTNG_UST_CONTEXT_PROCNAME: return lttng_add_procname_to_ctx(ctx); + case LTTNG_UST_CONTEXT_IP: + return lttng_add_ip_to_ctx(ctx); default: return -EINVAL; } @@ -768,6 +802,7 @@ static void lttng_enabler_destroy(struct lttng_enabler *enabler) { struct lttng_ust_filter_bytecode_node *filter_node, *tmp_filter_node; + struct lttng_ust_excluder_node *excluder_node, *tmp_excluder_node; /* Destroy filter bytecode */ cds_list_for_each_entry_safe(filter_node, tmp_filter_node, @@ -775,6 +810,12 @@ void lttng_enabler_destroy(struct lttng_enabler *enabler) free(filter_node); } + /* Destroy excluders */ + cds_list_for_each_entry_safe(excluder_node, tmp_excluder_node, + &enabler->excluder_head, node) { + free(excluder_node); + } + /* Destroy contexts */ lttng_destroy_context(enabler->ctx);