common: rename filter bytecode types
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index 5ab55ec29d3718b83a67135e3b6a155af8c74bfb..9321d278984186cce37591e0c5de99347bdf4073 100644 (file)
@@ -18,6 +18,7 @@
 #include <urcu/compiler.h>
 #include <signal.h>
 
+#include <common/bytecode/bytecode.h>
 #include <common/compat/errno.h>
 #include <common/common.h>
 #include <common/hashtable/utils.h>
@@ -41,6 +42,7 @@
 #include "lttng-sessiond.h"
 #include "notification-thread-commands.h"
 #include "rotate.h"
+#include "event.h"
 
 struct lttng_ht *ust_app_ht;
 struct lttng_ht *ust_app_ht_by_sock;
@@ -1316,36 +1318,13 @@ error:
        return NULL;
 }
 
-/*
- * Allocate a filter and copy the given original filter.
- *
- * Return allocated filter or NULL on error.
- */
-static struct lttng_filter_bytecode *copy_filter_bytecode(
-               struct lttng_filter_bytecode *orig_f)
-{
-       struct lttng_filter_bytecode *filter = NULL;
-
-       /* Copy filter bytecode */
-       filter = zmalloc(sizeof(*filter) + orig_f->len);
-       if (!filter) {
-               PERROR("zmalloc alloc filter bytecode");
-               goto error;
-       }
-
-       memcpy(filter, orig_f, sizeof(*filter) + orig_f->len);
-
-error:
-       return filter;
-}
-
 /*
  * Create a liblttng-ust filter bytecode from given bytecode.
  *
  * Return allocated filter or NULL on error.
  */
 static struct lttng_ust_filter_bytecode *create_ust_bytecode_from_bytecode(
-               const struct lttng_filter_bytecode *orig_f)
+               const struct lttng_bytecode *orig_f)
 {
        struct lttng_ust_filter_bytecode *filter = NULL;
 
@@ -1356,7 +1335,7 @@ static struct lttng_ust_filter_bytecode *create_ust_bytecode_from_bytecode(
                goto error;
        }
 
-       assert(sizeof(struct lttng_filter_bytecode) ==
+       assert(sizeof(struct lttng_bytecode) ==
                        sizeof(struct lttng_ust_filter_bytecode));
        memcpy(filter, orig_f, sizeof(*filter) + orig_f->len);
 error:
@@ -1415,7 +1394,7 @@ error:
  * Return an ust_app_event object or NULL on error.
  */
 static struct ust_app_event *find_ust_app_event(struct lttng_ht *ht,
-               const char *name, const struct lttng_filter_bytecode *filter,
+               const char *name, const struct lttng_bytecode *filter,
                int loglevel_value,
                const struct lttng_event_exclusion *exclusion)
 {
@@ -1524,7 +1503,7 @@ error:
  * Set the filter on the tracer.
  */
 static int set_ust_object_filter(struct ust_app *app,
-               const struct lttng_filter_bytecode *bytecode,
+               const struct lttng_bytecode *bytecode,
                struct lttng_ust_object_data *ust_object)
 {
        int ret;
@@ -1944,43 +1923,57 @@ static int init_ust_event_notifier_from_event_rule(
 
        memset(event_notifier, 0, sizeof(*event_notifier));
 
-       status = lttng_event_rule_tracepoint_get_pattern(rule, &pattern);
-       if (status != LTTNG_EVENT_RULE_STATUS_OK) {
-               /* At this point, this is a fatal error. */
-               abort();
-       }
+       if (lttng_event_rule_targets_agent_domain(rule)) {
+               /*
+                * Special event for agents
+                * The actual meat of the event is in the filter that will be
+                * attached later on.
+                * Set the default values for the agent event.
+                */
+               pattern = event_get_default_agent_ust_name(
+                               lttng_event_rule_get_domain_type(rule));
+               loglevel = 0;
+               ust_loglevel_type = LTTNG_UST_LOGLEVEL_ALL;
+       } else {
+               status = lttng_event_rule_tracepoint_get_pattern(
+                               rule, &pattern);
+               if (status != LTTNG_EVENT_RULE_STATUS_OK) {
+                       /* At this point, this is a fatal error. */
+                       abort();
+               }
 
-       status = lttng_event_rule_tracepoint_get_log_level_type(
-                       rule, &loglevel_type);
-       if (status != LTTNG_EVENT_RULE_STATUS_OK) {
-               /* At this point, this is a fatal error. */
-               abort();
-       }
+               status = lttng_event_rule_tracepoint_get_log_level_type(
+                               rule, &loglevel_type);
+               if (status != LTTNG_EVENT_RULE_STATUS_OK) {
+                       /* At this point, this is a fatal error. */
+                       abort();
+               }
 
-       switch (loglevel_type) {
-       case LTTNG_EVENT_LOGLEVEL_ALL:
-               ust_loglevel_type = LTTNG_UST_LOGLEVEL_ALL;
-               break;
-       case LTTNG_EVENT_LOGLEVEL_RANGE:
-               ust_loglevel_type = LTTNG_UST_LOGLEVEL_RANGE;
-               break;
-       case LTTNG_EVENT_LOGLEVEL_SINGLE:
-               ust_loglevel_type = LTTNG_UST_LOGLEVEL_SINGLE;
-               break;
-       default:
-               /* Unknown log level specification type. */
-               abort();
-       }
+               switch (loglevel_type) {
+               case LTTNG_EVENT_LOGLEVEL_ALL:
+                       ust_loglevel_type = LTTNG_UST_LOGLEVEL_ALL;
+                       break;
+               case LTTNG_EVENT_LOGLEVEL_RANGE:
+                       ust_loglevel_type = LTTNG_UST_LOGLEVEL_RANGE;
+                       break;
+               case LTTNG_EVENT_LOGLEVEL_SINGLE:
+                       ust_loglevel_type = LTTNG_UST_LOGLEVEL_SINGLE;
+                       break;
+               default:
+                       /* Unknown log level specification type. */
+                       abort();
+               }
 
-       if (loglevel_type != LTTNG_EVENT_LOGLEVEL_ALL) {
-               status = lttng_event_rule_tracepoint_get_log_level(
-                               rule, &loglevel);
-               assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+               if (loglevel_type != LTTNG_EVENT_LOGLEVEL_ALL) {
+                       status = lttng_event_rule_tracepoint_get_log_level(
+                                       rule, &loglevel);
+                       assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+               }
        }
 
        event_notifier->event.instrumentation = LTTNG_UST_TRACEPOINT;
        ret = lttng_strncpy(event_notifier->event.name, pattern,
-                           LTTNG_UST_SYM_NAME_LEN - 1);
+                       LTTNG_UST_SYM_NAME_LEN - 1);
        if (ret) {
                ERR("Failed to copy event rule pattern to notifier: pattern = '%s' ",
                                pattern);
@@ -2119,7 +2112,7 @@ static void shadow_copy_event(struct ust_app_event *ua_event,
 
        /* Copy filter bytecode */
        if (uevent->filter) {
-               ua_event->filter = copy_filter_bytecode(uevent->filter);
+               ua_event->filter = lttng_bytecode_copy(uevent->filter);
                /* Filter might be NULL here in case of ENONEM. */
        }
 
This page took 0.025682 seconds and 4 git commands to generate.