samples/kprobes: Add LoongArch support
authorTiezhu Yang <yangtiezhu@loongson.cn>
Sat, 25 Feb 2023 07:52:57 +0000 (15:52 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Sat, 25 Feb 2023 14:12:17 +0000 (22:12 +0800)
Add LoongArch specific info in handler_pre() and handler_post().

Tested-by: Jeff Xie <xiehuan09@gmail.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
samples/kprobes/kprobe_example.c

index fd346f5..ef44c61 100644 (file)
@@ -55,6 +55,10 @@ static int __kprobes handler_pre(struct kprobe *p, struct pt_regs *regs)
        pr_info("<%s> p->addr, 0x%p, ip = 0x%lx, flags = 0x%lx\n",
                p->symbol_name, p->addr, regs->psw.addr, regs->flags);
 #endif
+#ifdef CONFIG_LOONGARCH
+       pr_info("<%s> p->addr = 0x%p, era = 0x%lx, estat = 0x%lx\n",
+               p->symbol_name, p->addr, regs->csr_era, regs->csr_estat);
+#endif
 
        /* A dump_stack() here will give a stack backtrace */
        return 0;
@@ -92,6 +96,10 @@ static void __kprobes handler_post(struct kprobe *p, struct pt_regs *regs,
        pr_info("<%s> p->addr, 0x%p, flags = 0x%lx\n",
                p->symbol_name, p->addr, regs->flags);
 #endif
+#ifdef CONFIG_LOONGARCH
+       pr_info("<%s> p->addr = 0x%p, estat = 0x%lx\n",
+               p->symbol_name, p->addr, regs->csr_estat);
+#endif
 }
 
 static int __init kprobe_init(void)