Trivial, add set_stop_code() and turn syscall_code() into set_syscall_code().
--- kernel/ptrace.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) --- PU/kernel/ptrace.c~72_SET_CODE_HELPER 2009-10-09 14:18:55.000000000 +0200 +++ PU/kernel/ptrace.c 2009-10-09 14:34:38.000000000 +0200 @@ -53,6 +53,11 @@ static inline int get_stop_event(struct return context->stop_code >> 8; } +static inline void set_stop_code(struct ptrace_context *context, int event) +{ + context->stop_code = (event << 8) | SIGTRAP; +} + static inline struct ptrace_context * ptrace_context(struct utrace_engine *engine) { @@ -123,7 +128,7 @@ static u32 ptrace_report_exit(enum utrac WARN_ON(ptrace_event_pending(context)); - context->stop_code = (PTRACE_EVENT_EXIT << 8) | SIGTRAP; + set_stop_code(context, PTRACE_EVENT_EXIT); context->eventmsg = *code; return UTRACE_STOP; @@ -195,13 +200,13 @@ static u32 ptrace_report_clone(enum utra // XXX: child->pid is wrong! use tracer's pid_ns if (event) { - context->stop_code = (event << 8) | SIGTRAP; + set_stop_code(context, event); context->eventmsg = child->pid; ret = UTRACE_STOP; } else if ((clone_flags & CLONE_VFORK) && (context->options & PTRACE_O_TRACEVFORKDONE)) { - context->stop_code = (PTRACE_EVENT_VFORK_DONE << 8) | SIGTRAP; + set_stop_code(context, PTRACE_EVENT_VFORK_DONE); context->eventmsg = child->pid; ret = UTRACE_STOP; @@ -210,11 +215,11 @@ static u32 ptrace_report_clone(enum utra return ret; } -static inline int syscall_code(struct ptrace_context *context, int event) +static inline void set_syscall_code(struct ptrace_context *context, int event) { - int code = (context->options & PTRACE_O_TRACESYSGOOD) ? - (SIGTRAP | 0x80) : SIGTRAP; - return (event << 8) | code; + set_stop_code(context, event); + if (context->options & PTRACE_O_TRACESYSGOOD) + context->stop_code |= 0x80; } static u32 ptrace_report_syscall_entry(u32 action, @@ -226,7 +231,7 @@ static u32 ptrace_report_syscall_entry(u WARN_ON(ptrace_event_pending(context)); - context->stop_code = syscall_code(context, PTRACE_EVENT_SYSCALL_ENTRY); + set_syscall_code(context, PTRACE_EVENT_SYSCALL_ENTRY); return UTRACE_SYSCALL_RUN | UTRACE_STOP; } @@ -241,7 +246,7 @@ static u32 ptrace_report_syscall_exit(en if (ptrace_event_pending(context)) return UTRACE_STOP; - context->stop_code = syscall_code(context, PTRACE_EVENT_SYSCALL_EXIT); + set_syscall_code(context, PTRACE_EVENT_SYSCALL_EXIT); return UTRACE_STOP; } @@ -265,7 +270,7 @@ static u32 ptrace_report_exec(enum utrac return UTRACE_RESUME; } - context->stop_code = (PTRACE_EVENT_EXEC << 8) | SIGTRAP; + set_stop_code(context, PTRACE_EVENT_EXEC); return UTRACE_STOP; } @@ -938,8 +943,7 @@ static void do_ptrace_resume(struct utra case PTRACE_EVENT_FORK: case PTRACE_EVENT_CLONE: case PTRACE_EVENT_VFORK_DONE: - context->stop_code = syscall_code(context, - PTRACE_EVENT_SYSCALL_EXIT); + set_syscall_code(context, PTRACE_EVENT_SYSCALL_EXIT); do_ptrace_notify_stop(context, tracee); return; }