Error out if filter expression is attached to unsupported event types
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 4 Jul 2018 22:21:57 +0000 (18:21 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 Aug 2018 20:08:25 +0000 (16:08 -0400)
Attaching a filter on a probe event, a function event or an
userspace-probe event is not supported by the LTTng kernel tracer. So we
do an early sanity check in the lttng-enable-event and warn the user if
the filtering is not supported.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/enable_events.c
src/bin/lttng/utils.c
src/bin/lttng/utils.h

index 62f99a1fcfc760e659a3ab1c3a0e775fc79dccec..d973c5f6e1cc3579998aead3e2fba656f96ad428 100644 (file)
@@ -965,6 +965,30 @@ static int enable_events(char *session_name)
                }
        }
 
+       /*
+        * Adding a filter to a probe, function or userspace-probe would be
+        * denied by the kernel tracer as it's not supported at the moment. We
+        * do an early check here to warn the user.
+        */
+       if (opt_filter && opt_kernel) {
+               switch (opt_event_type) {
+               case LTTNG_EVENT_ALL:
+               case LTTNG_EVENT_TRACEPOINT:
+               case LTTNG_EVENT_SYSCALL:
+                       break;
+               case LTTNG_EVENT_PROBE:
+               case LTTNG_EVENT_USERSPACE_PROBE:
+               case LTTNG_EVENT_FUNCTION:
+                       ERR("Filter expressions are not supported for %s events",
+                                       get_event_type_str(opt_event_type));
+                       ret = CMD_ERROR;
+                       goto error;
+               default:
+                       ret = CMD_UNDEFINED;
+                       goto error;
+               }
+       }
+
        channel_name = opt_channel_name;
 
        handle = lttng_create_handle(session_name, &dom);
index 52a2440e7dc486e24b94d85fb94aea7bda3feefa..0e96ef0c3daf36f08b41c26749356a56705dac01 100644 (file)
@@ -41,6 +41,12 @@ static const char *str_ust = "UST";
 static const char *str_jul = "JUL";
 static const char *str_log4j = "LOG4J";
 static const char *str_python = "Python";
+static const char *str_all = "ALL";
+static const char *str_tracepoint = "Tracepoint";
+static const char *str_syscall = "Syscall";
+static const char *str_probe = "Probe";
+static const char *str_userspace_probe = "Userspace Probe";
+static const char *str_function = "Function";
 
 static
 char *_get_session_name(int quiet)
@@ -311,6 +317,37 @@ const char *get_domain_str(enum lttng_domain_type domain)
        return str_dom;
 }
 
+const char *get_event_type_str(enum lttng_event_type type)
+{
+       const char *str_event_type;
+
+       switch (type) {
+       case LTTNG_EVENT_ALL:
+               str_event_type = str_all;
+               break;
+       case LTTNG_EVENT_TRACEPOINT:
+               str_event_type = str_tracepoint;
+               break;
+       case LTTNG_EVENT_SYSCALL:
+               str_event_type = str_syscall;
+               break;
+       case LTTNG_EVENT_PROBE:
+               str_event_type = str_probe;
+               break;
+       case LTTNG_EVENT_USERSPACE_PROBE:
+               str_event_type = str_userspace_probe;
+               break;
+       case LTTNG_EVENT_FUNCTION:
+               str_event_type = str_function;
+               break;
+       default:
+               /* Should not have an unknown event type or else define it. */
+               assert(0);
+       }
+
+       return str_event_type;
+}
+
 /*
  * Spawn a lttng relayd daemon by forking and execv.
  */
index 4de7f0fe3e09cfae656d8ac800ffb6a91919f417..b1b97d725d9c0617aeee631ca8fa93447b62fdf7 100644 (file)
@@ -53,6 +53,7 @@ int get_count_order_u64(uint64_t x);
 int get_count_order_ulong(unsigned long x);
 
 const char *get_domain_str(enum lttng_domain_type domain);
+const char *get_event_type_str(enum lttng_event_type event_type);
 
 int print_missing_or_multiple_domains(unsigned int sum);
 
This page took 0.031866 seconds and 4 git commands to generate.