event-rule: Normalize pattern for syscall and tracepoint
[lttng-tools.git] / src / common / event-rule / syscall.c
index 51f22fcc0ff85602d680f5216d790dc48f1c38a8..fbaa65310a6966548690bbb7db65c9c6ca91712b 100644 (file)
@@ -14,6 +14,7 @@
 #include <common/runas.h>
 #include <common/hashtable/hashtable.h>
 #include <common/hashtable/utils.h>
+#include <common/string-utils/string-utils.h>
 #include <lttng/event-rule/event-rule-internal.h>
 #include <lttng/event-rule/syscall-internal.h>
 
@@ -148,7 +149,7 @@ static enum lttng_error_code lttng_event_rule_syscall_generate_filter_bytecode(
        struct lttng_event_rule_syscall *syscall;
        enum lttng_event_rule_status status;
        const char *filter;
-       struct lttng_filter_bytecode *bytecode = NULL;
+       struct lttng_bytecode *bytecode = NULL;
 
        assert(rule);
 
@@ -205,7 +206,7 @@ static const char *lttng_event_rule_syscall_get_internal_filter(
        return syscall->internal_filter.filter;
 }
 
-static const struct lttng_filter_bytecode *
+static const struct lttng_bytecode *
 lttng_event_rule_syscall_get_internal_filter_bytecode(
                const struct lttng_event_rule *rule)
 {
@@ -217,12 +218,13 @@ lttng_event_rule_syscall_get_internal_filter_bytecode(
        return syscall->internal_filter.bytecode;
 }
 
-static struct lttng_event_exclusion *
-lttng_event_rule_syscall_generate_exclusions(
-               const struct lttng_event_rule *rule)
+static enum lttng_event_rule_generate_exclusions_status
+lttng_event_rule_syscall_generate_exclusions(const struct lttng_event_rule *rule,
+               struct lttng_event_exclusion **exclusions)
 {
-       /* Not supported. */
-       return NULL;
+       /* Unsupported. */
+       *exclusions = NULL;
+       return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
 }
 
 static unsigned long
@@ -244,10 +246,11 @@ lttng_event_rule_syscall_hash(
        return hash;
 }
 
-struct lttng_event_rule *lttng_event_rule_syscall_create()
+struct lttng_event_rule *lttng_event_rule_syscall_create(void)
 {
        struct lttng_event_rule *rule = NULL;
        struct lttng_event_rule_syscall *syscall_rule;
+       enum lttng_event_rule_status status;
 
        syscall_rule = zmalloc(sizeof(struct lttng_event_rule_syscall));
        if (!syscall_rule) {
@@ -270,6 +273,14 @@ struct lttng_event_rule *lttng_event_rule_syscall_create()
        syscall_rule->parent.generate_exclusions =
                        lttng_event_rule_syscall_generate_exclusions;
        syscall_rule->parent.hash = lttng_event_rule_syscall_hash;
+
+       /* Default pattern is '*'. */
+       status = lttng_event_rule_syscall_set_pattern(rule, "*");
+       if (status != LTTNG_EVENT_RULE_STATUS_OK) {
+               lttng_event_rule_destroy(rule);
+               rule = NULL;
+       }
+
 end:
        return rule;
 }
@@ -404,9 +415,9 @@ enum lttng_event_rule_status lttng_event_rule_syscall_set_pattern(
                goto end;
        }
 
-       if (syscall->pattern) {
-               free(syscall->pattern);
-       }
+       strutils_normalize_star_glob_pattern(pattern_copy);
+
+       free(syscall->pattern);
 
        syscall->pattern = pattern_copy;
        pattern_copy = NULL;
This page took 0.026027 seconds and 4 git commands to generate.