e88bb5d63e6f8ae525e4e93b361a98ffc01d3223
[lttng-modules.git] / instrumentation / syscalls / lttng-syscalls-extractor / lttng-syscalls-extractor.c
1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
3 * lttng-syscalls-extractor.c
4 *
5 * Dump syscall metadata to console.
6 *
7 * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Copyright 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
9 */
10
11 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/types.h>
14 #include <linux/list.h>
15 #include <linux/err.h>
16 #include <linux/slab.h>
17 #include <linux/kallsyms.h>
18 #include <linux/dcache.h>
19 #include <linux/ftrace_event.h>
20 #include <trace/syscall.h>
21 #include <asm/syscall.h>
22
23 #ifndef CONFIG_FTRACE_SYSCALLS
24 #error "You need to set CONFIG_FTRACE_SYSCALLS=y"
25 #endif
26
27 #ifndef CONFIG_KALLSYMS_ALL
28 #error "You need to set CONFIG_KALLSYMS_ALL=y"
29 #endif
30
31 static struct syscall_metadata **__start_syscalls_metadata;
32 static struct syscall_metadata **__stop_syscalls_metadata;
33
34 static __init
35 struct syscall_metadata *find_syscall_meta(unsigned long syscall)
36 {
37 struct syscall_metadata **iter;
38
39 for (iter = __start_syscalls_metadata;
40 iter < __stop_syscalls_metadata; iter++) {
41 if ((*iter)->syscall_nr == syscall)
42 return (*iter);
43 }
44 return NULL;
45 }
46
47 int init_module(void)
48 {
49 struct syscall_metadata *meta;
50 int i;
51
52 __start_syscalls_metadata = (void *) kallsyms_lookup_name("__start_syscalls_metadata");
53 __stop_syscalls_metadata = (void *) kallsyms_lookup_name("__stop_syscalls_metadata");
54
55 for (i = 0; i < NR_syscalls; i++) {
56 int j;
57
58 meta = find_syscall_meta(i);
59 if (!meta)
60 continue;
61 printk("syscall %s nr %d nbargs %d ",
62 meta->name, meta->syscall_nr, meta->nb_args);
63 printk("types: (");
64 for (j = 0; j < meta->nb_args; j++) {
65 if (j > 0)
66 printk(", ");
67 printk("%s", meta->types[j]);
68 }
69 printk(") ");
70 printk("args: (");
71 for (j = 0; j < meta->nb_args; j++) {
72 if (j > 0)
73 printk(", ");
74 printk("%s", meta->args[j]);
75 }
76 printk(")\n");
77 }
78 printk("SUCCESS\n");
79
80 return -1;
81 }
82
83 void cleanup_module(void)
84 {
85 }
86
87 MODULE_LICENSE("GPL");
This page took 0.030195 seconds and 3 git commands to generate.