aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/m32r/kernel/ptrace.c42
-rw-r--r--include/asm-m32r/ptrace.h5
-rw-r--r--kernel/ptrace.c10
3 files changed, 17 insertions, 40 deletions
diff --git a/arch/m32r/kernel/ptrace.c b/arch/m32r/kernel/ptrace.c
index abbeaf8f6d0a..ed4d0756c5db 100644
--- a/arch/m32r/kernel/ptrace.c
+++ b/arch/m32r/kernel/ptrace.c
@@ -570,7 +570,7 @@ withdraw_debug_trap(struct pt_regs *regs)
570 } 570 }
571} 571}
572 572
573static void 573void
574init_debug_traps(struct task_struct *child) 574init_debug_traps(struct task_struct *child)
575{ 575{
576 struct debug_trap *p = &child->thread.debug_trap; 576 struct debug_trap *p = &child->thread.debug_trap;
@@ -593,8 +593,8 @@ void ptrace_disable(struct task_struct *child)
593 /* nothing to do.. */ 593 /* nothing to do.. */
594} 594}
595 595
596static int 596long
597do_ptrace(long request, struct task_struct *child, long addr, long data) 597arch_ptrace(struct task_struct *child, long request, long addr, long data)
598{ 598{
599 int ret; 599 int ret;
600 600
@@ -720,42 +720,6 @@ do_ptrace(long request, struct task_struct *child, long addr, long data)
720 return ret; 720 return ret;
721} 721}
722 722
723asmlinkage long sys_ptrace(long request, long pid, long addr, long data)
724{
725 struct task_struct *child;
726 int ret;
727
728 lock_kernel();
729 if (request == PTRACE_TRACEME) {
730 ret = ptrace_traceme();
731 goto out;
732 }
733
734 child = ptrace_get_task_struct(pid);
735 if (IS_ERR(child)) {
736 ret = PTR_ERR(child);
737 goto out;
738 }
739
740 if (request == PTRACE_ATTACH) {
741 ret = ptrace_attach(child);
742 if (ret == 0)
743 init_debug_traps(child);
744 goto out_tsk;
745 }
746
747 ret = ptrace_check_attach(child, request == PTRACE_KILL);
748 if (ret == 0)
749 ret = do_ptrace(request, child, addr, data);
750
751out_tsk:
752 put_task_struct(child);
753out:
754 unlock_kernel();
755
756 return ret;
757}
758
759/* notification of system call entry/exit 723/* notification of system call entry/exit
760 * - triggered by current->work.syscall_trace 724 * - triggered by current->work.syscall_trace
761 */ 725 */
diff --git a/include/asm-m32r/ptrace.h b/include/asm-m32r/ptrace.h
index 632b4ce4269a..a0755b982028 100644
--- a/include/asm-m32r/ptrace.h
+++ b/include/asm-m32r/ptrace.h
@@ -120,7 +120,10 @@ struct pt_regs {
120 120
121#include <asm/m32r.h> /* M32R_PSW_BSM, M32R_PSW_BPM */ 121#include <asm/m32r.h> /* M32R_PSW_BSM, M32R_PSW_BPM */
122 122
123#define __ARCH_SYS_PTRACE 1 123struct task_struct;
124extern void init_debug_traps(struct task_struct *);
125#define arch_ptrace_attach(child) \
126 init_debug_traps(child)
124 127
125#if defined(CONFIG_ISA_M32R2) || defined(CONFIG_CHIP_VDEC2) 128#if defined(CONFIG_ISA_M32R2) || defined(CONFIG_CHIP_VDEC2)
126#define user_mode(regs) ((M32R_PSW_BPM & (regs)->psw) != 0) 129#define user_mode(regs) ((M32R_PSW_BPM & (regs)->psw) != 0)
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 0870523c2ae4..a73ebd3b9d4c 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -453,6 +453,10 @@ struct task_struct *ptrace_get_task_struct(pid_t pid)
453 return child; 453 return child;
454} 454}
455 455
456#ifndef arch_ptrace_attach
457#define arch_ptrace_attach(child) do { } while (0)
458#endif
459
456#ifndef __ARCH_SYS_PTRACE 460#ifndef __ARCH_SYS_PTRACE
457asmlinkage long sys_ptrace(long request, long pid, long addr, long data) 461asmlinkage long sys_ptrace(long request, long pid, long addr, long data)
458{ 462{
@@ -476,6 +480,12 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data)
476 480
477 if (request == PTRACE_ATTACH) { 481 if (request == PTRACE_ATTACH) {
478 ret = ptrace_attach(child); 482 ret = ptrace_attach(child);
483 /*
484 * Some architectures need to do book-keeping after
485 * a ptrace attach.
486 */
487 if (!ret)
488 arch_ptrace_attach(child);
479 goto out_put_task_struct; 489 goto out_put_task_struct;
480 } 490 }
481 491