Pass lttng_event struct to the set_filter API call
authorDavid Goulet <dgoulet@efficios.com>
Mon, 19 Nov 2012 19:02:23 +0000 (14:02 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Thu, 22 Nov 2012 17:03:39 +0000 (12:03 -0500)
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 <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
include/lttng/lttng.h
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/cmd.h
src/bin/lttng-sessiond/filter.c
src/bin/lttng-sessiond/filter.h
src/bin/lttng-sessiond/main.c
src/bin/lttng/commands/enable_events.c
src/common/sessiond-comm/sessiond-comm.h
src/lib/lttng-ctl/lttng-ctl.c

index f4b07e29f94a175b56758dc4fb38a71d1e48cf8f..9e2d4d129894878631d38452f05bc5ffc25c946a 100644 (file)
@@ -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.
index d58c53b66865bc0126dab3a26882d7c58d1ce41d..eab52342cc2f60ce32d87add0e60e350d8dbe680 100644 (file)
@@ -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;
                }
index 061cb1aefef37d29f4208a69d558c1494825b87c..5cbd1da24b6f468516dfdedd04cb68f27ed448ec 100644 (file)
@@ -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);
index 688dfca4a889cf95eecb7107053dcb9d28386c45..1088cbed58e34e27fa023b538670075ebc9cc8f9 100644 (file)
@@ -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);
                                /*
index d706824339352f08c8bd16a60960f648d910fd95..3ec16bcac9812cad70741e150a2afbf468c21cbe 100644 (file)
@@ -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 */
index 7dd652abc38b62994d9ed9c1c9df8a663fedabca..0a156d8e7e1d024c218b03be6a6e81b29ed7979f 100644 (file)
@@ -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;
        }
index 4a76267baada7f23619b89517a510afff69be0ee..cdd137cc9193d3aed0efdfee037546b97c958402 100644 (file)
@@ -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) {
index 88ba54449885c628b441a7d62315eb49ef7d0a9e..41f96d8a4288c355d60df2655bbd04b135102f79 100644 (file)
@@ -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;
index 4884b0294a0bfcc3aa73b67df222c6a08d845b74..c9fb293be1ed74411d20238ec7f94663a613041e 100644 (file)
@@ -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);
 
This page took 0.0319 seconds and 4 git commands to generate.