[PATCH 89] ptrace_wake_up: clear context->stop_code

Oleg Nesterov oleg at redhat.com
Tue Oct 13 17:59:43 UTC 2009


Change ptrace_wake_up() to clear context->stop_code, this simplifies
the callers and looks right in any case.

Now ptrace_detach_task() becomes really trivial. If we create the
self-detaching engine we simply do:

	if (valid_signal(sig))
		context->signr = sig;
	context->resume = UTRACE_DETACH;

and nothing more.

Also, change the prototype to match that of utrace_control/etc.

---

 kernel/ptrace.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

--- PU/kernel/ptrace.c~89_WAKEUP_CLEAR_STOP_CODE	2009-10-13 19:20:24.000000000 +0200
+++ PU/kernel/ptrace.c	2009-10-13 19:55:25.000000000 +0200
@@ -80,8 +80,8 @@ void __ptrace_link(struct task_struct *c
 static const struct utrace_engine_ops ptrace_utrace_ops; /* forward decl */
 static int ptrace_attach_task(struct task_struct *tracee, int options);
 static void ptrace_abort_attach(struct task_struct *tracee);
-static void ptrace_wake_up(struct utrace_engine *engine,
-				struct task_struct *tracee,
+static void ptrace_wake_up(struct task_struct *tracee,
+				struct utrace_engine *engine,
 				enum utrace_resume_action action);
 
 static struct utrace_engine *ptrace_lookup_engine(struct task_struct *tracee)
@@ -111,14 +111,13 @@ static void ptrace_detach_task(struct ta
 		case PTRACE_EVENT_SIGNAL:
 			if (valid_signal(sig))
 				context->signr = sig;
-			context->stop_code = 0;
 			context->resume = UTRACE_DETACH;
 			action = UTRACE_RESUME;
 			break;
 		}
 	}
 
-	ptrace_wake_up(engine, tracee, action);
+	ptrace_wake_up(tracee, engine, action);
 	utrace_engine_put(engine);
 }
 
@@ -943,8 +942,8 @@ void ptrace_notify_stop(struct task_stru
 	utrace_engine_put(engine);
 }
 
-static void ptrace_wake_up(struct utrace_engine *engine,
-				struct task_struct *tracee,
+static void ptrace_wake_up( struct task_struct *tracee,
+				struct utrace_engine *engine,
 				enum utrace_resume_action action)
 {
 	unsigned long flags;
@@ -958,6 +957,7 @@ static void ptrace_wake_up(struct utrace
 	// XXX: FIXME!!! racy.
 	tracee->exit_code = 0;
 
+	ptrace_context(engine)->stop_code = 0;
 	utrace_control(tracee, engine, action);
 }
 
@@ -1011,9 +1011,8 @@ static void do_ptrace_resume(struct utra
 		}
 	}
 
-	context->stop_code = 0;
 	context->resume = action;
-	ptrace_wake_up(engine, tracee, action);
+	ptrace_wake_up(tracee, engine, action);
 }
 
 static int ptrace_resume(struct utrace_engine *engine,




More information about the utrace-devel mailing list