aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/skas
diff options
context:
space:
mode:
authorStanislaw Gruszka <stf_xl@wp.pl>2007-12-17 19:19:46 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-12-17 22:28:15 -0500
commit4dbed85a35ed37d9608f4f32e5d69efa775d6223 (patch)
tree67ab558db8ccaf8d706a25e5ce87b78be241cffb /arch/um/os-Linux/skas
parent5867a78f41f84e5388448da62c183255dc22601f (diff)
uml: stop gdb from deleting breakpoints when running UML
Sometimes when UML is debugged gdb miss breakpoints. When process traced by gdb do fork, debugger remove breakpoints from child address space. There is possibility to trace more than one fork, but this not work with UML, I guess (only guess) there is a deadlock - gdb waits for UML and UML waits for gdb. When clone() is called with SIGCHLD and CLONE_VM flags, gdb see this as PTRACE_EVENT_FORK not as PTRACE_EVENT_CLONE and remove breakpoints from child and at the same time from traced process, because either have the same address space. Maybe it is possible to do fix in gdb, but I'm not sure if there is easy way to find out if traced and child processes share memory. So I do fix for UML, it simply do not call clone() with both SIGCHLD and CLONE_VM flags together. Additionally __WALL flag is used for waitpid() to assure not miss clone and normal process events. [ jdike - checkpatch fixes ] Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl> Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/os-Linux/skas')
-rw-r--r--arch/um/os-Linux/skas/process.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index d77c81d7068a..e8b7a97e83d3 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -64,7 +64,7 @@ void wait_stub_done(int pid)
64 int n, status, err; 64 int n, status, err;
65 65
66 while (1) { 66 while (1) {
67 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); 67 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL));
68 if ((n < 0) || !WIFSTOPPED(status)) 68 if ((n < 0) || !WIFSTOPPED(status))
69 goto bad_wait; 69 goto bad_wait;
70 70
@@ -153,7 +153,7 @@ static void handle_trap(int pid, struct uml_pt_regs *regs,
153 panic("handle_trap - continuing to end of syscall " 153 panic("handle_trap - continuing to end of syscall "
154 "failed, errno = %d\n", errno); 154 "failed, errno = %d\n", errno);
155 155
156 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); 156 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED | __WALL));
157 if ((err < 0) || !WIFSTOPPED(status) || 157 if ((err < 0) || !WIFSTOPPED(status) ||
158 (WSTOPSIG(status) != SIGTRAP + 0x80)) { 158 (WSTOPSIG(status) != SIGTRAP + 0x80)) {
159 err = ptrace_dump_regs(pid); 159 err = ptrace_dump_regs(pid);
@@ -255,16 +255,18 @@ int start_userspace(unsigned long stub_stack)
255 panic("start_userspace : mmap failed, errno = %d", errno); 255 panic("start_userspace : mmap failed, errno = %d", errno);
256 sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); 256 sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *);
257 257
258 flags = CLONE_FILES | SIGCHLD; 258 flags = CLONE_FILES;
259 if (proc_mm) 259 if (proc_mm)
260 flags |= CLONE_VM; 260 flags |= CLONE_VM;
261 else
262 flags |= SIGCHLD;
261 263
262 pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack); 264 pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack);
263 if (pid < 0) 265 if (pid < 0)
264 panic("start_userspace : clone failed, errno = %d", errno); 266 panic("start_userspace : clone failed, errno = %d", errno);
265 267
266 do { 268 do {
267 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); 269 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL));
268 if (n < 0) 270 if (n < 0)
269 panic("start_userspace : wait failed, errno = %d", 271 panic("start_userspace : wait failed, errno = %d",
270 errno); 272 errno);
@@ -314,7 +316,7 @@ void userspace(struct uml_pt_regs *regs)
314 "pid=%d, ptrace operation = %d, errno = %d\n", 316 "pid=%d, ptrace operation = %d, errno = %d\n",
315 pid, op, errno); 317 pid, op, errno);
316 318
317 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); 319 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED | __WALL));
318 if (err < 0) 320 if (err < 0)
319 panic("userspace - waitpid failed, errno = %d\n", 321 panic("userspace - waitpid failed, errno = %d\n",
320 errno); 322 errno);