Save filter expressions as part of agent events
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 26 Aug 2015 15:37:48 +0000 (11:37 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 1 Sep 2015 16:03:08 +0000 (12:03 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/agent.c
src/bin/lttng-sessiond/agent.h
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/event.c
src/bin/lttng-sessiond/event.h

index d1e6723337c2a809100124e6762a730816218974..e68b680c2b866cdea2e11a9d537449ad6ff40567 100644 (file)
@@ -958,6 +958,7 @@ void agent_destroy_event(struct agent_event *event)
        assert(event);
 
        free(event->filter);
+       free(event->filter_expression);
        free(event);
 }
 
index 7faae117ee141cbcb8e99bfa76484fc46d957ed4..77c8faf584886e4590a7ae92ba73d4528aecaa3d 100644 (file)
@@ -92,6 +92,7 @@ struct agent_event {
        struct lttng_ht_node_str node;
 
        /* Bytecode filter associated with the event . NULL if none. */
+       char *filter_expression;
        struct lttng_filter_bytecode *filter;
 };
 
index ffff05809d2f072cd6c40ea00f83dec07fad5f56..ac489fa2fa7f946a7c65a8b81d8f4572323ea16d 100644 (file)
@@ -1769,6 +1769,7 @@ static int _cmd_enable_event(struct ltt_session *session,
 
                {
                        struct lttng_filter_bytecode *filter_copy = NULL;
+                       char *filter_expression_copy = NULL;
 
                        if (filter) {
                                filter_copy = zmalloc(
@@ -1779,16 +1780,28 @@ static int _cmd_enable_event(struct ltt_session *session,
                                }
 
                                memcpy(filter_copy, filter,
-                                       sizeof(struct lttng_filter_bytecode)
-                                       + filter->len);
+                                      sizeof(struct lttng_filter_bytecode)
+                                      + filter->len);
+                       }
+
+                       if (filter_expression) {
+                               filter_expression_copy =
+                                               strdup(filter_expression);
+                               if (!filter_expression) {
+                                       ret = LTTNG_ERR_NOMEM;
+                                       goto error_free_copy;
+                               }
                        }
 
                        ret = cmd_enable_event_internal(session, &tmp_dom,
                                        (char *) default_chan_name,
-                                       &uevent, filter_expression, filter_copy,
-                                       NULL, wpipe);
-                       /* We have passed ownership */
-                       filter_expression = NULL;
+                                       &uevent, filter_expression_copy,
+                                       filter_copy, NULL, wpipe);
+                       filter_copy = NULL;
+                       filter_expression_copy = NULL;
+error_free_copy:
+                       free(filter_copy);
+                       free(filter_expression_copy);
                }
 
                if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) {
@@ -1797,10 +1810,12 @@ static int _cmd_enable_event(struct ltt_session *session,
 
                /* The wild card * means that everything should be enabled. */
                if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) {
-                       ret = event_agent_enable_all(usess, agt, event, filter);
+                       ret = event_agent_enable_all(usess, agt, event, filter,
+                                       filter_expression);
                        filter = NULL;
                } else {
-                       ret = event_agent_enable(usess, agt, event, filter);
+                       ret = event_agent_enable(usess, agt, event, filter,
+                                       filter_expression);
                        filter = NULL;
                }
                if (ret != LTTNG_OK) {
index 9f4124ae77cb3f7a343f976b3239060fed085711..2244503c16d4287db0988adb40595f6ce20049bd 100644 (file)
@@ -359,7 +359,8 @@ error:
  */
 int event_agent_enable_all(struct ltt_ust_session *usess,
                struct agent *agt, struct lttng_event *event,
-               struct lttng_filter_bytecode *filter)
+               struct lttng_filter_bytecode *filter,
+               char *filter_expression)
 {
        int ret;
        struct agent_event *aevent;
@@ -370,7 +371,7 @@ int event_agent_enable_all(struct ltt_ust_session *usess,
        DBG("Event agent enabling ALL events for session %" PRIu64, usess->id);
 
        /* Enable event on agent application through TCP socket. */
-       ret = event_agent_enable(usess, agt, event, filter);
+       ret = event_agent_enable(usess, agt, event, filter, filter_expression);
        if (ret != LTTNG_OK) {
                goto error;
        }
@@ -396,7 +397,8 @@ error:
  */
 int event_agent_enable(struct ltt_ust_session *usess,
                struct agent *agt, struct lttng_event *event,
-               struct lttng_filter_bytecode *filter)
+               struct lttng_filter_bytecode *filter,
+               char *filter_expression)
 {
        int ret, created = 0;
        struct agent_event *aevent;
index 5f6bf07b7bef8e0d16e77136d80f2fe0310f0c68..2cf0d5eb502a6401aa09c5dd4a97c9e6c51e5959 100644 (file)
@@ -42,9 +42,11 @@ int event_ust_disable_tracepoint(struct ltt_ust_session *usess,
                struct ltt_ust_channel *uchan, char *event_name);
 
 int event_agent_enable(struct ltt_ust_session *usess, struct agent *agt,
-               struct lttng_event *event, struct lttng_filter_bytecode *filter);
+               struct lttng_event *event, struct lttng_filter_bytecode *filter,
+               char *filter_expression);
 int event_agent_enable_all(struct ltt_ust_session *usess, struct agent *agt,
-               struct lttng_event *event, struct lttng_filter_bytecode *filter);
+               struct lttng_event *event, struct lttng_filter_bytecode *filter,
+               char *filter_expression);
 
 int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt,
                char *event_name);
This page took 0.035604 seconds and 4 git commands to generate.