]> granicus.if.org Git - strace/commitdiff
Enhance wait status decoding
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 12 Feb 2015 22:43:02 +0000 (22:43 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 12 Feb 2015 23:24:46 +0000 (23:24 +0000)
* xlat/ptrace_events.in: New file.
* wait.c: Include "xlat/ptrace_events.h".
(printstatus): In case of WIFSTOPPED, print 0x80 flag separately from
the stop signal name.
[WIFCONTINUED]: Add WIFCONTINUED support.
Decode PTRACE_EVENT_* events.

wait.c
xlat/ptrace_events.in [new file with mode: 0644]

diff --git a/wait.c b/wait.c
index 53808641e238b902e77eb890650cd38de036e243..ad368d2709c171e1050a597a3d361cb0ee2469b9 100644 (file)
--- a/wait.c
+++ b/wait.c
 #ifndef W_EXITCODE
 # define W_EXITCODE(ret, sig)  ((ret) << 8 | (sig))
 #endif
+#ifndef W_CONTINUED
+# define W_CONTINUED 0xffff
+#endif
+
+#include "xlat/ptrace_events.h"
 
 static int
 printstatus(int status)
@@ -41,9 +46,11 @@ printstatus(int status)
         * are no wait status constructors it will have to do.
         */
        if (WIFSTOPPED(status)) {
-               tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
-                       signame(WSTOPSIG(status)));
-               status &= ~W_STOPCODE(WSTOPSIG(status));
+               int sig = WSTOPSIG(status);
+               tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s%s}",
+                       signame(sig & 0x7f),
+                       sig & 0x80 ? " | 0x80" : "");
+               status &= ~W_STOPCODE(sig);
        }
        else if (WIFSIGNALED(status)) {
                tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
@@ -57,15 +64,29 @@ printstatus(int status)
                exited = 1;
                status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
        }
+#ifdef WIFCONTINUED
+       else if (WIFCONTINUED(status)) {
+               tprints("[{WIFCONTINUED(s)}");
+               status &= ~W_CONTINUED;
+       }
+#endif
        else {
                tprintf("[%#x]", status);
                return 0;
        }
 
-       if (status == 0)
-               tprints("]");
-       else
-               tprintf(" | %#x]", status);
+       if (status) {
+               unsigned int event = (unsigned int) status >> 16;
+               if (event) {
+                       tprints(" | ");
+                       printxval(ptrace_events, event, "PTRACE_EVENT_???");
+                       tprints(" << 16");
+                       status &= 0xffff;
+               }
+               if (status)
+                       tprintf(" | %#x", status);
+       }
+       tprints("]");
 
        return exited;
 }
diff --git a/xlat/ptrace_events.in b/xlat/ptrace_events.in
new file mode 100644 (file)
index 0000000..9e8f2a1
--- /dev/null
@@ -0,0 +1,8 @@
+PTRACE_EVENT_FORK
+PTRACE_EVENT_VFORK
+PTRACE_EVENT_CLONE
+PTRACE_EVENT_EXEC
+PTRACE_EVENT_VFORK_DONE
+PTRACE_EVENT_EXIT
+PTRACE_EVENT_SECCOMP
+PTRACE_EVENT_STOP