[PATCH 108] cosmetic, fold do_ptrace_resume() into ptrace_resume()

Oleg Nesterov oleg at redhat.com
Tue Oct 20 16:15:30 UTC 2009


ptrace_resume() is trivial now, it can absorb do_ptrace_resume().

This and the previous patches are pure cosmetic, I can't explain why
I think the code looks more readable this way, but it certainly looks
better to me.

---

 kernel/ptrace.c |  105 +++++++++++++++++++++++++-------------------------------
 1 file changed, 48 insertions(+), 57 deletions(-)

--- PU/kernel/ptrace.c~108_FOLD_DO_PTRACE_RESUME	2009-10-20 17:55:20.000000000 +0200
+++ PU/kernel/ptrace.c	2009-10-20 18:03:02.000000000 +0200
@@ -961,62 +961,6 @@ static void ptrace_wake_up(struct task_s
 	utrace_control(tracee, engine, action);
 }
 
-static void do_ptrace_resume(struct utrace_engine *engine,
-				struct task_struct *tracee,
-				enum utrace_resume_action action,
-				long request, long data)
-{
-	struct ptrace_context *context = ptrace_context(engine);
-
-	switch (get_stop_event(context)) {
-	case PTRACE_EVENT_VFORK:
-		if (context->options & PTRACE_O_TRACEVFORKDONE) {
-			set_stop_code(context, PTRACE_EVENT_VFORK_DONE);
-			action = UTRACE_REPORT;
-		}
-		break;
-
-	case PTRACE_EVENT_EXEC:
-	case PTRACE_EVENT_FORK:
-	case PTRACE_EVENT_CLONE:
-	case PTRACE_EVENT_VFORK_DONE:
-		if (request == PTRACE_SYSCALL) {
-			set_syscall_code(context, PTRACE_EVENT_SYSCALL_EXIT);
-			do_ptrace_notify_stop(context, tracee);
-			return;
-		}
-		/* fallthrough, but suppress send_sig_info() below */
-		data = 0;
-
-	case PTRACE_EVENT_SYSCALL_EXIT:
-		if (action != UTRACE_RESUME) {
-			read_lock(&tasklist_lock);
-			if (tracee->sighand)
-				send_sigtrap(tracee, task_pt_regs(tracee),
-						0, TRAP_BRKPT);
-			read_unlock(&tasklist_lock);
-			action = UTRACE_RESUME;
-		}
-		/* fallthrough */
-
-	case PTRACE_EVENT_SYSCALL_ENTRY:
-		if (data)
-			send_sig_info(data, SEND_SIG_PRIV, tracee);
-		break;
-
-	case PTRACE_EVENT_SIGNAL:
-		context->signr = data;
-		break;
-
-	case 0:
-		// XXX: JCTL stop
-		break;
-	}
-
-	context->resume = action;
-	ptrace_wake_up(tracee, engine, action, true);
-}
-
 static int ptrace_resume_action(struct task_struct *tracee,
 				struct utrace_engine *engine, long request)
 {
@@ -1071,6 +1015,7 @@ static int ptrace_resume_action(struct t
 static int ptrace_resume(struct utrace_engine *engine,
 			struct task_struct *tracee, long request, long data)
 {
+	struct ptrace_context *context = ptrace_context(engine);
 	int action;
 
 	if (!valid_signal(data))
@@ -1080,7 +1025,53 @@ static int ptrace_resume(struct utrace_e
 	if (action < 0)
 		return action;
 
-	do_ptrace_resume(engine, tracee, action, request, data);
+	switch (get_stop_event(context)) {
+	case PTRACE_EVENT_VFORK:
+		if (context->options & PTRACE_O_TRACEVFORKDONE) {
+			set_stop_code(context, PTRACE_EVENT_VFORK_DONE);
+			action = UTRACE_REPORT;
+		}
+		break;
+
+	case PTRACE_EVENT_EXEC:
+	case PTRACE_EVENT_FORK:
+	case PTRACE_EVENT_CLONE:
+	case PTRACE_EVENT_VFORK_DONE:
+		if (request == PTRACE_SYSCALL) {
+			set_syscall_code(context, PTRACE_EVENT_SYSCALL_EXIT);
+			do_ptrace_notify_stop(context, tracee);
+			return 0;
+		}
+		/* fallthrough, but suppress send_sig_info() below */
+		data = 0;
+
+	case PTRACE_EVENT_SYSCALL_EXIT:
+		if (action != UTRACE_RESUME) {
+			read_lock(&tasklist_lock);
+			if (tracee->sighand)
+				send_sigtrap(tracee, task_pt_regs(tracee),
+						0, TRAP_BRKPT);
+			read_unlock(&tasklist_lock);
+			action = UTRACE_RESUME;
+		}
+		/* fallthrough */
+
+	case PTRACE_EVENT_SYSCALL_ENTRY:
+		if (data)
+			send_sig_info(data, SEND_SIG_PRIV, tracee);
+		break;
+
+	case PTRACE_EVENT_SIGNAL:
+		context->signr = data;
+		break;
+
+	case 0:
+		// XXX: JCTL stop
+		break;
+	}
+
+	context->resume = action;
+	ptrace_wake_up(tracee, engine, action, true);
 	return 0;
 }
 




More information about the utrace-devel mailing list