test mark update
[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"
2e871717 17asmlinkage void do_mark1(const char *format, int value)
3bb4bef8 18{
0efac34c 19 __mark_check_format(DO_MARK1_FORMAT, value);
3bb4bef8 20 printk("value is %d\n", value);
21}
22
abfc2016 23#define DO_MARK2_FORMAT "%d %s"
24asmlinkage void do_mark2(const char *format, int value, const char *string)
25{
26 __mark_check_format(DO_MARK2_FORMAT, value, string);
27 printk("value is %d %s\n", value, string);
28}
29
30#define DO_MARK3_FORMAT "%d %s %s"
31asmlinkage void do_mark3(const char *format, int value, const char *s1,
32 const char *s2)
33{
34 __mark_check_format(DO_MARK3_FORMAT, value, s1, s2);
35 printk("value is %d %s %s\n", value, s1, s2);
36}
37
3bb4bef8 38int init_module(void)
39{
abfc2016 40 int result;
41 result = marker_set_probe("subsys_mark1", DO_MARK1_FORMAT,
42 (marker_probe_func*)do_mark1);
9576ead5 43 if(!result) goto end;
abfc2016 44 result = marker_set_probe("subsys_mark2", DO_MARK2_FORMAT,
45 (marker_probe_func*)do_mark2);
9576ead5 46 if(!result) goto cleanup1;
abfc2016 47 result = marker_set_probe("subsys_mark3", DO_MARK3_FORMAT,
48 (marker_probe_func*)do_mark3);
9576ead5 49 if(!result) goto cleanup2;
abfc2016 50
9576ead5 51 return 0;
abfc2016 52
53cleanup2:
9576ead5 54 marker_remove_probe((marker_probe_func*)do_mark2);
abfc2016 55cleanup1:
9576ead5 56 marker_remove_probe((marker_probe_func*)do_mark1);
abfc2016 57end:
9576ead5 58 return -EPERM;
3bb4bef8 59}
60
61void cleanup_module(void)
62{
9576ead5 63 marker_remove_probe((marker_probe_func*)do_mark1);
64 marker_remove_probe((marker_probe_func*)do_mark2);
65 marker_remove_probe((marker_probe_func*)do_mark3);
3bb4bef8 66}
67
68MODULE_LICENSE("GPL");
69MODULE_AUTHOR("Mathieu Desnoyers");
70MODULE_DESCRIPTION("Probe");
71
This page took 0.031757 seconds and 4 git commands to generate.