Rename lttng_event_rule_userspace_probe to lttng_event_rule_kernel_uprobe
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 18 May 2021 17:44:38 +0000 (13:44 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 2 Jun 2021 19:27:11 +0000 (15:27 -0400)
The `--type` option for add trigger now only support `kernel:uprobe`.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I2c4de8e314d6fba735343d21c04fff366b92cca9

19 files changed:
include/Makefile.am
include/lttng/event-rule/event-rule.h
include/lttng/event-rule/kernel-uprobe-internal.h [new file with mode: 0644]
include/lttng/event-rule/kernel-uprobe.h [new file with mode: 0644]
include/lttng/event-rule/userspace-probe-internal.h [deleted file]
include/lttng/event-rule/userspace-probe.h [deleted file]
include/lttng/lttng.h
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/trace-kernel.c
src/bin/lttng/commands/add_trigger.c
src/bin/lttng/commands/list_triggers.c
src/common/Makefile.am
src/common/event-rule/event-rule.c
src/common/event-rule/kernel-uprobe.c [new file with mode: 0644]
src/common/event-rule/userspace-probe.c [deleted file]
tests/regression/tools/notification/notification.c
tests/regression/tools/trigger/test_add_trigger_cli
tests/regression/tools/trigger/test_list_triggers_cli
tests/unit/test_event_rule.c

index 2f403fe0a2123673f1230904020cc0be93fc5aee..0ab2888b24dd57e0cfd00b3d200c7cc1e6cf3f68 100644 (file)
@@ -154,7 +154,7 @@ lttngeventruleinclude_HEADERS= \
        lttng/event-rule/event-rule.h \
        lttng/event-rule/kernel-probe.h \
        lttng/event-rule/kernel-syscall.h \
        lttng/event-rule/event-rule.h \
        lttng/event-rule/kernel-probe.h \
        lttng/event-rule/kernel-syscall.h \
-       lttng/event-rule/userspace-probe.h \
+       lttng/event-rule/kernel-uprobe.h \
        lttng/event-rule/tracepoint.h
 
 noinst_HEADERS = \
        lttng/event-rule/tracepoint.h
 
 noinst_HEADERS = \
@@ -184,7 +184,7 @@ noinst_HEADERS = \
        lttng/event-rule/kernel-probe-internal.h \
        lttng/event-rule/kernel-syscall-internal.h \
        lttng/event-rule/tracepoint-internal.h \
        lttng/event-rule/kernel-probe-internal.h \
        lttng/event-rule/kernel-syscall-internal.h \
        lttng/event-rule/tracepoint-internal.h \
-       lttng/event-rule/userspace-probe-internal.h \
+       lttng/event-rule/kernel-uprobe-internal.h \
        lttng/health-internal.h \
        lttng/kernel-probe-internal.h \
        lttng/load-internal.h \
        lttng/health-internal.h \
        lttng/kernel-probe-internal.h \
        lttng/load-internal.h \
index aac9f5913b50c14ab77268c4c6edd62fc0c50f92..1fea37b4799256cf957cc790a4ff5def35420ba8 100644 (file)
@@ -20,7 +20,7 @@ enum lttng_event_rule_type {
        LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL = 1,
        LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE = 2,
        LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION = 3,
        LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL = 1,
        LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE = 2,
        LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION = 3,
-       LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE = 4,
+       LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE = 4,
 };
 
 enum lttng_event_rule_status {
 };
 
 enum lttng_event_rule_status {
diff --git a/include/lttng/event-rule/kernel-uprobe-internal.h b/include/lttng/event-rule/kernel-uprobe-internal.h
new file mode 100644 (file)
index 0000000..e14dc43
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H
+#define LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H
+
+#include <common/payload-view.h>
+#include <common/macros.h>
+#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/kernel-uprobe.h>
+
+struct lttng_event_rule_kernel_uprobe {
+       struct lttng_event_rule parent;
+       char *name;
+       struct lttng_userspace_probe_location *location;
+};
+
+struct lttng_event_rule_kernel_uprobe_comm {
+       /* Includes terminator `\0`. */
+       uint32_t name_len;
+       /* Includes terminator `\0`. */
+       uint32_t location_len;
+       /*
+        * Payload is composed of, in that order:
+        *   - name (null terminated),
+        *   - user space probe location object.
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+LTTNG_HIDDEN
+ssize_t lttng_event_rule_kernel_uprobe_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_rule **rule);
+
+LTTNG_HIDDEN
+struct lttng_userspace_probe_location *
+lttng_event_rule_kernel_uprobe_get_location_mutable(
+               const struct lttng_event_rule *rule);
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H */
diff --git a/include/lttng/event-rule/kernel-uprobe.h b/include/lttng/event-rule/kernel-uprobe.h
new file mode 100644 (file)
index 0000000..06712df
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_UPROBE_H
+#define LTTNG_EVENT_RULE_KERNEL_UPROBE_H
+
+#include <lttng/event-rule/event-rule.h>
+#include <lttng/userspace-probe.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Create a newly allocated kernel uprobe event rule.
+ *
+ * The location is copied internally.
+ *
+ * Returns a new event rule on success, NULL on failure. This event rule must be
+ * destroyed using lttng_event_rule_destroy().
+ */
+extern struct lttng_event_rule *lttng_event_rule_kernel_uprobe_create(
+               const struct lttng_userspace_probe_location *location);
+
+/*
+ * Get the location of a kernel uprobe event rule.
+ *
+ * The caller does not assume the ownership of the returned location.
+ * The location shall only be used for the duration of the event
+ * rule's lifetime, or before a different location is set.
+ *
+ * Returns LTTNG_EVENT_RULE_STATUS_OK and a pointer to the event rule's location
+ * on success, LTTNG_EVENT_RULE_STATUS_INVALID if an invalid parameter is
+ * passed, or LTTNG_EVENT_RULE_STATUS_UNSET if a location was not set prior to
+ * this call.
+ */
+extern enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_get_location(
+               const struct lttng_event_rule *rule,
+               const struct lttng_userspace_probe_location **location);
+
+/*
+ * Set the name of a kernel uprobe event rule.
+ *
+ * The name is copied internally.
+ *
+ * Return LTTNG_EVENT_RULE_STATUS_OK on success, LTTNG_EVENT_RULE_STATUS_INVALID
+ * if invalid parameters are passed.
+ */
+extern enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_set_event_name(
+               struct lttng_event_rule *rule, const char *name);
+
+/*
+ * Get the name of a kernel uprobe event rule.
+ *
+ * The caller does not assume the ownership of the returned name.
+ * The name shall only only be used for the duration of the event
+ * rule's lifetime, or before a different name is set.
+ *
+ * Returns LTTNG_EVENT_RULE_STATUS_OK and a pointer to the event rule's name on
+ * success, LTTNG_EVENT_RULE_STATUS_INVALID if an invalid parameter is passed,
+ * or LTTNG_EVENT_RULE_STATUS_UNSET if a name was not set prior to this call.
+ */
+extern enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_get_event_name(
+               const struct lttng_event_rule *rule, const char **name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_UPROBE_H */
diff --git a/include/lttng/event-rule/userspace-probe-internal.h b/include/lttng/event-rule/userspace-probe-internal.h
deleted file mode 100644 (file)
index 8ba5b2b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_USERSPACE_PROBE_INTERNAL_H
-#define LTTNG_EVENT_RULE_USERSPACE_PROBE_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/userspace-probe.h>
-
-struct lttng_event_rule_userspace_probe {
-       struct lttng_event_rule parent;
-       char *name;
-       struct lttng_userspace_probe_location *location;
-};
-
-struct lttng_event_rule_userspace_probe_comm {
-       /* Includes terminator `\0`. */
-       uint32_t name_len;
-       /* Includes terminator `\0`. */
-       uint32_t location_len;
-       /*
-        * Payload is composed of, in that order:
-        *   - name (null terminated),
-        *   - user space probe location object.
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-LTTNG_HIDDEN
-ssize_t lttng_event_rule_userspace_probe_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **rule);
-
-LTTNG_HIDDEN
-struct lttng_userspace_probe_location *
-lttng_event_rule_userspace_probe_get_location_mutable(
-               const struct lttng_event_rule *rule);
-
-#endif /* LTTNG_EVENT_RULE_USERSPACE_PROBE_INTERNAL_H */
diff --git a/include/lttng/event-rule/userspace-probe.h b/include/lttng/event-rule/userspace-probe.h
deleted file mode 100644 (file)
index 37b366b..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_USERSPACE_PROBE_H
-#define LTTNG_EVENT_RULE_USERSPACE_PROBE_H
-
-#include <lttng/event-rule/event-rule.h>
-#include <lttng/userspace-probe.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Create a newly allocated user space probe event rule.
- *
- * The location is copied internally.
- *
- * Returns a new event rule on success, NULL on failure. This event rule must be
- * destroyed using lttng_event_rule_destroy().
- */
-extern struct lttng_event_rule *lttng_event_rule_userspace_probe_create(
-               const struct lttng_userspace_probe_location *location);
-
-/*
- * Get the location of a user space probe event rule.
- *
- * The caller does not assume the ownership of the returned location.
- * The location shall only be used for the duration of the event
- * rule's lifetime, or before a different location is set.
- *
- * Returns LTTNG_EVENT_RULE_STATUS_OK and a pointer to the event rule's location
- * on success, LTTNG_EVENT_RULE_STATUS_INVALID if an invalid parameter is
- * passed, or LTTNG_EVENT_RULE_STATUS_UNSET if a location was not set prior to
- * this call.
- */
-extern enum lttng_event_rule_status lttng_event_rule_userspace_probe_get_location(
-               const struct lttng_event_rule *rule,
-               const struct lttng_userspace_probe_location **location);
-
-/*
- * Set the name of a user space probe event rule.
- *
- * The name is copied internally.
- *
- * Return LTTNG_EVENT_RULE_STATUS_OK on success, LTTNG_EVENT_RULE_STATUS_INVALID
- * if invalid parameters are passed.
- */
-extern enum lttng_event_rule_status lttng_event_rule_userspace_probe_set_event_name(
-               struct lttng_event_rule *rule, const char *name);
-
-/*
- * Get the name of a user space probe event rule.
- *
- * The caller does not assume the ownership of the returned name.
- * The name shall only only be used for the duration of the event
- * rule's lifetime, or before a different name is set.
- *
- * Returns LTTNG_EVENT_RULE_STATUS_OK and a pointer to the event rule's name on
- * success, LTTNG_EVENT_RULE_STATUS_INVALID if an invalid parameter is passed,
- * or LTTNG_EVENT_RULE_STATUS_UNSET if a name was not set prior to this call.
- */
-extern enum lttng_event_rule_status lttng_event_rule_userspace_probe_get_event_name(
-               const struct lttng_event_rule *rule, const char **name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LTTNG_EVENT_RULE_USERSPACE_PROBE_H */
index fc242c511585368b392cdcd712aec4b123a21aba..1fa904b4dc0ef0e8fc990380946d7b3b47728989 100644 (file)
@@ -45,7 +45,7 @@
 #include <lttng/event-rule/kernel-probe.h>
 #include <lttng/event-rule/kernel-syscall.h>
 #include <lttng/event-rule/tracepoint.h>
 #include <lttng/event-rule/kernel-probe.h>
 #include <lttng/event-rule/kernel-syscall.h>
 #include <lttng/event-rule/tracepoint.h>
-#include <lttng/event-rule/userspace-probe.h>
+#include <lttng/event-rule/kernel-uprobe.h>
 #include <lttng/event.h>
 #include <lttng/handle.h>
 #include <lttng/health.h>
 #include <lttng/event.h>
 #include <lttng/handle.h>
 #include <lttng/health.h>
index 5afd87734c3ba09d5729e9a482a16b9163bb1b3a..34975a3126dffde8ad7f0b100c485ad1149a404c 100644 (file)
@@ -32,7 +32,7 @@
 #include <lttng/condition/event-rule-matches-internal.h>
 #include <lttng/event-rule/event-rule.h>
 #include <lttng/event-rule/event-rule-internal.h>
 #include <lttng/condition/event-rule-matches-internal.h>
 #include <lttng/event-rule/event-rule.h>
 #include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/userspace-probe-internal.h>
+#include <lttng/event-rule/kernel-uprobe-internal.h>
 
 #include "event-notifier-error-accounting.h"
 #include "lttng-sessiond.h"
 
 #include "event-notifier-error-accounting.h"
 #include "lttng-sessiond.h"
@@ -542,9 +542,9 @@ static int userspace_probe_event_rule_add_callsites(
        assert(creds);
 
        event_rule_type = lttng_event_rule_get_type(rule);
        assert(creds);
 
        event_rule_type = lttng_event_rule_get_type(rule);
-       assert(event_rule_type == LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE);
+       assert(event_rule_type == LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE);
 
 
-       status = lttng_event_rule_userspace_probe_get_location(rule, &location);
+       status = lttng_event_rule_kernel_uprobe_get_location(rule, &location);
        if (status != LTTNG_EVENT_RULE_STATUS_OK || !location) {
                ret = -1;
                goto end;
        if (status != LTTNG_EVENT_RULE_STATUS_OK || !location) {
                ret = -1;
                goto end;
@@ -2394,7 +2394,7 @@ static enum lttng_error_code kernel_create_event_notifier_rule(
        }
 
        if (lttng_event_rule_get_type(event_rule) ==
        }
 
        if (lttng_event_rule_get_type(event_rule) ==
-                       LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE) {
+                       LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE) {
                ret = userspace_probe_event_rule_add_callsites(
                                event_rule, creds, event_notifier_rule->fd);
                if (ret) {
                ret = userspace_probe_event_rule_add_callsites(
                                event_rule, creds, event_notifier_rule->fd);
                if (ret) {
index 423bb0730c03837ae08019b671e37b987a5a2ecd..0ab1b6864808fd687d869956472ac1df63b581b6 100644 (file)
@@ -24,7 +24,7 @@
 #include <lttng/event-rule/kernel-syscall-internal.h>
 #include <lttng/event-rule/tracepoint.h>
 #include <lttng/event-rule/tracepoint-internal.h>
 #include <lttng/event-rule/kernel-syscall-internal.h>
 #include <lttng/event-rule/tracepoint.h>
 #include <lttng/event-rule/tracepoint-internal.h>
-#include <lttng/event-rule/userspace-probe-internal.h>
+#include <lttng/event-rule/kernel-uprobe-internal.h>
 #include <common/common.h>
 #include <common/defaults.h>
 #include <common/trace-chunk.h>
 #include <common/common.h>
 #include <common/defaults.h>
 #include <common/trace-chunk.h>
@@ -608,13 +608,13 @@ enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule(
                ret_code = LTTNG_OK;
                break;
        }
                ret_code = LTTNG_OK;
                break;
        }
-       case LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
        {
                const struct lttng_userspace_probe_location* location = NULL;
                const struct lttng_userspace_probe_location_lookup_method *lookup = NULL;
                enum lttng_event_rule_status status;
 
        {
                const struct lttng_userspace_probe_location* location = NULL;
                const struct lttng_userspace_probe_location_lookup_method *lookup = NULL;
                enum lttng_event_rule_status status;
 
-               status = lttng_event_rule_userspace_probe_get_location(rule, &location);
+               status = lttng_event_rule_kernel_uprobe_get_location(rule, &location);
                if (status != LTTNG_EVENT_RULE_STATUS_OK) {
                        ret_code = LTTNG_ERR_PROBE_LOCATION_INVAL;
                        goto error;
                if (status != LTTNG_EVENT_RULE_STATUS_OK) {
                        ret_code = LTTNG_ERR_PROBE_LOCATION_INVAL;
                        goto error;
@@ -649,7 +649,7 @@ enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule(
                        abort();
                }
 
                        abort();
                }
 
-               status = lttng_event_rule_userspace_probe_get_event_name(
+               status = lttng_event_rule_kernel_uprobe_get_event_name(
                                rule, &name);
                assert(status == LTTNG_EVENT_RULE_STATUS_OK);
                ret_code = LTTNG_OK;
                                rule, &name);
                assert(status == LTTNG_EVENT_RULE_STATUS_OK);
                ret_code = LTTNG_OK;
index a1bfe240e23d90a34cff1b802e4fb27a262e4a20..0f94ef1551d69348341e52d219296812a26e4820 100644 (file)
@@ -130,9 +130,8 @@ bool assign_event_rule_type(enum lttng_event_rule_type *dest, const char *arg)
        } else if (strcmp(arg, "kprobe") == 0 ||
                        strcmp(arg, "kernel-probe") == 0) {
                *dest = LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE;
        } else if (strcmp(arg, "kprobe") == 0 ||
                        strcmp(arg, "kernel-probe") == 0) {
                *dest = LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE;
-       } else if (strcmp(arg, "uprobe") == 0 ||
-                       strcmp(arg, "userspace-probe") == 0) {
-               *dest = LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE;
+       } else if (strcmp(arg, "kernel:uprobe") == 0) {
+               *dest = LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE;
        } else if (strcmp(arg, "function") == 0) {
                *dest = LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION;
        } else if (strncmp(arg, "syscall", strlen("syscall")) == 0 ||
        } else if (strcmp(arg, "function") == 0) {
                *dest = LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION;
        } else if (strncmp(arg, "syscall", strlen("syscall")) == 0 ||
@@ -887,7 +886,7 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv)
         */
        switch (event_rule_type) {
        case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
         */
        switch (event_rule_type) {
        case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
-       case LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
                if (!location) {
                        ERR("Event rule of type %s requires a --location.",
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
                if (!location) {
                        ERR("Event rule of type %s requires a --location.",
@@ -934,7 +933,7 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv)
        switch (event_rule_type) {
        case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
        switch (event_rule_type) {
        case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
-       case LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
                if (domain_type != LTTNG_DOMAIN_KERNEL) {
                        ERR("Event type not available for user-space tracing.");
        case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
                if (domain_type != LTTNG_DOMAIN_KERNEL) {
                        ERR("Event type not available for user-space tracing.");
@@ -1120,7 +1119,7 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv)
 
                break;
        }
 
                break;
        }
-       case LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
        {
                int ret;
                enum lttng_event_rule_status event_rule_status;
        {
                int ret;
                enum lttng_event_rule_status event_rule_status;
@@ -1132,14 +1131,14 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv)
                        goto error;
                }
 
                        goto error;
                }
 
-               res.er = lttng_event_rule_userspace_probe_create(userspace_probe_location);
+               res.er = lttng_event_rule_kernel_uprobe_create(userspace_probe_location);
                if (!res.er) {
                        ERR("Failed to create userspace probe event rule.");
                        goto error;
                }
 
                event_rule_status =
                if (!res.er) {
                        ERR("Failed to create userspace probe event rule.");
                        goto error;
                }
 
                event_rule_status =
-                               lttng_event_rule_userspace_probe_set_event_name(
+                               lttng_event_rule_kernel_uprobe_set_event_name(
                                                res.er, event_name);
                if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
                        ERR("Failed to set user space probe event rule's name to '%s'.",
                                                res.er, event_name);
                if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
                        ERR("Failed to set user space probe event rule's name to '%s'.",
index 10f76e843986fd99c1bb1e50073eedb5cea2d7bf..e10fc29f1fe2903dfc81aee455037b7717d40352 100644 (file)
@@ -327,23 +327,23 @@ void print_event_rule_userspace_probe(const struct lttng_event_rule *event_rule)
        const struct lttng_userspace_probe_location *location;
        enum lttng_userspace_probe_location_type userspace_probe_location_type;
 
        const struct lttng_userspace_probe_location *location;
        enum lttng_userspace_probe_location_type userspace_probe_location_type;
 
-       assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE);
+       assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE);
 
 
-       event_rule_status = lttng_event_rule_userspace_probe_get_event_name(
+       event_rule_status = lttng_event_rule_kernel_uprobe_get_event_name(
                        event_rule, &name);
        if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
                ERR("Failed to get uprobe event rule's name.");
                goto end;
        }
 
                        event_rule, &name);
        if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
                ERR("Failed to get uprobe event rule's name.");
                goto end;
        }
 
-       event_rule_status = lttng_event_rule_userspace_probe_get_location(
+       event_rule_status = lttng_event_rule_kernel_uprobe_get_location(
                        event_rule, &location);
        if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
                ERR("Failed to get uprobe event rule's location.");
                goto end;
        }
 
                        event_rule, &location);
        if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
                ERR("Failed to get uprobe event rule's location.");
                goto end;
        }
 
-       _MSG("    rule: %s (type: userspace probe, ", name);
+       _MSG("    rule: %s (type: kernel:uprobe, ", name);
 
        userspace_probe_location_type =
                        lttng_userspace_probe_location_get_type(location);
 
        userspace_probe_location_type =
                        lttng_userspace_probe_location_get_type(location);
@@ -428,7 +428,7 @@ void print_event_rule(const struct lttng_event_rule *event_rule)
        case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
                print_event_rule_kernel_probe(event_rule);
                break;
        case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
                print_event_rule_kernel_probe(event_rule);
                break;
-       case LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
                print_event_rule_userspace_probe(event_rule);
                break;
        case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
                print_event_rule_userspace_probe(event_rule);
                break;
        case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
index 32e9c02abf29eeeaf570e6b3211a40608172864d..296d4955119c27363d8a5f6674de56e6dba3e1bc 100644 (file)
@@ -67,7 +67,7 @@ libcommon_la_SOURCES = \
        event-rule/event-rule.c \
        event-rule/kernel-probe.c \
        event-rule/kernel-syscall.c \
        event-rule/event-rule.c \
        event-rule/kernel-probe.c \
        event-rule/kernel-syscall.c \
-       event-rule/userspace-probe.c \
+       event-rule/kernel-uprobe.c \
        event-rule/tracepoint.c \
        filter.c filter.h \
        fd-handle.c fd-handle.h \
        event-rule/tracepoint.c \
        filter.c filter.h \
        fd-handle.c fd-handle.h \
index 0443c75e96bfc0e61ae67fef51d1426dfd96e8be..291ef533c280eef3b013dc537fed9c9428b87072 100644 (file)
@@ -17,7 +17,7 @@
 #include <lttng/event-rule/kernel-probe-internal.h>
 #include <lttng/event-rule/kernel-syscall-internal.h>
 #include <lttng/event-rule/tracepoint-internal.h>
 #include <lttng/event-rule/kernel-probe-internal.h>
 #include <lttng/event-rule/kernel-syscall-internal.h>
 #include <lttng/event-rule/tracepoint-internal.h>
-#include <lttng/event-rule/userspace-probe-internal.h>
+#include <lttng/event-rule/kernel-uprobe-internal.h>
 #include <stdbool.h>
 
 enum lttng_event_rule_type lttng_event_rule_get_type(
 #include <stdbool.h>
 
 enum lttng_event_rule_type lttng_event_rule_get_type(
@@ -43,7 +43,7 @@ enum lttng_domain_type lttng_event_rule_get_domain_type(
        case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
-       case LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
                domain_type = LTTNG_DOMAIN_KERNEL;
                break;
        case LTTNG_EVENT_RULE_TYPE_UNKNOWN:
                domain_type = LTTNG_DOMAIN_KERNEL;
                break;
        case LTTNG_EVENT_RULE_TYPE_UNKNOWN:
@@ -178,8 +178,8 @@ ssize_t lttng_event_rule_create_from_payload(
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
                /* TODO */
                break;
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
                /* TODO */
                break;
-       case LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE:
-               create_from_payload = lttng_event_rule_userspace_probe_create_from_payload;
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
+               create_from_payload = lttng_event_rule_kernel_uprobe_create_from_payload;
                break;
        case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
                create_from_payload =
                break;
        case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
                create_from_payload =
@@ -319,8 +319,8 @@ const char *lttng_event_rule_type_str(enum lttng_event_rule_type type)
                return "probe";
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
                return "function";
                return "probe";
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
                return "function";
-       case LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE:
-               return "userspace-probe";
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
+               return "kernel uprobe";
        default:
                abort();
        }
        default:
                abort();
        }
diff --git a/src/common/event-rule/kernel-uprobe.c b/src/common/event-rule/kernel-uprobe.c
new file mode 100644 (file)
index 0000000..df5b896
--- /dev/null
@@ -0,0 +1,438 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <assert.h>
+#include <common/credentials.h>
+#include <common/error.h>
+#include <common/macros.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
+#include <common/runas.h>
+#include <common/hashtable/hashtable.h>
+#include <common/hashtable/utils.h>
+#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/kernel-uprobe-internal.h>
+#include <lttng/userspace-probe-internal.h>
+
+#define IS_UPROBE_EVENT_RULE(rule) \
+       (lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE)
+
+static void lttng_event_rule_kernel_uprobe_destroy(struct lttng_event_rule *rule)
+{
+       struct lttng_event_rule_kernel_uprobe *uprobe;
+
+       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+
+       lttng_userspace_probe_location_destroy(uprobe->location);
+       free(uprobe->name);
+       free(uprobe);
+}
+
+static bool lttng_event_rule_kernel_uprobe_validate(
+               const struct lttng_event_rule *rule)
+{
+       bool valid = false;
+       struct lttng_event_rule_kernel_uprobe *uprobe;
+
+       if (!rule) {
+               goto end;
+       }
+
+       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+
+       /* Required field. */
+       if (!uprobe->name) {
+               ERR("Invalid uprobe event rule: a pattern must be set.");
+               goto end;
+       }
+
+       if (!uprobe->location) {
+               ERR("Invalid uprobe event rule: a location must be set.");
+               goto end;
+       }
+
+       valid = true;
+end:
+       return valid;
+}
+
+static int lttng_event_rule_kernel_uprobe_serialize(
+               const struct lttng_event_rule *rule,
+               struct lttng_payload *payload)
+{
+       int ret;
+       size_t name_len, header_offset, size_before_probe;
+       struct lttng_event_rule_kernel_uprobe *uprobe;
+       struct lttng_event_rule_kernel_uprobe_comm uprobe_comm = {};
+       struct lttng_event_rule_kernel_uprobe_comm *header;
+
+       if (!rule || !IS_UPROBE_EVENT_RULE(rule)) {
+               ret = -1;
+               goto end;
+       }
+
+       header_offset = payload->buffer.size;
+
+       DBG("Serializing uprobe event rule.");
+       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+
+       name_len = strlen(uprobe->name) + 1;
+
+       uprobe_comm.name_len = name_len;
+
+       ret = lttng_dynamic_buffer_append(
+                       &payload->buffer, &uprobe_comm, sizeof(uprobe_comm));
+       if (ret) {
+               goto end;
+       }
+       ret = lttng_dynamic_buffer_append(
+                       &payload->buffer, uprobe->name, name_len);
+       if (ret) {
+               goto end;
+       }
+
+       size_before_probe = payload->buffer.size;
+
+       /* This serialize return the size taken in the buffer. */
+       ret = lttng_userspace_probe_location_serialize(
+                       uprobe->location, payload);
+       if (ret < 0) {
+               goto end;
+       }
+
+       /* Update the header regarding the probe size. */
+       header = (struct lttng_event_rule_kernel_uprobe_comm
+                                       *) ((char *) payload->buffer.data +
+                       header_offset);
+       header->location_len = payload->buffer.size - size_before_probe;
+
+       ret = 0;
+
+end:
+       return ret;
+}
+
+static bool lttng_event_rule_kernel_uprobe_is_equal(const struct lttng_event_rule *_a,
+               const struct lttng_event_rule *_b)
+{
+       bool is_equal = false;
+       struct lttng_event_rule_kernel_uprobe *a, *b;
+
+       a = container_of(_a, struct lttng_event_rule_kernel_uprobe, parent);
+       b = container_of(_b, struct lttng_event_rule_kernel_uprobe, parent);
+
+       /* uprobe is invalid if this is not true. */
+       assert(a->name);
+       assert(b->name);
+       if (strcmp(a->name, b->name)) {
+               goto end;
+       }
+
+       assert(a->location);
+       assert(b->location);
+       is_equal = lttng_userspace_probe_location_is_equal(
+                       a->location, b->location);
+end:
+       return is_equal;
+}
+
+static enum lttng_error_code lttng_event_rule_kernel_uprobe_generate_filter_bytecode(
+               struct lttng_event_rule *rule,
+               const struct lttng_credentials *creds)
+{
+       /* Nothing to do. */
+       return LTTNG_OK;
+}
+
+static const char *lttng_event_rule_kernel_uprobe_get_filter(
+               const struct lttng_event_rule *rule)
+{
+       /* Unsupported. */
+       return NULL;
+}
+
+static const struct lttng_bytecode *
+lttng_event_rule_kernel_uprobe_get_filter_bytecode(const struct lttng_event_rule *rule)
+{
+       /* Unsupported. */
+       return NULL;
+}
+
+static enum lttng_event_rule_generate_exclusions_status
+lttng_event_rule_kernel_uprobe_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_kernel_uprobe_hash(
+               const struct lttng_event_rule *rule)
+{
+       unsigned long hash;
+       struct lttng_event_rule_kernel_uprobe *urule =
+                       container_of(rule, typeof(*urule), parent);
+
+       hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE,
+                       lttng_ht_seed);
+       hash ^= hash_key_str(urule->name, lttng_ht_seed);
+       hash ^= lttng_userspace_probe_location_hash(urule->location);
+
+       return hash;
+}
+
+static
+int userspace_probe_set_location(
+               struct lttng_event_rule_kernel_uprobe *uprobe,
+               const struct lttng_userspace_probe_location *location)
+{
+       int ret;
+       struct lttng_userspace_probe_location *location_copy = NULL;
+
+       if (!uprobe || !location || uprobe->location) {
+               ret = -1;
+               goto end;
+       }
+
+       location_copy = lttng_userspace_probe_location_copy(location);
+       if (!location_copy) {
+               ret = -1;
+               goto end;
+       }
+
+       uprobe->location = location_copy;
+       location_copy = NULL;
+       ret = 0;
+end:
+       lttng_userspace_probe_location_destroy(location_copy);
+       return ret;
+}
+
+struct lttng_event_rule *lttng_event_rule_kernel_uprobe_create(
+               const struct lttng_userspace_probe_location *location)
+{
+       struct lttng_event_rule *rule = NULL;
+       struct lttng_event_rule_kernel_uprobe *urule;
+
+       urule = zmalloc(sizeof(struct lttng_event_rule_kernel_uprobe));
+       if (!urule) {
+               goto end;
+       }
+
+       rule = &urule->parent;
+       lttng_event_rule_init(&urule->parent, LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE);
+       urule->parent.validate = lttng_event_rule_kernel_uprobe_validate;
+       urule->parent.serialize = lttng_event_rule_kernel_uprobe_serialize;
+       urule->parent.equal = lttng_event_rule_kernel_uprobe_is_equal;
+       urule->parent.destroy = lttng_event_rule_kernel_uprobe_destroy;
+       urule->parent.generate_filter_bytecode =
+                       lttng_event_rule_kernel_uprobe_generate_filter_bytecode;
+       urule->parent.get_filter = lttng_event_rule_kernel_uprobe_get_filter;
+       urule->parent.get_filter_bytecode =
+                       lttng_event_rule_kernel_uprobe_get_filter_bytecode;
+       urule->parent.generate_exclusions =
+                       lttng_event_rule_kernel_uprobe_generate_exclusions;
+       urule->parent.hash = lttng_event_rule_kernel_uprobe_hash;
+
+       if (userspace_probe_set_location(urule, location)) {
+               lttng_event_rule_destroy(rule);
+               rule = NULL;
+       }
+
+end:
+       return rule;
+}
+
+LTTNG_HIDDEN
+ssize_t lttng_event_rule_kernel_uprobe_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_rule **_event_rule)
+{
+       ssize_t ret, offset = 0;
+       const struct lttng_event_rule_kernel_uprobe_comm *uprobe_comm;
+       const char *name;
+       struct lttng_buffer_view current_buffer_view;
+       struct lttng_event_rule *rule = NULL;
+       struct lttng_userspace_probe_location *location = NULL;
+       enum lttng_event_rule_status status;
+
+       if (!_event_rule) {
+               ret = -1;
+               goto end;
+       }
+
+       current_buffer_view = lttng_buffer_view_from_view(
+                       &view->buffer, offset, sizeof(*uprobe_comm));
+       if (!lttng_buffer_view_is_valid(&current_buffer_view)) {
+               ERR("Failed to initialize from malformed event rule uprobe: buffer too short to contain header");
+               ret = -1;
+               goto end;
+       }
+
+       uprobe_comm = (typeof(uprobe_comm)) current_buffer_view.data;
+
+       /* Skip to payload. */
+       offset += current_buffer_view.size;
+
+       /* Map the name. */
+       current_buffer_view = lttng_buffer_view_from_view(
+                       &view->buffer, offset, uprobe_comm->name_len);
+       if (!lttng_buffer_view_is_valid(&current_buffer_view)) {
+               ret = -1;
+               goto end;
+       }
+
+       name = current_buffer_view.data;
+       if (!lttng_buffer_view_contains_string(&current_buffer_view, name,
+                       uprobe_comm->name_len)) {
+               ret = -1;
+               goto end;
+       }
+
+       /* Skip after the name. */
+       offset += uprobe_comm->name_len;
+
+       /* Map the location. */
+       {
+               struct lttng_payload_view current_payload_view =
+                               lttng_payload_view_from_view(view, offset,
+                                               uprobe_comm->location_len);
+
+               if (!lttng_payload_view_is_valid(&current_payload_view)) {
+                       ERR("Failed to initialize from malformed event rule uprobe: buffer too short to contain location");
+                       ret = -1;
+                       goto end;
+               }
+
+               ret = lttng_userspace_probe_location_create_from_payload(
+                               &current_payload_view, &location);
+               if (ret < 0) {
+                       ret = -1;
+                       goto end;
+               }
+       }
+
+       assert(ret == uprobe_comm->location_len);
+
+       /* Skip after the location. */
+       offset += uprobe_comm->location_len;
+
+       rule = lttng_event_rule_kernel_uprobe_create(location);
+       if (!rule) {
+               ERR("Failed to create event rule uprobe.");
+               ret = -1;
+               goto end;
+       }
+
+       status = lttng_event_rule_kernel_uprobe_set_event_name(rule, name);
+       if (status != LTTNG_EVENT_RULE_STATUS_OK) {
+               ret = -1;
+               goto end;
+       }
+
+       if (!lttng_event_rule_kernel_uprobe_validate(rule)) {
+               ret = -1;
+               goto end;
+       }
+
+       *_event_rule = rule;
+       rule = NULL;
+       ret = offset;
+end:
+       lttng_userspace_probe_location_destroy(location);
+       lttng_event_rule_destroy(rule);
+       return ret;
+}
+
+
+enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_get_location(
+               const struct lttng_event_rule *rule,
+               const struct lttng_userspace_probe_location **location)
+{
+       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
+
+       if (!rule || !IS_UPROBE_EVENT_RULE(rule) || !location) {
+               status = LTTNG_EVENT_RULE_STATUS_INVALID;
+               goto end;
+       }
+
+       *location = lttng_event_rule_kernel_uprobe_get_location_mutable(rule);
+       if (!*location) {
+               status = LTTNG_EVENT_RULE_STATUS_UNSET;
+               goto end;
+       }
+
+end:
+       return status;
+}
+
+LTTNG_HIDDEN
+struct lttng_userspace_probe_location *
+lttng_event_rule_kernel_uprobe_get_location_mutable(
+               const struct lttng_event_rule *rule)
+{
+       struct lttng_event_rule_kernel_uprobe *uprobe;
+
+       assert(rule);
+       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+
+       return uprobe->location;
+}
+
+enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_set_event_name(
+               struct lttng_event_rule *rule, const char *name)
+{
+       char *name_copy = NULL;
+       struct lttng_event_rule_kernel_uprobe *uprobe;
+       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
+
+       if (!rule || !IS_UPROBE_EVENT_RULE(rule) || !name ||
+                       strlen(name) == 0) {
+               status = LTTNG_EVENT_RULE_STATUS_INVALID;
+               goto end;
+       }
+
+       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+       name_copy = strdup(name);
+       if (!name_copy) {
+               status = LTTNG_EVENT_RULE_STATUS_ERROR;
+               goto end;
+       }
+
+       if (uprobe->name) {
+               free(uprobe->name);
+       }
+
+       uprobe->name = name_copy;
+       name_copy = NULL;
+end:
+       return status;
+}
+
+enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_get_event_name(
+               const struct lttng_event_rule *rule, const char **name)
+{
+       struct lttng_event_rule_kernel_uprobe *uprobe;
+       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
+
+       if (!rule || !IS_UPROBE_EVENT_RULE(rule) || !name) {
+               status = LTTNG_EVENT_RULE_STATUS_INVALID;
+               goto end;
+       }
+
+       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+       if (!uprobe->name) {
+               status = LTTNG_EVENT_RULE_STATUS_UNSET;
+               goto end;
+       }
+
+       *name = uprobe->name;
+end:
+       return status;
+}
diff --git a/src/common/event-rule/userspace-probe.c b/src/common/event-rule/userspace-probe.c
deleted file mode 100644 (file)
index 52c7553..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <assert.h>
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
-#include <common/runas.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/userspace-probe-internal.h>
-#include <lttng/userspace-probe-internal.h>
-
-#define IS_UPROBE_EVENT_RULE(rule) \
-       (lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE)
-
-static void lttng_event_rule_userspace_probe_destroy(struct lttng_event_rule *rule)
-{
-       struct lttng_event_rule_userspace_probe *uprobe;
-
-       uprobe = container_of(rule, struct lttng_event_rule_userspace_probe, parent);
-
-       lttng_userspace_probe_location_destroy(uprobe->location);
-       free(uprobe->name);
-       free(uprobe);
-}
-
-static bool lttng_event_rule_userspace_probe_validate(
-               const struct lttng_event_rule *rule)
-{
-       bool valid = false;
-       struct lttng_event_rule_userspace_probe *uprobe;
-
-       if (!rule) {
-               goto end;
-       }
-
-       uprobe = container_of(rule, struct lttng_event_rule_userspace_probe, parent);
-
-       /* Required field. */
-       if (!uprobe->name) {
-               ERR("Invalid uprobe event rule: a pattern must be set.");
-               goto end;
-       }
-
-       if (!uprobe->location) {
-               ERR("Invalid uprobe event rule: a location must be set.");
-               goto end;
-       }
-
-       valid = true;
-end:
-       return valid;
-}
-
-static int lttng_event_rule_userspace_probe_serialize(
-               const struct lttng_event_rule *rule,
-               struct lttng_payload *payload)
-{
-       int ret;
-       size_t name_len, header_offset, size_before_probe;
-       struct lttng_event_rule_userspace_probe *uprobe;
-       struct lttng_event_rule_userspace_probe_comm uprobe_comm = {};
-       struct lttng_event_rule_userspace_probe_comm *header;
-
-       if (!rule || !IS_UPROBE_EVENT_RULE(rule)) {
-               ret = -1;
-               goto end;
-       }
-
-       header_offset = payload->buffer.size;
-
-       DBG("Serializing uprobe event rule.");
-       uprobe = container_of(rule, struct lttng_event_rule_userspace_probe, parent);
-
-       name_len = strlen(uprobe->name) + 1;
-
-       uprobe_comm.name_len = name_len;
-
-       ret = lttng_dynamic_buffer_append(
-                       &payload->buffer, &uprobe_comm, sizeof(uprobe_comm));
-       if (ret) {
-               goto end;
-       }
-       ret = lttng_dynamic_buffer_append(
-                       &payload->buffer, uprobe->name, name_len);
-       if (ret) {
-               goto end;
-       }
-
-       size_before_probe = payload->buffer.size;
-
-       /* This serialize return the size taken in the buffer. */
-       ret = lttng_userspace_probe_location_serialize(
-                       uprobe->location, payload);
-       if (ret < 0) {
-               goto end;
-       }
-
-       /* Update the header regarding the probe size. */
-       header = (struct lttng_event_rule_userspace_probe_comm
-                                       *) ((char *) payload->buffer.data +
-                       header_offset);
-       header->location_len = payload->buffer.size - size_before_probe;
-
-       ret = 0;
-
-end:
-       return ret;
-}
-
-static bool lttng_event_rule_userspace_probe_is_equal(const struct lttng_event_rule *_a,
-               const struct lttng_event_rule *_b)
-{
-       bool is_equal = false;
-       struct lttng_event_rule_userspace_probe *a, *b;
-
-       a = container_of(_a, struct lttng_event_rule_userspace_probe, parent);
-       b = container_of(_b, struct lttng_event_rule_userspace_probe, parent);
-
-       /* uprobe is invalid if this is not true. */
-       assert(a->name);
-       assert(b->name);
-       if (strcmp(a->name, b->name)) {
-               goto end;
-       }
-
-       assert(a->location);
-       assert(b->location);
-       is_equal = lttng_userspace_probe_location_is_equal(
-                       a->location, b->location);
-end:
-       return is_equal;
-}
-
-static enum lttng_error_code lttng_event_rule_userspace_probe_generate_filter_bytecode(
-               struct lttng_event_rule *rule,
-               const struct lttng_credentials *creds)
-{
-       /* Nothing to do. */
-       return LTTNG_OK;
-}
-
-static const char *lttng_event_rule_userspace_probe_get_filter(
-               const struct lttng_event_rule *rule)
-{
-       /* Unsupported. */
-       return NULL;
-}
-
-static const struct lttng_bytecode *
-lttng_event_rule_userspace_probe_get_filter_bytecode(const struct lttng_event_rule *rule)
-{
-       /* Unsupported. */
-       return NULL;
-}
-
-static enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_userspace_probe_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_userspace_probe_hash(
-               const struct lttng_event_rule *rule)
-{
-       unsigned long hash;
-       struct lttng_event_rule_userspace_probe *urule =
-                       container_of(rule, typeof(*urule), parent);
-
-       hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE,
-                       lttng_ht_seed);
-       hash ^= hash_key_str(urule->name, lttng_ht_seed);
-       hash ^= lttng_userspace_probe_location_hash(urule->location);
-
-       return hash;
-}
-
-static
-int userspace_probe_set_location(
-               struct lttng_event_rule_userspace_probe *uprobe,
-               const struct lttng_userspace_probe_location *location)
-{
-       int ret;
-       struct lttng_userspace_probe_location *location_copy = NULL;
-
-       if (!uprobe || !location || uprobe->location) {
-               ret = -1;
-               goto end;
-       }
-
-       location_copy = lttng_userspace_probe_location_copy(location);
-       if (!location_copy) {
-               ret = -1;
-               goto end;
-       }
-
-       uprobe->location = location_copy;
-       location_copy = NULL;
-       ret = 0;
-end:
-       lttng_userspace_probe_location_destroy(location_copy);
-       return ret;
-}
-
-struct lttng_event_rule *lttng_event_rule_userspace_probe_create(
-               const struct lttng_userspace_probe_location *location)
-{
-       struct lttng_event_rule *rule = NULL;
-       struct lttng_event_rule_userspace_probe *urule;
-
-       urule = zmalloc(sizeof(struct lttng_event_rule_userspace_probe));
-       if (!urule) {
-               goto end;
-       }
-
-       rule = &urule->parent;
-       lttng_event_rule_init(&urule->parent, LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE);
-       urule->parent.validate = lttng_event_rule_userspace_probe_validate;
-       urule->parent.serialize = lttng_event_rule_userspace_probe_serialize;
-       urule->parent.equal = lttng_event_rule_userspace_probe_is_equal;
-       urule->parent.destroy = lttng_event_rule_userspace_probe_destroy;
-       urule->parent.generate_filter_bytecode =
-                       lttng_event_rule_userspace_probe_generate_filter_bytecode;
-       urule->parent.get_filter = lttng_event_rule_userspace_probe_get_filter;
-       urule->parent.get_filter_bytecode =
-                       lttng_event_rule_userspace_probe_get_filter_bytecode;
-       urule->parent.generate_exclusions =
-                       lttng_event_rule_userspace_probe_generate_exclusions;
-       urule->parent.hash = lttng_event_rule_userspace_probe_hash;
-
-       if (userspace_probe_set_location(urule, location)) {
-               lttng_event_rule_destroy(rule);
-               rule = NULL;
-       }
-
-end:
-       return rule;
-}
-
-LTTNG_HIDDEN
-ssize_t lttng_event_rule_userspace_probe_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **_event_rule)
-{
-       ssize_t ret, offset = 0;
-       const struct lttng_event_rule_userspace_probe_comm *uprobe_comm;
-       const char *name;
-       struct lttng_buffer_view current_buffer_view;
-       struct lttng_event_rule *rule = NULL;
-       struct lttng_userspace_probe_location *location = NULL;
-       enum lttng_event_rule_status status;
-
-       if (!_event_rule) {
-               ret = -1;
-               goto end;
-       }
-
-       current_buffer_view = lttng_buffer_view_from_view(
-                       &view->buffer, offset, sizeof(*uprobe_comm));
-       if (!lttng_buffer_view_is_valid(&current_buffer_view)) {
-               ERR("Failed to initialize from malformed event rule uprobe: buffer too short to contain header");
-               ret = -1;
-               goto end;
-       }
-
-       uprobe_comm = (typeof(uprobe_comm)) current_buffer_view.data;
-
-       /* Skip to payload. */
-       offset += current_buffer_view.size;
-
-       /* Map the name. */
-       current_buffer_view = lttng_buffer_view_from_view(
-                       &view->buffer, offset, uprobe_comm->name_len);
-       if (!lttng_buffer_view_is_valid(&current_buffer_view)) {
-               ret = -1;
-               goto end;
-       }
-
-       name = current_buffer_view.data;
-       if (!lttng_buffer_view_contains_string(&current_buffer_view, name,
-                       uprobe_comm->name_len)) {
-               ret = -1;
-               goto end;
-       }
-
-       /* Skip after the name. */
-       offset += uprobe_comm->name_len;
-
-       /* Map the location. */
-       {
-               struct lttng_payload_view current_payload_view =
-                               lttng_payload_view_from_view(view, offset,
-                                               uprobe_comm->location_len);
-
-               if (!lttng_payload_view_is_valid(&current_payload_view)) {
-                       ERR("Failed to initialize from malformed event rule uprobe: buffer too short to contain location");
-                       ret = -1;
-                       goto end;
-               }
-
-               ret = lttng_userspace_probe_location_create_from_payload(
-                               &current_payload_view, &location);
-               if (ret < 0) {
-                       ret = -1;
-                       goto end;
-               }
-       }
-
-       assert(ret == uprobe_comm->location_len);
-
-       /* Skip after the location. */
-       offset += uprobe_comm->location_len;
-
-       rule = lttng_event_rule_userspace_probe_create(location);
-       if (!rule) {
-               ERR("Failed to create event rule uprobe.");
-               ret = -1;
-               goto end;
-       }
-
-       status = lttng_event_rule_userspace_probe_set_event_name(rule, name);
-       if (status != LTTNG_EVENT_RULE_STATUS_OK) {
-               ret = -1;
-               goto end;
-       }
-
-       if (!lttng_event_rule_userspace_probe_validate(rule)) {
-               ret = -1;
-               goto end;
-       }
-
-       *_event_rule = rule;
-       rule = NULL;
-       ret = offset;
-end:
-       lttng_userspace_probe_location_destroy(location);
-       lttng_event_rule_destroy(rule);
-       return ret;
-}
-
-
-enum lttng_event_rule_status lttng_event_rule_userspace_probe_get_location(
-               const struct lttng_event_rule *rule,
-               const struct lttng_userspace_probe_location **location)
-{
-       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
-
-       if (!rule || !IS_UPROBE_EVENT_RULE(rule) || !location) {
-               status = LTTNG_EVENT_RULE_STATUS_INVALID;
-               goto end;
-       }
-
-       *location = lttng_event_rule_userspace_probe_get_location_mutable(rule);
-       if (!*location) {
-               status = LTTNG_EVENT_RULE_STATUS_UNSET;
-               goto end;
-       }
-
-end:
-       return status;
-}
-
-LTTNG_HIDDEN
-struct lttng_userspace_probe_location *
-lttng_event_rule_userspace_probe_get_location_mutable(
-               const struct lttng_event_rule *rule)
-{
-       struct lttng_event_rule_userspace_probe *uprobe;
-
-       assert(rule);
-       uprobe = container_of(rule, struct lttng_event_rule_userspace_probe, parent);
-
-       return uprobe->location;
-}
-
-enum lttng_event_rule_status lttng_event_rule_userspace_probe_set_event_name(
-               struct lttng_event_rule *rule, const char *name)
-{
-       char *name_copy = NULL;
-       struct lttng_event_rule_userspace_probe *uprobe;
-       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
-
-       if (!rule || !IS_UPROBE_EVENT_RULE(rule) || !name ||
-                       strlen(name) == 0) {
-               status = LTTNG_EVENT_RULE_STATUS_INVALID;
-               goto end;
-       }
-
-       uprobe = container_of(rule, struct lttng_event_rule_userspace_probe, parent);
-       name_copy = strdup(name);
-       if (!name_copy) {
-               status = LTTNG_EVENT_RULE_STATUS_ERROR;
-               goto end;
-       }
-
-       if (uprobe->name) {
-               free(uprobe->name);
-       }
-
-       uprobe->name = name_copy;
-       name_copy = NULL;
-end:
-       return status;
-}
-
-enum lttng_event_rule_status lttng_event_rule_userspace_probe_get_event_name(
-               const struct lttng_event_rule *rule, const char **name)
-{
-       struct lttng_event_rule_userspace_probe *uprobe;
-       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
-
-       if (!rule || !IS_UPROBE_EVENT_RULE(rule) || !name) {
-               status = LTTNG_EVENT_RULE_STATUS_INVALID;
-               goto end;
-       }
-
-       uprobe = container_of(rule, struct lttng_event_rule_userspace_probe, parent);
-       if (!uprobe->name) {
-               status = LTTNG_EVENT_RULE_STATUS_UNSET;
-               goto end;
-       }
-
-       *name = uprobe->name;
-end:
-       return status;
-}
index e089d47c0527f908ec44e1369e94579f1983333b..aa42d5ef2f9584aad2d8b3cf6796d0917899bb82 100644 (file)
@@ -1966,10 +1966,10 @@ static void test_uprobe_event_rule_notification(
                        lttng_session_daemon_notification_endpoint);
        ok(notification_channel, "Notification channel object creation");
 
                        lttng_session_daemon_notification_endpoint);
        ok(notification_channel, "Notification channel object creation");
 
-       event_rule = lttng_event_rule_userspace_probe_create(probe_location);
+       event_rule = lttng_event_rule_kernel_uprobe_create(probe_location);
        ok(event_rule, "kprobe event rule object creation");
 
        ok(event_rule, "kprobe event rule object creation");
 
-       event_rule_status = lttng_event_rule_userspace_probe_set_event_name(
+       event_rule_status = lttng_event_rule_kernel_uprobe_set_event_name(
                        event_rule, trigger_name);
        ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
                        "Setting uprobe event rule name: '%s'", trigger_name);
                        event_rule, trigger_name);
        ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
                        "Setting uprobe event rule name: '%s'", trigger_name);
index 029f17cef6d139722a319b909aba8fdb0d4824bc..bbb34b51f5f4ade0583d35d66a91b23c04d62a5a 100755 (executable)
@@ -23,7 +23,7 @@ TESTDIR="$CURDIR/../../.."
 # shellcheck source=../../../utils/utils.sh
 source "$TESTDIR/utils/utils.sh"
 
 # shellcheck source=../../../utils/utils.sh
 source "$TESTDIR/utils/utils.sh"
 
-plan_tests 297
+plan_tests 288
 
 FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}"
 
 
 FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}"
 
@@ -178,16 +178,14 @@ skip $ist_root "non-root user: skipping kprobe tests" 18 || {
        done
 }
 
        done
 }
 
-skip $ist_root "non-root user: skipping uprobe tests" 12 || {
-       for type in uprobe userspace-probe; do
-               test_success "--condition event-rule-matches uprobe" \
-                       --condition event-rule-matches --domain=kernel --type=$type --location=${uprobe_elf_binary}:test_function --event-name=ma-probe \
-                       --action notify
+skip $ist_root "non-root user: skipping uprobe tests" 6 || {
+       test_success "--condition event-rule-matches uprobe" \
+               --condition event-rule-matches --domain=kernel --type=kernel:uprobe --location=${uprobe_elf_binary}:test_function --event-name=ma-probe \
+               --action notify
 
 
-               test_success "--condition event-rule-matches uprobe with elf prefix" \
-                       --condition event-rule-matches --domain=kernel --type=$type --location=elf:${uprobe_elf_binary}:test_function --event-name=ma-probe-2 \
-                       --action notify
-       done
+       test_success "--condition event-rule-matches uprobe with elf prefix" \
+               --condition event-rule-matches --domain=kernel --type=kernel:uprobe --location=elf:${uprobe_elf_binary}:test_function --event-name=ma-probe-2 \
+               --action notify
 }
 
 skip $ist_root "non-root user: skipping syscall tests" 30 || {
 }
 
 skip $ist_root "non-root user: skipping syscall tests" 30 || {
@@ -380,11 +378,9 @@ test_failure "--condition event-rule-matches: --event-name with tracepoint event
        "Error: Can't use --event-name with tracepoint event rules." \
        --condition event-rule-matches --domain=user --event-name='hello'
 
        "Error: Can't use --event-name with tracepoint event rules." \
        --condition event-rule-matches --domain=user --event-name='hello'
 
-for type in uprobe userspace-probe; do
-       test_failure "--condition event-rule-matches: extra argument with --type=$type" \
-               "Error: Unexpected argument 'hello'" \
-               --condition event-rule-matches --domain=kernel --type=$type --location=${uprobe_elf_binary}:test_failure hello
-done
+test_failure "--condition event-rule-matches: extra argument with --type=kernel:uprobe" \
+       "Error: Unexpected argument 'hello'" \
+       --condition event-rule-matches --domain=kernel --type=$type --location=${uprobe_elf_binary}:test_failure hello
 
 test_failure "--condition event-rule-matches: extra argument with --type=syscall" \
        "Error: Unexpected argument 'open'" \
 
 test_failure "--condition event-rule-matches: extra argument with --type=syscall" \
        "Error: Unexpected argument 'open'" \
index cfeab29b7d825f20bc4a250d0636b233d250ce7b..a36393f13a967646605af8a7073554dccd5de8a3 100755 (executable)
@@ -261,13 +261,13 @@ test_event_rule_matches_userspace_probe_elf ()
 
        diag "Listing event-rule-matches userspace-probe elf"
 
 
        diag "Listing event-rule-matches userspace-probe elf"
 
-       lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=uprobe --location=${uprobe_elf_binary}:test_function --event-name=ma-probe-elf --action notify
+       lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=kernel:uprobe --location=${uprobe_elf_binary}:test_function --event-name=ma-probe-elf --action notify
 
        cat > "${tmp_expected_stdout}" <<- EOF
        - name: T0
          owner uid: ${uid}
          condition: event rule matches
 
        cat > "${tmp_expected_stdout}" <<- EOF
        - name: T0
          owner uid: ${uid}
          condition: event rule matches
-           rule: ma-probe-elf (type: userspace probe, location type: ELF, location: ${uprobe_elf_binary}:${elf_function_name})
+           rule: ma-probe-elf (type: kernel:uprobe, location type: ELF, location: ${uprobe_elf_binary}:${elf_function_name})
          actions:
            notify
              errors: none
          actions:
            notify
              errors: none
@@ -286,13 +286,13 @@ test_event_rule_matches_userspace_probe_sdt ()
 
        diag "Listing event-rule-matches userspace-probe sdt"
 
 
        diag "Listing event-rule-matches userspace-probe sdt"
 
-       lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=uprobe --location=sdt:${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name} --event-name=ma-probe-sdt --action notify
+       lttng_add_trigger_ok "T0" --condition event-rule-matches --domain=kernel --type=kernel:uprobe --location=sdt:${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name} --event-name=ma-probe-sdt --action notify
 
        cat > "${tmp_expected_stdout}" <<- EOF
        - name: T0
          owner uid: 0
          condition: event rule matches
 
        cat > "${tmp_expected_stdout}" <<- EOF
        - name: T0
          owner uid: 0
          condition: event rule matches
-           rule: ma-probe-sdt (type: userspace probe, location type: SDT, location: ${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name})
+           rule: ma-probe-sdt (type: kernel:uprobe, location type: SDT, location: ${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name})
          actions:
            notify
              errors: none
          actions:
            notify
              errors: none
index 6ec49fe66ec39570393cf2dfd5bd29d02d2993b8..091f53aba784a9486d27dfa99c9409736df99283 100644 (file)
@@ -24,8 +24,8 @@
 #include <lttng/event-rule/kernel-syscall.h>
 #include <lttng/event-rule/tracepoint-internal.h>
 #include <lttng/event-rule/tracepoint.h>
 #include <lttng/event-rule/kernel-syscall.h>
 #include <lttng/event-rule/tracepoint-internal.h>
 #include <lttng/event-rule/tracepoint.h>
-#include <lttng/event-rule/userspace-probe-internal.h>
-#include <lttng/event-rule/userspace-probe.h>
+#include <lttng/event-rule/kernel-uprobe-internal.h>
+#include <lttng/event-rule/kernel-uprobe.h>
 #include <lttng/event.h>
 #include <lttng/kernel-probe-internal.h>
 #include <lttng/kernel-probe.h>
 #include <lttng/event.h>
 #include <lttng/kernel-probe-internal.h>
 #include <lttng/kernel-probe.h>
@@ -255,10 +255,10 @@ static void test_event_rule_userspace_probe(void)
 
        lttng_payload_init(&payload);
 
 
        lttng_payload_init(&payload);
 
-       uprobe = lttng_event_rule_userspace_probe_create(probe_location);
+       uprobe = lttng_event_rule_kernel_uprobe_create(probe_location);
        ok(uprobe, "uprobe event rule object creation.");
 
        ok(uprobe, "uprobe event rule object creation.");
 
-       status = lttng_event_rule_userspace_probe_get_location(
+       status = lttng_event_rule_kernel_uprobe_get_location(
                        uprobe, &probe_location_tmp);
        ok(status == LTTNG_EVENT_RULE_STATUS_OK,
                        "Getting uprobe event rule location.");
                        uprobe, &probe_location_tmp);
        ok(status == LTTNG_EVENT_RULE_STATUS_OK,
                        "Getting uprobe event rule location.");
@@ -266,10 +266,10 @@ static void test_event_rule_userspace_probe(void)
                           probe_location, probe_location_tmp),
                        "Location is equal.");
 
                           probe_location, probe_location_tmp),
                        "Location is equal.");
 
-       status = lttng_event_rule_userspace_probe_set_event_name(uprobe, probe_name);
+       status = lttng_event_rule_kernel_uprobe_set_event_name(uprobe, probe_name);
        ok(status == LTTNG_EVENT_RULE_STATUS_OK,
                        "Setting uprobe event rule name: %s.", probe_name);
        ok(status == LTTNG_EVENT_RULE_STATUS_OK,
                        "Setting uprobe event rule name: %s.", probe_name);
-       status = lttng_event_rule_userspace_probe_get_event_name(uprobe, &tmp);
+       status = lttng_event_rule_kernel_uprobe_get_event_name(uprobe, &tmp);
        ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Getting uprobe name.");
        ok(!strcmp(probe_name, tmp), "Uprobe name are equal.");
 
        ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Getting uprobe name.");
        ok(!strcmp(probe_name, tmp), "Uprobe name are equal.");
 
This page took 0.052551 seconds and 4 git commands to generate.