X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-ust.c;h=4b7363f9fd2b15c6e4e1f05c9fe49cd58ff9f9c9;hp=906f916a91b51ceb1b075ff172ef14281583a577;hb=ba999de09a8640b8652bce92450bf06c12e12e38;hpb=2106efa08d11229241a114d1d71635a02006690e diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 906f916a9..4b7363f9f 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -15,7 +15,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include #include @@ -72,6 +71,7 @@ int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key) struct ltt_ust_event *event; const struct ltt_ust_ht_key *key; int ev_loglevel_value; + int ll_match; assert(node); assert(_key); @@ -87,19 +87,13 @@ int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key) goto no_match; } - /* Event loglevel. */ - if (ev_loglevel_value != key->loglevel_type) { - if (event->attr.loglevel_type == LTTNG_UST_LOGLEVEL_ALL - && key->loglevel_type == 0 && ev_loglevel_value == -1) { - /* - * Match is accepted. This is because on event creation, the - * loglevel is set to -1 if the event loglevel type is ALL so 0 and - * -1 are accepted for this loglevel type since 0 is the one set by - * the API when receiving an enable event. - */ - } else { - goto no_match; - } + /* Event loglevel value and type. */ + ll_match = loglevels_match(event->attr.loglevel_type, + ev_loglevel_value, key->loglevel_type, + key->loglevel_value, LTTNG_UST_LOGLEVEL_ALL); + + if (!ll_match) { + goto no_match; } /* Only one of the filters is NULL, fail. */ @@ -174,7 +168,8 @@ error: */ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, char *name, struct lttng_filter_bytecode *filter, - int loglevel_value, struct lttng_event_exclusion *exclusion) + enum lttng_ust_loglevel_type loglevel_type, int loglevel_value, + struct lttng_event_exclusion *exclusion) { struct lttng_ht_node_str *node; struct lttng_ht_iter iter; @@ -185,7 +180,8 @@ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, key.name = name; key.filter = filter; - key.loglevel_type = loglevel_value; + key.loglevel_type = loglevel_type; + key.loglevel_value = loglevel_value; key.exclusion = exclusion; cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed), @@ -363,6 +359,39 @@ error: return luc; } +/* + * Validates an exclusion list. + * + * Returns 0 if valid, negative value if invalid. + */ +static int validate_exclusion(struct lttng_event_exclusion *exclusion) +{ + size_t i; + int ret = 0; + + assert(exclusion); + + for (i = 0; i < exclusion->count; ++i) { + size_t j; + const char *name_a = + LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, i); + + for (j = 0; j < i; ++j) { + const char *name_b = + LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, j); + + if (!strncmp(name_a, name_b, LTTNG_SYMBOL_NAME_LEN)) { + /* Match! */ + ret = -1; + goto end; + } + } + } + +end: + return ret; +} + /* * Allocate and initialize a ust event. Set name and event type. * We own filter_expression, filter, and exclusion. @@ -379,6 +408,10 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, assert(ev); + if (exclusion && validate_exclusion(exclusion)) { + goto error; + } + lue = zmalloc(sizeof(struct ltt_ust_event)); if (lue == NULL) { PERROR("ust event zmalloc");