aboutsummaryrefslogtreecommitdiffstats
path: root/arch/xtensa
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-03-10 18:22:57 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-12 18:52:39 -0500
commit6d75ca10225be4c7509026f9b61c740b22e734e4 (patch)
tree3a57ab05345bb25aff05e5da913468ee2897b45f /arch/xtensa
parent1bd095083558928cc3b36b826422d69bcd743dca (diff)
xtensa: 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. Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Roland McGrath <roland@redhat.com> Cc: Chris Zankel <chris@zankel.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/xtensa')
-rw-r--r--arch/xtensa/include/asm/ptrace.h1
-rw-r--r--arch/xtensa/kernel/ptrace.c56
2 files changed, 12 insertions, 45 deletions
diff --git a/arch/xtensa/include/asm/ptrace.h b/arch/xtensa/include/asm/ptrace.h
index 905e1e619654..3c549f798727 100644
--- a/arch/xtensa/include/asm/ptrace.h
+++ b/arch/xtensa/include/asm/ptrace.h
@@ -113,6 +113,7 @@ struct pt_regs {
113 113
114#include <variant/core.h> 114#include <variant/core.h>
115 115
116# define arch_has_single_step() (1)
116# define task_pt_regs(tsk) ((struct pt_regs*) \ 117# define task_pt_regs(tsk) ((struct pt_regs*) \
117 (task_stack_page(tsk) + KERNEL_STACK_SIZE - (XCHAL_NUM_AREGS-16)*4) - 1) 118 (task_stack_page(tsk) + KERNEL_STACK_SIZE - (XCHAL_NUM_AREGS-16)*4) - 1)
118# define user_mode(regs) (((regs)->ps & 0x00000020)!=0) 119# define user_mode(regs) (((regs)->ps & 0x00000020)!=0)
diff --git a/arch/xtensa/kernel/ptrace.c b/arch/xtensa/kernel/ptrace.c
index 9486882ef0af..9d4e1ceb3f09 100644
--- a/arch/xtensa/kernel/ptrace.c
+++ b/arch/xtensa/kernel/ptrace.c
@@ -30,6 +30,17 @@
30#include <asm/elf.h> 30#include <asm/elf.h>
31#include <asm/coprocessor.h> 31#include <asm/coprocessor.h>
32 32
33
34void user_enable_single_step(struct task_struct *child)
35{
36 child->ptrace |= PT_SINGLESTEP;
37}
38
39void user_disable_single_step(struct task_struct *child)
40{
41 child->ptrace &= ~PT_SINGLESTEP;
42}
43
33/* 44/*
34 * Called by kernel/ptrace.c when detaching to disable single stepping. 45 * Called by kernel/ptrace.c when detaching to disable single stepping.
35 */ 46 */
@@ -268,51 +279,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
268 ret = ptrace_pokeusr(child, addr, data); 279 ret = ptrace_pokeusr(child, addr, data);
269 break; 280 break;
270 281
271 /* continue and stop at next (return from) syscall */
272
273 case PTRACE_SYSCALL:
274 case PTRACE_CONT: /* restart after signal. */
275 {
276 ret = -EIO;
277 if (!valid_signal(data))
278 break;
279 if (request == PTRACE_SYSCALL)
280 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
281 else
282 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
283 child->exit_code = data;
284 /* Make sure the single step bit is not set. */
285 child->ptrace &= ~PT_SINGLESTEP;
286 wake_up_process(child);
287 ret = 0;
288 break;
289 }
290
291 /*
292 * make the child exit. Best I can do is send it a sigkill.
293 * perhaps it should be put in the status that it wants to
294 * exit.
295 */
296 case PTRACE_KILL:
297 ret = 0;
298 if (child->exit_state == EXIT_ZOMBIE) /* already dead */
299 break;
300 child->exit_code = SIGKILL;
301 child->ptrace &= ~PT_SINGLESTEP;
302 wake_up_process(child);
303 break;
304
305 case PTRACE_SINGLESTEP:
306 ret = -EIO;
307 if (!valid_signal(data))
308 break;
309 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
310 child->ptrace |= PT_SINGLESTEP;
311 child->exit_code = data;
312 wake_up_process(child);
313 ret = 0;
314 break;
315
316 case PTRACE_GETREGS: 282 case PTRACE_GETREGS:
317 ret = ptrace_getregs(child, (void __user *) data); 283 ret = ptrace_getregs(child, (void __user *) data);
318 break; 284 break;