2 * linux/arch/h8300/kernel/ptrace.c
4 * Yoshinori Sato <ysato@users.sourceforge.jp>
7 * linux/arch/m68k/kernel/ptrace.c
9 * Copyright (C) 1994 by Hamish Macdonald
10 * Taken from linux/kernel/ptrace.c and modified for M680x0.
11 * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
13 * This file is subject to the terms and conditions of the GNU General
14 * Public License. See the file COPYING in the main directory of
15 * this archive for more details.
18 #include <linux/kernel.h>
19 #include <linux/sched.h>
21 #include <linux/smp.h>
22 #include <linux/errno.h>
23 #include <linux/ptrace.h>
24 #include <linux/user.h>
25 #include <linux/signal.h>
27 #include <asm/uaccess.h>
29 #include <asm/pgtable.h>
30 #include <asm/processor.h>
31 #include <asm/signal.h>
33 /* cpu depend functions */
34 extern long h8300_get_reg(struct task_struct
*task
, int regno
);
35 extern int h8300_put_reg(struct task_struct
*task
, int regno
, unsigned long data
);
38 void user_disable_single_step(struct task_struct
*child
)
43 * does not yet catch signals sent when the child dies.
44 * in exit.c or in signal.c.
47 void ptrace_disable(struct task_struct
*child
)
49 user_disable_single_step(child
);
52 long arch_ptrace(struct task_struct
*child
, long request
,
53 unsigned long addr
, unsigned long data
)
56 int regno
= addr
>> 2;
57 unsigned long __user
*datap
= (unsigned long __user
*) data
;
60 /* read the word at location addr in the USER area. */
61 case PTRACE_PEEKUSR
: {
62 unsigned long tmp
= 0;
64 if ((addr
& 3) || addr
>= sizeof(struct user
)) {
69 ret
= 0; /* Default return condition */
71 if (regno
< H8300_REGS_NO
)
72 tmp
= h8300_get_reg(child
, regno
);
76 tmp
= child
->mm
->start_code
;
79 tmp
= child
->mm
->start_data
;
82 tmp
= child
->mm
->end_code
;
85 tmp
= child
->mm
->end_data
;
92 ret
= put_user(tmp
, datap
);
96 /* when I and D space are separate, this will have to be fixed. */
97 case PTRACE_POKEUSR
: /* write the word at location addr in the USER area */
98 if ((addr
& 3) || addr
>= sizeof(struct user
)) {
103 if (regno
== PT_ORIG_ER0
) {
107 if (regno
< H8300_REGS_NO
) {
108 ret
= h8300_put_reg(child
, regno
, data
);
114 case PTRACE_GETREGS
: { /* Get all gp regs from the child. */
117 for (i
= 0; i
< H8300_REGS_NO
; i
++) {
118 tmp
= h8300_get_reg(child
, i
);
119 if (put_user(tmp
, datap
)) {
129 case PTRACE_SETREGS
: { /* Set all gp regs in the child. */
132 for (i
= 0; i
< H8300_REGS_NO
; i
++) {
133 if (get_user(tmp
, datap
)) {
137 h8300_put_reg(child
, i
, tmp
);
145 ret
= ptrace_request(child
, request
, addr
, data
);
151 asmlinkage
void do_syscall_trace(void)
153 if (!test_thread_flag(TIF_SYSCALL_TRACE
))
155 if (!(current
->ptrace
& PT_PTRACED
))
157 ptrace_notify(SIGTRAP
| ((current
->ptrace
& PT_TRACESYSGOOD
)
160 * this isn't the same as continuing with a signal, but it will do
161 * for normal use. strace only continues with a signal if the
162 * stopping signal is not SIGTRAP. -brl
164 if (current
->exit_code
) {
165 send_sig(current
->exit_code
, current
, 1);
166 current
->exit_code
= 0;