From: David Goulet Date: Mon, 19 Nov 2012 19:02:23 +0000 (-0500) Subject: Pass lttng_event struct to the set_filter API call X-Git-Tag: v2.1.0-rc8~5 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=178191b3899f114001f000c2e7f46909969f9c6f;p=lttng-tools.git Pass lttng_event struct to the set_filter API call This is the first commit which aims at changing the event hash table key from the single event name to event_name/filter/loglevel triplet. Acked-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index f4b07e29f..9e2d4d129 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -511,14 +511,14 @@ extern int lttng_enable_event(struct lttng_handle *handle, /* * Apply a filter expression to an event. * - * If event_name is NULL, the filter is applied to all events of the channel. + * If event is NULL, the filter is applied to all events of the channel. * If channel_name is NULL, a lookup of the event's channel is done. * If both are NULL, the filter is applied to all events of all channels. */ extern int lttng_set_event_filter(struct lttng_handle *handle, - const char *event_name, - const char *channel_name, + struct lttng_event *event, const char *channel_name, const char *filter_expression); + /* * Create or enable a channel. * The channel name cannot be NULL. diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index d58c53b66..eab52342c 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -1107,7 +1107,7 @@ error: * Command LTTNG_SET_FILTER processed by the client thread. */ int cmd_set_filter(struct ltt_session *session, int domain, - char *channel_name, char *event_name, + char *channel_name, struct lttng_event *event, struct lttng_filter_bytecode *bytecode) { int ret; @@ -1120,7 +1120,7 @@ int cmd_set_filter(struct ltt_session *session, int domain, { struct ltt_ust_session *usess = session->ust_session; - ret = filter_ust_set(usess, domain, bytecode, event_name, channel_name); + ret = filter_ust_set(usess, domain, bytecode, event, channel_name); if (ret != LTTNG_OK) { goto error; } diff --git a/src/bin/lttng-sessiond/cmd.h b/src/bin/lttng-sessiond/cmd.h index 061cb1aef..5cbd1da24 100644 --- a/src/bin/lttng-sessiond/cmd.h +++ b/src/bin/lttng-sessiond/cmd.h @@ -47,7 +47,7 @@ int cmd_disable_event_all(struct ltt_session *session, int domain, int cmd_add_context(struct ltt_session *session, int domain, char *channel_name, struct lttng_event_context *ctx, int kwpipe); int cmd_set_filter(struct ltt_session *session, int domain, - char *channel_name, char *event_name, + char *channel_name, struct lttng_event *event, struct lttng_filter_bytecode *bytecode); int cmd_enable_event(struct ltt_session *session, int domain, char *channel_name, struct lttng_event *event, int wpipe); diff --git a/src/bin/lttng-sessiond/filter.c b/src/bin/lttng-sessiond/filter.c index 688dfca4a..1088cbed5 100644 --- a/src/bin/lttng-sessiond/filter.c +++ b/src/bin/lttng-sessiond/filter.c @@ -75,7 +75,7 @@ error: * Add UST context to tracer. */ int filter_ust_set(struct ltt_ust_session *usess, int domain, - struct lttng_filter_bytecode *bytecode, char *event_name, + struct lttng_filter_bytecode *bytecode, struct lttng_event *event, char *channel_name) { int ret = LTTNG_OK, have_event = 0; @@ -102,8 +102,8 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain, goto error; } - /* Do we have an event name */ - if (strlen(event_name) != 0) { + /* Do we have a valid event. */ + if (event && event->name[0] != '\0') { have_event = 1; } @@ -118,7 +118,7 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain, /* If UST channel specified and event name, get UST event ref */ if (uchan && have_event) { - uevent = trace_ust_find_event_by_name(uchan->events, event_name); + uevent = trace_ust_find_event_by_name(uchan->events, event->name); if (uevent == NULL) { ret = LTTNG_ERR_UST_EVENT_NOT_FOUND; goto error; @@ -137,7 +137,7 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain, } else if (!uchan && have_event) { /* Add filter to event */ /* Add context to event without having the channel name */ cds_lfht_for_each_entry(chan_ht->ht, &iter.iter, uchan, node.node) { - uevent = trace_ust_find_event_by_name(uchan->events, event_name); + uevent = trace_ust_find_event_by_name(uchan->events, event->name); if (uevent != NULL) { ret = add_ufilter_to_event(usess, domain, uchan, uevent, bytecode); /* diff --git a/src/bin/lttng-sessiond/filter.h b/src/bin/lttng-sessiond/filter.h index d70682433..3ec16bcac 100644 --- a/src/bin/lttng-sessiond/filter.h +++ b/src/bin/lttng-sessiond/filter.h @@ -28,7 +28,7 @@ struct lttng_filter_bytecode; int filter_ust_set(struct ltt_ust_session *usess, int domain, - struct lttng_filter_bytecode *bytecode, char *event_name, + struct lttng_filter_bytecode *bytecode, struct lttng_event *event, char *channel_name); #endif /* _LTT_FILTER_H */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 7dd652abc..0a156d8e7 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2879,7 +2879,7 @@ skip_domain: ret = cmd_set_filter(cmd_ctx->session, cmd_ctx->lsm->domain.type, cmd_ctx->lsm->u.filter.channel_name, - cmd_ctx->lsm->u.filter.event_name, + &cmd_ctx->lsm->u.filter.event, bytecode); break; } diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index 4a76267ba..cdd137cc9 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -422,7 +422,7 @@ static int enable_events(char *session_name) goto error; } if (opt_filter && event_enabled) { - ret = lttng_set_event_filter(handle, ev.name, channel_name, + ret = lttng_set_event_filter(handle, &ev, channel_name, opt_filter); if (ret < 0) { fprintf(stderr, "Ret filter: %d\n", ret); @@ -587,7 +587,7 @@ static int enable_events(char *session_name) event_enabled = 1; } if (opt_filter && event_enabled) { - ret = lttng_set_event_filter(handle, ev.name, channel_name, + ret = lttng_set_event_filter(handle, &ev, channel_name, opt_filter); if (ret < 0) { switch (-ret) { diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 88ba54449..41f96d8a4 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -204,7 +204,7 @@ struct lttcomm_session_msg { } uri; struct { char channel_name[LTTNG_SYMBOL_NAME_LEN]; - char event_name[LTTNG_SYMBOL_NAME_LEN]; + struct lttng_event event; /* Length of following bytecode */ uint32_t bytecode_len; } filter; diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 4884b0294..c9fb293be 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -827,13 +827,13 @@ int lttng_enable_event(struct lttng_handle *handle, } /* - * set filter for an event + * Set filter for an event + * * Return negative error value on error. * Return size of returned session payload data if OK. */ - int lttng_set_event_filter(struct lttng_handle *handle, - const char *event_name, const char *channel_name, + struct lttng_event *event, const char *channel_name, const char *filter_expression) { struct lttcomm_session_msg lsm; @@ -927,8 +927,10 @@ int lttng_set_event_filter(struct lttng_handle *handle, copy_string(lsm.u.filter.channel_name, channel_name, sizeof(lsm.u.filter.channel_name)); /* Copy event name */ - copy_string(lsm.u.filter.event_name, event_name, - sizeof(lsm.u.filter.event_name)); + if (event) { + memcpy(&lsm.u.enable.event, event, sizeof(lsm.u.enable.event)); + } + lsm.u.filter.bytecode_len = sizeof(ctx->bytecode->b) + bytecode_get_len(&ctx->bytecode->b);