diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-09-11 04:34:46 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-09-11 04:34:46 -0300 |
commit | 863981e96738983919de841ec669e157e6bdaeb0 (patch) | |
tree | d6d89a12e7eb8017837c057935a2271290907f76 /samples/kprobes | |
parent | 8dec7c70575785729a6a9e6719a955e9c545bcab (diff) |
Linux-libre 4.7.1-gnupck-4.7.1-gnu
Diffstat (limited to 'samples/kprobes')
-rw-r--r-- | samples/kprobes/jprobe_example.c | 2 | ||||
-rw-r--r-- | samples/kprobes/kprobe_example.c | 38 |
2 files changed, 22 insertions, 18 deletions
diff --git a/samples/kprobes/jprobe_example.c b/samples/kprobes/jprobe_example.c index c285a3b8a..c3108bb15 100644 --- a/samples/kprobes/jprobe_example.c +++ b/samples/kprobes/jprobe_example.c @@ -25,7 +25,7 @@ /* Proxy routine having the same arguments as actual _do_fork() routine */ static long j_do_fork(unsigned long clone_flags, unsigned long stack_start, unsigned long stack_size, int __user *parent_tidptr, - int __user *child_tidptr) + int __user *child_tidptr, unsigned long tls) { pr_info("jprobe: clone_flags = 0x%lx, stack_start = 0x%lx " "stack_size = 0x%lx\n", clone_flags, stack_start, stack_size); diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_example.c index 727eb21c9..ed0ca0c07 100644 --- a/samples/kprobes/kprobe_example.c +++ b/samples/kprobes/kprobe_example.c @@ -14,33 +14,37 @@ #include <linux/module.h> #include <linux/kprobes.h> +#define MAX_SYMBOL_LEN 64 +static char symbol[MAX_SYMBOL_LEN] = "_do_fork"; +module_param_string(symbol, symbol, sizeof(symbol), 0644); + /* For each probe you need to allocate a kprobe structure */ static struct kprobe kp = { - .symbol_name = "_do_fork", + .symbol_name = symbol, }; /* kprobe pre_handler: called just before the probed instruction is executed */ static int handler_pre(struct kprobe *p, struct pt_regs *regs) { #ifdef CONFIG_X86 - printk(KERN_INFO "pre_handler: p->addr = 0x%p, ip = %lx," + printk(KERN_INFO "<%s> pre_handler: p->addr = 0x%p, ip = %lx," " flags = 0x%lx\n", - p->addr, regs->ip, regs->flags); + p->symbol_name, p->addr, regs->ip, regs->flags); #endif #ifdef CONFIG_PPC - printk(KERN_INFO "pre_handler: p->addr = 0x%p, nip = 0x%lx," + printk(KERN_INFO "<%s> pre_handler: p->addr = 0x%p, nip = 0x%lx," " msr = 0x%lx\n", - p->addr, regs->nip, regs->msr); + p->symbol_name, p->addr, regs->nip, regs->msr); #endif #ifdef CONFIG_MIPS - printk(KERN_INFO "pre_handler: p->addr = 0x%p, epc = 0x%lx," + printk(KERN_INFO "<%s> pre_handler: p->addr = 0x%p, epc = 0x%lx," " status = 0x%lx\n", - p->addr, regs->cp0_epc, regs->cp0_status); + p->symbol_name, p->addr, regs->cp0_epc, regs->cp0_status); #endif #ifdef CONFIG_TILEGX - printk(KERN_INFO "pre_handler: p->addr = 0x%p, pc = 0x%lx," + printk(KERN_INFO "<%s> pre_handler: p->addr = 0x%p, pc = 0x%lx," " ex1 = 0x%lx\n", - p->addr, regs->pc, regs->ex1); + p->symbol_name, p->addr, regs->pc, regs->ex1); #endif /* A dump_stack() here will give a stack backtrace */ @@ -52,20 +56,20 @@ static void handler_post(struct kprobe *p, struct pt_regs *regs, unsigned long flags) { #ifdef CONFIG_X86 - printk(KERN_INFO "post_handler: p->addr = 0x%p, flags = 0x%lx\n", - p->addr, regs->flags); + printk(KERN_INFO "<%s> post_handler: p->addr = 0x%p, flags = 0x%lx\n", + p->symbol_name, p->addr, regs->flags); #endif #ifdef CONFIG_PPC - printk(KERN_INFO "post_handler: p->addr = 0x%p, msr = 0x%lx\n", - p->addr, regs->msr); + printk(KERN_INFO "<%s> post_handler: p->addr = 0x%p, msr = 0x%lx\n", + p->symbol_name, p->addr, regs->msr); #endif #ifdef CONFIG_MIPS - printk(KERN_INFO "post_handler: p->addr = 0x%p, status = 0x%lx\n", - p->addr, regs->cp0_status); + printk(KERN_INFO "<%s> post_handler: p->addr = 0x%p, status = 0x%lx\n", + p->symbol_name, p->addr, regs->cp0_status); #endif #ifdef CONFIG_TILEGX - printk(KERN_INFO "post_handler: p->addr = 0x%p, ex1 = 0x%lx\n", - p->addr, regs->ex1); + printk(KERN_INFO "<%s> post_handler: p->addr = 0x%p, ex1 = 0x%lx\n", + p->symbol_name, p->addr, regs->ex1); #endif } |