2 * lttng-syscalls-extractor.c
4 * Dump syscall metadata to console.
6 * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 * Copyright 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
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.
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.
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.
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>
36 #ifndef CONFIG_FTRACE_SYSCALLS
37 #error "You need to set CONFIG_FTRACE_SYSCALLS=y"
40 #ifndef CONFIG_KALLSYMS_ALL
41 #error "You need to set CONFIG_KALLSYMS_ALL=y"
44 static struct syscall_metadata
**__start_syscalls_metadata
;
45 static struct syscall_metadata
**__stop_syscalls_metadata
;
48 struct syscall_metadata
*find_syscall_meta(unsigned long syscall
)
50 struct syscall_metadata
**iter
;
52 for (iter
= __start_syscalls_metadata
;
53 iter
< __stop_syscalls_metadata
; iter
++) {
54 if ((*iter
)->syscall_nr
== syscall
)
62 struct syscall_metadata
*meta
;
65 __start_syscalls_metadata
= (void *) kallsyms_lookup_name("__start_syscalls_metadata");
66 __stop_syscalls_metadata
= (void *) kallsyms_lookup_name("__stop_syscalls_metadata");
68 for (i
= 0; i
< NR_syscalls
; i
++) {
71 meta
= find_syscall_meta(i
);
74 printk("syscall %s nr %d nbargs %d ",
75 meta
->name
, meta
->syscall_nr
, meta
->nb_args
);
77 for (j
= 0; j
< meta
->nb_args
; j
++) {
80 printk("%s", meta
->types
[j
]);
84 for (j
= 0; j
< meta
->nb_args
; j
++) {
87 printk("%s", meta
->args
[j
]);
96 void cleanup_module(void)
100 MODULE_LICENSE("GPL");