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
);
23 static void *saved_over
;
25 static void **target_mark_call
;
26 static void **target_mark_jump_over
;
27 static void **target_mark_jump_call
;
28 static void **target_mark_jump_inline
;
30 void show_symbol_pointers(void)
32 printk("Marker loader : Loading symbols...\n");
33 printk(" %s %p %p\n", __stringify(CALL
), target_mark_call
,
34 target_mark_call
?*target_mark_call
:0x0);
35 printk(" %s %p %p\n", __stringify(JUMP_OVER
), target_mark_jump_over
,
36 target_mark_jump_over
?*target_mark_jump_over
:0x0);
37 printk(" %s %p %p\n", __stringify(JUMP_CALL
), target_mark_jump_call
,
38 target_mark_jump_call
?*target_mark_jump_call
:0x0);
39 printk(" %s %p %p\n", __stringify(JUMP_INLINE
), target_mark_jump_inline
,
40 target_mark_jump_inline
?*target_mark_jump_inline
:0x0);
43 int mark_install_hook(void)
45 target_mark_call
= (void**)kallsyms_lookup_name(__stringify(CALL
));
46 target_mark_jump_over
= (void**)kallsyms_lookup_name(__stringify(JUMP_OVER
));
47 target_mark_jump_call
= (void**)kallsyms_lookup_name(__stringify(JUMP_CALL
));
48 target_mark_jump_inline
= (void**)kallsyms_lookup_name(__stringify(JUMP_INLINE
));
50 show_symbol_pointers();
52 if(!(target_mark_call
&& target_mark_jump_over
&& target_mark_jump_call
&&
53 target_mark_jump_inline
)) {
54 printk("Target symbols missing in kallsyms.\n");
58 printk("Installing hook\n");
59 *target_mark_call
= (void*)do_mark1
;
60 saved_over
= *target_mark_jump_over
;
61 *target_mark_jump_over
= *target_mark_jump_call
;
68 return mark_install_hook();
71 void cleanup_module(void)
73 printk("Removing hook\n");
74 *target_mark_jump_over
= saved_over
;
75 *target_mark_call
= __mark_empty_function
;
77 /* Wait for instrumentation functions to return before quitting */
81 MODULE_LICENSE("GPL");
82 MODULE_AUTHOR("Mathieu Desnoyers");
83 MODULE_DESCRIPTION("Marker Loader");
This page took 0.029925 seconds and 4 git commands to generate.