blob: 36f10ba6f21b9bf47823c0b59ffcc4d59b7e9c04 [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>
Denys Vlasenko84703742012-02-25 02:38:52 +010050# ifndef PTRACE_PEEKUSR
51# define PTRACE_PEEKUSR PTRACE_PEEKUSER
52# endif
53# ifndef PTRACE_POKEUSR
54# define PTRACE_POKEUSR PTRACE_POKEUSER
55# endif
Wichert Akkerman15dea971999-10-06 13:06:34 +000056#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000057
Roland McGrath5bd7cf82003-01-24 04:31:18 +000058#ifdef HAVE_LINUX_PTRACE_H
Denys Vlasenko84703742012-02-25 02:38:52 +010059# undef PTRACE_SYSCALL
Roland McGrathfb1bc072004-03-01 21:29:24 +000060# ifdef HAVE_STRUCT_IA64_FPREG
61# define ia64_fpreg XXX_ia64_fpreg
62# endif
63# ifdef HAVE_STRUCT_PT_ALL_USER_REGS
64# define pt_all_user_regs XXX_pt_all_user_regs
65# endif
Denys Vlasenko84703742012-02-25 02:38:52 +010066# include <linux/ptrace.h>
Roland McGrathfb1bc072004-03-01 21:29:24 +000067# undef ia64_fpreg
68# undef pt_all_user_regs
Roland McGrath5bd7cf82003-01-24 04:31:18 +000069#endif
70
Denys Vlasenko84703742012-02-25 02:38:52 +010071#if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +000072# define r_pc r_tpc
73# undef PTRACE_GETREGS
74# define PTRACE_GETREGS PTRACE_GETREGS64
75# undef PTRACE_SETREGS
76# define PTRACE_SETREGS PTRACE_SETREGS64
Denys Vlasenko84703742012-02-25 02:38:52 +010077#endif
Roland McGrath6d1a65c2004-07-12 07:44:08 +000078
Roland McGrath5a223472002-12-15 23:58:26 +000079#ifdef HAVE_LINUX_FUTEX_H
Dmitry V. Levine5e60852009-12-31 22:50:49 +000080# include <linux/futex.h>
Roland McGrath5a223472002-12-15 23:58:26 +000081#endif
Denys Vlasenko84703742012-02-25 02:38:52 +010082#ifndef FUTEX_WAIT
83# define FUTEX_WAIT 0
84#endif
85#ifndef FUTEX_WAKE
86# define FUTEX_WAKE 1
87#endif
88#ifndef FUTEX_FD
89# define FUTEX_FD 2
90#endif
91#ifndef FUTEX_REQUEUE
92# define FUTEX_REQUEUE 3
93#endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000094
Roland McGrath279d3782004-03-01 20:27:37 +000095#include <sched.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000096#include <asm/posix_types.h>
97#undef GETGROUPS_T
98#define GETGROUPS_T __kernel_gid_t
Roland McGrath83bd47a2003-11-13 22:32:26 +000099#undef GETGROUPS32_T
100#define GETGROUPS32_T __kernel_gid32_t
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000101
Denys Vlasenko84703742012-02-25 02:38:52 +0100102#if defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000103# include <asm/ptrace_offsets.h>
104# include <asm/rse.h>
105#endif
106
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000107#ifdef HAVE_PRCTL
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000108# include <sys/prctl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000109
Roland McGrathd9f816f2004-09-04 03:39:20 +0000110static const struct xlat prctl_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000111#ifdef PR_MAXPROCS
112 { PR_MAXPROCS, "PR_MAXPROCS" },
113#endif
114#ifdef PR_ISBLOCKED
115 { PR_ISBLOCKED, "PR_ISBLOCKED" },
116#endif
117#ifdef PR_SETSTACKSIZE
118 { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" },
119#endif
120#ifdef PR_GETSTACKSIZE
121 { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" },
122#endif
123#ifdef PR_MAXPPROCS
124 { PR_MAXPPROCS, "PR_MAXPPROCS" },
125#endif
126#ifdef PR_UNBLKONEXEC
127 { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" },
128#endif
129#ifdef PR_ATOMICSIM
130 { PR_ATOMICSIM, "PR_ATOMICSIM" },
131#endif
132#ifdef PR_SETEXITSIG
133 { PR_SETEXITSIG, "PR_SETEXITSIG" },
134#endif
135#ifdef PR_RESIDENT
136 { PR_RESIDENT, "PR_RESIDENT" },
137#endif
138#ifdef PR_ATTACHADDR
139 { PR_ATTACHADDR, "PR_ATTACHADDR" },
140#endif
141#ifdef PR_DETACHADDR
142 { PR_DETACHADDR, "PR_DETACHADDR" },
143#endif
144#ifdef PR_TERMCHILD
145 { PR_TERMCHILD, "PR_TERMCHILD" },
146#endif
147#ifdef PR_GETSHMASK
148 { PR_GETSHMASK, "PR_GETSHMASK" },
149#endif
150#ifdef PR_GETNSHARE
151 { PR_GETNSHARE, "PR_GETNSHARE" },
152#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +0000153#ifdef PR_COREPID
154 { PR_COREPID, "PR_COREPID" },
155#endif
156#ifdef PR_ATTACHADDRPERM
157 { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" },
158#endif
159#ifdef PR_PTHREADEXIT
160 { PR_PTHREADEXIT, "PR_PTHREADEXIT" },
161#endif
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000162
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000163#ifdef PR_SET_PDEATHSIG
164 { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
165#endif
166#ifdef PR_GET_PDEATHSIG
167 { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
168#endif
Dmitry V. Levinf02cf212008-09-03 00:54:40 +0000169#ifdef PR_GET_DUMPABLE
170 { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" },
171#endif
172#ifdef PR_SET_DUMPABLE
173 { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" },
174#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000175#ifdef PR_GET_UNALIGN
176 { PR_GET_UNALIGN, "PR_GET_UNALIGN" },
177#endif
178#ifdef PR_SET_UNALIGN
179 { PR_SET_UNALIGN, "PR_SET_UNALIGN" },
180#endif
181#ifdef PR_GET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000182 { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000183#endif
184#ifdef PR_SET_KEEPCAPS
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000185 { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" },
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000186#endif
Roland McGrathe5039fb2007-11-03 23:58:07 +0000187#ifdef PR_GET_FPEMU
188 { PR_GET_FPEMU, "PR_GET_FPEMU" },
189#endif
190#ifdef PR_SET_FPEMU
191 { PR_SET_FPEMU, "PR_SET_FPEMU" },
192#endif
193#ifdef PR_GET_FPEXC
194 { PR_GET_FPEXC, "PR_GET_FPEXC" },
195#endif
196#ifdef PR_SET_FPEXC
197 { PR_SET_FPEXC, "PR_SET_FPEXC" },
198#endif
199#ifdef PR_GET_TIMING
200 { PR_GET_TIMING, "PR_GET_TIMING" },
201#endif
202#ifdef PR_SET_TIMING
203 { PR_SET_TIMING, "PR_SET_TIMING" },
204#endif
205#ifdef PR_SET_NAME
206 { PR_SET_NAME, "PR_SET_NAME" },
207#endif
208#ifdef PR_GET_NAME
209 { PR_GET_NAME, "PR_GET_NAME" },
210#endif
211#ifdef PR_GET_ENDIAN
212 { PR_GET_ENDIAN, "PR_GET_ENDIAN" },
213#endif
214#ifdef PR_SET_ENDIAN
215 { PR_SET_ENDIAN, "PR_SET_ENDIAN" },
216#endif
217#ifdef PR_GET_SECCOMP
218 { PR_GET_SECCOMP, "PR_GET_SECCOMP" },
219#endif
220#ifdef PR_SET_SECCOMP
221 { PR_SET_SECCOMP, "PR_SET_SECCOMP" },
222#endif
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000223#ifdef PR_CAPBSET_READ
224 { PR_CAPBSET_READ, "PR_CAPBSET_READ" },
225#endif
226#ifdef PR_CAPBSET_DROP
227 { PR_CAPBSET_DROP, "PR_CAPBSET_DROP" },
228#endif
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000229#ifdef PR_GET_TSC
230 { PR_GET_TSC, "PR_GET_TSC" },
231#endif
232#ifdef PR_SET_TSC
233 { PR_SET_TSC, "PR_SET_TSC" },
234#endif
235#ifdef PR_GET_SECUREBITS
236 { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" },
237#endif
238#ifdef PR_SET_SECUREBITS
239 { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" },
240#endif
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000241#ifdef PR_SET_TIMERSLACK
242 { PR_SET_TIMERSLACK, "PR_SET_TIMERSLACK" },
243#endif
244#ifdef PR_GET_TIMERSLACK
245 { PR_GET_TIMERSLACK, "PR_GET_TIMERSLACK" },
246#endif
247#ifdef PR_TASK_PERF_EVENTS_DISABLE
248 { PR_TASK_PERF_EVENTS_DISABLE, "PR_TASK_PERF_EVENTS_DISABLE" },
249#endif
250#ifdef PR_TASK_PERF_EVENTS_ENABLE
251 { PR_TASK_PERF_EVENTS_ENABLE, "PR_TASK_PERF_EVENTS_ENABLE" },
252#endif
253#ifdef PR_MCE_KILL
254 { PR_MCE_KILL, "PR_MCE_KILL" },
255#endif
256#ifdef PR_MCE_KILL_GET
257 { PR_MCE_KILL_GET, "PR_MCE_KILL_GET" },
258#endif
259#ifdef PR_SET_MM
260 { PR_SET_MM, "PR_SET_MM" },
261#endif
262#ifdef PR_SET_CHILD_SUBREAPER
263 { PR_SET_CHILD_SUBREAPER, "PR_SET_CHILD_SUBREAPER" },
264#endif
265#ifdef PR_GET_CHILD_SUBREAPER
266 { PR_GET_CHILD_SUBREAPER, "PR_GET_CHILD_SUBREAPER" },
267#endif
268#ifdef PR_SET_NO_NEW_PRIVS
269 { PR_SET_NO_NEW_PRIVS, "PR_SET_NO_NEW_PRIVS" },
270#endif
271#ifdef PR_GET_NO_NEW_PRIVS
272 { PR_GET_NO_NEW_PRIVS, "PR_GET_NO_NEW_PRIVS" },
273#endif
274#ifdef PR_GET_TID_ADDRESS
275 { PR_GET_TID_ADDRESS, "PR_GET_TID_ADDRESS" },
276#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000277 { 0, NULL },
278};
279
Roland McGratha4d48532005-06-08 20:45:28 +0000280static const char *
Denys Vlasenko12014262011-05-30 14:00:14 +0200281unalignctl_string(unsigned int ctl)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000282{
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100283 static char buf[sizeof(int)*2 + 2];
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000284
285 switch (ctl) {
286#ifdef PR_UNALIGN_NOPRINT
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100287 case PR_UNALIGN_NOPRINT:
288 return "NOPRINT";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000289#endif
290#ifdef PR_UNALIGN_SIGBUS
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100291 case PR_UNALIGN_SIGBUS:
292 return "SIGBUS";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000293#endif
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100294 default:
295 break;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000296 }
297 sprintf(buf, "%x", ctl);
298 return buf;
299}
300
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000301int
Denys Vlasenko12014262011-05-30 14:00:14 +0200302sys_prctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000303{
304 int i;
305
306 if (entering(tcp)) {
307 printxval(prctl_options, tcp->u_arg[0], "PR_???");
308 switch (tcp->u_arg[0]) {
309#ifdef PR_GETNSHARE
310 case PR_GETNSHARE:
311 break;
312#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000313#ifdef PR_SET_PDEATHSIG
314 case PR_SET_PDEATHSIG:
315 tprintf(", %lu", tcp->u_arg[1]);
316 break;
317#endif
318#ifdef PR_GET_PDEATHSIG
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000319 case PR_GET_PDEATHSIG:
320 break;
321#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000322#ifdef PR_SET_DUMPABLE
323 case PR_SET_DUMPABLE:
324 tprintf(", %lu", tcp->u_arg[1]);
325 break;
326#endif
327#ifdef PR_GET_DUMPABLE
328 case PR_GET_DUMPABLE:
329 break;
330#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000331#ifdef PR_SET_UNALIGN
332 case PR_SET_UNALIGN:
333 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
334 break;
335#endif
336#ifdef PR_GET_UNALIGN
337 case PR_GET_UNALIGN:
338 tprintf(", %#lx", tcp->u_arg[1]);
339 break;
340#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000341#ifdef PR_SET_KEEPCAPS
342 case PR_SET_KEEPCAPS:
343 tprintf(", %lu", tcp->u_arg[1]);
344 break;
345#endif
346#ifdef PR_GET_KEEPCAPS
347 case PR_GET_KEEPCAPS:
348 break;
349#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000350 default:
Denys Vlasenko74ec14f2013-02-21 16:13:47 +0100351 for (i = 1; i < tcp->s_ent->nargs; i++)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000352 tprintf(", %#lx", tcp->u_arg[i]);
353 break;
354 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000355 } else {
356 switch (tcp->u_arg[0]) {
357#ifdef PR_GET_PDEATHSIG
358 case PR_GET_PDEATHSIG:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000359 if (umove(tcp, tcp->u_arg[1], &i) < 0)
360 tprintf(", %#lx", tcp->u_arg[1]);
361 else
362 tprintf(", {%u}", i);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000363 break;
364#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000365#ifdef PR_GET_DUMPABLE
366 case PR_GET_DUMPABLE:
367 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000368#endif
369#ifdef PR_GET_UNALIGN
370 case PR_GET_UNALIGN:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000371 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
372 break;
373 tcp->auxstr = unalignctl_string(i);
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000374 return RVAL_STR;
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000375#endif
376#ifdef PR_GET_KEEPCAPS
377 case PR_GET_KEEPCAPS:
378 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000379#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000380 default:
381 break;
382 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000383 }
384 return 0;
385}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000386#endif /* HAVE_PRCTL */
387
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000388int
Denys Vlasenko12014262011-05-30 14:00:14 +0200389sys_sethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000390{
391 if (entering(tcp)) {
392 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
393 tprintf(", %lu", tcp->u_arg[1]);
394 }
395 return 0;
396}
397
Denys Vlasenko84703742012-02-25 02:38:52 +0100398#if defined(ALPHA)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000399int
Denys Vlasenko12014262011-05-30 14:00:14 +0200400sys_gethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000401{
402 if (exiting(tcp)) {
403 if (syserror(tcp))
404 tprintf("%#lx", tcp->u_arg[0]);
405 else
406 printpath(tcp, tcp->u_arg[0]);
407 tprintf(", %lu", tcp->u_arg[1]);
408 }
409 return 0;
410}
Denys Vlasenko84703742012-02-25 02:38:52 +0100411#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000412
413int
Denys Vlasenko12014262011-05-30 14:00:14 +0200414sys_setdomainname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000415{
416 if (entering(tcp)) {
417 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
418 tprintf(", %lu", tcp->u_arg[1]);
419 }
420 return 0;
421}
422
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000423int
Denys Vlasenko12014262011-05-30 14:00:14 +0200424sys_exit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000425{
426 if (exiting(tcp)) {
427 fprintf(stderr, "_exit returned!\n");
428 return -1;
429 }
430 /* special case: we stop tracing this process, finish line now */
431 tprintf("%ld) ", tcp->u_arg[0]);
Denys Vlasenko102ec492011-08-25 01:27:59 +0200432 tabto();
Denys Vlasenko000b6012012-01-28 01:25:03 +0100433 tprints("= ?\n");
Denys Vlasenko7de265d2012-03-13 11:44:31 +0100434 line_ended();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000435 return 0;
436}
437
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000438/* defines copied from linux/sched.h since we can't include that
439 * ourselves (it conflicts with *lots* of libc includes)
440 */
441#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
442#define CLONE_VM 0x00000100 /* set if VM shared between processes */
443#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
444#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
445#define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
Roland McGrath909875b2002-12-22 03:34:36 +0000446#define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000447#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
448#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
449#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
Roland McGrath909875b2002-12-22 03:34:36 +0000450#define CLONE_THREAD 0x00010000 /* Same thread group? */
451#define CLONE_NEWNS 0x00020000 /* New namespace group? */
452#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
453#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
454#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
455#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
Roland McGrath909875b2002-12-22 03:34:36 +0000456#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
457#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000458#define CLONE_STOPPED 0x02000000 /* Start in stopped state */
459#define CLONE_NEWUTS 0x04000000 /* New utsname group? */
460#define CLONE_NEWIPC 0x08000000 /* New ipcs */
461#define CLONE_NEWUSER 0x10000000 /* New user namespace */
462#define CLONE_NEWPID 0x20000000 /* New pid namespace */
463#define CLONE_NEWNET 0x40000000 /* New network namespace */
464#define CLONE_IO 0x80000000 /* Clone io context */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000465
Roland McGrathd9f816f2004-09-04 03:39:20 +0000466static const struct xlat clone_flags[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100467 { CLONE_VM, "CLONE_VM" },
468 { CLONE_FS, "CLONE_FS" },
469 { CLONE_FILES, "CLONE_FILES" },
470 { CLONE_SIGHAND, "CLONE_SIGHAND" },
471 { CLONE_IDLETASK, "CLONE_IDLETASK" },
472 { CLONE_PTRACE, "CLONE_PTRACE" },
473 { CLONE_VFORK, "CLONE_VFORK" },
474 { CLONE_PARENT, "CLONE_PARENT" },
475 { CLONE_THREAD, "CLONE_THREAD" },
476 { CLONE_NEWNS, "CLONE_NEWNS" },
477 { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
478 { CLONE_SETTLS, "CLONE_SETTLS" },
479 { CLONE_PARENT_SETTID, "CLONE_PARENT_SETTID" },
480 { CLONE_CHILD_CLEARTID, "CLONE_CHILD_CLEARTID" },
481 { CLONE_UNTRACED, "CLONE_UNTRACED" },
482 { CLONE_CHILD_SETTID, "CLONE_CHILD_SETTID" },
483 { CLONE_STOPPED, "CLONE_STOPPED" },
484 { CLONE_NEWUTS, "CLONE_NEWUTS" },
485 { CLONE_NEWIPC, "CLONE_NEWIPC" },
486 { CLONE_NEWUSER, "CLONE_NEWUSER" },
487 { CLONE_NEWPID, "CLONE_NEWPID" },
488 { CLONE_NEWNET, "CLONE_NEWNET" },
489 { CLONE_IO, "CLONE_IO" },
490 { 0, NULL },
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000491};
492
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100493#ifdef I386
494# include <asm/ldt.h>
495# ifdef HAVE_STRUCT_USER_DESC
496# define modify_ldt_ldt_s user_desc
497# endif
Roland McGrath909875b2002-12-22 03:34:36 +0000498extern void print_ldt_entry();
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100499#endif
Roland McGrath909875b2002-12-22 03:34:36 +0000500
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100501#if defined IA64
502# define ARG_FLAGS 0
503# define ARG_STACK 1
504# define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
505# define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
506# define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
507# define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
508#elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
509# define ARG_STACK 0
510# define ARG_FLAGS 1
511# define ARG_PTID 2
512# define ARG_CTID 3
513# define ARG_TLS 4
Christian Svensson492f81f2013-02-14 13:26:27 +0100514#elif defined X86_64 || defined X32 || defined ALPHA || defined TILE \
515 || defined OR1K
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100516# define ARG_FLAGS 0
517# define ARG_STACK 1
518# define ARG_PTID 2
519# define ARG_CTID 3
520# define ARG_TLS 4
521#else
522# define ARG_FLAGS 0
523# define ARG_STACK 1
524# define ARG_PTID 2
525# define ARG_TLS 3
526# define ARG_CTID 4
527#endif
Roland McGrath9677b3a2003-03-12 09:54:36 +0000528
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000529int
Denys Vlasenko12014262011-05-30 14:00:14 +0200530sys_clone(struct tcb *tcp)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000531{
532 if (exiting(tcp)) {
Wang Chaocbdd1902010-09-02 15:08:59 +0800533 const char *sep = "|";
Roland McGrath9677b3a2003-03-12 09:54:36 +0000534 unsigned long flags = tcp->u_arg[ARG_FLAGS];
535 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100536#ifdef ARG_STACKSIZE
Roland McGrath9677b3a2003-03-12 09:54:36 +0000537 if (ARG_STACKSIZE != -1)
538 tprintf("stack_size=%#lx, ",
539 tcp->u_arg[ARG_STACKSIZE]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100540#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200541 tprints("flags=");
Wang Chaocbdd1902010-09-02 15:08:59 +0800542 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
543 sep = "";
Roland McGrath984154d2003-05-23 01:08:42 +0000544 if ((flags & CSIGNAL) != 0)
Wang Chaocbdd1902010-09-02 15:08:59 +0800545 tprintf("%s%s", sep, signame(flags & CSIGNAL));
Roland McGrathb4968be2003-01-20 09:04:33 +0000546 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
Roland McGrath9677b3a2003-03-12 09:54:36 +0000547 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
Roland McGrath909875b2002-12-22 03:34:36 +0000548 return 0;
Roland McGrath6f67a982003-03-21 07:33:15 +0000549 if (flags & CLONE_PARENT_SETTID)
550 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000551 if (flags & CLONE_SETTLS) {
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100552#ifdef I386
Roland McGrath909875b2002-12-22 03:34:36 +0000553 struct modify_ldt_ldt_s copy;
Roland McGrath9677b3a2003-03-12 09:54:36 +0000554 if (umove(tcp, tcp->u_arg[ARG_TLS], &copy) != -1) {
Roland McGrath909875b2002-12-22 03:34:36 +0000555 tprintf(", {entry_number:%d, ",
556 copy.entry_number);
557 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200558 tprints("...}");
Roland McGrath909875b2002-12-22 03:34:36 +0000559 else
560 print_ldt_entry(&copy);
561 }
562 else
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100563#endif
Roland McGrath43f2c842003-03-12 09:58:14 +0000564 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
Roland McGrath909875b2002-12-22 03:34:36 +0000565 }
Roland McGrath9677b3a2003-03-12 09:54:36 +0000566 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
567 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000568 }
569 return 0;
570}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000571
572int
573sys_unshare(struct tcb *tcp)
574{
575 if (entering(tcp))
576 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
577 return 0;
578}
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000579
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000580int
Denys Vlasenko081533c2012-03-17 02:17:51 +0100581sys_fork(struct tcb *tcp)
582{
583 if (exiting(tcp))
584 return RVAL_UDECIMAL;
585 return 0;
586}
587
588int
Denys Vlasenko12014262011-05-30 14:00:14 +0200589sys_vfork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000590{
591 if (exiting(tcp))
592 return RVAL_UDECIMAL;
593 return 0;
594}
595
Dmitry V. Levin50a218d2011-01-18 17:36:20 +0000596int sys_getuid(struct tcb *tcp)
597{
598 if (exiting(tcp))
599 tcp->u_rval = (uid_t) tcp->u_rval;
600 return RVAL_UDECIMAL;
601}
602
603int sys_setfsuid(struct tcb *tcp)
604{
605 if (entering(tcp))
606 tprintf("%u", (uid_t) tcp->u_arg[0]);
607 else
608 tcp->u_rval = (uid_t) tcp->u_rval;
609 return RVAL_UDECIMAL;
610}
611
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000612int
Denys Vlasenko12014262011-05-30 14:00:14 +0200613sys_setuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000614{
615 if (entering(tcp)) {
616 tprintf("%u", (uid_t) tcp->u_arg[0]);
617 }
618 return 0;
619}
620
621int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000622sys_getresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000623{
624 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000625 __kernel_uid_t uid;
626 if (syserror(tcp))
627 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
628 tcp->u_arg[1], tcp->u_arg[2]);
629 else {
630 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
631 tprintf("%#lx, ", tcp->u_arg[0]);
632 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000633 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000634 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
635 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000636 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000637 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000638 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
639 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000640 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000641 tprintf("[%lu]", (unsigned long) uid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000642 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000643 }
644 return 0;
645}
646
647int
Denys Vlasenko12014262011-05-30 14:00:14 +0200648sys_setreuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000649{
650 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000651 printuid("", tcp->u_arg[0]);
652 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000653 }
654 return 0;
655}
656
657int
Denys Vlasenko12014262011-05-30 14:00:14 +0200658sys_setresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000659{
660 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000661 printuid("", tcp->u_arg[0]);
662 printuid(", ", tcp->u_arg[1]);
663 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000664 }
665 return 0;
666}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000667
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000668int
Denys Vlasenko12014262011-05-30 14:00:14 +0200669sys_setgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000670{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000671 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000672 unsigned long len, size, start, cur, end, abbrev_end;
673 GETGROUPS_T gid;
674 int failed = 0;
675
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000676 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000677 tprintf("%lu, ", len);
678 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200679 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000680 return 0;
681 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000682 start = tcp->u_arg[1];
683 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200684 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000685 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000686 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000687 size = len * sizeof(gid);
688 end = start + size;
689 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
690 tprintf("%#lx", start);
691 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000692 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000693 if (abbrev(tcp)) {
694 abbrev_end = start + max_strlen * sizeof(gid);
695 if (abbrev_end < start)
696 abbrev_end = end;
697 } else {
698 abbrev_end = end;
699 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200700 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000701 for (cur = start; cur < end; cur += sizeof(gid)) {
702 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200703 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000704 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200705 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000706 break;
707 }
708 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200709 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000710 failed = 1;
711 break;
712 }
713 tprintf("%lu", (unsigned long) gid);
714 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200715 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000716 if (failed)
717 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000718 }
719 return 0;
720}
721
722int
Denys Vlasenko12014262011-05-30 14:00:14 +0200723sys_getgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000724{
Roland McGrathaa524c82005-06-01 19:22:06 +0000725 unsigned long len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000726
727 if (entering(tcp)) {
728 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000729 tprintf("%lu, ", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000730 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000731 unsigned long size, start, cur, end, abbrev_end;
732 GETGROUPS_T gid;
733 int failed = 0;
734
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000735 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000736 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200737 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000738 return 0;
739 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000740 start = tcp->u_arg[1];
741 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200742 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000743 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000744 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000745 if (tcp->u_arg[0] == 0) {
746 tprintf("%#lx", start);
747 return 0;
748 }
749 size = len * sizeof(gid);
750 end = start + size;
751 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
752 size / sizeof(gid) != len || end < start) {
753 tprintf("%#lx", start);
754 return 0;
755 }
756 if (abbrev(tcp)) {
757 abbrev_end = start + max_strlen * sizeof(gid);
758 if (abbrev_end < start)
759 abbrev_end = end;
760 } else {
761 abbrev_end = end;
762 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200763 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000764 for (cur = start; cur < end; cur += sizeof(gid)) {
765 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200766 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000767 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200768 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000769 break;
770 }
771 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200772 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000773 failed = 1;
774 break;
775 }
776 tprintf("%lu", (unsigned long) gid);
777 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200778 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000779 if (failed)
780 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000781 }
782 return 0;
783}
784
Roland McGrath83bd47a2003-11-13 22:32:26 +0000785int
Denys Vlasenko12014262011-05-30 14:00:14 +0200786sys_setgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000787{
Roland McGrath83bd47a2003-11-13 22:32:26 +0000788 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000789 unsigned long len, size, start, cur, end, abbrev_end;
790 GETGROUPS32_T gid;
791 int failed = 0;
792
Roland McGrath83bd47a2003-11-13 22:32:26 +0000793 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000794 tprintf("%lu, ", len);
795 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200796 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000797 return 0;
798 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000799 start = tcp->u_arg[1];
800 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200801 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000802 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000803 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000804 size = len * sizeof(gid);
805 end = start + size;
806 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
807 tprintf("%#lx", start);
808 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000809 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000810 if (abbrev(tcp)) {
811 abbrev_end = start + max_strlen * sizeof(gid);
812 if (abbrev_end < start)
813 abbrev_end = end;
814 } else {
815 abbrev_end = end;
816 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200817 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000818 for (cur = start; cur < end; cur += sizeof(gid)) {
819 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200820 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000821 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200822 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000823 break;
824 }
825 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200826 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000827 failed = 1;
828 break;
829 }
830 tprintf("%lu", (unsigned long) gid);
831 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200832 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000833 if (failed)
834 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000835 }
836 return 0;
837}
838
839int
Denys Vlasenko12014262011-05-30 14:00:14 +0200840sys_getgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000841{
Roland McGrathaa524c82005-06-01 19:22:06 +0000842 unsigned long len;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000843
844 if (entering(tcp)) {
845 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000846 tprintf("%lu, ", len);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000847 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000848 unsigned long size, start, cur, end, abbrev_end;
849 GETGROUPS32_T gid;
850 int failed = 0;
851
Roland McGrath83bd47a2003-11-13 22:32:26 +0000852 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000853 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200854 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000855 return 0;
856 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000857 start = tcp->u_arg[1];
858 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200859 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000860 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000861 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000862 size = len * sizeof(gid);
863 end = start + size;
864 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
865 size / sizeof(gid) != len || end < start) {
866 tprintf("%#lx", start);
867 return 0;
868 }
869 if (abbrev(tcp)) {
870 abbrev_end = start + max_strlen * sizeof(gid);
871 if (abbrev_end < start)
872 abbrev_end = end;
873 } else {
874 abbrev_end = end;
875 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200876 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000877 for (cur = start; cur < end; cur += sizeof(gid)) {
878 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200879 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000880 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200881 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000882 break;
883 }
884 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200885 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000886 failed = 1;
887 break;
888 }
889 tprintf("%lu", (unsigned long) gid);
890 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200891 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000892 if (failed)
893 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000894 }
895 return 0;
896}
Roland McGrath83bd47a2003-11-13 22:32:26 +0000897
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000898static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000899printargv(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000900{
Roland McGrath85a3bc42007-08-02 02:13:05 +0000901 union {
Andreas Schwab99c85692009-08-28 19:36:20 +0200902 unsigned int p32;
903 unsigned long p64;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000904 char data[sizeof(long)];
905 } cp;
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000906 const char *sep;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000907 int n = 0;
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100908 unsigned wordsize = current_wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000909
Roland McGrath85a3bc42007-08-02 02:13:05 +0000910 cp.p64 = 1;
911 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100912 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000913 tprintf("%#lx", addr);
914 return;
915 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100916 if (wordsize == 4)
Roland McGrath85a3bc42007-08-02 02:13:05 +0000917 cp.p64 = cp.p32;
918 if (cp.p64 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000919 break;
Denys Vlasenko5940e652011-09-01 09:55:05 +0200920 tprints(sep);
Roland McGrath85a3bc42007-08-02 02:13:05 +0000921 printstr(tcp, cp.p64, -1);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100922 addr += wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000923 }
Roland McGrath85a3bc42007-08-02 02:13:05 +0000924 if (cp.p64)
925 tprintf("%s...", sep);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000926}
927
928static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000929printargc(const char *fmt, struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000930{
931 int count;
932 char *cp;
933
934 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
935 addr += sizeof(char *);
936 }
937 tprintf(fmt, count, count == 1 ? "" : "s");
938}
939
Denys Vlasenko84703742012-02-25 02:38:52 +0100940#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000941int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000942sys_execv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000943{
944 if (entering(tcp)) {
945 printpath(tcp, tcp->u_arg[0]);
946 if (!verbose(tcp))
947 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000948 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200949 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000950 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200951 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000952 }
953 }
954 return 0;
955}
Denys Vlasenko84703742012-02-25 02:38:52 +0100956#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000957
958int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000959sys_execve(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000960{
961 if (entering(tcp)) {
962 printpath(tcp, tcp->u_arg[0]);
963 if (!verbose(tcp))
964 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000965 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200966 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000967 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200968 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000969 }
970 if (!verbose(tcp))
971 tprintf(", %#lx", tcp->u_arg[2]);
972 else if (abbrev(tcp))
973 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
974 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200975 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000976 printargv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200977 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000978 }
979 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000980 return 0;
981}
982
Roland McGrath7ec1d352002-12-17 04:50:44 +0000983#ifndef __WNOTHREAD
984#define __WNOTHREAD 0x20000000
985#endif
986#ifndef __WALL
987#define __WALL 0x40000000
988#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000989#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +0000990#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000991#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000992
Roland McGrathd9f816f2004-09-04 03:39:20 +0000993static const struct xlat wait4_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000994 { WNOHANG, "WNOHANG" },
995#ifndef WSTOPPED
996 { WUNTRACED, "WUNTRACED" },
997#endif
998#ifdef WEXITED
999 { WEXITED, "WEXITED" },
1000#endif
1001#ifdef WTRAPPED
1002 { WTRAPPED, "WTRAPPED" },
1003#endif
1004#ifdef WSTOPPED
1005 { WSTOPPED, "WSTOPPED" },
1006#endif
1007#ifdef WCONTINUED
1008 { WCONTINUED, "WCONTINUED" },
1009#endif
1010#ifdef WNOWAIT
1011 { WNOWAIT, "WNOWAIT" },
1012#endif
1013#ifdef __WCLONE
1014 { __WCLONE, "__WCLONE" },
1015#endif
Roland McGrath7ec1d352002-12-17 04:50:44 +00001016#ifdef __WALL
1017 { __WALL, "__WALL" },
1018#endif
1019#ifdef __WNOTHREAD
1020 { __WNOTHREAD, "__WNOTHREAD" },
1021#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001022 { 0, NULL },
1023};
1024
Roland McGrath5e02a572004-10-19 23:33:47 +00001025#if !defined WCOREFLAG && defined WCOREFLG
1026# define WCOREFLAG WCOREFLG
1027#endif
1028#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001029# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +00001030#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001031#ifndef WCOREDUMP
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001032# define WCOREDUMP(status) ((status) & 0200)
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001033#endif
Roland McGrath5e02a572004-10-19 23:33:47 +00001034#ifndef W_STOPCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001035# define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
Roland McGrath5e02a572004-10-19 23:33:47 +00001036#endif
1037#ifndef W_EXITCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001038# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
Roland McGrath5e02a572004-10-19 23:33:47 +00001039#endif
1040
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001041static int
Denys Vlasenko12014262011-05-30 14:00:14 +02001042printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001043{
1044 int exited = 0;
1045
1046 /*
1047 * Here is a tricky presentation problem. This solution
1048 * is still not entirely satisfactory but since there
1049 * are no wait status constructors it will have to do.
1050 */
Roland McGrath79fbda52004-04-14 02:45:55 +00001051 if (WIFSTOPPED(status)) {
1052 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001053 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +00001054 status &= ~W_STOPCODE(WSTOPSIG(status));
1055 }
1056 else if (WIFSIGNALED(status)) {
1057 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001058 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001059 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +00001060 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1061 }
1062 else if (WIFEXITED(status)) {
1063 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001064 WEXITSTATUS(status));
1065 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +00001066 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001067 }
Roland McGrath79fbda52004-04-14 02:45:55 +00001068 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001069 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001070 return 0;
1071 }
1072
1073 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001074 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +00001075 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +00001076 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001077
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001078 return exited;
1079}
1080
1081static int
Denys Vlasenko59432db2009-01-26 19:09:35 +00001082printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001083{
1084 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001085
1086 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001087 /* On Linux, kernel-side pid_t is typedef'ed to int
1088 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +00001089 * pid argument to int on 64bit arches, producing,
1090 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001091 * in strace. We have to use int here, not long.
1092 */
1093 int pid = tcp->u_arg[0];
1094 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001095 } else {
1096 /* status */
1097 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001098 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001099 else if (syserror(tcp) || tcp->u_rval == 0)
1100 tprintf("%#lx", tcp->u_arg[1]);
1101 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001102 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001103 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +00001104 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001105 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001106 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001107 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001108 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001109 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001110 /* usage */
1111 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001112 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001113 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +00001114#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001115 if (bitness)
1116 printrusage32(tcp, tcp->u_arg[3]);
1117 else
1118#endif
1119 printrusage(tcp, tcp->u_arg[3]);
1120 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001121 else
1122 tprintf("%#lx", tcp->u_arg[3]);
1123 }
1124 }
1125 return 0;
1126}
1127
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001128int
Denys Vlasenko12014262011-05-30 14:00:14 +02001129sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001130{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001131 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001132}
1133
1134int
Denys Vlasenko12014262011-05-30 14:00:14 +02001135sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001136{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001137 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001138}
1139
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001140#ifdef ALPHA
1141int
Denys Vlasenko12014262011-05-30 14:00:14 +02001142sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001143{
1144 return printwaitn(tcp, 4, 1);
1145}
1146#endif
1147
Roland McGrathd9f816f2004-09-04 03:39:20 +00001148static const struct xlat waitid_types[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001149 { P_PID, "P_PID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001150#ifdef P_PPID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001151 { P_PPID, "P_PPID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001152#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001153 { P_PGID, "P_PGID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001154#ifdef P_SID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001155 { P_SID, "P_SID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001156#endif
1157#ifdef P_CID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001158 { P_CID, "P_CID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001159#endif
1160#ifdef P_UID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001161 { P_UID, "P_UID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001162#endif
1163#ifdef P_GID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001164 { P_GID, "P_GID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001165#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001166 { P_ALL, "P_ALL" },
1167#ifdef P_LWPID
1168 { P_LWPID, "P_LWPID" },
1169#endif
1170 { 0, NULL },
1171};
1172
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001173int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +00001174sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001175{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001176 if (entering(tcp)) {
1177 printxval(waitid_types, tcp->u_arg[0], "P_???");
1178 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001179 }
1180 else {
1181 /* siginfo */
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01001182 printsiginfo_at(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001183 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001184 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001185 printflags(wait4_options, tcp->u_arg[3], "W???");
Denys Vlasenko74ec14f2013-02-21 16:13:47 +01001186 if (tcp->s_ent->nargs > 4) {
Roland McGrath39426a32004-10-06 22:02:59 +00001187 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001188 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +00001189 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001190 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +00001191 else if (tcp->u_error)
1192 tprintf("%#lx", tcp->u_arg[4]);
1193 else
1194 printrusage(tcp, tcp->u_arg[4]);
1195 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001196 }
1197 return 0;
1198}
1199
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001200int
Denys Vlasenko12014262011-05-30 14:00:14 +02001201sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001202{
1203 struct utsname uname;
1204
1205 if (exiting(tcp)) {
1206 if (syserror(tcp) || !verbose(tcp))
1207 tprintf("%#lx", tcp->u_arg[0]);
1208 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001209 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001210 else if (!abbrev(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001211 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1212 uname.sysname, uname.nodename);
1213 tprintf("release=\"%s\", version=\"%s\", ",
1214 uname.release, uname.version);
1215 tprintf("machine=\"%s\"", uname.machine);
Dmitry V. Levinea22e972012-05-01 20:56:32 +00001216#ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001217 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001218#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001219 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001220 }
1221 else
1222 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1223 uname.sysname, uname.nodename);
1224 }
1225 return 0;
1226}
1227
Roland McGratheb9e2e82009-06-02 16:49:22 -07001228static const struct xlat ptrace_cmds[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001229 { PTRACE_TRACEME, "PTRACE_TRACEME" },
Denys Vlasenko61526c62011-08-25 10:21:13 +02001230 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1231 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1232 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1233 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1234 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1235 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001236 { PTRACE_CONT, "PTRACE_CONT" },
1237 { PTRACE_KILL, "PTRACE_KILL" },
1238 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1239 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1240 { PTRACE_DETACH, "PTRACE_DETACH" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001241#ifdef PTRACE_GETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001242 { PTRACE_GETREGS, "PTRACE_GETREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001243#endif
1244#ifdef PTRACE_SETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001245 { PTRACE_SETREGS, "PTRACE_SETREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001246#endif
1247#ifdef PTRACE_GETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001248 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001249#endif
1250#ifdef PTRACE_SETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001251 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001252#endif
1253#ifdef PTRACE_GETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001254 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001255#endif
1256#ifdef PTRACE_SETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001257 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001258#endif
1259#ifdef PTRACE_GETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001260 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001261#endif
1262#ifdef PTRACE_SETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001263 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001264#endif
1265#ifdef PTRACE_SETOPTIONS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001266 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001267#endif
1268#ifdef PTRACE_GETEVENTMSG
Denys Vlasenko61526c62011-08-25 10:21:13 +02001269 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001270#endif
1271#ifdef PTRACE_GETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001272 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001273#endif
1274#ifdef PTRACE_SETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001275 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001276#endif
1277#ifdef PTRACE_GETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001278 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001279#endif
1280#ifdef PTRACE_SETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001281 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001282#endif
1283#ifdef PTRACE_SET_SYSCALL
Denys Vlasenko61526c62011-08-25 10:21:13 +02001284 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001285#endif
1286#ifdef PTRACE_SEIZE
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001287 { PTRACE_SEIZE, "PTRACE_SEIZE" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001288#endif
1289#ifdef PTRACE_INTERRUPT
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001290 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001291#endif
1292#ifdef PTRACE_LISTEN
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001293 { PTRACE_LISTEN, "PTRACE_LISTEN" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001294#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001295 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
Denys Vlasenkof535b542009-01-13 18:30:55 +00001296
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001297 { 0, NULL },
1298};
1299
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001300#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00001301static const struct xlat ptrace_setoptions_flags[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001302# ifdef PTRACE_O_TRACESYSGOOD
Denys Vlasenkof535b542009-01-13 18:30:55 +00001303 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001304# endif
1305# ifdef PTRACE_O_TRACEFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001306 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001307# endif
1308# ifdef PTRACE_O_TRACEVFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001309 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001310# endif
1311# ifdef PTRACE_O_TRACECLONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001312 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001313# endif
1314# ifdef PTRACE_O_TRACEEXEC
Denys Vlasenkof535b542009-01-13 18:30:55 +00001315 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001316# endif
1317# ifdef PTRACE_O_TRACEVFORKDONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001318 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001319# endif
1320# ifdef PTRACE_O_TRACEEXIT
Denys Vlasenkof535b542009-01-13 18:30:55 +00001321 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001322# endif
Denys Vlasenkof535b542009-01-13 18:30:55 +00001323 { 0, NULL },
1324};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001325#endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001326
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001327static const struct xlat nt_descriptor_types[] = {
1328#ifdef NT_PRSTATUS
1329 { NT_PRSTATUS, "NT_PRSTATUS" },
1330#endif
1331#ifdef NT_FPREGSET
1332 { NT_FPREGSET, "NT_FPREGSET" },
1333#endif
1334#ifdef NT_PRPSINFO
1335 { NT_PRPSINFO, "NT_PRPSINFO" },
1336#endif
1337#ifdef NT_PRXREG
1338 { NT_PRXREG, "NT_PRXREG" },
1339#endif
1340#ifdef NT_TASKSTRUCT
1341 { NT_TASKSTRUCT, "NT_TASKSTRUCT" },
1342#endif
1343#ifdef NT_PLATFORM
1344 { NT_PLATFORM, "NT_PLATFORM" },
1345#endif
1346#ifdef NT_AUXV
1347 { NT_AUXV, "NT_AUXV" },
1348#endif
1349#ifdef NT_GWINDOWS
1350 { NT_GWINDOWS, "NT_GWINDOWS" },
1351#endif
1352#ifdef NT_ASRS
1353 { NT_ASRS, "NT_ASRS" },
1354#endif
1355#ifdef NT_PSTATUS
1356 { NT_PSTATUS, "NT_PSTATUS" },
1357#endif
1358#ifdef NT_PSINFO
1359 { NT_PSINFO, "NT_PSINFO" },
1360#endif
1361#ifdef NT_PRCRED
1362 { NT_PRCRED, "NT_PRCRED" },
1363#endif
1364#ifdef NT_UTSNAME
1365 { NT_UTSNAME, "NT_UTSNAME" },
1366#endif
1367#ifdef NT_LWPSTATUS
1368 { NT_LWPSTATUS, "NT_LWPSTATUS" },
1369#endif
1370#ifdef NT_LWPSINFO
1371 { NT_LWPSINFO, "NT_LWPSINFO" },
1372#endif
1373#ifdef NT_PRFPXREG
1374 { NT_PRFPXREG, "NT_PRFPXREG" },
1375#endif
1376#ifdef NT_PRXFPREG
1377 { NT_PRXFPREG, "NT_PRXFPREG" },
1378#endif
1379#ifdef NT_PPC_VMX
1380 { NT_PPC_VMX, "NT_PPC_VMX" },
1381#endif
1382#ifdef NT_PPC_SPE
1383 { NT_PPC_SPE, "NT_PPC_SPE" },
1384#endif
1385#ifdef NT_PPC_VSX
1386 { NT_PPC_VSX, "NT_PPC_VSX" },
1387#endif
1388#ifdef NT_386_TLS
1389 { NT_386_TLS, "NT_386_TLS" },
1390#endif
1391#ifdef NT_386_IOPERM
1392 { NT_386_IOPERM, "NT_386_IOPERM" },
1393#endif
1394#ifdef NT_X86_XSTATE
1395 { NT_X86_XSTATE, "NT_X86_XSTATE" },
1396#endif
1397 { 0, NULL },
1398};
1399
Denys Vlasenko513e9c22012-03-21 14:39:22 +01001400#define uoff(member) offsetof(struct user, member)
1401
Roland McGrathd9f816f2004-09-04 03:39:20 +00001402const struct xlat struct_user_offsets[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001403#if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001404 { PT_PSWMASK, "psw_mask" },
1405 { PT_PSWADDR, "psw_addr" },
1406 { PT_GPR0, "gpr0" },
1407 { PT_GPR1, "gpr1" },
1408 { PT_GPR2, "gpr2" },
1409 { PT_GPR3, "gpr3" },
1410 { PT_GPR4, "gpr4" },
1411 { PT_GPR5, "gpr5" },
1412 { PT_GPR6, "gpr6" },
1413 { PT_GPR7, "gpr7" },
1414 { PT_GPR8, "gpr8" },
1415 { PT_GPR9, "gpr9" },
1416 { PT_GPR10, "gpr10" },
1417 { PT_GPR11, "gpr11" },
1418 { PT_GPR12, "gpr12" },
1419 { PT_GPR13, "gpr13" },
1420 { PT_GPR14, "gpr14" },
1421 { PT_GPR15, "gpr15" },
1422 { PT_ACR0, "acr0" },
1423 { PT_ACR1, "acr1" },
1424 { PT_ACR2, "acr2" },
1425 { PT_ACR3, "acr3" },
1426 { PT_ACR4, "acr4" },
1427 { PT_ACR5, "acr5" },
1428 { PT_ACR6, "acr6" },
1429 { PT_ACR7, "acr7" },
1430 { PT_ACR8, "acr8" },
1431 { PT_ACR9, "acr9" },
1432 { PT_ACR10, "acr10" },
1433 { PT_ACR11, "acr11" },
1434 { PT_ACR12, "acr12" },
1435 { PT_ACR13, "acr13" },
1436 { PT_ACR14, "acr14" },
1437 { PT_ACR15, "acr15" },
1438 { PT_ORIGGPR2, "orig_gpr2" },
1439 { PT_FPC, "fpc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001440#if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001441 { PT_FPR0_HI, "fpr0.hi" },
1442 { PT_FPR0_LO, "fpr0.lo" },
1443 { PT_FPR1_HI, "fpr1.hi" },
1444 { PT_FPR1_LO, "fpr1.lo" },
1445 { PT_FPR2_HI, "fpr2.hi" },
1446 { PT_FPR2_LO, "fpr2.lo" },
1447 { PT_FPR3_HI, "fpr3.hi" },
1448 { PT_FPR3_LO, "fpr3.lo" },
1449 { PT_FPR4_HI, "fpr4.hi" },
1450 { PT_FPR4_LO, "fpr4.lo" },
1451 { PT_FPR5_HI, "fpr5.hi" },
1452 { PT_FPR5_LO, "fpr5.lo" },
1453 { PT_FPR6_HI, "fpr6.hi" },
1454 { PT_FPR6_LO, "fpr6.lo" },
1455 { PT_FPR7_HI, "fpr7.hi" },
1456 { PT_FPR7_LO, "fpr7.lo" },
1457 { PT_FPR8_HI, "fpr8.hi" },
1458 { PT_FPR8_LO, "fpr8.lo" },
1459 { PT_FPR9_HI, "fpr9.hi" },
1460 { PT_FPR9_LO, "fpr9.lo" },
1461 { PT_FPR10_HI, "fpr10.hi" },
1462 { PT_FPR10_LO, "fpr10.lo" },
1463 { PT_FPR11_HI, "fpr11.hi" },
1464 { PT_FPR11_LO, "fpr11.lo" },
1465 { PT_FPR12_HI, "fpr12.hi" },
1466 { PT_FPR12_LO, "fpr12.lo" },
1467 { PT_FPR13_HI, "fpr13.hi" },
1468 { PT_FPR13_LO, "fpr13.lo" },
1469 { PT_FPR14_HI, "fpr14.hi" },
1470 { PT_FPR14_LO, "fpr14.lo" },
1471 { PT_FPR15_HI, "fpr15.hi" },
1472 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001473#endif
1474#if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001475 { PT_FPR0, "fpr0" },
1476 { PT_FPR1, "fpr1" },
1477 { PT_FPR2, "fpr2" },
1478 { PT_FPR3, "fpr3" },
1479 { PT_FPR4, "fpr4" },
1480 { PT_FPR5, "fpr5" },
1481 { PT_FPR6, "fpr6" },
1482 { PT_FPR7, "fpr7" },
1483 { PT_FPR8, "fpr8" },
1484 { PT_FPR9, "fpr9" },
1485 { PT_FPR10, "fpr10" },
1486 { PT_FPR11, "fpr11" },
1487 { PT_FPR12, "fpr12" },
1488 { PT_FPR13, "fpr13" },
1489 { PT_FPR14, "fpr14" },
1490 { PT_FPR15, "fpr15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001491#endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001492 { PT_CR_9, "cr9" },
1493 { PT_CR_10, "cr10" },
1494 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001495 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001496#elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001497 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001498#elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001499 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001500#elif defined(POWERPC)
1501# ifndef PT_ORIG_R3
1502# define PT_ORIG_R3 34
1503# endif
1504# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001505 { REGSIZE*PT_R0, "r0" },
1506 { REGSIZE*PT_R1, "r1" },
1507 { REGSIZE*PT_R2, "r2" },
1508 { REGSIZE*PT_R3, "r3" },
1509 { REGSIZE*PT_R4, "r4" },
1510 { REGSIZE*PT_R5, "r5" },
1511 { REGSIZE*PT_R6, "r6" },
1512 { REGSIZE*PT_R7, "r7" },
1513 { REGSIZE*PT_R8, "r8" },
1514 { REGSIZE*PT_R9, "r9" },
1515 { REGSIZE*PT_R10, "r10" },
1516 { REGSIZE*PT_R11, "r11" },
1517 { REGSIZE*PT_R12, "r12" },
1518 { REGSIZE*PT_R13, "r13" },
1519 { REGSIZE*PT_R14, "r14" },
1520 { REGSIZE*PT_R15, "r15" },
1521 { REGSIZE*PT_R16, "r16" },
1522 { REGSIZE*PT_R17, "r17" },
1523 { REGSIZE*PT_R18, "r18" },
1524 { REGSIZE*PT_R19, "r19" },
1525 { REGSIZE*PT_R20, "r20" },
1526 { REGSIZE*PT_R21, "r21" },
1527 { REGSIZE*PT_R22, "r22" },
1528 { REGSIZE*PT_R23, "r23" },
1529 { REGSIZE*PT_R24, "r24" },
1530 { REGSIZE*PT_R25, "r25" },
1531 { REGSIZE*PT_R26, "r26" },
1532 { REGSIZE*PT_R27, "r27" },
1533 { REGSIZE*PT_R28, "r28" },
1534 { REGSIZE*PT_R29, "r29" },
1535 { REGSIZE*PT_R30, "r30" },
1536 { REGSIZE*PT_R31, "r31" },
1537 { REGSIZE*PT_NIP, "NIP" },
1538 { REGSIZE*PT_MSR, "MSR" },
1539 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1540 { REGSIZE*PT_CTR, "CTR" },
1541 { REGSIZE*PT_LNK, "LNK" },
1542 { REGSIZE*PT_XER, "XER" },
1543 { REGSIZE*PT_CCR, "CCR" },
1544 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001545# undef REGSIZE
1546#elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001547 { 0, "r0" },
1548 { 1, "r1" },
1549 { 2, "r2" },
1550 { 3, "r3" },
1551 { 4, "r4" },
1552 { 5, "r5" },
1553 { 6, "r6" },
1554 { 7, "r7" },
1555 { 8, "r8" },
1556 { 9, "r9" },
1557 { 10, "r10" },
1558 { 11, "r11" },
1559 { 12, "r12" },
1560 { 13, "r13" },
1561 { 14, "r14" },
1562 { 15, "r15" },
1563 { 16, "r16" },
1564 { 17, "r17" },
1565 { 18, "r18" },
1566 { 19, "r19" },
1567 { 20, "r20" },
1568 { 21, "r21" },
1569 { 22, "r22" },
1570 { 23, "r23" },
1571 { 24, "r24" },
1572 { 25, "r25" },
1573 { 26, "r26" },
1574 { 27, "r27" },
1575 { 28, "r28" },
1576 { 29, "gp" },
1577 { 30, "fp" },
1578 { 31, "zero" },
1579 { 32, "fp0" },
1580 { 33, "fp" },
1581 { 34, "fp2" },
1582 { 35, "fp3" },
1583 { 36, "fp4" },
1584 { 37, "fp5" },
1585 { 38, "fp6" },
1586 { 39, "fp7" },
1587 { 40, "fp8" },
1588 { 41, "fp9" },
1589 { 42, "fp10" },
1590 { 43, "fp11" },
1591 { 44, "fp12" },
1592 { 45, "fp13" },
1593 { 46, "fp14" },
1594 { 47, "fp15" },
1595 { 48, "fp16" },
1596 { 49, "fp17" },
1597 { 50, "fp18" },
1598 { 51, "fp19" },
1599 { 52, "fp20" },
1600 { 53, "fp21" },
1601 { 54, "fp22" },
1602 { 55, "fp23" },
1603 { 56, "fp24" },
1604 { 57, "fp25" },
1605 { 58, "fp26" },
1606 { 59, "fp27" },
1607 { 60, "fp28" },
1608 { 61, "fp29" },
1609 { 62, "fp30" },
1610 { 63, "fp31" },
1611 { 64, "pc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001612#elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001613 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1614 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1615 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1616 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1617 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1618 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1619 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1620 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1621 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1622 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1623 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1624 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1625 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1626 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1627 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1628 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1629 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1630 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1631 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1632 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1633 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1634 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1635 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1636 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1637 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1638 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1639 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1640 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1641 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1642 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1643 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1644 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1645 /* switch stack: */
1646 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1647 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1648 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1649 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1650 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1651 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1652 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1653 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1654 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1655 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001656 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1657 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001658 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001659 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001660 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1661 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001662 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1663 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1664 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1665 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1666 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1667 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1668 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1669 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1670 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1671 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1672 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1673 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1674 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1675 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1676 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001677# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001678 { PT_AR_CSD, "ar.csd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001679# endif
1680# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001681 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001682# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001683 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001684#elif defined(I386)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001685 { 4*EBX, "4*EBX" },
1686 { 4*ECX, "4*ECX" },
1687 { 4*EDX, "4*EDX" },
1688 { 4*ESI, "4*ESI" },
1689 { 4*EDI, "4*EDI" },
1690 { 4*EBP, "4*EBP" },
1691 { 4*EAX, "4*EAX" },
1692 { 4*DS, "4*DS" },
1693 { 4*ES, "4*ES" },
1694 { 4*FS, "4*FS" },
1695 { 4*GS, "4*GS" },
1696 { 4*ORIG_EAX, "4*ORIG_EAX" },
1697 { 4*EIP, "4*EIP" },
1698 { 4*CS, "4*CS" },
1699 { 4*EFL, "4*EFL" },
1700 { 4*UESP, "4*UESP" },
1701 { 4*SS, "4*SS" },
H.J. Lu35be5812012-04-16 13:00:01 +02001702#elif defined(X86_64) || defined(X32)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001703 { 8*R15, "8*R15" },
1704 { 8*R14, "8*R14" },
1705 { 8*R13, "8*R13" },
1706 { 8*R12, "8*R12" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001707 { 8*RBP, "8*RBP" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001708 { 8*RBX, "8*RBX" },
1709 { 8*R11, "8*R11" },
1710 { 8*R10, "8*R10" },
1711 { 8*R9, "8*R9" },
1712 { 8*R8, "8*R8" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001713 { 8*RAX, "8*RAX" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001714 { 8*RCX, "8*RCX" },
1715 { 8*RDX, "8*RDX" },
1716 { 8*RSI, "8*RSI" },
1717 { 8*RDI, "8*RDI" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001718 { 8*ORIG_RAX, "8*ORIG_RAX" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001719 { 8*RIP, "8*RIP" },
1720 { 8*CS, "8*CS" },
1721 { 8*EFLAGS, "8*EFL" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001722 { 8*RSP, "8*RSP" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001723 { 8*SS, "8*SS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001724#elif defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001725 { 4*PT_D1, "4*PT_D1" },
1726 { 4*PT_D2, "4*PT_D2" },
1727 { 4*PT_D3, "4*PT_D3" },
1728 { 4*PT_D4, "4*PT_D4" },
1729 { 4*PT_D5, "4*PT_D5" },
1730 { 4*PT_D6, "4*PT_D6" },
1731 { 4*PT_D7, "4*PT_D7" },
1732 { 4*PT_A0, "4*PT_A0" },
1733 { 4*PT_A1, "4*PT_A1" },
1734 { 4*PT_A2, "4*PT_A2" },
1735 { 4*PT_A3, "4*PT_A3" },
1736 { 4*PT_A4, "4*PT_A4" },
1737 { 4*PT_A5, "4*PT_A5" },
1738 { 4*PT_A6, "4*PT_A6" },
1739 { 4*PT_D0, "4*PT_D0" },
1740 { 4*PT_USP, "4*PT_USP" },
1741 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1742 { 4*PT_SR, "4*PT_SR" },
1743 { 4*PT_PC, "4*PT_PC" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001744#elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001745 { 4*REG_REG0, "4*REG_REG0" },
1746 { 4*(REG_REG0+1), "4*REG_REG1" },
1747 { 4*(REG_REG0+2), "4*REG_REG2" },
1748 { 4*(REG_REG0+3), "4*REG_REG3" },
1749 { 4*(REG_REG0+4), "4*REG_REG4" },
1750 { 4*(REG_REG0+5), "4*REG_REG5" },
1751 { 4*(REG_REG0+6), "4*REG_REG6" },
1752 { 4*(REG_REG0+7), "4*REG_REG7" },
1753 { 4*(REG_REG0+8), "4*REG_REG8" },
1754 { 4*(REG_REG0+9), "4*REG_REG9" },
1755 { 4*(REG_REG0+10), "4*REG_REG10" },
1756 { 4*(REG_REG0+11), "4*REG_REG11" },
1757 { 4*(REG_REG0+12), "4*REG_REG12" },
1758 { 4*(REG_REG0+13), "4*REG_REG13" },
1759 { 4*(REG_REG0+14), "4*REG_REG14" },
1760 { 4*REG_REG15, "4*REG_REG15" },
1761 { 4*REG_PC, "4*REG_PC" },
1762 { 4*REG_PR, "4*REG_PR" },
1763 { 4*REG_SR, "4*REG_SR" },
1764 { 4*REG_GBR, "4*REG_GBR" },
1765 { 4*REG_MACH, "4*REG_MACH" },
1766 { 4*REG_MACL, "4*REG_MACL" },
1767 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1768 { 4*REG_FPUL, "4*REG_FPUL" },
1769 { 4*REG_FPREG0, "4*REG_FPREG0" },
1770 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1771 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1772 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1773 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1774 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1775 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1776 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1777 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1778 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1779 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1780 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1781 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1782 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1783 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1784 { 4*REG_FPREG15, "4*REG_FPREG15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001785# ifdef REG_XDREG0
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001786 { 4*REG_XDREG0, "4*REG_XDREG0" },
1787 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1788 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1789 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1790 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1791 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1792 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1793 { 4*REG_XDREG14, "4*REG_XDREG14" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001794# endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001795 { 4*REG_FPSCR, "4*REG_FPSCR" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001796#elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001797 { 0, "PC(L)" },
1798 { 4, "PC(U)" },
1799 { 8, "SR(L)" },
1800 { 12, "SR(U)" },
1801 { 16, "syscall no.(L)" },
1802 { 20, "syscall_no.(U)" },
1803 { 24, "R0(L)" },
1804 { 28, "R0(U)" },
1805 { 32, "R1(L)" },
1806 { 36, "R1(U)" },
1807 { 40, "R2(L)" },
1808 { 44, "R2(U)" },
1809 { 48, "R3(L)" },
1810 { 52, "R3(U)" },
1811 { 56, "R4(L)" },
1812 { 60, "R4(U)" },
1813 { 64, "R5(L)" },
1814 { 68, "R5(U)" },
1815 { 72, "R6(L)" },
1816 { 76, "R6(U)" },
1817 { 80, "R7(L)" },
1818 { 84, "R7(U)" },
1819 { 88, "R8(L)" },
1820 { 92, "R8(U)" },
1821 { 96, "R9(L)" },
1822 { 100, "R9(U)" },
1823 { 104, "R10(L)" },
1824 { 108, "R10(U)" },
1825 { 112, "R11(L)" },
1826 { 116, "R11(U)" },
1827 { 120, "R12(L)" },
1828 { 124, "R12(U)" },
1829 { 128, "R13(L)" },
1830 { 132, "R13(U)" },
1831 { 136, "R14(L)" },
1832 { 140, "R14(U)" },
1833 { 144, "R15(L)" },
1834 { 148, "R15(U)" },
1835 { 152, "R16(L)" },
1836 { 156, "R16(U)" },
1837 { 160, "R17(L)" },
1838 { 164, "R17(U)" },
1839 { 168, "R18(L)" },
1840 { 172, "R18(U)" },
1841 { 176, "R19(L)" },
1842 { 180, "R19(U)" },
1843 { 184, "R20(L)" },
1844 { 188, "R20(U)" },
1845 { 192, "R21(L)" },
1846 { 196, "R21(U)" },
1847 { 200, "R22(L)" },
1848 { 204, "R22(U)" },
1849 { 208, "R23(L)" },
1850 { 212, "R23(U)" },
1851 { 216, "R24(L)" },
1852 { 220, "R24(U)" },
1853 { 224, "R25(L)" },
1854 { 228, "R25(U)" },
1855 { 232, "R26(L)" },
1856 { 236, "R26(U)" },
1857 { 240, "R27(L)" },
1858 { 244, "R27(U)" },
1859 { 248, "R28(L)" },
1860 { 252, "R28(U)" },
1861 { 256, "R29(L)" },
1862 { 260, "R29(U)" },
1863 { 264, "R30(L)" },
1864 { 268, "R30(U)" },
1865 { 272, "R31(L)" },
1866 { 276, "R31(U)" },
1867 { 280, "R32(L)" },
1868 { 284, "R32(U)" },
1869 { 288, "R33(L)" },
1870 { 292, "R33(U)" },
1871 { 296, "R34(L)" },
1872 { 300, "R34(U)" },
1873 { 304, "R35(L)" },
1874 { 308, "R35(U)" },
1875 { 312, "R36(L)" },
1876 { 316, "R36(U)" },
1877 { 320, "R37(L)" },
1878 { 324, "R37(U)" },
1879 { 328, "R38(L)" },
1880 { 332, "R38(U)" },
1881 { 336, "R39(L)" },
1882 { 340, "R39(U)" },
1883 { 344, "R40(L)" },
1884 { 348, "R40(U)" },
1885 { 352, "R41(L)" },
1886 { 356, "R41(U)" },
1887 { 360, "R42(L)" },
1888 { 364, "R42(U)" },
1889 { 368, "R43(L)" },
1890 { 372, "R43(U)" },
1891 { 376, "R44(L)" },
1892 { 380, "R44(U)" },
1893 { 384, "R45(L)" },
1894 { 388, "R45(U)" },
1895 { 392, "R46(L)" },
1896 { 396, "R46(U)" },
1897 { 400, "R47(L)" },
1898 { 404, "R47(U)" },
1899 { 408, "R48(L)" },
1900 { 412, "R48(U)" },
1901 { 416, "R49(L)" },
1902 { 420, "R49(U)" },
1903 { 424, "R50(L)" },
1904 { 428, "R50(U)" },
1905 { 432, "R51(L)" },
1906 { 436, "R51(U)" },
1907 { 440, "R52(L)" },
1908 { 444, "R52(U)" },
1909 { 448, "R53(L)" },
1910 { 452, "R53(U)" },
1911 { 456, "R54(L)" },
1912 { 460, "R54(U)" },
1913 { 464, "R55(L)" },
1914 { 468, "R55(U)" },
1915 { 472, "R56(L)" },
1916 { 476, "R56(U)" },
1917 { 480, "R57(L)" },
1918 { 484, "R57(U)" },
1919 { 488, "R58(L)" },
1920 { 492, "R58(U)" },
1921 { 496, "R59(L)" },
1922 { 500, "R59(U)" },
1923 { 504, "R60(L)" },
1924 { 508, "R60(U)" },
1925 { 512, "R61(L)" },
1926 { 516, "R61(U)" },
1927 { 520, "R62(L)" },
1928 { 524, "R62(U)" },
1929 { 528, "TR0(L)" },
1930 { 532, "TR0(U)" },
1931 { 536, "TR1(L)" },
1932 { 540, "TR1(U)" },
1933 { 544, "TR2(L)" },
1934 { 548, "TR2(U)" },
1935 { 552, "TR3(L)" },
1936 { 556, "TR3(U)" },
1937 { 560, "TR4(L)" },
1938 { 564, "TR4(U)" },
1939 { 568, "TR5(L)" },
1940 { 572, "TR5(U)" },
1941 { 576, "TR6(L)" },
1942 { 580, "TR6(U)" },
1943 { 584, "TR7(L)" },
1944 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00001945 /* This entry is in case pt_regs contains dregs (depends on
1946 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001947 { uoff(regs), "offsetof(struct user, regs)" },
1948 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001949#elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00001950 { uoff(regs.ARM_r0), "r0" },
1951 { uoff(regs.ARM_r1), "r1" },
1952 { uoff(regs.ARM_r2), "r2" },
1953 { uoff(regs.ARM_r3), "r3" },
1954 { uoff(regs.ARM_r4), "r4" },
1955 { uoff(regs.ARM_r5), "r5" },
1956 { uoff(regs.ARM_r6), "r6" },
1957 { uoff(regs.ARM_r7), "r7" },
1958 { uoff(regs.ARM_r8), "r8" },
1959 { uoff(regs.ARM_r9), "r9" },
1960 { uoff(regs.ARM_r10), "r10" },
1961 { uoff(regs.ARM_fp), "fp" },
1962 { uoff(regs.ARM_ip), "ip" },
1963 { uoff(regs.ARM_sp), "sp" },
1964 { uoff(regs.ARM_lr), "lr" },
1965 { uoff(regs.ARM_pc), "pc" },
1966 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001967#elif defined(AVR32)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001968 { uoff(regs.sr), "sr" },
1969 { uoff(regs.pc), "pc" },
1970 { uoff(regs.lr), "lr" },
1971 { uoff(regs.sp), "sp" },
1972 { uoff(regs.r12), "r12" },
1973 { uoff(regs.r11), "r11" },
1974 { uoff(regs.r10), "r10" },
1975 { uoff(regs.r9), "r9" },
1976 { uoff(regs.r8), "r8" },
1977 { uoff(regs.r7), "r7" },
1978 { uoff(regs.r6), "r6" },
1979 { uoff(regs.r5), "r5" },
1980 { uoff(regs.r4), "r4" },
1981 { uoff(regs.r3), "r3" },
1982 { uoff(regs.r2), "r2" },
1983 { uoff(regs.r1), "r1" },
1984 { uoff(regs.r0), "r0" },
1985 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001986#elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00001987 { 0, "r0" },
1988 { 1, "r1" },
1989 { 2, "r2" },
1990 { 3, "r3" },
1991 { 4, "r4" },
1992 { 5, "r5" },
1993 { 6, "r6" },
1994 { 7, "r7" },
1995 { 8, "r8" },
1996 { 9, "r9" },
1997 { 10, "r10" },
1998 { 11, "r11" },
1999 { 12, "r12" },
2000 { 13, "r13" },
2001 { 14, "r14" },
2002 { 15, "r15" },
2003 { 16, "r16" },
2004 { 17, "r17" },
2005 { 18, "r18" },
2006 { 19, "r19" },
2007 { 20, "r20" },
2008 { 21, "r21" },
2009 { 22, "r22" },
2010 { 23, "r23" },
2011 { 24, "r24" },
2012 { 25, "r25" },
2013 { 26, "r26" },
2014 { 27, "r27" },
2015 { 28, "r28" },
2016 { 29, "r29" },
2017 { 30, "r30" },
2018 { 31, "r31" },
2019 { 32, "f0" },
2020 { 33, "f1" },
2021 { 34, "f2" },
2022 { 35, "f3" },
2023 { 36, "f4" },
2024 { 37, "f5" },
2025 { 38, "f6" },
2026 { 39, "f7" },
2027 { 40, "f8" },
2028 { 41, "f9" },
2029 { 42, "f10" },
2030 { 43, "f11" },
2031 { 44, "f12" },
2032 { 45, "f13" },
2033 { 46, "f14" },
2034 { 47, "f15" },
2035 { 48, "f16" },
2036 { 49, "f17" },
2037 { 50, "f18" },
2038 { 51, "f19" },
2039 { 52, "f20" },
2040 { 53, "f21" },
2041 { 54, "f22" },
2042 { 55, "f23" },
2043 { 56, "f24" },
2044 { 57, "f25" },
2045 { 58, "f26" },
2046 { 59, "f27" },
2047 { 60, "f28" },
2048 { 61, "f29" },
2049 { 62, "f30" },
2050 { 63, "f31" },
2051 { 64, "pc" },
2052 { 65, "cause" },
2053 { 66, "badvaddr" },
2054 { 67, "mmhi" },
2055 { 68, "mmlo" },
2056 { 69, "fpcsr" },
2057 { 70, "fpeir" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002058#elif defined(TILE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05002059 { PTREGS_OFFSET_REG(0), "r0" },
2060 { PTREGS_OFFSET_REG(1), "r1" },
2061 { PTREGS_OFFSET_REG(2), "r2" },
2062 { PTREGS_OFFSET_REG(3), "r3" },
2063 { PTREGS_OFFSET_REG(4), "r4" },
2064 { PTREGS_OFFSET_REG(5), "r5" },
2065 { PTREGS_OFFSET_REG(6), "r6" },
2066 { PTREGS_OFFSET_REG(7), "r7" },
2067 { PTREGS_OFFSET_REG(8), "r8" },
2068 { PTREGS_OFFSET_REG(9), "r9" },
2069 { PTREGS_OFFSET_REG(10), "r10" },
2070 { PTREGS_OFFSET_REG(11), "r11" },
2071 { PTREGS_OFFSET_REG(12), "r12" },
2072 { PTREGS_OFFSET_REG(13), "r13" },
2073 { PTREGS_OFFSET_REG(14), "r14" },
2074 { PTREGS_OFFSET_REG(15), "r15" },
2075 { PTREGS_OFFSET_REG(16), "r16" },
2076 { PTREGS_OFFSET_REG(17), "r17" },
2077 { PTREGS_OFFSET_REG(18), "r18" },
2078 { PTREGS_OFFSET_REG(19), "r19" },
2079 { PTREGS_OFFSET_REG(20), "r20" },
2080 { PTREGS_OFFSET_REG(21), "r21" },
2081 { PTREGS_OFFSET_REG(22), "r22" },
2082 { PTREGS_OFFSET_REG(23), "r23" },
2083 { PTREGS_OFFSET_REG(24), "r24" },
2084 { PTREGS_OFFSET_REG(25), "r25" },
2085 { PTREGS_OFFSET_REG(26), "r26" },
2086 { PTREGS_OFFSET_REG(27), "r27" },
2087 { PTREGS_OFFSET_REG(28), "r28" },
2088 { PTREGS_OFFSET_REG(29), "r29" },
2089 { PTREGS_OFFSET_REG(30), "r30" },
2090 { PTREGS_OFFSET_REG(31), "r31" },
2091 { PTREGS_OFFSET_REG(32), "r32" },
2092 { PTREGS_OFFSET_REG(33), "r33" },
2093 { PTREGS_OFFSET_REG(34), "r34" },
2094 { PTREGS_OFFSET_REG(35), "r35" },
2095 { PTREGS_OFFSET_REG(36), "r36" },
2096 { PTREGS_OFFSET_REG(37), "r37" },
2097 { PTREGS_OFFSET_REG(38), "r38" },
2098 { PTREGS_OFFSET_REG(39), "r39" },
2099 { PTREGS_OFFSET_REG(40), "r40" },
2100 { PTREGS_OFFSET_REG(41), "r41" },
2101 { PTREGS_OFFSET_REG(42), "r42" },
2102 { PTREGS_OFFSET_REG(43), "r43" },
2103 { PTREGS_OFFSET_REG(44), "r44" },
2104 { PTREGS_OFFSET_REG(45), "r45" },
2105 { PTREGS_OFFSET_REG(46), "r46" },
2106 { PTREGS_OFFSET_REG(47), "r47" },
2107 { PTREGS_OFFSET_REG(48), "r48" },
2108 { PTREGS_OFFSET_REG(49), "r49" },
2109 { PTREGS_OFFSET_REG(50), "r50" },
2110 { PTREGS_OFFSET_REG(51), "r51" },
2111 { PTREGS_OFFSET_REG(52), "r52" },
2112 { PTREGS_OFFSET_TP, "tp" },
2113 { PTREGS_OFFSET_SP, "sp" },
2114 { PTREGS_OFFSET_LR, "lr" },
2115 { PTREGS_OFFSET_PC, "pc" },
2116 { PTREGS_OFFSET_EX1, "ex1" },
2117 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2118 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2119 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002120#endif
2121#ifdef CRISV10
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002122 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2123 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2124 { 4*PT_R13, "4*PT_R13" },
2125 { 4*PT_R12, "4*PT_R12" },
2126 { 4*PT_R11, "4*PT_R11" },
2127 { 4*PT_R10, "4*PT_R10" },
2128 { 4*PT_R9, "4*PT_R9" },
2129 { 4*PT_R8, "4*PT_R8" },
2130 { 4*PT_R7, "4*PT_R7" },
2131 { 4*PT_R6, "4*PT_R6" },
2132 { 4*PT_R5, "4*PT_R5" },
2133 { 4*PT_R4, "4*PT_R4" },
2134 { 4*PT_R3, "4*PT_R3" },
2135 { 4*PT_R2, "4*PT_R2" },
2136 { 4*PT_R1, "4*PT_R1" },
2137 { 4*PT_R0, "4*PT_R0" },
2138 { 4*PT_MOF, "4*PT_MOF" },
2139 { 4*PT_DCCR, "4*PT_DCCR" },
2140 { 4*PT_SRP, "4*PT_SRP" },
2141 { 4*PT_IRP, "4*PT_IRP" },
2142 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2143 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2144 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2145 { 4*PT_USP, "4*PT_USP" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002146#endif
2147#ifdef CRISV32
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002148 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2149 { 4*PT_R0, "4*PT_R0" },
2150 { 4*PT_R1, "4*PT_R1" },
2151 { 4*PT_R2, "4*PT_R2" },
2152 { 4*PT_R3, "4*PT_R3" },
2153 { 4*PT_R4, "4*PT_R4" },
2154 { 4*PT_R5, "4*PT_R5" },
2155 { 4*PT_R6, "4*PT_R6" },
2156 { 4*PT_R7, "4*PT_R7" },
2157 { 4*PT_R8, "4*PT_R8" },
2158 { 4*PT_R9, "4*PT_R9" },
2159 { 4*PT_R10, "4*PT_R10" },
2160 { 4*PT_R11, "4*PT_R11" },
2161 { 4*PT_R12, "4*PT_R12" },
2162 { 4*PT_R13, "4*PT_R13" },
2163 { 4*PT_ACR, "4*PT_ACR" },
2164 { 4*PT_SRS, "4*PT_SRS" },
2165 { 4*PT_MOF, "4*PT_MOF" },
2166 { 4*PT_SPC, "4*PT_SPC" },
2167 { 4*PT_CCS, "4*PT_CCS" },
2168 { 4*PT_SRP, "4*PT_SRP" },
2169 { 4*PT_ERP, "4*PT_ERP" },
2170 { 4*PT_EXS, "4*PT_EXS" },
2171 { 4*PT_EDA, "4*PT_EDA" },
2172 { 4*PT_USP, "4*PT_USP" },
2173 { 4*PT_PPC, "4*PT_PPC" },
2174 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2175 { 4*PT_BP+4, "4*PT_BP+4" },
2176 { 4*PT_BP+8, "4*PT_BP+8" },
2177 { 4*PT_BP+12, "4*PT_BP+12" },
2178 { 4*PT_BP+16, "4*PT_BP+16" },
2179 { 4*PT_BP+20, "4*PT_BP+20" },
2180 { 4*PT_BP+24, "4*PT_BP+24" },
2181 { 4*PT_BP+28, "4*PT_BP+28" },
2182 { 4*PT_BP+32, "4*PT_BP+32" },
2183 { 4*PT_BP+36, "4*PT_BP+36" },
2184 { 4*PT_BP+40, "4*PT_BP+40" },
2185 { 4*PT_BP+44, "4*PT_BP+44" },
2186 { 4*PT_BP+48, "4*PT_BP+48" },
2187 { 4*PT_BP+52, "4*PT_BP+52" },
2188 { 4*PT_BP+56, "4*PT_BP+56" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002189#endif
2190#ifdef MICROBLAZE
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002191 { PT_GPR(0), "r0" },
2192 { PT_GPR(1), "r1" },
2193 { PT_GPR(2), "r2" },
2194 { PT_GPR(3), "r3" },
2195 { PT_GPR(4), "r4" },
2196 { PT_GPR(5), "r5" },
2197 { PT_GPR(6), "r6" },
2198 { PT_GPR(7), "r7" },
2199 { PT_GPR(8), "r8" },
2200 { PT_GPR(9), "r9" },
2201 { PT_GPR(10), "r10" },
2202 { PT_GPR(11), "r11" },
2203 { PT_GPR(12), "r12" },
2204 { PT_GPR(13), "r13" },
2205 { PT_GPR(14), "r14" },
2206 { PT_GPR(15), "r15" },
2207 { PT_GPR(16), "r16" },
2208 { PT_GPR(17), "r17" },
2209 { PT_GPR(18), "r18" },
2210 { PT_GPR(19), "r19" },
2211 { PT_GPR(20), "r20" },
2212 { PT_GPR(21), "r21" },
2213 { PT_GPR(22), "r22" },
2214 { PT_GPR(23), "r23" },
2215 { PT_GPR(24), "r24" },
2216 { PT_GPR(25), "r25" },
2217 { PT_GPR(26), "r26" },
2218 { PT_GPR(27), "r27" },
2219 { PT_GPR(28), "r28" },
2220 { PT_GPR(29), "r29" },
2221 { PT_GPR(30), "r30" },
2222 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002223 { PT_PC, "rpc", },
2224 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002225 { PT_EAR, "rear", },
2226 { PT_ESR, "resr", },
2227 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002228 { PT_KERNEL_MODE, "kernel_mode", },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002229#endif
Christian Svensson492f81f2013-02-14 13:26:27 +01002230#ifdef OR1K
2231 { 4*0, "r0" },
2232 { 4*1, "r1" },
2233 { 4*2, "r2" },
2234 { 4*3, "r3" },
2235 { 4*4, "r4" },
2236 { 4*5, "r5" },
2237 { 4*6, "r6" },
2238 { 4*7, "r7" },
2239 { 4*8, "r8" },
2240 { 4*9, "r9" },
2241 { 4*10, "r10" },
2242 { 4*11, "r11" },
2243 { 4*12, "r12" },
2244 { 4*13, "r13" },
2245 { 4*14, "r14" },
2246 { 4*15, "r15" },
2247 { 4*16, "r16" },
2248 { 4*17, "r17" },
2249 { 4*18, "r18" },
2250 { 4*19, "r19" },
2251 { 4*20, "r20" },
2252 { 4*21, "r21" },
2253 { 4*22, "r22" },
2254 { 4*23, "r23" },
2255 { 4*24, "r24" },
2256 { 4*25, "r25" },
2257 { 4*26, "r26" },
2258 { 4*27, "r27" },
2259 { 4*28, "r28" },
2260 { 4*29, "r29" },
2261 { 4*30, "r30" },
2262 { 4*31, "r31" },
2263 { 4*32, "pc" },
2264 { 4*33, "sr" },
2265#endif
Chris Zankel8f636ed2013-03-25 10:22:07 -07002266#ifdef XTENSA
2267 { SYSCALL_NR, "syscall_nr" },
2268 { REG_AR_BASE, "ar0" },
2269 { REG_AR_BASE+1, "ar1" },
2270 { REG_AR_BASE+2, "ar2" },
2271 { REG_AR_BASE+3, "ar3" },
2272 { REG_AR_BASE+4, "ar4" },
2273 { REG_AR_BASE+5, "ar5" },
2274 { REG_AR_BASE+6, "ar6" },
2275 { REG_AR_BASE+7, "ar7" },
2276 { REG_AR_BASE+8, "ar8" },
2277 { REG_AR_BASE+9, "ar9" },
2278 { REG_AR_BASE+10, "ar10" },
2279 { REG_AR_BASE+11, "ar11" },
2280 { REG_AR_BASE+12, "ar12" },
2281 { REG_AR_BASE+13, "ar13" },
2282 { REG_AR_BASE+14, "ar14" },
2283 { REG_AR_BASE+15, "ar15" },
2284 { REG_AR_BASE+16, "ar16" },
2285 { REG_AR_BASE+17, "ar17" },
2286 { REG_AR_BASE+18, "ar18" },
2287 { REG_AR_BASE+19, "ar19" },
2288 { REG_AR_BASE+20, "ar20" },
2289 { REG_AR_BASE+21, "ar21" },
2290 { REG_AR_BASE+22, "ar22" },
2291 { REG_AR_BASE+23, "ar23" },
2292 { REG_AR_BASE+24, "ar24" },
2293 { REG_AR_BASE+25, "ar25" },
2294 { REG_AR_BASE+26, "ar26" },
2295 { REG_AR_BASE+27, "ar27" },
2296 { REG_AR_BASE+28, "ar28" },
2297 { REG_AR_BASE+29, "ar29" },
2298 { REG_AR_BASE+30, "ar30" },
2299 { REG_AR_BASE+31, "ar31" },
2300 { REG_AR_BASE+32, "ar32" },
2301 { REG_AR_BASE+33, "ar33" },
2302 { REG_AR_BASE+34, "ar34" },
2303 { REG_AR_BASE+35, "ar35" },
2304 { REG_AR_BASE+36, "ar36" },
2305 { REG_AR_BASE+37, "ar37" },
2306 { REG_AR_BASE+38, "ar38" },
2307 { REG_AR_BASE+39, "ar39" },
2308 { REG_AR_BASE+40, "ar40" },
2309 { REG_AR_BASE+41, "ar41" },
2310 { REG_AR_BASE+42, "ar42" },
2311 { REG_AR_BASE+43, "ar43" },
2312 { REG_AR_BASE+44, "ar44" },
2313 { REG_AR_BASE+45, "ar45" },
2314 { REG_AR_BASE+46, "ar46" },
2315 { REG_AR_BASE+47, "ar47" },
2316 { REG_AR_BASE+48, "ar48" },
2317 { REG_AR_BASE+49, "ar49" },
2318 { REG_AR_BASE+50, "ar50" },
2319 { REG_AR_BASE+51, "ar51" },
2320 { REG_AR_BASE+52, "ar52" },
2321 { REG_AR_BASE+53, "ar53" },
2322 { REG_AR_BASE+54, "ar54" },
2323 { REG_AR_BASE+55, "ar55" },
2324 { REG_AR_BASE+56, "ar56" },
2325 { REG_AR_BASE+57, "ar57" },
2326 { REG_AR_BASE+58, "ar58" },
2327 { REG_AR_BASE+59, "ar59" },
2328 { REG_AR_BASE+60, "ar60" },
2329 { REG_AR_BASE+61, "ar61" },
2330 { REG_AR_BASE+62, "ar62" },
2331 { REG_AR_BASE+63, "ar63" },
2332 { REG_LBEG, "lbeg" },
2333 { REG_LEND, "lend" },
2334 { REG_LCOUNT, "lcount" },
2335 { REG_SAR, "sar" },
2336 { REG_WB, "wb" },
2337 { REG_WS, "ws" },
2338 { REG_PS, "ps" },
2339 { REG_PC, "pc" },
2340 { REG_A_BASE, "a0" },
2341 { REG_A_BASE+1, "a1" },
2342 { REG_A_BASE+2, "a2" },
2343 { REG_A_BASE+3, "a3" },
2344 { REG_A_BASE+4, "a4" },
2345 { REG_A_BASE+5, "a5" },
2346 { REG_A_BASE+6, "a6" },
2347 { REG_A_BASE+7, "a7" },
2348 { REG_A_BASE+8, "a8" },
2349 { REG_A_BASE+9, "a9" },
2350 { REG_A_BASE+10, "a10" },
2351 { REG_A_BASE+11, "a11" },
2352 { REG_A_BASE+12, "a12" },
2353 { REG_A_BASE+13, "a13" },
2354 { REG_A_BASE+14, "a14" },
2355 { REG_A_BASE+15, "a15" },
2356#endif
2357
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002358 /* Other fields in "struct user" */
2359#if defined(S390) || defined(S390X)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002360 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2361 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2362 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002363 { uoff(start_code), "offsetof(struct user, start_code)" },
2364 /* S390[X] has no start_data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002365 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2366 { uoff(signal), "offsetof(struct user, signal)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002367 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002368 { uoff(magic), "offsetof(struct user, magic)" },
2369 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002370 { sizeof(struct user), "sizeof(struct user)" },
2371#elif defined(POWERPC)
2372 { sizeof(struct user), "sizeof(struct user)" },
2373#elif defined(I386) || defined(X86_64) || defined(X32)
2374 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2375 { uoff(i387), "offsetof(struct user, i387)" },
2376 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2377 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2378 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2379 { uoff(start_code), "offsetof(struct user, start_code)" },
2380 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2381 { uoff(signal), "offsetof(struct user, signal)" },
2382 { uoff(reserved), "offsetof(struct user, reserved)" },
2383 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2384 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2385 { uoff(magic), "offsetof(struct user, magic)" },
2386 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002387 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002388 { sizeof(struct user), "sizeof(struct user)" },
2389#elif defined(IA64)
2390 { sizeof(struct user), "sizeof(struct user)" },
2391#elif defined(ARM)
2392 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2393 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2394 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2395 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2396 { uoff(start_code), "offsetof(struct user, start_code)" },
2397 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2398 { uoff(signal), "offsetof(struct user, signal)" },
2399 { uoff(reserved), "offsetof(struct user, reserved)" },
2400 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2401 { uoff(magic), "offsetof(struct user, magic)" },
2402 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2403 { sizeof(struct user), "sizeof(struct user)" },
2404#elif defined(AARCH64)
2405 /* nothing */
2406#elif defined(M68K)
2407 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2408 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2409 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2410 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2411 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2412 { uoff(start_code), "offsetof(struct user, start_code)" },
2413 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2414 { uoff(signal), "offsetof(struct user, signal)" },
2415 { uoff(reserved), "offsetof(struct user, reserved)" },
2416 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2417 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2418 { uoff(magic), "offsetof(struct user, magic)" },
2419 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2420 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002421#elif defined(MIPS) || defined(LINUX_MIPSN32)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002422 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2423 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2424 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2425 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002426 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002427 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2428 { uoff(signal), "offsetof(struct user, signal)" },
2429 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2430 { uoff(magic), "offsetof(struct user, magic)" },
2431 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2432 { sizeof(struct user), "sizeof(struct user)" },
2433#elif defined(ALPHA)
2434 { sizeof(struct user), "sizeof(struct user)" },
2435#elif defined(SPARC)
2436 { sizeof(struct user), "sizeof(struct user)" },
2437#elif defined(SPARC64)
2438 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2439 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2440 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2441 { uoff(signal), "offsetof(struct user, signal)" },
2442 { uoff(magic), "offsetof(struct user, magic)" },
2443 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2444 { sizeof(struct user), "sizeof(struct user)" },
2445#elif defined(HPPA)
2446 /* nothing */
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002447#elif defined(SH) || defined(SH64)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002448 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2449 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2450 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2451 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2452 { uoff(start_code), "offsetof(struct user, start_code)" },
2453 { uoff(start_data), "offsetof(struct user, start_data)" },
2454 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2455 { uoff(signal), "offsetof(struct user, signal)" },
2456 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2457 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2458 { uoff(magic), "offsetof(struct user, magic)" },
2459 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2460 { sizeof(struct user), "sizeof(struct user)" },
2461#elif defined(CRISV10) || defined(CRISV32)
2462 { sizeof(struct user), "sizeof(struct user)" },
2463#elif defined(TILE)
2464 /* nothing */
2465#elif defined(MICROBLAZE)
2466 { sizeof(struct user), "sizeof(struct user)" },
2467#elif defined(AVR32)
2468 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2469 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2470 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2471 { uoff(start_code), "offsetof(struct user, start_code)" },
2472 { uoff(start_data), "offsetof(struct user, start_data)" },
2473 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2474 { uoff(signal), "offsetof(struct user, signal)" },
2475 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2476 { uoff(magic), "offsetof(struct user, magic)" },
2477 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2478 { sizeof(struct user), "sizeof(struct user)" },
2479#elif defined(BFIN)
2480 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2481 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2482 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2483 { uoff(start_code), "offsetof(struct user, start_code)" },
2484 { uoff(signal), "offsetof(struct user, signal)" },
2485 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2486 { uoff(magic), "offsetof(struct user, magic)" },
2487 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002488 { sizeof(struct user), "sizeof(struct user)" },
Christian Svensson492f81f2013-02-14 13:26:27 +01002489#elif defined(OR1K)
2490 /* nothing */
James Hogan5f999a82013-02-22 14:44:10 +00002491#elif defined(METAG)
2492 /* nothing */
Chris Zankel8f636ed2013-03-25 10:22:07 -07002493#elif defined(XTENSA)
2494 /* nothing */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002495#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002496 { 0, NULL },
2497};
2498
2499int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002500sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002501{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002502 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002503 long addr;
2504
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002505 if (entering(tcp)) {
Denys Vlasenkob7a6dae2012-03-20 16:48:35 +01002506 printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
Roland McGrathbf621d42003-01-14 09:46:21 +00002507 tprintf(", %lu, ", tcp->u_arg[1]);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002508
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002509 addr = tcp->u_arg[2];
2510 if (tcp->u_arg[0] == PTRACE_PEEKUSER
Denys Vlasenkobe994972013-02-13 16:10:10 +01002511 || tcp->u_arg[0] == PTRACE_POKEUSER
2512 ) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002513 for (x = struct_user_offsets; x->str; x++) {
2514 if (x->val >= addr)
2515 break;
2516 }
2517 if (!x->str)
2518 tprintf("%#lx, ", addr);
2519 else if (x->val > addr && x != struct_user_offsets) {
2520 x--;
2521 tprintf("%s + %ld, ", x->str, addr - x->val);
2522 }
2523 else
2524 tprintf("%s, ", x->str);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002525 } else
2526#ifdef PTRACE_GETREGSET
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00002527 if (tcp->u_arg[0] == PTRACE_GETREGSET
2528 || tcp->u_arg[0] == PTRACE_SETREGSET
2529 ) {
2530 printxval(nt_descriptor_types, tcp->u_arg[2], "NT_???");
2531 tprints(", ");
2532 } else
Denys Vlasenkobe994972013-02-13 16:10:10 +01002533#endif
2534 tprintf("%#lx, ", addr);
2535
2536
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002537 switch (tcp->u_arg[0]) {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002538#ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002539 case PTRACE_PEEKDATA:
2540 case PTRACE_PEEKTEXT:
2541 case PTRACE_PEEKUSER:
2542 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002543#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002544 case PTRACE_CONT:
2545 case PTRACE_SINGLESTEP:
2546 case PTRACE_SYSCALL:
2547 case PTRACE_DETACH:
2548 printsignal(tcp->u_arg[3]);
2549 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002550#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002551 case PTRACE_SETOPTIONS:
2552 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2553 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002554#endif
2555#ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002556 case PTRACE_SETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002557 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002558 break;
2559 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002560#endif
2561#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002562 case PTRACE_GETSIGINFO:
2563 /* Don't print anything, do it at syscall return. */
2564 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002565#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002566#ifdef PTRACE_GETREGSET
2567 case PTRACE_GETREGSET:
2568 break;
2569 case PTRACE_SETREGSET:
2570 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2571 break;
2572#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002573 default:
2574 tprintf("%#lx", tcp->u_arg[3]);
2575 break;
2576 }
2577 } else {
2578 switch (tcp->u_arg[0]) {
2579 case PTRACE_PEEKDATA:
2580 case PTRACE_PEEKTEXT:
2581 case PTRACE_PEEKUSER:
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002582#ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002583 return RVAL_HEX;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002584#else
Roland McGratheb285352003-01-14 09:59:00 +00002585 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002586 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002587#endif
2588#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002589 case PTRACE_GETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002590 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002591 break;
2592 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002593#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002594#ifdef PTRACE_GETREGSET
2595 case PTRACE_GETREGSET:
2596 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2597 break;
2598#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002599 }
2600 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002601 return 0;
2602}
2603
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002604#ifndef FUTEX_CMP_REQUEUE
2605# define FUTEX_CMP_REQUEUE 4
2606#endif
2607#ifndef FUTEX_WAKE_OP
2608# define FUTEX_WAKE_OP 5
2609#endif
2610#ifndef FUTEX_LOCK_PI
2611# define FUTEX_LOCK_PI 6
2612# define FUTEX_UNLOCK_PI 7
2613# define FUTEX_TRYLOCK_PI 8
2614#endif
2615#ifndef FUTEX_WAIT_BITSET
2616# define FUTEX_WAIT_BITSET 9
2617#endif
2618#ifndef FUTEX_WAKE_BITSET
2619# define FUTEX_WAKE_BITSET 10
2620#endif
2621#ifndef FUTEX_WAIT_REQUEUE_PI
2622# define FUTEX_WAIT_REQUEUE_PI 11
2623#endif
2624#ifndef FUTEX_CMP_REQUEUE_PI
2625# define FUTEX_CMP_REQUEUE_PI 12
2626#endif
2627#ifndef FUTEX_PRIVATE_FLAG
2628# define FUTEX_PRIVATE_FLAG 128
2629#endif
2630#ifndef FUTEX_CLOCK_REALTIME
2631# define FUTEX_CLOCK_REALTIME 256
2632#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002633static const struct xlat futexops[] = {
Roland McGrath51942a92007-07-05 18:59:11 +00002634 { FUTEX_WAIT, "FUTEX_WAIT" },
2635 { FUTEX_WAKE, "FUTEX_WAKE" },
2636 { FUTEX_FD, "FUTEX_FD" },
2637 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2638 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2639 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2640 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2641 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2642 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002643 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2644 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002645 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2646 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
Roland McGrath51942a92007-07-05 18:59:11 +00002647 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2648 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2649 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2650 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2651 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2652 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2653 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2654 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2655 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002656 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2657 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002658 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2659 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2660 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2661 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2662 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2663 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI_PRIVATE|FUTEX_CLOCK_REALTIME" },
Roland McGrath51942a92007-07-05 18:59:11 +00002664 { 0, NULL }
2665};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002666#ifndef FUTEX_OP_SET
2667# define FUTEX_OP_SET 0
2668# define FUTEX_OP_ADD 1
2669# define FUTEX_OP_OR 2
2670# define FUTEX_OP_ANDN 3
2671# define FUTEX_OP_XOR 4
2672# define FUTEX_OP_CMP_EQ 0
2673# define FUTEX_OP_CMP_NE 1
2674# define FUTEX_OP_CMP_LT 2
2675# define FUTEX_OP_CMP_LE 3
2676# define FUTEX_OP_CMP_GT 4
2677# define FUTEX_OP_CMP_GE 5
2678#endif
Roland McGrath51942a92007-07-05 18:59:11 +00002679static const struct xlat futexwakeops[] = {
2680 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2681 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2682 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2683 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2684 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2685 { 0, NULL }
2686};
2687static const struct xlat futexwakecmps[] = {
2688 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2689 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2690 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2691 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2692 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2693 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2694 { 0, NULL }
Roland McGrath5a223472002-12-15 23:58:26 +00002695};
2696
2697int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002698sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002699{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002700 if (entering(tcp)) {
2701 long int cmd = tcp->u_arg[1] & 127;
2702 tprintf("%p, ", (void *) tcp->u_arg[0]);
2703 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2704 tprintf(", %ld", tcp->u_arg[2]);
2705 if (cmd == FUTEX_WAKE_BITSET)
2706 tprintf(", %lx", tcp->u_arg[5]);
2707 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002708 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002709 printtv(tcp, tcp->u_arg[3]);
2710 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002711 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002712 printtv(tcp, tcp->u_arg[3]);
2713 tprintf(", %lx", tcp->u_arg[5]);
2714 } else if (cmd == FUTEX_REQUEUE)
2715 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002716 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002717 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2718 else if (cmd == FUTEX_WAKE_OP) {
2719 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2720 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002721 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002722 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2723 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2724 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002725 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002726 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2727 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002728 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002729 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002730 printtv(tcp, tcp->u_arg[3]);
2731 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002732 }
Roland McGrath51942a92007-07-05 18:59:11 +00002733 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002734 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002735}
2736
2737static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002738print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002739{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002740 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002741 unsigned long w, min_len;
2742
2743 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2744 min_len = len - max_strlen * sizeof(w);
2745 else
2746 min_len = 0;
2747 for (; len >= sizeof(w) && len > min_len;
2748 len -= sizeof(w), list += sizeof(w)) {
2749 if (umove(tcp, list, &w) < 0)
2750 break;
2751 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002752 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002753 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002754 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002755 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002756 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002757 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002758 if (len) {
2759 if (first)
2760 tprintf("%#lx", list);
2761 else
2762 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2763 "???" : "..."));
2764 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002765 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002766 }
Roland McGrath5a223472002-12-15 23:58:26 +00002767}
2768
2769int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002770sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002771{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002772 if (entering(tcp)) {
2773 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2774 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2775 }
2776 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002777}
2778
2779int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002780sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002781{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002782 if (entering(tcp)) {
2783 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2784 } else {
2785 if (tcp->u_rval == -1)
2786 tprintf("%#lx", tcp->u_arg[2]);
2787 else
2788 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2789 }
2790 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002791}
Roland McGrath279d3782004-03-01 20:27:37 +00002792
Dmitry V. Levin1b0bae22012-03-11 22:32:26 +00002793int
2794sys_get_robust_list(struct tcb *tcp)
2795{
2796 if (entering(tcp)) {
2797 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2798 } else {
2799 void *addr;
2800 size_t len;
2801
2802 if (syserror(tcp) ||
2803 !tcp->u_arg[1] ||
2804 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2805 tprintf("%#lx, ", tcp->u_arg[1]);
2806 } else {
2807 tprintf("[%p], ", addr);
2808 }
2809
2810 if (syserror(tcp) ||
2811 !tcp->u_arg[2] ||
2812 umove(tcp, tcp->u_arg[2], &len) < 0) {
2813 tprintf("%#lx", tcp->u_arg[2]);
2814 } else {
2815 tprintf("[%lu]", (unsigned long) len);
2816 }
2817 }
2818 return 0;
2819}
2820
Roland McGrathd9f816f2004-09-04 03:39:20 +00002821static const struct xlat schedulers[] = {
Roland McGrath279d3782004-03-01 20:27:37 +00002822 { SCHED_OTHER, "SCHED_OTHER" },
2823 { SCHED_RR, "SCHED_RR" },
2824 { SCHED_FIFO, "SCHED_FIFO" },
2825 { 0, NULL }
2826};
2827
2828int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002829sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002830{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002831 if (entering(tcp)) {
2832 tprintf("%d", (int) tcp->u_arg[0]);
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002833 } else if (!syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002834 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002835 if (tcp->auxstr != NULL)
2836 return RVAL_STR;
2837 }
2838 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002839}
2840
2841int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002842sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002843{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002844 if (entering(tcp)) {
2845 struct sched_param p;
2846 tprintf("%d, ", (int) tcp->u_arg[0]);
2847 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2848 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2849 tprintf(", %#lx", tcp->u_arg[2]);
2850 else
2851 tprintf(", { %d }", p.__sched_priority);
2852 }
2853 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002854}
2855
2856int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002857sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002858{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002859 if (entering(tcp)) {
2860 tprintf("%d, ", (int) tcp->u_arg[0]);
2861 } else {
2862 struct sched_param p;
2863 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2864 tprintf("%#lx", tcp->u_arg[1]);
2865 else
2866 tprintf("{ %d }", p.__sched_priority);
2867 }
2868 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002869}
2870
2871int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002872sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002873{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002874 if (entering(tcp)) {
2875 struct sched_param p;
2876 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2877 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2878 else
2879 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2880 }
2881 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002882}
2883
2884int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002885sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002886{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002887 if (entering(tcp)) {
2888 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2889 }
2890 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002891}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002892
Dmitry V. Levin1ff463d2012-03-11 23:00:11 +00002893int
2894sys_sched_rr_get_interval(struct tcb *tcp)
2895{
2896 if (entering(tcp)) {
2897 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2898 } else {
2899 if (syserror(tcp))
2900 tprintf("%#lx", tcp->u_arg[1]);
2901 else
2902 print_timespec(tcp, tcp->u_arg[1]);
2903 }
2904 return 0;
2905}
2906
H.J. Lu35be5812012-04-16 13:00:01 +02002907#if defined X86_64 || defined X32
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002908# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002909
2910static const struct xlat archvals[] = {
2911 { ARCH_SET_GS, "ARCH_SET_GS" },
2912 { ARCH_SET_FS, "ARCH_SET_FS" },
2913 { ARCH_GET_FS, "ARCH_GET_FS" },
2914 { ARCH_GET_GS, "ARCH_GET_GS" },
2915 { 0, NULL },
2916};
2917
2918int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002919sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002920{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002921 if (entering(tcp)) {
2922 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2923 if (tcp->u_arg[0] == ARCH_SET_GS
2924 || tcp->u_arg[0] == ARCH_SET_FS
2925 ) {
2926 tprintf(", %#lx", tcp->u_arg[1]);
2927 }
2928 } else {
2929 if (tcp->u_arg[0] == ARCH_GET_GS
2930 || tcp->u_arg[0] == ARCH_GET_FS
2931 ) {
2932 long int v;
2933 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2934 tprintf(", [%#lx]", v);
2935 else
2936 tprintf(", %#lx", tcp->u_arg[1]);
2937 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002938 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002939 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002940}
H.J. Lu35be5812012-04-16 13:00:01 +02002941#endif /* X86_64 || X32 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002942
Roland McGrathdb8319f2007-08-02 01:37:55 +00002943int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002944sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002945{
2946 if (exiting(tcp)) {
2947 unsigned u;
2948 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002949 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002950 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2951 tprintf("%#lx, ", tcp->u_arg[0]);
2952 else
2953 tprintf("[%u], ", u);
2954 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002955 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002956 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2957 tprintf("%#lx, ", tcp->u_arg[1]);
2958 else
2959 tprintf("[%u], ", u);
2960 tprintf("%#lx", tcp->u_arg[2]);
2961 }
2962 return 0;
2963}
2964
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002965int
2966sys_process_vm_readv(struct tcb *tcp)
2967{
2968 if (entering(tcp)) {
2969 /* arg 1: pid */
2970 tprintf("%ld, ", tcp->u_arg[0]);
2971 } else {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002972 /* arg 2: local iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002973 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002974 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002975 } else {
2976 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2977 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002978 /* arg 3: local iovcnt */
2979 tprintf(", %lu, ", tcp->u_arg[2]);
2980 /* arg 4: remote iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002981 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002982 tprintf("%#lx", tcp->u_arg[3]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002983 } else {
2984 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2985 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002986 /* arg 5: remote iovcnt */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002987 /* arg 6: flags */
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002988 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002989 }
2990 return 0;
2991}
Dmitry V. Levin03952102012-03-10 14:14:49 +00002992
2993int
2994sys_process_vm_writev(struct tcb *tcp)
2995{
2996 if (entering(tcp)) {
2997 /* arg 1: pid */
2998 tprintf("%ld, ", tcp->u_arg[0]);
2999 /* arg 2: local iov */
3000 if (syserror(tcp))
3001 tprintf("%#lx", tcp->u_arg[1]);
3002 else
3003 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
3004 /* arg 3: local iovcnt */
3005 tprintf(", %lu, ", tcp->u_arg[2]);
3006 /* arg 4: remote iov */
3007 if (syserror(tcp))
3008 tprintf("%#lx", tcp->u_arg[3]);
3009 else
3010 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
3011 /* arg 5: remote iovcnt */
3012 /* arg 6: flags */
3013 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
3014 }
3015 return 0;
3016}