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