blob: e4d491a2e29b8ecfd7fc24187994d41a49441768 [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:
305 for (i = 1; i < tcp->u_nargs; i++)
306 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
Chris Metcalf0b99a8a2013-02-05 17:48:33 +0100468#elif defined X86_64 || defined X32 || defined ALPHA || defined TILE
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100469# define ARG_FLAGS 0
470# define ARG_STACK 1
471# define ARG_PTID 2
472# define ARG_CTID 3
473# define ARG_TLS 4
474#else
475# define ARG_FLAGS 0
476# define ARG_STACK 1
477# define ARG_PTID 2
478# define ARG_TLS 3
479# define ARG_CTID 4
480#endif
Roland McGrath9677b3a2003-03-12 09:54:36 +0000481
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000482int
Denys Vlasenko12014262011-05-30 14:00:14 +0200483sys_clone(struct tcb *tcp)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000484{
485 if (exiting(tcp)) {
Wang Chaocbdd1902010-09-02 15:08:59 +0800486 const char *sep = "|";
Roland McGrath9677b3a2003-03-12 09:54:36 +0000487 unsigned long flags = tcp->u_arg[ARG_FLAGS];
488 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100489#ifdef ARG_STACKSIZE
Roland McGrath9677b3a2003-03-12 09:54:36 +0000490 if (ARG_STACKSIZE != -1)
491 tprintf("stack_size=%#lx, ",
492 tcp->u_arg[ARG_STACKSIZE]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100493#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200494 tprints("flags=");
Wang Chaocbdd1902010-09-02 15:08:59 +0800495 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
496 sep = "";
Roland McGrath984154d2003-05-23 01:08:42 +0000497 if ((flags & CSIGNAL) != 0)
Wang Chaocbdd1902010-09-02 15:08:59 +0800498 tprintf("%s%s", sep, signame(flags & CSIGNAL));
Roland McGrathb4968be2003-01-20 09:04:33 +0000499 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
Roland McGrath9677b3a2003-03-12 09:54:36 +0000500 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
Roland McGrath909875b2002-12-22 03:34:36 +0000501 return 0;
Roland McGrath6f67a982003-03-21 07:33:15 +0000502 if (flags & CLONE_PARENT_SETTID)
503 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000504 if (flags & CLONE_SETTLS) {
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100505#ifdef I386
Roland McGrath909875b2002-12-22 03:34:36 +0000506 struct modify_ldt_ldt_s copy;
Roland McGrath9677b3a2003-03-12 09:54:36 +0000507 if (umove(tcp, tcp->u_arg[ARG_TLS], &copy) != -1) {
Roland McGrath909875b2002-12-22 03:34:36 +0000508 tprintf(", {entry_number:%d, ",
509 copy.entry_number);
510 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200511 tprints("...}");
Roland McGrath909875b2002-12-22 03:34:36 +0000512 else
513 print_ldt_entry(&copy);
514 }
515 else
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100516#endif
Roland McGrath43f2c842003-03-12 09:58:14 +0000517 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
Roland McGrath909875b2002-12-22 03:34:36 +0000518 }
Roland McGrath9677b3a2003-03-12 09:54:36 +0000519 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
520 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000521 }
522 return 0;
523}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000524
525int
526sys_unshare(struct tcb *tcp)
527{
528 if (entering(tcp))
529 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
530 return 0;
531}
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000532
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000533int
Denys Vlasenko081533c2012-03-17 02:17:51 +0100534sys_fork(struct tcb *tcp)
535{
536 if (exiting(tcp))
537 return RVAL_UDECIMAL;
538 return 0;
539}
540
541int
Denys Vlasenko12014262011-05-30 14:00:14 +0200542sys_vfork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000543{
544 if (exiting(tcp))
545 return RVAL_UDECIMAL;
546 return 0;
547}
548
Dmitry V. Levin50a218d2011-01-18 17:36:20 +0000549int sys_getuid(struct tcb *tcp)
550{
551 if (exiting(tcp))
552 tcp->u_rval = (uid_t) tcp->u_rval;
553 return RVAL_UDECIMAL;
554}
555
556int sys_setfsuid(struct tcb *tcp)
557{
558 if (entering(tcp))
559 tprintf("%u", (uid_t) tcp->u_arg[0]);
560 else
561 tcp->u_rval = (uid_t) tcp->u_rval;
562 return RVAL_UDECIMAL;
563}
564
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000565int
Denys Vlasenko12014262011-05-30 14:00:14 +0200566sys_setuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000567{
568 if (entering(tcp)) {
569 tprintf("%u", (uid_t) tcp->u_arg[0]);
570 }
571 return 0;
572}
573
574int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000575sys_getresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000576{
577 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000578 __kernel_uid_t uid;
579 if (syserror(tcp))
580 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
581 tcp->u_arg[1], tcp->u_arg[2]);
582 else {
583 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
584 tprintf("%#lx, ", tcp->u_arg[0]);
585 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000586 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000587 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
588 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000589 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000590 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000591 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
592 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000593 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000594 tprintf("[%lu]", (unsigned long) uid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000595 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000596 }
597 return 0;
598}
599
600int
Denys Vlasenko12014262011-05-30 14:00:14 +0200601sys_setreuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000602{
603 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000604 printuid("", tcp->u_arg[0]);
605 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000606 }
607 return 0;
608}
609
610int
Denys Vlasenko12014262011-05-30 14:00:14 +0200611sys_setresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000612{
613 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000614 printuid("", tcp->u_arg[0]);
615 printuid(", ", tcp->u_arg[1]);
616 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000617 }
618 return 0;
619}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000620
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000621int
Denys Vlasenko12014262011-05-30 14:00:14 +0200622sys_setgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000623{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000624 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000625 unsigned long len, size, start, cur, end, abbrev_end;
626 GETGROUPS_T gid;
627 int failed = 0;
628
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000629 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000630 tprintf("%lu, ", len);
631 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200632 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000633 return 0;
634 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000635 start = tcp->u_arg[1];
636 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200637 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000638 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000639 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000640 size = len * sizeof(gid);
641 end = start + size;
642 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
643 tprintf("%#lx", start);
644 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000645 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000646 if (abbrev(tcp)) {
647 abbrev_end = start + max_strlen * sizeof(gid);
648 if (abbrev_end < start)
649 abbrev_end = end;
650 } else {
651 abbrev_end = end;
652 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200653 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000654 for (cur = start; cur < end; cur += sizeof(gid)) {
655 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200656 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000657 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200658 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000659 break;
660 }
661 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200662 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000663 failed = 1;
664 break;
665 }
666 tprintf("%lu", (unsigned long) gid);
667 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200668 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000669 if (failed)
670 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000671 }
672 return 0;
673}
674
675int
Denys Vlasenko12014262011-05-30 14:00:14 +0200676sys_getgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000677{
Roland McGrathaa524c82005-06-01 19:22:06 +0000678 unsigned long len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000679
680 if (entering(tcp)) {
681 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000682 tprintf("%lu, ", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000683 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000684 unsigned long size, start, cur, end, abbrev_end;
685 GETGROUPS_T gid;
686 int failed = 0;
687
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000688 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000689 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200690 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000691 return 0;
692 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000693 start = tcp->u_arg[1];
694 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200695 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000696 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000697 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000698 if (tcp->u_arg[0] == 0) {
699 tprintf("%#lx", start);
700 return 0;
701 }
702 size = len * sizeof(gid);
703 end = start + size;
704 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
705 size / sizeof(gid) != len || end < start) {
706 tprintf("%#lx", start);
707 return 0;
708 }
709 if (abbrev(tcp)) {
710 abbrev_end = start + max_strlen * sizeof(gid);
711 if (abbrev_end < start)
712 abbrev_end = end;
713 } else {
714 abbrev_end = end;
715 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200716 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000717 for (cur = start; cur < end; cur += sizeof(gid)) {
718 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200719 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000720 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200721 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000722 break;
723 }
724 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200725 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000726 failed = 1;
727 break;
728 }
729 tprintf("%lu", (unsigned long) gid);
730 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200731 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000732 if (failed)
733 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000734 }
735 return 0;
736}
737
Roland McGrath83bd47a2003-11-13 22:32:26 +0000738int
Denys Vlasenko12014262011-05-30 14:00:14 +0200739sys_setgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000740{
Roland McGrath83bd47a2003-11-13 22:32:26 +0000741 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000742 unsigned long len, size, start, cur, end, abbrev_end;
743 GETGROUPS32_T gid;
744 int failed = 0;
745
Roland McGrath83bd47a2003-11-13 22:32:26 +0000746 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000747 tprintf("%lu, ", len);
748 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200749 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000750 return 0;
751 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000752 start = tcp->u_arg[1];
753 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200754 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000755 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000756 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000757 size = len * sizeof(gid);
758 end = start + size;
759 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
760 tprintf("%#lx", start);
761 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000762 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000763 if (abbrev(tcp)) {
764 abbrev_end = start + max_strlen * sizeof(gid);
765 if (abbrev_end < start)
766 abbrev_end = end;
767 } else {
768 abbrev_end = end;
769 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200770 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000771 for (cur = start; cur < end; cur += sizeof(gid)) {
772 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200773 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000774 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200775 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000776 break;
777 }
778 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200779 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000780 failed = 1;
781 break;
782 }
783 tprintf("%lu", (unsigned long) gid);
784 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200785 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000786 if (failed)
787 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000788 }
789 return 0;
790}
791
792int
Denys Vlasenko12014262011-05-30 14:00:14 +0200793sys_getgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000794{
Roland McGrathaa524c82005-06-01 19:22:06 +0000795 unsigned long len;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000796
797 if (entering(tcp)) {
798 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000799 tprintf("%lu, ", len);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000800 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000801 unsigned long size, start, cur, end, abbrev_end;
802 GETGROUPS32_T gid;
803 int failed = 0;
804
Roland McGrath83bd47a2003-11-13 22:32:26 +0000805 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000806 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200807 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000808 return 0;
809 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000810 start = tcp->u_arg[1];
811 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200812 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000813 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000814 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000815 size = len * sizeof(gid);
816 end = start + size;
817 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
818 size / sizeof(gid) != len || end < start) {
819 tprintf("%#lx", start);
820 return 0;
821 }
822 if (abbrev(tcp)) {
823 abbrev_end = start + max_strlen * sizeof(gid);
824 if (abbrev_end < start)
825 abbrev_end = end;
826 } else {
827 abbrev_end = end;
828 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200829 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000830 for (cur = start; cur < end; cur += sizeof(gid)) {
831 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200832 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000833 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200834 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000835 break;
836 }
837 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200838 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000839 failed = 1;
840 break;
841 }
842 tprintf("%lu", (unsigned long) gid);
843 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200844 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000845 if (failed)
846 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000847 }
848 return 0;
849}
Roland McGrath83bd47a2003-11-13 22:32:26 +0000850
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000851static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000852printargv(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000853{
Roland McGrath85a3bc42007-08-02 02:13:05 +0000854 union {
Andreas Schwab99c85692009-08-28 19:36:20 +0200855 unsigned int p32;
856 unsigned long p64;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000857 char data[sizeof(long)];
858 } cp;
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000859 const char *sep;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000860 int n = 0;
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100861 unsigned wordsize = current_wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000862
Roland McGrath85a3bc42007-08-02 02:13:05 +0000863 cp.p64 = 1;
864 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100865 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000866 tprintf("%#lx", addr);
867 return;
868 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100869 if (wordsize == 4)
Roland McGrath85a3bc42007-08-02 02:13:05 +0000870 cp.p64 = cp.p32;
871 if (cp.p64 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000872 break;
Denys Vlasenko5940e652011-09-01 09:55:05 +0200873 tprints(sep);
Roland McGrath85a3bc42007-08-02 02:13:05 +0000874 printstr(tcp, cp.p64, -1);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100875 addr += wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000876 }
Roland McGrath85a3bc42007-08-02 02:13:05 +0000877 if (cp.p64)
878 tprintf("%s...", sep);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000879}
880
881static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000882printargc(const char *fmt, struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000883{
884 int count;
885 char *cp;
886
887 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
888 addr += sizeof(char *);
889 }
890 tprintf(fmt, count, count == 1 ? "" : "s");
891}
892
Denys Vlasenko84703742012-02-25 02:38:52 +0100893#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000894int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000895sys_execv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000896{
897 if (entering(tcp)) {
898 printpath(tcp, tcp->u_arg[0]);
899 if (!verbose(tcp))
900 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000901 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200902 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000903 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200904 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000905 }
906 }
907 return 0;
908}
Denys Vlasenko84703742012-02-25 02:38:52 +0100909#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000910
911int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000912sys_execve(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000913{
914 if (entering(tcp)) {
915 printpath(tcp, tcp->u_arg[0]);
916 if (!verbose(tcp))
917 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000918 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200919 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000920 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200921 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000922 }
923 if (!verbose(tcp))
924 tprintf(", %#lx", tcp->u_arg[2]);
925 else if (abbrev(tcp))
926 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
927 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200928 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000929 printargv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200930 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000931 }
932 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000933 return 0;
934}
935
Roland McGrath7ec1d352002-12-17 04:50:44 +0000936#ifndef __WNOTHREAD
937#define __WNOTHREAD 0x20000000
938#endif
939#ifndef __WALL
940#define __WALL 0x40000000
941#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000942#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +0000943#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000944#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000945
Roland McGrathd9f816f2004-09-04 03:39:20 +0000946static const struct xlat wait4_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000947 { WNOHANG, "WNOHANG" },
948#ifndef WSTOPPED
949 { WUNTRACED, "WUNTRACED" },
950#endif
951#ifdef WEXITED
952 { WEXITED, "WEXITED" },
953#endif
954#ifdef WTRAPPED
955 { WTRAPPED, "WTRAPPED" },
956#endif
957#ifdef WSTOPPED
958 { WSTOPPED, "WSTOPPED" },
959#endif
960#ifdef WCONTINUED
961 { WCONTINUED, "WCONTINUED" },
962#endif
963#ifdef WNOWAIT
964 { WNOWAIT, "WNOWAIT" },
965#endif
966#ifdef __WCLONE
967 { __WCLONE, "__WCLONE" },
968#endif
Roland McGrath7ec1d352002-12-17 04:50:44 +0000969#ifdef __WALL
970 { __WALL, "__WALL" },
971#endif
972#ifdef __WNOTHREAD
973 { __WNOTHREAD, "__WNOTHREAD" },
974#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000975 { 0, NULL },
976};
977
Roland McGrath5e02a572004-10-19 23:33:47 +0000978#if !defined WCOREFLAG && defined WCOREFLG
979# define WCOREFLAG WCOREFLG
980#endif
981#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000982# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +0000983#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000984#ifndef WCOREDUMP
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100985# define WCOREDUMP(status) ((status) & 0200)
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000986#endif
Roland McGrath5e02a572004-10-19 23:33:47 +0000987#ifndef W_STOPCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100988# define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
Roland McGrath5e02a572004-10-19 23:33:47 +0000989#endif
990#ifndef W_EXITCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100991# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
Roland McGrath5e02a572004-10-19 23:33:47 +0000992#endif
993
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000994static int
Denys Vlasenko12014262011-05-30 14:00:14 +0200995printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000996{
997 int exited = 0;
998
999 /*
1000 * Here is a tricky presentation problem. This solution
1001 * is still not entirely satisfactory but since there
1002 * are no wait status constructors it will have to do.
1003 */
Roland McGrath79fbda52004-04-14 02:45:55 +00001004 if (WIFSTOPPED(status)) {
1005 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001006 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +00001007 status &= ~W_STOPCODE(WSTOPSIG(status));
1008 }
1009 else if (WIFSIGNALED(status)) {
1010 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001011 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001012 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +00001013 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1014 }
1015 else if (WIFEXITED(status)) {
1016 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001017 WEXITSTATUS(status));
1018 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +00001019 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001020 }
Roland McGrath79fbda52004-04-14 02:45:55 +00001021 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001022 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001023 return 0;
1024 }
1025
1026 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001027 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +00001028 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +00001029 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001030
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001031 return exited;
1032}
1033
1034static int
Denys Vlasenko59432db2009-01-26 19:09:35 +00001035printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001036{
1037 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001038
1039 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001040 /* On Linux, kernel-side pid_t is typedef'ed to int
1041 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +00001042 * pid argument to int on 64bit arches, producing,
1043 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001044 * in strace. We have to use int here, not long.
1045 */
1046 int pid = tcp->u_arg[0];
1047 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001048 } else {
1049 /* status */
1050 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001051 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001052 else if (syserror(tcp) || tcp->u_rval == 0)
1053 tprintf("%#lx", tcp->u_arg[1]);
1054 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001055 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001056 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +00001057 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001058 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001059 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001060 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001061 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001062 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001063 /* usage */
1064 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001065 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001066 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +00001067#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001068 if (bitness)
1069 printrusage32(tcp, tcp->u_arg[3]);
1070 else
1071#endif
1072 printrusage(tcp, tcp->u_arg[3]);
1073 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001074 else
1075 tprintf("%#lx", tcp->u_arg[3]);
1076 }
1077 }
1078 return 0;
1079}
1080
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001081int
Denys Vlasenko12014262011-05-30 14:00:14 +02001082sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001083{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001084 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001085}
1086
1087int
Denys Vlasenko12014262011-05-30 14:00:14 +02001088sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001089{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001090 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001091}
1092
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001093#ifdef ALPHA
1094int
Denys Vlasenko12014262011-05-30 14:00:14 +02001095sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001096{
1097 return printwaitn(tcp, 4, 1);
1098}
1099#endif
1100
Roland McGrathd9f816f2004-09-04 03:39:20 +00001101static const struct xlat waitid_types[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001102 { P_PID, "P_PID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001103#ifdef P_PPID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001104 { P_PPID, "P_PPID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001105#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001106 { P_PGID, "P_PGID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001107#ifdef P_SID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001108 { P_SID, "P_SID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001109#endif
1110#ifdef P_CID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001111 { P_CID, "P_CID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001112#endif
1113#ifdef P_UID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001114 { P_UID, "P_UID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001115#endif
1116#ifdef P_GID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001117 { P_GID, "P_GID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001118#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001119 { P_ALL, "P_ALL" },
1120#ifdef P_LWPID
1121 { P_LWPID, "P_LWPID" },
1122#endif
1123 { 0, NULL },
1124};
1125
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001126int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +00001127sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001128{
1129 siginfo_t si;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001130
1131 if (entering(tcp)) {
1132 printxval(waitid_types, tcp->u_arg[0], "P_???");
1133 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001134 }
1135 else {
1136 /* siginfo */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001137 if (!tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001138 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001139 else if (syserror(tcp))
1140 tprintf("%#lx", tcp->u_arg[2]);
1141 else if (umove(tcp, tcp->u_arg[2], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001142 tprints("{???}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001143 else
Denys Vlasenkof535b542009-01-13 18:30:55 +00001144 printsiginfo(&si, verbose(tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001145 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001146 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001147 printflags(wait4_options, tcp->u_arg[3], "W???");
Roland McGrath39426a32004-10-06 22:02:59 +00001148 if (tcp->u_nargs > 4) {
1149 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001150 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +00001151 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001152 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +00001153 else if (tcp->u_error)
1154 tprintf("%#lx", tcp->u_arg[4]);
1155 else
1156 printrusage(tcp, tcp->u_arg[4]);
1157 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001158 }
1159 return 0;
1160}
1161
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001162int
Denys Vlasenko12014262011-05-30 14:00:14 +02001163sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001164{
1165 struct utsname uname;
1166
1167 if (exiting(tcp)) {
1168 if (syserror(tcp) || !verbose(tcp))
1169 tprintf("%#lx", tcp->u_arg[0]);
1170 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001171 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001172 else if (!abbrev(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001173 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1174 uname.sysname, uname.nodename);
1175 tprintf("release=\"%s\", version=\"%s\", ",
1176 uname.release, uname.version);
1177 tprintf("machine=\"%s\"", uname.machine);
Dmitry V. Levinea22e972012-05-01 20:56:32 +00001178#ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001179 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001180#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001181 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001182 }
1183 else
1184 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1185 uname.sysname, uname.nodename);
1186 }
1187 return 0;
1188}
1189
Roland McGratheb9e2e82009-06-02 16:49:22 -07001190static const struct xlat ptrace_cmds[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001191 { PTRACE_TRACEME, "PTRACE_TRACEME" },
Denys Vlasenko61526c62011-08-25 10:21:13 +02001192 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1193 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1194 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1195 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1196 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1197 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001198 { PTRACE_CONT, "PTRACE_CONT" },
1199 { PTRACE_KILL, "PTRACE_KILL" },
1200 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1201 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1202 { PTRACE_DETACH, "PTRACE_DETACH" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001203#ifdef PTRACE_GETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001204 { PTRACE_GETREGS, "PTRACE_GETREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001205#endif
1206#ifdef PTRACE_SETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001207 { PTRACE_SETREGS, "PTRACE_SETREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001208#endif
1209#ifdef PTRACE_GETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001210 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001211#endif
1212#ifdef PTRACE_SETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001213 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001214#endif
1215#ifdef PTRACE_GETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001216 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001217#endif
1218#ifdef PTRACE_SETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001219 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001220#endif
1221#ifdef PTRACE_GETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001222 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001223#endif
1224#ifdef PTRACE_SETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001225 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001226#endif
1227#ifdef PTRACE_SETOPTIONS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001228 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001229#endif
1230#ifdef PTRACE_GETEVENTMSG
Denys Vlasenko61526c62011-08-25 10:21:13 +02001231 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001232#endif
1233#ifdef PTRACE_GETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001234 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001235#endif
1236#ifdef PTRACE_SETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001237 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001238#endif
1239#ifdef PTRACE_GETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001240 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001241#endif
1242#ifdef PTRACE_SETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001243 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001244#endif
1245#ifdef PTRACE_SET_SYSCALL
Denys Vlasenko61526c62011-08-25 10:21:13 +02001246 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001247#endif
1248#ifdef PTRACE_SEIZE
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001249 { PTRACE_SEIZE, "PTRACE_SEIZE" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001250#endif
1251#ifdef PTRACE_INTERRUPT
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001252 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001253#endif
1254#ifdef PTRACE_LISTEN
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001255 { PTRACE_LISTEN, "PTRACE_LISTEN" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001256#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001257 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
Denys Vlasenkof535b542009-01-13 18:30:55 +00001258
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001259 { 0, NULL },
1260};
1261
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001262#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00001263static const struct xlat ptrace_setoptions_flags[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001264# ifdef PTRACE_O_TRACESYSGOOD
Denys Vlasenkof535b542009-01-13 18:30:55 +00001265 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001266# endif
1267# ifdef PTRACE_O_TRACEFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001268 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001269# endif
1270# ifdef PTRACE_O_TRACEVFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001271 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001272# endif
1273# ifdef PTRACE_O_TRACECLONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001274 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001275# endif
1276# ifdef PTRACE_O_TRACEEXEC
Denys Vlasenkof535b542009-01-13 18:30:55 +00001277 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001278# endif
1279# ifdef PTRACE_O_TRACEVFORKDONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001280 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001281# endif
1282# ifdef PTRACE_O_TRACEEXIT
Denys Vlasenkof535b542009-01-13 18:30:55 +00001283 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001284# endif
Denys Vlasenkof535b542009-01-13 18:30:55 +00001285 { 0, NULL },
1286};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001287#endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001288
Denys Vlasenko513e9c22012-03-21 14:39:22 +01001289#define uoff(member) offsetof(struct user, member)
1290
Roland McGrathd9f816f2004-09-04 03:39:20 +00001291const struct xlat struct_user_offsets[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001292#if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001293 { PT_PSWMASK, "psw_mask" },
1294 { PT_PSWADDR, "psw_addr" },
1295 { PT_GPR0, "gpr0" },
1296 { PT_GPR1, "gpr1" },
1297 { PT_GPR2, "gpr2" },
1298 { PT_GPR3, "gpr3" },
1299 { PT_GPR4, "gpr4" },
1300 { PT_GPR5, "gpr5" },
1301 { PT_GPR6, "gpr6" },
1302 { PT_GPR7, "gpr7" },
1303 { PT_GPR8, "gpr8" },
1304 { PT_GPR9, "gpr9" },
1305 { PT_GPR10, "gpr10" },
1306 { PT_GPR11, "gpr11" },
1307 { PT_GPR12, "gpr12" },
1308 { PT_GPR13, "gpr13" },
1309 { PT_GPR14, "gpr14" },
1310 { PT_GPR15, "gpr15" },
1311 { PT_ACR0, "acr0" },
1312 { PT_ACR1, "acr1" },
1313 { PT_ACR2, "acr2" },
1314 { PT_ACR3, "acr3" },
1315 { PT_ACR4, "acr4" },
1316 { PT_ACR5, "acr5" },
1317 { PT_ACR6, "acr6" },
1318 { PT_ACR7, "acr7" },
1319 { PT_ACR8, "acr8" },
1320 { PT_ACR9, "acr9" },
1321 { PT_ACR10, "acr10" },
1322 { PT_ACR11, "acr11" },
1323 { PT_ACR12, "acr12" },
1324 { PT_ACR13, "acr13" },
1325 { PT_ACR14, "acr14" },
1326 { PT_ACR15, "acr15" },
1327 { PT_ORIGGPR2, "orig_gpr2" },
1328 { PT_FPC, "fpc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001329#if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001330 { PT_FPR0_HI, "fpr0.hi" },
1331 { PT_FPR0_LO, "fpr0.lo" },
1332 { PT_FPR1_HI, "fpr1.hi" },
1333 { PT_FPR1_LO, "fpr1.lo" },
1334 { PT_FPR2_HI, "fpr2.hi" },
1335 { PT_FPR2_LO, "fpr2.lo" },
1336 { PT_FPR3_HI, "fpr3.hi" },
1337 { PT_FPR3_LO, "fpr3.lo" },
1338 { PT_FPR4_HI, "fpr4.hi" },
1339 { PT_FPR4_LO, "fpr4.lo" },
1340 { PT_FPR5_HI, "fpr5.hi" },
1341 { PT_FPR5_LO, "fpr5.lo" },
1342 { PT_FPR6_HI, "fpr6.hi" },
1343 { PT_FPR6_LO, "fpr6.lo" },
1344 { PT_FPR7_HI, "fpr7.hi" },
1345 { PT_FPR7_LO, "fpr7.lo" },
1346 { PT_FPR8_HI, "fpr8.hi" },
1347 { PT_FPR8_LO, "fpr8.lo" },
1348 { PT_FPR9_HI, "fpr9.hi" },
1349 { PT_FPR9_LO, "fpr9.lo" },
1350 { PT_FPR10_HI, "fpr10.hi" },
1351 { PT_FPR10_LO, "fpr10.lo" },
1352 { PT_FPR11_HI, "fpr11.hi" },
1353 { PT_FPR11_LO, "fpr11.lo" },
1354 { PT_FPR12_HI, "fpr12.hi" },
1355 { PT_FPR12_LO, "fpr12.lo" },
1356 { PT_FPR13_HI, "fpr13.hi" },
1357 { PT_FPR13_LO, "fpr13.lo" },
1358 { PT_FPR14_HI, "fpr14.hi" },
1359 { PT_FPR14_LO, "fpr14.lo" },
1360 { PT_FPR15_HI, "fpr15.hi" },
1361 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001362#endif
1363#if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001364 { PT_FPR0, "fpr0" },
1365 { PT_FPR1, "fpr1" },
1366 { PT_FPR2, "fpr2" },
1367 { PT_FPR3, "fpr3" },
1368 { PT_FPR4, "fpr4" },
1369 { PT_FPR5, "fpr5" },
1370 { PT_FPR6, "fpr6" },
1371 { PT_FPR7, "fpr7" },
1372 { PT_FPR8, "fpr8" },
1373 { PT_FPR9, "fpr9" },
1374 { PT_FPR10, "fpr10" },
1375 { PT_FPR11, "fpr11" },
1376 { PT_FPR12, "fpr12" },
1377 { PT_FPR13, "fpr13" },
1378 { PT_FPR14, "fpr14" },
1379 { PT_FPR15, "fpr15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001380#endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001381 { PT_CR_9, "cr9" },
1382 { PT_CR_10, "cr10" },
1383 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001384 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001385#elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001386 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001387#elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001388 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001389#elif defined(POWERPC)
1390# ifndef PT_ORIG_R3
1391# define PT_ORIG_R3 34
1392# endif
1393# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001394 { REGSIZE*PT_R0, "r0" },
1395 { REGSIZE*PT_R1, "r1" },
1396 { REGSIZE*PT_R2, "r2" },
1397 { REGSIZE*PT_R3, "r3" },
1398 { REGSIZE*PT_R4, "r4" },
1399 { REGSIZE*PT_R5, "r5" },
1400 { REGSIZE*PT_R6, "r6" },
1401 { REGSIZE*PT_R7, "r7" },
1402 { REGSIZE*PT_R8, "r8" },
1403 { REGSIZE*PT_R9, "r9" },
1404 { REGSIZE*PT_R10, "r10" },
1405 { REGSIZE*PT_R11, "r11" },
1406 { REGSIZE*PT_R12, "r12" },
1407 { REGSIZE*PT_R13, "r13" },
1408 { REGSIZE*PT_R14, "r14" },
1409 { REGSIZE*PT_R15, "r15" },
1410 { REGSIZE*PT_R16, "r16" },
1411 { REGSIZE*PT_R17, "r17" },
1412 { REGSIZE*PT_R18, "r18" },
1413 { REGSIZE*PT_R19, "r19" },
1414 { REGSIZE*PT_R20, "r20" },
1415 { REGSIZE*PT_R21, "r21" },
1416 { REGSIZE*PT_R22, "r22" },
1417 { REGSIZE*PT_R23, "r23" },
1418 { REGSIZE*PT_R24, "r24" },
1419 { REGSIZE*PT_R25, "r25" },
1420 { REGSIZE*PT_R26, "r26" },
1421 { REGSIZE*PT_R27, "r27" },
1422 { REGSIZE*PT_R28, "r28" },
1423 { REGSIZE*PT_R29, "r29" },
1424 { REGSIZE*PT_R30, "r30" },
1425 { REGSIZE*PT_R31, "r31" },
1426 { REGSIZE*PT_NIP, "NIP" },
1427 { REGSIZE*PT_MSR, "MSR" },
1428 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1429 { REGSIZE*PT_CTR, "CTR" },
1430 { REGSIZE*PT_LNK, "LNK" },
1431 { REGSIZE*PT_XER, "XER" },
1432 { REGSIZE*PT_CCR, "CCR" },
1433 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001434# undef REGSIZE
1435#elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001436 { 0, "r0" },
1437 { 1, "r1" },
1438 { 2, "r2" },
1439 { 3, "r3" },
1440 { 4, "r4" },
1441 { 5, "r5" },
1442 { 6, "r6" },
1443 { 7, "r7" },
1444 { 8, "r8" },
1445 { 9, "r9" },
1446 { 10, "r10" },
1447 { 11, "r11" },
1448 { 12, "r12" },
1449 { 13, "r13" },
1450 { 14, "r14" },
1451 { 15, "r15" },
1452 { 16, "r16" },
1453 { 17, "r17" },
1454 { 18, "r18" },
1455 { 19, "r19" },
1456 { 20, "r20" },
1457 { 21, "r21" },
1458 { 22, "r22" },
1459 { 23, "r23" },
1460 { 24, "r24" },
1461 { 25, "r25" },
1462 { 26, "r26" },
1463 { 27, "r27" },
1464 { 28, "r28" },
1465 { 29, "gp" },
1466 { 30, "fp" },
1467 { 31, "zero" },
1468 { 32, "fp0" },
1469 { 33, "fp" },
1470 { 34, "fp2" },
1471 { 35, "fp3" },
1472 { 36, "fp4" },
1473 { 37, "fp5" },
1474 { 38, "fp6" },
1475 { 39, "fp7" },
1476 { 40, "fp8" },
1477 { 41, "fp9" },
1478 { 42, "fp10" },
1479 { 43, "fp11" },
1480 { 44, "fp12" },
1481 { 45, "fp13" },
1482 { 46, "fp14" },
1483 { 47, "fp15" },
1484 { 48, "fp16" },
1485 { 49, "fp17" },
1486 { 50, "fp18" },
1487 { 51, "fp19" },
1488 { 52, "fp20" },
1489 { 53, "fp21" },
1490 { 54, "fp22" },
1491 { 55, "fp23" },
1492 { 56, "fp24" },
1493 { 57, "fp25" },
1494 { 58, "fp26" },
1495 { 59, "fp27" },
1496 { 60, "fp28" },
1497 { 61, "fp29" },
1498 { 62, "fp30" },
1499 { 63, "fp31" },
1500 { 64, "pc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001501#elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001502 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1503 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1504 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1505 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1506 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1507 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1508 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1509 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1510 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1511 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1512 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1513 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1514 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1515 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1516 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1517 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1518 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1519 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1520 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1521 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1522 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1523 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1524 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1525 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1526 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1527 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1528 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1529 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1530 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1531 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1532 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1533 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1534 /* switch stack: */
1535 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1536 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1537 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1538 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1539 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1540 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1541 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1542 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1543 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1544 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001545 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1546 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001547 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001548 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001549 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1550 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001551 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1552 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1553 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1554 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1555 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1556 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1557 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1558 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1559 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1560 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1561 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1562 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1563 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1564 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1565 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001566# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001567 { PT_AR_CSD, "ar.csd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001568# endif
1569# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001570 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001571# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001572 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001573#elif defined(I386)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001574 { 4*EBX, "4*EBX" },
1575 { 4*ECX, "4*ECX" },
1576 { 4*EDX, "4*EDX" },
1577 { 4*ESI, "4*ESI" },
1578 { 4*EDI, "4*EDI" },
1579 { 4*EBP, "4*EBP" },
1580 { 4*EAX, "4*EAX" },
1581 { 4*DS, "4*DS" },
1582 { 4*ES, "4*ES" },
1583 { 4*FS, "4*FS" },
1584 { 4*GS, "4*GS" },
1585 { 4*ORIG_EAX, "4*ORIG_EAX" },
1586 { 4*EIP, "4*EIP" },
1587 { 4*CS, "4*CS" },
1588 { 4*EFL, "4*EFL" },
1589 { 4*UESP, "4*UESP" },
1590 { 4*SS, "4*SS" },
H.J. Lu35be5812012-04-16 13:00:01 +02001591#elif defined(X86_64) || defined(X32)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001592 { 8*R15, "8*R15" },
1593 { 8*R14, "8*R14" },
1594 { 8*R13, "8*R13" },
1595 { 8*R12, "8*R12" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001596 { 8*RBP, "8*RBP" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001597 { 8*RBX, "8*RBX" },
1598 { 8*R11, "8*R11" },
1599 { 8*R10, "8*R10" },
1600 { 8*R9, "8*R9" },
1601 { 8*R8, "8*R8" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001602 { 8*RAX, "8*RAX" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001603 { 8*RCX, "8*RCX" },
1604 { 8*RDX, "8*RDX" },
1605 { 8*RSI, "8*RSI" },
1606 { 8*RDI, "8*RDI" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001607 { 8*ORIG_RAX, "8*ORIG_RAX" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001608 { 8*RIP, "8*RIP" },
1609 { 8*CS, "8*CS" },
1610 { 8*EFLAGS, "8*EFL" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001611 { 8*RSP, "8*RSP" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001612 { 8*SS, "8*SS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001613#elif defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001614 { 4*PT_D1, "4*PT_D1" },
1615 { 4*PT_D2, "4*PT_D2" },
1616 { 4*PT_D3, "4*PT_D3" },
1617 { 4*PT_D4, "4*PT_D4" },
1618 { 4*PT_D5, "4*PT_D5" },
1619 { 4*PT_D6, "4*PT_D6" },
1620 { 4*PT_D7, "4*PT_D7" },
1621 { 4*PT_A0, "4*PT_A0" },
1622 { 4*PT_A1, "4*PT_A1" },
1623 { 4*PT_A2, "4*PT_A2" },
1624 { 4*PT_A3, "4*PT_A3" },
1625 { 4*PT_A4, "4*PT_A4" },
1626 { 4*PT_A5, "4*PT_A5" },
1627 { 4*PT_A6, "4*PT_A6" },
1628 { 4*PT_D0, "4*PT_D0" },
1629 { 4*PT_USP, "4*PT_USP" },
1630 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1631 { 4*PT_SR, "4*PT_SR" },
1632 { 4*PT_PC, "4*PT_PC" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001633#elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001634 { 4*REG_REG0, "4*REG_REG0" },
1635 { 4*(REG_REG0+1), "4*REG_REG1" },
1636 { 4*(REG_REG0+2), "4*REG_REG2" },
1637 { 4*(REG_REG0+3), "4*REG_REG3" },
1638 { 4*(REG_REG0+4), "4*REG_REG4" },
1639 { 4*(REG_REG0+5), "4*REG_REG5" },
1640 { 4*(REG_REG0+6), "4*REG_REG6" },
1641 { 4*(REG_REG0+7), "4*REG_REG7" },
1642 { 4*(REG_REG0+8), "4*REG_REG8" },
1643 { 4*(REG_REG0+9), "4*REG_REG9" },
1644 { 4*(REG_REG0+10), "4*REG_REG10" },
1645 { 4*(REG_REG0+11), "4*REG_REG11" },
1646 { 4*(REG_REG0+12), "4*REG_REG12" },
1647 { 4*(REG_REG0+13), "4*REG_REG13" },
1648 { 4*(REG_REG0+14), "4*REG_REG14" },
1649 { 4*REG_REG15, "4*REG_REG15" },
1650 { 4*REG_PC, "4*REG_PC" },
1651 { 4*REG_PR, "4*REG_PR" },
1652 { 4*REG_SR, "4*REG_SR" },
1653 { 4*REG_GBR, "4*REG_GBR" },
1654 { 4*REG_MACH, "4*REG_MACH" },
1655 { 4*REG_MACL, "4*REG_MACL" },
1656 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1657 { 4*REG_FPUL, "4*REG_FPUL" },
1658 { 4*REG_FPREG0, "4*REG_FPREG0" },
1659 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1660 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1661 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1662 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1663 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1664 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1665 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1666 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1667 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1668 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1669 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1670 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1671 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1672 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1673 { 4*REG_FPREG15, "4*REG_FPREG15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001674# ifdef REG_XDREG0
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001675 { 4*REG_XDREG0, "4*REG_XDREG0" },
1676 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1677 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1678 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1679 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1680 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1681 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1682 { 4*REG_XDREG14, "4*REG_XDREG14" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001683# endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001684 { 4*REG_FPSCR, "4*REG_FPSCR" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001685#elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001686 { 0, "PC(L)" },
1687 { 4, "PC(U)" },
1688 { 8, "SR(L)" },
1689 { 12, "SR(U)" },
1690 { 16, "syscall no.(L)" },
1691 { 20, "syscall_no.(U)" },
1692 { 24, "R0(L)" },
1693 { 28, "R0(U)" },
1694 { 32, "R1(L)" },
1695 { 36, "R1(U)" },
1696 { 40, "R2(L)" },
1697 { 44, "R2(U)" },
1698 { 48, "R3(L)" },
1699 { 52, "R3(U)" },
1700 { 56, "R4(L)" },
1701 { 60, "R4(U)" },
1702 { 64, "R5(L)" },
1703 { 68, "R5(U)" },
1704 { 72, "R6(L)" },
1705 { 76, "R6(U)" },
1706 { 80, "R7(L)" },
1707 { 84, "R7(U)" },
1708 { 88, "R8(L)" },
1709 { 92, "R8(U)" },
1710 { 96, "R9(L)" },
1711 { 100, "R9(U)" },
1712 { 104, "R10(L)" },
1713 { 108, "R10(U)" },
1714 { 112, "R11(L)" },
1715 { 116, "R11(U)" },
1716 { 120, "R12(L)" },
1717 { 124, "R12(U)" },
1718 { 128, "R13(L)" },
1719 { 132, "R13(U)" },
1720 { 136, "R14(L)" },
1721 { 140, "R14(U)" },
1722 { 144, "R15(L)" },
1723 { 148, "R15(U)" },
1724 { 152, "R16(L)" },
1725 { 156, "R16(U)" },
1726 { 160, "R17(L)" },
1727 { 164, "R17(U)" },
1728 { 168, "R18(L)" },
1729 { 172, "R18(U)" },
1730 { 176, "R19(L)" },
1731 { 180, "R19(U)" },
1732 { 184, "R20(L)" },
1733 { 188, "R20(U)" },
1734 { 192, "R21(L)" },
1735 { 196, "R21(U)" },
1736 { 200, "R22(L)" },
1737 { 204, "R22(U)" },
1738 { 208, "R23(L)" },
1739 { 212, "R23(U)" },
1740 { 216, "R24(L)" },
1741 { 220, "R24(U)" },
1742 { 224, "R25(L)" },
1743 { 228, "R25(U)" },
1744 { 232, "R26(L)" },
1745 { 236, "R26(U)" },
1746 { 240, "R27(L)" },
1747 { 244, "R27(U)" },
1748 { 248, "R28(L)" },
1749 { 252, "R28(U)" },
1750 { 256, "R29(L)" },
1751 { 260, "R29(U)" },
1752 { 264, "R30(L)" },
1753 { 268, "R30(U)" },
1754 { 272, "R31(L)" },
1755 { 276, "R31(U)" },
1756 { 280, "R32(L)" },
1757 { 284, "R32(U)" },
1758 { 288, "R33(L)" },
1759 { 292, "R33(U)" },
1760 { 296, "R34(L)" },
1761 { 300, "R34(U)" },
1762 { 304, "R35(L)" },
1763 { 308, "R35(U)" },
1764 { 312, "R36(L)" },
1765 { 316, "R36(U)" },
1766 { 320, "R37(L)" },
1767 { 324, "R37(U)" },
1768 { 328, "R38(L)" },
1769 { 332, "R38(U)" },
1770 { 336, "R39(L)" },
1771 { 340, "R39(U)" },
1772 { 344, "R40(L)" },
1773 { 348, "R40(U)" },
1774 { 352, "R41(L)" },
1775 { 356, "R41(U)" },
1776 { 360, "R42(L)" },
1777 { 364, "R42(U)" },
1778 { 368, "R43(L)" },
1779 { 372, "R43(U)" },
1780 { 376, "R44(L)" },
1781 { 380, "R44(U)" },
1782 { 384, "R45(L)" },
1783 { 388, "R45(U)" },
1784 { 392, "R46(L)" },
1785 { 396, "R46(U)" },
1786 { 400, "R47(L)" },
1787 { 404, "R47(U)" },
1788 { 408, "R48(L)" },
1789 { 412, "R48(U)" },
1790 { 416, "R49(L)" },
1791 { 420, "R49(U)" },
1792 { 424, "R50(L)" },
1793 { 428, "R50(U)" },
1794 { 432, "R51(L)" },
1795 { 436, "R51(U)" },
1796 { 440, "R52(L)" },
1797 { 444, "R52(U)" },
1798 { 448, "R53(L)" },
1799 { 452, "R53(U)" },
1800 { 456, "R54(L)" },
1801 { 460, "R54(U)" },
1802 { 464, "R55(L)" },
1803 { 468, "R55(U)" },
1804 { 472, "R56(L)" },
1805 { 476, "R56(U)" },
1806 { 480, "R57(L)" },
1807 { 484, "R57(U)" },
1808 { 488, "R58(L)" },
1809 { 492, "R58(U)" },
1810 { 496, "R59(L)" },
1811 { 500, "R59(U)" },
1812 { 504, "R60(L)" },
1813 { 508, "R60(U)" },
1814 { 512, "R61(L)" },
1815 { 516, "R61(U)" },
1816 { 520, "R62(L)" },
1817 { 524, "R62(U)" },
1818 { 528, "TR0(L)" },
1819 { 532, "TR0(U)" },
1820 { 536, "TR1(L)" },
1821 { 540, "TR1(U)" },
1822 { 544, "TR2(L)" },
1823 { 548, "TR2(U)" },
1824 { 552, "TR3(L)" },
1825 { 556, "TR3(U)" },
1826 { 560, "TR4(L)" },
1827 { 564, "TR4(U)" },
1828 { 568, "TR5(L)" },
1829 { 572, "TR5(U)" },
1830 { 576, "TR6(L)" },
1831 { 580, "TR6(U)" },
1832 { 584, "TR7(L)" },
1833 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00001834 /* This entry is in case pt_regs contains dregs (depends on
1835 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001836 { uoff(regs), "offsetof(struct user, regs)" },
1837 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001838#elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00001839 { uoff(regs.ARM_r0), "r0" },
1840 { uoff(regs.ARM_r1), "r1" },
1841 { uoff(regs.ARM_r2), "r2" },
1842 { uoff(regs.ARM_r3), "r3" },
1843 { uoff(regs.ARM_r4), "r4" },
1844 { uoff(regs.ARM_r5), "r5" },
1845 { uoff(regs.ARM_r6), "r6" },
1846 { uoff(regs.ARM_r7), "r7" },
1847 { uoff(regs.ARM_r8), "r8" },
1848 { uoff(regs.ARM_r9), "r9" },
1849 { uoff(regs.ARM_r10), "r10" },
1850 { uoff(regs.ARM_fp), "fp" },
1851 { uoff(regs.ARM_ip), "ip" },
1852 { uoff(regs.ARM_sp), "sp" },
1853 { uoff(regs.ARM_lr), "lr" },
1854 { uoff(regs.ARM_pc), "pc" },
1855 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001856#elif defined(AVR32)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001857 { uoff(regs.sr), "sr" },
1858 { uoff(regs.pc), "pc" },
1859 { uoff(regs.lr), "lr" },
1860 { uoff(regs.sp), "sp" },
1861 { uoff(regs.r12), "r12" },
1862 { uoff(regs.r11), "r11" },
1863 { uoff(regs.r10), "r10" },
1864 { uoff(regs.r9), "r9" },
1865 { uoff(regs.r8), "r8" },
1866 { uoff(regs.r7), "r7" },
1867 { uoff(regs.r6), "r6" },
1868 { uoff(regs.r5), "r5" },
1869 { uoff(regs.r4), "r4" },
1870 { uoff(regs.r3), "r3" },
1871 { uoff(regs.r2), "r2" },
1872 { uoff(regs.r1), "r1" },
1873 { uoff(regs.r0), "r0" },
1874 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001875#elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00001876 { 0, "r0" },
1877 { 1, "r1" },
1878 { 2, "r2" },
1879 { 3, "r3" },
1880 { 4, "r4" },
1881 { 5, "r5" },
1882 { 6, "r6" },
1883 { 7, "r7" },
1884 { 8, "r8" },
1885 { 9, "r9" },
1886 { 10, "r10" },
1887 { 11, "r11" },
1888 { 12, "r12" },
1889 { 13, "r13" },
1890 { 14, "r14" },
1891 { 15, "r15" },
1892 { 16, "r16" },
1893 { 17, "r17" },
1894 { 18, "r18" },
1895 { 19, "r19" },
1896 { 20, "r20" },
1897 { 21, "r21" },
1898 { 22, "r22" },
1899 { 23, "r23" },
1900 { 24, "r24" },
1901 { 25, "r25" },
1902 { 26, "r26" },
1903 { 27, "r27" },
1904 { 28, "r28" },
1905 { 29, "r29" },
1906 { 30, "r30" },
1907 { 31, "r31" },
1908 { 32, "f0" },
1909 { 33, "f1" },
1910 { 34, "f2" },
1911 { 35, "f3" },
1912 { 36, "f4" },
1913 { 37, "f5" },
1914 { 38, "f6" },
1915 { 39, "f7" },
1916 { 40, "f8" },
1917 { 41, "f9" },
1918 { 42, "f10" },
1919 { 43, "f11" },
1920 { 44, "f12" },
1921 { 45, "f13" },
1922 { 46, "f14" },
1923 { 47, "f15" },
1924 { 48, "f16" },
1925 { 49, "f17" },
1926 { 50, "f18" },
1927 { 51, "f19" },
1928 { 52, "f20" },
1929 { 53, "f21" },
1930 { 54, "f22" },
1931 { 55, "f23" },
1932 { 56, "f24" },
1933 { 57, "f25" },
1934 { 58, "f26" },
1935 { 59, "f27" },
1936 { 60, "f28" },
1937 { 61, "f29" },
1938 { 62, "f30" },
1939 { 63, "f31" },
1940 { 64, "pc" },
1941 { 65, "cause" },
1942 { 66, "badvaddr" },
1943 { 67, "mmhi" },
1944 { 68, "mmlo" },
1945 { 69, "fpcsr" },
1946 { 70, "fpeir" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001947#elif defined(TILE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05001948 { PTREGS_OFFSET_REG(0), "r0" },
1949 { PTREGS_OFFSET_REG(1), "r1" },
1950 { PTREGS_OFFSET_REG(2), "r2" },
1951 { PTREGS_OFFSET_REG(3), "r3" },
1952 { PTREGS_OFFSET_REG(4), "r4" },
1953 { PTREGS_OFFSET_REG(5), "r5" },
1954 { PTREGS_OFFSET_REG(6), "r6" },
1955 { PTREGS_OFFSET_REG(7), "r7" },
1956 { PTREGS_OFFSET_REG(8), "r8" },
1957 { PTREGS_OFFSET_REG(9), "r9" },
1958 { PTREGS_OFFSET_REG(10), "r10" },
1959 { PTREGS_OFFSET_REG(11), "r11" },
1960 { PTREGS_OFFSET_REG(12), "r12" },
1961 { PTREGS_OFFSET_REG(13), "r13" },
1962 { PTREGS_OFFSET_REG(14), "r14" },
1963 { PTREGS_OFFSET_REG(15), "r15" },
1964 { PTREGS_OFFSET_REG(16), "r16" },
1965 { PTREGS_OFFSET_REG(17), "r17" },
1966 { PTREGS_OFFSET_REG(18), "r18" },
1967 { PTREGS_OFFSET_REG(19), "r19" },
1968 { PTREGS_OFFSET_REG(20), "r20" },
1969 { PTREGS_OFFSET_REG(21), "r21" },
1970 { PTREGS_OFFSET_REG(22), "r22" },
1971 { PTREGS_OFFSET_REG(23), "r23" },
1972 { PTREGS_OFFSET_REG(24), "r24" },
1973 { PTREGS_OFFSET_REG(25), "r25" },
1974 { PTREGS_OFFSET_REG(26), "r26" },
1975 { PTREGS_OFFSET_REG(27), "r27" },
1976 { PTREGS_OFFSET_REG(28), "r28" },
1977 { PTREGS_OFFSET_REG(29), "r29" },
1978 { PTREGS_OFFSET_REG(30), "r30" },
1979 { PTREGS_OFFSET_REG(31), "r31" },
1980 { PTREGS_OFFSET_REG(32), "r32" },
1981 { PTREGS_OFFSET_REG(33), "r33" },
1982 { PTREGS_OFFSET_REG(34), "r34" },
1983 { PTREGS_OFFSET_REG(35), "r35" },
1984 { PTREGS_OFFSET_REG(36), "r36" },
1985 { PTREGS_OFFSET_REG(37), "r37" },
1986 { PTREGS_OFFSET_REG(38), "r38" },
1987 { PTREGS_OFFSET_REG(39), "r39" },
1988 { PTREGS_OFFSET_REG(40), "r40" },
1989 { PTREGS_OFFSET_REG(41), "r41" },
1990 { PTREGS_OFFSET_REG(42), "r42" },
1991 { PTREGS_OFFSET_REG(43), "r43" },
1992 { PTREGS_OFFSET_REG(44), "r44" },
1993 { PTREGS_OFFSET_REG(45), "r45" },
1994 { PTREGS_OFFSET_REG(46), "r46" },
1995 { PTREGS_OFFSET_REG(47), "r47" },
1996 { PTREGS_OFFSET_REG(48), "r48" },
1997 { PTREGS_OFFSET_REG(49), "r49" },
1998 { PTREGS_OFFSET_REG(50), "r50" },
1999 { PTREGS_OFFSET_REG(51), "r51" },
2000 { PTREGS_OFFSET_REG(52), "r52" },
2001 { PTREGS_OFFSET_TP, "tp" },
2002 { PTREGS_OFFSET_SP, "sp" },
2003 { PTREGS_OFFSET_LR, "lr" },
2004 { PTREGS_OFFSET_PC, "pc" },
2005 { PTREGS_OFFSET_EX1, "ex1" },
2006 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2007 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2008 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002009#endif
2010#ifdef CRISV10
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002011 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2012 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2013 { 4*PT_R13, "4*PT_R13" },
2014 { 4*PT_R12, "4*PT_R12" },
2015 { 4*PT_R11, "4*PT_R11" },
2016 { 4*PT_R10, "4*PT_R10" },
2017 { 4*PT_R9, "4*PT_R9" },
2018 { 4*PT_R8, "4*PT_R8" },
2019 { 4*PT_R7, "4*PT_R7" },
2020 { 4*PT_R6, "4*PT_R6" },
2021 { 4*PT_R5, "4*PT_R5" },
2022 { 4*PT_R4, "4*PT_R4" },
2023 { 4*PT_R3, "4*PT_R3" },
2024 { 4*PT_R2, "4*PT_R2" },
2025 { 4*PT_R1, "4*PT_R1" },
2026 { 4*PT_R0, "4*PT_R0" },
2027 { 4*PT_MOF, "4*PT_MOF" },
2028 { 4*PT_DCCR, "4*PT_DCCR" },
2029 { 4*PT_SRP, "4*PT_SRP" },
2030 { 4*PT_IRP, "4*PT_IRP" },
2031 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2032 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2033 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2034 { 4*PT_USP, "4*PT_USP" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002035#endif
2036#ifdef CRISV32
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002037 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2038 { 4*PT_R0, "4*PT_R0" },
2039 { 4*PT_R1, "4*PT_R1" },
2040 { 4*PT_R2, "4*PT_R2" },
2041 { 4*PT_R3, "4*PT_R3" },
2042 { 4*PT_R4, "4*PT_R4" },
2043 { 4*PT_R5, "4*PT_R5" },
2044 { 4*PT_R6, "4*PT_R6" },
2045 { 4*PT_R7, "4*PT_R7" },
2046 { 4*PT_R8, "4*PT_R8" },
2047 { 4*PT_R9, "4*PT_R9" },
2048 { 4*PT_R10, "4*PT_R10" },
2049 { 4*PT_R11, "4*PT_R11" },
2050 { 4*PT_R12, "4*PT_R12" },
2051 { 4*PT_R13, "4*PT_R13" },
2052 { 4*PT_ACR, "4*PT_ACR" },
2053 { 4*PT_SRS, "4*PT_SRS" },
2054 { 4*PT_MOF, "4*PT_MOF" },
2055 { 4*PT_SPC, "4*PT_SPC" },
2056 { 4*PT_CCS, "4*PT_CCS" },
2057 { 4*PT_SRP, "4*PT_SRP" },
2058 { 4*PT_ERP, "4*PT_ERP" },
2059 { 4*PT_EXS, "4*PT_EXS" },
2060 { 4*PT_EDA, "4*PT_EDA" },
2061 { 4*PT_USP, "4*PT_USP" },
2062 { 4*PT_PPC, "4*PT_PPC" },
2063 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2064 { 4*PT_BP+4, "4*PT_BP+4" },
2065 { 4*PT_BP+8, "4*PT_BP+8" },
2066 { 4*PT_BP+12, "4*PT_BP+12" },
2067 { 4*PT_BP+16, "4*PT_BP+16" },
2068 { 4*PT_BP+20, "4*PT_BP+20" },
2069 { 4*PT_BP+24, "4*PT_BP+24" },
2070 { 4*PT_BP+28, "4*PT_BP+28" },
2071 { 4*PT_BP+32, "4*PT_BP+32" },
2072 { 4*PT_BP+36, "4*PT_BP+36" },
2073 { 4*PT_BP+40, "4*PT_BP+40" },
2074 { 4*PT_BP+44, "4*PT_BP+44" },
2075 { 4*PT_BP+48, "4*PT_BP+48" },
2076 { 4*PT_BP+52, "4*PT_BP+52" },
2077 { 4*PT_BP+56, "4*PT_BP+56" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002078#endif
2079#ifdef MICROBLAZE
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002080 { PT_GPR(0), "r0" },
2081 { PT_GPR(1), "r1" },
2082 { PT_GPR(2), "r2" },
2083 { PT_GPR(3), "r3" },
2084 { PT_GPR(4), "r4" },
2085 { PT_GPR(5), "r5" },
2086 { PT_GPR(6), "r6" },
2087 { PT_GPR(7), "r7" },
2088 { PT_GPR(8), "r8" },
2089 { PT_GPR(9), "r9" },
2090 { PT_GPR(10), "r10" },
2091 { PT_GPR(11), "r11" },
2092 { PT_GPR(12), "r12" },
2093 { PT_GPR(13), "r13" },
2094 { PT_GPR(14), "r14" },
2095 { PT_GPR(15), "r15" },
2096 { PT_GPR(16), "r16" },
2097 { PT_GPR(17), "r17" },
2098 { PT_GPR(18), "r18" },
2099 { PT_GPR(19), "r19" },
2100 { PT_GPR(20), "r20" },
2101 { PT_GPR(21), "r21" },
2102 { PT_GPR(22), "r22" },
2103 { PT_GPR(23), "r23" },
2104 { PT_GPR(24), "r24" },
2105 { PT_GPR(25), "r25" },
2106 { PT_GPR(26), "r26" },
2107 { PT_GPR(27), "r27" },
2108 { PT_GPR(28), "r28" },
2109 { PT_GPR(29), "r29" },
2110 { PT_GPR(30), "r30" },
2111 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002112 { PT_PC, "rpc", },
2113 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002114 { PT_EAR, "rear", },
2115 { PT_ESR, "resr", },
2116 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002117 { PT_KERNEL_MODE, "kernel_mode", },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002118#endif
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002119 /* Other fields in "struct user" */
2120#if defined(S390) || defined(S390X)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002121 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2122 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2123 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002124 { uoff(start_code), "offsetof(struct user, start_code)" },
2125 /* S390[X] has no start_data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002126 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2127 { uoff(signal), "offsetof(struct user, signal)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002128 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002129 { uoff(magic), "offsetof(struct user, magic)" },
2130 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002131 { sizeof(struct user), "sizeof(struct user)" },
2132#elif defined(POWERPC)
2133 { sizeof(struct user), "sizeof(struct user)" },
2134#elif defined(I386) || defined(X86_64) || defined(X32)
2135 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2136 { uoff(i387), "offsetof(struct user, i387)" },
2137 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2138 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2139 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2140 { uoff(start_code), "offsetof(struct user, start_code)" },
2141 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2142 { uoff(signal), "offsetof(struct user, signal)" },
2143 { uoff(reserved), "offsetof(struct user, reserved)" },
2144 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2145 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2146 { uoff(magic), "offsetof(struct user, magic)" },
2147 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002148 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002149 { sizeof(struct user), "sizeof(struct user)" },
2150#elif defined(IA64)
2151 { sizeof(struct user), "sizeof(struct user)" },
2152#elif defined(ARM)
2153 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2154 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2155 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2156 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2157 { uoff(start_code), "offsetof(struct user, start_code)" },
2158 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2159 { uoff(signal), "offsetof(struct user, signal)" },
2160 { uoff(reserved), "offsetof(struct user, reserved)" },
2161 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2162 { uoff(magic), "offsetof(struct user, magic)" },
2163 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2164 { sizeof(struct user), "sizeof(struct user)" },
2165#elif defined(AARCH64)
2166 /* nothing */
2167#elif defined(M68K)
2168 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2169 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2170 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2171 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2172 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2173 { uoff(start_code), "offsetof(struct user, start_code)" },
2174 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2175 { uoff(signal), "offsetof(struct user, signal)" },
2176 { uoff(reserved), "offsetof(struct user, reserved)" },
2177 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2178 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2179 { uoff(magic), "offsetof(struct user, magic)" },
2180 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2181 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002182#elif defined(MIPS) || defined(LINUX_MIPSN32)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002183 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2184 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2185 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2186 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002187 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002188 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2189 { uoff(signal), "offsetof(struct user, signal)" },
2190 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2191 { uoff(magic), "offsetof(struct user, magic)" },
2192 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2193 { sizeof(struct user), "sizeof(struct user)" },
2194#elif defined(ALPHA)
2195 { sizeof(struct user), "sizeof(struct user)" },
2196#elif defined(SPARC)
2197 { sizeof(struct user), "sizeof(struct user)" },
2198#elif defined(SPARC64)
2199 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2200 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2201 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2202 { uoff(signal), "offsetof(struct user, signal)" },
2203 { uoff(magic), "offsetof(struct user, magic)" },
2204 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2205 { sizeof(struct user), "sizeof(struct user)" },
2206#elif defined(HPPA)
2207 /* nothing */
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002208#elif defined(SH) || defined(SH64)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002209 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2210 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2211 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2212 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2213 { uoff(start_code), "offsetof(struct user, start_code)" },
2214 { uoff(start_data), "offsetof(struct user, start_data)" },
2215 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2216 { uoff(signal), "offsetof(struct user, signal)" },
2217 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2218 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
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(CRISV10) || defined(CRISV32)
2223 { sizeof(struct user), "sizeof(struct user)" },
2224#elif defined(TILE)
2225 /* nothing */
2226#elif defined(MICROBLAZE)
2227 { sizeof(struct user), "sizeof(struct user)" },
2228#elif defined(AVR32)
2229 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2230 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2231 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2232 { uoff(start_code), "offsetof(struct user, start_code)" },
2233 { uoff(start_data), "offsetof(struct user, start_data)" },
2234 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2235 { uoff(signal), "offsetof(struct user, signal)" },
2236 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2237 { uoff(magic), "offsetof(struct user, magic)" },
2238 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2239 { sizeof(struct user), "sizeof(struct user)" },
2240#elif defined(BFIN)
2241 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2242 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2243 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2244 { uoff(start_code), "offsetof(struct user, start_code)" },
2245 { uoff(signal), "offsetof(struct user, signal)" },
2246 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2247 { uoff(magic), "offsetof(struct user, magic)" },
2248 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002249 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002250#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002251 { 0, NULL },
2252};
2253
2254int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002255sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002256{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002257 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002258 long addr;
2259
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002260 if (entering(tcp)) {
Denys Vlasenkob7a6dae2012-03-20 16:48:35 +01002261 printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
Roland McGrathbf621d42003-01-14 09:46:21 +00002262 tprintf(", %lu, ", tcp->u_arg[1]);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002263
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002264 addr = tcp->u_arg[2];
2265 if (tcp->u_arg[0] == PTRACE_PEEKUSER
Denys Vlasenkobe994972013-02-13 16:10:10 +01002266 || tcp->u_arg[0] == PTRACE_POKEUSER
2267 ) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002268 for (x = struct_user_offsets; x->str; x++) {
2269 if (x->val >= addr)
2270 break;
2271 }
2272 if (!x->str)
2273 tprintf("%#lx, ", addr);
2274 else if (x->val > addr && x != struct_user_offsets) {
2275 x--;
2276 tprintf("%s + %ld, ", x->str, addr - x->val);
2277 }
2278 else
2279 tprintf("%s, ", x->str);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002280 } else
2281#ifdef PTRACE_GETREGSET
2282 //if (tcp->u_arg[0] == PTRACE_GET/SETREGSET) {
2283 // TODO: show tcp->u_arg[2] as "NT_xxx, "
2284 //} else
2285#endif
2286 tprintf("%#lx, ", addr);
2287
2288
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002289 switch (tcp->u_arg[0]) {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002290#ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002291 case PTRACE_PEEKDATA:
2292 case PTRACE_PEEKTEXT:
2293 case PTRACE_PEEKUSER:
2294 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002295#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002296 case PTRACE_CONT:
2297 case PTRACE_SINGLESTEP:
2298 case PTRACE_SYSCALL:
2299 case PTRACE_DETACH:
2300 printsignal(tcp->u_arg[3]);
2301 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002302#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002303 case PTRACE_SETOPTIONS:
2304 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2305 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002306#endif
2307#ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002308 case PTRACE_SETSIGINFO: {
2309 siginfo_t si;
2310 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002311 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002312 else if (syserror(tcp))
2313 tprintf("%#lx", tcp->u_arg[3]);
2314 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002315 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002316 else
2317 printsiginfo(&si, verbose(tcp));
2318 break;
2319 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002320#endif
2321#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002322 case PTRACE_GETSIGINFO:
2323 /* Don't print anything, do it at syscall return. */
2324 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002325#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002326#ifdef PTRACE_GETREGSET
2327 case PTRACE_GETREGSET:
2328 break;
2329 case PTRACE_SETREGSET:
2330 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2331 break;
2332#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002333 default:
2334 tprintf("%#lx", tcp->u_arg[3]);
2335 break;
2336 }
2337 } else {
2338 switch (tcp->u_arg[0]) {
2339 case PTRACE_PEEKDATA:
2340 case PTRACE_PEEKTEXT:
2341 case PTRACE_PEEKUSER:
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002342#ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002343 return RVAL_HEX;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002344#else
Roland McGratheb285352003-01-14 09:59:00 +00002345 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002346 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002347#endif
2348#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002349 case PTRACE_GETSIGINFO: {
2350 siginfo_t si;
2351 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002352 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002353 else if (syserror(tcp))
2354 tprintf("%#lx", tcp->u_arg[3]);
2355 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002356 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002357 else
2358 printsiginfo(&si, verbose(tcp));
2359 break;
2360 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002361#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002362#ifdef PTRACE_GETREGSET
2363 case PTRACE_GETREGSET:
2364 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2365 break;
2366#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002367 }
2368 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002369 return 0;
2370}
2371
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002372#ifndef FUTEX_CMP_REQUEUE
2373# define FUTEX_CMP_REQUEUE 4
2374#endif
2375#ifndef FUTEX_WAKE_OP
2376# define FUTEX_WAKE_OP 5
2377#endif
2378#ifndef FUTEX_LOCK_PI
2379# define FUTEX_LOCK_PI 6
2380# define FUTEX_UNLOCK_PI 7
2381# define FUTEX_TRYLOCK_PI 8
2382#endif
2383#ifndef FUTEX_WAIT_BITSET
2384# define FUTEX_WAIT_BITSET 9
2385#endif
2386#ifndef FUTEX_WAKE_BITSET
2387# define FUTEX_WAKE_BITSET 10
2388#endif
2389#ifndef FUTEX_WAIT_REQUEUE_PI
2390# define FUTEX_WAIT_REQUEUE_PI 11
2391#endif
2392#ifndef FUTEX_CMP_REQUEUE_PI
2393# define FUTEX_CMP_REQUEUE_PI 12
2394#endif
2395#ifndef FUTEX_PRIVATE_FLAG
2396# define FUTEX_PRIVATE_FLAG 128
2397#endif
2398#ifndef FUTEX_CLOCK_REALTIME
2399# define FUTEX_CLOCK_REALTIME 256
2400#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002401static const struct xlat futexops[] = {
Roland McGrath51942a92007-07-05 18:59:11 +00002402 { FUTEX_WAIT, "FUTEX_WAIT" },
2403 { FUTEX_WAKE, "FUTEX_WAKE" },
2404 { FUTEX_FD, "FUTEX_FD" },
2405 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2406 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2407 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2408 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2409 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2410 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002411 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2412 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002413 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2414 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
Roland McGrath51942a92007-07-05 18:59:11 +00002415 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2416 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2417 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2418 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2419 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2420 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2421 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2422 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2423 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002424 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2425 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002426 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2427 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2428 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2429 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2430 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2431 { 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 +00002432 { 0, NULL }
2433};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002434#ifndef FUTEX_OP_SET
2435# define FUTEX_OP_SET 0
2436# define FUTEX_OP_ADD 1
2437# define FUTEX_OP_OR 2
2438# define FUTEX_OP_ANDN 3
2439# define FUTEX_OP_XOR 4
2440# define FUTEX_OP_CMP_EQ 0
2441# define FUTEX_OP_CMP_NE 1
2442# define FUTEX_OP_CMP_LT 2
2443# define FUTEX_OP_CMP_LE 3
2444# define FUTEX_OP_CMP_GT 4
2445# define FUTEX_OP_CMP_GE 5
2446#endif
Roland McGrath51942a92007-07-05 18:59:11 +00002447static const struct xlat futexwakeops[] = {
2448 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2449 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2450 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2451 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2452 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2453 { 0, NULL }
2454};
2455static const struct xlat futexwakecmps[] = {
2456 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2457 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2458 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2459 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2460 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2461 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2462 { 0, NULL }
Roland McGrath5a223472002-12-15 23:58:26 +00002463};
2464
2465int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002466sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002467{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002468 if (entering(tcp)) {
2469 long int cmd = tcp->u_arg[1] & 127;
2470 tprintf("%p, ", (void *) tcp->u_arg[0]);
2471 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2472 tprintf(", %ld", tcp->u_arg[2]);
2473 if (cmd == FUTEX_WAKE_BITSET)
2474 tprintf(", %lx", tcp->u_arg[5]);
2475 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002476 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002477 printtv(tcp, tcp->u_arg[3]);
2478 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002479 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002480 printtv(tcp, tcp->u_arg[3]);
2481 tprintf(", %lx", tcp->u_arg[5]);
2482 } else if (cmd == FUTEX_REQUEUE)
2483 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002484 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002485 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2486 else if (cmd == FUTEX_WAKE_OP) {
2487 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2488 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002489 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002490 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2491 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2492 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002493 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002494 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2495 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002496 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002497 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002498 printtv(tcp, tcp->u_arg[3]);
2499 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002500 }
Roland McGrath51942a92007-07-05 18:59:11 +00002501 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002502 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002503}
2504
2505static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002506print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002507{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002508 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002509 unsigned long w, min_len;
2510
2511 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2512 min_len = len - max_strlen * sizeof(w);
2513 else
2514 min_len = 0;
2515 for (; len >= sizeof(w) && len > min_len;
2516 len -= sizeof(w), list += sizeof(w)) {
2517 if (umove(tcp, list, &w) < 0)
2518 break;
2519 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002520 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002521 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002522 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002523 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002524 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002525 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002526 if (len) {
2527 if (first)
2528 tprintf("%#lx", list);
2529 else
2530 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2531 "???" : "..."));
2532 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002533 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002534 }
Roland McGrath5a223472002-12-15 23:58:26 +00002535}
2536
2537int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002538sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002539{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002540 if (entering(tcp)) {
2541 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2542 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2543 }
2544 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002545}
2546
2547int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002548sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002549{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002550 if (entering(tcp)) {
2551 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2552 } else {
2553 if (tcp->u_rval == -1)
2554 tprintf("%#lx", tcp->u_arg[2]);
2555 else
2556 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2557 }
2558 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002559}
Roland McGrath279d3782004-03-01 20:27:37 +00002560
Dmitry V. Levin1b0bae22012-03-11 22:32:26 +00002561int
2562sys_get_robust_list(struct tcb *tcp)
2563{
2564 if (entering(tcp)) {
2565 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2566 } else {
2567 void *addr;
2568 size_t len;
2569
2570 if (syserror(tcp) ||
2571 !tcp->u_arg[1] ||
2572 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2573 tprintf("%#lx, ", tcp->u_arg[1]);
2574 } else {
2575 tprintf("[%p], ", addr);
2576 }
2577
2578 if (syserror(tcp) ||
2579 !tcp->u_arg[2] ||
2580 umove(tcp, tcp->u_arg[2], &len) < 0) {
2581 tprintf("%#lx", tcp->u_arg[2]);
2582 } else {
2583 tprintf("[%lu]", (unsigned long) len);
2584 }
2585 }
2586 return 0;
2587}
2588
Roland McGrathd9f816f2004-09-04 03:39:20 +00002589static const struct xlat schedulers[] = {
Roland McGrath279d3782004-03-01 20:27:37 +00002590 { SCHED_OTHER, "SCHED_OTHER" },
2591 { SCHED_RR, "SCHED_RR" },
2592 { SCHED_FIFO, "SCHED_FIFO" },
2593 { 0, NULL }
2594};
2595
2596int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002597sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002598{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002599 if (entering(tcp)) {
2600 tprintf("%d", (int) tcp->u_arg[0]);
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002601 } else if (!syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002602 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002603 if (tcp->auxstr != NULL)
2604 return RVAL_STR;
2605 }
2606 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002607}
2608
2609int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002610sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002611{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002612 if (entering(tcp)) {
2613 struct sched_param p;
2614 tprintf("%d, ", (int) tcp->u_arg[0]);
2615 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2616 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2617 tprintf(", %#lx", tcp->u_arg[2]);
2618 else
2619 tprintf(", { %d }", p.__sched_priority);
2620 }
2621 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002622}
2623
2624int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002625sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002626{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002627 if (entering(tcp)) {
2628 tprintf("%d, ", (int) tcp->u_arg[0]);
2629 } else {
2630 struct sched_param p;
2631 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2632 tprintf("%#lx", tcp->u_arg[1]);
2633 else
2634 tprintf("{ %d }", p.__sched_priority);
2635 }
2636 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002637}
2638
2639int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002640sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002641{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002642 if (entering(tcp)) {
2643 struct sched_param p;
2644 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2645 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2646 else
2647 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2648 }
2649 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002650}
2651
2652int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002653sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002654{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002655 if (entering(tcp)) {
2656 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2657 }
2658 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002659}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002660
Dmitry V. Levin1ff463d2012-03-11 23:00:11 +00002661int
2662sys_sched_rr_get_interval(struct tcb *tcp)
2663{
2664 if (entering(tcp)) {
2665 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2666 } else {
2667 if (syserror(tcp))
2668 tprintf("%#lx", tcp->u_arg[1]);
2669 else
2670 print_timespec(tcp, tcp->u_arg[1]);
2671 }
2672 return 0;
2673}
2674
H.J. Lu35be5812012-04-16 13:00:01 +02002675#if defined X86_64 || defined X32
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002676# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002677
2678static const struct xlat archvals[] = {
2679 { ARCH_SET_GS, "ARCH_SET_GS" },
2680 { ARCH_SET_FS, "ARCH_SET_FS" },
2681 { ARCH_GET_FS, "ARCH_GET_FS" },
2682 { ARCH_GET_GS, "ARCH_GET_GS" },
2683 { 0, NULL },
2684};
2685
2686int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002687sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002688{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002689 if (entering(tcp)) {
2690 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2691 if (tcp->u_arg[0] == ARCH_SET_GS
2692 || tcp->u_arg[0] == ARCH_SET_FS
2693 ) {
2694 tprintf(", %#lx", tcp->u_arg[1]);
2695 }
2696 } else {
2697 if (tcp->u_arg[0] == ARCH_GET_GS
2698 || tcp->u_arg[0] == ARCH_GET_FS
2699 ) {
2700 long int v;
2701 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2702 tprintf(", [%#lx]", v);
2703 else
2704 tprintf(", %#lx", tcp->u_arg[1]);
2705 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002706 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002707 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002708}
H.J. Lu35be5812012-04-16 13:00:01 +02002709#endif /* X86_64 || X32 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002710
Roland McGrathdb8319f2007-08-02 01:37:55 +00002711int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002712sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002713{
2714 if (exiting(tcp)) {
2715 unsigned u;
2716 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002717 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002718 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2719 tprintf("%#lx, ", tcp->u_arg[0]);
2720 else
2721 tprintf("[%u], ", u);
2722 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002723 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002724 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2725 tprintf("%#lx, ", tcp->u_arg[1]);
2726 else
2727 tprintf("[%u], ", u);
2728 tprintf("%#lx", tcp->u_arg[2]);
2729 }
2730 return 0;
2731}
2732
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002733int
2734sys_process_vm_readv(struct tcb *tcp)
2735{
2736 if (entering(tcp)) {
2737 /* arg 1: pid */
2738 tprintf("%ld, ", tcp->u_arg[0]);
2739 } else {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002740 /* arg 2: local iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002741 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002742 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002743 } else {
2744 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2745 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002746 /* arg 3: local iovcnt */
2747 tprintf(", %lu, ", tcp->u_arg[2]);
2748 /* arg 4: remote iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002749 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002750 tprintf("%#lx", tcp->u_arg[3]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002751 } else {
2752 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2753 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002754 /* arg 5: remote iovcnt */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002755 /* arg 6: flags */
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002756 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002757 }
2758 return 0;
2759}
Dmitry V. Levin03952102012-03-10 14:14:49 +00002760
2761int
2762sys_process_vm_writev(struct tcb *tcp)
2763{
2764 if (entering(tcp)) {
2765 /* arg 1: pid */
2766 tprintf("%ld, ", tcp->u_arg[0]);
2767 /* arg 2: local iov */
2768 if (syserror(tcp))
2769 tprintf("%#lx", tcp->u_arg[1]);
2770 else
2771 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2772 /* arg 3: local iovcnt */
2773 tprintf(", %lu, ", tcp->u_arg[2]);
2774 /* arg 4: remote iov */
2775 if (syserror(tcp))
2776 tprintf("%#lx", tcp->u_arg[3]);
2777 else
2778 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2779 /* arg 5: remote iovcnt */
2780 /* arg 6: flags */
2781 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
2782 }
2783 return 0;
2784}