Fix: don't do 0 byte event reservation
[lttng-modules.git] / instrumentation / syscalls / lttng-syscalls-extractor / lttng-syscalls-extractor.c
CommitLineData
5fee13fd 1/*
886d51a3
MD
2 * lttng-syscalls-extractor.c
3 *
4 * Dump syscall metadata to console.
5 *
5fee13fd
MD
6 * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 * Copyright 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
8 *
886d51a3
MD
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.
5fee13fd 18 *
886d51a3
MD
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.
5fee13fd
MD
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
35#ifndef CONFIG_FTRACE_SYSCALLS
36#error "You need to set CONFIG_FTRACE_SYSCALLS=y"
37#endif
38
bc55cda3
MD
39#ifndef CONFIG_KALLSYMS_ALL
40#error "You need to set CONFIG_KALLSYMS_ALL=y"
41#endif
42
5fee13fd
MD
43static struct syscall_metadata **__start_syscalls_metadata;
44static struct syscall_metadata **__stop_syscalls_metadata;
45
46static __init
47struct syscall_metadata *find_syscall_meta(unsigned long syscall)
48{
49 struct syscall_metadata **iter;
50
51 for (iter = __start_syscalls_metadata;
52 iter < __stop_syscalls_metadata; iter++) {
53 if ((*iter)->syscall_nr == syscall)
54 return (*iter);
55 }
56 return NULL;
57}
58
59int init_module(void)
60{
61 struct syscall_metadata *meta;
62 int i;
63
64 __start_syscalls_metadata = (void *) kallsyms_lookup_name("__start_syscalls_metadata");
65 __stop_syscalls_metadata = (void *) kallsyms_lookup_name("__stop_syscalls_metadata");
66
67 for (i = 0; i < NR_syscalls; i++) {
68 int j;
69
70 meta = find_syscall_meta(i);
71 if (!meta)
72 continue;
73 printk("syscall %s nr %d nbargs %d ",
74 meta->name, meta->syscall_nr, meta->nb_args);
75 printk("types: (");
76 for (j = 0; j < meta->nb_args; j++) {
77 if (j > 0)
78 printk(", ");
79 printk("%s", meta->types[j]);
80 }
81 printk(") ");
82 printk("args: (");
83 for (j = 0; j < meta->nb_args; j++) {
84 if (j > 0)
85 printk(", ");
86 printk("%s", meta->args[j]);
87 }
88 printk(")\n");
89 }
90 printk("SUCCESS\n");
91
92 return -1;
93}
94
95void cleanup_module(void)
96{
97}
98
99MODULE_LICENSE("GPL");
This page took 0.027602 seconds and 4 git commands to generate.