From 35e34aeca4946a0cd1ef7052bd6df6c44f957ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= Date: Mon, 14 Apr 2008 21:28:42 -0700 Subject: kernel_debugger_core: Add sysrq command. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sysrq will run the sysrq command and dump what was added to the kernel log while the command ran. Signed-off-by: Brian Swetland Signed-off-by: Arve Hjønnevåg --- drivers/misc/kernel_debugger.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'drivers/misc/kernel_debugger.c') diff --git a/drivers/misc/kernel_debugger.c b/drivers/misc/kernel_debugger.c index 4c479d8af1c0..f10eaa4dfc45 100644 --- a/drivers/misc/kernel_debugger.c +++ b/drivers/misc/kernel_debugger.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #define dprintf(fmt...) (ctxt->printf(ctxt->cookie, fmt)) @@ -45,10 +46,33 @@ static void do_ps(struct kdbg_ctxt *ctxt) read_unlock(&tasklist_lock); } +int log_buf_copy(char *dest, int idx, int len); +extern int do_syslog(int type, char __user *bug, int count); +static void do_sysrq(struct kdbg_ctxt *ctxt, char rq) +{ + char buf[128]; + int ret; + int idx = 0; + do_syslog(5 /* clear */, NULL, 0); + __handle_sysrq(rq, NULL, 0); + while (1) { + ret = log_buf_copy(buf, idx, sizeof(buf) - 1); + if (ret <= 0) + break; + buf[ret] = 0; + dprintf("%s", buf); + idx += ret; + } +} + int kernel_debugger(struct kdbg_ctxt *ctxt, char *cmd) { if (!strcmp(cmd, "ps")) do_ps(ctxt); + if (!strcmp(cmd, "sysrq")) + do_sysrq(ctxt, 'h'); + if (!strncmp(cmd, "sysrq ", 6)) + do_sysrq(ctxt, cmd[6]); return 0; } -- cgit v1.2.3