Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/m68k/kernel/ptrace.c |
| 3 | * |
| 4 | * Copyright (C) 1994 by Hamish Macdonald |
| 5 | * Taken from linux/kernel/ptrace.c and modified for M680x0. |
| 6 | * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds |
| 7 | * |
| 8 | * This file is subject to the terms and conditions of the GNU General |
| 9 | * Public License. See the file COPYING in the main directory of |
| 10 | * this archive for more details. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/sched.h> |
| 15 | #include <linux/mm.h> |
| 16 | #include <linux/smp.h> |
| 17 | #include <linux/smp_lock.h> |
| 18 | #include <linux/errno.h> |
| 19 | #include <linux/ptrace.h> |
| 20 | #include <linux/user.h> |
| 21 | #include <linux/config.h> |
Jesper Juhl | 7ed20e1 | 2005-05-01 08:59:14 -0700 | [diff] [blame] | 22 | #include <linux/signal.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
| 24 | #include <asm/uaccess.h> |
| 25 | #include <asm/page.h> |
| 26 | #include <asm/pgtable.h> |
| 27 | #include <asm/system.h> |
| 28 | #include <asm/processor.h> |
| 29 | |
| 30 | /* |
| 31 | * does not yet catch signals sent when the child dies. |
| 32 | * in exit.c or in signal.c. |
| 33 | */ |
| 34 | |
| 35 | /* determines which bits in the SR the user has access to. */ |
| 36 | /* 1 = access 0 = no access */ |
| 37 | #define SR_MASK 0x001f |
| 38 | |
| 39 | /* sets the trace bits. */ |
| 40 | #define TRACE_BITS 0x8000 |
| 41 | |
| 42 | /* Find the stack offset for a register, relative to thread.esp0. */ |
| 43 | #define PT_REG(reg) ((long)&((struct pt_regs *)0)->reg) |
| 44 | #define SW_REG(reg) ((long)&((struct switch_stack *)0)->reg \ |
| 45 | - sizeof(struct switch_stack)) |
| 46 | /* Mapping from PT_xxx to the stack offset at which the register is |
| 47 | saved. Notice that usp has no stack-slot and needs to be treated |
| 48 | specially (see get_reg/put_reg below). */ |
| 49 | static int regoff[] = { |
| 50 | [0] = PT_REG(d1), |
| 51 | [1] = PT_REG(d2), |
| 52 | [2] = PT_REG(d3), |
| 53 | [3] = PT_REG(d4), |
| 54 | [4] = PT_REG(d5), |
| 55 | [5] = SW_REG(d6), |
| 56 | [6] = SW_REG(d7), |
| 57 | [7] = PT_REG(a0), |
| 58 | [8] = PT_REG(a1), |
| 59 | [9] = PT_REG(a2), |
| 60 | [10] = SW_REG(a3), |
| 61 | [11] = SW_REG(a4), |
| 62 | [12] = SW_REG(a5), |
| 63 | [13] = SW_REG(a6), |
| 64 | [14] = PT_REG(d0), |
| 65 | [15] = -1, |
| 66 | [16] = PT_REG(orig_d0), |
| 67 | [17] = PT_REG(sr), |
| 68 | [18] = PT_REG(pc), |
| 69 | }; |
| 70 | |
| 71 | /* |
| 72 | * Get contents of register REGNO in task TASK. |
| 73 | */ |
| 74 | static inline long get_reg(struct task_struct *task, int regno) |
| 75 | { |
| 76 | unsigned long *addr; |
| 77 | |
| 78 | if (regno == PT_USP) |
| 79 | addr = &task->thread.usp; |
| 80 | else if (regno < sizeof(regoff)/sizeof(regoff[0])) |
| 81 | addr = (unsigned long *)(task->thread.esp0 + regoff[regno]); |
| 82 | else |
| 83 | return 0; |
| 84 | return *addr; |
| 85 | } |
| 86 | |
| 87 | /* |
| 88 | * Write contents of register REGNO in task TASK. |
| 89 | */ |
| 90 | static inline int put_reg(struct task_struct *task, int regno, |
| 91 | unsigned long data) |
| 92 | { |
| 93 | unsigned long *addr; |
| 94 | |
| 95 | if (regno == PT_USP) |
| 96 | addr = &task->thread.usp; |
| 97 | else if (regno < sizeof(regoff)/sizeof(regoff[0])) |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 98 | addr = (unsigned long *)(task->thread.esp0 + regoff[regno]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | else |
| 100 | return -1; |
| 101 | *addr = data; |
| 102 | return 0; |
| 103 | } |
| 104 | |
| 105 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | * Make sure the single step bit is not set. |
| 107 | */ |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 108 | static inline void singlestep_disable(struct task_struct *child) |
| 109 | { |
| 110 | unsigned long tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); |
| 111 | put_reg(child, PT_SR, tmp); |
| 112 | child->thread.work.delayed_trace = 0; |
| 113 | } |
| 114 | |
| 115 | /* |
| 116 | * Called by kernel/ptrace.c when detaching.. |
| 117 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | void ptrace_disable(struct task_struct *child) |
| 119 | { |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 120 | singlestep_disable(child); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | child->thread.work.syscall_trace = 0; |
| 122 | } |
| 123 | |
| 124 | asmlinkage int sys_ptrace(long request, long pid, long addr, long data) |
| 125 | { |
| 126 | struct task_struct *child; |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 127 | unsigned long tmp; |
| 128 | int i, ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
| 130 | lock_kernel(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | if (request == PTRACE_TRACEME) { |
| 132 | /* are we already being traced? */ |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 133 | if (current->ptrace & PT_PTRACED) { |
| 134 | ret = -EPERM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | goto out; |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 136 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | /* set the ptrace bit in the process flags. */ |
| 138 | current->ptrace |= PT_PTRACED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | goto out; |
| 140 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | read_lock(&tasklist_lock); |
| 142 | child = find_task_by_pid(pid); |
| 143 | if (child) |
| 144 | get_task_struct(child); |
| 145 | read_unlock(&tasklist_lock); |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 146 | if (unlikely(!child)) { |
| 147 | ret = -ESRCH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | goto out; |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 149 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 151 | /* you may not mess with init */ |
| 152 | if (unlikely(pid == 1)) { |
| 153 | ret = -EPERM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | goto out_tsk; |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 155 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | |
| 157 | if (request == PTRACE_ATTACH) { |
| 158 | ret = ptrace_attach(child); |
| 159 | goto out_tsk; |
| 160 | } |
| 161 | |
| 162 | ret = ptrace_check_attach(child, request == PTRACE_KILL); |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 163 | if (ret) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | goto out_tsk; |
| 165 | |
| 166 | switch (request) { |
| 167 | /* when I and D space are separate, these will need to be fixed. */ |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 168 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 169 | case PTRACE_PEEKDATA: |
| 170 | i = access_process_vm(child, addr, &tmp, sizeof(tmp), 0); |
| 171 | if (i != sizeof(tmp)) |
| 172 | goto out_eio; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 173 | ret = put_user(tmp, (unsigned long *)data); |
| 174 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | |
| 176 | /* read the word at location addr in the USER area. */ |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 177 | case PTRACE_PEEKUSR: |
| 178 | if (addr & 3) |
| 179 | goto out_eio; |
| 180 | addr >>= 2; /* temporary hack. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 182 | if (addr >= 0 && addr < 19) { |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 183 | tmp = get_reg(child, addr); |
| 184 | if (addr == PT_SR) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | tmp >>= 16; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 186 | } else if (addr >= 21 && addr < 49) { |
| 187 | tmp = child->thread.fp[addr - 21]; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 188 | /* Convert internal fpu reg representation |
| 189 | * into long double format |
| 190 | */ |
| 191 | if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) |
| 192 | tmp = ((tmp & 0xffff0000) << 15) | |
| 193 | ((tmp & 0x0000ffff) << 16); |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 194 | } else |
| 195 | break; |
| 196 | ret = put_user(tmp, (unsigned long *)data); |
| 197 | break; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 198 | |
| 199 | /* when I and D space are separate, this will have to be fixed. */ |
| 200 | case PTRACE_POKETEXT: /* write the word at location addr. */ |
| 201 | case PTRACE_POKEDATA: |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 202 | if (access_process_vm(child, addr, &data, sizeof(data), 1) != sizeof(data)) |
| 203 | goto out_eio; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 204 | break; |
| 205 | |
| 206 | case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 207 | if (addr & 3) |
| 208 | goto out_eio; |
| 209 | addr >>= 2; /* temporary hack. */ |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 210 | |
| 211 | if (addr == PT_SR) { |
| 212 | data &= SR_MASK; |
| 213 | data <<= 16; |
| 214 | data |= get_reg(child, PT_SR) & ~(SR_MASK << 16); |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 215 | } else if (addr >= 0 && addr < 19) { |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 216 | if (put_reg(child, addr, data)) |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 217 | goto out_eio; |
| 218 | } else if (addr >= 21 && addr < 48) { |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 219 | /* Convert long double format |
| 220 | * into internal fpu reg representation |
| 221 | */ |
| 222 | if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) { |
| 223 | data = (unsigned long)data << 15; |
| 224 | data = (data & 0xffff0000) | |
| 225 | ((data & 0x0000ffff) >> 1); |
| 226 | } |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 227 | child->thread.fp[addr - 21] = data; |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 228 | } else |
| 229 | goto out_eio; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 230 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 232 | case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 233 | case PTRACE_CONT: /* restart after signal. */ |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 234 | if (!valid_signal(data)) |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 235 | goto out_eio; |
| 236 | |
| 237 | if (request == PTRACE_SYSCALL) |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 238 | child->thread.work.syscall_trace = ~0; |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 239 | else |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 240 | child->thread.work.syscall_trace = 0; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 241 | child->exit_code = data; |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 242 | singlestep_disable(child); |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 243 | wake_up_process(child); |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 244 | break; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 245 | |
| 246 | /* |
| 247 | * make the child exit. Best I can do is send it a sigkill. |
| 248 | * perhaps it should be put in the status that it wants to |
| 249 | * exit. |
| 250 | */ |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 251 | case PTRACE_KILL: |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 252 | if (child->exit_state == EXIT_ZOMBIE) /* already dead */ |
| 253 | break; |
| 254 | child->exit_code = SIGKILL; |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 255 | singlestep_disable(child); |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 256 | wake_up_process(child); |
| 257 | break; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 258 | |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 259 | case PTRACE_SINGLESTEP: /* set the trap flag. */ |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 260 | if (!valid_signal(data)) |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 261 | goto out_eio; |
| 262 | |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 263 | child->thread.work.syscall_trace = 0; |
| 264 | tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16); |
| 265 | put_reg(child, PT_SR, tmp); |
| 266 | child->thread.work.delayed_trace = 1; |
| 267 | |
| 268 | child->exit_code = data; |
| 269 | /* give it a chance to run. */ |
| 270 | wake_up_process(child); |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 271 | break; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 272 | |
| 273 | case PTRACE_DETACH: /* detach a process that was attached. */ |
| 274 | ret = ptrace_detach(child, data); |
| 275 | break; |
| 276 | |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 277 | case PTRACE_GETREGS: /* Get all gp regs from the child. */ |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 278 | for (i = 0; i < 19; i++) { |
| 279 | tmp = get_reg(child, i); |
| 280 | if (i == PT_SR) |
| 281 | tmp >>= 16; |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 282 | ret = put_user(tmp, (unsigned long *)data); |
| 283 | if (ret) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | break; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 285 | data += sizeof(long); |
| 286 | } |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 287 | break; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 288 | |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 289 | case PTRACE_SETREGS: /* Set all gp regs in the child. */ |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 290 | for (i = 0; i < 19; i++) { |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 291 | ret = get_user(tmp, (unsigned long *)data); |
| 292 | if (ret) |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 293 | break; |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 294 | if (i == PT_SR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | tmp &= SR_MASK; |
| 296 | tmp <<= 16; |
| 297 | tmp |= get_reg(child, PT_SR) & ~(SR_MASK << 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | } |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 299 | put_reg(child, i, tmp); |
| 300 | data += sizeof(long); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | } |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 302 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 304 | case PTRACE_GETFPREGS: /* Get the child FPU state. */ |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 305 | if (copy_to_user((void *)data, &child->thread.fp, |
| 306 | sizeof(struct user_m68kfp_struct))) |
| 307 | ret = -EFAULT; |
| 308 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 310 | case PTRACE_SETFPREGS: /* Set the child FPU state. */ |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 311 | if (copy_from_user(&child->thread.fp, (void *)data, |
| 312 | sizeof(struct user_m68kfp_struct))) |
| 313 | ret = -EFAULT; |
| 314 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
Roman Zippel | b3319f5 | 2005-09-03 15:57:07 -0700 | [diff] [blame] | 316 | default: |
| 317 | ret = ptrace_request(child, request, addr, data); |
| 318 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | } |
| 320 | out_tsk: |
| 321 | put_task_struct(child); |
| 322 | out: |
| 323 | unlock_kernel(); |
| 324 | return ret; |
Roman Zippel | 69f447c | 2005-09-03 15:57:08 -0700 | [diff] [blame^] | 325 | out_eio: |
| 326 | ret = -EIO; |
| 327 | goto out_tsk; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | asmlinkage void syscall_trace(void) |
| 331 | { |
| 332 | if (!current->thread.work.delayed_trace && |
| 333 | !current->thread.work.syscall_trace) |
| 334 | return; |
| 335 | ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) |
| 336 | ? 0x80 : 0)); |
| 337 | /* |
| 338 | * this isn't the same as continuing with a signal, but it will do |
| 339 | * for normal use. strace only continues with a signal if the |
| 340 | * stopping signal is not SIGTRAP. -brl |
| 341 | */ |
| 342 | if (current->exit_code) { |
| 343 | send_sig(current->exit_code, current, 1); |
| 344 | current->exit_code = 0; |
| 345 | } |
| 346 | } |