[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120401160359.4502.88900.stgit@shimauta>
Date: Mon, 02 Apr 2012 01:03:59 +0900
From: Masami Hiramatsu <masami.hiramatsu@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Huang Ying <ying.huang@...el.com>,
Ananth N Mavinakayanahalli <ananth@...ibm.com>,
Frederic Weisbecker <fweisbec@...il.com>,
"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
Jason Wessel <jason.wessel@...driver.com>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: [RFC PATCH -tip 10/16] x86/disasm: Indicate modified instructions
Show modified comment instead of disassembled code when
given instruction has been modified by kprobes or kdb.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu@...il.com>
---
arch/x86/kernel/kdebugfs.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
index 5da917d..eccd718 100644
--- a/arch/x86/kernel/kdebugfs.c
+++ b/arch/x86/kernel/kdebugfs.c
@@ -296,13 +296,32 @@ static int disasm_seq_show(struct seq_file *m, void *v)
u8 kbuf[MAX_INSN_SIZE];
struct insn insn;
void *p;
+ int i, ret;
+ /* recover if the instruction is probed */
p = (void *)recover_probed_instruction(kbuf, (unsigned long)v);
kernel_insn_init(&insn, p);
insn_get_length(&insn);
insn.kaddr = v;
- snprint_assembly(buf, DISASM_BUF_LEN, &insn, DISASM_PR_ALL);
- seq_printf(m, "%s", buf);
+
+ seq_printf(m, "%p: ", v);
+ for (i = 0; i < MAX_INSN_SIZE / 2 && i < insn.length; i++)
+ seq_printf(m, "%02x ", ((u8 *)v)[i]);
+ if (i != MAX_INSN_SIZE / 2)
+ seq_printf(m, "%*s", 3 * (MAX_INSN_SIZE / 2 - i), " ");
+
+ /* print assembly code */
+ ret = disassemble(buf, DISASM_BUF_LEN, &insn);
+ if (ret < 0)
+ return ret;
+ seq_printf(m, "%s%s\n", (p != v) ? "(probed)" : "", buf);
+
+ if (i < insn.length) {
+ seq_printf(m, "%p: ", v + i);
+ for (; i < insn.length - 1; i++)
+ seq_printf(m, "%02x ", ((u8 *)v)[i]);
+ seq_printf(m, "%02x\n", ((u8 *)v)[i]);
+ }
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists