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>
52 #include <machine/reg.h>
56 #include <sys/ptrace.h>
61 #ifndef PTRACE_PEEKUSR
62 # define PTRACE_PEEKUSR PTRACE_PEEKUSER
64 #ifndef PTRACE_POKEUSR
65 # define PTRACE_POKEUSR PTRACE_POKEUSER
69 #ifdef HAVE_LINUX_PTRACE_H
71 # ifdef HAVE_STRUCT_IA64_FPREG
72 # define ia64_fpreg XXX_ia64_fpreg
74 # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
75 # define pt_all_user_regs XXX_pt_all_user_regs
77 #include <linux/ptrace.h>
79 # undef pt_all_user_regs
82 #if defined (LINUX) && defined (SPARC64)
84 # undef PTRACE_GETREGS
85 # define PTRACE_GETREGS PTRACE_GETREGS64
86 # undef PTRACE_SETREGS
87 # define PTRACE_SETREGS PTRACE_SETREGS64
88 #endif /* LINUX && SPARC64 */
90 #ifdef HAVE_LINUX_FUTEX_H
91 # include <linux/futex.h>
103 # ifndef FUTEX_REQUEUE
104 # define FUTEX_REQUEUE 3
110 #include <asm/posix_types.h>
112 #define GETGROUPS_T __kernel_gid_t
114 #define GETGROUPS32_T __kernel_gid32_t
117 #if defined(LINUX) && defined(IA64)
118 # include <asm/ptrace_offsets.h>
119 # include <asm/rse.h>
123 # include <sys/prctl.h>
125 static const struct xlat prctl_options[] = {
127 { PR_MAXPROCS, "PR_MAXPROCS" },
130 { PR_ISBLOCKED, "PR_ISBLOCKED" },
132 #ifdef PR_SETSTACKSIZE
133 { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" },
135 #ifdef PR_GETSTACKSIZE
136 { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" },
139 { PR_MAXPPROCS, "PR_MAXPPROCS" },
141 #ifdef PR_UNBLKONEXEC
142 { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" },
145 { PR_ATOMICSIM, "PR_ATOMICSIM" },
148 { PR_SETEXITSIG, "PR_SETEXITSIG" },
151 { PR_RESIDENT, "PR_RESIDENT" },
154 { PR_ATTACHADDR, "PR_ATTACHADDR" },
157 { PR_DETACHADDR, "PR_DETACHADDR" },
160 { PR_TERMCHILD, "PR_TERMCHILD" },
163 { PR_GETSHMASK, "PR_GETSHMASK" },
166 { PR_GETNSHARE, "PR_GETNSHARE" },
169 { PR_COREPID, "PR_COREPID" },
171 #ifdef PR_ATTACHADDRPERM
172 { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" },
174 #ifdef PR_PTHREADEXIT
175 { PR_PTHREADEXIT, "PR_PTHREADEXIT" },
177 #ifdef PR_SET_PDEATHSIG
178 { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
180 #ifdef PR_GET_PDEATHSIG
181 { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
183 #ifdef PR_GET_DUMPABLE
184 { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" },
186 #ifdef PR_SET_DUMPABLE
187 { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" },
189 #ifdef PR_GET_UNALIGN
190 { PR_GET_UNALIGN, "PR_GET_UNALIGN" },
192 #ifdef PR_SET_UNALIGN
193 { PR_SET_UNALIGN, "PR_SET_UNALIGN" },
195 #ifdef PR_GET_KEEPCAPS
196 { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" },
198 #ifdef PR_SET_KEEPCAPS
199 { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" },
202 { PR_GET_FPEMU, "PR_GET_FPEMU" },
205 { PR_SET_FPEMU, "PR_SET_FPEMU" },
208 { PR_GET_FPEXC, "PR_GET_FPEXC" },
211 { PR_SET_FPEXC, "PR_SET_FPEXC" },
214 { PR_GET_TIMING, "PR_GET_TIMING" },
217 { PR_SET_TIMING, "PR_SET_TIMING" },
220 { PR_SET_NAME, "PR_SET_NAME" },
223 { PR_GET_NAME, "PR_GET_NAME" },
226 { PR_GET_ENDIAN, "PR_GET_ENDIAN" },
229 { PR_SET_ENDIAN, "PR_SET_ENDIAN" },
231 #ifdef PR_GET_SECCOMP
232 { PR_GET_SECCOMP, "PR_GET_SECCOMP" },
234 #ifdef PR_SET_SECCOMP
235 { PR_SET_SECCOMP, "PR_SET_SECCOMP" },
238 { PR_GET_TSC, "PR_GET_TSC" },
241 { PR_SET_TSC, "PR_SET_TSC" },
243 #ifdef PR_GET_SECUREBITS
244 { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" },
246 #ifdef PR_SET_SECUREBITS
247 { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" },
254 unalignctl_string(unsigned int ctl)
259 #ifdef PR_UNALIGN_NOPRINT
260 case PR_UNALIGN_NOPRINT:
263 #ifdef PR_UNALIGN_SIGBUS
264 case PR_UNALIGN_SIGBUS:
270 sprintf(buf, "%x", ctl);
276 sys_prctl(struct tcb *tcp)
281 printxval(prctl_options, tcp->u_arg[0], "PR_???");
282 switch (tcp->u_arg[0]) {
287 #ifdef PR_SET_PDEATHSIG
288 case PR_SET_PDEATHSIG:
289 tprintf(", %lu", tcp->u_arg[1]);
292 #ifdef PR_GET_PDEATHSIG
293 case PR_GET_PDEATHSIG:
296 #ifdef PR_SET_DUMPABLE
297 case PR_SET_DUMPABLE:
298 tprintf(", %lu", tcp->u_arg[1]);
301 #ifdef PR_GET_DUMPABLE
302 case PR_GET_DUMPABLE:
305 #ifdef PR_SET_UNALIGN
307 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
310 #ifdef PR_GET_UNALIGN
312 tprintf(", %#lx", tcp->u_arg[1]);
315 #ifdef PR_SET_KEEPCAPS
316 case PR_SET_KEEPCAPS:
317 tprintf(", %lu", tcp->u_arg[1]);
320 #ifdef PR_GET_KEEPCAPS
321 case PR_GET_KEEPCAPS:
325 for (i = 1; i < tcp->u_nargs; i++)
326 tprintf(", %#lx", tcp->u_arg[i]);
330 switch (tcp->u_arg[0]) {
331 #ifdef PR_GET_PDEATHSIG
332 case PR_GET_PDEATHSIG:
333 if (umove(tcp, tcp->u_arg[1], &i) < 0)
334 tprintf(", %#lx", tcp->u_arg[1]);
336 tprintf(", {%u}", i);
339 #ifdef PR_GET_DUMPABLE
340 case PR_GET_DUMPABLE:
341 return RVAL_UDECIMAL;
343 #ifdef PR_GET_UNALIGN
345 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
347 tcp->auxstr = unalignctl_string(i);
350 #ifdef PR_GET_KEEPCAPS
351 case PR_GET_KEEPCAPS:
352 return RVAL_UDECIMAL;
360 #endif /* HAVE_PRCTL */
362 #if defined(FREEBSD) || defined(SUNOS4) || defined(SVR4)
364 sys_gethostid(struct tcb *tcp)
370 #endif /* FREEBSD || SUNOS4 || SVR4 */
373 sys_sethostname(struct tcb *tcp)
376 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
377 tprintf(", %lu", tcp->u_arg[1]);
382 #if defined(ALPHA) || defined(FREEBSD) || defined(SUNOS4) || defined(SVR4)
384 sys_gethostname(struct tcb *tcp)
388 tprintf("%#lx", tcp->u_arg[0]);
390 printpath(tcp, tcp->u_arg[0]);
391 tprintf(", %lu", tcp->u_arg[1]);
395 #endif /* ALPHA || FREEBSD || SUNOS4 || SVR4 */
398 sys_setdomainname(struct tcb *tcp)
401 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
402 tprintf(", %lu", tcp->u_arg[1]);
410 sys_getdomainname(struct tcb *tcp)
414 tprintf("%#lx", tcp->u_arg[0]);
416 printpath(tcp, tcp->u_arg[0]);
417 tprintf(", %lu", tcp->u_arg[1]);
424 sys_exit(struct tcb *tcp)
427 fprintf(stderr, "_exit returned!\n");
430 /* special case: we stop tracing this process, finish line now */
431 tprintf("%ld) ", tcp->u_arg[0]);
441 sys_fork(struct tcb *tcp)
443 if (exiting(tcp) && !syserror(tcp)) {
445 tcp->auxstr = "child process";
446 return RVAL_UDECIMAL | RVAL_STR;
455 sys_rfork(struct tcb *tcp)
458 tprintf("%ld", tcp->u_arg[0]);
460 else if (!syserror(tcp)) {
462 tcp->auxstr = "child process";
463 return RVAL_UDECIMAL | RVAL_STR;
472 internal_fork(struct tcb *tcp)
474 struct tcb *tcpchild;
478 if (known_scno(tcp) == SYS_rfork && !(tcp->u_arg[0]&RFPROC))
487 tcpchild = alloctcb(tcp->u_rval);
488 if (proc_open(tcpchild, 2) < 0)
490 tcpchild->flags |= TCB_STARTUP;
495 #else /* !USE_PROCFS */
499 /* defines copied from linux/sched.h since we can't include that
500 * ourselves (it conflicts with *lots* of libc includes)
502 #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
503 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
504 #define CLONE_FS 0x00000200 /* set if fs info shared between processes */
505 #define CLONE_FILES 0x00000400 /* set if open files shared between processes */
506 #define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
507 #define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
508 #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
509 #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
510 #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
511 #define CLONE_THREAD 0x00010000 /* Same thread group? */
512 #define CLONE_NEWNS 0x00020000 /* New namespace group? */
513 #define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
514 #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
515 #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
516 #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
517 #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
518 #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
519 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
520 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
521 #define CLONE_NEWIPC 0x08000000 /* New ipcs */
522 #define CLONE_NEWUSER 0x10000000 /* New user namespace */
523 #define CLONE_NEWPID 0x20000000 /* New pid namespace */
524 #define CLONE_NEWNET 0x40000000 /* New network namespace */
525 #define CLONE_IO 0x80000000 /* Clone io context */
527 static const struct xlat clone_flags[] = {
528 { CLONE_VM, "CLONE_VM" },
529 { CLONE_FS, "CLONE_FS" },
530 { CLONE_FILES, "CLONE_FILES" },
531 { CLONE_SIGHAND, "CLONE_SIGHAND" },
532 { CLONE_IDLETASK, "CLONE_IDLETASK"},
533 { CLONE_PTRACE, "CLONE_PTRACE" },
534 { CLONE_VFORK, "CLONE_VFORK" },
535 { CLONE_PARENT, "CLONE_PARENT" },
536 { CLONE_THREAD, "CLONE_THREAD" },
537 { CLONE_NEWNS, "CLONE_NEWNS" },
538 { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
539 { CLONE_SETTLS, "CLONE_SETTLS" },
540 { CLONE_PARENT_SETTID,"CLONE_PARENT_SETTID" },
541 { CLONE_CHILD_CLEARTID,"CLONE_CHILD_CLEARTID" },
542 { CLONE_UNTRACED, "CLONE_UNTRACED" },
543 { CLONE_CHILD_SETTID,"CLONE_CHILD_SETTID" },
544 { CLONE_STOPPED, "CLONE_STOPPED" },
545 { CLONE_NEWUTS, "CLONE_NEWUTS" },
546 { CLONE_NEWIPC, "CLONE_NEWIPC" },
547 { CLONE_NEWUSER, "CLONE_NEWUSER" },
548 { CLONE_NEWPID, "CLONE_NEWPID" },
549 { CLONE_NEWNET, "CLONE_NEWNET" },
550 { CLONE_IO, "CLONE_IO" },
555 # include <asm/ldt.h>
556 # ifdef HAVE_STRUCT_USER_DESC
557 # define modify_ldt_ldt_s user_desc
559 extern void print_ldt_entry();
565 # define ARG_STACKSIZE (known_scno(tcp) == SYS_clone2 ? 2 : -1)
566 # define ARG_PTID (known_scno(tcp) == SYS_clone2 ? 3 : 2)
567 # define ARG_CTID (known_scno(tcp) == SYS_clone2 ? 4 : 3)
568 # define ARG_TLS (known_scno(tcp) == SYS_clone2 ? 5 : 4)
569 # elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
575 # elif defined X86_64 || defined ALPHA
590 sys_clone(struct tcb *tcp)
593 const char *sep = "|";
594 unsigned long flags = tcp->u_arg[ARG_FLAGS];
595 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
596 # ifdef ARG_STACKSIZE
597 if (ARG_STACKSIZE != -1)
598 tprintf("stack_size=%#lx, ",
599 tcp->u_arg[ARG_STACKSIZE]);
602 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
604 if ((flags & CSIGNAL) != 0)
605 tprintf("%s%s", sep, signame(flags & CSIGNAL));
606 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
607 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
609 if (flags & CLONE_PARENT_SETTID)
610 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
611 if (flags & CLONE_SETTLS) {
613 struct modify_ldt_ldt_s copy;
614 if (umove(tcp, tcp->u_arg[ARG_TLS], ©) != -1) {
615 tprintf(", {entry_number:%d, ",
620 print_ldt_entry(©);
624 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
626 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
627 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
633 sys_unshare(struct tcb *tcp)
636 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
642 sys_fork(struct tcb *tcp)
645 return RVAL_UDECIMAL;
650 change_syscall(struct tcb *tcp, int new)
654 /* Attempt to make vfork into fork, which we can follow. */
655 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0)
658 #elif defined(X86_64)
659 /* Attempt to make vfork into fork, which we can follow. */
660 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_RAX * 8), new) < 0)
663 #elif defined(POWERPC)
664 if (ptrace(PTRACE_POKEUSER, tcp->pid,
665 (char*)(sizeof(unsigned long)*PT_R0), new) < 0)
668 #elif defined(S390) || defined(S390X)
669 /* s390 linux after 2.4.7 has a hook in entry.S to allow this */
670 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR2), new) < 0)
674 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_ORIG_D0), new) < 0)
677 #elif defined(SPARC) || defined(SPARC64)
679 if (ptrace(PTRACE_GETREGS, tcp->pid, (char*)®s, 0) < 0)
681 regs.u_regs[U_REG_G1] = new;
682 if (ptrace(PTRACE_SETREGS, tcp->pid, (char*)®s, 0) < 0)
686 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new) < 0)
690 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new) < 0)
694 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_R8), new) < 0)
698 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_P0), new) < 0)
705 break; /* x86 SYS_fork */
710 fprintf(stderr, "%s: unexpected syscall %d\n",
714 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R1), new) < 0)
716 } else if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R15), new) < 0)
720 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR20), new) < 0)
724 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*(REG_REG0+3)), new) < 0)
728 /* Top half of reg encodes the no. of args n as 0x1n.
729 Assume 0 args as kernel never actually checks... */
730 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_SYSCALL),
734 #elif defined(CRISV10) || defined(CRISV32)
735 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R9), new) < 0)
739 /* Some kernels support this, some (pre-2.6.16 or so) don't. */
740 # ifndef PTRACE_SET_SYSCALL
741 # define PTRACE_SET_SYSCALL 23
744 if (ptrace(PTRACE_SET_SYSCALL, tcp->pid, 0, new & 0xffff) != 0)
749 if (ptrace(PTRACE_POKEUSER, tcp->pid,
750 (char*)PTREGS_OFFSET_REG(0),
754 #elif defined(MICROBLAZE)
755 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new) < 0)
759 #warning Do not know how to handle change_syscall for this architecture
760 #endif /* architecture */
768 internal_fork(struct tcb *tcp)
770 if ((ptrace_setoptions
771 & (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
772 == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
780 * We won't see the new child if clone is called with
781 * CLONE_UNTRACED, so we keep the same logic with that option
782 * and don't trace it.
784 if ((sysent[tcp->scno].sys_func == sys_clone) &&
785 (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED))
789 if (tcp->flags & TCB_BPTSET)
798 internal_fork(struct tcb *tcp)
800 struct tcb *tcpchild;
805 if (known_scno(tcp) == SYS_vfork) {
806 /* Attempt to make vfork into fork, which we can follow. */
807 if (change_syscall(tcp, SYS_fork) < 0)
821 int bpt = tcp->flags & TCB_BPTSET;
830 tcpchild = alloctcb(pid);
833 /* The child must have run before it can be attached. */
838 select(0, NULL, NULL, NULL, &tv);
840 if (ptrace(PTRACE_ATTACH, pid, (char *)1, 0) < 0) {
841 perror("PTRACE_ATTACH");
842 fprintf(stderr, "Too late?\n");
847 /* Try to catch the new process as soon as possible. */
850 for (i = 0; i < 1024; i++)
851 if (ptrace(PTRACE_ATTACH, pid, (char *) 1, 0) >= 0)
854 perror("PTRACE_ATTACH");
855 fprintf(stderr, "Too late?\n");
862 tcpchild->flags |= TCB_ATTACHED | TCB_STARTUP | TCB_IGNORE_ONE_SIGSTOP;
863 /* Child has BPT too, must be removed on first occasion */
865 tcpchild->flags |= TCB_BPTSET;
866 tcpchild->baddr = tcp->baddr;
867 memcpy(tcpchild->inst, tcp->inst,
868 sizeof tcpchild->inst);
871 fprintf(stderr, "Process %d attached\n", pid);
878 #endif /* !USE_PROCFS */
880 #if defined(SUNOS4) || defined(LINUX) || defined(FREEBSD)
883 sys_vfork(struct tcb *tcp)
886 return RVAL_UDECIMAL;
890 #endif /* SUNOS4 || LINUX || FREEBSD */
894 static char idstr[16];
897 sys_getpid(struct tcb *tcp)
900 sprintf(idstr, "ppid %lu", getrval2(tcp));
908 sys_getuid(struct tcb *tcp)
911 sprintf(idstr, "euid %lu", getrval2(tcp));
919 sys_getgid(struct tcb *tcp)
922 sprintf(idstr, "egid %lu", getrval2(tcp));
933 int sys_getuid(struct tcb *tcp)
936 tcp->u_rval = (uid_t) tcp->u_rval;
937 return RVAL_UDECIMAL;
940 int sys_setfsuid(struct tcb *tcp)
943 tprintf("%u", (uid_t) tcp->u_arg[0]);
945 tcp->u_rval = (uid_t) tcp->u_rval;
946 return RVAL_UDECIMAL;
950 sys_setuid(struct tcb *tcp)
953 tprintf("%u", (uid_t) tcp->u_arg[0]);
959 sys_setgid(struct tcb *tcp)
962 tprintf("%u", (gid_t) tcp->u_arg[0]);
968 sys_getresuid(struct tcb *tcp)
973 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
974 tcp->u_arg[1], tcp->u_arg[2]);
976 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
977 tprintf("%#lx, ", tcp->u_arg[0]);
979 tprintf("[%lu], ", (unsigned long) uid);
980 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
981 tprintf("%#lx, ", tcp->u_arg[1]);
983 tprintf("[%lu], ", (unsigned long) uid);
984 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
985 tprintf("%#lx", tcp->u_arg[2]);
987 tprintf("[%lu]", (unsigned long) uid);
994 sys_getresgid(struct tcb *tcp)
999 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
1000 tcp->u_arg[1], tcp->u_arg[2]);
1002 if (umove(tcp, tcp->u_arg[0], &gid) < 0)
1003 tprintf("%#lx, ", tcp->u_arg[0]);
1005 tprintf("[%lu], ", (unsigned long) gid);
1006 if (umove(tcp, tcp->u_arg[1], &gid) < 0)
1007 tprintf("%#lx, ", tcp->u_arg[1]);
1009 tprintf("[%lu], ", (unsigned long) gid);
1010 if (umove(tcp, tcp->u_arg[2], &gid) < 0)
1011 tprintf("%#lx", tcp->u_arg[2]);
1013 tprintf("[%lu]", (unsigned long) gid);
1022 sys_setreuid(struct tcb *tcp)
1024 if (entering(tcp)) {
1025 printuid("", tcp->u_arg[0]);
1026 printuid(", ", tcp->u_arg[1]);
1032 sys_setregid(struct tcb *tcp)
1034 if (entering(tcp)) {
1035 printuid("", tcp->u_arg[0]);
1036 printuid(", ", tcp->u_arg[1]);
1041 #if defined(LINUX) || defined(FREEBSD)
1043 sys_setresuid(struct tcb *tcp)
1045 if (entering(tcp)) {
1046 printuid("", tcp->u_arg[0]);
1047 printuid(", ", tcp->u_arg[1]);
1048 printuid(", ", tcp->u_arg[2]);
1053 sys_setresgid(struct tcb *tcp)
1055 if (entering(tcp)) {
1056 printuid("", tcp->u_arg[0]);
1057 printuid(", ", tcp->u_arg[1]);
1058 printuid(", ", tcp->u_arg[2]);
1063 #endif /* LINUX || FREEBSD */
1066 sys_setgroups(struct tcb *tcp)
1068 if (entering(tcp)) {
1069 unsigned long len, size, start, cur, end, abbrev_end;
1073 len = tcp->u_arg[0];
1074 tprintf("%lu, ", len);
1079 start = tcp->u_arg[1];
1084 size = len * sizeof(gid);
1086 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
1087 tprintf("%#lx", start);
1091 abbrev_end = start + max_strlen * sizeof(gid);
1092 if (abbrev_end < start)
1098 for (cur = start; cur < end; cur += sizeof(gid)) {
1101 if (cur >= abbrev_end) {
1105 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
1110 tprintf("%lu", (unsigned long) gid);
1114 tprintf(" %#lx", tcp->u_arg[1]);
1120 sys_getgroups(struct tcb *tcp)
1124 if (entering(tcp)) {
1125 len = tcp->u_arg[0];
1126 tprintf("%lu, ", len);
1128 unsigned long size, start, cur, end, abbrev_end;
1137 start = tcp->u_arg[1];
1142 if (tcp->u_arg[0] == 0) {
1143 tprintf("%#lx", start);
1146 size = len * sizeof(gid);
1148 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
1149 size / sizeof(gid) != len || end < start) {
1150 tprintf("%#lx", start);
1154 abbrev_end = start + max_strlen * sizeof(gid);
1155 if (abbrev_end < start)
1161 for (cur = start; cur < end; cur += sizeof(gid)) {
1164 if (cur >= abbrev_end) {
1168 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
1173 tprintf("%lu", (unsigned long) gid);
1177 tprintf(" %#lx", tcp->u_arg[1]);
1184 sys_setgroups32(struct tcb *tcp)
1186 if (entering(tcp)) {
1187 unsigned long len, size, start, cur, end, abbrev_end;
1191 len = tcp->u_arg[0];
1192 tprintf("%lu, ", len);
1197 start = tcp->u_arg[1];
1202 size = len * sizeof(gid);
1204 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
1205 tprintf("%#lx", start);
1209 abbrev_end = start + max_strlen * sizeof(gid);
1210 if (abbrev_end < start)
1216 for (cur = start; cur < end; cur += sizeof(gid)) {
1219 if (cur >= abbrev_end) {
1223 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
1228 tprintf("%lu", (unsigned long) gid);
1232 tprintf(" %#lx", tcp->u_arg[1]);
1238 sys_getgroups32(struct tcb *tcp)
1242 if (entering(tcp)) {
1243 len = tcp->u_arg[0];
1244 tprintf("%lu, ", len);
1246 unsigned long size, start, cur, end, abbrev_end;
1255 start = tcp->u_arg[1];
1260 size = len * sizeof(gid);
1262 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
1263 size / sizeof(gid) != len || end < start) {
1264 tprintf("%#lx", start);
1268 abbrev_end = start + max_strlen * sizeof(gid);
1269 if (abbrev_end < start)
1275 for (cur = start; cur < end; cur += sizeof(gid)) {
1278 if (cur >= abbrev_end) {
1282 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
1287 tprintf("%lu", (unsigned long) gid);
1291 tprintf(" %#lx", tcp->u_arg[1]);
1297 #if defined(ALPHA) || defined(SUNOS4) || defined(SVR4)
1299 sys_setpgrp(struct tcb *tcp)
1301 if (entering(tcp)) {
1303 tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]);
1308 #endif /* ALPHA || SUNOS4 || SVR4 */
1311 sys_getpgrp(struct tcb *tcp)
1313 if (entering(tcp)) {
1315 tprintf("%lu", tcp->u_arg[0]);
1322 sys_getsid(struct tcb *tcp)
1324 if (entering(tcp)) {
1325 tprintf("%lu", tcp->u_arg[0]);
1331 sys_setsid(struct tcb *tcp)
1337 sys_getpgid(struct tcb *tcp)
1339 if (entering(tcp)) {
1340 tprintf("%lu", tcp->u_arg[0]);
1346 sys_setpgid(struct tcb *tcp)
1348 if (entering(tcp)) {
1349 tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]);
1356 #include <sys/privilege.h>
1359 static const struct xlat procpriv_cmds[] = {
1360 { SETPRV, "SETPRV" },
1361 { CLRPRV, "CLRPRV" },
1362 { PUTPRV, "PUTPRV" },
1363 { GETPRV, "GETPRV" },
1364 { CNTPRV, "CNTPRV" },
1369 static const struct xlat procpriv_priv[] = {
1370 { P_OWNER, "P_OWNER" },
1371 { P_AUDIT, "P_AUDIT" },
1372 { P_COMPAT, "P_COMPAT" },
1373 { P_DACREAD, "P_DACREAD" },
1374 { P_DACWRITE, "P_DACWRITE" },
1376 { P_FILESYS, "P_FILESYS" },
1377 { P_MACREAD, "P_MACREAD" },
1378 { P_MACWRITE, "P_MACWRITE" },
1379 { P_MOUNT, "P_MOUNT" },
1380 { P_MULTIDIR, "P_MULTIDIR" },
1381 { P_SETPLEVEL, "P_SETPLEVEL" },
1382 { P_SETSPRIV, "P_SETSPRIV" },
1383 { P_SETUID, "P_SETUID" },
1384 { P_SYSOPS, "P_SYSOPS" },
1385 { P_SETUPRIV, "P_SETUPRIV" },
1386 { P_DRIVER, "P_DRIVER" },
1387 { P_RTIME, "P_RTIME" },
1388 { P_MACUPGRADE, "P_MACUPGRADE" },
1389 { P_FSYSRANGE, "P_FSYSRANGE" },
1390 { P_SETFLEVEL, "P_SETFLEVEL" },
1391 { P_AUDITWR, "P_AUDITWR" },
1392 { P_TSHAR, "P_TSHAR" },
1393 { P_PLOCK, "P_PLOCK" },
1394 { P_CORE, "P_CORE" },
1395 { P_LOADMOD, "P_LOADMOD" },
1396 { P_BIND, "P_BIND" },
1397 { P_ALLPRIVS, "P_ALLPRIVS" },
1402 static const struct xlat procpriv_type[] = {
1403 { PS_FIX, "PS_FIX" },
1404 { PS_INH, "PS_INH" },
1405 { PS_MAX, "PS_MAX" },
1406 { PS_WKG, "PS_WKG" },
1412 printpriv(struct tcb *tcp, long addr, int len, const struct xlat *opt)
1415 int max = verbose(tcp) ? ARRAY_SIZE(buf) : 10;
1416 int dots = len > max;
1419 if (len > max) len = max;
1422 umoven(tcp, addr, len * sizeof buf[0], (char *) buf) < 0)
1424 tprintf("%#lx", addr);
1430 for (i = 0; i < len; ++i) {
1433 if (i) tprints(", ");
1435 if ((t = xlookup(procpriv_type, buf[i] & PS_TYPE)) &&
1436 (p = xlookup(procpriv_priv, buf[i] & ~PS_TYPE)))
1438 tprintf("%s|%s", t, p);
1441 tprintf("%#lx", buf[i]);
1445 if (dots) tprints(" ...");
1452 sys_procpriv(struct tcb *tcp)
1454 if (entering(tcp)) {
1455 printxval(procpriv_cmds, tcp->u_arg[0], "???PRV");
1456 switch (tcp->u_arg[0]) {
1458 tprintf(", %#lx, %ld", tcp->u_arg[1], tcp->u_arg[2]);
1466 printpriv(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1467 tprintf(", %ld", tcp->u_arg[2]);
1470 else if (tcp->u_arg[0] == GETPRV) {
1471 if (syserror(tcp)) {
1472 tprintf(", %#lx, %ld", tcp->u_arg[1], tcp->u_arg[2]);
1476 printpriv(tcp, tcp->u_arg[1], tcp->u_rval);
1477 tprintf(", %ld", tcp->u_arg[2]);
1484 #endif /* UNIXWARE */
1488 printargv(struct tcb *tcp, long addr)
1493 char data[sizeof(long)];
1499 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
1500 if (umoven(tcp, addr, personality_wordsize[current_personality],
1502 tprintf("%#lx", addr);
1505 if (personality_wordsize[current_personality] == 4)
1510 printstr(tcp, cp.p64, -1);
1511 addr += personality_wordsize[current_personality];
1514 tprintf("%s...", sep);
1518 printargc(const char *fmt, struct tcb *tcp, long addr)
1523 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
1524 addr += sizeof(char *);
1526 tprintf(fmt, count, count == 1 ? "" : "s");
1529 #if defined(SPARC) || defined(SPARC64) || defined(SUNOS4)
1531 sys_execv(struct tcb *tcp)
1533 if (entering(tcp)) {
1534 printpath(tcp, tcp->u_arg[0]);
1536 tprintf(", %#lx", tcp->u_arg[1]);
1539 printargv(tcp, tcp->u_arg[1]);
1545 #endif /* SPARC || SPARC64 || SUNOS4 */
1548 sys_execve(struct tcb *tcp)
1550 if (entering(tcp)) {
1551 printpath(tcp, tcp->u_arg[0]);
1553 tprintf(", %#lx", tcp->u_arg[1]);
1556 printargv(tcp, tcp->u_arg[1]);
1560 tprintf(", %#lx", tcp->u_arg[2]);
1561 else if (abbrev(tcp))
1562 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
1565 printargv(tcp, tcp->u_arg[2]);
1574 int sys_rexecve(struct tcb *tcp)
1576 if (entering(tcp)) {
1578 tprintf(", %ld", tcp->u_arg[3]);
1585 #if defined SUNOS4 || (defined LINUX && defined TCB_WAITEXECVE)
1587 internal_exec(struct tcb *tcp)
1590 if (exiting(tcp) && !syserror(tcp) && followfork)
1593 # if defined LINUX && defined TCB_WAITEXECVE
1594 if (exiting(tcp) && syserror(tcp))
1595 tcp->flags &= ~TCB_WAITEXECVE;
1597 /* Maybe we have post-execve SIGTRAP suppressed? */
1598 if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC))
1599 tcp->flags |= TCB_WAITEXECVE; /* no */
1608 #define __WNOTHREAD 0x20000000
1611 #define __WALL 0x40000000
1614 #define __WCLONE 0x80000000
1618 static const struct xlat wait4_options[] = {
1619 { WNOHANG, "WNOHANG" },
1621 { WUNTRACED, "WUNTRACED" },
1624 { WEXITED, "WEXITED" },
1627 { WTRAPPED, "WTRAPPED" },
1630 { WSTOPPED, "WSTOPPED" },
1633 { WCONTINUED, "WCONTINUED" },
1636 { WNOWAIT, "WNOWAIT" },
1639 { __WCLONE, "__WCLONE" },
1642 { __WALL, "__WALL" },
1645 { __WNOTHREAD, "__WNOTHREAD" },
1650 #if !defined WCOREFLAG && defined WCOREFLG
1651 # define WCOREFLAG WCOREFLG
1654 # define WCOREFLAG 0x80
1657 # define WCOREDUMP(status) ((status) & 0200)
1662 #define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
1665 #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
1669 printstatus(int status)
1674 * Here is a tricky presentation problem. This solution
1675 * is still not entirely satisfactory but since there
1676 * are no wait status constructors it will have to do.
1678 if (WIFSTOPPED(status)) {
1679 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
1680 signame(WSTOPSIG(status)));
1681 status &= ~W_STOPCODE(WSTOPSIG(status));
1683 else if (WIFSIGNALED(status)) {
1684 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
1685 signame(WTERMSIG(status)),
1686 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
1687 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1689 else if (WIFEXITED(status)) {
1690 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
1691 WEXITSTATUS(status));
1693 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
1696 tprintf("[%#x]", status);
1703 tprintf(" | %#x]", status);
1709 printwaitn(struct tcb *tcp, int n, int bitness)
1716 if (entering(tcp)) {
1718 /* On Linux, kernel-side pid_t is typedef'ed to int
1719 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
1720 * pid argument to int on 64bit arches, producing,
1721 * for example, wait4(4294967295, ...) instead of -1
1722 * in strace. We have to use int here, not long.
1724 int pid = tcp->u_arg[0];
1725 tprintf("%d, ", pid);
1727 long pid = tcp->u_arg[0];
1728 # if SUPPORTED_PERSONALITIES > 1
1729 /* Sign-extend a 32-bit value when that's what it is. */
1730 if (personality_wordsize[current_personality] < sizeof pid)
1731 pid = (long) (int) pid;
1733 tprintf("%ld, ", pid);
1739 else if (syserror(tcp) || tcp->u_rval == 0)
1740 tprintf("%#lx", tcp->u_arg[1]);
1741 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
1747 printstatus(status);
1750 printflags(wait4_options, tcp->u_arg[2], "W???");
1757 else if (tcp->u_rval > 0) {
1760 printrusage32(tcp, tcp->u_arg[3]);
1763 printrusage(tcp, tcp->u_arg[3]);
1767 else if (tcp->u_rval > 0 && exited)
1768 printrusage(tcp, tcp->u_arg[3]);
1771 tprintf("%#lx", tcp->u_arg[3]);
1780 sys_wait(struct tcb *tcp)
1783 /* The library wrapper stuffs this into the user variable. */
1785 printstatus(getrval2(tcp));
1794 sys_wait(struct tcb *tcp)
1799 if (!syserror(tcp)) {
1800 if (umove(tcp, tcp->u_arg[0], &status) < 0)
1801 tprintf("%#lx", tcp->u_arg[0]);
1803 printstatus(status);
1811 sys_waitpid(struct tcb *tcp)
1813 return printwaitn(tcp, 3, 0);
1817 sys_wait4(struct tcb *tcp)
1819 return printwaitn(tcp, 4, 0);
1824 sys_osf_wait4(struct tcb *tcp)
1826 return printwaitn(tcp, 4, 1);
1830 #if defined SVR4 || defined LINUX
1832 static const struct xlat waitid_types[] = {
1835 { P_PPID, "P_PPID" },
1837 { P_PGID, "P_PGID" },
1852 { P_LWPID, "P_LWPID" },
1858 sys_waitid(struct tcb *tcp)
1862 if (entering(tcp)) {
1863 printxval(waitid_types, tcp->u_arg[0], "P_???");
1864 tprintf(", %ld, ", tcp->u_arg[1]);
1870 else if (syserror(tcp))
1871 tprintf("%#lx", tcp->u_arg[2]);
1872 else if (umove(tcp, tcp->u_arg[2], &si) < 0)
1875 printsiginfo(&si, verbose(tcp));
1878 printflags(wait4_options, tcp->u_arg[3], "W???");
1879 if (tcp->u_nargs > 4) {
1884 else if (tcp->u_error)
1885 tprintf("%#lx", tcp->u_arg[4]);
1887 printrusage(tcp, tcp->u_arg[4]);
1893 #endif /* SVR4 or LINUX */
1896 sys_alarm(struct tcb *tcp)
1899 tprintf("%lu", tcp->u_arg[0]);
1904 sys_uname(struct tcb *tcp)
1906 struct utsname uname;
1909 if (syserror(tcp) || !verbose(tcp))
1910 tprintf("%#lx", tcp->u_arg[0]);
1911 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
1913 else if (!abbrev(tcp)) {
1915 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1916 uname.sysname, uname.nodename);
1917 tprintf("release=\"%s\", version=\"%s\", ",
1918 uname.release, uname.version);
1919 tprintf("machine=\"%s\"", uname.machine);
1922 tprintf(", domainname=\"%s\"", uname.domainname);
1928 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1929 uname.sysname, uname.nodename);
1936 static const struct xlat ptrace_cmds[] = {
1938 { PTRACE_TRACEME, "PTRACE_TRACEME" },
1939 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1940 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1941 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1942 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1943 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1944 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
1945 { PTRACE_CONT, "PTRACE_CONT" },
1946 { PTRACE_KILL, "PTRACE_KILL" },
1947 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1948 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1949 { PTRACE_DETACH, "PTRACE_DETACH" },
1950 # ifdef PTRACE_GETREGS
1951 { PTRACE_GETREGS, "PTRACE_GETREGS" },
1953 # ifdef PTRACE_SETREGS
1954 { PTRACE_SETREGS, "PTRACE_SETREGS" },
1956 # ifdef PTRACE_GETFPREGS
1957 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
1959 # ifdef PTRACE_SETFPREGS
1960 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
1962 # ifdef PTRACE_GETFPXREGS
1963 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
1965 # ifdef PTRACE_SETFPXREGS
1966 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
1968 # ifdef PTRACE_GETVRREGS
1969 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
1971 # ifdef PTRACE_SETVRREGS
1972 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
1974 # ifdef PTRACE_SETOPTIONS
1975 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
1977 # ifdef PTRACE_GETEVENTMSG
1978 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
1980 # ifdef PTRACE_GETSIGINFO
1981 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
1983 # ifdef PTRACE_SETSIGINFO
1984 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
1986 # ifdef PTRACE_GETREGSET
1987 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
1989 # ifdef PTRACE_SETREGSET
1990 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
1992 # ifdef PTRACE_SET_SYSCALL
1993 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
1996 { PTRACE_READDATA, "PTRACE_READDATA" },
1997 { PTRACE_WRITEDATA, "PTRACE_WRITEDATA" },
1998 { PTRACE_READTEXT, "PTRACE_READTEXT" },
1999 { PTRACE_WRITETEXT, "PTRACE_WRITETEXT" },
2000 { PTRACE_GETFPAREGS, "PTRACE_GETFPAREGS" },
2001 { PTRACE_SETFPAREGS, "PTRACE_SETFPAREGS" },
2003 { PTRACE_GETWINDOW, "PTRACE_GETWINDOW" },
2004 { PTRACE_SETWINDOW, "PTRACE_SETWINDOW" },
2006 { PTRACE_22, "PTRACE_22" },
2007 { PTRACE_23, "PTRACE_3" },
2008 # endif /* !SPARC */
2009 # endif /* SUNOS4 */
2010 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
2012 { PTRACE_DUMPCORE, "PTRACE_DUMPCORE" },
2014 { PTRACE_SETWRBKPT, "PTRACE_SETWRBKPT" },
2015 { PTRACE_SETACBKPT, "PTRACE_SETACBKPT" },
2016 { PTRACE_CLRDR7, "PTRACE_CLRDR7" },
2018 { PTRACE_26, "PTRACE_26" },
2019 { PTRACE_27, "PTRACE_27" },
2020 { PTRACE_28, "PTRACE_28" },
2022 { PTRACE_GETUCODE, "PTRACE_GETUCODE" },
2023 # endif /* SUNOS4 */
2025 # else /* FREEBSD */
2027 { PT_TRACE_ME, "PT_TRACE_ME" },
2028 { PT_READ_I, "PT_READ_I" },
2029 { PT_READ_D, "PT_READ_D" },
2030 { PT_WRITE_I, "PT_WRITE_I" },
2031 { PT_WRITE_D, "PT_WRITE_D" },
2033 { PT_READ_U, "PT_READ_U" },
2035 { PT_CONTINUE, "PT_CONTINUE" },
2036 { PT_KILL, "PT_KILL" },
2037 { PT_STEP, "PT_STEP" },
2038 { PT_ATTACH, "PT_ATTACH" },
2039 { PT_DETACH, "PT_DETACH" },
2040 { PT_GETREGS, "PT_GETREGS" },
2041 { PT_SETREGS, "PT_SETREGS" },
2042 { PT_GETFPREGS, "PT_GETFPREGS" },
2043 { PT_SETFPREGS, "PT_SETFPREGS" },
2044 { PT_GETDBREGS, "PT_GETDBREGS" },
2045 { PT_SETDBREGS, "PT_SETDBREGS" },
2046 # endif /* FREEBSD */
2051 # ifdef PTRACE_SETOPTIONS
2052 static const struct xlat ptrace_setoptions_flags[] = {
2053 # ifdef PTRACE_O_TRACESYSGOOD
2054 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
2056 # ifdef PTRACE_O_TRACEFORK
2057 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
2059 # ifdef PTRACE_O_TRACEVFORK
2060 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
2062 # ifdef PTRACE_O_TRACECLONE
2063 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
2065 # ifdef PTRACE_O_TRACEEXEC
2066 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
2068 # ifdef PTRACE_O_TRACEVFORKDONE
2069 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
2071 # ifdef PTRACE_O_TRACEEXIT
2072 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
2076 # endif /* PTRACE_SETOPTIONS */
2077 # endif /* !FREEBSD */
2080 const struct xlat struct_user_offsets[] = {
2082 # if defined(S390) || defined(S390X)
2083 { PT_PSWMASK, "psw_mask" },
2084 { PT_PSWADDR, "psw_addr" },
2085 { PT_GPR0, "gpr0" },
2086 { PT_GPR1, "gpr1" },
2087 { PT_GPR2, "gpr2" },
2088 { PT_GPR3, "gpr3" },
2089 { PT_GPR4, "gpr4" },
2090 { PT_GPR5, "gpr5" },
2091 { PT_GPR6, "gpr6" },
2092 { PT_GPR7, "gpr7" },
2093 { PT_GPR8, "gpr8" },
2094 { PT_GPR9, "gpr9" },
2095 { PT_GPR10, "gpr10" },
2096 { PT_GPR11, "gpr11" },
2097 { PT_GPR12, "gpr12" },
2098 { PT_GPR13, "gpr13" },
2099 { PT_GPR14, "gpr14" },
2100 { PT_GPR15, "gpr15" },
2101 { PT_ACR0, "acr0" },
2102 { PT_ACR1, "acr1" },
2103 { PT_ACR2, "acr2" },
2104 { PT_ACR3, "acr3" },
2105 { PT_ACR4, "acr4" },
2106 { PT_ACR5, "acr5" },
2107 { PT_ACR6, "acr6" },
2108 { PT_ACR7, "acr7" },
2109 { PT_ACR8, "acr8" },
2110 { PT_ACR9, "acr9" },
2111 { PT_ACR10, "acr10" },
2112 { PT_ACR11, "acr11" },
2113 { PT_ACR12, "acr12" },
2114 { PT_ACR13, "acr13" },
2115 { PT_ACR14, "acr14" },
2116 { PT_ACR15, "acr15" },
2117 { PT_ORIGGPR2, "orig_gpr2" },
2120 { PT_FPR0_HI, "fpr0.hi" },
2121 { PT_FPR0_LO, "fpr0.lo" },
2122 { PT_FPR1_HI, "fpr1.hi" },
2123 { PT_FPR1_LO, "fpr1.lo" },
2124 { PT_FPR2_HI, "fpr2.hi" },
2125 { PT_FPR2_LO, "fpr2.lo" },
2126 { PT_FPR3_HI, "fpr3.hi" },
2127 { PT_FPR3_LO, "fpr3.lo" },
2128 { PT_FPR4_HI, "fpr4.hi" },
2129 { PT_FPR4_LO, "fpr4.lo" },
2130 { PT_FPR5_HI, "fpr5.hi" },
2131 { PT_FPR5_LO, "fpr5.lo" },
2132 { PT_FPR6_HI, "fpr6.hi" },
2133 { PT_FPR6_LO, "fpr6.lo" },
2134 { PT_FPR7_HI, "fpr7.hi" },
2135 { PT_FPR7_LO, "fpr7.lo" },
2136 { PT_FPR8_HI, "fpr8.hi" },
2137 { PT_FPR8_LO, "fpr8.lo" },
2138 { PT_FPR9_HI, "fpr9.hi" },
2139 { PT_FPR9_LO, "fpr9.lo" },
2140 { PT_FPR10_HI, "fpr10.hi" },
2141 { PT_FPR10_LO, "fpr10.lo" },
2142 { PT_FPR11_HI, "fpr11.hi" },
2143 { PT_FPR11_LO, "fpr11.lo" },
2144 { PT_FPR12_HI, "fpr12.hi" },
2145 { PT_FPR12_LO, "fpr12.lo" },
2146 { PT_FPR13_HI, "fpr13.hi" },
2147 { PT_FPR13_LO, "fpr13.lo" },
2148 { PT_FPR14_HI, "fpr14.hi" },
2149 { PT_FPR14_LO, "fpr14.lo" },
2150 { PT_FPR15_HI, "fpr15.hi" },
2151 { PT_FPR15_LO, "fpr15.lo" },
2154 { PT_FPR0, "fpr0" },
2155 { PT_FPR1, "fpr1" },
2156 { PT_FPR2, "fpr2" },
2157 { PT_FPR3, "fpr3" },
2158 { PT_FPR4, "fpr4" },
2159 { PT_FPR5, "fpr5" },
2160 { PT_FPR6, "fpr6" },
2161 { PT_FPR7, "fpr7" },
2162 { PT_FPR8, "fpr8" },
2163 { PT_FPR9, "fpr9" },
2164 { PT_FPR10, "fpr10" },
2165 { PT_FPR11, "fpr11" },
2166 { PT_FPR12, "fpr12" },
2167 { PT_FPR13, "fpr13" },
2168 { PT_FPR14, "fpr14" },
2169 { PT_FPR15, "fpr15" },
2172 { PT_CR_10, "cr10" },
2173 { PT_CR_11, "cr11" },
2174 { PT_IEEE_IP, "ieee_exception_ip" },
2175 # elif defined(SPARC)
2176 /* XXX No support for these offsets yet. */
2177 # elif defined(HPPA)
2178 /* XXX No support for these offsets yet. */
2179 # elif defined(POWERPC)
2181 # define PT_ORIG_R3 34
2183 # define REGSIZE (sizeof(unsigned long))
2184 { REGSIZE*PT_R0, "r0" },
2185 { REGSIZE*PT_R1, "r1" },
2186 { REGSIZE*PT_R2, "r2" },
2187 { REGSIZE*PT_R3, "r3" },
2188 { REGSIZE*PT_R4, "r4" },
2189 { REGSIZE*PT_R5, "r5" },
2190 { REGSIZE*PT_R6, "r6" },
2191 { REGSIZE*PT_R7, "r7" },
2192 { REGSIZE*PT_R8, "r8" },
2193 { REGSIZE*PT_R9, "r9" },
2194 { REGSIZE*PT_R10, "r10" },
2195 { REGSIZE*PT_R11, "r11" },
2196 { REGSIZE*PT_R12, "r12" },
2197 { REGSIZE*PT_R13, "r13" },
2198 { REGSIZE*PT_R14, "r14" },
2199 { REGSIZE*PT_R15, "r15" },
2200 { REGSIZE*PT_R16, "r16" },
2201 { REGSIZE*PT_R17, "r17" },
2202 { REGSIZE*PT_R18, "r18" },
2203 { REGSIZE*PT_R19, "r19" },
2204 { REGSIZE*PT_R20, "r20" },
2205 { REGSIZE*PT_R21, "r21" },
2206 { REGSIZE*PT_R22, "r22" },
2207 { REGSIZE*PT_R23, "r23" },
2208 { REGSIZE*PT_R24, "r24" },
2209 { REGSIZE*PT_R25, "r25" },
2210 { REGSIZE*PT_R26, "r26" },
2211 { REGSIZE*PT_R27, "r27" },
2212 { REGSIZE*PT_R28, "r28" },
2213 { REGSIZE*PT_R29, "r29" },
2214 { REGSIZE*PT_R30, "r30" },
2215 { REGSIZE*PT_R31, "r31" },
2216 { REGSIZE*PT_NIP, "NIP" },
2217 { REGSIZE*PT_MSR, "MSR" },
2218 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
2219 { REGSIZE*PT_CTR, "CTR" },
2220 { REGSIZE*PT_LNK, "LNK" },
2221 { REGSIZE*PT_XER, "XER" },
2222 { REGSIZE*PT_CCR, "CCR" },
2223 { REGSIZE*PT_FPR0, "FPR0" },
2225 # elif defined(ALPHA)
2291 # elif defined(IA64)
2292 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
2293 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
2294 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
2295 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
2296 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
2297 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
2298 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
2299 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
2300 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
2301 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
2302 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
2303 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
2304 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
2305 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
2306 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
2307 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
2308 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
2309 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
2310 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
2311 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
2312 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
2313 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
2314 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
2315 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
2316 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
2317 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
2318 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
2319 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
2320 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
2321 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
2322 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
2323 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
2325 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
2326 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
2327 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
2328 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
2329 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
2330 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
2331 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
2332 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
2333 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
2334 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
2335 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
2336 { PT_B4, "b4" }, { PT_B5, "b5" },
2337 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
2339 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
2340 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
2341 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
2342 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
2343 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
2344 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
2345 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
2346 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
2347 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
2348 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
2349 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
2350 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
2351 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
2352 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
2353 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
2354 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
2355 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
2357 { PT_AR_CSD, "ar.csd" },
2360 { PT_AR_SSD, "ar.ssd" },
2362 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
2363 # elif defined(I386)
2375 { 4*ORIG_EAX, "4*ORIG_EAX" },
2379 { 4*UESP, "4*UESP" },
2381 # elif defined(X86_64)
2397 { 8*ORIG_RAX, "8*ORIG_RAX" },
2400 { 8*EFLAGS, "8*EFL" },
2403 # elif defined(M68K)
2404 { 4*PT_D1, "4*PT_D1" },
2405 { 4*PT_D2, "4*PT_D2" },
2406 { 4*PT_D3, "4*PT_D3" },
2407 { 4*PT_D4, "4*PT_D4" },
2408 { 4*PT_D5, "4*PT_D5" },
2409 { 4*PT_D6, "4*PT_D6" },
2410 { 4*PT_D7, "4*PT_D7" },
2411 { 4*PT_A0, "4*PT_A0" },
2412 { 4*PT_A1, "4*PT_A1" },
2413 { 4*PT_A2, "4*PT_A2" },
2414 { 4*PT_A3, "4*PT_A3" },
2415 { 4*PT_A4, "4*PT_A4" },
2416 { 4*PT_A5, "4*PT_A5" },
2417 { 4*PT_A6, "4*PT_A6" },
2418 { 4*PT_D0, "4*PT_D0" },
2419 { 4*PT_USP, "4*PT_USP" },
2420 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
2421 { 4*PT_SR, "4*PT_SR" },
2422 { 4*PT_PC, "4*PT_PC" },
2424 { 4*REG_REG0, "4*REG_REG0" },
2425 { 4*(REG_REG0+1), "4*REG_REG1" },
2426 { 4*(REG_REG0+2), "4*REG_REG2" },
2427 { 4*(REG_REG0+3), "4*REG_REG3" },
2428 { 4*(REG_REG0+4), "4*REG_REG4" },
2429 { 4*(REG_REG0+5), "4*REG_REG5" },
2430 { 4*(REG_REG0+6), "4*REG_REG6" },
2431 { 4*(REG_REG0+7), "4*REG_REG7" },
2432 { 4*(REG_REG0+8), "4*REG_REG8" },
2433 { 4*(REG_REG0+9), "4*REG_REG9" },
2434 { 4*(REG_REG0+10), "4*REG_REG10" },
2435 { 4*(REG_REG0+11), "4*REG_REG11" },
2436 { 4*(REG_REG0+12), "4*REG_REG12" },
2437 { 4*(REG_REG0+13), "4*REG_REG13" },
2438 { 4*(REG_REG0+14), "4*REG_REG14" },
2439 { 4*REG_REG15, "4*REG_REG15" },
2440 { 4*REG_PC, "4*REG_PC" },
2441 { 4*REG_PR, "4*REG_PR" },
2442 { 4*REG_SR, "4*REG_SR" },
2443 { 4*REG_GBR, "4*REG_GBR" },
2444 { 4*REG_MACH, "4*REG_MACH" },
2445 { 4*REG_MACL, "4*REG_MACL" },
2446 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
2447 { 4*REG_FPUL, "4*REG_FPUL" },
2448 { 4*REG_FPREG0, "4*REG_FPREG0" },
2449 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
2450 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
2451 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
2452 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
2453 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
2454 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
2455 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
2456 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
2457 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
2458 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
2459 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
2460 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
2461 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
2462 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
2463 { 4*REG_FPREG15, "4*REG_FPREG15" },
2465 { 4*REG_XDREG0, "4*REG_XDREG0" },
2466 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
2467 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
2468 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
2469 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
2470 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
2471 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
2472 { 4*REG_XDREG14, "4*REG_XDREG14" },
2474 { 4*REG_FPSCR, "4*REG_FPSCR" },
2475 # elif defined(SH64)
2480 { 16, "syscall no.(L)" },
2481 { 20, "syscall_no.(U)" },
2624 /* This entry is in case pt_regs contains dregs (depends on
2625 the kernel build options). */
2626 { uoff(regs), "offsetof(struct user, regs)" },
2627 { uoff(fpu), "offsetof(struct user, fpu)" },
2629 { uoff(regs.ARM_r0), "r0" },
2630 { uoff(regs.ARM_r1), "r1" },
2631 { uoff(regs.ARM_r2), "r2" },
2632 { uoff(regs.ARM_r3), "r3" },
2633 { uoff(regs.ARM_r4), "r4" },
2634 { uoff(regs.ARM_r5), "r5" },
2635 { uoff(regs.ARM_r6), "r6" },
2636 { uoff(regs.ARM_r7), "r7" },
2637 { uoff(regs.ARM_r8), "r8" },
2638 { uoff(regs.ARM_r9), "r9" },
2639 { uoff(regs.ARM_r10), "r10" },
2640 { uoff(regs.ARM_fp), "fp" },
2641 { uoff(regs.ARM_ip), "ip" },
2642 { uoff(regs.ARM_sp), "sp" },
2643 { uoff(regs.ARM_lr), "lr" },
2644 { uoff(regs.ARM_pc), "pc" },
2645 { uoff(regs.ARM_cpsr), "cpsr" },
2646 # elif defined(AVR32)
2647 { uoff(regs.sr), "sr" },
2648 { uoff(regs.pc), "pc" },
2649 { uoff(regs.lr), "lr" },
2650 { uoff(regs.sp), "sp" },
2651 { uoff(regs.r12), "r12" },
2652 { uoff(regs.r11), "r11" },
2653 { uoff(regs.r10), "r10" },
2654 { uoff(regs.r9), "r9" },
2655 { uoff(regs.r8), "r8" },
2656 { uoff(regs.r7), "r7" },
2657 { uoff(regs.r6), "r6" },
2658 { uoff(regs.r5), "r5" },
2659 { uoff(regs.r4), "r4" },
2660 { uoff(regs.r3), "r3" },
2661 { uoff(regs.r2), "r2" },
2662 { uoff(regs.r1), "r1" },
2663 { uoff(regs.r0), "r0" },
2664 { uoff(regs.r12_orig), "orig_r12" },
2665 # elif defined(MIPS)
2737 # elif defined(TILE)
2738 { PTREGS_OFFSET_REG(0), "r0" },
2739 { PTREGS_OFFSET_REG(1), "r1" },
2740 { PTREGS_OFFSET_REG(2), "r2" },
2741 { PTREGS_OFFSET_REG(3), "r3" },
2742 { PTREGS_OFFSET_REG(4), "r4" },
2743 { PTREGS_OFFSET_REG(5), "r5" },
2744 { PTREGS_OFFSET_REG(6), "r6" },
2745 { PTREGS_OFFSET_REG(7), "r7" },
2746 { PTREGS_OFFSET_REG(8), "r8" },
2747 { PTREGS_OFFSET_REG(9), "r9" },
2748 { PTREGS_OFFSET_REG(10), "r10" },
2749 { PTREGS_OFFSET_REG(11), "r11" },
2750 { PTREGS_OFFSET_REG(12), "r12" },
2751 { PTREGS_OFFSET_REG(13), "r13" },
2752 { PTREGS_OFFSET_REG(14), "r14" },
2753 { PTREGS_OFFSET_REG(15), "r15" },
2754 { PTREGS_OFFSET_REG(16), "r16" },
2755 { PTREGS_OFFSET_REG(17), "r17" },
2756 { PTREGS_OFFSET_REG(18), "r18" },
2757 { PTREGS_OFFSET_REG(19), "r19" },
2758 { PTREGS_OFFSET_REG(20), "r20" },
2759 { PTREGS_OFFSET_REG(21), "r21" },
2760 { PTREGS_OFFSET_REG(22), "r22" },
2761 { PTREGS_OFFSET_REG(23), "r23" },
2762 { PTREGS_OFFSET_REG(24), "r24" },
2763 { PTREGS_OFFSET_REG(25), "r25" },
2764 { PTREGS_OFFSET_REG(26), "r26" },
2765 { PTREGS_OFFSET_REG(27), "r27" },
2766 { PTREGS_OFFSET_REG(28), "r28" },
2767 { PTREGS_OFFSET_REG(29), "r29" },
2768 { PTREGS_OFFSET_REG(30), "r30" },
2769 { PTREGS_OFFSET_REG(31), "r31" },
2770 { PTREGS_OFFSET_REG(32), "r32" },
2771 { PTREGS_OFFSET_REG(33), "r33" },
2772 { PTREGS_OFFSET_REG(34), "r34" },
2773 { PTREGS_OFFSET_REG(35), "r35" },
2774 { PTREGS_OFFSET_REG(36), "r36" },
2775 { PTREGS_OFFSET_REG(37), "r37" },
2776 { PTREGS_OFFSET_REG(38), "r38" },
2777 { PTREGS_OFFSET_REG(39), "r39" },
2778 { PTREGS_OFFSET_REG(40), "r40" },
2779 { PTREGS_OFFSET_REG(41), "r41" },
2780 { PTREGS_OFFSET_REG(42), "r42" },
2781 { PTREGS_OFFSET_REG(43), "r43" },
2782 { PTREGS_OFFSET_REG(44), "r44" },
2783 { PTREGS_OFFSET_REG(45), "r45" },
2784 { PTREGS_OFFSET_REG(46), "r46" },
2785 { PTREGS_OFFSET_REG(47), "r47" },
2786 { PTREGS_OFFSET_REG(48), "r48" },
2787 { PTREGS_OFFSET_REG(49), "r49" },
2788 { PTREGS_OFFSET_REG(50), "r50" },
2789 { PTREGS_OFFSET_REG(51), "r51" },
2790 { PTREGS_OFFSET_REG(52), "r52" },
2791 { PTREGS_OFFSET_TP, "tp" },
2792 { PTREGS_OFFSET_SP, "sp" },
2793 { PTREGS_OFFSET_LR, "lr" },
2794 { PTREGS_OFFSET_PC, "pc" },
2795 { PTREGS_OFFSET_EX1, "ex1" },
2796 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2797 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2798 { PTREGS_OFFSET_FLAGS, "flags" },
2801 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2802 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2803 { 4*PT_R13, "4*PT_R13" },
2804 { 4*PT_R12, "4*PT_R12" },
2805 { 4*PT_R11, "4*PT_R11" },
2806 { 4*PT_R10, "4*PT_R10" },
2807 { 4*PT_R9, "4*PT_R9" },
2808 { 4*PT_R8, "4*PT_R8" },
2809 { 4*PT_R7, "4*PT_R7" },
2810 { 4*PT_R6, "4*PT_R6" },
2811 { 4*PT_R5, "4*PT_R5" },
2812 { 4*PT_R4, "4*PT_R4" },
2813 { 4*PT_R3, "4*PT_R3" },
2814 { 4*PT_R2, "4*PT_R2" },
2815 { 4*PT_R1, "4*PT_R1" },
2816 { 4*PT_R0, "4*PT_R0" },
2817 { 4*PT_MOF, "4*PT_MOF" },
2818 { 4*PT_DCCR, "4*PT_DCCR" },
2819 { 4*PT_SRP, "4*PT_SRP" },
2820 { 4*PT_IRP, "4*PT_IRP" },
2821 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2822 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2823 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2824 { 4*PT_USP, "4*PT_USP" },
2827 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2828 { 4*PT_R0, "4*PT_R0" },
2829 { 4*PT_R1, "4*PT_R1" },
2830 { 4*PT_R2, "4*PT_R2" },
2831 { 4*PT_R3, "4*PT_R3" },
2832 { 4*PT_R4, "4*PT_R4" },
2833 { 4*PT_R5, "4*PT_R5" },
2834 { 4*PT_R6, "4*PT_R6" },
2835 { 4*PT_R7, "4*PT_R7" },
2836 { 4*PT_R8, "4*PT_R8" },
2837 { 4*PT_R9, "4*PT_R9" },
2838 { 4*PT_R10, "4*PT_R10" },
2839 { 4*PT_R11, "4*PT_R11" },
2840 { 4*PT_R12, "4*PT_R12" },
2841 { 4*PT_R13, "4*PT_R13" },
2842 { 4*PT_ACR, "4*PT_ACR" },
2843 { 4*PT_SRS, "4*PT_SRS" },
2844 { 4*PT_MOF, "4*PT_MOF" },
2845 { 4*PT_SPC, "4*PT_SPC" },
2846 { 4*PT_CCS, "4*PT_CCS" },
2847 { 4*PT_SRP, "4*PT_SRP" },
2848 { 4*PT_ERP, "4*PT_ERP" },
2849 { 4*PT_EXS, "4*PT_EXS" },
2850 { 4*PT_EDA, "4*PT_EDA" },
2851 { 4*PT_USP, "4*PT_USP" },
2852 { 4*PT_PPC, "4*PT_PPC" },
2853 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2854 { 4*PT_BP+4, "4*PT_BP+4" },
2855 { 4*PT_BP+8, "4*PT_BP+8" },
2856 { 4*PT_BP+12, "4*PT_BP+12" },
2857 { 4*PT_BP+16, "4*PT_BP+16" },
2858 { 4*PT_BP+20, "4*PT_BP+20" },
2859 { 4*PT_BP+24, "4*PT_BP+24" },
2860 { 4*PT_BP+28, "4*PT_BP+28" },
2861 { 4*PT_BP+32, "4*PT_BP+32" },
2862 { 4*PT_BP+36, "4*PT_BP+36" },
2863 { 4*PT_BP+40, "4*PT_BP+40" },
2864 { 4*PT_BP+44, "4*PT_BP+44" },
2865 { 4*PT_BP+48, "4*PT_BP+48" },
2866 { 4*PT_BP+52, "4*PT_BP+52" },
2867 { 4*PT_BP+56, "4*PT_BP+56" },
2870 { PT_GPR(0), "r0" },
2871 { PT_GPR(1), "r1" },
2872 { PT_GPR(2), "r2" },
2873 { PT_GPR(3), "r3" },
2874 { PT_GPR(4), "r4" },
2875 { PT_GPR(5), "r5" },
2876 { PT_GPR(6), "r6" },
2877 { PT_GPR(7), "r7" },
2878 { PT_GPR(8), "r8" },
2879 { PT_GPR(9), "r9" },
2880 { PT_GPR(10), "r10" },
2881 { PT_GPR(11), "r11" },
2882 { PT_GPR(12), "r12" },
2883 { PT_GPR(13), "r13" },
2884 { PT_GPR(14), "r14" },
2885 { PT_GPR(15), "r15" },
2886 { PT_GPR(16), "r16" },
2887 { PT_GPR(17), "r17" },
2888 { PT_GPR(18), "r18" },
2889 { PT_GPR(19), "r19" },
2890 { PT_GPR(20), "r20" },
2891 { PT_GPR(21), "r21" },
2892 { PT_GPR(22), "r22" },
2893 { PT_GPR(23), "r23" },
2894 { PT_GPR(24), "r24" },
2895 { PT_GPR(25), "r25" },
2896 { PT_GPR(26), "r26" },
2897 { PT_GPR(27), "r27" },
2898 { PT_GPR(28), "r28" },
2899 { PT_GPR(29), "r29" },
2900 { PT_GPR(30), "r30" },
2901 { PT_GPR(31), "r31" },
2903 { PT_MSR, "rmsr", },
2904 { PT_EAR, "rear", },
2905 { PT_ESR, "resr", },
2906 { PT_FSR, "rfsr", },
2907 { PT_KERNEL_MODE, "kernel_mode", },
2910 # if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \
2911 && !defined(ALPHA) && !defined(IA64) \
2912 && !defined(CRISV10) && !defined(CRISV32) && !defined(MICROBLAZE)
2913 # if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(AVR32) && !defined(BFIN) && !defined(TILE)
2914 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2916 # if defined(I386) || defined(X86_64)
2917 { uoff(i387), "offsetof(struct user, i387)" },
2920 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2922 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2923 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2924 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2925 # if !defined(SPARC64)
2926 { uoff(start_code), "offsetof(struct user, start_code)" },
2928 # if defined(AVR32) || defined(SH64)
2929 { uoff(start_data), "offsetof(struct user, start_data)" },
2931 # if !defined(SPARC64)
2932 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2934 { uoff(signal), "offsetof(struct user, signal)" },
2935 # if !defined(AVR32) && !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SH) && !defined(SH64) && !defined(SPARC64) && !defined(TILE)
2936 { uoff(reserved), "offsetof(struct user, reserved)" },
2938 # if !defined(SPARC64)
2939 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2941 # if !defined(ARM) && !defined(AVR32) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) && !defined(BFIN) && !defined(TILE)
2942 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2944 { uoff(magic), "offsetof(struct user, magic)" },
2945 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2946 # if defined(I386) || defined(X86_64)
2947 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
2949 # endif /* !defined(many arches) */
2954 { uoff(u_pcb), "offsetof(struct user, u_pcb)" },
2955 { uoff(u_procp), "offsetof(struct user, u_procp)" },
2956 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2957 { uoff(u_comm[0]), "offsetof(struct user, u_comm[0])" },
2958 { uoff(u_arg[0]), "offsetof(struct user, u_arg[0])" },
2959 { uoff(u_ap), "offsetof(struct user, u_ap)" },
2960 { uoff(u_qsave), "offsetof(struct user, u_qsave)" },
2961 { uoff(u_rval1), "offsetof(struct user, u_rval1)" },
2962 { uoff(u_rval2), "offsetof(struct user, u_rval2)" },
2963 { uoff(u_error), "offsetof(struct user, u_error)" },
2964 { uoff(u_eosys), "offsetof(struct user, u_eosys)" },
2965 { uoff(u_ssave), "offsetof(struct user, u_ssave)" },
2966 { uoff(u_signal[0]), "offsetof(struct user, u_signal)" },
2967 { uoff(u_sigmask[0]), "offsetof(struct user, u_sigmask)" },
2968 { uoff(u_sigonstack), "offsetof(struct user, u_sigonstack)" },
2969 { uoff(u_sigintr), "offsetof(struct user, u_sigintr)" },
2970 { uoff(u_sigreset), "offsetof(struct user, u_sigreset)" },
2971 { uoff(u_oldmask), "offsetof(struct user, u_oldmask)" },
2972 { uoff(u_code), "offsetof(struct user, u_code)" },
2973 { uoff(u_addr), "offsetof(struct user, u_addr)" },
2974 { uoff(u_sigstack), "offsetof(struct user, u_sigstack)" },
2975 { uoff(u_ofile), "offsetof(struct user, u_ofile)" },
2976 { uoff(u_pofile), "offsetof(struct user, u_pofile)" },
2977 { uoff(u_ofile_arr[0]), "offsetof(struct user, u_ofile_arr[0])" },
2978 { uoff(u_pofile_arr[0]),"offsetof(struct user, u_pofile_arr[0])"},
2979 { uoff(u_lastfile), "offsetof(struct user, u_lastfile)" },
2980 { uoff(u_cwd), "offsetof(struct user, u_cwd)" },
2981 { uoff(u_cdir), "offsetof(struct user, u_cdir)" },
2982 { uoff(u_rdir), "offsetof(struct user, u_rdir)" },
2983 { uoff(u_cmask), "offsetof(struct user, u_cmask)" },
2984 { uoff(u_ru), "offsetof(struct user, u_ru)" },
2985 { uoff(u_cru), "offsetof(struct user, u_cru)" },
2986 { uoff(u_timer[0]), "offsetof(struct user, u_timer[0])" },
2987 { uoff(u_XXX[0]), "offsetof(struct user, u_XXX[0])" },
2988 { uoff(u_ioch), "offsetof(struct user, u_ioch)" },
2989 { uoff(u_start), "offsetof(struct user, u_start)" },
2990 { uoff(u_acflag), "offsetof(struct user, u_acflag)" },
2991 { uoff(u_prof.pr_base), "offsetof(struct user, u_prof.pr_base)" },
2992 { uoff(u_prof.pr_size), "offsetof(struct user, u_prof.pr_size)" },
2993 { uoff(u_prof.pr_off), "offsetof(struct user, u_prof.pr_off)" },
2994 { uoff(u_prof.pr_scale),"offsetof(struct user, u_prof.pr_scale)"},
2995 { uoff(u_rlimit[0]), "offsetof(struct user, u_rlimit)" },
2996 { uoff(u_exdata.Ux_A), "offsetof(struct user, u_exdata.Ux_A)" },
2997 { uoff(u_exdata.ux_shell[0]),"offsetof(struct user, u_exdata.ux_shell[0])"},
2998 { uoff(u_lofault), "offsetof(struct user, u_lofault)" },
2999 # endif /* SUNOS4 */
3001 { sizeof(struct user), "sizeof(struct user)" },
3005 # endif /* !FREEBSD */
3008 sys_ptrace(struct tcb *tcp)
3010 const struct xlat *x;
3013 if (entering(tcp)) {
3014 printxval(ptrace_cmds, tcp->u_arg[0],
3021 tprintf(", %lu, ", tcp->u_arg[1]);
3022 addr = tcp->u_arg[2];
3024 if (tcp->u_arg[0] == PTRACE_PEEKUSER
3025 || tcp->u_arg[0] == PTRACE_POKEUSER) {
3026 for (x = struct_user_offsets; x->str; x++) {
3031 tprintf("%#lx, ", addr);
3032 else if (x->val > addr && x != struct_user_offsets) {
3034 tprintf("%s + %ld, ", x->str, addr - x->val);
3037 tprintf("%s, ", x->str);
3041 tprintf("%#lx, ", tcp->u_arg[2]);
3043 switch (tcp->u_arg[0]) {
3045 case PTRACE_PEEKDATA:
3046 case PTRACE_PEEKTEXT:
3047 case PTRACE_PEEKUSER:
3051 case PTRACE_SINGLESTEP:
3052 case PTRACE_SYSCALL:
3054 printsignal(tcp->u_arg[3]);
3056 # ifdef PTRACE_SETOPTIONS
3057 case PTRACE_SETOPTIONS:
3058 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
3061 # ifdef PTRACE_SETSIGINFO
3062 case PTRACE_SETSIGINFO: {
3066 else if (syserror(tcp))
3067 tprintf("%#lx", tcp->u_arg[3]);
3068 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
3071 printsiginfo(&si, verbose(tcp));
3075 # ifdef PTRACE_GETSIGINFO
3076 case PTRACE_GETSIGINFO:
3077 /* Don't print anything, do it at syscall return. */
3081 tprintf("%#lx", tcp->u_arg[3]);
3085 switch (tcp->u_arg[0]) {
3086 case PTRACE_PEEKDATA:
3087 case PTRACE_PEEKTEXT:
3088 case PTRACE_PEEKUSER:
3092 printnum(tcp, tcp->u_arg[3], "%#lx");
3095 # ifdef PTRACE_GETSIGINFO
3096 case PTRACE_GETSIGINFO: {
3100 else if (syserror(tcp))
3101 tprintf("%#lx", tcp->u_arg[3]);
3102 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
3105 printsiginfo(&si, verbose(tcp));
3113 if (tcp->u_arg[0] == PTRACE_WRITEDATA ||
3114 tcp->u_arg[0] == PTRACE_WRITETEXT) {
3115 tprintf("%lu, ", tcp->u_arg[3]);
3116 printstr(tcp, tcp->u_arg[4], tcp->u_arg[3]);
3117 } else if (tcp->u_arg[0] != PTRACE_READDATA &&
3118 tcp->u_arg[0] != PTRACE_READTEXT) {
3119 tprintf("%#lx", tcp->u_arg[3]);
3122 if (tcp->u_arg[0] == PTRACE_READDATA ||
3123 tcp->u_arg[0] == PTRACE_READTEXT) {
3124 tprintf("%lu, ", tcp->u_arg[3]);
3125 printstr(tcp, tcp->u_arg[4], tcp->u_arg[3]);
3128 # endif /* SUNOS4 */
3130 tprintf("%lu", tcp->u_arg[3]);
3132 # endif /* FREEBSD */
3139 # ifndef FUTEX_CMP_REQUEUE
3140 # define FUTEX_CMP_REQUEUE 4
3142 # ifndef FUTEX_WAKE_OP
3143 # define FUTEX_WAKE_OP 5
3145 # ifndef FUTEX_LOCK_PI
3146 # define FUTEX_LOCK_PI 6
3147 # define FUTEX_UNLOCK_PI 7
3148 # define FUTEX_TRYLOCK_PI 8
3150 # ifndef FUTEX_WAIT_BITSET
3151 # define FUTEX_WAIT_BITSET 9
3153 # ifndef FUTEX_WAKE_BITSET
3154 # define FUTEX_WAKE_BITSET 10
3156 # ifndef FUTEX_WAIT_REQUEUE_PI
3157 # define FUTEX_WAIT_REQUEUE_PI 11
3159 # ifndef FUTEX_CMP_REQUEUE_PI
3160 # define FUTEX_CMP_REQUEUE_PI 12
3162 # ifndef FUTEX_PRIVATE_FLAG
3163 # define FUTEX_PRIVATE_FLAG 128
3165 # ifndef FUTEX_CLOCK_REALTIME
3166 # define FUTEX_CLOCK_REALTIME 256
3168 static const struct xlat futexops[] = {
3169 { FUTEX_WAIT, "FUTEX_WAIT" },
3170 { FUTEX_WAKE, "FUTEX_WAKE" },
3171 { FUTEX_FD, "FUTEX_FD" },
3172 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
3173 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
3174 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
3175 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
3176 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
3177 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
3178 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
3179 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
3180 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
3181 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
3182 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
3183 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
3184 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
3185 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
3186 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
3187 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
3188 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
3189 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
3190 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
3191 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
3192 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
3193 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
3194 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
3195 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
3196 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
3197 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
3198 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI_PRIVATE|FUTEX_CLOCK_REALTIME" },
3201 # ifndef FUTEX_OP_SET
3202 # define FUTEX_OP_SET 0
3203 # define FUTEX_OP_ADD 1
3204 # define FUTEX_OP_OR 2
3205 # define FUTEX_OP_ANDN 3
3206 # define FUTEX_OP_XOR 4
3207 # define FUTEX_OP_CMP_EQ 0
3208 # define FUTEX_OP_CMP_NE 1
3209 # define FUTEX_OP_CMP_LT 2
3210 # define FUTEX_OP_CMP_LE 3
3211 # define FUTEX_OP_CMP_GT 4
3212 # define FUTEX_OP_CMP_GE 5
3214 static const struct xlat futexwakeops[] = {
3215 { FUTEX_OP_SET, "FUTEX_OP_SET" },
3216 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
3217 { FUTEX_OP_OR, "FUTEX_OP_OR" },
3218 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
3219 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
3222 static const struct xlat futexwakecmps[] = {
3223 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
3224 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
3225 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
3226 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
3227 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
3228 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
3233 sys_futex(struct tcb *tcp)
3235 if (entering(tcp)) {
3236 long int cmd = tcp->u_arg[1] & 127;
3237 tprintf("%p, ", (void *) tcp->u_arg[0]);
3238 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
3239 tprintf(", %ld", tcp->u_arg[2]);
3240 if (cmd == FUTEX_WAKE_BITSET)
3241 tprintf(", %lx", tcp->u_arg[5]);
3242 else if (cmd == FUTEX_WAIT) {
3244 printtv(tcp, tcp->u_arg[3]);
3245 } else if (cmd == FUTEX_WAIT_BITSET) {
3247 printtv(tcp, tcp->u_arg[3]);
3248 tprintf(", %lx", tcp->u_arg[5]);
3249 } else if (cmd == FUTEX_REQUEUE)
3250 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
3251 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
3252 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
3253 else if (cmd == FUTEX_WAKE_OP) {
3254 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
3255 if ((tcp->u_arg[5] >> 28) & 8)
3256 tprints("FUTEX_OP_OPARG_SHIFT|");
3257 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
3258 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
3259 if ((tcp->u_arg[5] >> 24) & 8)
3260 tprints("FUTEX_OP_OPARG_SHIFT|");
3261 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
3262 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
3263 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
3265 printtv(tcp, tcp->u_arg[3]);
3266 tprintf(", %p", (void *) tcp->u_arg[4]);
3273 print_affinitylist(struct tcb *tcp, long list, unsigned int len)
3276 unsigned long w, min_len;
3278 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
3279 min_len = len - max_strlen * sizeof(w);
3282 for (; len >= sizeof(w) && len > min_len;
3283 len -= sizeof(w), list += sizeof(w)) {
3284 if (umove(tcp, list, &w) < 0)
3295 tprintf("%#lx", list);
3297 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
3300 tprints(first ? "{}" : "}");
3305 sys_sched_setaffinity(struct tcb *tcp)
3307 if (entering(tcp)) {
3308 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
3309 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
3315 sys_sched_getaffinity(struct tcb *tcp)
3317 if (entering(tcp)) {
3318 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
3320 if (tcp->u_rval == -1)
3321 tprintf("%#lx", tcp->u_arg[2]);
3323 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
3328 static const struct xlat schedulers[] = {
3329 { SCHED_OTHER, "SCHED_OTHER" },
3330 { SCHED_RR, "SCHED_RR" },
3331 { SCHED_FIFO, "SCHED_FIFO" },
3336 sys_sched_getscheduler(struct tcb *tcp)
3338 if (entering(tcp)) {
3339 tprintf("%d", (int) tcp->u_arg[0]);
3340 } else if (! syserror(tcp)) {
3341 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
3342 if (tcp->auxstr != NULL)
3349 sys_sched_setscheduler(struct tcb *tcp)
3351 if (entering(tcp)) {
3352 struct sched_param p;
3353 tprintf("%d, ", (int) tcp->u_arg[0]);
3354 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
3355 if (umove(tcp, tcp->u_arg[2], &p) < 0)
3356 tprintf(", %#lx", tcp->u_arg[2]);
3358 tprintf(", { %d }", p.__sched_priority);
3364 sys_sched_getparam(struct tcb *tcp)
3366 if (entering(tcp)) {
3367 tprintf("%d, ", (int) tcp->u_arg[0]);
3369 struct sched_param p;
3370 if (umove(tcp, tcp->u_arg[1], &p) < 0)
3371 tprintf("%#lx", tcp->u_arg[1]);
3373 tprintf("{ %d }", p.__sched_priority);
3379 sys_sched_setparam(struct tcb *tcp)
3381 if (entering(tcp)) {
3382 struct sched_param p;
3383 if (umove(tcp, tcp->u_arg[1], &p) < 0)
3384 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
3386 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
3392 sys_sched_get_priority_min(struct tcb *tcp)
3394 if (entering(tcp)) {
3395 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
3401 # include <asm/prctl.h>
3403 static const struct xlat archvals[] = {
3404 { ARCH_SET_GS, "ARCH_SET_GS" },
3405 { ARCH_SET_FS, "ARCH_SET_FS" },
3406 { ARCH_GET_FS, "ARCH_GET_FS" },
3407 { ARCH_GET_GS, "ARCH_GET_GS" },
3412 sys_arch_prctl(struct tcb *tcp)
3414 if (entering(tcp)) {
3415 printxval(archvals, tcp->u_arg[0], "ARCH_???");
3416 if (tcp->u_arg[0] == ARCH_SET_GS
3417 || tcp->u_arg[0] == ARCH_SET_FS
3419 tprintf(", %#lx", tcp->u_arg[1]);
3422 if (tcp->u_arg[0] == ARCH_GET_GS
3423 || tcp->u_arg[0] == ARCH_GET_FS
3426 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
3427 tprintf(", [%#lx]", v);
3429 tprintf(", %#lx", tcp->u_arg[1]);
3434 # endif /* X86_64 */
3438 sys_getcpu(struct tcb *tcp)
3442 if (tcp->u_arg[0] == 0)
3444 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
3445 tprintf("%#lx, ", tcp->u_arg[0]);
3447 tprintf("[%u], ", u);
3448 if (tcp->u_arg[1] == 0)
3450 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
3451 tprintf("%#lx, ", tcp->u_arg[1]);
3453 tprintf("[%u], ", u);
3454 tprintf("%#lx", tcp->u_arg[2]);