From: Jeff Dike <jdike@addtoit.com>

From: Bodo Stroesser - Make singlestepping() generic.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/um/kernel/process_kern.c      |   10 ++++++++++
 25-akpm/arch/um/kernel/skas/include/skas.h |    1 -
 25-akpm/arch/um/kernel/skas/process.c      |    2 +-
 25-akpm/arch/um/kernel/skas/process_kern.c |    8 --------
 25-akpm/arch/um/kernel/skas/syscall_kern.c |    7 +++++++
 25-akpm/arch/um/kernel/tt/include/tt.h     |    1 -
 25-akpm/arch/um/kernel/tt/process_kern.c   |    9 ---------
 25-akpm/arch/um/kernel/tt/tracer.c         |    2 +-
 8 files changed, 19 insertions(+), 21 deletions(-)

diff -puN arch/um/kernel/process_kern.c~uml-generic-singlestepping arch/um/kernel/process_kern.c
--- 25/arch/um/kernel/process_kern.c~uml-generic-singlestepping	2004-11-04 20:37:34.609235552 -0800
+++ 25-akpm/arch/um/kernel/process_kern.c	2004-11-04 20:38:02.874938512 -0800
@@ -19,6 +19,7 @@
 #include "linux/vmalloc.h"
 #include "linux/spinlock.h"
 #include "linux/proc_fs.h"
+#include "linux/ptrace.h"
 #include "asm/unistd.h"
 #include "asm/mman.h"
 #include "asm/segment.h"
@@ -454,6 +455,15 @@ int __init make_proc_sysemu(void)
 
 late_initcall(make_proc_sysemu);
 
+int singlestepping(void * t)
+{
+	struct task_struct *task = t ? t : current;
+
+	if (task->thread.singlestep_syscall)
+		return(0);
+	return(task->ptrace & PT_DTRACE);
+}
+
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
  * Emacs will notice this stuff at the end of the file and automatically
diff -puN arch/um/kernel/skas/include/skas.h~uml-generic-singlestepping arch/um/kernel/skas/include/skas.h
--- 25/arch/um/kernel/skas/include/skas.h~uml-generic-singlestepping	2004-11-04 20:37:34.610235400 -0800
+++ 25-akpm/arch/um/kernel/skas/include/skas.h	2004-11-04 20:37:34.625233120 -0800
@@ -28,7 +28,6 @@ extern int unmap(int fd, void *addr, int
 extern int protect(int fd, unsigned long addr, unsigned long len, 
 		   int r, int w, int x, int must_succeed);
 extern void user_signal(int sig, union uml_pt_regs *regs);
-extern int singlestepping_skas(void);
 extern int new_mm(int from);
 extern void save_registers(union uml_pt_regs *regs);
 extern void restore_registers(union uml_pt_regs *regs);
diff -puN arch/um/kernel/skas/process.c~uml-generic-singlestepping arch/um/kernel/skas/process.c
--- 25/arch/um/kernel/skas/process.c~uml-generic-singlestepping	2004-11-04 20:37:34.612235096 -0800
+++ 25-akpm/arch/um/kernel/skas/process.c	2004-11-04 20:39:57.927447872 -0800
@@ -190,7 +190,7 @@ void userspace(union uml_pt_regs *regs)
 		local_using_sysemu = get_using_sysemu();
 		pt_syscall_parm = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL;
 
-		op = singlestepping_skas() ? PTRACE_SINGLESTEP :
+		op = singlestepping(NULL) ? PTRACE_SINGLESTEP :
 			pt_syscall_parm;
 
 		err = ptrace(op, pid, 0, 0);
diff -puN arch/um/kernel/skas/process_kern.c~uml-generic-singlestepping arch/um/kernel/skas/process_kern.c
--- 25/arch/um/kernel/skas/process_kern.c~uml-generic-singlestepping	2004-11-04 20:37:34.614234792 -0800
+++ 25-akpm/arch/um/kernel/skas/process_kern.c	2004-11-04 20:37:34.627232816 -0800
@@ -24,14 +24,6 @@
 #include "mode.h"
 #include "proc_mm.h"
 
-int singlestepping_skas(void)
-{
-	int ret = current->ptrace & PT_DTRACE;
-
-	current->ptrace &= ~PT_DTRACE;
-	return(ret);
-}
-
 void *switch_to_skas(void *prev, void *next)
 {
 	struct task_struct *from, *to;
diff -puN arch/um/kernel/skas/syscall_kern.c~uml-generic-singlestepping arch/um/kernel/skas/syscall_kern.c
--- 25/arch/um/kernel/skas/syscall_kern.c~uml-generic-singlestepping	2004-11-04 20:37:34.615234640 -0800
+++ 25-akpm/arch/um/kernel/skas/syscall_kern.c	2004-11-04 20:37:34.627232816 -0800
@@ -4,6 +4,7 @@
  */
 
 #include "linux/sys.h"
+#include "linux/ptrace.h"
 #include "asm/errno.h"
 #include "asm/unistd.h"
 #include "asm/ptrace.h"
@@ -27,6 +28,12 @@ long execute_syscall_skas(void *r)
 		res = -ENOSYS;
 	else res = EXECUTE_SYSCALL(syscall, regs);
 
+	if(current->thread.singlestep_syscall){
+		current->thread.singlestep_syscall = 0;
+		current->ptrace &= ~PT_DTRACE;
+		force_sig(SIGTRAP, current);
+	}
+
 	return(res);
 }
 
diff -puN arch/um/kernel/tt/include/tt.h~uml-generic-singlestepping arch/um/kernel/tt/include/tt.h
--- 25/arch/um/kernel/tt/include/tt.h~uml-generic-singlestepping	2004-11-04 20:37:34.617234336 -0800
+++ 25-akpm/arch/um/kernel/tt/include/tt.h	2004-11-04 20:37:34.627232816 -0800
@@ -24,7 +24,6 @@ extern void set_init_pid(int pid);
 extern int set_user_mode(void *task);
 extern void set_tracing(void *t, int tracing);
 extern int is_tracing(void *task);
-extern int singlestepping_tt(void *t);
 extern void clear_singlestep(void *t);
 extern void syscall_handler(int sig, union uml_pt_regs *regs);
 extern void exit_kernel(int pid, void *task);
diff -puN arch/um/kernel/tt/process_kern.c~uml-generic-singlestepping arch/um/kernel/tt/process_kern.c
--- 25/arch/um/kernel/tt/process_kern.c~uml-generic-singlestepping	2004-11-04 20:37:34.619234032 -0800
+++ 25-akpm/arch/um/kernel/tt/process_kern.c	2004-11-04 20:37:34.628232664 -0800
@@ -523,15 +523,6 @@ void set_init_pid(int pid)
 		      -err);
 }
 
-int singlestepping_tt(void *t)
-{
-	struct task_struct *task = t;
-
-	if(task->thread.singlestep_syscall)
-		return(0);
-	return(task->ptrace & PT_DTRACE);
-}
-
 void clear_singlestep(void *t)
 {
 	struct task_struct *task = t;
diff -puN arch/um/kernel/tt/tracer.c~uml-generic-singlestepping arch/um/kernel/tt/tracer.c
--- 25/arch/um/kernel/tt/tracer.c~uml-generic-singlestepping	2004-11-04 20:37:34.620233880 -0800
+++ 25-akpm/arch/um/kernel/tt/tracer.c	2004-11-04 20:37:34.629232512 -0800
@@ -373,7 +373,7 @@ int tracer(int (*init_proc)(void *), voi
 			}
 
 			if(tracing){
-				if(singlestepping_tt(task))
+				if(singlestepping(task))
 					cont_type = PTRACE_SINGLESTEP;
 				else cont_type = pt_syscall_parm;
 			}
_