aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-05-06 17:51:29 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:13:02 -0400
commitf30c2c983e09470446ee00472f9d4a927fe2e9cb (patch)
tree49d40dbf2143f178ce3a95f436c0a9db6f74394f /arch/um
parent2e3f5251ac716879df6b6271f243f657c6e02e9a (diff)
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: Jeff Dike <jdike@linux.intel.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/os-Linux/skas/process.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 29fd079c30b1..41bf8d1e14e0 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -44,6 +44,22 @@ int is_skas_winch(int pid, int fd, void *data)
44 return(1); 44 return(1);
45} 45}
46 46
47static int ptrace_dump_regs(int pid)
48{
49 unsigned long regs[MAX_REG_NR];
50 int i;
51
52 if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
53 return -errno;
54 else {
55 printk("Stub registers -\n");
56 for(i = 0; i < ARRAY_SIZE(regs); i++)
57 printk("\t%d - %lx\n", i, regs[i]);
58 }
59
60 return 0;
61}
62
47void wait_stub_done(int pid, int sig, char * fname) 63void wait_stub_done(int pid, int sig, char * fname)
48{ 64{
49 int n, status, err; 65 int n, status, err;
@@ -67,18 +83,10 @@ void wait_stub_done(int pid, int sig, char * fname)
67 83
68 if((n < 0) || !WIFSTOPPED(status) || 84 if((n < 0) || !WIFSTOPPED(status) ||
69 (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){ 85 (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){
70 unsigned long regs[MAX_REG_NR]; 86 err = ptrace_dump_regs(pid);
71 87 if(err)
72 if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
73 printk("Failed to get registers from stub, " 88 printk("Failed to get registers from stub, "
74 "errno = %d\n", errno); 89 "errno = %d\n", -err);
75 else {
76 int i;
77
78 printk("Stub registers -\n");
79 for(i = 0; i < ARRAY_SIZE(regs); i++)
80 printk("\t%d - %lx\n", i, regs[i]);
81 }
82 panic("%s : failed to wait for SIGUSR1/SIGTRAP, " 90 panic("%s : failed to wait for SIGUSR1/SIGTRAP, "
83 "pid = %d, n = %d, errno = %d, status = 0x%x\n", 91 "pid = %d, n = %d, errno = %d, status = 0x%x\n",
84 fname, pid, n, errno, status); 92 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 150
143 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); 151 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
144 if((err < 0) || !WIFSTOPPED(status) || 152 if((err < 0) || !WIFSTOPPED(status) ||
145 (WSTOPSIG(status) != SIGTRAP + 0x80)) 153 (WSTOPSIG(status) != SIGTRAP + 0x80)){
154 err = ptrace_dump_regs(pid);
155 if(err)
156 printk("Failed to get registers from process, "
157 "errno = %d\n", -err);
146 panic("handle_trap - failed to wait at end of syscall, " 158 panic("handle_trap - failed to wait at end of syscall, "
147 "errno = %d, status = %d\n", errno, status); 159 "errno = %d, status = %d\n", errno, status);
160 }
148 } 161 }
149 162
150 handle_syscall(regs); 163 handle_syscall(regs);