blob: 699355bfe7f8505b39e5eb3c960a2ba371bebfb6 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Linux for s390 port by D.J. Barrow
8 * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
Wichert Akkermanccef6372002-05-01 16:39:22 +00009 * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH
10 * port by Greg Banks <gbanks@pocketpenguins.com>
11
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +000012 *
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000013 * All rights reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. The name of the author may not be used to endorse or promote products
24 * derived from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * $Id$
38 */
39
40#include "defs.h"
41
42#include <fcntl.h>
43#include <sys/stat.h>
44#include <sys/time.h>
45#include <sys/wait.h>
46#include <sys/resource.h>
47#include <sys/utsname.h>
48#include <sys/user.h>
49#include <sys/syscall.h>
50#include <signal.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000051
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000052
Wichert Akkerman36915a11999-07-13 15:45:02 +000053#ifdef HAVE_SYS_REG_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000054# include <sys/reg.h>
Wichert Akkerman15dea971999-10-06 13:06:34 +000055#ifndef PTRACE_PEEKUSR
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000056# define PTRACE_PEEKUSR PTRACE_PEEKUSER
Wichert Akkerman15dea971999-10-06 13:06:34 +000057#endif
58#ifndef PTRACE_POKEUSR
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000059# define PTRACE_POKEUSR PTRACE_POKEUSER
60#endif
Wichert Akkerman15dea971999-10-06 13:06:34 +000061#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000062
Roland McGrath5bd7cf82003-01-24 04:31:18 +000063#ifdef HAVE_LINUX_PTRACE_H
64#undef PTRACE_SYSCALL
Roland McGrathfb1bc072004-03-01 21:29:24 +000065# ifdef HAVE_STRUCT_IA64_FPREG
66# define ia64_fpreg XXX_ia64_fpreg
67# endif
68# ifdef HAVE_STRUCT_PT_ALL_USER_REGS
69# define pt_all_user_regs XXX_pt_all_user_regs
70# endif
Roland McGrath5bd7cf82003-01-24 04:31:18 +000071#include <linux/ptrace.h>
Roland McGrathfb1bc072004-03-01 21:29:24 +000072# undef ia64_fpreg
73# undef pt_all_user_regs
Roland McGrath5bd7cf82003-01-24 04:31:18 +000074#endif
75
Roland McGrath6d1a65c2004-07-12 07:44:08 +000076#if defined (LINUX) && defined (SPARC64)
77# define r_pc r_tpc
78# undef PTRACE_GETREGS
79# define PTRACE_GETREGS PTRACE_GETREGS64
80# undef PTRACE_SETREGS
81# define PTRACE_SETREGS PTRACE_SETREGS64
82#endif /* LINUX && SPARC64 */
83
Roland McGrath5a223472002-12-15 23:58:26 +000084#ifdef HAVE_LINUX_FUTEX_H
Dmitry V. Levine5e60852009-12-31 22:50:49 +000085# include <linux/futex.h>
Roland McGrath5a223472002-12-15 23:58:26 +000086#endif
Roland McGrath5a223472002-12-15 23:58:26 +000087# ifndef FUTEX_WAIT
88# define FUTEX_WAIT 0
89# endif
90# ifndef FUTEX_WAKE
91# define FUTEX_WAKE 1
92# endif
93# ifndef FUTEX_FD
94# define FUTEX_FD 2
95# endif
Roland McGrath88812d62003-06-26 22:27:23 +000096# ifndef FUTEX_REQUEUE
97# define FUTEX_REQUEUE 3
98# endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000099
Roland McGrath279d3782004-03-01 20:27:37 +0000100#include <sched.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000101#include <asm/posix_types.h>
102#undef GETGROUPS_T
103#define GETGROUPS_T __kernel_gid_t
Roland McGrath83bd47a2003-11-13 22:32:26 +0000104#undef GETGROUPS32_T
105#define GETGROUPS32_T __kernel_gid32_t
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000106
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000107#if defined(LINUX) && defined(IA64)
108# include <asm/ptrace_offsets.h>
109# include <asm/rse.h>
110#endif
111
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000112#ifdef HAVE_PRCTL
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000113# include <sys/prctl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000114
Roland McGrathd9f816f2004-09-04 03:39:20 +0000115static const struct xlat prctl_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000116#ifdef PR_MAXPROCS
117 { PR_MAXPROCS, "PR_MAXPROCS" },
118#endif
119#ifdef PR_ISBLOCKED
120 { PR_ISBLOCKED, "PR_ISBLOCKED" },
121#endif
122#ifdef PR_SETSTACKSIZE
123 { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" },
124#endif
125#ifdef PR_GETSTACKSIZE
126 { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" },
127#endif
128#ifdef PR_MAXPPROCS
129 { PR_MAXPPROCS, "PR_MAXPPROCS" },
130#endif
131#ifdef PR_UNBLKONEXEC
132 { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" },
133#endif
134#ifdef PR_ATOMICSIM
135 { PR_ATOMICSIM, "PR_ATOMICSIM" },
136#endif
137#ifdef PR_SETEXITSIG
138 { PR_SETEXITSIG, "PR_SETEXITSIG" },
139#endif
140#ifdef PR_RESIDENT
141 { PR_RESIDENT, "PR_RESIDENT" },
142#endif
143#ifdef PR_ATTACHADDR
144 { PR_ATTACHADDR, "PR_ATTACHADDR" },
145#endif
146#ifdef PR_DETACHADDR
147 { PR_DETACHADDR, "PR_DETACHADDR" },
148#endif
149#ifdef PR_TERMCHILD
150 { PR_TERMCHILD, "PR_TERMCHILD" },
151#endif
152#ifdef PR_GETSHMASK
153 { PR_GETSHMASK, "PR_GETSHMASK" },
154#endif
155#ifdef PR_GETNSHARE
156 { PR_GETNSHARE, "PR_GETNSHARE" },
157#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +0000158#ifdef PR_COREPID
159 { PR_COREPID, "PR_COREPID" },
160#endif
161#ifdef PR_ATTACHADDRPERM
162 { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" },
163#endif
164#ifdef PR_PTHREADEXIT
165 { PR_PTHREADEXIT, "PR_PTHREADEXIT" },
166#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000167#ifdef PR_SET_PDEATHSIG
168 { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
169#endif
170#ifdef PR_GET_PDEATHSIG
171 { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
172#endif
Dmitry V. Levinf02cf212008-09-03 00:54:40 +0000173#ifdef PR_GET_DUMPABLE
174 { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" },
175#endif
176#ifdef PR_SET_DUMPABLE
177 { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" },
178#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000179#ifdef PR_GET_UNALIGN
180 { PR_GET_UNALIGN, "PR_GET_UNALIGN" },
181#endif
182#ifdef PR_SET_UNALIGN
183 { PR_SET_UNALIGN, "PR_SET_UNALIGN" },
184#endif
185#ifdef PR_GET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000186 { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000187#endif
188#ifdef PR_SET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000189 { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000190#endif
Roland McGrathe5039fb2007-11-03 23:58:07 +0000191#ifdef PR_GET_FPEMU
192 { PR_GET_FPEMU, "PR_GET_FPEMU" },
193#endif
194#ifdef PR_SET_FPEMU
195 { PR_SET_FPEMU, "PR_SET_FPEMU" },
196#endif
197#ifdef PR_GET_FPEXC
198 { PR_GET_FPEXC, "PR_GET_FPEXC" },
199#endif
200#ifdef PR_SET_FPEXC
201 { PR_SET_FPEXC, "PR_SET_FPEXC" },
202#endif
203#ifdef PR_GET_TIMING
204 { PR_GET_TIMING, "PR_GET_TIMING" },
205#endif
206#ifdef PR_SET_TIMING
207 { PR_SET_TIMING, "PR_SET_TIMING" },
208#endif
209#ifdef PR_SET_NAME
210 { PR_SET_NAME, "PR_SET_NAME" },
211#endif
212#ifdef PR_GET_NAME
213 { PR_GET_NAME, "PR_GET_NAME" },
214#endif
215#ifdef PR_GET_ENDIAN
216 { PR_GET_ENDIAN, "PR_GET_ENDIAN" },
217#endif
218#ifdef PR_SET_ENDIAN
219 { PR_SET_ENDIAN, "PR_SET_ENDIAN" },
220#endif
221#ifdef PR_GET_SECCOMP
222 { PR_GET_SECCOMP, "PR_GET_SECCOMP" },
223#endif
224#ifdef PR_SET_SECCOMP
225 { PR_SET_SECCOMP, "PR_SET_SECCOMP" },
226#endif
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000227#ifdef PR_GET_TSC
228 { PR_GET_TSC, "PR_GET_TSC" },
229#endif
230#ifdef PR_SET_TSC
231 { PR_SET_TSC, "PR_SET_TSC" },
232#endif
233#ifdef PR_GET_SECUREBITS
234 { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" },
235#endif
236#ifdef PR_SET_SECUREBITS
237 { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" },
238#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000239 { 0, NULL },
240};
241
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000242
Roland McGratha4d48532005-06-08 20:45:28 +0000243static const char *
Denys Vlasenko12014262011-05-30 14:00:14 +0200244unalignctl_string(unsigned int ctl)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000245{
246 static char buf[16];
247
248 switch (ctl) {
249#ifdef PR_UNALIGN_NOPRINT
250 case PR_UNALIGN_NOPRINT:
251 return "NOPRINT";
252#endif
253#ifdef PR_UNALIGN_SIGBUS
254 case PR_UNALIGN_SIGBUS:
255 return "SIGBUS";
256#endif
257 default:
258 break;
259 }
260 sprintf(buf, "%x", ctl);
261 return buf;
262}
263
264
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000265int
Denys Vlasenko12014262011-05-30 14:00:14 +0200266sys_prctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000267{
268 int i;
269
270 if (entering(tcp)) {
271 printxval(prctl_options, tcp->u_arg[0], "PR_???");
272 switch (tcp->u_arg[0]) {
273#ifdef PR_GETNSHARE
274 case PR_GETNSHARE:
275 break;
276#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000277#ifdef PR_SET_PDEATHSIG
278 case PR_SET_PDEATHSIG:
279 tprintf(", %lu", tcp->u_arg[1]);
280 break;
281#endif
282#ifdef PR_GET_PDEATHSIG
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000283 case PR_GET_PDEATHSIG:
284 break;
285#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000286#ifdef PR_SET_DUMPABLE
287 case PR_SET_DUMPABLE:
288 tprintf(", %lu", tcp->u_arg[1]);
289 break;
290#endif
291#ifdef PR_GET_DUMPABLE
292 case PR_GET_DUMPABLE:
293 break;
294#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000295#ifdef PR_SET_UNALIGN
296 case PR_SET_UNALIGN:
297 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
298 break;
299#endif
300#ifdef PR_GET_UNALIGN
301 case PR_GET_UNALIGN:
302 tprintf(", %#lx", tcp->u_arg[1]);
303 break;
304#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000305#ifdef PR_SET_KEEPCAPS
306 case PR_SET_KEEPCAPS:
307 tprintf(", %lu", tcp->u_arg[1]);
308 break;
309#endif
310#ifdef PR_GET_KEEPCAPS
311 case PR_GET_KEEPCAPS:
312 break;
313#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000314 default:
315 for (i = 1; i < tcp->u_nargs; i++)
316 tprintf(", %#lx", tcp->u_arg[i]);
317 break;
318 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000319 } else {
320 switch (tcp->u_arg[0]) {
321#ifdef PR_GET_PDEATHSIG
322 case PR_GET_PDEATHSIG:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000323 if (umove(tcp, tcp->u_arg[1], &i) < 0)
324 tprintf(", %#lx", tcp->u_arg[1]);
325 else
326 tprintf(", {%u}", i);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000327 break;
328#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000329#ifdef PR_GET_DUMPABLE
330 case PR_GET_DUMPABLE:
331 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000332#endif
333#ifdef PR_GET_UNALIGN
334 case PR_GET_UNALIGN:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000335 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
336 break;
337 tcp->auxstr = unalignctl_string(i);
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000338 return RVAL_STR;
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000339#endif
340#ifdef PR_GET_KEEPCAPS
341 case PR_GET_KEEPCAPS:
342 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000343#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000344 default:
345 break;
346 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000347 }
348 return 0;
349}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000350#endif /* HAVE_PRCTL */
351
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000352
353int
Denys Vlasenko12014262011-05-30 14:00:14 +0200354sys_sethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000355{
356 if (entering(tcp)) {
357 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
358 tprintf(", %lu", tcp->u_arg[1]);
359 }
360 return 0;
361}
362
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +0000363#if defined(ALPHA) || defined(FREEBSD) || defined(SUNOS4) || defined(SVR4)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000364int
Denys Vlasenko12014262011-05-30 14:00:14 +0200365sys_gethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000366{
367 if (exiting(tcp)) {
368 if (syserror(tcp))
369 tprintf("%#lx", tcp->u_arg[0]);
370 else
371 printpath(tcp, tcp->u_arg[0]);
372 tprintf(", %lu", tcp->u_arg[1]);
373 }
374 return 0;
375}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +0000376#endif /* ALPHA || FREEBSD || SUNOS4 || SVR4 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000377
378int
Denys Vlasenko12014262011-05-30 14:00:14 +0200379sys_setdomainname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000380{
381 if (entering(tcp)) {
382 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
383 tprintf(", %lu", tcp->u_arg[1]);
384 }
385 return 0;
386}
387
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000388
389int
Denys Vlasenko12014262011-05-30 14:00:14 +0200390sys_exit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000391{
392 if (exiting(tcp)) {
393 fprintf(stderr, "_exit returned!\n");
394 return -1;
395 }
396 /* special case: we stop tracing this process, finish line now */
397 tprintf("%ld) ", tcp->u_arg[0]);
Denys Vlasenko102ec492011-08-25 01:27:59 +0200398 tabto();
Denys Vlasenko000b6012012-01-28 01:25:03 +0100399 tprints("= ?\n");
400 printing_tcp = NULL;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000401 return 0;
402}
403
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000404
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000405
406/* defines copied from linux/sched.h since we can't include that
407 * ourselves (it conflicts with *lots* of libc includes)
408 */
409#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
410#define CLONE_VM 0x00000100 /* set if VM shared between processes */
411#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
412#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
413#define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
Roland McGrath909875b2002-12-22 03:34:36 +0000414#define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000415#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
416#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
417#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
Roland McGrath909875b2002-12-22 03:34:36 +0000418#define CLONE_THREAD 0x00010000 /* Same thread group? */
419#define CLONE_NEWNS 0x00020000 /* New namespace group? */
420#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
421#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
422#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
423#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
Roland McGrath909875b2002-12-22 03:34:36 +0000424#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
425#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000426#define CLONE_STOPPED 0x02000000 /* Start in stopped state */
427#define CLONE_NEWUTS 0x04000000 /* New utsname group? */
428#define CLONE_NEWIPC 0x08000000 /* New ipcs */
429#define CLONE_NEWUSER 0x10000000 /* New user namespace */
430#define CLONE_NEWPID 0x20000000 /* New pid namespace */
431#define CLONE_NEWNET 0x40000000 /* New network namespace */
432#define CLONE_IO 0x80000000 /* Clone io context */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000433
Roland McGrathd9f816f2004-09-04 03:39:20 +0000434static const struct xlat clone_flags[] = {
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000435 { CLONE_VM, "CLONE_VM" },
436 { CLONE_FS, "CLONE_FS" },
437 { CLONE_FILES, "CLONE_FILES" },
438 { CLONE_SIGHAND, "CLONE_SIGHAND" },
Roland McGrath909875b2002-12-22 03:34:36 +0000439 { CLONE_IDLETASK, "CLONE_IDLETASK"},
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000440 { CLONE_PTRACE, "CLONE_PTRACE" },
441 { CLONE_VFORK, "CLONE_VFORK" },
442 { CLONE_PARENT, "CLONE_PARENT" },
Roland McGrath909875b2002-12-22 03:34:36 +0000443 { CLONE_THREAD, "CLONE_THREAD" },
444 { CLONE_NEWNS, "CLONE_NEWNS" },
445 { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
446 { CLONE_SETTLS, "CLONE_SETTLS" },
447 { CLONE_PARENT_SETTID,"CLONE_PARENT_SETTID" },
448 { CLONE_CHILD_CLEARTID,"CLONE_CHILD_CLEARTID" },
Roland McGrath909875b2002-12-22 03:34:36 +0000449 { CLONE_UNTRACED, "CLONE_UNTRACED" },
450 { CLONE_CHILD_SETTID,"CLONE_CHILD_SETTID" },
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000451 { CLONE_STOPPED, "CLONE_STOPPED" },
452 { CLONE_NEWUTS, "CLONE_NEWUTS" },
453 { CLONE_NEWIPC, "CLONE_NEWIPC" },
454 { CLONE_NEWUSER, "CLONE_NEWUSER" },
455 { CLONE_NEWPID, "CLONE_NEWPID" },
456 { CLONE_NEWNET, "CLONE_NEWNET" },
457 { CLONE_IO, "CLONE_IO" },
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000458 { 0, NULL },
459};
460
Roland McGrath909875b2002-12-22 03:34:36 +0000461# ifdef I386
462# include <asm/ldt.h>
Roland McGrath7decfb22004-03-01 22:10:52 +0000463# ifdef HAVE_STRUCT_USER_DESC
464# define modify_ldt_ldt_s user_desc
465# endif
Roland McGrath909875b2002-12-22 03:34:36 +0000466extern void print_ldt_entry();
467# endif
468
Roland McGrath9677b3a2003-03-12 09:54:36 +0000469# if defined IA64
470# define ARG_FLAGS 0
471# define ARG_STACK 1
Dmitry V. Levin44824b92012-02-20 21:44:53 +0000472# define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
473# define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
474# define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
475# define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +0000476# elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
Roland McGrath9677b3a2003-03-12 09:54:36 +0000477# define ARG_STACK 0
478# define ARG_FLAGS 1
479# define ARG_PTID 2
Roland McGrathfe5fdb22003-05-23 00:29:05 +0000480# define ARG_CTID 3
481# define ARG_TLS 4
Roland McGrath9c555e72003-07-09 09:47:59 +0000482# elif defined X86_64 || defined ALPHA
Roland McGrath361aac52003-03-18 07:43:42 +0000483# define ARG_FLAGS 0
484# define ARG_STACK 1
485# define ARG_PTID 2
486# define ARG_CTID 3
487# define ARG_TLS 4
Roland McGrath9677b3a2003-03-12 09:54:36 +0000488# else
489# define ARG_FLAGS 0
490# define ARG_STACK 1
491# define ARG_PTID 2
492# define ARG_TLS 3
493# define ARG_CTID 4
494# endif
495
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000496int
Denys Vlasenko12014262011-05-30 14:00:14 +0200497sys_clone(struct tcb *tcp)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000498{
499 if (exiting(tcp)) {
Wang Chaocbdd1902010-09-02 15:08:59 +0800500 const char *sep = "|";
Roland McGrath9677b3a2003-03-12 09:54:36 +0000501 unsigned long flags = tcp->u_arg[ARG_FLAGS];
502 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
503# ifdef ARG_STACKSIZE
504 if (ARG_STACKSIZE != -1)
505 tprintf("stack_size=%#lx, ",
506 tcp->u_arg[ARG_STACKSIZE]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000507# endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200508 tprints("flags=");
Wang Chaocbdd1902010-09-02 15:08:59 +0800509 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
510 sep = "";
Roland McGrath984154d2003-05-23 01:08:42 +0000511 if ((flags & CSIGNAL) != 0)
Wang Chaocbdd1902010-09-02 15:08:59 +0800512 tprintf("%s%s", sep, signame(flags & CSIGNAL));
Roland McGrathb4968be2003-01-20 09:04:33 +0000513 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
Roland McGrath9677b3a2003-03-12 09:54:36 +0000514 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
Roland McGrath909875b2002-12-22 03:34:36 +0000515 return 0;
Roland McGrath6f67a982003-03-21 07:33:15 +0000516 if (flags & CLONE_PARENT_SETTID)
517 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000518 if (flags & CLONE_SETTLS) {
Roland McGrath9677b3a2003-03-12 09:54:36 +0000519# ifdef I386
Roland McGrath909875b2002-12-22 03:34:36 +0000520 struct modify_ldt_ldt_s copy;
Roland McGrath9677b3a2003-03-12 09:54:36 +0000521 if (umove(tcp, tcp->u_arg[ARG_TLS], &copy) != -1) {
Roland McGrath909875b2002-12-22 03:34:36 +0000522 tprintf(", {entry_number:%d, ",
523 copy.entry_number);
524 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200525 tprints("...}");
Roland McGrath909875b2002-12-22 03:34:36 +0000526 else
527 print_ldt_entry(&copy);
528 }
529 else
Roland McGrath9677b3a2003-03-12 09:54:36 +0000530# endif
Roland McGrath43f2c842003-03-12 09:58:14 +0000531 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
Roland McGrath909875b2002-12-22 03:34:36 +0000532 }
Roland McGrath9677b3a2003-03-12 09:54:36 +0000533 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
534 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000535 }
536 return 0;
537}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000538
539int
540sys_unshare(struct tcb *tcp)
541{
542 if (entering(tcp))
543 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
544 return 0;
545}
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000546
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000547int
Denys Vlasenko12014262011-05-30 14:00:14 +0200548sys_fork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000549{
550 if (exiting(tcp))
551 return RVAL_UDECIMAL;
552 return 0;
553}
554
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000555int
Denys Vlasenko418d66a2009-01-17 01:52:54 +0000556change_syscall(struct tcb *tcp, int new)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000557{
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000558#if defined(I386)
559 /* Attempt to make vfork into fork, which we can follow. */
Roland McGrath5a223472002-12-15 23:58:26 +0000560 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000561 return -1;
562 return 0;
Michal Ludvig0e035502002-09-23 15:41:01 +0000563#elif defined(X86_64)
564 /* Attempt to make vfork into fork, which we can follow. */
Roland McGrath5a223472002-12-15 23:58:26 +0000565 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_RAX * 8), new) < 0)
Michal Ludvig0e035502002-09-23 15:41:01 +0000566 return -1;
567 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000568#elif defined(POWERPC)
Roland McGratheb285352003-01-14 09:59:00 +0000569 if (ptrace(PTRACE_POKEUSER, tcp->pid,
570 (char*)(sizeof(unsigned long)*PT_R0), new) < 0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000571 return -1;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000572 return 0;
Michal Ludvig10a88d02002-10-07 14:31:00 +0000573#elif defined(S390) || defined(S390X)
574 /* s390 linux after 2.4.7 has a hook in entry.S to allow this */
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200575 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR2), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000576 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000577 return 0;
578#elif defined(M68K)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200579 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_ORIG_D0), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000580 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000581 return 0;
Roland McGrath6d1a65c2004-07-12 07:44:08 +0000582#elif defined(SPARC) || defined(SPARC64)
Mike Frysinger8566c502009-10-12 11:05:14 -0400583 struct pt_regs regs;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200584 if (ptrace(PTRACE_GETREGS, tcp->pid, (char*)&regs, 0) < 0)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000585 return -1;
Mike Frysinger8566c502009-10-12 11:05:14 -0400586 regs.u_regs[U_REG_G1] = new;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200587 if (ptrace(PTRACE_SETREGS, tcp->pid, (char*)&regs, 0) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000588 return -1;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000589 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000590#elif defined(MIPS)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200591 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000592 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000593 return 0;
594#elif defined(ALPHA)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200595 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000596 return -1;
597 return 0;
598#elif defined(AVR32)
599 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_R8), new) < 0)
600 return -1;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000601 return 0;
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000602#elif defined(BFIN)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200603 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_P0), new) < 0)
Dmitry V. Levin87ea1f42008-11-10 22:21:41 +0000604 return -1;
605 return 0;
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000606#elif defined(IA64)
Roland McGrath08267b82004-02-20 22:56:43 +0000607 if (ia32) {
608 switch (new) {
Denys Vlasenko418d66a2009-01-17 01:52:54 +0000609 case 2:
610 break; /* x86 SYS_fork */
611 case SYS_clone:
612 new = 120;
613 break;
614 default:
Roland McGrath08267b82004-02-20 22:56:43 +0000615 fprintf(stderr, "%s: unexpected syscall %d\n",
616 __FUNCTION__, new);
617 return -1;
618 }
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200619 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R1), new) < 0)
Roland McGrath08267b82004-02-20 22:56:43 +0000620 return -1;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200621 } else if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R15), new) < 0)
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000622 return -1;
623 return 0;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000624#elif defined(HPPA)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200625 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR20), new) < 0)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000626 return -1;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000627 return 0;
Wichert Akkermanccef6372002-05-01 16:39:22 +0000628#elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200629 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*(REG_REG0+3)), new) < 0)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000630 return -1;
631 return 0;
Roland McGrathf5a47772003-06-26 22:40:42 +0000632#elif defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000633 /* Top half of reg encodes the no. of args n as 0x1n.
634 Assume 0 args as kernel never actually checks... */
635 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_SYSCALL),
636 0x100000 | new) < 0)
637 return -1;
638 return 0;
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +0000639#elif defined(CRISV10) || defined(CRISV32)
640 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R9), new) < 0)
641 return -1;
642 return 0;
Roland McGrathf691bd22006-04-25 07:34:41 +0000643#elif defined(ARM)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000644 /* Some kernels support this, some (pre-2.6.16 or so) don't. */
Roland McGrathf691bd22006-04-25 07:34:41 +0000645# ifndef PTRACE_SET_SYSCALL
646# define PTRACE_SET_SYSCALL 23
647# endif
648
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200649 if (ptrace(PTRACE_SET_SYSCALL, tcp->pid, 0, new & 0xffff) != 0)
Roland McGrathf691bd22006-04-25 07:34:41 +0000650 return -1;
651
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000652 return 0;
Chris Metcalfc8c66982009-12-28 10:00:15 -0500653#elif defined(TILE)
654 if (ptrace(PTRACE_POKEUSER, tcp->pid,
655 (char*)PTREGS_OFFSET_REG(0),
656 new) != 0)
657 return -1;
658 return 0;
Edgar E. Iglesias939caba2010-07-06 14:21:07 +0200659#elif defined(MICROBLAZE)
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200660 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new) < 0)
Edgar E. Iglesias939caba2010-07-06 14:21:07 +0200661 return -1;
662 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000663#else
664#warning Do not know how to handle change_syscall for this architecture
665#endif /* architecture */
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000666 return -1;
667}
668
Wang Chaoca8ab8d2010-11-12 17:26:08 +0800669
670int
Dmitry V. Levin257e1572009-12-26 17:55:24 +0000671internal_fork(struct tcb *tcp)
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000672{
Denys Vlasenkof44cce42011-06-21 14:34:10 +0200673 if ((ptrace_setoptions
Wang Chaoca8ab8d2010-11-12 17:26:08 +0800674 & (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
675 == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
676 return 0;
677
Denys Vlasenko65d7c4d2011-06-23 21:46:37 +0200678 if (!followfork)
679 return 0;
680
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000681 if (entering(tcp)) {
Wang Chaoe636c852010-09-16 11:20:56 +0800682 /*
Denys Vlasenko833fb132011-08-17 11:30:56 +0200683 * We won't see the new child if clone is called with
684 * CLONE_UNTRACED, so we keep the same logic with that option
685 * and don't trace it.
Wang Chaoe636c852010-09-16 11:20:56 +0800686 */
687 if ((sysent[tcp->scno].sys_func == sys_clone) &&
688 (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED))
689 return 0;
Denys Vlasenkoe7c90242011-06-22 00:09:25 +0200690 setbpt(tcp);
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000691 } else {
Denys Vlasenko833fb132011-08-17 11:30:56 +0200692 if (tcp->flags & TCB_BPTSET)
693 clearbpt(tcp);
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000694 }
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000695 return 0;
696}
Dmitry V. Levin257e1572009-12-26 17:55:24 +0000697
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000698
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000699
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000700
701int
Denys Vlasenko12014262011-05-30 14:00:14 +0200702sys_vfork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000703{
704 if (exiting(tcp))
705 return RVAL_UDECIMAL;
706 return 0;
707}
708
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000709
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000710
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000711
Dmitry V. Levin50a218d2011-01-18 17:36:20 +0000712int sys_getuid(struct tcb *tcp)
713{
714 if (exiting(tcp))
715 tcp->u_rval = (uid_t) tcp->u_rval;
716 return RVAL_UDECIMAL;
717}
718
719int sys_setfsuid(struct tcb *tcp)
720{
721 if (entering(tcp))
722 tprintf("%u", (uid_t) tcp->u_arg[0]);
723 else
724 tcp->u_rval = (uid_t) tcp->u_rval;
725 return RVAL_UDECIMAL;
726}
727
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000728int
Denys Vlasenko12014262011-05-30 14:00:14 +0200729sys_setuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000730{
731 if (entering(tcp)) {
732 tprintf("%u", (uid_t) tcp->u_arg[0]);
733 }
734 return 0;
735}
736
737int
Denys Vlasenko12014262011-05-30 14:00:14 +0200738sys_setgid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000739{
740 if (entering(tcp)) {
741 tprintf("%u", (gid_t) tcp->u_arg[0]);
742 }
743 return 0;
744}
745
746int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000747sys_getresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000748{
749 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000750 __kernel_uid_t uid;
751 if (syserror(tcp))
752 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
753 tcp->u_arg[1], tcp->u_arg[2]);
754 else {
755 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
756 tprintf("%#lx, ", tcp->u_arg[0]);
757 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000758 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000759 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
760 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000761 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000762 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000763 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
764 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000765 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000766 tprintf("[%lu]", (unsigned long) uid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000767 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000768 }
769 return 0;
770}
771
772int
Denys Vlasenko12014262011-05-30 14:00:14 +0200773sys_getresgid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000774{
775 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000776 __kernel_gid_t gid;
777 if (syserror(tcp))
778 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
779 tcp->u_arg[1], tcp->u_arg[2]);
780 else {
781 if (umove(tcp, tcp->u_arg[0], &gid) < 0)
782 tprintf("%#lx, ", tcp->u_arg[0]);
783 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000784 tprintf("[%lu], ", (unsigned long) gid);
Roland McGrathd2450922003-02-24 10:18:07 +0000785 if (umove(tcp, tcp->u_arg[1], &gid) < 0)
786 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000787 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000788 tprintf("[%lu], ", (unsigned long) gid);
Roland McGrathd2450922003-02-24 10:18:07 +0000789 if (umove(tcp, tcp->u_arg[2], &gid) < 0)
790 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000791 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000792 tprintf("[%lu]", (unsigned long) gid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000793 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000794 }
795 return 0;
796}
797
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000798
799int
Denys Vlasenko12014262011-05-30 14:00:14 +0200800sys_setreuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000801{
802 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000803 printuid("", tcp->u_arg[0]);
804 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000805 }
806 return 0;
807}
808
809int
Denys Vlasenko12014262011-05-30 14:00:14 +0200810sys_setregid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000811{
812 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000813 printuid("", tcp->u_arg[0]);
814 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000815 }
816 return 0;
817}
818
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000819int
Denys Vlasenko12014262011-05-30 14:00:14 +0200820sys_setresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000821{
822 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000823 printuid("", tcp->u_arg[0]);
824 printuid(", ", tcp->u_arg[1]);
825 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000826 }
827 return 0;
828}
829int
Denys Vlasenko12014262011-05-30 14:00:14 +0200830sys_setresgid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000831{
832 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000833 printuid("", tcp->u_arg[0]);
834 printuid(", ", tcp->u_arg[1]);
835 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000836 }
837 return 0;
838}
839
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000840
841int
Denys Vlasenko12014262011-05-30 14:00:14 +0200842sys_setgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000843{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000844 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000845 unsigned long len, size, start, cur, end, abbrev_end;
846 GETGROUPS_T gid;
847 int failed = 0;
848
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000849 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000850 tprintf("%lu, ", len);
851 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200852 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000853 return 0;
854 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000855 start = tcp->u_arg[1];
856 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200857 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000858 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000859 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000860 size = len * sizeof(gid);
861 end = start + size;
862 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
863 tprintf("%#lx", start);
864 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000865 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000866 if (abbrev(tcp)) {
867 abbrev_end = start + max_strlen * sizeof(gid);
868 if (abbrev_end < start)
869 abbrev_end = end;
870 } else {
871 abbrev_end = end;
872 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200873 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000874 for (cur = start; cur < end; cur += sizeof(gid)) {
875 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200876 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000877 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200878 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000879 break;
880 }
881 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200882 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000883 failed = 1;
884 break;
885 }
886 tprintf("%lu", (unsigned long) gid);
887 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200888 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000889 if (failed)
890 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000891 }
892 return 0;
893}
894
895int
Denys Vlasenko12014262011-05-30 14:00:14 +0200896sys_getgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000897{
Roland McGrathaa524c82005-06-01 19:22:06 +0000898 unsigned long len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000899
900 if (entering(tcp)) {
901 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000902 tprintf("%lu, ", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000903 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000904 unsigned long size, start, cur, end, abbrev_end;
905 GETGROUPS_T gid;
906 int failed = 0;
907
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000908 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000909 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200910 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000911 return 0;
912 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000913 start = tcp->u_arg[1];
914 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200915 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000916 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000917 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000918 if (tcp->u_arg[0] == 0) {
919 tprintf("%#lx", start);
920 return 0;
921 }
922 size = len * sizeof(gid);
923 end = start + size;
924 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
925 size / sizeof(gid) != len || end < start) {
926 tprintf("%#lx", start);
927 return 0;
928 }
929 if (abbrev(tcp)) {
930 abbrev_end = start + max_strlen * sizeof(gid);
931 if (abbrev_end < start)
932 abbrev_end = end;
933 } else {
934 abbrev_end = end;
935 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200936 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000937 for (cur = start; cur < end; cur += sizeof(gid)) {
938 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200939 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000940 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200941 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000942 break;
943 }
944 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200945 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000946 failed = 1;
947 break;
948 }
949 tprintf("%lu", (unsigned long) gid);
950 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200951 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000952 if (failed)
953 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000954 }
955 return 0;
956}
957
Roland McGrath83bd47a2003-11-13 22:32:26 +0000958int
Denys Vlasenko12014262011-05-30 14:00:14 +0200959sys_setgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000960{
Roland McGrath83bd47a2003-11-13 22:32:26 +0000961 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000962 unsigned long len, size, start, cur, end, abbrev_end;
963 GETGROUPS32_T gid;
964 int failed = 0;
965
Roland McGrath83bd47a2003-11-13 22:32:26 +0000966 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000967 tprintf("%lu, ", len);
968 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200969 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000970 return 0;
971 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000972 start = tcp->u_arg[1];
973 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200974 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000975 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000976 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000977 size = len * sizeof(gid);
978 end = start + size;
979 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
980 tprintf("%#lx", start);
981 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000982 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000983 if (abbrev(tcp)) {
984 abbrev_end = start + max_strlen * sizeof(gid);
985 if (abbrev_end < start)
986 abbrev_end = end;
987 } else {
988 abbrev_end = end;
989 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200990 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000991 for (cur = start; cur < end; cur += sizeof(gid)) {
992 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200993 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000994 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200995 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000996 break;
997 }
998 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200999 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +00001000 failed = 1;
1001 break;
1002 }
1003 tprintf("%lu", (unsigned long) gid);
1004 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001005 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +00001006 if (failed)
1007 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +00001008 }
1009 return 0;
1010}
1011
1012int
Denys Vlasenko12014262011-05-30 14:00:14 +02001013sys_getgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +00001014{
Roland McGrathaa524c82005-06-01 19:22:06 +00001015 unsigned long len;
Roland McGrath83bd47a2003-11-13 22:32:26 +00001016
1017 if (entering(tcp)) {
1018 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +00001019 tprintf("%lu, ", len);
Roland McGrath83bd47a2003-11-13 22:32:26 +00001020 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +00001021 unsigned long size, start, cur, end, abbrev_end;
1022 GETGROUPS32_T gid;
1023 int failed = 0;
1024
Roland McGrath83bd47a2003-11-13 22:32:26 +00001025 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +00001026 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001027 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +00001028 return 0;
1029 }
Roland McGrathaa524c82005-06-01 19:22:06 +00001030 start = tcp->u_arg[1];
1031 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001032 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +00001033 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +00001034 }
Roland McGrathaa524c82005-06-01 19:22:06 +00001035 size = len * sizeof(gid);
1036 end = start + size;
1037 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
1038 size / sizeof(gid) != len || end < start) {
1039 tprintf("%#lx", start);
1040 return 0;
1041 }
1042 if (abbrev(tcp)) {
1043 abbrev_end = start + max_strlen * sizeof(gid);
1044 if (abbrev_end < start)
1045 abbrev_end = end;
1046 } else {
1047 abbrev_end = end;
1048 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001049 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +00001050 for (cur = start; cur < end; cur += sizeof(gid)) {
1051 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001052 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +00001053 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001054 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +00001055 break;
1056 }
1057 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001058 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +00001059 failed = 1;
1060 break;
1061 }
1062 tprintf("%lu", (unsigned long) gid);
1063 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001064 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +00001065 if (failed)
1066 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +00001067 }
1068 return 0;
1069}
Roland McGrath83bd47a2003-11-13 22:32:26 +00001070
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001071#if defined(ALPHA) || defined(SUNOS4) || defined(SVR4)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001072int
Denys Vlasenko12014262011-05-30 14:00:14 +02001073sys_setpgrp(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001074{
1075 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001076 tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001077 }
1078 return 0;
1079}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001080#endif /* ALPHA || SUNOS4 || SVR4 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001081
1082int
Denys Vlasenko12014262011-05-30 14:00:14 +02001083sys_getpgrp(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001084{
1085 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001086 tprintf("%lu", tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001087 }
1088 return 0;
1089}
1090
1091int
Denys Vlasenko12014262011-05-30 14:00:14 +02001092sys_getsid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001093{
1094 if (entering(tcp)) {
1095 tprintf("%lu", tcp->u_arg[0]);
1096 }
1097 return 0;
1098}
1099
1100int
Denys Vlasenko12014262011-05-30 14:00:14 +02001101sys_setsid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001102{
1103 return 0;
1104}
1105
1106int
Denys Vlasenko12014262011-05-30 14:00:14 +02001107sys_getpgid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001108{
1109 if (entering(tcp)) {
1110 tprintf("%lu", tcp->u_arg[0]);
1111 }
1112 return 0;
1113}
1114
1115int
Denys Vlasenko12014262011-05-30 14:00:14 +02001116sys_setpgid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001117{
1118 if (entering(tcp)) {
1119 tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]);
1120 }
1121 return 0;
1122}
1123
John Hughesc61eb3d2002-05-17 11:37:50 +00001124
1125
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001126static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +00001127printargv(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001128{
Roland McGrath85a3bc42007-08-02 02:13:05 +00001129 union {
Andreas Schwab99c85692009-08-28 19:36:20 +02001130 unsigned int p32;
1131 unsigned long p64;
Roland McGrath85a3bc42007-08-02 02:13:05 +00001132 char data[sizeof(long)];
1133 } cp;
Dmitry V. Levin30145dd2010-09-06 22:08:24 +00001134 const char *sep;
Roland McGrath85a3bc42007-08-02 02:13:05 +00001135 int n = 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001136
Roland McGrath85a3bc42007-08-02 02:13:05 +00001137 cp.p64 = 1;
1138 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
1139 if (umoven(tcp, addr, personality_wordsize[current_personality],
1140 cp.data) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001141 tprintf("%#lx", addr);
1142 return;
1143 }
Roland McGrath85a3bc42007-08-02 02:13:05 +00001144 if (personality_wordsize[current_personality] == 4)
1145 cp.p64 = cp.p32;
1146 if (cp.p64 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001147 break;
Denys Vlasenko5940e652011-09-01 09:55:05 +02001148 tprints(sep);
Roland McGrath85a3bc42007-08-02 02:13:05 +00001149 printstr(tcp, cp.p64, -1);
1150 addr += personality_wordsize[current_personality];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001151 }
Roland McGrath85a3bc42007-08-02 02:13:05 +00001152 if (cp.p64)
1153 tprintf("%s...", sep);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001154}
1155
1156static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +00001157printargc(const char *fmt, struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001158{
1159 int count;
1160 char *cp;
1161
1162 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
1163 addr += sizeof(char *);
1164 }
1165 tprintf(fmt, count, count == 1 ? "" : "s");
1166}
1167
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001168#if defined(SPARC) || defined(SPARC64) || defined(SUNOS4)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001169int
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001170sys_execv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001171{
1172 if (entering(tcp)) {
1173 printpath(tcp, tcp->u_arg[0]);
1174 if (!verbose(tcp))
1175 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001176 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001177 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001178 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001179 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001180 }
1181 }
1182 return 0;
1183}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +00001184#endif /* SPARC || SPARC64 || SUNOS4 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001185
1186int
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001187sys_execve(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001188{
1189 if (entering(tcp)) {
1190 printpath(tcp, tcp->u_arg[0]);
1191 if (!verbose(tcp))
1192 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001193 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001194 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001195 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001196 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001197 }
1198 if (!verbose(tcp))
1199 tprintf(", %#lx", tcp->u_arg[2]);
1200 else if (abbrev(tcp))
1201 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
1202 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001203 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001204 printargv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001205 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001206 }
1207 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001208 return 0;
1209}
1210
John Hughes4e36a812001-04-18 15:11:51 +00001211
Denys Vlasenkoa7949742011-08-21 17:26:55 +02001212#if defined SUNOS4 || (defined LINUX && defined TCB_WAITEXECVE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001213int
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001214internal_exec(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001215{
Denys Vlasenkoa7949742011-08-21 17:26:55 +02001216# if defined LINUX && defined TCB_WAITEXECVE
Roland McGrathfdb097f2004-07-12 07:38:55 +00001217 if (exiting(tcp) && syserror(tcp))
1218 tcp->flags &= ~TCB_WAITEXECVE;
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001219 else {
1220 /* Maybe we have post-execve SIGTRAP suppressed? */
Denys Vlasenkof44cce42011-06-21 14:34:10 +02001221 if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC))
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001222 tcp->flags |= TCB_WAITEXECVE; /* no */
1223 }
Denys Vlasenkoa7949742011-08-21 17:26:55 +02001224# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001225 return 0;
1226}
Denys Vlasenkoa7949742011-08-21 17:26:55 +02001227#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001228
Roland McGrath7ec1d352002-12-17 04:50:44 +00001229#ifndef __WNOTHREAD
1230#define __WNOTHREAD 0x20000000
1231#endif
1232#ifndef __WALL
1233#define __WALL 0x40000000
1234#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001235#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +00001236#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001237#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001238
Roland McGrathd9f816f2004-09-04 03:39:20 +00001239static const struct xlat wait4_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001240 { WNOHANG, "WNOHANG" },
1241#ifndef WSTOPPED
1242 { WUNTRACED, "WUNTRACED" },
1243#endif
1244#ifdef WEXITED
1245 { WEXITED, "WEXITED" },
1246#endif
1247#ifdef WTRAPPED
1248 { WTRAPPED, "WTRAPPED" },
1249#endif
1250#ifdef WSTOPPED
1251 { WSTOPPED, "WSTOPPED" },
1252#endif
1253#ifdef WCONTINUED
1254 { WCONTINUED, "WCONTINUED" },
1255#endif
1256#ifdef WNOWAIT
1257 { WNOWAIT, "WNOWAIT" },
1258#endif
1259#ifdef __WCLONE
1260 { __WCLONE, "__WCLONE" },
1261#endif
Roland McGrath7ec1d352002-12-17 04:50:44 +00001262#ifdef __WALL
1263 { __WALL, "__WALL" },
1264#endif
1265#ifdef __WNOTHREAD
1266 { __WNOTHREAD, "__WNOTHREAD" },
1267#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001268 { 0, NULL },
1269};
1270
Roland McGrath5e02a572004-10-19 23:33:47 +00001271#if !defined WCOREFLAG && defined WCOREFLG
1272# define WCOREFLAG WCOREFLG
1273#endif
1274#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001275# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +00001276#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001277#ifndef WCOREDUMP
1278# define WCOREDUMP(status) ((status) & 0200)
1279#endif
1280
Roland McGrath5e02a572004-10-19 23:33:47 +00001281
1282#ifndef W_STOPCODE
1283#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
1284#endif
1285#ifndef W_EXITCODE
1286#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
1287#endif
1288
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001289static int
Denys Vlasenko12014262011-05-30 14:00:14 +02001290printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001291{
1292 int exited = 0;
1293
1294 /*
1295 * Here is a tricky presentation problem. This solution
1296 * is still not entirely satisfactory but since there
1297 * are no wait status constructors it will have to do.
1298 */
Roland McGrath79fbda52004-04-14 02:45:55 +00001299 if (WIFSTOPPED(status)) {
1300 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001301 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +00001302 status &= ~W_STOPCODE(WSTOPSIG(status));
1303 }
1304 else if (WIFSIGNALED(status)) {
1305 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001306 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001307 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +00001308 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1309 }
1310 else if (WIFEXITED(status)) {
1311 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001312 WEXITSTATUS(status));
1313 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +00001314 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001315 }
Roland McGrath79fbda52004-04-14 02:45:55 +00001316 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001317 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001318 return 0;
1319 }
1320
1321 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001322 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +00001323 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +00001324 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001325
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001326 return exited;
1327}
1328
1329static int
Denys Vlasenko59432db2009-01-26 19:09:35 +00001330printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001331{
1332 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001333
1334 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001335 /* On Linux, kernel-side pid_t is typedef'ed to int
1336 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +00001337 * pid argument to int on 64bit arches, producing,
1338 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001339 * in strace. We have to use int here, not long.
1340 */
1341 int pid = tcp->u_arg[0];
1342 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001343 } else {
1344 /* status */
1345 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001346 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001347 else if (syserror(tcp) || tcp->u_rval == 0)
1348 tprintf("%#lx", tcp->u_arg[1]);
1349 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001350 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001351 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +00001352 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001353 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001354 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001355 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001356 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001357 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001358 /* usage */
1359 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001360 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001361 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +00001362#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001363 if (bitness)
1364 printrusage32(tcp, tcp->u_arg[3]);
1365 else
1366#endif
1367 printrusage(tcp, tcp->u_arg[3]);
1368 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001369 else
1370 tprintf("%#lx", tcp->u_arg[3]);
1371 }
1372 }
1373 return 0;
1374}
1375
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001376
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001377
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001378int
Denys Vlasenko12014262011-05-30 14:00:14 +02001379sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001380{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001381 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001382}
1383
1384int
Denys Vlasenko12014262011-05-30 14:00:14 +02001385sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001386{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001387 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001388}
1389
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001390#ifdef ALPHA
1391int
Denys Vlasenko12014262011-05-30 14:00:14 +02001392sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001393{
1394 return printwaitn(tcp, 4, 1);
1395}
1396#endif
1397
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001398
Roland McGrathd9f816f2004-09-04 03:39:20 +00001399static const struct xlat waitid_types[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001400 { P_PID, "P_PID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001401#ifdef P_PPID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001402 { P_PPID, "P_PPID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001403#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001404 { P_PGID, "P_PGID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001405#ifdef P_SID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001406 { P_SID, "P_SID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001407#endif
1408#ifdef P_CID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001409 { P_CID, "P_CID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001410#endif
1411#ifdef P_UID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001412 { P_UID, "P_UID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001413#endif
1414#ifdef P_GID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001415 { P_GID, "P_GID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001416#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001417 { P_ALL, "P_ALL" },
1418#ifdef P_LWPID
1419 { P_LWPID, "P_LWPID" },
1420#endif
1421 { 0, NULL },
1422};
1423
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001424int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +00001425sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001426{
1427 siginfo_t si;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001428
1429 if (entering(tcp)) {
1430 printxval(waitid_types, tcp->u_arg[0], "P_???");
1431 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001432 }
1433 else {
1434 /* siginfo */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001435 if (!tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001436 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001437 else if (syserror(tcp))
1438 tprintf("%#lx", tcp->u_arg[2]);
1439 else if (umove(tcp, tcp->u_arg[2], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001440 tprints("{???}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001441 else
Denys Vlasenkof535b542009-01-13 18:30:55 +00001442 printsiginfo(&si, verbose(tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001443 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001444 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001445 printflags(wait4_options, tcp->u_arg[3], "W???");
Roland McGrath39426a32004-10-06 22:02:59 +00001446 if (tcp->u_nargs > 4) {
1447 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001448 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +00001449 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001450 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +00001451 else if (tcp->u_error)
1452 tprintf("%#lx", tcp->u_arg[4]);
1453 else
1454 printrusage(tcp, tcp->u_arg[4]);
1455 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001456 }
1457 return 0;
1458}
1459
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001460
1461int
Denys Vlasenko12014262011-05-30 14:00:14 +02001462sys_alarm(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001463{
1464 if (entering(tcp))
1465 tprintf("%lu", tcp->u_arg[0]);
1466 return 0;
1467}
1468
1469int
Denys Vlasenko12014262011-05-30 14:00:14 +02001470sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001471{
1472 struct utsname uname;
1473
1474 if (exiting(tcp)) {
1475 if (syserror(tcp) || !verbose(tcp))
1476 tprintf("%#lx", tcp->u_arg[0]);
1477 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001478 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001479 else if (!abbrev(tcp)) {
1480
1481 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1482 uname.sysname, uname.nodename);
1483 tprintf("release=\"%s\", version=\"%s\", ",
1484 uname.release, uname.version);
1485 tprintf("machine=\"%s\"", uname.machine);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001486#ifndef __GLIBC__
1487 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001488#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001489 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001490 }
1491 else
1492 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1493 uname.sysname, uname.nodename);
1494 }
1495 return 0;
1496}
1497
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001498
Roland McGratheb9e2e82009-06-02 16:49:22 -07001499static const struct xlat ptrace_cmds[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001500 { PTRACE_TRACEME, "PTRACE_TRACEME" },
Denys Vlasenko61526c62011-08-25 10:21:13 +02001501 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1502 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1503 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1504 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1505 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1506 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001507 { PTRACE_CONT, "PTRACE_CONT" },
1508 { PTRACE_KILL, "PTRACE_KILL" },
1509 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1510 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1511 { PTRACE_DETACH, "PTRACE_DETACH" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001512# ifdef PTRACE_GETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001513 { PTRACE_GETREGS, "PTRACE_GETREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001514# endif
1515# ifdef PTRACE_SETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001516 { PTRACE_SETREGS, "PTRACE_SETREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001517# endif
1518# ifdef PTRACE_GETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001519 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001520# endif
1521# ifdef PTRACE_SETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001522 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001523# endif
1524# ifdef PTRACE_GETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001525 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001526# endif
1527# ifdef PTRACE_SETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001528 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001529# endif
1530# ifdef PTRACE_GETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001531 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001532# endif
1533# ifdef PTRACE_SETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001534 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001535# endif
1536# ifdef PTRACE_SETOPTIONS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001537 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001538# endif
1539# ifdef PTRACE_GETEVENTMSG
Denys Vlasenko61526c62011-08-25 10:21:13 +02001540 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001541# endif
1542# ifdef PTRACE_GETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001543 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001544# endif
1545# ifdef PTRACE_SETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001546 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001547# endif
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001548# ifdef PTRACE_GETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001549 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001550# endif
1551# ifdef PTRACE_SETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001552 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001553# endif
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001554# ifdef PTRACE_SET_SYSCALL
Denys Vlasenko61526c62011-08-25 10:21:13 +02001555 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001556# endif
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001557# ifdef PTRACE_SEIZE
1558 { PTRACE_SEIZE, "PTRACE_SEIZE" },
1559# endif
1560# ifdef PTRACE_INTERRUPT
1561 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
1562# endif
1563# ifdef PTRACE_LISTEN
1564 { PTRACE_LISTEN, "PTRACE_LISTEN" },
1565# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001566 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
Denys Vlasenkof535b542009-01-13 18:30:55 +00001567
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001568 { 0, NULL },
1569};
1570
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001571# ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00001572static const struct xlat ptrace_setoptions_flags[] = {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001573# ifdef PTRACE_O_TRACESYSGOOD
Denys Vlasenkof535b542009-01-13 18:30:55 +00001574 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001575# endif
1576# ifdef PTRACE_O_TRACEFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001577 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001578# endif
1579# ifdef PTRACE_O_TRACEVFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001580 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001581# endif
1582# ifdef PTRACE_O_TRACECLONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001583 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001584# endif
1585# ifdef PTRACE_O_TRACEEXEC
Denys Vlasenkof535b542009-01-13 18:30:55 +00001586 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001587# endif
1588# ifdef PTRACE_O_TRACEVFORKDONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001589 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001590# endif
1591# ifdef PTRACE_O_TRACEEXIT
Denys Vlasenkof535b542009-01-13 18:30:55 +00001592 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001593# endif
Denys Vlasenkof535b542009-01-13 18:30:55 +00001594 { 0, NULL },
1595};
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001596# endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001597
Roland McGrathd9f816f2004-09-04 03:39:20 +00001598const struct xlat struct_user_offsets[] = {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001599# if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001600 { PT_PSWMASK, "psw_mask" },
1601 { PT_PSWADDR, "psw_addr" },
1602 { PT_GPR0, "gpr0" },
1603 { PT_GPR1, "gpr1" },
1604 { PT_GPR2, "gpr2" },
1605 { PT_GPR3, "gpr3" },
1606 { PT_GPR4, "gpr4" },
1607 { PT_GPR5, "gpr5" },
1608 { PT_GPR6, "gpr6" },
1609 { PT_GPR7, "gpr7" },
1610 { PT_GPR8, "gpr8" },
1611 { PT_GPR9, "gpr9" },
1612 { PT_GPR10, "gpr10" },
1613 { PT_GPR11, "gpr11" },
1614 { PT_GPR12, "gpr12" },
1615 { PT_GPR13, "gpr13" },
1616 { PT_GPR14, "gpr14" },
1617 { PT_GPR15, "gpr15" },
1618 { PT_ACR0, "acr0" },
1619 { PT_ACR1, "acr1" },
1620 { PT_ACR2, "acr2" },
1621 { PT_ACR3, "acr3" },
1622 { PT_ACR4, "acr4" },
1623 { PT_ACR5, "acr5" },
1624 { PT_ACR6, "acr6" },
1625 { PT_ACR7, "acr7" },
1626 { PT_ACR8, "acr8" },
1627 { PT_ACR9, "acr9" },
1628 { PT_ACR10, "acr10" },
1629 { PT_ACR11, "acr11" },
1630 { PT_ACR12, "acr12" },
1631 { PT_ACR13, "acr13" },
1632 { PT_ACR14, "acr14" },
1633 { PT_ACR15, "acr15" },
1634 { PT_ORIGGPR2, "orig_gpr2" },
1635 { PT_FPC, "fpc" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001636# if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001637 { PT_FPR0_HI, "fpr0.hi" },
1638 { PT_FPR0_LO, "fpr0.lo" },
1639 { PT_FPR1_HI, "fpr1.hi" },
1640 { PT_FPR1_LO, "fpr1.lo" },
1641 { PT_FPR2_HI, "fpr2.hi" },
1642 { PT_FPR2_LO, "fpr2.lo" },
1643 { PT_FPR3_HI, "fpr3.hi" },
1644 { PT_FPR3_LO, "fpr3.lo" },
1645 { PT_FPR4_HI, "fpr4.hi" },
1646 { PT_FPR4_LO, "fpr4.lo" },
1647 { PT_FPR5_HI, "fpr5.hi" },
1648 { PT_FPR5_LO, "fpr5.lo" },
1649 { PT_FPR6_HI, "fpr6.hi" },
1650 { PT_FPR6_LO, "fpr6.lo" },
1651 { PT_FPR7_HI, "fpr7.hi" },
1652 { PT_FPR7_LO, "fpr7.lo" },
1653 { PT_FPR8_HI, "fpr8.hi" },
1654 { PT_FPR8_LO, "fpr8.lo" },
1655 { PT_FPR9_HI, "fpr9.hi" },
1656 { PT_FPR9_LO, "fpr9.lo" },
1657 { PT_FPR10_HI, "fpr10.hi" },
1658 { PT_FPR10_LO, "fpr10.lo" },
1659 { PT_FPR11_HI, "fpr11.hi" },
1660 { PT_FPR11_LO, "fpr11.lo" },
1661 { PT_FPR12_HI, "fpr12.hi" },
1662 { PT_FPR12_LO, "fpr12.lo" },
1663 { PT_FPR13_HI, "fpr13.hi" },
1664 { PT_FPR13_LO, "fpr13.lo" },
1665 { PT_FPR14_HI, "fpr14.hi" },
1666 { PT_FPR14_LO, "fpr14.lo" },
1667 { PT_FPR15_HI, "fpr15.hi" },
1668 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001669# endif
1670# if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001671 { PT_FPR0, "fpr0" },
1672 { PT_FPR1, "fpr1" },
1673 { PT_FPR2, "fpr2" },
1674 { PT_FPR3, "fpr3" },
1675 { PT_FPR4, "fpr4" },
1676 { PT_FPR5, "fpr5" },
1677 { PT_FPR6, "fpr6" },
1678 { PT_FPR7, "fpr7" },
1679 { PT_FPR8, "fpr8" },
1680 { PT_FPR9, "fpr9" },
1681 { PT_FPR10, "fpr10" },
1682 { PT_FPR11, "fpr11" },
1683 { PT_FPR12, "fpr12" },
1684 { PT_FPR13, "fpr13" },
1685 { PT_FPR14, "fpr14" },
1686 { PT_FPR15, "fpr15" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001687# endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001688 { PT_CR_9, "cr9" },
1689 { PT_CR_10, "cr10" },
1690 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001691 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001692# elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001693 /* XXX No support for these offsets yet. */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001694# elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001695 /* XXX No support for these offsets yet. */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001696# elif defined(POWERPC)
1697# ifndef PT_ORIG_R3
1698# define PT_ORIG_R3 34
1699# endif
1700# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001701 { REGSIZE*PT_R0, "r0" },
1702 { REGSIZE*PT_R1, "r1" },
1703 { REGSIZE*PT_R2, "r2" },
1704 { REGSIZE*PT_R3, "r3" },
1705 { REGSIZE*PT_R4, "r4" },
1706 { REGSIZE*PT_R5, "r5" },
1707 { REGSIZE*PT_R6, "r6" },
1708 { REGSIZE*PT_R7, "r7" },
1709 { REGSIZE*PT_R8, "r8" },
1710 { REGSIZE*PT_R9, "r9" },
1711 { REGSIZE*PT_R10, "r10" },
1712 { REGSIZE*PT_R11, "r11" },
1713 { REGSIZE*PT_R12, "r12" },
1714 { REGSIZE*PT_R13, "r13" },
1715 { REGSIZE*PT_R14, "r14" },
1716 { REGSIZE*PT_R15, "r15" },
1717 { REGSIZE*PT_R16, "r16" },
1718 { REGSIZE*PT_R17, "r17" },
1719 { REGSIZE*PT_R18, "r18" },
1720 { REGSIZE*PT_R19, "r19" },
1721 { REGSIZE*PT_R20, "r20" },
1722 { REGSIZE*PT_R21, "r21" },
1723 { REGSIZE*PT_R22, "r22" },
1724 { REGSIZE*PT_R23, "r23" },
1725 { REGSIZE*PT_R24, "r24" },
1726 { REGSIZE*PT_R25, "r25" },
1727 { REGSIZE*PT_R26, "r26" },
1728 { REGSIZE*PT_R27, "r27" },
1729 { REGSIZE*PT_R28, "r28" },
1730 { REGSIZE*PT_R29, "r29" },
1731 { REGSIZE*PT_R30, "r30" },
1732 { REGSIZE*PT_R31, "r31" },
1733 { REGSIZE*PT_NIP, "NIP" },
1734 { REGSIZE*PT_MSR, "MSR" },
1735 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1736 { REGSIZE*PT_CTR, "CTR" },
1737 { REGSIZE*PT_LNK, "LNK" },
1738 { REGSIZE*PT_XER, "XER" },
1739 { REGSIZE*PT_CCR, "CCR" },
1740 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001741# undef REGSIZE
1742# elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001743 { 0, "r0" },
1744 { 1, "r1" },
1745 { 2, "r2" },
1746 { 3, "r3" },
1747 { 4, "r4" },
1748 { 5, "r5" },
1749 { 6, "r6" },
1750 { 7, "r7" },
1751 { 8, "r8" },
1752 { 9, "r9" },
1753 { 10, "r10" },
1754 { 11, "r11" },
1755 { 12, "r12" },
1756 { 13, "r13" },
1757 { 14, "r14" },
1758 { 15, "r15" },
1759 { 16, "r16" },
1760 { 17, "r17" },
1761 { 18, "r18" },
1762 { 19, "r19" },
1763 { 20, "r20" },
1764 { 21, "r21" },
1765 { 22, "r22" },
1766 { 23, "r23" },
1767 { 24, "r24" },
1768 { 25, "r25" },
1769 { 26, "r26" },
1770 { 27, "r27" },
1771 { 28, "r28" },
1772 { 29, "gp" },
1773 { 30, "fp" },
1774 { 31, "zero" },
1775 { 32, "fp0" },
1776 { 33, "fp" },
1777 { 34, "fp2" },
1778 { 35, "fp3" },
1779 { 36, "fp4" },
1780 { 37, "fp5" },
1781 { 38, "fp6" },
1782 { 39, "fp7" },
1783 { 40, "fp8" },
1784 { 41, "fp9" },
1785 { 42, "fp10" },
1786 { 43, "fp11" },
1787 { 44, "fp12" },
1788 { 45, "fp13" },
1789 { 46, "fp14" },
1790 { 47, "fp15" },
1791 { 48, "fp16" },
1792 { 49, "fp17" },
1793 { 50, "fp18" },
1794 { 51, "fp19" },
1795 { 52, "fp20" },
1796 { 53, "fp21" },
1797 { 54, "fp22" },
1798 { 55, "fp23" },
1799 { 56, "fp24" },
1800 { 57, "fp25" },
1801 { 58, "fp26" },
1802 { 59, "fp27" },
1803 { 60, "fp28" },
1804 { 61, "fp29" },
1805 { 62, "fp30" },
1806 { 63, "fp31" },
1807 { 64, "pc" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001808# elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001809 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1810 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1811 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1812 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1813 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1814 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1815 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1816 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1817 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1818 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1819 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1820 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1821 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1822 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1823 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1824 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1825 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1826 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1827 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1828 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1829 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1830 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1831 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1832 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1833 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1834 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1835 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1836 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1837 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1838 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1839 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1840 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1841 /* switch stack: */
1842 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1843 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1844 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1845 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1846 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1847 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1848 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1849 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1850 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1851 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001852 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1853 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001854 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001855 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001856 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1857 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001858 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1859 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1860 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1861 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1862 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1863 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1864 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1865 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1866 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1867 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1868 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1869 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1870 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1871 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1872 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001873# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001874 { PT_AR_CSD, "ar.csd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001875# endif
1876# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001877 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001878# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001879 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001880# elif defined(I386)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001881 { 4*EBX, "4*EBX" },
1882 { 4*ECX, "4*ECX" },
1883 { 4*EDX, "4*EDX" },
1884 { 4*ESI, "4*ESI" },
1885 { 4*EDI, "4*EDI" },
1886 { 4*EBP, "4*EBP" },
1887 { 4*EAX, "4*EAX" },
1888 { 4*DS, "4*DS" },
1889 { 4*ES, "4*ES" },
1890 { 4*FS, "4*FS" },
1891 { 4*GS, "4*GS" },
1892 { 4*ORIG_EAX, "4*ORIG_EAX" },
1893 { 4*EIP, "4*EIP" },
1894 { 4*CS, "4*CS" },
1895 { 4*EFL, "4*EFL" },
1896 { 4*UESP, "4*UESP" },
1897 { 4*SS, "4*SS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001898# elif defined(X86_64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001899 { 8*R15, "8*R15" },
1900 { 8*R14, "8*R14" },
1901 { 8*R13, "8*R13" },
1902 { 8*R12, "8*R12" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001903 { 8*RBP, "8*RBP" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001904 { 8*RBX, "8*RBX" },
1905 { 8*R11, "8*R11" },
1906 { 8*R10, "8*R10" },
1907 { 8*R9, "8*R9" },
1908 { 8*R8, "8*R8" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001909 { 8*RAX, "8*RAX" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001910 { 8*RCX, "8*RCX" },
1911 { 8*RDX, "8*RDX" },
1912 { 8*RSI, "8*RSI" },
1913 { 8*RDI, "8*RDI" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001914 { 8*ORIG_RAX, "8*ORIG_RAX" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001915 { 8*RIP, "8*RIP" },
1916 { 8*CS, "8*CS" },
1917 { 8*EFLAGS, "8*EFL" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001918 { 8*RSP, "8*RSP" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001919 { 8*SS, "8*SS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001920# elif defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001921 { 4*PT_D1, "4*PT_D1" },
1922 { 4*PT_D2, "4*PT_D2" },
1923 { 4*PT_D3, "4*PT_D3" },
1924 { 4*PT_D4, "4*PT_D4" },
1925 { 4*PT_D5, "4*PT_D5" },
1926 { 4*PT_D6, "4*PT_D6" },
1927 { 4*PT_D7, "4*PT_D7" },
1928 { 4*PT_A0, "4*PT_A0" },
1929 { 4*PT_A1, "4*PT_A1" },
1930 { 4*PT_A2, "4*PT_A2" },
1931 { 4*PT_A3, "4*PT_A3" },
1932 { 4*PT_A4, "4*PT_A4" },
1933 { 4*PT_A5, "4*PT_A5" },
1934 { 4*PT_A6, "4*PT_A6" },
1935 { 4*PT_D0, "4*PT_D0" },
1936 { 4*PT_USP, "4*PT_USP" },
1937 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1938 { 4*PT_SR, "4*PT_SR" },
1939 { 4*PT_PC, "4*PT_PC" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001940# elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001941 { 4*REG_REG0, "4*REG_REG0" },
1942 { 4*(REG_REG0+1), "4*REG_REG1" },
1943 { 4*(REG_REG0+2), "4*REG_REG2" },
1944 { 4*(REG_REG0+3), "4*REG_REG3" },
1945 { 4*(REG_REG0+4), "4*REG_REG4" },
1946 { 4*(REG_REG0+5), "4*REG_REG5" },
1947 { 4*(REG_REG0+6), "4*REG_REG6" },
1948 { 4*(REG_REG0+7), "4*REG_REG7" },
1949 { 4*(REG_REG0+8), "4*REG_REG8" },
1950 { 4*(REG_REG0+9), "4*REG_REG9" },
1951 { 4*(REG_REG0+10), "4*REG_REG10" },
1952 { 4*(REG_REG0+11), "4*REG_REG11" },
1953 { 4*(REG_REG0+12), "4*REG_REG12" },
1954 { 4*(REG_REG0+13), "4*REG_REG13" },
1955 { 4*(REG_REG0+14), "4*REG_REG14" },
1956 { 4*REG_REG15, "4*REG_REG15" },
1957 { 4*REG_PC, "4*REG_PC" },
1958 { 4*REG_PR, "4*REG_PR" },
1959 { 4*REG_SR, "4*REG_SR" },
1960 { 4*REG_GBR, "4*REG_GBR" },
1961 { 4*REG_MACH, "4*REG_MACH" },
1962 { 4*REG_MACL, "4*REG_MACL" },
1963 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1964 { 4*REG_FPUL, "4*REG_FPUL" },
1965 { 4*REG_FPREG0, "4*REG_FPREG0" },
1966 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1967 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1968 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1969 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1970 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1971 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1972 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1973 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1974 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1975 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1976 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1977 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1978 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1979 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1980 { 4*REG_FPREG15, "4*REG_FPREG15" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001981# ifdef REG_XDREG0
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001982 { 4*REG_XDREG0, "4*REG_XDREG0" },
1983 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1984 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1985 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1986 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1987 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1988 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1989 { 4*REG_XDREG14, "4*REG_XDREG14" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001990# endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001991 { 4*REG_FPSCR, "4*REG_FPSCR" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001992# elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001993 { 0, "PC(L)" },
1994 { 4, "PC(U)" },
1995 { 8, "SR(L)" },
1996 { 12, "SR(U)" },
1997 { 16, "syscall no.(L)" },
1998 { 20, "syscall_no.(U)" },
1999 { 24, "R0(L)" },
2000 { 28, "R0(U)" },
2001 { 32, "R1(L)" },
2002 { 36, "R1(U)" },
2003 { 40, "R2(L)" },
2004 { 44, "R2(U)" },
2005 { 48, "R3(L)" },
2006 { 52, "R3(U)" },
2007 { 56, "R4(L)" },
2008 { 60, "R4(U)" },
2009 { 64, "R5(L)" },
2010 { 68, "R5(U)" },
2011 { 72, "R6(L)" },
2012 { 76, "R6(U)" },
2013 { 80, "R7(L)" },
2014 { 84, "R7(U)" },
2015 { 88, "R8(L)" },
2016 { 92, "R8(U)" },
2017 { 96, "R9(L)" },
2018 { 100, "R9(U)" },
2019 { 104, "R10(L)" },
2020 { 108, "R10(U)" },
2021 { 112, "R11(L)" },
2022 { 116, "R11(U)" },
2023 { 120, "R12(L)" },
2024 { 124, "R12(U)" },
2025 { 128, "R13(L)" },
2026 { 132, "R13(U)" },
2027 { 136, "R14(L)" },
2028 { 140, "R14(U)" },
2029 { 144, "R15(L)" },
2030 { 148, "R15(U)" },
2031 { 152, "R16(L)" },
2032 { 156, "R16(U)" },
2033 { 160, "R17(L)" },
2034 { 164, "R17(U)" },
2035 { 168, "R18(L)" },
2036 { 172, "R18(U)" },
2037 { 176, "R19(L)" },
2038 { 180, "R19(U)" },
2039 { 184, "R20(L)" },
2040 { 188, "R20(U)" },
2041 { 192, "R21(L)" },
2042 { 196, "R21(U)" },
2043 { 200, "R22(L)" },
2044 { 204, "R22(U)" },
2045 { 208, "R23(L)" },
2046 { 212, "R23(U)" },
2047 { 216, "R24(L)" },
2048 { 220, "R24(U)" },
2049 { 224, "R25(L)" },
2050 { 228, "R25(U)" },
2051 { 232, "R26(L)" },
2052 { 236, "R26(U)" },
2053 { 240, "R27(L)" },
2054 { 244, "R27(U)" },
2055 { 248, "R28(L)" },
2056 { 252, "R28(U)" },
2057 { 256, "R29(L)" },
2058 { 260, "R29(U)" },
2059 { 264, "R30(L)" },
2060 { 268, "R30(U)" },
2061 { 272, "R31(L)" },
2062 { 276, "R31(U)" },
2063 { 280, "R32(L)" },
2064 { 284, "R32(U)" },
2065 { 288, "R33(L)" },
2066 { 292, "R33(U)" },
2067 { 296, "R34(L)" },
2068 { 300, "R34(U)" },
2069 { 304, "R35(L)" },
2070 { 308, "R35(U)" },
2071 { 312, "R36(L)" },
2072 { 316, "R36(U)" },
2073 { 320, "R37(L)" },
2074 { 324, "R37(U)" },
2075 { 328, "R38(L)" },
2076 { 332, "R38(U)" },
2077 { 336, "R39(L)" },
2078 { 340, "R39(U)" },
2079 { 344, "R40(L)" },
2080 { 348, "R40(U)" },
2081 { 352, "R41(L)" },
2082 { 356, "R41(U)" },
2083 { 360, "R42(L)" },
2084 { 364, "R42(U)" },
2085 { 368, "R43(L)" },
2086 { 372, "R43(U)" },
2087 { 376, "R44(L)" },
2088 { 380, "R44(U)" },
2089 { 384, "R45(L)" },
2090 { 388, "R45(U)" },
2091 { 392, "R46(L)" },
2092 { 396, "R46(U)" },
2093 { 400, "R47(L)" },
2094 { 404, "R47(U)" },
2095 { 408, "R48(L)" },
2096 { 412, "R48(U)" },
2097 { 416, "R49(L)" },
2098 { 420, "R49(U)" },
2099 { 424, "R50(L)" },
2100 { 428, "R50(U)" },
2101 { 432, "R51(L)" },
2102 { 436, "R51(U)" },
2103 { 440, "R52(L)" },
2104 { 444, "R52(U)" },
2105 { 448, "R53(L)" },
2106 { 452, "R53(U)" },
2107 { 456, "R54(L)" },
2108 { 460, "R54(U)" },
2109 { 464, "R55(L)" },
2110 { 468, "R55(U)" },
2111 { 472, "R56(L)" },
2112 { 476, "R56(U)" },
2113 { 480, "R57(L)" },
2114 { 484, "R57(U)" },
2115 { 488, "R58(L)" },
2116 { 492, "R58(U)" },
2117 { 496, "R59(L)" },
2118 { 500, "R59(U)" },
2119 { 504, "R60(L)" },
2120 { 508, "R60(U)" },
2121 { 512, "R61(L)" },
2122 { 516, "R61(U)" },
2123 { 520, "R62(L)" },
2124 { 524, "R62(U)" },
2125 { 528, "TR0(L)" },
2126 { 532, "TR0(U)" },
2127 { 536, "TR1(L)" },
2128 { 540, "TR1(U)" },
2129 { 544, "TR2(L)" },
2130 { 548, "TR2(U)" },
2131 { 552, "TR3(L)" },
2132 { 556, "TR3(U)" },
2133 { 560, "TR4(L)" },
2134 { 564, "TR4(U)" },
2135 { 568, "TR5(L)" },
2136 { 572, "TR5(U)" },
2137 { 576, "TR6(L)" },
2138 { 580, "TR6(U)" },
2139 { 584, "TR7(L)" },
2140 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00002141 /* This entry is in case pt_regs contains dregs (depends on
2142 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002143 { uoff(regs), "offsetof(struct user, regs)" },
2144 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002145# elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00002146 { uoff(regs.ARM_r0), "r0" },
2147 { uoff(regs.ARM_r1), "r1" },
2148 { uoff(regs.ARM_r2), "r2" },
2149 { uoff(regs.ARM_r3), "r3" },
2150 { uoff(regs.ARM_r4), "r4" },
2151 { uoff(regs.ARM_r5), "r5" },
2152 { uoff(regs.ARM_r6), "r6" },
2153 { uoff(regs.ARM_r7), "r7" },
2154 { uoff(regs.ARM_r8), "r8" },
2155 { uoff(regs.ARM_r9), "r9" },
2156 { uoff(regs.ARM_r10), "r10" },
2157 { uoff(regs.ARM_fp), "fp" },
2158 { uoff(regs.ARM_ip), "ip" },
2159 { uoff(regs.ARM_sp), "sp" },
2160 { uoff(regs.ARM_lr), "lr" },
2161 { uoff(regs.ARM_pc), "pc" },
2162 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00002163# elif defined(AVR32)
2164 { uoff(regs.sr), "sr" },
2165 { uoff(regs.pc), "pc" },
2166 { uoff(regs.lr), "lr" },
2167 { uoff(regs.sp), "sp" },
2168 { uoff(regs.r12), "r12" },
2169 { uoff(regs.r11), "r11" },
2170 { uoff(regs.r10), "r10" },
2171 { uoff(regs.r9), "r9" },
2172 { uoff(regs.r8), "r8" },
2173 { uoff(regs.r7), "r7" },
2174 { uoff(regs.r6), "r6" },
2175 { uoff(regs.r5), "r5" },
2176 { uoff(regs.r4), "r4" },
2177 { uoff(regs.r3), "r3" },
2178 { uoff(regs.r2), "r2" },
2179 { uoff(regs.r1), "r1" },
2180 { uoff(regs.r0), "r0" },
2181 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002182# elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00002183 { 0, "r0" },
2184 { 1, "r1" },
2185 { 2, "r2" },
2186 { 3, "r3" },
2187 { 4, "r4" },
2188 { 5, "r5" },
2189 { 6, "r6" },
2190 { 7, "r7" },
2191 { 8, "r8" },
2192 { 9, "r9" },
2193 { 10, "r10" },
2194 { 11, "r11" },
2195 { 12, "r12" },
2196 { 13, "r13" },
2197 { 14, "r14" },
2198 { 15, "r15" },
2199 { 16, "r16" },
2200 { 17, "r17" },
2201 { 18, "r18" },
2202 { 19, "r19" },
2203 { 20, "r20" },
2204 { 21, "r21" },
2205 { 22, "r22" },
2206 { 23, "r23" },
2207 { 24, "r24" },
2208 { 25, "r25" },
2209 { 26, "r26" },
2210 { 27, "r27" },
2211 { 28, "r28" },
2212 { 29, "r29" },
2213 { 30, "r30" },
2214 { 31, "r31" },
2215 { 32, "f0" },
2216 { 33, "f1" },
2217 { 34, "f2" },
2218 { 35, "f3" },
2219 { 36, "f4" },
2220 { 37, "f5" },
2221 { 38, "f6" },
2222 { 39, "f7" },
2223 { 40, "f8" },
2224 { 41, "f9" },
2225 { 42, "f10" },
2226 { 43, "f11" },
2227 { 44, "f12" },
2228 { 45, "f13" },
2229 { 46, "f14" },
2230 { 47, "f15" },
2231 { 48, "f16" },
2232 { 49, "f17" },
2233 { 50, "f18" },
2234 { 51, "f19" },
2235 { 52, "f20" },
2236 { 53, "f21" },
2237 { 54, "f22" },
2238 { 55, "f23" },
2239 { 56, "f24" },
2240 { 57, "f25" },
2241 { 58, "f26" },
2242 { 59, "f27" },
2243 { 60, "f28" },
2244 { 61, "f29" },
2245 { 62, "f30" },
2246 { 63, "f31" },
2247 { 64, "pc" },
2248 { 65, "cause" },
2249 { 66, "badvaddr" },
2250 { 67, "mmhi" },
2251 { 68, "mmlo" },
2252 { 69, "fpcsr" },
2253 { 70, "fpeir" },
Chris Metcalfc8c66982009-12-28 10:00:15 -05002254# elif defined(TILE)
2255 { PTREGS_OFFSET_REG(0), "r0" },
2256 { PTREGS_OFFSET_REG(1), "r1" },
2257 { PTREGS_OFFSET_REG(2), "r2" },
2258 { PTREGS_OFFSET_REG(3), "r3" },
2259 { PTREGS_OFFSET_REG(4), "r4" },
2260 { PTREGS_OFFSET_REG(5), "r5" },
2261 { PTREGS_OFFSET_REG(6), "r6" },
2262 { PTREGS_OFFSET_REG(7), "r7" },
2263 { PTREGS_OFFSET_REG(8), "r8" },
2264 { PTREGS_OFFSET_REG(9), "r9" },
2265 { PTREGS_OFFSET_REG(10), "r10" },
2266 { PTREGS_OFFSET_REG(11), "r11" },
2267 { PTREGS_OFFSET_REG(12), "r12" },
2268 { PTREGS_OFFSET_REG(13), "r13" },
2269 { PTREGS_OFFSET_REG(14), "r14" },
2270 { PTREGS_OFFSET_REG(15), "r15" },
2271 { PTREGS_OFFSET_REG(16), "r16" },
2272 { PTREGS_OFFSET_REG(17), "r17" },
2273 { PTREGS_OFFSET_REG(18), "r18" },
2274 { PTREGS_OFFSET_REG(19), "r19" },
2275 { PTREGS_OFFSET_REG(20), "r20" },
2276 { PTREGS_OFFSET_REG(21), "r21" },
2277 { PTREGS_OFFSET_REG(22), "r22" },
2278 { PTREGS_OFFSET_REG(23), "r23" },
2279 { PTREGS_OFFSET_REG(24), "r24" },
2280 { PTREGS_OFFSET_REG(25), "r25" },
2281 { PTREGS_OFFSET_REG(26), "r26" },
2282 { PTREGS_OFFSET_REG(27), "r27" },
2283 { PTREGS_OFFSET_REG(28), "r28" },
2284 { PTREGS_OFFSET_REG(29), "r29" },
2285 { PTREGS_OFFSET_REG(30), "r30" },
2286 { PTREGS_OFFSET_REG(31), "r31" },
2287 { PTREGS_OFFSET_REG(32), "r32" },
2288 { PTREGS_OFFSET_REG(33), "r33" },
2289 { PTREGS_OFFSET_REG(34), "r34" },
2290 { PTREGS_OFFSET_REG(35), "r35" },
2291 { PTREGS_OFFSET_REG(36), "r36" },
2292 { PTREGS_OFFSET_REG(37), "r37" },
2293 { PTREGS_OFFSET_REG(38), "r38" },
2294 { PTREGS_OFFSET_REG(39), "r39" },
2295 { PTREGS_OFFSET_REG(40), "r40" },
2296 { PTREGS_OFFSET_REG(41), "r41" },
2297 { PTREGS_OFFSET_REG(42), "r42" },
2298 { PTREGS_OFFSET_REG(43), "r43" },
2299 { PTREGS_OFFSET_REG(44), "r44" },
2300 { PTREGS_OFFSET_REG(45), "r45" },
2301 { PTREGS_OFFSET_REG(46), "r46" },
2302 { PTREGS_OFFSET_REG(47), "r47" },
2303 { PTREGS_OFFSET_REG(48), "r48" },
2304 { PTREGS_OFFSET_REG(49), "r49" },
2305 { PTREGS_OFFSET_REG(50), "r50" },
2306 { PTREGS_OFFSET_REG(51), "r51" },
2307 { PTREGS_OFFSET_REG(52), "r52" },
2308 { PTREGS_OFFSET_TP, "tp" },
2309 { PTREGS_OFFSET_SP, "sp" },
2310 { PTREGS_OFFSET_LR, "lr" },
2311 { PTREGS_OFFSET_PC, "pc" },
2312 { PTREGS_OFFSET_EX1, "ex1" },
2313 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2314 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2315 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002316# endif
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002317# ifdef CRISV10
2318 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2319 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2320 { 4*PT_R13, "4*PT_R13" },
2321 { 4*PT_R12, "4*PT_R12" },
2322 { 4*PT_R11, "4*PT_R11" },
2323 { 4*PT_R10, "4*PT_R10" },
2324 { 4*PT_R9, "4*PT_R9" },
2325 { 4*PT_R8, "4*PT_R8" },
2326 { 4*PT_R7, "4*PT_R7" },
2327 { 4*PT_R6, "4*PT_R6" },
2328 { 4*PT_R5, "4*PT_R5" },
2329 { 4*PT_R4, "4*PT_R4" },
2330 { 4*PT_R3, "4*PT_R3" },
2331 { 4*PT_R2, "4*PT_R2" },
2332 { 4*PT_R1, "4*PT_R1" },
2333 { 4*PT_R0, "4*PT_R0" },
2334 { 4*PT_MOF, "4*PT_MOF" },
2335 { 4*PT_DCCR, "4*PT_DCCR" },
2336 { 4*PT_SRP, "4*PT_SRP" },
2337 { 4*PT_IRP, "4*PT_IRP" },
2338 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2339 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2340 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2341 { 4*PT_USP, "4*PT_USP" },
2342# endif
2343# ifdef CRISV32
2344 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2345 { 4*PT_R0, "4*PT_R0" },
2346 { 4*PT_R1, "4*PT_R1" },
2347 { 4*PT_R2, "4*PT_R2" },
2348 { 4*PT_R3, "4*PT_R3" },
2349 { 4*PT_R4, "4*PT_R4" },
2350 { 4*PT_R5, "4*PT_R5" },
2351 { 4*PT_R6, "4*PT_R6" },
2352 { 4*PT_R7, "4*PT_R7" },
2353 { 4*PT_R8, "4*PT_R8" },
2354 { 4*PT_R9, "4*PT_R9" },
2355 { 4*PT_R10, "4*PT_R10" },
2356 { 4*PT_R11, "4*PT_R11" },
2357 { 4*PT_R12, "4*PT_R12" },
2358 { 4*PT_R13, "4*PT_R13" },
2359 { 4*PT_ACR, "4*PT_ACR" },
2360 { 4*PT_SRS, "4*PT_SRS" },
2361 { 4*PT_MOF, "4*PT_MOF" },
2362 { 4*PT_SPC, "4*PT_SPC" },
2363 { 4*PT_CCS, "4*PT_CCS" },
2364 { 4*PT_SRP, "4*PT_SRP" },
2365 { 4*PT_ERP, "4*PT_ERP" },
2366 { 4*PT_EXS, "4*PT_EXS" },
2367 { 4*PT_EDA, "4*PT_EDA" },
2368 { 4*PT_USP, "4*PT_USP" },
2369 { 4*PT_PPC, "4*PT_PPC" },
2370 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2371 { 4*PT_BP+4, "4*PT_BP+4" },
2372 { 4*PT_BP+8, "4*PT_BP+8" },
2373 { 4*PT_BP+12, "4*PT_BP+12" },
2374 { 4*PT_BP+16, "4*PT_BP+16" },
2375 { 4*PT_BP+20, "4*PT_BP+20" },
2376 { 4*PT_BP+24, "4*PT_BP+24" },
2377 { 4*PT_BP+28, "4*PT_BP+28" },
2378 { 4*PT_BP+32, "4*PT_BP+32" },
2379 { 4*PT_BP+36, "4*PT_BP+36" },
2380 { 4*PT_BP+40, "4*PT_BP+40" },
2381 { 4*PT_BP+44, "4*PT_BP+44" },
2382 { 4*PT_BP+48, "4*PT_BP+48" },
2383 { 4*PT_BP+52, "4*PT_BP+52" },
2384 { 4*PT_BP+56, "4*PT_BP+56" },
2385# endif
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002386# ifdef MICROBLAZE
2387 { PT_GPR(0), "r0" },
2388 { PT_GPR(1), "r1" },
2389 { PT_GPR(2), "r2" },
2390 { PT_GPR(3), "r3" },
2391 { PT_GPR(4), "r4" },
2392 { PT_GPR(5), "r5" },
2393 { PT_GPR(6), "r6" },
2394 { PT_GPR(7), "r7" },
2395 { PT_GPR(8), "r8" },
2396 { PT_GPR(9), "r9" },
2397 { PT_GPR(10), "r10" },
2398 { PT_GPR(11), "r11" },
2399 { PT_GPR(12), "r12" },
2400 { PT_GPR(13), "r13" },
2401 { PT_GPR(14), "r14" },
2402 { PT_GPR(15), "r15" },
2403 { PT_GPR(16), "r16" },
2404 { PT_GPR(17), "r17" },
2405 { PT_GPR(18), "r18" },
2406 { PT_GPR(19), "r19" },
2407 { PT_GPR(20), "r20" },
2408 { PT_GPR(21), "r21" },
2409 { PT_GPR(22), "r22" },
2410 { PT_GPR(23), "r23" },
2411 { PT_GPR(24), "r24" },
2412 { PT_GPR(25), "r25" },
2413 { PT_GPR(26), "r26" },
2414 { PT_GPR(27), "r27" },
2415 { PT_GPR(28), "r28" },
2416 { PT_GPR(29), "r29" },
2417 { PT_GPR(30), "r30" },
2418 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002419 { PT_PC, "rpc", },
2420 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002421 { PT_EAR, "rear", },
2422 { PT_ESR, "resr", },
2423 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002424 { PT_KERNEL_MODE, "kernel_mode", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002425# endif
Roland McGrath542c2c62008-05-20 01:11:56 +00002426
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002427# if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \
2428 && !defined(ALPHA) && !defined(IA64) \
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002429 && !defined(CRISV10) && !defined(CRISV32) && !defined(MICROBLAZE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05002430# if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(AVR32) && !defined(BFIN) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002431 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002432# endif
2433# if defined(I386) || defined(X86_64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002434 { uoff(i387), "offsetof(struct user, i387)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002435# endif
2436# if defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002437 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002438# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002439 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2440 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2441 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002442# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002443 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002444# endif
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00002445# if defined(AVR32) || defined(SH64)
Roland McGrathe1e584b2003-06-02 19:18:58 +00002446 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002447# endif
2448# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002449 { uoff(start_stack), "offsetof(struct user, start_stack)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002450# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002451 { uoff(signal), "offsetof(struct user, signal)" },
Chris Metcalfc8c66982009-12-28 10:00:15 -05002452# if !defined(AVR32) && !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SH) && !defined(SH64) && !defined(SPARC64) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002453 { uoff(reserved), "offsetof(struct user, reserved)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002454# endif
2455# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002456 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002457# endif
Chris Metcalfc8c66982009-12-28 10:00:15 -05002458# if !defined(ARM) && !defined(AVR32) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) && !defined(BFIN) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002459 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002460# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002461 { uoff(magic), "offsetof(struct user, magic)" },
2462 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002463# if defined(I386) || defined(X86_64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002464 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002465# endif
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002466# endif /* !defined(many arches) */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002467
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002468
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002469# ifndef HPPA
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002470 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002471# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002472 { 0, NULL },
2473};
2474
2475int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002476sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002477{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002478 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002479 long addr;
2480
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002481 if (entering(tcp)) {
Roland McGrathbf621d42003-01-14 09:46:21 +00002482 printxval(ptrace_cmds, tcp->u_arg[0],
Roland McGrathbf621d42003-01-14 09:46:21 +00002483 "PTRACE_???"
Roland McGrathbf621d42003-01-14 09:46:21 +00002484 );
2485 tprintf(", %lu, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002486 addr = tcp->u_arg[2];
2487 if (tcp->u_arg[0] == PTRACE_PEEKUSER
2488 || tcp->u_arg[0] == PTRACE_POKEUSER) {
2489 for (x = struct_user_offsets; x->str; x++) {
2490 if (x->val >= addr)
2491 break;
2492 }
2493 if (!x->str)
2494 tprintf("%#lx, ", addr);
2495 else if (x->val > addr && x != struct_user_offsets) {
2496 x--;
2497 tprintf("%s + %ld, ", x->str, addr - x->val);
2498 }
2499 else
2500 tprintf("%s, ", x->str);
2501 }
2502 else
2503 tprintf("%#lx, ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002504 switch (tcp->u_arg[0]) {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002505# ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002506 case PTRACE_PEEKDATA:
2507 case PTRACE_PEEKTEXT:
2508 case PTRACE_PEEKUSER:
2509 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002510# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002511 case PTRACE_CONT:
2512 case PTRACE_SINGLESTEP:
2513 case PTRACE_SYSCALL:
2514 case PTRACE_DETACH:
2515 printsignal(tcp->u_arg[3]);
2516 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002517# ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002518 case PTRACE_SETOPTIONS:
2519 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2520 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002521# endif
2522# ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002523 case PTRACE_SETSIGINFO: {
2524 siginfo_t si;
2525 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002526 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002527 else if (syserror(tcp))
2528 tprintf("%#lx", tcp->u_arg[3]);
2529 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002530 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002531 else
2532 printsiginfo(&si, verbose(tcp));
2533 break;
2534 }
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002535# endif
2536# ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002537 case PTRACE_GETSIGINFO:
2538 /* Don't print anything, do it at syscall return. */
2539 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002540# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002541 default:
2542 tprintf("%#lx", tcp->u_arg[3]);
2543 break;
2544 }
2545 } else {
2546 switch (tcp->u_arg[0]) {
2547 case PTRACE_PEEKDATA:
2548 case PTRACE_PEEKTEXT:
2549 case PTRACE_PEEKUSER:
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002550# ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002551 return RVAL_HEX;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002552# else
Roland McGratheb285352003-01-14 09:59:00 +00002553 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002554 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002555# endif
2556# ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002557 case PTRACE_GETSIGINFO: {
2558 siginfo_t si;
2559 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002560 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002561 else if (syserror(tcp))
2562 tprintf("%#lx", tcp->u_arg[3]);
2563 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002564 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002565 else
2566 printsiginfo(&si, verbose(tcp));
2567 break;
2568 }
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002569# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002570 }
2571 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002572 return 0;
2573}
2574
Roland McGrath5a223472002-12-15 23:58:26 +00002575
Roland McGrath51942a92007-07-05 18:59:11 +00002576# ifndef FUTEX_CMP_REQUEUE
2577# define FUTEX_CMP_REQUEUE 4
2578# endif
2579# ifndef FUTEX_WAKE_OP
2580# define FUTEX_WAKE_OP 5
2581# endif
2582# ifndef FUTEX_LOCK_PI
2583# define FUTEX_LOCK_PI 6
2584# define FUTEX_UNLOCK_PI 7
2585# define FUTEX_TRYLOCK_PI 8
2586# endif
Roland McGrath1aeaf742008-07-18 01:27:39 +00002587# ifndef FUTEX_WAIT_BITSET
2588# define FUTEX_WAIT_BITSET 9
2589# endif
2590# ifndef FUTEX_WAKE_BITSET
2591# define FUTEX_WAKE_BITSET 10
Roland McGrath51942a92007-07-05 18:59:11 +00002592# endif
Andreas Schwab85f58322009-08-12 09:54:42 +02002593# ifndef FUTEX_WAIT_REQUEUE_PI
2594# define FUTEX_WAIT_REQUEUE_PI 11
2595# endif
2596# ifndef FUTEX_CMP_REQUEUE_PI
2597# define FUTEX_CMP_REQUEUE_PI 12
2598# endif
Roland McGrath51942a92007-07-05 18:59:11 +00002599# ifndef FUTEX_PRIVATE_FLAG
2600# define FUTEX_PRIVATE_FLAG 128
2601# endif
Andreas Schwab85f58322009-08-12 09:54:42 +02002602# ifndef FUTEX_CLOCK_REALTIME
2603# define FUTEX_CLOCK_REALTIME 256
2604# endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002605static const struct xlat futexops[] = {
Roland McGrath51942a92007-07-05 18:59:11 +00002606 { FUTEX_WAIT, "FUTEX_WAIT" },
2607 { FUTEX_WAKE, "FUTEX_WAKE" },
2608 { FUTEX_FD, "FUTEX_FD" },
2609 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2610 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2611 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2612 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2613 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2614 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002615 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2616 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002617 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2618 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
Roland McGrath51942a92007-07-05 18:59:11 +00002619 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2620 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2621 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2622 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2623 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2624 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2625 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2626 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2627 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002628 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2629 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002630 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2631 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2632 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2633 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2634 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2635 { 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 +00002636 { 0, NULL }
2637};
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002638# ifndef FUTEX_OP_SET
2639# define FUTEX_OP_SET 0
2640# define FUTEX_OP_ADD 1
2641# define FUTEX_OP_OR 2
2642# define FUTEX_OP_ANDN 3
2643# define FUTEX_OP_XOR 4
2644# define FUTEX_OP_CMP_EQ 0
2645# define FUTEX_OP_CMP_NE 1
2646# define FUTEX_OP_CMP_LT 2
2647# define FUTEX_OP_CMP_LE 3
2648# define FUTEX_OP_CMP_GT 4
2649# define FUTEX_OP_CMP_GE 5
2650# endif
Roland McGrath51942a92007-07-05 18:59:11 +00002651static const struct xlat futexwakeops[] = {
2652 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2653 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2654 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2655 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2656 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2657 { 0, NULL }
2658};
2659static const struct xlat futexwakecmps[] = {
2660 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2661 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2662 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2663 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2664 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2665 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2666 { 0, NULL }
Roland McGrath5a223472002-12-15 23:58:26 +00002667};
2668
2669int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002670sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002671{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002672 if (entering(tcp)) {
2673 long int cmd = tcp->u_arg[1] & 127;
2674 tprintf("%p, ", (void *) tcp->u_arg[0]);
2675 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2676 tprintf(", %ld", tcp->u_arg[2]);
2677 if (cmd == FUTEX_WAKE_BITSET)
2678 tprintf(", %lx", tcp->u_arg[5]);
2679 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002680 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002681 printtv(tcp, tcp->u_arg[3]);
2682 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002683 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002684 printtv(tcp, tcp->u_arg[3]);
2685 tprintf(", %lx", tcp->u_arg[5]);
2686 } else if (cmd == FUTEX_REQUEUE)
2687 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002688 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002689 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2690 else if (cmd == FUTEX_WAKE_OP) {
2691 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2692 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002693 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002694 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2695 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2696 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002697 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002698 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2699 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002700 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002701 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002702 printtv(tcp, tcp->u_arg[3]);
2703 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002704 }
Roland McGrath51942a92007-07-05 18:59:11 +00002705 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002706 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002707}
2708
2709static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002710print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002711{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002712 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002713 unsigned long w, min_len;
2714
2715 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2716 min_len = len - max_strlen * sizeof(w);
2717 else
2718 min_len = 0;
2719 for (; len >= sizeof(w) && len > min_len;
2720 len -= sizeof(w), list += sizeof(w)) {
2721 if (umove(tcp, list, &w) < 0)
2722 break;
2723 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002724 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002725 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002726 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002727 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002728 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002729 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002730 if (len) {
2731 if (first)
2732 tprintf("%#lx", list);
2733 else
2734 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2735 "???" : "..."));
2736 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002737 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002738 }
Roland McGrath5a223472002-12-15 23:58:26 +00002739}
2740
2741int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002742sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002743{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002744 if (entering(tcp)) {
2745 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2746 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2747 }
2748 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002749}
2750
2751int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002752sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002753{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002754 if (entering(tcp)) {
2755 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2756 } else {
2757 if (tcp->u_rval == -1)
2758 tprintf("%#lx", tcp->u_arg[2]);
2759 else
2760 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2761 }
2762 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002763}
Roland McGrath279d3782004-03-01 20:27:37 +00002764
Roland McGrathd9f816f2004-09-04 03:39:20 +00002765static const struct xlat schedulers[] = {
Roland McGrath279d3782004-03-01 20:27:37 +00002766 { SCHED_OTHER, "SCHED_OTHER" },
2767 { SCHED_RR, "SCHED_RR" },
2768 { SCHED_FIFO, "SCHED_FIFO" },
2769 { 0, NULL }
2770};
2771
2772int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002773sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002774{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002775 if (entering(tcp)) {
2776 tprintf("%d", (int) tcp->u_arg[0]);
2777 } else if (! syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002778 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002779 if (tcp->auxstr != NULL)
2780 return RVAL_STR;
2781 }
2782 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002783}
2784
2785int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002786sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002787{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002788 if (entering(tcp)) {
2789 struct sched_param p;
2790 tprintf("%d, ", (int) tcp->u_arg[0]);
2791 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2792 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2793 tprintf(", %#lx", tcp->u_arg[2]);
2794 else
2795 tprintf(", { %d }", p.__sched_priority);
2796 }
2797 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002798}
2799
2800int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002801sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002802{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002803 if (entering(tcp)) {
2804 tprintf("%d, ", (int) tcp->u_arg[0]);
2805 } else {
2806 struct sched_param p;
2807 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2808 tprintf("%#lx", tcp->u_arg[1]);
2809 else
2810 tprintf("{ %d }", p.__sched_priority);
2811 }
2812 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002813}
2814
2815int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002816sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002817{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002818 if (entering(tcp)) {
2819 struct sched_param p;
2820 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2821 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2822 else
2823 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2824 }
2825 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002826}
2827
2828int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002829sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002830{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002831 if (entering(tcp)) {
2832 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2833 }
2834 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002835}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002836
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002837# ifdef X86_64
2838# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002839
2840static const struct xlat archvals[] = {
2841 { ARCH_SET_GS, "ARCH_SET_GS" },
2842 { ARCH_SET_FS, "ARCH_SET_FS" },
2843 { ARCH_GET_FS, "ARCH_GET_FS" },
2844 { ARCH_GET_GS, "ARCH_GET_GS" },
2845 { 0, NULL },
2846};
2847
2848int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002849sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002850{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002851 if (entering(tcp)) {
2852 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2853 if (tcp->u_arg[0] == ARCH_SET_GS
2854 || tcp->u_arg[0] == ARCH_SET_FS
2855 ) {
2856 tprintf(", %#lx", tcp->u_arg[1]);
2857 }
2858 } else {
2859 if (tcp->u_arg[0] == ARCH_GET_GS
2860 || tcp->u_arg[0] == ARCH_GET_FS
2861 ) {
2862 long int v;
2863 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2864 tprintf(", [%#lx]", v);
2865 else
2866 tprintf(", %#lx", tcp->u_arg[1]);
2867 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002868 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002869 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002870}
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002871# endif /* X86_64 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002872
Roland McGrathdb8319f2007-08-02 01:37:55 +00002873
2874int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002875sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002876{
2877 if (exiting(tcp)) {
2878 unsigned u;
2879 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002880 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002881 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2882 tprintf("%#lx, ", tcp->u_arg[0]);
2883 else
2884 tprintf("[%u], ", u);
2885 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002886 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002887 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2888 tprintf("%#lx, ", tcp->u_arg[1]);
2889 else
2890 tprintf("[%u], ", u);
2891 tprintf("%#lx", tcp->u_arg[2]);
2892 }
2893 return 0;
2894}
2895
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002896int
2897sys_process_vm_readv(struct tcb *tcp)
2898{
2899 if (entering(tcp)) {
2900 /* arg 1: pid */
2901 tprintf("%ld, ", tcp->u_arg[0]);
2902 } else {
2903 /* args 2,3: local iov,cnt */
2904 if (syserror(tcp)) {
2905 tprintf("%#lx, %lu",
2906 tcp->u_arg[1], tcp->u_arg[2]);
2907 } else {
2908 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2909 }
2910 tprints(", ");
2911 /* args 4,5: remote iov,cnt */
2912 if (syserror(tcp)) {
2913 tprintf("%#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
2914 } else {
2915 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2916 }
2917 /* arg 6: flags */
2918 tprintf(", %lu", tcp->u_arg[5]);
2919 }
2920 return 0;
2921}