[PATCH 1/3] ptrace_resume: set/clear PT_SINGLESTEP/PT_BLOCKSTEP Contrary to the comment in ptrace.h, PT_SINGLESTEP is only used on arch/xtensa, and PT_BLOCKSTEP is not used at all. Change the arch independent ptrace_resume() to set/clear these bits before user_enable_*_step/user_disable_single_step() and remove this this code from arch/xtensa/kernel/ptrace.c. Also change ptrace_init_task() to prevent the copying of these bits. This doesn't make any difference on xtensa, and other arches do not use these flags so far. But, thereafter we can check task->ptrace & PT_*STEP to figure out if this tracer wants the stepping and unlike TIF_SINGLESTEP it is always correct in this sense and it is not arch dependent. Signed-off-by: Oleg Nesterov --- include/linux/ptrace.h | 4 ++-- kernel/ptrace.c | 3 +++ arch/xtensa/kernel/ptrace.c | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-) --- ptrace/include/linux/ptrace.h~1_use_PT_STEP 2011-06-28 17:50:27.000000000 +0200 +++ ptrace/include/linux/ptrace.h 2011-07-03 21:55:17.000000000 +0200 @@ -104,7 +104,6 @@ #define PT_TRACE_MASK 0x000003f4 -/* single stepping state bits (used on ARM and PA-RISC) */ #define PT_SINGLESTEP_BIT 31 #define PT_SINGLESTEP (1<parent = child->real_parent; child->ptrace = 0; if (unlikely(ptrace) && (current->ptrace & PT_PTRACED)) { - child->ptrace = current->ptrace; + child->ptrace = current->ptrace & + ~(PT_SINGLESTEP | PT_BLOCKSTEP); __ptrace_link(child, current->parent); } --- ptrace/kernel/ptrace.c~1_use_PT_STEP 2011-06-28 17:50:27.000000000 +0200 +++ ptrace/kernel/ptrace.c 2011-07-03 21:55:17.000000000 +0200 @@ -599,13 +599,16 @@ static int ptrace_resume(struct task_str clear_tsk_thread_flag(child, TIF_SYSCALL_EMU); #endif + child->ptrace &= ~(PT_SINGLESTEP | PT_BLOCKSTEP); if (is_singleblock(request)) { if (unlikely(!arch_has_block_step())) return -EIO; + child->ptrace |= PT_BLOCKSTEP; user_enable_block_step(child); } else if (is_singlestep(request) || is_sysemu_singlestep(request)) { if (unlikely(!arch_has_single_step())) return -EIO; + child->ptrace |= PT_SINGLESTEP; user_enable_single_step(child); } else { user_disable_single_step(child); --- ptrace/arch/xtensa/kernel/ptrace.c~1_use_PT_STEP 2011-04-06 21:33:43.000000000 +0200 +++ ptrace/arch/xtensa/kernel/ptrace.c 2011-07-03 20:30:57.000000000 +0200 @@ -33,12 +33,10 @@ void user_enable_single_step(struct task_struct *child) { - child->ptrace |= PT_SINGLESTEP; } void user_disable_single_step(struct task_struct *child) { - child->ptrace &= ~PT_SINGLESTEP; } /*