X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fevent-rule%2Fsyscall.c;h=fbaa65310a6966548690bbb7db65c9c6ca91712b;hp=b2feb2c6ecf4c772049d9c41d304544f185959d1;hb=40fd2ccf9faa3e8b6d67d40c8ee52a2b3d1f07bd;hpb=58daac01d91347336f24e1fc1cacd4e7a3101e93 diff --git a/src/common/event-rule/syscall.c b/src/common/event-rule/syscall.c index b2feb2c6e..fbaa65310 100644 --- a/src/common/event-rule/syscall.c +++ b/src/common/event-rule/syscall.c @@ -12,6 +12,9 @@ #include #include #include +#include +#include +#include #include #include @@ -146,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); @@ -203,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) { @@ -215,18 +218,39 @@ lttng_event_rule_syscall_get_internal_filter_bytecode( return syscall->internal_filter.bytecode; } -static struct lttng_event_exclusion * -lttng_event_rule_syscall_generate_exclusions( +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) +{ + /* Unsupported. */ + *exclusions = NULL; + return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE; +} + +static unsigned long +lttng_event_rule_syscall_hash( const struct lttng_event_rule *rule) { - /* Not supported. */ - return NULL; + unsigned long hash; + struct lttng_event_rule_syscall *syscall_rule = + container_of(rule, typeof(*syscall_rule), parent); + + hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_SYSCALL, + lttng_ht_seed); + hash ^= hash_key_str(syscall_rule->pattern, lttng_ht_seed); + if (syscall_rule->filter_expression) { + hash ^= hash_key_str(syscall_rule->filter_expression, + lttng_ht_seed); + } + + 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) { @@ -248,6 +272,15 @@ struct lttng_event_rule *lttng_event_rule_syscall_create() lttng_event_rule_syscall_get_internal_filter_bytecode; 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; } @@ -382,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;