move everything out of trunk
[lttv.git] / tests / kernel / probe.c
CommitLineData
3bb4bef8 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 */
0efac34c 16#define DO_MARK1_FORMAT "%d"
996926d1 17void do_mark1(const char *format, ...)
3bb4bef8 18{
996926d1 19 va_list ap;
20 int value;
21
22 va_start(ap, format);
23 value = va_arg(ap, int);
3bb4bef8 24 printk("value is %d\n", value);
996926d1 25
26 va_end(ap);
3bb4bef8 27}
28
996926d1 29void do_mark2(const char *format, ...)
abfc2016 30{
996926d1 31 va_list ap;
32
33 va_start(ap, format);
34 vprintk(format, ap);
35 va_end(ap);
36 printk("\n");
abfc2016 37}
38
39#define DO_MARK3_FORMAT "%d %s %s"
996926d1 40void do_mark3(const char *format, ...)
abfc2016 41{
996926d1 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);
abfc2016 54}
55
3bb4bef8 56int init_module(void)
57{
abfc2016 58 int result;
59 result = marker_set_probe("subsys_mark1", DO_MARK1_FORMAT,
60 (marker_probe_func*)do_mark1);
9576ead5 61 if(!result) goto end;
996926d1 62 result = marker_set_probe("subsys_mark2", NULL,
abfc2016 63 (marker_probe_func*)do_mark2);
9576ead5 64 if(!result) goto cleanup1;
abfc2016 65 result = marker_set_probe("subsys_mark3", DO_MARK3_FORMAT,
66 (marker_probe_func*)do_mark3);
9576ead5 67 if(!result) goto cleanup2;
abfc2016 68
9576ead5 69 return 0;
abfc2016 70
71cleanup2:
9576ead5 72 marker_remove_probe((marker_probe_func*)do_mark2);
abfc2016 73cleanup1:
9576ead5 74 marker_remove_probe((marker_probe_func*)do_mark1);
abfc2016 75end:
9576ead5 76 return -EPERM;
3bb4bef8 77}
78
79void cleanup_module(void)
80{
9576ead5 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);
3bb4bef8 84}
85
86MODULE_LICENSE("GPL");
87MODULE_AUTHOR("Mathieu Desnoyers");
88MODULE_DESCRIPTION("Probe");
This page took 0.042923 seconds and 4 git commands to generate.