[PATCH 3/5] ptrace-utrace: don't assume resume != UTRACE_RESUME means stepping

Oleg Nesterov oleg at redhat.com
Fri Dec 10 11:54:46 UTC 2010


No functional changes. Currently ptrace_report_syscall_exit() and
ptrace_report_signal(UTRACE_SIGNAL_HANDLER) can see either UTRACE_RESUME
or UTRACE_BLOCKSTEP/UTRACE_SINGLESTEP, but we are going to change this.
Change the code to not assume that resume != UTRACE_RESUME means stepping.
Add the trivial helper, is_step_resume(), which does the check.

Signed-off-by: Oleg Nesterov <oleg at redhat.com>
---

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

--- kstub/kernel/ptrace-utrace.c~3_resume_step_helper	2010-09-20 03:53:31.000000000 +0200
+++ kstub/kernel/ptrace-utrace.c	2010-09-20 03:53:31.000000000 +0200
@@ -418,6 +418,11 @@ static u32 ptrace_report_syscall_entry(u
 	return UTRACE_SYSCALL_RUN | UTRACE_STOP;
 }
 
+static inline bool is_step_resume(enum utrace_resume_action resume)
+{
+	return resume == UTRACE_BLOCKSTEP || resume == UTRACE_SINGLESTEP;
+}
+
 static u32 ptrace_report_syscall_exit(u32 action, struct utrace_engine *engine,
 				      struct pt_regs *regs)
 {
@@ -426,10 +431,7 @@ static u32 ptrace_report_syscall_exit(u3
 	if (ptrace_event_pending(ctx))
 		return UTRACE_STOP;
 
-	if (ctx->resume != UTRACE_RESUME) {
-		WARN_ON(ctx->resume != UTRACE_BLOCKSTEP &&
-			ctx->resume != UTRACE_SINGLESTEP);
-
+	if (is_step_resume(ctx->resume)) {
 		ctx->signr = SIGTRAP;
 		return UTRACE_INTERRUPT;
 	}
@@ -517,10 +519,7 @@ static u32 ptrace_report_signal(u32 acti
 		if (WARN_ON(ctx->siginfo))
 			ctx->siginfo = NULL;
 
-		if (resume != UTRACE_RESUME) {
-			WARN_ON(resume != UTRACE_BLOCKSTEP &&
-				resume != UTRACE_SINGLESTEP);
-
+		if (is_step_resume(resume)) {
 			set_stop_code(ctx, PTRACE_EVENT_SIGTRAP);
 			return UTRACE_STOP | UTRACE_SIGNAL_IGN;
 		}




More information about the utrace-devel mailing list