convert from svn repository: remove tags directory
[lttv.git] / trunk / tests / kernel / probe.c
... / ...
CommitLineData
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
15/* function to install */
16#define DO_MARK1_FORMAT "%d"
17void do_mark1(const char *format, ...)
18{
19 va_list ap;
20 int value;
21
22 va_start(ap, format);
23 value = va_arg(ap, int);
24 printk("value is %d\n", value);
25
26 va_end(ap);
27}
28
29void do_mark2(const char *format, ...)
30{
31 va_list ap;
32
33 va_start(ap, format);
34 vprintk(format, ap);
35 va_end(ap);
36 printk("\n");
37}
38
39#define DO_MARK3_FORMAT "%d %s %s"
40void do_mark3(const char *format, ...)
41{
42 va_list ap;
43 int value;
44 const char *s1, *s2;
45
46 va_start(ap, format);
47 value = va_arg(ap, int);
48 s1 = va_arg(ap, const char*);
49 s2 = va_arg(ap, const char *);
50
51 printk("value is %d %s %s\n",
52 value, s1, s2);
53 va_end(ap);
54}
55
56int init_module(void)
57{
58 int result;
59 result = marker_set_probe("subsys_mark1", DO_MARK1_FORMAT,
60 (marker_probe_func*)do_mark1);
61 if(!result) goto end;
62 result = marker_set_probe("subsys_mark2", NULL,
63 (marker_probe_func*)do_mark2);
64 if(!result) goto cleanup1;
65 result = marker_set_probe("subsys_mark3", DO_MARK3_FORMAT,
66 (marker_probe_func*)do_mark3);
67 if(!result) goto cleanup2;
68
69 return 0;
70
71cleanup2:
72 marker_remove_probe((marker_probe_func*)do_mark2);
73cleanup1:
74 marker_remove_probe((marker_probe_func*)do_mark1);
75end:
76 return -EPERM;
77}
78
79void cleanup_module(void)
80{
81 marker_remove_probe((marker_probe_func*)do_mark1);
82 marker_remove_probe((marker_probe_func*)do_mark2);
83 marker_remove_probe((marker_probe_func*)do_mark3);
84}
85
86MODULE_LICENSE("GPL");
87MODULE_AUTHOR("Mathieu Desnoyers");
88MODULE_DESCRIPTION("Probe");
This page took 0.024076 seconds and 4 git commands to generate.