]> granicus.if.org Git - strace/commitdiff
Conditionally optimize out unused code
authorDenys Vlasenko <dvlasenk@redhat.com>
Sun, 21 Aug 2011 15:26:55 +0000 (17:26 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Tue, 23 Aug 2011 10:53:02 +0000 (12:53 +0200)
* syscall.c (internal_syscall): Call internal_exec only if
SUNOS4 || (LINUX && TCB_WAITEXECVE).
* process.c (internal_exec): Define this function only if
SUNOS4 || (LINUX && TCB_WAITEXECVE).
(printwaitn): Don't check wordsize if SUPPORTED_PERSONALITIES == 1.
* signal.c (sys_kill): Likewise.
* syscall.c (is_negated_errno): Likewise.
(trace_syscall_exiting): Fold a tprintf into tprintfs which follow it.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
process.c
signal.c
syscall.c

index 12b872098e929adb44d15456a862bf8f40c46c9c..aba2f5655824303dd50f77ba7f36d460079ece31 100644 (file)
--- a/process.c
+++ b/process.c
@@ -1581,14 +1581,15 @@ int sys_rexecve(struct tcb *tcp)
 
 #endif
 
+#if defined SUNOS4 || (defined LINUX && defined TCB_WAITEXECVE)
 int
 internal_exec(struct tcb *tcp)
 {
-#ifdef SUNOS4
+# if defined SUNOS4
        if (exiting(tcp) && !syserror(tcp) && followfork)
                fixvfork(tcp);
-#endif /* SUNOS4 */
-#if defined LINUX && defined TCB_WAITEXECVE
+# endif
+# if defined LINUX && defined TCB_WAITEXECVE
        if (exiting(tcp) && syserror(tcp))
                tcp->flags &= ~TCB_WAITEXECVE;
        else {
@@ -1596,9 +1597,10 @@ internal_exec(struct tcb *tcp)
                if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC))
                        tcp->flags |= TCB_WAITEXECVE; /* no */
        }
-#endif /* LINUX && TCB_WAITEXECVE */
+# endif
        return 0;
 }
+#endif
 
 #ifdef LINUX
 #ifndef __WNOTHREAD
@@ -1721,12 +1723,12 @@ printwaitn(struct tcb *tcp, int n, int bitness)
                int pid = tcp->u_arg[0];
                tprintf("%d, ", pid);
 #else
-               /*
-                * Sign-extend a 32-bit value when that's what it is.
-                */
                long pid = tcp->u_arg[0];
+# if SUPPORTED_PERSONALITIES > 1
+               /* Sign-extend a 32-bit value when that's what it is. */
                if (personality_wordsize[current_personality] < sizeof pid)
                        pid = (long) (int) pid;
+# endif
                tprintf("%ld, ", pid);
 #endif
        } else {
index b623ac8dcbfa3bb257a5ff7338174710308cd6ec..31c5a65464e95f15d5c81b22c98362b281bd014f 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -1653,12 +1653,12 @@ int
 sys_kill(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               /*
-                * Sign-extend a 32-bit value when that's what it is.
-                */
                long pid = tcp->u_arg[0];
+#if SUPPORTED_PERSONALITIES > 1
+               /* Sign-extend a 32-bit value when that's what it is. */
                if (personality_wordsize[current_personality] < sizeof pid)
                        pid = (long) (int) pid;
+#endif
                tprintf("%ld, %s", pid, signame(tcp->u_arg[1]));
        }
        return 0;
index cbe9f124b20e46a0bf84a9ec3cfb5c0595b0a7d0..76ef39c19e0d99b48693750179987513297fa66f 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -657,7 +657,7 @@ internal_syscall(struct tcb *tcp)
         * correctly support following forks in the presence of tracing
         * qualifiers.
         */
-       int     (*func)();
+       int (*func)();
 
        if (tcp->scno < 0 || tcp->scno >= nsyscalls)
                return 0;
@@ -677,15 +677,17 @@ internal_syscall(struct tcb *tcp)
           )
                return internal_fork(tcp);
 
+#if defined SUNOS4 || (defined LINUX && defined TCB_WAITEXECVE)
        if (   sys_execve == func
-#if defined(SPARC) || defined(SPARC64) || defined(SUNOS4)
+# if defined(SPARC) || defined(SPARC64) || defined(SUNOS4)
            || sys_execv == func
-#endif
-#if UNIXWARE > 2
+# endif
+# if UNIXWARE > 2
            || sys_rexecve == func
-#endif
+# endif
           )
                return internal_exec(tcp);
+#endif
 
        return 0;
 }
@@ -1536,10 +1538,12 @@ static inline int
 is_negated_errno(unsigned long int val)
 {
        unsigned long int max = -(long int) nerrnos;
+# if SUPPORTED_PERSONALITIES > 1
        if (personality_wordsize[current_personality] < sizeof(val)) {
                val = (unsigned int) val;
                max = (unsigned int) max;
        }
+# endif
        return val > max;
 }
 #endif
@@ -2467,14 +2471,13 @@ trace_syscall_exiting(struct tcb *tcp)
                        break;
 #endif /* LINUX */
                default:
-                       tprintf("= -1 ");
                        if (u_error < 0)
-                               tprintf("E??? (errno %ld)", u_error);
+                               tprintf("= -1 E??? (errno %ld)", u_error);
                        else if (u_error < nerrnos)
-                               tprintf("%s (%s)", errnoent[u_error],
+                               tprintf("= -1 %s (%s)", errnoent[u_error],
                                        strerror(u_error));
                        else
-                               tprintf("ERRNO_%ld (%s)", u_error,
+                               tprintf("= -1 ERRNO_%ld (%s)", u_error,
                                        strerror(u_error));
                        break;
                }