blob: e465319e71210c335b6265f0a5f654c0c4994810 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Linux for s390 port by D.J. Barrow
8 * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
Wichert Akkermanccef6372002-05-01 16:39:22 +00009 * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH
10 * port by Greg Banks <gbanks@pocketpenguins.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +000011 *
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000012 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. The name of the author may not be used to endorse or promote products
23 * derived from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000035 */
36
37#include "defs.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000038#include <fcntl.h>
39#include <sys/stat.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000040#include <sys/wait.h>
41#include <sys/resource.h>
42#include <sys/utsname.h>
43#include <sys/user.h>
Dmitry V. Levinc41808b2013-03-18 00:52:29 +000044#ifdef HAVE_ELF_H
45# include <elf.h>
46#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047
Wichert Akkerman36915a11999-07-13 15:45:02 +000048#ifdef HAVE_SYS_REG_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000049# include <sys/reg.h>
Wichert Akkerman15dea971999-10-06 13:06:34 +000050#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000051
Roland McGrath5bd7cf82003-01-24 04:31:18 +000052#ifdef HAVE_LINUX_PTRACE_H
Denys Vlasenko84703742012-02-25 02:38:52 +010053# undef PTRACE_SYSCALL
Roland McGrathfb1bc072004-03-01 21:29:24 +000054# ifdef HAVE_STRUCT_IA64_FPREG
55# define ia64_fpreg XXX_ia64_fpreg
56# endif
57# ifdef HAVE_STRUCT_PT_ALL_USER_REGS
58# define pt_all_user_regs XXX_pt_all_user_regs
59# endif
Ali Polatel0b4060f2013-09-24 20:04:32 +030060# ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
61# define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args
62# endif
Denys Vlasenko84703742012-02-25 02:38:52 +010063# include <linux/ptrace.h>
Ali Polatel0b4060f2013-09-24 20:04:32 +030064# undef ptrace_peeksiginfo_args
Roland McGrathfb1bc072004-03-01 21:29:24 +000065# undef ia64_fpreg
66# undef pt_all_user_regs
Roland McGrath5bd7cf82003-01-24 04:31:18 +000067#endif
68
Denys Vlasenko84703742012-02-25 02:38:52 +010069#if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +000070# define r_pc r_tpc
71# undef PTRACE_GETREGS
72# define PTRACE_GETREGS PTRACE_GETREGS64
73# undef PTRACE_SETREGS
74# define PTRACE_SETREGS PTRACE_SETREGS64
Denys Vlasenko84703742012-02-25 02:38:52 +010075#endif
Roland McGrath6d1a65c2004-07-12 07:44:08 +000076
Roland McGrath5a223472002-12-15 23:58:26 +000077#ifdef HAVE_LINUX_FUTEX_H
Dmitry V. Levine5e60852009-12-31 22:50:49 +000078# include <linux/futex.h>
Roland McGrath5a223472002-12-15 23:58:26 +000079#endif
Denys Vlasenko84703742012-02-25 02:38:52 +010080#ifndef FUTEX_WAIT
81# define FUTEX_WAIT 0
82#endif
83#ifndef FUTEX_WAKE
84# define FUTEX_WAKE 1
85#endif
86#ifndef FUTEX_FD
87# define FUTEX_FD 2
88#endif
89#ifndef FUTEX_REQUEUE
90# define FUTEX_REQUEUE 3
91#endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000092
Roland McGrath279d3782004-03-01 20:27:37 +000093#include <sched.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000094#include <asm/posix_types.h>
95#undef GETGROUPS_T
96#define GETGROUPS_T __kernel_gid_t
Roland McGrath83bd47a2003-11-13 22:32:26 +000097#undef GETGROUPS32_T
98#define GETGROUPS32_T __kernel_gid32_t
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000099
Denys Vlasenko84703742012-02-25 02:38:52 +0100100#if defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000101# include <asm/ptrace_offsets.h>
102# include <asm/rse.h>
103#endif
104
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000105#ifdef HAVE_PRCTL
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000106# include <sys/prctl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000107
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000108#include "xlat/prctl_options.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000109
Roland McGratha4d48532005-06-08 20:45:28 +0000110static const char *
Denys Vlasenko12014262011-05-30 14:00:14 +0200111unalignctl_string(unsigned int ctl)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000112{
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100113 static char buf[sizeof(int)*2 + 2];
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000114
115 switch (ctl) {
116#ifdef PR_UNALIGN_NOPRINT
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100117 case PR_UNALIGN_NOPRINT:
118 return "NOPRINT";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000119#endif
120#ifdef PR_UNALIGN_SIGBUS
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100121 case PR_UNALIGN_SIGBUS:
122 return "SIGBUS";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000123#endif
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100124 default:
125 break;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000126 }
127 sprintf(buf, "%x", ctl);
128 return buf;
129}
130
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000131int
Denys Vlasenko12014262011-05-30 14:00:14 +0200132sys_prctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000133{
Dmitry V. Levin3ed5d022014-09-10 13:46:04 +0000134 unsigned int i;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000135
136 if (entering(tcp)) {
137 printxval(prctl_options, tcp->u_arg[0], "PR_???");
138 switch (tcp->u_arg[0]) {
139#ifdef PR_GETNSHARE
140 case PR_GETNSHARE:
141 break;
142#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000143#ifdef PR_SET_PDEATHSIG
144 case PR_SET_PDEATHSIG:
145 tprintf(", %lu", tcp->u_arg[1]);
146 break;
147#endif
148#ifdef PR_GET_PDEATHSIG
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000149 case PR_GET_PDEATHSIG:
150 break;
151#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000152#ifdef PR_SET_DUMPABLE
153 case PR_SET_DUMPABLE:
154 tprintf(", %lu", tcp->u_arg[1]);
155 break;
156#endif
157#ifdef PR_GET_DUMPABLE
158 case PR_GET_DUMPABLE:
159 break;
160#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000161#ifdef PR_SET_UNALIGN
162 case PR_SET_UNALIGN:
163 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
164 break;
165#endif
166#ifdef PR_GET_UNALIGN
167 case PR_GET_UNALIGN:
168 tprintf(", %#lx", tcp->u_arg[1]);
169 break;
170#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000171#ifdef PR_SET_KEEPCAPS
172 case PR_SET_KEEPCAPS:
173 tprintf(", %lu", tcp->u_arg[1]);
174 break;
175#endif
176#ifdef PR_GET_KEEPCAPS
177 case PR_GET_KEEPCAPS:
178 break;
179#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000180 default:
Denys Vlasenko74ec14f2013-02-21 16:13:47 +0100181 for (i = 1; i < tcp->s_ent->nargs; i++)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000182 tprintf(", %#lx", tcp->u_arg[i]);
183 break;
184 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000185 } else {
186 switch (tcp->u_arg[0]) {
187#ifdef PR_GET_PDEATHSIG
188 case PR_GET_PDEATHSIG:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000189 if (umove(tcp, tcp->u_arg[1], &i) < 0)
190 tprintf(", %#lx", tcp->u_arg[1]);
191 else
192 tprintf(", {%u}", i);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000193 break;
194#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000195#ifdef PR_GET_DUMPABLE
196 case PR_GET_DUMPABLE:
197 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000198#endif
199#ifdef PR_GET_UNALIGN
200 case PR_GET_UNALIGN:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000201 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
202 break;
203 tcp->auxstr = unalignctl_string(i);
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000204 return RVAL_STR;
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000205#endif
206#ifdef PR_GET_KEEPCAPS
207 case PR_GET_KEEPCAPS:
208 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000209#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000210 default:
211 break;
212 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000213 }
214 return 0;
215}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000216#endif /* HAVE_PRCTL */
217
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000218int
Denys Vlasenko12014262011-05-30 14:00:14 +0200219sys_sethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000220{
221 if (entering(tcp)) {
Dmitry V. Levin3a3b71c2014-05-28 16:38:44 +0000222 printstr(tcp, tcp->u_arg[0], tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000223 tprintf(", %lu", tcp->u_arg[1]);
224 }
225 return 0;
226}
227
Denys Vlasenko84703742012-02-25 02:38:52 +0100228#if defined(ALPHA)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000229int
Denys Vlasenko12014262011-05-30 14:00:14 +0200230sys_gethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000231{
232 if (exiting(tcp)) {
233 if (syserror(tcp))
234 tprintf("%#lx", tcp->u_arg[0]);
235 else
Dmitry V. Levin3a3b71c2014-05-28 16:38:44 +0000236 printstr(tcp, tcp->u_arg[0], -1);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000237 tprintf(", %lu", tcp->u_arg[1]);
238 }
239 return 0;
240}
Denys Vlasenko84703742012-02-25 02:38:52 +0100241#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000242
243int
Denys Vlasenko12014262011-05-30 14:00:14 +0200244sys_setdomainname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000245{
246 if (entering(tcp)) {
Dmitry V. Levin3a3b71c2014-05-28 16:38:44 +0000247 printstr(tcp, tcp->u_arg[0], tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000248 tprintf(", %lu", tcp->u_arg[1]);
249 }
250 return 0;
251}
252
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000253int
Denys Vlasenko12014262011-05-30 14:00:14 +0200254sys_exit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000255{
256 if (exiting(tcp)) {
257 fprintf(stderr, "_exit returned!\n");
258 return -1;
259 }
260 /* special case: we stop tracing this process, finish line now */
261 tprintf("%ld) ", tcp->u_arg[0]);
Denys Vlasenko102ec492011-08-25 01:27:59 +0200262 tabto();
Denys Vlasenko000b6012012-01-28 01:25:03 +0100263 tprints("= ?\n");
Denys Vlasenko7de265d2012-03-13 11:44:31 +0100264 line_ended();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000265 return 0;
266}
267
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000268/* defines copied from linux/sched.h since we can't include that
269 * ourselves (it conflicts with *lots* of libc includes)
270 */
271#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
272#define CLONE_VM 0x00000100 /* set if VM shared between processes */
273#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
274#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
275#define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
Roland McGrath909875b2002-12-22 03:34:36 +0000276#define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000277#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
278#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
279#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
Roland McGrath909875b2002-12-22 03:34:36 +0000280#define CLONE_THREAD 0x00010000 /* Same thread group? */
281#define CLONE_NEWNS 0x00020000 /* New namespace group? */
282#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
283#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
284#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
285#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
Roland McGrath909875b2002-12-22 03:34:36 +0000286#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
287#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000288#define CLONE_STOPPED 0x02000000 /* Start in stopped state */
289#define CLONE_NEWUTS 0x04000000 /* New utsname group? */
290#define CLONE_NEWIPC 0x08000000 /* New ipcs */
291#define CLONE_NEWUSER 0x10000000 /* New user namespace */
292#define CLONE_NEWPID 0x20000000 /* New pid namespace */
293#define CLONE_NEWNET 0x40000000 /* New network namespace */
294#define CLONE_IO 0x80000000 /* Clone io context */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000295
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000296#include "xlat/clone_flags.h"
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000297
Dmitry V. Levinf94e8472014-04-09 12:30:38 +0000298#if defined I386 || defined X86_64 || defined X32
Dmitry V. Levin99a05442014-04-10 14:10:17 +0000299extern void print_user_desc(struct tcb *, long);
Dmitry V. Levinf94e8472014-04-09 12:30:38 +0000300#endif /* I386 || X86_64 || X32 */
Roland McGrath909875b2002-12-22 03:34:36 +0000301
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100302#if defined IA64
303# define ARG_FLAGS 0
304# define ARG_STACK 1
305# define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
306# define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
307# define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
308# define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
309#elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
310# define ARG_STACK 0
311# define ARG_FLAGS 1
312# define ARG_PTID 2
313# define ARG_CTID 3
314# define ARG_TLS 4
Dmitry V. Levin2c4fb252014-04-09 12:34:58 +0000315#elif defined X86_64 || defined X32
Elliott Hughesb5633252014-04-05 11:56:17 -0700316/* x86 personality processes have the last two arguments flipped. */
317# define ARG_FLAGS 0
318# define ARG_STACK 1
319# define ARG_PTID 2
320# define ARG_CTID ((current_personality != 1) ? 3 : 4)
321# define ARG_TLS ((current_personality != 1) ? 4 : 3)
Dmitry V. Levin2c4fb252014-04-09 12:34:58 +0000322#elif defined ALPHA || defined TILE || defined OR1K
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100323# define ARG_FLAGS 0
324# define ARG_STACK 1
325# define ARG_PTID 2
326# define ARG_CTID 3
327# define ARG_TLS 4
328#else
329# define ARG_FLAGS 0
330# define ARG_STACK 1
331# define ARG_PTID 2
332# define ARG_TLS 3
333# define ARG_CTID 4
334#endif
Roland McGrath9677b3a2003-03-12 09:54:36 +0000335
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000336int
Denys Vlasenko12014262011-05-30 14:00:14 +0200337sys_clone(struct tcb *tcp)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000338{
339 if (exiting(tcp)) {
Wang Chaocbdd1902010-09-02 15:08:59 +0800340 const char *sep = "|";
Roland McGrath9677b3a2003-03-12 09:54:36 +0000341 unsigned long flags = tcp->u_arg[ARG_FLAGS];
342 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100343#ifdef ARG_STACKSIZE
Roland McGrath9677b3a2003-03-12 09:54:36 +0000344 if (ARG_STACKSIZE != -1)
345 tprintf("stack_size=%#lx, ",
346 tcp->u_arg[ARG_STACKSIZE]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100347#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200348 tprints("flags=");
Wang Chaocbdd1902010-09-02 15:08:59 +0800349 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
350 sep = "";
Roland McGrath984154d2003-05-23 01:08:42 +0000351 if ((flags & CSIGNAL) != 0)
Wang Chaocbdd1902010-09-02 15:08:59 +0800352 tprintf("%s%s", sep, signame(flags & CSIGNAL));
Roland McGrathb4968be2003-01-20 09:04:33 +0000353 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
Roland McGrath9677b3a2003-03-12 09:54:36 +0000354 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
Roland McGrath909875b2002-12-22 03:34:36 +0000355 return 0;
Roland McGrath6f67a982003-03-21 07:33:15 +0000356 if (flags & CLONE_PARENT_SETTID)
357 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000358 if (flags & CLONE_SETTLS) {
Dmitry V. Levinf94e8472014-04-09 12:30:38 +0000359#if defined I386 || defined X86_64 || defined X32
Elliott Hughes44655a42014-04-05 11:56:17 -0700360# ifndef I386
361 if (current_personality == 1)
362# endif
363 {
Dmitry V. Levin99a05442014-04-10 14:10:17 +0000364 tprints(", tls=");
365 print_user_desc(tcp, tcp->u_arg[ARG_TLS]);
Roland McGrath909875b2002-12-22 03:34:36 +0000366 }
Dmitry V. Levin99a05442014-04-10 14:10:17 +0000367# ifndef I386
Roland McGrath909875b2002-12-22 03:34:36 +0000368 else
Dmitry V. Levin99a05442014-04-10 14:10:17 +0000369# endif
Dmitry V. Levinf94e8472014-04-09 12:30:38 +0000370#endif /* I386 || X86_64 || X32 */
Roland McGrath43f2c842003-03-12 09:58:14 +0000371 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
Roland McGrath909875b2002-12-22 03:34:36 +0000372 }
Roland McGrath9677b3a2003-03-12 09:54:36 +0000373 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
374 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000375 }
Denys Vlasenkod0830162013-06-28 18:57:27 +0200376 /* TODO on syscall entry:
377 * We can clear CLONE_PTRACE here since it is an ancient hack
378 * to allow us to catch children, and we use another hack for that.
379 * But CLONE_PTRACE can conceivably be used by malicious programs
380 * to subvert us. By clearing this bit, we can defend against it:
381 * in untraced execution, CLONE_PTRACE should have no effect.
382 *
383 * We can also clear CLONE_UNTRACED, since it allows to start
384 * children outside of our control. At the moment
385 * I'm trying to figure out whether there is a *legitimate*
386 * use of this flag which we should respect.
387 */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000388 return 0;
389}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000390
391int
Masatake YAMATOb2ede142014-05-14 01:46:04 +0900392sys_setns(struct tcb *tcp)
393{
394 if (entering(tcp)) {
395 printfd(tcp, tcp->u_arg[0]);
396 tprints(", ");
397 printflags(clone_flags, tcp->u_arg[1], "CLONE_???");
398 }
399 return 0;
400}
401
402int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000403sys_unshare(struct tcb *tcp)
404{
405 if (entering(tcp))
406 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
407 return 0;
408}
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000409
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000410int
Denys Vlasenko081533c2012-03-17 02:17:51 +0100411sys_fork(struct tcb *tcp)
412{
413 if (exiting(tcp))
414 return RVAL_UDECIMAL;
415 return 0;
416}
417
Dmitry V. Levin50a218d2011-01-18 17:36:20 +0000418int sys_getuid(struct tcb *tcp)
419{
420 if (exiting(tcp))
421 tcp->u_rval = (uid_t) tcp->u_rval;
422 return RVAL_UDECIMAL;
423}
424
425int sys_setfsuid(struct tcb *tcp)
426{
427 if (entering(tcp))
428 tprintf("%u", (uid_t) tcp->u_arg[0]);
429 else
430 tcp->u_rval = (uid_t) tcp->u_rval;
431 return RVAL_UDECIMAL;
432}
433
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000434int
Denys Vlasenko12014262011-05-30 14:00:14 +0200435sys_setuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000436{
437 if (entering(tcp)) {
438 tprintf("%u", (uid_t) tcp->u_arg[0]);
439 }
440 return 0;
441}
442
443int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000444sys_getresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000445{
446 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000447 __kernel_uid_t uid;
448 if (syserror(tcp))
449 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
450 tcp->u_arg[1], tcp->u_arg[2]);
451 else {
452 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
453 tprintf("%#lx, ", tcp->u_arg[0]);
454 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000455 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000456 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
457 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000458 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000459 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000460 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
461 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000462 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000463 tprintf("[%lu]", (unsigned long) uid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000464 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000465 }
466 return 0;
467}
468
469int
Denys Vlasenko12014262011-05-30 14:00:14 +0200470sys_setreuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000471{
472 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000473 printuid("", tcp->u_arg[0]);
474 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000475 }
476 return 0;
477}
478
479int
Denys Vlasenko12014262011-05-30 14:00:14 +0200480sys_setresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000481{
482 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000483 printuid("", tcp->u_arg[0]);
484 printuid(", ", tcp->u_arg[1]);
485 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000486 }
487 return 0;
488}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000489
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000490int
Denys Vlasenko12014262011-05-30 14:00:14 +0200491sys_setgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000492{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000493 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000494 unsigned long len, size, start, cur, end, abbrev_end;
495 GETGROUPS_T gid;
496 int failed = 0;
497
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000498 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000499 tprintf("%lu, ", len);
500 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200501 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000502 return 0;
503 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000504 start = tcp->u_arg[1];
505 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200506 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000507 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000508 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000509 size = len * sizeof(gid);
510 end = start + size;
511 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
512 tprintf("%#lx", start);
513 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000514 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000515 if (abbrev(tcp)) {
516 abbrev_end = start + max_strlen * sizeof(gid);
517 if (abbrev_end < start)
518 abbrev_end = end;
519 } else {
520 abbrev_end = end;
521 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200522 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000523 for (cur = start; cur < end; cur += sizeof(gid)) {
524 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200525 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000526 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200527 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000528 break;
529 }
530 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200531 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000532 failed = 1;
533 break;
534 }
535 tprintf("%lu", (unsigned long) gid);
536 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200537 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000538 if (failed)
539 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000540 }
541 return 0;
542}
543
544int
Denys Vlasenko12014262011-05-30 14:00:14 +0200545sys_getgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000546{
Roland McGrathaa524c82005-06-01 19:22:06 +0000547 unsigned long len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000548
549 if (entering(tcp)) {
550 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000551 tprintf("%lu, ", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000552 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000553 unsigned long size, start, cur, end, abbrev_end;
554 GETGROUPS_T gid;
555 int failed = 0;
556
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000557 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000558 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200559 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000560 return 0;
561 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000562 start = tcp->u_arg[1];
563 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200564 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000565 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000566 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000567 if (tcp->u_arg[0] == 0) {
568 tprintf("%#lx", start);
569 return 0;
570 }
571 size = len * sizeof(gid);
572 end = start + size;
573 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
574 size / sizeof(gid) != len || end < start) {
575 tprintf("%#lx", start);
576 return 0;
577 }
578 if (abbrev(tcp)) {
579 abbrev_end = start + max_strlen * sizeof(gid);
580 if (abbrev_end < start)
581 abbrev_end = end;
582 } else {
583 abbrev_end = end;
584 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200585 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000586 for (cur = start; cur < end; cur += sizeof(gid)) {
587 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200588 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000589 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200590 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000591 break;
592 }
593 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200594 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000595 failed = 1;
596 break;
597 }
598 tprintf("%lu", (unsigned long) gid);
599 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200600 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000601 if (failed)
602 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000603 }
604 return 0;
605}
606
Roland McGrath83bd47a2003-11-13 22:32:26 +0000607int
Denys Vlasenko12014262011-05-30 14:00:14 +0200608sys_setgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000609{
Roland McGrath83bd47a2003-11-13 22:32:26 +0000610 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000611 unsigned long len, size, start, cur, end, abbrev_end;
612 GETGROUPS32_T gid;
613 int failed = 0;
614
Roland McGrath83bd47a2003-11-13 22:32:26 +0000615 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000616 tprintf("%lu, ", len);
617 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200618 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000619 return 0;
620 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000621 start = tcp->u_arg[1];
622 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200623 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000624 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000625 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000626 size = len * sizeof(gid);
627 end = start + size;
628 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
629 tprintf("%#lx", start);
630 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000631 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000632 if (abbrev(tcp)) {
633 abbrev_end = start + max_strlen * sizeof(gid);
634 if (abbrev_end < start)
635 abbrev_end = end;
636 } else {
637 abbrev_end = end;
638 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200639 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000640 for (cur = start; cur < end; cur += sizeof(gid)) {
641 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200642 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000643 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200644 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000645 break;
646 }
647 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200648 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000649 failed = 1;
650 break;
651 }
652 tprintf("%lu", (unsigned long) gid);
653 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200654 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000655 if (failed)
656 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000657 }
658 return 0;
659}
660
661int
Denys Vlasenko12014262011-05-30 14:00:14 +0200662sys_getgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000663{
Roland McGrathaa524c82005-06-01 19:22:06 +0000664 unsigned long len;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000665
666 if (entering(tcp)) {
667 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000668 tprintf("%lu, ", len);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000669 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000670 unsigned long size, start, cur, end, abbrev_end;
671 GETGROUPS32_T gid;
672 int failed = 0;
673
Roland McGrath83bd47a2003-11-13 22:32:26 +0000674 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000675 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200676 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000677 return 0;
678 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000679 start = tcp->u_arg[1];
680 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200681 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000682 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000683 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000684 size = len * sizeof(gid);
685 end = start + size;
686 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
687 size / sizeof(gid) != len || end < start) {
688 tprintf("%#lx", start);
689 return 0;
690 }
691 if (abbrev(tcp)) {
692 abbrev_end = start + max_strlen * sizeof(gid);
693 if (abbrev_end < start)
694 abbrev_end = end;
695 } else {
696 abbrev_end = end;
697 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200698 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000699 for (cur = start; cur < end; cur += sizeof(gid)) {
700 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200701 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000702 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200703 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000704 break;
705 }
706 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200707 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000708 failed = 1;
709 break;
710 }
711 tprintf("%lu", (unsigned long) gid);
712 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200713 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000714 if (failed)
715 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000716 }
717 return 0;
718}
Roland McGrath83bd47a2003-11-13 22:32:26 +0000719
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000720static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000721printargv(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000722{
Roland McGrath85a3bc42007-08-02 02:13:05 +0000723 union {
Andreas Schwab99c85692009-08-28 19:36:20 +0200724 unsigned int p32;
725 unsigned long p64;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000726 char data[sizeof(long)];
727 } cp;
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000728 const char *sep;
Dmitry V. Levin3ed5d022014-09-10 13:46:04 +0000729 unsigned int n = 0;
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100730 unsigned wordsize = current_wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000731
Roland McGrath85a3bc42007-08-02 02:13:05 +0000732 cp.p64 = 1;
733 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100734 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000735 tprintf("%#lx", addr);
736 return;
737 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100738 if (wordsize == 4)
Roland McGrath85a3bc42007-08-02 02:13:05 +0000739 cp.p64 = cp.p32;
740 if (cp.p64 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000741 break;
Denys Vlasenko5940e652011-09-01 09:55:05 +0200742 tprints(sep);
Roland McGrath85a3bc42007-08-02 02:13:05 +0000743 printstr(tcp, cp.p64, -1);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100744 addr += wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000745 }
Roland McGrath85a3bc42007-08-02 02:13:05 +0000746 if (cp.p64)
747 tprintf("%s...", sep);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000748}
749
750static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000751printargc(const char *fmt, struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000752{
753 int count;
754 char *cp;
755
756 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
757 addr += sizeof(char *);
758 }
759 tprintf(fmt, count, count == 1 ? "" : "s");
760}
761
Denys Vlasenko84703742012-02-25 02:38:52 +0100762#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000763int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000764sys_execv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000765{
766 if (entering(tcp)) {
767 printpath(tcp, tcp->u_arg[0]);
768 if (!verbose(tcp))
769 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000770 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200771 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000772 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200773 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000774 }
775 }
776 return 0;
777}
Denys Vlasenko84703742012-02-25 02:38:52 +0100778#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000779
780int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000781sys_execve(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000782{
783 if (entering(tcp)) {
784 printpath(tcp, tcp->u_arg[0]);
785 if (!verbose(tcp))
786 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000787 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200788 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000789 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200790 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000791 }
792 if (!verbose(tcp))
793 tprintf(", %#lx", tcp->u_arg[2]);
794 else if (abbrev(tcp))
795 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
796 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200797 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000798 printargv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200799 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000800 }
801 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000802 return 0;
803}
804
Roland McGrath7ec1d352002-12-17 04:50:44 +0000805#ifndef __WNOTHREAD
806#define __WNOTHREAD 0x20000000
807#endif
808#ifndef __WALL
809#define __WALL 0x40000000
810#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000811#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +0000812#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000813#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000814
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000815#include "xlat/wait4_options.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000816
Roland McGrath5e02a572004-10-19 23:33:47 +0000817#if !defined WCOREFLAG && defined WCOREFLG
818# define WCOREFLAG WCOREFLG
819#endif
820#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000821# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +0000822#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000823#ifndef WCOREDUMP
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100824# define WCOREDUMP(status) ((status) & 0200)
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000825#endif
Roland McGrath5e02a572004-10-19 23:33:47 +0000826#ifndef W_STOPCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100827# define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
Roland McGrath5e02a572004-10-19 23:33:47 +0000828#endif
829#ifndef W_EXITCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100830# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
Roland McGrath5e02a572004-10-19 23:33:47 +0000831#endif
832
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000833static int
Denys Vlasenko12014262011-05-30 14:00:14 +0200834printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000835{
836 int exited = 0;
837
838 /*
839 * Here is a tricky presentation problem. This solution
840 * is still not entirely satisfactory but since there
841 * are no wait status constructors it will have to do.
842 */
Roland McGrath79fbda52004-04-14 02:45:55 +0000843 if (WIFSTOPPED(status)) {
844 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +0000845 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +0000846 status &= ~W_STOPCODE(WSTOPSIG(status));
847 }
848 else if (WIFSIGNALED(status)) {
849 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +0000850 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000851 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +0000852 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
853 }
854 else if (WIFEXITED(status)) {
855 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000856 WEXITSTATUS(status));
857 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +0000858 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000859 }
Roland McGrath79fbda52004-04-14 02:45:55 +0000860 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000861 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +0000862 return 0;
863 }
864
865 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200866 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +0000867 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +0000868 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +0000869
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000870 return exited;
871}
872
873static int
Denys Vlasenko59432db2009-01-26 19:09:35 +0000874printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000875{
876 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000877
878 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +0000879 /* On Linux, kernel-side pid_t is typedef'ed to int
880 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +0000881 * pid argument to int on 64bit arches, producing,
882 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +0000883 * in strace. We have to use int here, not long.
884 */
885 int pid = tcp->u_arg[0];
886 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000887 } else {
888 /* status */
889 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200890 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000891 else if (syserror(tcp) || tcp->u_rval == 0)
892 tprintf("%#lx", tcp->u_arg[1]);
893 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200894 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000895 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +0000896 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000897 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200898 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000899 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000900 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200901 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000902 /* usage */
903 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200904 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000905 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +0000906#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000907 if (bitness)
908 printrusage32(tcp, tcp->u_arg[3]);
909 else
910#endif
911 printrusage(tcp, tcp->u_arg[3]);
912 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000913 else
914 tprintf("%#lx", tcp->u_arg[3]);
915 }
916 }
917 return 0;
918}
919
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000920int
Denys Vlasenko12014262011-05-30 14:00:14 +0200921sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000922{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000923 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000924}
925
926int
Denys Vlasenko12014262011-05-30 14:00:14 +0200927sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000928{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000929 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000930}
931
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000932#ifdef ALPHA
933int
Denys Vlasenko12014262011-05-30 14:00:14 +0200934sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000935{
936 return printwaitn(tcp, 4, 1);
937}
938#endif
939
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000940#include "xlat/waitid_types.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000941
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000942int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +0000943sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000944{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000945 if (entering(tcp)) {
946 printxval(waitid_types, tcp->u_arg[0], "P_???");
947 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000948 }
949 else {
950 /* siginfo */
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +0100951 printsiginfo_at(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000952 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200953 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000954 printflags(wait4_options, tcp->u_arg[3], "W???");
Denys Vlasenko74ec14f2013-02-21 16:13:47 +0100955 if (tcp->s_ent->nargs > 4) {
Roland McGrath39426a32004-10-06 22:02:59 +0000956 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200957 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +0000958 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200959 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +0000960 else if (tcp->u_error)
961 tprintf("%#lx", tcp->u_arg[4]);
962 else
963 printrusage(tcp, tcp->u_arg[4]);
964 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000965 }
966 return 0;
967}
968
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000969int
Denys Vlasenko12014262011-05-30 14:00:14 +0200970sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000971{
972 struct utsname uname;
973
974 if (exiting(tcp)) {
975 if (syserror(tcp) || !verbose(tcp))
976 tprintf("%#lx", tcp->u_arg[0]);
977 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200978 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000979 else if (!abbrev(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000980 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
981 uname.sysname, uname.nodename);
982 tprintf("release=\"%s\", version=\"%s\", ",
983 uname.release, uname.version);
984 tprintf("machine=\"%s\"", uname.machine);
Dmitry V. Levinea22e972012-05-01 20:56:32 +0000985#ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000986 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +0000987#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200988 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000989 }
990 else
991 tprintf("{sys=\"%s\", node=\"%s\", ...}",
992 uname.sysname, uname.nodename);
993 }
994 return 0;
995}
996
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000997#include "xlat/ptrace_cmds.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000998#include "xlat/ptrace_setoptions_flags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000999#include "xlat/nt_descriptor_types.h"
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001000
Denys Vlasenko513e9c22012-03-21 14:39:22 +01001001#define uoff(member) offsetof(struct user, member)
1002
Roland McGrathd9f816f2004-09-04 03:39:20 +00001003const struct xlat struct_user_offsets[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001004#if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001005 { PT_PSWMASK, "psw_mask" },
1006 { PT_PSWADDR, "psw_addr" },
1007 { PT_GPR0, "gpr0" },
1008 { PT_GPR1, "gpr1" },
1009 { PT_GPR2, "gpr2" },
1010 { PT_GPR3, "gpr3" },
1011 { PT_GPR4, "gpr4" },
1012 { PT_GPR5, "gpr5" },
1013 { PT_GPR6, "gpr6" },
1014 { PT_GPR7, "gpr7" },
1015 { PT_GPR8, "gpr8" },
1016 { PT_GPR9, "gpr9" },
1017 { PT_GPR10, "gpr10" },
1018 { PT_GPR11, "gpr11" },
1019 { PT_GPR12, "gpr12" },
1020 { PT_GPR13, "gpr13" },
1021 { PT_GPR14, "gpr14" },
1022 { PT_GPR15, "gpr15" },
1023 { PT_ACR0, "acr0" },
1024 { PT_ACR1, "acr1" },
1025 { PT_ACR2, "acr2" },
1026 { PT_ACR3, "acr3" },
1027 { PT_ACR4, "acr4" },
1028 { PT_ACR5, "acr5" },
1029 { PT_ACR6, "acr6" },
1030 { PT_ACR7, "acr7" },
1031 { PT_ACR8, "acr8" },
1032 { PT_ACR9, "acr9" },
1033 { PT_ACR10, "acr10" },
1034 { PT_ACR11, "acr11" },
1035 { PT_ACR12, "acr12" },
1036 { PT_ACR13, "acr13" },
1037 { PT_ACR14, "acr14" },
1038 { PT_ACR15, "acr15" },
1039 { PT_ORIGGPR2, "orig_gpr2" },
1040 { PT_FPC, "fpc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001041#if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001042 { PT_FPR0_HI, "fpr0.hi" },
1043 { PT_FPR0_LO, "fpr0.lo" },
1044 { PT_FPR1_HI, "fpr1.hi" },
1045 { PT_FPR1_LO, "fpr1.lo" },
1046 { PT_FPR2_HI, "fpr2.hi" },
1047 { PT_FPR2_LO, "fpr2.lo" },
1048 { PT_FPR3_HI, "fpr3.hi" },
1049 { PT_FPR3_LO, "fpr3.lo" },
1050 { PT_FPR4_HI, "fpr4.hi" },
1051 { PT_FPR4_LO, "fpr4.lo" },
1052 { PT_FPR5_HI, "fpr5.hi" },
1053 { PT_FPR5_LO, "fpr5.lo" },
1054 { PT_FPR6_HI, "fpr6.hi" },
1055 { PT_FPR6_LO, "fpr6.lo" },
1056 { PT_FPR7_HI, "fpr7.hi" },
1057 { PT_FPR7_LO, "fpr7.lo" },
1058 { PT_FPR8_HI, "fpr8.hi" },
1059 { PT_FPR8_LO, "fpr8.lo" },
1060 { PT_FPR9_HI, "fpr9.hi" },
1061 { PT_FPR9_LO, "fpr9.lo" },
1062 { PT_FPR10_HI, "fpr10.hi" },
1063 { PT_FPR10_LO, "fpr10.lo" },
1064 { PT_FPR11_HI, "fpr11.hi" },
1065 { PT_FPR11_LO, "fpr11.lo" },
1066 { PT_FPR12_HI, "fpr12.hi" },
1067 { PT_FPR12_LO, "fpr12.lo" },
1068 { PT_FPR13_HI, "fpr13.hi" },
1069 { PT_FPR13_LO, "fpr13.lo" },
1070 { PT_FPR14_HI, "fpr14.hi" },
1071 { PT_FPR14_LO, "fpr14.lo" },
1072 { PT_FPR15_HI, "fpr15.hi" },
1073 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001074#endif
1075#if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001076 { PT_FPR0, "fpr0" },
1077 { PT_FPR1, "fpr1" },
1078 { PT_FPR2, "fpr2" },
1079 { PT_FPR3, "fpr3" },
1080 { PT_FPR4, "fpr4" },
1081 { PT_FPR5, "fpr5" },
1082 { PT_FPR6, "fpr6" },
1083 { PT_FPR7, "fpr7" },
1084 { PT_FPR8, "fpr8" },
1085 { PT_FPR9, "fpr9" },
1086 { PT_FPR10, "fpr10" },
1087 { PT_FPR11, "fpr11" },
1088 { PT_FPR12, "fpr12" },
1089 { PT_FPR13, "fpr13" },
1090 { PT_FPR14, "fpr14" },
1091 { PT_FPR15, "fpr15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001092#endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001093 { PT_CR_9, "cr9" },
1094 { PT_CR_10, "cr10" },
1095 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001096 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001097#elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001098 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001099#elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001100 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001101#elif defined(POWERPC)
1102# ifndef PT_ORIG_R3
1103# define PT_ORIG_R3 34
1104# endif
1105# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001106 { REGSIZE*PT_R0, "r0" },
1107 { REGSIZE*PT_R1, "r1" },
1108 { REGSIZE*PT_R2, "r2" },
1109 { REGSIZE*PT_R3, "r3" },
1110 { REGSIZE*PT_R4, "r4" },
1111 { REGSIZE*PT_R5, "r5" },
1112 { REGSIZE*PT_R6, "r6" },
1113 { REGSIZE*PT_R7, "r7" },
1114 { REGSIZE*PT_R8, "r8" },
1115 { REGSIZE*PT_R9, "r9" },
1116 { REGSIZE*PT_R10, "r10" },
1117 { REGSIZE*PT_R11, "r11" },
1118 { REGSIZE*PT_R12, "r12" },
1119 { REGSIZE*PT_R13, "r13" },
1120 { REGSIZE*PT_R14, "r14" },
1121 { REGSIZE*PT_R15, "r15" },
1122 { REGSIZE*PT_R16, "r16" },
1123 { REGSIZE*PT_R17, "r17" },
1124 { REGSIZE*PT_R18, "r18" },
1125 { REGSIZE*PT_R19, "r19" },
1126 { REGSIZE*PT_R20, "r20" },
1127 { REGSIZE*PT_R21, "r21" },
1128 { REGSIZE*PT_R22, "r22" },
1129 { REGSIZE*PT_R23, "r23" },
1130 { REGSIZE*PT_R24, "r24" },
1131 { REGSIZE*PT_R25, "r25" },
1132 { REGSIZE*PT_R26, "r26" },
1133 { REGSIZE*PT_R27, "r27" },
1134 { REGSIZE*PT_R28, "r28" },
1135 { REGSIZE*PT_R29, "r29" },
1136 { REGSIZE*PT_R30, "r30" },
1137 { REGSIZE*PT_R31, "r31" },
1138 { REGSIZE*PT_NIP, "NIP" },
1139 { REGSIZE*PT_MSR, "MSR" },
1140 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1141 { REGSIZE*PT_CTR, "CTR" },
1142 { REGSIZE*PT_LNK, "LNK" },
1143 { REGSIZE*PT_XER, "XER" },
1144 { REGSIZE*PT_CCR, "CCR" },
1145 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001146# undef REGSIZE
1147#elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001148 { 0, "r0" },
1149 { 1, "r1" },
1150 { 2, "r2" },
1151 { 3, "r3" },
1152 { 4, "r4" },
1153 { 5, "r5" },
1154 { 6, "r6" },
1155 { 7, "r7" },
1156 { 8, "r8" },
1157 { 9, "r9" },
1158 { 10, "r10" },
1159 { 11, "r11" },
1160 { 12, "r12" },
1161 { 13, "r13" },
1162 { 14, "r14" },
1163 { 15, "r15" },
1164 { 16, "r16" },
1165 { 17, "r17" },
1166 { 18, "r18" },
1167 { 19, "r19" },
1168 { 20, "r20" },
1169 { 21, "r21" },
1170 { 22, "r22" },
1171 { 23, "r23" },
1172 { 24, "r24" },
1173 { 25, "r25" },
1174 { 26, "r26" },
1175 { 27, "r27" },
1176 { 28, "r28" },
1177 { 29, "gp" },
1178 { 30, "fp" },
1179 { 31, "zero" },
1180 { 32, "fp0" },
1181 { 33, "fp" },
1182 { 34, "fp2" },
1183 { 35, "fp3" },
1184 { 36, "fp4" },
1185 { 37, "fp5" },
1186 { 38, "fp6" },
1187 { 39, "fp7" },
1188 { 40, "fp8" },
1189 { 41, "fp9" },
1190 { 42, "fp10" },
1191 { 43, "fp11" },
1192 { 44, "fp12" },
1193 { 45, "fp13" },
1194 { 46, "fp14" },
1195 { 47, "fp15" },
1196 { 48, "fp16" },
1197 { 49, "fp17" },
1198 { 50, "fp18" },
1199 { 51, "fp19" },
1200 { 52, "fp20" },
1201 { 53, "fp21" },
1202 { 54, "fp22" },
1203 { 55, "fp23" },
1204 { 56, "fp24" },
1205 { 57, "fp25" },
1206 { 58, "fp26" },
1207 { 59, "fp27" },
1208 { 60, "fp28" },
1209 { 61, "fp29" },
1210 { 62, "fp30" },
1211 { 63, "fp31" },
1212 { 64, "pc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001213#elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001214 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1215 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1216 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1217 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1218 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1219 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1220 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1221 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1222 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1223 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1224 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1225 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1226 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1227 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1228 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1229 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1230 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1231 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1232 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1233 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1234 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1235 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1236 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1237 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1238 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1239 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1240 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1241 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1242 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1243 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1244 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1245 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1246 /* switch stack: */
1247 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1248 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1249 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1250 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1251 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1252 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1253 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1254 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1255 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1256 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001257 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1258 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001259 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001260 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001261 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1262 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001263 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1264 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1265 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1266 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1267 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1268 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1269 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1270 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1271 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1272 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1273 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1274 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1275 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1276 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1277 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001278# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001279 { PT_AR_CSD, "ar.csd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001280# endif
1281# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001282 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001283# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001284 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001285#elif defined(I386)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001286 XLAT(4*EBX),
1287 XLAT(4*ECX),
1288 XLAT(4*EDX),
1289 XLAT(4*ESI),
1290 XLAT(4*EDI),
1291 XLAT(4*EBP),
1292 XLAT(4*EAX),
1293 XLAT(4*DS),
1294 XLAT(4*ES),
1295 XLAT(4*FS),
1296 XLAT(4*GS),
1297 XLAT(4*ORIG_EAX),
1298 XLAT(4*EIP),
1299 XLAT(4*CS),
1300 XLAT(4*EFL),
1301 XLAT(4*UESP),
1302 XLAT(4*SS),
H.J. Lu35be5812012-04-16 13:00:01 +02001303#elif defined(X86_64) || defined(X32)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001304 XLAT(8*R15),
1305 XLAT(8*R14),
1306 XLAT(8*R13),
1307 XLAT(8*R12),
1308 XLAT(8*RBP),
1309 XLAT(8*RBX),
1310 XLAT(8*R11),
1311 XLAT(8*R10),
1312 XLAT(8*R9),
1313 XLAT(8*R8),
1314 XLAT(8*RAX),
1315 XLAT(8*RCX),
1316 XLAT(8*RDX),
1317 XLAT(8*RSI),
1318 XLAT(8*RDI),
1319 XLAT(8*ORIG_RAX),
1320 XLAT(8*RIP),
1321 XLAT(8*CS),
Michal Ludvig0e035502002-09-23 15:41:01 +00001322 { 8*EFLAGS, "8*EFL" },
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001323 XLAT(8*RSP),
1324 XLAT(8*SS),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001325#elif defined(M68K)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001326 XLAT(4*PT_D1),
1327 XLAT(4*PT_D2),
1328 XLAT(4*PT_D3),
1329 XLAT(4*PT_D4),
1330 XLAT(4*PT_D5),
1331 XLAT(4*PT_D6),
1332 XLAT(4*PT_D7),
1333 XLAT(4*PT_A0),
1334 XLAT(4*PT_A1),
1335 XLAT(4*PT_A2),
1336 XLAT(4*PT_A3),
1337 XLAT(4*PT_A4),
1338 XLAT(4*PT_A5),
1339 XLAT(4*PT_A6),
1340 XLAT(4*PT_D0),
1341 XLAT(4*PT_USP),
1342 XLAT(4*PT_ORIG_D0),
1343 XLAT(4*PT_SR),
1344 XLAT(4*PT_PC),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001345#elif defined(SH)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001346 XLAT(4*REG_REG0),
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001347 { 4*(REG_REG0+1), "4*REG_REG1" },
1348 { 4*(REG_REG0+2), "4*REG_REG2" },
1349 { 4*(REG_REG0+3), "4*REG_REG3" },
1350 { 4*(REG_REG0+4), "4*REG_REG4" },
1351 { 4*(REG_REG0+5), "4*REG_REG5" },
1352 { 4*(REG_REG0+6), "4*REG_REG6" },
1353 { 4*(REG_REG0+7), "4*REG_REG7" },
1354 { 4*(REG_REG0+8), "4*REG_REG8" },
1355 { 4*(REG_REG0+9), "4*REG_REG9" },
1356 { 4*(REG_REG0+10), "4*REG_REG10" },
1357 { 4*(REG_REG0+11), "4*REG_REG11" },
1358 { 4*(REG_REG0+12), "4*REG_REG12" },
1359 { 4*(REG_REG0+13), "4*REG_REG13" },
1360 { 4*(REG_REG0+14), "4*REG_REG14" },
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001361 XLAT(4*REG_REG15),
1362 XLAT(4*REG_PC),
1363 XLAT(4*REG_PR),
1364 XLAT(4*REG_SR),
1365 XLAT(4*REG_GBR),
1366 XLAT(4*REG_MACH),
1367 XLAT(4*REG_MACL),
1368 XLAT(4*REG_SYSCALL),
1369 XLAT(4*REG_FPUL),
1370 XLAT(4*REG_FPREG0),
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001371 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1372 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1373 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1374 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1375 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1376 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1377 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1378 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1379 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1380 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1381 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1382 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1383 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1384 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001385 XLAT(4*REG_FPREG15),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001386# ifdef REG_XDREG0
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001387 XLAT(4*REG_XDREG0),
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001388 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1389 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1390 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1391 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1392 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1393 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001394 XLAT(4*REG_XDREG14),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001395# endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001396 XLAT(4*REG_FPSCR),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001397#elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001398 { 0, "PC(L)" },
1399 { 4, "PC(U)" },
1400 { 8, "SR(L)" },
1401 { 12, "SR(U)" },
1402 { 16, "syscall no.(L)" },
1403 { 20, "syscall_no.(U)" },
1404 { 24, "R0(L)" },
1405 { 28, "R0(U)" },
1406 { 32, "R1(L)" },
1407 { 36, "R1(U)" },
1408 { 40, "R2(L)" },
1409 { 44, "R2(U)" },
1410 { 48, "R3(L)" },
1411 { 52, "R3(U)" },
1412 { 56, "R4(L)" },
1413 { 60, "R4(U)" },
1414 { 64, "R5(L)" },
1415 { 68, "R5(U)" },
1416 { 72, "R6(L)" },
1417 { 76, "R6(U)" },
1418 { 80, "R7(L)" },
1419 { 84, "R7(U)" },
1420 { 88, "R8(L)" },
1421 { 92, "R8(U)" },
1422 { 96, "R9(L)" },
1423 { 100, "R9(U)" },
1424 { 104, "R10(L)" },
1425 { 108, "R10(U)" },
1426 { 112, "R11(L)" },
1427 { 116, "R11(U)" },
1428 { 120, "R12(L)" },
1429 { 124, "R12(U)" },
1430 { 128, "R13(L)" },
1431 { 132, "R13(U)" },
1432 { 136, "R14(L)" },
1433 { 140, "R14(U)" },
1434 { 144, "R15(L)" },
1435 { 148, "R15(U)" },
1436 { 152, "R16(L)" },
1437 { 156, "R16(U)" },
1438 { 160, "R17(L)" },
1439 { 164, "R17(U)" },
1440 { 168, "R18(L)" },
1441 { 172, "R18(U)" },
1442 { 176, "R19(L)" },
1443 { 180, "R19(U)" },
1444 { 184, "R20(L)" },
1445 { 188, "R20(U)" },
1446 { 192, "R21(L)" },
1447 { 196, "R21(U)" },
1448 { 200, "R22(L)" },
1449 { 204, "R22(U)" },
1450 { 208, "R23(L)" },
1451 { 212, "R23(U)" },
1452 { 216, "R24(L)" },
1453 { 220, "R24(U)" },
1454 { 224, "R25(L)" },
1455 { 228, "R25(U)" },
1456 { 232, "R26(L)" },
1457 { 236, "R26(U)" },
1458 { 240, "R27(L)" },
1459 { 244, "R27(U)" },
1460 { 248, "R28(L)" },
1461 { 252, "R28(U)" },
1462 { 256, "R29(L)" },
1463 { 260, "R29(U)" },
1464 { 264, "R30(L)" },
1465 { 268, "R30(U)" },
1466 { 272, "R31(L)" },
1467 { 276, "R31(U)" },
1468 { 280, "R32(L)" },
1469 { 284, "R32(U)" },
1470 { 288, "R33(L)" },
1471 { 292, "R33(U)" },
1472 { 296, "R34(L)" },
1473 { 300, "R34(U)" },
1474 { 304, "R35(L)" },
1475 { 308, "R35(U)" },
1476 { 312, "R36(L)" },
1477 { 316, "R36(U)" },
1478 { 320, "R37(L)" },
1479 { 324, "R37(U)" },
1480 { 328, "R38(L)" },
1481 { 332, "R38(U)" },
1482 { 336, "R39(L)" },
1483 { 340, "R39(U)" },
1484 { 344, "R40(L)" },
1485 { 348, "R40(U)" },
1486 { 352, "R41(L)" },
1487 { 356, "R41(U)" },
1488 { 360, "R42(L)" },
1489 { 364, "R42(U)" },
1490 { 368, "R43(L)" },
1491 { 372, "R43(U)" },
1492 { 376, "R44(L)" },
1493 { 380, "R44(U)" },
1494 { 384, "R45(L)" },
1495 { 388, "R45(U)" },
1496 { 392, "R46(L)" },
1497 { 396, "R46(U)" },
1498 { 400, "R47(L)" },
1499 { 404, "R47(U)" },
1500 { 408, "R48(L)" },
1501 { 412, "R48(U)" },
1502 { 416, "R49(L)" },
1503 { 420, "R49(U)" },
1504 { 424, "R50(L)" },
1505 { 428, "R50(U)" },
1506 { 432, "R51(L)" },
1507 { 436, "R51(U)" },
1508 { 440, "R52(L)" },
1509 { 444, "R52(U)" },
1510 { 448, "R53(L)" },
1511 { 452, "R53(U)" },
1512 { 456, "R54(L)" },
1513 { 460, "R54(U)" },
1514 { 464, "R55(L)" },
1515 { 468, "R55(U)" },
1516 { 472, "R56(L)" },
1517 { 476, "R56(U)" },
1518 { 480, "R57(L)" },
1519 { 484, "R57(U)" },
1520 { 488, "R58(L)" },
1521 { 492, "R58(U)" },
1522 { 496, "R59(L)" },
1523 { 500, "R59(U)" },
1524 { 504, "R60(L)" },
1525 { 508, "R60(U)" },
1526 { 512, "R61(L)" },
1527 { 516, "R61(U)" },
1528 { 520, "R62(L)" },
1529 { 524, "R62(U)" },
1530 { 528, "TR0(L)" },
1531 { 532, "TR0(U)" },
1532 { 536, "TR1(L)" },
1533 { 540, "TR1(U)" },
1534 { 544, "TR2(L)" },
1535 { 548, "TR2(U)" },
1536 { 552, "TR3(L)" },
1537 { 556, "TR3(U)" },
1538 { 560, "TR4(L)" },
1539 { 564, "TR4(U)" },
1540 { 568, "TR5(L)" },
1541 { 572, "TR5(U)" },
1542 { 576, "TR6(L)" },
1543 { 580, "TR6(U)" },
1544 { 584, "TR7(L)" },
1545 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00001546 /* This entry is in case pt_regs contains dregs (depends on
1547 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001548 { uoff(regs), "offsetof(struct user, regs)" },
1549 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001550#elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00001551 { uoff(regs.ARM_r0), "r0" },
1552 { uoff(regs.ARM_r1), "r1" },
1553 { uoff(regs.ARM_r2), "r2" },
1554 { uoff(regs.ARM_r3), "r3" },
1555 { uoff(regs.ARM_r4), "r4" },
1556 { uoff(regs.ARM_r5), "r5" },
1557 { uoff(regs.ARM_r6), "r6" },
1558 { uoff(regs.ARM_r7), "r7" },
1559 { uoff(regs.ARM_r8), "r8" },
1560 { uoff(regs.ARM_r9), "r9" },
1561 { uoff(regs.ARM_r10), "r10" },
1562 { uoff(regs.ARM_fp), "fp" },
1563 { uoff(regs.ARM_ip), "ip" },
1564 { uoff(regs.ARM_sp), "sp" },
1565 { uoff(regs.ARM_lr), "lr" },
1566 { uoff(regs.ARM_pc), "pc" },
1567 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001568#elif defined(AVR32)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001569 { uoff(regs.sr), "sr" },
1570 { uoff(regs.pc), "pc" },
1571 { uoff(regs.lr), "lr" },
1572 { uoff(regs.sp), "sp" },
1573 { uoff(regs.r12), "r12" },
1574 { uoff(regs.r11), "r11" },
1575 { uoff(regs.r10), "r10" },
1576 { uoff(regs.r9), "r9" },
1577 { uoff(regs.r8), "r8" },
1578 { uoff(regs.r7), "r7" },
1579 { uoff(regs.r6), "r6" },
1580 { uoff(regs.r5), "r5" },
1581 { uoff(regs.r4), "r4" },
1582 { uoff(regs.r3), "r3" },
1583 { uoff(regs.r2), "r2" },
1584 { uoff(regs.r1), "r1" },
1585 { uoff(regs.r0), "r0" },
1586 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001587#elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00001588 { 0, "r0" },
1589 { 1, "r1" },
1590 { 2, "r2" },
1591 { 3, "r3" },
1592 { 4, "r4" },
1593 { 5, "r5" },
1594 { 6, "r6" },
1595 { 7, "r7" },
1596 { 8, "r8" },
1597 { 9, "r9" },
1598 { 10, "r10" },
1599 { 11, "r11" },
1600 { 12, "r12" },
1601 { 13, "r13" },
1602 { 14, "r14" },
1603 { 15, "r15" },
1604 { 16, "r16" },
1605 { 17, "r17" },
1606 { 18, "r18" },
1607 { 19, "r19" },
1608 { 20, "r20" },
1609 { 21, "r21" },
1610 { 22, "r22" },
1611 { 23, "r23" },
1612 { 24, "r24" },
1613 { 25, "r25" },
1614 { 26, "r26" },
1615 { 27, "r27" },
1616 { 28, "r28" },
1617 { 29, "r29" },
1618 { 30, "r30" },
1619 { 31, "r31" },
1620 { 32, "f0" },
1621 { 33, "f1" },
1622 { 34, "f2" },
1623 { 35, "f3" },
1624 { 36, "f4" },
1625 { 37, "f5" },
1626 { 38, "f6" },
1627 { 39, "f7" },
1628 { 40, "f8" },
1629 { 41, "f9" },
1630 { 42, "f10" },
1631 { 43, "f11" },
1632 { 44, "f12" },
1633 { 45, "f13" },
1634 { 46, "f14" },
1635 { 47, "f15" },
1636 { 48, "f16" },
1637 { 49, "f17" },
1638 { 50, "f18" },
1639 { 51, "f19" },
1640 { 52, "f20" },
1641 { 53, "f21" },
1642 { 54, "f22" },
1643 { 55, "f23" },
1644 { 56, "f24" },
1645 { 57, "f25" },
1646 { 58, "f26" },
1647 { 59, "f27" },
1648 { 60, "f28" },
1649 { 61, "f29" },
1650 { 62, "f30" },
1651 { 63, "f31" },
1652 { 64, "pc" },
1653 { 65, "cause" },
1654 { 66, "badvaddr" },
1655 { 67, "mmhi" },
1656 { 68, "mmlo" },
1657 { 69, "fpcsr" },
1658 { 70, "fpeir" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001659#elif defined(TILE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05001660 { PTREGS_OFFSET_REG(0), "r0" },
1661 { PTREGS_OFFSET_REG(1), "r1" },
1662 { PTREGS_OFFSET_REG(2), "r2" },
1663 { PTREGS_OFFSET_REG(3), "r3" },
1664 { PTREGS_OFFSET_REG(4), "r4" },
1665 { PTREGS_OFFSET_REG(5), "r5" },
1666 { PTREGS_OFFSET_REG(6), "r6" },
1667 { PTREGS_OFFSET_REG(7), "r7" },
1668 { PTREGS_OFFSET_REG(8), "r8" },
1669 { PTREGS_OFFSET_REG(9), "r9" },
1670 { PTREGS_OFFSET_REG(10), "r10" },
1671 { PTREGS_OFFSET_REG(11), "r11" },
1672 { PTREGS_OFFSET_REG(12), "r12" },
1673 { PTREGS_OFFSET_REG(13), "r13" },
1674 { PTREGS_OFFSET_REG(14), "r14" },
1675 { PTREGS_OFFSET_REG(15), "r15" },
1676 { PTREGS_OFFSET_REG(16), "r16" },
1677 { PTREGS_OFFSET_REG(17), "r17" },
1678 { PTREGS_OFFSET_REG(18), "r18" },
1679 { PTREGS_OFFSET_REG(19), "r19" },
1680 { PTREGS_OFFSET_REG(20), "r20" },
1681 { PTREGS_OFFSET_REG(21), "r21" },
1682 { PTREGS_OFFSET_REG(22), "r22" },
1683 { PTREGS_OFFSET_REG(23), "r23" },
1684 { PTREGS_OFFSET_REG(24), "r24" },
1685 { PTREGS_OFFSET_REG(25), "r25" },
1686 { PTREGS_OFFSET_REG(26), "r26" },
1687 { PTREGS_OFFSET_REG(27), "r27" },
1688 { PTREGS_OFFSET_REG(28), "r28" },
1689 { PTREGS_OFFSET_REG(29), "r29" },
1690 { PTREGS_OFFSET_REG(30), "r30" },
1691 { PTREGS_OFFSET_REG(31), "r31" },
1692 { PTREGS_OFFSET_REG(32), "r32" },
1693 { PTREGS_OFFSET_REG(33), "r33" },
1694 { PTREGS_OFFSET_REG(34), "r34" },
1695 { PTREGS_OFFSET_REG(35), "r35" },
1696 { PTREGS_OFFSET_REG(36), "r36" },
1697 { PTREGS_OFFSET_REG(37), "r37" },
1698 { PTREGS_OFFSET_REG(38), "r38" },
1699 { PTREGS_OFFSET_REG(39), "r39" },
1700 { PTREGS_OFFSET_REG(40), "r40" },
1701 { PTREGS_OFFSET_REG(41), "r41" },
1702 { PTREGS_OFFSET_REG(42), "r42" },
1703 { PTREGS_OFFSET_REG(43), "r43" },
1704 { PTREGS_OFFSET_REG(44), "r44" },
1705 { PTREGS_OFFSET_REG(45), "r45" },
1706 { PTREGS_OFFSET_REG(46), "r46" },
1707 { PTREGS_OFFSET_REG(47), "r47" },
1708 { PTREGS_OFFSET_REG(48), "r48" },
1709 { PTREGS_OFFSET_REG(49), "r49" },
1710 { PTREGS_OFFSET_REG(50), "r50" },
1711 { PTREGS_OFFSET_REG(51), "r51" },
1712 { PTREGS_OFFSET_REG(52), "r52" },
1713 { PTREGS_OFFSET_TP, "tp" },
1714 { PTREGS_OFFSET_SP, "sp" },
1715 { PTREGS_OFFSET_LR, "lr" },
1716 { PTREGS_OFFSET_PC, "pc" },
1717 { PTREGS_OFFSET_EX1, "ex1" },
1718 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
1719 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
1720 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001721#endif
1722#ifdef CRISV10
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001723 XLAT(4*PT_FRAMETYPE),
1724 XLAT(4*PT_ORIG_R10),
1725 XLAT(4*PT_R13),
1726 XLAT(4*PT_R12),
1727 XLAT(4*PT_R11),
1728 XLAT(4*PT_R10),
1729 XLAT(4*PT_R9),
1730 XLAT(4*PT_R8),
1731 XLAT(4*PT_R7),
1732 XLAT(4*PT_R6),
1733 XLAT(4*PT_R5),
1734 XLAT(4*PT_R4),
1735 XLAT(4*PT_R3),
1736 XLAT(4*PT_R2),
1737 XLAT(4*PT_R1),
1738 XLAT(4*PT_R0),
1739 XLAT(4*PT_MOF),
1740 XLAT(4*PT_DCCR),
1741 XLAT(4*PT_SRP),
1742 XLAT(4*PT_IRP),
1743 XLAT(4*PT_CSRINSTR),
1744 XLAT(4*PT_CSRADDR),
1745 XLAT(4*PT_CSRDATA),
1746 XLAT(4*PT_USP),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001747#endif
1748#ifdef CRISV32
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001749 XLAT(4*PT_ORIG_R10),
1750 XLAT(4*PT_R0),
1751 XLAT(4*PT_R1),
1752 XLAT(4*PT_R2),
1753 XLAT(4*PT_R3),
1754 XLAT(4*PT_R4),
1755 XLAT(4*PT_R5),
1756 XLAT(4*PT_R6),
1757 XLAT(4*PT_R7),
1758 XLAT(4*PT_R8),
1759 XLAT(4*PT_R9),
1760 XLAT(4*PT_R10),
1761 XLAT(4*PT_R11),
1762 XLAT(4*PT_R12),
1763 XLAT(4*PT_R13),
1764 XLAT(4*PT_ACR),
1765 XLAT(4*PT_SRS),
1766 XLAT(4*PT_MOF),
1767 XLAT(4*PT_SPC),
1768 XLAT(4*PT_CCS),
1769 XLAT(4*PT_SRP),
1770 XLAT(4*PT_ERP),
1771 XLAT(4*PT_EXS),
1772 XLAT(4*PT_EDA),
1773 XLAT(4*PT_USP),
1774 XLAT(4*PT_PPC),
1775 XLAT(4*PT_BP_CTRL),
1776 XLAT(4*PT_BP+4),
1777 XLAT(4*PT_BP+8),
1778 XLAT(4*PT_BP+12),
1779 XLAT(4*PT_BP+16),
1780 XLAT(4*PT_BP+20),
1781 XLAT(4*PT_BP+24),
1782 XLAT(4*PT_BP+28),
1783 XLAT(4*PT_BP+32),
1784 XLAT(4*PT_BP+36),
1785 XLAT(4*PT_BP+40),
1786 XLAT(4*PT_BP+44),
1787 XLAT(4*PT_BP+48),
1788 XLAT(4*PT_BP+52),
1789 XLAT(4*PT_BP+56),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001790#endif
1791#ifdef MICROBLAZE
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02001792 { PT_GPR(0), "r0" },
1793 { PT_GPR(1), "r1" },
1794 { PT_GPR(2), "r2" },
1795 { PT_GPR(3), "r3" },
1796 { PT_GPR(4), "r4" },
1797 { PT_GPR(5), "r5" },
1798 { PT_GPR(6), "r6" },
1799 { PT_GPR(7), "r7" },
1800 { PT_GPR(8), "r8" },
1801 { PT_GPR(9), "r9" },
1802 { PT_GPR(10), "r10" },
1803 { PT_GPR(11), "r11" },
1804 { PT_GPR(12), "r12" },
1805 { PT_GPR(13), "r13" },
1806 { PT_GPR(14), "r14" },
1807 { PT_GPR(15), "r15" },
1808 { PT_GPR(16), "r16" },
1809 { PT_GPR(17), "r17" },
1810 { PT_GPR(18), "r18" },
1811 { PT_GPR(19), "r19" },
1812 { PT_GPR(20), "r20" },
1813 { PT_GPR(21), "r21" },
1814 { PT_GPR(22), "r22" },
1815 { PT_GPR(23), "r23" },
1816 { PT_GPR(24), "r24" },
1817 { PT_GPR(25), "r25" },
1818 { PT_GPR(26), "r26" },
1819 { PT_GPR(27), "r27" },
1820 { PT_GPR(28), "r28" },
1821 { PT_GPR(29), "r29" },
1822 { PT_GPR(30), "r30" },
1823 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001824 { PT_PC, "rpc", },
1825 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02001826 { PT_EAR, "rear", },
1827 { PT_ESR, "resr", },
1828 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001829 { PT_KERNEL_MODE, "kernel_mode", },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001830#endif
Christian Svensson492f81f2013-02-14 13:26:27 +01001831#ifdef OR1K
1832 { 4*0, "r0" },
1833 { 4*1, "r1" },
1834 { 4*2, "r2" },
1835 { 4*3, "r3" },
1836 { 4*4, "r4" },
1837 { 4*5, "r5" },
1838 { 4*6, "r6" },
1839 { 4*7, "r7" },
1840 { 4*8, "r8" },
1841 { 4*9, "r9" },
1842 { 4*10, "r10" },
1843 { 4*11, "r11" },
1844 { 4*12, "r12" },
1845 { 4*13, "r13" },
1846 { 4*14, "r14" },
1847 { 4*15, "r15" },
1848 { 4*16, "r16" },
1849 { 4*17, "r17" },
1850 { 4*18, "r18" },
1851 { 4*19, "r19" },
1852 { 4*20, "r20" },
1853 { 4*21, "r21" },
1854 { 4*22, "r22" },
1855 { 4*23, "r23" },
1856 { 4*24, "r24" },
1857 { 4*25, "r25" },
1858 { 4*26, "r26" },
1859 { 4*27, "r27" },
1860 { 4*28, "r28" },
1861 { 4*29, "r29" },
1862 { 4*30, "r30" },
1863 { 4*31, "r31" },
1864 { 4*32, "pc" },
1865 { 4*33, "sr" },
1866#endif
Chris Zankel8f636ed2013-03-25 10:22:07 -07001867#ifdef XTENSA
Max Filippov57fac752014-06-18 06:04:06 +04001868 { REG_A_BASE, "a0" },
1869 { REG_A_BASE+1, "a1" },
1870 { REG_A_BASE+2, "a2" },
1871 { REG_A_BASE+3, "a3" },
1872 { REG_A_BASE+4, "a4" },
1873 { REG_A_BASE+5, "a5" },
1874 { REG_A_BASE+6, "a6" },
1875 { REG_A_BASE+7, "a7" },
1876 { REG_A_BASE+8, "a8" },
1877 { REG_A_BASE+9, "a9" },
1878 { REG_A_BASE+10, "a10" },
1879 { REG_A_BASE+11, "a11" },
1880 { REG_A_BASE+12, "a12" },
1881 { REG_A_BASE+13, "a13" },
1882 { REG_A_BASE+14, "a14" },
1883 { REG_A_BASE+15, "a15" },
1884 { REG_PC, "pc" },
Chris Zankel8f636ed2013-03-25 10:22:07 -07001885 { SYSCALL_NR, "syscall_nr" },
1886 { REG_AR_BASE, "ar0" },
1887 { REG_AR_BASE+1, "ar1" },
1888 { REG_AR_BASE+2, "ar2" },
1889 { REG_AR_BASE+3, "ar3" },
1890 { REG_AR_BASE+4, "ar4" },
1891 { REG_AR_BASE+5, "ar5" },
1892 { REG_AR_BASE+6, "ar6" },
1893 { REG_AR_BASE+7, "ar7" },
1894 { REG_AR_BASE+8, "ar8" },
1895 { REG_AR_BASE+9, "ar9" },
1896 { REG_AR_BASE+10, "ar10" },
1897 { REG_AR_BASE+11, "ar11" },
1898 { REG_AR_BASE+12, "ar12" },
1899 { REG_AR_BASE+13, "ar13" },
1900 { REG_AR_BASE+14, "ar14" },
1901 { REG_AR_BASE+15, "ar15" },
1902 { REG_AR_BASE+16, "ar16" },
1903 { REG_AR_BASE+17, "ar17" },
1904 { REG_AR_BASE+18, "ar18" },
1905 { REG_AR_BASE+19, "ar19" },
1906 { REG_AR_BASE+20, "ar20" },
1907 { REG_AR_BASE+21, "ar21" },
1908 { REG_AR_BASE+22, "ar22" },
1909 { REG_AR_BASE+23, "ar23" },
1910 { REG_AR_BASE+24, "ar24" },
1911 { REG_AR_BASE+25, "ar25" },
1912 { REG_AR_BASE+26, "ar26" },
1913 { REG_AR_BASE+27, "ar27" },
1914 { REG_AR_BASE+28, "ar28" },
1915 { REG_AR_BASE+29, "ar29" },
1916 { REG_AR_BASE+30, "ar30" },
1917 { REG_AR_BASE+31, "ar31" },
1918 { REG_AR_BASE+32, "ar32" },
1919 { REG_AR_BASE+33, "ar33" },
1920 { REG_AR_BASE+34, "ar34" },
1921 { REG_AR_BASE+35, "ar35" },
1922 { REG_AR_BASE+36, "ar36" },
1923 { REG_AR_BASE+37, "ar37" },
1924 { REG_AR_BASE+38, "ar38" },
1925 { REG_AR_BASE+39, "ar39" },
1926 { REG_AR_BASE+40, "ar40" },
1927 { REG_AR_BASE+41, "ar41" },
1928 { REG_AR_BASE+42, "ar42" },
1929 { REG_AR_BASE+43, "ar43" },
1930 { REG_AR_BASE+44, "ar44" },
1931 { REG_AR_BASE+45, "ar45" },
1932 { REG_AR_BASE+46, "ar46" },
1933 { REG_AR_BASE+47, "ar47" },
1934 { REG_AR_BASE+48, "ar48" },
1935 { REG_AR_BASE+49, "ar49" },
1936 { REG_AR_BASE+50, "ar50" },
1937 { REG_AR_BASE+51, "ar51" },
1938 { REG_AR_BASE+52, "ar52" },
1939 { REG_AR_BASE+53, "ar53" },
1940 { REG_AR_BASE+54, "ar54" },
1941 { REG_AR_BASE+55, "ar55" },
1942 { REG_AR_BASE+56, "ar56" },
1943 { REG_AR_BASE+57, "ar57" },
1944 { REG_AR_BASE+58, "ar58" },
1945 { REG_AR_BASE+59, "ar59" },
1946 { REG_AR_BASE+60, "ar60" },
1947 { REG_AR_BASE+61, "ar61" },
1948 { REG_AR_BASE+62, "ar62" },
1949 { REG_AR_BASE+63, "ar63" },
1950 { REG_LBEG, "lbeg" },
1951 { REG_LEND, "lend" },
1952 { REG_LCOUNT, "lcount" },
1953 { REG_SAR, "sar" },
1954 { REG_WB, "wb" },
1955 { REG_WS, "ws" },
1956 { REG_PS, "ps" },
Chris Zankel8f636ed2013-03-25 10:22:07 -07001957#endif
1958
Denys Vlasenko729e18d2013-02-12 15:51:58 +01001959 /* Other fields in "struct user" */
1960#if defined(S390) || defined(S390X)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001961 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
1962 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
1963 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01001964 { uoff(start_code), "offsetof(struct user, start_code)" },
1965 /* S390[X] has no start_data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001966 { uoff(start_stack), "offsetof(struct user, start_stack)" },
1967 { uoff(signal), "offsetof(struct user, signal)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001968 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001969 { uoff(magic), "offsetof(struct user, magic)" },
1970 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01001971 { sizeof(struct user), "sizeof(struct user)" },
1972#elif defined(POWERPC)
1973 { sizeof(struct user), "sizeof(struct user)" },
1974#elif defined(I386) || defined(X86_64) || defined(X32)
1975 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
1976 { uoff(i387), "offsetof(struct user, i387)" },
1977 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
1978 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
1979 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
1980 { uoff(start_code), "offsetof(struct user, start_code)" },
1981 { uoff(start_stack), "offsetof(struct user, start_stack)" },
1982 { uoff(signal), "offsetof(struct user, signal)" },
1983 { uoff(reserved), "offsetof(struct user, reserved)" },
1984 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
1985 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
1986 { uoff(magic), "offsetof(struct user, magic)" },
1987 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001988 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01001989 { sizeof(struct user), "sizeof(struct user)" },
1990#elif defined(IA64)
1991 { sizeof(struct user), "sizeof(struct user)" },
1992#elif defined(ARM)
1993 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
1994 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
1995 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
1996 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
1997 { uoff(start_code), "offsetof(struct user, start_code)" },
1998 { uoff(start_stack), "offsetof(struct user, start_stack)" },
1999 { uoff(signal), "offsetof(struct user, signal)" },
2000 { uoff(reserved), "offsetof(struct user, reserved)" },
2001 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2002 { uoff(magic), "offsetof(struct user, magic)" },
2003 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2004 { sizeof(struct user), "sizeof(struct user)" },
2005#elif defined(AARCH64)
2006 /* nothing */
2007#elif defined(M68K)
2008 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2009 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2010 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2011 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2012 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2013 { uoff(start_code), "offsetof(struct user, start_code)" },
2014 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2015 { uoff(signal), "offsetof(struct user, signal)" },
2016 { uoff(reserved), "offsetof(struct user, reserved)" },
2017 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2018 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2019 { uoff(magic), "offsetof(struct user, magic)" },
2020 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2021 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002022#elif defined(MIPS) || defined(LINUX_MIPSN32)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002023 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2024 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2025 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2026 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002027 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002028 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2029 { uoff(signal), "offsetof(struct user, signal)" },
2030 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2031 { uoff(magic), "offsetof(struct user, magic)" },
2032 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2033 { sizeof(struct user), "sizeof(struct user)" },
2034#elif defined(ALPHA)
2035 { sizeof(struct user), "sizeof(struct user)" },
2036#elif defined(SPARC)
2037 { sizeof(struct user), "sizeof(struct user)" },
2038#elif defined(SPARC64)
2039 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2040 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2041 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2042 { uoff(signal), "offsetof(struct user, signal)" },
2043 { uoff(magic), "offsetof(struct user, magic)" },
2044 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2045 { sizeof(struct user), "sizeof(struct user)" },
2046#elif defined(HPPA)
2047 /* nothing */
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002048#elif defined(SH) || defined(SH64)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002049 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2050 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2051 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2052 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2053 { uoff(start_code), "offsetof(struct user, start_code)" },
2054 { uoff(start_data), "offsetof(struct user, start_data)" },
2055 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2056 { uoff(signal), "offsetof(struct user, signal)" },
2057 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2058 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2059 { uoff(magic), "offsetof(struct user, magic)" },
2060 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2061 { sizeof(struct user), "sizeof(struct user)" },
2062#elif defined(CRISV10) || defined(CRISV32)
2063 { sizeof(struct user), "sizeof(struct user)" },
2064#elif defined(TILE)
2065 /* nothing */
2066#elif defined(MICROBLAZE)
2067 { sizeof(struct user), "sizeof(struct user)" },
2068#elif defined(AVR32)
2069 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2070 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2071 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2072 { uoff(start_code), "offsetof(struct user, start_code)" },
2073 { uoff(start_data), "offsetof(struct user, start_data)" },
2074 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2075 { uoff(signal), "offsetof(struct user, signal)" },
2076 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2077 { uoff(magic), "offsetof(struct user, magic)" },
2078 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2079 { sizeof(struct user), "sizeof(struct user)" },
2080#elif defined(BFIN)
2081 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2082 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2083 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2084 { uoff(start_code), "offsetof(struct user, start_code)" },
2085 { uoff(signal), "offsetof(struct user, signal)" },
2086 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2087 { uoff(magic), "offsetof(struct user, magic)" },
2088 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002089 { sizeof(struct user), "sizeof(struct user)" },
Christian Svensson492f81f2013-02-14 13:26:27 +01002090#elif defined(OR1K)
2091 /* nothing */
James Hogan5f999a82013-02-22 14:44:10 +00002092#elif defined(METAG)
2093 /* nothing */
Chris Zankel8f636ed2013-03-25 10:22:07 -07002094#elif defined(XTENSA)
2095 /* nothing */
Vineet Gupta7daacbb2013-08-16 12:47:06 +05302096#elif defined(ARC)
2097 /* nothing */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002098#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00002099 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002100};
2101
2102int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002103sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002104{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002105 const struct xlat *x;
Dmitry V. Levin3ed5d022014-09-10 13:46:04 +00002106 unsigned long addr;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002107
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002108 if (entering(tcp)) {
Denys Vlasenkob7a6dae2012-03-20 16:48:35 +01002109 printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
Roland McGrathbf621d42003-01-14 09:46:21 +00002110 tprintf(", %lu, ", tcp->u_arg[1]);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002111
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002112 addr = tcp->u_arg[2];
2113 if (tcp->u_arg[0] == PTRACE_PEEKUSER
Denys Vlasenkobe994972013-02-13 16:10:10 +01002114 || tcp->u_arg[0] == PTRACE_POKEUSER
2115 ) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002116 for (x = struct_user_offsets; x->str; x++) {
2117 if (x->val >= addr)
2118 break;
2119 }
2120 if (!x->str)
2121 tprintf("%#lx, ", addr);
2122 else if (x->val > addr && x != struct_user_offsets) {
2123 x--;
2124 tprintf("%s + %ld, ", x->str, addr - x->val);
2125 }
2126 else
2127 tprintf("%s, ", x->str);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002128 } else
2129#ifdef PTRACE_GETREGSET
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00002130 if (tcp->u_arg[0] == PTRACE_GETREGSET
2131 || tcp->u_arg[0] == PTRACE_SETREGSET
2132 ) {
2133 printxval(nt_descriptor_types, tcp->u_arg[2], "NT_???");
2134 tprints(", ");
2135 } else
Denys Vlasenkobe994972013-02-13 16:10:10 +01002136#endif
2137 tprintf("%#lx, ", addr);
2138
2139
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002140 switch (tcp->u_arg[0]) {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002141#ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002142 case PTRACE_PEEKDATA:
2143 case PTRACE_PEEKTEXT:
2144 case PTRACE_PEEKUSER:
2145 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002146#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002147 case PTRACE_CONT:
2148 case PTRACE_SINGLESTEP:
2149 case PTRACE_SYSCALL:
2150 case PTRACE_DETACH:
2151 printsignal(tcp->u_arg[3]);
2152 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002153#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002154 case PTRACE_SETOPTIONS:
2155 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2156 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002157#endif
2158#ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002159 case PTRACE_SETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002160 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002161 break;
2162 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002163#endif
2164#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002165 case PTRACE_GETSIGINFO:
2166 /* Don't print anything, do it at syscall return. */
2167 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002168#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002169#ifdef PTRACE_GETREGSET
2170 case PTRACE_GETREGSET:
2171 break;
2172 case PTRACE_SETREGSET:
2173 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2174 break;
2175#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002176 default:
2177 tprintf("%#lx", tcp->u_arg[3]);
2178 break;
2179 }
2180 } else {
2181 switch (tcp->u_arg[0]) {
2182 case PTRACE_PEEKDATA:
2183 case PTRACE_PEEKTEXT:
2184 case PTRACE_PEEKUSER:
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002185#ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002186 return RVAL_HEX;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002187#else
Roland McGratheb285352003-01-14 09:59:00 +00002188 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002189 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002190#endif
2191#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002192 case PTRACE_GETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002193 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002194 break;
2195 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002196#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002197#ifdef PTRACE_GETREGSET
2198 case PTRACE_GETREGSET:
2199 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2200 break;
2201#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002202 }
2203 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002204 return 0;
2205}
2206
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002207#ifndef FUTEX_CMP_REQUEUE
2208# define FUTEX_CMP_REQUEUE 4
2209#endif
2210#ifndef FUTEX_WAKE_OP
2211# define FUTEX_WAKE_OP 5
2212#endif
2213#ifndef FUTEX_LOCK_PI
2214# define FUTEX_LOCK_PI 6
2215# define FUTEX_UNLOCK_PI 7
2216# define FUTEX_TRYLOCK_PI 8
2217#endif
2218#ifndef FUTEX_WAIT_BITSET
2219# define FUTEX_WAIT_BITSET 9
2220#endif
2221#ifndef FUTEX_WAKE_BITSET
2222# define FUTEX_WAKE_BITSET 10
2223#endif
2224#ifndef FUTEX_WAIT_REQUEUE_PI
2225# define FUTEX_WAIT_REQUEUE_PI 11
2226#endif
2227#ifndef FUTEX_CMP_REQUEUE_PI
2228# define FUTEX_CMP_REQUEUE_PI 12
2229#endif
2230#ifndef FUTEX_PRIVATE_FLAG
2231# define FUTEX_PRIVATE_FLAG 128
2232#endif
2233#ifndef FUTEX_CLOCK_REALTIME
2234# define FUTEX_CLOCK_REALTIME 256
2235#endif
Dmitry V. Levin9f56d872014-02-05 02:01:16 +00002236#ifndef FUTEX_WAIT_PRIVATE
2237# define FUTEX_WAIT_PRIVATE (FUTEX_WAIT | FUTEX_PRIVATE_FLAG)
2238#endif
2239#ifndef FUTEX_WAKE_PRIVATE
2240# define FUTEX_WAKE_PRIVATE (FUTEX_WAKE | FUTEX_PRIVATE_FLAG)
2241#endif
2242#ifndef FUTEX_REQUEUE_PRIVATE
2243# define FUTEX_REQUEUE_PRIVATE (FUTEX_REQUEUE | FUTEX_PRIVATE_FLAG)
2244#endif
2245#ifndef FUTEX_CMP_REQUEUE_PRIVATE
2246# define FUTEX_CMP_REQUEUE_PRIVATE (FUTEX_CMP_REQUEUE | FUTEX_PRIVATE_FLAG)
2247#endif
2248#ifndef FUTEX_WAKE_OP_PRIVATE
2249# define FUTEX_WAKE_OP_PRIVATE (FUTEX_WAKE_OP | FUTEX_PRIVATE_FLAG)
2250#endif
2251#ifndef FUTEX_LOCK_PI_PRIVATE
2252# define FUTEX_LOCK_PI_PRIVATE (FUTEX_LOCK_PI | FUTEX_PRIVATE_FLAG)
2253#endif
2254#ifndef FUTEX_UNLOCK_PI_PRIVATE
2255# define FUTEX_UNLOCK_PI_PRIVATE (FUTEX_UNLOCK_PI | FUTEX_PRIVATE_FLAG)
2256#endif
2257#ifndef FUTEX_TRYLOCK_PI_PRIVATE
2258# define FUTEX_TRYLOCK_PI_PRIVATE (FUTEX_TRYLOCK_PI | FUTEX_PRIVATE_FLAG)
2259#endif
2260#ifndef FUTEX_WAIT_BITSET_PRIVATE
2261# define FUTEX_WAIT_BITSET_PRIVATE (FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG)
2262#endif
2263#ifndef FUTEX_WAKE_BITSET_PRIVATE
2264# define FUTEX_WAKE_BITSET_PRIVATE (FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG)
2265#endif
2266#ifndef FUTEX_WAIT_REQUEUE_PI_PRIVATE
2267# define FUTEX_WAIT_REQUEUE_PI_PRIVATE (FUTEX_WAIT_REQUEUE_PI | FUTEX_PRIVATE_FLAG)
2268#endif
2269#ifndef FUTEX_CMP_REQUEUE_PI_PRIVATE
2270# define FUTEX_CMP_REQUEUE_PI_PRIVATE (FUTEX_CMP_REQUEUE_PI | FUTEX_PRIVATE_FLAG)
2271#endif
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +00002272#include "xlat/futexops.h"
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002273#ifndef FUTEX_OP_SET
2274# define FUTEX_OP_SET 0
2275# define FUTEX_OP_ADD 1
2276# define FUTEX_OP_OR 2
2277# define FUTEX_OP_ANDN 3
2278# define FUTEX_OP_XOR 4
2279# define FUTEX_OP_CMP_EQ 0
2280# define FUTEX_OP_CMP_NE 1
2281# define FUTEX_OP_CMP_LT 2
2282# define FUTEX_OP_CMP_LE 3
2283# define FUTEX_OP_CMP_GT 4
2284# define FUTEX_OP_CMP_GE 5
2285#endif
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +00002286#include "xlat/futexwakeops.h"
2287#include "xlat/futexwakecmps.h"
Roland McGrath5a223472002-12-15 23:58:26 +00002288
2289int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002290sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002291{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002292 if (entering(tcp)) {
2293 long int cmd = tcp->u_arg[1] & 127;
2294 tprintf("%p, ", (void *) tcp->u_arg[0]);
2295 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2296 tprintf(", %ld", tcp->u_arg[2]);
2297 if (cmd == FUTEX_WAKE_BITSET)
2298 tprintf(", %lx", tcp->u_arg[5]);
2299 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002300 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002301 printtv(tcp, tcp->u_arg[3]);
2302 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002303 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002304 printtv(tcp, tcp->u_arg[3]);
2305 tprintf(", %lx", tcp->u_arg[5]);
2306 } else if (cmd == FUTEX_REQUEUE)
2307 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002308 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002309 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2310 else if (cmd == FUTEX_WAKE_OP) {
2311 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2312 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002313 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002314 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2315 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2316 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002317 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002318 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2319 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002320 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002321 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002322 printtv(tcp, tcp->u_arg[3]);
2323 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002324 }
Roland McGrath51942a92007-07-05 18:59:11 +00002325 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002326 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002327}
2328
2329static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002330print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002331{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002332 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002333 unsigned long w, min_len;
2334
2335 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2336 min_len = len - max_strlen * sizeof(w);
2337 else
2338 min_len = 0;
2339 for (; len >= sizeof(w) && len > min_len;
2340 len -= sizeof(w), list += sizeof(w)) {
2341 if (umove(tcp, list, &w) < 0)
2342 break;
2343 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002344 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002345 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002346 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002347 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002348 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002349 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002350 if (len) {
2351 if (first)
2352 tprintf("%#lx", list);
2353 else
2354 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2355 "???" : "..."));
2356 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002357 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002358 }
Roland McGrath5a223472002-12-15 23:58:26 +00002359}
2360
2361int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002362sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002363{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002364 if (entering(tcp)) {
2365 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2366 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2367 }
2368 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002369}
2370
2371int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002372sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002373{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002374 if (entering(tcp)) {
2375 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2376 } else {
2377 if (tcp->u_rval == -1)
2378 tprintf("%#lx", tcp->u_arg[2]);
2379 else
2380 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2381 }
2382 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002383}
Roland McGrath279d3782004-03-01 20:27:37 +00002384
Dmitry V. Levin1b0bae22012-03-11 22:32:26 +00002385int
2386sys_get_robust_list(struct tcb *tcp)
2387{
2388 if (entering(tcp)) {
2389 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2390 } else {
2391 void *addr;
2392 size_t len;
2393
2394 if (syserror(tcp) ||
2395 !tcp->u_arg[1] ||
2396 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2397 tprintf("%#lx, ", tcp->u_arg[1]);
2398 } else {
2399 tprintf("[%p], ", addr);
2400 }
2401
2402 if (syserror(tcp) ||
2403 !tcp->u_arg[2] ||
2404 umove(tcp, tcp->u_arg[2], &len) < 0) {
2405 tprintf("%#lx", tcp->u_arg[2]);
2406 } else {
2407 tprintf("[%lu]", (unsigned long) len);
2408 }
2409 }
2410 return 0;
2411}
2412
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +00002413#include "xlat/schedulers.h"
Roland McGrath279d3782004-03-01 20:27:37 +00002414
2415int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002416sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002417{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002418 if (entering(tcp)) {
2419 tprintf("%d", (int) tcp->u_arg[0]);
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002420 } else if (!syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002421 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002422 if (tcp->auxstr != NULL)
2423 return RVAL_STR;
2424 }
2425 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002426}
2427
2428int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002429sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002430{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002431 if (entering(tcp)) {
2432 struct sched_param p;
2433 tprintf("%d, ", (int) tcp->u_arg[0]);
2434 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2435 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2436 tprintf(", %#lx", tcp->u_arg[2]);
2437 else
Dmitry V. Levine19a7122013-11-12 15:09:56 +00002438 tprintf(", { %d }", p.sched_priority);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002439 }
2440 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002441}
2442
2443int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002444sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002445{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002446 if (entering(tcp)) {
2447 tprintf("%d, ", (int) tcp->u_arg[0]);
2448 } else {
2449 struct sched_param p;
2450 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2451 tprintf("%#lx", tcp->u_arg[1]);
2452 else
Dmitry V. Levine19a7122013-11-12 15:09:56 +00002453 tprintf("{ %d }", p.sched_priority);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002454 }
2455 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002456}
2457
2458int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002459sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002460{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002461 if (entering(tcp)) {
2462 struct sched_param p;
2463 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2464 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2465 else
Dmitry V. Levine19a7122013-11-12 15:09:56 +00002466 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.sched_priority);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002467 }
2468 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002469}
2470
2471int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002472sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002473{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002474 if (entering(tcp)) {
2475 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2476 }
2477 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002478}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002479
Dmitry V. Levin1ff463d2012-03-11 23:00:11 +00002480int
2481sys_sched_rr_get_interval(struct tcb *tcp)
2482{
2483 if (entering(tcp)) {
2484 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2485 } else {
2486 if (syserror(tcp))
2487 tprintf("%#lx", tcp->u_arg[1]);
2488 else
2489 print_timespec(tcp, tcp->u_arg[1]);
2490 }
2491 return 0;
2492}
2493
H.J. Lu35be5812012-04-16 13:00:01 +02002494#if defined X86_64 || defined X32
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002495# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002496
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +00002497#include "xlat/archvals.h"
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002498
2499int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002500sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002501{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002502 if (entering(tcp)) {
2503 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2504 if (tcp->u_arg[0] == ARCH_SET_GS
2505 || tcp->u_arg[0] == ARCH_SET_FS
2506 ) {
2507 tprintf(", %#lx", tcp->u_arg[1]);
2508 }
2509 } else {
2510 if (tcp->u_arg[0] == ARCH_GET_GS
2511 || tcp->u_arg[0] == ARCH_GET_FS
2512 ) {
2513 long int v;
2514 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2515 tprintf(", [%#lx]", v);
2516 else
2517 tprintf(", %#lx", tcp->u_arg[1]);
2518 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002519 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002520 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002521}
H.J. Lu35be5812012-04-16 13:00:01 +02002522#endif /* X86_64 || X32 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002523
Roland McGrathdb8319f2007-08-02 01:37:55 +00002524int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002525sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002526{
2527 if (exiting(tcp)) {
2528 unsigned u;
2529 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002530 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002531 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2532 tprintf("%#lx, ", tcp->u_arg[0]);
2533 else
2534 tprintf("[%u], ", u);
2535 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002536 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002537 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2538 tprintf("%#lx, ", tcp->u_arg[1]);
2539 else
2540 tprintf("[%u], ", u);
2541 tprintf("%#lx", tcp->u_arg[2]);
2542 }
2543 return 0;
2544}
2545
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002546int
2547sys_process_vm_readv(struct tcb *tcp)
2548{
2549 if (entering(tcp)) {
2550 /* arg 1: pid */
2551 tprintf("%ld, ", tcp->u_arg[0]);
2552 } else {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002553 /* arg 2: local iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002554 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002555 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002556 } else {
2557 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2558 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002559 /* arg 3: local iovcnt */
2560 tprintf(", %lu, ", tcp->u_arg[2]);
2561 /* arg 4: remote iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002562 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002563 tprintf("%#lx", tcp->u_arg[3]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002564 } else {
2565 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2566 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002567 /* arg 5: remote iovcnt */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002568 /* arg 6: flags */
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002569 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002570 }
2571 return 0;
2572}
Dmitry V. Levin03952102012-03-10 14:14:49 +00002573
2574int
2575sys_process_vm_writev(struct tcb *tcp)
2576{
2577 if (entering(tcp)) {
2578 /* arg 1: pid */
2579 tprintf("%ld, ", tcp->u_arg[0]);
2580 /* arg 2: local iov */
2581 if (syserror(tcp))
2582 tprintf("%#lx", tcp->u_arg[1]);
2583 else
2584 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2585 /* arg 3: local iovcnt */
2586 tprintf(", %lu, ", tcp->u_arg[2]);
2587 /* arg 4: remote iov */
2588 if (syserror(tcp))
2589 tprintf("%#lx", tcp->u_arg[3]);
2590 else
2591 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2592 /* arg 5: remote iovcnt */
2593 /* arg 6: flags */
2594 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
2595 }
2596 return 0;
2597}