6 # define __WNOTHREAD 0x20000000
9 # define __WALL 0x40000000
12 # define __WCLONE 0x80000000
15 #include "xlat/wait4_options.h"
17 #if !defined WCOREFLAG && defined WCOREFLG
18 # define WCOREFLAG WCOREFLG
21 # define WCOREFLAG 0x80
24 # define WCOREDUMP(status) ((status) & 0200)
27 # define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
30 # define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
33 # define W_CONTINUED 0xffff
37 #include "xlat/ptrace_events.h"
40 printstatus(int status)
45 * Here is a tricky presentation problem. This solution
46 * is still not entirely satisfactory but since there
47 * are no wait status constructors it will have to do.
49 if (WIFSTOPPED(status)) {
50 int sig = WSTOPSIG(status);
51 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s%s}",
53 sig & 0x80 ? " | 0x80" : "");
54 status &= ~W_STOPCODE(sig);
56 else if (WIFSIGNALED(status)) {
57 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
58 signame(WTERMSIG(status)),
59 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
60 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
62 else if (WIFEXITED(status)) {
63 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
66 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
69 else if (WIFCONTINUED(status)) {
70 tprints("[{WIFCONTINUED(s)}");
71 status &= ~W_CONTINUED;
75 tprintf("[%#x]", status);
80 unsigned int event = (unsigned int) status >> 16;
83 printxval(ptrace_events, event, "PTRACE_EVENT_???");
88 tprintf(" | %#x", status);
96 printwaitn(struct tcb *tcp, int n, int bitness)
101 /* On Linux, kernel-side pid_t is typedef'ed to int
102 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
103 * pid argument to int on 64bit arches, producing,
104 * for example, wait4(4294967295, ...) instead of -1
105 * in strace. We have to use int here, not long.
107 int pid = tcp->u_arg[0];
108 tprintf("%d, ", pid);
113 else if (syserror(tcp) || tcp->u_rval == 0)
114 tprintf("%#lx", tcp->u_arg[1]);
115 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
121 printflags(wait4_options, tcp->u_arg[2], "W???");
127 else if (tcp->u_rval > 0) {
130 printrusage32(tcp, tcp->u_arg[3]);
133 printrusage(tcp, tcp->u_arg[3]);
136 tprintf("%#lx", tcp->u_arg[3]);
143 sys_waitpid(struct tcb *tcp)
145 return printwaitn(tcp, 3, 0);
149 sys_wait4(struct tcb *tcp)
151 return printwaitn(tcp, 4, 0);
156 sys_osf_wait4(struct tcb *tcp)
158 return printwaitn(tcp, 4, 1);
162 #include "xlat/waitid_types.h"
165 sys_waitid(struct tcb *tcp)
168 printxval(waitid_types, tcp->u_arg[0], "P_???");
169 tprintf(", %ld, ", tcp->u_arg[1]);
173 printsiginfo_at(tcp, tcp->u_arg[2]);
176 printflags(wait4_options, tcp->u_arg[3], "W???");
177 if (tcp->s_ent->nargs > 4) {
182 else if (tcp->u_error)
183 tprintf("%#lx", tcp->u_arg[4]);
185 printrusage(tcp, tcp->u_arg[4]);