Commit 1d8393171b1f6c30a889fd7cb16fc193f689923c

Authored by Christoph Hellwig
Committed by Linus Torvalds
1 parent 440e6ca79a

avr32: use generic ptrace_resume code

Use the generic ptrace_resume code for PTRACE_SYSCALL, PTRACE_CONT,
PTRACE_KILL and PTRACE_SINGLESTEP.  This implies defining
arch_has_single_step in <asm/ptrace.h> and implementing the
user_enable_single_step and user_disable_single_step functions, which also
causes the breakpoint information to be cleared on fork, which could be
considered a bug fix.

Also the TIF_SYSCALL_TRACE thread flag is now cleared on PTRACE_KILL which
it previously wasn't which is consistent with all architectures using the
modern ptrace code.

Currently avr32 doesn't implement any code to disable single stepping when
one of the non-syscall requests is called which seems wrong, but I've left
it as-is for now.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Acked-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 9 additions and 46 deletions Side-by-side Diff

arch/avr32/include/asm/ptrace.h
... ... @@ -124,6 +124,8 @@
124 124  
125 125 #include <asm/ocd.h>
126 126  
  127 +#define arch_has_single_step() (1)
  128 +
127 129 #define arch_ptrace_attach(child) ocd_enable(child)
128 130  
129 131 #define user_mode(regs) (((regs)->sr & MODE_MASK) == MODE_USER)
arch/avr32/kernel/ptrace.c
... ... @@ -28,9 +28,9 @@
28 28 THREAD_SIZE - sizeof(struct pt_regs));
29 29 }
30 30  
31   -static void ptrace_single_step(struct task_struct *tsk)
  31 +static void user_enable_single_step(struct task_struct *tsk)
32 32 {
33   - pr_debug("ptrace_single_step: pid=%u, PC=0x%08lx, SR=0x%08lx\n",
  33 + pr_debug("user_enable_single_step: pid=%u, PC=0x%08lx, SR=0x%08lx\n",
34 34 tsk->pid, task_pt_regs(tsk)->pc, task_pt_regs(tsk)->sr);
35 35  
36 36 /*
... ... @@ -49,6 +49,11 @@
49 49 set_tsk_thread_flag(tsk, TIF_SINGLE_STEP);
50 50 }
51 51  
  52 +void user_disable_single_step(struct task_struct *child)
  53 +{
  54 + /* XXX(hch): a no-op here seems wrong.. */
  55 +}
  56 +
52 57 /*
53 58 * Called by kernel/ptrace.c when detaching
54 59 *
... ... @@ -165,50 +170,6 @@
165 170  
166 171 case PTRACE_POKEUSR:
167 172 ret = ptrace_write_user(child, addr, data);
168   - break;
169   -
170   - /* continue and stop at next (return from) syscall */
171   - case PTRACE_SYSCALL:
172   - /* restart after signal */
173   - case PTRACE_CONT:
174   - ret = -EIO;
175   - if (!valid_signal(data))
176   - break;
177   - if (request == PTRACE_SYSCALL)
178   - set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
179   - else
180   - clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
181   - child->exit_code = data;
182   - /* XXX: Are we sure no breakpoints are active here? */
183   - wake_up_process(child);
184   - ret = 0;
185   - break;
186   -
187   - /*
188   - * Make the child exit. Best I can do is send it a
189   - * SIGKILL. Perhaps it should be put in the status that it
190   - * wants to exit.
191   - */
192   - case PTRACE_KILL:
193   - ret = 0;
194   - if (child->exit_state == EXIT_ZOMBIE)
195   - break;
196   - child->exit_code = SIGKILL;
197   - wake_up_process(child);
198   - break;
199   -
200   - /*
201   - * execute single instruction.
202   - */
203   - case PTRACE_SINGLESTEP:
204   - ret = -EIO;
205   - if (!valid_signal(data))
206   - break;
207   - clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
208   - ptrace_single_step(child);
209   - child->exit_code = data;
210   - wake_up_process(child);
211   - ret = 0;
212 173 break;
213 174  
214 175 case PTRACE_GETREGS: