5 #include "xlat/wait4_options.h"
7 #if !defined WCOREFLAG && defined WCOREFLG
8 # define WCOREFLAG WCOREFLG
11 # define WCOREFLAG 0x80
14 # define WCOREDUMP(status) ((status) & 0200)
17 # define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
20 # define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
23 # define W_CONTINUED 0xffff
27 #include "xlat/ptrace_events.h"
30 printstatus(int status)
35 * Here is a tricky presentation problem. This solution
36 * is still not entirely satisfactory but since there
37 * are no wait status constructors it will have to do.
39 if (WIFSTOPPED(status)) {
40 int sig = WSTOPSIG(status);
41 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s%s}",
43 sig & 0x80 ? " | 0x80" : "");
44 status &= ~W_STOPCODE(sig);
46 else if (WIFSIGNALED(status)) {
47 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
48 signame(WTERMSIG(status)),
49 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
50 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
52 else if (WIFEXITED(status)) {
53 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
56 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
59 else if (WIFCONTINUED(status)) {
60 tprints("[{WIFCONTINUED(s)}");
61 status &= ~W_CONTINUED;
65 tprintf("[%#x]", status);
70 unsigned int event = (unsigned int) status >> 16;
73 printxval(ptrace_events, event, "PTRACE_EVENT_???");
78 tprintf(" | %#x", status);
86 printwaitn(struct tcb *tcp, int n, int bitness)
91 /* On Linux, kernel-side pid_t is typedef'ed to int
92 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
93 * pid argument to int on 64bit arches, producing,
94 * for example, wait4(4294967295, ...) instead of -1
95 * in strace. We have to use int here, not long.
97 int pid = tcp->u_arg[0];
101 if (tcp->u_rval == 0)
102 printaddr(tcp->u_arg[1]);
103 else if (!umove_or_printaddr(tcp, tcp->u_arg[1], &status))
107 printflags(wait4_options, tcp->u_arg[2], "W???");
111 if (tcp->u_rval > 0) {
114 printrusage32(tcp, tcp->u_arg[3]);
117 printrusage(tcp, tcp->u_arg[3]);
120 printaddr(tcp->u_arg[3]);
128 return printwaitn(tcp, 3, 0);
133 return printwaitn(tcp, 4, 0);
139 return printwaitn(tcp, 4, 1);
143 #include "xlat/waitid_types.h"
148 printxval(waitid_types, tcp->u_arg[0], "P_???");
149 tprintf(", %ld, ", tcp->u_arg[1]);
152 printsiginfo_at(tcp, tcp->u_arg[2]);
155 printflags(wait4_options, tcp->u_arg[3], "W???");
156 if (tcp->s_ent->nargs > 4) {
159 printrusage(tcp, tcp->u_arg[4]);