bc82195a |
1 | /* probe.c |
2 | * |
3 | * Loads a function at a marker call site. |
4 | * |
5 | * (C) Copyright 2006 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> |
6 | * |
7 | * This file is released under the GPLv2. |
8 | * See the file COPYING for more details. |
9 | */ |
10 | |
11 | #include <linux/marker.h> |
12 | #include <linux/module.h> |
13 | #include <linux/kallsyms.h> |
14 | #include <linux/linkage.h> |
15 | |
16 | |
17 | int value; |
18 | void *ptr; |
19 | |
20 | /* function to install */ |
21 | #define DO_MARK1_FORMAT "%d %p" |
22 | asmlinkage void do_mark1(const char *format, int pavalue, void *paptr) |
23 | { |
24 | value = pavalue; |
25 | ptr = paptr; |
26 | } |
27 | |
28 | int init_module(void) |
29 | { |
30 | int result; |
31 | result = marker_set_probe("subsys_mark1", DO_MARK1_FORMAT, |
32 | (marker_probe_func*)do_mark1); |
33 | if(!result) goto end; |
34 | |
35 | return 0; |
36 | |
37 | end: |
38 | marker_remove_probe((marker_probe_func*)do_mark1); |
39 | return -EPERM; |
40 | } |
41 | |
42 | void cleanup_module(void) |
43 | { |
44 | marker_remove_probe((marker_probe_func*)do_mark1); |
45 | } |
46 | |
47 | MODULE_LICENSE("GPL"); |
48 | MODULE_AUTHOR("Mathieu Desnoyers"); |
49 | MODULE_DESCRIPTION("Probe"); |