5686c21052f49974c86e86253748b39f8ae8d40b
5 * Loads a function at a marker call site.
7 * (C) Copyright 2006 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
9 * This file is released under the GPLv2.
10 * See the file COPYING for more details.
13 #include <linux/marker.h>
14 #include <linux/module.h>
15 #include <linux/kallsyms.h>
17 /* function to install */
18 void do_mark1(const char *format
, int value
)
20 printk("value is %d\n", value
);
24 #define PROBE_NAME subsys_mark1
26 #define CALL __mark_subsys_mark1_call
27 #define JUMP_OVER __mark_subsys_mark1_jump_over
28 #define JUMP_CALL __mark_subsys_mark1_jump_call
29 #define JUMP_INLINE __mark_subsys_mark1_jump_inline
31 static void *saved_over
;
33 static void **target_mark_call
;
34 static void **target_mark_jump_over
;
35 static void **target_mark_jump_call
;
36 static void **target_mark_jump_inline
;
38 void show_symbol_pointers(void)
40 printk("Marker loader : Loading symbols...\n");
41 printk(" %s %p %p\n", __stringify(CALL
), target_mark_call
,
42 target_mark_call
?*target_mark_call
:0x0);
43 printk(" %s %p %p\n", __stringify(JUMP_OVER
), target_mark_jump_over
,
44 target_mark_jump_over
?*target_mark_jump_over
:0x0);
45 printk(" %s %p %p\n", __stringify(JUMP_CALL
), target_mark_jump_call
,
46 target_mark_jump_call
?*target_mark_jump_call
:0x0);
47 printk(" %s %p %p\n", __stringify(JUMP_INLINE
), target_mark_jump_inline
,
48 target_mark_jump_inline
?*target_mark_jump_inline
:0x0);
51 int mark_install_hook(void)
53 target_mark_call
= (void**)kallsyms_lookup_name(__stringify(CALL
));
54 target_mark_jump_over
= (void**)kallsyms_lookup_name(__stringify(JUMP_OVER
));
55 target_mark_jump_call
= (void**)kallsyms_lookup_name(__stringify(JUMP_CALL
));
56 target_mark_jump_inline
= (void**)kallsyms_lookup_name(__stringify(JUMP_INLINE
));
58 show_symbol_pointers();
60 if(!(target_mark_call
&& target_mark_jump_over
&& target_mark_jump_call
&&
61 target_mark_jump_inline
)) {
62 printk("Target symbols missing in kallsyms.\n");
66 printk("Installing hook\n");
67 *target_mark_call
= (void*)do_mark1
;
68 saved_over
= *target_mark_jump_over
;
69 *target_mark_jump_over
= *target_mark_jump_call
;
76 return mark_install_hook();
79 void cleanup_module(void)
81 printk("Removing hook\n");
82 *target_mark_jump_over
= saved_over
;
83 *target_mark_call
= __mark_empty_function
;
85 /* Wait for instrumentation functions to return before quitting */
89 MODULE_LICENSE("GPL");
90 MODULE_AUTHOR("Mathieu Desnoyers");
91 MODULE_DESCRIPTION("Marker Loader");
This page took 0.04161 seconds and 4 git commands to generate.