blob: 20cfe206b0847ad96c040d073cae5c24611a29f4 [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>
Denys Vlasenko84703742012-02-25 02:38:52 +010055# ifndef PTRACE_PEEKUSR
56# define PTRACE_PEEKUSR PTRACE_PEEKUSER
57# endif
58# ifndef PTRACE_POKEUSR
59# 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
Denys Vlasenko84703742012-02-25 02:38:52 +010064# 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
Denys Vlasenko84703742012-02-25 02:38:52 +010071# 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
Denys Vlasenko84703742012-02-25 02:38:52 +010076#if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +000077# 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
Denys Vlasenko84703742012-02-25 02:38:52 +010082#endif
Roland McGrath6d1a65c2004-07-12 07:44:08 +000083
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
Denys Vlasenko84703742012-02-25 02:38:52 +010087#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
96#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
Denys Vlasenko84703742012-02-25 02:38:52 +0100107#if defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000108# 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
Denys Vlasenko84703742012-02-25 02:38:52 +0100363#if defined(ALPHA)
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}
Denys Vlasenko84703742012-02-25 02:38:52 +0100376#endif
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
Denys Vlasenko84703742012-02-25 02:38:52 +01001071#if defined(ALPHA)
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}
Denys Vlasenko84703742012-02-25 02:38:52 +01001080#endif
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
Denys Vlasenko84703742012-02-25 02:38:52 +01001168#if defined(SPARC) || defined(SPARC64)
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}
Denys Vlasenko84703742012-02-25 02:38:52 +01001184#endif
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 Vlasenko84703742012-02-25 02:38:52 +01001212#if 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{
Roland McGrathfdb097f2004-07-12 07:38:55 +00001216 if (exiting(tcp) && syserror(tcp))
1217 tcp->flags &= ~TCB_WAITEXECVE;
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001218 else {
1219 /* Maybe we have post-execve SIGTRAP suppressed? */
Denys Vlasenkof44cce42011-06-21 14:34:10 +02001220 if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC))
Denys Vlasenkof8bc0652011-05-24 20:30:24 +02001221 tcp->flags |= TCB_WAITEXECVE; /* no */
1222 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001223 return 0;
1224}
Denys Vlasenkoa7949742011-08-21 17:26:55 +02001225#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001226
Roland McGrath7ec1d352002-12-17 04:50:44 +00001227#ifndef __WNOTHREAD
1228#define __WNOTHREAD 0x20000000
1229#endif
1230#ifndef __WALL
1231#define __WALL 0x40000000
1232#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001233#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +00001234#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001235#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001236
Roland McGrathd9f816f2004-09-04 03:39:20 +00001237static const struct xlat wait4_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001238 { WNOHANG, "WNOHANG" },
1239#ifndef WSTOPPED
1240 { WUNTRACED, "WUNTRACED" },
1241#endif
1242#ifdef WEXITED
1243 { WEXITED, "WEXITED" },
1244#endif
1245#ifdef WTRAPPED
1246 { WTRAPPED, "WTRAPPED" },
1247#endif
1248#ifdef WSTOPPED
1249 { WSTOPPED, "WSTOPPED" },
1250#endif
1251#ifdef WCONTINUED
1252 { WCONTINUED, "WCONTINUED" },
1253#endif
1254#ifdef WNOWAIT
1255 { WNOWAIT, "WNOWAIT" },
1256#endif
1257#ifdef __WCLONE
1258 { __WCLONE, "__WCLONE" },
1259#endif
Roland McGrath7ec1d352002-12-17 04:50:44 +00001260#ifdef __WALL
1261 { __WALL, "__WALL" },
1262#endif
1263#ifdef __WNOTHREAD
1264 { __WNOTHREAD, "__WNOTHREAD" },
1265#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001266 { 0, NULL },
1267};
1268
Roland McGrath5e02a572004-10-19 23:33:47 +00001269#if !defined WCOREFLAG && defined WCOREFLG
1270# define WCOREFLAG WCOREFLG
1271#endif
1272#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001273# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +00001274#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001275#ifndef WCOREDUMP
1276# define WCOREDUMP(status) ((status) & 0200)
1277#endif
1278
Roland McGrath5e02a572004-10-19 23:33:47 +00001279
1280#ifndef W_STOPCODE
1281#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
1282#endif
1283#ifndef W_EXITCODE
1284#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
1285#endif
1286
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001287static int
Denys Vlasenko12014262011-05-30 14:00:14 +02001288printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001289{
1290 int exited = 0;
1291
1292 /*
1293 * Here is a tricky presentation problem. This solution
1294 * is still not entirely satisfactory but since there
1295 * are no wait status constructors it will have to do.
1296 */
Roland McGrath79fbda52004-04-14 02:45:55 +00001297 if (WIFSTOPPED(status)) {
1298 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001299 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +00001300 status &= ~W_STOPCODE(WSTOPSIG(status));
1301 }
1302 else if (WIFSIGNALED(status)) {
1303 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001304 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001305 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +00001306 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1307 }
1308 else if (WIFEXITED(status)) {
1309 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001310 WEXITSTATUS(status));
1311 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +00001312 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001313 }
Roland McGrath79fbda52004-04-14 02:45:55 +00001314 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001315 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001316 return 0;
1317 }
1318
1319 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001320 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +00001321 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +00001322 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001323
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001324 return exited;
1325}
1326
1327static int
Denys Vlasenko59432db2009-01-26 19:09:35 +00001328printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001329{
1330 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001331
1332 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001333 /* On Linux, kernel-side pid_t is typedef'ed to int
1334 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +00001335 * pid argument to int on 64bit arches, producing,
1336 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001337 * in strace. We have to use int here, not long.
1338 */
1339 int pid = tcp->u_arg[0];
1340 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001341 } else {
1342 /* status */
1343 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001344 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001345 else if (syserror(tcp) || tcp->u_rval == 0)
1346 tprintf("%#lx", tcp->u_arg[1]);
1347 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001348 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001349 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +00001350 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001351 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001352 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001353 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001354 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001355 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001356 /* usage */
1357 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001358 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001359 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +00001360#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001361 if (bitness)
1362 printrusage32(tcp, tcp->u_arg[3]);
1363 else
1364#endif
1365 printrusage(tcp, tcp->u_arg[3]);
1366 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001367 else
1368 tprintf("%#lx", tcp->u_arg[3]);
1369 }
1370 }
1371 return 0;
1372}
1373
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001374
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001375
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001376int
Denys Vlasenko12014262011-05-30 14:00:14 +02001377sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001378{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001379 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001380}
1381
1382int
Denys Vlasenko12014262011-05-30 14:00:14 +02001383sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001384{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001385 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001386}
1387
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001388#ifdef ALPHA
1389int
Denys Vlasenko12014262011-05-30 14:00:14 +02001390sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001391{
1392 return printwaitn(tcp, 4, 1);
1393}
1394#endif
1395
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001396
Roland McGrathd9f816f2004-09-04 03:39:20 +00001397static const struct xlat waitid_types[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001398 { P_PID, "P_PID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001399#ifdef P_PPID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001400 { P_PPID, "P_PPID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001401#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001402 { P_PGID, "P_PGID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001403#ifdef P_SID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001404 { P_SID, "P_SID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001405#endif
1406#ifdef P_CID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001407 { P_CID, "P_CID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001408#endif
1409#ifdef P_UID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001410 { P_UID, "P_UID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001411#endif
1412#ifdef P_GID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001413 { P_GID, "P_GID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001414#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001415 { P_ALL, "P_ALL" },
1416#ifdef P_LWPID
1417 { P_LWPID, "P_LWPID" },
1418#endif
1419 { 0, NULL },
1420};
1421
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001422int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +00001423sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001424{
1425 siginfo_t si;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001426
1427 if (entering(tcp)) {
1428 printxval(waitid_types, tcp->u_arg[0], "P_???");
1429 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001430 }
1431 else {
1432 /* siginfo */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001433 if (!tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001434 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001435 else if (syserror(tcp))
1436 tprintf("%#lx", tcp->u_arg[2]);
1437 else if (umove(tcp, tcp->u_arg[2], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001438 tprints("{???}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001439 else
Denys Vlasenkof535b542009-01-13 18:30:55 +00001440 printsiginfo(&si, verbose(tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001441 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001442 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001443 printflags(wait4_options, tcp->u_arg[3], "W???");
Roland McGrath39426a32004-10-06 22:02:59 +00001444 if (tcp->u_nargs > 4) {
1445 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001446 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +00001447 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001448 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +00001449 else if (tcp->u_error)
1450 tprintf("%#lx", tcp->u_arg[4]);
1451 else
1452 printrusage(tcp, tcp->u_arg[4]);
1453 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001454 }
1455 return 0;
1456}
1457
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001458
1459int
Denys Vlasenko12014262011-05-30 14:00:14 +02001460sys_alarm(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001461{
1462 if (entering(tcp))
1463 tprintf("%lu", tcp->u_arg[0]);
1464 return 0;
1465}
1466
1467int
Denys Vlasenko12014262011-05-30 14:00:14 +02001468sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001469{
1470 struct utsname uname;
1471
1472 if (exiting(tcp)) {
1473 if (syserror(tcp) || !verbose(tcp))
1474 tprintf("%#lx", tcp->u_arg[0]);
1475 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001476 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001477 else if (!abbrev(tcp)) {
1478
1479 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1480 uname.sysname, uname.nodename);
1481 tprintf("release=\"%s\", version=\"%s\", ",
1482 uname.release, uname.version);
1483 tprintf("machine=\"%s\"", uname.machine);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001484#ifndef __GLIBC__
1485 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001486#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001487 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001488 }
1489 else
1490 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1491 uname.sysname, uname.nodename);
1492 }
1493 return 0;
1494}
1495
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001496
Roland McGratheb9e2e82009-06-02 16:49:22 -07001497static const struct xlat ptrace_cmds[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001498 { PTRACE_TRACEME, "PTRACE_TRACEME" },
Denys Vlasenko61526c62011-08-25 10:21:13 +02001499 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1500 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1501 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1502 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1503 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1504 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001505 { PTRACE_CONT, "PTRACE_CONT" },
1506 { PTRACE_KILL, "PTRACE_KILL" },
1507 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1508 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1509 { PTRACE_DETACH, "PTRACE_DETACH" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001510# ifdef PTRACE_GETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001511 { PTRACE_GETREGS, "PTRACE_GETREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001512# endif
1513# ifdef PTRACE_SETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001514 { PTRACE_SETREGS, "PTRACE_SETREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001515# endif
1516# ifdef PTRACE_GETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001517 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001518# endif
1519# ifdef PTRACE_SETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001520 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001521# endif
1522# ifdef PTRACE_GETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001523 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001524# endif
1525# ifdef PTRACE_SETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001526 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001527# endif
1528# ifdef PTRACE_GETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001529 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001530# endif
1531# ifdef PTRACE_SETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001532 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001533# endif
1534# ifdef PTRACE_SETOPTIONS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001535 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001536# endif
1537# ifdef PTRACE_GETEVENTMSG
Denys Vlasenko61526c62011-08-25 10:21:13 +02001538 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001539# endif
1540# ifdef PTRACE_GETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001541 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001542# endif
1543# ifdef PTRACE_SETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001544 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001545# endif
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001546# ifdef PTRACE_GETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001547 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001548# endif
1549# ifdef PTRACE_SETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001550 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
Dmitry V. Levinbb668a52011-03-14 21:58:59 +00001551# endif
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001552# ifdef PTRACE_SET_SYSCALL
Denys Vlasenko61526c62011-08-25 10:21:13 +02001553 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001554# endif
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001555# ifdef PTRACE_SEIZE
1556 { PTRACE_SEIZE, "PTRACE_SEIZE" },
1557# endif
1558# ifdef PTRACE_INTERRUPT
1559 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
1560# endif
1561# ifdef PTRACE_LISTEN
1562 { PTRACE_LISTEN, "PTRACE_LISTEN" },
1563# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001564 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
Denys Vlasenkof535b542009-01-13 18:30:55 +00001565
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001566 { 0, NULL },
1567};
1568
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001569# ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00001570static const struct xlat ptrace_setoptions_flags[] = {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001571# ifdef PTRACE_O_TRACESYSGOOD
Denys Vlasenkof535b542009-01-13 18:30:55 +00001572 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001573# endif
1574# ifdef PTRACE_O_TRACEFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001575 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001576# endif
1577# ifdef PTRACE_O_TRACEVFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001578 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001579# endif
1580# ifdef PTRACE_O_TRACECLONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001581 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001582# endif
1583# ifdef PTRACE_O_TRACEEXEC
Denys Vlasenkof535b542009-01-13 18:30:55 +00001584 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001585# endif
1586# ifdef PTRACE_O_TRACEVFORKDONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001587 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001588# endif
1589# ifdef PTRACE_O_TRACEEXIT
Denys Vlasenkof535b542009-01-13 18:30:55 +00001590 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001591# endif
Denys Vlasenkof535b542009-01-13 18:30:55 +00001592 { 0, NULL },
1593};
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001594# endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001595
Roland McGrathd9f816f2004-09-04 03:39:20 +00001596const struct xlat struct_user_offsets[] = {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001597# if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001598 { PT_PSWMASK, "psw_mask" },
1599 { PT_PSWADDR, "psw_addr" },
1600 { PT_GPR0, "gpr0" },
1601 { PT_GPR1, "gpr1" },
1602 { PT_GPR2, "gpr2" },
1603 { PT_GPR3, "gpr3" },
1604 { PT_GPR4, "gpr4" },
1605 { PT_GPR5, "gpr5" },
1606 { PT_GPR6, "gpr6" },
1607 { PT_GPR7, "gpr7" },
1608 { PT_GPR8, "gpr8" },
1609 { PT_GPR9, "gpr9" },
1610 { PT_GPR10, "gpr10" },
1611 { PT_GPR11, "gpr11" },
1612 { PT_GPR12, "gpr12" },
1613 { PT_GPR13, "gpr13" },
1614 { PT_GPR14, "gpr14" },
1615 { PT_GPR15, "gpr15" },
1616 { PT_ACR0, "acr0" },
1617 { PT_ACR1, "acr1" },
1618 { PT_ACR2, "acr2" },
1619 { PT_ACR3, "acr3" },
1620 { PT_ACR4, "acr4" },
1621 { PT_ACR5, "acr5" },
1622 { PT_ACR6, "acr6" },
1623 { PT_ACR7, "acr7" },
1624 { PT_ACR8, "acr8" },
1625 { PT_ACR9, "acr9" },
1626 { PT_ACR10, "acr10" },
1627 { PT_ACR11, "acr11" },
1628 { PT_ACR12, "acr12" },
1629 { PT_ACR13, "acr13" },
1630 { PT_ACR14, "acr14" },
1631 { PT_ACR15, "acr15" },
1632 { PT_ORIGGPR2, "orig_gpr2" },
1633 { PT_FPC, "fpc" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001634# if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001635 { PT_FPR0_HI, "fpr0.hi" },
1636 { PT_FPR0_LO, "fpr0.lo" },
1637 { PT_FPR1_HI, "fpr1.hi" },
1638 { PT_FPR1_LO, "fpr1.lo" },
1639 { PT_FPR2_HI, "fpr2.hi" },
1640 { PT_FPR2_LO, "fpr2.lo" },
1641 { PT_FPR3_HI, "fpr3.hi" },
1642 { PT_FPR3_LO, "fpr3.lo" },
1643 { PT_FPR4_HI, "fpr4.hi" },
1644 { PT_FPR4_LO, "fpr4.lo" },
1645 { PT_FPR5_HI, "fpr5.hi" },
1646 { PT_FPR5_LO, "fpr5.lo" },
1647 { PT_FPR6_HI, "fpr6.hi" },
1648 { PT_FPR6_LO, "fpr6.lo" },
1649 { PT_FPR7_HI, "fpr7.hi" },
1650 { PT_FPR7_LO, "fpr7.lo" },
1651 { PT_FPR8_HI, "fpr8.hi" },
1652 { PT_FPR8_LO, "fpr8.lo" },
1653 { PT_FPR9_HI, "fpr9.hi" },
1654 { PT_FPR9_LO, "fpr9.lo" },
1655 { PT_FPR10_HI, "fpr10.hi" },
1656 { PT_FPR10_LO, "fpr10.lo" },
1657 { PT_FPR11_HI, "fpr11.hi" },
1658 { PT_FPR11_LO, "fpr11.lo" },
1659 { PT_FPR12_HI, "fpr12.hi" },
1660 { PT_FPR12_LO, "fpr12.lo" },
1661 { PT_FPR13_HI, "fpr13.hi" },
1662 { PT_FPR13_LO, "fpr13.lo" },
1663 { PT_FPR14_HI, "fpr14.hi" },
1664 { PT_FPR14_LO, "fpr14.lo" },
1665 { PT_FPR15_HI, "fpr15.hi" },
1666 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001667# endif
1668# if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001669 { PT_FPR0, "fpr0" },
1670 { PT_FPR1, "fpr1" },
1671 { PT_FPR2, "fpr2" },
1672 { PT_FPR3, "fpr3" },
1673 { PT_FPR4, "fpr4" },
1674 { PT_FPR5, "fpr5" },
1675 { PT_FPR6, "fpr6" },
1676 { PT_FPR7, "fpr7" },
1677 { PT_FPR8, "fpr8" },
1678 { PT_FPR9, "fpr9" },
1679 { PT_FPR10, "fpr10" },
1680 { PT_FPR11, "fpr11" },
1681 { PT_FPR12, "fpr12" },
1682 { PT_FPR13, "fpr13" },
1683 { PT_FPR14, "fpr14" },
1684 { PT_FPR15, "fpr15" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001685# endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001686 { PT_CR_9, "cr9" },
1687 { PT_CR_10, "cr10" },
1688 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001689 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001690# elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001691 /* XXX No support for these offsets yet. */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001692# elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001693 /* XXX No support for these offsets yet. */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001694# elif defined(POWERPC)
1695# ifndef PT_ORIG_R3
1696# define PT_ORIG_R3 34
1697# endif
1698# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001699 { REGSIZE*PT_R0, "r0" },
1700 { REGSIZE*PT_R1, "r1" },
1701 { REGSIZE*PT_R2, "r2" },
1702 { REGSIZE*PT_R3, "r3" },
1703 { REGSIZE*PT_R4, "r4" },
1704 { REGSIZE*PT_R5, "r5" },
1705 { REGSIZE*PT_R6, "r6" },
1706 { REGSIZE*PT_R7, "r7" },
1707 { REGSIZE*PT_R8, "r8" },
1708 { REGSIZE*PT_R9, "r9" },
1709 { REGSIZE*PT_R10, "r10" },
1710 { REGSIZE*PT_R11, "r11" },
1711 { REGSIZE*PT_R12, "r12" },
1712 { REGSIZE*PT_R13, "r13" },
1713 { REGSIZE*PT_R14, "r14" },
1714 { REGSIZE*PT_R15, "r15" },
1715 { REGSIZE*PT_R16, "r16" },
1716 { REGSIZE*PT_R17, "r17" },
1717 { REGSIZE*PT_R18, "r18" },
1718 { REGSIZE*PT_R19, "r19" },
1719 { REGSIZE*PT_R20, "r20" },
1720 { REGSIZE*PT_R21, "r21" },
1721 { REGSIZE*PT_R22, "r22" },
1722 { REGSIZE*PT_R23, "r23" },
1723 { REGSIZE*PT_R24, "r24" },
1724 { REGSIZE*PT_R25, "r25" },
1725 { REGSIZE*PT_R26, "r26" },
1726 { REGSIZE*PT_R27, "r27" },
1727 { REGSIZE*PT_R28, "r28" },
1728 { REGSIZE*PT_R29, "r29" },
1729 { REGSIZE*PT_R30, "r30" },
1730 { REGSIZE*PT_R31, "r31" },
1731 { REGSIZE*PT_NIP, "NIP" },
1732 { REGSIZE*PT_MSR, "MSR" },
1733 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1734 { REGSIZE*PT_CTR, "CTR" },
1735 { REGSIZE*PT_LNK, "LNK" },
1736 { REGSIZE*PT_XER, "XER" },
1737 { REGSIZE*PT_CCR, "CCR" },
1738 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001739# undef REGSIZE
1740# elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001741 { 0, "r0" },
1742 { 1, "r1" },
1743 { 2, "r2" },
1744 { 3, "r3" },
1745 { 4, "r4" },
1746 { 5, "r5" },
1747 { 6, "r6" },
1748 { 7, "r7" },
1749 { 8, "r8" },
1750 { 9, "r9" },
1751 { 10, "r10" },
1752 { 11, "r11" },
1753 { 12, "r12" },
1754 { 13, "r13" },
1755 { 14, "r14" },
1756 { 15, "r15" },
1757 { 16, "r16" },
1758 { 17, "r17" },
1759 { 18, "r18" },
1760 { 19, "r19" },
1761 { 20, "r20" },
1762 { 21, "r21" },
1763 { 22, "r22" },
1764 { 23, "r23" },
1765 { 24, "r24" },
1766 { 25, "r25" },
1767 { 26, "r26" },
1768 { 27, "r27" },
1769 { 28, "r28" },
1770 { 29, "gp" },
1771 { 30, "fp" },
1772 { 31, "zero" },
1773 { 32, "fp0" },
1774 { 33, "fp" },
1775 { 34, "fp2" },
1776 { 35, "fp3" },
1777 { 36, "fp4" },
1778 { 37, "fp5" },
1779 { 38, "fp6" },
1780 { 39, "fp7" },
1781 { 40, "fp8" },
1782 { 41, "fp9" },
1783 { 42, "fp10" },
1784 { 43, "fp11" },
1785 { 44, "fp12" },
1786 { 45, "fp13" },
1787 { 46, "fp14" },
1788 { 47, "fp15" },
1789 { 48, "fp16" },
1790 { 49, "fp17" },
1791 { 50, "fp18" },
1792 { 51, "fp19" },
1793 { 52, "fp20" },
1794 { 53, "fp21" },
1795 { 54, "fp22" },
1796 { 55, "fp23" },
1797 { 56, "fp24" },
1798 { 57, "fp25" },
1799 { 58, "fp26" },
1800 { 59, "fp27" },
1801 { 60, "fp28" },
1802 { 61, "fp29" },
1803 { 62, "fp30" },
1804 { 63, "fp31" },
1805 { 64, "pc" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001806# elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001807 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1808 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1809 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1810 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1811 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1812 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1813 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1814 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1815 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1816 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1817 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1818 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1819 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1820 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1821 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1822 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1823 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1824 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1825 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1826 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1827 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1828 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1829 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1830 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1831 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1832 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1833 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1834 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1835 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1836 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1837 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1838 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1839 /* switch stack: */
1840 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1841 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1842 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1843 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1844 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1845 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1846 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1847 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1848 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1849 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001850 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1851 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001852 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001853 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001854 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1855 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001856 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1857 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1858 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1859 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1860 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1861 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1862 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1863 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1864 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1865 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1866 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1867 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1868 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1869 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1870 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001871# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001872 { PT_AR_CSD, "ar.csd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001873# endif
1874# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001875 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001876# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001877 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001878# elif defined(I386)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001879 { 4*EBX, "4*EBX" },
1880 { 4*ECX, "4*ECX" },
1881 { 4*EDX, "4*EDX" },
1882 { 4*ESI, "4*ESI" },
1883 { 4*EDI, "4*EDI" },
1884 { 4*EBP, "4*EBP" },
1885 { 4*EAX, "4*EAX" },
1886 { 4*DS, "4*DS" },
1887 { 4*ES, "4*ES" },
1888 { 4*FS, "4*FS" },
1889 { 4*GS, "4*GS" },
1890 { 4*ORIG_EAX, "4*ORIG_EAX" },
1891 { 4*EIP, "4*EIP" },
1892 { 4*CS, "4*CS" },
1893 { 4*EFL, "4*EFL" },
1894 { 4*UESP, "4*UESP" },
1895 { 4*SS, "4*SS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001896# elif defined(X86_64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001897 { 8*R15, "8*R15" },
1898 { 8*R14, "8*R14" },
1899 { 8*R13, "8*R13" },
1900 { 8*R12, "8*R12" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001901 { 8*RBP, "8*RBP" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001902 { 8*RBX, "8*RBX" },
1903 { 8*R11, "8*R11" },
1904 { 8*R10, "8*R10" },
1905 { 8*R9, "8*R9" },
1906 { 8*R8, "8*R8" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001907 { 8*RAX, "8*RAX" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001908 { 8*RCX, "8*RCX" },
1909 { 8*RDX, "8*RDX" },
1910 { 8*RSI, "8*RSI" },
1911 { 8*RDI, "8*RDI" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001912 { 8*ORIG_RAX, "8*ORIG_RAX" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001913 { 8*RIP, "8*RIP" },
1914 { 8*CS, "8*CS" },
1915 { 8*EFLAGS, "8*EFL" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001916 { 8*RSP, "8*RSP" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001917 { 8*SS, "8*SS" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001918# elif defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001919 { 4*PT_D1, "4*PT_D1" },
1920 { 4*PT_D2, "4*PT_D2" },
1921 { 4*PT_D3, "4*PT_D3" },
1922 { 4*PT_D4, "4*PT_D4" },
1923 { 4*PT_D5, "4*PT_D5" },
1924 { 4*PT_D6, "4*PT_D6" },
1925 { 4*PT_D7, "4*PT_D7" },
1926 { 4*PT_A0, "4*PT_A0" },
1927 { 4*PT_A1, "4*PT_A1" },
1928 { 4*PT_A2, "4*PT_A2" },
1929 { 4*PT_A3, "4*PT_A3" },
1930 { 4*PT_A4, "4*PT_A4" },
1931 { 4*PT_A5, "4*PT_A5" },
1932 { 4*PT_A6, "4*PT_A6" },
1933 { 4*PT_D0, "4*PT_D0" },
1934 { 4*PT_USP, "4*PT_USP" },
1935 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1936 { 4*PT_SR, "4*PT_SR" },
1937 { 4*PT_PC, "4*PT_PC" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001938# elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001939 { 4*REG_REG0, "4*REG_REG0" },
1940 { 4*(REG_REG0+1), "4*REG_REG1" },
1941 { 4*(REG_REG0+2), "4*REG_REG2" },
1942 { 4*(REG_REG0+3), "4*REG_REG3" },
1943 { 4*(REG_REG0+4), "4*REG_REG4" },
1944 { 4*(REG_REG0+5), "4*REG_REG5" },
1945 { 4*(REG_REG0+6), "4*REG_REG6" },
1946 { 4*(REG_REG0+7), "4*REG_REG7" },
1947 { 4*(REG_REG0+8), "4*REG_REG8" },
1948 { 4*(REG_REG0+9), "4*REG_REG9" },
1949 { 4*(REG_REG0+10), "4*REG_REG10" },
1950 { 4*(REG_REG0+11), "4*REG_REG11" },
1951 { 4*(REG_REG0+12), "4*REG_REG12" },
1952 { 4*(REG_REG0+13), "4*REG_REG13" },
1953 { 4*(REG_REG0+14), "4*REG_REG14" },
1954 { 4*REG_REG15, "4*REG_REG15" },
1955 { 4*REG_PC, "4*REG_PC" },
1956 { 4*REG_PR, "4*REG_PR" },
1957 { 4*REG_SR, "4*REG_SR" },
1958 { 4*REG_GBR, "4*REG_GBR" },
1959 { 4*REG_MACH, "4*REG_MACH" },
1960 { 4*REG_MACL, "4*REG_MACL" },
1961 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1962 { 4*REG_FPUL, "4*REG_FPUL" },
1963 { 4*REG_FPREG0, "4*REG_FPREG0" },
1964 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1965 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1966 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1967 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1968 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1969 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1970 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1971 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1972 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1973 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1974 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1975 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1976 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1977 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1978 { 4*REG_FPREG15, "4*REG_FPREG15" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001979# ifdef REG_XDREG0
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001980 { 4*REG_XDREG0, "4*REG_XDREG0" },
1981 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1982 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1983 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1984 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1985 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1986 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1987 { 4*REG_XDREG14, "4*REG_XDREG14" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001988# endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001989 { 4*REG_FPSCR, "4*REG_FPSCR" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001990# elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001991 { 0, "PC(L)" },
1992 { 4, "PC(U)" },
1993 { 8, "SR(L)" },
1994 { 12, "SR(U)" },
1995 { 16, "syscall no.(L)" },
1996 { 20, "syscall_no.(U)" },
1997 { 24, "R0(L)" },
1998 { 28, "R0(U)" },
1999 { 32, "R1(L)" },
2000 { 36, "R1(U)" },
2001 { 40, "R2(L)" },
2002 { 44, "R2(U)" },
2003 { 48, "R3(L)" },
2004 { 52, "R3(U)" },
2005 { 56, "R4(L)" },
2006 { 60, "R4(U)" },
2007 { 64, "R5(L)" },
2008 { 68, "R5(U)" },
2009 { 72, "R6(L)" },
2010 { 76, "R6(U)" },
2011 { 80, "R7(L)" },
2012 { 84, "R7(U)" },
2013 { 88, "R8(L)" },
2014 { 92, "R8(U)" },
2015 { 96, "R9(L)" },
2016 { 100, "R9(U)" },
2017 { 104, "R10(L)" },
2018 { 108, "R10(U)" },
2019 { 112, "R11(L)" },
2020 { 116, "R11(U)" },
2021 { 120, "R12(L)" },
2022 { 124, "R12(U)" },
2023 { 128, "R13(L)" },
2024 { 132, "R13(U)" },
2025 { 136, "R14(L)" },
2026 { 140, "R14(U)" },
2027 { 144, "R15(L)" },
2028 { 148, "R15(U)" },
2029 { 152, "R16(L)" },
2030 { 156, "R16(U)" },
2031 { 160, "R17(L)" },
2032 { 164, "R17(U)" },
2033 { 168, "R18(L)" },
2034 { 172, "R18(U)" },
2035 { 176, "R19(L)" },
2036 { 180, "R19(U)" },
2037 { 184, "R20(L)" },
2038 { 188, "R20(U)" },
2039 { 192, "R21(L)" },
2040 { 196, "R21(U)" },
2041 { 200, "R22(L)" },
2042 { 204, "R22(U)" },
2043 { 208, "R23(L)" },
2044 { 212, "R23(U)" },
2045 { 216, "R24(L)" },
2046 { 220, "R24(U)" },
2047 { 224, "R25(L)" },
2048 { 228, "R25(U)" },
2049 { 232, "R26(L)" },
2050 { 236, "R26(U)" },
2051 { 240, "R27(L)" },
2052 { 244, "R27(U)" },
2053 { 248, "R28(L)" },
2054 { 252, "R28(U)" },
2055 { 256, "R29(L)" },
2056 { 260, "R29(U)" },
2057 { 264, "R30(L)" },
2058 { 268, "R30(U)" },
2059 { 272, "R31(L)" },
2060 { 276, "R31(U)" },
2061 { 280, "R32(L)" },
2062 { 284, "R32(U)" },
2063 { 288, "R33(L)" },
2064 { 292, "R33(U)" },
2065 { 296, "R34(L)" },
2066 { 300, "R34(U)" },
2067 { 304, "R35(L)" },
2068 { 308, "R35(U)" },
2069 { 312, "R36(L)" },
2070 { 316, "R36(U)" },
2071 { 320, "R37(L)" },
2072 { 324, "R37(U)" },
2073 { 328, "R38(L)" },
2074 { 332, "R38(U)" },
2075 { 336, "R39(L)" },
2076 { 340, "R39(U)" },
2077 { 344, "R40(L)" },
2078 { 348, "R40(U)" },
2079 { 352, "R41(L)" },
2080 { 356, "R41(U)" },
2081 { 360, "R42(L)" },
2082 { 364, "R42(U)" },
2083 { 368, "R43(L)" },
2084 { 372, "R43(U)" },
2085 { 376, "R44(L)" },
2086 { 380, "R44(U)" },
2087 { 384, "R45(L)" },
2088 { 388, "R45(U)" },
2089 { 392, "R46(L)" },
2090 { 396, "R46(U)" },
2091 { 400, "R47(L)" },
2092 { 404, "R47(U)" },
2093 { 408, "R48(L)" },
2094 { 412, "R48(U)" },
2095 { 416, "R49(L)" },
2096 { 420, "R49(U)" },
2097 { 424, "R50(L)" },
2098 { 428, "R50(U)" },
2099 { 432, "R51(L)" },
2100 { 436, "R51(U)" },
2101 { 440, "R52(L)" },
2102 { 444, "R52(U)" },
2103 { 448, "R53(L)" },
2104 { 452, "R53(U)" },
2105 { 456, "R54(L)" },
2106 { 460, "R54(U)" },
2107 { 464, "R55(L)" },
2108 { 468, "R55(U)" },
2109 { 472, "R56(L)" },
2110 { 476, "R56(U)" },
2111 { 480, "R57(L)" },
2112 { 484, "R57(U)" },
2113 { 488, "R58(L)" },
2114 { 492, "R58(U)" },
2115 { 496, "R59(L)" },
2116 { 500, "R59(U)" },
2117 { 504, "R60(L)" },
2118 { 508, "R60(U)" },
2119 { 512, "R61(L)" },
2120 { 516, "R61(U)" },
2121 { 520, "R62(L)" },
2122 { 524, "R62(U)" },
2123 { 528, "TR0(L)" },
2124 { 532, "TR0(U)" },
2125 { 536, "TR1(L)" },
2126 { 540, "TR1(U)" },
2127 { 544, "TR2(L)" },
2128 { 548, "TR2(U)" },
2129 { 552, "TR3(L)" },
2130 { 556, "TR3(U)" },
2131 { 560, "TR4(L)" },
2132 { 564, "TR4(U)" },
2133 { 568, "TR5(L)" },
2134 { 572, "TR5(U)" },
2135 { 576, "TR6(L)" },
2136 { 580, "TR6(U)" },
2137 { 584, "TR7(L)" },
2138 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00002139 /* This entry is in case pt_regs contains dregs (depends on
2140 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002141 { uoff(regs), "offsetof(struct user, regs)" },
2142 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002143# elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00002144 { uoff(regs.ARM_r0), "r0" },
2145 { uoff(regs.ARM_r1), "r1" },
2146 { uoff(regs.ARM_r2), "r2" },
2147 { uoff(regs.ARM_r3), "r3" },
2148 { uoff(regs.ARM_r4), "r4" },
2149 { uoff(regs.ARM_r5), "r5" },
2150 { uoff(regs.ARM_r6), "r6" },
2151 { uoff(regs.ARM_r7), "r7" },
2152 { uoff(regs.ARM_r8), "r8" },
2153 { uoff(regs.ARM_r9), "r9" },
2154 { uoff(regs.ARM_r10), "r10" },
2155 { uoff(regs.ARM_fp), "fp" },
2156 { uoff(regs.ARM_ip), "ip" },
2157 { uoff(regs.ARM_sp), "sp" },
2158 { uoff(regs.ARM_lr), "lr" },
2159 { uoff(regs.ARM_pc), "pc" },
2160 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00002161# elif defined(AVR32)
2162 { uoff(regs.sr), "sr" },
2163 { uoff(regs.pc), "pc" },
2164 { uoff(regs.lr), "lr" },
2165 { uoff(regs.sp), "sp" },
2166 { uoff(regs.r12), "r12" },
2167 { uoff(regs.r11), "r11" },
2168 { uoff(regs.r10), "r10" },
2169 { uoff(regs.r9), "r9" },
2170 { uoff(regs.r8), "r8" },
2171 { uoff(regs.r7), "r7" },
2172 { uoff(regs.r6), "r6" },
2173 { uoff(regs.r5), "r5" },
2174 { uoff(regs.r4), "r4" },
2175 { uoff(regs.r3), "r3" },
2176 { uoff(regs.r2), "r2" },
2177 { uoff(regs.r1), "r1" },
2178 { uoff(regs.r0), "r0" },
2179 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002180# elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00002181 { 0, "r0" },
2182 { 1, "r1" },
2183 { 2, "r2" },
2184 { 3, "r3" },
2185 { 4, "r4" },
2186 { 5, "r5" },
2187 { 6, "r6" },
2188 { 7, "r7" },
2189 { 8, "r8" },
2190 { 9, "r9" },
2191 { 10, "r10" },
2192 { 11, "r11" },
2193 { 12, "r12" },
2194 { 13, "r13" },
2195 { 14, "r14" },
2196 { 15, "r15" },
2197 { 16, "r16" },
2198 { 17, "r17" },
2199 { 18, "r18" },
2200 { 19, "r19" },
2201 { 20, "r20" },
2202 { 21, "r21" },
2203 { 22, "r22" },
2204 { 23, "r23" },
2205 { 24, "r24" },
2206 { 25, "r25" },
2207 { 26, "r26" },
2208 { 27, "r27" },
2209 { 28, "r28" },
2210 { 29, "r29" },
2211 { 30, "r30" },
2212 { 31, "r31" },
2213 { 32, "f0" },
2214 { 33, "f1" },
2215 { 34, "f2" },
2216 { 35, "f3" },
2217 { 36, "f4" },
2218 { 37, "f5" },
2219 { 38, "f6" },
2220 { 39, "f7" },
2221 { 40, "f8" },
2222 { 41, "f9" },
2223 { 42, "f10" },
2224 { 43, "f11" },
2225 { 44, "f12" },
2226 { 45, "f13" },
2227 { 46, "f14" },
2228 { 47, "f15" },
2229 { 48, "f16" },
2230 { 49, "f17" },
2231 { 50, "f18" },
2232 { 51, "f19" },
2233 { 52, "f20" },
2234 { 53, "f21" },
2235 { 54, "f22" },
2236 { 55, "f23" },
2237 { 56, "f24" },
2238 { 57, "f25" },
2239 { 58, "f26" },
2240 { 59, "f27" },
2241 { 60, "f28" },
2242 { 61, "f29" },
2243 { 62, "f30" },
2244 { 63, "f31" },
2245 { 64, "pc" },
2246 { 65, "cause" },
2247 { 66, "badvaddr" },
2248 { 67, "mmhi" },
2249 { 68, "mmlo" },
2250 { 69, "fpcsr" },
2251 { 70, "fpeir" },
Chris Metcalfc8c66982009-12-28 10:00:15 -05002252# elif defined(TILE)
2253 { PTREGS_OFFSET_REG(0), "r0" },
2254 { PTREGS_OFFSET_REG(1), "r1" },
2255 { PTREGS_OFFSET_REG(2), "r2" },
2256 { PTREGS_OFFSET_REG(3), "r3" },
2257 { PTREGS_OFFSET_REG(4), "r4" },
2258 { PTREGS_OFFSET_REG(5), "r5" },
2259 { PTREGS_OFFSET_REG(6), "r6" },
2260 { PTREGS_OFFSET_REG(7), "r7" },
2261 { PTREGS_OFFSET_REG(8), "r8" },
2262 { PTREGS_OFFSET_REG(9), "r9" },
2263 { PTREGS_OFFSET_REG(10), "r10" },
2264 { PTREGS_OFFSET_REG(11), "r11" },
2265 { PTREGS_OFFSET_REG(12), "r12" },
2266 { PTREGS_OFFSET_REG(13), "r13" },
2267 { PTREGS_OFFSET_REG(14), "r14" },
2268 { PTREGS_OFFSET_REG(15), "r15" },
2269 { PTREGS_OFFSET_REG(16), "r16" },
2270 { PTREGS_OFFSET_REG(17), "r17" },
2271 { PTREGS_OFFSET_REG(18), "r18" },
2272 { PTREGS_OFFSET_REG(19), "r19" },
2273 { PTREGS_OFFSET_REG(20), "r20" },
2274 { PTREGS_OFFSET_REG(21), "r21" },
2275 { PTREGS_OFFSET_REG(22), "r22" },
2276 { PTREGS_OFFSET_REG(23), "r23" },
2277 { PTREGS_OFFSET_REG(24), "r24" },
2278 { PTREGS_OFFSET_REG(25), "r25" },
2279 { PTREGS_OFFSET_REG(26), "r26" },
2280 { PTREGS_OFFSET_REG(27), "r27" },
2281 { PTREGS_OFFSET_REG(28), "r28" },
2282 { PTREGS_OFFSET_REG(29), "r29" },
2283 { PTREGS_OFFSET_REG(30), "r30" },
2284 { PTREGS_OFFSET_REG(31), "r31" },
2285 { PTREGS_OFFSET_REG(32), "r32" },
2286 { PTREGS_OFFSET_REG(33), "r33" },
2287 { PTREGS_OFFSET_REG(34), "r34" },
2288 { PTREGS_OFFSET_REG(35), "r35" },
2289 { PTREGS_OFFSET_REG(36), "r36" },
2290 { PTREGS_OFFSET_REG(37), "r37" },
2291 { PTREGS_OFFSET_REG(38), "r38" },
2292 { PTREGS_OFFSET_REG(39), "r39" },
2293 { PTREGS_OFFSET_REG(40), "r40" },
2294 { PTREGS_OFFSET_REG(41), "r41" },
2295 { PTREGS_OFFSET_REG(42), "r42" },
2296 { PTREGS_OFFSET_REG(43), "r43" },
2297 { PTREGS_OFFSET_REG(44), "r44" },
2298 { PTREGS_OFFSET_REG(45), "r45" },
2299 { PTREGS_OFFSET_REG(46), "r46" },
2300 { PTREGS_OFFSET_REG(47), "r47" },
2301 { PTREGS_OFFSET_REG(48), "r48" },
2302 { PTREGS_OFFSET_REG(49), "r49" },
2303 { PTREGS_OFFSET_REG(50), "r50" },
2304 { PTREGS_OFFSET_REG(51), "r51" },
2305 { PTREGS_OFFSET_REG(52), "r52" },
2306 { PTREGS_OFFSET_TP, "tp" },
2307 { PTREGS_OFFSET_SP, "sp" },
2308 { PTREGS_OFFSET_LR, "lr" },
2309 { PTREGS_OFFSET_PC, "pc" },
2310 { PTREGS_OFFSET_EX1, "ex1" },
2311 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2312 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2313 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002314# endif
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002315# ifdef CRISV10
2316 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2317 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2318 { 4*PT_R13, "4*PT_R13" },
2319 { 4*PT_R12, "4*PT_R12" },
2320 { 4*PT_R11, "4*PT_R11" },
2321 { 4*PT_R10, "4*PT_R10" },
2322 { 4*PT_R9, "4*PT_R9" },
2323 { 4*PT_R8, "4*PT_R8" },
2324 { 4*PT_R7, "4*PT_R7" },
2325 { 4*PT_R6, "4*PT_R6" },
2326 { 4*PT_R5, "4*PT_R5" },
2327 { 4*PT_R4, "4*PT_R4" },
2328 { 4*PT_R3, "4*PT_R3" },
2329 { 4*PT_R2, "4*PT_R2" },
2330 { 4*PT_R1, "4*PT_R1" },
2331 { 4*PT_R0, "4*PT_R0" },
2332 { 4*PT_MOF, "4*PT_MOF" },
2333 { 4*PT_DCCR, "4*PT_DCCR" },
2334 { 4*PT_SRP, "4*PT_SRP" },
2335 { 4*PT_IRP, "4*PT_IRP" },
2336 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2337 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2338 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2339 { 4*PT_USP, "4*PT_USP" },
2340# endif
2341# ifdef CRISV32
2342 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2343 { 4*PT_R0, "4*PT_R0" },
2344 { 4*PT_R1, "4*PT_R1" },
2345 { 4*PT_R2, "4*PT_R2" },
2346 { 4*PT_R3, "4*PT_R3" },
2347 { 4*PT_R4, "4*PT_R4" },
2348 { 4*PT_R5, "4*PT_R5" },
2349 { 4*PT_R6, "4*PT_R6" },
2350 { 4*PT_R7, "4*PT_R7" },
2351 { 4*PT_R8, "4*PT_R8" },
2352 { 4*PT_R9, "4*PT_R9" },
2353 { 4*PT_R10, "4*PT_R10" },
2354 { 4*PT_R11, "4*PT_R11" },
2355 { 4*PT_R12, "4*PT_R12" },
2356 { 4*PT_R13, "4*PT_R13" },
2357 { 4*PT_ACR, "4*PT_ACR" },
2358 { 4*PT_SRS, "4*PT_SRS" },
2359 { 4*PT_MOF, "4*PT_MOF" },
2360 { 4*PT_SPC, "4*PT_SPC" },
2361 { 4*PT_CCS, "4*PT_CCS" },
2362 { 4*PT_SRP, "4*PT_SRP" },
2363 { 4*PT_ERP, "4*PT_ERP" },
2364 { 4*PT_EXS, "4*PT_EXS" },
2365 { 4*PT_EDA, "4*PT_EDA" },
2366 { 4*PT_USP, "4*PT_USP" },
2367 { 4*PT_PPC, "4*PT_PPC" },
2368 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2369 { 4*PT_BP+4, "4*PT_BP+4" },
2370 { 4*PT_BP+8, "4*PT_BP+8" },
2371 { 4*PT_BP+12, "4*PT_BP+12" },
2372 { 4*PT_BP+16, "4*PT_BP+16" },
2373 { 4*PT_BP+20, "4*PT_BP+20" },
2374 { 4*PT_BP+24, "4*PT_BP+24" },
2375 { 4*PT_BP+28, "4*PT_BP+28" },
2376 { 4*PT_BP+32, "4*PT_BP+32" },
2377 { 4*PT_BP+36, "4*PT_BP+36" },
2378 { 4*PT_BP+40, "4*PT_BP+40" },
2379 { 4*PT_BP+44, "4*PT_BP+44" },
2380 { 4*PT_BP+48, "4*PT_BP+48" },
2381 { 4*PT_BP+52, "4*PT_BP+52" },
2382 { 4*PT_BP+56, "4*PT_BP+56" },
2383# endif
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002384# ifdef MICROBLAZE
2385 { PT_GPR(0), "r0" },
2386 { PT_GPR(1), "r1" },
2387 { PT_GPR(2), "r2" },
2388 { PT_GPR(3), "r3" },
2389 { PT_GPR(4), "r4" },
2390 { PT_GPR(5), "r5" },
2391 { PT_GPR(6), "r6" },
2392 { PT_GPR(7), "r7" },
2393 { PT_GPR(8), "r8" },
2394 { PT_GPR(9), "r9" },
2395 { PT_GPR(10), "r10" },
2396 { PT_GPR(11), "r11" },
2397 { PT_GPR(12), "r12" },
2398 { PT_GPR(13), "r13" },
2399 { PT_GPR(14), "r14" },
2400 { PT_GPR(15), "r15" },
2401 { PT_GPR(16), "r16" },
2402 { PT_GPR(17), "r17" },
2403 { PT_GPR(18), "r18" },
2404 { PT_GPR(19), "r19" },
2405 { PT_GPR(20), "r20" },
2406 { PT_GPR(21), "r21" },
2407 { PT_GPR(22), "r22" },
2408 { PT_GPR(23), "r23" },
2409 { PT_GPR(24), "r24" },
2410 { PT_GPR(25), "r25" },
2411 { PT_GPR(26), "r26" },
2412 { PT_GPR(27), "r27" },
2413 { PT_GPR(28), "r28" },
2414 { PT_GPR(29), "r29" },
2415 { PT_GPR(30), "r30" },
2416 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002417 { PT_PC, "rpc", },
2418 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002419 { PT_EAR, "rear", },
2420 { PT_ESR, "resr", },
2421 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002422 { PT_KERNEL_MODE, "kernel_mode", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002423# endif
Roland McGrath542c2c62008-05-20 01:11:56 +00002424
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002425# if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \
2426 && !defined(ALPHA) && !defined(IA64) \
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002427 && !defined(CRISV10) && !defined(CRISV32) && !defined(MICROBLAZE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05002428# if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(AVR32) && !defined(BFIN) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002429 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002430# endif
2431# if defined(I386) || defined(X86_64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002432 { uoff(i387), "offsetof(struct user, i387)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002433# endif
2434# if defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002435 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002436# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002437 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2438 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2439 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002440# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002441 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002442# endif
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00002443# if defined(AVR32) || defined(SH64)
Roland McGrathe1e584b2003-06-02 19:18:58 +00002444 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002445# endif
2446# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002447 { uoff(start_stack), "offsetof(struct user, start_stack)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002448# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002449 { uoff(signal), "offsetof(struct user, signal)" },
Chris Metcalfc8c66982009-12-28 10:00:15 -05002450# if !defined(AVR32) && !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SH) && !defined(SH64) && !defined(SPARC64) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002451 { uoff(reserved), "offsetof(struct user, reserved)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002452# endif
2453# if !defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002454 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002455# endif
Chris Metcalfc8c66982009-12-28 10:00:15 -05002456# if !defined(ARM) && !defined(AVR32) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) && !defined(BFIN) && !defined(TILE)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002457 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002458# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002459 { uoff(magic), "offsetof(struct user, magic)" },
2460 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002461# if defined(I386) || defined(X86_64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002462 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002463# endif
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002464# endif /* !defined(many arches) */
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002465
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002466
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002467# ifndef HPPA
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002468 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002469# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002470 { 0, NULL },
2471};
2472
2473int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002474sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002475{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002476 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002477 long addr;
2478
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002479 if (entering(tcp)) {
Roland McGrathbf621d42003-01-14 09:46:21 +00002480 printxval(ptrace_cmds, tcp->u_arg[0],
Roland McGrathbf621d42003-01-14 09:46:21 +00002481 "PTRACE_???"
Roland McGrathbf621d42003-01-14 09:46:21 +00002482 );
2483 tprintf(", %lu, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002484 addr = tcp->u_arg[2];
2485 if (tcp->u_arg[0] == PTRACE_PEEKUSER
2486 || tcp->u_arg[0] == PTRACE_POKEUSER) {
2487 for (x = struct_user_offsets; x->str; x++) {
2488 if (x->val >= addr)
2489 break;
2490 }
2491 if (!x->str)
2492 tprintf("%#lx, ", addr);
2493 else if (x->val > addr && x != struct_user_offsets) {
2494 x--;
2495 tprintf("%s + %ld, ", x->str, addr - x->val);
2496 }
2497 else
2498 tprintf("%s, ", x->str);
2499 }
2500 else
2501 tprintf("%#lx, ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002502 switch (tcp->u_arg[0]) {
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002503# ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002504 case PTRACE_PEEKDATA:
2505 case PTRACE_PEEKTEXT:
2506 case PTRACE_PEEKUSER:
2507 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002508# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002509 case PTRACE_CONT:
2510 case PTRACE_SINGLESTEP:
2511 case PTRACE_SYSCALL:
2512 case PTRACE_DETACH:
2513 printsignal(tcp->u_arg[3]);
2514 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002515# ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002516 case PTRACE_SETOPTIONS:
2517 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2518 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002519# endif
2520# ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002521 case PTRACE_SETSIGINFO: {
2522 siginfo_t si;
2523 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002524 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002525 else if (syserror(tcp))
2526 tprintf("%#lx", tcp->u_arg[3]);
2527 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002528 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002529 else
2530 printsiginfo(&si, verbose(tcp));
2531 break;
2532 }
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002533# endif
2534# ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002535 case PTRACE_GETSIGINFO:
2536 /* Don't print anything, do it at syscall return. */
2537 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002538# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002539 default:
2540 tprintf("%#lx", tcp->u_arg[3]);
2541 break;
2542 }
2543 } else {
2544 switch (tcp->u_arg[0]) {
2545 case PTRACE_PEEKDATA:
2546 case PTRACE_PEEKTEXT:
2547 case PTRACE_PEEKUSER:
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002548# ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002549 return RVAL_HEX;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002550# else
Roland McGratheb285352003-01-14 09:59:00 +00002551 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002552 break;
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002553# endif
2554# ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002555 case PTRACE_GETSIGINFO: {
2556 siginfo_t si;
2557 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002558 tprints("NULL");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002559 else if (syserror(tcp))
2560 tprintf("%#lx", tcp->u_arg[3]);
2561 else if (umove(tcp, tcp->u_arg[3], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002562 tprints("{???}");
Denys Vlasenkof535b542009-01-13 18:30:55 +00002563 else
2564 printsiginfo(&si, verbose(tcp));
2565 break;
2566 }
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002567# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002568 }
2569 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002570 return 0;
2571}
2572
Roland McGrath5a223472002-12-15 23:58:26 +00002573
Roland McGrath51942a92007-07-05 18:59:11 +00002574# ifndef FUTEX_CMP_REQUEUE
2575# define FUTEX_CMP_REQUEUE 4
2576# endif
2577# ifndef FUTEX_WAKE_OP
2578# define FUTEX_WAKE_OP 5
2579# endif
2580# ifndef FUTEX_LOCK_PI
2581# define FUTEX_LOCK_PI 6
2582# define FUTEX_UNLOCK_PI 7
2583# define FUTEX_TRYLOCK_PI 8
2584# endif
Roland McGrath1aeaf742008-07-18 01:27:39 +00002585# ifndef FUTEX_WAIT_BITSET
2586# define FUTEX_WAIT_BITSET 9
2587# endif
2588# ifndef FUTEX_WAKE_BITSET
2589# define FUTEX_WAKE_BITSET 10
Roland McGrath51942a92007-07-05 18:59:11 +00002590# endif
Andreas Schwab85f58322009-08-12 09:54:42 +02002591# ifndef FUTEX_WAIT_REQUEUE_PI
2592# define FUTEX_WAIT_REQUEUE_PI 11
2593# endif
2594# ifndef FUTEX_CMP_REQUEUE_PI
2595# define FUTEX_CMP_REQUEUE_PI 12
2596# endif
Roland McGrath51942a92007-07-05 18:59:11 +00002597# ifndef FUTEX_PRIVATE_FLAG
2598# define FUTEX_PRIVATE_FLAG 128
2599# endif
Andreas Schwab85f58322009-08-12 09:54:42 +02002600# ifndef FUTEX_CLOCK_REALTIME
2601# define FUTEX_CLOCK_REALTIME 256
2602# endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002603static const struct xlat futexops[] = {
Roland McGrath51942a92007-07-05 18:59:11 +00002604 { FUTEX_WAIT, "FUTEX_WAIT" },
2605 { FUTEX_WAKE, "FUTEX_WAKE" },
2606 { FUTEX_FD, "FUTEX_FD" },
2607 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2608 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2609 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2610 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2611 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2612 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002613 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2614 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002615 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2616 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
Roland McGrath51942a92007-07-05 18:59:11 +00002617 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2618 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2619 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2620 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2621 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2622 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2623 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2624 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2625 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002626 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2627 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002628 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2629 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2630 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2631 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2632 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2633 { 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 +00002634 { 0, NULL }
2635};
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002636# ifndef FUTEX_OP_SET
2637# define FUTEX_OP_SET 0
2638# define FUTEX_OP_ADD 1
2639# define FUTEX_OP_OR 2
2640# define FUTEX_OP_ANDN 3
2641# define FUTEX_OP_XOR 4
2642# define FUTEX_OP_CMP_EQ 0
2643# define FUTEX_OP_CMP_NE 1
2644# define FUTEX_OP_CMP_LT 2
2645# define FUTEX_OP_CMP_LE 3
2646# define FUTEX_OP_CMP_GT 4
2647# define FUTEX_OP_CMP_GE 5
2648# endif
Roland McGrath51942a92007-07-05 18:59:11 +00002649static const struct xlat futexwakeops[] = {
2650 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2651 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2652 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2653 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2654 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2655 { 0, NULL }
2656};
2657static const struct xlat futexwakecmps[] = {
2658 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2659 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2660 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2661 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2662 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2663 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2664 { 0, NULL }
Roland McGrath5a223472002-12-15 23:58:26 +00002665};
2666
2667int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002668sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002669{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002670 if (entering(tcp)) {
2671 long int cmd = tcp->u_arg[1] & 127;
2672 tprintf("%p, ", (void *) tcp->u_arg[0]);
2673 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2674 tprintf(", %ld", tcp->u_arg[2]);
2675 if (cmd == FUTEX_WAKE_BITSET)
2676 tprintf(", %lx", tcp->u_arg[5]);
2677 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002678 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002679 printtv(tcp, tcp->u_arg[3]);
2680 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002681 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002682 printtv(tcp, tcp->u_arg[3]);
2683 tprintf(", %lx", tcp->u_arg[5]);
2684 } else if (cmd == FUTEX_REQUEUE)
2685 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002686 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002687 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2688 else if (cmd == FUTEX_WAKE_OP) {
2689 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2690 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002691 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002692 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2693 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2694 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002695 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002696 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2697 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002698 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002699 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002700 printtv(tcp, tcp->u_arg[3]);
2701 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002702 }
Roland McGrath51942a92007-07-05 18:59:11 +00002703 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002704 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002705}
2706
2707static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002708print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002709{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002710 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002711 unsigned long w, min_len;
2712
2713 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2714 min_len = len - max_strlen * sizeof(w);
2715 else
2716 min_len = 0;
2717 for (; len >= sizeof(w) && len > min_len;
2718 len -= sizeof(w), list += sizeof(w)) {
2719 if (umove(tcp, list, &w) < 0)
2720 break;
2721 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002722 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002723 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002724 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002725 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002726 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002727 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002728 if (len) {
2729 if (first)
2730 tprintf("%#lx", list);
2731 else
2732 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2733 "???" : "..."));
2734 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002735 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002736 }
Roland McGrath5a223472002-12-15 23:58:26 +00002737}
2738
2739int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002740sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002741{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002742 if (entering(tcp)) {
2743 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2744 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2745 }
2746 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002747}
2748
2749int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002750sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002751{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002752 if (entering(tcp)) {
2753 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2754 } else {
2755 if (tcp->u_rval == -1)
2756 tprintf("%#lx", tcp->u_arg[2]);
2757 else
2758 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2759 }
2760 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002761}
Roland McGrath279d3782004-03-01 20:27:37 +00002762
Roland McGrathd9f816f2004-09-04 03:39:20 +00002763static const struct xlat schedulers[] = {
Roland McGrath279d3782004-03-01 20:27:37 +00002764 { SCHED_OTHER, "SCHED_OTHER" },
2765 { SCHED_RR, "SCHED_RR" },
2766 { SCHED_FIFO, "SCHED_FIFO" },
2767 { 0, NULL }
2768};
2769
2770int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002771sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002772{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002773 if (entering(tcp)) {
2774 tprintf("%d", (int) tcp->u_arg[0]);
2775 } else if (! syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002776 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002777 if (tcp->auxstr != NULL)
2778 return RVAL_STR;
2779 }
2780 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002781}
2782
2783int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002784sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002785{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002786 if (entering(tcp)) {
2787 struct sched_param p;
2788 tprintf("%d, ", (int) tcp->u_arg[0]);
2789 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2790 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2791 tprintf(", %#lx", tcp->u_arg[2]);
2792 else
2793 tprintf(", { %d }", p.__sched_priority);
2794 }
2795 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002796}
2797
2798int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002799sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002800{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002801 if (entering(tcp)) {
2802 tprintf("%d, ", (int) tcp->u_arg[0]);
2803 } else {
2804 struct sched_param p;
2805 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2806 tprintf("%#lx", tcp->u_arg[1]);
2807 else
2808 tprintf("{ %d }", p.__sched_priority);
2809 }
2810 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002811}
2812
2813int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002814sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002815{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002816 if (entering(tcp)) {
2817 struct sched_param p;
2818 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2819 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2820 else
2821 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2822 }
2823 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002824}
2825
2826int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002827sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002828{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002829 if (entering(tcp)) {
2830 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2831 }
2832 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002833}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002834
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002835# ifdef X86_64
2836# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002837
2838static const struct xlat archvals[] = {
2839 { ARCH_SET_GS, "ARCH_SET_GS" },
2840 { ARCH_SET_FS, "ARCH_SET_FS" },
2841 { ARCH_GET_FS, "ARCH_GET_FS" },
2842 { ARCH_GET_GS, "ARCH_GET_GS" },
2843 { 0, NULL },
2844};
2845
2846int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002847sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002848{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002849 if (entering(tcp)) {
2850 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2851 if (tcp->u_arg[0] == ARCH_SET_GS
2852 || tcp->u_arg[0] == ARCH_SET_FS
2853 ) {
2854 tprintf(", %#lx", tcp->u_arg[1]);
2855 }
2856 } else {
2857 if (tcp->u_arg[0] == ARCH_GET_GS
2858 || tcp->u_arg[0] == ARCH_GET_FS
2859 ) {
2860 long int v;
2861 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2862 tprintf(", [%#lx]", v);
2863 else
2864 tprintf(", %#lx", tcp->u_arg[1]);
2865 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002866 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002867 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002868}
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002869# endif /* X86_64 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002870
Roland McGrathdb8319f2007-08-02 01:37:55 +00002871
2872int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002873sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002874{
2875 if (exiting(tcp)) {
2876 unsigned u;
2877 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002878 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002879 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2880 tprintf("%#lx, ", tcp->u_arg[0]);
2881 else
2882 tprintf("[%u], ", u);
2883 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002884 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002885 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2886 tprintf("%#lx, ", tcp->u_arg[1]);
2887 else
2888 tprintf("[%u], ", u);
2889 tprintf("%#lx", tcp->u_arg[2]);
2890 }
2891 return 0;
2892}
2893
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002894int
2895sys_process_vm_readv(struct tcb *tcp)
2896{
2897 if (entering(tcp)) {
2898 /* arg 1: pid */
2899 tprintf("%ld, ", tcp->u_arg[0]);
2900 } else {
2901 /* args 2,3: local iov,cnt */
2902 if (syserror(tcp)) {
2903 tprintf("%#lx, %lu",
2904 tcp->u_arg[1], tcp->u_arg[2]);
2905 } else {
2906 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2907 }
2908 tprints(", ");
2909 /* args 4,5: remote iov,cnt */
2910 if (syserror(tcp)) {
2911 tprintf("%#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]);
2912 } else {
2913 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2914 }
2915 /* arg 6: flags */
2916 tprintf(", %lu", tcp->u_arg[5]);
2917 }
2918 return 0;
2919}