[PATCH 26] introduce context->resume_stopped()

Oleg Nesterov oleg at redhat.com
Mon Sep 7 22:04:08 UTC 2009


Note! I am not sure context->resume_stopped() is good idea. Perhaps
it will die, but currently it should help to convert the code.

When callback wants to stop we already know what should be done to
resume after stop. A callback should set ->resume_stopped which will
be used later by ptrace_resume().

See the next patch as an example.

---

 kernel/ptrace.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

--- PU/kernel/ptrace.c~26_CTX_RESUME	2009-09-07 22:12:41.000000000 +0200
+++ PU/kernel/ptrace.c	2009-09-07 22:52:39.000000000 +0200
@@ -24,10 +24,14 @@
 #include <linux/syscalls.h>
 #include <linux/uaccess.h>
 
+typedef void (*resume_stopped_t)(struct utrace_engine *,
+					struct task_struct*, long);
+
 struct ptrace_context {
 	int options;
 
 	int stopped_code;
+	resume_stopped_t resume_stopped;
 };
 
 static inline struct ptrace_context *
@@ -991,13 +995,22 @@ static int ptrace_resume(struct task_str
 	}
 
 	if (!ret) {
+		int event;
+
+		if (context->resume_stopped) {
+			resume_stopped_t resume = context->resume_stopped;
+			context->resume_stopped = NULL;
+			WARN_ON(context->stopped_code);
+			resume(engine, child, data);
+		}
+
 		/*
 		 * If there was a non-signal event reported last time,
 		 * we may need to simulate another event that follows
 		 * it, or do some other special case.  We'll set @event
 		 * nonzero here if there is an event to simulate.
 		 */
-		int event = ptrace_stop_event(child);
+		event = ptrace_stop_event(child);
 		ptrace_set_stop_event(child, 0);
 
 		switch (event) {




More information about the utrace-devel mailing list