]> granicus.if.org Git - strace/commitdiff
Add support for Linux/no-mmu with vfork
authorMike Frysinger <vapier@gentoo.org>
Thu, 8 Oct 2009 00:41:29 +0000 (20:41 -0400)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 8 Oct 2009 14:25:01 +0000 (14:25 +0000)
* configure.ac (AC_CHECK_FUNCS): Add fork.
* strace.c (strace_vforked): Define.
(startup_child): Do not raise SIGSTOP if vforked.
(trace): Skip first exec when starting up after vforked.
* syscall.c [BFIN] (get_scno): Drop waitexec checks.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
configure.ac
strace.c
syscall.c

index 95f769e40d4bb6668973af3982c5f777a12daac9..7b1a8c83ff43f88b0857d4131bd1496b7afbf7a9 100644 (file)
@@ -209,6 +209,7 @@ AC_CHECK_LIB(nsl, main)
 fi
 
 AC_CHECK_FUNCS([ \
+       fork \
        getdents \
        if_indextoname \
        inet_ntop \
index da8cc4a559c85df4906bc51605125dfbc628f8f3..6765ba3cce390cc334386dcd6fa7c8fd11c4e871 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -212,6 +212,14 @@ foobar()
 #endif /* MIPS */
 #endif /* SVR4 */
 
+/* Glue for systems without a MMU that cannot provide fork() */
+#ifdef HAVE_FORK
+# define strace_vforked 0
+#else
+# define strace_vforked 1
+# define fork()         vfork()
+#endif
+
 static int
 set_cloexec_flag(int fd)
 {
@@ -636,8 +644,11 @@ startup_child (char **argv)
                         * Induce an immediate stop so that the parent
                         * will resume us with PTRACE_SYSCALL and display
                         * this execve call normally.
+                        * Unless of course we're on a no-MMU system where
+                        * we vfork()-ed, so we cannot stop the child.
                         */
-                       kill(getpid(), SIGSTOP);
+                       if (!strace_vforked)
+                               kill(getpid(), SIGSTOP);
                } else {
                        struct sigaction sv_sigchld;
                        sigaction(SIGCHLD, NULL, &sv_sigchld);
@@ -2445,8 +2456,11 @@ Process %d attached (waiting for parent)\n",
                 * with STOPSIG equal to some other signal
                 * than SIGSTOP if we happend to attach
                 * just before the process takes a signal.
+                * A no-MMU vforked child won't send up a signal,
+                * so skip the first (lost) execve notification.
                 */
-               if ((tcp->flags & TCB_STARTUP) && WSTOPSIG(status) == SIGSTOP) {
+               if ((tcp->flags & TCB_STARTUP) &&
+                   (WSTOPSIG(status) == SIGSTOP || strace_vforked)) {
                        /*
                         * This flag is there to keep us in sync.
                         * Next time this process stops it should
index a2e688555bddb459544f1c8366dc44b36b141fa9..6a75c70ef81ba9f5bec34d994d3ef18dec349727 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -922,9 +922,6 @@ get_scno(struct tcb *tcp)
 # elif defined(BFIN)
        if (upeek(tcp, PT_ORIG_P0, &scno))
                return -1;
-       /* Check if we return from execve. */
-       if (tcp->flags & TCB_WAITEXECVE && tcp->flags & TCB_INSYSCALL)
-               tcp->flags &= ~(TCB_INSYSCALL | TCB_WAITEXECVE);
 # elif defined (I386)
        if (upeek(tcp, 4*ORIG_EAX, &scno) < 0)
                return -1;