Add support for star globbing patterns in event names
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sun, 19 Feb 2017 01:01:34 +0000 (20:01 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 10 Mar 2017 16:24:04 +0000 (11:24 -0500)
This patch adds support for full star-only globbing patterns used in
the event names (enabler names).

strutils_star_glob_match() is always used to perform the match when
the enabler is LTTNG_ENABLER_STAR_GLOB. This enabler is set when it is
detected that its name contains at least one non-escaped star with
strutils_is_star_glob_pattern().

The match is performed by strutils_star_glob_match(), the same function
that the filter interpreter uses.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-abi.c
lttng-abi.h
lttng-events.c
lttng-events.h

index 40f96eb5d76dc6992dd6e6a311742593ed3b87c1..f2b207cbac95aa9ced52b603242784ca90caaaf3 100644 (file)
@@ -51,6 +51,7 @@
 #include <wrapper/poll.h>
 #include <wrapper/file.h>
 #include <wrapper/kref.h>
+#include <lttng-string-utils.h>
 #include <lttng-abi.h>
 #include <lttng-abi-old.h>
 #include <lttng-events.h>
@@ -1068,8 +1069,12 @@ int lttng_abi_create_event(struct file *channel_file,
                        || event_param->instrumentation == LTTNG_KERNEL_SYSCALL) {
                struct lttng_enabler *enabler;
 
-               if (event_param->name[strlen(event_param->name) - 1] == '*') {
-                       enabler = lttng_enabler_create(LTTNG_ENABLER_WILDCARD,
+               if (strutils_is_star_glob_pattern(event_param->name)) {
+                       /*
+                        * If the event name is a star globbing pattern,
+                        * we create the special star globbing enabler.
+                        */
+                       enabler = lttng_enabler_create(LTTNG_ENABLER_STAR_GLOB,
                                event_param, channel);
                } else {
                        enabler = lttng_enabler_create(LTTNG_ENABLER_NAME,
index 822b8839a4fa815868ae051b1f4cf7a4b0f76ba1..dac8658479f52d8079982f742a4bb425a808c10c 100644 (file)
@@ -30,7 +30,7 @@
  * should be increased when an incompatible ABI change is done.
  */
 #define LTTNG_MODULES_ABI_MAJOR_VERSION                2
-#define LTTNG_MODULES_ABI_MINOR_VERSION                2
+#define LTTNG_MODULES_ABI_MINOR_VERSION                3
 
 #define LTTNG_KERNEL_SYM_NAME_LEN      256
 
index d00701466a5d47c532cf3d32c20368d19eda9527..6bfe710f57ea24b9d2da90fc4de04f96347da325 100644 (file)
@@ -51,6 +51,7 @@
 #include <lttng-tracer.h>
 #include <lttng-abi-old.h>
 #include <lttng-endian.h>
+#include <lttng-string-utils.h>
 #include <wrapper/vzalloc.h>
 #include <wrapper/ringbuffer/backend.h>
 #include <wrapper/ringbuffer/frontend.h>
@@ -1142,11 +1143,10 @@ fd_error:
  * Enabler management.
  */
 static
-int lttng_match_enabler_wildcard(const char *desc_name,
-               const char *name)
+int lttng_match_enabler_star_glob(const char *desc_name,
+               const char *pattern)
 {
-       /* Compare excluding final '*' */
-       if (strncmp(desc_name, name, strlen(name) - 1))
+       if (!strutils_star_glob_match(pattern, -1ULL, desc_name, -1ULL))
                return 0;
        return 1;
 }
@@ -1191,8 +1191,8 @@ int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
                return -EINVAL;
        }
        switch (enabler->type) {
-       case LTTNG_ENABLER_WILDCARD:
-               return lttng_match_enabler_wildcard(desc_name, enabler_name);
+       case LTTNG_ENABLER_STAR_GLOB:
+               return lttng_match_enabler_star_glob(desc_name, enabler_name);
        case LTTNG_ENABLER_NAME:
                return lttng_match_enabler_name(desc_name, enabler_name);
        default:
index 173f369f067cf2362de97f486ac491939a4378e2..f55bf6637c93643ae70fd32b09934dfd3e22dce3 100644 (file)
@@ -324,7 +324,7 @@ struct lttng_event {
 };
 
 enum lttng_enabler_type {
-       LTTNG_ENABLER_WILDCARD,
+       LTTNG_ENABLER_STAR_GLOB,
        LTTNG_ENABLER_NAME,
 };
 
This page took 0.028841 seconds and 4 git commands to generate.