Commit f30c2c98 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

uml: dump registers on ptrace or wait failure

Provide a register dump if handle_trap fails.  Abstract out ptrace_dump_regs
since it now has two callers.
Signed-off-by: default avatarJeff Dike <jdike@linux.intel.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2e3f5251
...@@ -44,6 +44,22 @@ int is_skas_winch(int pid, int fd, void *data) ...@@ -44,6 +44,22 @@ int is_skas_winch(int pid, int fd, void *data)
return(1); return(1);
} }
static int ptrace_dump_regs(int pid)
{
unsigned long regs[MAX_REG_NR];
int i;
if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
return -errno;
else {
printk("Stub registers -\n");
for(i = 0; i < ARRAY_SIZE(regs); i++)
printk("\t%d - %lx\n", i, regs[i]);
}
return 0;
}
void wait_stub_done(int pid, int sig, char * fname) void wait_stub_done(int pid, int sig, char * fname)
{ {
int n, status, err; int n, status, err;
...@@ -67,18 +83,10 @@ void wait_stub_done(int pid, int sig, char * fname) ...@@ -67,18 +83,10 @@ void wait_stub_done(int pid, int sig, char * fname)
if((n < 0) || !WIFSTOPPED(status) || if((n < 0) || !WIFSTOPPED(status) ||
(WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){ (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){
unsigned long regs[MAX_REG_NR]; err = ptrace_dump_regs(pid);
if(err)
if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
printk("Failed to get registers from stub, " printk("Failed to get registers from stub, "
"errno = %d\n", errno); "errno = %d\n", -err);
else {
int i;
printk("Stub registers -\n");
for(i = 0; i < ARRAY_SIZE(regs); i++)
printk("\t%d - %lx\n", i, regs[i]);
}
panic("%s : failed to wait for SIGUSR1/SIGTRAP, " panic("%s : failed to wait for SIGUSR1/SIGTRAP, "
"pid = %d, n = %d, errno = %d, status = 0x%x\n", "pid = %d, n = %d, errno = %d, status = 0x%x\n",
fname, pid, n, errno, status); fname, pid, n, errno, status);
...@@ -142,9 +150,14 @@ static void handle_trap(int pid, union uml_pt_regs *regs, int local_using_sysemu ...@@ -142,9 +150,14 @@ static void handle_trap(int pid, union uml_pt_regs *regs, int local_using_sysemu
CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
if((err < 0) || !WIFSTOPPED(status) || if((err < 0) || !WIFSTOPPED(status) ||
(WSTOPSIG(status) != SIGTRAP + 0x80)) (WSTOPSIG(status) != SIGTRAP + 0x80)){
err = ptrace_dump_regs(pid);
if(err)
printk("Failed to get registers from process, "
"errno = %d\n", -err);
panic("handle_trap - failed to wait at end of syscall, " panic("handle_trap - failed to wait at end of syscall, "
"errno = %d, status = %d\n", errno, status); "errno = %d, status = %d\n", errno, status);
}
} }
handle_syscall(regs); handle_syscall(regs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment