blob: 0393288e8d13656e2bb6bdba28f6004543211497 [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>
11
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +000012 *
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000013 * All rights reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. The name of the author may not be used to endorse or promote products
24 * derived from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * $Id$
38 */
39
40#include "defs.h"
41
42#include <fcntl.h>
43#include <sys/stat.h>
44#include <sys/time.h>
45#include <sys/wait.h>
46#include <sys/resource.h>
47#include <sys/utsname.h>
48#include <sys/user.h>
49#include <sys/syscall.h>
50#include <signal.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000051
Wichert Akkerman36915a11999-07-13 15:45:02 +000052#ifdef HAVE_SYS_REG_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000053# include <sys/reg.h>
Denys Vlasenko84703742012-02-25 02:38:52 +010054# ifndef PTRACE_PEEKUSR
55# define PTRACE_PEEKUSR PTRACE_PEEKUSER
56# endif
57# ifndef PTRACE_POKEUSR
58# define PTRACE_POKEUSR PTRACE_POKEUSER
59# endif
Wichert Akkerman15dea971999-10-06 13:06:34 +000060#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000061
Roland McGrath5bd7cf82003-01-24 04:31:18 +000062#ifdef HAVE_LINUX_PTRACE_H
Denys Vlasenko84703742012-02-25 02:38:52 +010063# undef PTRACE_SYSCALL
Roland McGrathfb1bc072004-03-01 21:29:24 +000064# ifdef HAVE_STRUCT_IA64_FPREG
65# define ia64_fpreg XXX_ia64_fpreg
66# endif
67# ifdef HAVE_STRUCT_PT_ALL_USER_REGS
68# define pt_all_user_regs XXX_pt_all_user_regs
69# endif
Denys Vlasenko84703742012-02-25 02:38:52 +010070# include <linux/ptrace.h>
Roland McGrathfb1bc072004-03-01 21:29:24 +000071# undef ia64_fpreg
72# undef pt_all_user_regs
Roland McGrath5bd7cf82003-01-24 04:31:18 +000073#endif
74
Denys Vlasenko84703742012-02-25 02:38:52 +010075#if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +000076# define r_pc r_tpc
77# undef PTRACE_GETREGS
78# define PTRACE_GETREGS PTRACE_GETREGS64
79# undef PTRACE_SETREGS
80# define PTRACE_SETREGS PTRACE_SETREGS64
Denys Vlasenko84703742012-02-25 02:38:52 +010081#endif
Roland McGrath6d1a65c2004-07-12 07:44:08 +000082
Roland McGrath5a223472002-12-15 23:58:26 +000083#ifdef HAVE_LINUX_FUTEX_H
Dmitry V. Levine5e60852009-12-31 22:50:49 +000084# include <linux/futex.h>
Roland McGrath5a223472002-12-15 23:58:26 +000085#endif
Denys Vlasenko84703742012-02-25 02:38:52 +010086#ifndef FUTEX_WAIT
87# define FUTEX_WAIT 0
88#endif
89#ifndef FUTEX_WAKE
90# define FUTEX_WAKE 1
91#endif
92#ifndef FUTEX_FD
93# define FUTEX_FD 2
94#endif
95#ifndef FUTEX_REQUEUE
96# define FUTEX_REQUEUE 3
97#endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000098
Roland McGrath279d3782004-03-01 20:27:37 +000099#include <sched.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000100#include <asm/posix_types.h>
101#undef GETGROUPS_T
102#define GETGROUPS_T __kernel_gid_t
Roland McGrath83bd47a2003-11-13 22:32:26 +0000103#undef GETGROUPS32_T
104#define GETGROUPS32_T __kernel_gid32_t
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000105
Denys Vlasenko84703742012-02-25 02:38:52 +0100106#if defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000107# include <asm/ptrace_offsets.h>
108# include <asm/rse.h>
109#endif
110
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000111#ifdef HAVE_PRCTL
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000112# include <sys/prctl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000113
Roland McGrathd9f816f2004-09-04 03:39:20 +0000114static const struct xlat prctl_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000115#ifdef PR_MAXPROCS
116 { PR_MAXPROCS, "PR_MAXPROCS" },
117#endif
118#ifdef PR_ISBLOCKED
119 { PR_ISBLOCKED, "PR_ISBLOCKED" },
120#endif
121#ifdef PR_SETSTACKSIZE
122 { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" },
123#endif
124#ifdef PR_GETSTACKSIZE
125 { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" },
126#endif
127#ifdef PR_MAXPPROCS
128 { PR_MAXPPROCS, "PR_MAXPPROCS" },
129#endif
130#ifdef PR_UNBLKONEXEC
131 { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" },
132#endif
133#ifdef PR_ATOMICSIM
134 { PR_ATOMICSIM, "PR_ATOMICSIM" },
135#endif
136#ifdef PR_SETEXITSIG
137 { PR_SETEXITSIG, "PR_SETEXITSIG" },
138#endif
139#ifdef PR_RESIDENT
140 { PR_RESIDENT, "PR_RESIDENT" },
141#endif
142#ifdef PR_ATTACHADDR
143 { PR_ATTACHADDR, "PR_ATTACHADDR" },
144#endif
145#ifdef PR_DETACHADDR
146 { PR_DETACHADDR, "PR_DETACHADDR" },
147#endif
148#ifdef PR_TERMCHILD
149 { PR_TERMCHILD, "PR_TERMCHILD" },
150#endif
151#ifdef PR_GETSHMASK
152 { PR_GETSHMASK, "PR_GETSHMASK" },
153#endif
154#ifdef PR_GETNSHARE
155 { PR_GETNSHARE, "PR_GETNSHARE" },
156#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +0000157#ifdef PR_COREPID
158 { PR_COREPID, "PR_COREPID" },
159#endif
160#ifdef PR_ATTACHADDRPERM
161 { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" },
162#endif
163#ifdef PR_PTHREADEXIT
164 { PR_PTHREADEXIT, "PR_PTHREADEXIT" },
165#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000166#ifdef PR_SET_PDEATHSIG
167 { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
168#endif
169#ifdef PR_GET_PDEATHSIG
170 { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
171#endif
Dmitry V. Levinf02cf212008-09-03 00:54:40 +0000172#ifdef PR_GET_DUMPABLE
173 { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" },
174#endif
175#ifdef PR_SET_DUMPABLE
176 { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" },
177#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000178#ifdef PR_GET_UNALIGN
179 { PR_GET_UNALIGN, "PR_GET_UNALIGN" },
180#endif
181#ifdef PR_SET_UNALIGN
182 { PR_SET_UNALIGN, "PR_SET_UNALIGN" },
183#endif
184#ifdef PR_GET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000185 { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000186#endif
187#ifdef PR_SET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000188 { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000189#endif
Roland McGrathe5039fb2007-11-03 23:58:07 +0000190#ifdef PR_GET_FPEMU
191 { PR_GET_FPEMU, "PR_GET_FPEMU" },
192#endif
193#ifdef PR_SET_FPEMU
194 { PR_SET_FPEMU, "PR_SET_FPEMU" },
195#endif
196#ifdef PR_GET_FPEXC
197 { PR_GET_FPEXC, "PR_GET_FPEXC" },
198#endif
199#ifdef PR_SET_FPEXC
200 { PR_SET_FPEXC, "PR_SET_FPEXC" },
201#endif
202#ifdef PR_GET_TIMING
203 { PR_GET_TIMING, "PR_GET_TIMING" },
204#endif
205#ifdef PR_SET_TIMING
206 { PR_SET_TIMING, "PR_SET_TIMING" },
207#endif
208#ifdef PR_SET_NAME
209 { PR_SET_NAME, "PR_SET_NAME" },
210#endif
211#ifdef PR_GET_NAME
212 { PR_GET_NAME, "PR_GET_NAME" },
213#endif
214#ifdef PR_GET_ENDIAN
215 { PR_GET_ENDIAN, "PR_GET_ENDIAN" },
216#endif
217#ifdef PR_SET_ENDIAN
218 { PR_SET_ENDIAN, "PR_SET_ENDIAN" },
219#endif
220#ifdef PR_GET_SECCOMP
221 { PR_GET_SECCOMP, "PR_GET_SECCOMP" },
222#endif
223#ifdef PR_SET_SECCOMP
224 { PR_SET_SECCOMP, "PR_SET_SECCOMP" },
225#endif
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000226#ifdef PR_GET_TSC
227 { PR_GET_TSC, "PR_GET_TSC" },
228#endif
229#ifdef PR_SET_TSC
230 { PR_SET_TSC, "PR_SET_TSC" },
231#endif
232#ifdef PR_GET_SECUREBITS
233 { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" },
234#endif
235#ifdef PR_SET_SECUREBITS
236 { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" },
237#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000238 { 0, NULL },
239};
240
Roland McGratha4d48532005-06-08 20:45:28 +0000241static const char *
Denys Vlasenko12014262011-05-30 14:00:14 +0200242unalignctl_string(unsigned int ctl)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000243{
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100244 static char buf[sizeof(int)*2 + 2];
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000245
246 switch (ctl) {
247#ifdef PR_UNALIGN_NOPRINT
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100248 case PR_UNALIGN_NOPRINT:
249 return "NOPRINT";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000250#endif
251#ifdef PR_UNALIGN_SIGBUS
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100252 case PR_UNALIGN_SIGBUS:
253 return "SIGBUS";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000254#endif
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100255 default:
256 break;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000257 }
258 sprintf(buf, "%x", ctl);
259 return buf;
260}
261
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000262int
Denys Vlasenko12014262011-05-30 14:00:14 +0200263sys_prctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000264{
265 int i;
266
267 if (entering(tcp)) {
268 printxval(prctl_options, tcp->u_arg[0], "PR_???");
269 switch (tcp->u_arg[0]) {
270#ifdef PR_GETNSHARE
271 case PR_GETNSHARE:
272 break;
273#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000274#ifdef PR_SET_PDEATHSIG
275 case PR_SET_PDEATHSIG:
276 tprintf(", %lu", tcp->u_arg[1]);
277 break;
278#endif
279#ifdef PR_GET_PDEATHSIG
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000280 case PR_GET_PDEATHSIG:
281 break;
282#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000283#ifdef PR_SET_DUMPABLE
284 case PR_SET_DUMPABLE:
285 tprintf(", %lu", tcp->u_arg[1]);
286 break;
287#endif
288#ifdef PR_GET_DUMPABLE
289 case PR_GET_DUMPABLE:
290 break;
291#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000292#ifdef PR_SET_UNALIGN
293 case PR_SET_UNALIGN:
294 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
295 break;
296#endif
297#ifdef PR_GET_UNALIGN
298 case PR_GET_UNALIGN:
299 tprintf(", %#lx", tcp->u_arg[1]);
300 break;
301#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000302#ifdef PR_SET_KEEPCAPS
303 case PR_SET_KEEPCAPS:
304 tprintf(", %lu", tcp->u_arg[1]);
305 break;
306#endif
307#ifdef PR_GET_KEEPCAPS
308 case PR_GET_KEEPCAPS:
309 break;
310#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000311 default:
312 for (i = 1; i < tcp->u_nargs; i++)
313 tprintf(", %#lx", tcp->u_arg[i]);
314 break;
315 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000316 } else {
317 switch (tcp->u_arg[0]) {
318#ifdef PR_GET_PDEATHSIG
319 case PR_GET_PDEATHSIG:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000320 if (umove(tcp, tcp->u_arg[1], &i) < 0)
321 tprintf(", %#lx", tcp->u_arg[1]);
322 else
323 tprintf(", {%u}", i);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000324 break;
325#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000326#ifdef PR_GET_DUMPABLE
327 case PR_GET_DUMPABLE:
328 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000329#endif
330#ifdef PR_GET_UNALIGN
331 case PR_GET_UNALIGN:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000332 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
333 break;
334 tcp->auxstr = unalignctl_string(i);
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000335 return RVAL_STR;
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000336#endif
337#ifdef PR_GET_KEEPCAPS
338 case PR_GET_KEEPCAPS:
339 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000340#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000341 default:
342 break;
343 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000344 }
345 return 0;
346}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000347#endif /* HAVE_PRCTL */
348
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000349int
Denys Vlasenko12014262011-05-30 14:00:14 +0200350sys_sethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000351{
352 if (entering(tcp)) {
353 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
354 tprintf(", %lu", tcp->u_arg[1]);
355 }
356 return 0;
357}
358
Denys Vlasenko84703742012-02-25 02:38:52 +0100359#if defined(ALPHA)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000360int
Denys Vlasenko12014262011-05-30 14:00:14 +0200361sys_gethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000362{
363 if (exiting(tcp)) {
364 if (syserror(tcp))
365 tprintf("%#lx", tcp->u_arg[0]);
366 else
367 printpath(tcp, tcp->u_arg[0]);
368 tprintf(", %lu", tcp->u_arg[1]);
369 }
370 return 0;
371}
Denys Vlasenko84703742012-02-25 02:38:52 +0100372#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000373
374int
Denys Vlasenko12014262011-05-30 14:00:14 +0200375sys_setdomainname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000376{
377 if (entering(tcp)) {
378 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
379 tprintf(", %lu", tcp->u_arg[1]);
380 }
381 return 0;
382}
383
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000384int
Denys Vlasenko12014262011-05-30 14:00:14 +0200385sys_exit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000386{
387 if (exiting(tcp)) {
388 fprintf(stderr, "_exit returned!\n");
389 return -1;
390 }
391 /* special case: we stop tracing this process, finish line now */
392 tprintf("%ld) ", tcp->u_arg[0]);
Denys Vlasenko102ec492011-08-25 01:27:59 +0200393 tabto();
Denys Vlasenko000b6012012-01-28 01:25:03 +0100394 tprints("= ?\n");
395 printing_tcp = NULL;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000396 return 0;
397}
398
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000399/* defines copied from linux/sched.h since we can't include that
400 * ourselves (it conflicts with *lots* of libc includes)
401 */
402#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
403#define CLONE_VM 0x00000100 /* set if VM shared between processes */
404#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
405#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
406#define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
Roland McGrath909875b2002-12-22 03:34:36 +0000407#define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000408#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
409#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
410#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
Roland McGrath909875b2002-12-22 03:34:36 +0000411#define CLONE_THREAD 0x00010000 /* Same thread group? */
412#define CLONE_NEWNS 0x00020000 /* New namespace group? */
413#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
414#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
415#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
416#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
Roland McGrath909875b2002-12-22 03:34:36 +0000417#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
418#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000419#define CLONE_STOPPED 0x02000000 /* Start in stopped state */
420#define CLONE_NEWUTS 0x04000000 /* New utsname group? */
421#define CLONE_NEWIPC 0x08000000 /* New ipcs */
422#define CLONE_NEWUSER 0x10000000 /* New user namespace */
423#define CLONE_NEWPID 0x20000000 /* New pid namespace */
424#define CLONE_NEWNET 0x40000000 /* New network namespace */
425#define CLONE_IO 0x80000000 /* Clone io context */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000426
Roland McGrathd9f816f2004-09-04 03:39:20 +0000427static const struct xlat clone_flags[] = {
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000428 { CLONE_VM, "CLONE_VM" },
429 { CLONE_FS, "CLONE_FS" },
430 { CLONE_FILES, "CLONE_FILES" },
431 { CLONE_SIGHAND, "CLONE_SIGHAND" },
Roland McGrath909875b2002-12-22 03:34:36 +0000432 { CLONE_IDLETASK, "CLONE_IDLETASK"},
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000433 { CLONE_PTRACE, "CLONE_PTRACE" },
434 { CLONE_VFORK, "CLONE_VFORK" },
435 { CLONE_PARENT, "CLONE_PARENT" },
Roland McGrath909875b2002-12-22 03:34:36 +0000436 { CLONE_THREAD, "CLONE_THREAD" },
437 { CLONE_NEWNS, "CLONE_NEWNS" },
438 { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
439 { CLONE_SETTLS, "CLONE_SETTLS" },
440 { CLONE_PARENT_SETTID,"CLONE_PARENT_SETTID" },
441 { CLONE_CHILD_CLEARTID,"CLONE_CHILD_CLEARTID" },
Roland McGrath909875b2002-12-22 03:34:36 +0000442 { CLONE_UNTRACED, "CLONE_UNTRACED" },
443 { CLONE_CHILD_SETTID,"CLONE_CHILD_SETTID" },
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000444 { CLONE_STOPPED, "CLONE_STOPPED" },
445 { CLONE_NEWUTS, "CLONE_NEWUTS" },
446 { CLONE_NEWIPC, "CLONE_NEWIPC" },
447 { CLONE_NEWUSER, "CLONE_NEWUSER" },
448 { CLONE_NEWPID, "CLONE_NEWPID" },
449 { CLONE_NEWNET, "CLONE_NEWNET" },
450 { CLONE_IO, "CLONE_IO" },
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000451 { 0, NULL },
452};
453
Roland McGrath909875b2002-12-22 03:34:36 +0000454# ifdef I386
455# include <asm/ldt.h>
Roland McGrath7decfb22004-03-01 22:10:52 +0000456# ifdef HAVE_STRUCT_USER_DESC
457# define modify_ldt_ldt_s user_desc
458# endif
Roland McGrath909875b2002-12-22 03:34:36 +0000459extern void print_ldt_entry();
460# endif
461
Roland McGrath9677b3a2003-03-12 09:54:36 +0000462# if defined IA64
463# define ARG_FLAGS 0
464# define ARG_STACK 1
Dmitry V. Levin44824b92012-02-20 21:44:53 +0000465# define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
466# define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
467# define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
468# define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +0000469# elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
Roland McGrath9677b3a2003-03-12 09:54:36 +0000470# define ARG_STACK 0
471# define ARG_FLAGS 1
472# define ARG_PTID 2
Roland McGrathfe5fdb22003-05-23 00:29:05 +0000473# define ARG_CTID 3
474# define ARG_TLS 4
Roland McGrath9c555e72003-07-09 09:47:59 +0000475# elif defined X86_64 || defined ALPHA
Roland McGrath361aac52003-03-18 07:43:42 +0000476# define ARG_FLAGS 0
477# define ARG_STACK 1
478# define ARG_PTID 2
479# define ARG_CTID 3
480# define ARG_TLS 4
Roland McGrath9677b3a2003-03-12 09:54:36 +0000481# else
482# define ARG_FLAGS 0
483# define ARG_STACK 1
484# define ARG_PTID 2
485# define ARG_TLS 3
486# define ARG_CTID 4
487# endif
488
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000489int
Denys Vlasenko12014262011-05-30 14:00:14 +0200490sys_clone(struct tcb *tcp)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000491{
492 if (exiting(tcp)) {
Wang Chaocbdd1902010-09-02 15:08:59 +0800493 const char *sep = "|";
Roland McGrath9677b3a2003-03-12 09:54:36 +0000494 unsigned long flags = tcp->u_arg[ARG_FLAGS];
495 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
496# ifdef ARG_STACKSIZE
497 if (ARG_STACKSIZE != -1)
498 tprintf("stack_size=%#lx, ",
499 tcp->u_arg[ARG_STACKSIZE]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000500# endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200501 tprints("flags=");
Wang Chaocbdd1902010-09-02 15:08:59 +0800502 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
503 sep = "";
Roland McGrath984154d2003-05-23 01:08:42 +0000504 if ((flags & CSIGNAL) != 0)
Wang Chaocbdd1902010-09-02 15:08:59 +0800505 tprintf("%s%s", sep, signame(flags & CSIGNAL));
Roland McGrathb4968be2003-01-20 09:04:33 +0000506 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
Roland McGrath9677b3a2003-03-12 09:54:36 +0000507 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
Roland McGrath909875b2002-12-22 03:34:36 +0000508 return 0;
Roland McGrath6f67a982003-03-21 07:33:15 +0000509 if (flags & CLONE_PARENT_SETTID)
510 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000511 if (flags & CLONE_SETTLS) {
Roland McGrath9677b3a2003-03-12 09:54:36 +0000512# ifdef I386
Roland McGrath909875b2002-12-22 03:34:36 +0000513 struct modify_ldt_ldt_s copy;
Roland McGrath9677b3a2003-03-12 09:54:36 +0000514 if (umove(tcp, tcp->u_arg[ARG_TLS], &copy) != -1) {
Roland McGrath909875b2002-12-22 03:34:36 +0000515 tprintf(", {entry_number:%d, ",
516 copy.entry_number);
517 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200518 tprints("...}");
Roland McGrath909875b2002-12-22 03:34:36 +0000519 else
520 print_ldt_entry(&copy);
521 }
522 else
Roland McGrath9677b3a2003-03-12 09:54:36 +0000523# endif
Roland McGrath43f2c842003-03-12 09:58:14 +0000524 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
Roland McGrath909875b2002-12-22 03:34:36 +0000525 }
Roland McGrath9677b3a2003-03-12 09:54:36 +0000526 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
527 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000528 }
529 return 0;
530}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000531
532int
533sys_unshare(struct tcb *tcp)
534{
535 if (entering(tcp))
536 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
537 return 0;
538}
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000539
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000540int
Denys Vlasenko12014262011-05-30 14:00:14 +0200541sys_fork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000542{
543 if (exiting(tcp))
544 return RVAL_UDECIMAL;
545 return 0;
546}
547
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000548int
Denys Vlasenko418d66a2009-01-17 01:52:54 +0000549change_syscall(struct tcb *tcp, int new)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000550{
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000551#if defined(I386)
552 /* Attempt to make vfork into fork, which we can follow. */
Roland McGrath5a223472002-12-15 23:58:26 +0000553 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000554 return -1;
555 return 0;
Michal Ludvig0e035502002-09-23 15:41:01 +0000556#elif defined(X86_64)
557 /* Attempt to make vfork into fork, which we can follow. */
Roland McGrath5a223472002-12-15 23:58:26 +0000558 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_RAX * 8), new) < 0)
Michal Ludvig0e035502002-09-23 15:41:01 +0000559 return -1;
560 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000561#elif defined(POWERPC)
Roland McGratheb285352003-01-14 09:59:00 +0000562 if (ptrace(PTRACE_POKEUSER, tcp->pid,
563 (char*)(sizeof(unsigned long)*PT_R0), new) < 0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000564 return -1;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000565 return 0;
Michal Ludvig10a88d02002-10-07 14:31:00 +0000566#elif defined(S390) || defined(S390X)
567 /* s390 linux after 2.4.7 has a hook in entry.S to allow this */
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200568 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR2), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000569 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000570 return 0;
571#elif defined(M68K)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200572 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_ORIG_D0), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000573 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000574 return 0;
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000575#elif defined(SPARC) || defined(SPARC64)
Mike Frysinger8566c502009-10-12 11:05:14 -0400576 struct pt_regs regs;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200577 if (ptrace(PTRACE_GETREGS, tcp->pid, (char*)&regs, 0) < 0)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000578 return -1;
Mike Frysinger8566c502009-10-12 11:05:14 -0400579 regs.u_regs[U_REG_G1] = new;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200580 if (ptrace(PTRACE_SETREGS, tcp->pid, (char*)&regs, 0) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000581 return -1;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000582 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000583#elif defined(MIPS)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200584 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000585 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000586 return 0;
587#elif defined(ALPHA)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200588 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000589 return -1;
590 return 0;
591#elif defined(AVR32)
592 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_R8), new) < 0)
593 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000594 return 0;
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000595#elif defined(BFIN)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200596 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_P0), new) < 0)
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000597 return -1;
598 return 0;
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000599#elif defined(IA64)
Roland McGrath08267b82004-02-20 22:56:43 +0000600 if (ia32) {
601 switch (new) {
Denys Vlasenko418d66a2009-01-17 01:52:54 +0000602 case 2:
603 break; /* x86 SYS_fork */
604 case SYS_clone:
605 new = 120;
606 break;
607 default:
Roland McGrath08267b82004-02-20 22:56:43 +0000608 fprintf(stderr, "%s: unexpected syscall %d\n",
609 __FUNCTION__, new);
610 return -1;
611 }
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200612 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R1), new) < 0)
Roland McGrath08267b82004-02-20 22:56:43 +0000613 return -1;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200614 } else if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R15), new) < 0)
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000615 return -1;
616 return 0;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000617#elif defined(HPPA)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200618 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR20), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000619 return -1;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000620 return 0;
Wichert Akkermanccef6372002-05-01 16:39:22 +0000621#elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200622 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*(REG_REG0+3)), new) < 0)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000623 return -1;
624 return 0;
Roland McGrathf5a47772003-06-26 22:40:42 +0000625#elif defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000626 /* Top half of reg encodes the no. of args n as 0x1n.
627 Assume 0 args as kernel never actually checks... */
628 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_SYSCALL),
629 0x100000 | new) < 0)
630 return -1;
631 return 0;
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +0000632#elif defined(CRISV10) || defined(CRISV32)
633 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R9), new) < 0)
634 return -1;
635 return 0;
Roland McGrathf691bd22006-04-25 07:34:41 +0000636#elif defined(ARM)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000637 /* Some kernels support this, some (pre-2.6.16 or so) don't. */
Roland McGrathf691bd22006-04-25 07:34:41 +0000638# ifndef PTRACE_SET_SYSCALL
639# define PTRACE_SET_SYSCALL 23
640# endif
641
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200642 if (ptrace(PTRACE_SET_SYSCALL, tcp->pid, 0, new & 0xffff) != 0)
Roland McGrathf691bd22006-04-25 07:34:41 +0000643 return -1;
644
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000645 return 0;
Chris Metcalfc8c66982009-12-28 10:00:15 -0500646#elif defined(TILE)
647 if (ptrace(PTRACE_POKEUSER, tcp->pid,
648 (char*)PTREGS_OFFSET_REG(0),
649 new) != 0)
650 return -1;
651 return 0;
Edgar E. Iglesias939caba2010-07-06 14:21:07 +0200652#elif defined(MICROBLAZE)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200653 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new) < 0)
Edgar E. Iglesias939caba2010-07-06 14:21:07 +0200654 return -1;
655 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000656#else
657#warning Do not know how to handle change_syscall for this architecture
658#endif /* architecture */
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000659 return -1;
660}
661
Wang Chaoca8ab8d2010-11-12 17:26:08 +0800662int
Dmitry V. Levin257e1572009-12-26 17:55:24 +0000663internal_fork(struct tcb *tcp)
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000664{
Denys Vlasenkof44cce42011-06-21 14:34:10 +0200665 if ((ptrace_setoptions
Wang Chaoca8ab8d2010-11-12 17:26:08 +0800666 & (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
667 == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
668 return 0;
669
Denys Vlasenko65d7c4d2011-06-23 21:46:37 +0200670 if (!followfork)
671 return 0;
672
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000673 if (entering(tcp)) {
Wang Chaoe636c852010-09-16 11:20:56 +0800674 /*
Denys Vlasenko833fb132011-08-17 11:30:56 +0200675 * We won't see the new child if clone is called with
676 * CLONE_UNTRACED, so we keep the same logic with that option
677 * and don't trace it.
Wang Chaoe636c852010-09-16 11:20:56 +0800678 */
679 if ((sysent[tcp->scno].sys_func == sys_clone) &&
680 (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED))
681 return 0;
Denys Vlasenkoe7c90242011-06-22 00:09:25 +0200682 setbpt(tcp);
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000683 } else {
Denys Vlasenko833fb132011-08-17 11:30:56 +0200684 if (tcp->flags & TCB_BPTSET)
685 clearbpt(tcp);
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000686 }
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000687 return 0;
688}
Dmitry V. Levin257e1572009-12-26 17:55:24 +0000689
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000690int
Denys Vlasenko12014262011-05-30 14:00:14 +0200691sys_vfork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000692{
693 if (exiting(tcp))
694 return RVAL_UDECIMAL;
695 return 0;
696}
697
Dmitry V. Levin50a218d2011-01-18 17:36:20 +0000698int sys_getuid(struct tcb *tcp)
699{
700 if (exiting(tcp))
701 tcp->u_rval = (uid_t) tcp->u_rval;
702 return RVAL_UDECIMAL;
703}
704
705int sys_setfsuid(struct tcb *tcp)
706{
707 if (entering(tcp))
708 tprintf("%u", (uid_t) tcp->u_arg[0]);
709 else
710 tcp->u_rval = (uid_t) tcp->u_rval;
711 return RVAL_UDECIMAL;
712}
713
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000714int
Denys Vlasenko12014262011-05-30 14:00:14 +0200715sys_setuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000716{
717 if (entering(tcp)) {
718 tprintf("%u", (uid_t) tcp->u_arg[0]);
719 }
720 return 0;
721}
722
723int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000724sys_getresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000725{
726 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000727 __kernel_uid_t uid;
728 if (syserror(tcp))
729 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
730 tcp->u_arg[1], tcp->u_arg[2]);
731 else {
732 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
733 tprintf("%#lx, ", tcp->u_arg[0]);
734 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000735 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000736 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
737 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000738 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000739 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000740 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
741 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000742 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000743 tprintf("[%lu]", (unsigned long) uid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000744 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000745 }
746 return 0;
747}
748
749int
Denys Vlasenko12014262011-05-30 14:00:14 +0200750sys_setreuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000751{
752 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000753 printuid("", tcp->u_arg[0]);
754 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000755 }
756 return 0;
757}
758
759int
Denys Vlasenko12014262011-05-30 14:00:14 +0200760sys_setresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000761{
762 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000763 printuid("", tcp->u_arg[0]);
764 printuid(", ", tcp->u_arg[1]);
765 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000766 }
767 return 0;
768}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000769
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000770int
Denys Vlasenko12014262011-05-30 14:00:14 +0200771sys_setgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000772{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000773 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000774 unsigned long len, size, start, cur, end, abbrev_end;
775 GETGROUPS_T gid;
776 int failed = 0;
777
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000778 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000779 tprintf("%lu, ", len);
780 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200781 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000782 return 0;
783 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000784 start = tcp->u_arg[1];
785 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200786 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000787 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000788 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000789 size = len * sizeof(gid);
790 end = start + size;
791 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
792 tprintf("%#lx", start);
793 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000794 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000795 if (abbrev(tcp)) {
796 abbrev_end = start + max_strlen * sizeof(gid);
797 if (abbrev_end < start)
798 abbrev_end = end;
799 } else {
800 abbrev_end = end;
801 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200802 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000803 for (cur = start; cur < end; cur += sizeof(gid)) {
804 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200805 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000806 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200807 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000808 break;
809 }
810 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200811 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000812 failed = 1;
813 break;
814 }
815 tprintf("%lu", (unsigned long) gid);
816 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200817 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000818 if (failed)
819 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000820 }
821 return 0;
822}
823
824int
Denys Vlasenko12014262011-05-30 14:00:14 +0200825sys_getgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000826{
Roland McGrathaa524c82005-06-01 19:22:06 +0000827 unsigned long len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000828
829 if (entering(tcp)) {
830 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000831 tprintf("%lu, ", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000832 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000833 unsigned long size, start, cur, end, abbrev_end;
834 GETGROUPS_T gid;
835 int failed = 0;
836
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000837 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000838 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200839 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000840 return 0;
841 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000842 start = tcp->u_arg[1];
843 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200844 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000845 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000846 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000847 if (tcp->u_arg[0] == 0) {
848 tprintf("%#lx", start);
849 return 0;
850 }
851 size = len * sizeof(gid);
852 end = start + size;
853 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
854 size / sizeof(gid) != len || end < start) {
855 tprintf("%#lx", start);
856 return 0;
857 }
858 if (abbrev(tcp)) {
859 abbrev_end = start + max_strlen * sizeof(gid);
860 if (abbrev_end < start)
861 abbrev_end = end;
862 } else {
863 abbrev_end = end;
864 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200865 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000866 for (cur = start; cur < end; cur += sizeof(gid)) {
867 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200868 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000869 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200870 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000871 break;
872 }
873 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200874 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000875 failed = 1;
876 break;
877 }
878 tprintf("%lu", (unsigned long) gid);
879 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200880 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000881 if (failed)
882 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000883 }
884 return 0;
885}
886
Roland McGrath83bd47a2003-11-13 22:32:26 +0000887int
Denys Vlasenko12014262011-05-30 14:00:14 +0200888sys_setgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000889{
Roland McGrath83bd47a2003-11-13 22:32:26 +0000890 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000891 unsigned long len, size, start, cur, end, abbrev_end;
892 GETGROUPS32_T gid;
893 int failed = 0;
894
Roland McGrath83bd47a2003-11-13 22:32:26 +0000895 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000896 tprintf("%lu, ", len);
897 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200898 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000899 return 0;
900 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000901 start = tcp->u_arg[1];
902 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200903 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000904 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000905 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000906 size = len * sizeof(gid);
907 end = start + size;
908 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
909 tprintf("%#lx", start);
910 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000911 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000912 if (abbrev(tcp)) {
913 abbrev_end = start + max_strlen * sizeof(gid);
914 if (abbrev_end < start)
915 abbrev_end = end;
916 } else {
917 abbrev_end = end;
918 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200919 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000920 for (cur = start; cur < end; cur += sizeof(gid)) {
921 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200922 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000923 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200924 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000925 break;
926 }
927 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200928 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000929 failed = 1;
930 break;
931 }
932 tprintf("%lu", (unsigned long) gid);
933 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200934 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000935 if (failed)
936 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000937 }
938 return 0;
939}
940
941int
Denys Vlasenko12014262011-05-30 14:00:14 +0200942sys_getgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000943{
Roland McGrathaa524c82005-06-01 19:22:06 +0000944 unsigned long len;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000945
946 if (entering(tcp)) {
947 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000948 tprintf("%lu, ", len);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000949 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000950 unsigned long size, start, cur, end, abbrev_end;
951 GETGROUPS32_T gid;
952 int failed = 0;
953
Roland McGrath83bd47a2003-11-13 22:32:26 +0000954 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000955 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200956 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000957 return 0;
958 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000959 start = tcp->u_arg[1];
960 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200961 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000962 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000963 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000964 size = len * sizeof(gid);
965 end = start + size;
966 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
967 size / sizeof(gid) != len || end < start) {
968 tprintf("%#lx", start);
969 return 0;
970 }
971 if (abbrev(tcp)) {
972 abbrev_end = start + max_strlen * sizeof(gid);
973 if (abbrev_end < start)
974 abbrev_end = end;
975 } else {
976 abbrev_end = end;
977 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200978 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000979 for (cur = start; cur < end; cur += sizeof(gid)) {
980 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200981 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000982 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200983 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000984 break;
985 }
986 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200987 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000988 failed = 1;
989 break;
990 }
991 tprintf("%lu", (unsigned long) gid);
992 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200993 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000994 if (failed)
995 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000996 }
997 return 0;
998}
Roland McGrath83bd47a2003-11-13 22:32:26 +0000999
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001000static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +00001001printargv(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001002{
Roland McGrath85a3bc42007-08-02 02:13:05 +00001003 union {
Andreas Schwab99c85692009-08-28 19:36:20 +02001004 unsigned int p32;
1005 unsigned long p64;
Roland McGrath85a3bc42007-08-02 02:13:05 +00001006 char data[sizeof(long)];
1007 } cp;
Dmitry V. Levin30145dd2010-09-06 22:08:24 +00001008 const char *sep;
Roland McGrath85a3bc42007-08-02 02:13:05 +00001009 int n = 0;
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001010 unsigned wordsize = personality_wordsize[current_personality];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001011
Roland McGrath85a3bc42007-08-02 02:13:05 +00001012 cp.p64 = 1;
1013 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001014 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001015 tprintf("%#lx", addr);
1016 return;
1017 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001018 if (wordsize == 4)
Roland McGrath85a3bc42007-08-02 02:13:05 +00001019 cp.p64 = cp.p32;
1020 if (cp.p64 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001021 break;
Denys Vlasenko5940e652011-09-01 09:55:05 +02001022 tprints(sep);
Roland McGrath85a3bc42007-08-02 02:13:05 +00001023 printstr(tcp, cp.p64, -1);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001024 addr += wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001025 }
Roland McGrath85a3bc42007-08-02 02:13:05 +00001026 if (cp.p64)
1027 tprintf("%s...", sep);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001028}
1029
1030static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +00001031printargc(const char *fmt, struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001032{
1033 int count;
1034 char *cp;
1035
1036 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
1037 addr += sizeof(char *);
1038 }
1039 tprintf(fmt, count, count == 1 ? "" : "s");
1040}
1041
Denys Vlasenko84703742012-02-25 02:38:52 +01001042#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001043int
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001044sys_execv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001045{
1046 if (entering(tcp)) {
1047 printpath(tcp, tcp->u_arg[0]);
1048 if (!verbose(tcp))
1049 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001050 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001051 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001052 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001053 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001054 }
1055 }
1056 return 0;
1057}
Denys Vlasenko84703742012-02-25 02:38:52 +01001058#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001059
1060int
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001061sys_execve(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001062{
1063 if (entering(tcp)) {
1064 printpath(tcp, tcp->u_arg[0]);
1065 if (!verbose(tcp))
1066 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001067 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001068 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001069 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001070 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001071 }
1072 if (!verbose(tcp))
1073 tprintf(", %#lx", tcp->u_arg[2]);
1074 else if (abbrev(tcp))
1075 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
1076 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001077 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001078 printargv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001079 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001080 }
1081 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001082 return 0;
1083}
1084
Denys Vlasenko84703742012-02-25 02:38:52 +01001085#if defined(TCB_WAITEXECVE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001086int
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001087internal_exec(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001088{
Roland McGrathfdb097f2004-07-12 07:38:55 +00001089 if (exiting(tcp) && syserror(tcp))
1090 tcp->flags &= ~TCB_WAITEXECVE;
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001091 else {
1092 /* Maybe we have post-execve SIGTRAP suppressed? */
Denys Vlasenkof44cce42011-06-21 14:34:10 +02001093 if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC))
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001094 tcp->flags |= TCB_WAITEXECVE; /* no */
1095 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001096 return 0;
1097}
Denys Vlasenkoa7949742011-08-21 17:26:55 +02001098#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001099
Roland McGrath7ec1d352002-12-17 04:50:44 +00001100#ifndef __WNOTHREAD
1101#define __WNOTHREAD 0x20000000
1102#endif
1103#ifndef __WALL
1104#define __WALL 0x40000000
1105#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001106#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +00001107#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001108#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001109
Roland McGrathd9f816f2004-09-04 03:39:20 +00001110static const struct xlat wait4_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001111 { WNOHANG, "WNOHANG" },
1112#ifndef WSTOPPED
1113 { WUNTRACED, "WUNTRACED" },
1114#endif
1115#ifdef WEXITED
1116 { WEXITED, "WEXITED" },
1117#endif
1118#ifdef WTRAPPED
1119 { WTRAPPED, "WTRAPPED" },
1120#endif
1121#ifdef WSTOPPED
1122 { WSTOPPED, "WSTOPPED" },
1123#endif
1124#ifdef WCONTINUED
1125 { WCONTINUED, "WCONTINUED" },
1126#endif
1127#ifdef WNOWAIT
1128 { WNOWAIT, "WNOWAIT" },
1129#endif
1130#ifdef __WCLONE
1131 { __WCLONE, "__WCLONE" },
1132#endif
Roland McGrath7ec1d352002-12-17 04:50:44 +00001133#ifdef __WALL
1134 { __WALL, "__WALL" },
1135#endif
1136#ifdef __WNOTHREAD
1137 { __WNOTHREAD, "__WNOTHREAD" },
1138#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001139 { 0, NULL },
1140};
1141
Roland McGrath5e02a572004-10-19 23:33:47 +00001142#if !defined WCOREFLAG && defined WCOREFLG
1143# define WCOREFLAG WCOREFLG
1144#endif
1145#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001146# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +00001147#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001148#ifndef WCOREDUMP
1149# define WCOREDUMP(status) ((status) & 0200)
1150#endif
1151
Roland McGrath5e02a572004-10-19 23:33:47 +00001152#ifndef W_STOPCODE
1153#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
1154#endif
1155#ifndef W_EXITCODE
1156#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
1157#endif
1158
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001159static int
Denys Vlasenko12014262011-05-30 14:00:14 +02001160printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001161{
1162 int exited = 0;
1163
1164 /*
1165 * Here is a tricky presentation problem. This solution
1166 * is still not entirely satisfactory but since there
1167 * are no wait status constructors it will have to do.
1168 */
Roland McGrath79fbda52004-04-14 02:45:55 +00001169 if (WIFSTOPPED(status)) {
1170 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001171 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +00001172 status &= ~W_STOPCODE(WSTOPSIG(status));
1173 }
1174 else if (WIFSIGNALED(status)) {
1175 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001176 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001177 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +00001178 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1179 }
1180 else if (WIFEXITED(status)) {
1181 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001182 WEXITSTATUS(status));
1183 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +00001184 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001185 }
Roland McGrath79fbda52004-04-14 02:45:55 +00001186 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001187 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001188 return 0;
1189 }
1190
1191 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001192 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +00001193 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +00001194 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001195
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001196 return exited;
1197}
1198
1199static int
Denys Vlasenko59432db2009-01-26 19:09:35 +00001200printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001201{
1202 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001203
1204 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001205 /* On Linux, kernel-side pid_t is typedef'ed to int
1206 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +00001207 * pid argument to int on 64bit arches, producing,
1208 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001209 * in strace. We have to use int here, not long.
1210 */
1211 int pid = tcp->u_arg[0];
1212 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001213 } else {
1214 /* status */
1215 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001216 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001217 else if (syserror(tcp) || tcp->u_rval == 0)
1218 tprintf("%#lx", tcp->u_arg[1]);
1219 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001220 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001221 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +00001222 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001223 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001224 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001225 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001226 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001227 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001228 /* usage */
1229 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001230 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001231 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +00001232#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001233 if (bitness)
1234 printrusage32(tcp, tcp->u_arg[3]);
1235 else
1236#endif
1237 printrusage(tcp, tcp->u_arg[3]);
1238 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001239 else
1240 tprintf("%#lx", tcp->u_arg[3]);
1241 }
1242 }
1243 return 0;
1244}
1245
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001246int
Denys Vlasenko12014262011-05-30 14:00:14 +02001247sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001248{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001249 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001250}
1251
1252int
Denys Vlasenko12014262011-05-30 14:00:14 +02001253sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001254{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001255 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001256}
1257
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001258#ifdef ALPHA
1259int
Denys Vlasenko12014262011-05-30 14:00:14 +02001260sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001261{
1262 return printwaitn(tcp, 4, 1);
1263}
1264#endif
1265
Roland McGrathd9f816f2004-09-04 03:39:20 +00001266static const struct xlat waitid_types[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001267 { P_PID, "P_PID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001268#ifdef P_PPID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001269 { P_PPID, "P_PPID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001270#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001271 { P_PGID, "P_PGID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001272#ifdef P_SID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001273 { P_SID, "P_SID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001274#endif
1275#ifdef P_CID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001276 { P_CID, "P_CID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001277#endif
1278#ifdef P_UID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001279 { P_UID, "P_UID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001280#endif
1281#ifdef P_GID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001282 { P_GID, "P_GID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001283#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001284 { P_ALL, "P_ALL" },
1285#ifdef P_LWPID
1286 { P_LWPID, "P_LWPID" },
1287#endif
1288 { 0, NULL },
1289};
1290
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001291int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +00001292sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001293{
1294 siginfo_t si;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001295
1296 if (entering(tcp)) {
1297 printxval(waitid_types, tcp->u_arg[0], "P_???");
1298 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001299 }
1300 else {
1301 /* siginfo */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001302 if (!tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001303 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001304 else if (syserror(tcp))
1305 tprintf("%#lx", tcp->u_arg[2]);
1306 else if (umove(tcp, tcp->u_arg[2], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001307 tprints("{???}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001308 else
Denys Vlasenkof535b542009-01-13 18:30:55 +00001309 printsiginfo(&si, verbose(tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001310 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001311 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001312 printflags(wait4_options, tcp->u_arg[3], "W???");
Roland McGrath39426a32004-10-06 22:02:59 +00001313 if (tcp->u_nargs > 4) {
1314 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001315 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +00001316 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001317 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +00001318 else if (tcp->u_error)
1319 tprintf("%#lx", tcp->u_arg[4]);
1320 else
1321 printrusage(tcp, tcp->u_arg[4]);
1322 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001323 }
1324 return 0;
1325}
1326
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001327int
Denys Vlasenko12014262011-05-30 14:00:14 +02001328sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001329{
1330 struct utsname uname;
1331
1332 if (exiting(tcp)) {
1333 if (syserror(tcp) || !verbose(tcp))
1334 tprintf("%#lx", tcp->u_arg[0]);
1335 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001336 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001337 else if (!abbrev(tcp)) {
1338
1339 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1340 uname.sysname, uname.nodename);
1341 tprintf("release=\"%s\", version=\"%s\", ",
1342 uname.release, uname.version);
1343 tprintf("machine=\"%s\"", uname.machine);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001344#ifndef __GLIBC__
1345 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001346#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001347 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001348 }
1349 else
1350 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1351 uname.sysname, uname.nodename);
1352 }
1353 return 0;
1354}
1355
Roland McGratheb9e2e82009-06-02 16:49:22 -07001356static const struct xlat ptrace_cmds[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001357 { PTRACE_TRACEME, "PTRACE_TRACEME" },
Denys Vlasenko61526c62011-08-25 10:21:13 +02001358 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1359 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1360 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1361 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1362 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1363 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001364 { PTRACE_CONT, "PTRACE_CONT" },
1365 { PTRACE_KILL, "PTRACE_KILL" },
1366 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1367 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1368 { PTRACE_DETACH, "PTRACE_DETACH" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001369# ifdef PTRACE_GETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001370 { PTRACE_GETREGS, "PTRACE_GETREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001371# endif
1372# ifdef PTRACE_SETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001373 { PTRACE_SETREGS, "PTRACE_SETREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001374# endif
1375# ifdef PTRACE_GETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001376 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001377# endif
1378# ifdef PTRACE_SETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001379 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001380# endif
1381# ifdef PTRACE_GETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001382 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001383# endif
1384# ifdef PTRACE_SETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001385 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001386# endif
1387# ifdef PTRACE_GETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001388 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001389# endif
1390# ifdef PTRACE_SETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001391 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001392# endif
1393# ifdef PTRACE_SETOPTIONS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001394 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001395# endif
1396# ifdef PTRACE_GETEVENTMSG
Denys Vlasenko61526c62011-08-25 10:21:13 +02001397 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001398# endif
1399# ifdef PTRACE_GETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001400 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001401# endif
1402# ifdef PTRACE_SETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001403 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001404# endif
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001405# ifdef PTRACE_GETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001406 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001407# endif
1408# ifdef PTRACE_SETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001409 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001410# endif
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001411# ifdef PTRACE_SET_SYSCALL
Denys Vlasenko61526c62011-08-25 10:21:13 +02001412 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001413# endif
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001414# ifdef PTRACE_SEIZE
1415 { PTRACE_SEIZE, "PTRACE_SEIZE" },
1416# endif
1417# ifdef PTRACE_INTERRUPT
1418 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
1419# endif
1420# ifdef PTRACE_LISTEN
1421 { PTRACE_LISTEN, "PTRACE_LISTEN" },
1422# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001423 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
Denys Vlasenkof535b542009-01-13 18:30:55 +00001424
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001425 { 0, NULL },
1426};
1427
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001428# ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00001429static const struct xlat ptrace_setoptions_flags[] = {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001430# ifdef PTRACE_O_TRACESYSGOOD
Denys Vlasenkof535b542009-01-13 18:30:55 +00001431 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001432# endif
1433# ifdef PTRACE_O_TRACEFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001434 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001435# endif
1436# ifdef PTRACE_O_TRACEVFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001437 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001438# endif
1439# ifdef PTRACE_O_TRACECLONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001440 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001441# endif
1442# ifdef PTRACE_O_TRACEEXEC
Denys Vlasenkof535b542009-01-13 18:30:55 +00001443 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001444# endif
1445# ifdef PTRACE_O_TRACEVFORKDONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001446 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001447# endif
1448# ifdef PTRACE_O_TRACEEXIT
Denys Vlasenkof535b542009-01-13 18:30:55 +00001449 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001450# endif
Denys Vlasenkof535b542009-01-13 18:30:55 +00001451 { 0, NULL },
1452};
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001453# endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001454
Roland McGrathd9f816f2004-09-04 03:39:20 +00001455const struct xlat struct_user_offsets[] = {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001456# if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001457 { PT_PSWMASK, "psw_mask" },
1458 { PT_PSWADDR, "psw_addr" },
1459 { PT_GPR0, "gpr0" },
1460 { PT_GPR1, "gpr1" },
1461 { PT_GPR2, "gpr2" },
1462 { PT_GPR3, "gpr3" },
1463 { PT_GPR4, "gpr4" },
1464 { PT_GPR5, "gpr5" },
1465 { PT_GPR6, "gpr6" },
1466 { PT_GPR7, "gpr7" },
1467 { PT_GPR8, "gpr8" },
1468 { PT_GPR9, "gpr9" },
1469 { PT_GPR10, "gpr10" },
1470 { PT_GPR11, "gpr11" },
1471 { PT_GPR12, "gpr12" },
1472 { PT_GPR13, "gpr13" },
1473 { PT_GPR14, "gpr14" },
1474 { PT_GPR15, "gpr15" },
1475 { PT_ACR0, "acr0" },
1476 { PT_ACR1, "acr1" },
1477 { PT_ACR2, "acr2" },
1478 { PT_ACR3, "acr3" },
1479 { PT_ACR4, "acr4" },
1480 { PT_ACR5, "acr5" },
1481 { PT_ACR6, "acr6" },
1482 { PT_ACR7, "acr7" },
1483 { PT_ACR8, "acr8" },
1484 { PT_ACR9, "acr9" },
1485 { PT_ACR10, "acr10" },
1486 { PT_ACR11, "acr11" },
1487 { PT_ACR12, "acr12" },
1488 { PT_ACR13, "acr13" },
1489 { PT_ACR14, "acr14" },
1490 { PT_ACR15, "acr15" },
1491 { PT_ORIGGPR2, "orig_gpr2" },
1492 { PT_FPC, "fpc" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001493# if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001494 { PT_FPR0_HI, "fpr0.hi" },
1495 { PT_FPR0_LO, "fpr0.lo" },
1496 { PT_FPR1_HI, "fpr1.hi" },
1497 { PT_FPR1_LO, "fpr1.lo" },
1498 { PT_FPR2_HI, "fpr2.hi" },
1499 { PT_FPR2_LO, "fpr2.lo" },
1500 { PT_FPR3_HI, "fpr3.hi" },
1501 { PT_FPR3_LO, "fpr3.lo" },
1502 { PT_FPR4_HI, "fpr4.hi" },
1503 { PT_FPR4_LO, "fpr4.lo" },
1504 { PT_FPR5_HI, "fpr5.hi" },
1505 { PT_FPR5_LO, "fpr5.lo" },
1506 { PT_FPR6_HI, "fpr6.hi" },
1507 { PT_FPR6_LO, "fpr6.lo" },
1508 { PT_FPR7_HI, "fpr7.hi" },
1509 { PT_FPR7_LO, "fpr7.lo" },
1510 { PT_FPR8_HI, "fpr8.hi" },
1511 { PT_FPR8_LO, "fpr8.lo" },
1512 { PT_FPR9_HI, "fpr9.hi" },
1513 { PT_FPR9_LO, "fpr9.lo" },
1514 { PT_FPR10_HI, "fpr10.hi" },
1515 { PT_FPR10_LO, "fpr10.lo" },
1516 { PT_FPR11_HI, "fpr11.hi" },
1517 { PT_FPR11_LO, "fpr11.lo" },
1518 { PT_FPR12_HI, "fpr12.hi" },
1519 { PT_FPR12_LO, "fpr12.lo" },
1520 { PT_FPR13_HI, "fpr13.hi" },
1521 { PT_FPR13_LO, "fpr13.lo" },
1522 { PT_FPR14_HI, "fpr14.hi" },
1523 { PT_FPR14_LO, "fpr14.lo" },
1524 { PT_FPR15_HI, "fpr15.hi" },
1525 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001526# endif
1527# if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001528 { PT_FPR0, "fpr0" },
1529 { PT_FPR1, "fpr1" },
1530 { PT_FPR2, "fpr2" },
1531 { PT_FPR3, "fpr3" },
1532 { PT_FPR4, "fpr4" },
1533 { PT_FPR5, "fpr5" },
1534 { PT_FPR6, "fpr6" },
1535 { PT_FPR7, "fpr7" },
1536 { PT_FPR8, "fpr8" },
1537 { PT_FPR9, "fpr9" },
1538 { PT_FPR10, "fpr10" },
1539 { PT_FPR11, "fpr11" },
1540 { PT_FPR12, "fpr12" },
1541 { PT_FPR13, "fpr13" },
1542 { PT_FPR14, "fpr14" },
1543 { PT_FPR15, "fpr15" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001544# endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001545 { PT_CR_9, "cr9" },
1546 { PT_CR_10, "cr10" },
1547 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001548 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001549# elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001550 /* XXX No support for these offsets yet. */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001551# elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001552 /* XXX No support for these offsets yet. */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001553# elif defined(POWERPC)
1554# ifndef PT_ORIG_R3
1555# define PT_ORIG_R3 34
1556# endif
1557# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001558 { REGSIZE*PT_R0, "r0" },
1559 { REGSIZE*PT_R1, "r1" },
1560 { REGSIZE*PT_R2, "r2" },
1561 { REGSIZE*PT_R3, "r3" },
1562 { REGSIZE*PT_R4, "r4" },
1563 { REGSIZE*PT_R5, "r5" },
1564 { REGSIZE*PT_R6, "r6" },
1565 { REGSIZE*PT_R7, "r7" },
1566 { REGSIZE*PT_R8, "r8" },
1567 { REGSIZE*PT_R9, "r9" },
1568 { REGSIZE*PT_R10, "r10" },
1569 { REGSIZE*PT_R11, "r11" },
1570 { REGSIZE*PT_R12, "r12" },
1571 { REGSIZE*PT_R13, "r13" },
1572 { REGSIZE*PT_R14, "r14" },
1573 { REGSIZE*PT_R15, "r15" },
1574 { REGSIZE*PT_R16, "r16" },
1575 { REGSIZE*PT_R17, "r17" },
1576 { REGSIZE*PT_R18, "r18" },
1577 { REGSIZE*PT_R19, "r19" },
1578 { REGSIZE*PT_R20, "r20" },
1579 { REGSIZE*PT_R21, "r21" },
1580 { REGSIZE*PT_R22, "r22" },
1581 { REGSIZE*PT_R23, "r23" },
1582 { REGSIZE*PT_R24, "r24" },
1583 { REGSIZE*PT_R25, "r25" },
1584 { REGSIZE*PT_R26, "r26" },
1585 { REGSIZE*PT_R27, "r27" },
1586 { REGSIZE*PT_R28, "r28" },
1587 { REGSIZE*PT_R29, "r29" },
1588 { REGSIZE*PT_R30, "r30" },
1589 { REGSIZE*PT_R31, "r31" },
1590 { REGSIZE*PT_NIP, "NIP" },
1591 { REGSIZE*PT_MSR, "MSR" },
1592 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1593 { REGSIZE*PT_CTR, "CTR" },
1594 { REGSIZE*PT_LNK, "LNK" },
1595 { REGSIZE*PT_XER, "XER" },
1596 { REGSIZE*PT_CCR, "CCR" },
1597 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001598# undef REGSIZE
1599# elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001600 { 0, "r0" },
1601 { 1, "r1" },
1602 { 2, "r2" },
1603 { 3, "r3" },
1604 { 4, "r4" },
1605 { 5, "r5" },
1606 { 6, "r6" },
1607 { 7, "r7" },
1608 { 8, "r8" },
1609 { 9, "r9" },
1610 { 10, "r10" },
1611 { 11, "r11" },
1612 { 12, "r12" },
1613 { 13, "r13" },
1614 { 14, "r14" },
1615 { 15, "r15" },
1616 { 16, "r16" },
1617 { 17, "r17" },
1618 { 18, "r18" },
1619 { 19, "r19" },
1620 { 20, "r20" },
1621 { 21, "r21" },
1622 { 22, "r22" },
1623 { 23, "r23" },
1624 { 24, "r24" },
1625 { 25, "r25" },
1626 { 26, "r26" },
1627 { 27, "r27" },
1628 { 28, "r28" },
1629 { 29, "gp" },
1630 { 30, "fp" },
1631 { 31, "zero" },
1632 { 32, "fp0" },
1633 { 33, "fp" },
1634 { 34, "fp2" },
1635 { 35, "fp3" },
1636 { 36, "fp4" },
1637 { 37, "fp5" },
1638 { 38, "fp6" },
1639 { 39, "fp7" },
1640 { 40, "fp8" },
1641 { 41, "fp9" },
1642 { 42, "fp10" },
1643 { 43, "fp11" },
1644 { 44, "fp12" },
1645 { 45, "fp13" },
1646 { 46, "fp14" },
1647 { 47, "fp15" },
1648 { 48, "fp16" },
1649 { 49, "fp17" },
1650 { 50, "fp18" },
1651 { 51, "fp19" },
1652 { 52, "fp20" },
1653 { 53, "fp21" },
1654 { 54, "fp22" },
1655 { 55, "fp23" },
1656 { 56, "fp24" },
1657 { 57, "fp25" },
1658 { 58, "fp26" },
1659 { 59, "fp27" },
1660 { 60, "fp28" },
1661 { 61, "fp29" },
1662 { 62, "fp30" },
1663 { 63, "fp31" },
1664 { 64, "pc" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001665# elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001666 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1667 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1668 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1669 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1670 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1671 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1672 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1673 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1674 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1675 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1676 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1677 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1678 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1679 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1680 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1681 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1682 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1683 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1684 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1685 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1686 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1687 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1688 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1689 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1690 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1691 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1692 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1693 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1694 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1695 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1696 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1697 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1698 /* switch stack: */
1699 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1700 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1701 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1702 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1703 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1704 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1705 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1706 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1707 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1708 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001709 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1710 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001711 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001712 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001713 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1714 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001715 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1716 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1717 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1718 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1719 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1720 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1721 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1722 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1723 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1724 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1725 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1726 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1727 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1728 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1729 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001730# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001731 { PT_AR_CSD, "ar.csd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001732# endif
1733# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001734 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001735# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001736 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001737# elif defined(I386)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001738 { 4*EBX, "4*EBX" },
1739 { 4*ECX, "4*ECX" },
1740 { 4*EDX, "4*EDX" },
1741 { 4*ESI, "4*ESI" },
1742 { 4*EDI, "4*EDI" },
1743 { 4*EBP, "4*EBP" },
1744 { 4*EAX, "4*EAX" },
1745 { 4*DS, "4*DS" },
1746 { 4*ES, "4*ES" },
1747 { 4*FS, "4*FS" },
1748 { 4*GS, "4*GS" },
1749 { 4*ORIG_EAX, "4*ORIG_EAX" },
1750 { 4*EIP, "4*EIP" },
1751 { 4*CS, "4*CS" },
1752 { 4*EFL, "4*EFL" },
1753 { 4*UESP, "4*UESP" },
1754 { 4*SS, "4*SS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001755# elif defined(X86_64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001756 { 8*R15, "8*R15" },
1757 { 8*R14, "8*R14" },
1758 { 8*R13, "8*R13" },
1759 { 8*R12, "8*R12" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001760 { 8*RBP, "8*RBP" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001761 { 8*RBX, "8*RBX" },
1762 { 8*R11, "8*R11" },
1763 { 8*R10, "8*R10" },
1764 { 8*R9, "8*R9" },
1765 { 8*R8, "8*R8" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001766 { 8*RAX, "8*RAX" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001767 { 8*RCX, "8*RCX" },
1768 { 8*RDX, "8*RDX" },
1769 { 8*RSI, "8*RSI" },
1770 { 8*RDI, "8*RDI" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001771 { 8*ORIG_RAX, "8*ORIG_RAX" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001772 { 8*RIP, "8*RIP" },
1773 { 8*CS, "8*CS" },
1774 { 8*EFLAGS, "8*EFL" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001775 { 8*RSP, "8*RSP" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001776 { 8*SS, "8*SS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001777# elif defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001778 { 4*PT_D1, "4*PT_D1" },
1779 { 4*PT_D2, "4*PT_D2" },
1780 { 4*PT_D3, "4*PT_D3" },
1781 { 4*PT_D4, "4*PT_D4" },
1782 { 4*PT_D5, "4*PT_D5" },
1783 { 4*PT_D6, "4*PT_D6" },
1784 { 4*PT_D7, "4*PT_D7" },
1785 { 4*PT_A0, "4*PT_A0" },
1786 { 4*PT_A1, "4*PT_A1" },
1787 { 4*PT_A2, "4*PT_A2" },
1788 { 4*PT_A3, "4*PT_A3" },
1789 { 4*PT_A4, "4*PT_A4" },
1790 { 4*PT_A5, "4*PT_A5" },
1791 { 4*PT_A6, "4*PT_A6" },
1792 { 4*PT_D0, "4*PT_D0" },
1793 { 4*PT_USP, "4*PT_USP" },
1794 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1795 { 4*PT_SR, "4*PT_SR" },
1796 { 4*PT_PC, "4*PT_PC" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001797# elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001798 { 4*REG_REG0, "4*REG_REG0" },
1799 { 4*(REG_REG0+1), "4*REG_REG1" },
1800 { 4*(REG_REG0+2), "4*REG_REG2" },
1801 { 4*(REG_REG0+3), "4*REG_REG3" },
1802 { 4*(REG_REG0+4), "4*REG_REG4" },
1803 { 4*(REG_REG0+5), "4*REG_REG5" },
1804 { 4*(REG_REG0+6), "4*REG_REG6" },
1805 { 4*(REG_REG0+7), "4*REG_REG7" },
1806 { 4*(REG_REG0+8), "4*REG_REG8" },
1807 { 4*(REG_REG0+9), "4*REG_REG9" },
1808 { 4*(REG_REG0+10), "4*REG_REG10" },
1809 { 4*(REG_REG0+11), "4*REG_REG11" },
1810 { 4*(REG_REG0+12), "4*REG_REG12" },
1811 { 4*(REG_REG0+13), "4*REG_REG13" },
1812 { 4*(REG_REG0+14), "4*REG_REG14" },
1813 { 4*REG_REG15, "4*REG_REG15" },
1814 { 4*REG_PC, "4*REG_PC" },
1815 { 4*REG_PR, "4*REG_PR" },
1816 { 4*REG_SR, "4*REG_SR" },
1817 { 4*REG_GBR, "4*REG_GBR" },
1818 { 4*REG_MACH, "4*REG_MACH" },
1819 { 4*REG_MACL, "4*REG_MACL" },
1820 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1821 { 4*REG_FPUL, "4*REG_FPUL" },
1822 { 4*REG_FPREG0, "4*REG_FPREG0" },
1823 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1824 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1825 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1826 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1827 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1828 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1829 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1830 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1831 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1832 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1833 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1834 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1835 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1836 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1837 { 4*REG_FPREG15, "4*REG_FPREG15" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001838# ifdef REG_XDREG0
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001839 { 4*REG_XDREG0, "4*REG_XDREG0" },
1840 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1841 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1842 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1843 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1844 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1845 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1846 { 4*REG_XDREG14, "4*REG_XDREG14" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001847# endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001848 { 4*REG_FPSCR, "4*REG_FPSCR" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001849# elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001850 { 0, "PC(L)" },
1851 { 4, "PC(U)" },
1852 { 8, "SR(L)" },
1853 { 12, "SR(U)" },
1854 { 16, "syscall no.(L)" },
1855 { 20, "syscall_no.(U)" },
1856 { 24, "R0(L)" },
1857 { 28, "R0(U)" },
1858 { 32, "R1(L)" },
1859 { 36, "R1(U)" },
1860 { 40, "R2(L)" },
1861 { 44, "R2(U)" },
1862 { 48, "R3(L)" },
1863 { 52, "R3(U)" },
1864 { 56, "R4(L)" },
1865 { 60, "R4(U)" },
1866 { 64, "R5(L)" },
1867 { 68, "R5(U)" },
1868 { 72, "R6(L)" },
1869 { 76, "R6(U)" },
1870 { 80, "R7(L)" },
1871 { 84, "R7(U)" },
1872 { 88, "R8(L)" },
1873 { 92, "R8(U)" },
1874 { 96, "R9(L)" },
1875 { 100, "R9(U)" },
1876 { 104, "R10(L)" },
1877 { 108, "R10(U)" },
1878 { 112, "R11(L)" },
1879 { 116, "R11(U)" },
1880 { 120, "R12(L)" },
1881 { 124, "R12(U)" },
1882 { 128, "R13(L)" },
1883 { 132, "R13(U)" },
1884 { 136, "R14(L)" },
1885 { 140, "R14(U)" },
1886 { 144, "R15(L)" },
1887 { 148, "R15(U)" },
1888 { 152, "R16(L)" },
1889 { 156, "R16(U)" },
1890 { 160, "R17(L)" },
1891 { 164, "R17(U)" },
1892 { 168, "R18(L)" },
1893 { 172, "R18(U)" },
1894 { 176, "R19(L)" },
1895 { 180, "R19(U)" },
1896 { 184, "R20(L)" },
1897 { 188, "R20(U)" },
1898 { 192, "R21(L)" },
1899 { 196, "R21(U)" },
1900 { 200, "R22(L)" },
1901 { 204, "R22(U)" },
1902 { 208, "R23(L)" },
1903 { 212, "R23(U)" },
1904 { 216, "R24(L)" },
1905 { 220, "R24(U)" },
1906 { 224, "R25(L)" },
1907 { 228, "R25(U)" },
1908 { 232, "R26(L)" },
1909 { 236, "R26(U)" },
1910 { 240, "R27(L)" },
1911 { 244, "R27(U)" },
1912 { 248, "R28(L)" },
1913 { 252, "R28(U)" },
1914 { 256, "R29(L)" },
1915 { 260, "R29(U)" },
1916 { 264, "R30(L)" },
1917 { 268, "R30(U)" },
1918 { 272, "R31(L)" },
1919 { 276, "R31(U)" },
1920 { 280, "R32(L)" },
1921 { 284, "R32(U)" },
1922 { 288, "R33(L)" },
1923 { 292, "R33(U)" },
1924 { 296, "R34(L)" },
1925 { 300, "R34(U)" },
1926 { 304, "R35(L)" },
1927 { 308, "R35(U)" },
1928 { 312, "R36(L)" },
1929 { 316, "R36(U)" },
1930 { 320, "R37(L)" },
1931 { 324, "R37(U)" },
1932 { 328, "R38(L)" },
1933 { 332, "R38(U)" },
1934 { 336, "R39(L)" },
1935 { 340, "R39(U)" },
1936 { 344, "R40(L)" },
1937 { 348, "R40(U)" },
1938 { 352, "R41(L)" },
1939 { 356, "R41(U)" },
1940 { 360, "R42(L)" },
1941 { 364, "R42(U)" },
1942 { 368, "R43(L)" },
1943 { 372, "R43(U)" },
1944 { 376, "R44(L)" },
1945 { 380, "R44(U)" },
1946 { 384, "R45(L)" },
1947 { 388, "R45(U)" },
1948 { 392, "R46(L)" },
1949 { 396, "R46(U)" },
1950 { 400, "R47(L)" },
1951 { 404, "R47(U)" },
1952 { 408, "R48(L)" },
1953 { 412, "R48(U)" },
1954 { 416, "R49(L)" },
1955 { 420, "R49(U)" },
1956 { 424, "R50(L)" },
1957 { 428, "R50(U)" },
1958 { 432, "R51(L)" },
1959 { 436, "R51(U)" },
1960 { 440, "R52(L)" },
1961 { 444, "R52(U)" },
1962 { 448, "R53(L)" },
1963 { 452, "R53(U)" },
1964 { 456, "R54(L)" },
1965 { 460, "R54(U)" },
1966 { 464, "R55(L)" },
1967 { 468, "R55(U)" },
1968 { 472, "R56(L)" },
1969 { 476, "R56(U)" },
1970 { 480, "R57(L)" },
1971 { 484, "R57(U)" },
1972 { 488, "R58(L)" },
1973 { 492, "R58(U)" },
1974 { 496, "R59(L)" },
1975 { 500, "R59(U)" },
1976 { 504, "R60(L)" },
1977 { 508, "R60(U)" },
1978 { 512, "R61(L)" },
1979 { 516, "R61(U)" },
1980 { 520, "R62(L)" },
1981 { 524, "R62(U)" },
1982 { 528, "TR0(L)" },
1983 { 532, "TR0(U)" },
1984 { 536, "TR1(L)" },
1985 { 540, "TR1(U)" },
1986 { 544, "TR2(L)" },
1987 { 548, "TR2(U)" },
1988 { 552, "TR3(L)" },
1989 { 556, "TR3(U)" },
1990 { 560, "TR4(L)" },
1991 { 564, "TR4(U)" },
1992 { 568, "TR5(L)" },
1993 { 572, "TR5(U)" },
1994 { 576, "TR6(L)" },
1995 { 580, "TR6(U)" },
1996 { 584, "TR7(L)" },
1997 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00001998 /* This entry is in case pt_regs contains dregs (depends on
1999 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002000 { uoff(regs), "offsetof(struct user, regs)" },
2001 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002002# elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00002003 { uoff(regs.ARM_r0), "r0" },
2004 { uoff(regs.ARM_r1), "r1" },
2005 { uoff(regs.ARM_r2), "r2" },
2006 { uoff(regs.ARM_r3), "r3" },
2007 { uoff(regs.ARM_r4), "r4" },
2008 { uoff(regs.ARM_r5), "r5" },
2009 { uoff(regs.ARM_r6), "r6" },
2010 { uoff(regs.ARM_r7), "r7" },
2011 { uoff(regs.ARM_r8), "r8" },
2012 { uoff(regs.ARM_r9), "r9" },
2013 { uoff(regs.ARM_r10), "r10" },
2014 { uoff(regs.ARM_fp), "fp" },
2015 { uoff(regs.ARM_ip), "ip" },
2016 { uoff(regs.ARM_sp), "sp" },
2017 { uoff(regs.ARM_lr), "lr" },
2018 { uoff(regs.ARM_pc), "pc" },
2019 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00002020# elif defined(AVR32)
2021 { uoff(regs.sr), "sr" },
2022 { uoff(regs.pc), "pc" },
2023 { uoff(regs.lr), "lr" },
2024 { uoff(regs.sp), "sp" },
2025 { uoff(regs.r12), "r12" },
2026 { uoff(regs.r11), "r11" },
2027 { uoff(regs.r10), "r10" },
2028 { uoff(regs.r9), "r9" },
2029 { uoff(regs.r8), "r8" },
2030 { uoff(regs.r7), "r7" },
2031 { uoff(regs.r6), "r6" },
2032 { uoff(regs.r5), "r5" },
2033 { uoff(regs.r4), "r4" },
2034 { uoff(regs.r3), "r3" },
2035 { uoff(regs.r2), "r2" },
2036 { uoff(regs.r1), "r1" },
2037 { uoff(regs.r0), "r0" },
2038 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002039# elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00002040 { 0, "r0" },
2041 { 1, "r1" },
2042 { 2, "r2" },
2043 { 3, "r3" },
2044 { 4, "r4" },
2045 { 5, "r5" },
2046 { 6, "r6" },
2047 { 7, "r7" },
2048 { 8, "r8" },
2049 { 9, "r9" },
2050 { 10, "r10" },
2051 { 11, "r11" },
2052 { 12, "r12" },
2053 { 13, "r13" },
2054 { 14, "r14" },
2055 { 15, "r15" },
2056 { 16, "r16" },
2057 { 17, "r17" },
2058 { 18, "r18" },
2059 { 19, "r19" },
2060 { 20, "r20" },
2061 { 21, "r21" },
2062 { 22, "r22" },
2063 { 23, "r23" },
2064 { 24, "r24" },
2065 { 25, "r25" },
2066 { 26, "r26" },
2067 { 27, "r27" },
2068 { 28, "r28" },
2069 { 29, "r29" },
2070 { 30, "r30" },
2071 { 31, "r31" },
2072 { 32, "f0" },
2073 { 33, "f1" },
2074 { 34, "f2" },
2075 { 35, "f3" },
2076 { 36, "f4" },
2077 { 37, "f5" },
2078 { 38, "f6" },
2079 { 39, "f7" },
2080 { 40, "f8" },
2081 { 41, "f9" },
2082 { 42, "f10" },
2083 { 43, "f11" },
2084 { 44, "f12" },
2085 { 45, "f13" },
2086 { 46, "f14" },
2087 { 47, "f15" },
2088 { 48, "f16" },
2089 { 49, "f17" },
2090 { 50, "f18" },
2091 { 51, "f19" },
2092 { 52, "f20" },
2093 { 53, "f21" },
2094 { 54, "f22" },
2095 { 55, "f23" },
2096 { 56, "f24" },
2097 { 57, "f25" },
2098 { 58, "f26" },
2099 { 59, "f27" },
2100 { 60, "f28" },
2101 { 61, "f29" },
2102 { 62, "f30" },
2103 { 63, "f31" },
2104 { 64, "pc" },
2105 { 65, "cause" },
2106 { 66, "badvaddr" },
2107 { 67, "mmhi" },
2108 { 68, "mmlo" },
2109 { 69, "fpcsr" },
2110 { 70, "fpeir" },
Chris Metcalfc8c66982009-12-28 10:00:15 -05002111# elif defined(TILE)
2112 { PTREGS_OFFSET_REG(0), "r0" },
2113 { PTREGS_OFFSET_REG(1), "r1" },
2114 { PTREGS_OFFSET_REG(2), "r2" },
2115 { PTREGS_OFFSET_REG(3), "r3" },
2116 { PTREGS_OFFSET_REG(4), "r4" },
2117 { PTREGS_OFFSET_REG(5), "r5" },
2118 { PTREGS_OFFSET_REG(6), "r6" },
2119 { PTREGS_OFFSET_REG(7), "r7" },
2120 { PTREGS_OFFSET_REG(8), "r8" },
2121 { PTREGS_OFFSET_REG(9), "r9" },
2122 { PTREGS_OFFSET_REG(10), "r10" },
2123 { PTREGS_OFFSET_REG(11), "r11" },
2124 { PTREGS_OFFSET_REG(12), "r12" },
2125 { PTREGS_OFFSET_REG(13), "r13" },
2126 { PTREGS_OFFSET_REG(14), "r14" },
2127 { PTREGS_OFFSET_REG(15), "r15" },
2128 { PTREGS_OFFSET_REG(16), "r16" },
2129 { PTREGS_OFFSET_REG(17), "r17" },
2130 { PTREGS_OFFSET_REG(18), "r18" },
2131 { PTREGS_OFFSET_REG(19), "r19" },
2132 { PTREGS_OFFSET_REG(20), "r20" },
2133 { PTREGS_OFFSET_REG(21), "r21" },
2134 { PTREGS_OFFSET_REG(22), "r22" },
2135 { PTREGS_OFFSET_REG(23), "r23" },
2136 { PTREGS_OFFSET_REG(24), "r24" },
2137 { PTREGS_OFFSET_REG(25), "r25" },
2138 { PTREGS_OFFSET_REG(26), "r26" },
2139 { PTREGS_OFFSET_REG(27), "r27" },
2140 { PTREGS_OFFSET_REG(28), "r28" },
2141 { PTREGS_OFFSET_REG(29), "r29" },
2142 { PTREGS_OFFSET_REG(30), "r30" },
2143 { PTREGS_OFFSET_REG(31), "r31" },
2144 { PTREGS_OFFSET_REG(32), "r32" },
2145 { PTREGS_OFFSET_REG(33), "r33" },
2146 { PTREGS_OFFSET_REG(34), "r34" },
2147 { PTREGS_OFFSET_REG(35), "r35" },
2148 { PTREGS_OFFSET_REG(36), "r36" },
2149 { PTREGS_OFFSET_REG(37), "r37" },
2150 { PTREGS_OFFSET_REG(38), "r38" },
2151 { PTREGS_OFFSET_REG(39), "r39" },
2152 { PTREGS_OFFSET_REG(40), "r40" },
2153 { PTREGS_OFFSET_REG(41), "r41" },
2154 { PTREGS_OFFSET_REG(42), "r42" },
2155 { PTREGS_OFFSET_REG(43), "r43" },
2156 { PTREGS_OFFSET_REG(44), "r44" },
2157 { PTREGS_OFFSET_REG(45), "r45" },
2158 { PTREGS_OFFSET_REG(46), "r46" },
2159 { PTREGS_OFFSET_REG(47), "r47" },
2160 { PTREGS_OFFSET_REG(48), "r48" },
2161 { PTREGS_OFFSET_REG(49), "r49" },
2162 { PTREGS_OFFSET_REG(50), "r50" },
2163 { PTREGS_OFFSET_REG(51), "r51" },
2164 { PTREGS_OFFSET_REG(52), "r52" },
2165 { PTREGS_OFFSET_TP, "tp" },
2166 { PTREGS_OFFSET_SP, "sp" },
2167 { PTREGS_OFFSET_LR, "lr" },
2168 { PTREGS_OFFSET_PC, "pc" },
2169 { PTREGS_OFFSET_EX1, "ex1" },
2170 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2171 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2172 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002173# endif
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002174# ifdef CRISV10
2175 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2176 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2177 { 4*PT_R13, "4*PT_R13" },
2178 { 4*PT_R12, "4*PT_R12" },
2179 { 4*PT_R11, "4*PT_R11" },
2180 { 4*PT_R10, "4*PT_R10" },
2181 { 4*PT_R9, "4*PT_R9" },
2182 { 4*PT_R8, "4*PT_R8" },
2183 { 4*PT_R7, "4*PT_R7" },
2184 { 4*PT_R6, "4*PT_R6" },
2185 { 4*PT_R5, "4*PT_R5" },
2186 { 4*PT_R4, "4*PT_R4" },
2187 { 4*PT_R3, "4*PT_R3" },
2188 { 4*PT_R2, "4*PT_R2" },
2189 { 4*PT_R1, "4*PT_R1" },
2190 { 4*PT_R0, "4*PT_R0" },
2191 { 4*PT_MOF, "4*PT_MOF" },
2192 { 4*PT_DCCR, "4*PT_DCCR" },
2193 { 4*PT_SRP, "4*PT_SRP" },
2194 { 4*PT_IRP, "4*PT_IRP" },
2195 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2196 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2197 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2198 { 4*PT_USP, "4*PT_USP" },
2199# endif
2200# ifdef CRISV32
2201 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2202 { 4*PT_R0, "4*PT_R0" },
2203 { 4*PT_R1, "4*PT_R1" },
2204 { 4*PT_R2, "4*PT_R2" },
2205 { 4*PT_R3, "4*PT_R3" },
2206 { 4*PT_R4, "4*PT_R4" },
2207 { 4*PT_R5, "4*PT_R5" },
2208 { 4*PT_R6, "4*PT_R6" },
2209 { 4*PT_R7, "4*PT_R7" },
2210 { 4*PT_R8, "4*PT_R8" },
2211 { 4*PT_R9, "4*PT_R9" },
2212 { 4*PT_R10, "4*PT_R10" },
2213 { 4*PT_R11, "4*PT_R11" },
2214 { 4*PT_R12, "4*PT_R12" },
2215 { 4*PT_R13, "4*PT_R13" },
2216 { 4*PT_ACR, "4*PT_ACR" },
2217 { 4*PT_SRS, "4*PT_SRS" },
2218 { 4*PT_MOF, "4*PT_MOF" },
2219 { 4*PT_SPC, "4*PT_SPC" },
2220 { 4*PT_CCS, "4*PT_CCS" },
2221 { 4*PT_SRP, "4*PT_SRP" },
2222 { 4*PT_ERP, "4*PT_ERP" },
2223 { 4*PT_EXS, "4*PT_EXS" },
2224 { 4*PT_EDA, "4*PT_EDA" },
2225 { 4*PT_USP, "4*PT_USP" },
2226 { 4*PT_PPC, "4*PT_PPC" },
2227 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2228 { 4*PT_BP+4, "4*PT_BP+4" },
2229 { 4*PT_BP+8, "4*PT_BP+8" },
2230 { 4*PT_BP+12, "4*PT_BP+12" },
2231 { 4*PT_BP+16, "4*PT_BP+16" },
2232 { 4*PT_BP+20, "4*PT_BP+20" },
2233 { 4*PT_BP+24, "4*PT_BP+24" },
2234 { 4*PT_BP+28, "4*PT_BP+28" },
2235 { 4*PT_BP+32, "4*PT_BP+32" },
2236 { 4*PT_BP+36, "4*PT_BP+36" },
2237 { 4*PT_BP+40, "4*PT_BP+40" },
2238 { 4*PT_BP+44, "4*PT_BP+44" },
2239 { 4*PT_BP+48, "4*PT_BP+48" },
2240 { 4*PT_BP+52, "4*PT_BP+52" },
2241 { 4*PT_BP+56, "4*PT_BP+56" },
2242# endif
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002243# ifdef MICROBLAZE
2244 { PT_GPR(0), "r0" },
2245 { PT_GPR(1), "r1" },
2246 { PT_GPR(2), "r2" },
2247 { PT_GPR(3), "r3" },
2248 { PT_GPR(4), "r4" },
2249 { PT_GPR(5), "r5" },
2250 { PT_GPR(6), "r6" },
2251 { PT_GPR(7), "r7" },
2252 { PT_GPR(8), "r8" },
2253 { PT_GPR(9), "r9" },
2254 { PT_GPR(10), "r10" },
2255 { PT_GPR(11), "r11" },
2256 { PT_GPR(12), "r12" },
2257 { PT_GPR(13), "r13" },
2258 { PT_GPR(14), "r14" },
2259 { PT_GPR(15), "r15" },
2260 { PT_GPR(16), "r16" },
2261 { PT_GPR(17), "r17" },
2262 { PT_GPR(18), "r18" },
2263 { PT_GPR(19), "r19" },
2264 { PT_GPR(20), "r20" },
2265 { PT_GPR(21), "r21" },
2266 { PT_GPR(22), "r22" },
2267 { PT_GPR(23), "r23" },
2268 { PT_GPR(24), "r24" },
2269 { PT_GPR(25), "r25" },
2270 { PT_GPR(26), "r26" },
2271 { PT_GPR(27), "r27" },
2272 { PT_GPR(28), "r28" },
2273 { PT_GPR(29), "r29" },
2274 { PT_GPR(30), "r30" },
2275 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002276 { PT_PC, "rpc", },
2277 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002278 { PT_EAR, "rear", },
2279 { PT_ESR, "resr", },
2280 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002281 { PT_KERNEL_MODE, "kernel_mode", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002282# endif
Roland McGrath542c2c62008-05-20 01:11:56 +00002283
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002284# if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \
2285 && !defined(ALPHA) && !defined(IA64) \
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002286 && !defined(CRISV10) && !defined(CRISV32) && !defined(MICROBLAZE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05002287# if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(AVR32) && !defined(BFIN) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002288 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002289# endif
2290# if defined(I386) || defined(X86_64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002291 { uoff(i387), "offsetof(struct user, i387)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002292# endif
2293# if defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002294 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002295# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002296 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2297 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2298 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002299# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002300 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002301# endif
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00002302# if defined(AVR32) || defined(SH64)
Roland McGrathe1e584b2003-06-02 19:18:58 +00002303 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002304# endif
2305# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002306 { uoff(start_stack), "offsetof(struct user, start_stack)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002307# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002308 { uoff(signal), "offsetof(struct user, signal)" },
Chris Metcalfc8c66982009-12-28 10:00:15 -05002309# if !defined(AVR32) && !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SH) && !defined(SH64) && !defined(SPARC64) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002310 { uoff(reserved), "offsetof(struct user, reserved)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002311# endif
2312# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002313 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002314# endif
Chris Metcalfc8c66982009-12-28 10:00:15 -05002315# if !defined(ARM) && !defined(AVR32) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) && !defined(BFIN) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002316 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002317# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002318 { uoff(magic), "offsetof(struct user, magic)" },
2319 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002320# if defined(I386) || defined(X86_64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002321 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002322# endif
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002323# endif /* !defined(many arches) */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002324
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002325# ifndef HPPA
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002326 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002327# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002328 { 0, NULL },
2329};
2330
2331int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002332sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002333{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002334 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002335 long addr;
2336
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002337 if (entering(tcp)) {
Roland McGrathbf621d42003-01-14 09:46:21 +00002338 printxval(ptrace_cmds, tcp->u_arg[0],
Roland McGrathbf621d42003-01-14 09:46:21 +00002339 "PTRACE_???"
Roland McGrathbf621d42003-01-14 09:46:21 +00002340 );
2341 tprintf(", %lu, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002342 addr = tcp->u_arg[2];
2343 if (tcp->u_arg[0] == PTRACE_PEEKUSER
2344 || tcp->u_arg[0] == PTRACE_POKEUSER) {
2345 for (x = struct_user_offsets; x->str; x++) {
2346 if (x->val >= addr)
2347 break;
2348 }
2349 if (!x->str)
2350 tprintf("%#lx, ", addr);
2351 else if (x->val > addr && x != struct_user_offsets) {
2352 x--;
2353 tprintf("%s + %ld, ", x->str, addr - x->val);
2354 }
2355 else
2356 tprintf("%s, ", x->str);
2357 }
2358 else
2359 tprintf("%#lx, ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002360 switch (tcp->u_arg[0]) {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002361# ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002362 case PTRACE_PEEKDATA:
2363 case PTRACE_PEEKTEXT:
2364 case PTRACE_PEEKUSER:
2365 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002366# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002367 case PTRACE_CONT:
2368 case PTRACE_SINGLESTEP:
2369 case PTRACE_SYSCALL:
2370 case PTRACE_DETACH:
2371 printsignal(tcp->u_arg[3]);
2372 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002373# ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002374 case PTRACE_SETOPTIONS:
2375 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2376 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002377# endif
2378# ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002379 case PTRACE_SETSIGINFO: {
2380 siginfo_t si;
2381 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002382 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002383 else if (syserror(tcp))
2384 tprintf("%#lx", tcp->u_arg[3]);
2385 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002386 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002387 else
2388 printsiginfo(&si, verbose(tcp));
2389 break;
2390 }
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002391# endif
2392# ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002393 case PTRACE_GETSIGINFO:
2394 /* Don't print anything, do it at syscall return. */
2395 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002396# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002397 default:
2398 tprintf("%#lx", tcp->u_arg[3]);
2399 break;
2400 }
2401 } else {
2402 switch (tcp->u_arg[0]) {
2403 case PTRACE_PEEKDATA:
2404 case PTRACE_PEEKTEXT:
2405 case PTRACE_PEEKUSER:
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002406# ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002407 return RVAL_HEX;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002408# else
Roland McGratheb285352003-01-14 09:59:00 +00002409 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002410 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002411# endif
2412# ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002413 case PTRACE_GETSIGINFO: {
2414 siginfo_t si;
2415 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002416 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002417 else if (syserror(tcp))
2418 tprintf("%#lx", tcp->u_arg[3]);
2419 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002420 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002421 else
2422 printsiginfo(&si, verbose(tcp));
2423 break;
2424 }
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002425# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002426 }
2427 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002428 return 0;
2429}
2430
Roland McGrath51942a92007-07-05 18:59:11 +00002431# ifndef FUTEX_CMP_REQUEUE
2432# define FUTEX_CMP_REQUEUE 4
2433# endif
2434# ifndef FUTEX_WAKE_OP
2435# define FUTEX_WAKE_OP 5
2436# endif
2437# ifndef FUTEX_LOCK_PI
2438# define FUTEX_LOCK_PI 6
2439# define FUTEX_UNLOCK_PI 7
2440# define FUTEX_TRYLOCK_PI 8
2441# endif
Roland McGrath1aeaf742008-07-18 01:27:39 +00002442# ifndef FUTEX_WAIT_BITSET
2443# define FUTEX_WAIT_BITSET 9
2444# endif
2445# ifndef FUTEX_WAKE_BITSET
2446# define FUTEX_WAKE_BITSET 10
Roland McGrath51942a92007-07-05 18:59:11 +00002447# endif
Andreas Schwab85f58322009-08-12 09:54:42 +02002448# ifndef FUTEX_WAIT_REQUEUE_PI
2449# define FUTEX_WAIT_REQUEUE_PI 11
2450# endif
2451# ifndef FUTEX_CMP_REQUEUE_PI
2452# define FUTEX_CMP_REQUEUE_PI 12
2453# endif
Roland McGrath51942a92007-07-05 18:59:11 +00002454# ifndef FUTEX_PRIVATE_FLAG
2455# define FUTEX_PRIVATE_FLAG 128
2456# endif
Andreas Schwab85f58322009-08-12 09:54:42 +02002457# ifndef FUTEX_CLOCK_REALTIME
2458# define FUTEX_CLOCK_REALTIME 256
2459# endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002460static const struct xlat futexops[] = {
Roland McGrath51942a92007-07-05 18:59:11 +00002461 { FUTEX_WAIT, "FUTEX_WAIT" },
2462 { FUTEX_WAKE, "FUTEX_WAKE" },
2463 { FUTEX_FD, "FUTEX_FD" },
2464 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2465 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2466 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2467 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2468 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2469 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002470 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2471 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002472 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2473 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
Roland McGrath51942a92007-07-05 18:59:11 +00002474 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2475 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2476 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2477 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2478 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2479 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2480 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2481 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2482 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002483 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2484 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002485 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2486 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2487 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2488 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2489 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2490 { 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 +00002491 { 0, NULL }
2492};
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002493# ifndef FUTEX_OP_SET
2494# define FUTEX_OP_SET 0
2495# define FUTEX_OP_ADD 1
2496# define FUTEX_OP_OR 2
2497# define FUTEX_OP_ANDN 3
2498# define FUTEX_OP_XOR 4
2499# define FUTEX_OP_CMP_EQ 0
2500# define FUTEX_OP_CMP_NE 1
2501# define FUTEX_OP_CMP_LT 2
2502# define FUTEX_OP_CMP_LE 3
2503# define FUTEX_OP_CMP_GT 4
2504# define FUTEX_OP_CMP_GE 5
2505# endif
Roland McGrath51942a92007-07-05 18:59:11 +00002506static const struct xlat futexwakeops[] = {
2507 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2508 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2509 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2510 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2511 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2512 { 0, NULL }
2513};
2514static const struct xlat futexwakecmps[] = {
2515 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2516 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2517 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2518 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2519 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2520 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2521 { 0, NULL }
Roland McGrath5a223472002-12-15 23:58:26 +00002522};
2523
2524int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002525sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002526{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002527 if (entering(tcp)) {
2528 long int cmd = tcp->u_arg[1] & 127;
2529 tprintf("%p, ", (void *) tcp->u_arg[0]);
2530 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2531 tprintf(", %ld", tcp->u_arg[2]);
2532 if (cmd == FUTEX_WAKE_BITSET)
2533 tprintf(", %lx", tcp->u_arg[5]);
2534 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002535 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002536 printtv(tcp, tcp->u_arg[3]);
2537 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002538 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002539 printtv(tcp, tcp->u_arg[3]);
2540 tprintf(", %lx", tcp->u_arg[5]);
2541 } else if (cmd == FUTEX_REQUEUE)
2542 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002543 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002544 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2545 else if (cmd == FUTEX_WAKE_OP) {
2546 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2547 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002548 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002549 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2550 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2551 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002552 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002553 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2554 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002555 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002556 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002557 printtv(tcp, tcp->u_arg[3]);
2558 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002559 }
Roland McGrath51942a92007-07-05 18:59:11 +00002560 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002561 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002562}
2563
2564static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002565print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002566{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002567 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002568 unsigned long w, min_len;
2569
2570 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2571 min_len = len - max_strlen * sizeof(w);
2572 else
2573 min_len = 0;
2574 for (; len >= sizeof(w) && len > min_len;
2575 len -= sizeof(w), list += sizeof(w)) {
2576 if (umove(tcp, list, &w) < 0)
2577 break;
2578 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002579 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002580 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002581 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002582 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002583 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002584 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002585 if (len) {
2586 if (first)
2587 tprintf("%#lx", list);
2588 else
2589 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2590 "???" : "..."));
2591 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002592 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002593 }
Roland McGrath5a223472002-12-15 23:58:26 +00002594}
2595
2596int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002597sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002598{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002599 if (entering(tcp)) {
2600 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2601 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2602 }
2603 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002604}
2605
2606int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002607sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002608{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002609 if (entering(tcp)) {
2610 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2611 } else {
2612 if (tcp->u_rval == -1)
2613 tprintf("%#lx", tcp->u_arg[2]);
2614 else
2615 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2616 }
2617 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002618}
Roland McGrath279d3782004-03-01 20:27:37 +00002619
Dmitry V. Levin1b0bae22012-03-11 22:32:26 +00002620int
2621sys_get_robust_list(struct tcb *tcp)
2622{
2623 if (entering(tcp)) {
2624 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2625 } else {
2626 void *addr;
2627 size_t len;
2628
2629 if (syserror(tcp) ||
2630 !tcp->u_arg[1] ||
2631 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2632 tprintf("%#lx, ", tcp->u_arg[1]);
2633 } else {
2634 tprintf("[%p], ", addr);
2635 }
2636
2637 if (syserror(tcp) ||
2638 !tcp->u_arg[2] ||
2639 umove(tcp, tcp->u_arg[2], &len) < 0) {
2640 tprintf("%#lx", tcp->u_arg[2]);
2641 } else {
2642 tprintf("[%lu]", (unsigned long) len);
2643 }
2644 }
2645 return 0;
2646}
2647
Roland McGrathd9f816f2004-09-04 03:39:20 +00002648static const struct xlat schedulers[] = {
Roland McGrath279d3782004-03-01 20:27:37 +00002649 { SCHED_OTHER, "SCHED_OTHER" },
2650 { SCHED_RR, "SCHED_RR" },
2651 { SCHED_FIFO, "SCHED_FIFO" },
2652 { 0, NULL }
2653};
2654
2655int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002656sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002657{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002658 if (entering(tcp)) {
2659 tprintf("%d", (int) tcp->u_arg[0]);
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002660 } else if (!syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002661 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002662 if (tcp->auxstr != NULL)
2663 return RVAL_STR;
2664 }
2665 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002666}
2667
2668int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002669sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002670{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002671 if (entering(tcp)) {
2672 struct sched_param p;
2673 tprintf("%d, ", (int) tcp->u_arg[0]);
2674 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2675 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2676 tprintf(", %#lx", tcp->u_arg[2]);
2677 else
2678 tprintf(", { %d }", p.__sched_priority);
2679 }
2680 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002681}
2682
2683int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002684sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002685{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002686 if (entering(tcp)) {
2687 tprintf("%d, ", (int) tcp->u_arg[0]);
2688 } else {
2689 struct sched_param p;
2690 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2691 tprintf("%#lx", tcp->u_arg[1]);
2692 else
2693 tprintf("{ %d }", p.__sched_priority);
2694 }
2695 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002696}
2697
2698int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002699sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002700{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002701 if (entering(tcp)) {
2702 struct sched_param p;
2703 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2704 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2705 else
2706 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2707 }
2708 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002709}
2710
2711int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002712sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002713{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002714 if (entering(tcp)) {
2715 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2716 }
2717 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002718}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002719
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002720# ifdef X86_64
2721# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002722
2723static const struct xlat archvals[] = {
2724 { ARCH_SET_GS, "ARCH_SET_GS" },
2725 { ARCH_SET_FS, "ARCH_SET_FS" },
2726 { ARCH_GET_FS, "ARCH_GET_FS" },
2727 { ARCH_GET_GS, "ARCH_GET_GS" },
2728 { 0, NULL },
2729};
2730
2731int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002732sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002733{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002734 if (entering(tcp)) {
2735 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2736 if (tcp->u_arg[0] == ARCH_SET_GS
2737 || tcp->u_arg[0] == ARCH_SET_FS
2738 ) {
2739 tprintf(", %#lx", tcp->u_arg[1]);
2740 }
2741 } else {
2742 if (tcp->u_arg[0] == ARCH_GET_GS
2743 || tcp->u_arg[0] == ARCH_GET_FS
2744 ) {
2745 long int v;
2746 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2747 tprintf(", [%#lx]", v);
2748 else
2749 tprintf(", %#lx", tcp->u_arg[1]);
2750 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002751 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002752 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002753}
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002754# endif /* X86_64 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002755
Roland McGrathdb8319f2007-08-02 01:37:55 +00002756int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002757sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002758{
2759 if (exiting(tcp)) {
2760 unsigned u;
2761 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002762 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002763 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2764 tprintf("%#lx, ", tcp->u_arg[0]);
2765 else
2766 tprintf("[%u], ", u);
2767 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002768 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002769 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2770 tprintf("%#lx, ", tcp->u_arg[1]);
2771 else
2772 tprintf("[%u], ", u);
2773 tprintf("%#lx", tcp->u_arg[2]);
2774 }
2775 return 0;
2776}
2777
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002778int
2779sys_process_vm_readv(struct tcb *tcp)
2780{
2781 if (entering(tcp)) {
2782 /* arg 1: pid */
2783 tprintf("%ld, ", tcp->u_arg[0]);
2784 } else {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002785 /* arg 2: local iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002786 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002787 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002788 } else {
2789 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2790 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002791 /* arg 3: local iovcnt */
2792 tprintf(", %lu, ", tcp->u_arg[2]);
2793 /* arg 4: remote iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002794 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002795 tprintf("%#lx", tcp->u_arg[3]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002796 } else {
2797 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2798 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002799 /* arg 5: remote iovcnt */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002800 /* arg 6: flags */
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002801 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002802 }
2803 return 0;
2804}
Dmitry V. Levin03952102012-03-10 14:14:49 +00002805
2806int
2807sys_process_vm_writev(struct tcb *tcp)
2808{
2809 if (entering(tcp)) {
2810 /* arg 1: pid */
2811 tprintf("%ld, ", tcp->u_arg[0]);
2812 /* arg 2: local iov */
2813 if (syserror(tcp))
2814 tprintf("%#lx", tcp->u_arg[1]);
2815 else
2816 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2817 /* arg 3: local iovcnt */
2818 tprintf(", %lu, ", tcp->u_arg[2]);
2819 /* arg 4: remote iov */
2820 if (syserror(tcp))
2821 tprintf("%#lx", tcp->u_arg[3]);
2822 else
2823 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2824 /* arg 5: remote iovcnt */
2825 /* arg 6: flags */
2826 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
2827 }
2828 return 0;
2829}