Merge master.kernel.org:/pub/scm/linux/kernel/git/bunk/trivial
[linux-2.6] / arch / frv / kernel / ptrace.c
1 /* ptrace.c: FRV specific parts of process tracing
2  *
3  * Copyright (C) 2003-5 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  * - Derived from arch/m68k/kernel/ptrace.c
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version
10  * 2 of the License, or (at your option) any later version.
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>
22 #include <linux/security.h>
23 #include <linux/signal.h>
24
25 #include <asm/uaccess.h>
26 #include <asm/page.h>
27 #include <asm/pgtable.h>
28 #include <asm/system.h>
29 #include <asm/processor.h>
30 #include <asm/unistd.h>
31
32 /*
33  * does not yet catch signals sent when the child dies.
34  * in exit.c or in signal.c.
35  */
36
37 /*
38  * Get contents of register REGNO in task TASK.
39  */
40 static inline long get_reg(struct task_struct *task, int regno)
41 {
42         struct user_context *user = task->thread.user;
43
44         if (regno < 0 || regno >= PT__END)
45                 return 0;
46
47         return ((unsigned long *) user)[regno];
48 }
49
50 /*
51  * Write contents of register REGNO in task TASK.
52  */
53 static inline int put_reg(struct task_struct *task, int regno,
54                           unsigned long data)
55 {
56         struct user_context *user = task->thread.user;
57
58         if (regno < 0 || regno >= PT__END)
59                 return -EIO;
60
61         switch (regno) {
62         case PT_GR(0):
63                 return 0;
64         case PT_PSR:
65         case PT__STATUS:
66                 return -EIO;
67         default:
68                 ((unsigned long *) user)[regno] = data;
69                 return 0;
70         }
71 }
72
73 /*
74  * check that an address falls within the bounds of the target process's memory mappings
75  */
76 static inline int is_user_addr_valid(struct task_struct *child,
77                                      unsigned long start, unsigned long len)
78 {
79 #ifdef CONFIG_MMU
80         if (start >= PAGE_OFFSET || len > PAGE_OFFSET - start)
81                 return -EIO;
82         return 0;
83 #else
84         struct vm_list_struct *vml;
85
86         for (vml = child->mm->context.vmlist; vml; vml = vml->next)
87                 if (start >= vml->vma->vm_start && start + len <= vml->vma->vm_end)
88                         return 0;
89
90         return -EIO;
91 #endif
92 }
93
94 /*
95  * Called by kernel/ptrace.c when detaching..
96  *
97  * Control h/w single stepping
98  */
99 void ptrace_disable(struct task_struct *child)
100 {
101         child->thread.frame0->__status &= ~REG__STATUS_STEP;
102 }
103
104 void ptrace_enable(struct task_struct *child)
105 {
106         child->thread.frame0->__status |= REG__STATUS_STEP;
107 }
108
109 long arch_ptrace(struct task_struct *child, long request, long addr, long data)
110 {
111         unsigned long tmp;
112         int ret;
113
114         switch (request) {
115                 /* when I and D space are separate, these will need to be fixed. */
116         case PTRACE_PEEKTEXT: /* read word at location addr. */
117         case PTRACE_PEEKDATA: {
118                 int copied;
119
120                 ret = -EIO;
121                 if (is_user_addr_valid(child, addr, sizeof(tmp)) < 0)
122                         break;
123
124                 copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
125                 if (copied != sizeof(tmp))
126                         break;
127
128                 ret = put_user(tmp,(unsigned long *) data);
129                 break;
130         }
131
132                 /* read the word at location addr in the USER area. */
133         case PTRACE_PEEKUSR: {
134                 tmp = 0;
135                 ret = -EIO;
136                 if ((addr & 3) || addr < 0)
137                         break;
138
139                 ret = 0;
140                 switch (addr >> 2) {
141                 case 0 ... PT__END - 1:
142                         tmp = get_reg(child, addr >> 2);
143                         break;
144
145                 case PT__END + 0:
146                         tmp = child->mm->end_code - child->mm->start_code;
147                         break;
148
149                 case PT__END + 1:
150                         tmp = child->mm->end_data - child->mm->start_data;
151                         break;
152
153                 case PT__END + 2:
154                         tmp = child->mm->start_stack - child->mm->start_brk;
155                         break;
156
157                 case PT__END + 3:
158                         tmp = child->mm->start_code;
159                         break;
160
161                 case PT__END + 4:
162                         tmp = child->mm->start_stack;
163                         break;
164
165                 default:
166                         ret = -EIO;
167                         break;
168                 }
169
170                 if (ret == 0)
171                         ret = put_user(tmp, (unsigned long *) data);
172                 break;
173         }
174
175                 /* when I and D space are separate, this will have to be fixed. */
176         case PTRACE_POKETEXT: /* write the word at location addr. */
177         case PTRACE_POKEDATA:
178                 ret = -EIO;
179                 if (is_user_addr_valid(child, addr, sizeof(tmp)) < 0)
180                         break;
181                 if (access_process_vm(child, addr, &data, sizeof(data), 1) != sizeof(data))
182                         break;
183                 ret = 0;
184                 break;
185
186         case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
187                 ret = -EIO;
188                 if ((addr & 3) || addr < 0)
189                         break;
190
191                 ret = 0;
192                 switch (addr >> 2) {
193                 case 0 ... PT__END-1:
194                         ret = put_reg(child, addr >> 2, data);
195                         break;
196
197                 default:
198                         ret = -EIO;
199                         break;
200                 }
201                 break;
202
203         case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
204         case PTRACE_CONT: /* restart after signal. */
205                 ret = -EIO;
206                 if (!valid_signal(data))
207                         break;
208                 if (request == PTRACE_SYSCALL)
209                         set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
210                 else
211                         clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
212                 child->exit_code = data;
213                 ptrace_disable(child);
214                 wake_up_process(child);
215                 ret = 0;
216                 break;
217
218                 /* make the child exit.  Best I can do is send it a sigkill.
219                  * perhaps it should be put in the status that it wants to
220                  * exit.
221                  */
222         case PTRACE_KILL:
223                 ret = 0;
224                 if (child->exit_state == EXIT_ZOMBIE)   /* already dead */
225                         break;
226                 child->exit_code = SIGKILL;
227                 clear_tsk_thread_flag(child, TIF_SINGLESTEP);
228                 ptrace_disable(child);
229                 wake_up_process(child);
230                 break;
231
232         case PTRACE_SINGLESTEP:  /* set the trap flag. */
233                 ret = -EIO;
234                 if (!valid_signal(data))
235                         break;
236                 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
237                 ptrace_enable(child);
238                 child->exit_code = data;
239                 wake_up_process(child);
240                 ret = 0;
241                 break;
242
243         case PTRACE_DETACH:     /* detach a process that was attached. */
244                 ret = ptrace_detach(child, data);
245                 break;
246
247         case PTRACE_GETREGS: { /* Get all integer regs from the child. */
248                 int i;
249                 for (i = 0; i < PT__GPEND; i++) {
250                         tmp = get_reg(child, i);
251                         if (put_user(tmp, (unsigned long *) data)) {
252                                 ret = -EFAULT;
253                                 break;
254                         }
255                         data += sizeof(long);
256                 }
257                 ret = 0;
258                 break;
259         }
260
261         case PTRACE_SETREGS: { /* Set all integer regs in the child. */
262                 int i;
263                 for (i = 0; i < PT__GPEND; i++) {
264                         if (get_user(tmp, (unsigned long *) data)) {
265                                 ret = -EFAULT;
266                                 break;
267                         }
268                         put_reg(child, i, tmp);
269                         data += sizeof(long);
270                 }
271                 ret = 0;
272                 break;
273         }
274
275         case PTRACE_GETFPREGS: { /* Get the child FP/Media state. */
276                 ret = 0;
277                 if (copy_to_user((void *) data,
278                                  &child->thread.user->f,
279                                  sizeof(child->thread.user->f)))
280                         ret = -EFAULT;
281                 break;
282         }
283
284         case PTRACE_SETFPREGS: { /* Set the child FP/Media state. */
285                 ret = 0;
286                 if (copy_from_user(&child->thread.user->f,
287                                    (void *) data,
288                                    sizeof(child->thread.user->f)))
289                         ret = -EFAULT;
290                 break;
291         }
292
293         case PTRACE_GETFDPIC:
294                 tmp = 0;
295                 switch (addr) {
296                 case PTRACE_GETFDPIC_EXEC:
297                         tmp = child->mm->context.exec_fdpic_loadmap;
298                         break;
299                 case PTRACE_GETFDPIC_INTERP:
300                         tmp = child->mm->context.interp_fdpic_loadmap;
301                         break;
302                 default:
303                         break;
304                 }
305
306                 ret = 0;
307                 if (put_user(tmp, (unsigned long *) data)) {
308                         ret = -EFAULT;
309                         break;
310                 }
311                 break;
312
313         default:
314                 ret = -EIO;
315                 break;
316         }
317         return ret;
318 }
319
320 int __nongprelbss kstrace;
321
322 static const struct {
323         const char      *name;
324         unsigned        argmask;
325 } __syscall_name_table[NR_syscalls] = {
326         [0]     = { "restart_syscall"                   },
327         [1]     = { "exit",             0x000001        },
328         [2]     = { "fork",             0xffffff        },
329         [3]     = { "read",             0x000141        },
330         [4]     = { "write",            0x000141        },
331         [5]     = { "open",             0x000235        },
332         [6]     = { "close",            0x000001        },
333         [7]     = { "waitpid",          0x000141        },
334         [8]     = { "creat",            0x000025        },
335         [9]     = { "link",             0x000055        },
336         [10]    = { "unlink",           0x000005        },
337         [11]    = { "execve",           0x000445        },
338         [12]    = { "chdir",            0x000005        },
339         [13]    = { "time",             0x000004        },
340         [14]    = { "mknod",            0x000325        },
341         [15]    = { "chmod",            0x000025        },
342         [16]    = { "lchown",           0x000025        },
343         [17]    = { "break" },
344         [18]    = { "oldstat",          0x000045        },
345         [19]    = { "lseek",            0x000131        },
346         [20]    = { "getpid",           0xffffff        },
347         [21]    = { "mount",            0x043555        },
348         [22]    = { "umount",           0x000005        },
349         [23]    = { "setuid",           0x000001        },
350         [24]    = { "getuid",           0xffffff        },
351         [25]    = { "stime",            0x000004        },
352         [26]    = { "ptrace",           0x004413        },
353         [27]    = { "alarm",            0x000001        },
354         [28]    = { "oldfstat",         0x000041        },
355         [29]    = { "pause",            0xffffff        },
356         [30]    = { "utime",            0x000045        },
357         [31]    = { "stty" },
358         [32]    = { "gtty" },
359         [33]    = { "access",           0x000025        },
360         [34]    = { "nice",             0x000001        },
361         [35]    = { "ftime" },
362         [36]    = { "sync",             0xffffff        },
363         [37]    = { "kill",             0x000011        },
364         [38]    = { "rename",           0x000055        },
365         [39]    = { "mkdir",            0x000025        },
366         [40]    = { "rmdir",            0x000005        },
367         [41]    = { "dup",              0x000001        },
368         [42]    = { "pipe",             0x000004        },
369         [43]    = { "times",            0x000004        },
370         [44]    = { "prof" },
371         [45]    = { "brk",              0x000004        },
372         [46]    = { "setgid",           0x000001        },
373         [47]    = { "getgid",           0xffffff        },
374         [48]    = { "signal",           0x000041        },
375         [49]    = { "geteuid",          0xffffff        },
376         [50]    = { "getegid",          0xffffff        },
377         [51]    = { "acct",             0x000005        },
378         [52]    = { "umount2",          0x000035        },
379         [53]    = { "lock" },
380         [54]    = { "ioctl",            0x000331        },
381         [55]    = { "fcntl",            0x000331        },
382         [56]    = { "mpx" },
383         [57]    = { "setpgid",          0x000011        },
384         [58]    = { "ulimit" },
385         [60]    = { "umask",            0x000002        },
386         [61]    = { "chroot",           0x000005        },
387         [62]    = { "ustat",            0x000043        },
388         [63]    = { "dup2",             0x000011        },
389         [64]    = { "getppid",          0xffffff        },
390         [65]    = { "getpgrp",          0xffffff        },
391         [66]    = { "setsid",           0xffffff        },
392         [67]    = { "sigaction" },
393         [68]    = { "sgetmask" },
394         [69]    = { "ssetmask" },
395         [70]    = { "setreuid" },
396         [71]    = { "setregid" },
397         [72]    = { "sigsuspend" },
398         [73]    = { "sigpending" },
399         [74]    = { "sethostname" },
400         [75]    = { "setrlimit" },
401         [76]    = { "getrlimit" },
402         [77]    = { "getrusage" },
403         [78]    = { "gettimeofday" },
404         [79]    = { "settimeofday" },
405         [80]    = { "getgroups" },
406         [81]    = { "setgroups" },
407         [82]    = { "select" },
408         [83]    = { "symlink" },
409         [84]    = { "oldlstat" },
410         [85]    = { "readlink" },
411         [86]    = { "uselib" },
412         [87]    = { "swapon" },
413         [88]    = { "reboot" },
414         [89]    = { "readdir" },
415         [91]    = { "munmap",           0x000034        },
416         [92]    = { "truncate" },
417         [93]    = { "ftruncate" },
418         [94]    = { "fchmod" },
419         [95]    = { "fchown" },
420         [96]    = { "getpriority" },
421         [97]    = { "setpriority" },
422         [99]    = { "statfs" },
423         [100]   = { "fstatfs" },
424         [102]   = { "socketcall" },
425         [103]   = { "syslog" },
426         [104]   = { "setitimer" },
427         [105]   = { "getitimer" },
428         [106]   = { "stat" },
429         [107]   = { "lstat" },
430         [108]   = { "fstat" },
431         [111]   = { "vhangup" },
432         [114]   = { "wait4" },
433         [115]   = { "swapoff" },
434         [116]   = { "sysinfo" },
435         [117]   = { "ipc" },
436         [118]   = { "fsync" },
437         [119]   = { "sigreturn" },
438         [120]   = { "clone" },
439         [121]   = { "setdomainname" },
440         [122]   = { "uname" },
441         [123]   = { "modify_ldt" },
442         [123]   = { "cacheflush" },
443         [124]   = { "adjtimex" },
444         [125]   = { "mprotect" },
445         [126]   = { "sigprocmask" },
446         [127]   = { "create_module" },
447         [128]   = { "init_module" },
448         [129]   = { "delete_module" },
449         [130]   = { "get_kernel_syms" },
450         [131]   = { "quotactl" },
451         [132]   = { "getpgid" },
452         [133]   = { "fchdir" },
453         [134]   = { "bdflush" },
454         [135]   = { "sysfs" },
455         [136]   = { "personality" },
456         [137]   = { "afs_syscall" },
457         [138]   = { "setfsuid" },
458         [139]   = { "setfsgid" },
459         [140]   = { "_llseek",                  0x014331        },
460         [141]   = { "getdents" },
461         [142]   = { "_newselect",               0x000141        },
462         [143]   = { "flock" },
463         [144]   = { "msync" },
464         [145]   = { "readv" },
465         [146]   = { "writev" },
466         [147]   = { "getsid",                   0x000001        },
467         [148]   = { "fdatasync",                0x000001        },
468         [149]   = { "_sysctl",                  0x000004        },
469         [150]   = { "mlock" },
470         [151]   = { "munlock" },
471         [152]   = { "mlockall" },
472         [153]   = { "munlockall" },
473         [154]   = { "sched_setparam" },
474         [155]   = { "sched_getparam" },
475         [156]   = { "sched_setscheduler" },
476         [157]   = { "sched_getscheduler" },
477         [158]   = { "sched_yield" },
478         [159]   = { "sched_get_priority_max" },
479         [160]   = { "sched_get_priority_min" },
480         [161]   = { "sched_rr_get_interval" },
481         [162]   = { "nanosleep",                0x000044        },
482         [163]   = { "mremap" },
483         [164]   = { "setresuid" },
484         [165]   = { "getresuid" },
485         [166]   = { "vm86" },
486         [167]   = { "query_module" },
487         [168]   = { "poll" },
488         [169]   = { "nfsservctl" },
489         [170]   = { "setresgid" },
490         [171]   = { "getresgid" },
491         [172]   = { "prctl",                    0x333331        },
492         [173]   = { "rt_sigreturn",             0xffffff        },
493         [174]   = { "rt_sigaction",             0x001441        },
494         [175]   = { "rt_sigprocmask",           0x001441        },
495         [176]   = { "rt_sigpending",            0x000014        },
496         [177]   = { "rt_sigtimedwait",          0x001444        },
497         [178]   = { "rt_sigqueueinfo",          0x000411        },
498         [179]   = { "rt_sigsuspend",            0x000014        },
499         [180]   = { "pread",                    0x003341        },
500         [181]   = { "pwrite",                   0x003341        },
501         [182]   = { "chown",                    0x000115        },
502         [183]   = { "getcwd" },
503         [184]   = { "capget" },
504         [185]   = { "capset" },
505         [186]   = { "sigaltstack" },
506         [187]   = { "sendfile" },
507         [188]   = { "getpmsg" },
508         [189]   = { "putpmsg" },
509         [190]   = { "vfork",                    0xffffff        },
510         [191]   = { "ugetrlimit" },
511         [192]   = { "mmap2",                    0x313314        },
512         [193]   = { "truncate64" },
513         [194]   = { "ftruncate64" },
514         [195]   = { "stat64",                   0x000045        },
515         [196]   = { "lstat64",                  0x000045        },
516         [197]   = { "fstat64",                  0x000041        },
517         [198]   = { "lchown32" },
518         [199]   = { "getuid32",                 0xffffff        },
519         [200]   = { "getgid32",                 0xffffff        },
520         [201]   = { "geteuid32",                0xffffff        },
521         [202]   = { "getegid32",                0xffffff        },
522         [203]   = { "setreuid32" },
523         [204]   = { "setregid32" },
524         [205]   = { "getgroups32" },
525         [206]   = { "setgroups32" },
526         [207]   = { "fchown32" },
527         [208]   = { "setresuid32" },
528         [209]   = { "getresuid32" },
529         [210]   = { "setresgid32" },
530         [211]   = { "getresgid32" },
531         [212]   = { "chown32" },
532         [213]   = { "setuid32" },
533         [214]   = { "setgid32" },
534         [215]   = { "setfsuid32" },
535         [216]   = { "setfsgid32" },
536         [217]   = { "pivot_root" },
537         [218]   = { "mincore" },
538         [219]   = { "madvise" },
539         [220]   = { "getdents64" },
540         [221]   = { "fcntl64" },
541         [223]   = { "security" },
542         [224]   = { "gettid" },
543         [225]   = { "readahead" },
544         [226]   = { "setxattr" },
545         [227]   = { "lsetxattr" },
546         [228]   = { "fsetxattr" },
547         [229]   = { "getxattr" },
548         [230]   = { "lgetxattr" },
549         [231]   = { "fgetxattr" },
550         [232]   = { "listxattr" },
551         [233]   = { "llistxattr" },
552         [234]   = { "flistxattr" },
553         [235]   = { "removexattr" },
554         [236]   = { "lremovexattr" },
555         [237]   = { "fremovexattr" },
556         [238]   = { "tkill" },
557         [239]   = { "sendfile64" },
558         [240]   = { "futex" },
559         [241]   = { "sched_setaffinity" },
560         [242]   = { "sched_getaffinity" },
561         [243]   = { "set_thread_area" },
562         [244]   = { "get_thread_area" },
563         [245]   = { "io_setup" },
564         [246]   = { "io_destroy" },
565         [247]   = { "io_getevents" },
566         [248]   = { "io_submit" },
567         [249]   = { "io_cancel" },
568         [250]   = { "fadvise64" },
569         [252]   = { "exit_group",               0x000001        },
570         [253]   = { "lookup_dcookie" },
571         [254]   = { "epoll_create" },
572         [255]   = { "epoll_ctl" },
573         [256]   = { "epoll_wait" },
574         [257]   = { "remap_file_pages" },
575         [258]   = { "set_tid_address" },
576         [259]   = { "timer_create" },
577         [260]   = { "timer_settime" },
578         [261]   = { "timer_gettime" },
579         [262]   = { "timer_getoverrun" },
580         [263]   = { "timer_delete" },
581         [264]   = { "clock_settime" },
582         [265]   = { "clock_gettime" },
583         [266]   = { "clock_getres" },
584         [267]   = { "clock_nanosleep" },
585         [268]   = { "statfs64" },
586         [269]   = { "fstatfs64" },
587         [270]   = { "tgkill" },
588         [271]   = { "utimes" },
589         [272]   = { "fadvise64_64" },
590         [273]   = { "vserver" },
591         [274]   = { "mbind" },
592         [275]   = { "get_mempolicy" },
593         [276]   = { "set_mempolicy" },
594         [277]   = { "mq_open" },
595         [278]   = { "mq_unlink" },
596         [279]   = { "mq_timedsend" },
597         [280]   = { "mq_timedreceive" },
598         [281]   = { "mq_notify" },
599         [282]   = { "mq_getsetattr" },
600         [283]   = { "sys_kexec_load" },
601 };
602
603 asmlinkage void do_syscall_trace(int leaving)
604 {
605 #if 0
606         unsigned long *argp;
607         const char *name;
608         unsigned argmask;
609         char buffer[16];
610
611         if (!kstrace)
612                 return;
613
614         if (!current->mm)
615                 return;
616
617         if (__frame->gr7 == __NR_close)
618                 return;
619
620 #if 0
621         if (__frame->gr7 != __NR_mmap2 &&
622             __frame->gr7 != __NR_vfork &&
623             __frame->gr7 != __NR_execve &&
624             __frame->gr7 != __NR_exit)
625                 return;
626 #endif
627
628         argmask = 0;
629         name = NULL;
630         if (__frame->gr7 < NR_syscalls) {
631                 name = __syscall_name_table[__frame->gr7].name;
632                 argmask = __syscall_name_table[__frame->gr7].argmask;
633         }
634         if (!name) {
635                 sprintf(buffer, "sys_%lx", __frame->gr7);
636                 name = buffer;
637         }
638
639         if (!leaving) {
640                 if (!argmask) {
641                         printk(KERN_CRIT "[%d] %s(%lx,%lx,%lx,%lx,%lx,%lx)\n",
642                                current->pid,
643                                name,
644                                __frame->gr8,
645                                __frame->gr9,
646                                __frame->gr10,
647                                __frame->gr11,
648                                __frame->gr12,
649                                __frame->gr13);
650                 }
651                 else if (argmask == 0xffffff) {
652                         printk(KERN_CRIT "[%d] %s()\n",
653                                current->pid,
654                                name);
655                 }
656                 else {
657                         printk(KERN_CRIT "[%d] %s(",
658                                current->pid,
659                                name);
660
661                         argp = &__frame->gr8;
662
663                         do {
664                                 switch (argmask & 0xf) {
665                                 case 1:
666                                         printk("%ld", (long) *argp);
667                                         break;
668                                 case 2:
669                                         printk("%lo", *argp);
670                                         break;
671                                 case 3:
672                                         printk("%lx", *argp);
673                                         break;
674                                 case 4:
675                                         printk("%p", (void *) *argp);
676                                         break;
677                                 case 5:
678                                         printk("\"%s\"", (char *) *argp);
679                                         break;
680                                 }
681
682                                 argp++;
683                                 argmask >>= 4;
684                                 if (argmask)
685                                         printk(",");
686
687                         } while (argmask);
688
689                         printk(")\n");
690                 }
691         }
692         else {
693                 if ((int)__frame->gr8 > -4096 && (int)__frame->gr8 < 4096)
694                         printk(KERN_CRIT "[%d] %s() = %ld\n", current->pid, name, __frame->gr8);
695                 else
696                         printk(KERN_CRIT "[%d] %s() = %lx\n", current->pid, name, __frame->gr8);
697         }
698         return;
699 #endif
700
701         if (!test_thread_flag(TIF_SYSCALL_TRACE))
702                 return;
703
704         if (!(current->ptrace & PT_PTRACED))
705                 return;
706
707         /* we need to indicate entry or exit to strace */
708         if (leaving)
709                 __frame->__status |= REG__STATUS_SYSC_EXIT;
710         else
711                 __frame->__status |= REG__STATUS_SYSC_ENTRY;
712
713         ptrace_notify(SIGTRAP);
714
715         /*
716          * this isn't the same as continuing with a signal, but it will do
717          * for normal use.  strace only continues with a signal if the
718          * stopping signal is not SIGTRAP.  -brl
719          */
720         if (current->exit_code) {
721                 send_sig(current->exit_code, current, 1);
722                 current->exit_code = 0;
723         }
724 }