Rename "tsc" to "timestamp"
[lttng-modules.git] / src / lttng-syscalls-extractor.c
1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
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 EfficiOS Inc.
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/trace_events.h>
20 #include <linux/kprobes.h>
21 #include <trace/syscall.h>
22 #include <asm/syscall.h>
23 #include <wrapper/kallsyms.h>
24
25 #ifndef CONFIG_FTRACE_SYSCALLS
26 #error "You need to set CONFIG_FTRACE_SYSCALLS=y"
27 #endif
28
29 #ifndef CONFIG_KALLSYMS_ALL
30 #error "You need to set CONFIG_KALLSYMS_ALL=y"
31 #endif
32
33 /*
34 * The 'ident' parameter is prepended to each printk line to help
35 * extract the proper lines from dmesg.
36 */
37 static char *ident = "";
38 module_param(ident, charp, 0);
39
40 static struct syscall_metadata **__start_syscalls_metadata;
41 static struct syscall_metadata **__stop_syscalls_metadata;
42
43 static __init
44 struct syscall_metadata *find_syscall_meta(unsigned long syscall)
45 {
46 struct syscall_metadata **iter;
47
48 for (iter = __start_syscalls_metadata;
49 iter < __stop_syscalls_metadata; iter++) {
50 if ((*iter)->syscall_nr == syscall)
51 return (*iter);
52 }
53 return NULL;
54 }
55
56 int init_module(void)
57 {
58 struct syscall_metadata *meta;
59 int i;
60
61 __start_syscalls_metadata = (void *) wrapper_kallsyms_lookup_name("__start_syscalls_metadata");
62 __stop_syscalls_metadata = (void *) wrapper_kallsyms_lookup_name("__stop_syscalls_metadata");
63
64 printk("%s---START---\n", ident);
65 for (i = 0; i < NR_syscalls; i++) {
66 int j;
67
68 meta = find_syscall_meta(i);
69 if (!meta)
70 continue;
71 printk("%ssyscall %s nr %d nbargs %d ",
72 ident, meta->name, meta->syscall_nr, meta->nb_args);
73 printk(KERN_CONT "types: (");
74 for (j = 0; j < meta->nb_args; j++) {
75 if (j > 0)
76 printk(KERN_CONT ", ");
77 printk(KERN_CONT "%s", meta->types[j]);
78 }
79 printk(KERN_CONT ") ");
80 printk(KERN_CONT "args: (");
81 for (j = 0; j < meta->nb_args; j++) {
82 if (j > 0)
83 printk(KERN_CONT ", ");
84 printk(KERN_CONT "%s", meta->args[j]);
85 }
86 printk(KERN_CONT ")\n");
87 }
88 printk("%s---END---\n", ident);
89
90 /*
91 * This module always fails to load.
92 */
93 return -1;
94 }
95
96 void cleanup_module(void)
97 {
98 }
99
100 MODULE_LICENSE("GPL");
This page took 0.031525 seconds and 4 git commands to generate.