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 CALL __mark_subsys_mark1_call
25 //#define JUMP_OVER __mark_subsys_mark1_jump_over
26 //#define JUMP_CALL __mark_subsys_mark1_jump_call
27 //#define JUMP_INLINE __mark_subsys_mark1_jump_inline
29 static void *saved_over
;
31 static void **target_mark_call
;
32 static void **target_mark_jump_over
;
33 static void **target_mark_jump_call
;
34 static void **target_mark_jump_inline
;
36 void show_symbol_pointers(void)
38 printk("Marker loader : Loading symbols...\n");
39 printk(" %s %p %p\n", __stringify(CALL
), target_mark_call
,
40 target_mark_call
?*target_mark_call
:0x0);
41 printk(" %s %p %p\n", __stringify(JUMP_OVER
), target_mark_jump_over
,
42 target_mark_jump_over
?*target_mark_jump_over
:0x0);
43 printk(" %s %p %p\n", __stringify(JUMP_CALL
), target_mark_jump_call
,
44 target_mark_jump_call
?*target_mark_jump_call
:0x0);
45 printk(" %s %p %p\n", __stringify(JUMP_INLINE
), target_mark_jump_inline
,
46 target_mark_jump_inline
?*target_mark_jump_inline
:0x0);
49 int mark_install_hook(void)
51 target_mark_call
= (void**)kallsyms_lookup_name(__stringify(CALL
));
52 target_mark_jump_over
= (void**)kallsyms_lookup_name(__stringify(JUMP_OVER
));
53 target_mark_jump_call
= (void**)kallsyms_lookup_name(__stringify(JUMP_CALL
));
54 target_mark_jump_inline
= (void**)kallsyms_lookup_name(__stringify(JUMP_INLINE
));
56 show_symbol_pointers();
58 if(!(target_mark_call
&& target_mark_jump_over
&& target_mark_jump_call
&&
59 target_mark_jump_inline
)) {
60 printk("Target symbols missing in kallsyms.\n");
64 printk("Installing hook\n");
65 *target_mark_call
= (void*)do_mark1
;
66 saved_over
= *target_mark_jump_over
;
67 *target_mark_jump_over
= *target_mark_jump_call
;
74 return mark_install_hook();
77 void cleanup_module(void)
79 printk("Removing hook\n");
80 *target_mark_jump_over
= saved_over
;
81 *target_mark_call
= __mark_empty_function
;
83 /* Wait for instrumentation functions to return before quitting */
87 MODULE_LICENSE("GPL");
88 MODULE_AUTHOR("Mathieu Desnoyers");
89 MODULE_DESCRIPTION("Marker Loader");
This page took 0.0318349999999999 seconds and 5 git commands to generate.