aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-03-10 18:22:51 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-12 18:52:38 -0500
commit1d8393171b1f6c30a889fd7cb16fc193f689923c (patch)
treef151b10950918700085bb7b4d4d905d54e7826f2 /arch
parent440e6ca79aebdc274ce4c625a6f42c8bf3c7bc91 (diff)
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>
Diffstat (limited to 'arch')
-rw-r--r--arch/avr32/include/asm/ptrace.h2
-rw-r--r--arch/avr32/kernel/ptrace.c53
2 files changed, 9 insertions, 46 deletions
diff --git a/arch/avr32/include/asm/ptrace.h b/arch/avr32/include/asm/ptrace.h
index 9e2d44f4e0fe..e53dd0d900f5 100644
--- a/arch/avr32/include/asm/ptrace.h
+++ b/arch/avr32/include/asm/ptrace.h
@@ -124,6 +124,8 @@ struct pt_regs {
124 124
125#include <asm/ocd.h> 125#include <asm/ocd.h>
126 126
127#define arch_has_single_step() (1)
128
127#define arch_ptrace_attach(child) ocd_enable(child) 129#define arch_ptrace_attach(child) ocd_enable(child)
128 130
129#define user_mode(regs) (((regs)->sr & MODE_MASK) == MODE_USER) 131#define user_mode(regs) (((regs)->sr & MODE_MASK) == MODE_USER)
diff --git a/arch/avr32/kernel/ptrace.c b/arch/avr32/kernel/ptrace.c
index 1fed38fcf594..dd5b882aab40 100644
--- a/arch/avr32/kernel/ptrace.c
+++ b/arch/avr32/kernel/ptrace.c
@@ -28,9 +28,9 @@ static struct pt_regs *get_user_regs(struct task_struct *tsk)
28 THREAD_SIZE - sizeof(struct pt_regs)); 28 THREAD_SIZE - sizeof(struct pt_regs));
29} 29}
30 30
31static void ptrace_single_step(struct task_struct *tsk) 31static 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 tsk->pid, task_pt_regs(tsk)->pc, task_pt_regs(tsk)->sr); 34 tsk->pid, task_pt_regs(tsk)->pc, task_pt_regs(tsk)->sr);
35 35
36 /* 36 /*
@@ -49,6 +49,11 @@ static void ptrace_single_step(struct task_struct *tsk)
49 set_tsk_thread_flag(tsk, TIF_SINGLE_STEP); 49 set_tsk_thread_flag(tsk, TIF_SINGLE_STEP);
50} 50}
51 51
52void user_disable_single_step(struct task_struct *child)
53{
54 /* XXX(hch): a no-op here seems wrong.. */
55}
56
52/* 57/*
53 * Called by kernel/ptrace.c when detaching 58 * Called by kernel/ptrace.c when detaching
54 * 59 *
@@ -167,50 +172,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
167 ret = ptrace_write_user(child, addr, data); 172 ret = ptrace_write_user(child, addr, data);
168 break; 173 break;
169 174
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 break;
213
214 case PTRACE_GETREGS: 175 case PTRACE_GETREGS:
215 ret = ptrace_getregs(child, (void __user *)data); 176 ret = ptrace_getregs(child, (void __user *)data);
216 break; 177 break;