blob: 9bc78d6cd19b5a3609341ce57a1f90db2c08fa1a [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
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>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * 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>
Wichert Akkermanccef6372002-05-01 16:39:22 +00009 * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH
10 * port by Greg Banks <gbanks@pocketpenguins.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +000011 *
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000012 * 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.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000035 */
36
37#include "defs.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000038#include <fcntl.h>
39#include <sys/stat.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000040#include <sys/wait.h>
41#include <sys/resource.h>
42#include <sys/utsname.h>
43#include <sys/user.h>
Dmitry V. Levinc41808b2013-03-18 00:52:29 +000044#ifdef HAVE_ELF_H
45# include <elf.h>
46#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047
Wichert Akkerman36915a11999-07-13 15:45:02 +000048#ifdef HAVE_SYS_REG_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000049# include <sys/reg.h>
Denys Vlasenko84703742012-02-25 02:38:52 +010050# ifndef PTRACE_PEEKUSR
51# define PTRACE_PEEKUSR PTRACE_PEEKUSER
52# endif
53# ifndef PTRACE_POKEUSR
54# define PTRACE_POKEUSR PTRACE_POKEUSER
55# endif
Wichert Akkerman15dea971999-10-06 13:06:34 +000056#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000057
Roland McGrath5bd7cf82003-01-24 04:31:18 +000058#ifdef HAVE_LINUX_PTRACE_H
Denys Vlasenko84703742012-02-25 02:38:52 +010059# undef PTRACE_SYSCALL
Roland McGrathfb1bc072004-03-01 21:29:24 +000060# ifdef HAVE_STRUCT_IA64_FPREG
61# define ia64_fpreg XXX_ia64_fpreg
62# endif
63# ifdef HAVE_STRUCT_PT_ALL_USER_REGS
64# define pt_all_user_regs XXX_pt_all_user_regs
65# endif
Denys Vlasenko84703742012-02-25 02:38:52 +010066# include <linux/ptrace.h>
Roland McGrathfb1bc072004-03-01 21:29:24 +000067# undef ia64_fpreg
68# undef pt_all_user_regs
Roland McGrath5bd7cf82003-01-24 04:31:18 +000069#endif
70
Denys Vlasenko84703742012-02-25 02:38:52 +010071#if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +000072# define r_pc r_tpc
73# undef PTRACE_GETREGS
74# define PTRACE_GETREGS PTRACE_GETREGS64
75# undef PTRACE_SETREGS
76# define PTRACE_SETREGS PTRACE_SETREGS64
Denys Vlasenko84703742012-02-25 02:38:52 +010077#endif
Roland McGrath6d1a65c2004-07-12 07:44:08 +000078
Roland McGrath5a223472002-12-15 23:58:26 +000079#ifdef HAVE_LINUX_FUTEX_H
Dmitry V. Levine5e60852009-12-31 22:50:49 +000080# include <linux/futex.h>
Roland McGrath5a223472002-12-15 23:58:26 +000081#endif
Denys Vlasenko84703742012-02-25 02:38:52 +010082#ifndef FUTEX_WAIT
83# define FUTEX_WAIT 0
84#endif
85#ifndef FUTEX_WAKE
86# define FUTEX_WAKE 1
87#endif
88#ifndef FUTEX_FD
89# define FUTEX_FD 2
90#endif
91#ifndef FUTEX_REQUEUE
92# define FUTEX_REQUEUE 3
93#endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000094
Roland McGrath279d3782004-03-01 20:27:37 +000095#include <sched.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000096#include <asm/posix_types.h>
97#undef GETGROUPS_T
98#define GETGROUPS_T __kernel_gid_t
Roland McGrath83bd47a2003-11-13 22:32:26 +000099#undef GETGROUPS32_T
100#define GETGROUPS32_T __kernel_gid32_t
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000101
Denys Vlasenko84703742012-02-25 02:38:52 +0100102#if defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000103# include <asm/ptrace_offsets.h>
104# include <asm/rse.h>
105#endif
106
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000107#ifdef HAVE_PRCTL
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000108# include <sys/prctl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000109
Roland McGrathd9f816f2004-09-04 03:39:20 +0000110static const struct xlat prctl_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000111#ifdef PR_MAXPROCS
112 { PR_MAXPROCS, "PR_MAXPROCS" },
113#endif
114#ifdef PR_ISBLOCKED
115 { PR_ISBLOCKED, "PR_ISBLOCKED" },
116#endif
117#ifdef PR_SETSTACKSIZE
118 { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" },
119#endif
120#ifdef PR_GETSTACKSIZE
121 { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" },
122#endif
123#ifdef PR_MAXPPROCS
124 { PR_MAXPPROCS, "PR_MAXPPROCS" },
125#endif
126#ifdef PR_UNBLKONEXEC
127 { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" },
128#endif
129#ifdef PR_ATOMICSIM
130 { PR_ATOMICSIM, "PR_ATOMICSIM" },
131#endif
132#ifdef PR_SETEXITSIG
133 { PR_SETEXITSIG, "PR_SETEXITSIG" },
134#endif
135#ifdef PR_RESIDENT
136 { PR_RESIDENT, "PR_RESIDENT" },
137#endif
138#ifdef PR_ATTACHADDR
139 { PR_ATTACHADDR, "PR_ATTACHADDR" },
140#endif
141#ifdef PR_DETACHADDR
142 { PR_DETACHADDR, "PR_DETACHADDR" },
143#endif
144#ifdef PR_TERMCHILD
145 { PR_TERMCHILD, "PR_TERMCHILD" },
146#endif
147#ifdef PR_GETSHMASK
148 { PR_GETSHMASK, "PR_GETSHMASK" },
149#endif
150#ifdef PR_GETNSHARE
151 { PR_GETNSHARE, "PR_GETNSHARE" },
152#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +0000153#ifdef PR_COREPID
154 { PR_COREPID, "PR_COREPID" },
155#endif
156#ifdef PR_ATTACHADDRPERM
157 { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" },
158#endif
159#ifdef PR_PTHREADEXIT
160 { PR_PTHREADEXIT, "PR_PTHREADEXIT" },
161#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000162#ifdef PR_SET_PDEATHSIG
163 { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
164#endif
165#ifdef PR_GET_PDEATHSIG
166 { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
167#endif
Dmitry V. Levinf02cf212008-09-03 00:54:40 +0000168#ifdef PR_GET_DUMPABLE
169 { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" },
170#endif
171#ifdef PR_SET_DUMPABLE
172 { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" },
173#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000174#ifdef PR_GET_UNALIGN
175 { PR_GET_UNALIGN, "PR_GET_UNALIGN" },
176#endif
177#ifdef PR_SET_UNALIGN
178 { PR_SET_UNALIGN, "PR_SET_UNALIGN" },
179#endif
180#ifdef PR_GET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000181 { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000182#endif
183#ifdef PR_SET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000184 { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000185#endif
Roland McGrathe5039fb2007-11-03 23:58:07 +0000186#ifdef PR_GET_FPEMU
187 { PR_GET_FPEMU, "PR_GET_FPEMU" },
188#endif
189#ifdef PR_SET_FPEMU
190 { PR_SET_FPEMU, "PR_SET_FPEMU" },
191#endif
192#ifdef PR_GET_FPEXC
193 { PR_GET_FPEXC, "PR_GET_FPEXC" },
194#endif
195#ifdef PR_SET_FPEXC
196 { PR_SET_FPEXC, "PR_SET_FPEXC" },
197#endif
198#ifdef PR_GET_TIMING
199 { PR_GET_TIMING, "PR_GET_TIMING" },
200#endif
201#ifdef PR_SET_TIMING
202 { PR_SET_TIMING, "PR_SET_TIMING" },
203#endif
204#ifdef PR_SET_NAME
205 { PR_SET_NAME, "PR_SET_NAME" },
206#endif
207#ifdef PR_GET_NAME
208 { PR_GET_NAME, "PR_GET_NAME" },
209#endif
210#ifdef PR_GET_ENDIAN
211 { PR_GET_ENDIAN, "PR_GET_ENDIAN" },
212#endif
213#ifdef PR_SET_ENDIAN
214 { PR_SET_ENDIAN, "PR_SET_ENDIAN" },
215#endif
216#ifdef PR_GET_SECCOMP
217 { PR_GET_SECCOMP, "PR_GET_SECCOMP" },
218#endif
219#ifdef PR_SET_SECCOMP
220 { PR_SET_SECCOMP, "PR_SET_SECCOMP" },
221#endif
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000222#ifdef PR_GET_TSC
223 { PR_GET_TSC, "PR_GET_TSC" },
224#endif
225#ifdef PR_SET_TSC
226 { PR_SET_TSC, "PR_SET_TSC" },
227#endif
228#ifdef PR_GET_SECUREBITS
229 { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" },
230#endif
231#ifdef PR_SET_SECUREBITS
232 { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" },
233#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000234 { 0, NULL },
235};
236
Roland McGratha4d48532005-06-08 20:45:28 +0000237static const char *
Denys Vlasenko12014262011-05-30 14:00:14 +0200238unalignctl_string(unsigned int ctl)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000239{
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100240 static char buf[sizeof(int)*2 + 2];
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000241
242 switch (ctl) {
243#ifdef PR_UNALIGN_NOPRINT
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100244 case PR_UNALIGN_NOPRINT:
245 return "NOPRINT";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000246#endif
247#ifdef PR_UNALIGN_SIGBUS
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100248 case PR_UNALIGN_SIGBUS:
249 return "SIGBUS";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000250#endif
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100251 default:
252 break;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000253 }
254 sprintf(buf, "%x", ctl);
255 return buf;
256}
257
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000258int
Denys Vlasenko12014262011-05-30 14:00:14 +0200259sys_prctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000260{
261 int i;
262
263 if (entering(tcp)) {
264 printxval(prctl_options, tcp->u_arg[0], "PR_???");
265 switch (tcp->u_arg[0]) {
266#ifdef PR_GETNSHARE
267 case PR_GETNSHARE:
268 break;
269#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000270#ifdef PR_SET_PDEATHSIG
271 case PR_SET_PDEATHSIG:
272 tprintf(", %lu", tcp->u_arg[1]);
273 break;
274#endif
275#ifdef PR_GET_PDEATHSIG
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000276 case PR_GET_PDEATHSIG:
277 break;
278#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000279#ifdef PR_SET_DUMPABLE
280 case PR_SET_DUMPABLE:
281 tprintf(", %lu", tcp->u_arg[1]);
282 break;
283#endif
284#ifdef PR_GET_DUMPABLE
285 case PR_GET_DUMPABLE:
286 break;
287#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000288#ifdef PR_SET_UNALIGN
289 case PR_SET_UNALIGN:
290 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
291 break;
292#endif
293#ifdef PR_GET_UNALIGN
294 case PR_GET_UNALIGN:
295 tprintf(", %#lx", tcp->u_arg[1]);
296 break;
297#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000298#ifdef PR_SET_KEEPCAPS
299 case PR_SET_KEEPCAPS:
300 tprintf(", %lu", tcp->u_arg[1]);
301 break;
302#endif
303#ifdef PR_GET_KEEPCAPS
304 case PR_GET_KEEPCAPS:
305 break;
306#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000307 default:
Denys Vlasenko74ec14f2013-02-21 16:13:47 +0100308 for (i = 1; i < tcp->s_ent->nargs; i++)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000309 tprintf(", %#lx", tcp->u_arg[i]);
310 break;
311 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000312 } else {
313 switch (tcp->u_arg[0]) {
314#ifdef PR_GET_PDEATHSIG
315 case PR_GET_PDEATHSIG:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000316 if (umove(tcp, tcp->u_arg[1], &i) < 0)
317 tprintf(", %#lx", tcp->u_arg[1]);
318 else
319 tprintf(", {%u}", i);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000320 break;
321#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000322#ifdef PR_GET_DUMPABLE
323 case PR_GET_DUMPABLE:
324 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000325#endif
326#ifdef PR_GET_UNALIGN
327 case PR_GET_UNALIGN:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000328 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
329 break;
330 tcp->auxstr = unalignctl_string(i);
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000331 return RVAL_STR;
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000332#endif
333#ifdef PR_GET_KEEPCAPS
334 case PR_GET_KEEPCAPS:
335 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000336#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000337 default:
338 break;
339 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000340 }
341 return 0;
342}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000343#endif /* HAVE_PRCTL */
344
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000345int
Denys Vlasenko12014262011-05-30 14:00:14 +0200346sys_sethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000347{
348 if (entering(tcp)) {
349 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
350 tprintf(", %lu", tcp->u_arg[1]);
351 }
352 return 0;
353}
354
Denys Vlasenko84703742012-02-25 02:38:52 +0100355#if defined(ALPHA)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000356int
Denys Vlasenko12014262011-05-30 14:00:14 +0200357sys_gethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000358{
359 if (exiting(tcp)) {
360 if (syserror(tcp))
361 tprintf("%#lx", tcp->u_arg[0]);
362 else
363 printpath(tcp, tcp->u_arg[0]);
364 tprintf(", %lu", tcp->u_arg[1]);
365 }
366 return 0;
367}
Denys Vlasenko84703742012-02-25 02:38:52 +0100368#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000369
370int
Denys Vlasenko12014262011-05-30 14:00:14 +0200371sys_setdomainname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000372{
373 if (entering(tcp)) {
374 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
375 tprintf(", %lu", tcp->u_arg[1]);
376 }
377 return 0;
378}
379
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000380int
Denys Vlasenko12014262011-05-30 14:00:14 +0200381sys_exit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000382{
383 if (exiting(tcp)) {
384 fprintf(stderr, "_exit returned!\n");
385 return -1;
386 }
387 /* special case: we stop tracing this process, finish line now */
388 tprintf("%ld) ", tcp->u_arg[0]);
Denys Vlasenko102ec492011-08-25 01:27:59 +0200389 tabto();
Denys Vlasenko000b6012012-01-28 01:25:03 +0100390 tprints("= ?\n");
Denys Vlasenko7de265d2012-03-13 11:44:31 +0100391 line_ended();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000392 return 0;
393}
394
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000395/* defines copied from linux/sched.h since we can't include that
396 * ourselves (it conflicts with *lots* of libc includes)
397 */
398#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
399#define CLONE_VM 0x00000100 /* set if VM shared between processes */
400#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
401#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
402#define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
Roland McGrath909875b2002-12-22 03:34:36 +0000403#define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000404#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
405#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
406#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
Roland McGrath909875b2002-12-22 03:34:36 +0000407#define CLONE_THREAD 0x00010000 /* Same thread group? */
408#define CLONE_NEWNS 0x00020000 /* New namespace group? */
409#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
410#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
411#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
412#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
Roland McGrath909875b2002-12-22 03:34:36 +0000413#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
414#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000415#define CLONE_STOPPED 0x02000000 /* Start in stopped state */
416#define CLONE_NEWUTS 0x04000000 /* New utsname group? */
417#define CLONE_NEWIPC 0x08000000 /* New ipcs */
418#define CLONE_NEWUSER 0x10000000 /* New user namespace */
419#define CLONE_NEWPID 0x20000000 /* New pid namespace */
420#define CLONE_NEWNET 0x40000000 /* New network namespace */
421#define CLONE_IO 0x80000000 /* Clone io context */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000422
Roland McGrathd9f816f2004-09-04 03:39:20 +0000423static const struct xlat clone_flags[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100424 { CLONE_VM, "CLONE_VM" },
425 { CLONE_FS, "CLONE_FS" },
426 { CLONE_FILES, "CLONE_FILES" },
427 { CLONE_SIGHAND, "CLONE_SIGHAND" },
428 { CLONE_IDLETASK, "CLONE_IDLETASK" },
429 { CLONE_PTRACE, "CLONE_PTRACE" },
430 { CLONE_VFORK, "CLONE_VFORK" },
431 { CLONE_PARENT, "CLONE_PARENT" },
432 { CLONE_THREAD, "CLONE_THREAD" },
433 { CLONE_NEWNS, "CLONE_NEWNS" },
434 { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
435 { CLONE_SETTLS, "CLONE_SETTLS" },
436 { CLONE_PARENT_SETTID, "CLONE_PARENT_SETTID" },
437 { CLONE_CHILD_CLEARTID, "CLONE_CHILD_CLEARTID" },
438 { CLONE_UNTRACED, "CLONE_UNTRACED" },
439 { CLONE_CHILD_SETTID, "CLONE_CHILD_SETTID" },
440 { CLONE_STOPPED, "CLONE_STOPPED" },
441 { CLONE_NEWUTS, "CLONE_NEWUTS" },
442 { CLONE_NEWIPC, "CLONE_NEWIPC" },
443 { CLONE_NEWUSER, "CLONE_NEWUSER" },
444 { CLONE_NEWPID, "CLONE_NEWPID" },
445 { CLONE_NEWNET, "CLONE_NEWNET" },
446 { CLONE_IO, "CLONE_IO" },
447 { 0, NULL },
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000448};
449
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100450#ifdef I386
451# include <asm/ldt.h>
452# ifdef HAVE_STRUCT_USER_DESC
453# define modify_ldt_ldt_s user_desc
454# endif
Roland McGrath909875b2002-12-22 03:34:36 +0000455extern void print_ldt_entry();
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100456#endif
Roland McGrath909875b2002-12-22 03:34:36 +0000457
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100458#if defined IA64
459# define ARG_FLAGS 0
460# define ARG_STACK 1
461# define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
462# define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
463# define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
464# define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
465#elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
466# define ARG_STACK 0
467# define ARG_FLAGS 1
468# define ARG_PTID 2
469# define ARG_CTID 3
470# define ARG_TLS 4
Christian Svensson492f81f2013-02-14 13:26:27 +0100471#elif defined X86_64 || defined X32 || defined ALPHA || defined TILE \
472 || defined OR1K
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100473# define ARG_FLAGS 0
474# define ARG_STACK 1
475# define ARG_PTID 2
476# define ARG_CTID 3
477# define ARG_TLS 4
478#else
479# define ARG_FLAGS 0
480# define ARG_STACK 1
481# define ARG_PTID 2
482# define ARG_TLS 3
483# define ARG_CTID 4
484#endif
Roland McGrath9677b3a2003-03-12 09:54:36 +0000485
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000486int
Denys Vlasenko12014262011-05-30 14:00:14 +0200487sys_clone(struct tcb *tcp)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000488{
489 if (exiting(tcp)) {
Wang Chaocbdd1902010-09-02 15:08:59 +0800490 const char *sep = "|";
Roland McGrath9677b3a2003-03-12 09:54:36 +0000491 unsigned long flags = tcp->u_arg[ARG_FLAGS];
492 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100493#ifdef ARG_STACKSIZE
Roland McGrath9677b3a2003-03-12 09:54:36 +0000494 if (ARG_STACKSIZE != -1)
495 tprintf("stack_size=%#lx, ",
496 tcp->u_arg[ARG_STACKSIZE]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100497#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200498 tprints("flags=");
Wang Chaocbdd1902010-09-02 15:08:59 +0800499 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
500 sep = "";
Roland McGrath984154d2003-05-23 01:08:42 +0000501 if ((flags & CSIGNAL) != 0)
Wang Chaocbdd1902010-09-02 15:08:59 +0800502 tprintf("%s%s", sep, signame(flags & CSIGNAL));
Roland McGrathb4968be2003-01-20 09:04:33 +0000503 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
Roland McGrath9677b3a2003-03-12 09:54:36 +0000504 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
Roland McGrath909875b2002-12-22 03:34:36 +0000505 return 0;
Roland McGrath6f67a982003-03-21 07:33:15 +0000506 if (flags & CLONE_PARENT_SETTID)
507 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000508 if (flags & CLONE_SETTLS) {
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100509#ifdef I386
Roland McGrath909875b2002-12-22 03:34:36 +0000510 struct modify_ldt_ldt_s copy;
Roland McGrath9677b3a2003-03-12 09:54:36 +0000511 if (umove(tcp, tcp->u_arg[ARG_TLS], &copy) != -1) {
Roland McGrath909875b2002-12-22 03:34:36 +0000512 tprintf(", {entry_number:%d, ",
513 copy.entry_number);
514 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200515 tprints("...}");
Roland McGrath909875b2002-12-22 03:34:36 +0000516 else
517 print_ldt_entry(&copy);
518 }
519 else
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100520#endif
Roland McGrath43f2c842003-03-12 09:58:14 +0000521 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
Roland McGrath909875b2002-12-22 03:34:36 +0000522 }
Roland McGrath9677b3a2003-03-12 09:54:36 +0000523 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
524 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000525 }
526 return 0;
527}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000528
529int
530sys_unshare(struct tcb *tcp)
531{
532 if (entering(tcp))
533 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
534 return 0;
535}
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000536
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000537int
Denys Vlasenko081533c2012-03-17 02:17:51 +0100538sys_fork(struct tcb *tcp)
539{
540 if (exiting(tcp))
541 return RVAL_UDECIMAL;
542 return 0;
543}
544
545int
Denys Vlasenko12014262011-05-30 14:00:14 +0200546sys_vfork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000547{
548 if (exiting(tcp))
549 return RVAL_UDECIMAL;
550 return 0;
551}
552
Dmitry V. Levin50a218d2011-01-18 17:36:20 +0000553int sys_getuid(struct tcb *tcp)
554{
555 if (exiting(tcp))
556 tcp->u_rval = (uid_t) tcp->u_rval;
557 return RVAL_UDECIMAL;
558}
559
560int sys_setfsuid(struct tcb *tcp)
561{
562 if (entering(tcp))
563 tprintf("%u", (uid_t) tcp->u_arg[0]);
564 else
565 tcp->u_rval = (uid_t) tcp->u_rval;
566 return RVAL_UDECIMAL;
567}
568
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000569int
Denys Vlasenko12014262011-05-30 14:00:14 +0200570sys_setuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000571{
572 if (entering(tcp)) {
573 tprintf("%u", (uid_t) tcp->u_arg[0]);
574 }
575 return 0;
576}
577
578int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000579sys_getresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000580{
581 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000582 __kernel_uid_t uid;
583 if (syserror(tcp))
584 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
585 tcp->u_arg[1], tcp->u_arg[2]);
586 else {
587 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
588 tprintf("%#lx, ", tcp->u_arg[0]);
589 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000590 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000591 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
592 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000593 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000594 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000595 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
596 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000597 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000598 tprintf("[%lu]", (unsigned long) uid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000599 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000600 }
601 return 0;
602}
603
604int
Denys Vlasenko12014262011-05-30 14:00:14 +0200605sys_setreuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000606{
607 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000608 printuid("", tcp->u_arg[0]);
609 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000610 }
611 return 0;
612}
613
614int
Denys Vlasenko12014262011-05-30 14:00:14 +0200615sys_setresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000616{
617 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000618 printuid("", tcp->u_arg[0]);
619 printuid(", ", tcp->u_arg[1]);
620 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000621 }
622 return 0;
623}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000624
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000625int
Denys Vlasenko12014262011-05-30 14:00:14 +0200626sys_setgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000627{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000628 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000629 unsigned long len, size, start, cur, end, abbrev_end;
630 GETGROUPS_T gid;
631 int failed = 0;
632
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000633 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000634 tprintf("%lu, ", len);
635 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200636 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000637 return 0;
638 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000639 start = tcp->u_arg[1];
640 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200641 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000642 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000643 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000644 size = len * sizeof(gid);
645 end = start + size;
646 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
647 tprintf("%#lx", start);
648 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000649 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000650 if (abbrev(tcp)) {
651 abbrev_end = start + max_strlen * sizeof(gid);
652 if (abbrev_end < start)
653 abbrev_end = end;
654 } else {
655 abbrev_end = end;
656 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200657 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000658 for (cur = start; cur < end; cur += sizeof(gid)) {
659 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200660 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000661 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200662 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000663 break;
664 }
665 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200666 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000667 failed = 1;
668 break;
669 }
670 tprintf("%lu", (unsigned long) gid);
671 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200672 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000673 if (failed)
674 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000675 }
676 return 0;
677}
678
679int
Denys Vlasenko12014262011-05-30 14:00:14 +0200680sys_getgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000681{
Roland McGrathaa524c82005-06-01 19:22:06 +0000682 unsigned long len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000683
684 if (entering(tcp)) {
685 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000686 tprintf("%lu, ", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000687 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000688 unsigned long size, start, cur, end, abbrev_end;
689 GETGROUPS_T gid;
690 int failed = 0;
691
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000692 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000693 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200694 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000695 return 0;
696 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000697 start = tcp->u_arg[1];
698 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200699 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000700 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000701 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000702 if (tcp->u_arg[0] == 0) {
703 tprintf("%#lx", start);
704 return 0;
705 }
706 size = len * sizeof(gid);
707 end = start + size;
708 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
709 size / sizeof(gid) != len || end < start) {
710 tprintf("%#lx", start);
711 return 0;
712 }
713 if (abbrev(tcp)) {
714 abbrev_end = start + max_strlen * sizeof(gid);
715 if (abbrev_end < start)
716 abbrev_end = end;
717 } else {
718 abbrev_end = end;
719 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200720 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000721 for (cur = start; cur < end; cur += sizeof(gid)) {
722 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200723 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000724 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200725 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000726 break;
727 }
728 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200729 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000730 failed = 1;
731 break;
732 }
733 tprintf("%lu", (unsigned long) gid);
734 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200735 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000736 if (failed)
737 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000738 }
739 return 0;
740}
741
Roland McGrath83bd47a2003-11-13 22:32:26 +0000742int
Denys Vlasenko12014262011-05-30 14:00:14 +0200743sys_setgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000744{
Roland McGrath83bd47a2003-11-13 22:32:26 +0000745 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000746 unsigned long len, size, start, cur, end, abbrev_end;
747 GETGROUPS32_T gid;
748 int failed = 0;
749
Roland McGrath83bd47a2003-11-13 22:32:26 +0000750 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000751 tprintf("%lu, ", len);
752 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200753 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000754 return 0;
755 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000756 start = tcp->u_arg[1];
757 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200758 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000759 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000760 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000761 size = len * sizeof(gid);
762 end = start + size;
763 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
764 tprintf("%#lx", start);
765 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000766 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000767 if (abbrev(tcp)) {
768 abbrev_end = start + max_strlen * sizeof(gid);
769 if (abbrev_end < start)
770 abbrev_end = end;
771 } else {
772 abbrev_end = end;
773 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200774 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000775 for (cur = start; cur < end; cur += sizeof(gid)) {
776 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200777 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000778 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200779 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000780 break;
781 }
782 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200783 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000784 failed = 1;
785 break;
786 }
787 tprintf("%lu", (unsigned long) gid);
788 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200789 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000790 if (failed)
791 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000792 }
793 return 0;
794}
795
796int
Denys Vlasenko12014262011-05-30 14:00:14 +0200797sys_getgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000798{
Roland McGrathaa524c82005-06-01 19:22:06 +0000799 unsigned long len;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000800
801 if (entering(tcp)) {
802 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000803 tprintf("%lu, ", len);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000804 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000805 unsigned long size, start, cur, end, abbrev_end;
806 GETGROUPS32_T gid;
807 int failed = 0;
808
Roland McGrath83bd47a2003-11-13 22:32:26 +0000809 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000810 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200811 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000812 return 0;
813 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000814 start = tcp->u_arg[1];
815 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200816 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000817 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000818 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000819 size = len * sizeof(gid);
820 end = start + size;
821 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
822 size / sizeof(gid) != len || end < start) {
823 tprintf("%#lx", start);
824 return 0;
825 }
826 if (abbrev(tcp)) {
827 abbrev_end = start + max_strlen * sizeof(gid);
828 if (abbrev_end < start)
829 abbrev_end = end;
830 } else {
831 abbrev_end = end;
832 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200833 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000834 for (cur = start; cur < end; cur += sizeof(gid)) {
835 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200836 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000837 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200838 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000839 break;
840 }
841 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200842 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000843 failed = 1;
844 break;
845 }
846 tprintf("%lu", (unsigned long) gid);
847 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200848 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000849 if (failed)
850 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000851 }
852 return 0;
853}
Roland McGrath83bd47a2003-11-13 22:32:26 +0000854
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000855static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000856printargv(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000857{
Roland McGrath85a3bc42007-08-02 02:13:05 +0000858 union {
Andreas Schwab99c85692009-08-28 19:36:20 +0200859 unsigned int p32;
860 unsigned long p64;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000861 char data[sizeof(long)];
862 } cp;
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000863 const char *sep;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000864 int n = 0;
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100865 unsigned wordsize = current_wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000866
Roland McGrath85a3bc42007-08-02 02:13:05 +0000867 cp.p64 = 1;
868 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100869 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000870 tprintf("%#lx", addr);
871 return;
872 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100873 if (wordsize == 4)
Roland McGrath85a3bc42007-08-02 02:13:05 +0000874 cp.p64 = cp.p32;
875 if (cp.p64 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000876 break;
Denys Vlasenko5940e652011-09-01 09:55:05 +0200877 tprints(sep);
Roland McGrath85a3bc42007-08-02 02:13:05 +0000878 printstr(tcp, cp.p64, -1);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100879 addr += wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000880 }
Roland McGrath85a3bc42007-08-02 02:13:05 +0000881 if (cp.p64)
882 tprintf("%s...", sep);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000883}
884
885static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000886printargc(const char *fmt, struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000887{
888 int count;
889 char *cp;
890
891 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
892 addr += sizeof(char *);
893 }
894 tprintf(fmt, count, count == 1 ? "" : "s");
895}
896
Denys Vlasenko84703742012-02-25 02:38:52 +0100897#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000898int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000899sys_execv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000900{
901 if (entering(tcp)) {
902 printpath(tcp, tcp->u_arg[0]);
903 if (!verbose(tcp))
904 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000905 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200906 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000907 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200908 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000909 }
910 }
911 return 0;
912}
Denys Vlasenko84703742012-02-25 02:38:52 +0100913#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000914
915int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000916sys_execve(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000917{
918 if (entering(tcp)) {
919 printpath(tcp, tcp->u_arg[0]);
920 if (!verbose(tcp))
921 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000922 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200923 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000924 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200925 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000926 }
927 if (!verbose(tcp))
928 tprintf(", %#lx", tcp->u_arg[2]);
929 else if (abbrev(tcp))
930 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
931 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200932 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000933 printargv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200934 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000935 }
936 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000937 return 0;
938}
939
Roland McGrath7ec1d352002-12-17 04:50:44 +0000940#ifndef __WNOTHREAD
941#define __WNOTHREAD 0x20000000
942#endif
943#ifndef __WALL
944#define __WALL 0x40000000
945#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000946#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +0000947#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000948#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000949
Roland McGrathd9f816f2004-09-04 03:39:20 +0000950static const struct xlat wait4_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000951 { WNOHANG, "WNOHANG" },
952#ifndef WSTOPPED
953 { WUNTRACED, "WUNTRACED" },
954#endif
955#ifdef WEXITED
956 { WEXITED, "WEXITED" },
957#endif
958#ifdef WTRAPPED
959 { WTRAPPED, "WTRAPPED" },
960#endif
961#ifdef WSTOPPED
962 { WSTOPPED, "WSTOPPED" },
963#endif
964#ifdef WCONTINUED
965 { WCONTINUED, "WCONTINUED" },
966#endif
967#ifdef WNOWAIT
968 { WNOWAIT, "WNOWAIT" },
969#endif
970#ifdef __WCLONE
971 { __WCLONE, "__WCLONE" },
972#endif
Roland McGrath7ec1d352002-12-17 04:50:44 +0000973#ifdef __WALL
974 { __WALL, "__WALL" },
975#endif
976#ifdef __WNOTHREAD
977 { __WNOTHREAD, "__WNOTHREAD" },
978#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000979 { 0, NULL },
980};
981
Roland McGrath5e02a572004-10-19 23:33:47 +0000982#if !defined WCOREFLAG && defined WCOREFLG
983# define WCOREFLAG WCOREFLG
984#endif
985#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000986# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +0000987#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000988#ifndef WCOREDUMP
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100989# define WCOREDUMP(status) ((status) & 0200)
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000990#endif
Roland McGrath5e02a572004-10-19 23:33:47 +0000991#ifndef W_STOPCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100992# define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
Roland McGrath5e02a572004-10-19 23:33:47 +0000993#endif
994#ifndef W_EXITCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100995# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
Roland McGrath5e02a572004-10-19 23:33:47 +0000996#endif
997
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000998static int
Denys Vlasenko12014262011-05-30 14:00:14 +0200999printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001000{
1001 int exited = 0;
1002
1003 /*
1004 * Here is a tricky presentation problem. This solution
1005 * is still not entirely satisfactory but since there
1006 * are no wait status constructors it will have to do.
1007 */
Roland McGrath79fbda52004-04-14 02:45:55 +00001008 if (WIFSTOPPED(status)) {
1009 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001010 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +00001011 status &= ~W_STOPCODE(WSTOPSIG(status));
1012 }
1013 else if (WIFSIGNALED(status)) {
1014 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001015 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001016 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +00001017 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1018 }
1019 else if (WIFEXITED(status)) {
1020 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001021 WEXITSTATUS(status));
1022 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +00001023 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001024 }
Roland McGrath79fbda52004-04-14 02:45:55 +00001025 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001026 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001027 return 0;
1028 }
1029
1030 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001031 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +00001032 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +00001033 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001034
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001035 return exited;
1036}
1037
1038static int
Denys Vlasenko59432db2009-01-26 19:09:35 +00001039printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001040{
1041 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001042
1043 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001044 /* On Linux, kernel-side pid_t is typedef'ed to int
1045 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +00001046 * pid argument to int on 64bit arches, producing,
1047 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001048 * in strace. We have to use int here, not long.
1049 */
1050 int pid = tcp->u_arg[0];
1051 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001052 } else {
1053 /* status */
1054 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001055 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001056 else if (syserror(tcp) || tcp->u_rval == 0)
1057 tprintf("%#lx", tcp->u_arg[1]);
1058 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001059 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001060 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +00001061 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001062 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001063 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001064 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001065 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001066 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001067 /* usage */
1068 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001069 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001070 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +00001071#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001072 if (bitness)
1073 printrusage32(tcp, tcp->u_arg[3]);
1074 else
1075#endif
1076 printrusage(tcp, tcp->u_arg[3]);
1077 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001078 else
1079 tprintf("%#lx", tcp->u_arg[3]);
1080 }
1081 }
1082 return 0;
1083}
1084
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001085int
Denys Vlasenko12014262011-05-30 14:00:14 +02001086sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001087{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001088 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001089}
1090
1091int
Denys Vlasenko12014262011-05-30 14:00:14 +02001092sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001093{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001094 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001095}
1096
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001097#ifdef ALPHA
1098int
Denys Vlasenko12014262011-05-30 14:00:14 +02001099sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001100{
1101 return printwaitn(tcp, 4, 1);
1102}
1103#endif
1104
Roland McGrathd9f816f2004-09-04 03:39:20 +00001105static const struct xlat waitid_types[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001106 { P_PID, "P_PID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001107#ifdef P_PPID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001108 { P_PPID, "P_PPID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001109#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001110 { P_PGID, "P_PGID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001111#ifdef P_SID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001112 { P_SID, "P_SID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001113#endif
1114#ifdef P_CID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001115 { P_CID, "P_CID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001116#endif
1117#ifdef P_UID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001118 { P_UID, "P_UID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001119#endif
1120#ifdef P_GID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001121 { P_GID, "P_GID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001122#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001123 { P_ALL, "P_ALL" },
1124#ifdef P_LWPID
1125 { P_LWPID, "P_LWPID" },
1126#endif
1127 { 0, NULL },
1128};
1129
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001130int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +00001131sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001132{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001133 if (entering(tcp)) {
1134 printxval(waitid_types, tcp->u_arg[0], "P_???");
1135 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001136 }
1137 else {
1138 /* siginfo */
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01001139 printsiginfo_at(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001140 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001141 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001142 printflags(wait4_options, tcp->u_arg[3], "W???");
Denys Vlasenko74ec14f2013-02-21 16:13:47 +01001143 if (tcp->s_ent->nargs > 4) {
Roland McGrath39426a32004-10-06 22:02:59 +00001144 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001145 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +00001146 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001147 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +00001148 else if (tcp->u_error)
1149 tprintf("%#lx", tcp->u_arg[4]);
1150 else
1151 printrusage(tcp, tcp->u_arg[4]);
1152 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001153 }
1154 return 0;
1155}
1156
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001157int
Denys Vlasenko12014262011-05-30 14:00:14 +02001158sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001159{
1160 struct utsname uname;
1161
1162 if (exiting(tcp)) {
1163 if (syserror(tcp) || !verbose(tcp))
1164 tprintf("%#lx", tcp->u_arg[0]);
1165 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001166 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001167 else if (!abbrev(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001168 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1169 uname.sysname, uname.nodename);
1170 tprintf("release=\"%s\", version=\"%s\", ",
1171 uname.release, uname.version);
1172 tprintf("machine=\"%s\"", uname.machine);
Dmitry V. Levinea22e972012-05-01 20:56:32 +00001173#ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001174 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001175#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001176 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001177 }
1178 else
1179 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1180 uname.sysname, uname.nodename);
1181 }
1182 return 0;
1183}
1184
Roland McGratheb9e2e82009-06-02 16:49:22 -07001185static const struct xlat ptrace_cmds[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001186 { PTRACE_TRACEME, "PTRACE_TRACEME" },
Denys Vlasenko61526c62011-08-25 10:21:13 +02001187 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1188 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1189 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1190 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1191 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1192 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001193 { PTRACE_CONT, "PTRACE_CONT" },
1194 { PTRACE_KILL, "PTRACE_KILL" },
1195 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1196 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1197 { PTRACE_DETACH, "PTRACE_DETACH" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001198#ifdef PTRACE_GETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001199 { PTRACE_GETREGS, "PTRACE_GETREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001200#endif
1201#ifdef PTRACE_SETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001202 { PTRACE_SETREGS, "PTRACE_SETREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001203#endif
1204#ifdef PTRACE_GETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001205 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001206#endif
1207#ifdef PTRACE_SETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001208 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001209#endif
1210#ifdef PTRACE_GETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001211 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001212#endif
1213#ifdef PTRACE_SETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001214 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001215#endif
1216#ifdef PTRACE_GETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001217 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001218#endif
1219#ifdef PTRACE_SETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001220 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001221#endif
1222#ifdef PTRACE_SETOPTIONS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001223 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001224#endif
1225#ifdef PTRACE_GETEVENTMSG
Denys Vlasenko61526c62011-08-25 10:21:13 +02001226 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001227#endif
1228#ifdef PTRACE_GETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001229 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001230#endif
1231#ifdef PTRACE_SETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001232 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001233#endif
1234#ifdef PTRACE_GETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001235 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001236#endif
1237#ifdef PTRACE_SETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001238 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001239#endif
1240#ifdef PTRACE_SET_SYSCALL
Denys Vlasenko61526c62011-08-25 10:21:13 +02001241 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001242#endif
1243#ifdef PTRACE_SEIZE
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001244 { PTRACE_SEIZE, "PTRACE_SEIZE" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001245#endif
1246#ifdef PTRACE_INTERRUPT
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001247 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001248#endif
1249#ifdef PTRACE_LISTEN
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001250 { PTRACE_LISTEN, "PTRACE_LISTEN" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001251#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001252 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
Denys Vlasenkof535b542009-01-13 18:30:55 +00001253
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001254 { 0, NULL },
1255};
1256
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001257#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00001258static const struct xlat ptrace_setoptions_flags[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001259# ifdef PTRACE_O_TRACESYSGOOD
Denys Vlasenkof535b542009-01-13 18:30:55 +00001260 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001261# endif
1262# ifdef PTRACE_O_TRACEFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001263 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001264# endif
1265# ifdef PTRACE_O_TRACEVFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001266 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001267# endif
1268# ifdef PTRACE_O_TRACECLONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001269 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001270# endif
1271# ifdef PTRACE_O_TRACEEXEC
Denys Vlasenkof535b542009-01-13 18:30:55 +00001272 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001273# endif
1274# ifdef PTRACE_O_TRACEVFORKDONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001275 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001276# endif
1277# ifdef PTRACE_O_TRACEEXIT
Denys Vlasenkof535b542009-01-13 18:30:55 +00001278 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001279# endif
Denys Vlasenkof535b542009-01-13 18:30:55 +00001280 { 0, NULL },
1281};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001282#endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001283
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001284static const struct xlat nt_descriptor_types[] = {
1285#ifdef NT_PRSTATUS
1286 { NT_PRSTATUS, "NT_PRSTATUS" },
1287#endif
1288#ifdef NT_FPREGSET
1289 { NT_FPREGSET, "NT_FPREGSET" },
1290#endif
1291#ifdef NT_PRPSINFO
1292 { NT_PRPSINFO, "NT_PRPSINFO" },
1293#endif
1294#ifdef NT_PRXREG
1295 { NT_PRXREG, "NT_PRXREG" },
1296#endif
1297#ifdef NT_TASKSTRUCT
1298 { NT_TASKSTRUCT, "NT_TASKSTRUCT" },
1299#endif
1300#ifdef NT_PLATFORM
1301 { NT_PLATFORM, "NT_PLATFORM" },
1302#endif
1303#ifdef NT_AUXV
1304 { NT_AUXV, "NT_AUXV" },
1305#endif
1306#ifdef NT_GWINDOWS
1307 { NT_GWINDOWS, "NT_GWINDOWS" },
1308#endif
1309#ifdef NT_ASRS
1310 { NT_ASRS, "NT_ASRS" },
1311#endif
1312#ifdef NT_PSTATUS
1313 { NT_PSTATUS, "NT_PSTATUS" },
1314#endif
1315#ifdef NT_PSINFO
1316 { NT_PSINFO, "NT_PSINFO" },
1317#endif
1318#ifdef NT_PRCRED
1319 { NT_PRCRED, "NT_PRCRED" },
1320#endif
1321#ifdef NT_UTSNAME
1322 { NT_UTSNAME, "NT_UTSNAME" },
1323#endif
1324#ifdef NT_LWPSTATUS
1325 { NT_LWPSTATUS, "NT_LWPSTATUS" },
1326#endif
1327#ifdef NT_LWPSINFO
1328 { NT_LWPSINFO, "NT_LWPSINFO" },
1329#endif
1330#ifdef NT_PRFPXREG
1331 { NT_PRFPXREG, "NT_PRFPXREG" },
1332#endif
1333#ifdef NT_PRXFPREG
1334 { NT_PRXFPREG, "NT_PRXFPREG" },
1335#endif
1336#ifdef NT_PPC_VMX
1337 { NT_PPC_VMX, "NT_PPC_VMX" },
1338#endif
1339#ifdef NT_PPC_SPE
1340 { NT_PPC_SPE, "NT_PPC_SPE" },
1341#endif
1342#ifdef NT_PPC_VSX
1343 { NT_PPC_VSX, "NT_PPC_VSX" },
1344#endif
1345#ifdef NT_386_TLS
1346 { NT_386_TLS, "NT_386_TLS" },
1347#endif
1348#ifdef NT_386_IOPERM
1349 { NT_386_IOPERM, "NT_386_IOPERM" },
1350#endif
1351#ifdef NT_X86_XSTATE
1352 { NT_X86_XSTATE, "NT_X86_XSTATE" },
1353#endif
1354 { 0, NULL },
1355};
1356
Denys Vlasenko513e9c22012-03-21 14:39:22 +01001357#define uoff(member) offsetof(struct user, member)
1358
Roland McGrathd9f816f2004-09-04 03:39:20 +00001359const struct xlat struct_user_offsets[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001360#if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001361 { PT_PSWMASK, "psw_mask" },
1362 { PT_PSWADDR, "psw_addr" },
1363 { PT_GPR0, "gpr0" },
1364 { PT_GPR1, "gpr1" },
1365 { PT_GPR2, "gpr2" },
1366 { PT_GPR3, "gpr3" },
1367 { PT_GPR4, "gpr4" },
1368 { PT_GPR5, "gpr5" },
1369 { PT_GPR6, "gpr6" },
1370 { PT_GPR7, "gpr7" },
1371 { PT_GPR8, "gpr8" },
1372 { PT_GPR9, "gpr9" },
1373 { PT_GPR10, "gpr10" },
1374 { PT_GPR11, "gpr11" },
1375 { PT_GPR12, "gpr12" },
1376 { PT_GPR13, "gpr13" },
1377 { PT_GPR14, "gpr14" },
1378 { PT_GPR15, "gpr15" },
1379 { PT_ACR0, "acr0" },
1380 { PT_ACR1, "acr1" },
1381 { PT_ACR2, "acr2" },
1382 { PT_ACR3, "acr3" },
1383 { PT_ACR4, "acr4" },
1384 { PT_ACR5, "acr5" },
1385 { PT_ACR6, "acr6" },
1386 { PT_ACR7, "acr7" },
1387 { PT_ACR8, "acr8" },
1388 { PT_ACR9, "acr9" },
1389 { PT_ACR10, "acr10" },
1390 { PT_ACR11, "acr11" },
1391 { PT_ACR12, "acr12" },
1392 { PT_ACR13, "acr13" },
1393 { PT_ACR14, "acr14" },
1394 { PT_ACR15, "acr15" },
1395 { PT_ORIGGPR2, "orig_gpr2" },
1396 { PT_FPC, "fpc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001397#if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001398 { PT_FPR0_HI, "fpr0.hi" },
1399 { PT_FPR0_LO, "fpr0.lo" },
1400 { PT_FPR1_HI, "fpr1.hi" },
1401 { PT_FPR1_LO, "fpr1.lo" },
1402 { PT_FPR2_HI, "fpr2.hi" },
1403 { PT_FPR2_LO, "fpr2.lo" },
1404 { PT_FPR3_HI, "fpr3.hi" },
1405 { PT_FPR3_LO, "fpr3.lo" },
1406 { PT_FPR4_HI, "fpr4.hi" },
1407 { PT_FPR4_LO, "fpr4.lo" },
1408 { PT_FPR5_HI, "fpr5.hi" },
1409 { PT_FPR5_LO, "fpr5.lo" },
1410 { PT_FPR6_HI, "fpr6.hi" },
1411 { PT_FPR6_LO, "fpr6.lo" },
1412 { PT_FPR7_HI, "fpr7.hi" },
1413 { PT_FPR7_LO, "fpr7.lo" },
1414 { PT_FPR8_HI, "fpr8.hi" },
1415 { PT_FPR8_LO, "fpr8.lo" },
1416 { PT_FPR9_HI, "fpr9.hi" },
1417 { PT_FPR9_LO, "fpr9.lo" },
1418 { PT_FPR10_HI, "fpr10.hi" },
1419 { PT_FPR10_LO, "fpr10.lo" },
1420 { PT_FPR11_HI, "fpr11.hi" },
1421 { PT_FPR11_LO, "fpr11.lo" },
1422 { PT_FPR12_HI, "fpr12.hi" },
1423 { PT_FPR12_LO, "fpr12.lo" },
1424 { PT_FPR13_HI, "fpr13.hi" },
1425 { PT_FPR13_LO, "fpr13.lo" },
1426 { PT_FPR14_HI, "fpr14.hi" },
1427 { PT_FPR14_LO, "fpr14.lo" },
1428 { PT_FPR15_HI, "fpr15.hi" },
1429 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001430#endif
1431#if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001432 { PT_FPR0, "fpr0" },
1433 { PT_FPR1, "fpr1" },
1434 { PT_FPR2, "fpr2" },
1435 { PT_FPR3, "fpr3" },
1436 { PT_FPR4, "fpr4" },
1437 { PT_FPR5, "fpr5" },
1438 { PT_FPR6, "fpr6" },
1439 { PT_FPR7, "fpr7" },
1440 { PT_FPR8, "fpr8" },
1441 { PT_FPR9, "fpr9" },
1442 { PT_FPR10, "fpr10" },
1443 { PT_FPR11, "fpr11" },
1444 { PT_FPR12, "fpr12" },
1445 { PT_FPR13, "fpr13" },
1446 { PT_FPR14, "fpr14" },
1447 { PT_FPR15, "fpr15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001448#endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001449 { PT_CR_9, "cr9" },
1450 { PT_CR_10, "cr10" },
1451 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001452 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001453#elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001454 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001455#elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001456 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001457#elif defined(POWERPC)
1458# ifndef PT_ORIG_R3
1459# define PT_ORIG_R3 34
1460# endif
1461# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001462 { REGSIZE*PT_R0, "r0" },
1463 { REGSIZE*PT_R1, "r1" },
1464 { REGSIZE*PT_R2, "r2" },
1465 { REGSIZE*PT_R3, "r3" },
1466 { REGSIZE*PT_R4, "r4" },
1467 { REGSIZE*PT_R5, "r5" },
1468 { REGSIZE*PT_R6, "r6" },
1469 { REGSIZE*PT_R7, "r7" },
1470 { REGSIZE*PT_R8, "r8" },
1471 { REGSIZE*PT_R9, "r9" },
1472 { REGSIZE*PT_R10, "r10" },
1473 { REGSIZE*PT_R11, "r11" },
1474 { REGSIZE*PT_R12, "r12" },
1475 { REGSIZE*PT_R13, "r13" },
1476 { REGSIZE*PT_R14, "r14" },
1477 { REGSIZE*PT_R15, "r15" },
1478 { REGSIZE*PT_R16, "r16" },
1479 { REGSIZE*PT_R17, "r17" },
1480 { REGSIZE*PT_R18, "r18" },
1481 { REGSIZE*PT_R19, "r19" },
1482 { REGSIZE*PT_R20, "r20" },
1483 { REGSIZE*PT_R21, "r21" },
1484 { REGSIZE*PT_R22, "r22" },
1485 { REGSIZE*PT_R23, "r23" },
1486 { REGSIZE*PT_R24, "r24" },
1487 { REGSIZE*PT_R25, "r25" },
1488 { REGSIZE*PT_R26, "r26" },
1489 { REGSIZE*PT_R27, "r27" },
1490 { REGSIZE*PT_R28, "r28" },
1491 { REGSIZE*PT_R29, "r29" },
1492 { REGSIZE*PT_R30, "r30" },
1493 { REGSIZE*PT_R31, "r31" },
1494 { REGSIZE*PT_NIP, "NIP" },
1495 { REGSIZE*PT_MSR, "MSR" },
1496 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1497 { REGSIZE*PT_CTR, "CTR" },
1498 { REGSIZE*PT_LNK, "LNK" },
1499 { REGSIZE*PT_XER, "XER" },
1500 { REGSIZE*PT_CCR, "CCR" },
1501 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001502# undef REGSIZE
1503#elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001504 { 0, "r0" },
1505 { 1, "r1" },
1506 { 2, "r2" },
1507 { 3, "r3" },
1508 { 4, "r4" },
1509 { 5, "r5" },
1510 { 6, "r6" },
1511 { 7, "r7" },
1512 { 8, "r8" },
1513 { 9, "r9" },
1514 { 10, "r10" },
1515 { 11, "r11" },
1516 { 12, "r12" },
1517 { 13, "r13" },
1518 { 14, "r14" },
1519 { 15, "r15" },
1520 { 16, "r16" },
1521 { 17, "r17" },
1522 { 18, "r18" },
1523 { 19, "r19" },
1524 { 20, "r20" },
1525 { 21, "r21" },
1526 { 22, "r22" },
1527 { 23, "r23" },
1528 { 24, "r24" },
1529 { 25, "r25" },
1530 { 26, "r26" },
1531 { 27, "r27" },
1532 { 28, "r28" },
1533 { 29, "gp" },
1534 { 30, "fp" },
1535 { 31, "zero" },
1536 { 32, "fp0" },
1537 { 33, "fp" },
1538 { 34, "fp2" },
1539 { 35, "fp3" },
1540 { 36, "fp4" },
1541 { 37, "fp5" },
1542 { 38, "fp6" },
1543 { 39, "fp7" },
1544 { 40, "fp8" },
1545 { 41, "fp9" },
1546 { 42, "fp10" },
1547 { 43, "fp11" },
1548 { 44, "fp12" },
1549 { 45, "fp13" },
1550 { 46, "fp14" },
1551 { 47, "fp15" },
1552 { 48, "fp16" },
1553 { 49, "fp17" },
1554 { 50, "fp18" },
1555 { 51, "fp19" },
1556 { 52, "fp20" },
1557 { 53, "fp21" },
1558 { 54, "fp22" },
1559 { 55, "fp23" },
1560 { 56, "fp24" },
1561 { 57, "fp25" },
1562 { 58, "fp26" },
1563 { 59, "fp27" },
1564 { 60, "fp28" },
1565 { 61, "fp29" },
1566 { 62, "fp30" },
1567 { 63, "fp31" },
1568 { 64, "pc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001569#elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001570 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1571 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1572 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1573 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1574 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1575 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1576 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1577 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1578 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1579 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1580 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1581 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1582 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1583 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1584 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1585 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1586 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1587 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1588 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1589 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1590 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1591 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1592 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1593 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1594 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1595 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1596 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1597 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1598 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1599 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1600 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1601 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1602 /* switch stack: */
1603 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1604 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1605 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1606 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1607 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1608 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1609 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1610 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1611 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1612 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001613 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1614 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001615 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001616 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001617 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1618 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001619 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1620 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1621 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1622 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1623 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1624 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1625 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1626 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1627 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1628 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1629 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1630 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1631 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1632 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1633 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001634# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001635 { PT_AR_CSD, "ar.csd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001636# endif
1637# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001638 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001639# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001640 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001641#elif defined(I386)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001642 { 4*EBX, "4*EBX" },
1643 { 4*ECX, "4*ECX" },
1644 { 4*EDX, "4*EDX" },
1645 { 4*ESI, "4*ESI" },
1646 { 4*EDI, "4*EDI" },
1647 { 4*EBP, "4*EBP" },
1648 { 4*EAX, "4*EAX" },
1649 { 4*DS, "4*DS" },
1650 { 4*ES, "4*ES" },
1651 { 4*FS, "4*FS" },
1652 { 4*GS, "4*GS" },
1653 { 4*ORIG_EAX, "4*ORIG_EAX" },
1654 { 4*EIP, "4*EIP" },
1655 { 4*CS, "4*CS" },
1656 { 4*EFL, "4*EFL" },
1657 { 4*UESP, "4*UESP" },
1658 { 4*SS, "4*SS" },
H.J. Lu35be5812012-04-16 13:00:01 +02001659#elif defined(X86_64) || defined(X32)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001660 { 8*R15, "8*R15" },
1661 { 8*R14, "8*R14" },
1662 { 8*R13, "8*R13" },
1663 { 8*R12, "8*R12" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001664 { 8*RBP, "8*RBP" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001665 { 8*RBX, "8*RBX" },
1666 { 8*R11, "8*R11" },
1667 { 8*R10, "8*R10" },
1668 { 8*R9, "8*R9" },
1669 { 8*R8, "8*R8" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001670 { 8*RAX, "8*RAX" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001671 { 8*RCX, "8*RCX" },
1672 { 8*RDX, "8*RDX" },
1673 { 8*RSI, "8*RSI" },
1674 { 8*RDI, "8*RDI" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001675 { 8*ORIG_RAX, "8*ORIG_RAX" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001676 { 8*RIP, "8*RIP" },
1677 { 8*CS, "8*CS" },
1678 { 8*EFLAGS, "8*EFL" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001679 { 8*RSP, "8*RSP" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001680 { 8*SS, "8*SS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001681#elif defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001682 { 4*PT_D1, "4*PT_D1" },
1683 { 4*PT_D2, "4*PT_D2" },
1684 { 4*PT_D3, "4*PT_D3" },
1685 { 4*PT_D4, "4*PT_D4" },
1686 { 4*PT_D5, "4*PT_D5" },
1687 { 4*PT_D6, "4*PT_D6" },
1688 { 4*PT_D7, "4*PT_D7" },
1689 { 4*PT_A0, "4*PT_A0" },
1690 { 4*PT_A1, "4*PT_A1" },
1691 { 4*PT_A2, "4*PT_A2" },
1692 { 4*PT_A3, "4*PT_A3" },
1693 { 4*PT_A4, "4*PT_A4" },
1694 { 4*PT_A5, "4*PT_A5" },
1695 { 4*PT_A6, "4*PT_A6" },
1696 { 4*PT_D0, "4*PT_D0" },
1697 { 4*PT_USP, "4*PT_USP" },
1698 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1699 { 4*PT_SR, "4*PT_SR" },
1700 { 4*PT_PC, "4*PT_PC" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001701#elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001702 { 4*REG_REG0, "4*REG_REG0" },
1703 { 4*(REG_REG0+1), "4*REG_REG1" },
1704 { 4*(REG_REG0+2), "4*REG_REG2" },
1705 { 4*(REG_REG0+3), "4*REG_REG3" },
1706 { 4*(REG_REG0+4), "4*REG_REG4" },
1707 { 4*(REG_REG0+5), "4*REG_REG5" },
1708 { 4*(REG_REG0+6), "4*REG_REG6" },
1709 { 4*(REG_REG0+7), "4*REG_REG7" },
1710 { 4*(REG_REG0+8), "4*REG_REG8" },
1711 { 4*(REG_REG0+9), "4*REG_REG9" },
1712 { 4*(REG_REG0+10), "4*REG_REG10" },
1713 { 4*(REG_REG0+11), "4*REG_REG11" },
1714 { 4*(REG_REG0+12), "4*REG_REG12" },
1715 { 4*(REG_REG0+13), "4*REG_REG13" },
1716 { 4*(REG_REG0+14), "4*REG_REG14" },
1717 { 4*REG_REG15, "4*REG_REG15" },
1718 { 4*REG_PC, "4*REG_PC" },
1719 { 4*REG_PR, "4*REG_PR" },
1720 { 4*REG_SR, "4*REG_SR" },
1721 { 4*REG_GBR, "4*REG_GBR" },
1722 { 4*REG_MACH, "4*REG_MACH" },
1723 { 4*REG_MACL, "4*REG_MACL" },
1724 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1725 { 4*REG_FPUL, "4*REG_FPUL" },
1726 { 4*REG_FPREG0, "4*REG_FPREG0" },
1727 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1728 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1729 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1730 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1731 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1732 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1733 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1734 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1735 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1736 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1737 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1738 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1739 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1740 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1741 { 4*REG_FPREG15, "4*REG_FPREG15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001742# ifdef REG_XDREG0
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001743 { 4*REG_XDREG0, "4*REG_XDREG0" },
1744 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1745 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1746 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1747 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1748 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1749 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1750 { 4*REG_XDREG14, "4*REG_XDREG14" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001751# endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001752 { 4*REG_FPSCR, "4*REG_FPSCR" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001753#elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001754 { 0, "PC(L)" },
1755 { 4, "PC(U)" },
1756 { 8, "SR(L)" },
1757 { 12, "SR(U)" },
1758 { 16, "syscall no.(L)" },
1759 { 20, "syscall_no.(U)" },
1760 { 24, "R0(L)" },
1761 { 28, "R0(U)" },
1762 { 32, "R1(L)" },
1763 { 36, "R1(U)" },
1764 { 40, "R2(L)" },
1765 { 44, "R2(U)" },
1766 { 48, "R3(L)" },
1767 { 52, "R3(U)" },
1768 { 56, "R4(L)" },
1769 { 60, "R4(U)" },
1770 { 64, "R5(L)" },
1771 { 68, "R5(U)" },
1772 { 72, "R6(L)" },
1773 { 76, "R6(U)" },
1774 { 80, "R7(L)" },
1775 { 84, "R7(U)" },
1776 { 88, "R8(L)" },
1777 { 92, "R8(U)" },
1778 { 96, "R9(L)" },
1779 { 100, "R9(U)" },
1780 { 104, "R10(L)" },
1781 { 108, "R10(U)" },
1782 { 112, "R11(L)" },
1783 { 116, "R11(U)" },
1784 { 120, "R12(L)" },
1785 { 124, "R12(U)" },
1786 { 128, "R13(L)" },
1787 { 132, "R13(U)" },
1788 { 136, "R14(L)" },
1789 { 140, "R14(U)" },
1790 { 144, "R15(L)" },
1791 { 148, "R15(U)" },
1792 { 152, "R16(L)" },
1793 { 156, "R16(U)" },
1794 { 160, "R17(L)" },
1795 { 164, "R17(U)" },
1796 { 168, "R18(L)" },
1797 { 172, "R18(U)" },
1798 { 176, "R19(L)" },
1799 { 180, "R19(U)" },
1800 { 184, "R20(L)" },
1801 { 188, "R20(U)" },
1802 { 192, "R21(L)" },
1803 { 196, "R21(U)" },
1804 { 200, "R22(L)" },
1805 { 204, "R22(U)" },
1806 { 208, "R23(L)" },
1807 { 212, "R23(U)" },
1808 { 216, "R24(L)" },
1809 { 220, "R24(U)" },
1810 { 224, "R25(L)" },
1811 { 228, "R25(U)" },
1812 { 232, "R26(L)" },
1813 { 236, "R26(U)" },
1814 { 240, "R27(L)" },
1815 { 244, "R27(U)" },
1816 { 248, "R28(L)" },
1817 { 252, "R28(U)" },
1818 { 256, "R29(L)" },
1819 { 260, "R29(U)" },
1820 { 264, "R30(L)" },
1821 { 268, "R30(U)" },
1822 { 272, "R31(L)" },
1823 { 276, "R31(U)" },
1824 { 280, "R32(L)" },
1825 { 284, "R32(U)" },
1826 { 288, "R33(L)" },
1827 { 292, "R33(U)" },
1828 { 296, "R34(L)" },
1829 { 300, "R34(U)" },
1830 { 304, "R35(L)" },
1831 { 308, "R35(U)" },
1832 { 312, "R36(L)" },
1833 { 316, "R36(U)" },
1834 { 320, "R37(L)" },
1835 { 324, "R37(U)" },
1836 { 328, "R38(L)" },
1837 { 332, "R38(U)" },
1838 { 336, "R39(L)" },
1839 { 340, "R39(U)" },
1840 { 344, "R40(L)" },
1841 { 348, "R40(U)" },
1842 { 352, "R41(L)" },
1843 { 356, "R41(U)" },
1844 { 360, "R42(L)" },
1845 { 364, "R42(U)" },
1846 { 368, "R43(L)" },
1847 { 372, "R43(U)" },
1848 { 376, "R44(L)" },
1849 { 380, "R44(U)" },
1850 { 384, "R45(L)" },
1851 { 388, "R45(U)" },
1852 { 392, "R46(L)" },
1853 { 396, "R46(U)" },
1854 { 400, "R47(L)" },
1855 { 404, "R47(U)" },
1856 { 408, "R48(L)" },
1857 { 412, "R48(U)" },
1858 { 416, "R49(L)" },
1859 { 420, "R49(U)" },
1860 { 424, "R50(L)" },
1861 { 428, "R50(U)" },
1862 { 432, "R51(L)" },
1863 { 436, "R51(U)" },
1864 { 440, "R52(L)" },
1865 { 444, "R52(U)" },
1866 { 448, "R53(L)" },
1867 { 452, "R53(U)" },
1868 { 456, "R54(L)" },
1869 { 460, "R54(U)" },
1870 { 464, "R55(L)" },
1871 { 468, "R55(U)" },
1872 { 472, "R56(L)" },
1873 { 476, "R56(U)" },
1874 { 480, "R57(L)" },
1875 { 484, "R57(U)" },
1876 { 488, "R58(L)" },
1877 { 492, "R58(U)" },
1878 { 496, "R59(L)" },
1879 { 500, "R59(U)" },
1880 { 504, "R60(L)" },
1881 { 508, "R60(U)" },
1882 { 512, "R61(L)" },
1883 { 516, "R61(U)" },
1884 { 520, "R62(L)" },
1885 { 524, "R62(U)" },
1886 { 528, "TR0(L)" },
1887 { 532, "TR0(U)" },
1888 { 536, "TR1(L)" },
1889 { 540, "TR1(U)" },
1890 { 544, "TR2(L)" },
1891 { 548, "TR2(U)" },
1892 { 552, "TR3(L)" },
1893 { 556, "TR3(U)" },
1894 { 560, "TR4(L)" },
1895 { 564, "TR4(U)" },
1896 { 568, "TR5(L)" },
1897 { 572, "TR5(U)" },
1898 { 576, "TR6(L)" },
1899 { 580, "TR6(U)" },
1900 { 584, "TR7(L)" },
1901 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00001902 /* This entry is in case pt_regs contains dregs (depends on
1903 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001904 { uoff(regs), "offsetof(struct user, regs)" },
1905 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001906#elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00001907 { uoff(regs.ARM_r0), "r0" },
1908 { uoff(regs.ARM_r1), "r1" },
1909 { uoff(regs.ARM_r2), "r2" },
1910 { uoff(regs.ARM_r3), "r3" },
1911 { uoff(regs.ARM_r4), "r4" },
1912 { uoff(regs.ARM_r5), "r5" },
1913 { uoff(regs.ARM_r6), "r6" },
1914 { uoff(regs.ARM_r7), "r7" },
1915 { uoff(regs.ARM_r8), "r8" },
1916 { uoff(regs.ARM_r9), "r9" },
1917 { uoff(regs.ARM_r10), "r10" },
1918 { uoff(regs.ARM_fp), "fp" },
1919 { uoff(regs.ARM_ip), "ip" },
1920 { uoff(regs.ARM_sp), "sp" },
1921 { uoff(regs.ARM_lr), "lr" },
1922 { uoff(regs.ARM_pc), "pc" },
1923 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001924#elif defined(AVR32)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001925 { uoff(regs.sr), "sr" },
1926 { uoff(regs.pc), "pc" },
1927 { uoff(regs.lr), "lr" },
1928 { uoff(regs.sp), "sp" },
1929 { uoff(regs.r12), "r12" },
1930 { uoff(regs.r11), "r11" },
1931 { uoff(regs.r10), "r10" },
1932 { uoff(regs.r9), "r9" },
1933 { uoff(regs.r8), "r8" },
1934 { uoff(regs.r7), "r7" },
1935 { uoff(regs.r6), "r6" },
1936 { uoff(regs.r5), "r5" },
1937 { uoff(regs.r4), "r4" },
1938 { uoff(regs.r3), "r3" },
1939 { uoff(regs.r2), "r2" },
1940 { uoff(regs.r1), "r1" },
1941 { uoff(regs.r0), "r0" },
1942 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001943#elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00001944 { 0, "r0" },
1945 { 1, "r1" },
1946 { 2, "r2" },
1947 { 3, "r3" },
1948 { 4, "r4" },
1949 { 5, "r5" },
1950 { 6, "r6" },
1951 { 7, "r7" },
1952 { 8, "r8" },
1953 { 9, "r9" },
1954 { 10, "r10" },
1955 { 11, "r11" },
1956 { 12, "r12" },
1957 { 13, "r13" },
1958 { 14, "r14" },
1959 { 15, "r15" },
1960 { 16, "r16" },
1961 { 17, "r17" },
1962 { 18, "r18" },
1963 { 19, "r19" },
1964 { 20, "r20" },
1965 { 21, "r21" },
1966 { 22, "r22" },
1967 { 23, "r23" },
1968 { 24, "r24" },
1969 { 25, "r25" },
1970 { 26, "r26" },
1971 { 27, "r27" },
1972 { 28, "r28" },
1973 { 29, "r29" },
1974 { 30, "r30" },
1975 { 31, "r31" },
1976 { 32, "f0" },
1977 { 33, "f1" },
1978 { 34, "f2" },
1979 { 35, "f3" },
1980 { 36, "f4" },
1981 { 37, "f5" },
1982 { 38, "f6" },
1983 { 39, "f7" },
1984 { 40, "f8" },
1985 { 41, "f9" },
1986 { 42, "f10" },
1987 { 43, "f11" },
1988 { 44, "f12" },
1989 { 45, "f13" },
1990 { 46, "f14" },
1991 { 47, "f15" },
1992 { 48, "f16" },
1993 { 49, "f17" },
1994 { 50, "f18" },
1995 { 51, "f19" },
1996 { 52, "f20" },
1997 { 53, "f21" },
1998 { 54, "f22" },
1999 { 55, "f23" },
2000 { 56, "f24" },
2001 { 57, "f25" },
2002 { 58, "f26" },
2003 { 59, "f27" },
2004 { 60, "f28" },
2005 { 61, "f29" },
2006 { 62, "f30" },
2007 { 63, "f31" },
2008 { 64, "pc" },
2009 { 65, "cause" },
2010 { 66, "badvaddr" },
2011 { 67, "mmhi" },
2012 { 68, "mmlo" },
2013 { 69, "fpcsr" },
2014 { 70, "fpeir" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002015#elif defined(TILE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05002016 { PTREGS_OFFSET_REG(0), "r0" },
2017 { PTREGS_OFFSET_REG(1), "r1" },
2018 { PTREGS_OFFSET_REG(2), "r2" },
2019 { PTREGS_OFFSET_REG(3), "r3" },
2020 { PTREGS_OFFSET_REG(4), "r4" },
2021 { PTREGS_OFFSET_REG(5), "r5" },
2022 { PTREGS_OFFSET_REG(6), "r6" },
2023 { PTREGS_OFFSET_REG(7), "r7" },
2024 { PTREGS_OFFSET_REG(8), "r8" },
2025 { PTREGS_OFFSET_REG(9), "r9" },
2026 { PTREGS_OFFSET_REG(10), "r10" },
2027 { PTREGS_OFFSET_REG(11), "r11" },
2028 { PTREGS_OFFSET_REG(12), "r12" },
2029 { PTREGS_OFFSET_REG(13), "r13" },
2030 { PTREGS_OFFSET_REG(14), "r14" },
2031 { PTREGS_OFFSET_REG(15), "r15" },
2032 { PTREGS_OFFSET_REG(16), "r16" },
2033 { PTREGS_OFFSET_REG(17), "r17" },
2034 { PTREGS_OFFSET_REG(18), "r18" },
2035 { PTREGS_OFFSET_REG(19), "r19" },
2036 { PTREGS_OFFSET_REG(20), "r20" },
2037 { PTREGS_OFFSET_REG(21), "r21" },
2038 { PTREGS_OFFSET_REG(22), "r22" },
2039 { PTREGS_OFFSET_REG(23), "r23" },
2040 { PTREGS_OFFSET_REG(24), "r24" },
2041 { PTREGS_OFFSET_REG(25), "r25" },
2042 { PTREGS_OFFSET_REG(26), "r26" },
2043 { PTREGS_OFFSET_REG(27), "r27" },
2044 { PTREGS_OFFSET_REG(28), "r28" },
2045 { PTREGS_OFFSET_REG(29), "r29" },
2046 { PTREGS_OFFSET_REG(30), "r30" },
2047 { PTREGS_OFFSET_REG(31), "r31" },
2048 { PTREGS_OFFSET_REG(32), "r32" },
2049 { PTREGS_OFFSET_REG(33), "r33" },
2050 { PTREGS_OFFSET_REG(34), "r34" },
2051 { PTREGS_OFFSET_REG(35), "r35" },
2052 { PTREGS_OFFSET_REG(36), "r36" },
2053 { PTREGS_OFFSET_REG(37), "r37" },
2054 { PTREGS_OFFSET_REG(38), "r38" },
2055 { PTREGS_OFFSET_REG(39), "r39" },
2056 { PTREGS_OFFSET_REG(40), "r40" },
2057 { PTREGS_OFFSET_REG(41), "r41" },
2058 { PTREGS_OFFSET_REG(42), "r42" },
2059 { PTREGS_OFFSET_REG(43), "r43" },
2060 { PTREGS_OFFSET_REG(44), "r44" },
2061 { PTREGS_OFFSET_REG(45), "r45" },
2062 { PTREGS_OFFSET_REG(46), "r46" },
2063 { PTREGS_OFFSET_REG(47), "r47" },
2064 { PTREGS_OFFSET_REG(48), "r48" },
2065 { PTREGS_OFFSET_REG(49), "r49" },
2066 { PTREGS_OFFSET_REG(50), "r50" },
2067 { PTREGS_OFFSET_REG(51), "r51" },
2068 { PTREGS_OFFSET_REG(52), "r52" },
2069 { PTREGS_OFFSET_TP, "tp" },
2070 { PTREGS_OFFSET_SP, "sp" },
2071 { PTREGS_OFFSET_LR, "lr" },
2072 { PTREGS_OFFSET_PC, "pc" },
2073 { PTREGS_OFFSET_EX1, "ex1" },
2074 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2075 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2076 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002077#endif
2078#ifdef CRISV10
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002079 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2080 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2081 { 4*PT_R13, "4*PT_R13" },
2082 { 4*PT_R12, "4*PT_R12" },
2083 { 4*PT_R11, "4*PT_R11" },
2084 { 4*PT_R10, "4*PT_R10" },
2085 { 4*PT_R9, "4*PT_R9" },
2086 { 4*PT_R8, "4*PT_R8" },
2087 { 4*PT_R7, "4*PT_R7" },
2088 { 4*PT_R6, "4*PT_R6" },
2089 { 4*PT_R5, "4*PT_R5" },
2090 { 4*PT_R4, "4*PT_R4" },
2091 { 4*PT_R3, "4*PT_R3" },
2092 { 4*PT_R2, "4*PT_R2" },
2093 { 4*PT_R1, "4*PT_R1" },
2094 { 4*PT_R0, "4*PT_R0" },
2095 { 4*PT_MOF, "4*PT_MOF" },
2096 { 4*PT_DCCR, "4*PT_DCCR" },
2097 { 4*PT_SRP, "4*PT_SRP" },
2098 { 4*PT_IRP, "4*PT_IRP" },
2099 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2100 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2101 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2102 { 4*PT_USP, "4*PT_USP" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002103#endif
2104#ifdef CRISV32
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002105 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2106 { 4*PT_R0, "4*PT_R0" },
2107 { 4*PT_R1, "4*PT_R1" },
2108 { 4*PT_R2, "4*PT_R2" },
2109 { 4*PT_R3, "4*PT_R3" },
2110 { 4*PT_R4, "4*PT_R4" },
2111 { 4*PT_R5, "4*PT_R5" },
2112 { 4*PT_R6, "4*PT_R6" },
2113 { 4*PT_R7, "4*PT_R7" },
2114 { 4*PT_R8, "4*PT_R8" },
2115 { 4*PT_R9, "4*PT_R9" },
2116 { 4*PT_R10, "4*PT_R10" },
2117 { 4*PT_R11, "4*PT_R11" },
2118 { 4*PT_R12, "4*PT_R12" },
2119 { 4*PT_R13, "4*PT_R13" },
2120 { 4*PT_ACR, "4*PT_ACR" },
2121 { 4*PT_SRS, "4*PT_SRS" },
2122 { 4*PT_MOF, "4*PT_MOF" },
2123 { 4*PT_SPC, "4*PT_SPC" },
2124 { 4*PT_CCS, "4*PT_CCS" },
2125 { 4*PT_SRP, "4*PT_SRP" },
2126 { 4*PT_ERP, "4*PT_ERP" },
2127 { 4*PT_EXS, "4*PT_EXS" },
2128 { 4*PT_EDA, "4*PT_EDA" },
2129 { 4*PT_USP, "4*PT_USP" },
2130 { 4*PT_PPC, "4*PT_PPC" },
2131 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2132 { 4*PT_BP+4, "4*PT_BP+4" },
2133 { 4*PT_BP+8, "4*PT_BP+8" },
2134 { 4*PT_BP+12, "4*PT_BP+12" },
2135 { 4*PT_BP+16, "4*PT_BP+16" },
2136 { 4*PT_BP+20, "4*PT_BP+20" },
2137 { 4*PT_BP+24, "4*PT_BP+24" },
2138 { 4*PT_BP+28, "4*PT_BP+28" },
2139 { 4*PT_BP+32, "4*PT_BP+32" },
2140 { 4*PT_BP+36, "4*PT_BP+36" },
2141 { 4*PT_BP+40, "4*PT_BP+40" },
2142 { 4*PT_BP+44, "4*PT_BP+44" },
2143 { 4*PT_BP+48, "4*PT_BP+48" },
2144 { 4*PT_BP+52, "4*PT_BP+52" },
2145 { 4*PT_BP+56, "4*PT_BP+56" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002146#endif
2147#ifdef MICROBLAZE
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002148 { PT_GPR(0), "r0" },
2149 { PT_GPR(1), "r1" },
2150 { PT_GPR(2), "r2" },
2151 { PT_GPR(3), "r3" },
2152 { PT_GPR(4), "r4" },
2153 { PT_GPR(5), "r5" },
2154 { PT_GPR(6), "r6" },
2155 { PT_GPR(7), "r7" },
2156 { PT_GPR(8), "r8" },
2157 { PT_GPR(9), "r9" },
2158 { PT_GPR(10), "r10" },
2159 { PT_GPR(11), "r11" },
2160 { PT_GPR(12), "r12" },
2161 { PT_GPR(13), "r13" },
2162 { PT_GPR(14), "r14" },
2163 { PT_GPR(15), "r15" },
2164 { PT_GPR(16), "r16" },
2165 { PT_GPR(17), "r17" },
2166 { PT_GPR(18), "r18" },
2167 { PT_GPR(19), "r19" },
2168 { PT_GPR(20), "r20" },
2169 { PT_GPR(21), "r21" },
2170 { PT_GPR(22), "r22" },
2171 { PT_GPR(23), "r23" },
2172 { PT_GPR(24), "r24" },
2173 { PT_GPR(25), "r25" },
2174 { PT_GPR(26), "r26" },
2175 { PT_GPR(27), "r27" },
2176 { PT_GPR(28), "r28" },
2177 { PT_GPR(29), "r29" },
2178 { PT_GPR(30), "r30" },
2179 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002180 { PT_PC, "rpc", },
2181 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002182 { PT_EAR, "rear", },
2183 { PT_ESR, "resr", },
2184 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002185 { PT_KERNEL_MODE, "kernel_mode", },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002186#endif
Christian Svensson492f81f2013-02-14 13:26:27 +01002187#ifdef OR1K
2188 { 4*0, "r0" },
2189 { 4*1, "r1" },
2190 { 4*2, "r2" },
2191 { 4*3, "r3" },
2192 { 4*4, "r4" },
2193 { 4*5, "r5" },
2194 { 4*6, "r6" },
2195 { 4*7, "r7" },
2196 { 4*8, "r8" },
2197 { 4*9, "r9" },
2198 { 4*10, "r10" },
2199 { 4*11, "r11" },
2200 { 4*12, "r12" },
2201 { 4*13, "r13" },
2202 { 4*14, "r14" },
2203 { 4*15, "r15" },
2204 { 4*16, "r16" },
2205 { 4*17, "r17" },
2206 { 4*18, "r18" },
2207 { 4*19, "r19" },
2208 { 4*20, "r20" },
2209 { 4*21, "r21" },
2210 { 4*22, "r22" },
2211 { 4*23, "r23" },
2212 { 4*24, "r24" },
2213 { 4*25, "r25" },
2214 { 4*26, "r26" },
2215 { 4*27, "r27" },
2216 { 4*28, "r28" },
2217 { 4*29, "r29" },
2218 { 4*30, "r30" },
2219 { 4*31, "r31" },
2220 { 4*32, "pc" },
2221 { 4*33, "sr" },
2222#endif
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002223 /* Other fields in "struct user" */
2224#if defined(S390) || defined(S390X)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002225 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2226 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2227 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002228 { uoff(start_code), "offsetof(struct user, start_code)" },
2229 /* S390[X] has no start_data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002230 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2231 { uoff(signal), "offsetof(struct user, signal)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002232 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002233 { uoff(magic), "offsetof(struct user, magic)" },
2234 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002235 { sizeof(struct user), "sizeof(struct user)" },
2236#elif defined(POWERPC)
2237 { sizeof(struct user), "sizeof(struct user)" },
2238#elif defined(I386) || defined(X86_64) || defined(X32)
2239 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2240 { uoff(i387), "offsetof(struct user, i387)" },
2241 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2242 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2243 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2244 { uoff(start_code), "offsetof(struct user, start_code)" },
2245 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2246 { uoff(signal), "offsetof(struct user, signal)" },
2247 { uoff(reserved), "offsetof(struct user, reserved)" },
2248 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2249 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2250 { uoff(magic), "offsetof(struct user, magic)" },
2251 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002252 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002253 { sizeof(struct user), "sizeof(struct user)" },
2254#elif defined(IA64)
2255 { sizeof(struct user), "sizeof(struct user)" },
2256#elif defined(ARM)
2257 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2258 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2259 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2260 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2261 { uoff(start_code), "offsetof(struct user, start_code)" },
2262 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2263 { uoff(signal), "offsetof(struct user, signal)" },
2264 { uoff(reserved), "offsetof(struct user, reserved)" },
2265 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2266 { uoff(magic), "offsetof(struct user, magic)" },
2267 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2268 { sizeof(struct user), "sizeof(struct user)" },
2269#elif defined(AARCH64)
2270 /* nothing */
2271#elif defined(M68K)
2272 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2273 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2274 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2275 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2276 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2277 { uoff(start_code), "offsetof(struct user, start_code)" },
2278 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2279 { uoff(signal), "offsetof(struct user, signal)" },
2280 { uoff(reserved), "offsetof(struct user, reserved)" },
2281 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2282 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2283 { uoff(magic), "offsetof(struct user, magic)" },
2284 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2285 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002286#elif defined(MIPS) || defined(LINUX_MIPSN32)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002287 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2288 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2289 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2290 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002291 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002292 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2293 { uoff(signal), "offsetof(struct user, signal)" },
2294 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2295 { uoff(magic), "offsetof(struct user, magic)" },
2296 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2297 { sizeof(struct user), "sizeof(struct user)" },
2298#elif defined(ALPHA)
2299 { sizeof(struct user), "sizeof(struct user)" },
2300#elif defined(SPARC)
2301 { sizeof(struct user), "sizeof(struct user)" },
2302#elif defined(SPARC64)
2303 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2304 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2305 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2306 { uoff(signal), "offsetof(struct user, signal)" },
2307 { uoff(magic), "offsetof(struct user, magic)" },
2308 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2309 { sizeof(struct user), "sizeof(struct user)" },
2310#elif defined(HPPA)
2311 /* nothing */
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002312#elif defined(SH) || defined(SH64)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002313 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2314 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2315 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2316 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2317 { uoff(start_code), "offsetof(struct user, start_code)" },
2318 { uoff(start_data), "offsetof(struct user, start_data)" },
2319 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2320 { uoff(signal), "offsetof(struct user, signal)" },
2321 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2322 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2323 { uoff(magic), "offsetof(struct user, magic)" },
2324 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2325 { sizeof(struct user), "sizeof(struct user)" },
2326#elif defined(CRISV10) || defined(CRISV32)
2327 { sizeof(struct user), "sizeof(struct user)" },
2328#elif defined(TILE)
2329 /* nothing */
2330#elif defined(MICROBLAZE)
2331 { sizeof(struct user), "sizeof(struct user)" },
2332#elif defined(AVR32)
2333 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2334 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2335 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2336 { uoff(start_code), "offsetof(struct user, start_code)" },
2337 { uoff(start_data), "offsetof(struct user, start_data)" },
2338 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2339 { uoff(signal), "offsetof(struct user, signal)" },
2340 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2341 { uoff(magic), "offsetof(struct user, magic)" },
2342 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2343 { sizeof(struct user), "sizeof(struct user)" },
2344#elif defined(BFIN)
2345 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2346 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2347 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2348 { uoff(start_code), "offsetof(struct user, start_code)" },
2349 { uoff(signal), "offsetof(struct user, signal)" },
2350 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2351 { uoff(magic), "offsetof(struct user, magic)" },
2352 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002353 { sizeof(struct user), "sizeof(struct user)" },
Christian Svensson492f81f2013-02-14 13:26:27 +01002354#elif defined(OR1K)
2355 /* nothing */
James Hogan5f999a82013-02-22 14:44:10 +00002356#elif defined(METAG)
2357 /* nothing */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002358#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002359 { 0, NULL },
2360};
2361
2362int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002363sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002364{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002365 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002366 long addr;
2367
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002368 if (entering(tcp)) {
Denys Vlasenkob7a6dae2012-03-20 16:48:35 +01002369 printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
Roland McGrathbf621d42003-01-14 09:46:21 +00002370 tprintf(", %lu, ", tcp->u_arg[1]);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002371
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002372 addr = tcp->u_arg[2];
2373 if (tcp->u_arg[0] == PTRACE_PEEKUSER
Denys Vlasenkobe994972013-02-13 16:10:10 +01002374 || tcp->u_arg[0] == PTRACE_POKEUSER
2375 ) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002376 for (x = struct_user_offsets; x->str; x++) {
2377 if (x->val >= addr)
2378 break;
2379 }
2380 if (!x->str)
2381 tprintf("%#lx, ", addr);
2382 else if (x->val > addr && x != struct_user_offsets) {
2383 x--;
2384 tprintf("%s + %ld, ", x->str, addr - x->val);
2385 }
2386 else
2387 tprintf("%s, ", x->str);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002388 } else
2389#ifdef PTRACE_GETREGSET
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00002390 if (tcp->u_arg[0] == PTRACE_GETREGSET
2391 || tcp->u_arg[0] == PTRACE_SETREGSET
2392 ) {
2393 printxval(nt_descriptor_types, tcp->u_arg[2], "NT_???");
2394 tprints(", ");
2395 } else
Denys Vlasenkobe994972013-02-13 16:10:10 +01002396#endif
2397 tprintf("%#lx, ", addr);
2398
2399
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002400 switch (tcp->u_arg[0]) {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002401#ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002402 case PTRACE_PEEKDATA:
2403 case PTRACE_PEEKTEXT:
2404 case PTRACE_PEEKUSER:
2405 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002406#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002407 case PTRACE_CONT:
2408 case PTRACE_SINGLESTEP:
2409 case PTRACE_SYSCALL:
2410 case PTRACE_DETACH:
2411 printsignal(tcp->u_arg[3]);
2412 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002413#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002414 case PTRACE_SETOPTIONS:
2415 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2416 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002417#endif
2418#ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002419 case PTRACE_SETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002420 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002421 break;
2422 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002423#endif
2424#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002425 case PTRACE_GETSIGINFO:
2426 /* Don't print anything, do it at syscall return. */
2427 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002428#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002429#ifdef PTRACE_GETREGSET
2430 case PTRACE_GETREGSET:
2431 break;
2432 case PTRACE_SETREGSET:
2433 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2434 break;
2435#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002436 default:
2437 tprintf("%#lx", tcp->u_arg[3]);
2438 break;
2439 }
2440 } else {
2441 switch (tcp->u_arg[0]) {
2442 case PTRACE_PEEKDATA:
2443 case PTRACE_PEEKTEXT:
2444 case PTRACE_PEEKUSER:
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002445#ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002446 return RVAL_HEX;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002447#else
Roland McGratheb285352003-01-14 09:59:00 +00002448 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002449 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002450#endif
2451#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002452 case PTRACE_GETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002453 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002454 break;
2455 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002456#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002457#ifdef PTRACE_GETREGSET
2458 case PTRACE_GETREGSET:
2459 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2460 break;
2461#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002462 }
2463 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002464 return 0;
2465}
2466
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002467#ifndef FUTEX_CMP_REQUEUE
2468# define FUTEX_CMP_REQUEUE 4
2469#endif
2470#ifndef FUTEX_WAKE_OP
2471# define FUTEX_WAKE_OP 5
2472#endif
2473#ifndef FUTEX_LOCK_PI
2474# define FUTEX_LOCK_PI 6
2475# define FUTEX_UNLOCK_PI 7
2476# define FUTEX_TRYLOCK_PI 8
2477#endif
2478#ifndef FUTEX_WAIT_BITSET
2479# define FUTEX_WAIT_BITSET 9
2480#endif
2481#ifndef FUTEX_WAKE_BITSET
2482# define FUTEX_WAKE_BITSET 10
2483#endif
2484#ifndef FUTEX_WAIT_REQUEUE_PI
2485# define FUTEX_WAIT_REQUEUE_PI 11
2486#endif
2487#ifndef FUTEX_CMP_REQUEUE_PI
2488# define FUTEX_CMP_REQUEUE_PI 12
2489#endif
2490#ifndef FUTEX_PRIVATE_FLAG
2491# define FUTEX_PRIVATE_FLAG 128
2492#endif
2493#ifndef FUTEX_CLOCK_REALTIME
2494# define FUTEX_CLOCK_REALTIME 256
2495#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002496static const struct xlat futexops[] = {
Roland McGrath51942a92007-07-05 18:59:11 +00002497 { FUTEX_WAIT, "FUTEX_WAIT" },
2498 { FUTEX_WAKE, "FUTEX_WAKE" },
2499 { FUTEX_FD, "FUTEX_FD" },
2500 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2501 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2502 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2503 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2504 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2505 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002506 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2507 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002508 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2509 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
Roland McGrath51942a92007-07-05 18:59:11 +00002510 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2511 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2512 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2513 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2514 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2515 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2516 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2517 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2518 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002519 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2520 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002521 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2522 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2523 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2524 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2525 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2526 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI_PRIVATE|FUTEX_CLOCK_REALTIME" },
Roland McGrath51942a92007-07-05 18:59:11 +00002527 { 0, NULL }
2528};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002529#ifndef FUTEX_OP_SET
2530# define FUTEX_OP_SET 0
2531# define FUTEX_OP_ADD 1
2532# define FUTEX_OP_OR 2
2533# define FUTEX_OP_ANDN 3
2534# define FUTEX_OP_XOR 4
2535# define FUTEX_OP_CMP_EQ 0
2536# define FUTEX_OP_CMP_NE 1
2537# define FUTEX_OP_CMP_LT 2
2538# define FUTEX_OP_CMP_LE 3
2539# define FUTEX_OP_CMP_GT 4
2540# define FUTEX_OP_CMP_GE 5
2541#endif
Roland McGrath51942a92007-07-05 18:59:11 +00002542static const struct xlat futexwakeops[] = {
2543 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2544 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2545 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2546 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2547 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2548 { 0, NULL }
2549};
2550static const struct xlat futexwakecmps[] = {
2551 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2552 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2553 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2554 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2555 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2556 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2557 { 0, NULL }
Roland McGrath5a223472002-12-15 23:58:26 +00002558};
2559
2560int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002561sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002562{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002563 if (entering(tcp)) {
2564 long int cmd = tcp->u_arg[1] & 127;
2565 tprintf("%p, ", (void *) tcp->u_arg[0]);
2566 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2567 tprintf(", %ld", tcp->u_arg[2]);
2568 if (cmd == FUTEX_WAKE_BITSET)
2569 tprintf(", %lx", tcp->u_arg[5]);
2570 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002571 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002572 printtv(tcp, tcp->u_arg[3]);
2573 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002574 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002575 printtv(tcp, tcp->u_arg[3]);
2576 tprintf(", %lx", tcp->u_arg[5]);
2577 } else if (cmd == FUTEX_REQUEUE)
2578 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002579 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002580 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2581 else if (cmd == FUTEX_WAKE_OP) {
2582 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2583 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002584 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002585 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2586 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2587 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002588 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002589 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2590 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002591 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002592 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002593 printtv(tcp, tcp->u_arg[3]);
2594 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002595 }
Roland McGrath51942a92007-07-05 18:59:11 +00002596 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002597 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002598}
2599
2600static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002601print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002602{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002603 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002604 unsigned long w, min_len;
2605
2606 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2607 min_len = len - max_strlen * sizeof(w);
2608 else
2609 min_len = 0;
2610 for (; len >= sizeof(w) && len > min_len;
2611 len -= sizeof(w), list += sizeof(w)) {
2612 if (umove(tcp, list, &w) < 0)
2613 break;
2614 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002615 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002616 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002617 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002618 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002619 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002620 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002621 if (len) {
2622 if (first)
2623 tprintf("%#lx", list);
2624 else
2625 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2626 "???" : "..."));
2627 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002628 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002629 }
Roland McGrath5a223472002-12-15 23:58:26 +00002630}
2631
2632int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002633sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002634{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002635 if (entering(tcp)) {
2636 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2637 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2638 }
2639 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002640}
2641
2642int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002643sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002644{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002645 if (entering(tcp)) {
2646 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2647 } else {
2648 if (tcp->u_rval == -1)
2649 tprintf("%#lx", tcp->u_arg[2]);
2650 else
2651 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2652 }
2653 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002654}
Roland McGrath279d3782004-03-01 20:27:37 +00002655
Dmitry V. Levin1b0bae22012-03-11 22:32:26 +00002656int
2657sys_get_robust_list(struct tcb *tcp)
2658{
2659 if (entering(tcp)) {
2660 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2661 } else {
2662 void *addr;
2663 size_t len;
2664
2665 if (syserror(tcp) ||
2666 !tcp->u_arg[1] ||
2667 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2668 tprintf("%#lx, ", tcp->u_arg[1]);
2669 } else {
2670 tprintf("[%p], ", addr);
2671 }
2672
2673 if (syserror(tcp) ||
2674 !tcp->u_arg[2] ||
2675 umove(tcp, tcp->u_arg[2], &len) < 0) {
2676 tprintf("%#lx", tcp->u_arg[2]);
2677 } else {
2678 tprintf("[%lu]", (unsigned long) len);
2679 }
2680 }
2681 return 0;
2682}
2683
Roland McGrathd9f816f2004-09-04 03:39:20 +00002684static const struct xlat schedulers[] = {
Roland McGrath279d3782004-03-01 20:27:37 +00002685 { SCHED_OTHER, "SCHED_OTHER" },
2686 { SCHED_RR, "SCHED_RR" },
2687 { SCHED_FIFO, "SCHED_FIFO" },
2688 { 0, NULL }
2689};
2690
2691int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002692sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002693{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002694 if (entering(tcp)) {
2695 tprintf("%d", (int) tcp->u_arg[0]);
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002696 } else if (!syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002697 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002698 if (tcp->auxstr != NULL)
2699 return RVAL_STR;
2700 }
2701 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002702}
2703
2704int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002705sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002706{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002707 if (entering(tcp)) {
2708 struct sched_param p;
2709 tprintf("%d, ", (int) tcp->u_arg[0]);
2710 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2711 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2712 tprintf(", %#lx", tcp->u_arg[2]);
2713 else
2714 tprintf(", { %d }", p.__sched_priority);
2715 }
2716 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002717}
2718
2719int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002720sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002721{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002722 if (entering(tcp)) {
2723 tprintf("%d, ", (int) tcp->u_arg[0]);
2724 } else {
2725 struct sched_param p;
2726 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2727 tprintf("%#lx", tcp->u_arg[1]);
2728 else
2729 tprintf("{ %d }", p.__sched_priority);
2730 }
2731 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002732}
2733
2734int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002735sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002736{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002737 if (entering(tcp)) {
2738 struct sched_param p;
2739 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2740 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2741 else
2742 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2743 }
2744 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002745}
2746
2747int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002748sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002749{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002750 if (entering(tcp)) {
2751 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2752 }
2753 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002754}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002755
Dmitry V. Levin1ff463d2012-03-11 23:00:11 +00002756int
2757sys_sched_rr_get_interval(struct tcb *tcp)
2758{
2759 if (entering(tcp)) {
2760 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2761 } else {
2762 if (syserror(tcp))
2763 tprintf("%#lx", tcp->u_arg[1]);
2764 else
2765 print_timespec(tcp, tcp->u_arg[1]);
2766 }
2767 return 0;
2768}
2769
H.J. Lu35be5812012-04-16 13:00:01 +02002770#if defined X86_64 || defined X32
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002771# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002772
2773static const struct xlat archvals[] = {
2774 { ARCH_SET_GS, "ARCH_SET_GS" },
2775 { ARCH_SET_FS, "ARCH_SET_FS" },
2776 { ARCH_GET_FS, "ARCH_GET_FS" },
2777 { ARCH_GET_GS, "ARCH_GET_GS" },
2778 { 0, NULL },
2779};
2780
2781int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002782sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002783{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002784 if (entering(tcp)) {
2785 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2786 if (tcp->u_arg[0] == ARCH_SET_GS
2787 || tcp->u_arg[0] == ARCH_SET_FS
2788 ) {
2789 tprintf(", %#lx", tcp->u_arg[1]);
2790 }
2791 } else {
2792 if (tcp->u_arg[0] == ARCH_GET_GS
2793 || tcp->u_arg[0] == ARCH_GET_FS
2794 ) {
2795 long int v;
2796 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2797 tprintf(", [%#lx]", v);
2798 else
2799 tprintf(", %#lx", tcp->u_arg[1]);
2800 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002801 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002802 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002803}
H.J. Lu35be5812012-04-16 13:00:01 +02002804#endif /* X86_64 || X32 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002805
Roland McGrathdb8319f2007-08-02 01:37:55 +00002806int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002807sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002808{
2809 if (exiting(tcp)) {
2810 unsigned u;
2811 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002812 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002813 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2814 tprintf("%#lx, ", tcp->u_arg[0]);
2815 else
2816 tprintf("[%u], ", u);
2817 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002818 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002819 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2820 tprintf("%#lx, ", tcp->u_arg[1]);
2821 else
2822 tprintf("[%u], ", u);
2823 tprintf("%#lx", tcp->u_arg[2]);
2824 }
2825 return 0;
2826}
2827
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002828int
2829sys_process_vm_readv(struct tcb *tcp)
2830{
2831 if (entering(tcp)) {
2832 /* arg 1: pid */
2833 tprintf("%ld, ", tcp->u_arg[0]);
2834 } else {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002835 /* arg 2: local iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002836 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002837 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002838 } else {
2839 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2840 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002841 /* arg 3: local iovcnt */
2842 tprintf(", %lu, ", tcp->u_arg[2]);
2843 /* arg 4: remote iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002844 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002845 tprintf("%#lx", tcp->u_arg[3]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002846 } else {
2847 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2848 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002849 /* arg 5: remote iovcnt */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002850 /* arg 6: flags */
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002851 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002852 }
2853 return 0;
2854}
Dmitry V. Levin03952102012-03-10 14:14:49 +00002855
2856int
2857sys_process_vm_writev(struct tcb *tcp)
2858{
2859 if (entering(tcp)) {
2860 /* arg 1: pid */
2861 tprintf("%ld, ", tcp->u_arg[0]);
2862 /* arg 2: local iov */
2863 if (syserror(tcp))
2864 tprintf("%#lx", tcp->u_arg[1]);
2865 else
2866 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2867 /* arg 3: local iovcnt */
2868 tprintf(", %lu, ", tcp->u_arg[2]);
2869 /* arg 4: remote iov */
2870 if (syserror(tcp))
2871 tprintf("%#lx", tcp->u_arg[3]);
2872 else
2873 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2874 /* arg 5: remote iovcnt */
2875 /* arg 6: flags */
2876 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
2877 }
2878 return 0;
2879}