blob: a1f963e633397900297f603468d2865445e5ac49 [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>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000044
Wichert Akkerman36915a11999-07-13 15:45:02 +000045#ifdef HAVE_SYS_REG_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000046# include <sys/reg.h>
Denys Vlasenko84703742012-02-25 02:38:52 +010047# ifndef PTRACE_PEEKUSR
48# define PTRACE_PEEKUSR PTRACE_PEEKUSER
49# endif
50# ifndef PTRACE_POKEUSR
51# define PTRACE_POKEUSR PTRACE_POKEUSER
52# endif
Wichert Akkerman15dea971999-10-06 13:06:34 +000053#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000054
Roland McGrath5bd7cf82003-01-24 04:31:18 +000055#ifdef HAVE_LINUX_PTRACE_H
Denys Vlasenko84703742012-02-25 02:38:52 +010056# undef PTRACE_SYSCALL
Roland McGrathfb1bc072004-03-01 21:29:24 +000057# ifdef HAVE_STRUCT_IA64_FPREG
58# define ia64_fpreg XXX_ia64_fpreg
59# endif
60# ifdef HAVE_STRUCT_PT_ALL_USER_REGS
61# define pt_all_user_regs XXX_pt_all_user_regs
62# endif
Denys Vlasenko84703742012-02-25 02:38:52 +010063# include <linux/ptrace.h>
Roland McGrathfb1bc072004-03-01 21:29:24 +000064# undef ia64_fpreg
65# undef pt_all_user_regs
Roland McGrath5bd7cf82003-01-24 04:31:18 +000066#endif
67
Denys Vlasenko84703742012-02-25 02:38:52 +010068#if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +000069# define r_pc r_tpc
70# undef PTRACE_GETREGS
71# define PTRACE_GETREGS PTRACE_GETREGS64
72# undef PTRACE_SETREGS
73# define PTRACE_SETREGS PTRACE_SETREGS64
Denys Vlasenko84703742012-02-25 02:38:52 +010074#endif
Roland McGrath6d1a65c2004-07-12 07:44:08 +000075
Roland McGrath5a223472002-12-15 23:58:26 +000076#ifdef HAVE_LINUX_FUTEX_H
Dmitry V. Levine5e60852009-12-31 22:50:49 +000077# include <linux/futex.h>
Roland McGrath5a223472002-12-15 23:58:26 +000078#endif
Denys Vlasenko84703742012-02-25 02:38:52 +010079#ifndef FUTEX_WAIT
80# define FUTEX_WAIT 0
81#endif
82#ifndef FUTEX_WAKE
83# define FUTEX_WAKE 1
84#endif
85#ifndef FUTEX_FD
86# define FUTEX_FD 2
87#endif
88#ifndef FUTEX_REQUEUE
89# define FUTEX_REQUEUE 3
90#endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000091
Roland McGrath279d3782004-03-01 20:27:37 +000092#include <sched.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000093#include <asm/posix_types.h>
94#undef GETGROUPS_T
95#define GETGROUPS_T __kernel_gid_t
Roland McGrath83bd47a2003-11-13 22:32:26 +000096#undef GETGROUPS32_T
97#define GETGROUPS32_T __kernel_gid32_t
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000098
Denys Vlasenko84703742012-02-25 02:38:52 +010099#if defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000100# include <asm/ptrace_offsets.h>
101# include <asm/rse.h>
102#endif
103
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000104#ifdef HAVE_PRCTL
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000105# include <sys/prctl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000106
Roland McGrathd9f816f2004-09-04 03:39:20 +0000107static const struct xlat prctl_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000108#ifdef PR_MAXPROCS
109 { PR_MAXPROCS, "PR_MAXPROCS" },
110#endif
111#ifdef PR_ISBLOCKED
112 { PR_ISBLOCKED, "PR_ISBLOCKED" },
113#endif
114#ifdef PR_SETSTACKSIZE
115 { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" },
116#endif
117#ifdef PR_GETSTACKSIZE
118 { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" },
119#endif
120#ifdef PR_MAXPPROCS
121 { PR_MAXPPROCS, "PR_MAXPPROCS" },
122#endif
123#ifdef PR_UNBLKONEXEC
124 { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" },
125#endif
126#ifdef PR_ATOMICSIM
127 { PR_ATOMICSIM, "PR_ATOMICSIM" },
128#endif
129#ifdef PR_SETEXITSIG
130 { PR_SETEXITSIG, "PR_SETEXITSIG" },
131#endif
132#ifdef PR_RESIDENT
133 { PR_RESIDENT, "PR_RESIDENT" },
134#endif
135#ifdef PR_ATTACHADDR
136 { PR_ATTACHADDR, "PR_ATTACHADDR" },
137#endif
138#ifdef PR_DETACHADDR
139 { PR_DETACHADDR, "PR_DETACHADDR" },
140#endif
141#ifdef PR_TERMCHILD
142 { PR_TERMCHILD, "PR_TERMCHILD" },
143#endif
144#ifdef PR_GETSHMASK
145 { PR_GETSHMASK, "PR_GETSHMASK" },
146#endif
147#ifdef PR_GETNSHARE
148 { PR_GETNSHARE, "PR_GETNSHARE" },
149#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +0000150#ifdef PR_COREPID
151 { PR_COREPID, "PR_COREPID" },
152#endif
153#ifdef PR_ATTACHADDRPERM
154 { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" },
155#endif
156#ifdef PR_PTHREADEXIT
157 { PR_PTHREADEXIT, "PR_PTHREADEXIT" },
158#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000159#ifdef PR_SET_PDEATHSIG
160 { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
161#endif
162#ifdef PR_GET_PDEATHSIG
163 { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
164#endif
Dmitry V. Levinf02cf212008-09-03 00:54:40 +0000165#ifdef PR_GET_DUMPABLE
166 { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" },
167#endif
168#ifdef PR_SET_DUMPABLE
169 { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" },
170#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000171#ifdef PR_GET_UNALIGN
172 { PR_GET_UNALIGN, "PR_GET_UNALIGN" },
173#endif
174#ifdef PR_SET_UNALIGN
175 { PR_SET_UNALIGN, "PR_SET_UNALIGN" },
176#endif
177#ifdef PR_GET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000178 { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000179#endif
180#ifdef PR_SET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000181 { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000182#endif
Roland McGrathe5039fb2007-11-03 23:58:07 +0000183#ifdef PR_GET_FPEMU
184 { PR_GET_FPEMU, "PR_GET_FPEMU" },
185#endif
186#ifdef PR_SET_FPEMU
187 { PR_SET_FPEMU, "PR_SET_FPEMU" },
188#endif
189#ifdef PR_GET_FPEXC
190 { PR_GET_FPEXC, "PR_GET_FPEXC" },
191#endif
192#ifdef PR_SET_FPEXC
193 { PR_SET_FPEXC, "PR_SET_FPEXC" },
194#endif
195#ifdef PR_GET_TIMING
196 { PR_GET_TIMING, "PR_GET_TIMING" },
197#endif
198#ifdef PR_SET_TIMING
199 { PR_SET_TIMING, "PR_SET_TIMING" },
200#endif
201#ifdef PR_SET_NAME
202 { PR_SET_NAME, "PR_SET_NAME" },
203#endif
204#ifdef PR_GET_NAME
205 { PR_GET_NAME, "PR_GET_NAME" },
206#endif
207#ifdef PR_GET_ENDIAN
208 { PR_GET_ENDIAN, "PR_GET_ENDIAN" },
209#endif
210#ifdef PR_SET_ENDIAN
211 { PR_SET_ENDIAN, "PR_SET_ENDIAN" },
212#endif
213#ifdef PR_GET_SECCOMP
214 { PR_GET_SECCOMP, "PR_GET_SECCOMP" },
215#endif
216#ifdef PR_SET_SECCOMP
217 { PR_SET_SECCOMP, "PR_SET_SECCOMP" },
218#endif
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000219#ifdef PR_GET_TSC
220 { PR_GET_TSC, "PR_GET_TSC" },
221#endif
222#ifdef PR_SET_TSC
223 { PR_SET_TSC, "PR_SET_TSC" },
224#endif
225#ifdef PR_GET_SECUREBITS
226 { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" },
227#endif
228#ifdef PR_SET_SECUREBITS
229 { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" },
230#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000231 { 0, NULL },
232};
233
Roland McGratha4d48532005-06-08 20:45:28 +0000234static const char *
Denys Vlasenko12014262011-05-30 14:00:14 +0200235unalignctl_string(unsigned int ctl)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000236{
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100237 static char buf[sizeof(int)*2 + 2];
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000238
239 switch (ctl) {
240#ifdef PR_UNALIGN_NOPRINT
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100241 case PR_UNALIGN_NOPRINT:
242 return "NOPRINT";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000243#endif
244#ifdef PR_UNALIGN_SIGBUS
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100245 case PR_UNALIGN_SIGBUS:
246 return "SIGBUS";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000247#endif
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100248 default:
249 break;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000250 }
251 sprintf(buf, "%x", ctl);
252 return buf;
253}
254
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000255int
Denys Vlasenko12014262011-05-30 14:00:14 +0200256sys_prctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000257{
258 int i;
259
260 if (entering(tcp)) {
261 printxval(prctl_options, tcp->u_arg[0], "PR_???");
262 switch (tcp->u_arg[0]) {
263#ifdef PR_GETNSHARE
264 case PR_GETNSHARE:
265 break;
266#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000267#ifdef PR_SET_PDEATHSIG
268 case PR_SET_PDEATHSIG:
269 tprintf(", %lu", tcp->u_arg[1]);
270 break;
271#endif
272#ifdef PR_GET_PDEATHSIG
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000273 case PR_GET_PDEATHSIG:
274 break;
275#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000276#ifdef PR_SET_DUMPABLE
277 case PR_SET_DUMPABLE:
278 tprintf(", %lu", tcp->u_arg[1]);
279 break;
280#endif
281#ifdef PR_GET_DUMPABLE
282 case PR_GET_DUMPABLE:
283 break;
284#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000285#ifdef PR_SET_UNALIGN
286 case PR_SET_UNALIGN:
287 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
288 break;
289#endif
290#ifdef PR_GET_UNALIGN
291 case PR_GET_UNALIGN:
292 tprintf(", %#lx", tcp->u_arg[1]);
293 break;
294#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000295#ifdef PR_SET_KEEPCAPS
296 case PR_SET_KEEPCAPS:
297 tprintf(", %lu", tcp->u_arg[1]);
298 break;
299#endif
300#ifdef PR_GET_KEEPCAPS
301 case PR_GET_KEEPCAPS:
302 break;
303#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000304 default:
Denys Vlasenko74ec14f2013-02-21 16:13:47 +0100305 for (i = 1; i < tcp->s_ent->nargs; i++)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000306 tprintf(", %#lx", tcp->u_arg[i]);
307 break;
308 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000309 } else {
310 switch (tcp->u_arg[0]) {
311#ifdef PR_GET_PDEATHSIG
312 case PR_GET_PDEATHSIG:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000313 if (umove(tcp, tcp->u_arg[1], &i) < 0)
314 tprintf(", %#lx", tcp->u_arg[1]);
315 else
316 tprintf(", {%u}", i);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000317 break;
318#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000319#ifdef PR_GET_DUMPABLE
320 case PR_GET_DUMPABLE:
321 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000322#endif
323#ifdef PR_GET_UNALIGN
324 case PR_GET_UNALIGN:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000325 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
326 break;
327 tcp->auxstr = unalignctl_string(i);
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000328 return RVAL_STR;
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000329#endif
330#ifdef PR_GET_KEEPCAPS
331 case PR_GET_KEEPCAPS:
332 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000333#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000334 default:
335 break;
336 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000337 }
338 return 0;
339}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000340#endif /* HAVE_PRCTL */
341
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000342int
Denys Vlasenko12014262011-05-30 14:00:14 +0200343sys_sethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000344{
345 if (entering(tcp)) {
346 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
347 tprintf(", %lu", tcp->u_arg[1]);
348 }
349 return 0;
350}
351
Denys Vlasenko84703742012-02-25 02:38:52 +0100352#if defined(ALPHA)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000353int
Denys Vlasenko12014262011-05-30 14:00:14 +0200354sys_gethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000355{
356 if (exiting(tcp)) {
357 if (syserror(tcp))
358 tprintf("%#lx", tcp->u_arg[0]);
359 else
360 printpath(tcp, tcp->u_arg[0]);
361 tprintf(", %lu", tcp->u_arg[1]);
362 }
363 return 0;
364}
Denys Vlasenko84703742012-02-25 02:38:52 +0100365#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000366
367int
Denys Vlasenko12014262011-05-30 14:00:14 +0200368sys_setdomainname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000369{
370 if (entering(tcp)) {
371 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
372 tprintf(", %lu", tcp->u_arg[1]);
373 }
374 return 0;
375}
376
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000377int
Denys Vlasenko12014262011-05-30 14:00:14 +0200378sys_exit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000379{
380 if (exiting(tcp)) {
381 fprintf(stderr, "_exit returned!\n");
382 return -1;
383 }
384 /* special case: we stop tracing this process, finish line now */
385 tprintf("%ld) ", tcp->u_arg[0]);
Denys Vlasenko102ec492011-08-25 01:27:59 +0200386 tabto();
Denys Vlasenko000b6012012-01-28 01:25:03 +0100387 tprints("= ?\n");
Denys Vlasenko7de265d2012-03-13 11:44:31 +0100388 line_ended();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000389 return 0;
390}
391
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000392/* defines copied from linux/sched.h since we can't include that
393 * ourselves (it conflicts with *lots* of libc includes)
394 */
395#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
396#define CLONE_VM 0x00000100 /* set if VM shared between processes */
397#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
398#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
399#define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
Roland McGrath909875b2002-12-22 03:34:36 +0000400#define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000401#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
402#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
403#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
Roland McGrath909875b2002-12-22 03:34:36 +0000404#define CLONE_THREAD 0x00010000 /* Same thread group? */
405#define CLONE_NEWNS 0x00020000 /* New namespace group? */
406#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
407#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
408#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
409#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
Roland McGrath909875b2002-12-22 03:34:36 +0000410#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
411#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000412#define CLONE_STOPPED 0x02000000 /* Start in stopped state */
413#define CLONE_NEWUTS 0x04000000 /* New utsname group? */
414#define CLONE_NEWIPC 0x08000000 /* New ipcs */
415#define CLONE_NEWUSER 0x10000000 /* New user namespace */
416#define CLONE_NEWPID 0x20000000 /* New pid namespace */
417#define CLONE_NEWNET 0x40000000 /* New network namespace */
418#define CLONE_IO 0x80000000 /* Clone io context */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000419
Roland McGrathd9f816f2004-09-04 03:39:20 +0000420static const struct xlat clone_flags[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100421 { CLONE_VM, "CLONE_VM" },
422 { CLONE_FS, "CLONE_FS" },
423 { CLONE_FILES, "CLONE_FILES" },
424 { CLONE_SIGHAND, "CLONE_SIGHAND" },
425 { CLONE_IDLETASK, "CLONE_IDLETASK" },
426 { CLONE_PTRACE, "CLONE_PTRACE" },
427 { CLONE_VFORK, "CLONE_VFORK" },
428 { CLONE_PARENT, "CLONE_PARENT" },
429 { CLONE_THREAD, "CLONE_THREAD" },
430 { CLONE_NEWNS, "CLONE_NEWNS" },
431 { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
432 { CLONE_SETTLS, "CLONE_SETTLS" },
433 { CLONE_PARENT_SETTID, "CLONE_PARENT_SETTID" },
434 { CLONE_CHILD_CLEARTID, "CLONE_CHILD_CLEARTID" },
435 { CLONE_UNTRACED, "CLONE_UNTRACED" },
436 { CLONE_CHILD_SETTID, "CLONE_CHILD_SETTID" },
437 { CLONE_STOPPED, "CLONE_STOPPED" },
438 { CLONE_NEWUTS, "CLONE_NEWUTS" },
439 { CLONE_NEWIPC, "CLONE_NEWIPC" },
440 { CLONE_NEWUSER, "CLONE_NEWUSER" },
441 { CLONE_NEWPID, "CLONE_NEWPID" },
442 { CLONE_NEWNET, "CLONE_NEWNET" },
443 { CLONE_IO, "CLONE_IO" },
444 { 0, NULL },
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000445};
446
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100447#ifdef I386
448# include <asm/ldt.h>
449# ifdef HAVE_STRUCT_USER_DESC
450# define modify_ldt_ldt_s user_desc
451# endif
Roland McGrath909875b2002-12-22 03:34:36 +0000452extern void print_ldt_entry();
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100453#endif
Roland McGrath909875b2002-12-22 03:34:36 +0000454
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100455#if defined IA64
456# define ARG_FLAGS 0
457# define ARG_STACK 1
458# define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
459# define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
460# define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
461# define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
462#elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
463# define ARG_STACK 0
464# define ARG_FLAGS 1
465# define ARG_PTID 2
466# define ARG_CTID 3
467# define ARG_TLS 4
Christian Svensson492f81f2013-02-14 13:26:27 +0100468#elif defined X86_64 || defined X32 || defined ALPHA || defined TILE \
469 || defined OR1K
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100470# define ARG_FLAGS 0
471# define ARG_STACK 1
472# define ARG_PTID 2
473# define ARG_CTID 3
474# define ARG_TLS 4
475#else
476# define ARG_FLAGS 0
477# define ARG_STACK 1
478# define ARG_PTID 2
479# define ARG_TLS 3
480# define ARG_CTID 4
481#endif
Roland McGrath9677b3a2003-03-12 09:54:36 +0000482
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000483int
Denys Vlasenko12014262011-05-30 14:00:14 +0200484sys_clone(struct tcb *tcp)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000485{
486 if (exiting(tcp)) {
Wang Chaocbdd1902010-09-02 15:08:59 +0800487 const char *sep = "|";
Roland McGrath9677b3a2003-03-12 09:54:36 +0000488 unsigned long flags = tcp->u_arg[ARG_FLAGS];
489 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100490#ifdef ARG_STACKSIZE
Roland McGrath9677b3a2003-03-12 09:54:36 +0000491 if (ARG_STACKSIZE != -1)
492 tprintf("stack_size=%#lx, ",
493 tcp->u_arg[ARG_STACKSIZE]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100494#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200495 tprints("flags=");
Wang Chaocbdd1902010-09-02 15:08:59 +0800496 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
497 sep = "";
Roland McGrath984154d2003-05-23 01:08:42 +0000498 if ((flags & CSIGNAL) != 0)
Wang Chaocbdd1902010-09-02 15:08:59 +0800499 tprintf("%s%s", sep, signame(flags & CSIGNAL));
Roland McGrathb4968be2003-01-20 09:04:33 +0000500 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
Roland McGrath9677b3a2003-03-12 09:54:36 +0000501 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
Roland McGrath909875b2002-12-22 03:34:36 +0000502 return 0;
Roland McGrath6f67a982003-03-21 07:33:15 +0000503 if (flags & CLONE_PARENT_SETTID)
504 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000505 if (flags & CLONE_SETTLS) {
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100506#ifdef I386
Roland McGrath909875b2002-12-22 03:34:36 +0000507 struct modify_ldt_ldt_s copy;
Roland McGrath9677b3a2003-03-12 09:54:36 +0000508 if (umove(tcp, tcp->u_arg[ARG_TLS], &copy) != -1) {
Roland McGrath909875b2002-12-22 03:34:36 +0000509 tprintf(", {entry_number:%d, ",
510 copy.entry_number);
511 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200512 tprints("...}");
Roland McGrath909875b2002-12-22 03:34:36 +0000513 else
514 print_ldt_entry(&copy);
515 }
516 else
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100517#endif
Roland McGrath43f2c842003-03-12 09:58:14 +0000518 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
Roland McGrath909875b2002-12-22 03:34:36 +0000519 }
Roland McGrath9677b3a2003-03-12 09:54:36 +0000520 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
521 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000522 }
523 return 0;
524}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000525
526int
527sys_unshare(struct tcb *tcp)
528{
529 if (entering(tcp))
530 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
531 return 0;
532}
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000533
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000534int
Denys Vlasenko081533c2012-03-17 02:17:51 +0100535sys_fork(struct tcb *tcp)
536{
537 if (exiting(tcp))
538 return RVAL_UDECIMAL;
539 return 0;
540}
541
542int
Denys Vlasenko12014262011-05-30 14:00:14 +0200543sys_vfork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000544{
545 if (exiting(tcp))
546 return RVAL_UDECIMAL;
547 return 0;
548}
549
Dmitry V. Levin50a218d2011-01-18 17:36:20 +0000550int sys_getuid(struct tcb *tcp)
551{
552 if (exiting(tcp))
553 tcp->u_rval = (uid_t) tcp->u_rval;
554 return RVAL_UDECIMAL;
555}
556
557int sys_setfsuid(struct tcb *tcp)
558{
559 if (entering(tcp))
560 tprintf("%u", (uid_t) tcp->u_arg[0]);
561 else
562 tcp->u_rval = (uid_t) tcp->u_rval;
563 return RVAL_UDECIMAL;
564}
565
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000566int
Denys Vlasenko12014262011-05-30 14:00:14 +0200567sys_setuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000568{
569 if (entering(tcp)) {
570 tprintf("%u", (uid_t) tcp->u_arg[0]);
571 }
572 return 0;
573}
574
575int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000576sys_getresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000577{
578 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000579 __kernel_uid_t uid;
580 if (syserror(tcp))
581 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
582 tcp->u_arg[1], tcp->u_arg[2]);
583 else {
584 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
585 tprintf("%#lx, ", tcp->u_arg[0]);
586 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000587 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000588 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
589 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000590 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000591 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000592 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
593 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000594 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000595 tprintf("[%lu]", (unsigned long) uid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000596 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000597 }
598 return 0;
599}
600
601int
Denys Vlasenko12014262011-05-30 14:00:14 +0200602sys_setreuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000603{
604 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000605 printuid("", tcp->u_arg[0]);
606 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000607 }
608 return 0;
609}
610
611int
Denys Vlasenko12014262011-05-30 14:00:14 +0200612sys_setresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000613{
614 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000615 printuid("", tcp->u_arg[0]);
616 printuid(", ", tcp->u_arg[1]);
617 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000618 }
619 return 0;
620}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000621
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000622int
Denys Vlasenko12014262011-05-30 14:00:14 +0200623sys_setgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000624{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000625 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000626 unsigned long len, size, start, cur, end, abbrev_end;
627 GETGROUPS_T gid;
628 int failed = 0;
629
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000630 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000631 tprintf("%lu, ", len);
632 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200633 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000634 return 0;
635 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000636 start = tcp->u_arg[1];
637 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200638 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000639 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000640 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000641 size = len * sizeof(gid);
642 end = start + size;
643 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
644 tprintf("%#lx", start);
645 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000646 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000647 if (abbrev(tcp)) {
648 abbrev_end = start + max_strlen * sizeof(gid);
649 if (abbrev_end < start)
650 abbrev_end = end;
651 } else {
652 abbrev_end = end;
653 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200654 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000655 for (cur = start; cur < end; cur += sizeof(gid)) {
656 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200657 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000658 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200659 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000660 break;
661 }
662 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200663 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000664 failed = 1;
665 break;
666 }
667 tprintf("%lu", (unsigned long) gid);
668 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200669 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000670 if (failed)
671 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000672 }
673 return 0;
674}
675
676int
Denys Vlasenko12014262011-05-30 14:00:14 +0200677sys_getgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000678{
Roland McGrathaa524c82005-06-01 19:22:06 +0000679 unsigned long len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000680
681 if (entering(tcp)) {
682 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000683 tprintf("%lu, ", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000684 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000685 unsigned long size, start, cur, end, abbrev_end;
686 GETGROUPS_T gid;
687 int failed = 0;
688
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000689 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000690 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200691 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000692 return 0;
693 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000694 start = tcp->u_arg[1];
695 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200696 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000697 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000698 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000699 if (tcp->u_arg[0] == 0) {
700 tprintf("%#lx", start);
701 return 0;
702 }
703 size = len * sizeof(gid);
704 end = start + size;
705 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
706 size / sizeof(gid) != len || end < start) {
707 tprintf("%#lx", start);
708 return 0;
709 }
710 if (abbrev(tcp)) {
711 abbrev_end = start + max_strlen * sizeof(gid);
712 if (abbrev_end < start)
713 abbrev_end = end;
714 } else {
715 abbrev_end = end;
716 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200717 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000718 for (cur = start; cur < end; cur += sizeof(gid)) {
719 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200720 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000721 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200722 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000723 break;
724 }
725 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200726 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000727 failed = 1;
728 break;
729 }
730 tprintf("%lu", (unsigned long) gid);
731 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200732 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000733 if (failed)
734 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000735 }
736 return 0;
737}
738
Roland McGrath83bd47a2003-11-13 22:32:26 +0000739int
Denys Vlasenko12014262011-05-30 14:00:14 +0200740sys_setgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000741{
Roland McGrath83bd47a2003-11-13 22:32:26 +0000742 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000743 unsigned long len, size, start, cur, end, abbrev_end;
744 GETGROUPS32_T gid;
745 int failed = 0;
746
Roland McGrath83bd47a2003-11-13 22:32:26 +0000747 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000748 tprintf("%lu, ", len);
749 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200750 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000751 return 0;
752 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000753 start = tcp->u_arg[1];
754 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200755 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000756 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000757 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000758 size = len * sizeof(gid);
759 end = start + size;
760 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
761 tprintf("%#lx", start);
762 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000763 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000764 if (abbrev(tcp)) {
765 abbrev_end = start + max_strlen * sizeof(gid);
766 if (abbrev_end < start)
767 abbrev_end = end;
768 } else {
769 abbrev_end = end;
770 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200771 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000772 for (cur = start; cur < end; cur += sizeof(gid)) {
773 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200774 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000775 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200776 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000777 break;
778 }
779 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200780 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000781 failed = 1;
782 break;
783 }
784 tprintf("%lu", (unsigned long) gid);
785 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200786 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000787 if (failed)
788 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000789 }
790 return 0;
791}
792
793int
Denys Vlasenko12014262011-05-30 14:00:14 +0200794sys_getgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000795{
Roland McGrathaa524c82005-06-01 19:22:06 +0000796 unsigned long len;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000797
798 if (entering(tcp)) {
799 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000800 tprintf("%lu, ", len);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000801 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000802 unsigned long size, start, cur, end, abbrev_end;
803 GETGROUPS32_T gid;
804 int failed = 0;
805
Roland McGrath83bd47a2003-11-13 22:32:26 +0000806 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000807 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200808 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000809 return 0;
810 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000811 start = tcp->u_arg[1];
812 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200813 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000814 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000815 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000816 size = len * sizeof(gid);
817 end = start + size;
818 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
819 size / sizeof(gid) != len || end < start) {
820 tprintf("%#lx", start);
821 return 0;
822 }
823 if (abbrev(tcp)) {
824 abbrev_end = start + max_strlen * sizeof(gid);
825 if (abbrev_end < start)
826 abbrev_end = end;
827 } else {
828 abbrev_end = end;
829 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200830 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000831 for (cur = start; cur < end; cur += sizeof(gid)) {
832 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200833 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000834 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200835 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000836 break;
837 }
838 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200839 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000840 failed = 1;
841 break;
842 }
843 tprintf("%lu", (unsigned long) gid);
844 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200845 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000846 if (failed)
847 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000848 }
849 return 0;
850}
Roland McGrath83bd47a2003-11-13 22:32:26 +0000851
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000852static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000853printargv(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000854{
Roland McGrath85a3bc42007-08-02 02:13:05 +0000855 union {
Andreas Schwab99c85692009-08-28 19:36:20 +0200856 unsigned int p32;
857 unsigned long p64;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000858 char data[sizeof(long)];
859 } cp;
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000860 const char *sep;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000861 int n = 0;
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100862 unsigned wordsize = current_wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000863
Roland McGrath85a3bc42007-08-02 02:13:05 +0000864 cp.p64 = 1;
865 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100866 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000867 tprintf("%#lx", addr);
868 return;
869 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100870 if (wordsize == 4)
Roland McGrath85a3bc42007-08-02 02:13:05 +0000871 cp.p64 = cp.p32;
872 if (cp.p64 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000873 break;
Denys Vlasenko5940e652011-09-01 09:55:05 +0200874 tprints(sep);
Roland McGrath85a3bc42007-08-02 02:13:05 +0000875 printstr(tcp, cp.p64, -1);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100876 addr += wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000877 }
Roland McGrath85a3bc42007-08-02 02:13:05 +0000878 if (cp.p64)
879 tprintf("%s...", sep);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000880}
881
882static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000883printargc(const char *fmt, struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000884{
885 int count;
886 char *cp;
887
888 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
889 addr += sizeof(char *);
890 }
891 tprintf(fmt, count, count == 1 ? "" : "s");
892}
893
Denys Vlasenko84703742012-02-25 02:38:52 +0100894#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000895int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000896sys_execv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000897{
898 if (entering(tcp)) {
899 printpath(tcp, tcp->u_arg[0]);
900 if (!verbose(tcp))
901 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000902 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200903 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000904 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200905 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000906 }
907 }
908 return 0;
909}
Denys Vlasenko84703742012-02-25 02:38:52 +0100910#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000911
912int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000913sys_execve(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000914{
915 if (entering(tcp)) {
916 printpath(tcp, tcp->u_arg[0]);
917 if (!verbose(tcp))
918 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000919 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200920 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000921 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200922 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000923 }
924 if (!verbose(tcp))
925 tprintf(", %#lx", tcp->u_arg[2]);
926 else if (abbrev(tcp))
927 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
928 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200929 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000930 printargv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200931 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000932 }
933 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000934 return 0;
935}
936
Roland McGrath7ec1d352002-12-17 04:50:44 +0000937#ifndef __WNOTHREAD
938#define __WNOTHREAD 0x20000000
939#endif
940#ifndef __WALL
941#define __WALL 0x40000000
942#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000943#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +0000944#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000945#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000946
Roland McGrathd9f816f2004-09-04 03:39:20 +0000947static const struct xlat wait4_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000948 { WNOHANG, "WNOHANG" },
949#ifndef WSTOPPED
950 { WUNTRACED, "WUNTRACED" },
951#endif
952#ifdef WEXITED
953 { WEXITED, "WEXITED" },
954#endif
955#ifdef WTRAPPED
956 { WTRAPPED, "WTRAPPED" },
957#endif
958#ifdef WSTOPPED
959 { WSTOPPED, "WSTOPPED" },
960#endif
961#ifdef WCONTINUED
962 { WCONTINUED, "WCONTINUED" },
963#endif
964#ifdef WNOWAIT
965 { WNOWAIT, "WNOWAIT" },
966#endif
967#ifdef __WCLONE
968 { __WCLONE, "__WCLONE" },
969#endif
Roland McGrath7ec1d352002-12-17 04:50:44 +0000970#ifdef __WALL
971 { __WALL, "__WALL" },
972#endif
973#ifdef __WNOTHREAD
974 { __WNOTHREAD, "__WNOTHREAD" },
975#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000976 { 0, NULL },
977};
978
Roland McGrath5e02a572004-10-19 23:33:47 +0000979#if !defined WCOREFLAG && defined WCOREFLG
980# define WCOREFLAG WCOREFLG
981#endif
982#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000983# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +0000984#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000985#ifndef WCOREDUMP
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100986# define WCOREDUMP(status) ((status) & 0200)
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000987#endif
Roland McGrath5e02a572004-10-19 23:33:47 +0000988#ifndef W_STOPCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100989# define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
Roland McGrath5e02a572004-10-19 23:33:47 +0000990#endif
991#ifndef W_EXITCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100992# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
Roland McGrath5e02a572004-10-19 23:33:47 +0000993#endif
994
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000995static int
Denys Vlasenko12014262011-05-30 14:00:14 +0200996printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000997{
998 int exited = 0;
999
1000 /*
1001 * Here is a tricky presentation problem. This solution
1002 * is still not entirely satisfactory but since there
1003 * are no wait status constructors it will have to do.
1004 */
Roland McGrath79fbda52004-04-14 02:45:55 +00001005 if (WIFSTOPPED(status)) {
1006 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001007 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +00001008 status &= ~W_STOPCODE(WSTOPSIG(status));
1009 }
1010 else if (WIFSIGNALED(status)) {
1011 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001012 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001013 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +00001014 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1015 }
1016 else if (WIFEXITED(status)) {
1017 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001018 WEXITSTATUS(status));
1019 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +00001020 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001021 }
Roland McGrath79fbda52004-04-14 02:45:55 +00001022 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001023 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001024 return 0;
1025 }
1026
1027 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001028 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +00001029 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +00001030 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001031
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001032 return exited;
1033}
1034
1035static int
Denys Vlasenko59432db2009-01-26 19:09:35 +00001036printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001037{
1038 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001039
1040 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001041 /* On Linux, kernel-side pid_t is typedef'ed to int
1042 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +00001043 * pid argument to int on 64bit arches, producing,
1044 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001045 * in strace. We have to use int here, not long.
1046 */
1047 int pid = tcp->u_arg[0];
1048 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001049 } else {
1050 /* status */
1051 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001052 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001053 else if (syserror(tcp) || tcp->u_rval == 0)
1054 tprintf("%#lx", tcp->u_arg[1]);
1055 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001056 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001057 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +00001058 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001059 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001060 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001061 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001062 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001063 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001064 /* usage */
1065 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001066 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001067 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +00001068#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001069 if (bitness)
1070 printrusage32(tcp, tcp->u_arg[3]);
1071 else
1072#endif
1073 printrusage(tcp, tcp->u_arg[3]);
1074 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001075 else
1076 tprintf("%#lx", tcp->u_arg[3]);
1077 }
1078 }
1079 return 0;
1080}
1081
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001082int
Denys Vlasenko12014262011-05-30 14:00:14 +02001083sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001084{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001085 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001086}
1087
1088int
Denys Vlasenko12014262011-05-30 14:00:14 +02001089sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001090{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001091 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001092}
1093
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001094#ifdef ALPHA
1095int
Denys Vlasenko12014262011-05-30 14:00:14 +02001096sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001097{
1098 return printwaitn(tcp, 4, 1);
1099}
1100#endif
1101
Roland McGrathd9f816f2004-09-04 03:39:20 +00001102static const struct xlat waitid_types[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001103 { P_PID, "P_PID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001104#ifdef P_PPID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001105 { P_PPID, "P_PPID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001106#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001107 { P_PGID, "P_PGID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001108#ifdef P_SID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001109 { P_SID, "P_SID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001110#endif
1111#ifdef P_CID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001112 { P_CID, "P_CID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001113#endif
1114#ifdef P_UID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001115 { P_UID, "P_UID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001116#endif
1117#ifdef P_GID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001118 { P_GID, "P_GID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001119#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001120 { P_ALL, "P_ALL" },
1121#ifdef P_LWPID
1122 { P_LWPID, "P_LWPID" },
1123#endif
1124 { 0, NULL },
1125};
1126
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001127int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +00001128sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001129{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001130 if (entering(tcp)) {
1131 printxval(waitid_types, tcp->u_arg[0], "P_???");
1132 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001133 }
1134 else {
1135 /* siginfo */
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01001136 printsiginfo_at(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001137 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001138 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001139 printflags(wait4_options, tcp->u_arg[3], "W???");
Denys Vlasenko74ec14f2013-02-21 16:13:47 +01001140 if (tcp->s_ent->nargs > 4) {
Roland McGrath39426a32004-10-06 22:02:59 +00001141 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001142 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +00001143 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001144 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +00001145 else if (tcp->u_error)
1146 tprintf("%#lx", tcp->u_arg[4]);
1147 else
1148 printrusage(tcp, tcp->u_arg[4]);
1149 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001150 }
1151 return 0;
1152}
1153
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001154int
Denys Vlasenko12014262011-05-30 14:00:14 +02001155sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001156{
1157 struct utsname uname;
1158
1159 if (exiting(tcp)) {
1160 if (syserror(tcp) || !verbose(tcp))
1161 tprintf("%#lx", tcp->u_arg[0]);
1162 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001163 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001164 else if (!abbrev(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001165 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1166 uname.sysname, uname.nodename);
1167 tprintf("release=\"%s\", version=\"%s\", ",
1168 uname.release, uname.version);
1169 tprintf("machine=\"%s\"", uname.machine);
Dmitry V. Levinea22e972012-05-01 20:56:32 +00001170#ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001171 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001172#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001173 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001174 }
1175 else
1176 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1177 uname.sysname, uname.nodename);
1178 }
1179 return 0;
1180}
1181
Roland McGratheb9e2e82009-06-02 16:49:22 -07001182static const struct xlat ptrace_cmds[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001183 { PTRACE_TRACEME, "PTRACE_TRACEME" },
Denys Vlasenko61526c62011-08-25 10:21:13 +02001184 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1185 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1186 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1187 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1188 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1189 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001190 { PTRACE_CONT, "PTRACE_CONT" },
1191 { PTRACE_KILL, "PTRACE_KILL" },
1192 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1193 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1194 { PTRACE_DETACH, "PTRACE_DETACH" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001195#ifdef PTRACE_GETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001196 { PTRACE_GETREGS, "PTRACE_GETREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001197#endif
1198#ifdef PTRACE_SETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001199 { PTRACE_SETREGS, "PTRACE_SETREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001200#endif
1201#ifdef PTRACE_GETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001202 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001203#endif
1204#ifdef PTRACE_SETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001205 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001206#endif
1207#ifdef PTRACE_GETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001208 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001209#endif
1210#ifdef PTRACE_SETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001211 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001212#endif
1213#ifdef PTRACE_GETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001214 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001215#endif
1216#ifdef PTRACE_SETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001217 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001218#endif
1219#ifdef PTRACE_SETOPTIONS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001220 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001221#endif
1222#ifdef PTRACE_GETEVENTMSG
Denys Vlasenko61526c62011-08-25 10:21:13 +02001223 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001224#endif
1225#ifdef PTRACE_GETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001226 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001227#endif
1228#ifdef PTRACE_SETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001229 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001230#endif
1231#ifdef PTRACE_GETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001232 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001233#endif
1234#ifdef PTRACE_SETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001235 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001236#endif
1237#ifdef PTRACE_SET_SYSCALL
Denys Vlasenko61526c62011-08-25 10:21:13 +02001238 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001239#endif
1240#ifdef PTRACE_SEIZE
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001241 { PTRACE_SEIZE, "PTRACE_SEIZE" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001242#endif
1243#ifdef PTRACE_INTERRUPT
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001244 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001245#endif
1246#ifdef PTRACE_LISTEN
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001247 { PTRACE_LISTEN, "PTRACE_LISTEN" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001248#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001249 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
Denys Vlasenkof535b542009-01-13 18:30:55 +00001250
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001251 { 0, NULL },
1252};
1253
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001254#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00001255static const struct xlat ptrace_setoptions_flags[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001256# ifdef PTRACE_O_TRACESYSGOOD
Denys Vlasenkof535b542009-01-13 18:30:55 +00001257 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001258# endif
1259# ifdef PTRACE_O_TRACEFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001260 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001261# endif
1262# ifdef PTRACE_O_TRACEVFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001263 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001264# endif
1265# ifdef PTRACE_O_TRACECLONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001266 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001267# endif
1268# ifdef PTRACE_O_TRACEEXEC
Denys Vlasenkof535b542009-01-13 18:30:55 +00001269 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001270# endif
1271# ifdef PTRACE_O_TRACEVFORKDONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001272 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001273# endif
1274# ifdef PTRACE_O_TRACEEXIT
Denys Vlasenkof535b542009-01-13 18:30:55 +00001275 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001276# endif
Denys Vlasenkof535b542009-01-13 18:30:55 +00001277 { 0, NULL },
1278};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001279#endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001280
Denys Vlasenko513e9c22012-03-21 14:39:22 +01001281#define uoff(member) offsetof(struct user, member)
1282
Roland McGrathd9f816f2004-09-04 03:39:20 +00001283const struct xlat struct_user_offsets[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001284#if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001285 { PT_PSWMASK, "psw_mask" },
1286 { PT_PSWADDR, "psw_addr" },
1287 { PT_GPR0, "gpr0" },
1288 { PT_GPR1, "gpr1" },
1289 { PT_GPR2, "gpr2" },
1290 { PT_GPR3, "gpr3" },
1291 { PT_GPR4, "gpr4" },
1292 { PT_GPR5, "gpr5" },
1293 { PT_GPR6, "gpr6" },
1294 { PT_GPR7, "gpr7" },
1295 { PT_GPR8, "gpr8" },
1296 { PT_GPR9, "gpr9" },
1297 { PT_GPR10, "gpr10" },
1298 { PT_GPR11, "gpr11" },
1299 { PT_GPR12, "gpr12" },
1300 { PT_GPR13, "gpr13" },
1301 { PT_GPR14, "gpr14" },
1302 { PT_GPR15, "gpr15" },
1303 { PT_ACR0, "acr0" },
1304 { PT_ACR1, "acr1" },
1305 { PT_ACR2, "acr2" },
1306 { PT_ACR3, "acr3" },
1307 { PT_ACR4, "acr4" },
1308 { PT_ACR5, "acr5" },
1309 { PT_ACR6, "acr6" },
1310 { PT_ACR7, "acr7" },
1311 { PT_ACR8, "acr8" },
1312 { PT_ACR9, "acr9" },
1313 { PT_ACR10, "acr10" },
1314 { PT_ACR11, "acr11" },
1315 { PT_ACR12, "acr12" },
1316 { PT_ACR13, "acr13" },
1317 { PT_ACR14, "acr14" },
1318 { PT_ACR15, "acr15" },
1319 { PT_ORIGGPR2, "orig_gpr2" },
1320 { PT_FPC, "fpc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001321#if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001322 { PT_FPR0_HI, "fpr0.hi" },
1323 { PT_FPR0_LO, "fpr0.lo" },
1324 { PT_FPR1_HI, "fpr1.hi" },
1325 { PT_FPR1_LO, "fpr1.lo" },
1326 { PT_FPR2_HI, "fpr2.hi" },
1327 { PT_FPR2_LO, "fpr2.lo" },
1328 { PT_FPR3_HI, "fpr3.hi" },
1329 { PT_FPR3_LO, "fpr3.lo" },
1330 { PT_FPR4_HI, "fpr4.hi" },
1331 { PT_FPR4_LO, "fpr4.lo" },
1332 { PT_FPR5_HI, "fpr5.hi" },
1333 { PT_FPR5_LO, "fpr5.lo" },
1334 { PT_FPR6_HI, "fpr6.hi" },
1335 { PT_FPR6_LO, "fpr6.lo" },
1336 { PT_FPR7_HI, "fpr7.hi" },
1337 { PT_FPR7_LO, "fpr7.lo" },
1338 { PT_FPR8_HI, "fpr8.hi" },
1339 { PT_FPR8_LO, "fpr8.lo" },
1340 { PT_FPR9_HI, "fpr9.hi" },
1341 { PT_FPR9_LO, "fpr9.lo" },
1342 { PT_FPR10_HI, "fpr10.hi" },
1343 { PT_FPR10_LO, "fpr10.lo" },
1344 { PT_FPR11_HI, "fpr11.hi" },
1345 { PT_FPR11_LO, "fpr11.lo" },
1346 { PT_FPR12_HI, "fpr12.hi" },
1347 { PT_FPR12_LO, "fpr12.lo" },
1348 { PT_FPR13_HI, "fpr13.hi" },
1349 { PT_FPR13_LO, "fpr13.lo" },
1350 { PT_FPR14_HI, "fpr14.hi" },
1351 { PT_FPR14_LO, "fpr14.lo" },
1352 { PT_FPR15_HI, "fpr15.hi" },
1353 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001354#endif
1355#if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001356 { PT_FPR0, "fpr0" },
1357 { PT_FPR1, "fpr1" },
1358 { PT_FPR2, "fpr2" },
1359 { PT_FPR3, "fpr3" },
1360 { PT_FPR4, "fpr4" },
1361 { PT_FPR5, "fpr5" },
1362 { PT_FPR6, "fpr6" },
1363 { PT_FPR7, "fpr7" },
1364 { PT_FPR8, "fpr8" },
1365 { PT_FPR9, "fpr9" },
1366 { PT_FPR10, "fpr10" },
1367 { PT_FPR11, "fpr11" },
1368 { PT_FPR12, "fpr12" },
1369 { PT_FPR13, "fpr13" },
1370 { PT_FPR14, "fpr14" },
1371 { PT_FPR15, "fpr15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001372#endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001373 { PT_CR_9, "cr9" },
1374 { PT_CR_10, "cr10" },
1375 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001376 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001377#elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001378 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001379#elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001380 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001381#elif defined(POWERPC)
1382# ifndef PT_ORIG_R3
1383# define PT_ORIG_R3 34
1384# endif
1385# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001386 { REGSIZE*PT_R0, "r0" },
1387 { REGSIZE*PT_R1, "r1" },
1388 { REGSIZE*PT_R2, "r2" },
1389 { REGSIZE*PT_R3, "r3" },
1390 { REGSIZE*PT_R4, "r4" },
1391 { REGSIZE*PT_R5, "r5" },
1392 { REGSIZE*PT_R6, "r6" },
1393 { REGSIZE*PT_R7, "r7" },
1394 { REGSIZE*PT_R8, "r8" },
1395 { REGSIZE*PT_R9, "r9" },
1396 { REGSIZE*PT_R10, "r10" },
1397 { REGSIZE*PT_R11, "r11" },
1398 { REGSIZE*PT_R12, "r12" },
1399 { REGSIZE*PT_R13, "r13" },
1400 { REGSIZE*PT_R14, "r14" },
1401 { REGSIZE*PT_R15, "r15" },
1402 { REGSIZE*PT_R16, "r16" },
1403 { REGSIZE*PT_R17, "r17" },
1404 { REGSIZE*PT_R18, "r18" },
1405 { REGSIZE*PT_R19, "r19" },
1406 { REGSIZE*PT_R20, "r20" },
1407 { REGSIZE*PT_R21, "r21" },
1408 { REGSIZE*PT_R22, "r22" },
1409 { REGSIZE*PT_R23, "r23" },
1410 { REGSIZE*PT_R24, "r24" },
1411 { REGSIZE*PT_R25, "r25" },
1412 { REGSIZE*PT_R26, "r26" },
1413 { REGSIZE*PT_R27, "r27" },
1414 { REGSIZE*PT_R28, "r28" },
1415 { REGSIZE*PT_R29, "r29" },
1416 { REGSIZE*PT_R30, "r30" },
1417 { REGSIZE*PT_R31, "r31" },
1418 { REGSIZE*PT_NIP, "NIP" },
1419 { REGSIZE*PT_MSR, "MSR" },
1420 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1421 { REGSIZE*PT_CTR, "CTR" },
1422 { REGSIZE*PT_LNK, "LNK" },
1423 { REGSIZE*PT_XER, "XER" },
1424 { REGSIZE*PT_CCR, "CCR" },
1425 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001426# undef REGSIZE
1427#elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001428 { 0, "r0" },
1429 { 1, "r1" },
1430 { 2, "r2" },
1431 { 3, "r3" },
1432 { 4, "r4" },
1433 { 5, "r5" },
1434 { 6, "r6" },
1435 { 7, "r7" },
1436 { 8, "r8" },
1437 { 9, "r9" },
1438 { 10, "r10" },
1439 { 11, "r11" },
1440 { 12, "r12" },
1441 { 13, "r13" },
1442 { 14, "r14" },
1443 { 15, "r15" },
1444 { 16, "r16" },
1445 { 17, "r17" },
1446 { 18, "r18" },
1447 { 19, "r19" },
1448 { 20, "r20" },
1449 { 21, "r21" },
1450 { 22, "r22" },
1451 { 23, "r23" },
1452 { 24, "r24" },
1453 { 25, "r25" },
1454 { 26, "r26" },
1455 { 27, "r27" },
1456 { 28, "r28" },
1457 { 29, "gp" },
1458 { 30, "fp" },
1459 { 31, "zero" },
1460 { 32, "fp0" },
1461 { 33, "fp" },
1462 { 34, "fp2" },
1463 { 35, "fp3" },
1464 { 36, "fp4" },
1465 { 37, "fp5" },
1466 { 38, "fp6" },
1467 { 39, "fp7" },
1468 { 40, "fp8" },
1469 { 41, "fp9" },
1470 { 42, "fp10" },
1471 { 43, "fp11" },
1472 { 44, "fp12" },
1473 { 45, "fp13" },
1474 { 46, "fp14" },
1475 { 47, "fp15" },
1476 { 48, "fp16" },
1477 { 49, "fp17" },
1478 { 50, "fp18" },
1479 { 51, "fp19" },
1480 { 52, "fp20" },
1481 { 53, "fp21" },
1482 { 54, "fp22" },
1483 { 55, "fp23" },
1484 { 56, "fp24" },
1485 { 57, "fp25" },
1486 { 58, "fp26" },
1487 { 59, "fp27" },
1488 { 60, "fp28" },
1489 { 61, "fp29" },
1490 { 62, "fp30" },
1491 { 63, "fp31" },
1492 { 64, "pc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001493#elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001494 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1495 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1496 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1497 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1498 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1499 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1500 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1501 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1502 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1503 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1504 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1505 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1506 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1507 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1508 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1509 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1510 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1511 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1512 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1513 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1514 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1515 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1516 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1517 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1518 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1519 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1520 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1521 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1522 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1523 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1524 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1525 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1526 /* switch stack: */
1527 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1528 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1529 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1530 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1531 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1532 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1533 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1534 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1535 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1536 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001537 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1538 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001539 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001540 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001541 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1542 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001543 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1544 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1545 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1546 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1547 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1548 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1549 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1550 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1551 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1552 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1553 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1554 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1555 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1556 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1557 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001558# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001559 { PT_AR_CSD, "ar.csd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001560# endif
1561# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001562 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001563# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001564 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001565#elif defined(I386)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001566 { 4*EBX, "4*EBX" },
1567 { 4*ECX, "4*ECX" },
1568 { 4*EDX, "4*EDX" },
1569 { 4*ESI, "4*ESI" },
1570 { 4*EDI, "4*EDI" },
1571 { 4*EBP, "4*EBP" },
1572 { 4*EAX, "4*EAX" },
1573 { 4*DS, "4*DS" },
1574 { 4*ES, "4*ES" },
1575 { 4*FS, "4*FS" },
1576 { 4*GS, "4*GS" },
1577 { 4*ORIG_EAX, "4*ORIG_EAX" },
1578 { 4*EIP, "4*EIP" },
1579 { 4*CS, "4*CS" },
1580 { 4*EFL, "4*EFL" },
1581 { 4*UESP, "4*UESP" },
1582 { 4*SS, "4*SS" },
H.J. Lu35be5812012-04-16 13:00:01 +02001583#elif defined(X86_64) || defined(X32)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001584 { 8*R15, "8*R15" },
1585 { 8*R14, "8*R14" },
1586 { 8*R13, "8*R13" },
1587 { 8*R12, "8*R12" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001588 { 8*RBP, "8*RBP" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001589 { 8*RBX, "8*RBX" },
1590 { 8*R11, "8*R11" },
1591 { 8*R10, "8*R10" },
1592 { 8*R9, "8*R9" },
1593 { 8*R8, "8*R8" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001594 { 8*RAX, "8*RAX" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001595 { 8*RCX, "8*RCX" },
1596 { 8*RDX, "8*RDX" },
1597 { 8*RSI, "8*RSI" },
1598 { 8*RDI, "8*RDI" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001599 { 8*ORIG_RAX, "8*ORIG_RAX" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001600 { 8*RIP, "8*RIP" },
1601 { 8*CS, "8*CS" },
1602 { 8*EFLAGS, "8*EFL" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001603 { 8*RSP, "8*RSP" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001604 { 8*SS, "8*SS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001605#elif defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001606 { 4*PT_D1, "4*PT_D1" },
1607 { 4*PT_D2, "4*PT_D2" },
1608 { 4*PT_D3, "4*PT_D3" },
1609 { 4*PT_D4, "4*PT_D4" },
1610 { 4*PT_D5, "4*PT_D5" },
1611 { 4*PT_D6, "4*PT_D6" },
1612 { 4*PT_D7, "4*PT_D7" },
1613 { 4*PT_A0, "4*PT_A0" },
1614 { 4*PT_A1, "4*PT_A1" },
1615 { 4*PT_A2, "4*PT_A2" },
1616 { 4*PT_A3, "4*PT_A3" },
1617 { 4*PT_A4, "4*PT_A4" },
1618 { 4*PT_A5, "4*PT_A5" },
1619 { 4*PT_A6, "4*PT_A6" },
1620 { 4*PT_D0, "4*PT_D0" },
1621 { 4*PT_USP, "4*PT_USP" },
1622 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1623 { 4*PT_SR, "4*PT_SR" },
1624 { 4*PT_PC, "4*PT_PC" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001625#elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001626 { 4*REG_REG0, "4*REG_REG0" },
1627 { 4*(REG_REG0+1), "4*REG_REG1" },
1628 { 4*(REG_REG0+2), "4*REG_REG2" },
1629 { 4*(REG_REG0+3), "4*REG_REG3" },
1630 { 4*(REG_REG0+4), "4*REG_REG4" },
1631 { 4*(REG_REG0+5), "4*REG_REG5" },
1632 { 4*(REG_REG0+6), "4*REG_REG6" },
1633 { 4*(REG_REG0+7), "4*REG_REG7" },
1634 { 4*(REG_REG0+8), "4*REG_REG8" },
1635 { 4*(REG_REG0+9), "4*REG_REG9" },
1636 { 4*(REG_REG0+10), "4*REG_REG10" },
1637 { 4*(REG_REG0+11), "4*REG_REG11" },
1638 { 4*(REG_REG0+12), "4*REG_REG12" },
1639 { 4*(REG_REG0+13), "4*REG_REG13" },
1640 { 4*(REG_REG0+14), "4*REG_REG14" },
1641 { 4*REG_REG15, "4*REG_REG15" },
1642 { 4*REG_PC, "4*REG_PC" },
1643 { 4*REG_PR, "4*REG_PR" },
1644 { 4*REG_SR, "4*REG_SR" },
1645 { 4*REG_GBR, "4*REG_GBR" },
1646 { 4*REG_MACH, "4*REG_MACH" },
1647 { 4*REG_MACL, "4*REG_MACL" },
1648 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1649 { 4*REG_FPUL, "4*REG_FPUL" },
1650 { 4*REG_FPREG0, "4*REG_FPREG0" },
1651 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1652 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1653 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1654 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1655 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1656 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1657 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1658 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1659 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1660 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1661 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1662 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1663 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1664 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1665 { 4*REG_FPREG15, "4*REG_FPREG15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001666# ifdef REG_XDREG0
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001667 { 4*REG_XDREG0, "4*REG_XDREG0" },
1668 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1669 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1670 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1671 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1672 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1673 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1674 { 4*REG_XDREG14, "4*REG_XDREG14" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001675# endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001676 { 4*REG_FPSCR, "4*REG_FPSCR" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001677#elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001678 { 0, "PC(L)" },
1679 { 4, "PC(U)" },
1680 { 8, "SR(L)" },
1681 { 12, "SR(U)" },
1682 { 16, "syscall no.(L)" },
1683 { 20, "syscall_no.(U)" },
1684 { 24, "R0(L)" },
1685 { 28, "R0(U)" },
1686 { 32, "R1(L)" },
1687 { 36, "R1(U)" },
1688 { 40, "R2(L)" },
1689 { 44, "R2(U)" },
1690 { 48, "R3(L)" },
1691 { 52, "R3(U)" },
1692 { 56, "R4(L)" },
1693 { 60, "R4(U)" },
1694 { 64, "R5(L)" },
1695 { 68, "R5(U)" },
1696 { 72, "R6(L)" },
1697 { 76, "R6(U)" },
1698 { 80, "R7(L)" },
1699 { 84, "R7(U)" },
1700 { 88, "R8(L)" },
1701 { 92, "R8(U)" },
1702 { 96, "R9(L)" },
1703 { 100, "R9(U)" },
1704 { 104, "R10(L)" },
1705 { 108, "R10(U)" },
1706 { 112, "R11(L)" },
1707 { 116, "R11(U)" },
1708 { 120, "R12(L)" },
1709 { 124, "R12(U)" },
1710 { 128, "R13(L)" },
1711 { 132, "R13(U)" },
1712 { 136, "R14(L)" },
1713 { 140, "R14(U)" },
1714 { 144, "R15(L)" },
1715 { 148, "R15(U)" },
1716 { 152, "R16(L)" },
1717 { 156, "R16(U)" },
1718 { 160, "R17(L)" },
1719 { 164, "R17(U)" },
1720 { 168, "R18(L)" },
1721 { 172, "R18(U)" },
1722 { 176, "R19(L)" },
1723 { 180, "R19(U)" },
1724 { 184, "R20(L)" },
1725 { 188, "R20(U)" },
1726 { 192, "R21(L)" },
1727 { 196, "R21(U)" },
1728 { 200, "R22(L)" },
1729 { 204, "R22(U)" },
1730 { 208, "R23(L)" },
1731 { 212, "R23(U)" },
1732 { 216, "R24(L)" },
1733 { 220, "R24(U)" },
1734 { 224, "R25(L)" },
1735 { 228, "R25(U)" },
1736 { 232, "R26(L)" },
1737 { 236, "R26(U)" },
1738 { 240, "R27(L)" },
1739 { 244, "R27(U)" },
1740 { 248, "R28(L)" },
1741 { 252, "R28(U)" },
1742 { 256, "R29(L)" },
1743 { 260, "R29(U)" },
1744 { 264, "R30(L)" },
1745 { 268, "R30(U)" },
1746 { 272, "R31(L)" },
1747 { 276, "R31(U)" },
1748 { 280, "R32(L)" },
1749 { 284, "R32(U)" },
1750 { 288, "R33(L)" },
1751 { 292, "R33(U)" },
1752 { 296, "R34(L)" },
1753 { 300, "R34(U)" },
1754 { 304, "R35(L)" },
1755 { 308, "R35(U)" },
1756 { 312, "R36(L)" },
1757 { 316, "R36(U)" },
1758 { 320, "R37(L)" },
1759 { 324, "R37(U)" },
1760 { 328, "R38(L)" },
1761 { 332, "R38(U)" },
1762 { 336, "R39(L)" },
1763 { 340, "R39(U)" },
1764 { 344, "R40(L)" },
1765 { 348, "R40(U)" },
1766 { 352, "R41(L)" },
1767 { 356, "R41(U)" },
1768 { 360, "R42(L)" },
1769 { 364, "R42(U)" },
1770 { 368, "R43(L)" },
1771 { 372, "R43(U)" },
1772 { 376, "R44(L)" },
1773 { 380, "R44(U)" },
1774 { 384, "R45(L)" },
1775 { 388, "R45(U)" },
1776 { 392, "R46(L)" },
1777 { 396, "R46(U)" },
1778 { 400, "R47(L)" },
1779 { 404, "R47(U)" },
1780 { 408, "R48(L)" },
1781 { 412, "R48(U)" },
1782 { 416, "R49(L)" },
1783 { 420, "R49(U)" },
1784 { 424, "R50(L)" },
1785 { 428, "R50(U)" },
1786 { 432, "R51(L)" },
1787 { 436, "R51(U)" },
1788 { 440, "R52(L)" },
1789 { 444, "R52(U)" },
1790 { 448, "R53(L)" },
1791 { 452, "R53(U)" },
1792 { 456, "R54(L)" },
1793 { 460, "R54(U)" },
1794 { 464, "R55(L)" },
1795 { 468, "R55(U)" },
1796 { 472, "R56(L)" },
1797 { 476, "R56(U)" },
1798 { 480, "R57(L)" },
1799 { 484, "R57(U)" },
1800 { 488, "R58(L)" },
1801 { 492, "R58(U)" },
1802 { 496, "R59(L)" },
1803 { 500, "R59(U)" },
1804 { 504, "R60(L)" },
1805 { 508, "R60(U)" },
1806 { 512, "R61(L)" },
1807 { 516, "R61(U)" },
1808 { 520, "R62(L)" },
1809 { 524, "R62(U)" },
1810 { 528, "TR0(L)" },
1811 { 532, "TR0(U)" },
1812 { 536, "TR1(L)" },
1813 { 540, "TR1(U)" },
1814 { 544, "TR2(L)" },
1815 { 548, "TR2(U)" },
1816 { 552, "TR3(L)" },
1817 { 556, "TR3(U)" },
1818 { 560, "TR4(L)" },
1819 { 564, "TR4(U)" },
1820 { 568, "TR5(L)" },
1821 { 572, "TR5(U)" },
1822 { 576, "TR6(L)" },
1823 { 580, "TR6(U)" },
1824 { 584, "TR7(L)" },
1825 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00001826 /* This entry is in case pt_regs contains dregs (depends on
1827 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001828 { uoff(regs), "offsetof(struct user, regs)" },
1829 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001830#elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00001831 { uoff(regs.ARM_r0), "r0" },
1832 { uoff(regs.ARM_r1), "r1" },
1833 { uoff(regs.ARM_r2), "r2" },
1834 { uoff(regs.ARM_r3), "r3" },
1835 { uoff(regs.ARM_r4), "r4" },
1836 { uoff(regs.ARM_r5), "r5" },
1837 { uoff(regs.ARM_r6), "r6" },
1838 { uoff(regs.ARM_r7), "r7" },
1839 { uoff(regs.ARM_r8), "r8" },
1840 { uoff(regs.ARM_r9), "r9" },
1841 { uoff(regs.ARM_r10), "r10" },
1842 { uoff(regs.ARM_fp), "fp" },
1843 { uoff(regs.ARM_ip), "ip" },
1844 { uoff(regs.ARM_sp), "sp" },
1845 { uoff(regs.ARM_lr), "lr" },
1846 { uoff(regs.ARM_pc), "pc" },
1847 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001848#elif defined(AVR32)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001849 { uoff(regs.sr), "sr" },
1850 { uoff(regs.pc), "pc" },
1851 { uoff(regs.lr), "lr" },
1852 { uoff(regs.sp), "sp" },
1853 { uoff(regs.r12), "r12" },
1854 { uoff(regs.r11), "r11" },
1855 { uoff(regs.r10), "r10" },
1856 { uoff(regs.r9), "r9" },
1857 { uoff(regs.r8), "r8" },
1858 { uoff(regs.r7), "r7" },
1859 { uoff(regs.r6), "r6" },
1860 { uoff(regs.r5), "r5" },
1861 { uoff(regs.r4), "r4" },
1862 { uoff(regs.r3), "r3" },
1863 { uoff(regs.r2), "r2" },
1864 { uoff(regs.r1), "r1" },
1865 { uoff(regs.r0), "r0" },
1866 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001867#elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00001868 { 0, "r0" },
1869 { 1, "r1" },
1870 { 2, "r2" },
1871 { 3, "r3" },
1872 { 4, "r4" },
1873 { 5, "r5" },
1874 { 6, "r6" },
1875 { 7, "r7" },
1876 { 8, "r8" },
1877 { 9, "r9" },
1878 { 10, "r10" },
1879 { 11, "r11" },
1880 { 12, "r12" },
1881 { 13, "r13" },
1882 { 14, "r14" },
1883 { 15, "r15" },
1884 { 16, "r16" },
1885 { 17, "r17" },
1886 { 18, "r18" },
1887 { 19, "r19" },
1888 { 20, "r20" },
1889 { 21, "r21" },
1890 { 22, "r22" },
1891 { 23, "r23" },
1892 { 24, "r24" },
1893 { 25, "r25" },
1894 { 26, "r26" },
1895 { 27, "r27" },
1896 { 28, "r28" },
1897 { 29, "r29" },
1898 { 30, "r30" },
1899 { 31, "r31" },
1900 { 32, "f0" },
1901 { 33, "f1" },
1902 { 34, "f2" },
1903 { 35, "f3" },
1904 { 36, "f4" },
1905 { 37, "f5" },
1906 { 38, "f6" },
1907 { 39, "f7" },
1908 { 40, "f8" },
1909 { 41, "f9" },
1910 { 42, "f10" },
1911 { 43, "f11" },
1912 { 44, "f12" },
1913 { 45, "f13" },
1914 { 46, "f14" },
1915 { 47, "f15" },
1916 { 48, "f16" },
1917 { 49, "f17" },
1918 { 50, "f18" },
1919 { 51, "f19" },
1920 { 52, "f20" },
1921 { 53, "f21" },
1922 { 54, "f22" },
1923 { 55, "f23" },
1924 { 56, "f24" },
1925 { 57, "f25" },
1926 { 58, "f26" },
1927 { 59, "f27" },
1928 { 60, "f28" },
1929 { 61, "f29" },
1930 { 62, "f30" },
1931 { 63, "f31" },
1932 { 64, "pc" },
1933 { 65, "cause" },
1934 { 66, "badvaddr" },
1935 { 67, "mmhi" },
1936 { 68, "mmlo" },
1937 { 69, "fpcsr" },
1938 { 70, "fpeir" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001939#elif defined(TILE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05001940 { PTREGS_OFFSET_REG(0), "r0" },
1941 { PTREGS_OFFSET_REG(1), "r1" },
1942 { PTREGS_OFFSET_REG(2), "r2" },
1943 { PTREGS_OFFSET_REG(3), "r3" },
1944 { PTREGS_OFFSET_REG(4), "r4" },
1945 { PTREGS_OFFSET_REG(5), "r5" },
1946 { PTREGS_OFFSET_REG(6), "r6" },
1947 { PTREGS_OFFSET_REG(7), "r7" },
1948 { PTREGS_OFFSET_REG(8), "r8" },
1949 { PTREGS_OFFSET_REG(9), "r9" },
1950 { PTREGS_OFFSET_REG(10), "r10" },
1951 { PTREGS_OFFSET_REG(11), "r11" },
1952 { PTREGS_OFFSET_REG(12), "r12" },
1953 { PTREGS_OFFSET_REG(13), "r13" },
1954 { PTREGS_OFFSET_REG(14), "r14" },
1955 { PTREGS_OFFSET_REG(15), "r15" },
1956 { PTREGS_OFFSET_REG(16), "r16" },
1957 { PTREGS_OFFSET_REG(17), "r17" },
1958 { PTREGS_OFFSET_REG(18), "r18" },
1959 { PTREGS_OFFSET_REG(19), "r19" },
1960 { PTREGS_OFFSET_REG(20), "r20" },
1961 { PTREGS_OFFSET_REG(21), "r21" },
1962 { PTREGS_OFFSET_REG(22), "r22" },
1963 { PTREGS_OFFSET_REG(23), "r23" },
1964 { PTREGS_OFFSET_REG(24), "r24" },
1965 { PTREGS_OFFSET_REG(25), "r25" },
1966 { PTREGS_OFFSET_REG(26), "r26" },
1967 { PTREGS_OFFSET_REG(27), "r27" },
1968 { PTREGS_OFFSET_REG(28), "r28" },
1969 { PTREGS_OFFSET_REG(29), "r29" },
1970 { PTREGS_OFFSET_REG(30), "r30" },
1971 { PTREGS_OFFSET_REG(31), "r31" },
1972 { PTREGS_OFFSET_REG(32), "r32" },
1973 { PTREGS_OFFSET_REG(33), "r33" },
1974 { PTREGS_OFFSET_REG(34), "r34" },
1975 { PTREGS_OFFSET_REG(35), "r35" },
1976 { PTREGS_OFFSET_REG(36), "r36" },
1977 { PTREGS_OFFSET_REG(37), "r37" },
1978 { PTREGS_OFFSET_REG(38), "r38" },
1979 { PTREGS_OFFSET_REG(39), "r39" },
1980 { PTREGS_OFFSET_REG(40), "r40" },
1981 { PTREGS_OFFSET_REG(41), "r41" },
1982 { PTREGS_OFFSET_REG(42), "r42" },
1983 { PTREGS_OFFSET_REG(43), "r43" },
1984 { PTREGS_OFFSET_REG(44), "r44" },
1985 { PTREGS_OFFSET_REG(45), "r45" },
1986 { PTREGS_OFFSET_REG(46), "r46" },
1987 { PTREGS_OFFSET_REG(47), "r47" },
1988 { PTREGS_OFFSET_REG(48), "r48" },
1989 { PTREGS_OFFSET_REG(49), "r49" },
1990 { PTREGS_OFFSET_REG(50), "r50" },
1991 { PTREGS_OFFSET_REG(51), "r51" },
1992 { PTREGS_OFFSET_REG(52), "r52" },
1993 { PTREGS_OFFSET_TP, "tp" },
1994 { PTREGS_OFFSET_SP, "sp" },
1995 { PTREGS_OFFSET_LR, "lr" },
1996 { PTREGS_OFFSET_PC, "pc" },
1997 { PTREGS_OFFSET_EX1, "ex1" },
1998 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
1999 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2000 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002001#endif
2002#ifdef CRISV10
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002003 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2004 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2005 { 4*PT_R13, "4*PT_R13" },
2006 { 4*PT_R12, "4*PT_R12" },
2007 { 4*PT_R11, "4*PT_R11" },
2008 { 4*PT_R10, "4*PT_R10" },
2009 { 4*PT_R9, "4*PT_R9" },
2010 { 4*PT_R8, "4*PT_R8" },
2011 { 4*PT_R7, "4*PT_R7" },
2012 { 4*PT_R6, "4*PT_R6" },
2013 { 4*PT_R5, "4*PT_R5" },
2014 { 4*PT_R4, "4*PT_R4" },
2015 { 4*PT_R3, "4*PT_R3" },
2016 { 4*PT_R2, "4*PT_R2" },
2017 { 4*PT_R1, "4*PT_R1" },
2018 { 4*PT_R0, "4*PT_R0" },
2019 { 4*PT_MOF, "4*PT_MOF" },
2020 { 4*PT_DCCR, "4*PT_DCCR" },
2021 { 4*PT_SRP, "4*PT_SRP" },
2022 { 4*PT_IRP, "4*PT_IRP" },
2023 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2024 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2025 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2026 { 4*PT_USP, "4*PT_USP" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002027#endif
2028#ifdef CRISV32
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002029 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2030 { 4*PT_R0, "4*PT_R0" },
2031 { 4*PT_R1, "4*PT_R1" },
2032 { 4*PT_R2, "4*PT_R2" },
2033 { 4*PT_R3, "4*PT_R3" },
2034 { 4*PT_R4, "4*PT_R4" },
2035 { 4*PT_R5, "4*PT_R5" },
2036 { 4*PT_R6, "4*PT_R6" },
2037 { 4*PT_R7, "4*PT_R7" },
2038 { 4*PT_R8, "4*PT_R8" },
2039 { 4*PT_R9, "4*PT_R9" },
2040 { 4*PT_R10, "4*PT_R10" },
2041 { 4*PT_R11, "4*PT_R11" },
2042 { 4*PT_R12, "4*PT_R12" },
2043 { 4*PT_R13, "4*PT_R13" },
2044 { 4*PT_ACR, "4*PT_ACR" },
2045 { 4*PT_SRS, "4*PT_SRS" },
2046 { 4*PT_MOF, "4*PT_MOF" },
2047 { 4*PT_SPC, "4*PT_SPC" },
2048 { 4*PT_CCS, "4*PT_CCS" },
2049 { 4*PT_SRP, "4*PT_SRP" },
2050 { 4*PT_ERP, "4*PT_ERP" },
2051 { 4*PT_EXS, "4*PT_EXS" },
2052 { 4*PT_EDA, "4*PT_EDA" },
2053 { 4*PT_USP, "4*PT_USP" },
2054 { 4*PT_PPC, "4*PT_PPC" },
2055 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2056 { 4*PT_BP+4, "4*PT_BP+4" },
2057 { 4*PT_BP+8, "4*PT_BP+8" },
2058 { 4*PT_BP+12, "4*PT_BP+12" },
2059 { 4*PT_BP+16, "4*PT_BP+16" },
2060 { 4*PT_BP+20, "4*PT_BP+20" },
2061 { 4*PT_BP+24, "4*PT_BP+24" },
2062 { 4*PT_BP+28, "4*PT_BP+28" },
2063 { 4*PT_BP+32, "4*PT_BP+32" },
2064 { 4*PT_BP+36, "4*PT_BP+36" },
2065 { 4*PT_BP+40, "4*PT_BP+40" },
2066 { 4*PT_BP+44, "4*PT_BP+44" },
2067 { 4*PT_BP+48, "4*PT_BP+48" },
2068 { 4*PT_BP+52, "4*PT_BP+52" },
2069 { 4*PT_BP+56, "4*PT_BP+56" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002070#endif
2071#ifdef MICROBLAZE
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002072 { PT_GPR(0), "r0" },
2073 { PT_GPR(1), "r1" },
2074 { PT_GPR(2), "r2" },
2075 { PT_GPR(3), "r3" },
2076 { PT_GPR(4), "r4" },
2077 { PT_GPR(5), "r5" },
2078 { PT_GPR(6), "r6" },
2079 { PT_GPR(7), "r7" },
2080 { PT_GPR(8), "r8" },
2081 { PT_GPR(9), "r9" },
2082 { PT_GPR(10), "r10" },
2083 { PT_GPR(11), "r11" },
2084 { PT_GPR(12), "r12" },
2085 { PT_GPR(13), "r13" },
2086 { PT_GPR(14), "r14" },
2087 { PT_GPR(15), "r15" },
2088 { PT_GPR(16), "r16" },
2089 { PT_GPR(17), "r17" },
2090 { PT_GPR(18), "r18" },
2091 { PT_GPR(19), "r19" },
2092 { PT_GPR(20), "r20" },
2093 { PT_GPR(21), "r21" },
2094 { PT_GPR(22), "r22" },
2095 { PT_GPR(23), "r23" },
2096 { PT_GPR(24), "r24" },
2097 { PT_GPR(25), "r25" },
2098 { PT_GPR(26), "r26" },
2099 { PT_GPR(27), "r27" },
2100 { PT_GPR(28), "r28" },
2101 { PT_GPR(29), "r29" },
2102 { PT_GPR(30), "r30" },
2103 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002104 { PT_PC, "rpc", },
2105 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002106 { PT_EAR, "rear", },
2107 { PT_ESR, "resr", },
2108 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002109 { PT_KERNEL_MODE, "kernel_mode", },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002110#endif
Christian Svensson492f81f2013-02-14 13:26:27 +01002111#ifdef OR1K
2112 { 4*0, "r0" },
2113 { 4*1, "r1" },
2114 { 4*2, "r2" },
2115 { 4*3, "r3" },
2116 { 4*4, "r4" },
2117 { 4*5, "r5" },
2118 { 4*6, "r6" },
2119 { 4*7, "r7" },
2120 { 4*8, "r8" },
2121 { 4*9, "r9" },
2122 { 4*10, "r10" },
2123 { 4*11, "r11" },
2124 { 4*12, "r12" },
2125 { 4*13, "r13" },
2126 { 4*14, "r14" },
2127 { 4*15, "r15" },
2128 { 4*16, "r16" },
2129 { 4*17, "r17" },
2130 { 4*18, "r18" },
2131 { 4*19, "r19" },
2132 { 4*20, "r20" },
2133 { 4*21, "r21" },
2134 { 4*22, "r22" },
2135 { 4*23, "r23" },
2136 { 4*24, "r24" },
2137 { 4*25, "r25" },
2138 { 4*26, "r26" },
2139 { 4*27, "r27" },
2140 { 4*28, "r28" },
2141 { 4*29, "r29" },
2142 { 4*30, "r30" },
2143 { 4*31, "r31" },
2144 { 4*32, "pc" },
2145 { 4*33, "sr" },
2146#endif
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002147 /* Other fields in "struct user" */
2148#if defined(S390) || defined(S390X)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002149 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2150 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2151 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002152 { uoff(start_code), "offsetof(struct user, start_code)" },
2153 /* S390[X] has no start_data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002154 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2155 { uoff(signal), "offsetof(struct user, signal)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002156 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002157 { uoff(magic), "offsetof(struct user, magic)" },
2158 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002159 { sizeof(struct user), "sizeof(struct user)" },
2160#elif defined(POWERPC)
2161 { sizeof(struct user), "sizeof(struct user)" },
2162#elif defined(I386) || defined(X86_64) || defined(X32)
2163 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2164 { uoff(i387), "offsetof(struct user, i387)" },
2165 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2166 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2167 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2168 { uoff(start_code), "offsetof(struct user, start_code)" },
2169 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2170 { uoff(signal), "offsetof(struct user, signal)" },
2171 { uoff(reserved), "offsetof(struct user, reserved)" },
2172 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2173 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2174 { uoff(magic), "offsetof(struct user, magic)" },
2175 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002176 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002177 { sizeof(struct user), "sizeof(struct user)" },
2178#elif defined(IA64)
2179 { sizeof(struct user), "sizeof(struct user)" },
2180#elif defined(ARM)
2181 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2182 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2183 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2184 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2185 { uoff(start_code), "offsetof(struct user, start_code)" },
2186 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2187 { uoff(signal), "offsetof(struct user, signal)" },
2188 { uoff(reserved), "offsetof(struct user, reserved)" },
2189 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2190 { uoff(magic), "offsetof(struct user, magic)" },
2191 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2192 { sizeof(struct user), "sizeof(struct user)" },
2193#elif defined(AARCH64)
2194 /* nothing */
2195#elif defined(M68K)
2196 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2197 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2198 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2199 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2200 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2201 { uoff(start_code), "offsetof(struct user, start_code)" },
2202 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2203 { uoff(signal), "offsetof(struct user, signal)" },
2204 { uoff(reserved), "offsetof(struct user, reserved)" },
2205 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2206 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2207 { uoff(magic), "offsetof(struct user, magic)" },
2208 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2209 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002210#elif defined(MIPS) || defined(LINUX_MIPSN32)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002211 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2212 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2213 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2214 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002215 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002216 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2217 { uoff(signal), "offsetof(struct user, signal)" },
2218 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2219 { uoff(magic), "offsetof(struct user, magic)" },
2220 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2221 { sizeof(struct user), "sizeof(struct user)" },
2222#elif defined(ALPHA)
2223 { sizeof(struct user), "sizeof(struct user)" },
2224#elif defined(SPARC)
2225 { sizeof(struct user), "sizeof(struct user)" },
2226#elif defined(SPARC64)
2227 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2228 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2229 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2230 { uoff(signal), "offsetof(struct user, signal)" },
2231 { uoff(magic), "offsetof(struct user, magic)" },
2232 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2233 { sizeof(struct user), "sizeof(struct user)" },
2234#elif defined(HPPA)
2235 /* nothing */
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002236#elif defined(SH) || defined(SH64)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002237 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2238 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2239 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2240 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2241 { uoff(start_code), "offsetof(struct user, start_code)" },
2242 { uoff(start_data), "offsetof(struct user, start_data)" },
2243 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2244 { uoff(signal), "offsetof(struct user, signal)" },
2245 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2246 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2247 { uoff(magic), "offsetof(struct user, magic)" },
2248 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2249 { sizeof(struct user), "sizeof(struct user)" },
2250#elif defined(CRISV10) || defined(CRISV32)
2251 { sizeof(struct user), "sizeof(struct user)" },
2252#elif defined(TILE)
2253 /* nothing */
2254#elif defined(MICROBLAZE)
2255 { sizeof(struct user), "sizeof(struct user)" },
2256#elif defined(AVR32)
2257 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2258 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2259 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2260 { uoff(start_code), "offsetof(struct user, start_code)" },
2261 { uoff(start_data), "offsetof(struct user, start_data)" },
2262 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2263 { uoff(signal), "offsetof(struct user, signal)" },
2264 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2265 { uoff(magic), "offsetof(struct user, magic)" },
2266 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2267 { sizeof(struct user), "sizeof(struct user)" },
2268#elif defined(BFIN)
2269 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2270 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2271 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2272 { uoff(start_code), "offsetof(struct user, start_code)" },
2273 { uoff(signal), "offsetof(struct user, signal)" },
2274 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2275 { uoff(magic), "offsetof(struct user, magic)" },
2276 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002277 { sizeof(struct user), "sizeof(struct user)" },
Christian Svensson492f81f2013-02-14 13:26:27 +01002278#elif defined(OR1K)
2279 /* nothing */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002280#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002281 { 0, NULL },
2282};
2283
2284int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002285sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002286{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002287 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002288 long addr;
2289
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002290 if (entering(tcp)) {
Denys Vlasenkob7a6dae2012-03-20 16:48:35 +01002291 printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
Roland McGrathbf621d42003-01-14 09:46:21 +00002292 tprintf(", %lu, ", tcp->u_arg[1]);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002293
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002294 addr = tcp->u_arg[2];
2295 if (tcp->u_arg[0] == PTRACE_PEEKUSER
Denys Vlasenkobe994972013-02-13 16:10:10 +01002296 || tcp->u_arg[0] == PTRACE_POKEUSER
2297 ) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002298 for (x = struct_user_offsets; x->str; x++) {
2299 if (x->val >= addr)
2300 break;
2301 }
2302 if (!x->str)
2303 tprintf("%#lx, ", addr);
2304 else if (x->val > addr && x != struct_user_offsets) {
2305 x--;
2306 tprintf("%s + %ld, ", x->str, addr - x->val);
2307 }
2308 else
2309 tprintf("%s, ", x->str);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002310 } else
2311#ifdef PTRACE_GETREGSET
2312 //if (tcp->u_arg[0] == PTRACE_GET/SETREGSET) {
2313 // TODO: show tcp->u_arg[2] as "NT_xxx, "
2314 //} else
2315#endif
2316 tprintf("%#lx, ", addr);
2317
2318
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002319 switch (tcp->u_arg[0]) {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002320#ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002321 case PTRACE_PEEKDATA:
2322 case PTRACE_PEEKTEXT:
2323 case PTRACE_PEEKUSER:
2324 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002325#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002326 case PTRACE_CONT:
2327 case PTRACE_SINGLESTEP:
2328 case PTRACE_SYSCALL:
2329 case PTRACE_DETACH:
2330 printsignal(tcp->u_arg[3]);
2331 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002332#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002333 case PTRACE_SETOPTIONS:
2334 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2335 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002336#endif
2337#ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002338 case PTRACE_SETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002339 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002340 break;
2341 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002342#endif
2343#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002344 case PTRACE_GETSIGINFO:
2345 /* Don't print anything, do it at syscall return. */
2346 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002347#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002348#ifdef PTRACE_GETREGSET
2349 case PTRACE_GETREGSET:
2350 break;
2351 case PTRACE_SETREGSET:
2352 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2353 break;
2354#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002355 default:
2356 tprintf("%#lx", tcp->u_arg[3]);
2357 break;
2358 }
2359 } else {
2360 switch (tcp->u_arg[0]) {
2361 case PTRACE_PEEKDATA:
2362 case PTRACE_PEEKTEXT:
2363 case PTRACE_PEEKUSER:
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002364#ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002365 return RVAL_HEX;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002366#else
Roland McGratheb285352003-01-14 09:59:00 +00002367 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002368 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002369#endif
2370#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002371 case PTRACE_GETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002372 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002373 break;
2374 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002375#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002376#ifdef PTRACE_GETREGSET
2377 case PTRACE_GETREGSET:
2378 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2379 break;
2380#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002381 }
2382 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002383 return 0;
2384}
2385
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002386#ifndef FUTEX_CMP_REQUEUE
2387# define FUTEX_CMP_REQUEUE 4
2388#endif
2389#ifndef FUTEX_WAKE_OP
2390# define FUTEX_WAKE_OP 5
2391#endif
2392#ifndef FUTEX_LOCK_PI
2393# define FUTEX_LOCK_PI 6
2394# define FUTEX_UNLOCK_PI 7
2395# define FUTEX_TRYLOCK_PI 8
2396#endif
2397#ifndef FUTEX_WAIT_BITSET
2398# define FUTEX_WAIT_BITSET 9
2399#endif
2400#ifndef FUTEX_WAKE_BITSET
2401# define FUTEX_WAKE_BITSET 10
2402#endif
2403#ifndef FUTEX_WAIT_REQUEUE_PI
2404# define FUTEX_WAIT_REQUEUE_PI 11
2405#endif
2406#ifndef FUTEX_CMP_REQUEUE_PI
2407# define FUTEX_CMP_REQUEUE_PI 12
2408#endif
2409#ifndef FUTEX_PRIVATE_FLAG
2410# define FUTEX_PRIVATE_FLAG 128
2411#endif
2412#ifndef FUTEX_CLOCK_REALTIME
2413# define FUTEX_CLOCK_REALTIME 256
2414#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002415static const struct xlat futexops[] = {
Roland McGrath51942a92007-07-05 18:59:11 +00002416 { FUTEX_WAIT, "FUTEX_WAIT" },
2417 { FUTEX_WAKE, "FUTEX_WAKE" },
2418 { FUTEX_FD, "FUTEX_FD" },
2419 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2420 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2421 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2422 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2423 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2424 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002425 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2426 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002427 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2428 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
Roland McGrath51942a92007-07-05 18:59:11 +00002429 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2430 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2431 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2432 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2433 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2434 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2435 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2436 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2437 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002438 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2439 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002440 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2441 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2442 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2443 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2444 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2445 { 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 +00002446 { 0, NULL }
2447};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002448#ifndef FUTEX_OP_SET
2449# define FUTEX_OP_SET 0
2450# define FUTEX_OP_ADD 1
2451# define FUTEX_OP_OR 2
2452# define FUTEX_OP_ANDN 3
2453# define FUTEX_OP_XOR 4
2454# define FUTEX_OP_CMP_EQ 0
2455# define FUTEX_OP_CMP_NE 1
2456# define FUTEX_OP_CMP_LT 2
2457# define FUTEX_OP_CMP_LE 3
2458# define FUTEX_OP_CMP_GT 4
2459# define FUTEX_OP_CMP_GE 5
2460#endif
Roland McGrath51942a92007-07-05 18:59:11 +00002461static const struct xlat futexwakeops[] = {
2462 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2463 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2464 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2465 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2466 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2467 { 0, NULL }
2468};
2469static const struct xlat futexwakecmps[] = {
2470 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2471 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2472 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2473 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2474 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2475 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2476 { 0, NULL }
Roland McGrath5a223472002-12-15 23:58:26 +00002477};
2478
2479int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002480sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002481{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002482 if (entering(tcp)) {
2483 long int cmd = tcp->u_arg[1] & 127;
2484 tprintf("%p, ", (void *) tcp->u_arg[0]);
2485 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2486 tprintf(", %ld", tcp->u_arg[2]);
2487 if (cmd == FUTEX_WAKE_BITSET)
2488 tprintf(", %lx", tcp->u_arg[5]);
2489 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002490 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002491 printtv(tcp, tcp->u_arg[3]);
2492 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002493 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002494 printtv(tcp, tcp->u_arg[3]);
2495 tprintf(", %lx", tcp->u_arg[5]);
2496 } else if (cmd == FUTEX_REQUEUE)
2497 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002498 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002499 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2500 else if (cmd == FUTEX_WAKE_OP) {
2501 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2502 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002503 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002504 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2505 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2506 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002507 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002508 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2509 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002510 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002511 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002512 printtv(tcp, tcp->u_arg[3]);
2513 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002514 }
Roland McGrath51942a92007-07-05 18:59:11 +00002515 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002516 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002517}
2518
2519static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002520print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002521{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002522 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002523 unsigned long w, min_len;
2524
2525 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2526 min_len = len - max_strlen * sizeof(w);
2527 else
2528 min_len = 0;
2529 for (; len >= sizeof(w) && len > min_len;
2530 len -= sizeof(w), list += sizeof(w)) {
2531 if (umove(tcp, list, &w) < 0)
2532 break;
2533 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002534 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002535 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002536 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002537 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002538 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002539 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002540 if (len) {
2541 if (first)
2542 tprintf("%#lx", list);
2543 else
2544 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2545 "???" : "..."));
2546 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002547 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002548 }
Roland McGrath5a223472002-12-15 23:58:26 +00002549}
2550
2551int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002552sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002553{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002554 if (entering(tcp)) {
2555 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2556 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2557 }
2558 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002559}
2560
2561int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002562sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002563{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002564 if (entering(tcp)) {
2565 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2566 } else {
2567 if (tcp->u_rval == -1)
2568 tprintf("%#lx", tcp->u_arg[2]);
2569 else
2570 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2571 }
2572 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002573}
Roland McGrath279d3782004-03-01 20:27:37 +00002574
Dmitry V. Levin1b0bae22012-03-11 22:32:26 +00002575int
2576sys_get_robust_list(struct tcb *tcp)
2577{
2578 if (entering(tcp)) {
2579 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2580 } else {
2581 void *addr;
2582 size_t len;
2583
2584 if (syserror(tcp) ||
2585 !tcp->u_arg[1] ||
2586 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2587 tprintf("%#lx, ", tcp->u_arg[1]);
2588 } else {
2589 tprintf("[%p], ", addr);
2590 }
2591
2592 if (syserror(tcp) ||
2593 !tcp->u_arg[2] ||
2594 umove(tcp, tcp->u_arg[2], &len) < 0) {
2595 tprintf("%#lx", tcp->u_arg[2]);
2596 } else {
2597 tprintf("[%lu]", (unsigned long) len);
2598 }
2599 }
2600 return 0;
2601}
2602
Roland McGrathd9f816f2004-09-04 03:39:20 +00002603static const struct xlat schedulers[] = {
Roland McGrath279d3782004-03-01 20:27:37 +00002604 { SCHED_OTHER, "SCHED_OTHER" },
2605 { SCHED_RR, "SCHED_RR" },
2606 { SCHED_FIFO, "SCHED_FIFO" },
2607 { 0, NULL }
2608};
2609
2610int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002611sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002612{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002613 if (entering(tcp)) {
2614 tprintf("%d", (int) tcp->u_arg[0]);
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002615 } else if (!syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002616 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002617 if (tcp->auxstr != NULL)
2618 return RVAL_STR;
2619 }
2620 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002621}
2622
2623int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002624sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002625{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002626 if (entering(tcp)) {
2627 struct sched_param p;
2628 tprintf("%d, ", (int) tcp->u_arg[0]);
2629 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2630 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2631 tprintf(", %#lx", tcp->u_arg[2]);
2632 else
2633 tprintf(", { %d }", p.__sched_priority);
2634 }
2635 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002636}
2637
2638int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002639sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002640{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002641 if (entering(tcp)) {
2642 tprintf("%d, ", (int) tcp->u_arg[0]);
2643 } else {
2644 struct sched_param p;
2645 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2646 tprintf("%#lx", tcp->u_arg[1]);
2647 else
2648 tprintf("{ %d }", p.__sched_priority);
2649 }
2650 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002651}
2652
2653int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002654sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002655{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002656 if (entering(tcp)) {
2657 struct sched_param p;
2658 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2659 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2660 else
2661 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2662 }
2663 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002664}
2665
2666int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002667sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002668{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002669 if (entering(tcp)) {
2670 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2671 }
2672 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002673}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002674
Dmitry V. Levin1ff463d2012-03-11 23:00:11 +00002675int
2676sys_sched_rr_get_interval(struct tcb *tcp)
2677{
2678 if (entering(tcp)) {
2679 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2680 } else {
2681 if (syserror(tcp))
2682 tprintf("%#lx", tcp->u_arg[1]);
2683 else
2684 print_timespec(tcp, tcp->u_arg[1]);
2685 }
2686 return 0;
2687}
2688
H.J. Lu35be5812012-04-16 13:00:01 +02002689#if defined X86_64 || defined X32
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002690# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002691
2692static const struct xlat archvals[] = {
2693 { ARCH_SET_GS, "ARCH_SET_GS" },
2694 { ARCH_SET_FS, "ARCH_SET_FS" },
2695 { ARCH_GET_FS, "ARCH_GET_FS" },
2696 { ARCH_GET_GS, "ARCH_GET_GS" },
2697 { 0, NULL },
2698};
2699
2700int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002701sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002702{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002703 if (entering(tcp)) {
2704 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2705 if (tcp->u_arg[0] == ARCH_SET_GS
2706 || tcp->u_arg[0] == ARCH_SET_FS
2707 ) {
2708 tprintf(", %#lx", tcp->u_arg[1]);
2709 }
2710 } else {
2711 if (tcp->u_arg[0] == ARCH_GET_GS
2712 || tcp->u_arg[0] == ARCH_GET_FS
2713 ) {
2714 long int v;
2715 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2716 tprintf(", [%#lx]", v);
2717 else
2718 tprintf(", %#lx", tcp->u_arg[1]);
2719 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002720 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002721 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002722}
H.J. Lu35be5812012-04-16 13:00:01 +02002723#endif /* X86_64 || X32 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002724
Roland McGrathdb8319f2007-08-02 01:37:55 +00002725int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002726sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002727{
2728 if (exiting(tcp)) {
2729 unsigned u;
2730 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002731 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002732 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2733 tprintf("%#lx, ", tcp->u_arg[0]);
2734 else
2735 tprintf("[%u], ", u);
2736 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002737 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002738 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2739 tprintf("%#lx, ", tcp->u_arg[1]);
2740 else
2741 tprintf("[%u], ", u);
2742 tprintf("%#lx", tcp->u_arg[2]);
2743 }
2744 return 0;
2745}
2746
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002747int
2748sys_process_vm_readv(struct tcb *tcp)
2749{
2750 if (entering(tcp)) {
2751 /* arg 1: pid */
2752 tprintf("%ld, ", tcp->u_arg[0]);
2753 } else {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002754 /* arg 2: local iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002755 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002756 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002757 } else {
2758 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2759 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002760 /* arg 3: local iovcnt */
2761 tprintf(", %lu, ", tcp->u_arg[2]);
2762 /* arg 4: remote iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002763 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002764 tprintf("%#lx", tcp->u_arg[3]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002765 } else {
2766 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2767 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002768 /* arg 5: remote iovcnt */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002769 /* arg 6: flags */
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002770 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002771 }
2772 return 0;
2773}
Dmitry V. Levin03952102012-03-10 14:14:49 +00002774
2775int
2776sys_process_vm_writev(struct tcb *tcp)
2777{
2778 if (entering(tcp)) {
2779 /* arg 1: pid */
2780 tprintf("%ld, ", tcp->u_arg[0]);
2781 /* arg 2: local iov */
2782 if (syserror(tcp))
2783 tprintf("%#lx", tcp->u_arg[1]);
2784 else
2785 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2786 /* arg 3: local iovcnt */
2787 tprintf(", %lu, ", tcp->u_arg[2]);
2788 /* arg 4: remote iov */
2789 if (syserror(tcp))
2790 tprintf("%#lx", tcp->u_arg[3]);
2791 else
2792 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2793 /* arg 5: remote iovcnt */
2794 /* arg 6: flags */
2795 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
2796 }
2797 return 0;
2798}