From: Jérémie Galarneau Date: Tue, 8 Nov 2022 22:13:37 +0000 (-0500) Subject: Fix: syscalls-extractor: kallsyms_lookup_name no longer available X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d504ea731ffc58dcdfa91ddc2c9d6aadfa9bcb37;p=lttng-modules.git Fix: syscalls-extractor: kallsyms_lookup_name no longer available Since v5.7, kallsyms_lookup_name is no longer available. In order to re-use the kallsyms wrapper, it is simpler to move the syscalls extractor module to the `src` directory and gate its compilation behind a new config option, CONFIG_LTTNG_SYSCALLS_EXTRACTOR. Signed-off-by: Jérémie Galarneau Signed-off-by: Mathieu Desnoyers Change-Id: I55d878dce55827d61035693aaf5865af3c4e775f --- diff --git a/Makefile b/Makefile index 81bdedac..8d25816c 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,13 @@ modules: KCPPFLAGS='$(LKCPPFLAGS)' \ modules +syscalls_extractor: + $(MAKE) -C $(KERNELDIR) M=$(PWD)/src \ + CONFIG_LTTNG_SYSCALLS_EXTRACTOR=m \ + CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m \ + KCPPFLAGS='$(LKCPPFLAGS)' \ + modules + modules_install: $(MAKE) -C $(KERNELDIR) M=$(PWD)/src \ CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m \ diff --git a/include/instrumentation/syscalls/lttng-syscalls-extractor/lttng-syscalls-extractor.c b/include/instrumentation/syscalls/lttng-syscalls-extractor/lttng-syscalls-extractor.c deleted file mode 100644 index 8670d25f..00000000 --- a/include/instrumentation/syscalls/lttng-syscalls-extractor/lttng-syscalls-extractor.c +++ /dev/null @@ -1,98 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-syscalls-extractor.c - * - * Dump syscall metadata to console. - * - * Copyright 2011 Mathieu Desnoyers - * Copyright 2011 EfficiOS Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef CONFIG_FTRACE_SYSCALLS -#error "You need to set CONFIG_FTRACE_SYSCALLS=y" -#endif - -#ifndef CONFIG_KALLSYMS_ALL -#error "You need to set CONFIG_KALLSYMS_ALL=y" -#endif - -/* - * The 'ident' parameter is prepended to each printk line to help - * extract the proper lines from dmesg. - */ -static char *ident = ""; -module_param(ident, charp, 0); - -static struct syscall_metadata **__start_syscalls_metadata; -static struct syscall_metadata **__stop_syscalls_metadata; - -static __init -struct syscall_metadata *find_syscall_meta(unsigned long syscall) -{ - struct syscall_metadata **iter; - - for (iter = __start_syscalls_metadata; - iter < __stop_syscalls_metadata; iter++) { - if ((*iter)->syscall_nr == syscall) - return (*iter); - } - return NULL; -} - -int init_module(void) -{ - struct syscall_metadata *meta; - int i; - - __start_syscalls_metadata = (void *) kallsyms_lookup_name("__start_syscalls_metadata"); - __stop_syscalls_metadata = (void *) kallsyms_lookup_name("__stop_syscalls_metadata"); - - printk("%s---START---\n", ident); - for (i = 0; i < NR_syscalls; i++) { - int j; - - meta = find_syscall_meta(i); - if (!meta) - continue; - printk("%ssyscall %s nr %d nbargs %d ", - ident, meta->name, meta->syscall_nr, meta->nb_args); - printk(KERN_CONT "types: ("); - for (j = 0; j < meta->nb_args; j++) { - if (j > 0) - printk(KERN_CONT ", "); - printk(KERN_CONT "%s", meta->types[j]); - } - printk(KERN_CONT ") "); - printk(KERN_CONT "args: ("); - for (j = 0; j < meta->nb_args; j++) { - if (j > 0) - printk(KERN_CONT ", "); - printk(KERN_CONT "%s", meta->args[j]); - } - printk(KERN_CONT ")\n"); - } - printk("%s---END---\n", ident); - - /* - * This module always fails to load. - */ - return -1; -} - -void cleanup_module(void) -{ -} - -MODULE_LICENSE("GPL"); diff --git a/src/Kbuild b/src/Kbuild index 7137874f..440b61d9 100644 --- a/src/Kbuild +++ b/src/Kbuild @@ -150,3 +150,5 @@ lttng-statedump-objs := lttng-statedump-impl.o obj-$(CONFIG_LTTNG) += probes/ obj-$(CONFIG_LTTNG) += lib/ obj-$(CONFIG_LTTNG) += tests/ + +obj-$(CONFIG_LTTNG_SYSCALLS_EXTRACTOR) += lttng-syscalls-extractor.o diff --git a/src/Kconfig b/src/Kconfig index a2a7b8f1..c1e5781b 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -25,4 +25,13 @@ config LTTNG_EXPERIMENTAL_BITWISE_ENUM If unsure, say N. +config LTTNG_SYSCALLS_EXTRACTOR + bool "LTTng syscalls extraction helper" + default n + depends on LTTNG + help + Enable the LTTng system call extraction helper which prints the list + of enabled system calls, along with their signature, to dmesg. This + is not meant for mainline; it is a development helper. + source "lttng/src/tests/Kconfig" diff --git a/src/lttng-syscalls-extractor.c b/src/lttng-syscalls-extractor.c new file mode 100644 index 00000000..3fba1a94 --- /dev/null +++ b/src/lttng-syscalls-extractor.c @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng-syscalls-extractor.c + * + * Dump syscall metadata to console. + * + * Copyright 2011 Mathieu Desnoyers + * Copyright 2011 EfficiOS Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef CONFIG_FTRACE_SYSCALLS +#error "You need to set CONFIG_FTRACE_SYSCALLS=y" +#endif + +#ifndef CONFIG_KALLSYMS_ALL +#error "You need to set CONFIG_KALLSYMS_ALL=y" +#endif + +/* + * The 'ident' parameter is prepended to each printk line to help + * extract the proper lines from dmesg. + */ +static char *ident = ""; +module_param(ident, charp, 0); + +static struct syscall_metadata **__start_syscalls_metadata; +static struct syscall_metadata **__stop_syscalls_metadata; + +static __init +struct syscall_metadata *find_syscall_meta(unsigned long syscall) +{ + struct syscall_metadata **iter; + + for (iter = __start_syscalls_metadata; + iter < __stop_syscalls_metadata; iter++) { + if ((*iter)->syscall_nr == syscall) + return (*iter); + } + return NULL; +} + +int init_module(void) +{ + struct syscall_metadata *meta; + int i; + + __start_syscalls_metadata = (void *) wrapper_kallsyms_lookup_name("__start_syscalls_metadata"); + __stop_syscalls_metadata = (void *) wrapper_kallsyms_lookup_name("__stop_syscalls_metadata"); + + printk("%s---START---\n", ident); + for (i = 0; i < NR_syscalls; i++) { + int j; + + meta = find_syscall_meta(i); + if (!meta) + continue; + printk("%ssyscall %s nr %d nbargs %d ", + ident, meta->name, meta->syscall_nr, meta->nb_args); + printk(KERN_CONT "types: ("); + for (j = 0; j < meta->nb_args; j++) { + if (j > 0) + printk(KERN_CONT ", "); + printk(KERN_CONT "%s", meta->types[j]); + } + printk(KERN_CONT ") "); + printk(KERN_CONT "args: ("); + for (j = 0; j < meta->nb_args; j++) { + if (j > 0) + printk(KERN_CONT ", "); + printk(KERN_CONT "%s", meta->args[j]); + } + printk(KERN_CONT ")\n"); + } + printk("%s---END---\n", ident); + + /* + * This module always fails to load. + */ + return -1; +} + +void cleanup_module(void) +{ +} + +MODULE_LICENSE("GPL");