Rename lttng_event_rule_kernel_probe to lttng_event_rule_kernel_kprobe
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 18 May 2021 18:48:37 +0000 (14:48 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 2 Jun 2021 19:28:20 +0000 (15:28 -0400)
The add trigger command now accepts `kernel:kprobe` instead of `kernel-
probe`. `kprobe` is still accepted.

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

18 files changed:
include/Makefile.am
include/lttng/event-rule/event-rule.h
include/lttng/event-rule/kernel-kprobe-internal.h [new file with mode: 0644]
include/lttng/event-rule/kernel-kprobe.h [new file with mode: 0644]
include/lttng/event-rule/kernel-probe-internal.h [deleted file]
include/lttng/event-rule/kernel-probe.h [deleted file]
include/lttng/lttng.h
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-kprobe.c [new file with mode: 0644]
src/common/event-rule/kernel-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 0ab2888b24dd57e0cfd00b3d200c7cc1e6cf3f68..6b0343a62b0be0215d8b93530a13afd8398d0e23 100644 (file)
@@ -152,7 +152,7 @@ lttngtriggerinclude_HEADERS= \
 
 lttngeventruleinclude_HEADERS= \
        lttng/event-rule/event-rule.h \
-       lttng/event-rule/kernel-probe.h \
+       lttng/event-rule/kernel-kprobe.h \
        lttng/event-rule/kernel-syscall.h \
        lttng/event-rule/kernel-uprobe.h \
        lttng/event-rule/tracepoint.h
@@ -181,7 +181,7 @@ noinst_HEADERS = \
        lttng/event-field-value-internal.h \
        lttng/event-internal.h \
        lttng/event-rule/event-rule-internal.h \
-       lttng/event-rule/kernel-probe-internal.h \
+       lttng/event-rule/kernel-kprobe-internal.h \
        lttng/event-rule/kernel-syscall-internal.h \
        lttng/event-rule/tracepoint-internal.h \
        lttng/event-rule/kernel-uprobe-internal.h \
index 1fea37b4799256cf957cc790a4ff5def35420ba8..df2056b35e091d9102390a23285c3065ce5b5a8d 100644 (file)
@@ -18,7 +18,7 @@ enum lttng_event_rule_type {
        LTTNG_EVENT_RULE_TYPE_UNKNOWN = -1,
        LTTNG_EVENT_RULE_TYPE_TRACEPOINT = 0,
        LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL = 1,
-       LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE = 2,
+       LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE = 2,
        LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION = 3,
        LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE = 4,
 };
diff --git a/include/lttng/event-rule/kernel-kprobe-internal.h b/include/lttng/event-rule/kernel-kprobe-internal.h
new file mode 100644 (file)
index 0000000..b6e40b3
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H
+#define LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H
+
+#include <common/payload-view.h>
+#include <common/macros.h>
+#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/kernel-kprobe.h>
+
+struct lttng_event_rule_kernel_kprobe {
+       struct lttng_event_rule parent;
+       char *name;
+       struct lttng_kernel_probe_location *location;
+};
+
+struct lttng_event_rule_kernel_kprobe_comm {
+       /* Includes terminator `\0`. */
+       uint32_t name_len;
+       uint32_t location_len;
+       /*
+        * Payload is composed of, in that order:
+        *   - name (null terminated),
+        *   - kernel probe location object.
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+LTTNG_HIDDEN
+ssize_t lttng_event_rule_kernel_kprobe_create_from_payload(
+               struct lttng_payload_view *payload,
+               struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H */
diff --git a/include/lttng/event-rule/kernel-kprobe.h b/include/lttng/event-rule/kernel-kprobe.h
new file mode 100644 (file)
index 0000000..95f0002
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_KPROBE_H
+#define LTTNG_EVENT_RULE_KERNEL_KPROBE_H
+
+#include <lttng/event-rule/event-rule.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct lttng_kernel_probe_location;
+
+/*
+ * Create a newly allocated kernel kprobe event rule.
+ *
+ * The location is copied internally.
+ *
+ * Returns a new event rule on success, NULL on failure. The returned event rule
+ * must be destroyed using lttng_event_rule_destroy().
+ */
+extern struct lttng_event_rule *lttng_event_rule_kernel_kprobe_create(
+               const struct lttng_kernel_probe_location *location);
+
+/*
+ * Get the kernel probe location of a kernel kprobe 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_kprobe_get_location(
+               const struct lttng_event_rule *rule,
+               const struct lttng_kernel_probe_location **location);
+
+/*
+ * Set the name of a kernel kprobe event rule.
+ *
+ * The name is copied internally.
+ *
+ * Returns 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_kprobe_set_event_name(
+               struct lttng_event_rule *rule, const char *name);
+
+/*
+ * Get the name of a kernel kprobe 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_kprobe_get_event_name(
+               const struct lttng_event_rule *rule, const char **name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_KPROBE_H */
diff --git a/include/lttng/event-rule/kernel-probe-internal.h b/include/lttng/event-rule/kernel-probe-internal.h
deleted file mode 100644 (file)
index 50c02d8..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_KERNEL_PROBE_INTERNAL_H
-#define LTTNG_EVENT_RULE_KERNEL_PROBE_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-probe.h>
-
-struct lttng_event_rule_kernel_probe {
-       struct lttng_event_rule parent;
-       char *name;
-       struct lttng_kernel_probe_location *location;
-};
-
-struct lttng_event_rule_kernel_probe_comm {
-       /* Includes terminator `\0`. */
-       uint32_t name_len;
-       uint32_t location_len;
-       /*
-        * Payload is composed of, in that order:
-        *   - name (null terminated),
-        *   - kernel probe location object.
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-LTTNG_HIDDEN
-ssize_t lttng_event_rule_kernel_probe_create_from_payload(
-               struct lttng_payload_view *payload,
-               struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_KERNEL_PROBE_INTERNAL_H */
diff --git a/include/lttng/event-rule/kernel-probe.h b/include/lttng/event-rule/kernel-probe.h
deleted file mode 100644 (file)
index e9272ff..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_KERNEL_PROBE_H
-#define LTTNG_EVENT_RULE_KERNEL_PROBE_H
-
-#include <lttng/event-rule/event-rule.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct lttng_kernel_probe_location;
-
-/*
- * Create a newly allocated kernel probe event rule.
- *
- * The location is copied internally.
- *
- * Returns a new event rule on success, NULL on failure. The returned event rule
- * must be destroyed using lttng_event_rule_destroy().
- */
-extern struct lttng_event_rule *lttng_event_rule_kernel_probe_create(
-               const struct lttng_kernel_probe_location *location);
-
-/*
- * Get the kernel probe location of a kernel 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_kernel_probe_get_location(
-               const struct lttng_event_rule *rule,
-               const struct lttng_kernel_probe_location **location);
-
-/*
- * Set the name of a kernel probe event rule.
- *
- * The name is copied internally.
- *
- * Returns 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_probe_set_event_name(
-               struct lttng_event_rule *rule, const char *name);
-
-/*
- * Get the name of a kernel 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_kernel_probe_get_event_name(
-               const struct lttng_event_rule *rule, const char **name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LTTNG_EVENT_RULE_KERNEL_PROBE_H */
index 1fa904b4dc0ef0e8fc990380946d7b3b47728989..dc09f2037850779b45ab80482a1130ddd847485f 100644 (file)
@@ -42,7 +42,7 @@
 #include <lttng/event-expr.h>
 #include <lttng/event-field-value.h>
 #include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/kernel-probe.h>
+#include <lttng/event-rule/kernel-kprobe.h>
 #include <lttng/event-rule/kernel-syscall.h>
 #include <lttng/event-rule/tracepoint.h>
 #include <lttng/event-rule/kernel-uprobe.h>
index 0ab1b6864808fd687d869956472ac1df63b581b6..952342e5424dd4e8b08de6379808137c1ab61ea5 100644 (file)
@@ -18,8 +18,8 @@
 #include <lttng/userspace-probe-internal.h>
 #include <lttng/event-rule/event-rule.h>
 #include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-probe.h>
-#include <lttng/event-rule/kernel-probe-internal.h>
+#include <lttng/event-rule/kernel-kprobe.h>
+#include <lttng/event-rule/kernel-kprobe-internal.h>
 #include <lttng/event-rule/kernel-syscall.h>
 #include <lttng/event-rule/kernel-syscall-internal.h>
 #include <lttng/event-rule/tracepoint.h>
@@ -552,7 +552,7 @@ enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule(
        int strncpy_ret;
 
        switch (lttng_event_rule_get_type(rule)) {
-       case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE:
        {
                uint64_t address = 0, offset = 0;
                const char *symbol_name = NULL;
@@ -560,7 +560,7 @@ enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule(
                enum lttng_kernel_probe_location_status k_status;
                enum lttng_event_rule_status status;
 
-               status = lttng_event_rule_kernel_probe_get_location(rule, &location);
+               status = lttng_event_rule_kernel_kprobe_get_location(rule, &location);
                if (status != LTTNG_EVENT_RULE_STATUS_OK) {
                        ret_code = LTTNG_ERR_PROBE_LOCATION_INVAL;
                        goto error;
@@ -603,7 +603,7 @@ enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule(
 
                kernel_event_notifier->event.u.kprobe.symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
 
-               status = lttng_event_rule_kernel_probe_get_event_name(rule, &name);
+               status = lttng_event_rule_kernel_kprobe_get_event_name(rule, &name);
                assert(status == LTTNG_EVENT_RULE_STATUS_OK);
                ret_code = LTTNG_OK;
                break;
index 0f94ef1551d69348341e52d219296812a26e4820..8b0754bd2a216987bf022b6df7719dfbe953454d 100644 (file)
@@ -128,8 +128,8 @@ bool assign_event_rule_type(enum lttng_event_rule_type *dest, const char *arg)
        if (strcmp(arg, "tracepoint") == 0 || strcmp(arg, "logging") == 0) {
                *dest = LTTNG_EVENT_RULE_TYPE_TRACEPOINT;
        } else if (strcmp(arg, "kprobe") == 0 ||
-                       strcmp(arg, "kernel-probe") == 0) {
-               *dest = LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE;
+                       strcmp(arg, "kernel:kprobe") == 0) {
+               *dest = LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE;
        } else if (strcmp(arg, "kernel:uprobe") == 0) {
                *dest = LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE;
        } else if (strcmp(arg, "function") == 0) {
@@ -885,7 +885,7 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv)
         * If omitted, it defaults to the location.
         */
        switch (event_rule_type) {
-       case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
                if (!location) {
@@ -931,7 +931,7 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv)
 
        /* Validate event rule type against domain. */
        switch (event_rule_type) {
-       case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
@@ -1089,7 +1089,7 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv)
 
                break;
        }
-       case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE:
        {
                int ret;
                enum lttng_event_rule_status event_rule_status;
@@ -1102,14 +1102,14 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv)
                }
 
                assert(kernel_probe_location);
-               res.er = lttng_event_rule_kernel_probe_create(kernel_probe_location);
+               res.er = lttng_event_rule_kernel_kprobe_create(kernel_probe_location);
                if (!res.er) {
                        ERR("Failed to create kprobe event rule.");
                        goto error;
                }
 
                event_rule_status =
-                               lttng_event_rule_kernel_probe_set_event_name(
+                               lttng_event_rule_kernel_kprobe_set_event_name(
                                                res.er, event_name);
                if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
                        ERR("Failed to set kprobe event rule's name to '%s'.",
index e10fc29f1fe2903dfc81aee455037b7717d40352..9c2cf0909ed61bf06d093578d57d1e44cde0e23c 100644 (file)
@@ -294,22 +294,22 @@ void print_event_rule_kernel_probe(const struct lttng_event_rule *event_rule)
        const char *name;
        const struct lttng_kernel_probe_location *location;
 
-       assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE);
+       assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE);
 
-       event_rule_status = lttng_event_rule_kernel_probe_get_event_name(event_rule, &name);
+       event_rule_status = lttng_event_rule_kernel_kprobe_get_event_name(event_rule, &name);
        if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
                ERR("Failed to get kprobe event rule's name.");
                goto end;
        }
 
-       event_rule_status = lttng_event_rule_kernel_probe_get_location(
+       event_rule_status = lttng_event_rule_kernel_kprobe_get_location(
                        event_rule, &location);
        if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
                ERR("Failed to get kprobe event rule's location.");
                goto end;
        }
 
-       _MSG("    rule: %s (type: probe, location: ", name);
+       _MSG("    rule: %s (type: kernel:kprobe, location: ", name);
 
        print_kernel_probe_location(location);
 
@@ -425,7 +425,7 @@ void print_event_rule(const struct lttng_event_rule *event_rule)
        case LTTNG_EVENT_RULE_TYPE_TRACEPOINT:
                print_event_rule_tracepoint(event_rule);
                break;
-       case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE:
                print_event_rule_kernel_probe(event_rule);
                break;
        case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
index 296d4955119c27363d8a5f6674de56e6dba3e1bc..12a6ba807678484eb9458b60a5752aaef06618b8 100644 (file)
@@ -65,7 +65,7 @@ libcommon_la_SOURCES = \
        event-expr-to-bytecode.c event-expr-to-bytecode.h \
        event-field-value.c \
        event-rule/event-rule.c \
-       event-rule/kernel-probe.c \
+       event-rule/kernel-kprobe.c \
        event-rule/kernel-syscall.c \
        event-rule/kernel-uprobe.c \
        event-rule/tracepoint.c \
index 291ef533c280eef3b013dc537fed9c9428b87072..33e91cdfb02649add73e6fc64632bc660ffede09 100644 (file)
@@ -14,7 +14,7 @@
 #include <common/hashtable/hashtable.h>
 #include <common/hashtable/utils.h>
 #include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-probe-internal.h>
+#include <lttng/event-rule/kernel-kprobe-internal.h>
 #include <lttng/event-rule/kernel-syscall-internal.h>
 #include <lttng/event-rule/tracepoint-internal.h>
 #include <lttng/event-rule/kernel-uprobe-internal.h>
@@ -41,7 +41,7 @@ enum lttng_domain_type lttng_event_rule_get_domain_type(
                break;
        }
        case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
-       case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
        case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
                domain_type = LTTNG_DOMAIN_KERNEL;
@@ -172,8 +172,8 @@ ssize_t lttng_event_rule_create_from_payload(
                create_from_payload =
                                lttng_event_rule_tracepoint_create_from_payload;
                break;
-       case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
-               create_from_payload = lttng_event_rule_kernel_probe_create_from_payload;
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE:
+               create_from_payload = lttng_event_rule_kernel_kprobe_create_from_payload;
                break;
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
                /* TODO */
@@ -315,8 +315,8 @@ const char *lttng_event_rule_type_str(enum lttng_event_rule_type type)
                return "tracepoint";
        case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
                return "kernel syscall";
-       case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE:
-               return "probe";
+       case LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE:
+               return "kernel kprobe";
        case LTTNG_EVENT_RULE_TYPE_KERNEL_FUNCTION:
                return "function";
        case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
diff --git a/src/common/event-rule/kernel-kprobe.c b/src/common/event-rule/kernel-kprobe.c
new file mode 100644 (file)
index 0000000..b069bdb
--- /dev/null
@@ -0,0 +1,437 @@
+/*
+ * 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 <ctype.h>
+#include <lttng/constant.h>
+#include <lttng/event-rule/event-rule.h>
+#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/kernel-kprobe-internal.h>
+#include <lttng/kernel-probe.h>
+#include <lttng/kernel-probe-internal.h>
+#include <stdio.h>
+
+#define IS_KPROBE_EVENT_RULE(rule) \
+       (lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE)
+
+#if (LTTNG_SYMBOL_NAME_LEN == 256)
+#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
+#endif
+
+static void lttng_event_rule_kernel_kprobe_destroy(struct lttng_event_rule *rule)
+{
+       struct lttng_event_rule_kernel_kprobe *kprobe;
+
+       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+
+       lttng_kernel_probe_location_destroy(kprobe->location);
+       free(kprobe->name);
+       free(kprobe);
+}
+
+static bool lttng_event_rule_kernel_kprobe_validate(
+               const struct lttng_event_rule *rule)
+{
+       bool valid = false;
+       struct lttng_event_rule_kernel_kprobe *kprobe;
+
+       if (!rule) {
+               goto end;
+       }
+
+       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+
+       /* Required field. */
+       if (!kprobe->name) {
+               ERR("Invalid name event rule: a name must be set.");
+               goto end;
+       }
+
+       /* Required field. */
+       if(!kprobe->location) {
+               ERR("Invalid name event rule: a location must be set.");
+               goto end;
+       }
+
+       valid = true;
+end:
+       return valid;
+}
+
+static int lttng_event_rule_kernel_kprobe_serialize(
+               const struct lttng_event_rule *rule,
+               struct lttng_payload *payload)
+{
+       int ret;
+       size_t name_len, header_offset, size_before_location;
+       struct lttng_event_rule_kernel_kprobe *kprobe;
+       struct lttng_event_rule_kernel_kprobe_comm kprobe_comm;
+       struct lttng_event_rule_kernel_kprobe_comm *header;
+
+       if (!rule || !IS_KPROBE_EVENT_RULE(rule)) {
+               ret = -1;
+               goto end;
+       }
+
+       header_offset = payload->buffer.size;
+
+       DBG("Serializing kprobe event rule.");
+       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+
+       name_len = strlen(kprobe->name) + 1;
+       kprobe_comm.name_len = name_len;
+
+       ret = lttng_dynamic_buffer_append(
+                       &payload->buffer, &kprobe_comm, sizeof(kprobe_comm));
+       if (ret) {
+               goto end;
+       }
+
+       ret = lttng_dynamic_buffer_append(&payload->buffer, kprobe->name, name_len);
+       if (ret) {
+               goto end;
+       }
+
+       size_before_location = payload->buffer.size;
+
+       ret = lttng_kernel_probe_location_serialize(kprobe->location, payload);
+       if (ret < 0) {
+               goto end;
+       }
+
+       /* Update the header regarding the probe size. */
+       header = (struct lttng_event_rule_kernel_kprobe_comm*) (
+                       (char *) payload->buffer.data + header_offset);
+       header->location_len = payload->buffer.size - size_before_location;
+
+       ret = 0;
+
+end:
+       return ret;
+}
+
+static bool lttng_event_rule_kernel_kprobe_is_equal(const struct lttng_event_rule *_a,
+               const struct lttng_event_rule *_b)
+{
+       bool is_equal = false;
+       struct lttng_event_rule_kernel_kprobe *a, *b;
+
+       a = container_of(_a, struct lttng_event_rule_kernel_kprobe, parent);
+       b = container_of(_b, struct lttng_event_rule_kernel_kprobe, parent);
+
+       /* Quick checks */
+       if (!!a->name != !!b->name) {
+               goto end;
+       }
+
+       /* Long check */
+       assert(a->name);
+       assert(b->name);
+       if (strcmp(a->name, b->name)) {
+               goto end;
+       }
+
+       is_equal = lttng_kernel_probe_location_is_equal(
+                       a->location, b->location);
+end:
+       return is_equal;
+}
+
+static enum lttng_error_code lttng_event_rule_kernel_kprobe_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_kprobe_get_filter(
+               const struct lttng_event_rule *rule)
+{
+       /* Not supported. */
+       return NULL;
+}
+
+static const struct lttng_bytecode *
+lttng_event_rule_kernel_kprobe_get_filter_bytecode(const struct lttng_event_rule *rule)
+{
+       /* Not supported. */
+       return NULL;
+}
+
+static enum lttng_event_rule_generate_exclusions_status
+lttng_event_rule_kernel_kprobe_generate_exclusions(const struct lttng_event_rule *rule,
+               struct lttng_event_exclusion **exclusions)
+{
+       /* Not supported. */
+       *exclusions = NULL;
+       return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
+}
+
+static unsigned long
+lttng_event_rule_kernel_kprobe_hash(
+               const struct lttng_event_rule *rule)
+{
+       unsigned long hash;
+       struct lttng_event_rule_kernel_kprobe *krule =
+                       container_of(rule, typeof(*krule), parent);
+
+       hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE,
+                       lttng_ht_seed);
+       hash ^= hash_key_str(krule->name, lttng_ht_seed);
+       hash ^= lttng_kernel_probe_location_hash(krule->location);
+
+       return hash;
+}
+
+static
+int kernel_probe_set_location(
+               struct lttng_event_rule_kernel_kprobe *kprobe,
+               const struct lttng_kernel_probe_location *location)
+{
+       int ret;
+       struct lttng_kernel_probe_location *location_copy = NULL;
+
+       if (!kprobe || !location || kprobe->location) {
+               ret = -1;
+               goto end;
+       }
+
+       location_copy = lttng_kernel_probe_location_copy(location);
+       if (!location_copy) {
+               ret = -1;
+               goto end;
+       }
+
+       kprobe->location = location_copy;
+       location_copy = NULL;
+       ret = 0;
+end:
+       lttng_kernel_probe_location_destroy(location_copy);
+       return ret;
+}
+
+struct lttng_event_rule *lttng_event_rule_kernel_kprobe_create(
+               const struct lttng_kernel_probe_location *location)
+{
+       struct lttng_event_rule *rule = NULL;
+       struct lttng_event_rule_kernel_kprobe *krule;
+
+       krule = zmalloc(sizeof(struct lttng_event_rule_kernel_kprobe));
+       if (!krule) {
+               goto end;
+       }
+
+       rule = &krule->parent;
+       lttng_event_rule_init(&krule->parent, LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE);
+       krule->parent.validate = lttng_event_rule_kernel_kprobe_validate;
+       krule->parent.serialize = lttng_event_rule_kernel_kprobe_serialize;
+       krule->parent.equal = lttng_event_rule_kernel_kprobe_is_equal;
+       krule->parent.destroy = lttng_event_rule_kernel_kprobe_destroy;
+       krule->parent.generate_filter_bytecode =
+                       lttng_event_rule_kernel_kprobe_generate_filter_bytecode;
+       krule->parent.get_filter = lttng_event_rule_kernel_kprobe_get_filter;
+       krule->parent.get_filter_bytecode =
+                       lttng_event_rule_kernel_kprobe_get_filter_bytecode;
+       krule->parent.generate_exclusions =
+                       lttng_event_rule_kernel_kprobe_generate_exclusions;
+       krule->parent.hash = lttng_event_rule_kernel_kprobe_hash;
+
+       if (kernel_probe_set_location(krule, location)) {
+               lttng_event_rule_destroy(rule);
+               rule = NULL;
+       }
+
+end:
+       return rule;
+}
+
+LTTNG_HIDDEN
+ssize_t lttng_event_rule_kernel_kprobe_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_rule **_event_rule)
+{
+       ssize_t ret, offset = 0;
+       enum lttng_event_rule_status status;
+       const struct lttng_event_rule_kernel_kprobe_comm *kprobe_comm;
+       const char *name;
+       struct lttng_buffer_view current_buffer_view;
+       struct lttng_event_rule *rule = NULL;
+       struct lttng_kernel_probe_location *location = NULL;
+
+       if (!_event_rule) {
+               ret = -1;
+               goto end;
+       }
+
+       current_buffer_view = lttng_buffer_view_from_view(
+                       &view->buffer, offset, sizeof(*kprobe_comm));
+       if (!lttng_buffer_view_is_valid(&current_buffer_view)) {
+               ERR("Failed to initialize from malformed event rule kprobe: buffer too short to contain header.");
+               ret = -1;
+               goto end;
+       }
+
+       kprobe_comm = (typeof(kprobe_comm)) current_buffer_view.data;
+
+       /* Skip to payload */
+       offset += current_buffer_view.size;
+
+       {
+               /* Map the name. */
+               struct lttng_payload_view current_payload_view =
+                               lttng_payload_view_from_view(view, offset,
+                                               kprobe_comm->name_len);
+
+               if (!lttng_payload_view_is_valid(&current_payload_view)) {
+                       ret = -1;
+                       goto end;
+               }
+
+               name = current_payload_view.buffer.data;
+               if (!lttng_buffer_view_contains_string(
+                               &current_payload_view.buffer, name,
+                               kprobe_comm->name_len)) {
+                       ret = -1;
+                       goto end;
+               }
+       }
+
+       /* Skip after the name. */
+       offset += kprobe_comm->name_len;
+
+       /* Map the kernel probe location. */
+       {
+               struct lttng_payload_view current_payload_view =
+                               lttng_payload_view_from_view(view, offset,
+                                               kprobe_comm->location_len);
+
+               if (!lttng_payload_view_is_valid(&current_payload_view)) {
+                       ret = -1;
+                       goto end;
+               }
+
+               ret = lttng_kernel_probe_location_create_from_payload(
+                               &current_payload_view, &location);
+               if (ret < 0) {
+                       ret = -1;
+                       goto end;
+               }
+       }
+
+       if (ret != kprobe_comm->location_len) {
+               ret = -1;
+               goto end;
+       }
+
+       /* Skip after the location */
+       offset += kprobe_comm->location_len;
+
+       rule = lttng_event_rule_kernel_kprobe_create(location);
+       if (!rule) {
+               ERR("Failed to create event rule kprobe.");
+               ret = -1;
+               goto end;
+       }
+
+       status = lttng_event_rule_kernel_kprobe_set_event_name(rule, name);
+       if (status != LTTNG_EVENT_RULE_STATUS_OK) {
+               ERR("Failed to set event rule kprobe name.");
+               ret = -1;
+               goto end;
+       }
+
+       *_event_rule = rule;
+       rule = NULL;
+       ret = offset;
+end:
+       lttng_kernel_probe_location_destroy(location);
+       lttng_event_rule_destroy(rule);
+       return ret;
+}
+
+enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_get_location(
+               const struct lttng_event_rule *rule,
+               const struct lttng_kernel_probe_location **location)
+{
+       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
+       struct lttng_event_rule_kernel_kprobe *kprobe;
+
+       if (!rule || !IS_KPROBE_EVENT_RULE(rule) || !location) {
+               status = LTTNG_EVENT_RULE_STATUS_INVALID;
+               goto end;
+       }
+
+       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+       *location = kprobe->location;
+
+       if (!*location) {
+               status = LTTNG_EVENT_RULE_STATUS_UNSET;
+               goto end;
+       }
+
+end:
+       return status;
+}
+
+enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_set_event_name(
+               struct lttng_event_rule *rule, const char *name)
+{
+       char *name_copy = NULL;
+       struct lttng_event_rule_kernel_kprobe *kprobe;
+       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
+
+       if (!rule || !IS_KPROBE_EVENT_RULE(rule) || !name ||
+                       strlen(name) == 0) {
+               status = LTTNG_EVENT_RULE_STATUS_INVALID;
+               goto end;
+       }
+
+       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+       name_copy = strdup(name);
+       if (!name_copy) {
+               status = LTTNG_EVENT_RULE_STATUS_ERROR;
+               goto end;
+       }
+
+       free(kprobe->name);
+
+       kprobe->name = name_copy;
+       name_copy = NULL;
+end:
+       return status;
+}
+
+enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_get_event_name(
+               const struct lttng_event_rule *rule, const char **name)
+{
+       struct lttng_event_rule_kernel_kprobe *kprobe;
+       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
+
+       if (!rule || !IS_KPROBE_EVENT_RULE(rule) || !name) {
+               status = LTTNG_EVENT_RULE_STATUS_INVALID;
+               goto end;
+       }
+
+       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+       if (!kprobe->name) {
+               status = LTTNG_EVENT_RULE_STATUS_UNSET;
+               goto end;
+       }
+
+       *name = kprobe->name;
+end:
+       return status;
+}
diff --git a/src/common/event-rule/kernel-probe.c b/src/common/event-rule/kernel-probe.c
deleted file mode 100644 (file)
index f53e924..0000000
+++ /dev/null
@@ -1,437 +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 <ctype.h>
-#include <lttng/constant.h>
-#include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-probe-internal.h>
-#include <lttng/kernel-probe.h>
-#include <lttng/kernel-probe-internal.h>
-#include <stdio.h>
-
-#define IS_KPROBE_EVENT_RULE(rule) \
-       (lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE)
-
-#if (LTTNG_SYMBOL_NAME_LEN == 256)
-#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
-#endif
-
-static void lttng_event_rule_kernel_probe_destroy(struct lttng_event_rule *rule)
-{
-       struct lttng_event_rule_kernel_probe *kprobe;
-
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_probe, parent);
-
-       lttng_kernel_probe_location_destroy(kprobe->location);
-       free(kprobe->name);
-       free(kprobe);
-}
-
-static bool lttng_event_rule_kernel_probe_validate(
-               const struct lttng_event_rule *rule)
-{
-       bool valid = false;
-       struct lttng_event_rule_kernel_probe *kprobe;
-
-       if (!rule) {
-               goto end;
-       }
-
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_probe, parent);
-
-       /* Required field. */
-       if (!kprobe->name) {
-               ERR("Invalid name event rule: a name must be set.");
-               goto end;
-       }
-
-       /* Required field. */
-       if(!kprobe->location) {
-               ERR("Invalid name event rule: a location must be set.");
-               goto end;
-       }
-
-       valid = true;
-end:
-       return valid;
-}
-
-static int lttng_event_rule_kernel_probe_serialize(
-               const struct lttng_event_rule *rule,
-               struct lttng_payload *payload)
-{
-       int ret;
-       size_t name_len, header_offset, size_before_location;
-       struct lttng_event_rule_kernel_probe *kprobe;
-       struct lttng_event_rule_kernel_probe_comm kprobe_comm;
-       struct lttng_event_rule_kernel_probe_comm *header;
-
-       if (!rule || !IS_KPROBE_EVENT_RULE(rule)) {
-               ret = -1;
-               goto end;
-       }
-
-       header_offset = payload->buffer.size;
-
-       DBG("Serializing kprobe event rule.");
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_probe, parent);
-
-       name_len = strlen(kprobe->name) + 1;
-       kprobe_comm.name_len = name_len;
-
-       ret = lttng_dynamic_buffer_append(
-                       &payload->buffer, &kprobe_comm, sizeof(kprobe_comm));
-       if (ret) {
-               goto end;
-       }
-
-       ret = lttng_dynamic_buffer_append(&payload->buffer, kprobe->name, name_len);
-       if (ret) {
-               goto end;
-       }
-
-       size_before_location = payload->buffer.size;
-
-       ret = lttng_kernel_probe_location_serialize(kprobe->location, payload);
-       if (ret < 0) {
-               goto end;
-       }
-
-       /* Update the header regarding the probe size. */
-       header = (struct lttng_event_rule_kernel_probe_comm*) (
-                       (char *) payload->buffer.data + header_offset);
-       header->location_len = payload->buffer.size - size_before_location;
-
-       ret = 0;
-
-end:
-       return ret;
-}
-
-static bool lttng_event_rule_kernel_probe_is_equal(const struct lttng_event_rule *_a,
-               const struct lttng_event_rule *_b)
-{
-       bool is_equal = false;
-       struct lttng_event_rule_kernel_probe *a, *b;
-
-       a = container_of(_a, struct lttng_event_rule_kernel_probe, parent);
-       b = container_of(_b, struct lttng_event_rule_kernel_probe, parent);
-
-       /* Quick checks */
-       if (!!a->name != !!b->name) {
-               goto end;
-       }
-
-       /* Long check */
-       assert(a->name);
-       assert(b->name);
-       if (strcmp(a->name, b->name)) {
-               goto end;
-       }
-
-       is_equal = lttng_kernel_probe_location_is_equal(
-                       a->location, b->location);
-end:
-       return is_equal;
-}
-
-static enum lttng_error_code lttng_event_rule_kernel_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_kernel_probe_get_filter(
-               const struct lttng_event_rule *rule)
-{
-       /* Not supported. */
-       return NULL;
-}
-
-static const struct lttng_bytecode *
-lttng_event_rule_kernel_probe_get_filter_bytecode(const struct lttng_event_rule *rule)
-{
-       /* Not supported. */
-       return NULL;
-}
-
-static enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_kernel_probe_generate_exclusions(const struct lttng_event_rule *rule,
-               struct lttng_event_exclusion **exclusions)
-{
-       /* Not supported. */
-       *exclusions = NULL;
-       return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
-}
-
-static unsigned long
-lttng_event_rule_kernel_probe_hash(
-               const struct lttng_event_rule *rule)
-{
-       unsigned long hash;
-       struct lttng_event_rule_kernel_probe *krule =
-                       container_of(rule, typeof(*krule), parent);
-
-       hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE,
-                       lttng_ht_seed);
-       hash ^= hash_key_str(krule->name, lttng_ht_seed);
-       hash ^= lttng_kernel_probe_location_hash(krule->location);
-
-       return hash;
-}
-
-static
-int kernel_probe_set_location(
-               struct lttng_event_rule_kernel_probe *kprobe,
-               const struct lttng_kernel_probe_location *location)
-{
-       int ret;
-       struct lttng_kernel_probe_location *location_copy = NULL;
-
-       if (!kprobe || !location || kprobe->location) {
-               ret = -1;
-               goto end;
-       }
-
-       location_copy = lttng_kernel_probe_location_copy(location);
-       if (!location_copy) {
-               ret = -1;
-               goto end;
-       }
-
-       kprobe->location = location_copy;
-       location_copy = NULL;
-       ret = 0;
-end:
-       lttng_kernel_probe_location_destroy(location_copy);
-       return ret;
-}
-
-struct lttng_event_rule *lttng_event_rule_kernel_probe_create(
-               const struct lttng_kernel_probe_location *location)
-{
-       struct lttng_event_rule *rule = NULL;
-       struct lttng_event_rule_kernel_probe *krule;
-
-       krule = zmalloc(sizeof(struct lttng_event_rule_kernel_probe));
-       if (!krule) {
-               goto end;
-       }
-
-       rule = &krule->parent;
-       lttng_event_rule_init(&krule->parent, LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE);
-       krule->parent.validate = lttng_event_rule_kernel_probe_validate;
-       krule->parent.serialize = lttng_event_rule_kernel_probe_serialize;
-       krule->parent.equal = lttng_event_rule_kernel_probe_is_equal;
-       krule->parent.destroy = lttng_event_rule_kernel_probe_destroy;
-       krule->parent.generate_filter_bytecode =
-                       lttng_event_rule_kernel_probe_generate_filter_bytecode;
-       krule->parent.get_filter = lttng_event_rule_kernel_probe_get_filter;
-       krule->parent.get_filter_bytecode =
-                       lttng_event_rule_kernel_probe_get_filter_bytecode;
-       krule->parent.generate_exclusions =
-                       lttng_event_rule_kernel_probe_generate_exclusions;
-       krule->parent.hash = lttng_event_rule_kernel_probe_hash;
-
-       if (kernel_probe_set_location(krule, location)) {
-               lttng_event_rule_destroy(rule);
-               rule = NULL;
-       }
-
-end:
-       return rule;
-}
-
-LTTNG_HIDDEN
-ssize_t lttng_event_rule_kernel_probe_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **_event_rule)
-{
-       ssize_t ret, offset = 0;
-       enum lttng_event_rule_status status;
-       const struct lttng_event_rule_kernel_probe_comm *kprobe_comm;
-       const char *name;
-       struct lttng_buffer_view current_buffer_view;
-       struct lttng_event_rule *rule = NULL;
-       struct lttng_kernel_probe_location *location = NULL;
-
-       if (!_event_rule) {
-               ret = -1;
-               goto end;
-       }
-
-       current_buffer_view = lttng_buffer_view_from_view(
-                       &view->buffer, offset, sizeof(*kprobe_comm));
-       if (!lttng_buffer_view_is_valid(&current_buffer_view)) {
-               ERR("Failed to initialize from malformed event rule kprobe: buffer too short to contain header.");
-               ret = -1;
-               goto end;
-       }
-
-       kprobe_comm = (typeof(kprobe_comm)) current_buffer_view.data;
-
-       /* Skip to payload */
-       offset += current_buffer_view.size;
-
-       {
-               /* Map the name. */
-               struct lttng_payload_view current_payload_view =
-                               lttng_payload_view_from_view(view, offset,
-                                               kprobe_comm->name_len);
-
-               if (!lttng_payload_view_is_valid(&current_payload_view)) {
-                       ret = -1;
-                       goto end;
-               }
-
-               name = current_payload_view.buffer.data;
-               if (!lttng_buffer_view_contains_string(
-                               &current_payload_view.buffer, name,
-                               kprobe_comm->name_len)) {
-                       ret = -1;
-                       goto end;
-               }
-       }
-
-       /* Skip after the name. */
-       offset += kprobe_comm->name_len;
-
-       /* Map the kernel probe location. */
-       {
-               struct lttng_payload_view current_payload_view =
-                               lttng_payload_view_from_view(view, offset,
-                                               kprobe_comm->location_len);
-
-               if (!lttng_payload_view_is_valid(&current_payload_view)) {
-                       ret = -1;
-                       goto end;
-               }
-
-               ret = lttng_kernel_probe_location_create_from_payload(
-                               &current_payload_view, &location);
-               if (ret < 0) {
-                       ret = -1;
-                       goto end;
-               }
-       }
-
-       if (ret != kprobe_comm->location_len) {
-               ret = -1;
-               goto end;
-       }
-
-       /* Skip after the location */
-       offset += kprobe_comm->location_len;
-
-       rule = lttng_event_rule_kernel_probe_create(location);
-       if (!rule) {
-               ERR("Failed to create event rule kprobe.");
-               ret = -1;
-               goto end;
-       }
-
-       status = lttng_event_rule_kernel_probe_set_event_name(rule, name);
-       if (status != LTTNG_EVENT_RULE_STATUS_OK) {
-               ERR("Failed to set event rule kprobe name.");
-               ret = -1;
-               goto end;
-       }
-
-       *_event_rule = rule;
-       rule = NULL;
-       ret = offset;
-end:
-       lttng_kernel_probe_location_destroy(location);
-       lttng_event_rule_destroy(rule);
-       return ret;
-}
-
-enum lttng_event_rule_status lttng_event_rule_kernel_probe_get_location(
-               const struct lttng_event_rule *rule,
-               const struct lttng_kernel_probe_location **location)
-{
-       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
-       struct lttng_event_rule_kernel_probe *kprobe;
-
-       if (!rule || !IS_KPROBE_EVENT_RULE(rule) || !location) {
-               status = LTTNG_EVENT_RULE_STATUS_INVALID;
-               goto end;
-       }
-
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_probe, parent);
-       *location = kprobe->location;
-
-       if (!*location) {
-               status = LTTNG_EVENT_RULE_STATUS_UNSET;
-               goto end;
-       }
-
-end:
-       return status;
-}
-
-enum lttng_event_rule_status lttng_event_rule_kernel_probe_set_event_name(
-               struct lttng_event_rule *rule, const char *name)
-{
-       char *name_copy = NULL;
-       struct lttng_event_rule_kernel_probe *kprobe;
-       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
-
-       if (!rule || !IS_KPROBE_EVENT_RULE(rule) || !name ||
-                       strlen(name) == 0) {
-               status = LTTNG_EVENT_RULE_STATUS_INVALID;
-               goto end;
-       }
-
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_probe, parent);
-       name_copy = strdup(name);
-       if (!name_copy) {
-               status = LTTNG_EVENT_RULE_STATUS_ERROR;
-               goto end;
-       }
-
-       free(kprobe->name);
-
-       kprobe->name = name_copy;
-       name_copy = NULL;
-end:
-       return status;
-}
-
-enum lttng_event_rule_status lttng_event_rule_kernel_probe_get_event_name(
-               const struct lttng_event_rule *rule, const char **name)
-{
-       struct lttng_event_rule_kernel_probe *kprobe;
-       enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
-
-       if (!rule || !IS_KPROBE_EVENT_RULE(rule) || !name) {
-               status = LTTNG_EVENT_RULE_STATUS_INVALID;
-               goto end;
-       }
-
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_probe, parent);
-       if (!kprobe->name) {
-               status = LTTNG_EVENT_RULE_STATUS_UNSET;
-               goto end;
-       }
-
-       *name = kprobe->name;
-end:
-       return status;
-}
index aa42d5ef2f9584aad2d8b3cf6796d0917899bb82..1b657663c9816361022e9118efde5b6bac7d967a 100644 (file)
@@ -1861,10 +1861,10 @@ static void test_kprobe_event_rule_notification(
                        lttng_session_daemon_notification_endpoint);
        ok(notification_channel, "Notification channel object creation");
 
-       event_rule = lttng_event_rule_kernel_probe_create(location);
+       event_rule = lttng_event_rule_kernel_kprobe_create(location);
        ok(event_rule, "kprobe event rule object creation");
 
-       event_rule_status = lttng_event_rule_kernel_probe_set_event_name(
+       event_rule_status = lttng_event_rule_kernel_kprobe_set_event_name(
                        event_rule, trigger_name);
        ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
                        "Setting kprobe event rule name: '%s'", trigger_name);
index bbb34b51f5f4ade0583d35d66a91b23c04d62a5a..01859ee74f7ac520fccd641389e7a1e55797e57d 100755 (executable)
@@ -147,7 +147,7 @@ test_success "--exclude-name two" \
        --action notify
 
 skip $ist_root "non-root user: skipping kprobe tests" 18 || {
-       for type in kprobe kernel-probe; do
+       for type in kprobe kernel:kprobe; do
                test_success "--condition event-rule-matches probe by symbol" \
                        --condition event-rule-matches --domain=kernel --type=$type --location=lttng_channel_enable --event-name=my_channel_enable \
                        --action notify
@@ -364,9 +364,9 @@ test_failure "two different --domain" \
        "Error: More than one \`--domain\` was specified." \
        --condition event-rule-matches --domain=user --domain=kernel
 
-for type in kprobe kernel-probe; do
+for type in kprobe kernel:kprobe; do
        test_failure "--condition event-rule-matches: --name with --type=$type" \
-               "Error: Can't use --name with probe event rules." \
+               "Error: Can't use --name with kernel kprobe event rules." \
                --condition event-rule-matches --type=$type --location=do_sys_open --name='hello'
 done
 
index a36393f13a967646605af8a7073554dccd5de8a3..5366a030ccc1434347a05aab15dff6c6a7da9176 100755 (executable)
@@ -225,7 +225,7 @@ test_event_rule_matches_probe ()
        - name: T0
          owner uid: ${uid}
          condition: event rule matches
-           rule: my_channel_enable (type: probe, location: lttng_channel_enable)
+           rule: my_channel_enable (type: kernel:kprobe, location: lttng_channel_enable)
          actions:
            notify
              errors: none
@@ -233,7 +233,7 @@ test_event_rule_matches_probe ()
        - name: T1
          owner uid: ${uid}
          condition: event rule matches
-           rule: my_channel_enable (type: probe, location: ${base_symbol}+${offset_hex})
+           rule: my_channel_enable (type: kernel:kprobe, location: ${base_symbol}+${offset_hex})
          actions:
            notify
              errors: none
@@ -241,7 +241,7 @@ test_event_rule_matches_probe ()
        - name: T2
          owner uid: ${uid}
          condition: event rule matches
-           rule: my_channel_enable (type: probe, location: 0x${channel_enable_addr})
+           rule: my_channel_enable (type: kernel:kprobe, location: 0x${channel_enable_addr})
          actions:
            notify
              errors: none
index 091f53aba784a9486d27dfa99c9409736df99283..8d2ffe35f5488b2273cfb2b16d790885af5003fc 100644 (file)
@@ -18,8 +18,8 @@
 #include <common/payload-view.h>
 #include <common/payload.h>
 #include <lttng/domain.h>
-#include <lttng/event-rule/kernel-probe-internal.h>
-#include <lttng/event-rule/kernel-probe.h>
+#include <lttng/event-rule/kernel-kprobe-internal.h>
+#include <lttng/event-rule/kernel-kprobe.h>
 #include <lttng/event-rule/kernel-syscall-internal.h>
 #include <lttng/event-rule/kernel-syscall.h>
 #include <lttng/event-rule/tracepoint-internal.h>
@@ -313,18 +313,18 @@ static void test_event_rule_kernel_probe_by_location(
 
        lttng_payload_init(&payload);
 
-       kprobe = lttng_event_rule_kernel_probe_create(location);
+       kprobe = lttng_event_rule_kernel_kprobe_create(location);
        ok(kprobe, "kprobe event rule object creation.");
 
-       status = lttng_event_rule_kernel_probe_get_location(kprobe, &_location);
+       status = lttng_event_rule_kernel_kprobe_get_location(kprobe, &_location);
        ok(status == LTTNG_EVENT_RULE_STATUS_OK,
                        "Getting kprobe event rule location.");
        ok(lttng_kernel_probe_location_is_equal(location, _location), "Locations are equal.");
 
-       status = lttng_event_rule_kernel_probe_set_event_name(kprobe, probe_name);
+       status = lttng_event_rule_kernel_kprobe_set_event_name(kprobe, probe_name);
        ok(status == LTTNG_EVENT_RULE_STATUS_OK,
                        "Setting kprobe event rule name: %s.", probe_name);
-       status = lttng_event_rule_kernel_probe_get_event_name(kprobe, &tmp);
+       status = lttng_event_rule_kernel_kprobe_get_event_name(kprobe, &tmp);
        ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Getting kprobe name.");
        ok(!strcmp(probe_name, tmp), "kprobe name are equal.");
 
This page took 0.045886 seconds and 4 git commands to generate.