parisc: tracehook_report_syscall
authorKyle McMartin <kyle@mcmartin.ca>
Mon, 27 Apr 2009 03:53:34 +0000 (23:53 -0400)
committerKyle McMartin <kyle@ihatethathostname.lab.bos.redhat.com>
Mon, 28 Sep 2009 03:07:21 +0000 (23:07 -0400)
This makes parisc use the standard tracehook_report_syscall_entry
and tracehook_report_syscall_exit hooks in <linux/tracehook.h>.

To do this, we need to access current->thread.regs, and to know
whether we're entering or exiting the syscall, so add this to
syscall_trace.

Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
arch/parisc/kernel/ptrace.c
arch/parisc/kernel/syscall.S

index 927db3668b6ffd6bec55e8a1b90d099f5cd7a1dc..2118ed02e88640c8327f5036cc491e2595544281 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/smp.h>
 #include <linux/errno.h>
 #include <linux/ptrace.h>
+#include <linux/tracehook.h>
 #include <linux/user.h>
 #include <linux/personality.h>
 #include <linux/security.h>
@@ -264,21 +265,19 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 #endif
 
 
-void syscall_trace(void)
+void syscall_trace(int why)
 {
+       struct pt_regs *regs = &current->thread.regs;
+
        if (!test_thread_flag(TIF_SYSCALL_TRACE))
                return;
-       if (!(current->ptrace & PT_PTRACED))
-               return;
-       ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
-                                ? 0x80 : 0));
        /*
-        * this isn't the same as continuing with a signal, but it will do
-        * for normal use.  strace only continues with a signal if the
-        * stopping signal is not SIGTRAP.  -brl
+        * Report the system call for tracing.  Entry tracing can
+        * decide to abort the call.  We handle that by setting an
+        * invalid syscall number (-1) to force an ENOSYS error.
         */
-       if (current->exit_code) {
-               send_sig(current->exit_code, current, 1);
-               current->exit_code = 0;
-       }
+       if (why)
+               tracehook_report_syscall_exit(regs, 0);
+       else if (tracehook_report_syscall_entry(regs))
+               regs->gr[20] = -1;      /* force ENOSYS */
 }
index 59fc1a43ec3ef094ae514694e549ab6b518aa05a..5698668166cd1cbc8cf7de05b3dd65e642fb3960 100644 (file)
@@ -288,6 +288,7 @@ tracesys:
        STREG   %r18,PT_GR18(%r2)
        /* Finished saving things for the debugger */
 
+       ldi     0,%r26                          /* syscall entry */
        ldil    L%syscall_trace,%r1
        ldil    L%tracesys_next,%r2
        be      R%syscall_trace(%sr7,%r1)
@@ -336,6 +337,7 @@ tracesys_exit:
 #ifdef CONFIG_64BIT
        ldo     -16(%r30),%r29                  /* Reference param save area */
 #endif
+       ldi     1,%r26                          /* syscall exit */
        bl      syscall_trace, %r2
        STREG   %r28,TASK_PT_GR28(%r1)          /* save return value now */
        ldo     -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1      /* get task ptr */
@@ -358,7 +360,7 @@ tracesys_sigexit:
        ldo     -16(%r30),%r29                  /* Reference param save area */
 #endif
        bl      syscall_trace, %r2
-       nop
+       ldi     1,%r26                          /* syscall exit */
 
        ldil    L%syscall_exit_rfi,%r1
        be,n    R%syscall_exit_rfi(%sr7,%r1)