9 #include <linux/kernel.h>
10 #include <linux/sched.h>
12 #include <linux/ptrace.h>
13 #include <linux/errno.h>
19 #include <asm/traps.h>
20 #include <asm/uaccess.h>
22 #include <asm/mmu_context.h>
33 pr_debug(
"user_enable_single_step: pid=%u, PC=0x%08lx, SR=0x%08lx\n",
74 unsigned long __user *
data)
79 if (offset & 3 || offset >=
sizeof(
struct user)) {
80 printk(
"ptrace_read_user: invalid offset 0x%08lx\n", offset);
84 regs = (
unsigned long *)get_user_regs(tsk);
87 if (offset <
sizeof(
struct pt_regs))
88 value = regs[offset /
sizeof(regs[0])];
90 pr_debug(
"ptrace_read_user(%s[%u], %#lx, %p) -> %#lx\n",
91 tsk->
comm, tsk->
pid, offset, data, value);
101 static int ptrace_write_user(
struct task_struct *tsk,
unsigned long offset,
106 pr_debug(
"ptrace_write_user(%s[%u], %#lx, %#lx)\n",
107 tsk->
comm, tsk->
pid, offset, value);
109 if (offset & 3 || offset >=
sizeof(
struct user)) {
110 pr_debug(
" invalid offset 0x%08lx\n", offset);
114 if (offset >=
sizeof(
struct pt_regs))
117 regs = (
unsigned long *)get_user_regs(tsk);
118 regs[offset /
sizeof(regs[0])] = value;
125 struct pt_regs *regs = get_user_regs(tsk);
130 static int ptrace_setregs(
struct task_struct *tsk,
const void __user *uregs)
137 struct pt_regs *regs = get_user_regs(tsk);
140 if (valid_user_regs(&newregs)) {
150 unsigned long addr,
unsigned long data)
163 ret = ptrace_read_user(child, addr, datap);
173 ret = ptrace_write_user(child, addr, data);
177 ret = ptrace_getregs(child, datap);
181 ret = ptrace_setregs(child, datap);
210 pr_debug(
"syscall_trace: sending signal %d to PID %u\n",
237 unsigned long trampoline_addr;
246 pr_debug(
"do_debug: status=0x%08x PC=0x%08lx SR=0x%08lx tif=0x%08lx\n",
260 && test_and_clear_ti_thread_flag(
270 pr_debug(
" -> TIF_BREAKPOINT done, adjusted regs:"
271 "PC=0x%08lx SR=0x%08lx\n",
276 pr_debug(
"Going to do single step...\n");
289 "setting TIF_BREAKPOINT...\n");
307 pr_debug(
"Setting up trampoline...\n");
324 pr_debug(
"Supervisor; no single step\n");
337 die(
"Unhandled debug trap in kernel mode",
349 pr_debug(
"Sending SIGTRAP: code=%d PC=0x%08lx SR=0x%08lx\n",
350 code, regs->
pc, regs->
sr);