]> granicus.if.org Git - strace/commitdiff
Optimize out dummy PC printing on signal delivery
authorDenys Vlasenko <dvlasenk@redhat.com>
Sun, 21 Aug 2011 15:35:39 +0000 (17:35 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Tue, 23 Aug 2011 10:53:02 +0000 (12:53 +0200)
* strace.c (trace): Optimize out dummy PC printing on signal delivery.
While at it, tweak comments.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
strace.c

index e5973b416eb11884be4a4ab47a28a7aa69d44279..c018abf3fa5087a745d35cb4a78466e83e501f8f 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -2493,7 +2493,7 @@ trace()
                        if (tcp->flags & TCB_BPTSET) {
                                /*
                                 * One example is a breakpoint inherited from
-                                * parent through fork ().
+                                * parent through fork().
                                 */
                                if (clearbpt(tcp) < 0) /* Pretty fatal */ {
                                        droptcb(tcp);
@@ -2543,22 +2543,22 @@ trace()
 # define PSR_RI        41
                                pc += (psr >> PSR_RI) & 0x3;
 # define PC_FORMAT_STR " @ %lx"
-# define PC_FORMAT_ARG pc
+# define PC_FORMAT_ARG pc
 #else
-# define PC_FORMAT_STR "%s"
-# define PC_FORMAT_ARG ""
+# define PC_FORMAT_STR ""
+# define PC_FORMAT_ARG /* nothing */
 #endif
                                printleader(tcp);
                                if (ptrace(PTRACE_GETSIGINFO, pid, 0, &si) == 0) {
                                        tprintf("--- ");
                                        printsiginfo(&si, verbose(tcp));
                                        tprintf(" (%s)" PC_FORMAT_STR " ---",
-                                               strsignal(WSTOPSIG(status)),
+                                               strsignal(WSTOPSIG(status))
                                                PC_FORMAT_ARG);
                                } else
                                        tprintf("--- %s by %s" PC_FORMAT_STR " ---",
                                                strsignal(WSTOPSIG(status)),
-                                               signame(WSTOPSIG(status)),
+                                               signame(WSTOPSIG(status))
                                                PC_FORMAT_ARG);
                                printtrailer();
                        }
@@ -2568,9 +2568,15 @@ trace()
                        }
                        continue;
                }
-               /* we handled the STATUS, we are permitted to interrupt now. */
+
+               /* We handled quick cases, we are permitted to interrupt now. */
                if (interrupted)
                        return 0;
+
+               /* This should be syscall entry or exit.
+                * (Or it still can be that pesky post-execve SIGTRAP!)
+                * Handle it.
+                */
                if (trace_syscall(tcp) < 0 && !tcp->ptrace_errno) {
                        /* ptrace() failed in trace_syscall() with ESRCH.
                         * Likely a result of process disappearing mid-flight.