diff options
author | David Howells <dhowells@redhat.com> | 2009-06-11 08:08:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-11 12:02:20 -0400 |
commit | 5d289964e1f1e8a2ec4289274bf15bce6a4f8ab8 (patch) | |
tree | 061886f652727e344067fef18ed50446bae84986 /arch/mn10300/kernel/ptrace.c | |
parent | fd4f683d045e053abb093f80d81afce30ceadad2 (diff) |
MN10300: Add utrace/tracehooks support
Add utrace/tracehooks support to MN10300.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/mn10300/kernel/ptrace.c')
-rw-r--r-- | arch/mn10300/kernel/ptrace.c | 454 |
1 files changed, 231 insertions, 223 deletions
diff --git a/arch/mn10300/kernel/ptrace.c b/arch/mn10300/kernel/ptrace.c index d6d6cdc75c52..e143339ad28e 100644 --- a/arch/mn10300/kernel/ptrace.c +++ b/arch/mn10300/kernel/ptrace.c | |||
@@ -17,6 +17,9 @@ | |||
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/ptrace.h> | 18 | #include <linux/ptrace.h> |
19 | #include <linux/user.h> | 19 | #include <linux/user.h> |
20 | #include <linux/regset.h> | ||
21 | #include <linux/elf.h> | ||
22 | #include <linux/tracehook.h> | ||
20 | #include <asm/uaccess.h> | 23 | #include <asm/uaccess.h> |
21 | #include <asm/pgtable.h> | 24 | #include <asm/pgtable.h> |
22 | #include <asm/system.h> | 25 | #include <asm/system.h> |
@@ -64,12 +67,6 @@ static inline int get_stack_long(struct task_struct *task, int offset) | |||
64 | ((unsigned long) task->thread.uregs + offset); | 67 | ((unsigned long) task->thread.uregs + offset); |
65 | } | 68 | } |
66 | 69 | ||
67 | /* | ||
68 | * this routine will put a word on the processes privileged stack. | ||
69 | * the offset is how far from the base addr as stored in the TSS. | ||
70 | * this routine assumes that all the privileged stacks are in our | ||
71 | * data space. | ||
72 | */ | ||
73 | static inline | 70 | static inline |
74 | int put_stack_long(struct task_struct *task, int offset, unsigned long data) | 71 | int put_stack_long(struct task_struct *task, int offset, unsigned long data) |
75 | { | 72 | { |
@@ -80,94 +77,233 @@ int put_stack_long(struct task_struct *task, int offset, unsigned long data) | |||
80 | return 0; | 77 | return 0; |
81 | } | 78 | } |
82 | 79 | ||
83 | static inline unsigned long get_fpregs(struct fpu_state_struct *buf, | 80 | /* |
84 | struct task_struct *tsk) | 81 | * retrieve the contents of MN10300 userspace general registers |
82 | */ | ||
83 | static int genregs_get(struct task_struct *target, | ||
84 | const struct user_regset *regset, | ||
85 | unsigned int pos, unsigned int count, | ||
86 | void *kbuf, void __user *ubuf) | ||
85 | { | 87 | { |
86 | return __copy_to_user(buf, &tsk->thread.fpu_state, | 88 | const struct pt_regs *regs = task_pt_regs(target); |
87 | sizeof(struct fpu_state_struct)); | 89 | int ret; |
90 | |||
91 | /* we need to skip regs->next */ | ||
92 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, | ||
93 | regs, 0, PT_ORIG_D0 * sizeof(long)); | ||
94 | if (ret < 0) | ||
95 | return ret; | ||
96 | |||
97 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, | ||
98 | ®s->orig_d0, PT_ORIG_D0 * sizeof(long), | ||
99 | NR_PTREGS * sizeof(long)); | ||
100 | if (ret < 0) | ||
101 | return ret; | ||
102 | |||
103 | return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, | ||
104 | NR_PTREGS * sizeof(long), -1); | ||
88 | } | 105 | } |
89 | 106 | ||
90 | static inline unsigned long set_fpregs(struct task_struct *tsk, | 107 | /* |
91 | struct fpu_state_struct *buf) | 108 | * update the contents of the MN10300 userspace general registers |
109 | */ | ||
110 | static int genregs_set(struct task_struct *target, | ||
111 | const struct user_regset *regset, | ||
112 | unsigned int pos, unsigned int count, | ||
113 | const void *kbuf, const void __user *ubuf) | ||
92 | { | 114 | { |
93 | return __copy_from_user(&tsk->thread.fpu_state, buf, | 115 | struct pt_regs *regs = task_pt_regs(target); |
94 | sizeof(struct fpu_state_struct)); | 116 | unsigned long tmp; |
117 | int ret; | ||
118 | |||
119 | /* we need to skip regs->next */ | ||
120 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, | ||
121 | regs, 0, PT_ORIG_D0 * sizeof(long)); | ||
122 | if (ret < 0) | ||
123 | return ret; | ||
124 | |||
125 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, | ||
126 | ®s->orig_d0, PT_ORIG_D0 * sizeof(long), | ||
127 | PT_EPSW * sizeof(long)); | ||
128 | if (ret < 0) | ||
129 | return ret; | ||
130 | |||
131 | /* we need to mask off changes to EPSW */ | ||
132 | tmp = regs->epsw; | ||
133 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, | ||
134 | &tmp, PT_EPSW * sizeof(long), | ||
135 | PT_PC * sizeof(long)); | ||
136 | tmp &= EPSW_FLAG_V | EPSW_FLAG_C | EPSW_FLAG_N | EPSW_FLAG_Z; | ||
137 | tmp |= regs->epsw & ~(EPSW_FLAG_V | EPSW_FLAG_C | EPSW_FLAG_N | | ||
138 | EPSW_FLAG_Z); | ||
139 | regs->epsw = tmp; | ||
140 | |||
141 | if (ret < 0) | ||
142 | return ret; | ||
143 | |||
144 | /* and finally load the PC */ | ||
145 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, | ||
146 | ®s->pc, PT_PC * sizeof(long), | ||
147 | NR_PTREGS * sizeof(long)); | ||
148 | |||
149 | if (ret < 0) | ||
150 | return ret; | ||
151 | |||
152 | return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, | ||
153 | NR_PTREGS * sizeof(long), -1); | ||
95 | } | 154 | } |
96 | 155 | ||
97 | static inline void fpsave_init(struct task_struct *task) | 156 | /* |
157 | * retrieve the contents of MN10300 userspace FPU registers | ||
158 | */ | ||
159 | static int fpuregs_get(struct task_struct *target, | ||
160 | const struct user_regset *regset, | ||
161 | unsigned int pos, unsigned int count, | ||
162 | void *kbuf, void __user *ubuf) | ||
98 | { | 163 | { |
99 | memset(&task->thread.fpu_state, 0, sizeof(struct fpu_state_struct)); | 164 | const struct fpu_state_struct *fpregs = &target->thread.fpu_state; |
165 | int ret; | ||
166 | |||
167 | unlazy_fpu(target); | ||
168 | |||
169 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, | ||
170 | fpregs, 0, sizeof(*fpregs)); | ||
171 | if (ret < 0) | ||
172 | return ret; | ||
173 | |||
174 | return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, | ||
175 | sizeof(*fpregs), -1); | ||
100 | } | 176 | } |
101 | 177 | ||
102 | /* | 178 | /* |
103 | * make sure the single step bit is not set | 179 | * update the contents of the MN10300 userspace FPU registers |
104 | */ | 180 | */ |
105 | void ptrace_disable(struct task_struct *child) | 181 | static int fpuregs_set(struct task_struct *target, |
182 | const struct user_regset *regset, | ||
183 | unsigned int pos, unsigned int count, | ||
184 | const void *kbuf, const void __user *ubuf) | ||
185 | { | ||
186 | struct fpu_state_struct fpu_state = target->thread.fpu_state; | ||
187 | int ret; | ||
188 | |||
189 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, | ||
190 | &fpu_state, 0, sizeof(fpu_state)); | ||
191 | if (ret < 0) | ||
192 | return ret; | ||
193 | |||
194 | fpu_kill_state(target); | ||
195 | target->thread.fpu_state = fpu_state; | ||
196 | set_using_fpu(target); | ||
197 | |||
198 | return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, | ||
199 | sizeof(fpu_state), -1); | ||
200 | } | ||
201 | |||
202 | /* | ||
203 | * determine if the FPU registers have actually been used | ||
204 | */ | ||
205 | static int fpuregs_active(struct task_struct *target, | ||
206 | const struct user_regset *regset) | ||
207 | { | ||
208 | return is_using_fpu(target) ? regset->n : 0; | ||
209 | } | ||
210 | |||
211 | /* | ||
212 | * Define the register sets available on the MN10300 under Linux | ||
213 | */ | ||
214 | enum mn10300_regset { | ||
215 | REGSET_GENERAL, | ||
216 | REGSET_FPU, | ||
217 | }; | ||
218 | |||
219 | static const struct user_regset mn10300_regsets[] = { | ||
220 | /* | ||
221 | * General register format is: | ||
222 | * A3, A2, D3, D2, MCVF, MCRL, MCRH, MDRQ | ||
223 | * E1, E0, E7...E2, SP, LAR, LIR, MDR | ||
224 | * A1, A0, D1, D0, ORIG_D0, EPSW, PC | ||
225 | */ | ||
226 | [REGSET_GENERAL] = { | ||
227 | .core_note_type = NT_PRSTATUS, | ||
228 | .n = ELF_NGREG, | ||
229 | .size = sizeof(long), | ||
230 | .align = sizeof(long), | ||
231 | .get = genregs_get, | ||
232 | .set = genregs_set, | ||
233 | }, | ||
234 | /* | ||
235 | * FPU register format is: | ||
236 | * FS0-31, FPCR | ||
237 | */ | ||
238 | [REGSET_FPU] = { | ||
239 | .core_note_type = NT_PRFPREG, | ||
240 | .n = sizeof(struct fpu_state_struct) / sizeof(long), | ||
241 | .size = sizeof(long), | ||
242 | .align = sizeof(long), | ||
243 | .get = fpuregs_get, | ||
244 | .set = fpuregs_set, | ||
245 | .active = fpuregs_active, | ||
246 | }, | ||
247 | }; | ||
248 | |||
249 | static const struct user_regset_view user_mn10300_native_view = { | ||
250 | .name = "mn10300", | ||
251 | .e_machine = EM_MN10300, | ||
252 | .regsets = mn10300_regsets, | ||
253 | .n = ARRAY_SIZE(mn10300_regsets), | ||
254 | }; | ||
255 | |||
256 | const struct user_regset_view *task_user_regset_view(struct task_struct *task) | ||
257 | { | ||
258 | return &user_mn10300_native_view; | ||
259 | } | ||
260 | |||
261 | /* | ||
262 | * set the single-step bit | ||
263 | */ | ||
264 | void user_enable_single_step(struct task_struct *child) | ||
106 | { | 265 | { |
107 | #ifndef CONFIG_MN10300_USING_JTAG | 266 | #ifndef CONFIG_MN10300_USING_JTAG |
108 | struct user *dummy = NULL; | 267 | struct user *dummy = NULL; |
109 | long tmp; | 268 | long tmp; |
110 | 269 | ||
111 | tmp = get_stack_long(child, (unsigned long) &dummy->regs.epsw); | 270 | tmp = get_stack_long(child, (unsigned long) &dummy->regs.epsw); |
112 | tmp &= ~EPSW_T; | 271 | tmp |= EPSW_T; |
113 | put_stack_long(child, (unsigned long) &dummy->regs.epsw, tmp); | 272 | put_stack_long(child, (unsigned long) &dummy->regs.epsw, tmp); |
114 | #endif | 273 | #endif |
115 | } | 274 | } |
116 | 275 | ||
117 | /* | 276 | /* |
118 | * set the single step bit | 277 | * make sure the single-step bit is not set |
119 | */ | 278 | */ |
120 | void ptrace_enable(struct task_struct *child) | 279 | void user_disable_single_step(struct task_struct *child) |
121 | { | 280 | { |
122 | #ifndef CONFIG_MN10300_USING_JTAG | 281 | #ifndef CONFIG_MN10300_USING_JTAG |
123 | struct user *dummy = NULL; | 282 | struct user *dummy = NULL; |
124 | long tmp; | 283 | long tmp; |
125 | 284 | ||
126 | tmp = get_stack_long(child, (unsigned long) &dummy->regs.epsw); | 285 | tmp = get_stack_long(child, (unsigned long) &dummy->regs.epsw); |
127 | tmp |= EPSW_T; | 286 | tmp &= ~EPSW_T; |
128 | put_stack_long(child, (unsigned long) &dummy->regs.epsw, tmp); | 287 | put_stack_long(child, (unsigned long) &dummy->regs.epsw, tmp); |
129 | #endif | 288 | #endif |
130 | } | 289 | } |
131 | 290 | ||
291 | void ptrace_disable(struct task_struct *child) | ||
292 | { | ||
293 | user_disable_single_step(child); | ||
294 | } | ||
295 | |||
132 | /* | 296 | /* |
133 | * handle the arch-specific side of process tracing | 297 | * handle the arch-specific side of process tracing |
134 | */ | 298 | */ |
135 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) | 299 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
136 | { | 300 | { |
137 | struct fpu_state_struct fpu_state; | 301 | unsigned long tmp; |
138 | int i, ret; | 302 | int ret; |
139 | 303 | ||
140 | switch (request) { | 304 | switch (request) { |
141 | /* read the word at location addr. */ | ||
142 | case PTRACE_PEEKTEXT: { | ||
143 | unsigned long tmp; | ||
144 | int copied; | ||
145 | |||
146 | copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0); | ||
147 | ret = -EIO; | ||
148 | if (copied != sizeof(tmp)) | ||
149 | break; | ||
150 | ret = put_user(tmp, (unsigned long *) data); | ||
151 | break; | ||
152 | } | ||
153 | |||
154 | /* read the word at location addr. */ | ||
155 | case PTRACE_PEEKDATA: { | ||
156 | unsigned long tmp; | ||
157 | int copied; | ||
158 | |||
159 | copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0); | ||
160 | ret = -EIO; | ||
161 | if (copied != sizeof(tmp)) | ||
162 | break; | ||
163 | ret = put_user(tmp, (unsigned long *) data); | ||
164 | break; | ||
165 | } | ||
166 | |||
167 | /* read the word at location addr in the USER area. */ | 305 | /* read the word at location addr in the USER area. */ |
168 | case PTRACE_PEEKUSR: { | 306 | case PTRACE_PEEKUSR: |
169 | unsigned long tmp; | ||
170 | |||
171 | ret = -EIO; | 307 | ret = -EIO; |
172 | if ((addr & 3) || addr < 0 || | 308 | if ((addr & 3) || addr < 0 || |
173 | addr > sizeof(struct user) - 3) | 309 | addr > sizeof(struct user) - 3) |
@@ -179,17 +315,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) | |||
179 | ptrace_regid_to_frame[addr]); | 315 | ptrace_regid_to_frame[addr]); |
180 | ret = put_user(tmp, (unsigned long *) data); | 316 | ret = put_user(tmp, (unsigned long *) data); |
181 | break; | 317 | break; |
182 | } | ||
183 | |||
184 | /* write the word at location addr. */ | ||
185 | case PTRACE_POKETEXT: | ||
186 | case PTRACE_POKEDATA: | ||
187 | if (access_process_vm(child, addr, &data, sizeof(data), 1) == | ||
188 | sizeof(data)) | ||
189 | ret = 0; | ||
190 | else | ||
191 | ret = -EIO; | ||
192 | break; | ||
193 | 318 | ||
194 | /* write the word at location addr in the USER area */ | 319 | /* write the word at location addr in the USER area */ |
195 | case PTRACE_POKEUSR: | 320 | case PTRACE_POKEUSR: |
@@ -204,132 +329,32 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) | |||
204 | data); | 329 | data); |
205 | break; | 330 | break; |
206 | 331 | ||
207 | /* continue and stop at next (return from) syscall */ | 332 | case PTRACE_GETREGS: /* Get all integer regs from the child. */ |
208 | case PTRACE_SYSCALL: | 333 | return copy_regset_to_user(child, &user_mn10300_native_view, |
209 | /* restart after signal. */ | 334 | REGSET_GENERAL, |
210 | case PTRACE_CONT: | 335 | 0, NR_PTREGS * sizeof(long), |
211 | ret = -EIO; | 336 | (void __user *)data); |
212 | if ((unsigned long) data > _NSIG) | 337 | |
213 | break; | 338 | case PTRACE_SETREGS: /* Set all integer regs in the child. */ |
214 | if (request == PTRACE_SYSCALL) | 339 | return copy_regset_from_user(child, &user_mn10300_native_view, |
215 | set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); | 340 | REGSET_GENERAL, |
216 | else | 341 | 0, NR_PTREGS * sizeof(long), |
217 | clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); | 342 | (const void __user *)data); |
218 | child->exit_code = data; | 343 | |
219 | ptrace_disable(child); | 344 | case PTRACE_GETFPREGS: /* Get the child FPU state. */ |
220 | wake_up_process(child); | 345 | return copy_regset_to_user(child, &user_mn10300_native_view, |
221 | ret = 0; | 346 | REGSET_FPU, |
222 | break; | 347 | 0, sizeof(struct fpu_state_struct), |
223 | 348 | (void __user *)data); | |
224 | /* | 349 | |
225 | * make the child exit | 350 | case PTRACE_SETFPREGS: /* Set the child FPU state. */ |
226 | * - the best I can do is send it a sigkill | 351 | return copy_regset_from_user(child, &user_mn10300_native_view, |
227 | * - perhaps it should be put in the status that it wants to | 352 | REGSET_FPU, |
228 | * exit | 353 | 0, sizeof(struct fpu_state_struct), |
229 | */ | 354 | (const void __user *)data); |
230 | case PTRACE_KILL: | ||
231 | ret = 0; | ||
232 | if (child->exit_state == EXIT_ZOMBIE) /* already dead */ | ||
233 | break; | ||
234 | child->exit_code = SIGKILL; | ||
235 | clear_tsk_thread_flag(child, TIF_SINGLESTEP); | ||
236 | ptrace_disable(child); | ||
237 | wake_up_process(child); | ||
238 | break; | ||
239 | |||
240 | case PTRACE_SINGLESTEP: /* set the trap flag. */ | ||
241 | #ifndef CONFIG_MN10300_USING_JTAG | ||
242 | ret = -EIO; | ||
243 | if ((unsigned long) data > _NSIG) | ||
244 | break; | ||
245 | clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); | ||
246 | ptrace_enable(child); | ||
247 | child->exit_code = data; | ||
248 | wake_up_process(child); | ||
249 | ret = 0; | ||
250 | #else | ||
251 | ret = -EINVAL; | ||
252 | #endif | ||
253 | break; | ||
254 | |||
255 | case PTRACE_DETACH: /* detach a process that was attached. */ | ||
256 | ret = ptrace_detach(child, data); | ||
257 | break; | ||
258 | |||
259 | /* Get all gp regs from the child. */ | ||
260 | case PTRACE_GETREGS: { | ||
261 | unsigned long tmp; | ||
262 | |||
263 | if (!access_ok(VERIFY_WRITE, (unsigned *) data, NR_PTREGS << 2)) { | ||
264 | ret = -EIO; | ||
265 | break; | ||
266 | } | ||
267 | |||
268 | for (i = 0; i < NR_PTREGS << 2; i += 4) { | ||
269 | tmp = get_stack_long(child, ptrace_regid_to_frame[i]); | ||
270 | __put_user(tmp, (unsigned long *) data); | ||
271 | data += sizeof(tmp); | ||
272 | } | ||
273 | ret = 0; | ||
274 | break; | ||
275 | } | ||
276 | |||
277 | case PTRACE_SETREGS: { /* Set all gp regs in the child. */ | ||
278 | unsigned long tmp; | ||
279 | |||
280 | if (!access_ok(VERIFY_READ, (unsigned long *)data, | ||
281 | sizeof(struct pt_regs))) { | ||
282 | ret = -EIO; | ||
283 | break; | ||
284 | } | ||
285 | |||
286 | for (i = 0; i < NR_PTREGS << 2; i += 4) { | ||
287 | __get_user(tmp, (unsigned long *) data); | ||
288 | put_stack_long(child, ptrace_regid_to_frame[i], tmp); | ||
289 | data += sizeof(tmp); | ||
290 | } | ||
291 | ret = 0; | ||
292 | break; | ||
293 | } | ||
294 | |||
295 | case PTRACE_GETFPREGS: { /* Get the child FPU state. */ | ||
296 | if (is_using_fpu(child)) { | ||
297 | unlazy_fpu(child); | ||
298 | fpu_state = child->thread.fpu_state; | ||
299 | } else { | ||
300 | memset(&fpu_state, 0, sizeof(fpu_state)); | ||
301 | } | ||
302 | |||
303 | ret = -EIO; | ||
304 | if (copy_to_user((void *) data, &fpu_state, | ||
305 | sizeof(fpu_state)) == 0) | ||
306 | ret = 0; | ||
307 | break; | ||
308 | } | ||
309 | |||
310 | case PTRACE_SETFPREGS: { /* Set the child FPU state. */ | ||
311 | ret = -EFAULT; | ||
312 | if (copy_from_user(&fpu_state, (const void *) data, | ||
313 | sizeof(fpu_state)) == 0) { | ||
314 | fpu_kill_state(child); | ||
315 | child->thread.fpu_state = fpu_state; | ||
316 | set_using_fpu(child); | ||
317 | ret = 0; | ||
318 | } | ||
319 | break; | ||
320 | } | ||
321 | |||
322 | case PTRACE_SETOPTIONS: { | ||
323 | if (data & PTRACE_O_TRACESYSGOOD) | ||
324 | child->ptrace |= PT_TRACESYSGOOD; | ||
325 | else | ||
326 | child->ptrace &= ~PT_TRACESYSGOOD; | ||
327 | ret = 0; | ||
328 | break; | ||
329 | } | ||
330 | 355 | ||
331 | default: | 356 | default: |
332 | ret = -EIO; | 357 | ret = ptrace_request(child, request, addr, data); |
333 | break; | 358 | break; |
334 | } | 359 | } |
335 | 360 | ||
@@ -337,43 +362,26 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) | |||
337 | } | 362 | } |
338 | 363 | ||
339 | /* | 364 | /* |
340 | * notification of system call entry/exit | 365 | * handle tracing of system call entry |
341 | * - triggered by current->work.syscall_trace | 366 | * - return the revised system call number or ULONG_MAX to cause ENOSYS |
342 | */ | 367 | */ |
343 | asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit) | 368 | asmlinkage unsigned long syscall_trace_entry(struct pt_regs *regs) |
344 | { | 369 | { |
345 | #if 0 | 370 | if (tracehook_report_syscall_entry(regs)) |
346 | /* just in case... */ | 371 | /* tracing decided this syscall should not happen, so |
347 | printk(KERN_DEBUG "[%d] syscall_%lu(%lx,%lx,%lx,%lx) = %lx\n", | 372 | * We'll return a bogus call number to get an ENOSYS |
348 | current->pid, | 373 | * error, but leave the original number in |
349 | regs->orig_d0, | 374 | * regs->orig_d0 |
350 | regs->a0, | 375 | */ |
351 | regs->d1, | 376 | return ULONG_MAX; |
352 | regs->a3, | ||
353 | regs->a2, | ||
354 | regs->d0); | ||
355 | return; | ||
356 | #endif | ||
357 | |||
358 | if (!test_thread_flag(TIF_SYSCALL_TRACE) && | ||
359 | !test_thread_flag(TIF_SINGLESTEP)) | ||
360 | return; | ||
361 | if (!(current->ptrace & PT_PTRACED)) | ||
362 | return; | ||
363 | 377 | ||
364 | /* the 0x80 provides a way for the tracing parent to distinguish | 378 | return regs->orig_d0; |
365 | between a syscall stop and SIGTRAP delivery */ | 379 | } |
366 | ptrace_notify(SIGTRAP | | ||
367 | ((current->ptrace & PT_TRACESYSGOOD) && | ||
368 | !test_thread_flag(TIF_SINGLESTEP) ? 0x80 : 0)); | ||
369 | 380 | ||
370 | /* | 381 | /* |
371 | * this isn't the same as continuing with a signal, but it will do | 382 | * handle tracing of system call exit |
372 | * for normal use. strace only continues with a signal if the | 383 | */ |
373 | * stopping signal is not SIGTRAP. -brl | 384 | asmlinkage void syscall_trace_exit(struct pt_regs *regs) |
374 | */ | 385 | { |
375 | if (current->exit_code) { | 386 | tracehook_report_syscall_exit(regs, 0); |
376 | send_sig(current->exit_code, current, 1); | ||
377 | current->exit_code = 0; | ||
378 | } | ||
379 | } | 387 | } |