[parisc-linux-cvs] strace -f fixes

Richard Hirst rhirst@linuxcare.com
Mon, 19 Feb 2001 12:08:58 +0000


Fixes for strace -f.  Still requires a mod to the kernel entry.S to
preserve the syscall number in r20 over a fork() call.  With that,
strace -f works for me, however, (a) I've added a delay to ensure
that the child has been scheduled before we try to attach to it (see
comment in process.c), and (b) there are some unexplained pauses in
the strace output.

Oh, and to make strace -d (debug) work I had to comment out the
following two lines in strace.c:

                      if (debug)
                              kill(getpid(), SIGSTOP);

where the forked child of strace (which will become the process
you are tracing) sends itself a SIGSTOP after PTRACE_ATTACH and
before execv().  Havn't committed that change.

Richard



Index: process.c
===================================================================
RCS file: /home/cvs/parisc/strace/process.c,v
retrieving revision 1.1.1.1
diff -r1.1.1.1 process.c
485a486,503
> #ifdef HPPA
>               /* The child must have run before it can be attached. */
>               /* This must be a bug in the parisc kernel, but I havn't
>                * identified it yet.  Seems to be an issue associated
>                * with attaching to a process (which sends it a signal)
>                * before that process has ever been scheduled.  When
>                * debugging, I started seeing crashes in
>                * arch/parisc/kernel/signal.c:do_signal(), apparently
>                * caused by r8 getting corrupt over the dequeue_signal()
>                * call.  Didn't make much sense though...
>                */
>               {
>                       struct timeval tv;
>                       tv.tv_sec = 0;
>                       tv.tv_usec = 10000;
>                       select(0, NULL, NULL, NULL, &tv);
>               }
> #endif
Index: syscall.c
===================================================================
RCS file: /home/cvs/parisc/strace/syscall.c,v
retrieving revision 1.2
diff -r1.2 syscall.c
926c926
< #else !SPARC
---
> #else /* !SPARC */
Index: util.c
===================================================================
RCS file: /home/cvs/parisc/strace/util.c,v
retrieving revision 1.2
diff -r1.2 util.c
981c981
< #else !SPARC
---
> #else /* !SPARC */
1109c1109,1111
<       return -1;      /* XXX */
---
>       if (upeek(tcp->pid, PT_IAOQ0, &tcp->baddr) < 0)
>               return -1;
>       tcp->baddr &= ~0x03;
                                pc, tcp->baddr);
                return 0;
        }
#else /* !ALPHA */
#ifdef HPPA
        if (upeek(tcp->pid, PT_IAOQ0, &iaoq) < 0)
                return -1;
        iaoq &= ~0x03;
        if (iaoq != tcp->baddr && iaoq != tcp->baddr + 4) {
                /* The breakpoint has not been reached yet.  */
                if (debug)
                        fprintf(stderr, "NOTE: PC not at bpt (iaoq %#lx baddr %#lx)\n",
                                iaoq, tcp->baddr);
                return 0;
        }
        iaoq = tcp->baddr | 3;
        /* We should be pointing at a 'ldi -1000,r1' in glibc, so it is
         * safe to set both IAOQ0 and IAOQ1 to that so the PSW N bit
         * has no significant effect.
         */
        ptrace(PTRACE_POKEUSER, tcp->pid, (void *)PT_IAOQ0, iaoq);
        ptrace(PTRACE_POKEUSER, tcp->pid, (void *)PT_IAOQ1, iaoq);
#endif /* HPPA */
#endif /* !ALPHA */
#endif /* !M68K */
#endif /* !POWERPC */
===================================================================
RCS file: /home/cvs/parisc/strace/defs.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- defs.h      2001/02/07 12:29:21     1.3
+++ defs.h      2001/02/19 11:51:32     1.4
@@ -166,6 +166,7 @@
 #  define PT_GR26 (26*4)
 #  define PT_GR28 (28*4)
 #  define PT_IAOQ0 (106*4)
+#  define PT_IAOQ1 (107*4)
 #endif /* HPPA */
 #endif /* LINUX */