]> granicus.if.org Git - strace/commitdiff
Don't perform TCB_WAITEXECVE wait if not needed.
authorDenys Vlasenko <dvlasenk@redhat.com>
Tue, 24 May 2011 18:30:24 +0000 (20:30 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Tue, 24 May 2011 18:30:24 +0000 (20:30 +0200)
* defs.h (ptrace_setoptions_for_all): Expose this variable.
* strace.c (ptrace_setoptions_for_all): Remove "static".
* process.c (internal_exec): Don't set TCB_WAITEXECVE bit
if we know that post-execve SIGTRAP is not going to happen.

defs.h
process.c
strace.c

diff --git a/defs.h b/defs.h
index ef4ac4755afa209ed493d6c0804ea1241e5ba2e1..d2c905a69ab2f225df5f9710343f7e194117f2ae 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -505,6 +505,7 @@ extern struct tcb **tcbtab;
 extern int *qual_flags;
 extern int debug, followfork;
 extern unsigned int ptrace_setoptions_followfork;
+extern unsigned int ptrace_setoptions_for_all;
 extern int dtime, xflag, qflag;
 extern cflag_t cflag;
 extern int acolumn;
index 36ac5ab8326a59b0b7de6007fc9ecafdf750062e..9a767d3e6d42c26c90b993d4ca202acd068d0bba 100644 (file)
--- a/process.c
+++ b/process.c
@@ -1775,8 +1775,7 @@ struct tcb *tcp;
 #endif
 
 int
-internal_exec(tcp)
-struct tcb *tcp;
+internal_exec(struct tcb *tcp)
 {
 #ifdef SUNOS4
        if (exiting(tcp) && !syserror(tcp) && followfork)
@@ -1785,8 +1784,11 @@ struct tcb *tcp;
 #if defined LINUX && defined TCB_WAITEXECVE
        if (exiting(tcp) && syserror(tcp))
                tcp->flags &= ~TCB_WAITEXECVE;
-       else
-               tcp->flags |= TCB_WAITEXECVE;
+       else {
+               /* Maybe we have post-execve SIGTRAP suppressed? */
+               if (!(ptrace_setoptions_for_all & PTRACE_O_TRACEEXEC))
+                       tcp->flags |= TCB_WAITEXECVE; /* no */
+       }
 #endif /* LINUX && TCB_WAITEXECVE */
        return 0;
 }
index 472805482e02b2b9d422d4b21fc2855960e9e2ba..61176b674111a1494834857083fda7dac5c2ac51 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -85,7 +85,7 @@ extern char *optarg;
 
 int debug = 0, followfork = 0;
 unsigned int ptrace_setoptions_followfork = 0;
-static unsigned int ptrace_setoptions_for_all = 0;
+unsigned int ptrace_setoptions_for_all = 0;
 /* Which WSTOPSIG(status) value marks syscall traps? */
 static unsigned int SYSCALLTRAP = SIGTRAP;
 int dtime = 0, xflag = 0, qflag = 0;