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>
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. The name of the author may not be used to endorse or promote products
24 * derived from this software without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <sys/resource.h>
47 #include <sys/utsname.h>
49 #include <sys/syscall.h>
55 # ifndef PTRACE_PEEKUSR
56 # define PTRACE_PEEKUSR PTRACE_PEEKUSER
58 # ifndef PTRACE_POKEUSR
59 # define PTRACE_POKEUSR PTRACE_POKEUSER
63 #ifdef HAVE_LINUX_PTRACE_H
64 # undef PTRACE_SYSCALL
65 # ifdef HAVE_STRUCT_IA64_FPREG
66 # define ia64_fpreg XXX_ia64_fpreg
68 # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
69 # define pt_all_user_regs XXX_pt_all_user_regs
71 # include <linux/ptrace.h>
73 # undef pt_all_user_regs
78 # undef PTRACE_GETREGS
79 # define PTRACE_GETREGS PTRACE_GETREGS64
80 # undef PTRACE_SETREGS
81 # define PTRACE_SETREGS PTRACE_SETREGS64
84 #ifdef HAVE_LINUX_FUTEX_H
85 # include <linux/futex.h>
97 # define FUTEX_REQUEUE 3
101 #include <asm/posix_types.h>
103 #define GETGROUPS_T __kernel_gid_t
105 #define GETGROUPS32_T __kernel_gid32_t
108 # include <asm/ptrace_offsets.h>
109 # include <asm/rse.h>
113 # include <sys/prctl.h>
115 static const struct xlat prctl_options[] = {
117 { PR_MAXPROCS, "PR_MAXPROCS" },
120 { PR_ISBLOCKED, "PR_ISBLOCKED" },
122 #ifdef PR_SETSTACKSIZE
123 { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" },
125 #ifdef PR_GETSTACKSIZE
126 { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" },
129 { PR_MAXPPROCS, "PR_MAXPPROCS" },
131 #ifdef PR_UNBLKONEXEC
132 { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" },
135 { PR_ATOMICSIM, "PR_ATOMICSIM" },
138 { PR_SETEXITSIG, "PR_SETEXITSIG" },
141 { PR_RESIDENT, "PR_RESIDENT" },
144 { PR_ATTACHADDR, "PR_ATTACHADDR" },
147 { PR_DETACHADDR, "PR_DETACHADDR" },
150 { PR_TERMCHILD, "PR_TERMCHILD" },
153 { PR_GETSHMASK, "PR_GETSHMASK" },
156 { PR_GETNSHARE, "PR_GETNSHARE" },
159 { PR_COREPID, "PR_COREPID" },
161 #ifdef PR_ATTACHADDRPERM
162 { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" },
164 #ifdef PR_PTHREADEXIT
165 { PR_PTHREADEXIT, "PR_PTHREADEXIT" },
167 #ifdef PR_SET_PDEATHSIG
168 { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
170 #ifdef PR_GET_PDEATHSIG
171 { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
173 #ifdef PR_GET_DUMPABLE
174 { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" },
176 #ifdef PR_SET_DUMPABLE
177 { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" },
179 #ifdef PR_GET_UNALIGN
180 { PR_GET_UNALIGN, "PR_GET_UNALIGN" },
182 #ifdef PR_SET_UNALIGN
183 { PR_SET_UNALIGN, "PR_SET_UNALIGN" },
185 #ifdef PR_GET_KEEPCAPS
186 { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" },
188 #ifdef PR_SET_KEEPCAPS
189 { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" },
192 { PR_GET_FPEMU, "PR_GET_FPEMU" },
195 { PR_SET_FPEMU, "PR_SET_FPEMU" },
198 { PR_GET_FPEXC, "PR_GET_FPEXC" },
201 { PR_SET_FPEXC, "PR_SET_FPEXC" },
204 { PR_GET_TIMING, "PR_GET_TIMING" },
207 { PR_SET_TIMING, "PR_SET_TIMING" },
210 { PR_SET_NAME, "PR_SET_NAME" },
213 { PR_GET_NAME, "PR_GET_NAME" },
216 { PR_GET_ENDIAN, "PR_GET_ENDIAN" },
219 { PR_SET_ENDIAN, "PR_SET_ENDIAN" },
221 #ifdef PR_GET_SECCOMP
222 { PR_GET_SECCOMP, "PR_GET_SECCOMP" },
224 #ifdef PR_SET_SECCOMP
225 { PR_SET_SECCOMP, "PR_SET_SECCOMP" },
228 { PR_GET_TSC, "PR_GET_TSC" },
231 { PR_SET_TSC, "PR_SET_TSC" },
233 #ifdef PR_GET_SECUREBITS
234 { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" },
236 #ifdef PR_SET_SECUREBITS
237 { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" },
244 unalignctl_string(unsigned int ctl)
249 #ifdef PR_UNALIGN_NOPRINT
250 case PR_UNALIGN_NOPRINT:
253 #ifdef PR_UNALIGN_SIGBUS
254 case PR_UNALIGN_SIGBUS:
260 sprintf(buf, "%x", ctl);
266 sys_prctl(struct tcb *tcp)
271 printxval(prctl_options, tcp->u_arg[0], "PR_???");
272 switch (tcp->u_arg[0]) {
277 #ifdef PR_SET_PDEATHSIG
278 case PR_SET_PDEATHSIG:
279 tprintf(", %lu", tcp->u_arg[1]);
282 #ifdef PR_GET_PDEATHSIG
283 case PR_GET_PDEATHSIG:
286 #ifdef PR_SET_DUMPABLE
287 case PR_SET_DUMPABLE:
288 tprintf(", %lu", tcp->u_arg[1]);
291 #ifdef PR_GET_DUMPABLE
292 case PR_GET_DUMPABLE:
295 #ifdef PR_SET_UNALIGN
297 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
300 #ifdef PR_GET_UNALIGN
302 tprintf(", %#lx", tcp->u_arg[1]);
305 #ifdef PR_SET_KEEPCAPS
306 case PR_SET_KEEPCAPS:
307 tprintf(", %lu", tcp->u_arg[1]);
310 #ifdef PR_GET_KEEPCAPS
311 case PR_GET_KEEPCAPS:
315 for (i = 1; i < tcp->u_nargs; i++)
316 tprintf(", %#lx", tcp->u_arg[i]);
320 switch (tcp->u_arg[0]) {
321 #ifdef PR_GET_PDEATHSIG
322 case PR_GET_PDEATHSIG:
323 if (umove(tcp, tcp->u_arg[1], &i) < 0)
324 tprintf(", %#lx", tcp->u_arg[1]);
326 tprintf(", {%u}", i);
329 #ifdef PR_GET_DUMPABLE
330 case PR_GET_DUMPABLE:
331 return RVAL_UDECIMAL;
333 #ifdef PR_GET_UNALIGN
335 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
337 tcp->auxstr = unalignctl_string(i);
340 #ifdef PR_GET_KEEPCAPS
341 case PR_GET_KEEPCAPS:
342 return RVAL_UDECIMAL;
350 #endif /* HAVE_PRCTL */
354 sys_sethostname(struct tcb *tcp)
357 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
358 tprintf(", %lu", tcp->u_arg[1]);
365 sys_gethostname(struct tcb *tcp)
369 tprintf("%#lx", tcp->u_arg[0]);
371 printpath(tcp, tcp->u_arg[0]);
372 tprintf(", %lu", tcp->u_arg[1]);
379 sys_setdomainname(struct tcb *tcp)
382 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
383 tprintf(", %lu", tcp->u_arg[1]);
390 sys_exit(struct tcb *tcp)
393 fprintf(stderr, "_exit returned!\n");
396 /* special case: we stop tracing this process, finish line now */
397 tprintf("%ld) ", tcp->u_arg[0]);
406 /* defines copied from linux/sched.h since we can't include that
407 * ourselves (it conflicts with *lots* of libc includes)
409 #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
410 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
411 #define CLONE_FS 0x00000200 /* set if fs info shared between processes */
412 #define CLONE_FILES 0x00000400 /* set if open files shared between processes */
413 #define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
414 #define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
415 #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
416 #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
417 #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
418 #define CLONE_THREAD 0x00010000 /* Same thread group? */
419 #define CLONE_NEWNS 0x00020000 /* New namespace group? */
420 #define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
421 #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
422 #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
423 #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
424 #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
425 #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
426 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
427 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
428 #define CLONE_NEWIPC 0x08000000 /* New ipcs */
429 #define CLONE_NEWUSER 0x10000000 /* New user namespace */
430 #define CLONE_NEWPID 0x20000000 /* New pid namespace */
431 #define CLONE_NEWNET 0x40000000 /* New network namespace */
432 #define CLONE_IO 0x80000000 /* Clone io context */
434 static const struct xlat clone_flags[] = {
435 { CLONE_VM, "CLONE_VM" },
436 { CLONE_FS, "CLONE_FS" },
437 { CLONE_FILES, "CLONE_FILES" },
438 { CLONE_SIGHAND, "CLONE_SIGHAND" },
439 { CLONE_IDLETASK, "CLONE_IDLETASK"},
440 { CLONE_PTRACE, "CLONE_PTRACE" },
441 { CLONE_VFORK, "CLONE_VFORK" },
442 { CLONE_PARENT, "CLONE_PARENT" },
443 { CLONE_THREAD, "CLONE_THREAD" },
444 { CLONE_NEWNS, "CLONE_NEWNS" },
445 { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
446 { CLONE_SETTLS, "CLONE_SETTLS" },
447 { CLONE_PARENT_SETTID,"CLONE_PARENT_SETTID" },
448 { CLONE_CHILD_CLEARTID,"CLONE_CHILD_CLEARTID" },
449 { CLONE_UNTRACED, "CLONE_UNTRACED" },
450 { CLONE_CHILD_SETTID,"CLONE_CHILD_SETTID" },
451 { CLONE_STOPPED, "CLONE_STOPPED" },
452 { CLONE_NEWUTS, "CLONE_NEWUTS" },
453 { CLONE_NEWIPC, "CLONE_NEWIPC" },
454 { CLONE_NEWUSER, "CLONE_NEWUSER" },
455 { CLONE_NEWPID, "CLONE_NEWPID" },
456 { CLONE_NEWNET, "CLONE_NEWNET" },
457 { CLONE_IO, "CLONE_IO" },
462 # include <asm/ldt.h>
463 # ifdef HAVE_STRUCT_USER_DESC
464 # define modify_ldt_ldt_s user_desc
466 extern void print_ldt_entry();
472 # define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
473 # define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
474 # define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
475 # define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
476 # elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
482 # elif defined X86_64 || defined ALPHA
497 sys_clone(struct tcb *tcp)
500 const char *sep = "|";
501 unsigned long flags = tcp->u_arg[ARG_FLAGS];
502 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
503 # ifdef ARG_STACKSIZE
504 if (ARG_STACKSIZE != -1)
505 tprintf("stack_size=%#lx, ",
506 tcp->u_arg[ARG_STACKSIZE]);
509 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
511 if ((flags & CSIGNAL) != 0)
512 tprintf("%s%s", sep, signame(flags & CSIGNAL));
513 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
514 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
516 if (flags & CLONE_PARENT_SETTID)
517 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
518 if (flags & CLONE_SETTLS) {
520 struct modify_ldt_ldt_s copy;
521 if (umove(tcp, tcp->u_arg[ARG_TLS], ©) != -1) {
522 tprintf(", {entry_number:%d, ",
527 print_ldt_entry(©);
531 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
533 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
534 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
540 sys_unshare(struct tcb *tcp)
543 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
548 sys_fork(struct tcb *tcp)
551 return RVAL_UDECIMAL;
556 change_syscall(struct tcb *tcp, int new)
559 /* Attempt to make vfork into fork, which we can follow. */
560 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0)
563 #elif defined(X86_64)
564 /* Attempt to make vfork into fork, which we can follow. */
565 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_RAX * 8), new) < 0)
568 #elif defined(POWERPC)
569 if (ptrace(PTRACE_POKEUSER, tcp->pid,
570 (char*)(sizeof(unsigned long)*PT_R0), new) < 0)
573 #elif defined(S390) || defined(S390X)
574 /* s390 linux after 2.4.7 has a hook in entry.S to allow this */
575 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR2), new) < 0)
579 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_ORIG_D0), new) < 0)
582 #elif defined(SPARC) || defined(SPARC64)
584 if (ptrace(PTRACE_GETREGS, tcp->pid, (char*)®s, 0) < 0)
586 regs.u_regs[U_REG_G1] = new;
587 if (ptrace(PTRACE_SETREGS, tcp->pid, (char*)®s, 0) < 0)
591 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new) < 0)
595 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new) < 0)
599 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_R8), new) < 0)
603 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_P0), new) < 0)
610 break; /* x86 SYS_fork */
615 fprintf(stderr, "%s: unexpected syscall %d\n",
619 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R1), new) < 0)
621 } else if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R15), new) < 0)
625 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR20), new) < 0)
629 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*(REG_REG0+3)), new) < 0)
633 /* Top half of reg encodes the no. of args n as 0x1n.
634 Assume 0 args as kernel never actually checks... */
635 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_SYSCALL),
639 #elif defined(CRISV10) || defined(CRISV32)
640 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R9), new) < 0)
644 /* Some kernels support this, some (pre-2.6.16 or so) don't. */
645 # ifndef PTRACE_SET_SYSCALL
646 # define PTRACE_SET_SYSCALL 23
649 if (ptrace(PTRACE_SET_SYSCALL, tcp->pid, 0, new & 0xffff) != 0)
654 if (ptrace(PTRACE_POKEUSER, tcp->pid,
655 (char*)PTREGS_OFFSET_REG(0),
659 #elif defined(MICROBLAZE)
660 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new) < 0)
664 #warning Do not know how to handle change_syscall for this architecture
665 #endif /* architecture */
671 internal_fork(struct tcb *tcp)
673 if ((ptrace_setoptions
674 & (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
675 == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
683 * We won't see the new child if clone is called with
684 * CLONE_UNTRACED, so we keep the same logic with that option
685 * and don't trace it.
687 if ((sysent[tcp->scno].sys_func == sys_clone) &&
688 (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED))
692 if (tcp->flags & TCB_BPTSET)
702 sys_vfork(struct tcb *tcp)
705 return RVAL_UDECIMAL;
712 int sys_getuid(struct tcb *tcp)
715 tcp->u_rval = (uid_t) tcp->u_rval;
716 return RVAL_UDECIMAL;
719 int sys_setfsuid(struct tcb *tcp)
722 tprintf("%u", (uid_t) tcp->u_arg[0]);
724 tcp->u_rval = (uid_t) tcp->u_rval;
725 return RVAL_UDECIMAL;
729 sys_setuid(struct tcb *tcp)
732 tprintf("%u", (uid_t) tcp->u_arg[0]);
738 sys_setgid(struct tcb *tcp)
741 tprintf("%u", (gid_t) tcp->u_arg[0]);
747 sys_getresuid(struct tcb *tcp)
752 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
753 tcp->u_arg[1], tcp->u_arg[2]);
755 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
756 tprintf("%#lx, ", tcp->u_arg[0]);
758 tprintf("[%lu], ", (unsigned long) uid);
759 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
760 tprintf("%#lx, ", tcp->u_arg[1]);
762 tprintf("[%lu], ", (unsigned long) uid);
763 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
764 tprintf("%#lx", tcp->u_arg[2]);
766 tprintf("[%lu]", (unsigned long) uid);
773 sys_getresgid(struct tcb *tcp)
778 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
779 tcp->u_arg[1], tcp->u_arg[2]);
781 if (umove(tcp, tcp->u_arg[0], &gid) < 0)
782 tprintf("%#lx, ", tcp->u_arg[0]);
784 tprintf("[%lu], ", (unsigned long) gid);
785 if (umove(tcp, tcp->u_arg[1], &gid) < 0)
786 tprintf("%#lx, ", tcp->u_arg[1]);
788 tprintf("[%lu], ", (unsigned long) gid);
789 if (umove(tcp, tcp->u_arg[2], &gid) < 0)
790 tprintf("%#lx", tcp->u_arg[2]);
792 tprintf("[%lu]", (unsigned long) gid);
800 sys_setreuid(struct tcb *tcp)
803 printuid("", tcp->u_arg[0]);
804 printuid(", ", tcp->u_arg[1]);
810 sys_setregid(struct tcb *tcp)
813 printuid("", tcp->u_arg[0]);
814 printuid(", ", tcp->u_arg[1]);
820 sys_setresuid(struct tcb *tcp)
823 printuid("", tcp->u_arg[0]);
824 printuid(", ", tcp->u_arg[1]);
825 printuid(", ", tcp->u_arg[2]);
830 sys_setresgid(struct tcb *tcp)
833 printuid("", tcp->u_arg[0]);
834 printuid(", ", tcp->u_arg[1]);
835 printuid(", ", tcp->u_arg[2]);
842 sys_setgroups(struct tcb *tcp)
845 unsigned long len, size, start, cur, end, abbrev_end;
850 tprintf("%lu, ", len);
855 start = tcp->u_arg[1];
860 size = len * sizeof(gid);
862 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
863 tprintf("%#lx", start);
867 abbrev_end = start + max_strlen * sizeof(gid);
868 if (abbrev_end < start)
874 for (cur = start; cur < end; cur += sizeof(gid)) {
877 if (cur >= abbrev_end) {
881 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
886 tprintf("%lu", (unsigned long) gid);
890 tprintf(" %#lx", tcp->u_arg[1]);
896 sys_getgroups(struct tcb *tcp)
902 tprintf("%lu, ", len);
904 unsigned long size, start, cur, end, abbrev_end;
913 start = tcp->u_arg[1];
918 if (tcp->u_arg[0] == 0) {
919 tprintf("%#lx", start);
922 size = len * sizeof(gid);
924 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
925 size / sizeof(gid) != len || end < start) {
926 tprintf("%#lx", start);
930 abbrev_end = start + max_strlen * sizeof(gid);
931 if (abbrev_end < start)
937 for (cur = start; cur < end; cur += sizeof(gid)) {
940 if (cur >= abbrev_end) {
944 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
949 tprintf("%lu", (unsigned long) gid);
953 tprintf(" %#lx", tcp->u_arg[1]);
959 sys_setgroups32(struct tcb *tcp)
962 unsigned long len, size, start, cur, end, abbrev_end;
967 tprintf("%lu, ", len);
972 start = tcp->u_arg[1];
977 size = len * sizeof(gid);
979 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
980 tprintf("%#lx", start);
984 abbrev_end = start + max_strlen * sizeof(gid);
985 if (abbrev_end < start)
991 for (cur = start; cur < end; cur += sizeof(gid)) {
994 if (cur >= abbrev_end) {
998 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
1003 tprintf("%lu", (unsigned long) gid);
1007 tprintf(" %#lx", tcp->u_arg[1]);
1013 sys_getgroups32(struct tcb *tcp)
1017 if (entering(tcp)) {
1018 len = tcp->u_arg[0];
1019 tprintf("%lu, ", len);
1021 unsigned long size, start, cur, end, abbrev_end;
1030 start = tcp->u_arg[1];
1035 size = len * sizeof(gid);
1037 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
1038 size / sizeof(gid) != len || end < start) {
1039 tprintf("%#lx", start);
1043 abbrev_end = start + max_strlen * sizeof(gid);
1044 if (abbrev_end < start)
1050 for (cur = start; cur < end; cur += sizeof(gid)) {
1053 if (cur >= abbrev_end) {
1057 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
1062 tprintf("%lu", (unsigned long) gid);
1066 tprintf(" %#lx", tcp->u_arg[1]);
1073 sys_setpgrp(struct tcb *tcp)
1075 if (entering(tcp)) {
1076 tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]);
1083 sys_getpgrp(struct tcb *tcp)
1085 if (entering(tcp)) {
1086 tprintf("%lu", tcp->u_arg[0]);
1092 sys_getsid(struct tcb *tcp)
1094 if (entering(tcp)) {
1095 tprintf("%lu", tcp->u_arg[0]);
1101 sys_setsid(struct tcb *tcp)
1107 sys_getpgid(struct tcb *tcp)
1109 if (entering(tcp)) {
1110 tprintf("%lu", tcp->u_arg[0]);
1116 sys_setpgid(struct tcb *tcp)
1118 if (entering(tcp)) {
1119 tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]);
1127 printargv(struct tcb *tcp, long addr)
1132 char data[sizeof(long)];
1138 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
1139 if (umoven(tcp, addr, personality_wordsize[current_personality],
1141 tprintf("%#lx", addr);
1144 if (personality_wordsize[current_personality] == 4)
1149 printstr(tcp, cp.p64, -1);
1150 addr += personality_wordsize[current_personality];
1153 tprintf("%s...", sep);
1157 printargc(const char *fmt, struct tcb *tcp, long addr)
1162 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
1163 addr += sizeof(char *);
1165 tprintf(fmt, count, count == 1 ? "" : "s");
1168 #if defined(SPARC) || defined(SPARC64)
1170 sys_execv(struct tcb *tcp)
1172 if (entering(tcp)) {
1173 printpath(tcp, tcp->u_arg[0]);
1175 tprintf(", %#lx", tcp->u_arg[1]);
1178 printargv(tcp, tcp->u_arg[1]);
1187 sys_execve(struct tcb *tcp)
1189 if (entering(tcp)) {
1190 printpath(tcp, tcp->u_arg[0]);
1192 tprintf(", %#lx", tcp->u_arg[1]);
1195 printargv(tcp, tcp->u_arg[1]);
1199 tprintf(", %#lx", tcp->u_arg[2]);
1200 else if (abbrev(tcp))
1201 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
1204 printargv(tcp, tcp->u_arg[2]);
1212 #if defined(TCB_WAITEXECVE)
1214 internal_exec(struct tcb *tcp)
1216 if (exiting(tcp) && syserror(tcp))
1217 tcp->flags &= ~TCB_WAITEXECVE;
1219 /* Maybe we have post-execve SIGTRAP suppressed? */
1220 if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC))
1221 tcp->flags |= TCB_WAITEXECVE; /* no */
1228 #define __WNOTHREAD 0x20000000
1231 #define __WALL 0x40000000
1234 #define __WCLONE 0x80000000
1237 static const struct xlat wait4_options[] = {
1238 { WNOHANG, "WNOHANG" },
1240 { WUNTRACED, "WUNTRACED" },
1243 { WEXITED, "WEXITED" },
1246 { WTRAPPED, "WTRAPPED" },
1249 { WSTOPPED, "WSTOPPED" },
1252 { WCONTINUED, "WCONTINUED" },
1255 { WNOWAIT, "WNOWAIT" },
1258 { __WCLONE, "__WCLONE" },
1261 { __WALL, "__WALL" },
1264 { __WNOTHREAD, "__WNOTHREAD" },
1269 #if !defined WCOREFLAG && defined WCOREFLG
1270 # define WCOREFLAG WCOREFLG
1273 # define WCOREFLAG 0x80
1276 # define WCOREDUMP(status) ((status) & 0200)
1281 #define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
1284 #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
1288 printstatus(int status)
1293 * Here is a tricky presentation problem. This solution
1294 * is still not entirely satisfactory but since there
1295 * are no wait status constructors it will have to do.
1297 if (WIFSTOPPED(status)) {
1298 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
1299 signame(WSTOPSIG(status)));
1300 status &= ~W_STOPCODE(WSTOPSIG(status));
1302 else if (WIFSIGNALED(status)) {
1303 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
1304 signame(WTERMSIG(status)),
1305 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
1306 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1308 else if (WIFEXITED(status)) {
1309 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
1310 WEXITSTATUS(status));
1312 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
1315 tprintf("[%#x]", status);
1322 tprintf(" | %#x]", status);
1328 printwaitn(struct tcb *tcp, int n, int bitness)
1332 if (entering(tcp)) {
1333 /* On Linux, kernel-side pid_t is typedef'ed to int
1334 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
1335 * pid argument to int on 64bit arches, producing,
1336 * for example, wait4(4294967295, ...) instead of -1
1337 * in strace. We have to use int here, not long.
1339 int pid = tcp->u_arg[0];
1340 tprintf("%d, ", pid);
1345 else if (syserror(tcp) || tcp->u_rval == 0)
1346 tprintf("%#lx", tcp->u_arg[1]);
1347 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
1350 printstatus(status);
1353 printflags(wait4_options, tcp->u_arg[2], "W???");
1359 else if (tcp->u_rval > 0) {
1362 printrusage32(tcp, tcp->u_arg[3]);
1365 printrusage(tcp, tcp->u_arg[3]);
1368 tprintf("%#lx", tcp->u_arg[3]);
1377 sys_waitpid(struct tcb *tcp)
1379 return printwaitn(tcp, 3, 0);
1383 sys_wait4(struct tcb *tcp)
1385 return printwaitn(tcp, 4, 0);
1390 sys_osf_wait4(struct tcb *tcp)
1392 return printwaitn(tcp, 4, 1);
1397 static const struct xlat waitid_types[] = {
1400 { P_PPID, "P_PPID" },
1402 { P_PGID, "P_PGID" },
1417 { P_LWPID, "P_LWPID" },
1423 sys_waitid(struct tcb *tcp)
1427 if (entering(tcp)) {
1428 printxval(waitid_types, tcp->u_arg[0], "P_???");
1429 tprintf(", %ld, ", tcp->u_arg[1]);
1435 else if (syserror(tcp))
1436 tprintf("%#lx", tcp->u_arg[2]);
1437 else if (umove(tcp, tcp->u_arg[2], &si) < 0)
1440 printsiginfo(&si, verbose(tcp));
1443 printflags(wait4_options, tcp->u_arg[3], "W???");
1444 if (tcp->u_nargs > 4) {
1449 else if (tcp->u_error)
1450 tprintf("%#lx", tcp->u_arg[4]);
1452 printrusage(tcp, tcp->u_arg[4]);
1460 sys_alarm(struct tcb *tcp)
1463 tprintf("%lu", tcp->u_arg[0]);
1468 sys_uname(struct tcb *tcp)
1470 struct utsname uname;
1473 if (syserror(tcp) || !verbose(tcp))
1474 tprintf("%#lx", tcp->u_arg[0]);
1475 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
1477 else if (!abbrev(tcp)) {
1479 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1480 uname.sysname, uname.nodename);
1481 tprintf("release=\"%s\", version=\"%s\", ",
1482 uname.release, uname.version);
1483 tprintf("machine=\"%s\"", uname.machine);
1485 tprintf(", domainname=\"%s\"", uname.domainname);
1490 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1491 uname.sysname, uname.nodename);
1497 static const struct xlat ptrace_cmds[] = {
1498 { PTRACE_TRACEME, "PTRACE_TRACEME" },
1499 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1500 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1501 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1502 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1503 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1504 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
1505 { PTRACE_CONT, "PTRACE_CONT" },
1506 { PTRACE_KILL, "PTRACE_KILL" },
1507 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1508 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1509 { PTRACE_DETACH, "PTRACE_DETACH" },
1510 # ifdef PTRACE_GETREGS
1511 { PTRACE_GETREGS, "PTRACE_GETREGS" },
1513 # ifdef PTRACE_SETREGS
1514 { PTRACE_SETREGS, "PTRACE_SETREGS" },
1516 # ifdef PTRACE_GETFPREGS
1517 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
1519 # ifdef PTRACE_SETFPREGS
1520 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
1522 # ifdef PTRACE_GETFPXREGS
1523 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
1525 # ifdef PTRACE_SETFPXREGS
1526 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
1528 # ifdef PTRACE_GETVRREGS
1529 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
1531 # ifdef PTRACE_SETVRREGS
1532 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
1534 # ifdef PTRACE_SETOPTIONS
1535 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
1537 # ifdef PTRACE_GETEVENTMSG
1538 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
1540 # ifdef PTRACE_GETSIGINFO
1541 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
1543 # ifdef PTRACE_SETSIGINFO
1544 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
1546 # ifdef PTRACE_GETREGSET
1547 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
1549 # ifdef PTRACE_SETREGSET
1550 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
1552 # ifdef PTRACE_SET_SYSCALL
1553 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
1555 # ifdef PTRACE_SEIZE
1556 { PTRACE_SEIZE, "PTRACE_SEIZE" },
1558 # ifdef PTRACE_INTERRUPT
1559 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
1561 # ifdef PTRACE_LISTEN
1562 { PTRACE_LISTEN, "PTRACE_LISTEN" },
1564 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
1569 # ifdef PTRACE_SETOPTIONS
1570 static const struct xlat ptrace_setoptions_flags[] = {
1571 # ifdef PTRACE_O_TRACESYSGOOD
1572 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
1574 # ifdef PTRACE_O_TRACEFORK
1575 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
1577 # ifdef PTRACE_O_TRACEVFORK
1578 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
1580 # ifdef PTRACE_O_TRACECLONE
1581 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
1583 # ifdef PTRACE_O_TRACEEXEC
1584 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
1586 # ifdef PTRACE_O_TRACEVFORKDONE
1587 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
1589 # ifdef PTRACE_O_TRACEEXIT
1590 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
1594 # endif /* PTRACE_SETOPTIONS */
1596 const struct xlat struct_user_offsets[] = {
1597 # if defined(S390) || defined(S390X)
1598 { PT_PSWMASK, "psw_mask" },
1599 { PT_PSWADDR, "psw_addr" },
1600 { PT_GPR0, "gpr0" },
1601 { PT_GPR1, "gpr1" },
1602 { PT_GPR2, "gpr2" },
1603 { PT_GPR3, "gpr3" },
1604 { PT_GPR4, "gpr4" },
1605 { PT_GPR5, "gpr5" },
1606 { PT_GPR6, "gpr6" },
1607 { PT_GPR7, "gpr7" },
1608 { PT_GPR8, "gpr8" },
1609 { PT_GPR9, "gpr9" },
1610 { PT_GPR10, "gpr10" },
1611 { PT_GPR11, "gpr11" },
1612 { PT_GPR12, "gpr12" },
1613 { PT_GPR13, "gpr13" },
1614 { PT_GPR14, "gpr14" },
1615 { PT_GPR15, "gpr15" },
1616 { PT_ACR0, "acr0" },
1617 { PT_ACR1, "acr1" },
1618 { PT_ACR2, "acr2" },
1619 { PT_ACR3, "acr3" },
1620 { PT_ACR4, "acr4" },
1621 { PT_ACR5, "acr5" },
1622 { PT_ACR6, "acr6" },
1623 { PT_ACR7, "acr7" },
1624 { PT_ACR8, "acr8" },
1625 { PT_ACR9, "acr9" },
1626 { PT_ACR10, "acr10" },
1627 { PT_ACR11, "acr11" },
1628 { PT_ACR12, "acr12" },
1629 { PT_ACR13, "acr13" },
1630 { PT_ACR14, "acr14" },
1631 { PT_ACR15, "acr15" },
1632 { PT_ORIGGPR2, "orig_gpr2" },
1635 { PT_FPR0_HI, "fpr0.hi" },
1636 { PT_FPR0_LO, "fpr0.lo" },
1637 { PT_FPR1_HI, "fpr1.hi" },
1638 { PT_FPR1_LO, "fpr1.lo" },
1639 { PT_FPR2_HI, "fpr2.hi" },
1640 { PT_FPR2_LO, "fpr2.lo" },
1641 { PT_FPR3_HI, "fpr3.hi" },
1642 { PT_FPR3_LO, "fpr3.lo" },
1643 { PT_FPR4_HI, "fpr4.hi" },
1644 { PT_FPR4_LO, "fpr4.lo" },
1645 { PT_FPR5_HI, "fpr5.hi" },
1646 { PT_FPR5_LO, "fpr5.lo" },
1647 { PT_FPR6_HI, "fpr6.hi" },
1648 { PT_FPR6_LO, "fpr6.lo" },
1649 { PT_FPR7_HI, "fpr7.hi" },
1650 { PT_FPR7_LO, "fpr7.lo" },
1651 { PT_FPR8_HI, "fpr8.hi" },
1652 { PT_FPR8_LO, "fpr8.lo" },
1653 { PT_FPR9_HI, "fpr9.hi" },
1654 { PT_FPR9_LO, "fpr9.lo" },
1655 { PT_FPR10_HI, "fpr10.hi" },
1656 { PT_FPR10_LO, "fpr10.lo" },
1657 { PT_FPR11_HI, "fpr11.hi" },
1658 { PT_FPR11_LO, "fpr11.lo" },
1659 { PT_FPR12_HI, "fpr12.hi" },
1660 { PT_FPR12_LO, "fpr12.lo" },
1661 { PT_FPR13_HI, "fpr13.hi" },
1662 { PT_FPR13_LO, "fpr13.lo" },
1663 { PT_FPR14_HI, "fpr14.hi" },
1664 { PT_FPR14_LO, "fpr14.lo" },
1665 { PT_FPR15_HI, "fpr15.hi" },
1666 { PT_FPR15_LO, "fpr15.lo" },
1669 { PT_FPR0, "fpr0" },
1670 { PT_FPR1, "fpr1" },
1671 { PT_FPR2, "fpr2" },
1672 { PT_FPR3, "fpr3" },
1673 { PT_FPR4, "fpr4" },
1674 { PT_FPR5, "fpr5" },
1675 { PT_FPR6, "fpr6" },
1676 { PT_FPR7, "fpr7" },
1677 { PT_FPR8, "fpr8" },
1678 { PT_FPR9, "fpr9" },
1679 { PT_FPR10, "fpr10" },
1680 { PT_FPR11, "fpr11" },
1681 { PT_FPR12, "fpr12" },
1682 { PT_FPR13, "fpr13" },
1683 { PT_FPR14, "fpr14" },
1684 { PT_FPR15, "fpr15" },
1687 { PT_CR_10, "cr10" },
1688 { PT_CR_11, "cr11" },
1689 { PT_IEEE_IP, "ieee_exception_ip" },
1690 # elif defined(SPARC)
1691 /* XXX No support for these offsets yet. */
1692 # elif defined(HPPA)
1693 /* XXX No support for these offsets yet. */
1694 # elif defined(POWERPC)
1696 # define PT_ORIG_R3 34
1698 # define REGSIZE (sizeof(unsigned long))
1699 { REGSIZE*PT_R0, "r0" },
1700 { REGSIZE*PT_R1, "r1" },
1701 { REGSIZE*PT_R2, "r2" },
1702 { REGSIZE*PT_R3, "r3" },
1703 { REGSIZE*PT_R4, "r4" },
1704 { REGSIZE*PT_R5, "r5" },
1705 { REGSIZE*PT_R6, "r6" },
1706 { REGSIZE*PT_R7, "r7" },
1707 { REGSIZE*PT_R8, "r8" },
1708 { REGSIZE*PT_R9, "r9" },
1709 { REGSIZE*PT_R10, "r10" },
1710 { REGSIZE*PT_R11, "r11" },
1711 { REGSIZE*PT_R12, "r12" },
1712 { REGSIZE*PT_R13, "r13" },
1713 { REGSIZE*PT_R14, "r14" },
1714 { REGSIZE*PT_R15, "r15" },
1715 { REGSIZE*PT_R16, "r16" },
1716 { REGSIZE*PT_R17, "r17" },
1717 { REGSIZE*PT_R18, "r18" },
1718 { REGSIZE*PT_R19, "r19" },
1719 { REGSIZE*PT_R20, "r20" },
1720 { REGSIZE*PT_R21, "r21" },
1721 { REGSIZE*PT_R22, "r22" },
1722 { REGSIZE*PT_R23, "r23" },
1723 { REGSIZE*PT_R24, "r24" },
1724 { REGSIZE*PT_R25, "r25" },
1725 { REGSIZE*PT_R26, "r26" },
1726 { REGSIZE*PT_R27, "r27" },
1727 { REGSIZE*PT_R28, "r28" },
1728 { REGSIZE*PT_R29, "r29" },
1729 { REGSIZE*PT_R30, "r30" },
1730 { REGSIZE*PT_R31, "r31" },
1731 { REGSIZE*PT_NIP, "NIP" },
1732 { REGSIZE*PT_MSR, "MSR" },
1733 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1734 { REGSIZE*PT_CTR, "CTR" },
1735 { REGSIZE*PT_LNK, "LNK" },
1736 { REGSIZE*PT_XER, "XER" },
1737 { REGSIZE*PT_CCR, "CCR" },
1738 { REGSIZE*PT_FPR0, "FPR0" },
1740 # elif defined(ALPHA)
1806 # elif defined(IA64)
1807 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1808 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1809 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1810 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1811 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1812 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1813 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1814 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1815 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1816 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1817 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1818 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1819 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1820 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1821 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1822 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1823 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1824 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1825 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1826 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1827 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1828 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1829 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1830 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1831 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1832 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1833 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1834 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1835 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1836 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1837 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1838 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1840 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1841 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1842 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1843 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1844 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1845 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1846 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1847 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1848 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1849 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
1850 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1851 { PT_B4, "b4" }, { PT_B5, "b5" },
1852 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
1854 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1855 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
1856 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1857 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1858 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1859 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1860 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1861 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1862 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1863 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1864 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1865 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1866 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1867 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1868 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1869 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1870 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
1872 { PT_AR_CSD, "ar.csd" },
1875 { PT_AR_SSD, "ar.ssd" },
1877 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
1878 # elif defined(I386)
1890 { 4*ORIG_EAX, "4*ORIG_EAX" },
1894 { 4*UESP, "4*UESP" },
1896 # elif defined(X86_64)
1912 { 8*ORIG_RAX, "8*ORIG_RAX" },
1915 { 8*EFLAGS, "8*EFL" },
1918 # elif defined(M68K)
1919 { 4*PT_D1, "4*PT_D1" },
1920 { 4*PT_D2, "4*PT_D2" },
1921 { 4*PT_D3, "4*PT_D3" },
1922 { 4*PT_D4, "4*PT_D4" },
1923 { 4*PT_D5, "4*PT_D5" },
1924 { 4*PT_D6, "4*PT_D6" },
1925 { 4*PT_D7, "4*PT_D7" },
1926 { 4*PT_A0, "4*PT_A0" },
1927 { 4*PT_A1, "4*PT_A1" },
1928 { 4*PT_A2, "4*PT_A2" },
1929 { 4*PT_A3, "4*PT_A3" },
1930 { 4*PT_A4, "4*PT_A4" },
1931 { 4*PT_A5, "4*PT_A5" },
1932 { 4*PT_A6, "4*PT_A6" },
1933 { 4*PT_D0, "4*PT_D0" },
1934 { 4*PT_USP, "4*PT_USP" },
1935 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1936 { 4*PT_SR, "4*PT_SR" },
1937 { 4*PT_PC, "4*PT_PC" },
1939 { 4*REG_REG0, "4*REG_REG0" },
1940 { 4*(REG_REG0+1), "4*REG_REG1" },
1941 { 4*(REG_REG0+2), "4*REG_REG2" },
1942 { 4*(REG_REG0+3), "4*REG_REG3" },
1943 { 4*(REG_REG0+4), "4*REG_REG4" },
1944 { 4*(REG_REG0+5), "4*REG_REG5" },
1945 { 4*(REG_REG0+6), "4*REG_REG6" },
1946 { 4*(REG_REG0+7), "4*REG_REG7" },
1947 { 4*(REG_REG0+8), "4*REG_REG8" },
1948 { 4*(REG_REG0+9), "4*REG_REG9" },
1949 { 4*(REG_REG0+10), "4*REG_REG10" },
1950 { 4*(REG_REG0+11), "4*REG_REG11" },
1951 { 4*(REG_REG0+12), "4*REG_REG12" },
1952 { 4*(REG_REG0+13), "4*REG_REG13" },
1953 { 4*(REG_REG0+14), "4*REG_REG14" },
1954 { 4*REG_REG15, "4*REG_REG15" },
1955 { 4*REG_PC, "4*REG_PC" },
1956 { 4*REG_PR, "4*REG_PR" },
1957 { 4*REG_SR, "4*REG_SR" },
1958 { 4*REG_GBR, "4*REG_GBR" },
1959 { 4*REG_MACH, "4*REG_MACH" },
1960 { 4*REG_MACL, "4*REG_MACL" },
1961 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1962 { 4*REG_FPUL, "4*REG_FPUL" },
1963 { 4*REG_FPREG0, "4*REG_FPREG0" },
1964 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1965 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1966 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1967 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1968 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1969 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1970 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1971 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1972 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1973 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1974 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1975 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1976 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1977 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1978 { 4*REG_FPREG15, "4*REG_FPREG15" },
1980 { 4*REG_XDREG0, "4*REG_XDREG0" },
1981 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1982 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1983 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1984 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1985 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1986 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1987 { 4*REG_XDREG14, "4*REG_XDREG14" },
1989 { 4*REG_FPSCR, "4*REG_FPSCR" },
1990 # elif defined(SH64)
1995 { 16, "syscall no.(L)" },
1996 { 20, "syscall_no.(U)" },
2139 /* This entry is in case pt_regs contains dregs (depends on
2140 the kernel build options). */
2141 { uoff(regs), "offsetof(struct user, regs)" },
2142 { uoff(fpu), "offsetof(struct user, fpu)" },
2144 { uoff(regs.ARM_r0), "r0" },
2145 { uoff(regs.ARM_r1), "r1" },
2146 { uoff(regs.ARM_r2), "r2" },
2147 { uoff(regs.ARM_r3), "r3" },
2148 { uoff(regs.ARM_r4), "r4" },
2149 { uoff(regs.ARM_r5), "r5" },
2150 { uoff(regs.ARM_r6), "r6" },
2151 { uoff(regs.ARM_r7), "r7" },
2152 { uoff(regs.ARM_r8), "r8" },
2153 { uoff(regs.ARM_r9), "r9" },
2154 { uoff(regs.ARM_r10), "r10" },
2155 { uoff(regs.ARM_fp), "fp" },
2156 { uoff(regs.ARM_ip), "ip" },
2157 { uoff(regs.ARM_sp), "sp" },
2158 { uoff(regs.ARM_lr), "lr" },
2159 { uoff(regs.ARM_pc), "pc" },
2160 { uoff(regs.ARM_cpsr), "cpsr" },
2161 # elif defined(AVR32)
2162 { uoff(regs.sr), "sr" },
2163 { uoff(regs.pc), "pc" },
2164 { uoff(regs.lr), "lr" },
2165 { uoff(regs.sp), "sp" },
2166 { uoff(regs.r12), "r12" },
2167 { uoff(regs.r11), "r11" },
2168 { uoff(regs.r10), "r10" },
2169 { uoff(regs.r9), "r9" },
2170 { uoff(regs.r8), "r8" },
2171 { uoff(regs.r7), "r7" },
2172 { uoff(regs.r6), "r6" },
2173 { uoff(regs.r5), "r5" },
2174 { uoff(regs.r4), "r4" },
2175 { uoff(regs.r3), "r3" },
2176 { uoff(regs.r2), "r2" },
2177 { uoff(regs.r1), "r1" },
2178 { uoff(regs.r0), "r0" },
2179 { uoff(regs.r12_orig), "orig_r12" },
2180 # elif defined(MIPS)
2252 # elif defined(TILE)
2253 { PTREGS_OFFSET_REG(0), "r0" },
2254 { PTREGS_OFFSET_REG(1), "r1" },
2255 { PTREGS_OFFSET_REG(2), "r2" },
2256 { PTREGS_OFFSET_REG(3), "r3" },
2257 { PTREGS_OFFSET_REG(4), "r4" },
2258 { PTREGS_OFFSET_REG(5), "r5" },
2259 { PTREGS_OFFSET_REG(6), "r6" },
2260 { PTREGS_OFFSET_REG(7), "r7" },
2261 { PTREGS_OFFSET_REG(8), "r8" },
2262 { PTREGS_OFFSET_REG(9), "r9" },
2263 { PTREGS_OFFSET_REG(10), "r10" },
2264 { PTREGS_OFFSET_REG(11), "r11" },
2265 { PTREGS_OFFSET_REG(12), "r12" },
2266 { PTREGS_OFFSET_REG(13), "r13" },
2267 { PTREGS_OFFSET_REG(14), "r14" },
2268 { PTREGS_OFFSET_REG(15), "r15" },
2269 { PTREGS_OFFSET_REG(16), "r16" },
2270 { PTREGS_OFFSET_REG(17), "r17" },
2271 { PTREGS_OFFSET_REG(18), "r18" },
2272 { PTREGS_OFFSET_REG(19), "r19" },
2273 { PTREGS_OFFSET_REG(20), "r20" },
2274 { PTREGS_OFFSET_REG(21), "r21" },
2275 { PTREGS_OFFSET_REG(22), "r22" },
2276 { PTREGS_OFFSET_REG(23), "r23" },
2277 { PTREGS_OFFSET_REG(24), "r24" },
2278 { PTREGS_OFFSET_REG(25), "r25" },
2279 { PTREGS_OFFSET_REG(26), "r26" },
2280 { PTREGS_OFFSET_REG(27), "r27" },
2281 { PTREGS_OFFSET_REG(28), "r28" },
2282 { PTREGS_OFFSET_REG(29), "r29" },
2283 { PTREGS_OFFSET_REG(30), "r30" },
2284 { PTREGS_OFFSET_REG(31), "r31" },
2285 { PTREGS_OFFSET_REG(32), "r32" },
2286 { PTREGS_OFFSET_REG(33), "r33" },
2287 { PTREGS_OFFSET_REG(34), "r34" },
2288 { PTREGS_OFFSET_REG(35), "r35" },
2289 { PTREGS_OFFSET_REG(36), "r36" },
2290 { PTREGS_OFFSET_REG(37), "r37" },
2291 { PTREGS_OFFSET_REG(38), "r38" },
2292 { PTREGS_OFFSET_REG(39), "r39" },
2293 { PTREGS_OFFSET_REG(40), "r40" },
2294 { PTREGS_OFFSET_REG(41), "r41" },
2295 { PTREGS_OFFSET_REG(42), "r42" },
2296 { PTREGS_OFFSET_REG(43), "r43" },
2297 { PTREGS_OFFSET_REG(44), "r44" },
2298 { PTREGS_OFFSET_REG(45), "r45" },
2299 { PTREGS_OFFSET_REG(46), "r46" },
2300 { PTREGS_OFFSET_REG(47), "r47" },
2301 { PTREGS_OFFSET_REG(48), "r48" },
2302 { PTREGS_OFFSET_REG(49), "r49" },
2303 { PTREGS_OFFSET_REG(50), "r50" },
2304 { PTREGS_OFFSET_REG(51), "r51" },
2305 { PTREGS_OFFSET_REG(52), "r52" },
2306 { PTREGS_OFFSET_TP, "tp" },
2307 { PTREGS_OFFSET_SP, "sp" },
2308 { PTREGS_OFFSET_LR, "lr" },
2309 { PTREGS_OFFSET_PC, "pc" },
2310 { PTREGS_OFFSET_EX1, "ex1" },
2311 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2312 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2313 { PTREGS_OFFSET_FLAGS, "flags" },
2316 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2317 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2318 { 4*PT_R13, "4*PT_R13" },
2319 { 4*PT_R12, "4*PT_R12" },
2320 { 4*PT_R11, "4*PT_R11" },
2321 { 4*PT_R10, "4*PT_R10" },
2322 { 4*PT_R9, "4*PT_R9" },
2323 { 4*PT_R8, "4*PT_R8" },
2324 { 4*PT_R7, "4*PT_R7" },
2325 { 4*PT_R6, "4*PT_R6" },
2326 { 4*PT_R5, "4*PT_R5" },
2327 { 4*PT_R4, "4*PT_R4" },
2328 { 4*PT_R3, "4*PT_R3" },
2329 { 4*PT_R2, "4*PT_R2" },
2330 { 4*PT_R1, "4*PT_R1" },
2331 { 4*PT_R0, "4*PT_R0" },
2332 { 4*PT_MOF, "4*PT_MOF" },
2333 { 4*PT_DCCR, "4*PT_DCCR" },
2334 { 4*PT_SRP, "4*PT_SRP" },
2335 { 4*PT_IRP, "4*PT_IRP" },
2336 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2337 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2338 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2339 { 4*PT_USP, "4*PT_USP" },
2342 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2343 { 4*PT_R0, "4*PT_R0" },
2344 { 4*PT_R1, "4*PT_R1" },
2345 { 4*PT_R2, "4*PT_R2" },
2346 { 4*PT_R3, "4*PT_R3" },
2347 { 4*PT_R4, "4*PT_R4" },
2348 { 4*PT_R5, "4*PT_R5" },
2349 { 4*PT_R6, "4*PT_R6" },
2350 { 4*PT_R7, "4*PT_R7" },
2351 { 4*PT_R8, "4*PT_R8" },
2352 { 4*PT_R9, "4*PT_R9" },
2353 { 4*PT_R10, "4*PT_R10" },
2354 { 4*PT_R11, "4*PT_R11" },
2355 { 4*PT_R12, "4*PT_R12" },
2356 { 4*PT_R13, "4*PT_R13" },
2357 { 4*PT_ACR, "4*PT_ACR" },
2358 { 4*PT_SRS, "4*PT_SRS" },
2359 { 4*PT_MOF, "4*PT_MOF" },
2360 { 4*PT_SPC, "4*PT_SPC" },
2361 { 4*PT_CCS, "4*PT_CCS" },
2362 { 4*PT_SRP, "4*PT_SRP" },
2363 { 4*PT_ERP, "4*PT_ERP" },
2364 { 4*PT_EXS, "4*PT_EXS" },
2365 { 4*PT_EDA, "4*PT_EDA" },
2366 { 4*PT_USP, "4*PT_USP" },
2367 { 4*PT_PPC, "4*PT_PPC" },
2368 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2369 { 4*PT_BP+4, "4*PT_BP+4" },
2370 { 4*PT_BP+8, "4*PT_BP+8" },
2371 { 4*PT_BP+12, "4*PT_BP+12" },
2372 { 4*PT_BP+16, "4*PT_BP+16" },
2373 { 4*PT_BP+20, "4*PT_BP+20" },
2374 { 4*PT_BP+24, "4*PT_BP+24" },
2375 { 4*PT_BP+28, "4*PT_BP+28" },
2376 { 4*PT_BP+32, "4*PT_BP+32" },
2377 { 4*PT_BP+36, "4*PT_BP+36" },
2378 { 4*PT_BP+40, "4*PT_BP+40" },
2379 { 4*PT_BP+44, "4*PT_BP+44" },
2380 { 4*PT_BP+48, "4*PT_BP+48" },
2381 { 4*PT_BP+52, "4*PT_BP+52" },
2382 { 4*PT_BP+56, "4*PT_BP+56" },
2385 { PT_GPR(0), "r0" },
2386 { PT_GPR(1), "r1" },
2387 { PT_GPR(2), "r2" },
2388 { PT_GPR(3), "r3" },
2389 { PT_GPR(4), "r4" },
2390 { PT_GPR(5), "r5" },
2391 { PT_GPR(6), "r6" },
2392 { PT_GPR(7), "r7" },
2393 { PT_GPR(8), "r8" },
2394 { PT_GPR(9), "r9" },
2395 { PT_GPR(10), "r10" },
2396 { PT_GPR(11), "r11" },
2397 { PT_GPR(12), "r12" },
2398 { PT_GPR(13), "r13" },
2399 { PT_GPR(14), "r14" },
2400 { PT_GPR(15), "r15" },
2401 { PT_GPR(16), "r16" },
2402 { PT_GPR(17), "r17" },
2403 { PT_GPR(18), "r18" },
2404 { PT_GPR(19), "r19" },
2405 { PT_GPR(20), "r20" },
2406 { PT_GPR(21), "r21" },
2407 { PT_GPR(22), "r22" },
2408 { PT_GPR(23), "r23" },
2409 { PT_GPR(24), "r24" },
2410 { PT_GPR(25), "r25" },
2411 { PT_GPR(26), "r26" },
2412 { PT_GPR(27), "r27" },
2413 { PT_GPR(28), "r28" },
2414 { PT_GPR(29), "r29" },
2415 { PT_GPR(30), "r30" },
2416 { PT_GPR(31), "r31" },
2418 { PT_MSR, "rmsr", },
2419 { PT_EAR, "rear", },
2420 { PT_ESR, "resr", },
2421 { PT_FSR, "rfsr", },
2422 { PT_KERNEL_MODE, "kernel_mode", },
2425 # if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \
2426 && !defined(ALPHA) && !defined(IA64) \
2427 && !defined(CRISV10) && !defined(CRISV32) && !defined(MICROBLAZE)
2428 # if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(AVR32) && !defined(BFIN) && !defined(TILE)
2429 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2431 # if defined(I386) || defined(X86_64)
2432 { uoff(i387), "offsetof(struct user, i387)" },
2435 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2437 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2438 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2439 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2440 # if !defined(SPARC64)
2441 { uoff(start_code), "offsetof(struct user, start_code)" },
2443 # if defined(AVR32) || defined(SH64)
2444 { uoff(start_data), "offsetof(struct user, start_data)" },
2446 # if !defined(SPARC64)
2447 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2449 { uoff(signal), "offsetof(struct user, signal)" },
2450 # if !defined(AVR32) && !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SH) && !defined(SH64) && !defined(SPARC64) && !defined(TILE)
2451 { uoff(reserved), "offsetof(struct user, reserved)" },
2453 # if !defined(SPARC64)
2454 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2456 # if !defined(ARM) && !defined(AVR32) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) && !defined(BFIN) && !defined(TILE)
2457 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2459 { uoff(magic), "offsetof(struct user, magic)" },
2460 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2461 # if defined(I386) || defined(X86_64)
2462 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
2464 # endif /* !defined(many arches) */
2468 { sizeof(struct user), "sizeof(struct user)" },
2474 sys_ptrace(struct tcb *tcp)
2476 const struct xlat *x;
2479 if (entering(tcp)) {
2480 printxval(ptrace_cmds, tcp->u_arg[0],
2483 tprintf(", %lu, ", tcp->u_arg[1]);
2484 addr = tcp->u_arg[2];
2485 if (tcp->u_arg[0] == PTRACE_PEEKUSER
2486 || tcp->u_arg[0] == PTRACE_POKEUSER) {
2487 for (x = struct_user_offsets; x->str; x++) {
2492 tprintf("%#lx, ", addr);
2493 else if (x->val > addr && x != struct_user_offsets) {
2495 tprintf("%s + %ld, ", x->str, addr - x->val);
2498 tprintf("%s, ", x->str);
2501 tprintf("%#lx, ", tcp->u_arg[2]);
2502 switch (tcp->u_arg[0]) {
2504 case PTRACE_PEEKDATA:
2505 case PTRACE_PEEKTEXT:
2506 case PTRACE_PEEKUSER:
2510 case PTRACE_SINGLESTEP:
2511 case PTRACE_SYSCALL:
2513 printsignal(tcp->u_arg[3]);
2515 # ifdef PTRACE_SETOPTIONS
2516 case PTRACE_SETOPTIONS:
2517 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2520 # ifdef PTRACE_SETSIGINFO
2521 case PTRACE_SETSIGINFO: {
2525 else if (syserror(tcp))
2526 tprintf("%#lx", tcp->u_arg[3]);
2527 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
2530 printsiginfo(&si, verbose(tcp));
2534 # ifdef PTRACE_GETSIGINFO
2535 case PTRACE_GETSIGINFO:
2536 /* Don't print anything, do it at syscall return. */
2540 tprintf("%#lx", tcp->u_arg[3]);
2544 switch (tcp->u_arg[0]) {
2545 case PTRACE_PEEKDATA:
2546 case PTRACE_PEEKTEXT:
2547 case PTRACE_PEEKUSER:
2551 printnum(tcp, tcp->u_arg[3], "%#lx");
2554 # ifdef PTRACE_GETSIGINFO
2555 case PTRACE_GETSIGINFO: {
2559 else if (syserror(tcp))
2560 tprintf("%#lx", tcp->u_arg[3]);
2561 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
2564 printsiginfo(&si, verbose(tcp));
2574 # ifndef FUTEX_CMP_REQUEUE
2575 # define FUTEX_CMP_REQUEUE 4
2577 # ifndef FUTEX_WAKE_OP
2578 # define FUTEX_WAKE_OP 5
2580 # ifndef FUTEX_LOCK_PI
2581 # define FUTEX_LOCK_PI 6
2582 # define FUTEX_UNLOCK_PI 7
2583 # define FUTEX_TRYLOCK_PI 8
2585 # ifndef FUTEX_WAIT_BITSET
2586 # define FUTEX_WAIT_BITSET 9
2588 # ifndef FUTEX_WAKE_BITSET
2589 # define FUTEX_WAKE_BITSET 10
2591 # ifndef FUTEX_WAIT_REQUEUE_PI
2592 # define FUTEX_WAIT_REQUEUE_PI 11
2594 # ifndef FUTEX_CMP_REQUEUE_PI
2595 # define FUTEX_CMP_REQUEUE_PI 12
2597 # ifndef FUTEX_PRIVATE_FLAG
2598 # define FUTEX_PRIVATE_FLAG 128
2600 # ifndef FUTEX_CLOCK_REALTIME
2601 # define FUTEX_CLOCK_REALTIME 256
2603 static const struct xlat futexops[] = {
2604 { FUTEX_WAIT, "FUTEX_WAIT" },
2605 { FUTEX_WAKE, "FUTEX_WAKE" },
2606 { FUTEX_FD, "FUTEX_FD" },
2607 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2608 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2609 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2610 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2611 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2612 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
2613 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2614 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
2615 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2616 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
2617 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2618 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2619 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2620 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2621 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2622 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2623 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2624 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2625 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
2626 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2627 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
2628 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2629 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2630 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2631 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2632 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2633 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI_PRIVATE|FUTEX_CLOCK_REALTIME" },
2636 # ifndef FUTEX_OP_SET
2637 # define FUTEX_OP_SET 0
2638 # define FUTEX_OP_ADD 1
2639 # define FUTEX_OP_OR 2
2640 # define FUTEX_OP_ANDN 3
2641 # define FUTEX_OP_XOR 4
2642 # define FUTEX_OP_CMP_EQ 0
2643 # define FUTEX_OP_CMP_NE 1
2644 # define FUTEX_OP_CMP_LT 2
2645 # define FUTEX_OP_CMP_LE 3
2646 # define FUTEX_OP_CMP_GT 4
2647 # define FUTEX_OP_CMP_GE 5
2649 static const struct xlat futexwakeops[] = {
2650 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2651 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2652 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2653 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2654 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2657 static const struct xlat futexwakecmps[] = {
2658 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2659 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2660 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2661 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2662 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2663 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2668 sys_futex(struct tcb *tcp)
2670 if (entering(tcp)) {
2671 long int cmd = tcp->u_arg[1] & 127;
2672 tprintf("%p, ", (void *) tcp->u_arg[0]);
2673 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2674 tprintf(", %ld", tcp->u_arg[2]);
2675 if (cmd == FUTEX_WAKE_BITSET)
2676 tprintf(", %lx", tcp->u_arg[5]);
2677 else if (cmd == FUTEX_WAIT) {
2679 printtv(tcp, tcp->u_arg[3]);
2680 } else if (cmd == FUTEX_WAIT_BITSET) {
2682 printtv(tcp, tcp->u_arg[3]);
2683 tprintf(", %lx", tcp->u_arg[5]);
2684 } else if (cmd == FUTEX_REQUEUE)
2685 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2686 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
2687 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2688 else if (cmd == FUTEX_WAKE_OP) {
2689 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2690 if ((tcp->u_arg[5] >> 28) & 8)
2691 tprints("FUTEX_OP_OPARG_SHIFT|");
2692 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2693 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2694 if ((tcp->u_arg[5] >> 24) & 8)
2695 tprints("FUTEX_OP_OPARG_SHIFT|");
2696 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2697 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
2698 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
2700 printtv(tcp, tcp->u_arg[3]);
2701 tprintf(", %p", (void *) tcp->u_arg[4]);
2708 print_affinitylist(struct tcb *tcp, long list, unsigned int len)
2711 unsigned long w, min_len;
2713 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2714 min_len = len - max_strlen * sizeof(w);
2717 for (; len >= sizeof(w) && len > min_len;
2718 len -= sizeof(w), list += sizeof(w)) {
2719 if (umove(tcp, list, &w) < 0)
2730 tprintf("%#lx", list);
2732 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2735 tprints(first ? "{}" : "}");
2740 sys_sched_setaffinity(struct tcb *tcp)
2742 if (entering(tcp)) {
2743 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2744 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2750 sys_sched_getaffinity(struct tcb *tcp)
2752 if (entering(tcp)) {
2753 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2755 if (tcp->u_rval == -1)
2756 tprintf("%#lx", tcp->u_arg[2]);
2758 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2763 static const struct xlat schedulers[] = {
2764 { SCHED_OTHER, "SCHED_OTHER" },
2765 { SCHED_RR, "SCHED_RR" },
2766 { SCHED_FIFO, "SCHED_FIFO" },
2771 sys_sched_getscheduler(struct tcb *tcp)
2773 if (entering(tcp)) {
2774 tprintf("%d", (int) tcp->u_arg[0]);
2775 } else if (! syserror(tcp)) {
2776 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
2777 if (tcp->auxstr != NULL)
2784 sys_sched_setscheduler(struct tcb *tcp)
2786 if (entering(tcp)) {
2787 struct sched_param p;
2788 tprintf("%d, ", (int) tcp->u_arg[0]);
2789 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2790 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2791 tprintf(", %#lx", tcp->u_arg[2]);
2793 tprintf(", { %d }", p.__sched_priority);
2799 sys_sched_getparam(struct tcb *tcp)
2801 if (entering(tcp)) {
2802 tprintf("%d, ", (int) tcp->u_arg[0]);
2804 struct sched_param p;
2805 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2806 tprintf("%#lx", tcp->u_arg[1]);
2808 tprintf("{ %d }", p.__sched_priority);
2814 sys_sched_setparam(struct tcb *tcp)
2816 if (entering(tcp)) {
2817 struct sched_param p;
2818 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2819 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2821 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2827 sys_sched_get_priority_min(struct tcb *tcp)
2829 if (entering(tcp)) {
2830 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2836 # include <asm/prctl.h>
2838 static const struct xlat archvals[] = {
2839 { ARCH_SET_GS, "ARCH_SET_GS" },
2840 { ARCH_SET_FS, "ARCH_SET_FS" },
2841 { ARCH_GET_FS, "ARCH_GET_FS" },
2842 { ARCH_GET_GS, "ARCH_GET_GS" },
2847 sys_arch_prctl(struct tcb *tcp)
2849 if (entering(tcp)) {
2850 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2851 if (tcp->u_arg[0] == ARCH_SET_GS
2852 || tcp->u_arg[0] == ARCH_SET_FS
2854 tprintf(", %#lx", tcp->u_arg[1]);
2857 if (tcp->u_arg[0] == ARCH_GET_GS
2858 || tcp->u_arg[0] == ARCH_GET_FS
2861 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2862 tprintf(", [%#lx]", v);
2864 tprintf(", %#lx", tcp->u_arg[1]);
2869 # endif /* X86_64 */
2873 sys_getcpu(struct tcb *tcp)
2877 if (tcp->u_arg[0] == 0)
2879 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2880 tprintf("%#lx, ", tcp->u_arg[0]);
2882 tprintf("[%u], ", u);
2883 if (tcp->u_arg[1] == 0)
2885 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2886 tprintf("%#lx, ", tcp->u_arg[1]);
2888 tprintf("[%u], ", u);
2889 tprintf("%#lx", tcp->u_arg[2]);
2895 sys_process_vm_readv(struct tcb *tcp)
2897 if (entering(tcp)) {
2899 tprintf("%ld, ", tcp->u_arg[0]);
2901 /* args 2,3: local iov,cnt */
2902 if (syserror(tcp)) {
2903 tprintf("%#lx, %lu",
2904 tcp->u_arg[1], tcp->u_arg[2]);
2906 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2909 /* args 4,5: remote iov,cnt */
2910 if (syserror(tcp)) {
2911 tprintf("%#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
2913 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2916 tprintf(", %lu", tcp->u_arg[5]);