2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Linux for s390 port by D.J. Barrow
8 * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
9 * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH
10 * port by Greg Banks <gbanks@pocketpenguins.com>
12 * All rights reserved.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. The name of the author may not be used to endorse or promote products
23 * derived from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 #include <sys/resource.h>
42 #include <sys/utsname.h>
52 #ifdef HAVE_LINUX_PTRACE_H
53 # undef PTRACE_SYSCALL
54 # ifdef HAVE_STRUCT_IA64_FPREG
55 # define ia64_fpreg XXX_ia64_fpreg
57 # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
58 # define pt_all_user_regs XXX_pt_all_user_regs
60 # ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
61 # define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args
63 # include <linux/ptrace.h>
64 # undef ptrace_peeksiginfo_args
66 # undef pt_all_user_regs
71 # undef PTRACE_GETREGS
72 # define PTRACE_GETREGS PTRACE_GETREGS64
73 # undef PTRACE_SETREGS
74 # define PTRACE_SETREGS PTRACE_SETREGS64
77 #ifdef HAVE_LINUX_FUTEX_H
78 # include <linux/futex.h>
90 # define FUTEX_REQUEUE 3
94 #include <asm/posix_types.h>
96 #define GETGROUPS_T __kernel_gid_t
98 #define GETGROUPS32_T __kernel_gid32_t
101 # include <asm/ptrace_offsets.h>
102 # include <asm/rse.h>
106 # include <sys/prctl.h>
108 static const struct xlat prctl_options[] = {
115 #ifdef PR_SETSTACKSIZE
116 XLAT(PR_SETSTACKSIZE),
118 #ifdef PR_GETSTACKSIZE
119 XLAT(PR_GETSTACKSIZE),
124 #ifdef PR_UNBLKONEXEC
125 XLAT(PR_UNBLKONEXEC),
154 #ifdef PR_ATTACHADDRPERM
155 XLAT(PR_ATTACHADDRPERM),
157 #ifdef PR_PTHREADEXIT
158 XLAT(PR_PTHREADEXIT),
161 #ifdef PR_SET_PDEATHSIG
162 XLAT(PR_SET_PDEATHSIG),
164 #ifdef PR_GET_PDEATHSIG
165 XLAT(PR_GET_PDEATHSIG),
167 #ifdef PR_GET_DUMPABLE
168 XLAT(PR_GET_DUMPABLE),
170 #ifdef PR_SET_DUMPABLE
171 XLAT(PR_SET_DUMPABLE),
173 #ifdef PR_GET_UNALIGN
174 XLAT(PR_GET_UNALIGN),
176 #ifdef PR_SET_UNALIGN
177 XLAT(PR_SET_UNALIGN),
179 #ifdef PR_GET_KEEPCAPS
180 XLAT(PR_GET_KEEPCAPS),
182 #ifdef PR_SET_KEEPCAPS
183 XLAT(PR_SET_KEEPCAPS),
215 #ifdef PR_GET_SECCOMP
216 XLAT(PR_GET_SECCOMP),
218 #ifdef PR_SET_SECCOMP
219 XLAT(PR_SET_SECCOMP),
221 #ifdef PR_CAPBSET_READ
222 XLAT(PR_CAPBSET_READ),
224 #ifdef PR_CAPBSET_DROP
225 XLAT(PR_CAPBSET_DROP),
233 #ifdef PR_GET_SECUREBITS
234 XLAT(PR_GET_SECUREBITS),
236 #ifdef PR_SET_SECUREBITS
237 XLAT(PR_SET_SECUREBITS),
239 #ifdef PR_SET_TIMERSLACK
240 XLAT(PR_SET_TIMERSLACK),
242 #ifdef PR_GET_TIMERSLACK
243 XLAT(PR_GET_TIMERSLACK),
245 #ifdef PR_TASK_PERF_EVENTS_DISABLE
246 XLAT(PR_TASK_PERF_EVENTS_DISABLE),
248 #ifdef PR_TASK_PERF_EVENTS_ENABLE
249 XLAT(PR_TASK_PERF_EVENTS_ENABLE),
254 #ifdef PR_MCE_KILL_GET
255 XLAT(PR_MCE_KILL_GET),
260 #ifdef PR_SET_PTRACER
261 XLAT(PR_SET_PTRACER),
263 #ifdef PR_SET_CHILD_SUBREAPER
264 XLAT(PR_SET_CHILD_SUBREAPER),
266 #ifdef PR_GET_CHILD_SUBREAPER
267 XLAT(PR_GET_CHILD_SUBREAPER),
269 #ifdef PR_SET_NO_NEW_PRIVS
270 XLAT(PR_SET_NO_NEW_PRIVS),
272 #ifdef PR_GET_NO_NEW_PRIVS
273 XLAT(PR_GET_NO_NEW_PRIVS),
275 #ifdef PR_GET_TID_ADDRESS
276 XLAT(PR_GET_TID_ADDRESS),
282 unalignctl_string(unsigned int ctl)
284 static char buf[sizeof(int)*2 + 2];
287 #ifdef PR_UNALIGN_NOPRINT
288 case PR_UNALIGN_NOPRINT:
291 #ifdef PR_UNALIGN_SIGBUS
292 case PR_UNALIGN_SIGBUS:
298 sprintf(buf, "%x", ctl);
303 sys_prctl(struct tcb *tcp)
308 printxval(prctl_options, tcp->u_arg[0], "PR_???");
309 switch (tcp->u_arg[0]) {
314 #ifdef PR_SET_PDEATHSIG
315 case PR_SET_PDEATHSIG:
316 tprintf(", %lu", tcp->u_arg[1]);
319 #ifdef PR_GET_PDEATHSIG
320 case PR_GET_PDEATHSIG:
323 #ifdef PR_SET_DUMPABLE
324 case PR_SET_DUMPABLE:
325 tprintf(", %lu", tcp->u_arg[1]);
328 #ifdef PR_GET_DUMPABLE
329 case PR_GET_DUMPABLE:
332 #ifdef PR_SET_UNALIGN
334 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
337 #ifdef PR_GET_UNALIGN
339 tprintf(", %#lx", tcp->u_arg[1]);
342 #ifdef PR_SET_KEEPCAPS
343 case PR_SET_KEEPCAPS:
344 tprintf(", %lu", tcp->u_arg[1]);
347 #ifdef PR_GET_KEEPCAPS
348 case PR_GET_KEEPCAPS:
352 for (i = 1; i < tcp->s_ent->nargs; i++)
353 tprintf(", %#lx", tcp->u_arg[i]);
357 switch (tcp->u_arg[0]) {
358 #ifdef PR_GET_PDEATHSIG
359 case PR_GET_PDEATHSIG:
360 if (umove(tcp, tcp->u_arg[1], &i) < 0)
361 tprintf(", %#lx", tcp->u_arg[1]);
363 tprintf(", {%u}", i);
366 #ifdef PR_GET_DUMPABLE
367 case PR_GET_DUMPABLE:
368 return RVAL_UDECIMAL;
370 #ifdef PR_GET_UNALIGN
372 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
374 tcp->auxstr = unalignctl_string(i);
377 #ifdef PR_GET_KEEPCAPS
378 case PR_GET_KEEPCAPS:
379 return RVAL_UDECIMAL;
387 #endif /* HAVE_PRCTL */
390 sys_sethostname(struct tcb *tcp)
393 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
394 tprintf(", %lu", tcp->u_arg[1]);
401 sys_gethostname(struct tcb *tcp)
405 tprintf("%#lx", tcp->u_arg[0]);
407 printpath(tcp, tcp->u_arg[0]);
408 tprintf(", %lu", tcp->u_arg[1]);
415 sys_setdomainname(struct tcb *tcp)
418 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
419 tprintf(", %lu", tcp->u_arg[1]);
425 sys_exit(struct tcb *tcp)
428 fprintf(stderr, "_exit returned!\n");
431 /* special case: we stop tracing this process, finish line now */
432 tprintf("%ld) ", tcp->u_arg[0]);
439 /* defines copied from linux/sched.h since we can't include that
440 * ourselves (it conflicts with *lots* of libc includes)
442 #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
443 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
444 #define CLONE_FS 0x00000200 /* set if fs info shared between processes */
445 #define CLONE_FILES 0x00000400 /* set if open files shared between processes */
446 #define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
447 #define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
448 #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
449 #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
450 #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
451 #define CLONE_THREAD 0x00010000 /* Same thread group? */
452 #define CLONE_NEWNS 0x00020000 /* New namespace group? */
453 #define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
454 #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
455 #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
456 #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
457 #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
458 #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
459 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
460 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
461 #define CLONE_NEWIPC 0x08000000 /* New ipcs */
462 #define CLONE_NEWUSER 0x10000000 /* New user namespace */
463 #define CLONE_NEWPID 0x20000000 /* New pid namespace */
464 #define CLONE_NEWNET 0x40000000 /* New network namespace */
465 #define CLONE_IO 0x80000000 /* Clone io context */
467 static const struct xlat clone_flags[] = {
472 XLAT(CLONE_IDLETASK),
480 XLAT(CLONE_PARENT_SETTID),
481 XLAT(CLONE_CHILD_CLEARTID),
482 XLAT(CLONE_UNTRACED),
483 XLAT(CLONE_CHILD_SETTID),
494 #if defined I386 || defined X86_64 || defined X32
495 extern void print_user_desc(struct tcb *, long);
496 #endif /* I386 || X86_64 || X32 */
501 # define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
502 # define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
503 # define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
504 # define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
505 #elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
511 #elif defined X86_64 || defined X32
512 /* x86 personality processes have the last two arguments flipped. */
516 # define ARG_CTID ((current_personality != 1) ? 3 : 4)
517 # define ARG_TLS ((current_personality != 1) ? 4 : 3)
518 #elif defined ALPHA || defined TILE || defined OR1K
533 sys_clone(struct tcb *tcp)
536 const char *sep = "|";
537 unsigned long flags = tcp->u_arg[ARG_FLAGS];
538 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
540 if (ARG_STACKSIZE != -1)
541 tprintf("stack_size=%#lx, ",
542 tcp->u_arg[ARG_STACKSIZE]);
545 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
547 if ((flags & CSIGNAL) != 0)
548 tprintf("%s%s", sep, signame(flags & CSIGNAL));
549 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
550 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
552 if (flags & CLONE_PARENT_SETTID)
553 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
554 if (flags & CLONE_SETTLS) {
555 #if defined I386 || defined X86_64 || defined X32
557 if (current_personality == 1)
561 print_user_desc(tcp, tcp->u_arg[ARG_TLS]);
566 #endif /* I386 || X86_64 || X32 */
567 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
569 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
570 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
572 /* TODO on syscall entry:
573 * We can clear CLONE_PTRACE here since it is an ancient hack
574 * to allow us to catch children, and we use another hack for that.
575 * But CLONE_PTRACE can conceivably be used by malicious programs
576 * to subvert us. By clearing this bit, we can defend against it:
577 * in untraced execution, CLONE_PTRACE should have no effect.
579 * We can also clear CLONE_UNTRACED, since it allows to start
580 * children outside of our control. At the moment
581 * I'm trying to figure out whether there is a *legitimate*
582 * use of this flag which we should respect.
588 sys_unshare(struct tcb *tcp)
591 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
596 sys_fork(struct tcb *tcp)
599 return RVAL_UDECIMAL;
604 sys_vfork(struct tcb *tcp)
607 return RVAL_UDECIMAL;
611 int sys_getuid(struct tcb *tcp)
614 tcp->u_rval = (uid_t) tcp->u_rval;
615 return RVAL_UDECIMAL;
618 int sys_setfsuid(struct tcb *tcp)
621 tprintf("%u", (uid_t) tcp->u_arg[0]);
623 tcp->u_rval = (uid_t) tcp->u_rval;
624 return RVAL_UDECIMAL;
628 sys_setuid(struct tcb *tcp)
631 tprintf("%u", (uid_t) tcp->u_arg[0]);
637 sys_getresuid(struct tcb *tcp)
642 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
643 tcp->u_arg[1], tcp->u_arg[2]);
645 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
646 tprintf("%#lx, ", tcp->u_arg[0]);
648 tprintf("[%lu], ", (unsigned long) uid);
649 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
650 tprintf("%#lx, ", tcp->u_arg[1]);
652 tprintf("[%lu], ", (unsigned long) uid);
653 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
654 tprintf("%#lx", tcp->u_arg[2]);
656 tprintf("[%lu]", (unsigned long) uid);
663 sys_setreuid(struct tcb *tcp)
666 printuid("", tcp->u_arg[0]);
667 printuid(", ", tcp->u_arg[1]);
673 sys_setresuid(struct tcb *tcp)
676 printuid("", tcp->u_arg[0]);
677 printuid(", ", tcp->u_arg[1]);
678 printuid(", ", tcp->u_arg[2]);
684 sys_setgroups(struct tcb *tcp)
687 unsigned long len, size, start, cur, end, abbrev_end;
692 tprintf("%lu, ", len);
697 start = tcp->u_arg[1];
702 size = len * sizeof(gid);
704 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
705 tprintf("%#lx", start);
709 abbrev_end = start + max_strlen * sizeof(gid);
710 if (abbrev_end < start)
716 for (cur = start; cur < end; cur += sizeof(gid)) {
719 if (cur >= abbrev_end) {
723 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
728 tprintf("%lu", (unsigned long) gid);
732 tprintf(" %#lx", tcp->u_arg[1]);
738 sys_getgroups(struct tcb *tcp)
744 tprintf("%lu, ", len);
746 unsigned long size, start, cur, end, abbrev_end;
755 start = tcp->u_arg[1];
760 if (tcp->u_arg[0] == 0) {
761 tprintf("%#lx", start);
764 size = len * sizeof(gid);
766 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
767 size / sizeof(gid) != len || end < start) {
768 tprintf("%#lx", start);
772 abbrev_end = start + max_strlen * sizeof(gid);
773 if (abbrev_end < start)
779 for (cur = start; cur < end; cur += sizeof(gid)) {
782 if (cur >= abbrev_end) {
786 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
791 tprintf("%lu", (unsigned long) gid);
795 tprintf(" %#lx", tcp->u_arg[1]);
801 sys_setgroups32(struct tcb *tcp)
804 unsigned long len, size, start, cur, end, abbrev_end;
809 tprintf("%lu, ", len);
814 start = tcp->u_arg[1];
819 size = len * sizeof(gid);
821 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
822 tprintf("%#lx", start);
826 abbrev_end = start + max_strlen * sizeof(gid);
827 if (abbrev_end < start)
833 for (cur = start; cur < end; cur += sizeof(gid)) {
836 if (cur >= abbrev_end) {
840 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
845 tprintf("%lu", (unsigned long) gid);
849 tprintf(" %#lx", tcp->u_arg[1]);
855 sys_getgroups32(struct tcb *tcp)
861 tprintf("%lu, ", len);
863 unsigned long size, start, cur, end, abbrev_end;
872 start = tcp->u_arg[1];
877 size = len * sizeof(gid);
879 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
880 size / sizeof(gid) != len || end < start) {
881 tprintf("%#lx", start);
885 abbrev_end = start + max_strlen * sizeof(gid);
886 if (abbrev_end < start)
892 for (cur = start; cur < end; cur += sizeof(gid)) {
895 if (cur >= abbrev_end) {
899 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
904 tprintf("%lu", (unsigned long) gid);
908 tprintf(" %#lx", tcp->u_arg[1]);
914 printargv(struct tcb *tcp, long addr)
919 char data[sizeof(long)];
923 unsigned wordsize = current_wordsize;
926 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
927 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
928 tprintf("%#lx", addr);
936 printstr(tcp, cp.p64, -1);
940 tprintf("%s...", sep);
944 printargc(const char *fmt, struct tcb *tcp, long addr)
949 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
950 addr += sizeof(char *);
952 tprintf(fmt, count, count == 1 ? "" : "s");
955 #if defined(SPARC) || defined(SPARC64)
957 sys_execv(struct tcb *tcp)
960 printpath(tcp, tcp->u_arg[0]);
962 tprintf(", %#lx", tcp->u_arg[1]);
965 printargv(tcp, tcp->u_arg[1]);
974 sys_execve(struct tcb *tcp)
977 printpath(tcp, tcp->u_arg[0]);
979 tprintf(", %#lx", tcp->u_arg[1]);
982 printargv(tcp, tcp->u_arg[1]);
986 tprintf(", %#lx", tcp->u_arg[2]);
987 else if (abbrev(tcp))
988 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
991 printargv(tcp, tcp->u_arg[2]);
999 #define __WNOTHREAD 0x20000000
1002 #define __WALL 0x40000000
1005 #define __WCLONE 0x80000000
1008 static const struct xlat wait4_options[] = {
1040 #if !defined WCOREFLAG && defined WCOREFLG
1041 # define WCOREFLAG WCOREFLG
1044 # define WCOREFLAG 0x80
1047 # define WCOREDUMP(status) ((status) & 0200)
1050 # define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
1053 # define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
1057 printstatus(int status)
1062 * Here is a tricky presentation problem. This solution
1063 * is still not entirely satisfactory but since there
1064 * are no wait status constructors it will have to do.
1066 if (WIFSTOPPED(status)) {
1067 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
1068 signame(WSTOPSIG(status)));
1069 status &= ~W_STOPCODE(WSTOPSIG(status));
1071 else if (WIFSIGNALED(status)) {
1072 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
1073 signame(WTERMSIG(status)),
1074 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
1075 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1077 else if (WIFEXITED(status)) {
1078 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
1079 WEXITSTATUS(status));
1081 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
1084 tprintf("[%#x]", status);
1091 tprintf(" | %#x]", status);
1097 printwaitn(struct tcb *tcp, int n, int bitness)
1101 if (entering(tcp)) {
1102 /* On Linux, kernel-side pid_t is typedef'ed to int
1103 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
1104 * pid argument to int on 64bit arches, producing,
1105 * for example, wait4(4294967295, ...) instead of -1
1106 * in strace. We have to use int here, not long.
1108 int pid = tcp->u_arg[0];
1109 tprintf("%d, ", pid);
1114 else if (syserror(tcp) || tcp->u_rval == 0)
1115 tprintf("%#lx", tcp->u_arg[1]);
1116 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
1119 printstatus(status);
1122 printflags(wait4_options, tcp->u_arg[2], "W???");
1128 else if (tcp->u_rval > 0) {
1131 printrusage32(tcp, tcp->u_arg[3]);
1134 printrusage(tcp, tcp->u_arg[3]);
1137 tprintf("%#lx", tcp->u_arg[3]);
1144 sys_waitpid(struct tcb *tcp)
1146 return printwaitn(tcp, 3, 0);
1150 sys_wait4(struct tcb *tcp)
1152 return printwaitn(tcp, 4, 0);
1157 sys_osf_wait4(struct tcb *tcp)
1159 return printwaitn(tcp, 4, 1);
1163 static const struct xlat waitid_types[] = {
1189 sys_waitid(struct tcb *tcp)
1191 if (entering(tcp)) {
1192 printxval(waitid_types, tcp->u_arg[0], "P_???");
1193 tprintf(", %ld, ", tcp->u_arg[1]);
1197 printsiginfo_at(tcp, tcp->u_arg[2]);
1200 printflags(wait4_options, tcp->u_arg[3], "W???");
1201 if (tcp->s_ent->nargs > 4) {
1206 else if (tcp->u_error)
1207 tprintf("%#lx", tcp->u_arg[4]);
1209 printrusage(tcp, tcp->u_arg[4]);
1216 sys_uname(struct tcb *tcp)
1218 struct utsname uname;
1221 if (syserror(tcp) || !verbose(tcp))
1222 tprintf("%#lx", tcp->u_arg[0]);
1223 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
1225 else if (!abbrev(tcp)) {
1226 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1227 uname.sysname, uname.nodename);
1228 tprintf("release=\"%s\", version=\"%s\", ",
1229 uname.release, uname.version);
1230 tprintf("machine=\"%s\"", uname.machine);
1231 #ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
1232 tprintf(", domainname=\"%s\"", uname.domainname);
1237 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1238 uname.sysname, uname.nodename);
1243 static const struct xlat ptrace_cmds[] = {
1244 XLAT(PTRACE_TRACEME),
1245 XLAT(PTRACE_PEEKTEXT),
1246 XLAT(PTRACE_PEEKDATA),
1247 XLAT(PTRACE_PEEKUSER),
1248 XLAT(PTRACE_POKETEXT),
1249 XLAT(PTRACE_POKEDATA),
1250 XLAT(PTRACE_POKEUSER),
1253 XLAT(PTRACE_SINGLESTEP),
1254 XLAT(PTRACE_ATTACH),
1255 XLAT(PTRACE_DETACH),
1256 #ifdef PTRACE_GETREGS
1257 XLAT(PTRACE_GETREGS),
1259 #ifdef PTRACE_SETREGS
1260 XLAT(PTRACE_SETREGS),
1262 #ifdef PTRACE_GETFPREGS
1263 XLAT(PTRACE_GETFPREGS),
1265 #ifdef PTRACE_SETFPREGS
1266 XLAT(PTRACE_SETFPREGS),
1268 #ifdef PTRACE_GETFPXREGS
1269 XLAT(PTRACE_GETFPXREGS),
1271 #ifdef PTRACE_SETFPXREGS
1272 XLAT(PTRACE_SETFPXREGS),
1274 #ifdef PTRACE_GETVRREGS
1275 XLAT(PTRACE_GETVRREGS),
1277 #ifdef PTRACE_SETVRREGS
1278 XLAT(PTRACE_SETVRREGS),
1280 #ifdef PTRACE_SETOPTIONS
1281 XLAT(PTRACE_SETOPTIONS),
1283 #ifdef PTRACE_GETEVENTMSG
1284 XLAT(PTRACE_GETEVENTMSG),
1286 #ifdef PTRACE_GETSIGINFO
1287 XLAT(PTRACE_GETSIGINFO),
1289 #ifdef PTRACE_SETSIGINFO
1290 XLAT(PTRACE_SETSIGINFO),
1292 #ifdef PTRACE_GETREGSET
1293 XLAT(PTRACE_GETREGSET),
1295 #ifdef PTRACE_SETREGSET
1296 XLAT(PTRACE_SETREGSET),
1298 #ifdef PTRACE_SET_SYSCALL
1299 XLAT(PTRACE_SET_SYSCALL),
1304 #ifdef PTRACE_INTERRUPT
1305 XLAT(PTRACE_INTERRUPT),
1307 #ifdef PTRACE_LISTEN
1308 XLAT(PTRACE_LISTEN),
1310 XLAT(PTRACE_SYSCALL),
1315 #ifdef PTRACE_SETOPTIONS
1316 static const struct xlat ptrace_setoptions_flags[] = {
1317 # ifdef PTRACE_O_TRACESYSGOOD
1318 XLAT(PTRACE_O_TRACESYSGOOD),
1320 # ifdef PTRACE_O_TRACEFORK
1321 XLAT(PTRACE_O_TRACEFORK),
1323 # ifdef PTRACE_O_TRACEVFORK
1324 XLAT(PTRACE_O_TRACEVFORK),
1326 # ifdef PTRACE_O_TRACECLONE
1327 XLAT(PTRACE_O_TRACECLONE),
1329 # ifdef PTRACE_O_TRACEEXEC
1330 XLAT(PTRACE_O_TRACEEXEC),
1332 # ifdef PTRACE_O_TRACEVFORKDONE
1333 XLAT(PTRACE_O_TRACEVFORKDONE),
1335 # ifdef PTRACE_O_TRACEEXIT
1336 XLAT(PTRACE_O_TRACEEXIT),
1338 # ifdef PTRACE_O_TRACESECCOMP
1339 XLAT(PTRACE_O_TRACESECCOMP),
1341 # ifdef PTRACE_O_EXITKILL
1342 XLAT(PTRACE_O_EXITKILL),
1346 #endif /* PTRACE_SETOPTIONS */
1348 static const struct xlat nt_descriptor_types[] = {
1361 #ifdef NT_TASKSTRUCT
1362 XLAT(NT_TASKSTRUCT),
1412 #ifdef NT_386_IOPERM
1413 XLAT(NT_386_IOPERM),
1415 #ifdef NT_X86_XSTATE
1416 XLAT(NT_X86_XSTATE),
1421 #define uoff(member) offsetof(struct user, member)
1423 const struct xlat struct_user_offsets[] = {
1424 #if defined(S390) || defined(S390X)
1425 { PT_PSWMASK, "psw_mask" },
1426 { PT_PSWADDR, "psw_addr" },
1427 { PT_GPR0, "gpr0" },
1428 { PT_GPR1, "gpr1" },
1429 { PT_GPR2, "gpr2" },
1430 { PT_GPR3, "gpr3" },
1431 { PT_GPR4, "gpr4" },
1432 { PT_GPR5, "gpr5" },
1433 { PT_GPR6, "gpr6" },
1434 { PT_GPR7, "gpr7" },
1435 { PT_GPR8, "gpr8" },
1436 { PT_GPR9, "gpr9" },
1437 { PT_GPR10, "gpr10" },
1438 { PT_GPR11, "gpr11" },
1439 { PT_GPR12, "gpr12" },
1440 { PT_GPR13, "gpr13" },
1441 { PT_GPR14, "gpr14" },
1442 { PT_GPR15, "gpr15" },
1443 { PT_ACR0, "acr0" },
1444 { PT_ACR1, "acr1" },
1445 { PT_ACR2, "acr2" },
1446 { PT_ACR3, "acr3" },
1447 { PT_ACR4, "acr4" },
1448 { PT_ACR5, "acr5" },
1449 { PT_ACR6, "acr6" },
1450 { PT_ACR7, "acr7" },
1451 { PT_ACR8, "acr8" },
1452 { PT_ACR9, "acr9" },
1453 { PT_ACR10, "acr10" },
1454 { PT_ACR11, "acr11" },
1455 { PT_ACR12, "acr12" },
1456 { PT_ACR13, "acr13" },
1457 { PT_ACR14, "acr14" },
1458 { PT_ACR15, "acr15" },
1459 { PT_ORIGGPR2, "orig_gpr2" },
1462 { PT_FPR0_HI, "fpr0.hi" },
1463 { PT_FPR0_LO, "fpr0.lo" },
1464 { PT_FPR1_HI, "fpr1.hi" },
1465 { PT_FPR1_LO, "fpr1.lo" },
1466 { PT_FPR2_HI, "fpr2.hi" },
1467 { PT_FPR2_LO, "fpr2.lo" },
1468 { PT_FPR3_HI, "fpr3.hi" },
1469 { PT_FPR3_LO, "fpr3.lo" },
1470 { PT_FPR4_HI, "fpr4.hi" },
1471 { PT_FPR4_LO, "fpr4.lo" },
1472 { PT_FPR5_HI, "fpr5.hi" },
1473 { PT_FPR5_LO, "fpr5.lo" },
1474 { PT_FPR6_HI, "fpr6.hi" },
1475 { PT_FPR6_LO, "fpr6.lo" },
1476 { PT_FPR7_HI, "fpr7.hi" },
1477 { PT_FPR7_LO, "fpr7.lo" },
1478 { PT_FPR8_HI, "fpr8.hi" },
1479 { PT_FPR8_LO, "fpr8.lo" },
1480 { PT_FPR9_HI, "fpr9.hi" },
1481 { PT_FPR9_LO, "fpr9.lo" },
1482 { PT_FPR10_HI, "fpr10.hi" },
1483 { PT_FPR10_LO, "fpr10.lo" },
1484 { PT_FPR11_HI, "fpr11.hi" },
1485 { PT_FPR11_LO, "fpr11.lo" },
1486 { PT_FPR12_HI, "fpr12.hi" },
1487 { PT_FPR12_LO, "fpr12.lo" },
1488 { PT_FPR13_HI, "fpr13.hi" },
1489 { PT_FPR13_LO, "fpr13.lo" },
1490 { PT_FPR14_HI, "fpr14.hi" },
1491 { PT_FPR14_LO, "fpr14.lo" },
1492 { PT_FPR15_HI, "fpr15.hi" },
1493 { PT_FPR15_LO, "fpr15.lo" },
1496 { PT_FPR0, "fpr0" },
1497 { PT_FPR1, "fpr1" },
1498 { PT_FPR2, "fpr2" },
1499 { PT_FPR3, "fpr3" },
1500 { PT_FPR4, "fpr4" },
1501 { PT_FPR5, "fpr5" },
1502 { PT_FPR6, "fpr6" },
1503 { PT_FPR7, "fpr7" },
1504 { PT_FPR8, "fpr8" },
1505 { PT_FPR9, "fpr9" },
1506 { PT_FPR10, "fpr10" },
1507 { PT_FPR11, "fpr11" },
1508 { PT_FPR12, "fpr12" },
1509 { PT_FPR13, "fpr13" },
1510 { PT_FPR14, "fpr14" },
1511 { PT_FPR15, "fpr15" },
1514 { PT_CR_10, "cr10" },
1515 { PT_CR_11, "cr11" },
1516 { PT_IEEE_IP, "ieee_exception_ip" },
1517 #elif defined(SPARC)
1518 /* XXX No support for these offsets yet. */
1520 /* XXX No support for these offsets yet. */
1521 #elif defined(POWERPC)
1523 # define PT_ORIG_R3 34
1525 # define REGSIZE (sizeof(unsigned long))
1526 { REGSIZE*PT_R0, "r0" },
1527 { REGSIZE*PT_R1, "r1" },
1528 { REGSIZE*PT_R2, "r2" },
1529 { REGSIZE*PT_R3, "r3" },
1530 { REGSIZE*PT_R4, "r4" },
1531 { REGSIZE*PT_R5, "r5" },
1532 { REGSIZE*PT_R6, "r6" },
1533 { REGSIZE*PT_R7, "r7" },
1534 { REGSIZE*PT_R8, "r8" },
1535 { REGSIZE*PT_R9, "r9" },
1536 { REGSIZE*PT_R10, "r10" },
1537 { REGSIZE*PT_R11, "r11" },
1538 { REGSIZE*PT_R12, "r12" },
1539 { REGSIZE*PT_R13, "r13" },
1540 { REGSIZE*PT_R14, "r14" },
1541 { REGSIZE*PT_R15, "r15" },
1542 { REGSIZE*PT_R16, "r16" },
1543 { REGSIZE*PT_R17, "r17" },
1544 { REGSIZE*PT_R18, "r18" },
1545 { REGSIZE*PT_R19, "r19" },
1546 { REGSIZE*PT_R20, "r20" },
1547 { REGSIZE*PT_R21, "r21" },
1548 { REGSIZE*PT_R22, "r22" },
1549 { REGSIZE*PT_R23, "r23" },
1550 { REGSIZE*PT_R24, "r24" },
1551 { REGSIZE*PT_R25, "r25" },
1552 { REGSIZE*PT_R26, "r26" },
1553 { REGSIZE*PT_R27, "r27" },
1554 { REGSIZE*PT_R28, "r28" },
1555 { REGSIZE*PT_R29, "r29" },
1556 { REGSIZE*PT_R30, "r30" },
1557 { REGSIZE*PT_R31, "r31" },
1558 { REGSIZE*PT_NIP, "NIP" },
1559 { REGSIZE*PT_MSR, "MSR" },
1560 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1561 { REGSIZE*PT_CTR, "CTR" },
1562 { REGSIZE*PT_LNK, "LNK" },
1563 { REGSIZE*PT_XER, "XER" },
1564 { REGSIZE*PT_CCR, "CCR" },
1565 { REGSIZE*PT_FPR0, "FPR0" },
1567 #elif defined(ALPHA)
1634 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1635 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1636 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1637 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1638 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1639 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1640 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1641 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1642 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1643 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1644 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1645 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1646 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1647 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1648 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1649 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1650 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1651 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1652 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1653 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1654 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1655 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1656 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1657 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1658 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1659 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1660 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1661 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1662 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1663 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1664 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1665 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1667 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1668 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1669 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1670 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1671 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1672 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1673 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1674 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1675 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1676 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
1677 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1678 { PT_B4, "b4" }, { PT_B5, "b5" },
1679 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
1681 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1682 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
1683 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1684 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1685 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1686 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1687 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1688 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1689 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1690 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1691 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1692 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1693 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1694 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1695 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1696 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1697 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
1699 { PT_AR_CSD, "ar.csd" },
1702 { PT_AR_SSD, "ar.ssd" },
1704 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
1723 #elif defined(X86_64) || defined(X32)
1742 { 8*EFLAGS, "8*EFL" },
1767 { 4*(REG_REG0+1), "4*REG_REG1" },
1768 { 4*(REG_REG0+2), "4*REG_REG2" },
1769 { 4*(REG_REG0+3), "4*REG_REG3" },
1770 { 4*(REG_REG0+4), "4*REG_REG4" },
1771 { 4*(REG_REG0+5), "4*REG_REG5" },
1772 { 4*(REG_REG0+6), "4*REG_REG6" },
1773 { 4*(REG_REG0+7), "4*REG_REG7" },
1774 { 4*(REG_REG0+8), "4*REG_REG8" },
1775 { 4*(REG_REG0+9), "4*REG_REG9" },
1776 { 4*(REG_REG0+10), "4*REG_REG10" },
1777 { 4*(REG_REG0+11), "4*REG_REG11" },
1778 { 4*(REG_REG0+12), "4*REG_REG12" },
1779 { 4*(REG_REG0+13), "4*REG_REG13" },
1780 { 4*(REG_REG0+14), "4*REG_REG14" },
1788 XLAT(4*REG_SYSCALL),
1791 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1792 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1793 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1794 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1795 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1796 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1797 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1798 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1799 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1800 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1801 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1802 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1803 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1804 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1805 XLAT(4*REG_FPREG15),
1808 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1809 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1810 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1811 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1812 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1813 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1814 XLAT(4*REG_XDREG14),
1822 { 16, "syscall no.(L)" },
1823 { 20, "syscall_no.(U)" },
1966 /* This entry is in case pt_regs contains dregs (depends on
1967 the kernel build options). */
1968 { uoff(regs), "offsetof(struct user, regs)" },
1969 { uoff(fpu), "offsetof(struct user, fpu)" },
1971 { uoff(regs.ARM_r0), "r0" },
1972 { uoff(regs.ARM_r1), "r1" },
1973 { uoff(regs.ARM_r2), "r2" },
1974 { uoff(regs.ARM_r3), "r3" },
1975 { uoff(regs.ARM_r4), "r4" },
1976 { uoff(regs.ARM_r5), "r5" },
1977 { uoff(regs.ARM_r6), "r6" },
1978 { uoff(regs.ARM_r7), "r7" },
1979 { uoff(regs.ARM_r8), "r8" },
1980 { uoff(regs.ARM_r9), "r9" },
1981 { uoff(regs.ARM_r10), "r10" },
1982 { uoff(regs.ARM_fp), "fp" },
1983 { uoff(regs.ARM_ip), "ip" },
1984 { uoff(regs.ARM_sp), "sp" },
1985 { uoff(regs.ARM_lr), "lr" },
1986 { uoff(regs.ARM_pc), "pc" },
1987 { uoff(regs.ARM_cpsr), "cpsr" },
1988 #elif defined(AVR32)
1989 { uoff(regs.sr), "sr" },
1990 { uoff(regs.pc), "pc" },
1991 { uoff(regs.lr), "lr" },
1992 { uoff(regs.sp), "sp" },
1993 { uoff(regs.r12), "r12" },
1994 { uoff(regs.r11), "r11" },
1995 { uoff(regs.r10), "r10" },
1996 { uoff(regs.r9), "r9" },
1997 { uoff(regs.r8), "r8" },
1998 { uoff(regs.r7), "r7" },
1999 { uoff(regs.r6), "r6" },
2000 { uoff(regs.r5), "r5" },
2001 { uoff(regs.r4), "r4" },
2002 { uoff(regs.r3), "r3" },
2003 { uoff(regs.r2), "r2" },
2004 { uoff(regs.r1), "r1" },
2005 { uoff(regs.r0), "r0" },
2006 { uoff(regs.r12_orig), "orig_r12" },
2080 { PTREGS_OFFSET_REG(0), "r0" },
2081 { PTREGS_OFFSET_REG(1), "r1" },
2082 { PTREGS_OFFSET_REG(2), "r2" },
2083 { PTREGS_OFFSET_REG(3), "r3" },
2084 { PTREGS_OFFSET_REG(4), "r4" },
2085 { PTREGS_OFFSET_REG(5), "r5" },
2086 { PTREGS_OFFSET_REG(6), "r6" },
2087 { PTREGS_OFFSET_REG(7), "r7" },
2088 { PTREGS_OFFSET_REG(8), "r8" },
2089 { PTREGS_OFFSET_REG(9), "r9" },
2090 { PTREGS_OFFSET_REG(10), "r10" },
2091 { PTREGS_OFFSET_REG(11), "r11" },
2092 { PTREGS_OFFSET_REG(12), "r12" },
2093 { PTREGS_OFFSET_REG(13), "r13" },
2094 { PTREGS_OFFSET_REG(14), "r14" },
2095 { PTREGS_OFFSET_REG(15), "r15" },
2096 { PTREGS_OFFSET_REG(16), "r16" },
2097 { PTREGS_OFFSET_REG(17), "r17" },
2098 { PTREGS_OFFSET_REG(18), "r18" },
2099 { PTREGS_OFFSET_REG(19), "r19" },
2100 { PTREGS_OFFSET_REG(20), "r20" },
2101 { PTREGS_OFFSET_REG(21), "r21" },
2102 { PTREGS_OFFSET_REG(22), "r22" },
2103 { PTREGS_OFFSET_REG(23), "r23" },
2104 { PTREGS_OFFSET_REG(24), "r24" },
2105 { PTREGS_OFFSET_REG(25), "r25" },
2106 { PTREGS_OFFSET_REG(26), "r26" },
2107 { PTREGS_OFFSET_REG(27), "r27" },
2108 { PTREGS_OFFSET_REG(28), "r28" },
2109 { PTREGS_OFFSET_REG(29), "r29" },
2110 { PTREGS_OFFSET_REG(30), "r30" },
2111 { PTREGS_OFFSET_REG(31), "r31" },
2112 { PTREGS_OFFSET_REG(32), "r32" },
2113 { PTREGS_OFFSET_REG(33), "r33" },
2114 { PTREGS_OFFSET_REG(34), "r34" },
2115 { PTREGS_OFFSET_REG(35), "r35" },
2116 { PTREGS_OFFSET_REG(36), "r36" },
2117 { PTREGS_OFFSET_REG(37), "r37" },
2118 { PTREGS_OFFSET_REG(38), "r38" },
2119 { PTREGS_OFFSET_REG(39), "r39" },
2120 { PTREGS_OFFSET_REG(40), "r40" },
2121 { PTREGS_OFFSET_REG(41), "r41" },
2122 { PTREGS_OFFSET_REG(42), "r42" },
2123 { PTREGS_OFFSET_REG(43), "r43" },
2124 { PTREGS_OFFSET_REG(44), "r44" },
2125 { PTREGS_OFFSET_REG(45), "r45" },
2126 { PTREGS_OFFSET_REG(46), "r46" },
2127 { PTREGS_OFFSET_REG(47), "r47" },
2128 { PTREGS_OFFSET_REG(48), "r48" },
2129 { PTREGS_OFFSET_REG(49), "r49" },
2130 { PTREGS_OFFSET_REG(50), "r50" },
2131 { PTREGS_OFFSET_REG(51), "r51" },
2132 { PTREGS_OFFSET_REG(52), "r52" },
2133 { PTREGS_OFFSET_TP, "tp" },
2134 { PTREGS_OFFSET_SP, "sp" },
2135 { PTREGS_OFFSET_LR, "lr" },
2136 { PTREGS_OFFSET_PC, "pc" },
2137 { PTREGS_OFFSET_EX1, "ex1" },
2138 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2139 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2140 { PTREGS_OFFSET_FLAGS, "flags" },
2143 XLAT(4*PT_FRAMETYPE),
2144 XLAT(4*PT_ORIG_R10),
2163 XLAT(4*PT_CSRINSTR),
2169 XLAT(4*PT_ORIG_R10),
2212 { PT_GPR(0), "r0" },
2213 { PT_GPR(1), "r1" },
2214 { PT_GPR(2), "r2" },
2215 { PT_GPR(3), "r3" },
2216 { PT_GPR(4), "r4" },
2217 { PT_GPR(5), "r5" },
2218 { PT_GPR(6), "r6" },
2219 { PT_GPR(7), "r7" },
2220 { PT_GPR(8), "r8" },
2221 { PT_GPR(9), "r9" },
2222 { PT_GPR(10), "r10" },
2223 { PT_GPR(11), "r11" },
2224 { PT_GPR(12), "r12" },
2225 { PT_GPR(13), "r13" },
2226 { PT_GPR(14), "r14" },
2227 { PT_GPR(15), "r15" },
2228 { PT_GPR(16), "r16" },
2229 { PT_GPR(17), "r17" },
2230 { PT_GPR(18), "r18" },
2231 { PT_GPR(19), "r19" },
2232 { PT_GPR(20), "r20" },
2233 { PT_GPR(21), "r21" },
2234 { PT_GPR(22), "r22" },
2235 { PT_GPR(23), "r23" },
2236 { PT_GPR(24), "r24" },
2237 { PT_GPR(25), "r25" },
2238 { PT_GPR(26), "r26" },
2239 { PT_GPR(27), "r27" },
2240 { PT_GPR(28), "r28" },
2241 { PT_GPR(29), "r29" },
2242 { PT_GPR(30), "r30" },
2243 { PT_GPR(31), "r31" },
2245 { PT_MSR, "rmsr", },
2246 { PT_EAR, "rear", },
2247 { PT_ESR, "resr", },
2248 { PT_FSR, "rfsr", },
2249 { PT_KERNEL_MODE, "kernel_mode", },
2288 { SYSCALL_NR, "syscall_nr" },
2289 { REG_AR_BASE, "ar0" },
2290 { REG_AR_BASE+1, "ar1" },
2291 { REG_AR_BASE+2, "ar2" },
2292 { REG_AR_BASE+3, "ar3" },
2293 { REG_AR_BASE+4, "ar4" },
2294 { REG_AR_BASE+5, "ar5" },
2295 { REG_AR_BASE+6, "ar6" },
2296 { REG_AR_BASE+7, "ar7" },
2297 { REG_AR_BASE+8, "ar8" },
2298 { REG_AR_BASE+9, "ar9" },
2299 { REG_AR_BASE+10, "ar10" },
2300 { REG_AR_BASE+11, "ar11" },
2301 { REG_AR_BASE+12, "ar12" },
2302 { REG_AR_BASE+13, "ar13" },
2303 { REG_AR_BASE+14, "ar14" },
2304 { REG_AR_BASE+15, "ar15" },
2305 { REG_AR_BASE+16, "ar16" },
2306 { REG_AR_BASE+17, "ar17" },
2307 { REG_AR_BASE+18, "ar18" },
2308 { REG_AR_BASE+19, "ar19" },
2309 { REG_AR_BASE+20, "ar20" },
2310 { REG_AR_BASE+21, "ar21" },
2311 { REG_AR_BASE+22, "ar22" },
2312 { REG_AR_BASE+23, "ar23" },
2313 { REG_AR_BASE+24, "ar24" },
2314 { REG_AR_BASE+25, "ar25" },
2315 { REG_AR_BASE+26, "ar26" },
2316 { REG_AR_BASE+27, "ar27" },
2317 { REG_AR_BASE+28, "ar28" },
2318 { REG_AR_BASE+29, "ar29" },
2319 { REG_AR_BASE+30, "ar30" },
2320 { REG_AR_BASE+31, "ar31" },
2321 { REG_AR_BASE+32, "ar32" },
2322 { REG_AR_BASE+33, "ar33" },
2323 { REG_AR_BASE+34, "ar34" },
2324 { REG_AR_BASE+35, "ar35" },
2325 { REG_AR_BASE+36, "ar36" },
2326 { REG_AR_BASE+37, "ar37" },
2327 { REG_AR_BASE+38, "ar38" },
2328 { REG_AR_BASE+39, "ar39" },
2329 { REG_AR_BASE+40, "ar40" },
2330 { REG_AR_BASE+41, "ar41" },
2331 { REG_AR_BASE+42, "ar42" },
2332 { REG_AR_BASE+43, "ar43" },
2333 { REG_AR_BASE+44, "ar44" },
2334 { REG_AR_BASE+45, "ar45" },
2335 { REG_AR_BASE+46, "ar46" },
2336 { REG_AR_BASE+47, "ar47" },
2337 { REG_AR_BASE+48, "ar48" },
2338 { REG_AR_BASE+49, "ar49" },
2339 { REG_AR_BASE+50, "ar50" },
2340 { REG_AR_BASE+51, "ar51" },
2341 { REG_AR_BASE+52, "ar52" },
2342 { REG_AR_BASE+53, "ar53" },
2343 { REG_AR_BASE+54, "ar54" },
2344 { REG_AR_BASE+55, "ar55" },
2345 { REG_AR_BASE+56, "ar56" },
2346 { REG_AR_BASE+57, "ar57" },
2347 { REG_AR_BASE+58, "ar58" },
2348 { REG_AR_BASE+59, "ar59" },
2349 { REG_AR_BASE+60, "ar60" },
2350 { REG_AR_BASE+61, "ar61" },
2351 { REG_AR_BASE+62, "ar62" },
2352 { REG_AR_BASE+63, "ar63" },
2353 { REG_LBEG, "lbeg" },
2354 { REG_LEND, "lend" },
2355 { REG_LCOUNT, "lcount" },
2361 { REG_A_BASE, "a0" },
2362 { REG_A_BASE+1, "a1" },
2363 { REG_A_BASE+2, "a2" },
2364 { REG_A_BASE+3, "a3" },
2365 { REG_A_BASE+4, "a4" },
2366 { REG_A_BASE+5, "a5" },
2367 { REG_A_BASE+6, "a6" },
2368 { REG_A_BASE+7, "a7" },
2369 { REG_A_BASE+8, "a8" },
2370 { REG_A_BASE+9, "a9" },
2371 { REG_A_BASE+10, "a10" },
2372 { REG_A_BASE+11, "a11" },
2373 { REG_A_BASE+12, "a12" },
2374 { REG_A_BASE+13, "a13" },
2375 { REG_A_BASE+14, "a14" },
2376 { REG_A_BASE+15, "a15" },
2379 /* Other fields in "struct user" */
2380 #if defined(S390) || defined(S390X)
2381 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2382 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2383 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2384 { uoff(start_code), "offsetof(struct user, start_code)" },
2385 /* S390[X] has no start_data */
2386 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2387 { uoff(signal), "offsetof(struct user, signal)" },
2388 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2389 { uoff(magic), "offsetof(struct user, magic)" },
2390 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2391 { sizeof(struct user), "sizeof(struct user)" },
2392 #elif defined(POWERPC)
2393 { sizeof(struct user), "sizeof(struct user)" },
2394 #elif defined(I386) || defined(X86_64) || defined(X32)
2395 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2396 { uoff(i387), "offsetof(struct user, i387)" },
2397 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2398 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2399 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2400 { uoff(start_code), "offsetof(struct user, start_code)" },
2401 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2402 { uoff(signal), "offsetof(struct user, signal)" },
2403 { uoff(reserved), "offsetof(struct user, reserved)" },
2404 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2405 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2406 { uoff(magic), "offsetof(struct user, magic)" },
2407 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2408 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
2409 { sizeof(struct user), "sizeof(struct user)" },
2411 { sizeof(struct user), "sizeof(struct user)" },
2413 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2414 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2415 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2416 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2417 { uoff(start_code), "offsetof(struct user, start_code)" },
2418 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2419 { uoff(signal), "offsetof(struct user, signal)" },
2420 { uoff(reserved), "offsetof(struct user, reserved)" },
2421 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2422 { uoff(magic), "offsetof(struct user, magic)" },
2423 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2424 { sizeof(struct user), "sizeof(struct user)" },
2425 #elif defined(AARCH64)
2428 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2429 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2430 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2431 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2432 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2433 { uoff(start_code), "offsetof(struct user, start_code)" },
2434 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2435 { uoff(signal), "offsetof(struct user, signal)" },
2436 { uoff(reserved), "offsetof(struct user, reserved)" },
2437 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2438 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2439 { uoff(magic), "offsetof(struct user, magic)" },
2440 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2441 { sizeof(struct user), "sizeof(struct user)" },
2442 #elif defined(MIPS) || defined(LINUX_MIPSN32)
2443 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2444 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2445 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2446 { uoff(start_code), "offsetof(struct user, start_code)" },
2447 { uoff(start_data), "offsetof(struct user, start_data)" },
2448 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2449 { uoff(signal), "offsetof(struct user, signal)" },
2450 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2451 { uoff(magic), "offsetof(struct user, magic)" },
2452 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2453 { sizeof(struct user), "sizeof(struct user)" },
2454 #elif defined(ALPHA)
2455 { sizeof(struct user), "sizeof(struct user)" },
2456 #elif defined(SPARC)
2457 { sizeof(struct user), "sizeof(struct user)" },
2458 #elif defined(SPARC64)
2459 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2460 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2461 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2462 { uoff(signal), "offsetof(struct user, signal)" },
2463 { uoff(magic), "offsetof(struct user, magic)" },
2464 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2465 { sizeof(struct user), "sizeof(struct user)" },
2468 #elif defined(SH) || defined(SH64)
2469 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2470 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2471 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2472 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2473 { uoff(start_code), "offsetof(struct user, start_code)" },
2474 { uoff(start_data), "offsetof(struct user, start_data)" },
2475 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2476 { uoff(signal), "offsetof(struct user, signal)" },
2477 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2478 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2479 { uoff(magic), "offsetof(struct user, magic)" },
2480 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2481 { sizeof(struct user), "sizeof(struct user)" },
2482 #elif defined(CRISV10) || defined(CRISV32)
2483 { sizeof(struct user), "sizeof(struct user)" },
2486 #elif defined(MICROBLAZE)
2487 { sizeof(struct user), "sizeof(struct user)" },
2488 #elif defined(AVR32)
2489 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2490 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2491 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2492 { uoff(start_code), "offsetof(struct user, start_code)" },
2493 { uoff(start_data), "offsetof(struct user, start_data)" },
2494 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2495 { uoff(signal), "offsetof(struct user, signal)" },
2496 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2497 { uoff(magic), "offsetof(struct user, magic)" },
2498 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2499 { sizeof(struct user), "sizeof(struct user)" },
2501 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2502 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2503 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2504 { uoff(start_code), "offsetof(struct user, start_code)" },
2505 { uoff(signal), "offsetof(struct user, signal)" },
2506 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2507 { uoff(magic), "offsetof(struct user, magic)" },
2508 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2509 { sizeof(struct user), "sizeof(struct user)" },
2512 #elif defined(METAG)
2514 #elif defined(XTENSA)
2523 sys_ptrace(struct tcb *tcp)
2525 const struct xlat *x;
2528 if (entering(tcp)) {
2529 printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
2530 tprintf(", %lu, ", tcp->u_arg[1]);
2532 addr = tcp->u_arg[2];
2533 if (tcp->u_arg[0] == PTRACE_PEEKUSER
2534 || tcp->u_arg[0] == PTRACE_POKEUSER
2536 for (x = struct_user_offsets; x->str; x++) {
2541 tprintf("%#lx, ", addr);
2542 else if (x->val > addr && x != struct_user_offsets) {
2544 tprintf("%s + %ld, ", x->str, addr - x->val);
2547 tprintf("%s, ", x->str);
2549 #ifdef PTRACE_GETREGSET
2550 if (tcp->u_arg[0] == PTRACE_GETREGSET
2551 || tcp->u_arg[0] == PTRACE_SETREGSET
2553 printxval(nt_descriptor_types, tcp->u_arg[2], "NT_???");
2557 tprintf("%#lx, ", addr);
2560 switch (tcp->u_arg[0]) {
2562 case PTRACE_PEEKDATA:
2563 case PTRACE_PEEKTEXT:
2564 case PTRACE_PEEKUSER:
2568 case PTRACE_SINGLESTEP:
2569 case PTRACE_SYSCALL:
2571 printsignal(tcp->u_arg[3]);
2573 #ifdef PTRACE_SETOPTIONS
2574 case PTRACE_SETOPTIONS:
2575 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2578 #ifdef PTRACE_SETSIGINFO
2579 case PTRACE_SETSIGINFO: {
2580 printsiginfo_at(tcp, tcp->u_arg[3]);
2584 #ifdef PTRACE_GETSIGINFO
2585 case PTRACE_GETSIGINFO:
2586 /* Don't print anything, do it at syscall return. */
2589 #ifdef PTRACE_GETREGSET
2590 case PTRACE_GETREGSET:
2592 case PTRACE_SETREGSET:
2593 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2597 tprintf("%#lx", tcp->u_arg[3]);
2601 switch (tcp->u_arg[0]) {
2602 case PTRACE_PEEKDATA:
2603 case PTRACE_PEEKTEXT:
2604 case PTRACE_PEEKUSER:
2608 printnum(tcp, tcp->u_arg[3], "%#lx");
2611 #ifdef PTRACE_GETSIGINFO
2612 case PTRACE_GETSIGINFO: {
2613 printsiginfo_at(tcp, tcp->u_arg[3]);
2617 #ifdef PTRACE_GETREGSET
2618 case PTRACE_GETREGSET:
2619 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2627 #ifndef FUTEX_CMP_REQUEUE
2628 # define FUTEX_CMP_REQUEUE 4
2630 #ifndef FUTEX_WAKE_OP
2631 # define FUTEX_WAKE_OP 5
2633 #ifndef FUTEX_LOCK_PI
2634 # define FUTEX_LOCK_PI 6
2635 # define FUTEX_UNLOCK_PI 7
2636 # define FUTEX_TRYLOCK_PI 8
2638 #ifndef FUTEX_WAIT_BITSET
2639 # define FUTEX_WAIT_BITSET 9
2641 #ifndef FUTEX_WAKE_BITSET
2642 # define FUTEX_WAKE_BITSET 10
2644 #ifndef FUTEX_WAIT_REQUEUE_PI
2645 # define FUTEX_WAIT_REQUEUE_PI 11
2647 #ifndef FUTEX_CMP_REQUEUE_PI
2648 # define FUTEX_CMP_REQUEUE_PI 12
2650 #ifndef FUTEX_PRIVATE_FLAG
2651 # define FUTEX_PRIVATE_FLAG 128
2653 #ifndef FUTEX_CLOCK_REALTIME
2654 # define FUTEX_CLOCK_REALTIME 256
2656 #ifndef FUTEX_WAIT_PRIVATE
2657 # define FUTEX_WAIT_PRIVATE (FUTEX_WAIT | FUTEX_PRIVATE_FLAG)
2659 #ifndef FUTEX_WAKE_PRIVATE
2660 # define FUTEX_WAKE_PRIVATE (FUTEX_WAKE | FUTEX_PRIVATE_FLAG)
2662 #ifndef FUTEX_REQUEUE_PRIVATE
2663 # define FUTEX_REQUEUE_PRIVATE (FUTEX_REQUEUE | FUTEX_PRIVATE_FLAG)
2665 #ifndef FUTEX_CMP_REQUEUE_PRIVATE
2666 # define FUTEX_CMP_REQUEUE_PRIVATE (FUTEX_CMP_REQUEUE | FUTEX_PRIVATE_FLAG)
2668 #ifndef FUTEX_WAKE_OP_PRIVATE
2669 # define FUTEX_WAKE_OP_PRIVATE (FUTEX_WAKE_OP | FUTEX_PRIVATE_FLAG)
2671 #ifndef FUTEX_LOCK_PI_PRIVATE
2672 # define FUTEX_LOCK_PI_PRIVATE (FUTEX_LOCK_PI | FUTEX_PRIVATE_FLAG)
2674 #ifndef FUTEX_UNLOCK_PI_PRIVATE
2675 # define FUTEX_UNLOCK_PI_PRIVATE (FUTEX_UNLOCK_PI | FUTEX_PRIVATE_FLAG)
2677 #ifndef FUTEX_TRYLOCK_PI_PRIVATE
2678 # define FUTEX_TRYLOCK_PI_PRIVATE (FUTEX_TRYLOCK_PI | FUTEX_PRIVATE_FLAG)
2680 #ifndef FUTEX_WAIT_BITSET_PRIVATE
2681 # define FUTEX_WAIT_BITSET_PRIVATE (FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG)
2683 #ifndef FUTEX_WAKE_BITSET_PRIVATE
2684 # define FUTEX_WAKE_BITSET_PRIVATE (FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG)
2686 #ifndef FUTEX_WAIT_REQUEUE_PI_PRIVATE
2687 # define FUTEX_WAIT_REQUEUE_PI_PRIVATE (FUTEX_WAIT_REQUEUE_PI | FUTEX_PRIVATE_FLAG)
2689 #ifndef FUTEX_CMP_REQUEUE_PI_PRIVATE
2690 # define FUTEX_CMP_REQUEUE_PI_PRIVATE (FUTEX_CMP_REQUEUE_PI | FUTEX_PRIVATE_FLAG)
2692 static const struct xlat futexops[] = {
2696 XLAT(FUTEX_REQUEUE),
2697 XLAT(FUTEX_CMP_REQUEUE),
2698 XLAT(FUTEX_WAKE_OP),
2699 XLAT(FUTEX_LOCK_PI),
2700 XLAT(FUTEX_UNLOCK_PI),
2701 XLAT(FUTEX_TRYLOCK_PI),
2702 XLAT(FUTEX_WAIT_BITSET),
2703 XLAT(FUTEX_WAKE_BITSET),
2704 XLAT(FUTEX_WAIT_REQUEUE_PI),
2705 XLAT(FUTEX_CMP_REQUEUE_PI),
2706 XLAT(FUTEX_WAIT_PRIVATE),
2707 XLAT(FUTEX_WAKE_PRIVATE),
2708 XLAT(FUTEX_FD|FUTEX_PRIVATE_FLAG),
2709 XLAT(FUTEX_REQUEUE_PRIVATE),
2710 XLAT(FUTEX_CMP_REQUEUE_PRIVATE),
2711 XLAT(FUTEX_WAKE_OP_PRIVATE),
2712 XLAT(FUTEX_LOCK_PI_PRIVATE),
2713 XLAT(FUTEX_UNLOCK_PI_PRIVATE),
2714 XLAT(FUTEX_TRYLOCK_PI_PRIVATE),
2715 XLAT(FUTEX_WAIT_BITSET_PRIVATE),
2716 XLAT(FUTEX_WAKE_BITSET_PRIVATE),
2717 XLAT(FUTEX_WAIT_REQUEUE_PI_PRIVATE),
2718 XLAT(FUTEX_CMP_REQUEUE_PI_PRIVATE),
2719 XLAT(FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME),
2720 XLAT(FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME),
2721 XLAT(FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME),
2722 XLAT(FUTEX_WAIT_REQUEUE_PI_PRIVATE|FUTEX_CLOCK_REALTIME),
2725 #ifndef FUTEX_OP_SET
2726 # define FUTEX_OP_SET 0
2727 # define FUTEX_OP_ADD 1
2728 # define FUTEX_OP_OR 2
2729 # define FUTEX_OP_ANDN 3
2730 # define FUTEX_OP_XOR 4
2731 # define FUTEX_OP_CMP_EQ 0
2732 # define FUTEX_OP_CMP_NE 1
2733 # define FUTEX_OP_CMP_LT 2
2734 # define FUTEX_OP_CMP_LE 3
2735 # define FUTEX_OP_CMP_GT 4
2736 # define FUTEX_OP_CMP_GE 5
2738 static const struct xlat futexwakeops[] = {
2742 XLAT(FUTEX_OP_ANDN),
2746 static const struct xlat futexwakecmps[] = {
2747 XLAT(FUTEX_OP_CMP_EQ),
2748 XLAT(FUTEX_OP_CMP_NE),
2749 XLAT(FUTEX_OP_CMP_LT),
2750 XLAT(FUTEX_OP_CMP_LE),
2751 XLAT(FUTEX_OP_CMP_GT),
2752 XLAT(FUTEX_OP_CMP_GE),
2757 sys_futex(struct tcb *tcp)
2759 if (entering(tcp)) {
2760 long int cmd = tcp->u_arg[1] & 127;
2761 tprintf("%p, ", (void *) tcp->u_arg[0]);
2762 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2763 tprintf(", %ld", tcp->u_arg[2]);
2764 if (cmd == FUTEX_WAKE_BITSET)
2765 tprintf(", %lx", tcp->u_arg[5]);
2766 else if (cmd == FUTEX_WAIT) {
2768 printtv(tcp, tcp->u_arg[3]);
2769 } else if (cmd == FUTEX_WAIT_BITSET) {
2771 printtv(tcp, tcp->u_arg[3]);
2772 tprintf(", %lx", tcp->u_arg[5]);
2773 } else if (cmd == FUTEX_REQUEUE)
2774 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2775 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
2776 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2777 else if (cmd == FUTEX_WAKE_OP) {
2778 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2779 if ((tcp->u_arg[5] >> 28) & 8)
2780 tprints("FUTEX_OP_OPARG_SHIFT|");
2781 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2782 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2783 if ((tcp->u_arg[5] >> 24) & 8)
2784 tprints("FUTEX_OP_OPARG_SHIFT|");
2785 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2786 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
2787 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
2789 printtv(tcp, tcp->u_arg[3]);
2790 tprintf(", %p", (void *) tcp->u_arg[4]);
2797 print_affinitylist(struct tcb *tcp, long list, unsigned int len)
2800 unsigned long w, min_len;
2802 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2803 min_len = len - max_strlen * sizeof(w);
2806 for (; len >= sizeof(w) && len > min_len;
2807 len -= sizeof(w), list += sizeof(w)) {
2808 if (umove(tcp, list, &w) < 0)
2819 tprintf("%#lx", list);
2821 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2824 tprints(first ? "{}" : "}");
2829 sys_sched_setaffinity(struct tcb *tcp)
2831 if (entering(tcp)) {
2832 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2833 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2839 sys_sched_getaffinity(struct tcb *tcp)
2841 if (entering(tcp)) {
2842 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2844 if (tcp->u_rval == -1)
2845 tprintf("%#lx", tcp->u_arg[2]);
2847 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2853 sys_get_robust_list(struct tcb *tcp)
2855 if (entering(tcp)) {
2856 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2861 if (syserror(tcp) ||
2863 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2864 tprintf("%#lx, ", tcp->u_arg[1]);
2866 tprintf("[%p], ", addr);
2869 if (syserror(tcp) ||
2871 umove(tcp, tcp->u_arg[2], &len) < 0) {
2872 tprintf("%#lx", tcp->u_arg[2]);
2874 tprintf("[%lu]", (unsigned long) len);
2880 static const struct xlat schedulers[] = {
2888 sys_sched_getscheduler(struct tcb *tcp)
2890 if (entering(tcp)) {
2891 tprintf("%d", (int) tcp->u_arg[0]);
2892 } else if (!syserror(tcp)) {
2893 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
2894 if (tcp->auxstr != NULL)
2901 sys_sched_setscheduler(struct tcb *tcp)
2903 if (entering(tcp)) {
2904 struct sched_param p;
2905 tprintf("%d, ", (int) tcp->u_arg[0]);
2906 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2907 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2908 tprintf(", %#lx", tcp->u_arg[2]);
2910 tprintf(", { %d }", p.sched_priority);
2916 sys_sched_getparam(struct tcb *tcp)
2918 if (entering(tcp)) {
2919 tprintf("%d, ", (int) tcp->u_arg[0]);
2921 struct sched_param p;
2922 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2923 tprintf("%#lx", tcp->u_arg[1]);
2925 tprintf("{ %d }", p.sched_priority);
2931 sys_sched_setparam(struct tcb *tcp)
2933 if (entering(tcp)) {
2934 struct sched_param p;
2935 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2936 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2938 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.sched_priority);
2944 sys_sched_get_priority_min(struct tcb *tcp)
2946 if (entering(tcp)) {
2947 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2953 sys_sched_rr_get_interval(struct tcb *tcp)
2955 if (entering(tcp)) {
2956 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2959 tprintf("%#lx", tcp->u_arg[1]);
2961 print_timespec(tcp, tcp->u_arg[1]);
2966 #if defined X86_64 || defined X32
2967 # include <asm/prctl.h>
2969 static const struct xlat archvals[] = {
2978 sys_arch_prctl(struct tcb *tcp)
2980 if (entering(tcp)) {
2981 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2982 if (tcp->u_arg[0] == ARCH_SET_GS
2983 || tcp->u_arg[0] == ARCH_SET_FS
2985 tprintf(", %#lx", tcp->u_arg[1]);
2988 if (tcp->u_arg[0] == ARCH_GET_GS
2989 || tcp->u_arg[0] == ARCH_GET_FS
2992 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2993 tprintf(", [%#lx]", v);
2995 tprintf(", %#lx", tcp->u_arg[1]);
3000 #endif /* X86_64 || X32 */
3003 sys_getcpu(struct tcb *tcp)
3007 if (tcp->u_arg[0] == 0)
3009 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
3010 tprintf("%#lx, ", tcp->u_arg[0]);
3012 tprintf("[%u], ", u);
3013 if (tcp->u_arg[1] == 0)
3015 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
3016 tprintf("%#lx, ", tcp->u_arg[1]);
3018 tprintf("[%u], ", u);
3019 tprintf("%#lx", tcp->u_arg[2]);
3025 sys_process_vm_readv(struct tcb *tcp)
3027 if (entering(tcp)) {
3029 tprintf("%ld, ", tcp->u_arg[0]);
3031 /* arg 2: local iov */
3032 if (syserror(tcp)) {
3033 tprintf("%#lx", tcp->u_arg[1]);
3035 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
3037 /* arg 3: local iovcnt */
3038 tprintf(", %lu, ", tcp->u_arg[2]);
3039 /* arg 4: remote iov */
3040 if (syserror(tcp)) {
3041 tprintf("%#lx", tcp->u_arg[3]);
3043 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
3045 /* arg 5: remote iovcnt */
3047 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
3053 sys_process_vm_writev(struct tcb *tcp)
3055 if (entering(tcp)) {
3057 tprintf("%ld, ", tcp->u_arg[0]);
3058 /* arg 2: local iov */
3060 tprintf("%#lx", tcp->u_arg[1]);
3062 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
3063 /* arg 3: local iovcnt */
3064 tprintf(", %lu, ", tcp->u_arg[2]);
3065 /* arg 4: remote iov */
3067 tprintf("%#lx", tcp->u_arg[3]);
3069 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
3070 /* arg 5: remote iovcnt */
3072 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);