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>
Wed, 23 Sep 2015 19:24:41 +0000 (15:24 -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 50a6a7b1ea444728ea72701114856501e84bff18..29541ac23c57a4979470367f3fe464ef0cf7ef5e 100644 (file)
@@ -914,6 +914,7 @@ void agent_destroy_event(struct agent_event *event)
        assert(event);
 
        free(event->filter);
+       free(event->filter_expression);
        free(event);
 }
 
index d08ad6e220360ab87e6ce68b1bc8e9838e21962b..de95b31d90ed998c8393a148af1dd0fe4eb67ec9 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 bef4aa9594a95c64c193cf156fa77d0115ddd4e7..2d49aae2da892e1c41a47472145590c9d622fc00 100644 (file)
@@ -1609,6 +1609,7 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
 
                {
                        struct lttng_filter_bytecode *filter_copy = NULL;
+                       char *filter_expression_copy = NULL;
 
                        if (filter) {
                                filter_copy = zmalloc(
@@ -1619,16 +1620,28 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
                                }
 
                                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(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) {
@@ -1637,10 +1650,12 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
 
                /* 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 a7d437e8a2cc6cdd43c2b5ff97129e150e2d12de..243937908f11ffdc0bd50b79da7ec5ab1b6a8c1c 100644 (file)
@@ -632,7 +632,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;
@@ -643,7 +644,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;
        }
@@ -669,7 +670,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 501ee02d1eeb7d43a9e71c254a8a6e83f5d80763..c0b37ab8daf6ffa5617ec9168223a843e3f4920c 100644 (file)
@@ -53,9 +53,11 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess,
                struct ltt_ust_channel *uchan);
 
 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.030235 seconds and 4 git commands to generate.