diff options
author | Huang Shijie <shijie.huang@arm.com> | 2016-05-20 20:04:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-20 20:58:30 -0400 |
commit | d04659ac94528e9224dbf1aed37dd11dd952cacc (patch) | |
tree | ae3a0e641fc2d15309ac25fc40143cd9617b08c0 /samples | |
parent | 603ac5df86df5bfd26ed4d9c310dd196b07590ae (diff) |
samples/kprobes: add a new module parameter
Add a new module parameter which can be used as the symbol name.
Without this patch, we can only test the "_do_fork" function with this
kernel module. With this patch, the module becomes more flexible; we
can test any functions with this module with
# insmod kprobe_example.ko symbol="xxx"
Link: http://lkml.kernel.org/r/1463535417-29637-1-git-send-email-shijie.huang@arm.com
Signed-off-by: Huang Shijie <shijie.huang@arm.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Steve Capper <steve.capper@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/kprobes/kprobe_example.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c index 727eb21c9c56..2bb190dee66f 100644 --- a/samples/kprobes/kprobe_example.c +++ b/samples/kprobes/kprobe_example.c | |||
@@ -14,9 +14,13 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/kprobes.h> | 15 | #include <linux/kprobes.h> |
16 | 16 | ||
17 | #define MAX_SYMBOL_LEN 64 | ||
18 | static char symbol[MAX_SYMBOL_LEN] = "_do_fork"; | ||
19 | module_param_string(symbol, symbol, sizeof(symbol), 0644); | ||
20 | |||
17 | /* For each probe you need to allocate a kprobe structure */ | 21 | /* For each probe you need to allocate a kprobe structure */ |
18 | static struct kprobe kp = { | 22 | static struct kprobe kp = { |
19 | .symbol_name = "_do_fork", | 23 | .symbol_name = symbol, |
20 | }; | 24 | }; |
21 | 25 | ||
22 | /* kprobe pre_handler: called just before the probed instruction is executed */ | 26 | /* kprobe pre_handler: called just before the probed instruction is executed */ |