blob: d4aa35242d0785a2f5542276d6717c8c4588f7ed [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[] = {
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000421 { CLONE_VM, "CLONE_VM" },
422 { CLONE_FS, "CLONE_FS" },
423 { CLONE_FILES, "CLONE_FILES" },
424 { CLONE_SIGHAND, "CLONE_SIGHAND" },
Roland McGrath909875b2002-12-22 03:34:36 +0000425 { CLONE_IDLETASK, "CLONE_IDLETASK"},
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000426 { CLONE_PTRACE, "CLONE_PTRACE" },
427 { CLONE_VFORK, "CLONE_VFORK" },
428 { CLONE_PARENT, "CLONE_PARENT" },
Roland McGrath909875b2002-12-22 03:34:36 +0000429 { 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" },
Roland McGrath909875b2002-12-22 03:34:36 +0000435 { CLONE_UNTRACED, "CLONE_UNTRACED" },
436 { CLONE_CHILD_SETTID,"CLONE_CHILD_SETTID" },
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000437 { 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" },
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000444 { 0, NULL },
445};
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
468#elif defined X86_64 || defined ALPHA
469# define ARG_FLAGS 0
470# define ARG_STACK 1
471# define ARG_PTID 2
472# define ARG_CTID 3
473# define ARG_TLS 4
474#else
475# define ARG_FLAGS 0
476# define ARG_STACK 1
477# define ARG_PTID 2
478# define ARG_TLS 3
479# define ARG_CTID 4
480#endif
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 Vlasenko12014262011-05-30 14:00:14 +0200534sys_fork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000535{
536 if (exiting(tcp))
537 return RVAL_UDECIMAL;
538 return 0;
539}
540
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000541int
Denys Vlasenko418d66a2009-01-17 01:52:54 +0000542change_syscall(struct tcb *tcp, int new)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000543{
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000544#if defined(I386)
545 /* Attempt to make vfork into fork, which we can follow. */
Roland McGrath5a223472002-12-15 23:58:26 +0000546 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000547 return -1;
548 return 0;
Michal Ludvig0e035502002-09-23 15:41:01 +0000549#elif defined(X86_64)
550 /* Attempt to make vfork into fork, which we can follow. */
Roland McGrath5a223472002-12-15 23:58:26 +0000551 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_RAX * 8), new) < 0)
Michal Ludvig0e035502002-09-23 15:41:01 +0000552 return -1;
553 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000554#elif defined(POWERPC)
Roland McGratheb285352003-01-14 09:59:00 +0000555 if (ptrace(PTRACE_POKEUSER, tcp->pid,
556 (char*)(sizeof(unsigned long)*PT_R0), new) < 0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000557 return -1;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000558 return 0;
Michal Ludvig10a88d02002-10-07 14:31:00 +0000559#elif defined(S390) || defined(S390X)
560 /* s390 linux after 2.4.7 has a hook in entry.S to allow this */
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200561 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR2), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000562 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000563 return 0;
564#elif defined(M68K)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200565 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_ORIG_D0), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000566 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000567 return 0;
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000568#elif defined(SPARC) || defined(SPARC64)
Mike Frysinger8566c502009-10-12 11:05:14 -0400569 struct pt_regs regs;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200570 if (ptrace(PTRACE_GETREGS, tcp->pid, (char*)&regs, 0) < 0)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000571 return -1;
Mike Frysinger8566c502009-10-12 11:05:14 -0400572 regs.u_regs[U_REG_G1] = new;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200573 if (ptrace(PTRACE_SETREGS, tcp->pid, (char*)&regs, 0) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000574 return -1;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000575 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000576#elif defined(MIPS)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200577 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000578 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000579 return 0;
580#elif defined(ALPHA)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200581 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000582 return -1;
583 return 0;
584#elif defined(AVR32)
585 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_R8), new) < 0)
586 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000587 return 0;
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000588#elif defined(BFIN)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200589 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_P0), new) < 0)
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000590 return -1;
591 return 0;
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000592#elif defined(IA64)
Roland McGrath08267b82004-02-20 22:56:43 +0000593 if (ia32) {
594 switch (new) {
Denys Vlasenko418d66a2009-01-17 01:52:54 +0000595 case 2:
596 break; /* x86 SYS_fork */
597 case SYS_clone:
598 new = 120;
599 break;
600 default:
Roland McGrath08267b82004-02-20 22:56:43 +0000601 fprintf(stderr, "%s: unexpected syscall %d\n",
602 __FUNCTION__, new);
603 return -1;
604 }
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200605 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R1), new) < 0)
Roland McGrath08267b82004-02-20 22:56:43 +0000606 return -1;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200607 } else if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R15), new) < 0)
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000608 return -1;
609 return 0;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000610#elif defined(HPPA)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200611 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR20), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000612 return -1;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000613 return 0;
Wichert Akkermanccef6372002-05-01 16:39:22 +0000614#elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200615 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*(REG_REG0+3)), new) < 0)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000616 return -1;
617 return 0;
Roland McGrathf5a47772003-06-26 22:40:42 +0000618#elif defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000619 /* Top half of reg encodes the no. of args n as 0x1n.
620 Assume 0 args as kernel never actually checks... */
621 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_SYSCALL),
622 0x100000 | new) < 0)
623 return -1;
624 return 0;
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +0000625#elif defined(CRISV10) || defined(CRISV32)
626 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R9), new) < 0)
627 return -1;
628 return 0;
Roland McGrathf691bd22006-04-25 07:34:41 +0000629#elif defined(ARM)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000630 /* Some kernels support this, some (pre-2.6.16 or so) don't. */
Roland McGrathf691bd22006-04-25 07:34:41 +0000631# ifndef PTRACE_SET_SYSCALL
632# define PTRACE_SET_SYSCALL 23
633# endif
634
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200635 if (ptrace(PTRACE_SET_SYSCALL, tcp->pid, 0, new & 0xffff) != 0)
Roland McGrathf691bd22006-04-25 07:34:41 +0000636 return -1;
637
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000638 return 0;
Chris Metcalfc8c66982009-12-28 10:00:15 -0500639#elif defined(TILE)
640 if (ptrace(PTRACE_POKEUSER, tcp->pid,
641 (char*)PTREGS_OFFSET_REG(0),
642 new) != 0)
643 return -1;
644 return 0;
Edgar E. Iglesias939caba2010-07-06 14:21:07 +0200645#elif defined(MICROBLAZE)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200646 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new) < 0)
Edgar E. Iglesias939caba2010-07-06 14:21:07 +0200647 return -1;
648 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000649#else
650#warning Do not know how to handle change_syscall for this architecture
651#endif /* architecture */
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000652 return -1;
653}
654
Wang Chaoca8ab8d2010-11-12 17:26:08 +0800655int
Dmitry V. Levin257e1572009-12-26 17:55:24 +0000656internal_fork(struct tcb *tcp)
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000657{
Denys Vlasenkof44cce42011-06-21 14:34:10 +0200658 if ((ptrace_setoptions
Wang Chaoca8ab8d2010-11-12 17:26:08 +0800659 & (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
660 == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
661 return 0;
662
Denys Vlasenko65d7c4d2011-06-23 21:46:37 +0200663 if (!followfork)
664 return 0;
665
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000666 if (entering(tcp)) {
Wang Chaoe636c852010-09-16 11:20:56 +0800667 /*
Denys Vlasenko833fb132011-08-17 11:30:56 +0200668 * We won't see the new child if clone is called with
669 * CLONE_UNTRACED, so we keep the same logic with that option
670 * and don't trace it.
Wang Chaoe636c852010-09-16 11:20:56 +0800671 */
672 if ((sysent[tcp->scno].sys_func == sys_clone) &&
673 (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED))
674 return 0;
Denys Vlasenkoe7c90242011-06-22 00:09:25 +0200675 setbpt(tcp);
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000676 } else {
Denys Vlasenko833fb132011-08-17 11:30:56 +0200677 if (tcp->flags & TCB_BPTSET)
678 clearbpt(tcp);
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000679 }
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000680 return 0;
681}
Dmitry V. Levin257e1572009-12-26 17:55:24 +0000682
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000683int
Denys Vlasenko12014262011-05-30 14:00:14 +0200684sys_vfork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000685{
686 if (exiting(tcp))
687 return RVAL_UDECIMAL;
688 return 0;
689}
690
Dmitry V. Levin50a218d2011-01-18 17:36:20 +0000691int sys_getuid(struct tcb *tcp)
692{
693 if (exiting(tcp))
694 tcp->u_rval = (uid_t) tcp->u_rval;
695 return RVAL_UDECIMAL;
696}
697
698int sys_setfsuid(struct tcb *tcp)
699{
700 if (entering(tcp))
701 tprintf("%u", (uid_t) tcp->u_arg[0]);
702 else
703 tcp->u_rval = (uid_t) tcp->u_rval;
704 return RVAL_UDECIMAL;
705}
706
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000707int
Denys Vlasenko12014262011-05-30 14:00:14 +0200708sys_setuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000709{
710 if (entering(tcp)) {
711 tprintf("%u", (uid_t) tcp->u_arg[0]);
712 }
713 return 0;
714}
715
716int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000717sys_getresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000718{
719 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000720 __kernel_uid_t uid;
721 if (syserror(tcp))
722 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
723 tcp->u_arg[1], tcp->u_arg[2]);
724 else {
725 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
726 tprintf("%#lx, ", tcp->u_arg[0]);
727 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000728 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000729 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
730 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000731 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000732 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000733 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
734 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000735 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000736 tprintf("[%lu]", (unsigned long) uid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000737 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000738 }
739 return 0;
740}
741
742int
Denys Vlasenko12014262011-05-30 14:00:14 +0200743sys_setreuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000744{
745 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000746 printuid("", tcp->u_arg[0]);
747 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000748 }
749 return 0;
750}
751
752int
Denys Vlasenko12014262011-05-30 14:00:14 +0200753sys_setresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000754{
755 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000756 printuid("", tcp->u_arg[0]);
757 printuid(", ", tcp->u_arg[1]);
758 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000759 }
760 return 0;
761}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000762
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000763int
Denys Vlasenko12014262011-05-30 14:00:14 +0200764sys_setgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000765{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000766 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000767 unsigned long len, size, start, cur, end, abbrev_end;
768 GETGROUPS_T gid;
769 int failed = 0;
770
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000771 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000772 tprintf("%lu, ", len);
773 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200774 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000775 return 0;
776 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000777 start = tcp->u_arg[1];
778 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200779 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000780 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000781 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000782 size = len * sizeof(gid);
783 end = start + size;
784 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
785 tprintf("%#lx", start);
786 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000787 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000788 if (abbrev(tcp)) {
789 abbrev_end = start + max_strlen * sizeof(gid);
790 if (abbrev_end < start)
791 abbrev_end = end;
792 } else {
793 abbrev_end = end;
794 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200795 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000796 for (cur = start; cur < end; cur += sizeof(gid)) {
797 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200798 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000799 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200800 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000801 break;
802 }
803 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200804 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000805 failed = 1;
806 break;
807 }
808 tprintf("%lu", (unsigned long) gid);
809 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200810 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000811 if (failed)
812 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000813 }
814 return 0;
815}
816
817int
Denys Vlasenko12014262011-05-30 14:00:14 +0200818sys_getgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000819{
Roland McGrathaa524c82005-06-01 19:22:06 +0000820 unsigned long len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000821
822 if (entering(tcp)) {
823 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000824 tprintf("%lu, ", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000825 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000826 unsigned long size, start, cur, end, abbrev_end;
827 GETGROUPS_T gid;
828 int failed = 0;
829
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000830 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000831 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200832 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000833 return 0;
834 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000835 start = tcp->u_arg[1];
836 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200837 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000838 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000839 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000840 if (tcp->u_arg[0] == 0) {
841 tprintf("%#lx", start);
842 return 0;
843 }
844 size = len * sizeof(gid);
845 end = start + size;
846 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
847 size / sizeof(gid) != len || end < start) {
848 tprintf("%#lx", start);
849 return 0;
850 }
851 if (abbrev(tcp)) {
852 abbrev_end = start + max_strlen * sizeof(gid);
853 if (abbrev_end < start)
854 abbrev_end = end;
855 } else {
856 abbrev_end = end;
857 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200858 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000859 for (cur = start; cur < end; cur += sizeof(gid)) {
860 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200861 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000862 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200863 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000864 break;
865 }
866 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200867 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000868 failed = 1;
869 break;
870 }
871 tprintf("%lu", (unsigned long) gid);
872 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200873 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000874 if (failed)
875 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000876 }
877 return 0;
878}
879
Roland McGrath83bd47a2003-11-13 22:32:26 +0000880int
Denys Vlasenko12014262011-05-30 14:00:14 +0200881sys_setgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000882{
Roland McGrath83bd47a2003-11-13 22:32:26 +0000883 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000884 unsigned long len, size, start, cur, end, abbrev_end;
885 GETGROUPS32_T gid;
886 int failed = 0;
887
Roland McGrath83bd47a2003-11-13 22:32:26 +0000888 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000889 tprintf("%lu, ", len);
890 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200891 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000892 return 0;
893 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000894 start = tcp->u_arg[1];
895 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200896 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000897 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000898 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000899 size = len * sizeof(gid);
900 end = start + size;
901 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
902 tprintf("%#lx", start);
903 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000904 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000905 if (abbrev(tcp)) {
906 abbrev_end = start + max_strlen * sizeof(gid);
907 if (abbrev_end < start)
908 abbrev_end = end;
909 } else {
910 abbrev_end = end;
911 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200912 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000913 for (cur = start; cur < end; cur += sizeof(gid)) {
914 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200915 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000916 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200917 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000918 break;
919 }
920 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200921 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000922 failed = 1;
923 break;
924 }
925 tprintf("%lu", (unsigned long) gid);
926 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200927 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000928 if (failed)
929 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000930 }
931 return 0;
932}
933
934int
Denys Vlasenko12014262011-05-30 14:00:14 +0200935sys_getgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000936{
Roland McGrathaa524c82005-06-01 19:22:06 +0000937 unsigned long len;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000938
939 if (entering(tcp)) {
940 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000941 tprintf("%lu, ", len);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000942 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000943 unsigned long size, start, cur, end, abbrev_end;
944 GETGROUPS32_T gid;
945 int failed = 0;
946
Roland McGrath83bd47a2003-11-13 22:32:26 +0000947 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000948 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200949 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000950 return 0;
951 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000952 start = tcp->u_arg[1];
953 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200954 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000955 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000956 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000957 size = len * sizeof(gid);
958 end = start + size;
959 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
960 size / sizeof(gid) != len || end < start) {
961 tprintf("%#lx", start);
962 return 0;
963 }
964 if (abbrev(tcp)) {
965 abbrev_end = start + max_strlen * sizeof(gid);
966 if (abbrev_end < start)
967 abbrev_end = end;
968 } else {
969 abbrev_end = end;
970 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200971 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000972 for (cur = start; cur < end; cur += sizeof(gid)) {
973 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200974 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000975 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200976 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000977 break;
978 }
979 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200980 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000981 failed = 1;
982 break;
983 }
984 tprintf("%lu", (unsigned long) gid);
985 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200986 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000987 if (failed)
988 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000989 }
990 return 0;
991}
Roland McGrath83bd47a2003-11-13 22:32:26 +0000992
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000993static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000994printargv(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000995{
Roland McGrath85a3bc42007-08-02 02:13:05 +0000996 union {
Andreas Schwab99c85692009-08-28 19:36:20 +0200997 unsigned int p32;
998 unsigned long p64;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000999 char data[sizeof(long)];
1000 } cp;
Dmitry V. Levin30145dd2010-09-06 22:08:24 +00001001 const char *sep;
Roland McGrath85a3bc42007-08-02 02:13:05 +00001002 int n = 0;
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001003 unsigned wordsize = personality_wordsize[current_personality];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001004
Roland McGrath85a3bc42007-08-02 02:13:05 +00001005 cp.p64 = 1;
1006 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001007 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001008 tprintf("%#lx", addr);
1009 return;
1010 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001011 if (wordsize == 4)
Roland McGrath85a3bc42007-08-02 02:13:05 +00001012 cp.p64 = cp.p32;
1013 if (cp.p64 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001014 break;
Denys Vlasenko5940e652011-09-01 09:55:05 +02001015 tprints(sep);
Roland McGrath85a3bc42007-08-02 02:13:05 +00001016 printstr(tcp, cp.p64, -1);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001017 addr += wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001018 }
Roland McGrath85a3bc42007-08-02 02:13:05 +00001019 if (cp.p64)
1020 tprintf("%s...", sep);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001021}
1022
1023static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +00001024printargc(const char *fmt, struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001025{
1026 int count;
1027 char *cp;
1028
1029 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
1030 addr += sizeof(char *);
1031 }
1032 tprintf(fmt, count, count == 1 ? "" : "s");
1033}
1034
Denys Vlasenko84703742012-02-25 02:38:52 +01001035#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001036int
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001037sys_execv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001038{
1039 if (entering(tcp)) {
1040 printpath(tcp, tcp->u_arg[0]);
1041 if (!verbose(tcp))
1042 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001043 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001044 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001045 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001046 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001047 }
1048 }
1049 return 0;
1050}
Denys Vlasenko84703742012-02-25 02:38:52 +01001051#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001052
1053int
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001054sys_execve(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001055{
1056 if (entering(tcp)) {
1057 printpath(tcp, tcp->u_arg[0]);
1058 if (!verbose(tcp))
1059 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001060 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001061 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001062 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001063 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001064 }
1065 if (!verbose(tcp))
1066 tprintf(", %#lx", tcp->u_arg[2]);
1067 else if (abbrev(tcp))
1068 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
1069 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001070 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001071 printargv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001072 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001073 }
1074 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001075 return 0;
1076}
1077
Denys Vlasenko84703742012-02-25 02:38:52 +01001078#if defined(TCB_WAITEXECVE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001079int
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001080internal_exec(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001081{
Roland McGrathfdb097f2004-07-12 07:38:55 +00001082 if (exiting(tcp) && syserror(tcp))
1083 tcp->flags &= ~TCB_WAITEXECVE;
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001084 else {
1085 /* Maybe we have post-execve SIGTRAP suppressed? */
Denys Vlasenkof44cce42011-06-21 14:34:10 +02001086 if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC))
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001087 tcp->flags |= TCB_WAITEXECVE; /* no */
1088 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001089 return 0;
1090}
Denys Vlasenkoa7949742011-08-21 17:26:55 +02001091#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001092
Roland McGrath7ec1d352002-12-17 04:50:44 +00001093#ifndef __WNOTHREAD
1094#define __WNOTHREAD 0x20000000
1095#endif
1096#ifndef __WALL
1097#define __WALL 0x40000000
1098#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001099#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +00001100#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001101#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001102
Roland McGrathd9f816f2004-09-04 03:39:20 +00001103static const struct xlat wait4_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001104 { WNOHANG, "WNOHANG" },
1105#ifndef WSTOPPED
1106 { WUNTRACED, "WUNTRACED" },
1107#endif
1108#ifdef WEXITED
1109 { WEXITED, "WEXITED" },
1110#endif
1111#ifdef WTRAPPED
1112 { WTRAPPED, "WTRAPPED" },
1113#endif
1114#ifdef WSTOPPED
1115 { WSTOPPED, "WSTOPPED" },
1116#endif
1117#ifdef WCONTINUED
1118 { WCONTINUED, "WCONTINUED" },
1119#endif
1120#ifdef WNOWAIT
1121 { WNOWAIT, "WNOWAIT" },
1122#endif
1123#ifdef __WCLONE
1124 { __WCLONE, "__WCLONE" },
1125#endif
Roland McGrath7ec1d352002-12-17 04:50:44 +00001126#ifdef __WALL
1127 { __WALL, "__WALL" },
1128#endif
1129#ifdef __WNOTHREAD
1130 { __WNOTHREAD, "__WNOTHREAD" },
1131#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001132 { 0, NULL },
1133};
1134
Roland McGrath5e02a572004-10-19 23:33:47 +00001135#if !defined WCOREFLAG && defined WCOREFLG
1136# define WCOREFLAG WCOREFLG
1137#endif
1138#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001139# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +00001140#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001141#ifndef WCOREDUMP
1142# define WCOREDUMP(status) ((status) & 0200)
1143#endif
1144
Roland McGrath5e02a572004-10-19 23:33:47 +00001145#ifndef W_STOPCODE
1146#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
1147#endif
1148#ifndef W_EXITCODE
1149#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
1150#endif
1151
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001152static int
Denys Vlasenko12014262011-05-30 14:00:14 +02001153printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001154{
1155 int exited = 0;
1156
1157 /*
1158 * Here is a tricky presentation problem. This solution
1159 * is still not entirely satisfactory but since there
1160 * are no wait status constructors it will have to do.
1161 */
Roland McGrath79fbda52004-04-14 02:45:55 +00001162 if (WIFSTOPPED(status)) {
1163 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001164 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +00001165 status &= ~W_STOPCODE(WSTOPSIG(status));
1166 }
1167 else if (WIFSIGNALED(status)) {
1168 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001169 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001170 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +00001171 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1172 }
1173 else if (WIFEXITED(status)) {
1174 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001175 WEXITSTATUS(status));
1176 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +00001177 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001178 }
Roland McGrath79fbda52004-04-14 02:45:55 +00001179 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001180 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001181 return 0;
1182 }
1183
1184 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001185 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +00001186 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +00001187 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001188
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001189 return exited;
1190}
1191
1192static int
Denys Vlasenko59432db2009-01-26 19:09:35 +00001193printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001194{
1195 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001196
1197 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001198 /* On Linux, kernel-side pid_t is typedef'ed to int
1199 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +00001200 * pid argument to int on 64bit arches, producing,
1201 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001202 * in strace. We have to use int here, not long.
1203 */
1204 int pid = tcp->u_arg[0];
1205 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001206 } else {
1207 /* status */
1208 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001209 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001210 else if (syserror(tcp) || tcp->u_rval == 0)
1211 tprintf("%#lx", tcp->u_arg[1]);
1212 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001213 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001214 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +00001215 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001216 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001217 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001218 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001219 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001220 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001221 /* usage */
1222 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001223 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001224 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +00001225#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001226 if (bitness)
1227 printrusage32(tcp, tcp->u_arg[3]);
1228 else
1229#endif
1230 printrusage(tcp, tcp->u_arg[3]);
1231 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001232 else
1233 tprintf("%#lx", tcp->u_arg[3]);
1234 }
1235 }
1236 return 0;
1237}
1238
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001239int
Denys Vlasenko12014262011-05-30 14:00:14 +02001240sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001241{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001242 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001243}
1244
1245int
Denys Vlasenko12014262011-05-30 14:00:14 +02001246sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001247{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001248 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001249}
1250
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001251#ifdef ALPHA
1252int
Denys Vlasenko12014262011-05-30 14:00:14 +02001253sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001254{
1255 return printwaitn(tcp, 4, 1);
1256}
1257#endif
1258
Roland McGrathd9f816f2004-09-04 03:39:20 +00001259static const struct xlat waitid_types[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001260 { P_PID, "P_PID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001261#ifdef P_PPID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001262 { P_PPID, "P_PPID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001263#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001264 { P_PGID, "P_PGID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001265#ifdef P_SID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001266 { P_SID, "P_SID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001267#endif
1268#ifdef P_CID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001269 { P_CID, "P_CID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001270#endif
1271#ifdef P_UID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001272 { P_UID, "P_UID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001273#endif
1274#ifdef P_GID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001275 { P_GID, "P_GID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001276#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001277 { P_ALL, "P_ALL" },
1278#ifdef P_LWPID
1279 { P_LWPID, "P_LWPID" },
1280#endif
1281 { 0, NULL },
1282};
1283
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001284int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +00001285sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001286{
1287 siginfo_t si;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001288
1289 if (entering(tcp)) {
1290 printxval(waitid_types, tcp->u_arg[0], "P_???");
1291 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001292 }
1293 else {
1294 /* siginfo */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001295 if (!tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001296 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001297 else if (syserror(tcp))
1298 tprintf("%#lx", tcp->u_arg[2]);
1299 else if (umove(tcp, tcp->u_arg[2], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001300 tprints("{???}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001301 else
Denys Vlasenkof535b542009-01-13 18:30:55 +00001302 printsiginfo(&si, verbose(tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001303 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001304 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001305 printflags(wait4_options, tcp->u_arg[3], "W???");
Roland McGrath39426a32004-10-06 22:02:59 +00001306 if (tcp->u_nargs > 4) {
1307 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001308 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +00001309 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001310 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +00001311 else if (tcp->u_error)
1312 tprintf("%#lx", tcp->u_arg[4]);
1313 else
1314 printrusage(tcp, tcp->u_arg[4]);
1315 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001316 }
1317 return 0;
1318}
1319
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001320int
Denys Vlasenko12014262011-05-30 14:00:14 +02001321sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001322{
1323 struct utsname uname;
1324
1325 if (exiting(tcp)) {
1326 if (syserror(tcp) || !verbose(tcp))
1327 tprintf("%#lx", tcp->u_arg[0]);
1328 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001329 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001330 else if (!abbrev(tcp)) {
1331
1332 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1333 uname.sysname, uname.nodename);
1334 tprintf("release=\"%s\", version=\"%s\", ",
1335 uname.release, uname.version);
1336 tprintf("machine=\"%s\"", uname.machine);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001337#ifndef __GLIBC__
1338 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001339#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001340 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001341 }
1342 else
1343 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1344 uname.sysname, uname.nodename);
1345 }
1346 return 0;
1347}
1348
Roland McGratheb9e2e82009-06-02 16:49:22 -07001349static const struct xlat ptrace_cmds[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001350 { PTRACE_TRACEME, "PTRACE_TRACEME" },
Denys Vlasenko61526c62011-08-25 10:21:13 +02001351 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1352 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1353 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1354 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1355 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1356 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001357 { PTRACE_CONT, "PTRACE_CONT" },
1358 { PTRACE_KILL, "PTRACE_KILL" },
1359 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1360 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1361 { PTRACE_DETACH, "PTRACE_DETACH" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001362# ifdef PTRACE_GETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001363 { PTRACE_GETREGS, "PTRACE_GETREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001364# endif
1365# ifdef PTRACE_SETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001366 { PTRACE_SETREGS, "PTRACE_SETREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001367# endif
1368# ifdef PTRACE_GETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001369 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001370# endif
1371# ifdef PTRACE_SETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001372 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001373# endif
1374# ifdef PTRACE_GETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001375 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001376# endif
1377# ifdef PTRACE_SETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001378 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001379# endif
1380# ifdef PTRACE_GETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001381 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001382# endif
1383# ifdef PTRACE_SETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001384 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001385# endif
1386# ifdef PTRACE_SETOPTIONS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001387 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001388# endif
1389# ifdef PTRACE_GETEVENTMSG
Denys Vlasenko61526c62011-08-25 10:21:13 +02001390 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001391# endif
1392# ifdef PTRACE_GETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001393 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001394# endif
1395# ifdef PTRACE_SETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001396 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001397# endif
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001398# ifdef PTRACE_GETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001399 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001400# endif
1401# ifdef PTRACE_SETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001402 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001403# endif
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001404# ifdef PTRACE_SET_SYSCALL
Denys Vlasenko61526c62011-08-25 10:21:13 +02001405 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001406# endif
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001407# ifdef PTRACE_SEIZE
1408 { PTRACE_SEIZE, "PTRACE_SEIZE" },
1409# endif
1410# ifdef PTRACE_INTERRUPT
1411 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
1412# endif
1413# ifdef PTRACE_LISTEN
1414 { PTRACE_LISTEN, "PTRACE_LISTEN" },
1415# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001416 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
Denys Vlasenkof535b542009-01-13 18:30:55 +00001417
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001418 { 0, NULL },
1419};
1420
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001421# ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00001422static const struct xlat ptrace_setoptions_flags[] = {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001423# ifdef PTRACE_O_TRACESYSGOOD
Denys Vlasenkof535b542009-01-13 18:30:55 +00001424 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001425# endif
1426# ifdef PTRACE_O_TRACEFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001427 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001428# endif
1429# ifdef PTRACE_O_TRACEVFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001430 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001431# endif
1432# ifdef PTRACE_O_TRACECLONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001433 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001434# endif
1435# ifdef PTRACE_O_TRACEEXEC
Denys Vlasenkof535b542009-01-13 18:30:55 +00001436 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001437# endif
1438# ifdef PTRACE_O_TRACEVFORKDONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001439 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001440# endif
1441# ifdef PTRACE_O_TRACEEXIT
Denys Vlasenkof535b542009-01-13 18:30:55 +00001442 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001443# endif
Denys Vlasenkof535b542009-01-13 18:30:55 +00001444 { 0, NULL },
1445};
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001446# endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001447
Roland McGrathd9f816f2004-09-04 03:39:20 +00001448const struct xlat struct_user_offsets[] = {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001449# if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001450 { PT_PSWMASK, "psw_mask" },
1451 { PT_PSWADDR, "psw_addr" },
1452 { PT_GPR0, "gpr0" },
1453 { PT_GPR1, "gpr1" },
1454 { PT_GPR2, "gpr2" },
1455 { PT_GPR3, "gpr3" },
1456 { PT_GPR4, "gpr4" },
1457 { PT_GPR5, "gpr5" },
1458 { PT_GPR6, "gpr6" },
1459 { PT_GPR7, "gpr7" },
1460 { PT_GPR8, "gpr8" },
1461 { PT_GPR9, "gpr9" },
1462 { PT_GPR10, "gpr10" },
1463 { PT_GPR11, "gpr11" },
1464 { PT_GPR12, "gpr12" },
1465 { PT_GPR13, "gpr13" },
1466 { PT_GPR14, "gpr14" },
1467 { PT_GPR15, "gpr15" },
1468 { PT_ACR0, "acr0" },
1469 { PT_ACR1, "acr1" },
1470 { PT_ACR2, "acr2" },
1471 { PT_ACR3, "acr3" },
1472 { PT_ACR4, "acr4" },
1473 { PT_ACR5, "acr5" },
1474 { PT_ACR6, "acr6" },
1475 { PT_ACR7, "acr7" },
1476 { PT_ACR8, "acr8" },
1477 { PT_ACR9, "acr9" },
1478 { PT_ACR10, "acr10" },
1479 { PT_ACR11, "acr11" },
1480 { PT_ACR12, "acr12" },
1481 { PT_ACR13, "acr13" },
1482 { PT_ACR14, "acr14" },
1483 { PT_ACR15, "acr15" },
1484 { PT_ORIGGPR2, "orig_gpr2" },
1485 { PT_FPC, "fpc" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001486# if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001487 { PT_FPR0_HI, "fpr0.hi" },
1488 { PT_FPR0_LO, "fpr0.lo" },
1489 { PT_FPR1_HI, "fpr1.hi" },
1490 { PT_FPR1_LO, "fpr1.lo" },
1491 { PT_FPR2_HI, "fpr2.hi" },
1492 { PT_FPR2_LO, "fpr2.lo" },
1493 { PT_FPR3_HI, "fpr3.hi" },
1494 { PT_FPR3_LO, "fpr3.lo" },
1495 { PT_FPR4_HI, "fpr4.hi" },
1496 { PT_FPR4_LO, "fpr4.lo" },
1497 { PT_FPR5_HI, "fpr5.hi" },
1498 { PT_FPR5_LO, "fpr5.lo" },
1499 { PT_FPR6_HI, "fpr6.hi" },
1500 { PT_FPR6_LO, "fpr6.lo" },
1501 { PT_FPR7_HI, "fpr7.hi" },
1502 { PT_FPR7_LO, "fpr7.lo" },
1503 { PT_FPR8_HI, "fpr8.hi" },
1504 { PT_FPR8_LO, "fpr8.lo" },
1505 { PT_FPR9_HI, "fpr9.hi" },
1506 { PT_FPR9_LO, "fpr9.lo" },
1507 { PT_FPR10_HI, "fpr10.hi" },
1508 { PT_FPR10_LO, "fpr10.lo" },
1509 { PT_FPR11_HI, "fpr11.hi" },
1510 { PT_FPR11_LO, "fpr11.lo" },
1511 { PT_FPR12_HI, "fpr12.hi" },
1512 { PT_FPR12_LO, "fpr12.lo" },
1513 { PT_FPR13_HI, "fpr13.hi" },
1514 { PT_FPR13_LO, "fpr13.lo" },
1515 { PT_FPR14_HI, "fpr14.hi" },
1516 { PT_FPR14_LO, "fpr14.lo" },
1517 { PT_FPR15_HI, "fpr15.hi" },
1518 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001519# endif
1520# if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001521 { PT_FPR0, "fpr0" },
1522 { PT_FPR1, "fpr1" },
1523 { PT_FPR2, "fpr2" },
1524 { PT_FPR3, "fpr3" },
1525 { PT_FPR4, "fpr4" },
1526 { PT_FPR5, "fpr5" },
1527 { PT_FPR6, "fpr6" },
1528 { PT_FPR7, "fpr7" },
1529 { PT_FPR8, "fpr8" },
1530 { PT_FPR9, "fpr9" },
1531 { PT_FPR10, "fpr10" },
1532 { PT_FPR11, "fpr11" },
1533 { PT_FPR12, "fpr12" },
1534 { PT_FPR13, "fpr13" },
1535 { PT_FPR14, "fpr14" },
1536 { PT_FPR15, "fpr15" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001537# endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001538 { PT_CR_9, "cr9" },
1539 { PT_CR_10, "cr10" },
1540 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001541 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001542# elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001543 /* XXX No support for these offsets yet. */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001544# elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001545 /* XXX No support for these offsets yet. */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001546# elif defined(POWERPC)
1547# ifndef PT_ORIG_R3
1548# define PT_ORIG_R3 34
1549# endif
1550# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001551 { REGSIZE*PT_R0, "r0" },
1552 { REGSIZE*PT_R1, "r1" },
1553 { REGSIZE*PT_R2, "r2" },
1554 { REGSIZE*PT_R3, "r3" },
1555 { REGSIZE*PT_R4, "r4" },
1556 { REGSIZE*PT_R5, "r5" },
1557 { REGSIZE*PT_R6, "r6" },
1558 { REGSIZE*PT_R7, "r7" },
1559 { REGSIZE*PT_R8, "r8" },
1560 { REGSIZE*PT_R9, "r9" },
1561 { REGSIZE*PT_R10, "r10" },
1562 { REGSIZE*PT_R11, "r11" },
1563 { REGSIZE*PT_R12, "r12" },
1564 { REGSIZE*PT_R13, "r13" },
1565 { REGSIZE*PT_R14, "r14" },
1566 { REGSIZE*PT_R15, "r15" },
1567 { REGSIZE*PT_R16, "r16" },
1568 { REGSIZE*PT_R17, "r17" },
1569 { REGSIZE*PT_R18, "r18" },
1570 { REGSIZE*PT_R19, "r19" },
1571 { REGSIZE*PT_R20, "r20" },
1572 { REGSIZE*PT_R21, "r21" },
1573 { REGSIZE*PT_R22, "r22" },
1574 { REGSIZE*PT_R23, "r23" },
1575 { REGSIZE*PT_R24, "r24" },
1576 { REGSIZE*PT_R25, "r25" },
1577 { REGSIZE*PT_R26, "r26" },
1578 { REGSIZE*PT_R27, "r27" },
1579 { REGSIZE*PT_R28, "r28" },
1580 { REGSIZE*PT_R29, "r29" },
1581 { REGSIZE*PT_R30, "r30" },
1582 { REGSIZE*PT_R31, "r31" },
1583 { REGSIZE*PT_NIP, "NIP" },
1584 { REGSIZE*PT_MSR, "MSR" },
1585 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1586 { REGSIZE*PT_CTR, "CTR" },
1587 { REGSIZE*PT_LNK, "LNK" },
1588 { REGSIZE*PT_XER, "XER" },
1589 { REGSIZE*PT_CCR, "CCR" },
1590 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001591# undef REGSIZE
1592# elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001593 { 0, "r0" },
1594 { 1, "r1" },
1595 { 2, "r2" },
1596 { 3, "r3" },
1597 { 4, "r4" },
1598 { 5, "r5" },
1599 { 6, "r6" },
1600 { 7, "r7" },
1601 { 8, "r8" },
1602 { 9, "r9" },
1603 { 10, "r10" },
1604 { 11, "r11" },
1605 { 12, "r12" },
1606 { 13, "r13" },
1607 { 14, "r14" },
1608 { 15, "r15" },
1609 { 16, "r16" },
1610 { 17, "r17" },
1611 { 18, "r18" },
1612 { 19, "r19" },
1613 { 20, "r20" },
1614 { 21, "r21" },
1615 { 22, "r22" },
1616 { 23, "r23" },
1617 { 24, "r24" },
1618 { 25, "r25" },
1619 { 26, "r26" },
1620 { 27, "r27" },
1621 { 28, "r28" },
1622 { 29, "gp" },
1623 { 30, "fp" },
1624 { 31, "zero" },
1625 { 32, "fp0" },
1626 { 33, "fp" },
1627 { 34, "fp2" },
1628 { 35, "fp3" },
1629 { 36, "fp4" },
1630 { 37, "fp5" },
1631 { 38, "fp6" },
1632 { 39, "fp7" },
1633 { 40, "fp8" },
1634 { 41, "fp9" },
1635 { 42, "fp10" },
1636 { 43, "fp11" },
1637 { 44, "fp12" },
1638 { 45, "fp13" },
1639 { 46, "fp14" },
1640 { 47, "fp15" },
1641 { 48, "fp16" },
1642 { 49, "fp17" },
1643 { 50, "fp18" },
1644 { 51, "fp19" },
1645 { 52, "fp20" },
1646 { 53, "fp21" },
1647 { 54, "fp22" },
1648 { 55, "fp23" },
1649 { 56, "fp24" },
1650 { 57, "fp25" },
1651 { 58, "fp26" },
1652 { 59, "fp27" },
1653 { 60, "fp28" },
1654 { 61, "fp29" },
1655 { 62, "fp30" },
1656 { 63, "fp31" },
1657 { 64, "pc" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001658# elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001659 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1660 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1661 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1662 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1663 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1664 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1665 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1666 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1667 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1668 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1669 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1670 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1671 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1672 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1673 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1674 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1675 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1676 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1677 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1678 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1679 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1680 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1681 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1682 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1683 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1684 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1685 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1686 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1687 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1688 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1689 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1690 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1691 /* switch stack: */
1692 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1693 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1694 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1695 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1696 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1697 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1698 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1699 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1700 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1701 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001702 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1703 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001704 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001705 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001706 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1707 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001708 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1709 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1710 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1711 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1712 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1713 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1714 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1715 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1716 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1717 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1718 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1719 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1720 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1721 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1722 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001723# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001724 { PT_AR_CSD, "ar.csd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001725# endif
1726# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001727 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001728# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001729 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001730# elif defined(I386)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001731 { 4*EBX, "4*EBX" },
1732 { 4*ECX, "4*ECX" },
1733 { 4*EDX, "4*EDX" },
1734 { 4*ESI, "4*ESI" },
1735 { 4*EDI, "4*EDI" },
1736 { 4*EBP, "4*EBP" },
1737 { 4*EAX, "4*EAX" },
1738 { 4*DS, "4*DS" },
1739 { 4*ES, "4*ES" },
1740 { 4*FS, "4*FS" },
1741 { 4*GS, "4*GS" },
1742 { 4*ORIG_EAX, "4*ORIG_EAX" },
1743 { 4*EIP, "4*EIP" },
1744 { 4*CS, "4*CS" },
1745 { 4*EFL, "4*EFL" },
1746 { 4*UESP, "4*UESP" },
1747 { 4*SS, "4*SS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001748# elif defined(X86_64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001749 { 8*R15, "8*R15" },
1750 { 8*R14, "8*R14" },
1751 { 8*R13, "8*R13" },
1752 { 8*R12, "8*R12" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001753 { 8*RBP, "8*RBP" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001754 { 8*RBX, "8*RBX" },
1755 { 8*R11, "8*R11" },
1756 { 8*R10, "8*R10" },
1757 { 8*R9, "8*R9" },
1758 { 8*R8, "8*R8" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001759 { 8*RAX, "8*RAX" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001760 { 8*RCX, "8*RCX" },
1761 { 8*RDX, "8*RDX" },
1762 { 8*RSI, "8*RSI" },
1763 { 8*RDI, "8*RDI" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001764 { 8*ORIG_RAX, "8*ORIG_RAX" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001765 { 8*RIP, "8*RIP" },
1766 { 8*CS, "8*CS" },
1767 { 8*EFLAGS, "8*EFL" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001768 { 8*RSP, "8*RSP" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001769 { 8*SS, "8*SS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001770# elif defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001771 { 4*PT_D1, "4*PT_D1" },
1772 { 4*PT_D2, "4*PT_D2" },
1773 { 4*PT_D3, "4*PT_D3" },
1774 { 4*PT_D4, "4*PT_D4" },
1775 { 4*PT_D5, "4*PT_D5" },
1776 { 4*PT_D6, "4*PT_D6" },
1777 { 4*PT_D7, "4*PT_D7" },
1778 { 4*PT_A0, "4*PT_A0" },
1779 { 4*PT_A1, "4*PT_A1" },
1780 { 4*PT_A2, "4*PT_A2" },
1781 { 4*PT_A3, "4*PT_A3" },
1782 { 4*PT_A4, "4*PT_A4" },
1783 { 4*PT_A5, "4*PT_A5" },
1784 { 4*PT_A6, "4*PT_A6" },
1785 { 4*PT_D0, "4*PT_D0" },
1786 { 4*PT_USP, "4*PT_USP" },
1787 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1788 { 4*PT_SR, "4*PT_SR" },
1789 { 4*PT_PC, "4*PT_PC" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001790# elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001791 { 4*REG_REG0, "4*REG_REG0" },
1792 { 4*(REG_REG0+1), "4*REG_REG1" },
1793 { 4*(REG_REG0+2), "4*REG_REG2" },
1794 { 4*(REG_REG0+3), "4*REG_REG3" },
1795 { 4*(REG_REG0+4), "4*REG_REG4" },
1796 { 4*(REG_REG0+5), "4*REG_REG5" },
1797 { 4*(REG_REG0+6), "4*REG_REG6" },
1798 { 4*(REG_REG0+7), "4*REG_REG7" },
1799 { 4*(REG_REG0+8), "4*REG_REG8" },
1800 { 4*(REG_REG0+9), "4*REG_REG9" },
1801 { 4*(REG_REG0+10), "4*REG_REG10" },
1802 { 4*(REG_REG0+11), "4*REG_REG11" },
1803 { 4*(REG_REG0+12), "4*REG_REG12" },
1804 { 4*(REG_REG0+13), "4*REG_REG13" },
1805 { 4*(REG_REG0+14), "4*REG_REG14" },
1806 { 4*REG_REG15, "4*REG_REG15" },
1807 { 4*REG_PC, "4*REG_PC" },
1808 { 4*REG_PR, "4*REG_PR" },
1809 { 4*REG_SR, "4*REG_SR" },
1810 { 4*REG_GBR, "4*REG_GBR" },
1811 { 4*REG_MACH, "4*REG_MACH" },
1812 { 4*REG_MACL, "4*REG_MACL" },
1813 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1814 { 4*REG_FPUL, "4*REG_FPUL" },
1815 { 4*REG_FPREG0, "4*REG_FPREG0" },
1816 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1817 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1818 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1819 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1820 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1821 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1822 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1823 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1824 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1825 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1826 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1827 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1828 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1829 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1830 { 4*REG_FPREG15, "4*REG_FPREG15" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001831# ifdef REG_XDREG0
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001832 { 4*REG_XDREG0, "4*REG_XDREG0" },
1833 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1834 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1835 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1836 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1837 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1838 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1839 { 4*REG_XDREG14, "4*REG_XDREG14" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001840# endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001841 { 4*REG_FPSCR, "4*REG_FPSCR" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001842# elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001843 { 0, "PC(L)" },
1844 { 4, "PC(U)" },
1845 { 8, "SR(L)" },
1846 { 12, "SR(U)" },
1847 { 16, "syscall no.(L)" },
1848 { 20, "syscall_no.(U)" },
1849 { 24, "R0(L)" },
1850 { 28, "R0(U)" },
1851 { 32, "R1(L)" },
1852 { 36, "R1(U)" },
1853 { 40, "R2(L)" },
1854 { 44, "R2(U)" },
1855 { 48, "R3(L)" },
1856 { 52, "R3(U)" },
1857 { 56, "R4(L)" },
1858 { 60, "R4(U)" },
1859 { 64, "R5(L)" },
1860 { 68, "R5(U)" },
1861 { 72, "R6(L)" },
1862 { 76, "R6(U)" },
1863 { 80, "R7(L)" },
1864 { 84, "R7(U)" },
1865 { 88, "R8(L)" },
1866 { 92, "R8(U)" },
1867 { 96, "R9(L)" },
1868 { 100, "R9(U)" },
1869 { 104, "R10(L)" },
1870 { 108, "R10(U)" },
1871 { 112, "R11(L)" },
1872 { 116, "R11(U)" },
1873 { 120, "R12(L)" },
1874 { 124, "R12(U)" },
1875 { 128, "R13(L)" },
1876 { 132, "R13(U)" },
1877 { 136, "R14(L)" },
1878 { 140, "R14(U)" },
1879 { 144, "R15(L)" },
1880 { 148, "R15(U)" },
1881 { 152, "R16(L)" },
1882 { 156, "R16(U)" },
1883 { 160, "R17(L)" },
1884 { 164, "R17(U)" },
1885 { 168, "R18(L)" },
1886 { 172, "R18(U)" },
1887 { 176, "R19(L)" },
1888 { 180, "R19(U)" },
1889 { 184, "R20(L)" },
1890 { 188, "R20(U)" },
1891 { 192, "R21(L)" },
1892 { 196, "R21(U)" },
1893 { 200, "R22(L)" },
1894 { 204, "R22(U)" },
1895 { 208, "R23(L)" },
1896 { 212, "R23(U)" },
1897 { 216, "R24(L)" },
1898 { 220, "R24(U)" },
1899 { 224, "R25(L)" },
1900 { 228, "R25(U)" },
1901 { 232, "R26(L)" },
1902 { 236, "R26(U)" },
1903 { 240, "R27(L)" },
1904 { 244, "R27(U)" },
1905 { 248, "R28(L)" },
1906 { 252, "R28(U)" },
1907 { 256, "R29(L)" },
1908 { 260, "R29(U)" },
1909 { 264, "R30(L)" },
1910 { 268, "R30(U)" },
1911 { 272, "R31(L)" },
1912 { 276, "R31(U)" },
1913 { 280, "R32(L)" },
1914 { 284, "R32(U)" },
1915 { 288, "R33(L)" },
1916 { 292, "R33(U)" },
1917 { 296, "R34(L)" },
1918 { 300, "R34(U)" },
1919 { 304, "R35(L)" },
1920 { 308, "R35(U)" },
1921 { 312, "R36(L)" },
1922 { 316, "R36(U)" },
1923 { 320, "R37(L)" },
1924 { 324, "R37(U)" },
1925 { 328, "R38(L)" },
1926 { 332, "R38(U)" },
1927 { 336, "R39(L)" },
1928 { 340, "R39(U)" },
1929 { 344, "R40(L)" },
1930 { 348, "R40(U)" },
1931 { 352, "R41(L)" },
1932 { 356, "R41(U)" },
1933 { 360, "R42(L)" },
1934 { 364, "R42(U)" },
1935 { 368, "R43(L)" },
1936 { 372, "R43(U)" },
1937 { 376, "R44(L)" },
1938 { 380, "R44(U)" },
1939 { 384, "R45(L)" },
1940 { 388, "R45(U)" },
1941 { 392, "R46(L)" },
1942 { 396, "R46(U)" },
1943 { 400, "R47(L)" },
1944 { 404, "R47(U)" },
1945 { 408, "R48(L)" },
1946 { 412, "R48(U)" },
1947 { 416, "R49(L)" },
1948 { 420, "R49(U)" },
1949 { 424, "R50(L)" },
1950 { 428, "R50(U)" },
1951 { 432, "R51(L)" },
1952 { 436, "R51(U)" },
1953 { 440, "R52(L)" },
1954 { 444, "R52(U)" },
1955 { 448, "R53(L)" },
1956 { 452, "R53(U)" },
1957 { 456, "R54(L)" },
1958 { 460, "R54(U)" },
1959 { 464, "R55(L)" },
1960 { 468, "R55(U)" },
1961 { 472, "R56(L)" },
1962 { 476, "R56(U)" },
1963 { 480, "R57(L)" },
1964 { 484, "R57(U)" },
1965 { 488, "R58(L)" },
1966 { 492, "R58(U)" },
1967 { 496, "R59(L)" },
1968 { 500, "R59(U)" },
1969 { 504, "R60(L)" },
1970 { 508, "R60(U)" },
1971 { 512, "R61(L)" },
1972 { 516, "R61(U)" },
1973 { 520, "R62(L)" },
1974 { 524, "R62(U)" },
1975 { 528, "TR0(L)" },
1976 { 532, "TR0(U)" },
1977 { 536, "TR1(L)" },
1978 { 540, "TR1(U)" },
1979 { 544, "TR2(L)" },
1980 { 548, "TR2(U)" },
1981 { 552, "TR3(L)" },
1982 { 556, "TR3(U)" },
1983 { 560, "TR4(L)" },
1984 { 564, "TR4(U)" },
1985 { 568, "TR5(L)" },
1986 { 572, "TR5(U)" },
1987 { 576, "TR6(L)" },
1988 { 580, "TR6(U)" },
1989 { 584, "TR7(L)" },
1990 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00001991 /* This entry is in case pt_regs contains dregs (depends on
1992 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001993 { uoff(regs), "offsetof(struct user, regs)" },
1994 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001995# elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00001996 { uoff(regs.ARM_r0), "r0" },
1997 { uoff(regs.ARM_r1), "r1" },
1998 { uoff(regs.ARM_r2), "r2" },
1999 { uoff(regs.ARM_r3), "r3" },
2000 { uoff(regs.ARM_r4), "r4" },
2001 { uoff(regs.ARM_r5), "r5" },
2002 { uoff(regs.ARM_r6), "r6" },
2003 { uoff(regs.ARM_r7), "r7" },
2004 { uoff(regs.ARM_r8), "r8" },
2005 { uoff(regs.ARM_r9), "r9" },
2006 { uoff(regs.ARM_r10), "r10" },
2007 { uoff(regs.ARM_fp), "fp" },
2008 { uoff(regs.ARM_ip), "ip" },
2009 { uoff(regs.ARM_sp), "sp" },
2010 { uoff(regs.ARM_lr), "lr" },
2011 { uoff(regs.ARM_pc), "pc" },
2012 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00002013# elif defined(AVR32)
2014 { uoff(regs.sr), "sr" },
2015 { uoff(regs.pc), "pc" },
2016 { uoff(regs.lr), "lr" },
2017 { uoff(regs.sp), "sp" },
2018 { uoff(regs.r12), "r12" },
2019 { uoff(regs.r11), "r11" },
2020 { uoff(regs.r10), "r10" },
2021 { uoff(regs.r9), "r9" },
2022 { uoff(regs.r8), "r8" },
2023 { uoff(regs.r7), "r7" },
2024 { uoff(regs.r6), "r6" },
2025 { uoff(regs.r5), "r5" },
2026 { uoff(regs.r4), "r4" },
2027 { uoff(regs.r3), "r3" },
2028 { uoff(regs.r2), "r2" },
2029 { uoff(regs.r1), "r1" },
2030 { uoff(regs.r0), "r0" },
2031 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002032# elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00002033 { 0, "r0" },
2034 { 1, "r1" },
2035 { 2, "r2" },
2036 { 3, "r3" },
2037 { 4, "r4" },
2038 { 5, "r5" },
2039 { 6, "r6" },
2040 { 7, "r7" },
2041 { 8, "r8" },
2042 { 9, "r9" },
2043 { 10, "r10" },
2044 { 11, "r11" },
2045 { 12, "r12" },
2046 { 13, "r13" },
2047 { 14, "r14" },
2048 { 15, "r15" },
2049 { 16, "r16" },
2050 { 17, "r17" },
2051 { 18, "r18" },
2052 { 19, "r19" },
2053 { 20, "r20" },
2054 { 21, "r21" },
2055 { 22, "r22" },
2056 { 23, "r23" },
2057 { 24, "r24" },
2058 { 25, "r25" },
2059 { 26, "r26" },
2060 { 27, "r27" },
2061 { 28, "r28" },
2062 { 29, "r29" },
2063 { 30, "r30" },
2064 { 31, "r31" },
2065 { 32, "f0" },
2066 { 33, "f1" },
2067 { 34, "f2" },
2068 { 35, "f3" },
2069 { 36, "f4" },
2070 { 37, "f5" },
2071 { 38, "f6" },
2072 { 39, "f7" },
2073 { 40, "f8" },
2074 { 41, "f9" },
2075 { 42, "f10" },
2076 { 43, "f11" },
2077 { 44, "f12" },
2078 { 45, "f13" },
2079 { 46, "f14" },
2080 { 47, "f15" },
2081 { 48, "f16" },
2082 { 49, "f17" },
2083 { 50, "f18" },
2084 { 51, "f19" },
2085 { 52, "f20" },
2086 { 53, "f21" },
2087 { 54, "f22" },
2088 { 55, "f23" },
2089 { 56, "f24" },
2090 { 57, "f25" },
2091 { 58, "f26" },
2092 { 59, "f27" },
2093 { 60, "f28" },
2094 { 61, "f29" },
2095 { 62, "f30" },
2096 { 63, "f31" },
2097 { 64, "pc" },
2098 { 65, "cause" },
2099 { 66, "badvaddr" },
2100 { 67, "mmhi" },
2101 { 68, "mmlo" },
2102 { 69, "fpcsr" },
2103 { 70, "fpeir" },
Chris Metcalfc8c66982009-12-28 10:00:15 -05002104# elif defined(TILE)
2105 { PTREGS_OFFSET_REG(0), "r0" },
2106 { PTREGS_OFFSET_REG(1), "r1" },
2107 { PTREGS_OFFSET_REG(2), "r2" },
2108 { PTREGS_OFFSET_REG(3), "r3" },
2109 { PTREGS_OFFSET_REG(4), "r4" },
2110 { PTREGS_OFFSET_REG(5), "r5" },
2111 { PTREGS_OFFSET_REG(6), "r6" },
2112 { PTREGS_OFFSET_REG(7), "r7" },
2113 { PTREGS_OFFSET_REG(8), "r8" },
2114 { PTREGS_OFFSET_REG(9), "r9" },
2115 { PTREGS_OFFSET_REG(10), "r10" },
2116 { PTREGS_OFFSET_REG(11), "r11" },
2117 { PTREGS_OFFSET_REG(12), "r12" },
2118 { PTREGS_OFFSET_REG(13), "r13" },
2119 { PTREGS_OFFSET_REG(14), "r14" },
2120 { PTREGS_OFFSET_REG(15), "r15" },
2121 { PTREGS_OFFSET_REG(16), "r16" },
2122 { PTREGS_OFFSET_REG(17), "r17" },
2123 { PTREGS_OFFSET_REG(18), "r18" },
2124 { PTREGS_OFFSET_REG(19), "r19" },
2125 { PTREGS_OFFSET_REG(20), "r20" },
2126 { PTREGS_OFFSET_REG(21), "r21" },
2127 { PTREGS_OFFSET_REG(22), "r22" },
2128 { PTREGS_OFFSET_REG(23), "r23" },
2129 { PTREGS_OFFSET_REG(24), "r24" },
2130 { PTREGS_OFFSET_REG(25), "r25" },
2131 { PTREGS_OFFSET_REG(26), "r26" },
2132 { PTREGS_OFFSET_REG(27), "r27" },
2133 { PTREGS_OFFSET_REG(28), "r28" },
2134 { PTREGS_OFFSET_REG(29), "r29" },
2135 { PTREGS_OFFSET_REG(30), "r30" },
2136 { PTREGS_OFFSET_REG(31), "r31" },
2137 { PTREGS_OFFSET_REG(32), "r32" },
2138 { PTREGS_OFFSET_REG(33), "r33" },
2139 { PTREGS_OFFSET_REG(34), "r34" },
2140 { PTREGS_OFFSET_REG(35), "r35" },
2141 { PTREGS_OFFSET_REG(36), "r36" },
2142 { PTREGS_OFFSET_REG(37), "r37" },
2143 { PTREGS_OFFSET_REG(38), "r38" },
2144 { PTREGS_OFFSET_REG(39), "r39" },
2145 { PTREGS_OFFSET_REG(40), "r40" },
2146 { PTREGS_OFFSET_REG(41), "r41" },
2147 { PTREGS_OFFSET_REG(42), "r42" },
2148 { PTREGS_OFFSET_REG(43), "r43" },
2149 { PTREGS_OFFSET_REG(44), "r44" },
2150 { PTREGS_OFFSET_REG(45), "r45" },
2151 { PTREGS_OFFSET_REG(46), "r46" },
2152 { PTREGS_OFFSET_REG(47), "r47" },
2153 { PTREGS_OFFSET_REG(48), "r48" },
2154 { PTREGS_OFFSET_REG(49), "r49" },
2155 { PTREGS_OFFSET_REG(50), "r50" },
2156 { PTREGS_OFFSET_REG(51), "r51" },
2157 { PTREGS_OFFSET_REG(52), "r52" },
2158 { PTREGS_OFFSET_TP, "tp" },
2159 { PTREGS_OFFSET_SP, "sp" },
2160 { PTREGS_OFFSET_LR, "lr" },
2161 { PTREGS_OFFSET_PC, "pc" },
2162 { PTREGS_OFFSET_EX1, "ex1" },
2163 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2164 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2165 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002166# endif
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002167# ifdef CRISV10
2168 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2169 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2170 { 4*PT_R13, "4*PT_R13" },
2171 { 4*PT_R12, "4*PT_R12" },
2172 { 4*PT_R11, "4*PT_R11" },
2173 { 4*PT_R10, "4*PT_R10" },
2174 { 4*PT_R9, "4*PT_R9" },
2175 { 4*PT_R8, "4*PT_R8" },
2176 { 4*PT_R7, "4*PT_R7" },
2177 { 4*PT_R6, "4*PT_R6" },
2178 { 4*PT_R5, "4*PT_R5" },
2179 { 4*PT_R4, "4*PT_R4" },
2180 { 4*PT_R3, "4*PT_R3" },
2181 { 4*PT_R2, "4*PT_R2" },
2182 { 4*PT_R1, "4*PT_R1" },
2183 { 4*PT_R0, "4*PT_R0" },
2184 { 4*PT_MOF, "4*PT_MOF" },
2185 { 4*PT_DCCR, "4*PT_DCCR" },
2186 { 4*PT_SRP, "4*PT_SRP" },
2187 { 4*PT_IRP, "4*PT_IRP" },
2188 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2189 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2190 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2191 { 4*PT_USP, "4*PT_USP" },
2192# endif
2193# ifdef CRISV32
2194 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2195 { 4*PT_R0, "4*PT_R0" },
2196 { 4*PT_R1, "4*PT_R1" },
2197 { 4*PT_R2, "4*PT_R2" },
2198 { 4*PT_R3, "4*PT_R3" },
2199 { 4*PT_R4, "4*PT_R4" },
2200 { 4*PT_R5, "4*PT_R5" },
2201 { 4*PT_R6, "4*PT_R6" },
2202 { 4*PT_R7, "4*PT_R7" },
2203 { 4*PT_R8, "4*PT_R8" },
2204 { 4*PT_R9, "4*PT_R9" },
2205 { 4*PT_R10, "4*PT_R10" },
2206 { 4*PT_R11, "4*PT_R11" },
2207 { 4*PT_R12, "4*PT_R12" },
2208 { 4*PT_R13, "4*PT_R13" },
2209 { 4*PT_ACR, "4*PT_ACR" },
2210 { 4*PT_SRS, "4*PT_SRS" },
2211 { 4*PT_MOF, "4*PT_MOF" },
2212 { 4*PT_SPC, "4*PT_SPC" },
2213 { 4*PT_CCS, "4*PT_CCS" },
2214 { 4*PT_SRP, "4*PT_SRP" },
2215 { 4*PT_ERP, "4*PT_ERP" },
2216 { 4*PT_EXS, "4*PT_EXS" },
2217 { 4*PT_EDA, "4*PT_EDA" },
2218 { 4*PT_USP, "4*PT_USP" },
2219 { 4*PT_PPC, "4*PT_PPC" },
2220 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2221 { 4*PT_BP+4, "4*PT_BP+4" },
2222 { 4*PT_BP+8, "4*PT_BP+8" },
2223 { 4*PT_BP+12, "4*PT_BP+12" },
2224 { 4*PT_BP+16, "4*PT_BP+16" },
2225 { 4*PT_BP+20, "4*PT_BP+20" },
2226 { 4*PT_BP+24, "4*PT_BP+24" },
2227 { 4*PT_BP+28, "4*PT_BP+28" },
2228 { 4*PT_BP+32, "4*PT_BP+32" },
2229 { 4*PT_BP+36, "4*PT_BP+36" },
2230 { 4*PT_BP+40, "4*PT_BP+40" },
2231 { 4*PT_BP+44, "4*PT_BP+44" },
2232 { 4*PT_BP+48, "4*PT_BP+48" },
2233 { 4*PT_BP+52, "4*PT_BP+52" },
2234 { 4*PT_BP+56, "4*PT_BP+56" },
2235# endif
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002236# ifdef MICROBLAZE
2237 { PT_GPR(0), "r0" },
2238 { PT_GPR(1), "r1" },
2239 { PT_GPR(2), "r2" },
2240 { PT_GPR(3), "r3" },
2241 { PT_GPR(4), "r4" },
2242 { PT_GPR(5), "r5" },
2243 { PT_GPR(6), "r6" },
2244 { PT_GPR(7), "r7" },
2245 { PT_GPR(8), "r8" },
2246 { PT_GPR(9), "r9" },
2247 { PT_GPR(10), "r10" },
2248 { PT_GPR(11), "r11" },
2249 { PT_GPR(12), "r12" },
2250 { PT_GPR(13), "r13" },
2251 { PT_GPR(14), "r14" },
2252 { PT_GPR(15), "r15" },
2253 { PT_GPR(16), "r16" },
2254 { PT_GPR(17), "r17" },
2255 { PT_GPR(18), "r18" },
2256 { PT_GPR(19), "r19" },
2257 { PT_GPR(20), "r20" },
2258 { PT_GPR(21), "r21" },
2259 { PT_GPR(22), "r22" },
2260 { PT_GPR(23), "r23" },
2261 { PT_GPR(24), "r24" },
2262 { PT_GPR(25), "r25" },
2263 { PT_GPR(26), "r26" },
2264 { PT_GPR(27), "r27" },
2265 { PT_GPR(28), "r28" },
2266 { PT_GPR(29), "r29" },
2267 { PT_GPR(30), "r30" },
2268 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002269 { PT_PC, "rpc", },
2270 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002271 { PT_EAR, "rear", },
2272 { PT_ESR, "resr", },
2273 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002274 { PT_KERNEL_MODE, "kernel_mode", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002275# endif
Roland McGrath542c2c62008-05-20 01:11:56 +00002276
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002277# if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \
2278 && !defined(ALPHA) && !defined(IA64) \
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002279 && !defined(CRISV10) && !defined(CRISV32) && !defined(MICROBLAZE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05002280# if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(AVR32) && !defined(BFIN) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002281 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002282# endif
2283# if defined(I386) || defined(X86_64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002284 { uoff(i387), "offsetof(struct user, i387)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002285# endif
2286# if defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002287 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002288# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002289 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2290 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2291 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002292# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002293 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002294# endif
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00002295# if defined(AVR32) || defined(SH64)
Roland McGrathe1e584b2003-06-02 19:18:58 +00002296 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002297# endif
2298# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002299 { uoff(start_stack), "offsetof(struct user, start_stack)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002300# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002301 { uoff(signal), "offsetof(struct user, signal)" },
Chris Metcalfc8c66982009-12-28 10:00:15 -05002302# if !defined(AVR32) && !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SH) && !defined(SH64) && !defined(SPARC64) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002303 { uoff(reserved), "offsetof(struct user, reserved)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002304# endif
2305# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002306 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002307# endif
Chris Metcalfc8c66982009-12-28 10:00:15 -05002308# if !defined(ARM) && !defined(AVR32) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) && !defined(BFIN) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002309 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002310# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002311 { uoff(magic), "offsetof(struct user, magic)" },
2312 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002313# if defined(I386) || defined(X86_64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002314 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002315# endif
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002316# endif /* !defined(many arches) */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002317
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002318# ifndef HPPA
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002319 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002320# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002321 { 0, NULL },
2322};
2323
2324int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002325sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002326{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002327 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002328 long addr;
2329
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002330 if (entering(tcp)) {
Roland McGrathbf621d42003-01-14 09:46:21 +00002331 printxval(ptrace_cmds, tcp->u_arg[0],
Roland McGrathbf621d42003-01-14 09:46:21 +00002332 "PTRACE_???"
Roland McGrathbf621d42003-01-14 09:46:21 +00002333 );
2334 tprintf(", %lu, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002335 addr = tcp->u_arg[2];
2336 if (tcp->u_arg[0] == PTRACE_PEEKUSER
2337 || tcp->u_arg[0] == PTRACE_POKEUSER) {
2338 for (x = struct_user_offsets; x->str; x++) {
2339 if (x->val >= addr)
2340 break;
2341 }
2342 if (!x->str)
2343 tprintf("%#lx, ", addr);
2344 else if (x->val > addr && x != struct_user_offsets) {
2345 x--;
2346 tprintf("%s + %ld, ", x->str, addr - x->val);
2347 }
2348 else
2349 tprintf("%s, ", x->str);
2350 }
2351 else
2352 tprintf("%#lx, ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002353 switch (tcp->u_arg[0]) {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002354# ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002355 case PTRACE_PEEKDATA:
2356 case PTRACE_PEEKTEXT:
2357 case PTRACE_PEEKUSER:
2358 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002359# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002360 case PTRACE_CONT:
2361 case PTRACE_SINGLESTEP:
2362 case PTRACE_SYSCALL:
2363 case PTRACE_DETACH:
2364 printsignal(tcp->u_arg[3]);
2365 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002366# ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002367 case PTRACE_SETOPTIONS:
2368 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2369 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002370# endif
2371# ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002372 case PTRACE_SETSIGINFO: {
2373 siginfo_t si;
2374 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002375 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002376 else if (syserror(tcp))
2377 tprintf("%#lx", tcp->u_arg[3]);
2378 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002379 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002380 else
2381 printsiginfo(&si, verbose(tcp));
2382 break;
2383 }
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002384# endif
2385# ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002386 case PTRACE_GETSIGINFO:
2387 /* Don't print anything, do it at syscall return. */
2388 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002389# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002390 default:
2391 tprintf("%#lx", tcp->u_arg[3]);
2392 break;
2393 }
2394 } else {
2395 switch (tcp->u_arg[0]) {
2396 case PTRACE_PEEKDATA:
2397 case PTRACE_PEEKTEXT:
2398 case PTRACE_PEEKUSER:
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002399# ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002400 return RVAL_HEX;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002401# else
Roland McGratheb285352003-01-14 09:59:00 +00002402 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002403 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002404# endif
2405# ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002406 case PTRACE_GETSIGINFO: {
2407 siginfo_t si;
2408 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002409 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002410 else if (syserror(tcp))
2411 tprintf("%#lx", tcp->u_arg[3]);
2412 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002413 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002414 else
2415 printsiginfo(&si, verbose(tcp));
2416 break;
2417 }
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002418# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002419 }
2420 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002421 return 0;
2422}
2423
Roland McGrath51942a92007-07-05 18:59:11 +00002424# ifndef FUTEX_CMP_REQUEUE
2425# define FUTEX_CMP_REQUEUE 4
2426# endif
2427# ifndef FUTEX_WAKE_OP
2428# define FUTEX_WAKE_OP 5
2429# endif
2430# ifndef FUTEX_LOCK_PI
2431# define FUTEX_LOCK_PI 6
2432# define FUTEX_UNLOCK_PI 7
2433# define FUTEX_TRYLOCK_PI 8
2434# endif
Roland McGrath1aeaf742008-07-18 01:27:39 +00002435# ifndef FUTEX_WAIT_BITSET
2436# define FUTEX_WAIT_BITSET 9
2437# endif
2438# ifndef FUTEX_WAKE_BITSET
2439# define FUTEX_WAKE_BITSET 10
Roland McGrath51942a92007-07-05 18:59:11 +00002440# endif
Andreas Schwab85f58322009-08-12 09:54:42 +02002441# ifndef FUTEX_WAIT_REQUEUE_PI
2442# define FUTEX_WAIT_REQUEUE_PI 11
2443# endif
2444# ifndef FUTEX_CMP_REQUEUE_PI
2445# define FUTEX_CMP_REQUEUE_PI 12
2446# endif
Roland McGrath51942a92007-07-05 18:59:11 +00002447# ifndef FUTEX_PRIVATE_FLAG
2448# define FUTEX_PRIVATE_FLAG 128
2449# endif
Andreas Schwab85f58322009-08-12 09:54:42 +02002450# ifndef FUTEX_CLOCK_REALTIME
2451# define FUTEX_CLOCK_REALTIME 256
2452# endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002453static const struct xlat futexops[] = {
Roland McGrath51942a92007-07-05 18:59:11 +00002454 { FUTEX_WAIT, "FUTEX_WAIT" },
2455 { FUTEX_WAKE, "FUTEX_WAKE" },
2456 { FUTEX_FD, "FUTEX_FD" },
2457 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2458 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2459 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2460 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2461 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2462 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002463 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2464 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002465 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2466 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
Roland McGrath51942a92007-07-05 18:59:11 +00002467 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2468 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2469 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2470 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2471 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2472 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2473 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2474 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2475 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002476 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2477 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002478 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2479 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2480 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2481 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2482 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2483 { 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 +00002484 { 0, NULL }
2485};
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002486# ifndef FUTEX_OP_SET
2487# define FUTEX_OP_SET 0
2488# define FUTEX_OP_ADD 1
2489# define FUTEX_OP_OR 2
2490# define FUTEX_OP_ANDN 3
2491# define FUTEX_OP_XOR 4
2492# define FUTEX_OP_CMP_EQ 0
2493# define FUTEX_OP_CMP_NE 1
2494# define FUTEX_OP_CMP_LT 2
2495# define FUTEX_OP_CMP_LE 3
2496# define FUTEX_OP_CMP_GT 4
2497# define FUTEX_OP_CMP_GE 5
2498# endif
Roland McGrath51942a92007-07-05 18:59:11 +00002499static const struct xlat futexwakeops[] = {
2500 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2501 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2502 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2503 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2504 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2505 { 0, NULL }
2506};
2507static const struct xlat futexwakecmps[] = {
2508 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2509 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2510 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2511 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2512 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2513 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2514 { 0, NULL }
Roland McGrath5a223472002-12-15 23:58:26 +00002515};
2516
2517int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002518sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002519{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002520 if (entering(tcp)) {
2521 long int cmd = tcp->u_arg[1] & 127;
2522 tprintf("%p, ", (void *) tcp->u_arg[0]);
2523 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2524 tprintf(", %ld", tcp->u_arg[2]);
2525 if (cmd == FUTEX_WAKE_BITSET)
2526 tprintf(", %lx", tcp->u_arg[5]);
2527 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002528 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002529 printtv(tcp, tcp->u_arg[3]);
2530 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002531 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002532 printtv(tcp, tcp->u_arg[3]);
2533 tprintf(", %lx", tcp->u_arg[5]);
2534 } else if (cmd == FUTEX_REQUEUE)
2535 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002536 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002537 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2538 else if (cmd == FUTEX_WAKE_OP) {
2539 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2540 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002541 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002542 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2543 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2544 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002545 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002546 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2547 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002548 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002549 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002550 printtv(tcp, tcp->u_arg[3]);
2551 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002552 }
Roland McGrath51942a92007-07-05 18:59:11 +00002553 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002554 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002555}
2556
2557static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002558print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002559{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002560 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002561 unsigned long w, min_len;
2562
2563 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2564 min_len = len - max_strlen * sizeof(w);
2565 else
2566 min_len = 0;
2567 for (; len >= sizeof(w) && len > min_len;
2568 len -= sizeof(w), list += sizeof(w)) {
2569 if (umove(tcp, list, &w) < 0)
2570 break;
2571 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002572 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002573 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002574 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002575 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002576 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002577 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002578 if (len) {
2579 if (first)
2580 tprintf("%#lx", list);
2581 else
2582 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2583 "???" : "..."));
2584 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002585 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002586 }
Roland McGrath5a223472002-12-15 23:58:26 +00002587}
2588
2589int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002590sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002591{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002592 if (entering(tcp)) {
2593 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2594 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2595 }
2596 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002597}
2598
2599int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002600sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002601{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002602 if (entering(tcp)) {
2603 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2604 } else {
2605 if (tcp->u_rval == -1)
2606 tprintf("%#lx", tcp->u_arg[2]);
2607 else
2608 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2609 }
2610 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002611}
Roland McGrath279d3782004-03-01 20:27:37 +00002612
Dmitry V. Levin1b0bae22012-03-11 22:32:26 +00002613int
2614sys_get_robust_list(struct tcb *tcp)
2615{
2616 if (entering(tcp)) {
2617 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2618 } else {
2619 void *addr;
2620 size_t len;
2621
2622 if (syserror(tcp) ||
2623 !tcp->u_arg[1] ||
2624 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2625 tprintf("%#lx, ", tcp->u_arg[1]);
2626 } else {
2627 tprintf("[%p], ", addr);
2628 }
2629
2630 if (syserror(tcp) ||
2631 !tcp->u_arg[2] ||
2632 umove(tcp, tcp->u_arg[2], &len) < 0) {
2633 tprintf("%#lx", tcp->u_arg[2]);
2634 } else {
2635 tprintf("[%lu]", (unsigned long) len);
2636 }
2637 }
2638 return 0;
2639}
2640
Roland McGrathd9f816f2004-09-04 03:39:20 +00002641static const struct xlat schedulers[] = {
Roland McGrath279d3782004-03-01 20:27:37 +00002642 { SCHED_OTHER, "SCHED_OTHER" },
2643 { SCHED_RR, "SCHED_RR" },
2644 { SCHED_FIFO, "SCHED_FIFO" },
2645 { 0, NULL }
2646};
2647
2648int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002649sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002650{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002651 if (entering(tcp)) {
2652 tprintf("%d", (int) tcp->u_arg[0]);
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002653 } else if (!syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002654 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002655 if (tcp->auxstr != NULL)
2656 return RVAL_STR;
2657 }
2658 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002659}
2660
2661int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002662sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002663{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002664 if (entering(tcp)) {
2665 struct sched_param p;
2666 tprintf("%d, ", (int) tcp->u_arg[0]);
2667 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2668 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2669 tprintf(", %#lx", tcp->u_arg[2]);
2670 else
2671 tprintf(", { %d }", p.__sched_priority);
2672 }
2673 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002674}
2675
2676int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002677sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002678{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002679 if (entering(tcp)) {
2680 tprintf("%d, ", (int) tcp->u_arg[0]);
2681 } else {
2682 struct sched_param p;
2683 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2684 tprintf("%#lx", tcp->u_arg[1]);
2685 else
2686 tprintf("{ %d }", p.__sched_priority);
2687 }
2688 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002689}
2690
2691int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002692sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002693{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002694 if (entering(tcp)) {
2695 struct sched_param p;
2696 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2697 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2698 else
2699 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2700 }
2701 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002702}
2703
2704int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002705sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002706{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002707 if (entering(tcp)) {
2708 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2709 }
2710 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002711}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002712
Dmitry V. Levin1ff463d2012-03-11 23:00:11 +00002713int
2714sys_sched_rr_get_interval(struct tcb *tcp)
2715{
2716 if (entering(tcp)) {
2717 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2718 } else {
2719 if (syserror(tcp))
2720 tprintf("%#lx", tcp->u_arg[1]);
2721 else
2722 print_timespec(tcp, tcp->u_arg[1]);
2723 }
2724 return 0;
2725}
2726
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002727# ifdef X86_64
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +01002728# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002729
2730static const struct xlat archvals[] = {
2731 { ARCH_SET_GS, "ARCH_SET_GS" },
2732 { ARCH_SET_FS, "ARCH_SET_FS" },
2733 { ARCH_GET_FS, "ARCH_GET_FS" },
2734 { ARCH_GET_GS, "ARCH_GET_GS" },
2735 { 0, NULL },
2736};
2737
2738int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002739sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002740{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002741 if (entering(tcp)) {
2742 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2743 if (tcp->u_arg[0] == ARCH_SET_GS
2744 || tcp->u_arg[0] == ARCH_SET_FS
2745 ) {
2746 tprintf(", %#lx", tcp->u_arg[1]);
2747 }
2748 } else {
2749 if (tcp->u_arg[0] == ARCH_GET_GS
2750 || tcp->u_arg[0] == ARCH_GET_FS
2751 ) {
2752 long int v;
2753 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2754 tprintf(", [%#lx]", v);
2755 else
2756 tprintf(", %#lx", tcp->u_arg[1]);
2757 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002758 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002759 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002760}
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002761# endif /* X86_64 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002762
Roland McGrathdb8319f2007-08-02 01:37:55 +00002763int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002764sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002765{
2766 if (exiting(tcp)) {
2767 unsigned u;
2768 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002769 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002770 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2771 tprintf("%#lx, ", tcp->u_arg[0]);
2772 else
2773 tprintf("[%u], ", u);
2774 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002775 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002776 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2777 tprintf("%#lx, ", tcp->u_arg[1]);
2778 else
2779 tprintf("[%u], ", u);
2780 tprintf("%#lx", tcp->u_arg[2]);
2781 }
2782 return 0;
2783}
2784
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002785int
2786sys_process_vm_readv(struct tcb *tcp)
2787{
2788 if (entering(tcp)) {
2789 /* arg 1: pid */
2790 tprintf("%ld, ", tcp->u_arg[0]);
2791 } else {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002792 /* arg 2: local iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002793 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002794 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002795 } else {
2796 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2797 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002798 /* arg 3: local iovcnt */
2799 tprintf(", %lu, ", tcp->u_arg[2]);
2800 /* arg 4: remote iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002801 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002802 tprintf("%#lx", tcp->u_arg[3]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002803 } else {
2804 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2805 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002806 /* arg 5: remote iovcnt */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002807 /* arg 6: flags */
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002808 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002809 }
2810 return 0;
2811}
Dmitry V. Levin03952102012-03-10 14:14:49 +00002812
2813int
2814sys_process_vm_writev(struct tcb *tcp)
2815{
2816 if (entering(tcp)) {
2817 /* arg 1: pid */
2818 tprintf("%ld, ", tcp->u_arg[0]);
2819 /* arg 2: local iov */
2820 if (syserror(tcp))
2821 tprintf("%#lx", tcp->u_arg[1]);
2822 else
2823 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2824 /* arg 3: local iovcnt */
2825 tprintf(", %lu, ", tcp->u_arg[2]);
2826 /* arg 4: remote iov */
2827 if (syserror(tcp))
2828 tprintf("%#lx", tcp->u_arg[3]);
2829 else
2830 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2831 /* arg 5: remote iovcnt */
2832 /* arg 6: flags */
2833 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
2834 }
2835 return 0;
2836}