blob: 41179cd1ccb009e95560c8730c2398750ee774b8 [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>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000044#include <sys/wait.h>
45#include <sys/resource.h>
46#include <sys/utsname.h>
47#include <sys/user.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000048
Wichert Akkerman36915a11999-07-13 15:45:02 +000049#ifdef HAVE_SYS_REG_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000050# include <sys/reg.h>
Denys Vlasenko84703742012-02-25 02:38:52 +010051# ifndef PTRACE_PEEKUSR
52# define PTRACE_PEEKUSR PTRACE_PEEKUSER
53# endif
54# ifndef PTRACE_POKEUSR
55# define PTRACE_POKEUSR PTRACE_POKEUSER
56# endif
Wichert Akkerman15dea971999-10-06 13:06:34 +000057#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000058
Roland McGrath5bd7cf82003-01-24 04:31:18 +000059#ifdef HAVE_LINUX_PTRACE_H
Denys Vlasenko84703742012-02-25 02:38:52 +010060# undef PTRACE_SYSCALL
Roland McGrathfb1bc072004-03-01 21:29:24 +000061# ifdef HAVE_STRUCT_IA64_FPREG
62# define ia64_fpreg XXX_ia64_fpreg
63# endif
64# ifdef HAVE_STRUCT_PT_ALL_USER_REGS
65# define pt_all_user_regs XXX_pt_all_user_regs
66# endif
Denys Vlasenko84703742012-02-25 02:38:52 +010067# include <linux/ptrace.h>
Roland McGrathfb1bc072004-03-01 21:29:24 +000068# undef ia64_fpreg
69# undef pt_all_user_regs
Roland McGrath5bd7cf82003-01-24 04:31:18 +000070#endif
71
Denys Vlasenko84703742012-02-25 02:38:52 +010072#if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +000073# define r_pc r_tpc
74# undef PTRACE_GETREGS
75# define PTRACE_GETREGS PTRACE_GETREGS64
76# undef PTRACE_SETREGS
77# define PTRACE_SETREGS PTRACE_SETREGS64
Denys Vlasenko84703742012-02-25 02:38:52 +010078#endif
Roland McGrath6d1a65c2004-07-12 07:44:08 +000079
Roland McGrath5a223472002-12-15 23:58:26 +000080#ifdef HAVE_LINUX_FUTEX_H
Dmitry V. Levine5e60852009-12-31 22:50:49 +000081# include <linux/futex.h>
Roland McGrath5a223472002-12-15 23:58:26 +000082#endif
Denys Vlasenko84703742012-02-25 02:38:52 +010083#ifndef FUTEX_WAIT
84# define FUTEX_WAIT 0
85#endif
86#ifndef FUTEX_WAKE
87# define FUTEX_WAKE 1
88#endif
89#ifndef FUTEX_FD
90# define FUTEX_FD 2
91#endif
92#ifndef FUTEX_REQUEUE
93# define FUTEX_REQUEUE 3
94#endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000095
Roland McGrath279d3782004-03-01 20:27:37 +000096#include <sched.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000097#include <asm/posix_types.h>
98#undef GETGROUPS_T
99#define GETGROUPS_T __kernel_gid_t
Roland McGrath83bd47a2003-11-13 22:32:26 +0000100#undef GETGROUPS32_T
101#define GETGROUPS32_T __kernel_gid32_t
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000102
Denys Vlasenko84703742012-02-25 02:38:52 +0100103#if defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000104# include <asm/ptrace_offsets.h>
105# include <asm/rse.h>
106#endif
107
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000108#ifdef HAVE_PRCTL
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000109# include <sys/prctl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000110
Roland McGrathd9f816f2004-09-04 03:39:20 +0000111static const struct xlat prctl_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000112#ifdef PR_MAXPROCS
113 { PR_MAXPROCS, "PR_MAXPROCS" },
114#endif
115#ifdef PR_ISBLOCKED
116 { PR_ISBLOCKED, "PR_ISBLOCKED" },
117#endif
118#ifdef PR_SETSTACKSIZE
119 { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" },
120#endif
121#ifdef PR_GETSTACKSIZE
122 { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" },
123#endif
124#ifdef PR_MAXPPROCS
125 { PR_MAXPPROCS, "PR_MAXPPROCS" },
126#endif
127#ifdef PR_UNBLKONEXEC
128 { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" },
129#endif
130#ifdef PR_ATOMICSIM
131 { PR_ATOMICSIM, "PR_ATOMICSIM" },
132#endif
133#ifdef PR_SETEXITSIG
134 { PR_SETEXITSIG, "PR_SETEXITSIG" },
135#endif
136#ifdef PR_RESIDENT
137 { PR_RESIDENT, "PR_RESIDENT" },
138#endif
139#ifdef PR_ATTACHADDR
140 { PR_ATTACHADDR, "PR_ATTACHADDR" },
141#endif
142#ifdef PR_DETACHADDR
143 { PR_DETACHADDR, "PR_DETACHADDR" },
144#endif
145#ifdef PR_TERMCHILD
146 { PR_TERMCHILD, "PR_TERMCHILD" },
147#endif
148#ifdef PR_GETSHMASK
149 { PR_GETSHMASK, "PR_GETSHMASK" },
150#endif
151#ifdef PR_GETNSHARE
152 { PR_GETNSHARE, "PR_GETNSHARE" },
153#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +0000154#ifdef PR_COREPID
155 { PR_COREPID, "PR_COREPID" },
156#endif
157#ifdef PR_ATTACHADDRPERM
158 { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" },
159#endif
160#ifdef PR_PTHREADEXIT
161 { PR_PTHREADEXIT, "PR_PTHREADEXIT" },
162#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000163#ifdef PR_SET_PDEATHSIG
164 { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
165#endif
166#ifdef PR_GET_PDEATHSIG
167 { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
168#endif
Dmitry V. Levinf02cf212008-09-03 00:54:40 +0000169#ifdef PR_GET_DUMPABLE
170 { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" },
171#endif
172#ifdef PR_SET_DUMPABLE
173 { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" },
174#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000175#ifdef PR_GET_UNALIGN
176 { PR_GET_UNALIGN, "PR_GET_UNALIGN" },
177#endif
178#ifdef PR_SET_UNALIGN
179 { PR_SET_UNALIGN, "PR_SET_UNALIGN" },
180#endif
181#ifdef PR_GET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000182 { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000183#endif
184#ifdef PR_SET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000185 { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000186#endif
Roland McGrathe5039fb2007-11-03 23:58:07 +0000187#ifdef PR_GET_FPEMU
188 { PR_GET_FPEMU, "PR_GET_FPEMU" },
189#endif
190#ifdef PR_SET_FPEMU
191 { PR_SET_FPEMU, "PR_SET_FPEMU" },
192#endif
193#ifdef PR_GET_FPEXC
194 { PR_GET_FPEXC, "PR_GET_FPEXC" },
195#endif
196#ifdef PR_SET_FPEXC
197 { PR_SET_FPEXC, "PR_SET_FPEXC" },
198#endif
199#ifdef PR_GET_TIMING
200 { PR_GET_TIMING, "PR_GET_TIMING" },
201#endif
202#ifdef PR_SET_TIMING
203 { PR_SET_TIMING, "PR_SET_TIMING" },
204#endif
205#ifdef PR_SET_NAME
206 { PR_SET_NAME, "PR_SET_NAME" },
207#endif
208#ifdef PR_GET_NAME
209 { PR_GET_NAME, "PR_GET_NAME" },
210#endif
211#ifdef PR_GET_ENDIAN
212 { PR_GET_ENDIAN, "PR_GET_ENDIAN" },
213#endif
214#ifdef PR_SET_ENDIAN
215 { PR_SET_ENDIAN, "PR_SET_ENDIAN" },
216#endif
217#ifdef PR_GET_SECCOMP
218 { PR_GET_SECCOMP, "PR_GET_SECCOMP" },
219#endif
220#ifdef PR_SET_SECCOMP
221 { PR_SET_SECCOMP, "PR_SET_SECCOMP" },
222#endif
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000223#ifdef PR_GET_TSC
224 { PR_GET_TSC, "PR_GET_TSC" },
225#endif
226#ifdef PR_SET_TSC
227 { PR_SET_TSC, "PR_SET_TSC" },
228#endif
229#ifdef PR_GET_SECUREBITS
230 { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" },
231#endif
232#ifdef PR_SET_SECUREBITS
233 { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" },
234#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000235 { 0, NULL },
236};
237
Roland McGratha4d48532005-06-08 20:45:28 +0000238static const char *
Denys Vlasenko12014262011-05-30 14:00:14 +0200239unalignctl_string(unsigned int ctl)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000240{
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100241 static char buf[sizeof(int)*2 + 2];
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000242
243 switch (ctl) {
244#ifdef PR_UNALIGN_NOPRINT
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100245 case PR_UNALIGN_NOPRINT:
246 return "NOPRINT";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000247#endif
248#ifdef PR_UNALIGN_SIGBUS
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100249 case PR_UNALIGN_SIGBUS:
250 return "SIGBUS";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000251#endif
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100252 default:
253 break;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000254 }
255 sprintf(buf, "%x", ctl);
256 return buf;
257}
258
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259int
Denys Vlasenko12014262011-05-30 14:00:14 +0200260sys_prctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000261{
262 int i;
263
264 if (entering(tcp)) {
265 printxval(prctl_options, tcp->u_arg[0], "PR_???");
266 switch (tcp->u_arg[0]) {
267#ifdef PR_GETNSHARE
268 case PR_GETNSHARE:
269 break;
270#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000271#ifdef PR_SET_PDEATHSIG
272 case PR_SET_PDEATHSIG:
273 tprintf(", %lu", tcp->u_arg[1]);
274 break;
275#endif
276#ifdef PR_GET_PDEATHSIG
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000277 case PR_GET_PDEATHSIG:
278 break;
279#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000280#ifdef PR_SET_DUMPABLE
281 case PR_SET_DUMPABLE:
282 tprintf(", %lu", tcp->u_arg[1]);
283 break;
284#endif
285#ifdef PR_GET_DUMPABLE
286 case PR_GET_DUMPABLE:
287 break;
288#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000289#ifdef PR_SET_UNALIGN
290 case PR_SET_UNALIGN:
291 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
292 break;
293#endif
294#ifdef PR_GET_UNALIGN
295 case PR_GET_UNALIGN:
296 tprintf(", %#lx", tcp->u_arg[1]);
297 break;
298#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000299#ifdef PR_SET_KEEPCAPS
300 case PR_SET_KEEPCAPS:
301 tprintf(", %lu", tcp->u_arg[1]);
302 break;
303#endif
304#ifdef PR_GET_KEEPCAPS
305 case PR_GET_KEEPCAPS:
306 break;
307#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000308 default:
309 for (i = 1; i < tcp->u_nargs; i++)
310 tprintf(", %#lx", tcp->u_arg[i]);
311 break;
312 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000313 } else {
314 switch (tcp->u_arg[0]) {
315#ifdef PR_GET_PDEATHSIG
316 case PR_GET_PDEATHSIG:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000317 if (umove(tcp, tcp->u_arg[1], &i) < 0)
318 tprintf(", %#lx", tcp->u_arg[1]);
319 else
320 tprintf(", {%u}", i);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000321 break;
322#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000323#ifdef PR_GET_DUMPABLE
324 case PR_GET_DUMPABLE:
325 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000326#endif
327#ifdef PR_GET_UNALIGN
328 case PR_GET_UNALIGN:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000329 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
330 break;
331 tcp->auxstr = unalignctl_string(i);
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000332 return RVAL_STR;
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000333#endif
334#ifdef PR_GET_KEEPCAPS
335 case PR_GET_KEEPCAPS:
336 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000337#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000338 default:
339 break;
340 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000341 }
342 return 0;
343}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000344#endif /* HAVE_PRCTL */
345
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000346int
Denys Vlasenko12014262011-05-30 14:00:14 +0200347sys_sethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000348{
349 if (entering(tcp)) {
350 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
351 tprintf(", %lu", tcp->u_arg[1]);
352 }
353 return 0;
354}
355
Denys Vlasenko84703742012-02-25 02:38:52 +0100356#if defined(ALPHA)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000357int
Denys Vlasenko12014262011-05-30 14:00:14 +0200358sys_gethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000359{
360 if (exiting(tcp)) {
361 if (syserror(tcp))
362 tprintf("%#lx", tcp->u_arg[0]);
363 else
364 printpath(tcp, tcp->u_arg[0]);
365 tprintf(", %lu", tcp->u_arg[1]);
366 }
367 return 0;
368}
Denys Vlasenko84703742012-02-25 02:38:52 +0100369#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000370
371int
Denys Vlasenko12014262011-05-30 14:00:14 +0200372sys_setdomainname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000373{
374 if (entering(tcp)) {
375 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
376 tprintf(", %lu", tcp->u_arg[1]);
377 }
378 return 0;
379}
380
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000381int
Denys Vlasenko12014262011-05-30 14:00:14 +0200382sys_exit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000383{
384 if (exiting(tcp)) {
385 fprintf(stderr, "_exit returned!\n");
386 return -1;
387 }
388 /* special case: we stop tracing this process, finish line now */
389 tprintf("%ld) ", tcp->u_arg[0]);
Denys Vlasenko102ec492011-08-25 01:27:59 +0200390 tabto();
Denys Vlasenko000b6012012-01-28 01:25:03 +0100391 tprints("= ?\n");
Denys Vlasenko7de265d2012-03-13 11:44:31 +0100392 line_ended();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000393 return 0;
394}
395
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000396/* defines copied from linux/sched.h since we can't include that
397 * ourselves (it conflicts with *lots* of libc includes)
398 */
399#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
400#define CLONE_VM 0x00000100 /* set if VM shared between processes */
401#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
402#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
403#define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
Roland McGrath909875b2002-12-22 03:34:36 +0000404#define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000405#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
406#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
407#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
Roland McGrath909875b2002-12-22 03:34:36 +0000408#define CLONE_THREAD 0x00010000 /* Same thread group? */
409#define CLONE_NEWNS 0x00020000 /* New namespace group? */
410#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
411#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
412#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
413#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
Roland McGrath909875b2002-12-22 03:34:36 +0000414#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
415#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000416#define CLONE_STOPPED 0x02000000 /* Start in stopped state */
417#define CLONE_NEWUTS 0x04000000 /* New utsname group? */
418#define CLONE_NEWIPC 0x08000000 /* New ipcs */
419#define CLONE_NEWUSER 0x10000000 /* New user namespace */
420#define CLONE_NEWPID 0x20000000 /* New pid namespace */
421#define CLONE_NEWNET 0x40000000 /* New network namespace */
422#define CLONE_IO 0x80000000 /* Clone io context */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000423
Roland McGrathd9f816f2004-09-04 03:39:20 +0000424static const struct xlat clone_flags[] = {
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000425 { CLONE_VM, "CLONE_VM" },
426 { CLONE_FS, "CLONE_FS" },
427 { CLONE_FILES, "CLONE_FILES" },
428 { CLONE_SIGHAND, "CLONE_SIGHAND" },
Roland McGrath909875b2002-12-22 03:34:36 +0000429 { CLONE_IDLETASK, "CLONE_IDLETASK"},
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000430 { CLONE_PTRACE, "CLONE_PTRACE" },
431 { CLONE_VFORK, "CLONE_VFORK" },
432 { CLONE_PARENT, "CLONE_PARENT" },
Roland McGrath909875b2002-12-22 03:34:36 +0000433 { CLONE_THREAD, "CLONE_THREAD" },
434 { CLONE_NEWNS, "CLONE_NEWNS" },
435 { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
436 { CLONE_SETTLS, "CLONE_SETTLS" },
437 { CLONE_PARENT_SETTID,"CLONE_PARENT_SETTID" },
438 { CLONE_CHILD_CLEARTID,"CLONE_CHILD_CLEARTID" },
Roland McGrath909875b2002-12-22 03:34:36 +0000439 { CLONE_UNTRACED, "CLONE_UNTRACED" },
440 { CLONE_CHILD_SETTID,"CLONE_CHILD_SETTID" },
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000441 { CLONE_STOPPED, "CLONE_STOPPED" },
442 { CLONE_NEWUTS, "CLONE_NEWUTS" },
443 { CLONE_NEWIPC, "CLONE_NEWIPC" },
444 { CLONE_NEWUSER, "CLONE_NEWUSER" },
445 { CLONE_NEWPID, "CLONE_NEWPID" },
446 { CLONE_NEWNET, "CLONE_NEWNET" },
447 { CLONE_IO, "CLONE_IO" },
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000448 { 0, NULL },
449};
450
Roland McGrath909875b2002-12-22 03:34:36 +0000451# ifdef I386
452# include <asm/ldt.h>
Roland McGrath7decfb22004-03-01 22:10:52 +0000453# ifdef HAVE_STRUCT_USER_DESC
454# define modify_ldt_ldt_s user_desc
455# endif
Roland McGrath909875b2002-12-22 03:34:36 +0000456extern void print_ldt_entry();
457# endif
458
Roland McGrath9677b3a2003-03-12 09:54:36 +0000459# if defined IA64
460# define ARG_FLAGS 0
461# define ARG_STACK 1
Dmitry V. Levin44824b92012-02-20 21:44:53 +0000462# define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
463# define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
464# define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
465# define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +0000466# elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
Roland McGrath9677b3a2003-03-12 09:54:36 +0000467# define ARG_STACK 0
468# define ARG_FLAGS 1
469# define ARG_PTID 2
Roland McGrathfe5fdb22003-05-23 00:29:05 +0000470# define ARG_CTID 3
471# define ARG_TLS 4
Roland McGrath9c555e72003-07-09 09:47:59 +0000472# elif defined X86_64 || defined ALPHA
Roland McGrath361aac52003-03-18 07:43:42 +0000473# define ARG_FLAGS 0
474# define ARG_STACK 1
475# define ARG_PTID 2
476# define ARG_CTID 3
477# define ARG_TLS 4
Roland McGrath9677b3a2003-03-12 09:54:36 +0000478# else
479# define ARG_FLAGS 0
480# define ARG_STACK 1
481# define ARG_PTID 2
482# define ARG_TLS 3
483# define ARG_CTID 4
484# endif
485
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000486int
Denys Vlasenko12014262011-05-30 14:00:14 +0200487sys_clone(struct tcb *tcp)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000488{
489 if (exiting(tcp)) {
Wang Chaocbdd1902010-09-02 15:08:59 +0800490 const char *sep = "|";
Roland McGrath9677b3a2003-03-12 09:54:36 +0000491 unsigned long flags = tcp->u_arg[ARG_FLAGS];
492 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
493# ifdef ARG_STACKSIZE
494 if (ARG_STACKSIZE != -1)
495 tprintf("stack_size=%#lx, ",
496 tcp->u_arg[ARG_STACKSIZE]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000497# endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200498 tprints("flags=");
Wang Chaocbdd1902010-09-02 15:08:59 +0800499 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
500 sep = "";
Roland McGrath984154d2003-05-23 01:08:42 +0000501 if ((flags & CSIGNAL) != 0)
Wang Chaocbdd1902010-09-02 15:08:59 +0800502 tprintf("%s%s", sep, signame(flags & CSIGNAL));
Roland McGrathb4968be2003-01-20 09:04:33 +0000503 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
Roland McGrath9677b3a2003-03-12 09:54:36 +0000504 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
Roland McGrath909875b2002-12-22 03:34:36 +0000505 return 0;
Roland McGrath6f67a982003-03-21 07:33:15 +0000506 if (flags & CLONE_PARENT_SETTID)
507 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000508 if (flags & CLONE_SETTLS) {
Roland McGrath9677b3a2003-03-12 09:54:36 +0000509# ifdef I386
Roland McGrath909875b2002-12-22 03:34:36 +0000510 struct modify_ldt_ldt_s copy;
Roland McGrath9677b3a2003-03-12 09:54:36 +0000511 if (umove(tcp, tcp->u_arg[ARG_TLS], &copy) != -1) {
Roland McGrath909875b2002-12-22 03:34:36 +0000512 tprintf(", {entry_number:%d, ",
513 copy.entry_number);
514 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200515 tprints("...}");
Roland McGrath909875b2002-12-22 03:34:36 +0000516 else
517 print_ldt_entry(&copy);
518 }
519 else
Roland McGrath9677b3a2003-03-12 09:54:36 +0000520# endif
Roland McGrath43f2c842003-03-12 09:58:14 +0000521 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
Roland McGrath909875b2002-12-22 03:34:36 +0000522 }
Roland McGrath9677b3a2003-03-12 09:54:36 +0000523 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
524 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000525 }
526 return 0;
527}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000528
529int
530sys_unshare(struct tcb *tcp)
531{
532 if (entering(tcp))
533 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
534 return 0;
535}
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000536
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000537int
Denys Vlasenko12014262011-05-30 14:00:14 +0200538sys_fork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000539{
540 if (exiting(tcp))
541 return RVAL_UDECIMAL;
542 return 0;
543}
544
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000545int
Denys Vlasenko418d66a2009-01-17 01:52:54 +0000546change_syscall(struct tcb *tcp, int new)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000547{
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000548#if defined(I386)
549 /* Attempt to make vfork into fork, which we can follow. */
Roland McGrath5a223472002-12-15 23:58:26 +0000550 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000551 return -1;
552 return 0;
Michal Ludvig0e035502002-09-23 15:41:01 +0000553#elif defined(X86_64)
554 /* Attempt to make vfork into fork, which we can follow. */
Roland McGrath5a223472002-12-15 23:58:26 +0000555 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_RAX * 8), new) < 0)
Michal Ludvig0e035502002-09-23 15:41:01 +0000556 return -1;
557 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000558#elif defined(POWERPC)
Roland McGratheb285352003-01-14 09:59:00 +0000559 if (ptrace(PTRACE_POKEUSER, tcp->pid,
560 (char*)(sizeof(unsigned long)*PT_R0), new) < 0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000561 return -1;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000562 return 0;
Michal Ludvig10a88d02002-10-07 14:31:00 +0000563#elif defined(S390) || defined(S390X)
564 /* s390 linux after 2.4.7 has a hook in entry.S to allow this */
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200565 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR2), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000566 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000567 return 0;
568#elif defined(M68K)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200569 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_ORIG_D0), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000570 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000571 return 0;
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000572#elif defined(SPARC) || defined(SPARC64)
Mike Frysinger8566c502009-10-12 11:05:14 -0400573 struct pt_regs regs;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200574 if (ptrace(PTRACE_GETREGS, tcp->pid, (char*)&regs, 0) < 0)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000575 return -1;
Mike Frysinger8566c502009-10-12 11:05:14 -0400576 regs.u_regs[U_REG_G1] = new;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200577 if (ptrace(PTRACE_SETREGS, tcp->pid, (char*)&regs, 0) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000578 return -1;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000579 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000580#elif defined(MIPS)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200581 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000582 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000583 return 0;
584#elif defined(ALPHA)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200585 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000586 return -1;
587 return 0;
588#elif defined(AVR32)
589 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_R8), new) < 0)
590 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000591 return 0;
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000592#elif defined(BFIN)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200593 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_P0), new) < 0)
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000594 return -1;
595 return 0;
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000596#elif defined(IA64)
Roland McGrath08267b82004-02-20 22:56:43 +0000597 if (ia32) {
598 switch (new) {
Denys Vlasenko418d66a2009-01-17 01:52:54 +0000599 case 2:
600 break; /* x86 SYS_fork */
601 case SYS_clone:
602 new = 120;
603 break;
604 default:
Roland McGrath08267b82004-02-20 22:56:43 +0000605 fprintf(stderr, "%s: unexpected syscall %d\n",
606 __FUNCTION__, new);
607 return -1;
608 }
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200609 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R1), new) < 0)
Roland McGrath08267b82004-02-20 22:56:43 +0000610 return -1;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200611 } else if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R15), new) < 0)
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000612 return -1;
613 return 0;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000614#elif defined(HPPA)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200615 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR20), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000616 return -1;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000617 return 0;
Wichert Akkermanccef6372002-05-01 16:39:22 +0000618#elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200619 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*(REG_REG0+3)), new) < 0)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000620 return -1;
621 return 0;
Roland McGrathf5a47772003-06-26 22:40:42 +0000622#elif defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000623 /* Top half of reg encodes the no. of args n as 0x1n.
624 Assume 0 args as kernel never actually checks... */
625 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_SYSCALL),
626 0x100000 | new) < 0)
627 return -1;
628 return 0;
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +0000629#elif defined(CRISV10) || defined(CRISV32)
630 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R9), new) < 0)
631 return -1;
632 return 0;
Roland McGrathf691bd22006-04-25 07:34:41 +0000633#elif defined(ARM)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000634 /* Some kernels support this, some (pre-2.6.16 or so) don't. */
Roland McGrathf691bd22006-04-25 07:34:41 +0000635# ifndef PTRACE_SET_SYSCALL
636# define PTRACE_SET_SYSCALL 23
637# endif
638
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200639 if (ptrace(PTRACE_SET_SYSCALL, tcp->pid, 0, new & 0xffff) != 0)
Roland McGrathf691bd22006-04-25 07:34:41 +0000640 return -1;
641
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000642 return 0;
Chris Metcalfc8c66982009-12-28 10:00:15 -0500643#elif defined(TILE)
644 if (ptrace(PTRACE_POKEUSER, tcp->pid,
645 (char*)PTREGS_OFFSET_REG(0),
646 new) != 0)
647 return -1;
648 return 0;
Edgar E. Iglesias939caba2010-07-06 14:21:07 +0200649#elif defined(MICROBLAZE)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200650 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new) < 0)
Edgar E. Iglesias939caba2010-07-06 14:21:07 +0200651 return -1;
652 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000653#else
654#warning Do not know how to handle change_syscall for this architecture
655#endif /* architecture */
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000656 return -1;
657}
658
Wang Chaoca8ab8d2010-11-12 17:26:08 +0800659int
Dmitry V. Levin257e1572009-12-26 17:55:24 +0000660internal_fork(struct tcb *tcp)
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000661{
Denys Vlasenkof44cce42011-06-21 14:34:10 +0200662 if ((ptrace_setoptions
Wang Chaoca8ab8d2010-11-12 17:26:08 +0800663 & (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
664 == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
665 return 0;
666
Denys Vlasenko65d7c4d2011-06-23 21:46:37 +0200667 if (!followfork)
668 return 0;
669
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000670 if (entering(tcp)) {
Wang Chaoe636c852010-09-16 11:20:56 +0800671 /*
Denys Vlasenko833fb132011-08-17 11:30:56 +0200672 * We won't see the new child if clone is called with
673 * CLONE_UNTRACED, so we keep the same logic with that option
674 * and don't trace it.
Wang Chaoe636c852010-09-16 11:20:56 +0800675 */
676 if ((sysent[tcp->scno].sys_func == sys_clone) &&
677 (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED))
678 return 0;
Denys Vlasenkoe7c90242011-06-22 00:09:25 +0200679 setbpt(tcp);
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000680 } else {
Denys Vlasenko833fb132011-08-17 11:30:56 +0200681 if (tcp->flags & TCB_BPTSET)
682 clearbpt(tcp);
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000683 }
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000684 return 0;
685}
Dmitry V. Levin257e1572009-12-26 17:55:24 +0000686
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000687int
Denys Vlasenko12014262011-05-30 14:00:14 +0200688sys_vfork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000689{
690 if (exiting(tcp))
691 return RVAL_UDECIMAL;
692 return 0;
693}
694
Dmitry V. Levin50a218d2011-01-18 17:36:20 +0000695int sys_getuid(struct tcb *tcp)
696{
697 if (exiting(tcp))
698 tcp->u_rval = (uid_t) tcp->u_rval;
699 return RVAL_UDECIMAL;
700}
701
702int sys_setfsuid(struct tcb *tcp)
703{
704 if (entering(tcp))
705 tprintf("%u", (uid_t) tcp->u_arg[0]);
706 else
707 tcp->u_rval = (uid_t) tcp->u_rval;
708 return RVAL_UDECIMAL;
709}
710
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000711int
Denys Vlasenko12014262011-05-30 14:00:14 +0200712sys_setuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000713{
714 if (entering(tcp)) {
715 tprintf("%u", (uid_t) tcp->u_arg[0]);
716 }
717 return 0;
718}
719
720int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000721sys_getresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000722{
723 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000724 __kernel_uid_t uid;
725 if (syserror(tcp))
726 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
727 tcp->u_arg[1], tcp->u_arg[2]);
728 else {
729 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
730 tprintf("%#lx, ", tcp->u_arg[0]);
731 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000732 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000733 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
734 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000735 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000736 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000737 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
738 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000739 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000740 tprintf("[%lu]", (unsigned long) uid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000741 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000742 }
743 return 0;
744}
745
746int
Denys Vlasenko12014262011-05-30 14:00:14 +0200747sys_setreuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000748{
749 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000750 printuid("", tcp->u_arg[0]);
751 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000752 }
753 return 0;
754}
755
756int
Denys Vlasenko12014262011-05-30 14:00:14 +0200757sys_setresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000758{
759 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000760 printuid("", tcp->u_arg[0]);
761 printuid(", ", tcp->u_arg[1]);
762 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000763 }
764 return 0;
765}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000766
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000767int
Denys Vlasenko12014262011-05-30 14:00:14 +0200768sys_setgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000769{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000770 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000771 unsigned long len, size, start, cur, end, abbrev_end;
772 GETGROUPS_T gid;
773 int failed = 0;
774
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000775 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000776 tprintf("%lu, ", len);
777 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200778 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000779 return 0;
780 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000781 start = tcp->u_arg[1];
782 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200783 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000784 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000785 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000786 size = len * sizeof(gid);
787 end = start + size;
788 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
789 tprintf("%#lx", start);
790 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000791 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000792 if (abbrev(tcp)) {
793 abbrev_end = start + max_strlen * sizeof(gid);
794 if (abbrev_end < start)
795 abbrev_end = end;
796 } else {
797 abbrev_end = end;
798 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200799 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000800 for (cur = start; cur < end; cur += sizeof(gid)) {
801 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200802 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000803 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200804 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000805 break;
806 }
807 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200808 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000809 failed = 1;
810 break;
811 }
812 tprintf("%lu", (unsigned long) gid);
813 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200814 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000815 if (failed)
816 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000817 }
818 return 0;
819}
820
821int
Denys Vlasenko12014262011-05-30 14:00:14 +0200822sys_getgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000823{
Roland McGrathaa524c82005-06-01 19:22:06 +0000824 unsigned long len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000825
826 if (entering(tcp)) {
827 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000828 tprintf("%lu, ", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000829 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000830 unsigned long size, start, cur, end, abbrev_end;
831 GETGROUPS_T gid;
832 int failed = 0;
833
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000834 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000835 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200836 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000837 return 0;
838 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000839 start = tcp->u_arg[1];
840 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200841 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000842 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000843 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000844 if (tcp->u_arg[0] == 0) {
845 tprintf("%#lx", start);
846 return 0;
847 }
848 size = len * sizeof(gid);
849 end = start + size;
850 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
851 size / sizeof(gid) != len || end < start) {
852 tprintf("%#lx", start);
853 return 0;
854 }
855 if (abbrev(tcp)) {
856 abbrev_end = start + max_strlen * sizeof(gid);
857 if (abbrev_end < start)
858 abbrev_end = end;
859 } else {
860 abbrev_end = end;
861 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200862 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000863 for (cur = start; cur < end; cur += sizeof(gid)) {
864 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200865 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000866 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200867 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000868 break;
869 }
870 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200871 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000872 failed = 1;
873 break;
874 }
875 tprintf("%lu", (unsigned long) gid);
876 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200877 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000878 if (failed)
879 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000880 }
881 return 0;
882}
883
Roland McGrath83bd47a2003-11-13 22:32:26 +0000884int
Denys Vlasenko12014262011-05-30 14:00:14 +0200885sys_setgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000886{
Roland McGrath83bd47a2003-11-13 22:32:26 +0000887 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000888 unsigned long len, size, start, cur, end, abbrev_end;
889 GETGROUPS32_T gid;
890 int failed = 0;
891
Roland McGrath83bd47a2003-11-13 22:32:26 +0000892 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000893 tprintf("%lu, ", len);
894 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200895 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000896 return 0;
897 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000898 start = tcp->u_arg[1];
899 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200900 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000901 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000902 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000903 size = len * sizeof(gid);
904 end = start + size;
905 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
906 tprintf("%#lx", start);
907 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000908 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000909 if (abbrev(tcp)) {
910 abbrev_end = start + max_strlen * sizeof(gid);
911 if (abbrev_end < start)
912 abbrev_end = end;
913 } else {
914 abbrev_end = end;
915 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200916 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000917 for (cur = start; cur < end; cur += sizeof(gid)) {
918 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200919 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000920 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200921 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000922 break;
923 }
924 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200925 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000926 failed = 1;
927 break;
928 }
929 tprintf("%lu", (unsigned long) gid);
930 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200931 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000932 if (failed)
933 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000934 }
935 return 0;
936}
937
938int
Denys Vlasenko12014262011-05-30 14:00:14 +0200939sys_getgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000940{
Roland McGrathaa524c82005-06-01 19:22:06 +0000941 unsigned long len;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000942
943 if (entering(tcp)) {
944 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000945 tprintf("%lu, ", len);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000946 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000947 unsigned long size, start, cur, end, abbrev_end;
948 GETGROUPS32_T gid;
949 int failed = 0;
950
Roland McGrath83bd47a2003-11-13 22:32:26 +0000951 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000952 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200953 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000954 return 0;
955 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000956 start = tcp->u_arg[1];
957 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200958 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000959 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000960 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000961 size = len * sizeof(gid);
962 end = start + size;
963 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
964 size / sizeof(gid) != len || end < start) {
965 tprintf("%#lx", start);
966 return 0;
967 }
968 if (abbrev(tcp)) {
969 abbrev_end = start + max_strlen * sizeof(gid);
970 if (abbrev_end < start)
971 abbrev_end = end;
972 } else {
973 abbrev_end = end;
974 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200975 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000976 for (cur = start; cur < end; cur += sizeof(gid)) {
977 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200978 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000979 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200980 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000981 break;
982 }
983 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200984 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000985 failed = 1;
986 break;
987 }
988 tprintf("%lu", (unsigned long) gid);
989 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200990 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000991 if (failed)
992 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000993 }
994 return 0;
995}
Roland McGrath83bd47a2003-11-13 22:32:26 +0000996
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000997static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000998printargv(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000999{
Roland McGrath85a3bc42007-08-02 02:13:05 +00001000 union {
Andreas Schwab99c85692009-08-28 19:36:20 +02001001 unsigned int p32;
1002 unsigned long p64;
Roland McGrath85a3bc42007-08-02 02:13:05 +00001003 char data[sizeof(long)];
1004 } cp;
Dmitry V. Levin30145dd2010-09-06 22:08:24 +00001005 const char *sep;
Roland McGrath85a3bc42007-08-02 02:13:05 +00001006 int n = 0;
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001007 unsigned wordsize = personality_wordsize[current_personality];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001008
Roland McGrath85a3bc42007-08-02 02:13:05 +00001009 cp.p64 = 1;
1010 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001011 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001012 tprintf("%#lx", addr);
1013 return;
1014 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001015 if (wordsize == 4)
Roland McGrath85a3bc42007-08-02 02:13:05 +00001016 cp.p64 = cp.p32;
1017 if (cp.p64 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001018 break;
Denys Vlasenko5940e652011-09-01 09:55:05 +02001019 tprints(sep);
Roland McGrath85a3bc42007-08-02 02:13:05 +00001020 printstr(tcp, cp.p64, -1);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +01001021 addr += wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001022 }
Roland McGrath85a3bc42007-08-02 02:13:05 +00001023 if (cp.p64)
1024 tprintf("%s...", sep);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001025}
1026
1027static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +00001028printargc(const char *fmt, struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001029{
1030 int count;
1031 char *cp;
1032
1033 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
1034 addr += sizeof(char *);
1035 }
1036 tprintf(fmt, count, count == 1 ? "" : "s");
1037}
1038
Denys Vlasenko84703742012-02-25 02:38:52 +01001039#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001040int
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001041sys_execv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001042{
1043 if (entering(tcp)) {
1044 printpath(tcp, tcp->u_arg[0]);
1045 if (!verbose(tcp))
1046 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001047 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001048 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001049 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001050 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001051 }
1052 }
1053 return 0;
1054}
Denys Vlasenko84703742012-02-25 02:38:52 +01001055#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001056
1057int
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001058sys_execve(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001059{
1060 if (entering(tcp)) {
1061 printpath(tcp, tcp->u_arg[0]);
1062 if (!verbose(tcp))
1063 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001064 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001065 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001066 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001067 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001068 }
1069 if (!verbose(tcp))
1070 tprintf(", %#lx", tcp->u_arg[2]);
1071 else if (abbrev(tcp))
1072 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
1073 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001074 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001075 printargv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001076 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001077 }
1078 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001079 return 0;
1080}
1081
Denys Vlasenko84703742012-02-25 02:38:52 +01001082#if defined(TCB_WAITEXECVE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001083int
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001084internal_exec(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001085{
Roland McGrathfdb097f2004-07-12 07:38:55 +00001086 if (exiting(tcp) && syserror(tcp))
1087 tcp->flags &= ~TCB_WAITEXECVE;
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001088 else {
1089 /* Maybe we have post-execve SIGTRAP suppressed? */
Denys Vlasenkof44cce42011-06-21 14:34:10 +02001090 if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC))
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001091 tcp->flags |= TCB_WAITEXECVE; /* no */
1092 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001093 return 0;
1094}
Denys Vlasenkoa7949742011-08-21 17:26:55 +02001095#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001096
Roland McGrath7ec1d352002-12-17 04:50:44 +00001097#ifndef __WNOTHREAD
1098#define __WNOTHREAD 0x20000000
1099#endif
1100#ifndef __WALL
1101#define __WALL 0x40000000
1102#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001103#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +00001104#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001105#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001106
Roland McGrathd9f816f2004-09-04 03:39:20 +00001107static const struct xlat wait4_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001108 { WNOHANG, "WNOHANG" },
1109#ifndef WSTOPPED
1110 { WUNTRACED, "WUNTRACED" },
1111#endif
1112#ifdef WEXITED
1113 { WEXITED, "WEXITED" },
1114#endif
1115#ifdef WTRAPPED
1116 { WTRAPPED, "WTRAPPED" },
1117#endif
1118#ifdef WSTOPPED
1119 { WSTOPPED, "WSTOPPED" },
1120#endif
1121#ifdef WCONTINUED
1122 { WCONTINUED, "WCONTINUED" },
1123#endif
1124#ifdef WNOWAIT
1125 { WNOWAIT, "WNOWAIT" },
1126#endif
1127#ifdef __WCLONE
1128 { __WCLONE, "__WCLONE" },
1129#endif
Roland McGrath7ec1d352002-12-17 04:50:44 +00001130#ifdef __WALL
1131 { __WALL, "__WALL" },
1132#endif
1133#ifdef __WNOTHREAD
1134 { __WNOTHREAD, "__WNOTHREAD" },
1135#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001136 { 0, NULL },
1137};
1138
Roland McGrath5e02a572004-10-19 23:33:47 +00001139#if !defined WCOREFLAG && defined WCOREFLG
1140# define WCOREFLAG WCOREFLG
1141#endif
1142#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001143# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +00001144#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001145#ifndef WCOREDUMP
1146# define WCOREDUMP(status) ((status) & 0200)
1147#endif
1148
Roland McGrath5e02a572004-10-19 23:33:47 +00001149#ifndef W_STOPCODE
1150#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
1151#endif
1152#ifndef W_EXITCODE
1153#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
1154#endif
1155
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001156static int
Denys Vlasenko12014262011-05-30 14:00:14 +02001157printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001158{
1159 int exited = 0;
1160
1161 /*
1162 * Here is a tricky presentation problem. This solution
1163 * is still not entirely satisfactory but since there
1164 * are no wait status constructors it will have to do.
1165 */
Roland McGrath79fbda52004-04-14 02:45:55 +00001166 if (WIFSTOPPED(status)) {
1167 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001168 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +00001169 status &= ~W_STOPCODE(WSTOPSIG(status));
1170 }
1171 else if (WIFSIGNALED(status)) {
1172 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001173 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001174 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +00001175 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1176 }
1177 else if (WIFEXITED(status)) {
1178 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001179 WEXITSTATUS(status));
1180 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +00001181 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001182 }
Roland McGrath79fbda52004-04-14 02:45:55 +00001183 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001184 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001185 return 0;
1186 }
1187
1188 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001189 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +00001190 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +00001191 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001192
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001193 return exited;
1194}
1195
1196static int
Denys Vlasenko59432db2009-01-26 19:09:35 +00001197printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001198{
1199 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001200
1201 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001202 /* On Linux, kernel-side pid_t is typedef'ed to int
1203 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +00001204 * pid argument to int on 64bit arches, producing,
1205 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001206 * in strace. We have to use int here, not long.
1207 */
1208 int pid = tcp->u_arg[0];
1209 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001210 } else {
1211 /* status */
1212 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001213 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001214 else if (syserror(tcp) || tcp->u_rval == 0)
1215 tprintf("%#lx", tcp->u_arg[1]);
1216 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001217 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001218 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +00001219 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001220 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001221 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001222 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001223 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001224 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001225 /* usage */
1226 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001227 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001228 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +00001229#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001230 if (bitness)
1231 printrusage32(tcp, tcp->u_arg[3]);
1232 else
1233#endif
1234 printrusage(tcp, tcp->u_arg[3]);
1235 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001236 else
1237 tprintf("%#lx", tcp->u_arg[3]);
1238 }
1239 }
1240 return 0;
1241}
1242
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001243int
Denys Vlasenko12014262011-05-30 14:00:14 +02001244sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001245{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001246 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001247}
1248
1249int
Denys Vlasenko12014262011-05-30 14:00:14 +02001250sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001251{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001252 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001253}
1254
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001255#ifdef ALPHA
1256int
Denys Vlasenko12014262011-05-30 14:00:14 +02001257sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001258{
1259 return printwaitn(tcp, 4, 1);
1260}
1261#endif
1262
Roland McGrathd9f816f2004-09-04 03:39:20 +00001263static const struct xlat waitid_types[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001264 { P_PID, "P_PID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001265#ifdef P_PPID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001266 { P_PPID, "P_PPID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001267#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001268 { P_PGID, "P_PGID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001269#ifdef P_SID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001270 { P_SID, "P_SID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001271#endif
1272#ifdef P_CID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001273 { P_CID, "P_CID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001274#endif
1275#ifdef P_UID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001276 { P_UID, "P_UID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001277#endif
1278#ifdef P_GID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001279 { P_GID, "P_GID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001280#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001281 { P_ALL, "P_ALL" },
1282#ifdef P_LWPID
1283 { P_LWPID, "P_LWPID" },
1284#endif
1285 { 0, NULL },
1286};
1287
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001288int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +00001289sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001290{
1291 siginfo_t si;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001292
1293 if (entering(tcp)) {
1294 printxval(waitid_types, tcp->u_arg[0], "P_???");
1295 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001296 }
1297 else {
1298 /* siginfo */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001299 if (!tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001300 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001301 else if (syserror(tcp))
1302 tprintf("%#lx", tcp->u_arg[2]);
1303 else if (umove(tcp, tcp->u_arg[2], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001304 tprints("{???}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001305 else
Denys Vlasenkof535b542009-01-13 18:30:55 +00001306 printsiginfo(&si, verbose(tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001307 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001308 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001309 printflags(wait4_options, tcp->u_arg[3], "W???");
Roland McGrath39426a32004-10-06 22:02:59 +00001310 if (tcp->u_nargs > 4) {
1311 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001312 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +00001313 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001314 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +00001315 else if (tcp->u_error)
1316 tprintf("%#lx", tcp->u_arg[4]);
1317 else
1318 printrusage(tcp, tcp->u_arg[4]);
1319 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001320 }
1321 return 0;
1322}
1323
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001324int
Denys Vlasenko12014262011-05-30 14:00:14 +02001325sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001326{
1327 struct utsname uname;
1328
1329 if (exiting(tcp)) {
1330 if (syserror(tcp) || !verbose(tcp))
1331 tprintf("%#lx", tcp->u_arg[0]);
1332 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001333 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001334 else if (!abbrev(tcp)) {
1335
1336 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1337 uname.sysname, uname.nodename);
1338 tprintf("release=\"%s\", version=\"%s\", ",
1339 uname.release, uname.version);
1340 tprintf("machine=\"%s\"", uname.machine);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001341#ifndef __GLIBC__
1342 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001343#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001344 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001345 }
1346 else
1347 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1348 uname.sysname, uname.nodename);
1349 }
1350 return 0;
1351}
1352
Roland McGratheb9e2e82009-06-02 16:49:22 -07001353static const struct xlat ptrace_cmds[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001354 { PTRACE_TRACEME, "PTRACE_TRACEME" },
Denys Vlasenko61526c62011-08-25 10:21:13 +02001355 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1356 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1357 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1358 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1359 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1360 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001361 { PTRACE_CONT, "PTRACE_CONT" },
1362 { PTRACE_KILL, "PTRACE_KILL" },
1363 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1364 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1365 { PTRACE_DETACH, "PTRACE_DETACH" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001366# ifdef PTRACE_GETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001367 { PTRACE_GETREGS, "PTRACE_GETREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001368# endif
1369# ifdef PTRACE_SETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001370 { PTRACE_SETREGS, "PTRACE_SETREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001371# endif
1372# ifdef PTRACE_GETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001373 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001374# endif
1375# ifdef PTRACE_SETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001376 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001377# endif
1378# ifdef PTRACE_GETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001379 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001380# endif
1381# ifdef PTRACE_SETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001382 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001383# endif
1384# ifdef PTRACE_GETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001385 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001386# endif
1387# ifdef PTRACE_SETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001388 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001389# endif
1390# ifdef PTRACE_SETOPTIONS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001391 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001392# endif
1393# ifdef PTRACE_GETEVENTMSG
Denys Vlasenko61526c62011-08-25 10:21:13 +02001394 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001395# endif
1396# ifdef PTRACE_GETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001397 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001398# endif
1399# ifdef PTRACE_SETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001400 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001401# endif
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001402# ifdef PTRACE_GETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001403 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001404# endif
1405# ifdef PTRACE_SETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001406 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001407# endif
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001408# ifdef PTRACE_SET_SYSCALL
Denys Vlasenko61526c62011-08-25 10:21:13 +02001409 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001410# endif
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001411# ifdef PTRACE_SEIZE
1412 { PTRACE_SEIZE, "PTRACE_SEIZE" },
1413# endif
1414# ifdef PTRACE_INTERRUPT
1415 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
1416# endif
1417# ifdef PTRACE_LISTEN
1418 { PTRACE_LISTEN, "PTRACE_LISTEN" },
1419# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001420 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
Denys Vlasenkof535b542009-01-13 18:30:55 +00001421
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001422 { 0, NULL },
1423};
1424
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001425# ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00001426static const struct xlat ptrace_setoptions_flags[] = {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001427# ifdef PTRACE_O_TRACESYSGOOD
Denys Vlasenkof535b542009-01-13 18:30:55 +00001428 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001429# endif
1430# ifdef PTRACE_O_TRACEFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001431 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001432# endif
1433# ifdef PTRACE_O_TRACEVFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001434 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001435# endif
1436# ifdef PTRACE_O_TRACECLONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001437 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001438# endif
1439# ifdef PTRACE_O_TRACEEXEC
Denys Vlasenkof535b542009-01-13 18:30:55 +00001440 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001441# endif
1442# ifdef PTRACE_O_TRACEVFORKDONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001443 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001444# endif
1445# ifdef PTRACE_O_TRACEEXIT
Denys Vlasenkof535b542009-01-13 18:30:55 +00001446 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001447# endif
Denys Vlasenkof535b542009-01-13 18:30:55 +00001448 { 0, NULL },
1449};
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001450# endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001451
Roland McGrathd9f816f2004-09-04 03:39:20 +00001452const struct xlat struct_user_offsets[] = {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001453# if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001454 { PT_PSWMASK, "psw_mask" },
1455 { PT_PSWADDR, "psw_addr" },
1456 { PT_GPR0, "gpr0" },
1457 { PT_GPR1, "gpr1" },
1458 { PT_GPR2, "gpr2" },
1459 { PT_GPR3, "gpr3" },
1460 { PT_GPR4, "gpr4" },
1461 { PT_GPR5, "gpr5" },
1462 { PT_GPR6, "gpr6" },
1463 { PT_GPR7, "gpr7" },
1464 { PT_GPR8, "gpr8" },
1465 { PT_GPR9, "gpr9" },
1466 { PT_GPR10, "gpr10" },
1467 { PT_GPR11, "gpr11" },
1468 { PT_GPR12, "gpr12" },
1469 { PT_GPR13, "gpr13" },
1470 { PT_GPR14, "gpr14" },
1471 { PT_GPR15, "gpr15" },
1472 { PT_ACR0, "acr0" },
1473 { PT_ACR1, "acr1" },
1474 { PT_ACR2, "acr2" },
1475 { PT_ACR3, "acr3" },
1476 { PT_ACR4, "acr4" },
1477 { PT_ACR5, "acr5" },
1478 { PT_ACR6, "acr6" },
1479 { PT_ACR7, "acr7" },
1480 { PT_ACR8, "acr8" },
1481 { PT_ACR9, "acr9" },
1482 { PT_ACR10, "acr10" },
1483 { PT_ACR11, "acr11" },
1484 { PT_ACR12, "acr12" },
1485 { PT_ACR13, "acr13" },
1486 { PT_ACR14, "acr14" },
1487 { PT_ACR15, "acr15" },
1488 { PT_ORIGGPR2, "orig_gpr2" },
1489 { PT_FPC, "fpc" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001490# if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001491 { PT_FPR0_HI, "fpr0.hi" },
1492 { PT_FPR0_LO, "fpr0.lo" },
1493 { PT_FPR1_HI, "fpr1.hi" },
1494 { PT_FPR1_LO, "fpr1.lo" },
1495 { PT_FPR2_HI, "fpr2.hi" },
1496 { PT_FPR2_LO, "fpr2.lo" },
1497 { PT_FPR3_HI, "fpr3.hi" },
1498 { PT_FPR3_LO, "fpr3.lo" },
1499 { PT_FPR4_HI, "fpr4.hi" },
1500 { PT_FPR4_LO, "fpr4.lo" },
1501 { PT_FPR5_HI, "fpr5.hi" },
1502 { PT_FPR5_LO, "fpr5.lo" },
1503 { PT_FPR6_HI, "fpr6.hi" },
1504 { PT_FPR6_LO, "fpr6.lo" },
1505 { PT_FPR7_HI, "fpr7.hi" },
1506 { PT_FPR7_LO, "fpr7.lo" },
1507 { PT_FPR8_HI, "fpr8.hi" },
1508 { PT_FPR8_LO, "fpr8.lo" },
1509 { PT_FPR9_HI, "fpr9.hi" },
1510 { PT_FPR9_LO, "fpr9.lo" },
1511 { PT_FPR10_HI, "fpr10.hi" },
1512 { PT_FPR10_LO, "fpr10.lo" },
1513 { PT_FPR11_HI, "fpr11.hi" },
1514 { PT_FPR11_LO, "fpr11.lo" },
1515 { PT_FPR12_HI, "fpr12.hi" },
1516 { PT_FPR12_LO, "fpr12.lo" },
1517 { PT_FPR13_HI, "fpr13.hi" },
1518 { PT_FPR13_LO, "fpr13.lo" },
1519 { PT_FPR14_HI, "fpr14.hi" },
1520 { PT_FPR14_LO, "fpr14.lo" },
1521 { PT_FPR15_HI, "fpr15.hi" },
1522 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001523# endif
1524# if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001525 { PT_FPR0, "fpr0" },
1526 { PT_FPR1, "fpr1" },
1527 { PT_FPR2, "fpr2" },
1528 { PT_FPR3, "fpr3" },
1529 { PT_FPR4, "fpr4" },
1530 { PT_FPR5, "fpr5" },
1531 { PT_FPR6, "fpr6" },
1532 { PT_FPR7, "fpr7" },
1533 { PT_FPR8, "fpr8" },
1534 { PT_FPR9, "fpr9" },
1535 { PT_FPR10, "fpr10" },
1536 { PT_FPR11, "fpr11" },
1537 { PT_FPR12, "fpr12" },
1538 { PT_FPR13, "fpr13" },
1539 { PT_FPR14, "fpr14" },
1540 { PT_FPR15, "fpr15" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001541# endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001542 { PT_CR_9, "cr9" },
1543 { PT_CR_10, "cr10" },
1544 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001545 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001546# elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001547 /* XXX No support for these offsets yet. */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001548# elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001549 /* XXX No support for these offsets yet. */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001550# elif defined(POWERPC)
1551# ifndef PT_ORIG_R3
1552# define PT_ORIG_R3 34
1553# endif
1554# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001555 { REGSIZE*PT_R0, "r0" },
1556 { REGSIZE*PT_R1, "r1" },
1557 { REGSIZE*PT_R2, "r2" },
1558 { REGSIZE*PT_R3, "r3" },
1559 { REGSIZE*PT_R4, "r4" },
1560 { REGSIZE*PT_R5, "r5" },
1561 { REGSIZE*PT_R6, "r6" },
1562 { REGSIZE*PT_R7, "r7" },
1563 { REGSIZE*PT_R8, "r8" },
1564 { REGSIZE*PT_R9, "r9" },
1565 { REGSIZE*PT_R10, "r10" },
1566 { REGSIZE*PT_R11, "r11" },
1567 { REGSIZE*PT_R12, "r12" },
1568 { REGSIZE*PT_R13, "r13" },
1569 { REGSIZE*PT_R14, "r14" },
1570 { REGSIZE*PT_R15, "r15" },
1571 { REGSIZE*PT_R16, "r16" },
1572 { REGSIZE*PT_R17, "r17" },
1573 { REGSIZE*PT_R18, "r18" },
1574 { REGSIZE*PT_R19, "r19" },
1575 { REGSIZE*PT_R20, "r20" },
1576 { REGSIZE*PT_R21, "r21" },
1577 { REGSIZE*PT_R22, "r22" },
1578 { REGSIZE*PT_R23, "r23" },
1579 { REGSIZE*PT_R24, "r24" },
1580 { REGSIZE*PT_R25, "r25" },
1581 { REGSIZE*PT_R26, "r26" },
1582 { REGSIZE*PT_R27, "r27" },
1583 { REGSIZE*PT_R28, "r28" },
1584 { REGSIZE*PT_R29, "r29" },
1585 { REGSIZE*PT_R30, "r30" },
1586 { REGSIZE*PT_R31, "r31" },
1587 { REGSIZE*PT_NIP, "NIP" },
1588 { REGSIZE*PT_MSR, "MSR" },
1589 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1590 { REGSIZE*PT_CTR, "CTR" },
1591 { REGSIZE*PT_LNK, "LNK" },
1592 { REGSIZE*PT_XER, "XER" },
1593 { REGSIZE*PT_CCR, "CCR" },
1594 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001595# undef REGSIZE
1596# elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001597 { 0, "r0" },
1598 { 1, "r1" },
1599 { 2, "r2" },
1600 { 3, "r3" },
1601 { 4, "r4" },
1602 { 5, "r5" },
1603 { 6, "r6" },
1604 { 7, "r7" },
1605 { 8, "r8" },
1606 { 9, "r9" },
1607 { 10, "r10" },
1608 { 11, "r11" },
1609 { 12, "r12" },
1610 { 13, "r13" },
1611 { 14, "r14" },
1612 { 15, "r15" },
1613 { 16, "r16" },
1614 { 17, "r17" },
1615 { 18, "r18" },
1616 { 19, "r19" },
1617 { 20, "r20" },
1618 { 21, "r21" },
1619 { 22, "r22" },
1620 { 23, "r23" },
1621 { 24, "r24" },
1622 { 25, "r25" },
1623 { 26, "r26" },
1624 { 27, "r27" },
1625 { 28, "r28" },
1626 { 29, "gp" },
1627 { 30, "fp" },
1628 { 31, "zero" },
1629 { 32, "fp0" },
1630 { 33, "fp" },
1631 { 34, "fp2" },
1632 { 35, "fp3" },
1633 { 36, "fp4" },
1634 { 37, "fp5" },
1635 { 38, "fp6" },
1636 { 39, "fp7" },
1637 { 40, "fp8" },
1638 { 41, "fp9" },
1639 { 42, "fp10" },
1640 { 43, "fp11" },
1641 { 44, "fp12" },
1642 { 45, "fp13" },
1643 { 46, "fp14" },
1644 { 47, "fp15" },
1645 { 48, "fp16" },
1646 { 49, "fp17" },
1647 { 50, "fp18" },
1648 { 51, "fp19" },
1649 { 52, "fp20" },
1650 { 53, "fp21" },
1651 { 54, "fp22" },
1652 { 55, "fp23" },
1653 { 56, "fp24" },
1654 { 57, "fp25" },
1655 { 58, "fp26" },
1656 { 59, "fp27" },
1657 { 60, "fp28" },
1658 { 61, "fp29" },
1659 { 62, "fp30" },
1660 { 63, "fp31" },
1661 { 64, "pc" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001662# elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001663 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1664 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1665 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1666 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1667 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1668 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1669 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1670 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1671 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1672 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1673 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1674 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1675 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1676 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1677 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1678 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1679 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1680 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1681 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1682 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1683 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1684 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1685 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1686 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1687 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1688 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1689 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1690 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1691 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1692 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1693 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1694 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1695 /* switch stack: */
1696 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1697 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1698 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1699 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1700 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1701 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1702 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1703 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1704 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1705 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001706 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1707 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001708 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001709 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001710 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1711 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001712 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1713 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1714 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1715 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1716 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1717 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1718 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1719 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1720 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1721 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1722 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1723 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1724 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1725 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1726 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001727# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001728 { PT_AR_CSD, "ar.csd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001729# endif
1730# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001731 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001732# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001733 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001734# elif defined(I386)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001735 { 4*EBX, "4*EBX" },
1736 { 4*ECX, "4*ECX" },
1737 { 4*EDX, "4*EDX" },
1738 { 4*ESI, "4*ESI" },
1739 { 4*EDI, "4*EDI" },
1740 { 4*EBP, "4*EBP" },
1741 { 4*EAX, "4*EAX" },
1742 { 4*DS, "4*DS" },
1743 { 4*ES, "4*ES" },
1744 { 4*FS, "4*FS" },
1745 { 4*GS, "4*GS" },
1746 { 4*ORIG_EAX, "4*ORIG_EAX" },
1747 { 4*EIP, "4*EIP" },
1748 { 4*CS, "4*CS" },
1749 { 4*EFL, "4*EFL" },
1750 { 4*UESP, "4*UESP" },
1751 { 4*SS, "4*SS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001752# elif defined(X86_64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001753 { 8*R15, "8*R15" },
1754 { 8*R14, "8*R14" },
1755 { 8*R13, "8*R13" },
1756 { 8*R12, "8*R12" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001757 { 8*RBP, "8*RBP" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001758 { 8*RBX, "8*RBX" },
1759 { 8*R11, "8*R11" },
1760 { 8*R10, "8*R10" },
1761 { 8*R9, "8*R9" },
1762 { 8*R8, "8*R8" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001763 { 8*RAX, "8*RAX" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001764 { 8*RCX, "8*RCX" },
1765 { 8*RDX, "8*RDX" },
1766 { 8*RSI, "8*RSI" },
1767 { 8*RDI, "8*RDI" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001768 { 8*ORIG_RAX, "8*ORIG_RAX" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001769 { 8*RIP, "8*RIP" },
1770 { 8*CS, "8*CS" },
1771 { 8*EFLAGS, "8*EFL" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001772 { 8*RSP, "8*RSP" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001773 { 8*SS, "8*SS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001774# elif defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001775 { 4*PT_D1, "4*PT_D1" },
1776 { 4*PT_D2, "4*PT_D2" },
1777 { 4*PT_D3, "4*PT_D3" },
1778 { 4*PT_D4, "4*PT_D4" },
1779 { 4*PT_D5, "4*PT_D5" },
1780 { 4*PT_D6, "4*PT_D6" },
1781 { 4*PT_D7, "4*PT_D7" },
1782 { 4*PT_A0, "4*PT_A0" },
1783 { 4*PT_A1, "4*PT_A1" },
1784 { 4*PT_A2, "4*PT_A2" },
1785 { 4*PT_A3, "4*PT_A3" },
1786 { 4*PT_A4, "4*PT_A4" },
1787 { 4*PT_A5, "4*PT_A5" },
1788 { 4*PT_A6, "4*PT_A6" },
1789 { 4*PT_D0, "4*PT_D0" },
1790 { 4*PT_USP, "4*PT_USP" },
1791 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1792 { 4*PT_SR, "4*PT_SR" },
1793 { 4*PT_PC, "4*PT_PC" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001794# elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001795 { 4*REG_REG0, "4*REG_REG0" },
1796 { 4*(REG_REG0+1), "4*REG_REG1" },
1797 { 4*(REG_REG0+2), "4*REG_REG2" },
1798 { 4*(REG_REG0+3), "4*REG_REG3" },
1799 { 4*(REG_REG0+4), "4*REG_REG4" },
1800 { 4*(REG_REG0+5), "4*REG_REG5" },
1801 { 4*(REG_REG0+6), "4*REG_REG6" },
1802 { 4*(REG_REG0+7), "4*REG_REG7" },
1803 { 4*(REG_REG0+8), "4*REG_REG8" },
1804 { 4*(REG_REG0+9), "4*REG_REG9" },
1805 { 4*(REG_REG0+10), "4*REG_REG10" },
1806 { 4*(REG_REG0+11), "4*REG_REG11" },
1807 { 4*(REG_REG0+12), "4*REG_REG12" },
1808 { 4*(REG_REG0+13), "4*REG_REG13" },
1809 { 4*(REG_REG0+14), "4*REG_REG14" },
1810 { 4*REG_REG15, "4*REG_REG15" },
1811 { 4*REG_PC, "4*REG_PC" },
1812 { 4*REG_PR, "4*REG_PR" },
1813 { 4*REG_SR, "4*REG_SR" },
1814 { 4*REG_GBR, "4*REG_GBR" },
1815 { 4*REG_MACH, "4*REG_MACH" },
1816 { 4*REG_MACL, "4*REG_MACL" },
1817 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1818 { 4*REG_FPUL, "4*REG_FPUL" },
1819 { 4*REG_FPREG0, "4*REG_FPREG0" },
1820 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1821 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1822 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1823 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1824 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1825 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1826 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1827 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1828 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1829 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1830 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1831 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1832 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1833 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1834 { 4*REG_FPREG15, "4*REG_FPREG15" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001835# ifdef REG_XDREG0
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001836 { 4*REG_XDREG0, "4*REG_XDREG0" },
1837 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1838 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1839 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1840 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1841 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1842 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1843 { 4*REG_XDREG14, "4*REG_XDREG14" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001844# endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001845 { 4*REG_FPSCR, "4*REG_FPSCR" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001846# elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001847 { 0, "PC(L)" },
1848 { 4, "PC(U)" },
1849 { 8, "SR(L)" },
1850 { 12, "SR(U)" },
1851 { 16, "syscall no.(L)" },
1852 { 20, "syscall_no.(U)" },
1853 { 24, "R0(L)" },
1854 { 28, "R0(U)" },
1855 { 32, "R1(L)" },
1856 { 36, "R1(U)" },
1857 { 40, "R2(L)" },
1858 { 44, "R2(U)" },
1859 { 48, "R3(L)" },
1860 { 52, "R3(U)" },
1861 { 56, "R4(L)" },
1862 { 60, "R4(U)" },
1863 { 64, "R5(L)" },
1864 { 68, "R5(U)" },
1865 { 72, "R6(L)" },
1866 { 76, "R6(U)" },
1867 { 80, "R7(L)" },
1868 { 84, "R7(U)" },
1869 { 88, "R8(L)" },
1870 { 92, "R8(U)" },
1871 { 96, "R9(L)" },
1872 { 100, "R9(U)" },
1873 { 104, "R10(L)" },
1874 { 108, "R10(U)" },
1875 { 112, "R11(L)" },
1876 { 116, "R11(U)" },
1877 { 120, "R12(L)" },
1878 { 124, "R12(U)" },
1879 { 128, "R13(L)" },
1880 { 132, "R13(U)" },
1881 { 136, "R14(L)" },
1882 { 140, "R14(U)" },
1883 { 144, "R15(L)" },
1884 { 148, "R15(U)" },
1885 { 152, "R16(L)" },
1886 { 156, "R16(U)" },
1887 { 160, "R17(L)" },
1888 { 164, "R17(U)" },
1889 { 168, "R18(L)" },
1890 { 172, "R18(U)" },
1891 { 176, "R19(L)" },
1892 { 180, "R19(U)" },
1893 { 184, "R20(L)" },
1894 { 188, "R20(U)" },
1895 { 192, "R21(L)" },
1896 { 196, "R21(U)" },
1897 { 200, "R22(L)" },
1898 { 204, "R22(U)" },
1899 { 208, "R23(L)" },
1900 { 212, "R23(U)" },
1901 { 216, "R24(L)" },
1902 { 220, "R24(U)" },
1903 { 224, "R25(L)" },
1904 { 228, "R25(U)" },
1905 { 232, "R26(L)" },
1906 { 236, "R26(U)" },
1907 { 240, "R27(L)" },
1908 { 244, "R27(U)" },
1909 { 248, "R28(L)" },
1910 { 252, "R28(U)" },
1911 { 256, "R29(L)" },
1912 { 260, "R29(U)" },
1913 { 264, "R30(L)" },
1914 { 268, "R30(U)" },
1915 { 272, "R31(L)" },
1916 { 276, "R31(U)" },
1917 { 280, "R32(L)" },
1918 { 284, "R32(U)" },
1919 { 288, "R33(L)" },
1920 { 292, "R33(U)" },
1921 { 296, "R34(L)" },
1922 { 300, "R34(U)" },
1923 { 304, "R35(L)" },
1924 { 308, "R35(U)" },
1925 { 312, "R36(L)" },
1926 { 316, "R36(U)" },
1927 { 320, "R37(L)" },
1928 { 324, "R37(U)" },
1929 { 328, "R38(L)" },
1930 { 332, "R38(U)" },
1931 { 336, "R39(L)" },
1932 { 340, "R39(U)" },
1933 { 344, "R40(L)" },
1934 { 348, "R40(U)" },
1935 { 352, "R41(L)" },
1936 { 356, "R41(U)" },
1937 { 360, "R42(L)" },
1938 { 364, "R42(U)" },
1939 { 368, "R43(L)" },
1940 { 372, "R43(U)" },
1941 { 376, "R44(L)" },
1942 { 380, "R44(U)" },
1943 { 384, "R45(L)" },
1944 { 388, "R45(U)" },
1945 { 392, "R46(L)" },
1946 { 396, "R46(U)" },
1947 { 400, "R47(L)" },
1948 { 404, "R47(U)" },
1949 { 408, "R48(L)" },
1950 { 412, "R48(U)" },
1951 { 416, "R49(L)" },
1952 { 420, "R49(U)" },
1953 { 424, "R50(L)" },
1954 { 428, "R50(U)" },
1955 { 432, "R51(L)" },
1956 { 436, "R51(U)" },
1957 { 440, "R52(L)" },
1958 { 444, "R52(U)" },
1959 { 448, "R53(L)" },
1960 { 452, "R53(U)" },
1961 { 456, "R54(L)" },
1962 { 460, "R54(U)" },
1963 { 464, "R55(L)" },
1964 { 468, "R55(U)" },
1965 { 472, "R56(L)" },
1966 { 476, "R56(U)" },
1967 { 480, "R57(L)" },
1968 { 484, "R57(U)" },
1969 { 488, "R58(L)" },
1970 { 492, "R58(U)" },
1971 { 496, "R59(L)" },
1972 { 500, "R59(U)" },
1973 { 504, "R60(L)" },
1974 { 508, "R60(U)" },
1975 { 512, "R61(L)" },
1976 { 516, "R61(U)" },
1977 { 520, "R62(L)" },
1978 { 524, "R62(U)" },
1979 { 528, "TR0(L)" },
1980 { 532, "TR0(U)" },
1981 { 536, "TR1(L)" },
1982 { 540, "TR1(U)" },
1983 { 544, "TR2(L)" },
1984 { 548, "TR2(U)" },
1985 { 552, "TR3(L)" },
1986 { 556, "TR3(U)" },
1987 { 560, "TR4(L)" },
1988 { 564, "TR4(U)" },
1989 { 568, "TR5(L)" },
1990 { 572, "TR5(U)" },
1991 { 576, "TR6(L)" },
1992 { 580, "TR6(U)" },
1993 { 584, "TR7(L)" },
1994 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00001995 /* This entry is in case pt_regs contains dregs (depends on
1996 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001997 { uoff(regs), "offsetof(struct user, regs)" },
1998 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001999# elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00002000 { uoff(regs.ARM_r0), "r0" },
2001 { uoff(regs.ARM_r1), "r1" },
2002 { uoff(regs.ARM_r2), "r2" },
2003 { uoff(regs.ARM_r3), "r3" },
2004 { uoff(regs.ARM_r4), "r4" },
2005 { uoff(regs.ARM_r5), "r5" },
2006 { uoff(regs.ARM_r6), "r6" },
2007 { uoff(regs.ARM_r7), "r7" },
2008 { uoff(regs.ARM_r8), "r8" },
2009 { uoff(regs.ARM_r9), "r9" },
2010 { uoff(regs.ARM_r10), "r10" },
2011 { uoff(regs.ARM_fp), "fp" },
2012 { uoff(regs.ARM_ip), "ip" },
2013 { uoff(regs.ARM_sp), "sp" },
2014 { uoff(regs.ARM_lr), "lr" },
2015 { uoff(regs.ARM_pc), "pc" },
2016 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00002017# elif defined(AVR32)
2018 { uoff(regs.sr), "sr" },
2019 { uoff(regs.pc), "pc" },
2020 { uoff(regs.lr), "lr" },
2021 { uoff(regs.sp), "sp" },
2022 { uoff(regs.r12), "r12" },
2023 { uoff(regs.r11), "r11" },
2024 { uoff(regs.r10), "r10" },
2025 { uoff(regs.r9), "r9" },
2026 { uoff(regs.r8), "r8" },
2027 { uoff(regs.r7), "r7" },
2028 { uoff(regs.r6), "r6" },
2029 { uoff(regs.r5), "r5" },
2030 { uoff(regs.r4), "r4" },
2031 { uoff(regs.r3), "r3" },
2032 { uoff(regs.r2), "r2" },
2033 { uoff(regs.r1), "r1" },
2034 { uoff(regs.r0), "r0" },
2035 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002036# elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00002037 { 0, "r0" },
2038 { 1, "r1" },
2039 { 2, "r2" },
2040 { 3, "r3" },
2041 { 4, "r4" },
2042 { 5, "r5" },
2043 { 6, "r6" },
2044 { 7, "r7" },
2045 { 8, "r8" },
2046 { 9, "r9" },
2047 { 10, "r10" },
2048 { 11, "r11" },
2049 { 12, "r12" },
2050 { 13, "r13" },
2051 { 14, "r14" },
2052 { 15, "r15" },
2053 { 16, "r16" },
2054 { 17, "r17" },
2055 { 18, "r18" },
2056 { 19, "r19" },
2057 { 20, "r20" },
2058 { 21, "r21" },
2059 { 22, "r22" },
2060 { 23, "r23" },
2061 { 24, "r24" },
2062 { 25, "r25" },
2063 { 26, "r26" },
2064 { 27, "r27" },
2065 { 28, "r28" },
2066 { 29, "r29" },
2067 { 30, "r30" },
2068 { 31, "r31" },
2069 { 32, "f0" },
2070 { 33, "f1" },
2071 { 34, "f2" },
2072 { 35, "f3" },
2073 { 36, "f4" },
2074 { 37, "f5" },
2075 { 38, "f6" },
2076 { 39, "f7" },
2077 { 40, "f8" },
2078 { 41, "f9" },
2079 { 42, "f10" },
2080 { 43, "f11" },
2081 { 44, "f12" },
2082 { 45, "f13" },
2083 { 46, "f14" },
2084 { 47, "f15" },
2085 { 48, "f16" },
2086 { 49, "f17" },
2087 { 50, "f18" },
2088 { 51, "f19" },
2089 { 52, "f20" },
2090 { 53, "f21" },
2091 { 54, "f22" },
2092 { 55, "f23" },
2093 { 56, "f24" },
2094 { 57, "f25" },
2095 { 58, "f26" },
2096 { 59, "f27" },
2097 { 60, "f28" },
2098 { 61, "f29" },
2099 { 62, "f30" },
2100 { 63, "f31" },
2101 { 64, "pc" },
2102 { 65, "cause" },
2103 { 66, "badvaddr" },
2104 { 67, "mmhi" },
2105 { 68, "mmlo" },
2106 { 69, "fpcsr" },
2107 { 70, "fpeir" },
Chris Metcalfc8c66982009-12-28 10:00:15 -05002108# elif defined(TILE)
2109 { PTREGS_OFFSET_REG(0), "r0" },
2110 { PTREGS_OFFSET_REG(1), "r1" },
2111 { PTREGS_OFFSET_REG(2), "r2" },
2112 { PTREGS_OFFSET_REG(3), "r3" },
2113 { PTREGS_OFFSET_REG(4), "r4" },
2114 { PTREGS_OFFSET_REG(5), "r5" },
2115 { PTREGS_OFFSET_REG(6), "r6" },
2116 { PTREGS_OFFSET_REG(7), "r7" },
2117 { PTREGS_OFFSET_REG(8), "r8" },
2118 { PTREGS_OFFSET_REG(9), "r9" },
2119 { PTREGS_OFFSET_REG(10), "r10" },
2120 { PTREGS_OFFSET_REG(11), "r11" },
2121 { PTREGS_OFFSET_REG(12), "r12" },
2122 { PTREGS_OFFSET_REG(13), "r13" },
2123 { PTREGS_OFFSET_REG(14), "r14" },
2124 { PTREGS_OFFSET_REG(15), "r15" },
2125 { PTREGS_OFFSET_REG(16), "r16" },
2126 { PTREGS_OFFSET_REG(17), "r17" },
2127 { PTREGS_OFFSET_REG(18), "r18" },
2128 { PTREGS_OFFSET_REG(19), "r19" },
2129 { PTREGS_OFFSET_REG(20), "r20" },
2130 { PTREGS_OFFSET_REG(21), "r21" },
2131 { PTREGS_OFFSET_REG(22), "r22" },
2132 { PTREGS_OFFSET_REG(23), "r23" },
2133 { PTREGS_OFFSET_REG(24), "r24" },
2134 { PTREGS_OFFSET_REG(25), "r25" },
2135 { PTREGS_OFFSET_REG(26), "r26" },
2136 { PTREGS_OFFSET_REG(27), "r27" },
2137 { PTREGS_OFFSET_REG(28), "r28" },
2138 { PTREGS_OFFSET_REG(29), "r29" },
2139 { PTREGS_OFFSET_REG(30), "r30" },
2140 { PTREGS_OFFSET_REG(31), "r31" },
2141 { PTREGS_OFFSET_REG(32), "r32" },
2142 { PTREGS_OFFSET_REG(33), "r33" },
2143 { PTREGS_OFFSET_REG(34), "r34" },
2144 { PTREGS_OFFSET_REG(35), "r35" },
2145 { PTREGS_OFFSET_REG(36), "r36" },
2146 { PTREGS_OFFSET_REG(37), "r37" },
2147 { PTREGS_OFFSET_REG(38), "r38" },
2148 { PTREGS_OFFSET_REG(39), "r39" },
2149 { PTREGS_OFFSET_REG(40), "r40" },
2150 { PTREGS_OFFSET_REG(41), "r41" },
2151 { PTREGS_OFFSET_REG(42), "r42" },
2152 { PTREGS_OFFSET_REG(43), "r43" },
2153 { PTREGS_OFFSET_REG(44), "r44" },
2154 { PTREGS_OFFSET_REG(45), "r45" },
2155 { PTREGS_OFFSET_REG(46), "r46" },
2156 { PTREGS_OFFSET_REG(47), "r47" },
2157 { PTREGS_OFFSET_REG(48), "r48" },
2158 { PTREGS_OFFSET_REG(49), "r49" },
2159 { PTREGS_OFFSET_REG(50), "r50" },
2160 { PTREGS_OFFSET_REG(51), "r51" },
2161 { PTREGS_OFFSET_REG(52), "r52" },
2162 { PTREGS_OFFSET_TP, "tp" },
2163 { PTREGS_OFFSET_SP, "sp" },
2164 { PTREGS_OFFSET_LR, "lr" },
2165 { PTREGS_OFFSET_PC, "pc" },
2166 { PTREGS_OFFSET_EX1, "ex1" },
2167 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2168 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2169 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002170# endif
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002171# ifdef CRISV10
2172 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2173 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2174 { 4*PT_R13, "4*PT_R13" },
2175 { 4*PT_R12, "4*PT_R12" },
2176 { 4*PT_R11, "4*PT_R11" },
2177 { 4*PT_R10, "4*PT_R10" },
2178 { 4*PT_R9, "4*PT_R9" },
2179 { 4*PT_R8, "4*PT_R8" },
2180 { 4*PT_R7, "4*PT_R7" },
2181 { 4*PT_R6, "4*PT_R6" },
2182 { 4*PT_R5, "4*PT_R5" },
2183 { 4*PT_R4, "4*PT_R4" },
2184 { 4*PT_R3, "4*PT_R3" },
2185 { 4*PT_R2, "4*PT_R2" },
2186 { 4*PT_R1, "4*PT_R1" },
2187 { 4*PT_R0, "4*PT_R0" },
2188 { 4*PT_MOF, "4*PT_MOF" },
2189 { 4*PT_DCCR, "4*PT_DCCR" },
2190 { 4*PT_SRP, "4*PT_SRP" },
2191 { 4*PT_IRP, "4*PT_IRP" },
2192 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2193 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2194 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2195 { 4*PT_USP, "4*PT_USP" },
2196# endif
2197# ifdef CRISV32
2198 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2199 { 4*PT_R0, "4*PT_R0" },
2200 { 4*PT_R1, "4*PT_R1" },
2201 { 4*PT_R2, "4*PT_R2" },
2202 { 4*PT_R3, "4*PT_R3" },
2203 { 4*PT_R4, "4*PT_R4" },
2204 { 4*PT_R5, "4*PT_R5" },
2205 { 4*PT_R6, "4*PT_R6" },
2206 { 4*PT_R7, "4*PT_R7" },
2207 { 4*PT_R8, "4*PT_R8" },
2208 { 4*PT_R9, "4*PT_R9" },
2209 { 4*PT_R10, "4*PT_R10" },
2210 { 4*PT_R11, "4*PT_R11" },
2211 { 4*PT_R12, "4*PT_R12" },
2212 { 4*PT_R13, "4*PT_R13" },
2213 { 4*PT_ACR, "4*PT_ACR" },
2214 { 4*PT_SRS, "4*PT_SRS" },
2215 { 4*PT_MOF, "4*PT_MOF" },
2216 { 4*PT_SPC, "4*PT_SPC" },
2217 { 4*PT_CCS, "4*PT_CCS" },
2218 { 4*PT_SRP, "4*PT_SRP" },
2219 { 4*PT_ERP, "4*PT_ERP" },
2220 { 4*PT_EXS, "4*PT_EXS" },
2221 { 4*PT_EDA, "4*PT_EDA" },
2222 { 4*PT_USP, "4*PT_USP" },
2223 { 4*PT_PPC, "4*PT_PPC" },
2224 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2225 { 4*PT_BP+4, "4*PT_BP+4" },
2226 { 4*PT_BP+8, "4*PT_BP+8" },
2227 { 4*PT_BP+12, "4*PT_BP+12" },
2228 { 4*PT_BP+16, "4*PT_BP+16" },
2229 { 4*PT_BP+20, "4*PT_BP+20" },
2230 { 4*PT_BP+24, "4*PT_BP+24" },
2231 { 4*PT_BP+28, "4*PT_BP+28" },
2232 { 4*PT_BP+32, "4*PT_BP+32" },
2233 { 4*PT_BP+36, "4*PT_BP+36" },
2234 { 4*PT_BP+40, "4*PT_BP+40" },
2235 { 4*PT_BP+44, "4*PT_BP+44" },
2236 { 4*PT_BP+48, "4*PT_BP+48" },
2237 { 4*PT_BP+52, "4*PT_BP+52" },
2238 { 4*PT_BP+56, "4*PT_BP+56" },
2239# endif
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002240# ifdef MICROBLAZE
2241 { PT_GPR(0), "r0" },
2242 { PT_GPR(1), "r1" },
2243 { PT_GPR(2), "r2" },
2244 { PT_GPR(3), "r3" },
2245 { PT_GPR(4), "r4" },
2246 { PT_GPR(5), "r5" },
2247 { PT_GPR(6), "r6" },
2248 { PT_GPR(7), "r7" },
2249 { PT_GPR(8), "r8" },
2250 { PT_GPR(9), "r9" },
2251 { PT_GPR(10), "r10" },
2252 { PT_GPR(11), "r11" },
2253 { PT_GPR(12), "r12" },
2254 { PT_GPR(13), "r13" },
2255 { PT_GPR(14), "r14" },
2256 { PT_GPR(15), "r15" },
2257 { PT_GPR(16), "r16" },
2258 { PT_GPR(17), "r17" },
2259 { PT_GPR(18), "r18" },
2260 { PT_GPR(19), "r19" },
2261 { PT_GPR(20), "r20" },
2262 { PT_GPR(21), "r21" },
2263 { PT_GPR(22), "r22" },
2264 { PT_GPR(23), "r23" },
2265 { PT_GPR(24), "r24" },
2266 { PT_GPR(25), "r25" },
2267 { PT_GPR(26), "r26" },
2268 { PT_GPR(27), "r27" },
2269 { PT_GPR(28), "r28" },
2270 { PT_GPR(29), "r29" },
2271 { PT_GPR(30), "r30" },
2272 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002273 { PT_PC, "rpc", },
2274 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002275 { PT_EAR, "rear", },
2276 { PT_ESR, "resr", },
2277 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002278 { PT_KERNEL_MODE, "kernel_mode", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002279# endif
Roland McGrath542c2c62008-05-20 01:11:56 +00002280
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002281# if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \
2282 && !defined(ALPHA) && !defined(IA64) \
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002283 && !defined(CRISV10) && !defined(CRISV32) && !defined(MICROBLAZE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05002284# if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(AVR32) && !defined(BFIN) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002285 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002286# endif
2287# if defined(I386) || defined(X86_64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002288 { uoff(i387), "offsetof(struct user, i387)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002289# endif
2290# if defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002291 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002292# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002293 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2294 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2295 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002296# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002297 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002298# endif
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00002299# if defined(AVR32) || defined(SH64)
Roland McGrathe1e584b2003-06-02 19:18:58 +00002300 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002301# endif
2302# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002303 { uoff(start_stack), "offsetof(struct user, start_stack)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002304# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002305 { uoff(signal), "offsetof(struct user, signal)" },
Chris Metcalfc8c66982009-12-28 10:00:15 -05002306# if !defined(AVR32) && !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SH) && !defined(SH64) && !defined(SPARC64) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002307 { uoff(reserved), "offsetof(struct user, reserved)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002308# endif
2309# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002310 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002311# endif
Chris Metcalfc8c66982009-12-28 10:00:15 -05002312# if !defined(ARM) && !defined(AVR32) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) && !defined(BFIN) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002313 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002314# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002315 { uoff(magic), "offsetof(struct user, magic)" },
2316 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002317# if defined(I386) || defined(X86_64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002318 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002319# endif
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002320# endif /* !defined(many arches) */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002321
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002322# ifndef HPPA
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002323 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002324# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002325 { 0, NULL },
2326};
2327
2328int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002329sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002330{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002331 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002332 long addr;
2333
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002334 if (entering(tcp)) {
Roland McGrathbf621d42003-01-14 09:46:21 +00002335 printxval(ptrace_cmds, tcp->u_arg[0],
Roland McGrathbf621d42003-01-14 09:46:21 +00002336 "PTRACE_???"
Roland McGrathbf621d42003-01-14 09:46:21 +00002337 );
2338 tprintf(", %lu, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002339 addr = tcp->u_arg[2];
2340 if (tcp->u_arg[0] == PTRACE_PEEKUSER
2341 || tcp->u_arg[0] == PTRACE_POKEUSER) {
2342 for (x = struct_user_offsets; x->str; x++) {
2343 if (x->val >= addr)
2344 break;
2345 }
2346 if (!x->str)
2347 tprintf("%#lx, ", addr);
2348 else if (x->val > addr && x != struct_user_offsets) {
2349 x--;
2350 tprintf("%s + %ld, ", x->str, addr - x->val);
2351 }
2352 else
2353 tprintf("%s, ", x->str);
2354 }
2355 else
2356 tprintf("%#lx, ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002357 switch (tcp->u_arg[0]) {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002358# ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002359 case PTRACE_PEEKDATA:
2360 case PTRACE_PEEKTEXT:
2361 case PTRACE_PEEKUSER:
2362 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002363# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002364 case PTRACE_CONT:
2365 case PTRACE_SINGLESTEP:
2366 case PTRACE_SYSCALL:
2367 case PTRACE_DETACH:
2368 printsignal(tcp->u_arg[3]);
2369 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002370# ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002371 case PTRACE_SETOPTIONS:
2372 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2373 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002374# endif
2375# ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002376 case PTRACE_SETSIGINFO: {
2377 siginfo_t si;
2378 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002379 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002380 else if (syserror(tcp))
2381 tprintf("%#lx", tcp->u_arg[3]);
2382 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002383 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002384 else
2385 printsiginfo(&si, verbose(tcp));
2386 break;
2387 }
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002388# endif
2389# ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002390 case PTRACE_GETSIGINFO:
2391 /* Don't print anything, do it at syscall return. */
2392 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002393# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002394 default:
2395 tprintf("%#lx", tcp->u_arg[3]);
2396 break;
2397 }
2398 } else {
2399 switch (tcp->u_arg[0]) {
2400 case PTRACE_PEEKDATA:
2401 case PTRACE_PEEKTEXT:
2402 case PTRACE_PEEKUSER:
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002403# ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002404 return RVAL_HEX;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002405# else
Roland McGratheb285352003-01-14 09:59:00 +00002406 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002407 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002408# endif
2409# ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002410 case PTRACE_GETSIGINFO: {
2411 siginfo_t si;
2412 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002413 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002414 else if (syserror(tcp))
2415 tprintf("%#lx", tcp->u_arg[3]);
2416 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002417 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002418 else
2419 printsiginfo(&si, verbose(tcp));
2420 break;
2421 }
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002422# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002423 }
2424 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002425 return 0;
2426}
2427
Roland McGrath51942a92007-07-05 18:59:11 +00002428# ifndef FUTEX_CMP_REQUEUE
2429# define FUTEX_CMP_REQUEUE 4
2430# endif
2431# ifndef FUTEX_WAKE_OP
2432# define FUTEX_WAKE_OP 5
2433# endif
2434# ifndef FUTEX_LOCK_PI
2435# define FUTEX_LOCK_PI 6
2436# define FUTEX_UNLOCK_PI 7
2437# define FUTEX_TRYLOCK_PI 8
2438# endif
Roland McGrath1aeaf742008-07-18 01:27:39 +00002439# ifndef FUTEX_WAIT_BITSET
2440# define FUTEX_WAIT_BITSET 9
2441# endif
2442# ifndef FUTEX_WAKE_BITSET
2443# define FUTEX_WAKE_BITSET 10
Roland McGrath51942a92007-07-05 18:59:11 +00002444# endif
Andreas Schwab85f58322009-08-12 09:54:42 +02002445# ifndef FUTEX_WAIT_REQUEUE_PI
2446# define FUTEX_WAIT_REQUEUE_PI 11
2447# endif
2448# ifndef FUTEX_CMP_REQUEUE_PI
2449# define FUTEX_CMP_REQUEUE_PI 12
2450# endif
Roland McGrath51942a92007-07-05 18:59:11 +00002451# ifndef FUTEX_PRIVATE_FLAG
2452# define FUTEX_PRIVATE_FLAG 128
2453# endif
Andreas Schwab85f58322009-08-12 09:54:42 +02002454# ifndef FUTEX_CLOCK_REALTIME
2455# define FUTEX_CLOCK_REALTIME 256
2456# endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002457static const struct xlat futexops[] = {
Roland McGrath51942a92007-07-05 18:59:11 +00002458 { FUTEX_WAIT, "FUTEX_WAIT" },
2459 { FUTEX_WAKE, "FUTEX_WAKE" },
2460 { FUTEX_FD, "FUTEX_FD" },
2461 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2462 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2463 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2464 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2465 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2466 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002467 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2468 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002469 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2470 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
Roland McGrath51942a92007-07-05 18:59:11 +00002471 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2472 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2473 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2474 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2475 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2476 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2477 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2478 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2479 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002480 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2481 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002482 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2483 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2484 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2485 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2486 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2487 { 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 +00002488 { 0, NULL }
2489};
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002490# ifndef FUTEX_OP_SET
2491# define FUTEX_OP_SET 0
2492# define FUTEX_OP_ADD 1
2493# define FUTEX_OP_OR 2
2494# define FUTEX_OP_ANDN 3
2495# define FUTEX_OP_XOR 4
2496# define FUTEX_OP_CMP_EQ 0
2497# define FUTEX_OP_CMP_NE 1
2498# define FUTEX_OP_CMP_LT 2
2499# define FUTEX_OP_CMP_LE 3
2500# define FUTEX_OP_CMP_GT 4
2501# define FUTEX_OP_CMP_GE 5
2502# endif
Roland McGrath51942a92007-07-05 18:59:11 +00002503static const struct xlat futexwakeops[] = {
2504 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2505 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2506 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2507 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2508 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2509 { 0, NULL }
2510};
2511static const struct xlat futexwakecmps[] = {
2512 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2513 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2514 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2515 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2516 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2517 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2518 { 0, NULL }
Roland McGrath5a223472002-12-15 23:58:26 +00002519};
2520
2521int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002522sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002523{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002524 if (entering(tcp)) {
2525 long int cmd = tcp->u_arg[1] & 127;
2526 tprintf("%p, ", (void *) tcp->u_arg[0]);
2527 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2528 tprintf(", %ld", tcp->u_arg[2]);
2529 if (cmd == FUTEX_WAKE_BITSET)
2530 tprintf(", %lx", tcp->u_arg[5]);
2531 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002532 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002533 printtv(tcp, tcp->u_arg[3]);
2534 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002535 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002536 printtv(tcp, tcp->u_arg[3]);
2537 tprintf(", %lx", tcp->u_arg[5]);
2538 } else if (cmd == FUTEX_REQUEUE)
2539 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002540 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002541 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2542 else if (cmd == FUTEX_WAKE_OP) {
2543 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2544 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002545 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002546 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2547 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2548 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002549 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002550 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2551 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002552 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002553 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002554 printtv(tcp, tcp->u_arg[3]);
2555 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002556 }
Roland McGrath51942a92007-07-05 18:59:11 +00002557 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002558 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002559}
2560
2561static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002562print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002563{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002564 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002565 unsigned long w, min_len;
2566
2567 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2568 min_len = len - max_strlen * sizeof(w);
2569 else
2570 min_len = 0;
2571 for (; len >= sizeof(w) && len > min_len;
2572 len -= sizeof(w), list += sizeof(w)) {
2573 if (umove(tcp, list, &w) < 0)
2574 break;
2575 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002576 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002577 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002578 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002579 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002580 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002581 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002582 if (len) {
2583 if (first)
2584 tprintf("%#lx", list);
2585 else
2586 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2587 "???" : "..."));
2588 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002589 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002590 }
Roland McGrath5a223472002-12-15 23:58:26 +00002591}
2592
2593int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002594sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002595{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002596 if (entering(tcp)) {
2597 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2598 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2599 }
2600 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002601}
2602
2603int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002604sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002605{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002606 if (entering(tcp)) {
2607 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2608 } else {
2609 if (tcp->u_rval == -1)
2610 tprintf("%#lx", tcp->u_arg[2]);
2611 else
2612 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2613 }
2614 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002615}
Roland McGrath279d3782004-03-01 20:27:37 +00002616
Dmitry V. Levin1b0bae22012-03-11 22:32:26 +00002617int
2618sys_get_robust_list(struct tcb *tcp)
2619{
2620 if (entering(tcp)) {
2621 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2622 } else {
2623 void *addr;
2624 size_t len;
2625
2626 if (syserror(tcp) ||
2627 !tcp->u_arg[1] ||
2628 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2629 tprintf("%#lx, ", tcp->u_arg[1]);
2630 } else {
2631 tprintf("[%p], ", addr);
2632 }
2633
2634 if (syserror(tcp) ||
2635 !tcp->u_arg[2] ||
2636 umove(tcp, tcp->u_arg[2], &len) < 0) {
2637 tprintf("%#lx", tcp->u_arg[2]);
2638 } else {
2639 tprintf("[%lu]", (unsigned long) len);
2640 }
2641 }
2642 return 0;
2643}
2644
Roland McGrathd9f816f2004-09-04 03:39:20 +00002645static const struct xlat schedulers[] = {
Roland McGrath279d3782004-03-01 20:27:37 +00002646 { SCHED_OTHER, "SCHED_OTHER" },
2647 { SCHED_RR, "SCHED_RR" },
2648 { SCHED_FIFO, "SCHED_FIFO" },
2649 { 0, NULL }
2650};
2651
2652int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002653sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002654{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002655 if (entering(tcp)) {
2656 tprintf("%d", (int) tcp->u_arg[0]);
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002657 } else if (!syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002658 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002659 if (tcp->auxstr != NULL)
2660 return RVAL_STR;
2661 }
2662 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002663}
2664
2665int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002666sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002667{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002668 if (entering(tcp)) {
2669 struct sched_param p;
2670 tprintf("%d, ", (int) tcp->u_arg[0]);
2671 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2672 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2673 tprintf(", %#lx", tcp->u_arg[2]);
2674 else
2675 tprintf(", { %d }", p.__sched_priority);
2676 }
2677 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002678}
2679
2680int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002681sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002682{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002683 if (entering(tcp)) {
2684 tprintf("%d, ", (int) tcp->u_arg[0]);
2685 } else {
2686 struct sched_param p;
2687 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2688 tprintf("%#lx", tcp->u_arg[1]);
2689 else
2690 tprintf("{ %d }", p.__sched_priority);
2691 }
2692 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002693}
2694
2695int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002696sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002697{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002698 if (entering(tcp)) {
2699 struct sched_param p;
2700 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2701 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2702 else
2703 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2704 }
2705 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002706}
2707
2708int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002709sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002710{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002711 if (entering(tcp)) {
2712 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2713 }
2714 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002715}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002716
Dmitry V. Levin1ff463d2012-03-11 23:00:11 +00002717int
2718sys_sched_rr_get_interval(struct tcb *tcp)
2719{
2720 if (entering(tcp)) {
2721 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2722 } else {
2723 if (syserror(tcp))
2724 tprintf("%#lx", tcp->u_arg[1]);
2725 else
2726 print_timespec(tcp, tcp->u_arg[1]);
2727 }
2728 return 0;
2729}
2730
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002731# ifdef X86_64
2732# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002733
2734static const struct xlat archvals[] = {
2735 { ARCH_SET_GS, "ARCH_SET_GS" },
2736 { ARCH_SET_FS, "ARCH_SET_FS" },
2737 { ARCH_GET_FS, "ARCH_GET_FS" },
2738 { ARCH_GET_GS, "ARCH_GET_GS" },
2739 { 0, NULL },
2740};
2741
2742int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002743sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002744{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002745 if (entering(tcp)) {
2746 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2747 if (tcp->u_arg[0] == ARCH_SET_GS
2748 || tcp->u_arg[0] == ARCH_SET_FS
2749 ) {
2750 tprintf(", %#lx", tcp->u_arg[1]);
2751 }
2752 } else {
2753 if (tcp->u_arg[0] == ARCH_GET_GS
2754 || tcp->u_arg[0] == ARCH_GET_FS
2755 ) {
2756 long int v;
2757 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2758 tprintf(", [%#lx]", v);
2759 else
2760 tprintf(", %#lx", tcp->u_arg[1]);
2761 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002762 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002763 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002764}
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002765# endif /* X86_64 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002766
Roland McGrathdb8319f2007-08-02 01:37:55 +00002767int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002768sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002769{
2770 if (exiting(tcp)) {
2771 unsigned u;
2772 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002773 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002774 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2775 tprintf("%#lx, ", tcp->u_arg[0]);
2776 else
2777 tprintf("[%u], ", u);
2778 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002779 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002780 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2781 tprintf("%#lx, ", tcp->u_arg[1]);
2782 else
2783 tprintf("[%u], ", u);
2784 tprintf("%#lx", tcp->u_arg[2]);
2785 }
2786 return 0;
2787}
2788
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002789int
2790sys_process_vm_readv(struct tcb *tcp)
2791{
2792 if (entering(tcp)) {
2793 /* arg 1: pid */
2794 tprintf("%ld, ", tcp->u_arg[0]);
2795 } else {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002796 /* arg 2: local iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002797 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002798 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002799 } else {
2800 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2801 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002802 /* arg 3: local iovcnt */
2803 tprintf(", %lu, ", tcp->u_arg[2]);
2804 /* arg 4: remote iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002805 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002806 tprintf("%#lx", tcp->u_arg[3]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002807 } else {
2808 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2809 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002810 /* arg 5: remote iovcnt */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002811 /* arg 6: flags */
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002812 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002813 }
2814 return 0;
2815}
Dmitry V. Levin03952102012-03-10 14:14:49 +00002816
2817int
2818sys_process_vm_writev(struct tcb *tcp)
2819{
2820 if (entering(tcp)) {
2821 /* arg 1: pid */
2822 tprintf("%ld, ", tcp->u_arg[0]);
2823 /* arg 2: local iov */
2824 if (syserror(tcp))
2825 tprintf("%#lx", tcp->u_arg[1]);
2826 else
2827 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2828 /* arg 3: local iovcnt */
2829 tprintf(", %lu, ", tcp->u_arg[2]);
2830 /* arg 4: remote iov */
2831 if (syserror(tcp))
2832 tprintf("%#lx", tcp->u_arg[3]);
2833 else
2834 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2835 /* arg 5: remote iovcnt */
2836 /* arg 6: flags */
2837 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
2838 }
2839 return 0;
2840}