Refactoring: combine common code into lttng_syscall_table_set_wildcard_all
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 3 Nov 2021 19:09:53 +0000 (15:09 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 3 Nov 2021 19:11:12 +0000 (15:11 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I84bda6aa93f5ca67e57dec95710c51f9464a11f4

include/lttng/events-internal.h
src/lttng-events.c
src/lttng-syscalls.c

index 21d887f03f80f65410809540e6ae9e4543ac01d1..57a7325eb62a3105eca41656e046c9613f01dec8 100644 (file)
@@ -860,6 +860,8 @@ int lttng_syscalls_destroy_syscall_table(struct lttng_kernel_syscall_table *sysc
 
 long lttng_syscall_table_get_active_mask(struct lttng_kernel_syscall_table *syscall_table,
                struct lttng_kernel_abi_syscall_mask __user *usyscall_mask);
+
+void lttng_syscall_table_set_wildcard_all(struct lttng_event_enabler_common *event_enabler);
 #else
 static inline int lttng_syscalls_register_event(struct lttng_event_enabler_common *event_enabler)
 {
@@ -897,6 +899,9 @@ static inline int lttng_syscalls_create_matching_event_notifiers(struct lttng_ev
        return -ENOSYS;
 }
 
+static inline void lttng_syscall_table_set_wildcard_all(struct lttng_event_enabler_common *event_enabler)
+{
+}
 #endif
 
 #ifdef CONFIG_KPROBES
index fa151acfb15ad8f4a30bb206a09bee5e5a6fb962..12ef85e365b713ccf8f17d9b1f5dd7ab0dca6b67 100644 (file)
@@ -2230,24 +2230,11 @@ void lttng_create_event_if_missing(struct lttng_event_enabler_common *event_enab
 static
 int lttng_event_enabler_ref_events(struct lttng_event_recorder_enabler *event_enabler)
 {
-       struct lttng_kernel_channel_buffer *chan = event_enabler->chan;
        struct lttng_event_enabler_common *base_enabler = lttng_event_recorder_enabler_as_enabler(event_enabler);
        struct lttng_kernel_event_recorder_private *event_recorder_priv;
        struct list_head *event_list_head = lttng_get_event_list_head_from_enabler(&event_enabler->parent);
 
-       if (base_enabler->event_param.instrumentation == LTTNG_KERNEL_ABI_SYSCALL &&
-                       base_enabler->event_param.u.syscall.abi == LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL &&
-                       base_enabler->event_param.u.syscall.match == LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME &&
-                       !strcmp(base_enabler->event_param.name, "*")) {
-               int enabled = base_enabler->enabled;
-               enum lttng_kernel_abi_syscall_entryexit entryexit = base_enabler->event_param.u.syscall.entryexit;
-
-               if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
-                       WRITE_ONCE(chan->priv->parent.syscall_table.syscall_all_entry, enabled);
-
-               if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
-                       WRITE_ONCE(chan->priv->parent.syscall_table.syscall_all_exit, enabled);
-       }
+       lttng_syscall_table_set_wildcard_all(base_enabler);
 
        /* First ensure that probe events are created for this enabler. */
        lttng_create_event_if_missing(&event_enabler->parent);
@@ -2292,26 +2279,10 @@ static
 int lttng_event_notifier_enabler_ref_event_notifiers(
                struct lttng_event_notifier_enabler *event_notifier_enabler)
 {
-       struct lttng_event_notifier_group *event_notifier_group = event_notifier_enabler->group;
-       struct lttng_event_enabler_common *base_enabler = lttng_event_notifier_enabler_as_enabler(event_notifier_enabler);
        struct lttng_kernel_event_notifier_private *event_notifier_priv;
        struct list_head *event_list_head = lttng_get_event_list_head_from_enabler(&event_notifier_enabler->parent);
 
-       if (base_enabler->event_param.instrumentation == LTTNG_KERNEL_ABI_SYSCALL &&
-                       base_enabler->event_param.u.syscall.abi == LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL &&
-                       base_enabler->event_param.u.syscall.match == LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME &&
-                       !strcmp(base_enabler->event_param.name, "*")) {
-
-               int enabled = base_enabler->enabled;
-               enum lttng_kernel_abi_syscall_entryexit entryexit = base_enabler->event_param.u.syscall.entryexit;
-
-               if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
-                       WRITE_ONCE(event_notifier_group->syscall_table.syscall_all_entry, enabled);
-
-               if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
-                       WRITE_ONCE(event_notifier_group->syscall_table.syscall_all_exit, enabled);
-
-       }
+       lttng_syscall_table_set_wildcard_all(&event_notifier_enabler->parent);
 
        /* First ensure that probe event_notifiers are created for this enabler. */
        lttng_create_event_if_missing(&event_notifier_enabler->parent);
index b5bd5bd39e9ee25c59536ef4b5248cfc929b36ab..d26dd83fc15763b5ecbc5970ad5c29c3bc66d186 100644 (file)
@@ -1397,6 +1397,29 @@ int lttng_syscall_filter_disable_event(struct lttng_kernel_event_common *event)
        return 0;
 }
 
+void lttng_syscall_table_set_wildcard_all(struct lttng_event_enabler_common *event_enabler)
+{
+       struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_enabler(event_enabler);
+       enum lttng_kernel_abi_syscall_entryexit entryexit;
+       int enabled = event_enabler->enabled;
+
+       if (event_enabler->event_param.instrumentation != LTTNG_KERNEL_ABI_SYSCALL)
+               return;
+       if (event_enabler->event_param.u.syscall.abi != LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL)
+               return;
+       if (event_enabler->event_param.u.syscall.match != LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME)
+               return;
+       if (strcmp(event_enabler->event_param.name, "*"))
+               return;
+
+       entryexit = event_enabler->event_param.u.syscall.entryexit;
+       if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
+               WRITE_ONCE(syscall_table->syscall_all_entry, enabled);
+
+       if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
+               WRITE_ONCE(syscall_table->syscall_all_exit, enabled);
+}
+
 static
 const struct trace_syscall_entry *syscall_list_get_entry(loff_t *pos)
 {
This page took 0.029888 seconds and 4 git commands to generate.