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.
45 #include <sys/resource.h>
46 #include <sys/utsname.h>
51 # ifndef PTRACE_PEEKUSR
52 # define PTRACE_PEEKUSR PTRACE_PEEKUSER
54 # ifndef PTRACE_POKEUSR
55 # define PTRACE_POKEUSR PTRACE_POKEUSER
59 #ifdef HAVE_LINUX_PTRACE_H
60 # undef PTRACE_SYSCALL
61 # ifdef HAVE_STRUCT_IA64_FPREG
62 # define ia64_fpreg XXX_ia64_fpreg
64 # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
65 # define pt_all_user_regs XXX_pt_all_user_regs
67 # include <linux/ptrace.h>
69 # undef pt_all_user_regs
74 # undef PTRACE_GETREGS
75 # define PTRACE_GETREGS PTRACE_GETREGS64
76 # undef PTRACE_SETREGS
77 # define PTRACE_SETREGS PTRACE_SETREGS64
80 #ifdef HAVE_LINUX_FUTEX_H
81 # include <linux/futex.h>
93 # define FUTEX_REQUEUE 3
97 #include <asm/posix_types.h>
99 #define GETGROUPS_T __kernel_gid_t
101 #define GETGROUPS32_T __kernel_gid32_t
104 # include <asm/ptrace_offsets.h>
105 # include <asm/rse.h>
109 # include <sys/prctl.h>
111 static const struct xlat prctl_options[] = {
113 { PR_MAXPROCS, "PR_MAXPROCS" },
116 { PR_ISBLOCKED, "PR_ISBLOCKED" },
118 #ifdef PR_SETSTACKSIZE
119 { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" },
121 #ifdef PR_GETSTACKSIZE
122 { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" },
125 { PR_MAXPPROCS, "PR_MAXPPROCS" },
127 #ifdef PR_UNBLKONEXEC
128 { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" },
131 { PR_ATOMICSIM, "PR_ATOMICSIM" },
134 { PR_SETEXITSIG, "PR_SETEXITSIG" },
137 { PR_RESIDENT, "PR_RESIDENT" },
140 { PR_ATTACHADDR, "PR_ATTACHADDR" },
143 { PR_DETACHADDR, "PR_DETACHADDR" },
146 { PR_TERMCHILD, "PR_TERMCHILD" },
149 { PR_GETSHMASK, "PR_GETSHMASK" },
152 { PR_GETNSHARE, "PR_GETNSHARE" },
155 { PR_COREPID, "PR_COREPID" },
157 #ifdef PR_ATTACHADDRPERM
158 { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" },
160 #ifdef PR_PTHREADEXIT
161 { PR_PTHREADEXIT, "PR_PTHREADEXIT" },
163 #ifdef PR_SET_PDEATHSIG
164 { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
166 #ifdef PR_GET_PDEATHSIG
167 { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
169 #ifdef PR_GET_DUMPABLE
170 { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" },
172 #ifdef PR_SET_DUMPABLE
173 { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" },
175 #ifdef PR_GET_UNALIGN
176 { PR_GET_UNALIGN, "PR_GET_UNALIGN" },
178 #ifdef PR_SET_UNALIGN
179 { PR_SET_UNALIGN, "PR_SET_UNALIGN" },
181 #ifdef PR_GET_KEEPCAPS
182 { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" },
184 #ifdef PR_SET_KEEPCAPS
185 { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" },
188 { PR_GET_FPEMU, "PR_GET_FPEMU" },
191 { PR_SET_FPEMU, "PR_SET_FPEMU" },
194 { PR_GET_FPEXC, "PR_GET_FPEXC" },
197 { PR_SET_FPEXC, "PR_SET_FPEXC" },
200 { PR_GET_TIMING, "PR_GET_TIMING" },
203 { PR_SET_TIMING, "PR_SET_TIMING" },
206 { PR_SET_NAME, "PR_SET_NAME" },
209 { PR_GET_NAME, "PR_GET_NAME" },
212 { PR_GET_ENDIAN, "PR_GET_ENDIAN" },
215 { PR_SET_ENDIAN, "PR_SET_ENDIAN" },
217 #ifdef PR_GET_SECCOMP
218 { PR_GET_SECCOMP, "PR_GET_SECCOMP" },
220 #ifdef PR_SET_SECCOMP
221 { PR_SET_SECCOMP, "PR_SET_SECCOMP" },
224 { PR_GET_TSC, "PR_GET_TSC" },
227 { PR_SET_TSC, "PR_SET_TSC" },
229 #ifdef PR_GET_SECUREBITS
230 { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" },
232 #ifdef PR_SET_SECUREBITS
233 { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" },
239 unalignctl_string(unsigned int ctl)
241 static char buf[sizeof(int)*2 + 2];
244 #ifdef PR_UNALIGN_NOPRINT
245 case PR_UNALIGN_NOPRINT:
248 #ifdef PR_UNALIGN_SIGBUS
249 case PR_UNALIGN_SIGBUS:
255 sprintf(buf, "%x", ctl);
260 sys_prctl(struct tcb *tcp)
265 printxval(prctl_options, tcp->u_arg[0], "PR_???");
266 switch (tcp->u_arg[0]) {
271 #ifdef PR_SET_PDEATHSIG
272 case PR_SET_PDEATHSIG:
273 tprintf(", %lu", tcp->u_arg[1]);
276 #ifdef PR_GET_PDEATHSIG
277 case PR_GET_PDEATHSIG:
280 #ifdef PR_SET_DUMPABLE
281 case PR_SET_DUMPABLE:
282 tprintf(", %lu", tcp->u_arg[1]);
285 #ifdef PR_GET_DUMPABLE
286 case PR_GET_DUMPABLE:
289 #ifdef PR_SET_UNALIGN
291 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
294 #ifdef PR_GET_UNALIGN
296 tprintf(", %#lx", tcp->u_arg[1]);
299 #ifdef PR_SET_KEEPCAPS
300 case PR_SET_KEEPCAPS:
301 tprintf(", %lu", tcp->u_arg[1]);
304 #ifdef PR_GET_KEEPCAPS
305 case PR_GET_KEEPCAPS:
309 for (i = 1; i < tcp->u_nargs; i++)
310 tprintf(", %#lx", tcp->u_arg[i]);
314 switch (tcp->u_arg[0]) {
315 #ifdef PR_GET_PDEATHSIG
316 case PR_GET_PDEATHSIG:
317 if (umove(tcp, tcp->u_arg[1], &i) < 0)
318 tprintf(", %#lx", tcp->u_arg[1]);
320 tprintf(", {%u}", i);
323 #ifdef PR_GET_DUMPABLE
324 case PR_GET_DUMPABLE:
325 return RVAL_UDECIMAL;
327 #ifdef PR_GET_UNALIGN
329 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
331 tcp->auxstr = unalignctl_string(i);
334 #ifdef PR_GET_KEEPCAPS
335 case PR_GET_KEEPCAPS:
336 return RVAL_UDECIMAL;
344 #endif /* HAVE_PRCTL */
347 sys_sethostname(struct tcb *tcp)
350 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
351 tprintf(", %lu", tcp->u_arg[1]);
358 sys_gethostname(struct tcb *tcp)
362 tprintf("%#lx", tcp->u_arg[0]);
364 printpath(tcp, tcp->u_arg[0]);
365 tprintf(", %lu", tcp->u_arg[1]);
372 sys_setdomainname(struct tcb *tcp)
375 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
376 tprintf(", %lu", tcp->u_arg[1]);
382 sys_exit(struct tcb *tcp)
385 fprintf(stderr, "_exit returned!\n");
388 /* special case: we stop tracing this process, finish line now */
389 tprintf("%ld) ", tcp->u_arg[0]);
396 /* defines copied from linux/sched.h since we can't include that
397 * ourselves (it conflicts with *lots* of libc includes)
399 #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
400 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
401 #define CLONE_FS 0x00000200 /* set if fs info shared between processes */
402 #define CLONE_FILES 0x00000400 /* set if open files shared between processes */
403 #define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
404 #define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
405 #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
406 #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
407 #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
408 #define CLONE_THREAD 0x00010000 /* Same thread group? */
409 #define CLONE_NEWNS 0x00020000 /* New namespace group? */
410 #define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
411 #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
412 #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
413 #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
414 #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
415 #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
416 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
417 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
418 #define CLONE_NEWIPC 0x08000000 /* New ipcs */
419 #define CLONE_NEWUSER 0x10000000 /* New user namespace */
420 #define CLONE_NEWPID 0x20000000 /* New pid namespace */
421 #define CLONE_NEWNET 0x40000000 /* New network namespace */
422 #define CLONE_IO 0x80000000 /* Clone io context */
424 static const struct xlat clone_flags[] = {
425 { CLONE_VM, "CLONE_VM" },
426 { CLONE_FS, "CLONE_FS" },
427 { CLONE_FILES, "CLONE_FILES" },
428 { CLONE_SIGHAND, "CLONE_SIGHAND" },
429 { CLONE_IDLETASK, "CLONE_IDLETASK"},
430 { CLONE_PTRACE, "CLONE_PTRACE" },
431 { CLONE_VFORK, "CLONE_VFORK" },
432 { CLONE_PARENT, "CLONE_PARENT" },
433 { CLONE_THREAD, "CLONE_THREAD" },
434 { CLONE_NEWNS, "CLONE_NEWNS" },
435 { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
436 { CLONE_SETTLS, "CLONE_SETTLS" },
437 { CLONE_PARENT_SETTID,"CLONE_PARENT_SETTID" },
438 { CLONE_CHILD_CLEARTID,"CLONE_CHILD_CLEARTID" },
439 { CLONE_UNTRACED, "CLONE_UNTRACED" },
440 { CLONE_CHILD_SETTID,"CLONE_CHILD_SETTID" },
441 { CLONE_STOPPED, "CLONE_STOPPED" },
442 { CLONE_NEWUTS, "CLONE_NEWUTS" },
443 { CLONE_NEWIPC, "CLONE_NEWIPC" },
444 { CLONE_NEWUSER, "CLONE_NEWUSER" },
445 { CLONE_NEWPID, "CLONE_NEWPID" },
446 { CLONE_NEWNET, "CLONE_NEWNET" },
447 { CLONE_IO, "CLONE_IO" },
452 # include <asm/ldt.h>
453 # ifdef HAVE_STRUCT_USER_DESC
454 # define modify_ldt_ldt_s user_desc
456 extern void print_ldt_entry();
462 # define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
463 # define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
464 # define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
465 # define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
466 # elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
472 # elif defined X86_64 || defined ALPHA
487 sys_clone(struct tcb *tcp)
490 const char *sep = "|";
491 unsigned long flags = tcp->u_arg[ARG_FLAGS];
492 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
493 # ifdef ARG_STACKSIZE
494 if (ARG_STACKSIZE != -1)
495 tprintf("stack_size=%#lx, ",
496 tcp->u_arg[ARG_STACKSIZE]);
499 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
501 if ((flags & CSIGNAL) != 0)
502 tprintf("%s%s", sep, signame(flags & CSIGNAL));
503 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
504 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
506 if (flags & CLONE_PARENT_SETTID)
507 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
508 if (flags & CLONE_SETTLS) {
510 struct modify_ldt_ldt_s copy;
511 if (umove(tcp, tcp->u_arg[ARG_TLS], ©) != -1) {
512 tprintf(", {entry_number:%d, ",
517 print_ldt_entry(©);
521 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
523 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
524 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
530 sys_unshare(struct tcb *tcp)
533 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
538 sys_fork(struct tcb *tcp)
541 return RVAL_UDECIMAL;
546 change_syscall(struct tcb *tcp, int new)
549 /* Attempt to make vfork into fork, which we can follow. */
550 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0)
553 #elif defined(X86_64)
554 /* Attempt to make vfork into fork, which we can follow. */
555 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_RAX * 8), new) < 0)
558 #elif defined(POWERPC)
559 if (ptrace(PTRACE_POKEUSER, tcp->pid,
560 (char*)(sizeof(unsigned long)*PT_R0), new) < 0)
563 #elif defined(S390) || defined(S390X)
564 /* s390 linux after 2.4.7 has a hook in entry.S to allow this */
565 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR2), new) < 0)
569 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_ORIG_D0), new) < 0)
572 #elif defined(SPARC) || defined(SPARC64)
574 if (ptrace(PTRACE_GETREGS, tcp->pid, (char*)®s, 0) < 0)
576 regs.u_regs[U_REG_G1] = new;
577 if (ptrace(PTRACE_SETREGS, tcp->pid, (char*)®s, 0) < 0)
581 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new) < 0)
585 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new) < 0)
589 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_R8), new) < 0)
593 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_P0), new) < 0)
600 break; /* x86 SYS_fork */
605 fprintf(stderr, "%s: unexpected syscall %d\n",
609 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R1), new) < 0)
611 } else if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R15), new) < 0)
615 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR20), new) < 0)
619 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*(REG_REG0+3)), new) < 0)
623 /* Top half of reg encodes the no. of args n as 0x1n.
624 Assume 0 args as kernel never actually checks... */
625 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_SYSCALL),
629 #elif defined(CRISV10) || defined(CRISV32)
630 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R9), new) < 0)
634 /* Some kernels support this, some (pre-2.6.16 or so) don't. */
635 # ifndef PTRACE_SET_SYSCALL
636 # define PTRACE_SET_SYSCALL 23
639 if (ptrace(PTRACE_SET_SYSCALL, tcp->pid, 0, new & 0xffff) != 0)
644 if (ptrace(PTRACE_POKEUSER, tcp->pid,
645 (char*)PTREGS_OFFSET_REG(0),
649 #elif defined(MICROBLAZE)
650 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new) < 0)
654 #warning Do not know how to handle change_syscall for this architecture
655 #endif /* architecture */
660 internal_fork(struct tcb *tcp)
662 if ((ptrace_setoptions
663 & (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
664 == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
672 * We won't see the new child if clone is called with
673 * CLONE_UNTRACED, so we keep the same logic with that option
674 * and don't trace it.
676 if ((sysent[tcp->scno].sys_func == sys_clone) &&
677 (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED))
681 if (tcp->flags & TCB_BPTSET)
688 sys_vfork(struct tcb *tcp)
691 return RVAL_UDECIMAL;
695 int sys_getuid(struct tcb *tcp)
698 tcp->u_rval = (uid_t) tcp->u_rval;
699 return RVAL_UDECIMAL;
702 int sys_setfsuid(struct tcb *tcp)
705 tprintf("%u", (uid_t) tcp->u_arg[0]);
707 tcp->u_rval = (uid_t) tcp->u_rval;
708 return RVAL_UDECIMAL;
712 sys_setuid(struct tcb *tcp)
715 tprintf("%u", (uid_t) tcp->u_arg[0]);
721 sys_getresuid(struct tcb *tcp)
726 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
727 tcp->u_arg[1], tcp->u_arg[2]);
729 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
730 tprintf("%#lx, ", tcp->u_arg[0]);
732 tprintf("[%lu], ", (unsigned long) uid);
733 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
734 tprintf("%#lx, ", tcp->u_arg[1]);
736 tprintf("[%lu], ", (unsigned long) uid);
737 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
738 tprintf("%#lx", tcp->u_arg[2]);
740 tprintf("[%lu]", (unsigned long) uid);
747 sys_setreuid(struct tcb *tcp)
750 printuid("", tcp->u_arg[0]);
751 printuid(", ", tcp->u_arg[1]);
757 sys_setresuid(struct tcb *tcp)
760 printuid("", tcp->u_arg[0]);
761 printuid(", ", tcp->u_arg[1]);
762 printuid(", ", tcp->u_arg[2]);
768 sys_setgroups(struct tcb *tcp)
771 unsigned long len, size, start, cur, end, abbrev_end;
776 tprintf("%lu, ", len);
781 start = tcp->u_arg[1];
786 size = len * sizeof(gid);
788 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
789 tprintf("%#lx", start);
793 abbrev_end = start + max_strlen * sizeof(gid);
794 if (abbrev_end < start)
800 for (cur = start; cur < end; cur += sizeof(gid)) {
803 if (cur >= abbrev_end) {
807 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
812 tprintf("%lu", (unsigned long) gid);
816 tprintf(" %#lx", tcp->u_arg[1]);
822 sys_getgroups(struct tcb *tcp)
828 tprintf("%lu, ", len);
830 unsigned long size, start, cur, end, abbrev_end;
839 start = tcp->u_arg[1];
844 if (tcp->u_arg[0] == 0) {
845 tprintf("%#lx", start);
848 size = len * sizeof(gid);
850 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
851 size / sizeof(gid) != len || end < start) {
852 tprintf("%#lx", start);
856 abbrev_end = start + max_strlen * sizeof(gid);
857 if (abbrev_end < start)
863 for (cur = start; cur < end; cur += sizeof(gid)) {
866 if (cur >= abbrev_end) {
870 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
875 tprintf("%lu", (unsigned long) gid);
879 tprintf(" %#lx", tcp->u_arg[1]);
885 sys_setgroups32(struct tcb *tcp)
888 unsigned long len, size, start, cur, end, abbrev_end;
893 tprintf("%lu, ", len);
898 start = tcp->u_arg[1];
903 size = len * sizeof(gid);
905 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
906 tprintf("%#lx", start);
910 abbrev_end = start + max_strlen * sizeof(gid);
911 if (abbrev_end < start)
917 for (cur = start; cur < end; cur += sizeof(gid)) {
920 if (cur >= abbrev_end) {
924 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
929 tprintf("%lu", (unsigned long) gid);
933 tprintf(" %#lx", tcp->u_arg[1]);
939 sys_getgroups32(struct tcb *tcp)
945 tprintf("%lu, ", len);
947 unsigned long size, start, cur, end, abbrev_end;
956 start = tcp->u_arg[1];
961 size = len * sizeof(gid);
963 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
964 size / sizeof(gid) != len || end < start) {
965 tprintf("%#lx", start);
969 abbrev_end = start + max_strlen * sizeof(gid);
970 if (abbrev_end < start)
976 for (cur = start; cur < end; cur += sizeof(gid)) {
979 if (cur >= abbrev_end) {
983 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
988 tprintf("%lu", (unsigned long) gid);
992 tprintf(" %#lx", tcp->u_arg[1]);
998 printargv(struct tcb *tcp, long addr)
1003 char data[sizeof(long)];
1007 unsigned wordsize = personality_wordsize[current_personality];
1010 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
1011 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
1012 tprintf("%#lx", addr);
1020 printstr(tcp, cp.p64, -1);
1024 tprintf("%s...", sep);
1028 printargc(const char *fmt, struct tcb *tcp, long addr)
1033 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
1034 addr += sizeof(char *);
1036 tprintf(fmt, count, count == 1 ? "" : "s");
1039 #if defined(SPARC) || defined(SPARC64)
1041 sys_execv(struct tcb *tcp)
1043 if (entering(tcp)) {
1044 printpath(tcp, tcp->u_arg[0]);
1046 tprintf(", %#lx", tcp->u_arg[1]);
1049 printargv(tcp, tcp->u_arg[1]);
1058 sys_execve(struct tcb *tcp)
1060 if (entering(tcp)) {
1061 printpath(tcp, tcp->u_arg[0]);
1063 tprintf(", %#lx", tcp->u_arg[1]);
1066 printargv(tcp, tcp->u_arg[1]);
1070 tprintf(", %#lx", tcp->u_arg[2]);
1071 else if (abbrev(tcp))
1072 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
1075 printargv(tcp, tcp->u_arg[2]);
1082 #if defined(TCB_WAITEXECVE)
1084 internal_exec(struct tcb *tcp)
1086 if (exiting(tcp) && syserror(tcp))
1087 tcp->flags &= ~TCB_WAITEXECVE;
1089 /* Maybe we have post-execve SIGTRAP suppressed? */
1090 if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC))
1091 tcp->flags |= TCB_WAITEXECVE; /* no */
1098 #define __WNOTHREAD 0x20000000
1101 #define __WALL 0x40000000
1104 #define __WCLONE 0x80000000
1107 static const struct xlat wait4_options[] = {
1108 { WNOHANG, "WNOHANG" },
1110 { WUNTRACED, "WUNTRACED" },
1113 { WEXITED, "WEXITED" },
1116 { WTRAPPED, "WTRAPPED" },
1119 { WSTOPPED, "WSTOPPED" },
1122 { WCONTINUED, "WCONTINUED" },
1125 { WNOWAIT, "WNOWAIT" },
1128 { __WCLONE, "__WCLONE" },
1131 { __WALL, "__WALL" },
1134 { __WNOTHREAD, "__WNOTHREAD" },
1139 #if !defined WCOREFLAG && defined WCOREFLG
1140 # define WCOREFLAG WCOREFLG
1143 # define WCOREFLAG 0x80
1146 # define WCOREDUMP(status) ((status) & 0200)
1150 #define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
1153 #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
1157 printstatus(int status)
1162 * Here is a tricky presentation problem. This solution
1163 * is still not entirely satisfactory but since there
1164 * are no wait status constructors it will have to do.
1166 if (WIFSTOPPED(status)) {
1167 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
1168 signame(WSTOPSIG(status)));
1169 status &= ~W_STOPCODE(WSTOPSIG(status));
1171 else if (WIFSIGNALED(status)) {
1172 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
1173 signame(WTERMSIG(status)),
1174 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
1175 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1177 else if (WIFEXITED(status)) {
1178 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
1179 WEXITSTATUS(status));
1181 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
1184 tprintf("[%#x]", status);
1191 tprintf(" | %#x]", status);
1197 printwaitn(struct tcb *tcp, int n, int bitness)
1201 if (entering(tcp)) {
1202 /* On Linux, kernel-side pid_t is typedef'ed to int
1203 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
1204 * pid argument to int on 64bit arches, producing,
1205 * for example, wait4(4294967295, ...) instead of -1
1206 * in strace. We have to use int here, not long.
1208 int pid = tcp->u_arg[0];
1209 tprintf("%d, ", pid);
1214 else if (syserror(tcp) || tcp->u_rval == 0)
1215 tprintf("%#lx", tcp->u_arg[1]);
1216 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
1219 printstatus(status);
1222 printflags(wait4_options, tcp->u_arg[2], "W???");
1228 else if (tcp->u_rval > 0) {
1231 printrusage32(tcp, tcp->u_arg[3]);
1234 printrusage(tcp, tcp->u_arg[3]);
1237 tprintf("%#lx", tcp->u_arg[3]);
1244 sys_waitpid(struct tcb *tcp)
1246 return printwaitn(tcp, 3, 0);
1250 sys_wait4(struct tcb *tcp)
1252 return printwaitn(tcp, 4, 0);
1257 sys_osf_wait4(struct tcb *tcp)
1259 return printwaitn(tcp, 4, 1);
1263 static const struct xlat waitid_types[] = {
1266 { P_PPID, "P_PPID" },
1268 { P_PGID, "P_PGID" },
1283 { P_LWPID, "P_LWPID" },
1289 sys_waitid(struct tcb *tcp)
1293 if (entering(tcp)) {
1294 printxval(waitid_types, tcp->u_arg[0], "P_???");
1295 tprintf(", %ld, ", tcp->u_arg[1]);
1301 else if (syserror(tcp))
1302 tprintf("%#lx", tcp->u_arg[2]);
1303 else if (umove(tcp, tcp->u_arg[2], &si) < 0)
1306 printsiginfo(&si, verbose(tcp));
1309 printflags(wait4_options, tcp->u_arg[3], "W???");
1310 if (tcp->u_nargs > 4) {
1315 else if (tcp->u_error)
1316 tprintf("%#lx", tcp->u_arg[4]);
1318 printrusage(tcp, tcp->u_arg[4]);
1325 sys_uname(struct tcb *tcp)
1327 struct utsname uname;
1330 if (syserror(tcp) || !verbose(tcp))
1331 tprintf("%#lx", tcp->u_arg[0]);
1332 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
1334 else if (!abbrev(tcp)) {
1336 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1337 uname.sysname, uname.nodename);
1338 tprintf("release=\"%s\", version=\"%s\", ",
1339 uname.release, uname.version);
1340 tprintf("machine=\"%s\"", uname.machine);
1342 tprintf(", domainname=\"%s\"", uname.domainname);
1347 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1348 uname.sysname, uname.nodename);
1353 static const struct xlat ptrace_cmds[] = {
1354 { PTRACE_TRACEME, "PTRACE_TRACEME" },
1355 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1356 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1357 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1358 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1359 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1360 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
1361 { PTRACE_CONT, "PTRACE_CONT" },
1362 { PTRACE_KILL, "PTRACE_KILL" },
1363 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1364 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1365 { PTRACE_DETACH, "PTRACE_DETACH" },
1366 # ifdef PTRACE_GETREGS
1367 { PTRACE_GETREGS, "PTRACE_GETREGS" },
1369 # ifdef PTRACE_SETREGS
1370 { PTRACE_SETREGS, "PTRACE_SETREGS" },
1372 # ifdef PTRACE_GETFPREGS
1373 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
1375 # ifdef PTRACE_SETFPREGS
1376 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
1378 # ifdef PTRACE_GETFPXREGS
1379 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
1381 # ifdef PTRACE_SETFPXREGS
1382 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
1384 # ifdef PTRACE_GETVRREGS
1385 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
1387 # ifdef PTRACE_SETVRREGS
1388 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
1390 # ifdef PTRACE_SETOPTIONS
1391 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
1393 # ifdef PTRACE_GETEVENTMSG
1394 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
1396 # ifdef PTRACE_GETSIGINFO
1397 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
1399 # ifdef PTRACE_SETSIGINFO
1400 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
1402 # ifdef PTRACE_GETREGSET
1403 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
1405 # ifdef PTRACE_SETREGSET
1406 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
1408 # ifdef PTRACE_SET_SYSCALL
1409 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
1411 # ifdef PTRACE_SEIZE
1412 { PTRACE_SEIZE, "PTRACE_SEIZE" },
1414 # ifdef PTRACE_INTERRUPT
1415 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
1417 # ifdef PTRACE_LISTEN
1418 { PTRACE_LISTEN, "PTRACE_LISTEN" },
1420 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
1425 # ifdef PTRACE_SETOPTIONS
1426 static const struct xlat ptrace_setoptions_flags[] = {
1427 # ifdef PTRACE_O_TRACESYSGOOD
1428 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
1430 # ifdef PTRACE_O_TRACEFORK
1431 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
1433 # ifdef PTRACE_O_TRACEVFORK
1434 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
1436 # ifdef PTRACE_O_TRACECLONE
1437 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
1439 # ifdef PTRACE_O_TRACEEXEC
1440 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
1442 # ifdef PTRACE_O_TRACEVFORKDONE
1443 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
1445 # ifdef PTRACE_O_TRACEEXIT
1446 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
1450 # endif /* PTRACE_SETOPTIONS */
1452 const struct xlat struct_user_offsets[] = {
1453 # if defined(S390) || defined(S390X)
1454 { PT_PSWMASK, "psw_mask" },
1455 { PT_PSWADDR, "psw_addr" },
1456 { PT_GPR0, "gpr0" },
1457 { PT_GPR1, "gpr1" },
1458 { PT_GPR2, "gpr2" },
1459 { PT_GPR3, "gpr3" },
1460 { PT_GPR4, "gpr4" },
1461 { PT_GPR5, "gpr5" },
1462 { PT_GPR6, "gpr6" },
1463 { PT_GPR7, "gpr7" },
1464 { PT_GPR8, "gpr8" },
1465 { PT_GPR9, "gpr9" },
1466 { PT_GPR10, "gpr10" },
1467 { PT_GPR11, "gpr11" },
1468 { PT_GPR12, "gpr12" },
1469 { PT_GPR13, "gpr13" },
1470 { PT_GPR14, "gpr14" },
1471 { PT_GPR15, "gpr15" },
1472 { PT_ACR0, "acr0" },
1473 { PT_ACR1, "acr1" },
1474 { PT_ACR2, "acr2" },
1475 { PT_ACR3, "acr3" },
1476 { PT_ACR4, "acr4" },
1477 { PT_ACR5, "acr5" },
1478 { PT_ACR6, "acr6" },
1479 { PT_ACR7, "acr7" },
1480 { PT_ACR8, "acr8" },
1481 { PT_ACR9, "acr9" },
1482 { PT_ACR10, "acr10" },
1483 { PT_ACR11, "acr11" },
1484 { PT_ACR12, "acr12" },
1485 { PT_ACR13, "acr13" },
1486 { PT_ACR14, "acr14" },
1487 { PT_ACR15, "acr15" },
1488 { PT_ORIGGPR2, "orig_gpr2" },
1491 { PT_FPR0_HI, "fpr0.hi" },
1492 { PT_FPR0_LO, "fpr0.lo" },
1493 { PT_FPR1_HI, "fpr1.hi" },
1494 { PT_FPR1_LO, "fpr1.lo" },
1495 { PT_FPR2_HI, "fpr2.hi" },
1496 { PT_FPR2_LO, "fpr2.lo" },
1497 { PT_FPR3_HI, "fpr3.hi" },
1498 { PT_FPR3_LO, "fpr3.lo" },
1499 { PT_FPR4_HI, "fpr4.hi" },
1500 { PT_FPR4_LO, "fpr4.lo" },
1501 { PT_FPR5_HI, "fpr5.hi" },
1502 { PT_FPR5_LO, "fpr5.lo" },
1503 { PT_FPR6_HI, "fpr6.hi" },
1504 { PT_FPR6_LO, "fpr6.lo" },
1505 { PT_FPR7_HI, "fpr7.hi" },
1506 { PT_FPR7_LO, "fpr7.lo" },
1507 { PT_FPR8_HI, "fpr8.hi" },
1508 { PT_FPR8_LO, "fpr8.lo" },
1509 { PT_FPR9_HI, "fpr9.hi" },
1510 { PT_FPR9_LO, "fpr9.lo" },
1511 { PT_FPR10_HI, "fpr10.hi" },
1512 { PT_FPR10_LO, "fpr10.lo" },
1513 { PT_FPR11_HI, "fpr11.hi" },
1514 { PT_FPR11_LO, "fpr11.lo" },
1515 { PT_FPR12_HI, "fpr12.hi" },
1516 { PT_FPR12_LO, "fpr12.lo" },
1517 { PT_FPR13_HI, "fpr13.hi" },
1518 { PT_FPR13_LO, "fpr13.lo" },
1519 { PT_FPR14_HI, "fpr14.hi" },
1520 { PT_FPR14_LO, "fpr14.lo" },
1521 { PT_FPR15_HI, "fpr15.hi" },
1522 { PT_FPR15_LO, "fpr15.lo" },
1525 { PT_FPR0, "fpr0" },
1526 { PT_FPR1, "fpr1" },
1527 { PT_FPR2, "fpr2" },
1528 { PT_FPR3, "fpr3" },
1529 { PT_FPR4, "fpr4" },
1530 { PT_FPR5, "fpr5" },
1531 { PT_FPR6, "fpr6" },
1532 { PT_FPR7, "fpr7" },
1533 { PT_FPR8, "fpr8" },
1534 { PT_FPR9, "fpr9" },
1535 { PT_FPR10, "fpr10" },
1536 { PT_FPR11, "fpr11" },
1537 { PT_FPR12, "fpr12" },
1538 { PT_FPR13, "fpr13" },
1539 { PT_FPR14, "fpr14" },
1540 { PT_FPR15, "fpr15" },
1543 { PT_CR_10, "cr10" },
1544 { PT_CR_11, "cr11" },
1545 { PT_IEEE_IP, "ieee_exception_ip" },
1546 # elif defined(SPARC)
1547 /* XXX No support for these offsets yet. */
1548 # elif defined(HPPA)
1549 /* XXX No support for these offsets yet. */
1550 # elif defined(POWERPC)
1552 # define PT_ORIG_R3 34
1554 # define REGSIZE (sizeof(unsigned long))
1555 { REGSIZE*PT_R0, "r0" },
1556 { REGSIZE*PT_R1, "r1" },
1557 { REGSIZE*PT_R2, "r2" },
1558 { REGSIZE*PT_R3, "r3" },
1559 { REGSIZE*PT_R4, "r4" },
1560 { REGSIZE*PT_R5, "r5" },
1561 { REGSIZE*PT_R6, "r6" },
1562 { REGSIZE*PT_R7, "r7" },
1563 { REGSIZE*PT_R8, "r8" },
1564 { REGSIZE*PT_R9, "r9" },
1565 { REGSIZE*PT_R10, "r10" },
1566 { REGSIZE*PT_R11, "r11" },
1567 { REGSIZE*PT_R12, "r12" },
1568 { REGSIZE*PT_R13, "r13" },
1569 { REGSIZE*PT_R14, "r14" },
1570 { REGSIZE*PT_R15, "r15" },
1571 { REGSIZE*PT_R16, "r16" },
1572 { REGSIZE*PT_R17, "r17" },
1573 { REGSIZE*PT_R18, "r18" },
1574 { REGSIZE*PT_R19, "r19" },
1575 { REGSIZE*PT_R20, "r20" },
1576 { REGSIZE*PT_R21, "r21" },
1577 { REGSIZE*PT_R22, "r22" },
1578 { REGSIZE*PT_R23, "r23" },
1579 { REGSIZE*PT_R24, "r24" },
1580 { REGSIZE*PT_R25, "r25" },
1581 { REGSIZE*PT_R26, "r26" },
1582 { REGSIZE*PT_R27, "r27" },
1583 { REGSIZE*PT_R28, "r28" },
1584 { REGSIZE*PT_R29, "r29" },
1585 { REGSIZE*PT_R30, "r30" },
1586 { REGSIZE*PT_R31, "r31" },
1587 { REGSIZE*PT_NIP, "NIP" },
1588 { REGSIZE*PT_MSR, "MSR" },
1589 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1590 { REGSIZE*PT_CTR, "CTR" },
1591 { REGSIZE*PT_LNK, "LNK" },
1592 { REGSIZE*PT_XER, "XER" },
1593 { REGSIZE*PT_CCR, "CCR" },
1594 { REGSIZE*PT_FPR0, "FPR0" },
1596 # elif defined(ALPHA)
1662 # elif defined(IA64)
1663 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1664 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1665 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1666 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1667 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1668 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1669 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1670 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1671 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1672 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1673 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1674 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1675 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1676 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1677 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1678 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1679 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1680 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1681 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1682 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1683 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1684 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1685 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1686 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1687 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1688 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1689 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1690 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1691 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1692 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1693 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1694 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1696 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1697 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1698 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1699 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1700 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1701 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1702 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1703 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1704 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1705 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
1706 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1707 { PT_B4, "b4" }, { PT_B5, "b5" },
1708 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
1710 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1711 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
1712 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1713 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1714 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1715 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1716 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1717 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1718 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1719 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1720 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1721 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1722 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1723 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1724 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1725 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1726 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
1728 { PT_AR_CSD, "ar.csd" },
1731 { PT_AR_SSD, "ar.ssd" },
1733 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
1734 # elif defined(I386)
1746 { 4*ORIG_EAX, "4*ORIG_EAX" },
1750 { 4*UESP, "4*UESP" },
1752 # elif defined(X86_64)
1768 { 8*ORIG_RAX, "8*ORIG_RAX" },
1771 { 8*EFLAGS, "8*EFL" },
1774 # elif defined(M68K)
1775 { 4*PT_D1, "4*PT_D1" },
1776 { 4*PT_D2, "4*PT_D2" },
1777 { 4*PT_D3, "4*PT_D3" },
1778 { 4*PT_D4, "4*PT_D4" },
1779 { 4*PT_D5, "4*PT_D5" },
1780 { 4*PT_D6, "4*PT_D6" },
1781 { 4*PT_D7, "4*PT_D7" },
1782 { 4*PT_A0, "4*PT_A0" },
1783 { 4*PT_A1, "4*PT_A1" },
1784 { 4*PT_A2, "4*PT_A2" },
1785 { 4*PT_A3, "4*PT_A3" },
1786 { 4*PT_A4, "4*PT_A4" },
1787 { 4*PT_A5, "4*PT_A5" },
1788 { 4*PT_A6, "4*PT_A6" },
1789 { 4*PT_D0, "4*PT_D0" },
1790 { 4*PT_USP, "4*PT_USP" },
1791 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1792 { 4*PT_SR, "4*PT_SR" },
1793 { 4*PT_PC, "4*PT_PC" },
1795 { 4*REG_REG0, "4*REG_REG0" },
1796 { 4*(REG_REG0+1), "4*REG_REG1" },
1797 { 4*(REG_REG0+2), "4*REG_REG2" },
1798 { 4*(REG_REG0+3), "4*REG_REG3" },
1799 { 4*(REG_REG0+4), "4*REG_REG4" },
1800 { 4*(REG_REG0+5), "4*REG_REG5" },
1801 { 4*(REG_REG0+6), "4*REG_REG6" },
1802 { 4*(REG_REG0+7), "4*REG_REG7" },
1803 { 4*(REG_REG0+8), "4*REG_REG8" },
1804 { 4*(REG_REG0+9), "4*REG_REG9" },
1805 { 4*(REG_REG0+10), "4*REG_REG10" },
1806 { 4*(REG_REG0+11), "4*REG_REG11" },
1807 { 4*(REG_REG0+12), "4*REG_REG12" },
1808 { 4*(REG_REG0+13), "4*REG_REG13" },
1809 { 4*(REG_REG0+14), "4*REG_REG14" },
1810 { 4*REG_REG15, "4*REG_REG15" },
1811 { 4*REG_PC, "4*REG_PC" },
1812 { 4*REG_PR, "4*REG_PR" },
1813 { 4*REG_SR, "4*REG_SR" },
1814 { 4*REG_GBR, "4*REG_GBR" },
1815 { 4*REG_MACH, "4*REG_MACH" },
1816 { 4*REG_MACL, "4*REG_MACL" },
1817 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1818 { 4*REG_FPUL, "4*REG_FPUL" },
1819 { 4*REG_FPREG0, "4*REG_FPREG0" },
1820 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1821 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1822 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1823 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1824 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1825 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1826 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1827 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1828 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1829 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1830 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1831 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1832 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1833 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1834 { 4*REG_FPREG15, "4*REG_FPREG15" },
1836 { 4*REG_XDREG0, "4*REG_XDREG0" },
1837 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1838 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1839 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1840 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1841 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1842 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1843 { 4*REG_XDREG14, "4*REG_XDREG14" },
1845 { 4*REG_FPSCR, "4*REG_FPSCR" },
1846 # elif defined(SH64)
1851 { 16, "syscall no.(L)" },
1852 { 20, "syscall_no.(U)" },
1995 /* This entry is in case pt_regs contains dregs (depends on
1996 the kernel build options). */
1997 { uoff(regs), "offsetof(struct user, regs)" },
1998 { uoff(fpu), "offsetof(struct user, fpu)" },
2000 { uoff(regs.ARM_r0), "r0" },
2001 { uoff(regs.ARM_r1), "r1" },
2002 { uoff(regs.ARM_r2), "r2" },
2003 { uoff(regs.ARM_r3), "r3" },
2004 { uoff(regs.ARM_r4), "r4" },
2005 { uoff(regs.ARM_r5), "r5" },
2006 { uoff(regs.ARM_r6), "r6" },
2007 { uoff(regs.ARM_r7), "r7" },
2008 { uoff(regs.ARM_r8), "r8" },
2009 { uoff(regs.ARM_r9), "r9" },
2010 { uoff(regs.ARM_r10), "r10" },
2011 { uoff(regs.ARM_fp), "fp" },
2012 { uoff(regs.ARM_ip), "ip" },
2013 { uoff(regs.ARM_sp), "sp" },
2014 { uoff(regs.ARM_lr), "lr" },
2015 { uoff(regs.ARM_pc), "pc" },
2016 { uoff(regs.ARM_cpsr), "cpsr" },
2017 # elif defined(AVR32)
2018 { uoff(regs.sr), "sr" },
2019 { uoff(regs.pc), "pc" },
2020 { uoff(regs.lr), "lr" },
2021 { uoff(regs.sp), "sp" },
2022 { uoff(regs.r12), "r12" },
2023 { uoff(regs.r11), "r11" },
2024 { uoff(regs.r10), "r10" },
2025 { uoff(regs.r9), "r9" },
2026 { uoff(regs.r8), "r8" },
2027 { uoff(regs.r7), "r7" },
2028 { uoff(regs.r6), "r6" },
2029 { uoff(regs.r5), "r5" },
2030 { uoff(regs.r4), "r4" },
2031 { uoff(regs.r3), "r3" },
2032 { uoff(regs.r2), "r2" },
2033 { uoff(regs.r1), "r1" },
2034 { uoff(regs.r0), "r0" },
2035 { uoff(regs.r12_orig), "orig_r12" },
2036 # elif defined(MIPS)
2108 # elif defined(TILE)
2109 { PTREGS_OFFSET_REG(0), "r0" },
2110 { PTREGS_OFFSET_REG(1), "r1" },
2111 { PTREGS_OFFSET_REG(2), "r2" },
2112 { PTREGS_OFFSET_REG(3), "r3" },
2113 { PTREGS_OFFSET_REG(4), "r4" },
2114 { PTREGS_OFFSET_REG(5), "r5" },
2115 { PTREGS_OFFSET_REG(6), "r6" },
2116 { PTREGS_OFFSET_REG(7), "r7" },
2117 { PTREGS_OFFSET_REG(8), "r8" },
2118 { PTREGS_OFFSET_REG(9), "r9" },
2119 { PTREGS_OFFSET_REG(10), "r10" },
2120 { PTREGS_OFFSET_REG(11), "r11" },
2121 { PTREGS_OFFSET_REG(12), "r12" },
2122 { PTREGS_OFFSET_REG(13), "r13" },
2123 { PTREGS_OFFSET_REG(14), "r14" },
2124 { PTREGS_OFFSET_REG(15), "r15" },
2125 { PTREGS_OFFSET_REG(16), "r16" },
2126 { PTREGS_OFFSET_REG(17), "r17" },
2127 { PTREGS_OFFSET_REG(18), "r18" },
2128 { PTREGS_OFFSET_REG(19), "r19" },
2129 { PTREGS_OFFSET_REG(20), "r20" },
2130 { PTREGS_OFFSET_REG(21), "r21" },
2131 { PTREGS_OFFSET_REG(22), "r22" },
2132 { PTREGS_OFFSET_REG(23), "r23" },
2133 { PTREGS_OFFSET_REG(24), "r24" },
2134 { PTREGS_OFFSET_REG(25), "r25" },
2135 { PTREGS_OFFSET_REG(26), "r26" },
2136 { PTREGS_OFFSET_REG(27), "r27" },
2137 { PTREGS_OFFSET_REG(28), "r28" },
2138 { PTREGS_OFFSET_REG(29), "r29" },
2139 { PTREGS_OFFSET_REG(30), "r30" },
2140 { PTREGS_OFFSET_REG(31), "r31" },
2141 { PTREGS_OFFSET_REG(32), "r32" },
2142 { PTREGS_OFFSET_REG(33), "r33" },
2143 { PTREGS_OFFSET_REG(34), "r34" },
2144 { PTREGS_OFFSET_REG(35), "r35" },
2145 { PTREGS_OFFSET_REG(36), "r36" },
2146 { PTREGS_OFFSET_REG(37), "r37" },
2147 { PTREGS_OFFSET_REG(38), "r38" },
2148 { PTREGS_OFFSET_REG(39), "r39" },
2149 { PTREGS_OFFSET_REG(40), "r40" },
2150 { PTREGS_OFFSET_REG(41), "r41" },
2151 { PTREGS_OFFSET_REG(42), "r42" },
2152 { PTREGS_OFFSET_REG(43), "r43" },
2153 { PTREGS_OFFSET_REG(44), "r44" },
2154 { PTREGS_OFFSET_REG(45), "r45" },
2155 { PTREGS_OFFSET_REG(46), "r46" },
2156 { PTREGS_OFFSET_REG(47), "r47" },
2157 { PTREGS_OFFSET_REG(48), "r48" },
2158 { PTREGS_OFFSET_REG(49), "r49" },
2159 { PTREGS_OFFSET_REG(50), "r50" },
2160 { PTREGS_OFFSET_REG(51), "r51" },
2161 { PTREGS_OFFSET_REG(52), "r52" },
2162 { PTREGS_OFFSET_TP, "tp" },
2163 { PTREGS_OFFSET_SP, "sp" },
2164 { PTREGS_OFFSET_LR, "lr" },
2165 { PTREGS_OFFSET_PC, "pc" },
2166 { PTREGS_OFFSET_EX1, "ex1" },
2167 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2168 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2169 { PTREGS_OFFSET_FLAGS, "flags" },
2172 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2173 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2174 { 4*PT_R13, "4*PT_R13" },
2175 { 4*PT_R12, "4*PT_R12" },
2176 { 4*PT_R11, "4*PT_R11" },
2177 { 4*PT_R10, "4*PT_R10" },
2178 { 4*PT_R9, "4*PT_R9" },
2179 { 4*PT_R8, "4*PT_R8" },
2180 { 4*PT_R7, "4*PT_R7" },
2181 { 4*PT_R6, "4*PT_R6" },
2182 { 4*PT_R5, "4*PT_R5" },
2183 { 4*PT_R4, "4*PT_R4" },
2184 { 4*PT_R3, "4*PT_R3" },
2185 { 4*PT_R2, "4*PT_R2" },
2186 { 4*PT_R1, "4*PT_R1" },
2187 { 4*PT_R0, "4*PT_R0" },
2188 { 4*PT_MOF, "4*PT_MOF" },
2189 { 4*PT_DCCR, "4*PT_DCCR" },
2190 { 4*PT_SRP, "4*PT_SRP" },
2191 { 4*PT_IRP, "4*PT_IRP" },
2192 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2193 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2194 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2195 { 4*PT_USP, "4*PT_USP" },
2198 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2199 { 4*PT_R0, "4*PT_R0" },
2200 { 4*PT_R1, "4*PT_R1" },
2201 { 4*PT_R2, "4*PT_R2" },
2202 { 4*PT_R3, "4*PT_R3" },
2203 { 4*PT_R4, "4*PT_R4" },
2204 { 4*PT_R5, "4*PT_R5" },
2205 { 4*PT_R6, "4*PT_R6" },
2206 { 4*PT_R7, "4*PT_R7" },
2207 { 4*PT_R8, "4*PT_R8" },
2208 { 4*PT_R9, "4*PT_R9" },
2209 { 4*PT_R10, "4*PT_R10" },
2210 { 4*PT_R11, "4*PT_R11" },
2211 { 4*PT_R12, "4*PT_R12" },
2212 { 4*PT_R13, "4*PT_R13" },
2213 { 4*PT_ACR, "4*PT_ACR" },
2214 { 4*PT_SRS, "4*PT_SRS" },
2215 { 4*PT_MOF, "4*PT_MOF" },
2216 { 4*PT_SPC, "4*PT_SPC" },
2217 { 4*PT_CCS, "4*PT_CCS" },
2218 { 4*PT_SRP, "4*PT_SRP" },
2219 { 4*PT_ERP, "4*PT_ERP" },
2220 { 4*PT_EXS, "4*PT_EXS" },
2221 { 4*PT_EDA, "4*PT_EDA" },
2222 { 4*PT_USP, "4*PT_USP" },
2223 { 4*PT_PPC, "4*PT_PPC" },
2224 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2225 { 4*PT_BP+4, "4*PT_BP+4" },
2226 { 4*PT_BP+8, "4*PT_BP+8" },
2227 { 4*PT_BP+12, "4*PT_BP+12" },
2228 { 4*PT_BP+16, "4*PT_BP+16" },
2229 { 4*PT_BP+20, "4*PT_BP+20" },
2230 { 4*PT_BP+24, "4*PT_BP+24" },
2231 { 4*PT_BP+28, "4*PT_BP+28" },
2232 { 4*PT_BP+32, "4*PT_BP+32" },
2233 { 4*PT_BP+36, "4*PT_BP+36" },
2234 { 4*PT_BP+40, "4*PT_BP+40" },
2235 { 4*PT_BP+44, "4*PT_BP+44" },
2236 { 4*PT_BP+48, "4*PT_BP+48" },
2237 { 4*PT_BP+52, "4*PT_BP+52" },
2238 { 4*PT_BP+56, "4*PT_BP+56" },
2241 { PT_GPR(0), "r0" },
2242 { PT_GPR(1), "r1" },
2243 { PT_GPR(2), "r2" },
2244 { PT_GPR(3), "r3" },
2245 { PT_GPR(4), "r4" },
2246 { PT_GPR(5), "r5" },
2247 { PT_GPR(6), "r6" },
2248 { PT_GPR(7), "r7" },
2249 { PT_GPR(8), "r8" },
2250 { PT_GPR(9), "r9" },
2251 { PT_GPR(10), "r10" },
2252 { PT_GPR(11), "r11" },
2253 { PT_GPR(12), "r12" },
2254 { PT_GPR(13), "r13" },
2255 { PT_GPR(14), "r14" },
2256 { PT_GPR(15), "r15" },
2257 { PT_GPR(16), "r16" },
2258 { PT_GPR(17), "r17" },
2259 { PT_GPR(18), "r18" },
2260 { PT_GPR(19), "r19" },
2261 { PT_GPR(20), "r20" },
2262 { PT_GPR(21), "r21" },
2263 { PT_GPR(22), "r22" },
2264 { PT_GPR(23), "r23" },
2265 { PT_GPR(24), "r24" },
2266 { PT_GPR(25), "r25" },
2267 { PT_GPR(26), "r26" },
2268 { PT_GPR(27), "r27" },
2269 { PT_GPR(28), "r28" },
2270 { PT_GPR(29), "r29" },
2271 { PT_GPR(30), "r30" },
2272 { PT_GPR(31), "r31" },
2274 { PT_MSR, "rmsr", },
2275 { PT_EAR, "rear", },
2276 { PT_ESR, "resr", },
2277 { PT_FSR, "rfsr", },
2278 { PT_KERNEL_MODE, "kernel_mode", },
2281 # if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \
2282 && !defined(ALPHA) && !defined(IA64) \
2283 && !defined(CRISV10) && !defined(CRISV32) && !defined(MICROBLAZE)
2284 # if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(AVR32) && !defined(BFIN) && !defined(TILE)
2285 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2287 # if defined(I386) || defined(X86_64)
2288 { uoff(i387), "offsetof(struct user, i387)" },
2291 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2293 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2294 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2295 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2296 # if !defined(SPARC64)
2297 { uoff(start_code), "offsetof(struct user, start_code)" },
2299 # if defined(AVR32) || defined(SH64)
2300 { uoff(start_data), "offsetof(struct user, start_data)" },
2302 # if !defined(SPARC64)
2303 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2305 { uoff(signal), "offsetof(struct user, signal)" },
2306 # if !defined(AVR32) && !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SH) && !defined(SH64) && !defined(SPARC64) && !defined(TILE)
2307 { uoff(reserved), "offsetof(struct user, reserved)" },
2309 # if !defined(SPARC64)
2310 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2312 # if !defined(ARM) && !defined(AVR32) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) && !defined(BFIN) && !defined(TILE)
2313 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2315 { uoff(magic), "offsetof(struct user, magic)" },
2316 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2317 # if defined(I386) || defined(X86_64)
2318 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
2320 # endif /* !defined(many arches) */
2323 { sizeof(struct user), "sizeof(struct user)" },
2329 sys_ptrace(struct tcb *tcp)
2331 const struct xlat *x;
2334 if (entering(tcp)) {
2335 printxval(ptrace_cmds, tcp->u_arg[0],
2338 tprintf(", %lu, ", tcp->u_arg[1]);
2339 addr = tcp->u_arg[2];
2340 if (tcp->u_arg[0] == PTRACE_PEEKUSER
2341 || tcp->u_arg[0] == PTRACE_POKEUSER) {
2342 for (x = struct_user_offsets; x->str; x++) {
2347 tprintf("%#lx, ", addr);
2348 else if (x->val > addr && x != struct_user_offsets) {
2350 tprintf("%s + %ld, ", x->str, addr - x->val);
2353 tprintf("%s, ", x->str);
2356 tprintf("%#lx, ", tcp->u_arg[2]);
2357 switch (tcp->u_arg[0]) {
2359 case PTRACE_PEEKDATA:
2360 case PTRACE_PEEKTEXT:
2361 case PTRACE_PEEKUSER:
2365 case PTRACE_SINGLESTEP:
2366 case PTRACE_SYSCALL:
2368 printsignal(tcp->u_arg[3]);
2370 # ifdef PTRACE_SETOPTIONS
2371 case PTRACE_SETOPTIONS:
2372 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2375 # ifdef PTRACE_SETSIGINFO
2376 case PTRACE_SETSIGINFO: {
2380 else if (syserror(tcp))
2381 tprintf("%#lx", tcp->u_arg[3]);
2382 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
2385 printsiginfo(&si, verbose(tcp));
2389 # ifdef PTRACE_GETSIGINFO
2390 case PTRACE_GETSIGINFO:
2391 /* Don't print anything, do it at syscall return. */
2395 tprintf("%#lx", tcp->u_arg[3]);
2399 switch (tcp->u_arg[0]) {
2400 case PTRACE_PEEKDATA:
2401 case PTRACE_PEEKTEXT:
2402 case PTRACE_PEEKUSER:
2406 printnum(tcp, tcp->u_arg[3], "%#lx");
2409 # ifdef PTRACE_GETSIGINFO
2410 case PTRACE_GETSIGINFO: {
2414 else if (syserror(tcp))
2415 tprintf("%#lx", tcp->u_arg[3]);
2416 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
2419 printsiginfo(&si, verbose(tcp));
2428 # ifndef FUTEX_CMP_REQUEUE
2429 # define FUTEX_CMP_REQUEUE 4
2431 # ifndef FUTEX_WAKE_OP
2432 # define FUTEX_WAKE_OP 5
2434 # ifndef FUTEX_LOCK_PI
2435 # define FUTEX_LOCK_PI 6
2436 # define FUTEX_UNLOCK_PI 7
2437 # define FUTEX_TRYLOCK_PI 8
2439 # ifndef FUTEX_WAIT_BITSET
2440 # define FUTEX_WAIT_BITSET 9
2442 # ifndef FUTEX_WAKE_BITSET
2443 # define FUTEX_WAKE_BITSET 10
2445 # ifndef FUTEX_WAIT_REQUEUE_PI
2446 # define FUTEX_WAIT_REQUEUE_PI 11
2448 # ifndef FUTEX_CMP_REQUEUE_PI
2449 # define FUTEX_CMP_REQUEUE_PI 12
2451 # ifndef FUTEX_PRIVATE_FLAG
2452 # define FUTEX_PRIVATE_FLAG 128
2454 # ifndef FUTEX_CLOCK_REALTIME
2455 # define FUTEX_CLOCK_REALTIME 256
2457 static const struct xlat futexops[] = {
2458 { FUTEX_WAIT, "FUTEX_WAIT" },
2459 { FUTEX_WAKE, "FUTEX_WAKE" },
2460 { FUTEX_FD, "FUTEX_FD" },
2461 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2462 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2463 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2464 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2465 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2466 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
2467 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2468 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
2469 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2470 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
2471 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2472 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2473 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2474 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2475 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2476 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2477 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2478 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2479 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
2480 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2481 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
2482 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2483 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2484 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2485 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2486 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2487 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI_PRIVATE|FUTEX_CLOCK_REALTIME" },
2490 # ifndef FUTEX_OP_SET
2491 # define FUTEX_OP_SET 0
2492 # define FUTEX_OP_ADD 1
2493 # define FUTEX_OP_OR 2
2494 # define FUTEX_OP_ANDN 3
2495 # define FUTEX_OP_XOR 4
2496 # define FUTEX_OP_CMP_EQ 0
2497 # define FUTEX_OP_CMP_NE 1
2498 # define FUTEX_OP_CMP_LT 2
2499 # define FUTEX_OP_CMP_LE 3
2500 # define FUTEX_OP_CMP_GT 4
2501 # define FUTEX_OP_CMP_GE 5
2503 static const struct xlat futexwakeops[] = {
2504 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2505 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2506 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2507 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2508 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2511 static const struct xlat futexwakecmps[] = {
2512 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2513 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2514 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2515 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2516 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2517 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2522 sys_futex(struct tcb *tcp)
2524 if (entering(tcp)) {
2525 long int cmd = tcp->u_arg[1] & 127;
2526 tprintf("%p, ", (void *) tcp->u_arg[0]);
2527 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2528 tprintf(", %ld", tcp->u_arg[2]);
2529 if (cmd == FUTEX_WAKE_BITSET)
2530 tprintf(", %lx", tcp->u_arg[5]);
2531 else if (cmd == FUTEX_WAIT) {
2533 printtv(tcp, tcp->u_arg[3]);
2534 } else if (cmd == FUTEX_WAIT_BITSET) {
2536 printtv(tcp, tcp->u_arg[3]);
2537 tprintf(", %lx", tcp->u_arg[5]);
2538 } else if (cmd == FUTEX_REQUEUE)
2539 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2540 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
2541 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2542 else if (cmd == FUTEX_WAKE_OP) {
2543 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2544 if ((tcp->u_arg[5] >> 28) & 8)
2545 tprints("FUTEX_OP_OPARG_SHIFT|");
2546 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2547 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2548 if ((tcp->u_arg[5] >> 24) & 8)
2549 tprints("FUTEX_OP_OPARG_SHIFT|");
2550 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2551 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
2552 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
2554 printtv(tcp, tcp->u_arg[3]);
2555 tprintf(", %p", (void *) tcp->u_arg[4]);
2562 print_affinitylist(struct tcb *tcp, long list, unsigned int len)
2565 unsigned long w, min_len;
2567 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2568 min_len = len - max_strlen * sizeof(w);
2571 for (; len >= sizeof(w) && len > min_len;
2572 len -= sizeof(w), list += sizeof(w)) {
2573 if (umove(tcp, list, &w) < 0)
2584 tprintf("%#lx", list);
2586 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2589 tprints(first ? "{}" : "}");
2594 sys_sched_setaffinity(struct tcb *tcp)
2596 if (entering(tcp)) {
2597 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2598 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2604 sys_sched_getaffinity(struct tcb *tcp)
2606 if (entering(tcp)) {
2607 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2609 if (tcp->u_rval == -1)
2610 tprintf("%#lx", tcp->u_arg[2]);
2612 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2618 sys_get_robust_list(struct tcb *tcp)
2620 if (entering(tcp)) {
2621 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2626 if (syserror(tcp) ||
2628 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2629 tprintf("%#lx, ", tcp->u_arg[1]);
2631 tprintf("[%p], ", addr);
2634 if (syserror(tcp) ||
2636 umove(tcp, tcp->u_arg[2], &len) < 0) {
2637 tprintf("%#lx", tcp->u_arg[2]);
2639 tprintf("[%lu]", (unsigned long) len);
2645 static const struct xlat schedulers[] = {
2646 { SCHED_OTHER, "SCHED_OTHER" },
2647 { SCHED_RR, "SCHED_RR" },
2648 { SCHED_FIFO, "SCHED_FIFO" },
2653 sys_sched_getscheduler(struct tcb *tcp)
2655 if (entering(tcp)) {
2656 tprintf("%d", (int) tcp->u_arg[0]);
2657 } else if (!syserror(tcp)) {
2658 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
2659 if (tcp->auxstr != NULL)
2666 sys_sched_setscheduler(struct tcb *tcp)
2668 if (entering(tcp)) {
2669 struct sched_param p;
2670 tprintf("%d, ", (int) tcp->u_arg[0]);
2671 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2672 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2673 tprintf(", %#lx", tcp->u_arg[2]);
2675 tprintf(", { %d }", p.__sched_priority);
2681 sys_sched_getparam(struct tcb *tcp)
2683 if (entering(tcp)) {
2684 tprintf("%d, ", (int) tcp->u_arg[0]);
2686 struct sched_param p;
2687 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2688 tprintf("%#lx", tcp->u_arg[1]);
2690 tprintf("{ %d }", p.__sched_priority);
2696 sys_sched_setparam(struct tcb *tcp)
2698 if (entering(tcp)) {
2699 struct sched_param p;
2700 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2701 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2703 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2709 sys_sched_get_priority_min(struct tcb *tcp)
2711 if (entering(tcp)) {
2712 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2718 sys_sched_rr_get_interval(struct tcb *tcp)
2720 if (entering(tcp)) {
2721 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2724 tprintf("%#lx", tcp->u_arg[1]);
2726 print_timespec(tcp, tcp->u_arg[1]);
2732 # include <asm/prctl.h>
2734 static const struct xlat archvals[] = {
2735 { ARCH_SET_GS, "ARCH_SET_GS" },
2736 { ARCH_SET_FS, "ARCH_SET_FS" },
2737 { ARCH_GET_FS, "ARCH_GET_FS" },
2738 { ARCH_GET_GS, "ARCH_GET_GS" },
2743 sys_arch_prctl(struct tcb *tcp)
2745 if (entering(tcp)) {
2746 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2747 if (tcp->u_arg[0] == ARCH_SET_GS
2748 || tcp->u_arg[0] == ARCH_SET_FS
2750 tprintf(", %#lx", tcp->u_arg[1]);
2753 if (tcp->u_arg[0] == ARCH_GET_GS
2754 || tcp->u_arg[0] == ARCH_GET_FS
2757 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2758 tprintf(", [%#lx]", v);
2760 tprintf(", %#lx", tcp->u_arg[1]);
2765 # endif /* X86_64 */
2768 sys_getcpu(struct tcb *tcp)
2772 if (tcp->u_arg[0] == 0)
2774 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2775 tprintf("%#lx, ", tcp->u_arg[0]);
2777 tprintf("[%u], ", u);
2778 if (tcp->u_arg[1] == 0)
2780 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2781 tprintf("%#lx, ", tcp->u_arg[1]);
2783 tprintf("[%u], ", u);
2784 tprintf("%#lx", tcp->u_arg[2]);
2790 sys_process_vm_readv(struct tcb *tcp)
2792 if (entering(tcp)) {
2794 tprintf("%ld, ", tcp->u_arg[0]);
2796 /* arg 2: local iov */
2797 if (syserror(tcp)) {
2798 tprintf("%#lx", tcp->u_arg[1]);
2800 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2802 /* arg 3: local iovcnt */
2803 tprintf(", %lu, ", tcp->u_arg[2]);
2804 /* arg 4: remote iov */
2805 if (syserror(tcp)) {
2806 tprintf("%#lx", tcp->u_arg[3]);
2808 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2810 /* arg 5: remote iovcnt */
2812 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
2818 sys_process_vm_writev(struct tcb *tcp)
2820 if (entering(tcp)) {
2822 tprintf("%ld, ", tcp->u_arg[0]);
2823 /* arg 2: local iov */
2825 tprintf("%#lx", tcp->u_arg[1]);
2827 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2828 /* arg 3: local iovcnt */
2829 tprintf(", %lu, ", tcp->u_arg[2]);
2830 /* arg 4: remote iov */
2832 tprintf("%#lx", tcp->u_arg[3]);
2834 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2835 /* arg 5: remote iovcnt */
2837 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);