kprobe_example.c (4f2c0a4acffbec01079c28f839422e64ddeff004) | kprobe_example.c (a6484baa3b02b9d71bfd6016e7632dd1c02d5cba) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Here's a sample kernel module showing the use of kprobes to dump a 4 * stack trace and selected registers when kernel_clone() is called. 5 * 6 * For more information on theory of operation of kprobes, see 7 * Documentation/trace/kprobes.rst 8 * --- 41 unchanged lines hidden (view full) --- 50#ifdef CONFIG_RISCV 51 pr_info("<%s> p->addr = 0x%p, pc = 0x%lx, status = 0x%lx\n", 52 p->symbol_name, p->addr, regs->epc, regs->status); 53#endif 54#ifdef CONFIG_S390 55 pr_info("<%s> p->addr, 0x%p, ip = 0x%lx, flags = 0x%lx\n", 56 p->symbol_name, p->addr, regs->psw.addr, regs->flags); 57#endif | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Here's a sample kernel module showing the use of kprobes to dump a 4 * stack trace and selected registers when kernel_clone() is called. 5 * 6 * For more information on theory of operation of kprobes, see 7 * Documentation/trace/kprobes.rst 8 * --- 41 unchanged lines hidden (view full) --- 50#ifdef CONFIG_RISCV 51 pr_info("<%s> p->addr = 0x%p, pc = 0x%lx, status = 0x%lx\n", 52 p->symbol_name, p->addr, regs->epc, regs->status); 53#endif 54#ifdef CONFIG_S390 55 pr_info("<%s> p->addr, 0x%p, ip = 0x%lx, flags = 0x%lx\n", 56 p->symbol_name, p->addr, regs->psw.addr, regs->flags); 57#endif |
58#ifdef CONFIG_LOONGARCH 59 pr_info("<%s> p->addr = 0x%p, era = 0x%lx, estat = 0x%lx\n", 60 p->symbol_name, p->addr, regs->csr_era, regs->csr_estat); 61#endif |
|
58 59 /* A dump_stack() here will give a stack backtrace */ 60 return 0; 61} 62 63/* kprobe post_handler: called after the probed instruction is executed */ 64static void __kprobes handler_post(struct kprobe *p, struct pt_regs *regs, 65 unsigned long flags) --- 21 unchanged lines hidden (view full) --- 87#ifdef CONFIG_RISCV 88 pr_info("<%s> p->addr = 0x%p, status = 0x%lx\n", 89 p->symbol_name, p->addr, regs->status); 90#endif 91#ifdef CONFIG_S390 92 pr_info("<%s> p->addr, 0x%p, flags = 0x%lx\n", 93 p->symbol_name, p->addr, regs->flags); 94#endif | 62 63 /* A dump_stack() here will give a stack backtrace */ 64 return 0; 65} 66 67/* kprobe post_handler: called after the probed instruction is executed */ 68static void __kprobes handler_post(struct kprobe *p, struct pt_regs *regs, 69 unsigned long flags) --- 21 unchanged lines hidden (view full) --- 91#ifdef CONFIG_RISCV 92 pr_info("<%s> p->addr = 0x%p, status = 0x%lx\n", 93 p->symbol_name, p->addr, regs->status); 94#endif 95#ifdef CONFIG_S390 96 pr_info("<%s> p->addr, 0x%p, flags = 0x%lx\n", 97 p->symbol_name, p->addr, regs->flags); 98#endif |
99#ifdef CONFIG_LOONGARCH 100 pr_info("<%s> p->addr = 0x%p, estat = 0x%lx\n", 101 p->symbol_name, p->addr, regs->csr_estat); 102#endif |
|
95} 96 97static int __init kprobe_init(void) 98{ 99 int ret; 100 kp.pre_handler = handler_pre; 101 kp.post_handler = handler_post; 102 --- 18 unchanged lines hidden --- | 103} 104 105static int __init kprobe_init(void) 106{ 107 int ret; 108 kp.pre_handler = handler_pre; 109 kp.post_handler = handler_post; 110 --- 18 unchanged lines hidden --- |