71197468986377b30153683cd7f81bee6f01ee4a
[lttng-modules.git] / instrumentation / syscalls / lttng-syscalls-extractor / lttng-syscalls-extractor.c
1 /*
2 * lttng-syscalls-extractor.c
3 *
4 * Dump syscall metadata to console.
5 *
6 * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 * Copyright 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24 #include <linux/module.h>
25 #include <linux/kernel.h>
26 #include <linux/types.h>
27 #include <linux/list.h>
28 #include <linux/err.h>
29 #include <linux/slab.h>
30 #include <linux/kallsyms.h>
31 #include <linux/dcache.h>
32 #include <linux/ftrace_event.h>
33 #include <trace/syscall.h>
34 #include <asm/syscall.h>
35
36 #ifndef CONFIG_FTRACE_SYSCALLS
37 #error "You need to set CONFIG_FTRACE_SYSCALLS=y"
38 #endif
39
40 #ifndef CONFIG_KALLSYMS_ALL
41 #error "You need to set CONFIG_KALLSYMS_ALL=y"
42 #endif
43
44 static struct syscall_metadata **__start_syscalls_metadata;
45 static struct syscall_metadata **__stop_syscalls_metadata;
46
47 static __init
48 struct syscall_metadata *find_syscall_meta(unsigned long syscall)
49 {
50 struct syscall_metadata **iter;
51
52 for (iter = __start_syscalls_metadata;
53 iter < __stop_syscalls_metadata; iter++) {
54 if ((*iter)->syscall_nr == syscall)
55 return (*iter);
56 }
57 return NULL;
58 }
59
60 int init_module(void)
61 {
62 struct syscall_metadata *meta;
63 int i;
64
65 __start_syscalls_metadata = (void *) kallsyms_lookup_name("__start_syscalls_metadata");
66 __stop_syscalls_metadata = (void *) kallsyms_lookup_name("__stop_syscalls_metadata");
67
68 for (i = 0; i < NR_syscalls; i++) {
69 int j;
70
71 meta = find_syscall_meta(i);
72 if (!meta)
73 continue;
74 printk("syscall %s nr %d nbargs %d ",
75 meta->name, meta->syscall_nr, meta->nb_args);
76 printk("types: (");
77 for (j = 0; j < meta->nb_args; j++) {
78 if (j > 0)
79 printk(", ");
80 printk("%s", meta->types[j]);
81 }
82 printk(") ");
83 printk("args: (");
84 for (j = 0; j < meta->nb_args; j++) {
85 if (j > 0)
86 printk(", ");
87 printk("%s", meta->args[j]);
88 }
89 printk(")\n");
90 }
91 printk("SUCCESS\n");
92
93 return -1;
94 }
95
96 void cleanup_module(void)
97 {
98 }
99
100 MODULE_LICENSE("GPL");
This page took 0.030116 seconds and 3 git commands to generate.