[RFC PATCH -tip 08/16] x86/kprobes: Recover breakpoint instruction ifKGDB knows

From: Masami Hiramatsu
Date: Sun Apr 01 2012 - 12:03:47 EST


Recover a breakpoint instruction which KGDB has put.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu@xxxxxxxxx>
---
arch/x86/kernel/kprobes.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index e213fc8..ddd21b8 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -49,6 +49,7 @@
#include <linux/kdebug.h>
#include <linux/kallsyms.h>
#include <linux/ftrace.h>
+#include <linux/kgdb.h>

#include <asm/cacheflush.h>
#include <asm/desc.h>
@@ -252,6 +253,14 @@ unsigned long recover_probed_instruction(kprobe_opcode_t *buf, unsigned long add
{
unsigned long __addr;

+#ifdef CONFIG_KGDB
+ /* Recover if kgdb has put a breakpoint */
+ if (kgdb_get_saved_instr(addr, buf)) {
+ memcpy(buf + BREAK_INSTR_SIZE, (void *)addr + BREAK_INSTR_SIZE,
+ (MAX_INSN_SIZE - BREAK_INSTR_SIZE) * sizeof(kprobe_opcode_t));
+ return (unsigned long)buf;
+ }
+#endif
__addr = __recover_optprobed_insn(buf, addr);
if (__addr != addr)
return __addr;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/