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>
50 # ifndef PTRACE_PEEKUSR
51 # define PTRACE_PEEKUSR PTRACE_PEEKUSER
53 # ifndef PTRACE_POKEUSR
54 # define PTRACE_POKEUSR PTRACE_POKEUSER
58 #ifdef HAVE_LINUX_PTRACE_H
59 # undef PTRACE_SYSCALL
60 # ifdef HAVE_STRUCT_IA64_FPREG
61 # define ia64_fpreg XXX_ia64_fpreg
63 # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
64 # define pt_all_user_regs XXX_pt_all_user_regs
66 # include <linux/ptrace.h>
68 # undef pt_all_user_regs
73 # undef PTRACE_GETREGS
74 # define PTRACE_GETREGS PTRACE_GETREGS64
75 # undef PTRACE_SETREGS
76 # define PTRACE_SETREGS PTRACE_SETREGS64
79 #ifdef HAVE_LINUX_FUTEX_H
80 # include <linux/futex.h>
92 # define FUTEX_REQUEUE 3
96 #include <asm/posix_types.h>
98 #define GETGROUPS_T __kernel_gid_t
100 #define GETGROUPS32_T __kernel_gid32_t
103 # include <asm/ptrace_offsets.h>
104 # include <asm/rse.h>
108 # include <sys/prctl.h>
110 static const struct xlat prctl_options[] = {
112 { PR_MAXPROCS, "PR_MAXPROCS" },
115 { PR_ISBLOCKED, "PR_ISBLOCKED" },
117 #ifdef PR_SETSTACKSIZE
118 { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" },
120 #ifdef PR_GETSTACKSIZE
121 { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" },
124 { PR_MAXPPROCS, "PR_MAXPPROCS" },
126 #ifdef PR_UNBLKONEXEC
127 { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" },
130 { PR_ATOMICSIM, "PR_ATOMICSIM" },
133 { PR_SETEXITSIG, "PR_SETEXITSIG" },
136 { PR_RESIDENT, "PR_RESIDENT" },
139 { PR_ATTACHADDR, "PR_ATTACHADDR" },
142 { PR_DETACHADDR, "PR_DETACHADDR" },
145 { PR_TERMCHILD, "PR_TERMCHILD" },
148 { PR_GETSHMASK, "PR_GETSHMASK" },
151 { PR_GETNSHARE, "PR_GETNSHARE" },
154 { PR_COREPID, "PR_COREPID" },
156 #ifdef PR_ATTACHADDRPERM
157 { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" },
159 #ifdef PR_PTHREADEXIT
160 { PR_PTHREADEXIT, "PR_PTHREADEXIT" },
162 #ifdef PR_SET_PDEATHSIG
163 { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
165 #ifdef PR_GET_PDEATHSIG
166 { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
168 #ifdef PR_GET_DUMPABLE
169 { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" },
171 #ifdef PR_SET_DUMPABLE
172 { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" },
174 #ifdef PR_GET_UNALIGN
175 { PR_GET_UNALIGN, "PR_GET_UNALIGN" },
177 #ifdef PR_SET_UNALIGN
178 { PR_SET_UNALIGN, "PR_SET_UNALIGN" },
180 #ifdef PR_GET_KEEPCAPS
181 { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" },
183 #ifdef PR_SET_KEEPCAPS
184 { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" },
187 { PR_GET_FPEMU, "PR_GET_FPEMU" },
190 { PR_SET_FPEMU, "PR_SET_FPEMU" },
193 { PR_GET_FPEXC, "PR_GET_FPEXC" },
196 { PR_SET_FPEXC, "PR_SET_FPEXC" },
199 { PR_GET_TIMING, "PR_GET_TIMING" },
202 { PR_SET_TIMING, "PR_SET_TIMING" },
205 { PR_SET_NAME, "PR_SET_NAME" },
208 { PR_GET_NAME, "PR_GET_NAME" },
211 { PR_GET_ENDIAN, "PR_GET_ENDIAN" },
214 { PR_SET_ENDIAN, "PR_SET_ENDIAN" },
216 #ifdef PR_GET_SECCOMP
217 { PR_GET_SECCOMP, "PR_GET_SECCOMP" },
219 #ifdef PR_SET_SECCOMP
220 { PR_SET_SECCOMP, "PR_SET_SECCOMP" },
223 { PR_GET_TSC, "PR_GET_TSC" },
226 { PR_SET_TSC, "PR_SET_TSC" },
228 #ifdef PR_GET_SECUREBITS
229 { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" },
231 #ifdef PR_SET_SECUREBITS
232 { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" },
238 unalignctl_string(unsigned int ctl)
240 static char buf[sizeof(int)*2 + 2];
243 #ifdef PR_UNALIGN_NOPRINT
244 case PR_UNALIGN_NOPRINT:
247 #ifdef PR_UNALIGN_SIGBUS
248 case PR_UNALIGN_SIGBUS:
254 sprintf(buf, "%x", ctl);
259 sys_prctl(struct tcb *tcp)
264 printxval(prctl_options, tcp->u_arg[0], "PR_???");
265 switch (tcp->u_arg[0]) {
270 #ifdef PR_SET_PDEATHSIG
271 case PR_SET_PDEATHSIG:
272 tprintf(", %lu", tcp->u_arg[1]);
275 #ifdef PR_GET_PDEATHSIG
276 case PR_GET_PDEATHSIG:
279 #ifdef PR_SET_DUMPABLE
280 case PR_SET_DUMPABLE:
281 tprintf(", %lu", tcp->u_arg[1]);
284 #ifdef PR_GET_DUMPABLE
285 case PR_GET_DUMPABLE:
288 #ifdef PR_SET_UNALIGN
290 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
293 #ifdef PR_GET_UNALIGN
295 tprintf(", %#lx", tcp->u_arg[1]);
298 #ifdef PR_SET_KEEPCAPS
299 case PR_SET_KEEPCAPS:
300 tprintf(", %lu", tcp->u_arg[1]);
303 #ifdef PR_GET_KEEPCAPS
304 case PR_GET_KEEPCAPS:
308 for (i = 1; i < tcp->s_ent->nargs; i++)
309 tprintf(", %#lx", tcp->u_arg[i]);
313 switch (tcp->u_arg[0]) {
314 #ifdef PR_GET_PDEATHSIG
315 case PR_GET_PDEATHSIG:
316 if (umove(tcp, tcp->u_arg[1], &i) < 0)
317 tprintf(", %#lx", tcp->u_arg[1]);
319 tprintf(", {%u}", i);
322 #ifdef PR_GET_DUMPABLE
323 case PR_GET_DUMPABLE:
324 return RVAL_UDECIMAL;
326 #ifdef PR_GET_UNALIGN
328 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
330 tcp->auxstr = unalignctl_string(i);
333 #ifdef PR_GET_KEEPCAPS
334 case PR_GET_KEEPCAPS:
335 return RVAL_UDECIMAL;
343 #endif /* HAVE_PRCTL */
346 sys_sethostname(struct tcb *tcp)
349 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
350 tprintf(", %lu", tcp->u_arg[1]);
357 sys_gethostname(struct tcb *tcp)
361 tprintf("%#lx", tcp->u_arg[0]);
363 printpath(tcp, tcp->u_arg[0]);
364 tprintf(", %lu", tcp->u_arg[1]);
371 sys_setdomainname(struct tcb *tcp)
374 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
375 tprintf(", %lu", tcp->u_arg[1]);
381 sys_exit(struct tcb *tcp)
384 fprintf(stderr, "_exit returned!\n");
387 /* special case: we stop tracing this process, finish line now */
388 tprintf("%ld) ", tcp->u_arg[0]);
395 /* defines copied from linux/sched.h since we can't include that
396 * ourselves (it conflicts with *lots* of libc includes)
398 #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
399 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
400 #define CLONE_FS 0x00000200 /* set if fs info shared between processes */
401 #define CLONE_FILES 0x00000400 /* set if open files shared between processes */
402 #define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
403 #define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
404 #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
405 #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
406 #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
407 #define CLONE_THREAD 0x00010000 /* Same thread group? */
408 #define CLONE_NEWNS 0x00020000 /* New namespace group? */
409 #define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
410 #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
411 #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
412 #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
413 #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
414 #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
415 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
416 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
417 #define CLONE_NEWIPC 0x08000000 /* New ipcs */
418 #define CLONE_NEWUSER 0x10000000 /* New user namespace */
419 #define CLONE_NEWPID 0x20000000 /* New pid namespace */
420 #define CLONE_NEWNET 0x40000000 /* New network namespace */
421 #define CLONE_IO 0x80000000 /* Clone io context */
423 static const struct xlat clone_flags[] = {
424 { CLONE_VM, "CLONE_VM" },
425 { CLONE_FS, "CLONE_FS" },
426 { CLONE_FILES, "CLONE_FILES" },
427 { CLONE_SIGHAND, "CLONE_SIGHAND" },
428 { CLONE_IDLETASK, "CLONE_IDLETASK" },
429 { CLONE_PTRACE, "CLONE_PTRACE" },
430 { CLONE_VFORK, "CLONE_VFORK" },
431 { CLONE_PARENT, "CLONE_PARENT" },
432 { CLONE_THREAD, "CLONE_THREAD" },
433 { CLONE_NEWNS, "CLONE_NEWNS" },
434 { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
435 { CLONE_SETTLS, "CLONE_SETTLS" },
436 { CLONE_PARENT_SETTID, "CLONE_PARENT_SETTID" },
437 { CLONE_CHILD_CLEARTID, "CLONE_CHILD_CLEARTID" },
438 { CLONE_UNTRACED, "CLONE_UNTRACED" },
439 { CLONE_CHILD_SETTID, "CLONE_CHILD_SETTID" },
440 { CLONE_STOPPED, "CLONE_STOPPED" },
441 { CLONE_NEWUTS, "CLONE_NEWUTS" },
442 { CLONE_NEWIPC, "CLONE_NEWIPC" },
443 { CLONE_NEWUSER, "CLONE_NEWUSER" },
444 { CLONE_NEWPID, "CLONE_NEWPID" },
445 { CLONE_NEWNET, "CLONE_NEWNET" },
446 { CLONE_IO, "CLONE_IO" },
451 # include <asm/ldt.h>
452 # ifdef HAVE_STRUCT_USER_DESC
453 # define modify_ldt_ldt_s user_desc
455 extern void print_ldt_entry();
461 # define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
462 # define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
463 # define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
464 # define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
465 #elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
471 #elif defined X86_64 || defined X32 || defined ALPHA || defined TILE \
487 sys_clone(struct tcb *tcp)
490 const char *sep = "|";
491 unsigned long flags = tcp->u_arg[ARG_FLAGS];
492 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
494 if (ARG_STACKSIZE != -1)
495 tprintf("stack_size=%#lx, ",
496 tcp->u_arg[ARG_STACKSIZE]);
499 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
501 if ((flags & CSIGNAL) != 0)
502 tprintf("%s%s", sep, signame(flags & CSIGNAL));
503 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
504 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
506 if (flags & CLONE_PARENT_SETTID)
507 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
508 if (flags & CLONE_SETTLS) {
510 struct modify_ldt_ldt_s copy;
511 if (umove(tcp, tcp->u_arg[ARG_TLS], ©) != -1) {
512 tprintf(", {entry_number:%d, ",
517 print_ldt_entry(©);
521 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
523 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
524 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
530 sys_unshare(struct tcb *tcp)
533 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
538 sys_fork(struct tcb *tcp)
541 return RVAL_UDECIMAL;
546 sys_vfork(struct tcb *tcp)
549 return RVAL_UDECIMAL;
553 int sys_getuid(struct tcb *tcp)
556 tcp->u_rval = (uid_t) tcp->u_rval;
557 return RVAL_UDECIMAL;
560 int sys_setfsuid(struct tcb *tcp)
563 tprintf("%u", (uid_t) tcp->u_arg[0]);
565 tcp->u_rval = (uid_t) tcp->u_rval;
566 return RVAL_UDECIMAL;
570 sys_setuid(struct tcb *tcp)
573 tprintf("%u", (uid_t) tcp->u_arg[0]);
579 sys_getresuid(struct tcb *tcp)
584 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
585 tcp->u_arg[1], tcp->u_arg[2]);
587 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
588 tprintf("%#lx, ", tcp->u_arg[0]);
590 tprintf("[%lu], ", (unsigned long) uid);
591 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
592 tprintf("%#lx, ", tcp->u_arg[1]);
594 tprintf("[%lu], ", (unsigned long) uid);
595 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
596 tprintf("%#lx", tcp->u_arg[2]);
598 tprintf("[%lu]", (unsigned long) uid);
605 sys_setreuid(struct tcb *tcp)
608 printuid("", tcp->u_arg[0]);
609 printuid(", ", tcp->u_arg[1]);
615 sys_setresuid(struct tcb *tcp)
618 printuid("", tcp->u_arg[0]);
619 printuid(", ", tcp->u_arg[1]);
620 printuid(", ", tcp->u_arg[2]);
626 sys_setgroups(struct tcb *tcp)
629 unsigned long len, size, start, cur, end, abbrev_end;
634 tprintf("%lu, ", len);
639 start = tcp->u_arg[1];
644 size = len * sizeof(gid);
646 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
647 tprintf("%#lx", start);
651 abbrev_end = start + max_strlen * sizeof(gid);
652 if (abbrev_end < start)
658 for (cur = start; cur < end; cur += sizeof(gid)) {
661 if (cur >= abbrev_end) {
665 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
670 tprintf("%lu", (unsigned long) gid);
674 tprintf(" %#lx", tcp->u_arg[1]);
680 sys_getgroups(struct tcb *tcp)
686 tprintf("%lu, ", len);
688 unsigned long size, start, cur, end, abbrev_end;
697 start = tcp->u_arg[1];
702 if (tcp->u_arg[0] == 0) {
703 tprintf("%#lx", start);
706 size = len * sizeof(gid);
708 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
709 size / sizeof(gid) != len || end < start) {
710 tprintf("%#lx", start);
714 abbrev_end = start + max_strlen * sizeof(gid);
715 if (abbrev_end < start)
721 for (cur = start; cur < end; cur += sizeof(gid)) {
724 if (cur >= abbrev_end) {
728 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
733 tprintf("%lu", (unsigned long) gid);
737 tprintf(" %#lx", tcp->u_arg[1]);
743 sys_setgroups32(struct tcb *tcp)
746 unsigned long len, size, start, cur, end, abbrev_end;
751 tprintf("%lu, ", len);
756 start = tcp->u_arg[1];
761 size = len * sizeof(gid);
763 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
764 tprintf("%#lx", start);
768 abbrev_end = start + max_strlen * sizeof(gid);
769 if (abbrev_end < start)
775 for (cur = start; cur < end; cur += sizeof(gid)) {
778 if (cur >= abbrev_end) {
782 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
787 tprintf("%lu", (unsigned long) gid);
791 tprintf(" %#lx", tcp->u_arg[1]);
797 sys_getgroups32(struct tcb *tcp)
803 tprintf("%lu, ", len);
805 unsigned long size, start, cur, end, abbrev_end;
814 start = tcp->u_arg[1];
819 size = len * sizeof(gid);
821 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
822 size / sizeof(gid) != len || end < start) {
823 tprintf("%#lx", start);
827 abbrev_end = start + max_strlen * sizeof(gid);
828 if (abbrev_end < start)
834 for (cur = start; cur < end; cur += sizeof(gid)) {
837 if (cur >= abbrev_end) {
841 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
846 tprintf("%lu", (unsigned long) gid);
850 tprintf(" %#lx", tcp->u_arg[1]);
856 printargv(struct tcb *tcp, long addr)
861 char data[sizeof(long)];
865 unsigned wordsize = current_wordsize;
868 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
869 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
870 tprintf("%#lx", addr);
878 printstr(tcp, cp.p64, -1);
882 tprintf("%s...", sep);
886 printargc(const char *fmt, struct tcb *tcp, long addr)
891 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
892 addr += sizeof(char *);
894 tprintf(fmt, count, count == 1 ? "" : "s");
897 #if defined(SPARC) || defined(SPARC64)
899 sys_execv(struct tcb *tcp)
902 printpath(tcp, tcp->u_arg[0]);
904 tprintf(", %#lx", tcp->u_arg[1]);
907 printargv(tcp, tcp->u_arg[1]);
916 sys_execve(struct tcb *tcp)
919 printpath(tcp, tcp->u_arg[0]);
921 tprintf(", %#lx", tcp->u_arg[1]);
924 printargv(tcp, tcp->u_arg[1]);
928 tprintf(", %#lx", tcp->u_arg[2]);
929 else if (abbrev(tcp))
930 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
933 printargv(tcp, tcp->u_arg[2]);
941 #define __WNOTHREAD 0x20000000
944 #define __WALL 0x40000000
947 #define __WCLONE 0x80000000
950 static const struct xlat wait4_options[] = {
951 { WNOHANG, "WNOHANG" },
953 { WUNTRACED, "WUNTRACED" },
956 { WEXITED, "WEXITED" },
959 { WTRAPPED, "WTRAPPED" },
962 { WSTOPPED, "WSTOPPED" },
965 { WCONTINUED, "WCONTINUED" },
968 { WNOWAIT, "WNOWAIT" },
971 { __WCLONE, "__WCLONE" },
974 { __WALL, "__WALL" },
977 { __WNOTHREAD, "__WNOTHREAD" },
982 #if !defined WCOREFLAG && defined WCOREFLG
983 # define WCOREFLAG WCOREFLG
986 # define WCOREFLAG 0x80
989 # define WCOREDUMP(status) ((status) & 0200)
992 # define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
995 # define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
999 printstatus(int status)
1004 * Here is a tricky presentation problem. This solution
1005 * is still not entirely satisfactory but since there
1006 * are no wait status constructors it will have to do.
1008 if (WIFSTOPPED(status)) {
1009 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
1010 signame(WSTOPSIG(status)));
1011 status &= ~W_STOPCODE(WSTOPSIG(status));
1013 else if (WIFSIGNALED(status)) {
1014 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
1015 signame(WTERMSIG(status)),
1016 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
1017 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1019 else if (WIFEXITED(status)) {
1020 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
1021 WEXITSTATUS(status));
1023 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
1026 tprintf("[%#x]", status);
1033 tprintf(" | %#x]", status);
1039 printwaitn(struct tcb *tcp, int n, int bitness)
1043 if (entering(tcp)) {
1044 /* On Linux, kernel-side pid_t is typedef'ed to int
1045 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
1046 * pid argument to int on 64bit arches, producing,
1047 * for example, wait4(4294967295, ...) instead of -1
1048 * in strace. We have to use int here, not long.
1050 int pid = tcp->u_arg[0];
1051 tprintf("%d, ", pid);
1056 else if (syserror(tcp) || tcp->u_rval == 0)
1057 tprintf("%#lx", tcp->u_arg[1]);
1058 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
1061 printstatus(status);
1064 printflags(wait4_options, tcp->u_arg[2], "W???");
1070 else if (tcp->u_rval > 0) {
1073 printrusage32(tcp, tcp->u_arg[3]);
1076 printrusage(tcp, tcp->u_arg[3]);
1079 tprintf("%#lx", tcp->u_arg[3]);
1086 sys_waitpid(struct tcb *tcp)
1088 return printwaitn(tcp, 3, 0);
1092 sys_wait4(struct tcb *tcp)
1094 return printwaitn(tcp, 4, 0);
1099 sys_osf_wait4(struct tcb *tcp)
1101 return printwaitn(tcp, 4, 1);
1105 static const struct xlat waitid_types[] = {
1108 { P_PPID, "P_PPID" },
1110 { P_PGID, "P_PGID" },
1125 { P_LWPID, "P_LWPID" },
1131 sys_waitid(struct tcb *tcp)
1133 if (entering(tcp)) {
1134 printxval(waitid_types, tcp->u_arg[0], "P_???");
1135 tprintf(", %ld, ", tcp->u_arg[1]);
1139 printsiginfo_at(tcp, tcp->u_arg[2]);
1142 printflags(wait4_options, tcp->u_arg[3], "W???");
1143 if (tcp->s_ent->nargs > 4) {
1148 else if (tcp->u_error)
1149 tprintf("%#lx", tcp->u_arg[4]);
1151 printrusage(tcp, tcp->u_arg[4]);
1158 sys_uname(struct tcb *tcp)
1160 struct utsname uname;
1163 if (syserror(tcp) || !verbose(tcp))
1164 tprintf("%#lx", tcp->u_arg[0]);
1165 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
1167 else if (!abbrev(tcp)) {
1168 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1169 uname.sysname, uname.nodename);
1170 tprintf("release=\"%s\", version=\"%s\", ",
1171 uname.release, uname.version);
1172 tprintf("machine=\"%s\"", uname.machine);
1173 #ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
1174 tprintf(", domainname=\"%s\"", uname.domainname);
1179 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1180 uname.sysname, uname.nodename);
1185 static const struct xlat ptrace_cmds[] = {
1186 { PTRACE_TRACEME, "PTRACE_TRACEME" },
1187 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1188 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1189 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1190 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1191 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1192 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
1193 { PTRACE_CONT, "PTRACE_CONT" },
1194 { PTRACE_KILL, "PTRACE_KILL" },
1195 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1196 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1197 { PTRACE_DETACH, "PTRACE_DETACH" },
1198 #ifdef PTRACE_GETREGS
1199 { PTRACE_GETREGS, "PTRACE_GETREGS" },
1201 #ifdef PTRACE_SETREGS
1202 { PTRACE_SETREGS, "PTRACE_SETREGS" },
1204 #ifdef PTRACE_GETFPREGS
1205 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
1207 #ifdef PTRACE_SETFPREGS
1208 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
1210 #ifdef PTRACE_GETFPXREGS
1211 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
1213 #ifdef PTRACE_SETFPXREGS
1214 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
1216 #ifdef PTRACE_GETVRREGS
1217 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
1219 #ifdef PTRACE_SETVRREGS
1220 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
1222 #ifdef PTRACE_SETOPTIONS
1223 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
1225 #ifdef PTRACE_GETEVENTMSG
1226 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
1228 #ifdef PTRACE_GETSIGINFO
1229 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
1231 #ifdef PTRACE_SETSIGINFO
1232 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
1234 #ifdef PTRACE_GETREGSET
1235 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
1237 #ifdef PTRACE_SETREGSET
1238 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
1240 #ifdef PTRACE_SET_SYSCALL
1241 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
1244 { PTRACE_SEIZE, "PTRACE_SEIZE" },
1246 #ifdef PTRACE_INTERRUPT
1247 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
1249 #ifdef PTRACE_LISTEN
1250 { PTRACE_LISTEN, "PTRACE_LISTEN" },
1252 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
1257 #ifdef PTRACE_SETOPTIONS
1258 static const struct xlat ptrace_setoptions_flags[] = {
1259 # ifdef PTRACE_O_TRACESYSGOOD
1260 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
1262 # ifdef PTRACE_O_TRACEFORK
1263 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
1265 # ifdef PTRACE_O_TRACEVFORK
1266 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
1268 # ifdef PTRACE_O_TRACECLONE
1269 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
1271 # ifdef PTRACE_O_TRACEEXEC
1272 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
1274 # ifdef PTRACE_O_TRACEVFORKDONE
1275 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
1277 # ifdef PTRACE_O_TRACEEXIT
1278 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
1282 #endif /* PTRACE_SETOPTIONS */
1284 static const struct xlat nt_descriptor_types[] = {
1286 { NT_PRSTATUS, "NT_PRSTATUS" },
1289 { NT_FPREGSET, "NT_FPREGSET" },
1292 { NT_PRPSINFO, "NT_PRPSINFO" },
1295 { NT_PRXREG, "NT_PRXREG" },
1297 #ifdef NT_TASKSTRUCT
1298 { NT_TASKSTRUCT, "NT_TASKSTRUCT" },
1301 { NT_PLATFORM, "NT_PLATFORM" },
1304 { NT_AUXV, "NT_AUXV" },
1307 { NT_GWINDOWS, "NT_GWINDOWS" },
1310 { NT_ASRS, "NT_ASRS" },
1313 { NT_PSTATUS, "NT_PSTATUS" },
1316 { NT_PSINFO, "NT_PSINFO" },
1319 { NT_PRCRED, "NT_PRCRED" },
1322 { NT_UTSNAME, "NT_UTSNAME" },
1325 { NT_LWPSTATUS, "NT_LWPSTATUS" },
1328 { NT_LWPSINFO, "NT_LWPSINFO" },
1331 { NT_PRFPXREG, "NT_PRFPXREG" },
1334 { NT_PRXFPREG, "NT_PRXFPREG" },
1337 { NT_PPC_VMX, "NT_PPC_VMX" },
1340 { NT_PPC_SPE, "NT_PPC_SPE" },
1343 { NT_PPC_VSX, "NT_PPC_VSX" },
1346 { NT_386_TLS, "NT_386_TLS" },
1348 #ifdef NT_386_IOPERM
1349 { NT_386_IOPERM, "NT_386_IOPERM" },
1351 #ifdef NT_X86_XSTATE
1352 { NT_X86_XSTATE, "NT_X86_XSTATE" },
1357 #define uoff(member) offsetof(struct user, member)
1359 const struct xlat struct_user_offsets[] = {
1360 #if defined(S390) || defined(S390X)
1361 { PT_PSWMASK, "psw_mask" },
1362 { PT_PSWADDR, "psw_addr" },
1363 { PT_GPR0, "gpr0" },
1364 { PT_GPR1, "gpr1" },
1365 { PT_GPR2, "gpr2" },
1366 { PT_GPR3, "gpr3" },
1367 { PT_GPR4, "gpr4" },
1368 { PT_GPR5, "gpr5" },
1369 { PT_GPR6, "gpr6" },
1370 { PT_GPR7, "gpr7" },
1371 { PT_GPR8, "gpr8" },
1372 { PT_GPR9, "gpr9" },
1373 { PT_GPR10, "gpr10" },
1374 { PT_GPR11, "gpr11" },
1375 { PT_GPR12, "gpr12" },
1376 { PT_GPR13, "gpr13" },
1377 { PT_GPR14, "gpr14" },
1378 { PT_GPR15, "gpr15" },
1379 { PT_ACR0, "acr0" },
1380 { PT_ACR1, "acr1" },
1381 { PT_ACR2, "acr2" },
1382 { PT_ACR3, "acr3" },
1383 { PT_ACR4, "acr4" },
1384 { PT_ACR5, "acr5" },
1385 { PT_ACR6, "acr6" },
1386 { PT_ACR7, "acr7" },
1387 { PT_ACR8, "acr8" },
1388 { PT_ACR9, "acr9" },
1389 { PT_ACR10, "acr10" },
1390 { PT_ACR11, "acr11" },
1391 { PT_ACR12, "acr12" },
1392 { PT_ACR13, "acr13" },
1393 { PT_ACR14, "acr14" },
1394 { PT_ACR15, "acr15" },
1395 { PT_ORIGGPR2, "orig_gpr2" },
1398 { PT_FPR0_HI, "fpr0.hi" },
1399 { PT_FPR0_LO, "fpr0.lo" },
1400 { PT_FPR1_HI, "fpr1.hi" },
1401 { PT_FPR1_LO, "fpr1.lo" },
1402 { PT_FPR2_HI, "fpr2.hi" },
1403 { PT_FPR2_LO, "fpr2.lo" },
1404 { PT_FPR3_HI, "fpr3.hi" },
1405 { PT_FPR3_LO, "fpr3.lo" },
1406 { PT_FPR4_HI, "fpr4.hi" },
1407 { PT_FPR4_LO, "fpr4.lo" },
1408 { PT_FPR5_HI, "fpr5.hi" },
1409 { PT_FPR5_LO, "fpr5.lo" },
1410 { PT_FPR6_HI, "fpr6.hi" },
1411 { PT_FPR6_LO, "fpr6.lo" },
1412 { PT_FPR7_HI, "fpr7.hi" },
1413 { PT_FPR7_LO, "fpr7.lo" },
1414 { PT_FPR8_HI, "fpr8.hi" },
1415 { PT_FPR8_LO, "fpr8.lo" },
1416 { PT_FPR9_HI, "fpr9.hi" },
1417 { PT_FPR9_LO, "fpr9.lo" },
1418 { PT_FPR10_HI, "fpr10.hi" },
1419 { PT_FPR10_LO, "fpr10.lo" },
1420 { PT_FPR11_HI, "fpr11.hi" },
1421 { PT_FPR11_LO, "fpr11.lo" },
1422 { PT_FPR12_HI, "fpr12.hi" },
1423 { PT_FPR12_LO, "fpr12.lo" },
1424 { PT_FPR13_HI, "fpr13.hi" },
1425 { PT_FPR13_LO, "fpr13.lo" },
1426 { PT_FPR14_HI, "fpr14.hi" },
1427 { PT_FPR14_LO, "fpr14.lo" },
1428 { PT_FPR15_HI, "fpr15.hi" },
1429 { PT_FPR15_LO, "fpr15.lo" },
1432 { PT_FPR0, "fpr0" },
1433 { PT_FPR1, "fpr1" },
1434 { PT_FPR2, "fpr2" },
1435 { PT_FPR3, "fpr3" },
1436 { PT_FPR4, "fpr4" },
1437 { PT_FPR5, "fpr5" },
1438 { PT_FPR6, "fpr6" },
1439 { PT_FPR7, "fpr7" },
1440 { PT_FPR8, "fpr8" },
1441 { PT_FPR9, "fpr9" },
1442 { PT_FPR10, "fpr10" },
1443 { PT_FPR11, "fpr11" },
1444 { PT_FPR12, "fpr12" },
1445 { PT_FPR13, "fpr13" },
1446 { PT_FPR14, "fpr14" },
1447 { PT_FPR15, "fpr15" },
1450 { PT_CR_10, "cr10" },
1451 { PT_CR_11, "cr11" },
1452 { PT_IEEE_IP, "ieee_exception_ip" },
1453 #elif defined(SPARC)
1454 /* XXX No support for these offsets yet. */
1456 /* XXX No support for these offsets yet. */
1457 #elif defined(POWERPC)
1459 # define PT_ORIG_R3 34
1461 # define REGSIZE (sizeof(unsigned long))
1462 { REGSIZE*PT_R0, "r0" },
1463 { REGSIZE*PT_R1, "r1" },
1464 { REGSIZE*PT_R2, "r2" },
1465 { REGSIZE*PT_R3, "r3" },
1466 { REGSIZE*PT_R4, "r4" },
1467 { REGSIZE*PT_R5, "r5" },
1468 { REGSIZE*PT_R6, "r6" },
1469 { REGSIZE*PT_R7, "r7" },
1470 { REGSIZE*PT_R8, "r8" },
1471 { REGSIZE*PT_R9, "r9" },
1472 { REGSIZE*PT_R10, "r10" },
1473 { REGSIZE*PT_R11, "r11" },
1474 { REGSIZE*PT_R12, "r12" },
1475 { REGSIZE*PT_R13, "r13" },
1476 { REGSIZE*PT_R14, "r14" },
1477 { REGSIZE*PT_R15, "r15" },
1478 { REGSIZE*PT_R16, "r16" },
1479 { REGSIZE*PT_R17, "r17" },
1480 { REGSIZE*PT_R18, "r18" },
1481 { REGSIZE*PT_R19, "r19" },
1482 { REGSIZE*PT_R20, "r20" },
1483 { REGSIZE*PT_R21, "r21" },
1484 { REGSIZE*PT_R22, "r22" },
1485 { REGSIZE*PT_R23, "r23" },
1486 { REGSIZE*PT_R24, "r24" },
1487 { REGSIZE*PT_R25, "r25" },
1488 { REGSIZE*PT_R26, "r26" },
1489 { REGSIZE*PT_R27, "r27" },
1490 { REGSIZE*PT_R28, "r28" },
1491 { REGSIZE*PT_R29, "r29" },
1492 { REGSIZE*PT_R30, "r30" },
1493 { REGSIZE*PT_R31, "r31" },
1494 { REGSIZE*PT_NIP, "NIP" },
1495 { REGSIZE*PT_MSR, "MSR" },
1496 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1497 { REGSIZE*PT_CTR, "CTR" },
1498 { REGSIZE*PT_LNK, "LNK" },
1499 { REGSIZE*PT_XER, "XER" },
1500 { REGSIZE*PT_CCR, "CCR" },
1501 { REGSIZE*PT_FPR0, "FPR0" },
1503 #elif defined(ALPHA)
1570 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1571 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1572 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1573 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1574 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1575 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1576 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1577 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1578 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1579 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1580 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1581 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1582 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1583 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1584 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1585 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1586 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1587 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1588 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1589 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1590 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1591 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1592 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1593 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1594 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1595 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1596 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1597 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1598 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1599 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1600 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1601 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1603 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1604 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1605 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1606 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1607 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1608 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1609 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1610 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1611 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1612 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
1613 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1614 { PT_B4, "b4" }, { PT_B5, "b5" },
1615 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
1617 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1618 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
1619 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1620 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1621 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1622 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1623 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1624 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1625 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1626 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1627 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1628 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1629 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1630 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1631 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1632 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1633 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
1635 { PT_AR_CSD, "ar.csd" },
1638 { PT_AR_SSD, "ar.ssd" },
1640 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
1653 { 4*ORIG_EAX, "4*ORIG_EAX" },
1657 { 4*UESP, "4*UESP" },
1659 #elif defined(X86_64) || defined(X32)
1675 { 8*ORIG_RAX, "8*ORIG_RAX" },
1678 { 8*EFLAGS, "8*EFL" },
1682 { 4*PT_D1, "4*PT_D1" },
1683 { 4*PT_D2, "4*PT_D2" },
1684 { 4*PT_D3, "4*PT_D3" },
1685 { 4*PT_D4, "4*PT_D4" },
1686 { 4*PT_D5, "4*PT_D5" },
1687 { 4*PT_D6, "4*PT_D6" },
1688 { 4*PT_D7, "4*PT_D7" },
1689 { 4*PT_A0, "4*PT_A0" },
1690 { 4*PT_A1, "4*PT_A1" },
1691 { 4*PT_A2, "4*PT_A2" },
1692 { 4*PT_A3, "4*PT_A3" },
1693 { 4*PT_A4, "4*PT_A4" },
1694 { 4*PT_A5, "4*PT_A5" },
1695 { 4*PT_A6, "4*PT_A6" },
1696 { 4*PT_D0, "4*PT_D0" },
1697 { 4*PT_USP, "4*PT_USP" },
1698 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1699 { 4*PT_SR, "4*PT_SR" },
1700 { 4*PT_PC, "4*PT_PC" },
1702 { 4*REG_REG0, "4*REG_REG0" },
1703 { 4*(REG_REG0+1), "4*REG_REG1" },
1704 { 4*(REG_REG0+2), "4*REG_REG2" },
1705 { 4*(REG_REG0+3), "4*REG_REG3" },
1706 { 4*(REG_REG0+4), "4*REG_REG4" },
1707 { 4*(REG_REG0+5), "4*REG_REG5" },
1708 { 4*(REG_REG0+6), "4*REG_REG6" },
1709 { 4*(REG_REG0+7), "4*REG_REG7" },
1710 { 4*(REG_REG0+8), "4*REG_REG8" },
1711 { 4*(REG_REG0+9), "4*REG_REG9" },
1712 { 4*(REG_REG0+10), "4*REG_REG10" },
1713 { 4*(REG_REG0+11), "4*REG_REG11" },
1714 { 4*(REG_REG0+12), "4*REG_REG12" },
1715 { 4*(REG_REG0+13), "4*REG_REG13" },
1716 { 4*(REG_REG0+14), "4*REG_REG14" },
1717 { 4*REG_REG15, "4*REG_REG15" },
1718 { 4*REG_PC, "4*REG_PC" },
1719 { 4*REG_PR, "4*REG_PR" },
1720 { 4*REG_SR, "4*REG_SR" },
1721 { 4*REG_GBR, "4*REG_GBR" },
1722 { 4*REG_MACH, "4*REG_MACH" },
1723 { 4*REG_MACL, "4*REG_MACL" },
1724 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1725 { 4*REG_FPUL, "4*REG_FPUL" },
1726 { 4*REG_FPREG0, "4*REG_FPREG0" },
1727 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1728 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1729 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1730 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1731 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1732 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1733 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1734 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1735 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1736 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1737 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1738 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1739 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1740 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1741 { 4*REG_FPREG15, "4*REG_FPREG15" },
1743 { 4*REG_XDREG0, "4*REG_XDREG0" },
1744 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1745 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1746 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1747 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1748 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1749 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1750 { 4*REG_XDREG14, "4*REG_XDREG14" },
1752 { 4*REG_FPSCR, "4*REG_FPSCR" },
1758 { 16, "syscall no.(L)" },
1759 { 20, "syscall_no.(U)" },
1902 /* This entry is in case pt_regs contains dregs (depends on
1903 the kernel build options). */
1904 { uoff(regs), "offsetof(struct user, regs)" },
1905 { uoff(fpu), "offsetof(struct user, fpu)" },
1907 { uoff(regs.ARM_r0), "r0" },
1908 { uoff(regs.ARM_r1), "r1" },
1909 { uoff(regs.ARM_r2), "r2" },
1910 { uoff(regs.ARM_r3), "r3" },
1911 { uoff(regs.ARM_r4), "r4" },
1912 { uoff(regs.ARM_r5), "r5" },
1913 { uoff(regs.ARM_r6), "r6" },
1914 { uoff(regs.ARM_r7), "r7" },
1915 { uoff(regs.ARM_r8), "r8" },
1916 { uoff(regs.ARM_r9), "r9" },
1917 { uoff(regs.ARM_r10), "r10" },
1918 { uoff(regs.ARM_fp), "fp" },
1919 { uoff(regs.ARM_ip), "ip" },
1920 { uoff(regs.ARM_sp), "sp" },
1921 { uoff(regs.ARM_lr), "lr" },
1922 { uoff(regs.ARM_pc), "pc" },
1923 { uoff(regs.ARM_cpsr), "cpsr" },
1924 #elif defined(AVR32)
1925 { uoff(regs.sr), "sr" },
1926 { uoff(regs.pc), "pc" },
1927 { uoff(regs.lr), "lr" },
1928 { uoff(regs.sp), "sp" },
1929 { uoff(regs.r12), "r12" },
1930 { uoff(regs.r11), "r11" },
1931 { uoff(regs.r10), "r10" },
1932 { uoff(regs.r9), "r9" },
1933 { uoff(regs.r8), "r8" },
1934 { uoff(regs.r7), "r7" },
1935 { uoff(regs.r6), "r6" },
1936 { uoff(regs.r5), "r5" },
1937 { uoff(regs.r4), "r4" },
1938 { uoff(regs.r3), "r3" },
1939 { uoff(regs.r2), "r2" },
1940 { uoff(regs.r1), "r1" },
1941 { uoff(regs.r0), "r0" },
1942 { uoff(regs.r12_orig), "orig_r12" },
2016 { PTREGS_OFFSET_REG(0), "r0" },
2017 { PTREGS_OFFSET_REG(1), "r1" },
2018 { PTREGS_OFFSET_REG(2), "r2" },
2019 { PTREGS_OFFSET_REG(3), "r3" },
2020 { PTREGS_OFFSET_REG(4), "r4" },
2021 { PTREGS_OFFSET_REG(5), "r5" },
2022 { PTREGS_OFFSET_REG(6), "r6" },
2023 { PTREGS_OFFSET_REG(7), "r7" },
2024 { PTREGS_OFFSET_REG(8), "r8" },
2025 { PTREGS_OFFSET_REG(9), "r9" },
2026 { PTREGS_OFFSET_REG(10), "r10" },
2027 { PTREGS_OFFSET_REG(11), "r11" },
2028 { PTREGS_OFFSET_REG(12), "r12" },
2029 { PTREGS_OFFSET_REG(13), "r13" },
2030 { PTREGS_OFFSET_REG(14), "r14" },
2031 { PTREGS_OFFSET_REG(15), "r15" },
2032 { PTREGS_OFFSET_REG(16), "r16" },
2033 { PTREGS_OFFSET_REG(17), "r17" },
2034 { PTREGS_OFFSET_REG(18), "r18" },
2035 { PTREGS_OFFSET_REG(19), "r19" },
2036 { PTREGS_OFFSET_REG(20), "r20" },
2037 { PTREGS_OFFSET_REG(21), "r21" },
2038 { PTREGS_OFFSET_REG(22), "r22" },
2039 { PTREGS_OFFSET_REG(23), "r23" },
2040 { PTREGS_OFFSET_REG(24), "r24" },
2041 { PTREGS_OFFSET_REG(25), "r25" },
2042 { PTREGS_OFFSET_REG(26), "r26" },
2043 { PTREGS_OFFSET_REG(27), "r27" },
2044 { PTREGS_OFFSET_REG(28), "r28" },
2045 { PTREGS_OFFSET_REG(29), "r29" },
2046 { PTREGS_OFFSET_REG(30), "r30" },
2047 { PTREGS_OFFSET_REG(31), "r31" },
2048 { PTREGS_OFFSET_REG(32), "r32" },
2049 { PTREGS_OFFSET_REG(33), "r33" },
2050 { PTREGS_OFFSET_REG(34), "r34" },
2051 { PTREGS_OFFSET_REG(35), "r35" },
2052 { PTREGS_OFFSET_REG(36), "r36" },
2053 { PTREGS_OFFSET_REG(37), "r37" },
2054 { PTREGS_OFFSET_REG(38), "r38" },
2055 { PTREGS_OFFSET_REG(39), "r39" },
2056 { PTREGS_OFFSET_REG(40), "r40" },
2057 { PTREGS_OFFSET_REG(41), "r41" },
2058 { PTREGS_OFFSET_REG(42), "r42" },
2059 { PTREGS_OFFSET_REG(43), "r43" },
2060 { PTREGS_OFFSET_REG(44), "r44" },
2061 { PTREGS_OFFSET_REG(45), "r45" },
2062 { PTREGS_OFFSET_REG(46), "r46" },
2063 { PTREGS_OFFSET_REG(47), "r47" },
2064 { PTREGS_OFFSET_REG(48), "r48" },
2065 { PTREGS_OFFSET_REG(49), "r49" },
2066 { PTREGS_OFFSET_REG(50), "r50" },
2067 { PTREGS_OFFSET_REG(51), "r51" },
2068 { PTREGS_OFFSET_REG(52), "r52" },
2069 { PTREGS_OFFSET_TP, "tp" },
2070 { PTREGS_OFFSET_SP, "sp" },
2071 { PTREGS_OFFSET_LR, "lr" },
2072 { PTREGS_OFFSET_PC, "pc" },
2073 { PTREGS_OFFSET_EX1, "ex1" },
2074 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2075 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2076 { PTREGS_OFFSET_FLAGS, "flags" },
2079 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2080 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2081 { 4*PT_R13, "4*PT_R13" },
2082 { 4*PT_R12, "4*PT_R12" },
2083 { 4*PT_R11, "4*PT_R11" },
2084 { 4*PT_R10, "4*PT_R10" },
2085 { 4*PT_R9, "4*PT_R9" },
2086 { 4*PT_R8, "4*PT_R8" },
2087 { 4*PT_R7, "4*PT_R7" },
2088 { 4*PT_R6, "4*PT_R6" },
2089 { 4*PT_R5, "4*PT_R5" },
2090 { 4*PT_R4, "4*PT_R4" },
2091 { 4*PT_R3, "4*PT_R3" },
2092 { 4*PT_R2, "4*PT_R2" },
2093 { 4*PT_R1, "4*PT_R1" },
2094 { 4*PT_R0, "4*PT_R0" },
2095 { 4*PT_MOF, "4*PT_MOF" },
2096 { 4*PT_DCCR, "4*PT_DCCR" },
2097 { 4*PT_SRP, "4*PT_SRP" },
2098 { 4*PT_IRP, "4*PT_IRP" },
2099 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2100 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2101 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2102 { 4*PT_USP, "4*PT_USP" },
2105 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2106 { 4*PT_R0, "4*PT_R0" },
2107 { 4*PT_R1, "4*PT_R1" },
2108 { 4*PT_R2, "4*PT_R2" },
2109 { 4*PT_R3, "4*PT_R3" },
2110 { 4*PT_R4, "4*PT_R4" },
2111 { 4*PT_R5, "4*PT_R5" },
2112 { 4*PT_R6, "4*PT_R6" },
2113 { 4*PT_R7, "4*PT_R7" },
2114 { 4*PT_R8, "4*PT_R8" },
2115 { 4*PT_R9, "4*PT_R9" },
2116 { 4*PT_R10, "4*PT_R10" },
2117 { 4*PT_R11, "4*PT_R11" },
2118 { 4*PT_R12, "4*PT_R12" },
2119 { 4*PT_R13, "4*PT_R13" },
2120 { 4*PT_ACR, "4*PT_ACR" },
2121 { 4*PT_SRS, "4*PT_SRS" },
2122 { 4*PT_MOF, "4*PT_MOF" },
2123 { 4*PT_SPC, "4*PT_SPC" },
2124 { 4*PT_CCS, "4*PT_CCS" },
2125 { 4*PT_SRP, "4*PT_SRP" },
2126 { 4*PT_ERP, "4*PT_ERP" },
2127 { 4*PT_EXS, "4*PT_EXS" },
2128 { 4*PT_EDA, "4*PT_EDA" },
2129 { 4*PT_USP, "4*PT_USP" },
2130 { 4*PT_PPC, "4*PT_PPC" },
2131 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2132 { 4*PT_BP+4, "4*PT_BP+4" },
2133 { 4*PT_BP+8, "4*PT_BP+8" },
2134 { 4*PT_BP+12, "4*PT_BP+12" },
2135 { 4*PT_BP+16, "4*PT_BP+16" },
2136 { 4*PT_BP+20, "4*PT_BP+20" },
2137 { 4*PT_BP+24, "4*PT_BP+24" },
2138 { 4*PT_BP+28, "4*PT_BP+28" },
2139 { 4*PT_BP+32, "4*PT_BP+32" },
2140 { 4*PT_BP+36, "4*PT_BP+36" },
2141 { 4*PT_BP+40, "4*PT_BP+40" },
2142 { 4*PT_BP+44, "4*PT_BP+44" },
2143 { 4*PT_BP+48, "4*PT_BP+48" },
2144 { 4*PT_BP+52, "4*PT_BP+52" },
2145 { 4*PT_BP+56, "4*PT_BP+56" },
2148 { PT_GPR(0), "r0" },
2149 { PT_GPR(1), "r1" },
2150 { PT_GPR(2), "r2" },
2151 { PT_GPR(3), "r3" },
2152 { PT_GPR(4), "r4" },
2153 { PT_GPR(5), "r5" },
2154 { PT_GPR(6), "r6" },
2155 { PT_GPR(7), "r7" },
2156 { PT_GPR(8), "r8" },
2157 { PT_GPR(9), "r9" },
2158 { PT_GPR(10), "r10" },
2159 { PT_GPR(11), "r11" },
2160 { PT_GPR(12), "r12" },
2161 { PT_GPR(13), "r13" },
2162 { PT_GPR(14), "r14" },
2163 { PT_GPR(15), "r15" },
2164 { PT_GPR(16), "r16" },
2165 { PT_GPR(17), "r17" },
2166 { PT_GPR(18), "r18" },
2167 { PT_GPR(19), "r19" },
2168 { PT_GPR(20), "r20" },
2169 { PT_GPR(21), "r21" },
2170 { PT_GPR(22), "r22" },
2171 { PT_GPR(23), "r23" },
2172 { PT_GPR(24), "r24" },
2173 { PT_GPR(25), "r25" },
2174 { PT_GPR(26), "r26" },
2175 { PT_GPR(27), "r27" },
2176 { PT_GPR(28), "r28" },
2177 { PT_GPR(29), "r29" },
2178 { PT_GPR(30), "r30" },
2179 { PT_GPR(31), "r31" },
2181 { PT_MSR, "rmsr", },
2182 { PT_EAR, "rear", },
2183 { PT_ESR, "resr", },
2184 { PT_FSR, "rfsr", },
2185 { PT_KERNEL_MODE, "kernel_mode", },
2223 /* Other fields in "struct user" */
2224 #if defined(S390) || defined(S390X)
2225 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2226 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2227 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2228 { uoff(start_code), "offsetof(struct user, start_code)" },
2229 /* S390[X] has no start_data */
2230 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2231 { uoff(signal), "offsetof(struct user, signal)" },
2232 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2233 { uoff(magic), "offsetof(struct user, magic)" },
2234 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2235 { sizeof(struct user), "sizeof(struct user)" },
2236 #elif defined(POWERPC)
2237 { sizeof(struct user), "sizeof(struct user)" },
2238 #elif defined(I386) || defined(X86_64) || defined(X32)
2239 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2240 { uoff(i387), "offsetof(struct user, i387)" },
2241 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2242 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2243 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2244 { uoff(start_code), "offsetof(struct user, start_code)" },
2245 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2246 { uoff(signal), "offsetof(struct user, signal)" },
2247 { uoff(reserved), "offsetof(struct user, reserved)" },
2248 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2249 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2250 { uoff(magic), "offsetof(struct user, magic)" },
2251 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2252 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
2253 { sizeof(struct user), "sizeof(struct user)" },
2255 { sizeof(struct user), "sizeof(struct user)" },
2257 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2258 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2259 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2260 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2261 { uoff(start_code), "offsetof(struct user, start_code)" },
2262 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2263 { uoff(signal), "offsetof(struct user, signal)" },
2264 { uoff(reserved), "offsetof(struct user, reserved)" },
2265 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2266 { uoff(magic), "offsetof(struct user, magic)" },
2267 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2268 { sizeof(struct user), "sizeof(struct user)" },
2269 #elif defined(AARCH64)
2272 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2273 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2274 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2275 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2276 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2277 { uoff(start_code), "offsetof(struct user, start_code)" },
2278 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2279 { uoff(signal), "offsetof(struct user, signal)" },
2280 { uoff(reserved), "offsetof(struct user, reserved)" },
2281 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2282 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2283 { uoff(magic), "offsetof(struct user, magic)" },
2284 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2285 { sizeof(struct user), "sizeof(struct user)" },
2286 #elif defined(MIPS) || defined(LINUX_MIPSN32)
2287 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2288 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2289 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2290 { uoff(start_code), "offsetof(struct user, start_code)" },
2291 { uoff(start_data), "offsetof(struct user, start_data)" },
2292 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2293 { uoff(signal), "offsetof(struct user, signal)" },
2294 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2295 { uoff(magic), "offsetof(struct user, magic)" },
2296 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2297 { sizeof(struct user), "sizeof(struct user)" },
2298 #elif defined(ALPHA)
2299 { sizeof(struct user), "sizeof(struct user)" },
2300 #elif defined(SPARC)
2301 { sizeof(struct user), "sizeof(struct user)" },
2302 #elif defined(SPARC64)
2303 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2304 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2305 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2306 { uoff(signal), "offsetof(struct user, signal)" },
2307 { uoff(magic), "offsetof(struct user, magic)" },
2308 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2309 { sizeof(struct user), "sizeof(struct user)" },
2312 #elif defined(SH) || defined(SH64)
2313 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2314 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2315 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2316 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2317 { uoff(start_code), "offsetof(struct user, start_code)" },
2318 { uoff(start_data), "offsetof(struct user, start_data)" },
2319 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2320 { uoff(signal), "offsetof(struct user, signal)" },
2321 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2322 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2323 { uoff(magic), "offsetof(struct user, magic)" },
2324 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2325 { sizeof(struct user), "sizeof(struct user)" },
2326 #elif defined(CRISV10) || defined(CRISV32)
2327 { sizeof(struct user), "sizeof(struct user)" },
2330 #elif defined(MICROBLAZE)
2331 { sizeof(struct user), "sizeof(struct user)" },
2332 #elif defined(AVR32)
2333 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2334 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2335 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2336 { uoff(start_code), "offsetof(struct user, start_code)" },
2337 { uoff(start_data), "offsetof(struct user, start_data)" },
2338 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2339 { uoff(signal), "offsetof(struct user, signal)" },
2340 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2341 { uoff(magic), "offsetof(struct user, magic)" },
2342 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2343 { sizeof(struct user), "sizeof(struct user)" },
2345 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2346 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2347 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2348 { uoff(start_code), "offsetof(struct user, start_code)" },
2349 { uoff(signal), "offsetof(struct user, signal)" },
2350 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2351 { uoff(magic), "offsetof(struct user, magic)" },
2352 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2353 { sizeof(struct user), "sizeof(struct user)" },
2356 #elif defined(METAG)
2363 sys_ptrace(struct tcb *tcp)
2365 const struct xlat *x;
2368 if (entering(tcp)) {
2369 printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
2370 tprintf(", %lu, ", tcp->u_arg[1]);
2372 addr = tcp->u_arg[2];
2373 if (tcp->u_arg[0] == PTRACE_PEEKUSER
2374 || tcp->u_arg[0] == PTRACE_POKEUSER
2376 for (x = struct_user_offsets; x->str; x++) {
2381 tprintf("%#lx, ", addr);
2382 else if (x->val > addr && x != struct_user_offsets) {
2384 tprintf("%s + %ld, ", x->str, addr - x->val);
2387 tprintf("%s, ", x->str);
2389 #ifdef PTRACE_GETREGSET
2390 if (tcp->u_arg[0] == PTRACE_GETREGSET
2391 || tcp->u_arg[0] == PTRACE_SETREGSET
2393 printxval(nt_descriptor_types, tcp->u_arg[2], "NT_???");
2397 tprintf("%#lx, ", addr);
2400 switch (tcp->u_arg[0]) {
2402 case PTRACE_PEEKDATA:
2403 case PTRACE_PEEKTEXT:
2404 case PTRACE_PEEKUSER:
2408 case PTRACE_SINGLESTEP:
2409 case PTRACE_SYSCALL:
2411 printsignal(tcp->u_arg[3]);
2413 #ifdef PTRACE_SETOPTIONS
2414 case PTRACE_SETOPTIONS:
2415 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2418 #ifdef PTRACE_SETSIGINFO
2419 case PTRACE_SETSIGINFO: {
2420 printsiginfo_at(tcp, tcp->u_arg[3]);
2424 #ifdef PTRACE_GETSIGINFO
2425 case PTRACE_GETSIGINFO:
2426 /* Don't print anything, do it at syscall return. */
2429 #ifdef PTRACE_GETREGSET
2430 case PTRACE_GETREGSET:
2432 case PTRACE_SETREGSET:
2433 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2437 tprintf("%#lx", tcp->u_arg[3]);
2441 switch (tcp->u_arg[0]) {
2442 case PTRACE_PEEKDATA:
2443 case PTRACE_PEEKTEXT:
2444 case PTRACE_PEEKUSER:
2448 printnum(tcp, tcp->u_arg[3], "%#lx");
2451 #ifdef PTRACE_GETSIGINFO
2452 case PTRACE_GETSIGINFO: {
2453 printsiginfo_at(tcp, tcp->u_arg[3]);
2457 #ifdef PTRACE_GETREGSET
2458 case PTRACE_GETREGSET:
2459 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2467 #ifndef FUTEX_CMP_REQUEUE
2468 # define FUTEX_CMP_REQUEUE 4
2470 #ifndef FUTEX_WAKE_OP
2471 # define FUTEX_WAKE_OP 5
2473 #ifndef FUTEX_LOCK_PI
2474 # define FUTEX_LOCK_PI 6
2475 # define FUTEX_UNLOCK_PI 7
2476 # define FUTEX_TRYLOCK_PI 8
2478 #ifndef FUTEX_WAIT_BITSET
2479 # define FUTEX_WAIT_BITSET 9
2481 #ifndef FUTEX_WAKE_BITSET
2482 # define FUTEX_WAKE_BITSET 10
2484 #ifndef FUTEX_WAIT_REQUEUE_PI
2485 # define FUTEX_WAIT_REQUEUE_PI 11
2487 #ifndef FUTEX_CMP_REQUEUE_PI
2488 # define FUTEX_CMP_REQUEUE_PI 12
2490 #ifndef FUTEX_PRIVATE_FLAG
2491 # define FUTEX_PRIVATE_FLAG 128
2493 #ifndef FUTEX_CLOCK_REALTIME
2494 # define FUTEX_CLOCK_REALTIME 256
2496 static const struct xlat futexops[] = {
2497 { FUTEX_WAIT, "FUTEX_WAIT" },
2498 { FUTEX_WAKE, "FUTEX_WAKE" },
2499 { FUTEX_FD, "FUTEX_FD" },
2500 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2501 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2502 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2503 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2504 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2505 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
2506 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2507 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
2508 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2509 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
2510 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2511 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2512 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2513 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2514 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2515 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2516 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2517 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2518 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
2519 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2520 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
2521 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2522 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2523 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2524 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2525 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2526 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI_PRIVATE|FUTEX_CLOCK_REALTIME" },
2529 #ifndef FUTEX_OP_SET
2530 # define FUTEX_OP_SET 0
2531 # define FUTEX_OP_ADD 1
2532 # define FUTEX_OP_OR 2
2533 # define FUTEX_OP_ANDN 3
2534 # define FUTEX_OP_XOR 4
2535 # define FUTEX_OP_CMP_EQ 0
2536 # define FUTEX_OP_CMP_NE 1
2537 # define FUTEX_OP_CMP_LT 2
2538 # define FUTEX_OP_CMP_LE 3
2539 # define FUTEX_OP_CMP_GT 4
2540 # define FUTEX_OP_CMP_GE 5
2542 static const struct xlat futexwakeops[] = {
2543 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2544 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2545 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2546 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2547 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2550 static const struct xlat futexwakecmps[] = {
2551 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2552 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2553 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2554 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2555 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2556 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2561 sys_futex(struct tcb *tcp)
2563 if (entering(tcp)) {
2564 long int cmd = tcp->u_arg[1] & 127;
2565 tprintf("%p, ", (void *) tcp->u_arg[0]);
2566 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2567 tprintf(", %ld", tcp->u_arg[2]);
2568 if (cmd == FUTEX_WAKE_BITSET)
2569 tprintf(", %lx", tcp->u_arg[5]);
2570 else if (cmd == FUTEX_WAIT) {
2572 printtv(tcp, tcp->u_arg[3]);
2573 } else if (cmd == FUTEX_WAIT_BITSET) {
2575 printtv(tcp, tcp->u_arg[3]);
2576 tprintf(", %lx", tcp->u_arg[5]);
2577 } else if (cmd == FUTEX_REQUEUE)
2578 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2579 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
2580 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2581 else if (cmd == FUTEX_WAKE_OP) {
2582 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2583 if ((tcp->u_arg[5] >> 28) & 8)
2584 tprints("FUTEX_OP_OPARG_SHIFT|");
2585 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2586 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2587 if ((tcp->u_arg[5] >> 24) & 8)
2588 tprints("FUTEX_OP_OPARG_SHIFT|");
2589 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2590 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
2591 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
2593 printtv(tcp, tcp->u_arg[3]);
2594 tprintf(", %p", (void *) tcp->u_arg[4]);
2601 print_affinitylist(struct tcb *tcp, long list, unsigned int len)
2604 unsigned long w, min_len;
2606 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2607 min_len = len - max_strlen * sizeof(w);
2610 for (; len >= sizeof(w) && len > min_len;
2611 len -= sizeof(w), list += sizeof(w)) {
2612 if (umove(tcp, list, &w) < 0)
2623 tprintf("%#lx", list);
2625 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2628 tprints(first ? "{}" : "}");
2633 sys_sched_setaffinity(struct tcb *tcp)
2635 if (entering(tcp)) {
2636 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2637 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2643 sys_sched_getaffinity(struct tcb *tcp)
2645 if (entering(tcp)) {
2646 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2648 if (tcp->u_rval == -1)
2649 tprintf("%#lx", tcp->u_arg[2]);
2651 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2657 sys_get_robust_list(struct tcb *tcp)
2659 if (entering(tcp)) {
2660 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2665 if (syserror(tcp) ||
2667 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2668 tprintf("%#lx, ", tcp->u_arg[1]);
2670 tprintf("[%p], ", addr);
2673 if (syserror(tcp) ||
2675 umove(tcp, tcp->u_arg[2], &len) < 0) {
2676 tprintf("%#lx", tcp->u_arg[2]);
2678 tprintf("[%lu]", (unsigned long) len);
2684 static const struct xlat schedulers[] = {
2685 { SCHED_OTHER, "SCHED_OTHER" },
2686 { SCHED_RR, "SCHED_RR" },
2687 { SCHED_FIFO, "SCHED_FIFO" },
2692 sys_sched_getscheduler(struct tcb *tcp)
2694 if (entering(tcp)) {
2695 tprintf("%d", (int) tcp->u_arg[0]);
2696 } else if (!syserror(tcp)) {
2697 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
2698 if (tcp->auxstr != NULL)
2705 sys_sched_setscheduler(struct tcb *tcp)
2707 if (entering(tcp)) {
2708 struct sched_param p;
2709 tprintf("%d, ", (int) tcp->u_arg[0]);
2710 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2711 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2712 tprintf(", %#lx", tcp->u_arg[2]);
2714 tprintf(", { %d }", p.__sched_priority);
2720 sys_sched_getparam(struct tcb *tcp)
2722 if (entering(tcp)) {
2723 tprintf("%d, ", (int) tcp->u_arg[0]);
2725 struct sched_param p;
2726 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2727 tprintf("%#lx", tcp->u_arg[1]);
2729 tprintf("{ %d }", p.__sched_priority);
2735 sys_sched_setparam(struct tcb *tcp)
2737 if (entering(tcp)) {
2738 struct sched_param p;
2739 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2740 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2742 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2748 sys_sched_get_priority_min(struct tcb *tcp)
2750 if (entering(tcp)) {
2751 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2757 sys_sched_rr_get_interval(struct tcb *tcp)
2759 if (entering(tcp)) {
2760 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2763 tprintf("%#lx", tcp->u_arg[1]);
2765 print_timespec(tcp, tcp->u_arg[1]);
2770 #if defined X86_64 || defined X32
2771 # include <asm/prctl.h>
2773 static const struct xlat archvals[] = {
2774 { ARCH_SET_GS, "ARCH_SET_GS" },
2775 { ARCH_SET_FS, "ARCH_SET_FS" },
2776 { ARCH_GET_FS, "ARCH_GET_FS" },
2777 { ARCH_GET_GS, "ARCH_GET_GS" },
2782 sys_arch_prctl(struct tcb *tcp)
2784 if (entering(tcp)) {
2785 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2786 if (tcp->u_arg[0] == ARCH_SET_GS
2787 || tcp->u_arg[0] == ARCH_SET_FS
2789 tprintf(", %#lx", tcp->u_arg[1]);
2792 if (tcp->u_arg[0] == ARCH_GET_GS
2793 || tcp->u_arg[0] == ARCH_GET_FS
2796 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2797 tprintf(", [%#lx]", v);
2799 tprintf(", %#lx", tcp->u_arg[1]);
2804 #endif /* X86_64 || X32 */
2807 sys_getcpu(struct tcb *tcp)
2811 if (tcp->u_arg[0] == 0)
2813 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2814 tprintf("%#lx, ", tcp->u_arg[0]);
2816 tprintf("[%u], ", u);
2817 if (tcp->u_arg[1] == 0)
2819 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2820 tprintf("%#lx, ", tcp->u_arg[1]);
2822 tprintf("[%u], ", u);
2823 tprintf("%#lx", tcp->u_arg[2]);
2829 sys_process_vm_readv(struct tcb *tcp)
2831 if (entering(tcp)) {
2833 tprintf("%ld, ", tcp->u_arg[0]);
2835 /* arg 2: local iov */
2836 if (syserror(tcp)) {
2837 tprintf("%#lx", tcp->u_arg[1]);
2839 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2841 /* arg 3: local iovcnt */
2842 tprintf(", %lu, ", tcp->u_arg[2]);
2843 /* arg 4: remote iov */
2844 if (syserror(tcp)) {
2845 tprintf("%#lx", tcp->u_arg[3]);
2847 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2849 /* arg 5: remote iovcnt */
2851 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
2857 sys_process_vm_writev(struct tcb *tcp)
2859 if (entering(tcp)) {
2861 tprintf("%ld, ", tcp->u_arg[0]);
2862 /* arg 2: local iov */
2864 tprintf("%#lx", tcp->u_arg[1]);
2866 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2867 /* arg 3: local iovcnt */
2868 tprintf(", %lu, ", tcp->u_arg[2]);
2869 /* arg 4: remote iov */
2871 tprintf("%#lx", tcp->u_arg[3]);
2873 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2874 /* arg 5: remote iovcnt */
2876 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);