]> granicus.if.org Git - strace/blob - process.c
Decode mtd ioctls
[strace] / process.c
1 /*
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>
11  *
12  * All rights reserved.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the distribution.
22  * 3. The name of the author may not be used to endorse or promote products
23  *    derived from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36
37 #include "defs.h"
38 #include <fcntl.h>
39 #include <sys/stat.h>
40 #include <sys/wait.h>
41 #include <sys/resource.h>
42 #include <sys/utsname.h>
43 #include <sys/user.h>
44
45 #ifdef HAVE_SYS_REG_H
46 # include <sys/reg.h>
47 # ifndef PTRACE_PEEKUSR
48 #  define PTRACE_PEEKUSR PTRACE_PEEKUSER
49 # endif
50 # ifndef PTRACE_POKEUSR
51 #  define PTRACE_POKEUSR PTRACE_POKEUSER
52 # endif
53 #endif
54
55 #ifdef HAVE_LINUX_PTRACE_H
56 # undef PTRACE_SYSCALL
57 # ifdef HAVE_STRUCT_IA64_FPREG
58 #  define ia64_fpreg XXX_ia64_fpreg
59 # endif
60 # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
61 #  define pt_all_user_regs XXX_pt_all_user_regs
62 # endif
63 # include <linux/ptrace.h>
64 # undef ia64_fpreg
65 # undef pt_all_user_regs
66 #endif
67
68 #if defined(SPARC64)
69 # define r_pc r_tpc
70 # undef PTRACE_GETREGS
71 # define PTRACE_GETREGS PTRACE_GETREGS64
72 # undef PTRACE_SETREGS
73 # define PTRACE_SETREGS PTRACE_SETREGS64
74 #endif
75
76 #ifdef HAVE_LINUX_FUTEX_H
77 # include <linux/futex.h>
78 #endif
79 #ifndef FUTEX_WAIT
80 # define FUTEX_WAIT 0
81 #endif
82 #ifndef FUTEX_WAKE
83 # define FUTEX_WAKE 1
84 #endif
85 #ifndef FUTEX_FD
86 # define FUTEX_FD 2
87 #endif
88 #ifndef FUTEX_REQUEUE
89 # define FUTEX_REQUEUE 3
90 #endif
91
92 #include <sched.h>
93 #include <asm/posix_types.h>
94 #undef GETGROUPS_T
95 #define GETGROUPS_T __kernel_gid_t
96 #undef GETGROUPS32_T
97 #define GETGROUPS32_T __kernel_gid32_t
98
99 #if defined(IA64)
100 # include <asm/ptrace_offsets.h>
101 # include <asm/rse.h>
102 #endif
103
104 #ifdef HAVE_PRCTL
105 # include <sys/prctl.h>
106
107 static const struct xlat prctl_options[] = {
108 #ifdef PR_MAXPROCS
109         { PR_MAXPROCS,          "PR_MAXPROCS"           },
110 #endif
111 #ifdef PR_ISBLOCKED
112         { PR_ISBLOCKED,         "PR_ISBLOCKED"          },
113 #endif
114 #ifdef PR_SETSTACKSIZE
115         { PR_SETSTACKSIZE,      "PR_SETSTACKSIZE"       },
116 #endif
117 #ifdef PR_GETSTACKSIZE
118         { PR_GETSTACKSIZE,      "PR_GETSTACKSIZE"       },
119 #endif
120 #ifdef PR_MAXPPROCS
121         { PR_MAXPPROCS,         "PR_MAXPPROCS"          },
122 #endif
123 #ifdef PR_UNBLKONEXEC
124         { PR_UNBLKONEXEC,       "PR_UNBLKONEXEC"        },
125 #endif
126 #ifdef PR_ATOMICSIM
127         { PR_ATOMICSIM,         "PR_ATOMICSIM"          },
128 #endif
129 #ifdef PR_SETEXITSIG
130         { PR_SETEXITSIG,        "PR_SETEXITSIG"         },
131 #endif
132 #ifdef PR_RESIDENT
133         { PR_RESIDENT,          "PR_RESIDENT"           },
134 #endif
135 #ifdef PR_ATTACHADDR
136         { PR_ATTACHADDR,        "PR_ATTACHADDR"         },
137 #endif
138 #ifdef PR_DETACHADDR
139         { PR_DETACHADDR,        "PR_DETACHADDR"         },
140 #endif
141 #ifdef PR_TERMCHILD
142         { PR_TERMCHILD,         "PR_TERMCHILD"          },
143 #endif
144 #ifdef PR_GETSHMASK
145         { PR_GETSHMASK,         "PR_GETSHMASK"          },
146 #endif
147 #ifdef PR_GETNSHARE
148         { PR_GETNSHARE,         "PR_GETNSHARE"          },
149 #endif
150 #ifdef PR_COREPID
151         { PR_COREPID,           "PR_COREPID"            },
152 #endif
153 #ifdef PR_ATTACHADDRPERM
154         { PR_ATTACHADDRPERM,    "PR_ATTACHADDRPERM"     },
155 #endif
156 #ifdef PR_PTHREADEXIT
157         { PR_PTHREADEXIT,       "PR_PTHREADEXIT"        },
158 #endif
159 #ifdef PR_SET_PDEATHSIG
160         { PR_SET_PDEATHSIG,     "PR_SET_PDEATHSIG"      },
161 #endif
162 #ifdef PR_GET_PDEATHSIG
163         { PR_GET_PDEATHSIG,     "PR_GET_PDEATHSIG"      },
164 #endif
165 #ifdef PR_GET_DUMPABLE
166         { PR_GET_DUMPABLE,      "PR_GET_DUMPABLE"       },
167 #endif
168 #ifdef PR_SET_DUMPABLE
169         { PR_SET_DUMPABLE,      "PR_SET_DUMPABLE"       },
170 #endif
171 #ifdef PR_GET_UNALIGN
172         { PR_GET_UNALIGN,       "PR_GET_UNALIGN"        },
173 #endif
174 #ifdef PR_SET_UNALIGN
175         { PR_SET_UNALIGN,       "PR_SET_UNALIGN"        },
176 #endif
177 #ifdef PR_GET_KEEPCAPS
178         { PR_GET_KEEPCAPS,      "PR_GET_KEEPCAPS"       },
179 #endif
180 #ifdef PR_SET_KEEPCAPS
181         { PR_SET_KEEPCAPS,      "PR_SET_KEEPCAPS"       },
182 #endif
183 #ifdef PR_GET_FPEMU
184         { PR_GET_FPEMU,         "PR_GET_FPEMU"          },
185 #endif
186 #ifdef PR_SET_FPEMU
187         { PR_SET_FPEMU,         "PR_SET_FPEMU"          },
188 #endif
189 #ifdef PR_GET_FPEXC
190         { PR_GET_FPEXC,         "PR_GET_FPEXC"          },
191 #endif
192 #ifdef PR_SET_FPEXC
193         { PR_SET_FPEXC,         "PR_SET_FPEXC"          },
194 #endif
195 #ifdef PR_GET_TIMING
196         { PR_GET_TIMING,        "PR_GET_TIMING"         },
197 #endif
198 #ifdef PR_SET_TIMING
199         { PR_SET_TIMING,        "PR_SET_TIMING"         },
200 #endif
201 #ifdef PR_SET_NAME
202         { PR_SET_NAME,          "PR_SET_NAME"           },
203 #endif
204 #ifdef PR_GET_NAME
205         { PR_GET_NAME,          "PR_GET_NAME"           },
206 #endif
207 #ifdef PR_GET_ENDIAN
208         { PR_GET_ENDIAN,        "PR_GET_ENDIAN"         },
209 #endif
210 #ifdef PR_SET_ENDIAN
211         { PR_SET_ENDIAN,        "PR_SET_ENDIAN"         },
212 #endif
213 #ifdef PR_GET_SECCOMP
214         { PR_GET_SECCOMP,       "PR_GET_SECCOMP"        },
215 #endif
216 #ifdef PR_SET_SECCOMP
217         { PR_SET_SECCOMP,       "PR_SET_SECCOMP"        },
218 #endif
219 #ifdef PR_GET_TSC
220         { PR_GET_TSC,           "PR_GET_TSC"            },
221 #endif
222 #ifdef PR_SET_TSC
223         { PR_SET_TSC,           "PR_SET_TSC"            },
224 #endif
225 #ifdef PR_GET_SECUREBITS
226         { PR_GET_SECUREBITS,    "PR_GET_SECUREBITS"     },
227 #endif
228 #ifdef PR_SET_SECUREBITS
229         { PR_SET_SECUREBITS,    "PR_SET_SECUREBITS"     },
230 #endif
231         { 0,                    NULL                    },
232 };
233
234 static const char *
235 unalignctl_string(unsigned int ctl)
236 {
237         static char buf[sizeof(int)*2 + 2];
238
239         switch (ctl) {
240 #ifdef PR_UNALIGN_NOPRINT
241                 case PR_UNALIGN_NOPRINT:
242                         return "NOPRINT";
243 #endif
244 #ifdef PR_UNALIGN_SIGBUS
245                 case PR_UNALIGN_SIGBUS:
246                         return "SIGBUS";
247 #endif
248                 default:
249                         break;
250         }
251         sprintf(buf, "%x", ctl);
252         return buf;
253 }
254
255 int
256 sys_prctl(struct tcb *tcp)
257 {
258         int i;
259
260         if (entering(tcp)) {
261                 printxval(prctl_options, tcp->u_arg[0], "PR_???");
262                 switch (tcp->u_arg[0]) {
263 #ifdef PR_GETNSHARE
264                 case PR_GETNSHARE:
265                         break;
266 #endif
267 #ifdef PR_SET_PDEATHSIG
268                 case PR_SET_PDEATHSIG:
269                         tprintf(", %lu", tcp->u_arg[1]);
270                         break;
271 #endif
272 #ifdef PR_GET_PDEATHSIG
273                 case PR_GET_PDEATHSIG:
274                         break;
275 #endif
276 #ifdef PR_SET_DUMPABLE
277                 case PR_SET_DUMPABLE:
278                         tprintf(", %lu", tcp->u_arg[1]);
279                         break;
280 #endif
281 #ifdef PR_GET_DUMPABLE
282                 case PR_GET_DUMPABLE:
283                         break;
284 #endif
285 #ifdef PR_SET_UNALIGN
286                 case PR_SET_UNALIGN:
287                         tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
288                         break;
289 #endif
290 #ifdef PR_GET_UNALIGN
291                 case PR_GET_UNALIGN:
292                         tprintf(", %#lx", tcp->u_arg[1]);
293                         break;
294 #endif
295 #ifdef PR_SET_KEEPCAPS
296                 case PR_SET_KEEPCAPS:
297                         tprintf(", %lu", tcp->u_arg[1]);
298                         break;
299 #endif
300 #ifdef PR_GET_KEEPCAPS
301                 case PR_GET_KEEPCAPS:
302                         break;
303 #endif
304                 default:
305                         for (i = 1; i < tcp->u_nargs; i++)
306                                 tprintf(", %#lx", tcp->u_arg[i]);
307                         break;
308                 }
309         } else {
310                 switch (tcp->u_arg[0]) {
311 #ifdef PR_GET_PDEATHSIG
312                 case PR_GET_PDEATHSIG:
313                         if (umove(tcp, tcp->u_arg[1], &i) < 0)
314                                 tprintf(", %#lx", tcp->u_arg[1]);
315                         else
316                                 tprintf(", {%u}", i);
317                         break;
318 #endif
319 #ifdef PR_GET_DUMPABLE
320                 case PR_GET_DUMPABLE:
321                         return RVAL_UDECIMAL;
322 #endif
323 #ifdef PR_GET_UNALIGN
324                 case PR_GET_UNALIGN:
325                         if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
326                                 break;
327                         tcp->auxstr = unalignctl_string(i);
328                         return RVAL_STR;
329 #endif
330 #ifdef PR_GET_KEEPCAPS
331                 case PR_GET_KEEPCAPS:
332                         return RVAL_UDECIMAL;
333 #endif
334                 default:
335                         break;
336                 }
337         }
338         return 0;
339 }
340 #endif /* HAVE_PRCTL */
341
342 int
343 sys_sethostname(struct tcb *tcp)
344 {
345         if (entering(tcp)) {
346                 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
347                 tprintf(", %lu", tcp->u_arg[1]);
348         }
349         return 0;
350 }
351
352 #if defined(ALPHA)
353 int
354 sys_gethostname(struct tcb *tcp)
355 {
356         if (exiting(tcp)) {
357                 if (syserror(tcp))
358                         tprintf("%#lx", tcp->u_arg[0]);
359                 else
360                         printpath(tcp, tcp->u_arg[0]);
361                 tprintf(", %lu", tcp->u_arg[1]);
362         }
363         return 0;
364 }
365 #endif
366
367 int
368 sys_setdomainname(struct tcb *tcp)
369 {
370         if (entering(tcp)) {
371                 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
372                 tprintf(", %lu", tcp->u_arg[1]);
373         }
374         return 0;
375 }
376
377 int
378 sys_exit(struct tcb *tcp)
379 {
380         if (exiting(tcp)) {
381                 fprintf(stderr, "_exit returned!\n");
382                 return -1;
383         }
384         /* special case: we stop tracing this process, finish line now */
385         tprintf("%ld) ", tcp->u_arg[0]);
386         tabto();
387         tprints("= ?\n");
388         line_ended();
389         return 0;
390 }
391
392 /* defines copied from linux/sched.h since we can't include that
393  * ourselves (it conflicts with *lots* of libc includes)
394  */
395 #define CSIGNAL         0x000000ff      /* signal mask to be sent at exit */
396 #define CLONE_VM        0x00000100      /* set if VM shared between processes */
397 #define CLONE_FS        0x00000200      /* set if fs info shared between processes */
398 #define CLONE_FILES     0x00000400      /* set if open files shared between processes */
399 #define CLONE_SIGHAND   0x00000800      /* set if signal handlers shared */
400 #define CLONE_IDLETASK  0x00001000      /* kernel-only flag */
401 #define CLONE_PTRACE    0x00002000      /* set if we want to let tracing continue on the child too */
402 #define CLONE_VFORK     0x00004000      /* set if the parent wants the child to wake it up on mm_release */
403 #define CLONE_PARENT    0x00008000      /* set if we want to have the same parent as the cloner */
404 #define CLONE_THREAD    0x00010000      /* Same thread group? */
405 #define CLONE_NEWNS     0x00020000      /* New namespace group? */
406 #define CLONE_SYSVSEM   0x00040000      /* share system V SEM_UNDO semantics */
407 #define CLONE_SETTLS    0x00080000      /* create a new TLS for the child */
408 #define CLONE_PARENT_SETTID     0x00100000      /* set the TID in the parent */
409 #define CLONE_CHILD_CLEARTID    0x00200000      /* clear the TID in the child */
410 #define CLONE_UNTRACED          0x00800000      /* set if the tracing process can't force CLONE_PTRACE on this clone */
411 #define CLONE_CHILD_SETTID      0x01000000      /* set the TID in the child */
412 #define CLONE_STOPPED           0x02000000      /* Start in stopped state */
413 #define CLONE_NEWUTS            0x04000000      /* New utsname group? */
414 #define CLONE_NEWIPC            0x08000000      /* New ipcs */
415 #define CLONE_NEWUSER           0x10000000      /* New user namespace */
416 #define CLONE_NEWPID            0x20000000      /* New pid namespace */
417 #define CLONE_NEWNET            0x40000000      /* New network namespace */
418 #define CLONE_IO                0x80000000      /* Clone io context */
419
420 static const struct xlat clone_flags[] = {
421         { CLONE_VM,             "CLONE_VM"      },
422         { CLONE_FS,             "CLONE_FS"      },
423         { CLONE_FILES,          "CLONE_FILES"   },
424         { CLONE_SIGHAND,        "CLONE_SIGHAND" },
425         { CLONE_IDLETASK,       "CLONE_IDLETASK" },
426         { CLONE_PTRACE,         "CLONE_PTRACE"  },
427         { CLONE_VFORK,          "CLONE_VFORK"   },
428         { CLONE_PARENT,         "CLONE_PARENT"  },
429         { CLONE_THREAD,         "CLONE_THREAD"  },
430         { CLONE_NEWNS,          "CLONE_NEWNS"   },
431         { CLONE_SYSVSEM,        "CLONE_SYSVSEM" },
432         { CLONE_SETTLS,         "CLONE_SETTLS"  },
433         { CLONE_PARENT_SETTID,  "CLONE_PARENT_SETTID" },
434         { CLONE_CHILD_CLEARTID, "CLONE_CHILD_CLEARTID" },
435         { CLONE_UNTRACED,       "CLONE_UNTRACED" },
436         { CLONE_CHILD_SETTID,   "CLONE_CHILD_SETTID" },
437         { CLONE_STOPPED,        "CLONE_STOPPED" },
438         { CLONE_NEWUTS,         "CLONE_NEWUTS"  },
439         { CLONE_NEWIPC,         "CLONE_NEWIPC"  },
440         { CLONE_NEWUSER,        "CLONE_NEWUSER" },
441         { CLONE_NEWPID,         "CLONE_NEWPID"  },
442         { CLONE_NEWNET,         "CLONE_NEWNET"  },
443         { CLONE_IO,             "CLONE_IO"      },
444         { 0,                    NULL            },
445 };
446
447 #ifdef I386
448 # include <asm/ldt.h>
449 #  ifdef HAVE_STRUCT_USER_DESC
450 #   define modify_ldt_ldt_s user_desc
451 #  endif
452 extern void print_ldt_entry();
453 #endif
454
455 #if defined IA64
456 # define ARG_FLAGS      0
457 # define ARG_STACK      1
458 # define ARG_STACKSIZE  (tcp->scno == SYS_clone2 ? 2 : -1)
459 # define ARG_PTID       (tcp->scno == SYS_clone2 ? 3 : 2)
460 # define ARG_CTID       (tcp->scno == SYS_clone2 ? 4 : 3)
461 # define ARG_TLS        (tcp->scno == SYS_clone2 ? 5 : 4)
462 #elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
463 # define ARG_STACK      0
464 # define ARG_FLAGS      1
465 # define ARG_PTID       2
466 # define ARG_CTID       3
467 # define ARG_TLS        4
468 #elif defined X86_64 || defined ALPHA
469 # define ARG_FLAGS      0
470 # define ARG_STACK      1
471 # define ARG_PTID       2
472 # define ARG_CTID       3
473 # define ARG_TLS        4
474 #else
475 # define ARG_FLAGS      0
476 # define ARG_STACK      1
477 # define ARG_PTID       2
478 # define ARG_TLS        3
479 # define ARG_CTID       4
480 #endif
481
482 int
483 sys_clone(struct tcb *tcp)
484 {
485         if (exiting(tcp)) {
486                 const char *sep = "|";
487                 unsigned long flags = tcp->u_arg[ARG_FLAGS];
488                 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
489 #ifdef ARG_STACKSIZE
490                 if (ARG_STACKSIZE != -1)
491                         tprintf("stack_size=%#lx, ",
492                                 tcp->u_arg[ARG_STACKSIZE]);
493 #endif
494                 tprints("flags=");
495                 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
496                         sep = "";
497                 if ((flags & CSIGNAL) != 0)
498                         tprintf("%s%s", sep, signame(flags & CSIGNAL));
499                 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
500                               |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
501                         return 0;
502                 if (flags & CLONE_PARENT_SETTID)
503                         tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
504                 if (flags & CLONE_SETTLS) {
505 #ifdef I386
506                         struct modify_ldt_ldt_s copy;
507                         if (umove(tcp, tcp->u_arg[ARG_TLS], &copy) != -1) {
508                                 tprintf(", {entry_number:%d, ",
509                                         copy.entry_number);
510                                 if (!verbose(tcp))
511                                         tprints("...}");
512                                 else
513                                         print_ldt_entry(&copy);
514                         }
515                         else
516 #endif
517                                 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
518                 }
519                 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
520                         tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
521         }
522         return 0;
523 }
524
525 int
526 sys_unshare(struct tcb *tcp)
527 {
528         if (entering(tcp))
529                 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
530         return 0;
531 }
532
533 int
534 sys_fork(struct tcb *tcp)
535 {
536         if (exiting(tcp))
537                 return RVAL_UDECIMAL;
538         return 0;
539 }
540
541 int
542 sys_vfork(struct tcb *tcp)
543 {
544         if (exiting(tcp))
545                 return RVAL_UDECIMAL;
546         return 0;
547 }
548
549 int sys_getuid(struct tcb *tcp)
550 {
551         if (exiting(tcp))
552                 tcp->u_rval = (uid_t) tcp->u_rval;
553         return RVAL_UDECIMAL;
554 }
555
556 int sys_setfsuid(struct tcb *tcp)
557 {
558         if (entering(tcp))
559                 tprintf("%u", (uid_t) tcp->u_arg[0]);
560         else
561                 tcp->u_rval = (uid_t) tcp->u_rval;
562         return RVAL_UDECIMAL;
563 }
564
565 int
566 sys_setuid(struct tcb *tcp)
567 {
568         if (entering(tcp)) {
569                 tprintf("%u", (uid_t) tcp->u_arg[0]);
570         }
571         return 0;
572 }
573
574 int
575 sys_getresuid(struct tcb *tcp)
576 {
577         if (exiting(tcp)) {
578                 __kernel_uid_t uid;
579                 if (syserror(tcp))
580                         tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
581                                 tcp->u_arg[1], tcp->u_arg[2]);
582                 else {
583                         if (umove(tcp, tcp->u_arg[0], &uid) < 0)
584                                 tprintf("%#lx, ", tcp->u_arg[0]);
585                         else
586                                 tprintf("[%lu], ", (unsigned long) uid);
587                         if (umove(tcp, tcp->u_arg[1], &uid) < 0)
588                                 tprintf("%#lx, ", tcp->u_arg[1]);
589                         else
590                                 tprintf("[%lu], ", (unsigned long) uid);
591                         if (umove(tcp, tcp->u_arg[2], &uid) < 0)
592                                 tprintf("%#lx", tcp->u_arg[2]);
593                         else
594                                 tprintf("[%lu]", (unsigned long) uid);
595                 }
596         }
597         return 0;
598 }
599
600 int
601 sys_setreuid(struct tcb *tcp)
602 {
603         if (entering(tcp)) {
604                 printuid("", tcp->u_arg[0]);
605                 printuid(", ", tcp->u_arg[1]);
606         }
607         return 0;
608 }
609
610 int
611 sys_setresuid(struct tcb *tcp)
612 {
613         if (entering(tcp)) {
614                 printuid("", tcp->u_arg[0]);
615                 printuid(", ", tcp->u_arg[1]);
616                 printuid(", ", tcp->u_arg[2]);
617         }
618         return 0;
619 }
620
621 int
622 sys_setgroups(struct tcb *tcp)
623 {
624         if (entering(tcp)) {
625                 unsigned long len, size, start, cur, end, abbrev_end;
626                 GETGROUPS_T gid;
627                 int failed = 0;
628
629                 len = tcp->u_arg[0];
630                 tprintf("%lu, ", len);
631                 if (len == 0) {
632                         tprints("[]");
633                         return 0;
634                 }
635                 start = tcp->u_arg[1];
636                 if (start == 0) {
637                         tprints("NULL");
638                         return 0;
639                 }
640                 size = len * sizeof(gid);
641                 end = start + size;
642                 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
643                         tprintf("%#lx", start);
644                         return 0;
645                 }
646                 if (abbrev(tcp)) {
647                         abbrev_end = start + max_strlen * sizeof(gid);
648                         if (abbrev_end < start)
649                                 abbrev_end = end;
650                 } else {
651                         abbrev_end = end;
652                 }
653                 tprints("[");
654                 for (cur = start; cur < end; cur += sizeof(gid)) {
655                         if (cur > start)
656                                 tprints(", ");
657                         if (cur >= abbrev_end) {
658                                 tprints("...");
659                                 break;
660                         }
661                         if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
662                                 tprints("?");
663                                 failed = 1;
664                                 break;
665                         }
666                         tprintf("%lu", (unsigned long) gid);
667                 }
668                 tprints("]");
669                 if (failed)
670                         tprintf(" %#lx", tcp->u_arg[1]);
671         }
672         return 0;
673 }
674
675 int
676 sys_getgroups(struct tcb *tcp)
677 {
678         unsigned long len;
679
680         if (entering(tcp)) {
681                 len = tcp->u_arg[0];
682                 tprintf("%lu, ", len);
683         } else {
684                 unsigned long size, start, cur, end, abbrev_end;
685                 GETGROUPS_T gid;
686                 int failed = 0;
687
688                 len = tcp->u_rval;
689                 if (len == 0) {
690                         tprints("[]");
691                         return 0;
692                 }
693                 start = tcp->u_arg[1];
694                 if (start == 0) {
695                         tprints("NULL");
696                         return 0;
697                 }
698                 if (tcp->u_arg[0] == 0) {
699                         tprintf("%#lx", start);
700                         return 0;
701                 }
702                 size = len * sizeof(gid);
703                 end = start + size;
704                 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
705                     size / sizeof(gid) != len || end < start) {
706                         tprintf("%#lx", start);
707                         return 0;
708                 }
709                 if (abbrev(tcp)) {
710                         abbrev_end = start + max_strlen * sizeof(gid);
711                         if (abbrev_end < start)
712                                 abbrev_end = end;
713                 } else {
714                         abbrev_end = end;
715                 }
716                 tprints("[");
717                 for (cur = start; cur < end; cur += sizeof(gid)) {
718                         if (cur > start)
719                                 tprints(", ");
720                         if (cur >= abbrev_end) {
721                                 tprints("...");
722                                 break;
723                         }
724                         if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
725                                 tprints("?");
726                                 failed = 1;
727                                 break;
728                         }
729                         tprintf("%lu", (unsigned long) gid);
730                 }
731                 tprints("]");
732                 if (failed)
733                         tprintf(" %#lx", tcp->u_arg[1]);
734         }
735         return 0;
736 }
737
738 int
739 sys_setgroups32(struct tcb *tcp)
740 {
741         if (entering(tcp)) {
742                 unsigned long len, size, start, cur, end, abbrev_end;
743                 GETGROUPS32_T gid;
744                 int failed = 0;
745
746                 len = tcp->u_arg[0];
747                 tprintf("%lu, ", len);
748                 if (len == 0) {
749                         tprints("[]");
750                         return 0;
751                 }
752                 start = tcp->u_arg[1];
753                 if (start == 0) {
754                         tprints("NULL");
755                         return 0;
756                 }
757                 size = len * sizeof(gid);
758                 end = start + size;
759                 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
760                         tprintf("%#lx", start);
761                         return 0;
762                 }
763                 if (abbrev(tcp)) {
764                         abbrev_end = start + max_strlen * sizeof(gid);
765                         if (abbrev_end < start)
766                                 abbrev_end = end;
767                 } else {
768                         abbrev_end = end;
769                 }
770                 tprints("[");
771                 for (cur = start; cur < end; cur += sizeof(gid)) {
772                         if (cur > start)
773                                 tprints(", ");
774                         if (cur >= abbrev_end) {
775                                 tprints("...");
776                                 break;
777                         }
778                         if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
779                                 tprints("?");
780                                 failed = 1;
781                                 break;
782                         }
783                         tprintf("%lu", (unsigned long) gid);
784                 }
785                 tprints("]");
786                 if (failed)
787                         tprintf(" %#lx", tcp->u_arg[1]);
788         }
789         return 0;
790 }
791
792 int
793 sys_getgroups32(struct tcb *tcp)
794 {
795         unsigned long len;
796
797         if (entering(tcp)) {
798                 len = tcp->u_arg[0];
799                 tprintf("%lu, ", len);
800         } else {
801                 unsigned long size, start, cur, end, abbrev_end;
802                 GETGROUPS32_T gid;
803                 int failed = 0;
804
805                 len = tcp->u_rval;
806                 if (len == 0) {
807                         tprints("[]");
808                         return 0;
809                 }
810                 start = tcp->u_arg[1];
811                 if (start == 0) {
812                         tprints("NULL");
813                         return 0;
814                 }
815                 size = len * sizeof(gid);
816                 end = start + size;
817                 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
818                     size / sizeof(gid) != len || end < start) {
819                         tprintf("%#lx", start);
820                         return 0;
821                 }
822                 if (abbrev(tcp)) {
823                         abbrev_end = start + max_strlen * sizeof(gid);
824                         if (abbrev_end < start)
825                                 abbrev_end = end;
826                 } else {
827                         abbrev_end = end;
828                 }
829                 tprints("[");
830                 for (cur = start; cur < end; cur += sizeof(gid)) {
831                         if (cur > start)
832                                 tprints(", ");
833                         if (cur >= abbrev_end) {
834                                 tprints("...");
835                                 break;
836                         }
837                         if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
838                                 tprints("?");
839                                 failed = 1;
840                                 break;
841                         }
842                         tprintf("%lu", (unsigned long) gid);
843                 }
844                 tprints("]");
845                 if (failed)
846                         tprintf(" %#lx", tcp->u_arg[1]);
847         }
848         return 0;
849 }
850
851 static void
852 printargv(struct tcb *tcp, long addr)
853 {
854         union {
855                 unsigned int p32;
856                 unsigned long p64;
857                 char data[sizeof(long)];
858         } cp;
859         const char *sep;
860         int n = 0;
861         unsigned wordsize = current_wordsize;
862
863         cp.p64 = 1;
864         for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
865                 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
866                         tprintf("%#lx", addr);
867                         return;
868                 }
869                 if (wordsize == 4)
870                         cp.p64 = cp.p32;
871                 if (cp.p64 == 0)
872                         break;
873                 tprints(sep);
874                 printstr(tcp, cp.p64, -1);
875                 addr += wordsize;
876         }
877         if (cp.p64)
878                 tprintf("%s...", sep);
879 }
880
881 static void
882 printargc(const char *fmt, struct tcb *tcp, long addr)
883 {
884         int count;
885         char *cp;
886
887         for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
888                 addr += sizeof(char *);
889         }
890         tprintf(fmt, count, count == 1 ? "" : "s");
891 }
892
893 #if defined(SPARC) || defined(SPARC64)
894 int
895 sys_execv(struct tcb *tcp)
896 {
897         if (entering(tcp)) {
898                 printpath(tcp, tcp->u_arg[0]);
899                 if (!verbose(tcp))
900                         tprintf(", %#lx", tcp->u_arg[1]);
901                 else {
902                         tprints(", [");
903                         printargv(tcp, tcp->u_arg[1]);
904                         tprints("]");
905                 }
906         }
907         return 0;
908 }
909 #endif
910
911 int
912 sys_execve(struct tcb *tcp)
913 {
914         if (entering(tcp)) {
915                 printpath(tcp, tcp->u_arg[0]);
916                 if (!verbose(tcp))
917                         tprintf(", %#lx", tcp->u_arg[1]);
918                 else {
919                         tprints(", [");
920                         printargv(tcp, tcp->u_arg[1]);
921                         tprints("]");
922                 }
923                 if (!verbose(tcp))
924                         tprintf(", %#lx", tcp->u_arg[2]);
925                 else if (abbrev(tcp))
926                         printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
927                 else {
928                         tprints(", [");
929                         printargv(tcp, tcp->u_arg[2]);
930                         tprints("]");
931                 }
932         }
933         return 0;
934 }
935
936 #ifndef __WNOTHREAD
937 #define __WNOTHREAD     0x20000000
938 #endif
939 #ifndef __WALL
940 #define __WALL          0x40000000
941 #endif
942 #ifndef __WCLONE
943 #define __WCLONE        0x80000000
944 #endif
945
946 static const struct xlat wait4_options[] = {
947         { WNOHANG,      "WNOHANG"       },
948 #ifndef WSTOPPED
949         { WUNTRACED,    "WUNTRACED"     },
950 #endif
951 #ifdef WEXITED
952         { WEXITED,      "WEXITED"       },
953 #endif
954 #ifdef WTRAPPED
955         { WTRAPPED,     "WTRAPPED"      },
956 #endif
957 #ifdef WSTOPPED
958         { WSTOPPED,     "WSTOPPED"      },
959 #endif
960 #ifdef WCONTINUED
961         { WCONTINUED,   "WCONTINUED"    },
962 #endif
963 #ifdef WNOWAIT
964         { WNOWAIT,      "WNOWAIT"       },
965 #endif
966 #ifdef __WCLONE
967         { __WCLONE,     "__WCLONE"      },
968 #endif
969 #ifdef __WALL
970         { __WALL,       "__WALL"        },
971 #endif
972 #ifdef __WNOTHREAD
973         { __WNOTHREAD,  "__WNOTHREAD"   },
974 #endif
975         { 0,            NULL            },
976 };
977
978 #if !defined WCOREFLAG && defined WCOREFLG
979 # define WCOREFLAG WCOREFLG
980 #endif
981 #ifndef WCOREFLAG
982 # define WCOREFLAG 0x80
983 #endif
984 #ifndef WCOREDUMP
985 # define WCOREDUMP(status)  ((status) & 0200)
986 #endif
987 #ifndef W_STOPCODE
988 # define W_STOPCODE(sig)  ((sig) << 8 | 0x7f)
989 #endif
990 #ifndef W_EXITCODE
991 # define W_EXITCODE(ret, sig)  ((ret) << 8 | (sig))
992 #endif
993
994 static int
995 printstatus(int status)
996 {
997         int exited = 0;
998
999         /*
1000          * Here is a tricky presentation problem.  This solution
1001          * is still not entirely satisfactory but since there
1002          * are no wait status constructors it will have to do.
1003          */
1004         if (WIFSTOPPED(status)) {
1005                 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
1006                         signame(WSTOPSIG(status)));
1007                 status &= ~W_STOPCODE(WSTOPSIG(status));
1008         }
1009         else if (WIFSIGNALED(status)) {
1010                 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
1011                         signame(WTERMSIG(status)),
1012                         WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
1013                 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1014         }
1015         else if (WIFEXITED(status)) {
1016                 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
1017                         WEXITSTATUS(status));
1018                 exited = 1;
1019                 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
1020         }
1021         else {
1022                 tprintf("[%#x]", status);
1023                 return 0;
1024         }
1025
1026         if (status == 0)
1027                 tprints("]");
1028         else
1029                 tprintf(" | %#x]", status);
1030
1031         return exited;
1032 }
1033
1034 static int
1035 printwaitn(struct tcb *tcp, int n, int bitness)
1036 {
1037         int status;
1038
1039         if (entering(tcp)) {
1040                 /* On Linux, kernel-side pid_t is typedef'ed to int
1041                  * on all arches. Also, glibc-2.8 truncates wait3 and wait4
1042                  * pid argument to int on 64bit arches, producing,
1043                  * for example, wait4(4294967295, ...) instead of -1
1044                  * in strace. We have to use int here, not long.
1045                  */
1046                 int pid = tcp->u_arg[0];
1047                 tprintf("%d, ", pid);
1048         } else {
1049                 /* status */
1050                 if (!tcp->u_arg[1])
1051                         tprints("NULL");
1052                 else if (syserror(tcp) || tcp->u_rval == 0)
1053                         tprintf("%#lx", tcp->u_arg[1]);
1054                 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
1055                         tprints("[?]");
1056                 else
1057                         printstatus(status);
1058                 /* options */
1059                 tprints(", ");
1060                 printflags(wait4_options, tcp->u_arg[2], "W???");
1061                 if (n == 4) {
1062                         tprints(", ");
1063                         /* usage */
1064                         if (!tcp->u_arg[3])
1065                                 tprints("NULL");
1066                         else if (tcp->u_rval > 0) {
1067 #ifdef ALPHA
1068                                 if (bitness)
1069                                         printrusage32(tcp, tcp->u_arg[3]);
1070                                 else
1071 #endif
1072                                         printrusage(tcp, tcp->u_arg[3]);
1073                         }
1074                         else
1075                                 tprintf("%#lx", tcp->u_arg[3]);
1076                 }
1077         }
1078         return 0;
1079 }
1080
1081 int
1082 sys_waitpid(struct tcb *tcp)
1083 {
1084         return printwaitn(tcp, 3, 0);
1085 }
1086
1087 int
1088 sys_wait4(struct tcb *tcp)
1089 {
1090         return printwaitn(tcp, 4, 0);
1091 }
1092
1093 #ifdef ALPHA
1094 int
1095 sys_osf_wait4(struct tcb *tcp)
1096 {
1097         return printwaitn(tcp, 4, 1);
1098 }
1099 #endif
1100
1101 static const struct xlat waitid_types[] = {
1102         { P_PID,        "P_PID"         },
1103 #ifdef P_PPID
1104         { P_PPID,       "P_PPID"        },
1105 #endif
1106         { P_PGID,       "P_PGID"        },
1107 #ifdef P_SID
1108         { P_SID,        "P_SID"         },
1109 #endif
1110 #ifdef P_CID
1111         { P_CID,        "P_CID"         },
1112 #endif
1113 #ifdef P_UID
1114         { P_UID,        "P_UID"         },
1115 #endif
1116 #ifdef P_GID
1117         { P_GID,        "P_GID"         },
1118 #endif
1119         { P_ALL,        "P_ALL"         },
1120 #ifdef P_LWPID
1121         { P_LWPID,      "P_LWPID"       },
1122 #endif
1123         { 0,            NULL            },
1124 };
1125
1126 int
1127 sys_waitid(struct tcb *tcp)
1128 {
1129         siginfo_t si;
1130
1131         if (entering(tcp)) {
1132                 printxval(waitid_types, tcp->u_arg[0], "P_???");
1133                 tprintf(", %ld, ", tcp->u_arg[1]);
1134         }
1135         else {
1136                 /* siginfo */
1137                 if (!tcp->u_arg[2])
1138                         tprints("NULL");
1139                 else if (syserror(tcp))
1140                         tprintf("%#lx", tcp->u_arg[2]);
1141                 else if (umove(tcp, tcp->u_arg[2], &si) < 0)
1142                         tprints("{???}");
1143                 else
1144                         printsiginfo(&si, verbose(tcp));
1145                 /* options */
1146                 tprints(", ");
1147                 printflags(wait4_options, tcp->u_arg[3], "W???");
1148                 if (tcp->u_nargs > 4) {
1149                         /* usage */
1150                         tprints(", ");
1151                         if (!tcp->u_arg[4])
1152                                 tprints("NULL");
1153                         else if (tcp->u_error)
1154                                 tprintf("%#lx", tcp->u_arg[4]);
1155                         else
1156                                 printrusage(tcp, tcp->u_arg[4]);
1157                 }
1158         }
1159         return 0;
1160 }
1161
1162 int
1163 sys_uname(struct tcb *tcp)
1164 {
1165         struct utsname uname;
1166
1167         if (exiting(tcp)) {
1168                 if (syserror(tcp) || !verbose(tcp))
1169                         tprintf("%#lx", tcp->u_arg[0]);
1170                 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
1171                         tprints("{...}");
1172                 else if (!abbrev(tcp)) {
1173
1174                         tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1175                                 uname.sysname, uname.nodename);
1176                         tprintf("release=\"%s\", version=\"%s\", ",
1177                                 uname.release, uname.version);
1178                         tprintf("machine=\"%s\"", uname.machine);
1179 #ifndef __GLIBC__
1180                         tprintf(", domainname=\"%s\"", uname.domainname);
1181 #endif
1182                         tprints("}");
1183                 }
1184                 else
1185                         tprintf("{sys=\"%s\", node=\"%s\", ...}",
1186                                 uname.sysname, uname.nodename);
1187         }
1188         return 0;
1189 }
1190
1191 static const struct xlat ptrace_cmds[] = {
1192         { PTRACE_TRACEME,       "PTRACE_TRACEME"        },
1193         { PTRACE_PEEKTEXT,      "PTRACE_PEEKTEXT"       },
1194         { PTRACE_PEEKDATA,      "PTRACE_PEEKDATA"       },
1195         { PTRACE_PEEKUSER,      "PTRACE_PEEKUSER"       },
1196         { PTRACE_POKETEXT,      "PTRACE_POKETEXT"       },
1197         { PTRACE_POKEDATA,      "PTRACE_POKEDATA"       },
1198         { PTRACE_POKEUSER,      "PTRACE_POKEUSER"       },
1199         { PTRACE_CONT,          "PTRACE_CONT"           },
1200         { PTRACE_KILL,          "PTRACE_KILL"           },
1201         { PTRACE_SINGLESTEP,    "PTRACE_SINGLESTEP"     },
1202         { PTRACE_ATTACH,        "PTRACE_ATTACH"         },
1203         { PTRACE_DETACH,        "PTRACE_DETACH"         },
1204 #ifdef PTRACE_GETREGS
1205         { PTRACE_GETREGS,       "PTRACE_GETREGS"        },
1206 #endif
1207 #ifdef PTRACE_SETREGS
1208         { PTRACE_SETREGS,       "PTRACE_SETREGS"        },
1209 #endif
1210 #ifdef PTRACE_GETFPREGS
1211         { PTRACE_GETFPREGS,     "PTRACE_GETFPREGS"      },
1212 #endif
1213 #ifdef PTRACE_SETFPREGS
1214         { PTRACE_SETFPREGS,     "PTRACE_SETFPREGS"      },
1215 #endif
1216 #ifdef PTRACE_GETFPXREGS
1217         { PTRACE_GETFPXREGS,    "PTRACE_GETFPXREGS"     },
1218 #endif
1219 #ifdef PTRACE_SETFPXREGS
1220         { PTRACE_SETFPXREGS,    "PTRACE_SETFPXREGS"     },
1221 #endif
1222 #ifdef PTRACE_GETVRREGS
1223         { PTRACE_GETVRREGS,     "PTRACE_GETVRREGS"      },
1224 #endif
1225 #ifdef PTRACE_SETVRREGS
1226         { PTRACE_SETVRREGS,     "PTRACE_SETVRREGS"      },
1227 #endif
1228 #ifdef PTRACE_SETOPTIONS
1229         { PTRACE_SETOPTIONS,    "PTRACE_SETOPTIONS"     },
1230 #endif
1231 #ifdef PTRACE_GETEVENTMSG
1232         { PTRACE_GETEVENTMSG,   "PTRACE_GETEVENTMSG"    },
1233 #endif
1234 #ifdef PTRACE_GETSIGINFO
1235         { PTRACE_GETSIGINFO,    "PTRACE_GETSIGINFO"     },
1236 #endif
1237 #ifdef PTRACE_SETSIGINFO
1238         { PTRACE_SETSIGINFO,    "PTRACE_SETSIGINFO"     },
1239 #endif
1240 #ifdef PTRACE_GETREGSET
1241         { PTRACE_GETREGSET,     "PTRACE_GETREGSET"      },
1242 #endif
1243 #ifdef PTRACE_SETREGSET
1244         { PTRACE_SETREGSET,     "PTRACE_SETREGSET"      },
1245 #endif
1246 #ifdef PTRACE_SET_SYSCALL
1247         { PTRACE_SET_SYSCALL,   "PTRACE_SET_SYSCALL"    },
1248 #endif
1249 #ifdef PTRACE_SEIZE
1250         { PTRACE_SEIZE,         "PTRACE_SEIZE"          },
1251 #endif
1252 #ifdef PTRACE_INTERRUPT
1253         { PTRACE_INTERRUPT,     "PTRACE_INTERRUPT"      },
1254 #endif
1255 #ifdef PTRACE_LISTEN
1256         { PTRACE_LISTEN,        "PTRACE_LISTEN"         },
1257 #endif
1258         { PTRACE_SYSCALL,       "PTRACE_SYSCALL"        },
1259
1260         { 0,                    NULL                    },
1261 };
1262
1263 #ifdef PTRACE_SETOPTIONS
1264 static const struct xlat ptrace_setoptions_flags[] = {
1265 # ifdef PTRACE_O_TRACESYSGOOD
1266         { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
1267 # endif
1268 # ifdef PTRACE_O_TRACEFORK
1269         { PTRACE_O_TRACEFORK,   "PTRACE_O_TRACEFORK"    },
1270 # endif
1271 # ifdef PTRACE_O_TRACEVFORK
1272         { PTRACE_O_TRACEVFORK,  "PTRACE_O_TRACEVFORK"   },
1273 # endif
1274 # ifdef PTRACE_O_TRACECLONE
1275         { PTRACE_O_TRACECLONE,  "PTRACE_O_TRACECLONE"   },
1276 # endif
1277 # ifdef PTRACE_O_TRACEEXEC
1278         { PTRACE_O_TRACEEXEC,   "PTRACE_O_TRACEEXEC"    },
1279 # endif
1280 # ifdef PTRACE_O_TRACEVFORKDONE
1281         { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
1282 # endif
1283 # ifdef PTRACE_O_TRACEEXIT
1284         { PTRACE_O_TRACEEXIT,   "PTRACE_O_TRACEEXIT"    },
1285 # endif
1286         { 0,                    NULL                    },
1287 };
1288 #endif /* PTRACE_SETOPTIONS */
1289
1290 #define uoff(member)    offsetof(struct user, member)
1291
1292 const struct xlat struct_user_offsets[] = {
1293 #if defined(S390) || defined(S390X)
1294         { PT_PSWMASK,           "psw_mask"                              },
1295         { PT_PSWADDR,           "psw_addr"                              },
1296         { PT_GPR0,              "gpr0"                                  },
1297         { PT_GPR1,              "gpr1"                                  },
1298         { PT_GPR2,              "gpr2"                                  },
1299         { PT_GPR3,              "gpr3"                                  },
1300         { PT_GPR4,              "gpr4"                                  },
1301         { PT_GPR5,              "gpr5"                                  },
1302         { PT_GPR6,              "gpr6"                                  },
1303         { PT_GPR7,              "gpr7"                                  },
1304         { PT_GPR8,              "gpr8"                                  },
1305         { PT_GPR9,              "gpr9"                                  },
1306         { PT_GPR10,             "gpr10"                                 },
1307         { PT_GPR11,             "gpr11"                                 },
1308         { PT_GPR12,             "gpr12"                                 },
1309         { PT_GPR13,             "gpr13"                                 },
1310         { PT_GPR14,             "gpr14"                                 },
1311         { PT_GPR15,             "gpr15"                                 },
1312         { PT_ACR0,              "acr0"                                  },
1313         { PT_ACR1,              "acr1"                                  },
1314         { PT_ACR2,              "acr2"                                  },
1315         { PT_ACR3,              "acr3"                                  },
1316         { PT_ACR4,              "acr4"                                  },
1317         { PT_ACR5,              "acr5"                                  },
1318         { PT_ACR6,              "acr6"                                  },
1319         { PT_ACR7,              "acr7"                                  },
1320         { PT_ACR8,              "acr8"                                  },
1321         { PT_ACR9,              "acr9"                                  },
1322         { PT_ACR10,             "acr10"                                 },
1323         { PT_ACR11,             "acr11"                                 },
1324         { PT_ACR12,             "acr12"                                 },
1325         { PT_ACR13,             "acr13"                                 },
1326         { PT_ACR14,             "acr14"                                 },
1327         { PT_ACR15,             "acr15"                                 },
1328         { PT_ORIGGPR2,          "orig_gpr2"                             },
1329         { PT_FPC,               "fpc"                                   },
1330 #if defined(S390)
1331         { PT_FPR0_HI,           "fpr0.hi"                               },
1332         { PT_FPR0_LO,           "fpr0.lo"                               },
1333         { PT_FPR1_HI,           "fpr1.hi"                               },
1334         { PT_FPR1_LO,           "fpr1.lo"                               },
1335         { PT_FPR2_HI,           "fpr2.hi"                               },
1336         { PT_FPR2_LO,           "fpr2.lo"                               },
1337         { PT_FPR3_HI,           "fpr3.hi"                               },
1338         { PT_FPR3_LO,           "fpr3.lo"                               },
1339         { PT_FPR4_HI,           "fpr4.hi"                               },
1340         { PT_FPR4_LO,           "fpr4.lo"                               },
1341         { PT_FPR5_HI,           "fpr5.hi"                               },
1342         { PT_FPR5_LO,           "fpr5.lo"                               },
1343         { PT_FPR6_HI,           "fpr6.hi"                               },
1344         { PT_FPR6_LO,           "fpr6.lo"                               },
1345         { PT_FPR7_HI,           "fpr7.hi"                               },
1346         { PT_FPR7_LO,           "fpr7.lo"                               },
1347         { PT_FPR8_HI,           "fpr8.hi"                               },
1348         { PT_FPR8_LO,           "fpr8.lo"                               },
1349         { PT_FPR9_HI,           "fpr9.hi"                               },
1350         { PT_FPR9_LO,           "fpr9.lo"                               },
1351         { PT_FPR10_HI,          "fpr10.hi"                              },
1352         { PT_FPR10_LO,          "fpr10.lo"                              },
1353         { PT_FPR11_HI,          "fpr11.hi"                              },
1354         { PT_FPR11_LO,          "fpr11.lo"                              },
1355         { PT_FPR12_HI,          "fpr12.hi"                              },
1356         { PT_FPR12_LO,          "fpr12.lo"                              },
1357         { PT_FPR13_HI,          "fpr13.hi"                              },
1358         { PT_FPR13_LO,          "fpr13.lo"                              },
1359         { PT_FPR14_HI,          "fpr14.hi"                              },
1360         { PT_FPR14_LO,          "fpr14.lo"                              },
1361         { PT_FPR15_HI,          "fpr15.hi"                              },
1362         { PT_FPR15_LO,          "fpr15.lo"                              },
1363 #endif
1364 #if defined(S390X)
1365         { PT_FPR0,              "fpr0"                                  },
1366         { PT_FPR1,              "fpr1"                                  },
1367         { PT_FPR2,              "fpr2"                                  },
1368         { PT_FPR3,              "fpr3"                                  },
1369         { PT_FPR4,              "fpr4"                                  },
1370         { PT_FPR5,              "fpr5"                                  },
1371         { PT_FPR6,              "fpr6"                                  },
1372         { PT_FPR7,              "fpr7"                                  },
1373         { PT_FPR8,              "fpr8"                                  },
1374         { PT_FPR9,              "fpr9"                                  },
1375         { PT_FPR10,             "fpr10"                                 },
1376         { PT_FPR11,             "fpr11"                                 },
1377         { PT_FPR12,             "fpr12"                                 },
1378         { PT_FPR13,             "fpr13"                                 },
1379         { PT_FPR14,             "fpr14"                                 },
1380         { PT_FPR15,             "fpr15"                                 },
1381 #endif
1382         { PT_CR_9,              "cr9"                                   },
1383         { PT_CR_10,             "cr10"                                  },
1384         { PT_CR_11,             "cr11"                                  },
1385         { PT_IEEE_IP,           "ieee_exception_ip"                     },
1386 #elif defined(SPARC)
1387         /* XXX No support for these offsets yet. */
1388 #elif defined(HPPA)
1389         /* XXX No support for these offsets yet. */
1390 #elif defined(POWERPC)
1391 # ifndef PT_ORIG_R3
1392 #  define PT_ORIG_R3 34
1393 # endif
1394 # define REGSIZE (sizeof(unsigned long))
1395         { REGSIZE*PT_R0,                "r0"                            },
1396         { REGSIZE*PT_R1,                "r1"                            },
1397         { REGSIZE*PT_R2,                "r2"                            },
1398         { REGSIZE*PT_R3,                "r3"                            },
1399         { REGSIZE*PT_R4,                "r4"                            },
1400         { REGSIZE*PT_R5,                "r5"                            },
1401         { REGSIZE*PT_R6,                "r6"                            },
1402         { REGSIZE*PT_R7,                "r7"                            },
1403         { REGSIZE*PT_R8,                "r8"                            },
1404         { REGSIZE*PT_R9,                "r9"                            },
1405         { REGSIZE*PT_R10,               "r10"                           },
1406         { REGSIZE*PT_R11,               "r11"                           },
1407         { REGSIZE*PT_R12,               "r12"                           },
1408         { REGSIZE*PT_R13,               "r13"                           },
1409         { REGSIZE*PT_R14,               "r14"                           },
1410         { REGSIZE*PT_R15,               "r15"                           },
1411         { REGSIZE*PT_R16,               "r16"                           },
1412         { REGSIZE*PT_R17,               "r17"                           },
1413         { REGSIZE*PT_R18,               "r18"                           },
1414         { REGSIZE*PT_R19,               "r19"                           },
1415         { REGSIZE*PT_R20,               "r20"                           },
1416         { REGSIZE*PT_R21,               "r21"                           },
1417         { REGSIZE*PT_R22,               "r22"                           },
1418         { REGSIZE*PT_R23,               "r23"                           },
1419         { REGSIZE*PT_R24,               "r24"                           },
1420         { REGSIZE*PT_R25,               "r25"                           },
1421         { REGSIZE*PT_R26,               "r26"                           },
1422         { REGSIZE*PT_R27,               "r27"                           },
1423         { REGSIZE*PT_R28,               "r28"                           },
1424         { REGSIZE*PT_R29,               "r29"                           },
1425         { REGSIZE*PT_R30,               "r30"                           },
1426         { REGSIZE*PT_R31,               "r31"                           },
1427         { REGSIZE*PT_NIP,               "NIP"                           },
1428         { REGSIZE*PT_MSR,               "MSR"                           },
1429         { REGSIZE*PT_ORIG_R3,           "ORIG_R3"                       },
1430         { REGSIZE*PT_CTR,               "CTR"                           },
1431         { REGSIZE*PT_LNK,               "LNK"                           },
1432         { REGSIZE*PT_XER,               "XER"                           },
1433         { REGSIZE*PT_CCR,               "CCR"                           },
1434         { REGSIZE*PT_FPR0,              "FPR0"                          },
1435 # undef REGSIZE
1436 #elif defined(ALPHA)
1437         { 0,                    "r0"                                    },
1438         { 1,                    "r1"                                    },
1439         { 2,                    "r2"                                    },
1440         { 3,                    "r3"                                    },
1441         { 4,                    "r4"                                    },
1442         { 5,                    "r5"                                    },
1443         { 6,                    "r6"                                    },
1444         { 7,                    "r7"                                    },
1445         { 8,                    "r8"                                    },
1446         { 9,                    "r9"                                    },
1447         { 10,                   "r10"                                   },
1448         { 11,                   "r11"                                   },
1449         { 12,                   "r12"                                   },
1450         { 13,                   "r13"                                   },
1451         { 14,                   "r14"                                   },
1452         { 15,                   "r15"                                   },
1453         { 16,                   "r16"                                   },
1454         { 17,                   "r17"                                   },
1455         { 18,                   "r18"                                   },
1456         { 19,                   "r19"                                   },
1457         { 20,                   "r20"                                   },
1458         { 21,                   "r21"                                   },
1459         { 22,                   "r22"                                   },
1460         { 23,                   "r23"                                   },
1461         { 24,                   "r24"                                   },
1462         { 25,                   "r25"                                   },
1463         { 26,                   "r26"                                   },
1464         { 27,                   "r27"                                   },
1465         { 28,                   "r28"                                   },
1466         { 29,                   "gp"                                    },
1467         { 30,                   "fp"                                    },
1468         { 31,                   "zero"                                  },
1469         { 32,                   "fp0"                                   },
1470         { 33,                   "fp"                                    },
1471         { 34,                   "fp2"                                   },
1472         { 35,                   "fp3"                                   },
1473         { 36,                   "fp4"                                   },
1474         { 37,                   "fp5"                                   },
1475         { 38,                   "fp6"                                   },
1476         { 39,                   "fp7"                                   },
1477         { 40,                   "fp8"                                   },
1478         { 41,                   "fp9"                                   },
1479         { 42,                   "fp10"                                  },
1480         { 43,                   "fp11"                                  },
1481         { 44,                   "fp12"                                  },
1482         { 45,                   "fp13"                                  },
1483         { 46,                   "fp14"                                  },
1484         { 47,                   "fp15"                                  },
1485         { 48,                   "fp16"                                  },
1486         { 49,                   "fp17"                                  },
1487         { 50,                   "fp18"                                  },
1488         { 51,                   "fp19"                                  },
1489         { 52,                   "fp20"                                  },
1490         { 53,                   "fp21"                                  },
1491         { 54,                   "fp22"                                  },
1492         { 55,                   "fp23"                                  },
1493         { 56,                   "fp24"                                  },
1494         { 57,                   "fp25"                                  },
1495         { 58,                   "fp26"                                  },
1496         { 59,                   "fp27"                                  },
1497         { 60,                   "fp28"                                  },
1498         { 61,                   "fp29"                                  },
1499         { 62,                   "fp30"                                  },
1500         { 63,                   "fp31"                                  },
1501         { 64,                   "pc"                                    },
1502 #elif defined(IA64)
1503         { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1504         { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1505         { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1506         { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1507         { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1508         { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1509         { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1510         { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1511         { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1512         { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1513         { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1514         { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1515         { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1516         { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1517         { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1518         { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1519         { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1520         { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1521         { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1522         { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1523         { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1524         { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1525         { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1526         { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1527         { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1528         { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1529         { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1530         { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1531         { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1532         { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1533         { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1534         { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1535         /* switch stack: */
1536         { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1537         { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1538         { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1539         { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1540         { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1541         { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1542         { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1543         { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1544         { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1545         { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
1546         { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1547         { PT_B4, "b4" }, { PT_B5, "b5" },
1548         { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
1549         /* pt_regs */
1550         { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1551         { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
1552         { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1553         { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1554         { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1555         { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1556         { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1557         { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1558         { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1559         { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1560         { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1561         { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1562         { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1563         { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1564         { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1565         { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1566         { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
1567 # ifdef PT_AR_CSD
1568         { PT_AR_CSD, "ar.csd" },
1569 # endif
1570 # ifdef PT_AR_SSD
1571         { PT_AR_SSD, "ar.ssd" },
1572 # endif
1573         { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
1574 #elif defined(I386)
1575         { 4*EBX,                "4*EBX"                                 },
1576         { 4*ECX,                "4*ECX"                                 },
1577         { 4*EDX,                "4*EDX"                                 },
1578         { 4*ESI,                "4*ESI"                                 },
1579         { 4*EDI,                "4*EDI"                                 },
1580         { 4*EBP,                "4*EBP"                                 },
1581         { 4*EAX,                "4*EAX"                                 },
1582         { 4*DS,                 "4*DS"                                  },
1583         { 4*ES,                 "4*ES"                                  },
1584         { 4*FS,                 "4*FS"                                  },
1585         { 4*GS,                 "4*GS"                                  },
1586         { 4*ORIG_EAX,           "4*ORIG_EAX"                            },
1587         { 4*EIP,                "4*EIP"                                 },
1588         { 4*CS,                 "4*CS"                                  },
1589         { 4*EFL,                "4*EFL"                                 },
1590         { 4*UESP,               "4*UESP"                                },
1591         { 4*SS,                 "4*SS"                                  },
1592 #elif defined(X86_64)
1593         { 8*R15,                "8*R15"                                 },
1594         { 8*R14,                "8*R14"                                 },
1595         { 8*R13,                "8*R13"                                 },
1596         { 8*R12,                "8*R12"                                 },
1597         { 8*RBP,                "8*RBP"                                 },
1598         { 8*RBX,                "8*RBX"                                 },
1599         { 8*R11,                "8*R11"                                 },
1600         { 8*R10,                "8*R10"                                 },
1601         { 8*R9,                 "8*R9"                                  },
1602         { 8*R8,                 "8*R8"                                  },
1603         { 8*RAX,                "8*RAX"                                 },
1604         { 8*RCX,                "8*RCX"                                 },
1605         { 8*RDX,                "8*RDX"                                 },
1606         { 8*RSI,                "8*RSI"                                 },
1607         { 8*RDI,                "8*RDI"                                 },
1608         { 8*ORIG_RAX,           "8*ORIG_RAX"                            },
1609         { 8*RIP,                "8*RIP"                                 },
1610         { 8*CS,                 "8*CS"                                  },
1611         { 8*EFLAGS,             "8*EFL"                                 },
1612         { 8*RSP,                "8*RSP"                                 },
1613         { 8*SS,                 "8*SS"                                  },
1614 #elif defined(M68K)
1615         { 4*PT_D1,              "4*PT_D1"                               },
1616         { 4*PT_D2,              "4*PT_D2"                               },
1617         { 4*PT_D3,              "4*PT_D3"                               },
1618         { 4*PT_D4,              "4*PT_D4"                               },
1619         { 4*PT_D5,              "4*PT_D5"                               },
1620         { 4*PT_D6,              "4*PT_D6"                               },
1621         { 4*PT_D7,              "4*PT_D7"                               },
1622         { 4*PT_A0,              "4*PT_A0"                               },
1623         { 4*PT_A1,              "4*PT_A1"                               },
1624         { 4*PT_A2,              "4*PT_A2"                               },
1625         { 4*PT_A3,              "4*PT_A3"                               },
1626         { 4*PT_A4,              "4*PT_A4"                               },
1627         { 4*PT_A5,              "4*PT_A5"                               },
1628         { 4*PT_A6,              "4*PT_A6"                               },
1629         { 4*PT_D0,              "4*PT_D0"                               },
1630         { 4*PT_USP,             "4*PT_USP"                              },
1631         { 4*PT_ORIG_D0,         "4*PT_ORIG_D0"                          },
1632         { 4*PT_SR,              "4*PT_SR"                               },
1633         { 4*PT_PC,              "4*PT_PC"                               },
1634 #elif defined(SH)
1635         { 4*REG_REG0,           "4*REG_REG0"                            },
1636         { 4*(REG_REG0+1),       "4*REG_REG1"                            },
1637         { 4*(REG_REG0+2),       "4*REG_REG2"                            },
1638         { 4*(REG_REG0+3),       "4*REG_REG3"                            },
1639         { 4*(REG_REG0+4),       "4*REG_REG4"                            },
1640         { 4*(REG_REG0+5),       "4*REG_REG5"                            },
1641         { 4*(REG_REG0+6),       "4*REG_REG6"                            },
1642         { 4*(REG_REG0+7),       "4*REG_REG7"                            },
1643         { 4*(REG_REG0+8),       "4*REG_REG8"                            },
1644         { 4*(REG_REG0+9),       "4*REG_REG9"                            },
1645         { 4*(REG_REG0+10),      "4*REG_REG10"                           },
1646         { 4*(REG_REG0+11),      "4*REG_REG11"                           },
1647         { 4*(REG_REG0+12),      "4*REG_REG12"                           },
1648         { 4*(REG_REG0+13),      "4*REG_REG13"                           },
1649         { 4*(REG_REG0+14),      "4*REG_REG14"                           },
1650         { 4*REG_REG15,          "4*REG_REG15"                           },
1651         { 4*REG_PC,             "4*REG_PC"                              },
1652         { 4*REG_PR,             "4*REG_PR"                              },
1653         { 4*REG_SR,             "4*REG_SR"                              },
1654         { 4*REG_GBR,            "4*REG_GBR"                             },
1655         { 4*REG_MACH,           "4*REG_MACH"                            },
1656         { 4*REG_MACL,           "4*REG_MACL"                            },
1657         { 4*REG_SYSCALL,        "4*REG_SYSCALL"                         },
1658         { 4*REG_FPUL,           "4*REG_FPUL"                            },
1659         { 4*REG_FPREG0,         "4*REG_FPREG0"                          },
1660         { 4*(REG_FPREG0+1),     "4*REG_FPREG1"                          },
1661         { 4*(REG_FPREG0+2),     "4*REG_FPREG2"                          },
1662         { 4*(REG_FPREG0+3),     "4*REG_FPREG3"                          },
1663         { 4*(REG_FPREG0+4),     "4*REG_FPREG4"                          },
1664         { 4*(REG_FPREG0+5),     "4*REG_FPREG5"                          },
1665         { 4*(REG_FPREG0+6),     "4*REG_FPREG6"                          },
1666         { 4*(REG_FPREG0+7),     "4*REG_FPREG7"                          },
1667         { 4*(REG_FPREG0+8),     "4*REG_FPREG8"                          },
1668         { 4*(REG_FPREG0+9),     "4*REG_FPREG9"                          },
1669         { 4*(REG_FPREG0+10),    "4*REG_FPREG10"                         },
1670         { 4*(REG_FPREG0+11),    "4*REG_FPREG11"                         },
1671         { 4*(REG_FPREG0+12),    "4*REG_FPREG12"                         },
1672         { 4*(REG_FPREG0+13),    "4*REG_FPREG13"                         },
1673         { 4*(REG_FPREG0+14),    "4*REG_FPREG14"                         },
1674         { 4*REG_FPREG15,        "4*REG_FPREG15"                         },
1675 # ifdef REG_XDREG0
1676         { 4*REG_XDREG0,         "4*REG_XDREG0"                          },
1677         { 4*(REG_XDREG0+2),     "4*REG_XDREG2"                          },
1678         { 4*(REG_XDREG0+4),     "4*REG_XDREG4"                          },
1679         { 4*(REG_XDREG0+6),     "4*REG_XDREG6"                          },
1680         { 4*(REG_XDREG0+8),     "4*REG_XDREG8"                          },
1681         { 4*(REG_XDREG0+10),    "4*REG_XDREG10"                         },
1682         { 4*(REG_XDREG0+12),    "4*REG_XDREG12"                         },
1683         { 4*REG_XDREG14,        "4*REG_XDREG14"                         },
1684 # endif
1685         { 4*REG_FPSCR,          "4*REG_FPSCR"                           },
1686 #elif defined(SH64)
1687         { 0,                    "PC(L)"                                 },
1688         { 4,                    "PC(U)"                                 },
1689         { 8,                    "SR(L)"                                 },
1690         { 12,                   "SR(U)"                                 },
1691         { 16,                   "syscall no.(L)"                        },
1692         { 20,                   "syscall_no.(U)"                        },
1693         { 24,                   "R0(L)"                                 },
1694         { 28,                   "R0(U)"                                 },
1695         { 32,                   "R1(L)"                                 },
1696         { 36,                   "R1(U)"                                 },
1697         { 40,                   "R2(L)"                                 },
1698         { 44,                   "R2(U)"                                 },
1699         { 48,                   "R3(L)"                                 },
1700         { 52,                   "R3(U)"                                 },
1701         { 56,                   "R4(L)"                                 },
1702         { 60,                   "R4(U)"                                 },
1703         { 64,                   "R5(L)"                                 },
1704         { 68,                   "R5(U)"                                 },
1705         { 72,                   "R6(L)"                                 },
1706         { 76,                   "R6(U)"                                 },
1707         { 80,                   "R7(L)"                                 },
1708         { 84,                   "R7(U)"                                 },
1709         { 88,                   "R8(L)"                                 },
1710         { 92,                   "R8(U)"                                 },
1711         { 96,                   "R9(L)"                                 },
1712         { 100,                  "R9(U)"                                 },
1713         { 104,                  "R10(L)"                                },
1714         { 108,                  "R10(U)"                                },
1715         { 112,                  "R11(L)"                                },
1716         { 116,                  "R11(U)"                                },
1717         { 120,                  "R12(L)"                                },
1718         { 124,                  "R12(U)"                                },
1719         { 128,                  "R13(L)"                                },
1720         { 132,                  "R13(U)"                                },
1721         { 136,                  "R14(L)"                                },
1722         { 140,                  "R14(U)"                                },
1723         { 144,                  "R15(L)"                                },
1724         { 148,                  "R15(U)"                                },
1725         { 152,                  "R16(L)"                                },
1726         { 156,                  "R16(U)"                                },
1727         { 160,                  "R17(L)"                                },
1728         { 164,                  "R17(U)"                                },
1729         { 168,                  "R18(L)"                                },
1730         { 172,                  "R18(U)"                                },
1731         { 176,                  "R19(L)"                                },
1732         { 180,                  "R19(U)"                                },
1733         { 184,                  "R20(L)"                                },
1734         { 188,                  "R20(U)"                                },
1735         { 192,                  "R21(L)"                                },
1736         { 196,                  "R21(U)"                                },
1737         { 200,                  "R22(L)"                                },
1738         { 204,                  "R22(U)"                                },
1739         { 208,                  "R23(L)"                                },
1740         { 212,                  "R23(U)"                                },
1741         { 216,                  "R24(L)"                                },
1742         { 220,                  "R24(U)"                                },
1743         { 224,                  "R25(L)"                                },
1744         { 228,                  "R25(U)"                                },
1745         { 232,                  "R26(L)"                                },
1746         { 236,                  "R26(U)"                                },
1747         { 240,                  "R27(L)"                                },
1748         { 244,                  "R27(U)"                                },
1749         { 248,                  "R28(L)"                                },
1750         { 252,                  "R28(U)"                                },
1751         { 256,                  "R29(L)"                                },
1752         { 260,                  "R29(U)"                                },
1753         { 264,                  "R30(L)"                                },
1754         { 268,                  "R30(U)"                                },
1755         { 272,                  "R31(L)"                                },
1756         { 276,                  "R31(U)"                                },
1757         { 280,                  "R32(L)"                                },
1758         { 284,                  "R32(U)"                                },
1759         { 288,                  "R33(L)"                                },
1760         { 292,                  "R33(U)"                                },
1761         { 296,                  "R34(L)"                                },
1762         { 300,                  "R34(U)"                                },
1763         { 304,                  "R35(L)"                                },
1764         { 308,                  "R35(U)"                                },
1765         { 312,                  "R36(L)"                                },
1766         { 316,                  "R36(U)"                                },
1767         { 320,                  "R37(L)"                                },
1768         { 324,                  "R37(U)"                                },
1769         { 328,                  "R38(L)"                                },
1770         { 332,                  "R38(U)"                                },
1771         { 336,                  "R39(L)"                                },
1772         { 340,                  "R39(U)"                                },
1773         { 344,                  "R40(L)"                                },
1774         { 348,                  "R40(U)"                                },
1775         { 352,                  "R41(L)"                                },
1776         { 356,                  "R41(U)"                                },
1777         { 360,                  "R42(L)"                                },
1778         { 364,                  "R42(U)"                                },
1779         { 368,                  "R43(L)"                                },
1780         { 372,                  "R43(U)"                                },
1781         { 376,                  "R44(L)"                                },
1782         { 380,                  "R44(U)"                                },
1783         { 384,                  "R45(L)"                                },
1784         { 388,                  "R45(U)"                                },
1785         { 392,                  "R46(L)"                                },
1786         { 396,                  "R46(U)"                                },
1787         { 400,                  "R47(L)"                                },
1788         { 404,                  "R47(U)"                                },
1789         { 408,                  "R48(L)"                                },
1790         { 412,                  "R48(U)"                                },
1791         { 416,                  "R49(L)"                                },
1792         { 420,                  "R49(U)"                                },
1793         { 424,                  "R50(L)"                                },
1794         { 428,                  "R50(U)"                                },
1795         { 432,                  "R51(L)"                                },
1796         { 436,                  "R51(U)"                                },
1797         { 440,                  "R52(L)"                                },
1798         { 444,                  "R52(U)"                                },
1799         { 448,                  "R53(L)"                                },
1800         { 452,                  "R53(U)"                                },
1801         { 456,                  "R54(L)"                                },
1802         { 460,                  "R54(U)"                                },
1803         { 464,                  "R55(L)"                                },
1804         { 468,                  "R55(U)"                                },
1805         { 472,                  "R56(L)"                                },
1806         { 476,                  "R56(U)"                                },
1807         { 480,                  "R57(L)"                                },
1808         { 484,                  "R57(U)"                                },
1809         { 488,                  "R58(L)"                                },
1810         { 492,                  "R58(U)"                                },
1811         { 496,                  "R59(L)"                                },
1812         { 500,                  "R59(U)"                                },
1813         { 504,                  "R60(L)"                                },
1814         { 508,                  "R60(U)"                                },
1815         { 512,                  "R61(L)"                                },
1816         { 516,                  "R61(U)"                                },
1817         { 520,                  "R62(L)"                                },
1818         { 524,                  "R62(U)"                                },
1819         { 528,                  "TR0(L)"                                },
1820         { 532,                  "TR0(U)"                                },
1821         { 536,                  "TR1(L)"                                },
1822         { 540,                  "TR1(U)"                                },
1823         { 544,                  "TR2(L)"                                },
1824         { 548,                  "TR2(U)"                                },
1825         { 552,                  "TR3(L)"                                },
1826         { 556,                  "TR3(U)"                                },
1827         { 560,                  "TR4(L)"                                },
1828         { 564,                  "TR4(U)"                                },
1829         { 568,                  "TR5(L)"                                },
1830         { 572,                  "TR5(U)"                                },
1831         { 576,                  "TR6(L)"                                },
1832         { 580,                  "TR6(U)"                                },
1833         { 584,                  "TR7(L)"                                },
1834         { 588,                  "TR7(U)"                                },
1835         /* This entry is in case pt_regs contains dregs (depends on
1836            the kernel build options). */
1837         { uoff(regs),           "offsetof(struct user, regs)"           },
1838         { uoff(fpu),            "offsetof(struct user, fpu)"            },
1839 #elif defined(ARM)
1840         { uoff(regs.ARM_r0),    "r0"                                    },
1841         { uoff(regs.ARM_r1),    "r1"                                    },
1842         { uoff(regs.ARM_r2),    "r2"                                    },
1843         { uoff(regs.ARM_r3),    "r3"                                    },
1844         { uoff(regs.ARM_r4),    "r4"                                    },
1845         { uoff(regs.ARM_r5),    "r5"                                    },
1846         { uoff(regs.ARM_r6),    "r6"                                    },
1847         { uoff(regs.ARM_r7),    "r7"                                    },
1848         { uoff(regs.ARM_r8),    "r8"                                    },
1849         { uoff(regs.ARM_r9),    "r9"                                    },
1850         { uoff(regs.ARM_r10),   "r10"                                   },
1851         { uoff(regs.ARM_fp),    "fp"                                    },
1852         { uoff(regs.ARM_ip),    "ip"                                    },
1853         { uoff(regs.ARM_sp),    "sp"                                    },
1854         { uoff(regs.ARM_lr),    "lr"                                    },
1855         { uoff(regs.ARM_pc),    "pc"                                    },
1856         { uoff(regs.ARM_cpsr),  "cpsr"                                  },
1857 #elif defined(AVR32)
1858         { uoff(regs.sr),        "sr"                                    },
1859         { uoff(regs.pc),        "pc"                                    },
1860         { uoff(regs.lr),        "lr"                                    },
1861         { uoff(regs.sp),        "sp"                                    },
1862         { uoff(regs.r12),       "r12"                                   },
1863         { uoff(regs.r11),       "r11"                                   },
1864         { uoff(regs.r10),       "r10"                                   },
1865         { uoff(regs.r9),        "r9"                                    },
1866         { uoff(regs.r8),        "r8"                                    },
1867         { uoff(regs.r7),        "r7"                                    },
1868         { uoff(regs.r6),        "r6"                                    },
1869         { uoff(regs.r5),        "r5"                                    },
1870         { uoff(regs.r4),        "r4"                                    },
1871         { uoff(regs.r3),        "r3"                                    },
1872         { uoff(regs.r2),        "r2"                                    },
1873         { uoff(regs.r1),        "r1"                                    },
1874         { uoff(regs.r0),        "r0"                                    },
1875         { uoff(regs.r12_orig),  "orig_r12"                              },
1876 #elif defined(MIPS)
1877         { 0,                    "r0"                                    },
1878         { 1,                    "r1"                                    },
1879         { 2,                    "r2"                                    },
1880         { 3,                    "r3"                                    },
1881         { 4,                    "r4"                                    },
1882         { 5,                    "r5"                                    },
1883         { 6,                    "r6"                                    },
1884         { 7,                    "r7"                                    },
1885         { 8,                    "r8"                                    },
1886         { 9,                    "r9"                                    },
1887         { 10,                   "r10"                                   },
1888         { 11,                   "r11"                                   },
1889         { 12,                   "r12"                                   },
1890         { 13,                   "r13"                                   },
1891         { 14,                   "r14"                                   },
1892         { 15,                   "r15"                                   },
1893         { 16,                   "r16"                                   },
1894         { 17,                   "r17"                                   },
1895         { 18,                   "r18"                                   },
1896         { 19,                   "r19"                                   },
1897         { 20,                   "r20"                                   },
1898         { 21,                   "r21"                                   },
1899         { 22,                   "r22"                                   },
1900         { 23,                   "r23"                                   },
1901         { 24,                   "r24"                                   },
1902         { 25,                   "r25"                                   },
1903         { 26,                   "r26"                                   },
1904         { 27,                   "r27"                                   },
1905         { 28,                   "r28"                                   },
1906         { 29,                   "r29"                                   },
1907         { 30,                   "r30"                                   },
1908         { 31,                   "r31"                                   },
1909         { 32,                   "f0"                                    },
1910         { 33,                   "f1"                                    },
1911         { 34,                   "f2"                                    },
1912         { 35,                   "f3"                                    },
1913         { 36,                   "f4"                                    },
1914         { 37,                   "f5"                                    },
1915         { 38,                   "f6"                                    },
1916         { 39,                   "f7"                                    },
1917         { 40,                   "f8"                                    },
1918         { 41,                   "f9"                                    },
1919         { 42,                   "f10"                                   },
1920         { 43,                   "f11"                                   },
1921         { 44,                   "f12"                                   },
1922         { 45,                   "f13"                                   },
1923         { 46,                   "f14"                                   },
1924         { 47,                   "f15"                                   },
1925         { 48,                   "f16"                                   },
1926         { 49,                   "f17"                                   },
1927         { 50,                   "f18"                                   },
1928         { 51,                   "f19"                                   },
1929         { 52,                   "f20"                                   },
1930         { 53,                   "f21"                                   },
1931         { 54,                   "f22"                                   },
1932         { 55,                   "f23"                                   },
1933         { 56,                   "f24"                                   },
1934         { 57,                   "f25"                                   },
1935         { 58,                   "f26"                                   },
1936         { 59,                   "f27"                                   },
1937         { 60,                   "f28"                                   },
1938         { 61,                   "f29"                                   },
1939         { 62,                   "f30"                                   },
1940         { 63,                   "f31"                                   },
1941         { 64,                   "pc"                                    },
1942         { 65,                   "cause"                                 },
1943         { 66,                   "badvaddr"                              },
1944         { 67,                   "mmhi"                                  },
1945         { 68,                   "mmlo"                                  },
1946         { 69,                   "fpcsr"                                 },
1947         { 70,                   "fpeir"                                 },
1948 #elif defined(TILE)
1949         { PTREGS_OFFSET_REG(0),  "r0"  },
1950         { PTREGS_OFFSET_REG(1),  "r1"  },
1951         { PTREGS_OFFSET_REG(2),  "r2"  },
1952         { PTREGS_OFFSET_REG(3),  "r3"  },
1953         { PTREGS_OFFSET_REG(4),  "r4"  },
1954         { PTREGS_OFFSET_REG(5),  "r5"  },
1955         { PTREGS_OFFSET_REG(6),  "r6"  },
1956         { PTREGS_OFFSET_REG(7),  "r7"  },
1957         { PTREGS_OFFSET_REG(8),  "r8"  },
1958         { PTREGS_OFFSET_REG(9),  "r9"  },
1959         { PTREGS_OFFSET_REG(10), "r10" },
1960         { PTREGS_OFFSET_REG(11), "r11" },
1961         { PTREGS_OFFSET_REG(12), "r12" },
1962         { PTREGS_OFFSET_REG(13), "r13" },
1963         { PTREGS_OFFSET_REG(14), "r14" },
1964         { PTREGS_OFFSET_REG(15), "r15" },
1965         { PTREGS_OFFSET_REG(16), "r16" },
1966         { PTREGS_OFFSET_REG(17), "r17" },
1967         { PTREGS_OFFSET_REG(18), "r18" },
1968         { PTREGS_OFFSET_REG(19), "r19" },
1969         { PTREGS_OFFSET_REG(20), "r20" },
1970         { PTREGS_OFFSET_REG(21), "r21" },
1971         { PTREGS_OFFSET_REG(22), "r22" },
1972         { PTREGS_OFFSET_REG(23), "r23" },
1973         { PTREGS_OFFSET_REG(24), "r24" },
1974         { PTREGS_OFFSET_REG(25), "r25" },
1975         { PTREGS_OFFSET_REG(26), "r26" },
1976         { PTREGS_OFFSET_REG(27), "r27" },
1977         { PTREGS_OFFSET_REG(28), "r28" },
1978         { PTREGS_OFFSET_REG(29), "r29" },
1979         { PTREGS_OFFSET_REG(30), "r30" },
1980         { PTREGS_OFFSET_REG(31), "r31" },
1981         { PTREGS_OFFSET_REG(32), "r32" },
1982         { PTREGS_OFFSET_REG(33), "r33" },
1983         { PTREGS_OFFSET_REG(34), "r34" },
1984         { PTREGS_OFFSET_REG(35), "r35" },
1985         { PTREGS_OFFSET_REG(36), "r36" },
1986         { PTREGS_OFFSET_REG(37), "r37" },
1987         { PTREGS_OFFSET_REG(38), "r38" },
1988         { PTREGS_OFFSET_REG(39), "r39" },
1989         { PTREGS_OFFSET_REG(40), "r40" },
1990         { PTREGS_OFFSET_REG(41), "r41" },
1991         { PTREGS_OFFSET_REG(42), "r42" },
1992         { PTREGS_OFFSET_REG(43), "r43" },
1993         { PTREGS_OFFSET_REG(44), "r44" },
1994         { PTREGS_OFFSET_REG(45), "r45" },
1995         { PTREGS_OFFSET_REG(46), "r46" },
1996         { PTREGS_OFFSET_REG(47), "r47" },
1997         { PTREGS_OFFSET_REG(48), "r48" },
1998         { PTREGS_OFFSET_REG(49), "r49" },
1999         { PTREGS_OFFSET_REG(50), "r50" },
2000         { PTREGS_OFFSET_REG(51), "r51" },
2001         { PTREGS_OFFSET_REG(52), "r52" },
2002         { PTREGS_OFFSET_TP, "tp" },
2003         { PTREGS_OFFSET_SP, "sp" },
2004         { PTREGS_OFFSET_LR, "lr" },
2005         { PTREGS_OFFSET_PC, "pc" },
2006         { PTREGS_OFFSET_EX1, "ex1" },
2007         { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2008         { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2009         { PTREGS_OFFSET_FLAGS, "flags" },
2010 #endif
2011 #ifdef CRISV10
2012         { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2013         { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2014         { 4*PT_R13, "4*PT_R13" },
2015         { 4*PT_R12, "4*PT_R12" },
2016         { 4*PT_R11, "4*PT_R11" },
2017         { 4*PT_R10, "4*PT_R10" },
2018         { 4*PT_R9, "4*PT_R9" },
2019         { 4*PT_R8, "4*PT_R8" },
2020         { 4*PT_R7, "4*PT_R7" },
2021         { 4*PT_R6, "4*PT_R6" },
2022         { 4*PT_R5, "4*PT_R5" },
2023         { 4*PT_R4, "4*PT_R4" },
2024         { 4*PT_R3, "4*PT_R3" },
2025         { 4*PT_R2, "4*PT_R2" },
2026         { 4*PT_R1, "4*PT_R1" },
2027         { 4*PT_R0, "4*PT_R0" },
2028         { 4*PT_MOF, "4*PT_MOF" },
2029         { 4*PT_DCCR, "4*PT_DCCR" },
2030         { 4*PT_SRP, "4*PT_SRP" },
2031         { 4*PT_IRP, "4*PT_IRP" },
2032         { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2033         { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2034         { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2035         { 4*PT_USP, "4*PT_USP" },
2036 #endif
2037 #ifdef CRISV32
2038         { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2039         { 4*PT_R0, "4*PT_R0" },
2040         { 4*PT_R1, "4*PT_R1" },
2041         { 4*PT_R2, "4*PT_R2" },
2042         { 4*PT_R3, "4*PT_R3" },
2043         { 4*PT_R4, "4*PT_R4" },
2044         { 4*PT_R5, "4*PT_R5" },
2045         { 4*PT_R6, "4*PT_R6" },
2046         { 4*PT_R7, "4*PT_R7" },
2047         { 4*PT_R8, "4*PT_R8" },
2048         { 4*PT_R9, "4*PT_R9" },
2049         { 4*PT_R10, "4*PT_R10" },
2050         { 4*PT_R11, "4*PT_R11" },
2051         { 4*PT_R12, "4*PT_R12" },
2052         { 4*PT_R13, "4*PT_R13" },
2053         { 4*PT_ACR, "4*PT_ACR" },
2054         { 4*PT_SRS, "4*PT_SRS" },
2055         { 4*PT_MOF, "4*PT_MOF" },
2056         { 4*PT_SPC, "4*PT_SPC" },
2057         { 4*PT_CCS, "4*PT_CCS" },
2058         { 4*PT_SRP, "4*PT_SRP" },
2059         { 4*PT_ERP, "4*PT_ERP" },
2060         { 4*PT_EXS, "4*PT_EXS" },
2061         { 4*PT_EDA, "4*PT_EDA" },
2062         { 4*PT_USP, "4*PT_USP" },
2063         { 4*PT_PPC, "4*PT_PPC" },
2064         { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2065         { 4*PT_BP+4, "4*PT_BP+4" },
2066         { 4*PT_BP+8, "4*PT_BP+8" },
2067         { 4*PT_BP+12, "4*PT_BP+12" },
2068         { 4*PT_BP+16, "4*PT_BP+16" },
2069         { 4*PT_BP+20, "4*PT_BP+20" },
2070         { 4*PT_BP+24, "4*PT_BP+24" },
2071         { 4*PT_BP+28, "4*PT_BP+28" },
2072         { 4*PT_BP+32, "4*PT_BP+32" },
2073         { 4*PT_BP+36, "4*PT_BP+36" },
2074         { 4*PT_BP+40, "4*PT_BP+40" },
2075         { 4*PT_BP+44, "4*PT_BP+44" },
2076         { 4*PT_BP+48, "4*PT_BP+48" },
2077         { 4*PT_BP+52, "4*PT_BP+52" },
2078         { 4*PT_BP+56, "4*PT_BP+56" },
2079 #endif
2080 #ifdef MICROBLAZE
2081         { PT_GPR(0),            "r0"                                    },
2082         { PT_GPR(1),            "r1"                                    },
2083         { PT_GPR(2),            "r2"                                    },
2084         { PT_GPR(3),            "r3"                                    },
2085         { PT_GPR(4),            "r4"                                    },
2086         { PT_GPR(5),            "r5"                                    },
2087         { PT_GPR(6),            "r6"                                    },
2088         { PT_GPR(7),            "r7"                                    },
2089         { PT_GPR(8),            "r8"                                    },
2090         { PT_GPR(9),            "r9"                                    },
2091         { PT_GPR(10),           "r10"                                   },
2092         { PT_GPR(11),           "r11"                                   },
2093         { PT_GPR(12),           "r12"                                   },
2094         { PT_GPR(13),           "r13"                                   },
2095         { PT_GPR(14),           "r14"                                   },
2096         { PT_GPR(15),           "r15"                                   },
2097         { PT_GPR(16),           "r16"                                   },
2098         { PT_GPR(17),           "r17"                                   },
2099         { PT_GPR(18),           "r18"                                   },
2100         { PT_GPR(19),           "r19"                                   },
2101         { PT_GPR(20),           "r20"                                   },
2102         { PT_GPR(21),           "r21"                                   },
2103         { PT_GPR(22),           "r22"                                   },
2104         { PT_GPR(23),           "r23"                                   },
2105         { PT_GPR(24),           "r24"                                   },
2106         { PT_GPR(25),           "r25"                                   },
2107         { PT_GPR(26),           "r26"                                   },
2108         { PT_GPR(27),           "r27"                                   },
2109         { PT_GPR(28),           "r28"                                   },
2110         { PT_GPR(29),           "r29"                                   },
2111         { PT_GPR(30),           "r30"                                   },
2112         { PT_GPR(31),           "r31"                                   },
2113         { PT_PC,                "rpc",                                  },
2114         { PT_MSR,               "rmsr",                                 },
2115         { PT_EAR,               "rear",                                 },
2116         { PT_ESR,               "resr",                                 },
2117         { PT_FSR,               "rfsr",                                 },
2118         { PT_KERNEL_MODE,       "kernel_mode",                          },
2119 #endif
2120
2121 #if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \
2122                 && !defined(ALPHA) && !defined(IA64) \
2123                 && !defined(CRISV10) && !defined(CRISV32) && !defined(MICROBLAZE)
2124 # if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(AVR32) && !defined(BFIN) && !defined(TILE)
2125         { uoff(u_fpvalid),      "offsetof(struct user, u_fpvalid)"      },
2126 # endif
2127 # if defined(I386) || defined(X86_64)
2128         { uoff(i387),           "offsetof(struct user, i387)"           },
2129 # endif
2130 # if defined(M68K)
2131         { uoff(m68kfp),         "offsetof(struct user, m68kfp)"         },
2132 # endif
2133         { uoff(u_tsize),        "offsetof(struct user, u_tsize)"        },
2134         { uoff(u_dsize),        "offsetof(struct user, u_dsize)"        },
2135         { uoff(u_ssize),        "offsetof(struct user, u_ssize)"        },
2136 # if !defined(SPARC64)
2137         { uoff(start_code),     "offsetof(struct user, start_code)"     },
2138 # endif
2139 # if defined(AVR32) || defined(SH64)
2140         { uoff(start_data),     "offsetof(struct user, start_data)"     },
2141 # endif
2142 # if !defined(SPARC64)
2143         { uoff(start_stack),    "offsetof(struct user, start_stack)"    },
2144 # endif
2145         { uoff(signal),         "offsetof(struct user, signal)"         },
2146 # if !defined(AVR32) && !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SH) && !defined(SH64) && !defined(SPARC64) && !defined(TILE)
2147         { uoff(reserved),       "offsetof(struct user, reserved)"       },
2148 # endif
2149 # if !defined(SPARC64)
2150         { uoff(u_ar0),          "offsetof(struct user, u_ar0)"          },
2151 # endif
2152 # if !defined(ARM) && !defined(AVR32) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) && !defined(BFIN) && !defined(TILE)
2153         { uoff(u_fpstate),      "offsetof(struct user, u_fpstate)"      },
2154 # endif
2155         { uoff(magic),          "offsetof(struct user, magic)"          },
2156         { uoff(u_comm),         "offsetof(struct user, u_comm)"         },
2157 # if defined(I386) || defined(X86_64)
2158         { uoff(u_debugreg),     "offsetof(struct user, u_debugreg)"     },
2159 # endif
2160 #endif /* !defined(many arches) */
2161
2162 #ifndef HPPA
2163         { sizeof(struct user),  "sizeof(struct user)"                   },
2164 #endif
2165         { 0,                    NULL                                    },
2166 };
2167
2168 int
2169 sys_ptrace(struct tcb *tcp)
2170 {
2171         const struct xlat *x;
2172         long addr;
2173
2174         if (entering(tcp)) {
2175                 printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
2176                 tprintf(", %lu, ", tcp->u_arg[1]);
2177                 addr = tcp->u_arg[2];
2178                 if (tcp->u_arg[0] == PTRACE_PEEKUSER
2179                         || tcp->u_arg[0] == PTRACE_POKEUSER) {
2180                         for (x = struct_user_offsets; x->str; x++) {
2181                                 if (x->val >= addr)
2182                                         break;
2183                         }
2184                         if (!x->str)
2185                                 tprintf("%#lx, ", addr);
2186                         else if (x->val > addr && x != struct_user_offsets) {
2187                                 x--;
2188                                 tprintf("%s + %ld, ", x->str, addr - x->val);
2189                         }
2190                         else
2191                                 tprintf("%s, ", x->str);
2192                 }
2193                 else
2194                         tprintf("%#lx, ", tcp->u_arg[2]);
2195                 switch (tcp->u_arg[0]) {
2196 #ifndef IA64
2197                 case PTRACE_PEEKDATA:
2198                 case PTRACE_PEEKTEXT:
2199                 case PTRACE_PEEKUSER:
2200                         break;
2201 #endif
2202                 case PTRACE_CONT:
2203                 case PTRACE_SINGLESTEP:
2204                 case PTRACE_SYSCALL:
2205                 case PTRACE_DETACH:
2206                         printsignal(tcp->u_arg[3]);
2207                         break;
2208 #ifdef PTRACE_SETOPTIONS
2209                 case PTRACE_SETOPTIONS:
2210                         printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2211                         break;
2212 #endif
2213 #ifdef PTRACE_SETSIGINFO
2214                 case PTRACE_SETSIGINFO: {
2215                         siginfo_t si;
2216                         if (!tcp->u_arg[3])
2217                                 tprints("NULL");
2218                         else if (syserror(tcp))
2219                                 tprintf("%#lx", tcp->u_arg[3]);
2220                         else if (umove(tcp, tcp->u_arg[3], &si) < 0)
2221                                 tprints("{???}");
2222                         else
2223                                 printsiginfo(&si, verbose(tcp));
2224                         break;
2225                 }
2226 #endif
2227 #ifdef PTRACE_GETSIGINFO
2228                 case PTRACE_GETSIGINFO:
2229                         /* Don't print anything, do it at syscall return. */
2230                         break;
2231 #endif
2232                 default:
2233                         tprintf("%#lx", tcp->u_arg[3]);
2234                         break;
2235                 }
2236         } else {
2237                 switch (tcp->u_arg[0]) {
2238                 case PTRACE_PEEKDATA:
2239                 case PTRACE_PEEKTEXT:
2240                 case PTRACE_PEEKUSER:
2241 #ifdef IA64
2242                         return RVAL_HEX;
2243 #else
2244                         printnum(tcp, tcp->u_arg[3], "%#lx");
2245                         break;
2246 #endif
2247 #ifdef PTRACE_GETSIGINFO
2248                 case PTRACE_GETSIGINFO: {
2249                         siginfo_t si;
2250                         if (!tcp->u_arg[3])
2251                                 tprints("NULL");
2252                         else if (syserror(tcp))
2253                                 tprintf("%#lx", tcp->u_arg[3]);
2254                         else if (umove(tcp, tcp->u_arg[3], &si) < 0)
2255                                 tprints("{???}");
2256                         else
2257                                 printsiginfo(&si, verbose(tcp));
2258                         break;
2259                 }
2260 #endif
2261                 }
2262         }
2263         return 0;
2264 }
2265
2266 #ifndef FUTEX_CMP_REQUEUE
2267 # define FUTEX_CMP_REQUEUE 4
2268 #endif
2269 #ifndef FUTEX_WAKE_OP
2270 # define FUTEX_WAKE_OP 5
2271 #endif
2272 #ifndef FUTEX_LOCK_PI
2273 # define FUTEX_LOCK_PI 6
2274 # define FUTEX_UNLOCK_PI 7
2275 # define FUTEX_TRYLOCK_PI 8
2276 #endif
2277 #ifndef FUTEX_WAIT_BITSET
2278 # define FUTEX_WAIT_BITSET 9
2279 #endif
2280 #ifndef FUTEX_WAKE_BITSET
2281 # define FUTEX_WAKE_BITSET 10
2282 #endif
2283 #ifndef FUTEX_WAIT_REQUEUE_PI
2284 # define FUTEX_WAIT_REQUEUE_PI 11
2285 #endif
2286 #ifndef FUTEX_CMP_REQUEUE_PI
2287 # define FUTEX_CMP_REQUEUE_PI 12
2288 #endif
2289 #ifndef FUTEX_PRIVATE_FLAG
2290 # define FUTEX_PRIVATE_FLAG 128
2291 #endif
2292 #ifndef FUTEX_CLOCK_REALTIME
2293 # define FUTEX_CLOCK_REALTIME 256
2294 #endif
2295 static const struct xlat futexops[] = {
2296         { FUTEX_WAIT,                                   "FUTEX_WAIT" },
2297         { FUTEX_WAKE,                                   "FUTEX_WAKE" },
2298         { FUTEX_FD,                                     "FUTEX_FD" },
2299         { FUTEX_REQUEUE,                                "FUTEX_REQUEUE" },
2300         { FUTEX_CMP_REQUEUE,                            "FUTEX_CMP_REQUEUE" },
2301         { FUTEX_WAKE_OP,                                "FUTEX_WAKE_OP" },
2302         { FUTEX_LOCK_PI,                                "FUTEX_LOCK_PI" },
2303         { FUTEX_UNLOCK_PI,                              "FUTEX_UNLOCK_PI" },
2304         { FUTEX_TRYLOCK_PI,                             "FUTEX_TRYLOCK_PI" },
2305         { FUTEX_WAIT_BITSET,                            "FUTEX_WAIT_BITSET" },
2306         { FUTEX_WAKE_BITSET,                            "FUTEX_WAKE_BITSET" },
2307         { FUTEX_WAIT_REQUEUE_PI,                        "FUTEX_WAIT_REQUEUE_PI" },
2308         { FUTEX_CMP_REQUEUE_PI,                         "FUTEX_CMP_REQUEUE_PI" },
2309         { FUTEX_WAIT|FUTEX_PRIVATE_FLAG,                "FUTEX_WAIT_PRIVATE" },
2310         { FUTEX_WAKE|FUTEX_PRIVATE_FLAG,                "FUTEX_WAKE_PRIVATE" },
2311         { FUTEX_FD|FUTEX_PRIVATE_FLAG,                  "FUTEX_FD_PRIVATE" },
2312         { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG,             "FUTEX_REQUEUE_PRIVATE" },
2313         { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG,         "FUTEX_CMP_REQUEUE_PRIVATE" },
2314         { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG,             "FUTEX_WAKE_OP_PRIVATE" },
2315         { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG,             "FUTEX_LOCK_PI_PRIVATE" },
2316         { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG,           "FUTEX_UNLOCK_PI_PRIVATE" },
2317         { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG,          "FUTEX_TRYLOCK_PI_PRIVATE" },
2318         { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG,         "FUTEX_WAIT_BITSET_PRIVATE" },
2319         { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG,         "FUTEX_WAKE_BITSET_PRIVATE" },
2320         { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG,     "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2321         { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG,      "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2322         { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME,       "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2323         { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME,    "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2324         { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME,   "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2325         { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME,        "FUTEX_WAIT_REQUEUE_PI_PRIVATE|FUTEX_CLOCK_REALTIME" },
2326         { 0,                                            NULL }
2327 };
2328 #ifndef FUTEX_OP_SET
2329 # define FUTEX_OP_SET           0
2330 # define FUTEX_OP_ADD           1
2331 # define FUTEX_OP_OR            2
2332 # define FUTEX_OP_ANDN          3
2333 # define FUTEX_OP_XOR           4
2334 # define FUTEX_OP_CMP_EQ        0
2335 # define FUTEX_OP_CMP_NE        1
2336 # define FUTEX_OP_CMP_LT        2
2337 # define FUTEX_OP_CMP_LE        3
2338 # define FUTEX_OP_CMP_GT        4
2339 # define FUTEX_OP_CMP_GE        5
2340 #endif
2341 static const struct xlat futexwakeops[] = {
2342         { FUTEX_OP_SET,         "FUTEX_OP_SET" },
2343         { FUTEX_OP_ADD,         "FUTEX_OP_ADD" },
2344         { FUTEX_OP_OR,          "FUTEX_OP_OR" },
2345         { FUTEX_OP_ANDN,        "FUTEX_OP_ANDN" },
2346         { FUTEX_OP_XOR,         "FUTEX_OP_XOR" },
2347         { 0,                    NULL }
2348 };
2349 static const struct xlat futexwakecmps[] = {
2350         { FUTEX_OP_CMP_EQ,      "FUTEX_OP_CMP_EQ" },
2351         { FUTEX_OP_CMP_NE,      "FUTEX_OP_CMP_NE" },
2352         { FUTEX_OP_CMP_LT,      "FUTEX_OP_CMP_LT" },
2353         { FUTEX_OP_CMP_LE,      "FUTEX_OP_CMP_LE" },
2354         { FUTEX_OP_CMP_GT,      "FUTEX_OP_CMP_GT" },
2355         { FUTEX_OP_CMP_GE,      "FUTEX_OP_CMP_GE" },
2356         { 0,                    NULL }
2357 };
2358
2359 int
2360 sys_futex(struct tcb *tcp)
2361 {
2362         if (entering(tcp)) {
2363                 long int cmd = tcp->u_arg[1] & 127;
2364                 tprintf("%p, ", (void *) tcp->u_arg[0]);
2365                 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2366                 tprintf(", %ld", tcp->u_arg[2]);
2367                 if (cmd == FUTEX_WAKE_BITSET)
2368                         tprintf(", %lx", tcp->u_arg[5]);
2369                 else if (cmd == FUTEX_WAIT) {
2370                         tprints(", ");
2371                         printtv(tcp, tcp->u_arg[3]);
2372                 } else if (cmd == FUTEX_WAIT_BITSET) {
2373                         tprints(", ");
2374                         printtv(tcp, tcp->u_arg[3]);
2375                         tprintf(", %lx", tcp->u_arg[5]);
2376                 } else if (cmd == FUTEX_REQUEUE)
2377                         tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2378                 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
2379                         tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2380                 else if (cmd == FUTEX_WAKE_OP) {
2381                         tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2382                         if ((tcp->u_arg[5] >> 28) & 8)
2383                                 tprints("FUTEX_OP_OPARG_SHIFT|");
2384                         printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2385                         tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2386                         if ((tcp->u_arg[5] >> 24) & 8)
2387                                 tprints("FUTEX_OP_OPARG_SHIFT|");
2388                         printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2389                         tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
2390                 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
2391                         tprints(", ");
2392                         printtv(tcp, tcp->u_arg[3]);
2393                         tprintf(", %p", (void *) tcp->u_arg[4]);
2394                 }
2395         }
2396         return 0;
2397 }
2398
2399 static void
2400 print_affinitylist(struct tcb *tcp, long list, unsigned int len)
2401 {
2402         int first = 1;
2403         unsigned long w, min_len;
2404
2405         if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2406                 min_len = len - max_strlen * sizeof(w);
2407         else
2408                 min_len = 0;
2409         for (; len >= sizeof(w) && len > min_len;
2410              len -= sizeof(w), list += sizeof(w)) {
2411                 if (umove(tcp, list, &w) < 0)
2412                         break;
2413                 if (first)
2414                         tprints("{");
2415                 else
2416                         tprints(", ");
2417                 first = 0;
2418                 tprintf("%lx", w);
2419         }
2420         if (len) {
2421                 if (first)
2422                         tprintf("%#lx", list);
2423                 else
2424                         tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2425                                 "???" : "..."));
2426         } else {
2427                 tprints(first ? "{}" : "}");
2428         }
2429 }
2430
2431 int
2432 sys_sched_setaffinity(struct tcb *tcp)
2433 {
2434         if (entering(tcp)) {
2435                 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2436                 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2437         }
2438         return 0;
2439 }
2440
2441 int
2442 sys_sched_getaffinity(struct tcb *tcp)
2443 {
2444         if (entering(tcp)) {
2445                 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2446         } else {
2447                 if (tcp->u_rval == -1)
2448                         tprintf("%#lx", tcp->u_arg[2]);
2449                 else
2450                         print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2451         }
2452         return 0;
2453 }
2454
2455 int
2456 sys_get_robust_list(struct tcb *tcp)
2457 {
2458         if (entering(tcp)) {
2459                 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2460         } else {
2461                 void *addr;
2462                 size_t len;
2463
2464                 if (syserror(tcp) ||
2465                     !tcp->u_arg[1] ||
2466                     umove(tcp, tcp->u_arg[1], &addr) < 0) {
2467                         tprintf("%#lx, ", tcp->u_arg[1]);
2468                 } else {
2469                         tprintf("[%p], ", addr);
2470                 }
2471
2472                 if (syserror(tcp) ||
2473                     !tcp->u_arg[2] ||
2474                     umove(tcp, tcp->u_arg[2], &len) < 0) {
2475                         tprintf("%#lx", tcp->u_arg[2]);
2476                 } else {
2477                         tprintf("[%lu]", (unsigned long) len);
2478                 }
2479         }
2480         return 0;
2481 }
2482
2483 static const struct xlat schedulers[] = {
2484         { SCHED_OTHER,  "SCHED_OTHER" },
2485         { SCHED_RR,     "SCHED_RR" },
2486         { SCHED_FIFO,   "SCHED_FIFO" },
2487         { 0,            NULL }
2488 };
2489
2490 int
2491 sys_sched_getscheduler(struct tcb *tcp)
2492 {
2493         if (entering(tcp)) {
2494                 tprintf("%d", (int) tcp->u_arg[0]);
2495         } else if (!syserror(tcp)) {
2496                 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
2497                 if (tcp->auxstr != NULL)
2498                         return RVAL_STR;
2499         }
2500         return 0;
2501 }
2502
2503 int
2504 sys_sched_setscheduler(struct tcb *tcp)
2505 {
2506         if (entering(tcp)) {
2507                 struct sched_param p;
2508                 tprintf("%d, ", (int) tcp->u_arg[0]);
2509                 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2510                 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2511                         tprintf(", %#lx", tcp->u_arg[2]);
2512                 else
2513                         tprintf(", { %d }", p.__sched_priority);
2514         }
2515         return 0;
2516 }
2517
2518 int
2519 sys_sched_getparam(struct tcb *tcp)
2520 {
2521         if (entering(tcp)) {
2522                 tprintf("%d, ", (int) tcp->u_arg[0]);
2523         } else {
2524                 struct sched_param p;
2525                 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2526                         tprintf("%#lx", tcp->u_arg[1]);
2527                 else
2528                         tprintf("{ %d }", p.__sched_priority);
2529         }
2530         return 0;
2531 }
2532
2533 int
2534 sys_sched_setparam(struct tcb *tcp)
2535 {
2536         if (entering(tcp)) {
2537                 struct sched_param p;
2538                 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2539                         tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2540                 else
2541                         tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2542         }
2543         return 0;
2544 }
2545
2546 int
2547 sys_sched_get_priority_min(struct tcb *tcp)
2548 {
2549         if (entering(tcp)) {
2550                 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2551         }
2552         return 0;
2553 }
2554
2555 int
2556 sys_sched_rr_get_interval(struct tcb *tcp)
2557 {
2558         if (entering(tcp)) {
2559                 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2560         } else {
2561                 if (syserror(tcp))
2562                         tprintf("%#lx", tcp->u_arg[1]);
2563                 else
2564                         print_timespec(tcp, tcp->u_arg[1]);
2565         }
2566         return 0;
2567 }
2568
2569 #ifdef X86_64
2570 # include <asm/prctl.h>
2571
2572 static const struct xlat archvals[] = {
2573         { ARCH_SET_GS,          "ARCH_SET_GS"           },
2574         { ARCH_SET_FS,          "ARCH_SET_FS"           },
2575         { ARCH_GET_FS,          "ARCH_GET_FS"           },
2576         { ARCH_GET_GS,          "ARCH_GET_GS"           },
2577         { 0,                    NULL                    },
2578 };
2579
2580 int
2581 sys_arch_prctl(struct tcb *tcp)
2582 {
2583         if (entering(tcp)) {
2584                 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2585                 if (tcp->u_arg[0] == ARCH_SET_GS
2586                  || tcp->u_arg[0] == ARCH_SET_FS
2587                 ) {
2588                         tprintf(", %#lx", tcp->u_arg[1]);
2589                 }
2590         } else {
2591                 if (tcp->u_arg[0] == ARCH_GET_GS
2592                  || tcp->u_arg[0] == ARCH_GET_FS
2593                 ) {
2594                         long int v;
2595                         if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2596                                 tprintf(", [%#lx]", v);
2597                         else
2598                                 tprintf(", %#lx", tcp->u_arg[1]);
2599                 }
2600         }
2601         return 0;
2602 }
2603 #endif /* X86_64 */
2604
2605 int
2606 sys_getcpu(struct tcb *tcp)
2607 {
2608         if (exiting(tcp)) {
2609                 unsigned u;
2610                 if (tcp->u_arg[0] == 0)
2611                         tprints("NULL, ");
2612                 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2613                         tprintf("%#lx, ", tcp->u_arg[0]);
2614                 else
2615                         tprintf("[%u], ", u);
2616                 if (tcp->u_arg[1] == 0)
2617                         tprints("NULL, ");
2618                 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2619                         tprintf("%#lx, ", tcp->u_arg[1]);
2620                 else
2621                         tprintf("[%u], ", u);
2622                 tprintf("%#lx", tcp->u_arg[2]);
2623         }
2624         return 0;
2625 }
2626
2627 int
2628 sys_process_vm_readv(struct tcb *tcp)
2629 {
2630         if (entering(tcp)) {
2631                 /* arg 1: pid */
2632                 tprintf("%ld, ", tcp->u_arg[0]);
2633         } else {
2634                 /* arg 2: local iov */
2635                 if (syserror(tcp)) {
2636                         tprintf("%#lx", tcp->u_arg[1]);
2637                 } else {
2638                         tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2639                 }
2640                 /* arg 3: local iovcnt */
2641                 tprintf(", %lu, ", tcp->u_arg[2]);
2642                 /* arg 4: remote iov */
2643                 if (syserror(tcp)) {
2644                         tprintf("%#lx", tcp->u_arg[3]);
2645                 } else {
2646                         tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2647                 }
2648                 /* arg 5: remote iovcnt */
2649                 /* arg 6: flags */
2650                 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
2651         }
2652         return 0;
2653 }
2654
2655 int
2656 sys_process_vm_writev(struct tcb *tcp)
2657 {
2658         if (entering(tcp)) {
2659                 /* arg 1: pid */
2660                 tprintf("%ld, ", tcp->u_arg[0]);
2661                 /* arg 2: local iov */
2662                 if (syserror(tcp))
2663                         tprintf("%#lx", tcp->u_arg[1]);
2664                 else
2665                         tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2666                 /* arg 3: local iovcnt */
2667                 tprintf(", %lu, ", tcp->u_arg[2]);
2668                 /* arg 4: remote iov */
2669                 if (syserror(tcp))
2670                         tprintf("%#lx", tcp->u_arg[3]);
2671                 else
2672                         tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2673                 /* arg 5: remote iovcnt */
2674                 /* arg 6: flags */
2675                 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
2676         }
2677         return 0;
2678 }