aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-01-26 02:33:53 -0500
committerMike Frysinger <vapier@gentoo.org>2010-03-09 00:30:51 -0500
commite8f263dfd32a784a816fe68956e564f8ede4a9fc (patch)
tree58fcc786db192f13c3df7febee705adaaf61012c /arch/blackfin/kernel
parente50e2f25c5b90abd00a1e5871c45094cf5207afc (diff)
Blackfin: initial tracehook support
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin/kernel')
-rw-r--r--arch/blackfin/kernel/ptrace.c66
-rw-r--r--arch/blackfin/kernel/signal.c14
2 files changed, 20 insertions, 60 deletions
diff --git a/arch/blackfin/kernel/ptrace.c b/arch/blackfin/kernel/ptrace.c
index 92b4ca0b5af6..0618b8287e34 100644
--- a/arch/blackfin/kernel/ptrace.c
+++ b/arch/blackfin/kernel/ptrace.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds 2 * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
3 * these modifications are Copyright 2004-2009 Analog Devices Inc. 3 * these modifications are Copyright 2004-2010 Analog Devices Inc.
4 * 4 *
5 * Licensed under the GPL-2 5 * Licensed under the GPL-2
6 */ 6 */
@@ -15,6 +15,7 @@
15#include <linux/user.h> 15#include <linux/user.h>
16#include <linux/regset.h> 16#include <linux/regset.h>
17#include <linux/signal.h> 17#include <linux/signal.h>
18#include <linux/tracehook.h>
18#include <linux/uaccess.h> 19#include <linux/uaccess.h>
19 20
20#include <asm/page.h> 21#include <asm/page.h>
@@ -32,25 +33,6 @@
32 * in exit.c or in signal.c. 33 * in exit.c or in signal.c.
33 */ 34 */
34 35
35/* Find the stack offset for a register, relative to thread.esp0. */
36#define PT_REG(reg) ((long)&((struct pt_regs *)0)->reg)
37
38/*
39 * Get the address of the live pt_regs for the specified task.
40 * These are saved onto the top kernel stack when the process
41 * is not running.
42 *
43 * Note: if a user thread is execve'd from kernel space, the
44 * kernel stack will not be empty on entry to the kernel, so
45 * ptracing these tasks will fail.
46 */
47static inline struct pt_regs *task_pt_regs(struct task_struct *task)
48{
49 return (struct pt_regs *)
50 ((unsigned long)task_stack_page(task) +
51 (THREAD_SIZE - sizeof(struct pt_regs)));
52}
53
54/* 36/*
55 * Get contents of register REGNO in task TASK. 37 * Get contents of register REGNO in task TASK.
56 */ 38 */
@@ -234,18 +216,13 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
234 return &user_bfin_native_view; 216 return &user_bfin_native_view;
235} 217}
236 218
237void ptrace_enable(struct task_struct *child) 219void user_enable_single_step(struct task_struct *child)
238{ 220{
239 struct pt_regs *regs = task_pt_regs(child); 221 struct pt_regs *regs = task_pt_regs(child);
240 regs->syscfg |= SYSCFG_SSSTEP; 222 regs->syscfg |= SYSCFG_SSSTEP;
241} 223}
242 224
243/* 225void user_disable_single_step(struct task_struct *child)
244 * Called by kernel/ptrace.c when detaching..
245 *
246 * Make sure the single step bit is not set.
247 */
248void ptrace_disable(struct task_struct *child)
249{ 226{
250 struct pt_regs *regs = task_pt_regs(child); 227 struct pt_regs *regs = task_pt_regs(child);
251 regs->syscfg &= ~SYSCFG_SSSTEP; 228 regs->syscfg &= ~SYSCFG_SSSTEP;
@@ -412,27 +389,18 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
412 return ret; 389 return ret;
413} 390}
414 391
415asmlinkage void syscall_trace(void) 392asmlinkage int syscall_trace_enter(struct pt_regs *regs)
416{ 393{
417 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 394 int ret = 0;
418 return; 395
419 396 if (test_thread_flag(TIF_SYSCALL_TRACE))
420 if (!(current->ptrace & PT_PTRACED)) 397 ret = tracehook_report_syscall_entry(regs);
421 return; 398
422 399 return ret;
423 /* the 0x80 provides a way for the tracing parent to distinguish 400}
424 * between a syscall stop and SIGTRAP delivery 401
425 */ 402asmlinkage void syscall_trace_leave(struct pt_regs *regs)
426 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) 403{
427 ? 0x80 : 0)); 404 if (test_thread_flag(TIF_SYSCALL_TRACE))
428 405 tracehook_report_syscall_exit(regs, 0);
429 /*
430 * this isn't the same as continuing with a signal, but it will do
431 * for normal use. strace only continues with a signal if the
432 * stopping signal is not SIGTRAP. -brl
433 */
434 if (current->exit_code) {
435 send_sig(current->exit_code, current, 1);
436 current->exit_code = 0;
437 }
438} 406}
diff --git a/arch/blackfin/kernel/signal.c b/arch/blackfin/kernel/signal.c
index e0fd63e9e38a..e60990c0a1f0 100644
--- a/arch/blackfin/kernel/signal.c
+++ b/arch/blackfin/kernel/signal.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2004-2009 Analog Devices Inc. 2 * Copyright 2004-2010 Analog Devices Inc.
3 * 3 *
4 * Licensed under the GPL-2 or later 4 * Licensed under the GPL-2 or later
5 */ 5 */
@@ -206,16 +206,6 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t * info,
206 regs->r1 = (unsigned long)(&frame->info); 206 regs->r1 = (unsigned long)(&frame->info);
207 regs->r2 = (unsigned long)(&frame->uc); 207 regs->r2 = (unsigned long)(&frame->uc);
208 208
209 /*
210 * Clear the trace flag when entering the signal handler, but
211 * notify any tracer that was single-stepping it. The tracer
212 * may want to single-step inside the handler too.
213 */
214 if (regs->syscfg & TRACE_BITS) {
215 regs->syscfg &= ~TRACE_BITS;
216 ptrace_notify(SIGTRAP);
217 }
218
219 return 0; 209 return 0;
220 210
221 give_sigsegv: 211 give_sigsegv:
@@ -315,6 +305,8 @@ asmlinkage void do_signal(struct pt_regs *regs)
315 * clear the TIF_RESTORE_SIGMASK flag */ 305 * clear the TIF_RESTORE_SIGMASK flag */
316 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 306 if (test_thread_flag(TIF_RESTORE_SIGMASK))
317 clear_thread_flag(TIF_RESTORE_SIGMASK); 307 clear_thread_flag(TIF_RESTORE_SIGMASK);
308
309 tracehook_signal_handler(signr, &info, &ka, regs, 1);
318 } 310 }
319 311
320 return; 312 return;