diff options
author | Mike Frysinger <vapier@gentoo.org> | 2010-01-26 02:33:53 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2010-03-09 00:30:51 -0500 |
commit | e8f263dfd32a784a816fe68956e564f8ede4a9fc (patch) | |
tree | 58fcc786db192f13c3df7febee705adaaf61012c /arch/blackfin/kernel/ptrace.c | |
parent | e50e2f25c5b90abd00a1e5871c45094cf5207afc (diff) |
Blackfin: initial tracehook support
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin/kernel/ptrace.c')
-rw-r--r-- | arch/blackfin/kernel/ptrace.c | 66 |
1 files changed, 17 insertions, 49 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 | */ | ||
47 | static 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 | ||
237 | void ptrace_enable(struct task_struct *child) | 219 | void 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 | /* | 225 | void 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 | */ | ||
248 | void 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 | ||
415 | asmlinkage void syscall_trace(void) | 392 | asmlinkage 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 | */ | 402 | asmlinkage 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 | } |