blob: 2c619e7fe9abed81199097b42fa6c75c42f99d05 [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
Dmitry V. Levin7a0fb382013-05-13 18:34:15 +0000262#ifdef PR_SET_PTRACER
263 { PR_SET_PTRACER, "PR_SET_PTRACER" },
264#endif
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000265#ifdef PR_SET_CHILD_SUBREAPER
266 { PR_SET_CHILD_SUBREAPER, "PR_SET_CHILD_SUBREAPER" },
267#endif
268#ifdef PR_GET_CHILD_SUBREAPER
269 { PR_GET_CHILD_SUBREAPER, "PR_GET_CHILD_SUBREAPER" },
270#endif
271#ifdef PR_SET_NO_NEW_PRIVS
272 { PR_SET_NO_NEW_PRIVS, "PR_SET_NO_NEW_PRIVS" },
273#endif
274#ifdef PR_GET_NO_NEW_PRIVS
275 { PR_GET_NO_NEW_PRIVS, "PR_GET_NO_NEW_PRIVS" },
276#endif
277#ifdef PR_GET_TID_ADDRESS
278 { PR_GET_TID_ADDRESS, "PR_GET_TID_ADDRESS" },
279#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000280 { 0, NULL },
281};
282
Roland McGratha4d48532005-06-08 20:45:28 +0000283static const char *
Denys Vlasenko12014262011-05-30 14:00:14 +0200284unalignctl_string(unsigned int ctl)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000285{
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100286 static char buf[sizeof(int)*2 + 2];
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000287
288 switch (ctl) {
289#ifdef PR_UNALIGN_NOPRINT
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100290 case PR_UNALIGN_NOPRINT:
291 return "NOPRINT";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000292#endif
293#ifdef PR_UNALIGN_SIGBUS
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100294 case PR_UNALIGN_SIGBUS:
295 return "SIGBUS";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000296#endif
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100297 default:
298 break;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000299 }
300 sprintf(buf, "%x", ctl);
301 return buf;
302}
303
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000304int
Denys Vlasenko12014262011-05-30 14:00:14 +0200305sys_prctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000306{
307 int i;
308
309 if (entering(tcp)) {
310 printxval(prctl_options, tcp->u_arg[0], "PR_???");
311 switch (tcp->u_arg[0]) {
312#ifdef PR_GETNSHARE
313 case PR_GETNSHARE:
314 break;
315#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000316#ifdef PR_SET_PDEATHSIG
317 case PR_SET_PDEATHSIG:
318 tprintf(", %lu", tcp->u_arg[1]);
319 break;
320#endif
321#ifdef PR_GET_PDEATHSIG
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000322 case PR_GET_PDEATHSIG:
323 break;
324#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000325#ifdef PR_SET_DUMPABLE
326 case PR_SET_DUMPABLE:
327 tprintf(", %lu", tcp->u_arg[1]);
328 break;
329#endif
330#ifdef PR_GET_DUMPABLE
331 case PR_GET_DUMPABLE:
332 break;
333#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000334#ifdef PR_SET_UNALIGN
335 case PR_SET_UNALIGN:
336 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
337 break;
338#endif
339#ifdef PR_GET_UNALIGN
340 case PR_GET_UNALIGN:
341 tprintf(", %#lx", tcp->u_arg[1]);
342 break;
343#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000344#ifdef PR_SET_KEEPCAPS
345 case PR_SET_KEEPCAPS:
346 tprintf(", %lu", tcp->u_arg[1]);
347 break;
348#endif
349#ifdef PR_GET_KEEPCAPS
350 case PR_GET_KEEPCAPS:
351 break;
352#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000353 default:
Denys Vlasenko74ec14f2013-02-21 16:13:47 +0100354 for (i = 1; i < tcp->s_ent->nargs; i++)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000355 tprintf(", %#lx", tcp->u_arg[i]);
356 break;
357 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000358 } else {
359 switch (tcp->u_arg[0]) {
360#ifdef PR_GET_PDEATHSIG
361 case PR_GET_PDEATHSIG:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000362 if (umove(tcp, tcp->u_arg[1], &i) < 0)
363 tprintf(", %#lx", tcp->u_arg[1]);
364 else
365 tprintf(", {%u}", i);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000366 break;
367#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000368#ifdef PR_GET_DUMPABLE
369 case PR_GET_DUMPABLE:
370 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000371#endif
372#ifdef PR_GET_UNALIGN
373 case PR_GET_UNALIGN:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000374 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
375 break;
376 tcp->auxstr = unalignctl_string(i);
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000377 return RVAL_STR;
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000378#endif
379#ifdef PR_GET_KEEPCAPS
380 case PR_GET_KEEPCAPS:
381 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000382#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000383 default:
384 break;
385 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000386 }
387 return 0;
388}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000389#endif /* HAVE_PRCTL */
390
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000391int
Denys Vlasenko12014262011-05-30 14:00:14 +0200392sys_sethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000393{
394 if (entering(tcp)) {
395 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
396 tprintf(", %lu", tcp->u_arg[1]);
397 }
398 return 0;
399}
400
Denys Vlasenko84703742012-02-25 02:38:52 +0100401#if defined(ALPHA)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000402int
Denys Vlasenko12014262011-05-30 14:00:14 +0200403sys_gethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000404{
405 if (exiting(tcp)) {
406 if (syserror(tcp))
407 tprintf("%#lx", tcp->u_arg[0]);
408 else
409 printpath(tcp, tcp->u_arg[0]);
410 tprintf(", %lu", tcp->u_arg[1]);
411 }
412 return 0;
413}
Denys Vlasenko84703742012-02-25 02:38:52 +0100414#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000415
416int
Denys Vlasenko12014262011-05-30 14:00:14 +0200417sys_setdomainname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000418{
419 if (entering(tcp)) {
420 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
421 tprintf(", %lu", tcp->u_arg[1]);
422 }
423 return 0;
424}
425
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000426int
Denys Vlasenko12014262011-05-30 14:00:14 +0200427sys_exit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000428{
429 if (exiting(tcp)) {
430 fprintf(stderr, "_exit returned!\n");
431 return -1;
432 }
433 /* special case: we stop tracing this process, finish line now */
434 tprintf("%ld) ", tcp->u_arg[0]);
Denys Vlasenko102ec492011-08-25 01:27:59 +0200435 tabto();
Denys Vlasenko000b6012012-01-28 01:25:03 +0100436 tprints("= ?\n");
Denys Vlasenko7de265d2012-03-13 11:44:31 +0100437 line_ended();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000438 return 0;
439}
440
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000441/* defines copied from linux/sched.h since we can't include that
442 * ourselves (it conflicts with *lots* of libc includes)
443 */
444#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
445#define CLONE_VM 0x00000100 /* set if VM shared between processes */
446#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
447#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
448#define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
Roland McGrath909875b2002-12-22 03:34:36 +0000449#define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000450#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
451#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
452#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
Roland McGrath909875b2002-12-22 03:34:36 +0000453#define CLONE_THREAD 0x00010000 /* Same thread group? */
454#define CLONE_NEWNS 0x00020000 /* New namespace group? */
455#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
456#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
457#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
458#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
Roland McGrath909875b2002-12-22 03:34:36 +0000459#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
460#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000461#define CLONE_STOPPED 0x02000000 /* Start in stopped state */
462#define CLONE_NEWUTS 0x04000000 /* New utsname group? */
463#define CLONE_NEWIPC 0x08000000 /* New ipcs */
464#define CLONE_NEWUSER 0x10000000 /* New user namespace */
465#define CLONE_NEWPID 0x20000000 /* New pid namespace */
466#define CLONE_NEWNET 0x40000000 /* New network namespace */
467#define CLONE_IO 0x80000000 /* Clone io context */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000468
Roland McGrathd9f816f2004-09-04 03:39:20 +0000469static const struct xlat clone_flags[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100470 { CLONE_VM, "CLONE_VM" },
471 { CLONE_FS, "CLONE_FS" },
472 { CLONE_FILES, "CLONE_FILES" },
473 { CLONE_SIGHAND, "CLONE_SIGHAND" },
474 { CLONE_IDLETASK, "CLONE_IDLETASK" },
475 { CLONE_PTRACE, "CLONE_PTRACE" },
476 { CLONE_VFORK, "CLONE_VFORK" },
477 { CLONE_PARENT, "CLONE_PARENT" },
478 { CLONE_THREAD, "CLONE_THREAD" },
479 { CLONE_NEWNS, "CLONE_NEWNS" },
480 { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
481 { CLONE_SETTLS, "CLONE_SETTLS" },
482 { CLONE_PARENT_SETTID, "CLONE_PARENT_SETTID" },
483 { CLONE_CHILD_CLEARTID, "CLONE_CHILD_CLEARTID" },
484 { CLONE_UNTRACED, "CLONE_UNTRACED" },
485 { CLONE_CHILD_SETTID, "CLONE_CHILD_SETTID" },
486 { CLONE_STOPPED, "CLONE_STOPPED" },
487 { CLONE_NEWUTS, "CLONE_NEWUTS" },
488 { CLONE_NEWIPC, "CLONE_NEWIPC" },
489 { CLONE_NEWUSER, "CLONE_NEWUSER" },
490 { CLONE_NEWPID, "CLONE_NEWPID" },
491 { CLONE_NEWNET, "CLONE_NEWNET" },
492 { CLONE_IO, "CLONE_IO" },
493 { 0, NULL },
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000494};
495
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100496#ifdef I386
497# include <asm/ldt.h>
498# ifdef HAVE_STRUCT_USER_DESC
499# define modify_ldt_ldt_s user_desc
500# endif
Roland McGrath909875b2002-12-22 03:34:36 +0000501extern void print_ldt_entry();
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100502#endif
Roland McGrath909875b2002-12-22 03:34:36 +0000503
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100504#if defined IA64
505# define ARG_FLAGS 0
506# define ARG_STACK 1
507# define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
508# define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
509# define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
510# define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
511#elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
512# define ARG_STACK 0
513# define ARG_FLAGS 1
514# define ARG_PTID 2
515# define ARG_CTID 3
516# define ARG_TLS 4
Christian Svensson492f81f2013-02-14 13:26:27 +0100517#elif defined X86_64 || defined X32 || defined ALPHA || defined TILE \
518 || defined OR1K
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100519# define ARG_FLAGS 0
520# define ARG_STACK 1
521# define ARG_PTID 2
522# define ARG_CTID 3
523# define ARG_TLS 4
524#else
525# define ARG_FLAGS 0
526# define ARG_STACK 1
527# define ARG_PTID 2
528# define ARG_TLS 3
529# define ARG_CTID 4
530#endif
Roland McGrath9677b3a2003-03-12 09:54:36 +0000531
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000532int
Denys Vlasenko12014262011-05-30 14:00:14 +0200533sys_clone(struct tcb *tcp)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000534{
535 if (exiting(tcp)) {
Wang Chaocbdd1902010-09-02 15:08:59 +0800536 const char *sep = "|";
Roland McGrath9677b3a2003-03-12 09:54:36 +0000537 unsigned long flags = tcp->u_arg[ARG_FLAGS];
538 tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100539#ifdef ARG_STACKSIZE
Roland McGrath9677b3a2003-03-12 09:54:36 +0000540 if (ARG_STACKSIZE != -1)
541 tprintf("stack_size=%#lx, ",
542 tcp->u_arg[ARG_STACKSIZE]);
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100543#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200544 tprints("flags=");
Wang Chaocbdd1902010-09-02 15:08:59 +0800545 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
546 sep = "";
Roland McGrath984154d2003-05-23 01:08:42 +0000547 if ((flags & CSIGNAL) != 0)
Wang Chaocbdd1902010-09-02 15:08:59 +0800548 tprintf("%s%s", sep, signame(flags & CSIGNAL));
Roland McGrathb4968be2003-01-20 09:04:33 +0000549 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
Roland McGrath9677b3a2003-03-12 09:54:36 +0000550 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
Roland McGrath909875b2002-12-22 03:34:36 +0000551 return 0;
Roland McGrath6f67a982003-03-21 07:33:15 +0000552 if (flags & CLONE_PARENT_SETTID)
553 tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
Roland McGrathb4968be2003-01-20 09:04:33 +0000554 if (flags & CLONE_SETTLS) {
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100555#ifdef I386
Roland McGrath909875b2002-12-22 03:34:36 +0000556 struct modify_ldt_ldt_s copy;
Roland McGrath9677b3a2003-03-12 09:54:36 +0000557 if (umove(tcp, tcp->u_arg[ARG_TLS], &copy) != -1) {
Roland McGrath909875b2002-12-22 03:34:36 +0000558 tprintf(", {entry_number:%d, ",
559 copy.entry_number);
560 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200561 tprints("...}");
Roland McGrath909875b2002-12-22 03:34:36 +0000562 else
563 print_ldt_entry(&copy);
564 }
565 else
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100566#endif
Roland McGrath43f2c842003-03-12 09:58:14 +0000567 tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
Roland McGrath909875b2002-12-22 03:34:36 +0000568 }
Roland McGrath9677b3a2003-03-12 09:54:36 +0000569 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
570 tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000571 }
572 return 0;
573}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000574
575int
576sys_unshare(struct tcb *tcp)
577{
578 if (entering(tcp))
579 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
580 return 0;
581}
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000582
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000583int
Denys Vlasenko081533c2012-03-17 02:17:51 +0100584sys_fork(struct tcb *tcp)
585{
586 if (exiting(tcp))
587 return RVAL_UDECIMAL;
588 return 0;
589}
590
591int
Denys Vlasenko12014262011-05-30 14:00:14 +0200592sys_vfork(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000593{
594 if (exiting(tcp))
595 return RVAL_UDECIMAL;
596 return 0;
597}
598
Dmitry V. Levin50a218d2011-01-18 17:36:20 +0000599int sys_getuid(struct tcb *tcp)
600{
601 if (exiting(tcp))
602 tcp->u_rval = (uid_t) tcp->u_rval;
603 return RVAL_UDECIMAL;
604}
605
606int sys_setfsuid(struct tcb *tcp)
607{
608 if (entering(tcp))
609 tprintf("%u", (uid_t) tcp->u_arg[0]);
610 else
611 tcp->u_rval = (uid_t) tcp->u_rval;
612 return RVAL_UDECIMAL;
613}
614
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000615int
Denys Vlasenko12014262011-05-30 14:00:14 +0200616sys_setuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000617{
618 if (entering(tcp)) {
619 tprintf("%u", (uid_t) tcp->u_arg[0]);
620 }
621 return 0;
622}
623
624int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000625sys_getresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000626{
627 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000628 __kernel_uid_t uid;
629 if (syserror(tcp))
630 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
631 tcp->u_arg[1], tcp->u_arg[2]);
632 else {
633 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
634 tprintf("%#lx, ", tcp->u_arg[0]);
635 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000636 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000637 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
638 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000639 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000640 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000641 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
642 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000643 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000644 tprintf("[%lu]", (unsigned long) uid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000645 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000646 }
647 return 0;
648}
649
650int
Denys Vlasenko12014262011-05-30 14:00:14 +0200651sys_setreuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000652{
653 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000654 printuid("", tcp->u_arg[0]);
655 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000656 }
657 return 0;
658}
659
660int
Denys Vlasenko12014262011-05-30 14:00:14 +0200661sys_setresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000662{
663 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000664 printuid("", tcp->u_arg[0]);
665 printuid(", ", tcp->u_arg[1]);
666 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000667 }
668 return 0;
669}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000670
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000671int
Denys Vlasenko12014262011-05-30 14:00:14 +0200672sys_setgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000673{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000674 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000675 unsigned long len, size, start, cur, end, abbrev_end;
676 GETGROUPS_T gid;
677 int failed = 0;
678
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000679 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000680 tprintf("%lu, ", len);
681 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200682 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000683 return 0;
684 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000685 start = tcp->u_arg[1];
686 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200687 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000688 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000689 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000690 size = len * sizeof(gid);
691 end = start + size;
692 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
693 tprintf("%#lx", start);
694 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000695 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000696 if (abbrev(tcp)) {
697 abbrev_end = start + max_strlen * sizeof(gid);
698 if (abbrev_end < start)
699 abbrev_end = end;
700 } else {
701 abbrev_end = end;
702 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200703 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000704 for (cur = start; cur < end; cur += sizeof(gid)) {
705 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200706 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000707 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200708 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000709 break;
710 }
711 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200712 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000713 failed = 1;
714 break;
715 }
716 tprintf("%lu", (unsigned long) gid);
717 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200718 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000719 if (failed)
720 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000721 }
722 return 0;
723}
724
725int
Denys Vlasenko12014262011-05-30 14:00:14 +0200726sys_getgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000727{
Roland McGrathaa524c82005-06-01 19:22:06 +0000728 unsigned long len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000729
730 if (entering(tcp)) {
731 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000732 tprintf("%lu, ", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000733 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000734 unsigned long size, start, cur, end, abbrev_end;
735 GETGROUPS_T gid;
736 int failed = 0;
737
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000738 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000739 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200740 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000741 return 0;
742 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000743 start = tcp->u_arg[1];
744 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200745 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000746 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000747 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000748 if (tcp->u_arg[0] == 0) {
749 tprintf("%#lx", start);
750 return 0;
751 }
752 size = len * sizeof(gid);
753 end = start + size;
754 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
755 size / sizeof(gid) != len || end < start) {
756 tprintf("%#lx", start);
757 return 0;
758 }
759 if (abbrev(tcp)) {
760 abbrev_end = start + max_strlen * sizeof(gid);
761 if (abbrev_end < start)
762 abbrev_end = end;
763 } else {
764 abbrev_end = end;
765 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200766 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000767 for (cur = start; cur < end; cur += sizeof(gid)) {
768 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200769 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000770 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200771 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000772 break;
773 }
774 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200775 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000776 failed = 1;
777 break;
778 }
779 tprintf("%lu", (unsigned long) gid);
780 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200781 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000782 if (failed)
783 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000784 }
785 return 0;
786}
787
Roland McGrath83bd47a2003-11-13 22:32:26 +0000788int
Denys Vlasenko12014262011-05-30 14:00:14 +0200789sys_setgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000790{
Roland McGrath83bd47a2003-11-13 22:32:26 +0000791 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000792 unsigned long len, size, start, cur, end, abbrev_end;
793 GETGROUPS32_T gid;
794 int failed = 0;
795
Roland McGrath83bd47a2003-11-13 22:32:26 +0000796 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000797 tprintf("%lu, ", len);
798 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200799 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000800 return 0;
801 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000802 start = tcp->u_arg[1];
803 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200804 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000805 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000806 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000807 size = len * sizeof(gid);
808 end = start + size;
809 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
810 tprintf("%#lx", start);
811 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000812 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000813 if (abbrev(tcp)) {
814 abbrev_end = start + max_strlen * sizeof(gid);
815 if (abbrev_end < start)
816 abbrev_end = end;
817 } else {
818 abbrev_end = end;
819 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200820 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000821 for (cur = start; cur < end; cur += sizeof(gid)) {
822 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200823 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000824 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200825 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000826 break;
827 }
828 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200829 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000830 failed = 1;
831 break;
832 }
833 tprintf("%lu", (unsigned long) gid);
834 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200835 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000836 if (failed)
837 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000838 }
839 return 0;
840}
841
842int
Denys Vlasenko12014262011-05-30 14:00:14 +0200843sys_getgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000844{
Roland McGrathaa524c82005-06-01 19:22:06 +0000845 unsigned long len;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000846
847 if (entering(tcp)) {
848 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000849 tprintf("%lu, ", len);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000850 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000851 unsigned long size, start, cur, end, abbrev_end;
852 GETGROUPS32_T gid;
853 int failed = 0;
854
Roland McGrath83bd47a2003-11-13 22:32:26 +0000855 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000856 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200857 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000858 return 0;
859 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000860 start = tcp->u_arg[1];
861 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200862 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000863 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000864 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000865 size = len * sizeof(gid);
866 end = start + size;
867 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
868 size / sizeof(gid) != len || end < start) {
869 tprintf("%#lx", start);
870 return 0;
871 }
872 if (abbrev(tcp)) {
873 abbrev_end = start + max_strlen * sizeof(gid);
874 if (abbrev_end < start)
875 abbrev_end = end;
876 } else {
877 abbrev_end = end;
878 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200879 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000880 for (cur = start; cur < end; cur += sizeof(gid)) {
881 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200882 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000883 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200884 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000885 break;
886 }
887 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200888 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000889 failed = 1;
890 break;
891 }
892 tprintf("%lu", (unsigned long) gid);
893 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200894 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000895 if (failed)
896 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000897 }
898 return 0;
899}
Roland McGrath83bd47a2003-11-13 22:32:26 +0000900
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000901static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000902printargv(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000903{
Roland McGrath85a3bc42007-08-02 02:13:05 +0000904 union {
Andreas Schwab99c85692009-08-28 19:36:20 +0200905 unsigned int p32;
906 unsigned long p64;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000907 char data[sizeof(long)];
908 } cp;
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000909 const char *sep;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000910 int n = 0;
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100911 unsigned wordsize = current_wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000912
Roland McGrath85a3bc42007-08-02 02:13:05 +0000913 cp.p64 = 1;
914 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100915 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000916 tprintf("%#lx", addr);
917 return;
918 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100919 if (wordsize == 4)
Roland McGrath85a3bc42007-08-02 02:13:05 +0000920 cp.p64 = cp.p32;
921 if (cp.p64 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000922 break;
Denys Vlasenko5940e652011-09-01 09:55:05 +0200923 tprints(sep);
Roland McGrath85a3bc42007-08-02 02:13:05 +0000924 printstr(tcp, cp.p64, -1);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100925 addr += wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000926 }
Roland McGrath85a3bc42007-08-02 02:13:05 +0000927 if (cp.p64)
928 tprintf("%s...", sep);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000929}
930
931static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000932printargc(const char *fmt, struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000933{
934 int count;
935 char *cp;
936
937 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
938 addr += sizeof(char *);
939 }
940 tprintf(fmt, count, count == 1 ? "" : "s");
941}
942
Denys Vlasenko84703742012-02-25 02:38:52 +0100943#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000944int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000945sys_execv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000946{
947 if (entering(tcp)) {
948 printpath(tcp, tcp->u_arg[0]);
949 if (!verbose(tcp))
950 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000951 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200952 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000953 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200954 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000955 }
956 }
957 return 0;
958}
Denys Vlasenko84703742012-02-25 02:38:52 +0100959#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000960
961int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000962sys_execve(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000963{
964 if (entering(tcp)) {
965 printpath(tcp, tcp->u_arg[0]);
966 if (!verbose(tcp))
967 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000968 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200969 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000970 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200971 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000972 }
973 if (!verbose(tcp))
974 tprintf(", %#lx", tcp->u_arg[2]);
975 else if (abbrev(tcp))
976 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
977 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200978 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000979 printargv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200980 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000981 }
982 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000983 return 0;
984}
985
Roland McGrath7ec1d352002-12-17 04:50:44 +0000986#ifndef __WNOTHREAD
987#define __WNOTHREAD 0x20000000
988#endif
989#ifndef __WALL
990#define __WALL 0x40000000
991#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000992#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +0000993#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000994#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000995
Roland McGrathd9f816f2004-09-04 03:39:20 +0000996static const struct xlat wait4_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000997 { WNOHANG, "WNOHANG" },
998#ifndef WSTOPPED
999 { WUNTRACED, "WUNTRACED" },
1000#endif
1001#ifdef WEXITED
1002 { WEXITED, "WEXITED" },
1003#endif
1004#ifdef WTRAPPED
1005 { WTRAPPED, "WTRAPPED" },
1006#endif
1007#ifdef WSTOPPED
1008 { WSTOPPED, "WSTOPPED" },
1009#endif
1010#ifdef WCONTINUED
1011 { WCONTINUED, "WCONTINUED" },
1012#endif
1013#ifdef WNOWAIT
1014 { WNOWAIT, "WNOWAIT" },
1015#endif
1016#ifdef __WCLONE
1017 { __WCLONE, "__WCLONE" },
1018#endif
Roland McGrath7ec1d352002-12-17 04:50:44 +00001019#ifdef __WALL
1020 { __WALL, "__WALL" },
1021#endif
1022#ifdef __WNOTHREAD
1023 { __WNOTHREAD, "__WNOTHREAD" },
1024#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001025 { 0, NULL },
1026};
1027
Roland McGrath5e02a572004-10-19 23:33:47 +00001028#if !defined WCOREFLAG && defined WCOREFLG
1029# define WCOREFLAG WCOREFLG
1030#endif
1031#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001032# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +00001033#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001034#ifndef WCOREDUMP
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001035# define WCOREDUMP(status) ((status) & 0200)
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001036#endif
Roland McGrath5e02a572004-10-19 23:33:47 +00001037#ifndef W_STOPCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001038# define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
Roland McGrath5e02a572004-10-19 23:33:47 +00001039#endif
1040#ifndef W_EXITCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001041# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
Roland McGrath5e02a572004-10-19 23:33:47 +00001042#endif
1043
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001044static int
Denys Vlasenko12014262011-05-30 14:00:14 +02001045printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001046{
1047 int exited = 0;
1048
1049 /*
1050 * Here is a tricky presentation problem. This solution
1051 * is still not entirely satisfactory but since there
1052 * are no wait status constructors it will have to do.
1053 */
Roland McGrath79fbda52004-04-14 02:45:55 +00001054 if (WIFSTOPPED(status)) {
1055 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001056 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +00001057 status &= ~W_STOPCODE(WSTOPSIG(status));
1058 }
1059 else if (WIFSIGNALED(status)) {
1060 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001061 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001062 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +00001063 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1064 }
1065 else if (WIFEXITED(status)) {
1066 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001067 WEXITSTATUS(status));
1068 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +00001069 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001070 }
Roland McGrath79fbda52004-04-14 02:45:55 +00001071 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001072 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001073 return 0;
1074 }
1075
1076 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001077 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +00001078 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +00001079 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001080
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001081 return exited;
1082}
1083
1084static int
Denys Vlasenko59432db2009-01-26 19:09:35 +00001085printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001086{
1087 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001088
1089 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001090 /* On Linux, kernel-side pid_t is typedef'ed to int
1091 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +00001092 * pid argument to int on 64bit arches, producing,
1093 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001094 * in strace. We have to use int here, not long.
1095 */
1096 int pid = tcp->u_arg[0];
1097 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001098 } else {
1099 /* status */
1100 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001101 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001102 else if (syserror(tcp) || tcp->u_rval == 0)
1103 tprintf("%#lx", tcp->u_arg[1]);
1104 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001105 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001106 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +00001107 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001108 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001109 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001110 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001111 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001112 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001113 /* usage */
1114 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001115 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001116 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +00001117#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001118 if (bitness)
1119 printrusage32(tcp, tcp->u_arg[3]);
1120 else
1121#endif
1122 printrusage(tcp, tcp->u_arg[3]);
1123 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001124 else
1125 tprintf("%#lx", tcp->u_arg[3]);
1126 }
1127 }
1128 return 0;
1129}
1130
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001131int
Denys Vlasenko12014262011-05-30 14:00:14 +02001132sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001133{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001134 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001135}
1136
1137int
Denys Vlasenko12014262011-05-30 14:00:14 +02001138sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001139{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001140 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001141}
1142
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001143#ifdef ALPHA
1144int
Denys Vlasenko12014262011-05-30 14:00:14 +02001145sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001146{
1147 return printwaitn(tcp, 4, 1);
1148}
1149#endif
1150
Roland McGrathd9f816f2004-09-04 03:39:20 +00001151static const struct xlat waitid_types[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001152 { P_PID, "P_PID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001153#ifdef P_PPID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001154 { P_PPID, "P_PPID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001155#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001156 { P_PGID, "P_PGID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001157#ifdef P_SID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001158 { P_SID, "P_SID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001159#endif
1160#ifdef P_CID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001161 { P_CID, "P_CID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001162#endif
1163#ifdef P_UID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001164 { P_UID, "P_UID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001165#endif
1166#ifdef P_GID
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001167 { P_GID, "P_GID" },
Roland McGrathc74c0b72004-09-01 19:39:46 +00001168#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001169 { P_ALL, "P_ALL" },
1170#ifdef P_LWPID
1171 { P_LWPID, "P_LWPID" },
1172#endif
1173 { 0, NULL },
1174};
1175
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001176int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +00001177sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001178{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001179 if (entering(tcp)) {
1180 printxval(waitid_types, tcp->u_arg[0], "P_???");
1181 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001182 }
1183 else {
1184 /* siginfo */
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01001185 printsiginfo_at(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001186 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001187 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001188 printflags(wait4_options, tcp->u_arg[3], "W???");
Denys Vlasenko74ec14f2013-02-21 16:13:47 +01001189 if (tcp->s_ent->nargs > 4) {
Roland McGrath39426a32004-10-06 22:02:59 +00001190 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001191 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +00001192 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001193 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +00001194 else if (tcp->u_error)
1195 tprintf("%#lx", tcp->u_arg[4]);
1196 else
1197 printrusage(tcp, tcp->u_arg[4]);
1198 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001199 }
1200 return 0;
1201}
1202
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001203int
Denys Vlasenko12014262011-05-30 14:00:14 +02001204sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001205{
1206 struct utsname uname;
1207
1208 if (exiting(tcp)) {
1209 if (syserror(tcp) || !verbose(tcp))
1210 tprintf("%#lx", tcp->u_arg[0]);
1211 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001212 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001213 else if (!abbrev(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001214 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1215 uname.sysname, uname.nodename);
1216 tprintf("release=\"%s\", version=\"%s\", ",
1217 uname.release, uname.version);
1218 tprintf("machine=\"%s\"", uname.machine);
Dmitry V. Levinea22e972012-05-01 20:56:32 +00001219#ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001220 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001221#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001222 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001223 }
1224 else
1225 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1226 uname.sysname, uname.nodename);
1227 }
1228 return 0;
1229}
1230
Roland McGratheb9e2e82009-06-02 16:49:22 -07001231static const struct xlat ptrace_cmds[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001232 { PTRACE_TRACEME, "PTRACE_TRACEME" },
Denys Vlasenko61526c62011-08-25 10:21:13 +02001233 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
1234 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
1235 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
1236 { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
1237 { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
1238 { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001239 { PTRACE_CONT, "PTRACE_CONT" },
1240 { PTRACE_KILL, "PTRACE_KILL" },
1241 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1242 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1243 { PTRACE_DETACH, "PTRACE_DETACH" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001244#ifdef PTRACE_GETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001245 { PTRACE_GETREGS, "PTRACE_GETREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001246#endif
1247#ifdef PTRACE_SETREGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001248 { PTRACE_SETREGS, "PTRACE_SETREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001249#endif
1250#ifdef PTRACE_GETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001251 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001252#endif
1253#ifdef PTRACE_SETFPREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001254 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001255#endif
1256#ifdef PTRACE_GETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001257 { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001258#endif
1259#ifdef PTRACE_SETFPXREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001260 { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001261#endif
1262#ifdef PTRACE_GETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001263 { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001264#endif
1265#ifdef PTRACE_SETVRREGS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001266 { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001267#endif
1268#ifdef PTRACE_SETOPTIONS
Denys Vlasenko61526c62011-08-25 10:21:13 +02001269 { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001270#endif
1271#ifdef PTRACE_GETEVENTMSG
Denys Vlasenko61526c62011-08-25 10:21:13 +02001272 { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001273#endif
1274#ifdef PTRACE_GETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001275 { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001276#endif
1277#ifdef PTRACE_SETSIGINFO
Denys Vlasenko61526c62011-08-25 10:21:13 +02001278 { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001279#endif
1280#ifdef PTRACE_GETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001281 { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001282#endif
1283#ifdef PTRACE_SETREGSET
Denys Vlasenko61526c62011-08-25 10:21:13 +02001284 { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001285#endif
1286#ifdef PTRACE_SET_SYSCALL
Denys Vlasenko61526c62011-08-25 10:21:13 +02001287 { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001288#endif
1289#ifdef PTRACE_SEIZE
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001290 { PTRACE_SEIZE, "PTRACE_SEIZE" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001291#endif
1292#ifdef PTRACE_INTERRUPT
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001293 { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001294#endif
1295#ifdef PTRACE_LISTEN
Denys Vlasenko31fa8a22012-01-29 02:01:44 +01001296 { PTRACE_LISTEN, "PTRACE_LISTEN" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001297#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001298 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
Denys Vlasenkof535b542009-01-13 18:30:55 +00001299
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001300 { 0, NULL },
1301};
1302
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001303#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00001304static const struct xlat ptrace_setoptions_flags[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001305# ifdef PTRACE_O_TRACESYSGOOD
Denys Vlasenkof535b542009-01-13 18:30:55 +00001306 { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001307# endif
1308# ifdef PTRACE_O_TRACEFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001309 { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001310# endif
1311# ifdef PTRACE_O_TRACEVFORK
Denys Vlasenkof535b542009-01-13 18:30:55 +00001312 { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001313# endif
1314# ifdef PTRACE_O_TRACECLONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001315 { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001316# endif
1317# ifdef PTRACE_O_TRACEEXEC
Denys Vlasenkof535b542009-01-13 18:30:55 +00001318 { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001319# endif
1320# ifdef PTRACE_O_TRACEVFORKDONE
Denys Vlasenkof535b542009-01-13 18:30:55 +00001321 { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001322# endif
1323# ifdef PTRACE_O_TRACEEXIT
Denys Vlasenkof535b542009-01-13 18:30:55 +00001324 { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001325# endif
Denys Vlasenkof535b542009-01-13 18:30:55 +00001326 { 0, NULL },
1327};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001328#endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001329
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001330static const struct xlat nt_descriptor_types[] = {
1331#ifdef NT_PRSTATUS
1332 { NT_PRSTATUS, "NT_PRSTATUS" },
1333#endif
1334#ifdef NT_FPREGSET
1335 { NT_FPREGSET, "NT_FPREGSET" },
1336#endif
1337#ifdef NT_PRPSINFO
1338 { NT_PRPSINFO, "NT_PRPSINFO" },
1339#endif
1340#ifdef NT_PRXREG
1341 { NT_PRXREG, "NT_PRXREG" },
1342#endif
1343#ifdef NT_TASKSTRUCT
1344 { NT_TASKSTRUCT, "NT_TASKSTRUCT" },
1345#endif
1346#ifdef NT_PLATFORM
1347 { NT_PLATFORM, "NT_PLATFORM" },
1348#endif
1349#ifdef NT_AUXV
1350 { NT_AUXV, "NT_AUXV" },
1351#endif
1352#ifdef NT_GWINDOWS
1353 { NT_GWINDOWS, "NT_GWINDOWS" },
1354#endif
1355#ifdef NT_ASRS
1356 { NT_ASRS, "NT_ASRS" },
1357#endif
1358#ifdef NT_PSTATUS
1359 { NT_PSTATUS, "NT_PSTATUS" },
1360#endif
1361#ifdef NT_PSINFO
1362 { NT_PSINFO, "NT_PSINFO" },
1363#endif
1364#ifdef NT_PRCRED
1365 { NT_PRCRED, "NT_PRCRED" },
1366#endif
1367#ifdef NT_UTSNAME
1368 { NT_UTSNAME, "NT_UTSNAME" },
1369#endif
1370#ifdef NT_LWPSTATUS
1371 { NT_LWPSTATUS, "NT_LWPSTATUS" },
1372#endif
1373#ifdef NT_LWPSINFO
1374 { NT_LWPSINFO, "NT_LWPSINFO" },
1375#endif
1376#ifdef NT_PRFPXREG
1377 { NT_PRFPXREG, "NT_PRFPXREG" },
1378#endif
1379#ifdef NT_PRXFPREG
1380 { NT_PRXFPREG, "NT_PRXFPREG" },
1381#endif
1382#ifdef NT_PPC_VMX
1383 { NT_PPC_VMX, "NT_PPC_VMX" },
1384#endif
1385#ifdef NT_PPC_SPE
1386 { NT_PPC_SPE, "NT_PPC_SPE" },
1387#endif
1388#ifdef NT_PPC_VSX
1389 { NT_PPC_VSX, "NT_PPC_VSX" },
1390#endif
1391#ifdef NT_386_TLS
1392 { NT_386_TLS, "NT_386_TLS" },
1393#endif
1394#ifdef NT_386_IOPERM
1395 { NT_386_IOPERM, "NT_386_IOPERM" },
1396#endif
1397#ifdef NT_X86_XSTATE
1398 { NT_X86_XSTATE, "NT_X86_XSTATE" },
1399#endif
1400 { 0, NULL },
1401};
1402
Denys Vlasenko513e9c22012-03-21 14:39:22 +01001403#define uoff(member) offsetof(struct user, member)
1404
Roland McGrathd9f816f2004-09-04 03:39:20 +00001405const struct xlat struct_user_offsets[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001406#if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001407 { PT_PSWMASK, "psw_mask" },
1408 { PT_PSWADDR, "psw_addr" },
1409 { PT_GPR0, "gpr0" },
1410 { PT_GPR1, "gpr1" },
1411 { PT_GPR2, "gpr2" },
1412 { PT_GPR3, "gpr3" },
1413 { PT_GPR4, "gpr4" },
1414 { PT_GPR5, "gpr5" },
1415 { PT_GPR6, "gpr6" },
1416 { PT_GPR7, "gpr7" },
1417 { PT_GPR8, "gpr8" },
1418 { PT_GPR9, "gpr9" },
1419 { PT_GPR10, "gpr10" },
1420 { PT_GPR11, "gpr11" },
1421 { PT_GPR12, "gpr12" },
1422 { PT_GPR13, "gpr13" },
1423 { PT_GPR14, "gpr14" },
1424 { PT_GPR15, "gpr15" },
1425 { PT_ACR0, "acr0" },
1426 { PT_ACR1, "acr1" },
1427 { PT_ACR2, "acr2" },
1428 { PT_ACR3, "acr3" },
1429 { PT_ACR4, "acr4" },
1430 { PT_ACR5, "acr5" },
1431 { PT_ACR6, "acr6" },
1432 { PT_ACR7, "acr7" },
1433 { PT_ACR8, "acr8" },
1434 { PT_ACR9, "acr9" },
1435 { PT_ACR10, "acr10" },
1436 { PT_ACR11, "acr11" },
1437 { PT_ACR12, "acr12" },
1438 { PT_ACR13, "acr13" },
1439 { PT_ACR14, "acr14" },
1440 { PT_ACR15, "acr15" },
1441 { PT_ORIGGPR2, "orig_gpr2" },
1442 { PT_FPC, "fpc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001443#if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001444 { PT_FPR0_HI, "fpr0.hi" },
1445 { PT_FPR0_LO, "fpr0.lo" },
1446 { PT_FPR1_HI, "fpr1.hi" },
1447 { PT_FPR1_LO, "fpr1.lo" },
1448 { PT_FPR2_HI, "fpr2.hi" },
1449 { PT_FPR2_LO, "fpr2.lo" },
1450 { PT_FPR3_HI, "fpr3.hi" },
1451 { PT_FPR3_LO, "fpr3.lo" },
1452 { PT_FPR4_HI, "fpr4.hi" },
1453 { PT_FPR4_LO, "fpr4.lo" },
1454 { PT_FPR5_HI, "fpr5.hi" },
1455 { PT_FPR5_LO, "fpr5.lo" },
1456 { PT_FPR6_HI, "fpr6.hi" },
1457 { PT_FPR6_LO, "fpr6.lo" },
1458 { PT_FPR7_HI, "fpr7.hi" },
1459 { PT_FPR7_LO, "fpr7.lo" },
1460 { PT_FPR8_HI, "fpr8.hi" },
1461 { PT_FPR8_LO, "fpr8.lo" },
1462 { PT_FPR9_HI, "fpr9.hi" },
1463 { PT_FPR9_LO, "fpr9.lo" },
1464 { PT_FPR10_HI, "fpr10.hi" },
1465 { PT_FPR10_LO, "fpr10.lo" },
1466 { PT_FPR11_HI, "fpr11.hi" },
1467 { PT_FPR11_LO, "fpr11.lo" },
1468 { PT_FPR12_HI, "fpr12.hi" },
1469 { PT_FPR12_LO, "fpr12.lo" },
1470 { PT_FPR13_HI, "fpr13.hi" },
1471 { PT_FPR13_LO, "fpr13.lo" },
1472 { PT_FPR14_HI, "fpr14.hi" },
1473 { PT_FPR14_LO, "fpr14.lo" },
1474 { PT_FPR15_HI, "fpr15.hi" },
1475 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001476#endif
1477#if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001478 { PT_FPR0, "fpr0" },
1479 { PT_FPR1, "fpr1" },
1480 { PT_FPR2, "fpr2" },
1481 { PT_FPR3, "fpr3" },
1482 { PT_FPR4, "fpr4" },
1483 { PT_FPR5, "fpr5" },
1484 { PT_FPR6, "fpr6" },
1485 { PT_FPR7, "fpr7" },
1486 { PT_FPR8, "fpr8" },
1487 { PT_FPR9, "fpr9" },
1488 { PT_FPR10, "fpr10" },
1489 { PT_FPR11, "fpr11" },
1490 { PT_FPR12, "fpr12" },
1491 { PT_FPR13, "fpr13" },
1492 { PT_FPR14, "fpr14" },
1493 { PT_FPR15, "fpr15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001494#endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001495 { PT_CR_9, "cr9" },
1496 { PT_CR_10, "cr10" },
1497 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001498 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001499#elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001500 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001501#elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001502 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001503#elif defined(POWERPC)
1504# ifndef PT_ORIG_R3
1505# define PT_ORIG_R3 34
1506# endif
1507# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001508 { REGSIZE*PT_R0, "r0" },
1509 { REGSIZE*PT_R1, "r1" },
1510 { REGSIZE*PT_R2, "r2" },
1511 { REGSIZE*PT_R3, "r3" },
1512 { REGSIZE*PT_R4, "r4" },
1513 { REGSIZE*PT_R5, "r5" },
1514 { REGSIZE*PT_R6, "r6" },
1515 { REGSIZE*PT_R7, "r7" },
1516 { REGSIZE*PT_R8, "r8" },
1517 { REGSIZE*PT_R9, "r9" },
1518 { REGSIZE*PT_R10, "r10" },
1519 { REGSIZE*PT_R11, "r11" },
1520 { REGSIZE*PT_R12, "r12" },
1521 { REGSIZE*PT_R13, "r13" },
1522 { REGSIZE*PT_R14, "r14" },
1523 { REGSIZE*PT_R15, "r15" },
1524 { REGSIZE*PT_R16, "r16" },
1525 { REGSIZE*PT_R17, "r17" },
1526 { REGSIZE*PT_R18, "r18" },
1527 { REGSIZE*PT_R19, "r19" },
1528 { REGSIZE*PT_R20, "r20" },
1529 { REGSIZE*PT_R21, "r21" },
1530 { REGSIZE*PT_R22, "r22" },
1531 { REGSIZE*PT_R23, "r23" },
1532 { REGSIZE*PT_R24, "r24" },
1533 { REGSIZE*PT_R25, "r25" },
1534 { REGSIZE*PT_R26, "r26" },
1535 { REGSIZE*PT_R27, "r27" },
1536 { REGSIZE*PT_R28, "r28" },
1537 { REGSIZE*PT_R29, "r29" },
1538 { REGSIZE*PT_R30, "r30" },
1539 { REGSIZE*PT_R31, "r31" },
1540 { REGSIZE*PT_NIP, "NIP" },
1541 { REGSIZE*PT_MSR, "MSR" },
1542 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1543 { REGSIZE*PT_CTR, "CTR" },
1544 { REGSIZE*PT_LNK, "LNK" },
1545 { REGSIZE*PT_XER, "XER" },
1546 { REGSIZE*PT_CCR, "CCR" },
1547 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001548# undef REGSIZE
1549#elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001550 { 0, "r0" },
1551 { 1, "r1" },
1552 { 2, "r2" },
1553 { 3, "r3" },
1554 { 4, "r4" },
1555 { 5, "r5" },
1556 { 6, "r6" },
1557 { 7, "r7" },
1558 { 8, "r8" },
1559 { 9, "r9" },
1560 { 10, "r10" },
1561 { 11, "r11" },
1562 { 12, "r12" },
1563 { 13, "r13" },
1564 { 14, "r14" },
1565 { 15, "r15" },
1566 { 16, "r16" },
1567 { 17, "r17" },
1568 { 18, "r18" },
1569 { 19, "r19" },
1570 { 20, "r20" },
1571 { 21, "r21" },
1572 { 22, "r22" },
1573 { 23, "r23" },
1574 { 24, "r24" },
1575 { 25, "r25" },
1576 { 26, "r26" },
1577 { 27, "r27" },
1578 { 28, "r28" },
1579 { 29, "gp" },
1580 { 30, "fp" },
1581 { 31, "zero" },
1582 { 32, "fp0" },
1583 { 33, "fp" },
1584 { 34, "fp2" },
1585 { 35, "fp3" },
1586 { 36, "fp4" },
1587 { 37, "fp5" },
1588 { 38, "fp6" },
1589 { 39, "fp7" },
1590 { 40, "fp8" },
1591 { 41, "fp9" },
1592 { 42, "fp10" },
1593 { 43, "fp11" },
1594 { 44, "fp12" },
1595 { 45, "fp13" },
1596 { 46, "fp14" },
1597 { 47, "fp15" },
1598 { 48, "fp16" },
1599 { 49, "fp17" },
1600 { 50, "fp18" },
1601 { 51, "fp19" },
1602 { 52, "fp20" },
1603 { 53, "fp21" },
1604 { 54, "fp22" },
1605 { 55, "fp23" },
1606 { 56, "fp24" },
1607 { 57, "fp25" },
1608 { 58, "fp26" },
1609 { 59, "fp27" },
1610 { 60, "fp28" },
1611 { 61, "fp29" },
1612 { 62, "fp30" },
1613 { 63, "fp31" },
1614 { 64, "pc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001615#elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001616 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1617 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1618 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1619 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1620 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1621 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1622 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1623 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1624 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1625 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1626 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1627 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1628 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1629 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1630 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1631 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1632 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1633 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1634 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1635 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1636 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1637 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1638 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1639 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1640 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1641 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1642 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1643 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1644 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1645 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1646 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1647 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1648 /* switch stack: */
1649 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1650 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1651 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1652 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1653 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1654 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1655 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1656 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1657 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1658 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001659 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1660 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001661 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001662 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001663 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1664 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001665 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1666 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1667 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1668 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1669 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1670 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1671 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1672 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1673 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1674 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1675 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1676 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1677 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1678 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1679 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001680# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001681 { PT_AR_CSD, "ar.csd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001682# endif
1683# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001684 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001685# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001686 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001687#elif defined(I386)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001688 { 4*EBX, "4*EBX" },
1689 { 4*ECX, "4*ECX" },
1690 { 4*EDX, "4*EDX" },
1691 { 4*ESI, "4*ESI" },
1692 { 4*EDI, "4*EDI" },
1693 { 4*EBP, "4*EBP" },
1694 { 4*EAX, "4*EAX" },
1695 { 4*DS, "4*DS" },
1696 { 4*ES, "4*ES" },
1697 { 4*FS, "4*FS" },
1698 { 4*GS, "4*GS" },
1699 { 4*ORIG_EAX, "4*ORIG_EAX" },
1700 { 4*EIP, "4*EIP" },
1701 { 4*CS, "4*CS" },
1702 { 4*EFL, "4*EFL" },
1703 { 4*UESP, "4*UESP" },
1704 { 4*SS, "4*SS" },
H.J. Lu35be5812012-04-16 13:00:01 +02001705#elif defined(X86_64) || defined(X32)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001706 { 8*R15, "8*R15" },
1707 { 8*R14, "8*R14" },
1708 { 8*R13, "8*R13" },
1709 { 8*R12, "8*R12" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001710 { 8*RBP, "8*RBP" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001711 { 8*RBX, "8*RBX" },
1712 { 8*R11, "8*R11" },
1713 { 8*R10, "8*R10" },
1714 { 8*R9, "8*R9" },
1715 { 8*R8, "8*R8" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001716 { 8*RAX, "8*RAX" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001717 { 8*RCX, "8*RCX" },
1718 { 8*RDX, "8*RDX" },
1719 { 8*RSI, "8*RSI" },
1720 { 8*RDI, "8*RDI" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001721 { 8*ORIG_RAX, "8*ORIG_RAX" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001722 { 8*RIP, "8*RIP" },
1723 { 8*CS, "8*CS" },
1724 { 8*EFLAGS, "8*EFL" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001725 { 8*RSP, "8*RSP" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001726 { 8*SS, "8*SS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001727#elif defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001728 { 4*PT_D1, "4*PT_D1" },
1729 { 4*PT_D2, "4*PT_D2" },
1730 { 4*PT_D3, "4*PT_D3" },
1731 { 4*PT_D4, "4*PT_D4" },
1732 { 4*PT_D5, "4*PT_D5" },
1733 { 4*PT_D6, "4*PT_D6" },
1734 { 4*PT_D7, "4*PT_D7" },
1735 { 4*PT_A0, "4*PT_A0" },
1736 { 4*PT_A1, "4*PT_A1" },
1737 { 4*PT_A2, "4*PT_A2" },
1738 { 4*PT_A3, "4*PT_A3" },
1739 { 4*PT_A4, "4*PT_A4" },
1740 { 4*PT_A5, "4*PT_A5" },
1741 { 4*PT_A6, "4*PT_A6" },
1742 { 4*PT_D0, "4*PT_D0" },
1743 { 4*PT_USP, "4*PT_USP" },
1744 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1745 { 4*PT_SR, "4*PT_SR" },
1746 { 4*PT_PC, "4*PT_PC" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001747#elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001748 { 4*REG_REG0, "4*REG_REG0" },
1749 { 4*(REG_REG0+1), "4*REG_REG1" },
1750 { 4*(REG_REG0+2), "4*REG_REG2" },
1751 { 4*(REG_REG0+3), "4*REG_REG3" },
1752 { 4*(REG_REG0+4), "4*REG_REG4" },
1753 { 4*(REG_REG0+5), "4*REG_REG5" },
1754 { 4*(REG_REG0+6), "4*REG_REG6" },
1755 { 4*(REG_REG0+7), "4*REG_REG7" },
1756 { 4*(REG_REG0+8), "4*REG_REG8" },
1757 { 4*(REG_REG0+9), "4*REG_REG9" },
1758 { 4*(REG_REG0+10), "4*REG_REG10" },
1759 { 4*(REG_REG0+11), "4*REG_REG11" },
1760 { 4*(REG_REG0+12), "4*REG_REG12" },
1761 { 4*(REG_REG0+13), "4*REG_REG13" },
1762 { 4*(REG_REG0+14), "4*REG_REG14" },
1763 { 4*REG_REG15, "4*REG_REG15" },
1764 { 4*REG_PC, "4*REG_PC" },
1765 { 4*REG_PR, "4*REG_PR" },
1766 { 4*REG_SR, "4*REG_SR" },
1767 { 4*REG_GBR, "4*REG_GBR" },
1768 { 4*REG_MACH, "4*REG_MACH" },
1769 { 4*REG_MACL, "4*REG_MACL" },
1770 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1771 { 4*REG_FPUL, "4*REG_FPUL" },
1772 { 4*REG_FPREG0, "4*REG_FPREG0" },
1773 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1774 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1775 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1776 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1777 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1778 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1779 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1780 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1781 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1782 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1783 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1784 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1785 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1786 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1787 { 4*REG_FPREG15, "4*REG_FPREG15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001788# ifdef REG_XDREG0
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001789 { 4*REG_XDREG0, "4*REG_XDREG0" },
1790 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1791 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1792 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1793 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1794 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1795 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1796 { 4*REG_XDREG14, "4*REG_XDREG14" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001797# endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001798 { 4*REG_FPSCR, "4*REG_FPSCR" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001799#elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001800 { 0, "PC(L)" },
1801 { 4, "PC(U)" },
1802 { 8, "SR(L)" },
1803 { 12, "SR(U)" },
1804 { 16, "syscall no.(L)" },
1805 { 20, "syscall_no.(U)" },
1806 { 24, "R0(L)" },
1807 { 28, "R0(U)" },
1808 { 32, "R1(L)" },
1809 { 36, "R1(U)" },
1810 { 40, "R2(L)" },
1811 { 44, "R2(U)" },
1812 { 48, "R3(L)" },
1813 { 52, "R3(U)" },
1814 { 56, "R4(L)" },
1815 { 60, "R4(U)" },
1816 { 64, "R5(L)" },
1817 { 68, "R5(U)" },
1818 { 72, "R6(L)" },
1819 { 76, "R6(U)" },
1820 { 80, "R7(L)" },
1821 { 84, "R7(U)" },
1822 { 88, "R8(L)" },
1823 { 92, "R8(U)" },
1824 { 96, "R9(L)" },
1825 { 100, "R9(U)" },
1826 { 104, "R10(L)" },
1827 { 108, "R10(U)" },
1828 { 112, "R11(L)" },
1829 { 116, "R11(U)" },
1830 { 120, "R12(L)" },
1831 { 124, "R12(U)" },
1832 { 128, "R13(L)" },
1833 { 132, "R13(U)" },
1834 { 136, "R14(L)" },
1835 { 140, "R14(U)" },
1836 { 144, "R15(L)" },
1837 { 148, "R15(U)" },
1838 { 152, "R16(L)" },
1839 { 156, "R16(U)" },
1840 { 160, "R17(L)" },
1841 { 164, "R17(U)" },
1842 { 168, "R18(L)" },
1843 { 172, "R18(U)" },
1844 { 176, "R19(L)" },
1845 { 180, "R19(U)" },
1846 { 184, "R20(L)" },
1847 { 188, "R20(U)" },
1848 { 192, "R21(L)" },
1849 { 196, "R21(U)" },
1850 { 200, "R22(L)" },
1851 { 204, "R22(U)" },
1852 { 208, "R23(L)" },
1853 { 212, "R23(U)" },
1854 { 216, "R24(L)" },
1855 { 220, "R24(U)" },
1856 { 224, "R25(L)" },
1857 { 228, "R25(U)" },
1858 { 232, "R26(L)" },
1859 { 236, "R26(U)" },
1860 { 240, "R27(L)" },
1861 { 244, "R27(U)" },
1862 { 248, "R28(L)" },
1863 { 252, "R28(U)" },
1864 { 256, "R29(L)" },
1865 { 260, "R29(U)" },
1866 { 264, "R30(L)" },
1867 { 268, "R30(U)" },
1868 { 272, "R31(L)" },
1869 { 276, "R31(U)" },
1870 { 280, "R32(L)" },
1871 { 284, "R32(U)" },
1872 { 288, "R33(L)" },
1873 { 292, "R33(U)" },
1874 { 296, "R34(L)" },
1875 { 300, "R34(U)" },
1876 { 304, "R35(L)" },
1877 { 308, "R35(U)" },
1878 { 312, "R36(L)" },
1879 { 316, "R36(U)" },
1880 { 320, "R37(L)" },
1881 { 324, "R37(U)" },
1882 { 328, "R38(L)" },
1883 { 332, "R38(U)" },
1884 { 336, "R39(L)" },
1885 { 340, "R39(U)" },
1886 { 344, "R40(L)" },
1887 { 348, "R40(U)" },
1888 { 352, "R41(L)" },
1889 { 356, "R41(U)" },
1890 { 360, "R42(L)" },
1891 { 364, "R42(U)" },
1892 { 368, "R43(L)" },
1893 { 372, "R43(U)" },
1894 { 376, "R44(L)" },
1895 { 380, "R44(U)" },
1896 { 384, "R45(L)" },
1897 { 388, "R45(U)" },
1898 { 392, "R46(L)" },
1899 { 396, "R46(U)" },
1900 { 400, "R47(L)" },
1901 { 404, "R47(U)" },
1902 { 408, "R48(L)" },
1903 { 412, "R48(U)" },
1904 { 416, "R49(L)" },
1905 { 420, "R49(U)" },
1906 { 424, "R50(L)" },
1907 { 428, "R50(U)" },
1908 { 432, "R51(L)" },
1909 { 436, "R51(U)" },
1910 { 440, "R52(L)" },
1911 { 444, "R52(U)" },
1912 { 448, "R53(L)" },
1913 { 452, "R53(U)" },
1914 { 456, "R54(L)" },
1915 { 460, "R54(U)" },
1916 { 464, "R55(L)" },
1917 { 468, "R55(U)" },
1918 { 472, "R56(L)" },
1919 { 476, "R56(U)" },
1920 { 480, "R57(L)" },
1921 { 484, "R57(U)" },
1922 { 488, "R58(L)" },
1923 { 492, "R58(U)" },
1924 { 496, "R59(L)" },
1925 { 500, "R59(U)" },
1926 { 504, "R60(L)" },
1927 { 508, "R60(U)" },
1928 { 512, "R61(L)" },
1929 { 516, "R61(U)" },
1930 { 520, "R62(L)" },
1931 { 524, "R62(U)" },
1932 { 528, "TR0(L)" },
1933 { 532, "TR0(U)" },
1934 { 536, "TR1(L)" },
1935 { 540, "TR1(U)" },
1936 { 544, "TR2(L)" },
1937 { 548, "TR2(U)" },
1938 { 552, "TR3(L)" },
1939 { 556, "TR3(U)" },
1940 { 560, "TR4(L)" },
1941 { 564, "TR4(U)" },
1942 { 568, "TR5(L)" },
1943 { 572, "TR5(U)" },
1944 { 576, "TR6(L)" },
1945 { 580, "TR6(U)" },
1946 { 584, "TR7(L)" },
1947 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00001948 /* This entry is in case pt_regs contains dregs (depends on
1949 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001950 { uoff(regs), "offsetof(struct user, regs)" },
1951 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001952#elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00001953 { uoff(regs.ARM_r0), "r0" },
1954 { uoff(regs.ARM_r1), "r1" },
1955 { uoff(regs.ARM_r2), "r2" },
1956 { uoff(regs.ARM_r3), "r3" },
1957 { uoff(regs.ARM_r4), "r4" },
1958 { uoff(regs.ARM_r5), "r5" },
1959 { uoff(regs.ARM_r6), "r6" },
1960 { uoff(regs.ARM_r7), "r7" },
1961 { uoff(regs.ARM_r8), "r8" },
1962 { uoff(regs.ARM_r9), "r9" },
1963 { uoff(regs.ARM_r10), "r10" },
1964 { uoff(regs.ARM_fp), "fp" },
1965 { uoff(regs.ARM_ip), "ip" },
1966 { uoff(regs.ARM_sp), "sp" },
1967 { uoff(regs.ARM_lr), "lr" },
1968 { uoff(regs.ARM_pc), "pc" },
1969 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001970#elif defined(AVR32)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001971 { uoff(regs.sr), "sr" },
1972 { uoff(regs.pc), "pc" },
1973 { uoff(regs.lr), "lr" },
1974 { uoff(regs.sp), "sp" },
1975 { uoff(regs.r12), "r12" },
1976 { uoff(regs.r11), "r11" },
1977 { uoff(regs.r10), "r10" },
1978 { uoff(regs.r9), "r9" },
1979 { uoff(regs.r8), "r8" },
1980 { uoff(regs.r7), "r7" },
1981 { uoff(regs.r6), "r6" },
1982 { uoff(regs.r5), "r5" },
1983 { uoff(regs.r4), "r4" },
1984 { uoff(regs.r3), "r3" },
1985 { uoff(regs.r2), "r2" },
1986 { uoff(regs.r1), "r1" },
1987 { uoff(regs.r0), "r0" },
1988 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001989#elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00001990 { 0, "r0" },
1991 { 1, "r1" },
1992 { 2, "r2" },
1993 { 3, "r3" },
1994 { 4, "r4" },
1995 { 5, "r5" },
1996 { 6, "r6" },
1997 { 7, "r7" },
1998 { 8, "r8" },
1999 { 9, "r9" },
2000 { 10, "r10" },
2001 { 11, "r11" },
2002 { 12, "r12" },
2003 { 13, "r13" },
2004 { 14, "r14" },
2005 { 15, "r15" },
2006 { 16, "r16" },
2007 { 17, "r17" },
2008 { 18, "r18" },
2009 { 19, "r19" },
2010 { 20, "r20" },
2011 { 21, "r21" },
2012 { 22, "r22" },
2013 { 23, "r23" },
2014 { 24, "r24" },
2015 { 25, "r25" },
2016 { 26, "r26" },
2017 { 27, "r27" },
2018 { 28, "r28" },
2019 { 29, "r29" },
2020 { 30, "r30" },
2021 { 31, "r31" },
2022 { 32, "f0" },
2023 { 33, "f1" },
2024 { 34, "f2" },
2025 { 35, "f3" },
2026 { 36, "f4" },
2027 { 37, "f5" },
2028 { 38, "f6" },
2029 { 39, "f7" },
2030 { 40, "f8" },
2031 { 41, "f9" },
2032 { 42, "f10" },
2033 { 43, "f11" },
2034 { 44, "f12" },
2035 { 45, "f13" },
2036 { 46, "f14" },
2037 { 47, "f15" },
2038 { 48, "f16" },
2039 { 49, "f17" },
2040 { 50, "f18" },
2041 { 51, "f19" },
2042 { 52, "f20" },
2043 { 53, "f21" },
2044 { 54, "f22" },
2045 { 55, "f23" },
2046 { 56, "f24" },
2047 { 57, "f25" },
2048 { 58, "f26" },
2049 { 59, "f27" },
2050 { 60, "f28" },
2051 { 61, "f29" },
2052 { 62, "f30" },
2053 { 63, "f31" },
2054 { 64, "pc" },
2055 { 65, "cause" },
2056 { 66, "badvaddr" },
2057 { 67, "mmhi" },
2058 { 68, "mmlo" },
2059 { 69, "fpcsr" },
2060 { 70, "fpeir" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002061#elif defined(TILE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05002062 { PTREGS_OFFSET_REG(0), "r0" },
2063 { PTREGS_OFFSET_REG(1), "r1" },
2064 { PTREGS_OFFSET_REG(2), "r2" },
2065 { PTREGS_OFFSET_REG(3), "r3" },
2066 { PTREGS_OFFSET_REG(4), "r4" },
2067 { PTREGS_OFFSET_REG(5), "r5" },
2068 { PTREGS_OFFSET_REG(6), "r6" },
2069 { PTREGS_OFFSET_REG(7), "r7" },
2070 { PTREGS_OFFSET_REG(8), "r8" },
2071 { PTREGS_OFFSET_REG(9), "r9" },
2072 { PTREGS_OFFSET_REG(10), "r10" },
2073 { PTREGS_OFFSET_REG(11), "r11" },
2074 { PTREGS_OFFSET_REG(12), "r12" },
2075 { PTREGS_OFFSET_REG(13), "r13" },
2076 { PTREGS_OFFSET_REG(14), "r14" },
2077 { PTREGS_OFFSET_REG(15), "r15" },
2078 { PTREGS_OFFSET_REG(16), "r16" },
2079 { PTREGS_OFFSET_REG(17), "r17" },
2080 { PTREGS_OFFSET_REG(18), "r18" },
2081 { PTREGS_OFFSET_REG(19), "r19" },
2082 { PTREGS_OFFSET_REG(20), "r20" },
2083 { PTREGS_OFFSET_REG(21), "r21" },
2084 { PTREGS_OFFSET_REG(22), "r22" },
2085 { PTREGS_OFFSET_REG(23), "r23" },
2086 { PTREGS_OFFSET_REG(24), "r24" },
2087 { PTREGS_OFFSET_REG(25), "r25" },
2088 { PTREGS_OFFSET_REG(26), "r26" },
2089 { PTREGS_OFFSET_REG(27), "r27" },
2090 { PTREGS_OFFSET_REG(28), "r28" },
2091 { PTREGS_OFFSET_REG(29), "r29" },
2092 { PTREGS_OFFSET_REG(30), "r30" },
2093 { PTREGS_OFFSET_REG(31), "r31" },
2094 { PTREGS_OFFSET_REG(32), "r32" },
2095 { PTREGS_OFFSET_REG(33), "r33" },
2096 { PTREGS_OFFSET_REG(34), "r34" },
2097 { PTREGS_OFFSET_REG(35), "r35" },
2098 { PTREGS_OFFSET_REG(36), "r36" },
2099 { PTREGS_OFFSET_REG(37), "r37" },
2100 { PTREGS_OFFSET_REG(38), "r38" },
2101 { PTREGS_OFFSET_REG(39), "r39" },
2102 { PTREGS_OFFSET_REG(40), "r40" },
2103 { PTREGS_OFFSET_REG(41), "r41" },
2104 { PTREGS_OFFSET_REG(42), "r42" },
2105 { PTREGS_OFFSET_REG(43), "r43" },
2106 { PTREGS_OFFSET_REG(44), "r44" },
2107 { PTREGS_OFFSET_REG(45), "r45" },
2108 { PTREGS_OFFSET_REG(46), "r46" },
2109 { PTREGS_OFFSET_REG(47), "r47" },
2110 { PTREGS_OFFSET_REG(48), "r48" },
2111 { PTREGS_OFFSET_REG(49), "r49" },
2112 { PTREGS_OFFSET_REG(50), "r50" },
2113 { PTREGS_OFFSET_REG(51), "r51" },
2114 { PTREGS_OFFSET_REG(52), "r52" },
2115 { PTREGS_OFFSET_TP, "tp" },
2116 { PTREGS_OFFSET_SP, "sp" },
2117 { PTREGS_OFFSET_LR, "lr" },
2118 { PTREGS_OFFSET_PC, "pc" },
2119 { PTREGS_OFFSET_EX1, "ex1" },
2120 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2121 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2122 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002123#endif
2124#ifdef CRISV10
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002125 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2126 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2127 { 4*PT_R13, "4*PT_R13" },
2128 { 4*PT_R12, "4*PT_R12" },
2129 { 4*PT_R11, "4*PT_R11" },
2130 { 4*PT_R10, "4*PT_R10" },
2131 { 4*PT_R9, "4*PT_R9" },
2132 { 4*PT_R8, "4*PT_R8" },
2133 { 4*PT_R7, "4*PT_R7" },
2134 { 4*PT_R6, "4*PT_R6" },
2135 { 4*PT_R5, "4*PT_R5" },
2136 { 4*PT_R4, "4*PT_R4" },
2137 { 4*PT_R3, "4*PT_R3" },
2138 { 4*PT_R2, "4*PT_R2" },
2139 { 4*PT_R1, "4*PT_R1" },
2140 { 4*PT_R0, "4*PT_R0" },
2141 { 4*PT_MOF, "4*PT_MOF" },
2142 { 4*PT_DCCR, "4*PT_DCCR" },
2143 { 4*PT_SRP, "4*PT_SRP" },
2144 { 4*PT_IRP, "4*PT_IRP" },
2145 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2146 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2147 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2148 { 4*PT_USP, "4*PT_USP" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002149#endif
2150#ifdef CRISV32
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002151 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2152 { 4*PT_R0, "4*PT_R0" },
2153 { 4*PT_R1, "4*PT_R1" },
2154 { 4*PT_R2, "4*PT_R2" },
2155 { 4*PT_R3, "4*PT_R3" },
2156 { 4*PT_R4, "4*PT_R4" },
2157 { 4*PT_R5, "4*PT_R5" },
2158 { 4*PT_R6, "4*PT_R6" },
2159 { 4*PT_R7, "4*PT_R7" },
2160 { 4*PT_R8, "4*PT_R8" },
2161 { 4*PT_R9, "4*PT_R9" },
2162 { 4*PT_R10, "4*PT_R10" },
2163 { 4*PT_R11, "4*PT_R11" },
2164 { 4*PT_R12, "4*PT_R12" },
2165 { 4*PT_R13, "4*PT_R13" },
2166 { 4*PT_ACR, "4*PT_ACR" },
2167 { 4*PT_SRS, "4*PT_SRS" },
2168 { 4*PT_MOF, "4*PT_MOF" },
2169 { 4*PT_SPC, "4*PT_SPC" },
2170 { 4*PT_CCS, "4*PT_CCS" },
2171 { 4*PT_SRP, "4*PT_SRP" },
2172 { 4*PT_ERP, "4*PT_ERP" },
2173 { 4*PT_EXS, "4*PT_EXS" },
2174 { 4*PT_EDA, "4*PT_EDA" },
2175 { 4*PT_USP, "4*PT_USP" },
2176 { 4*PT_PPC, "4*PT_PPC" },
2177 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2178 { 4*PT_BP+4, "4*PT_BP+4" },
2179 { 4*PT_BP+8, "4*PT_BP+8" },
2180 { 4*PT_BP+12, "4*PT_BP+12" },
2181 { 4*PT_BP+16, "4*PT_BP+16" },
2182 { 4*PT_BP+20, "4*PT_BP+20" },
2183 { 4*PT_BP+24, "4*PT_BP+24" },
2184 { 4*PT_BP+28, "4*PT_BP+28" },
2185 { 4*PT_BP+32, "4*PT_BP+32" },
2186 { 4*PT_BP+36, "4*PT_BP+36" },
2187 { 4*PT_BP+40, "4*PT_BP+40" },
2188 { 4*PT_BP+44, "4*PT_BP+44" },
2189 { 4*PT_BP+48, "4*PT_BP+48" },
2190 { 4*PT_BP+52, "4*PT_BP+52" },
2191 { 4*PT_BP+56, "4*PT_BP+56" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002192#endif
2193#ifdef MICROBLAZE
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002194 { PT_GPR(0), "r0" },
2195 { PT_GPR(1), "r1" },
2196 { PT_GPR(2), "r2" },
2197 { PT_GPR(3), "r3" },
2198 { PT_GPR(4), "r4" },
2199 { PT_GPR(5), "r5" },
2200 { PT_GPR(6), "r6" },
2201 { PT_GPR(7), "r7" },
2202 { PT_GPR(8), "r8" },
2203 { PT_GPR(9), "r9" },
2204 { PT_GPR(10), "r10" },
2205 { PT_GPR(11), "r11" },
2206 { PT_GPR(12), "r12" },
2207 { PT_GPR(13), "r13" },
2208 { PT_GPR(14), "r14" },
2209 { PT_GPR(15), "r15" },
2210 { PT_GPR(16), "r16" },
2211 { PT_GPR(17), "r17" },
2212 { PT_GPR(18), "r18" },
2213 { PT_GPR(19), "r19" },
2214 { PT_GPR(20), "r20" },
2215 { PT_GPR(21), "r21" },
2216 { PT_GPR(22), "r22" },
2217 { PT_GPR(23), "r23" },
2218 { PT_GPR(24), "r24" },
2219 { PT_GPR(25), "r25" },
2220 { PT_GPR(26), "r26" },
2221 { PT_GPR(27), "r27" },
2222 { PT_GPR(28), "r28" },
2223 { PT_GPR(29), "r29" },
2224 { PT_GPR(30), "r30" },
2225 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002226 { PT_PC, "rpc", },
2227 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002228 { PT_EAR, "rear", },
2229 { PT_ESR, "resr", },
2230 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002231 { PT_KERNEL_MODE, "kernel_mode", },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002232#endif
Christian Svensson492f81f2013-02-14 13:26:27 +01002233#ifdef OR1K
2234 { 4*0, "r0" },
2235 { 4*1, "r1" },
2236 { 4*2, "r2" },
2237 { 4*3, "r3" },
2238 { 4*4, "r4" },
2239 { 4*5, "r5" },
2240 { 4*6, "r6" },
2241 { 4*7, "r7" },
2242 { 4*8, "r8" },
2243 { 4*9, "r9" },
2244 { 4*10, "r10" },
2245 { 4*11, "r11" },
2246 { 4*12, "r12" },
2247 { 4*13, "r13" },
2248 { 4*14, "r14" },
2249 { 4*15, "r15" },
2250 { 4*16, "r16" },
2251 { 4*17, "r17" },
2252 { 4*18, "r18" },
2253 { 4*19, "r19" },
2254 { 4*20, "r20" },
2255 { 4*21, "r21" },
2256 { 4*22, "r22" },
2257 { 4*23, "r23" },
2258 { 4*24, "r24" },
2259 { 4*25, "r25" },
2260 { 4*26, "r26" },
2261 { 4*27, "r27" },
2262 { 4*28, "r28" },
2263 { 4*29, "r29" },
2264 { 4*30, "r30" },
2265 { 4*31, "r31" },
2266 { 4*32, "pc" },
2267 { 4*33, "sr" },
2268#endif
Chris Zankel8f636ed2013-03-25 10:22:07 -07002269#ifdef XTENSA
2270 { SYSCALL_NR, "syscall_nr" },
2271 { REG_AR_BASE, "ar0" },
2272 { REG_AR_BASE+1, "ar1" },
2273 { REG_AR_BASE+2, "ar2" },
2274 { REG_AR_BASE+3, "ar3" },
2275 { REG_AR_BASE+4, "ar4" },
2276 { REG_AR_BASE+5, "ar5" },
2277 { REG_AR_BASE+6, "ar6" },
2278 { REG_AR_BASE+7, "ar7" },
2279 { REG_AR_BASE+8, "ar8" },
2280 { REG_AR_BASE+9, "ar9" },
2281 { REG_AR_BASE+10, "ar10" },
2282 { REG_AR_BASE+11, "ar11" },
2283 { REG_AR_BASE+12, "ar12" },
2284 { REG_AR_BASE+13, "ar13" },
2285 { REG_AR_BASE+14, "ar14" },
2286 { REG_AR_BASE+15, "ar15" },
2287 { REG_AR_BASE+16, "ar16" },
2288 { REG_AR_BASE+17, "ar17" },
2289 { REG_AR_BASE+18, "ar18" },
2290 { REG_AR_BASE+19, "ar19" },
2291 { REG_AR_BASE+20, "ar20" },
2292 { REG_AR_BASE+21, "ar21" },
2293 { REG_AR_BASE+22, "ar22" },
2294 { REG_AR_BASE+23, "ar23" },
2295 { REG_AR_BASE+24, "ar24" },
2296 { REG_AR_BASE+25, "ar25" },
2297 { REG_AR_BASE+26, "ar26" },
2298 { REG_AR_BASE+27, "ar27" },
2299 { REG_AR_BASE+28, "ar28" },
2300 { REG_AR_BASE+29, "ar29" },
2301 { REG_AR_BASE+30, "ar30" },
2302 { REG_AR_BASE+31, "ar31" },
2303 { REG_AR_BASE+32, "ar32" },
2304 { REG_AR_BASE+33, "ar33" },
2305 { REG_AR_BASE+34, "ar34" },
2306 { REG_AR_BASE+35, "ar35" },
2307 { REG_AR_BASE+36, "ar36" },
2308 { REG_AR_BASE+37, "ar37" },
2309 { REG_AR_BASE+38, "ar38" },
2310 { REG_AR_BASE+39, "ar39" },
2311 { REG_AR_BASE+40, "ar40" },
2312 { REG_AR_BASE+41, "ar41" },
2313 { REG_AR_BASE+42, "ar42" },
2314 { REG_AR_BASE+43, "ar43" },
2315 { REG_AR_BASE+44, "ar44" },
2316 { REG_AR_BASE+45, "ar45" },
2317 { REG_AR_BASE+46, "ar46" },
2318 { REG_AR_BASE+47, "ar47" },
2319 { REG_AR_BASE+48, "ar48" },
2320 { REG_AR_BASE+49, "ar49" },
2321 { REG_AR_BASE+50, "ar50" },
2322 { REG_AR_BASE+51, "ar51" },
2323 { REG_AR_BASE+52, "ar52" },
2324 { REG_AR_BASE+53, "ar53" },
2325 { REG_AR_BASE+54, "ar54" },
2326 { REG_AR_BASE+55, "ar55" },
2327 { REG_AR_BASE+56, "ar56" },
2328 { REG_AR_BASE+57, "ar57" },
2329 { REG_AR_BASE+58, "ar58" },
2330 { REG_AR_BASE+59, "ar59" },
2331 { REG_AR_BASE+60, "ar60" },
2332 { REG_AR_BASE+61, "ar61" },
2333 { REG_AR_BASE+62, "ar62" },
2334 { REG_AR_BASE+63, "ar63" },
2335 { REG_LBEG, "lbeg" },
2336 { REG_LEND, "lend" },
2337 { REG_LCOUNT, "lcount" },
2338 { REG_SAR, "sar" },
2339 { REG_WB, "wb" },
2340 { REG_WS, "ws" },
2341 { REG_PS, "ps" },
2342 { REG_PC, "pc" },
2343 { REG_A_BASE, "a0" },
2344 { REG_A_BASE+1, "a1" },
2345 { REG_A_BASE+2, "a2" },
2346 { REG_A_BASE+3, "a3" },
2347 { REG_A_BASE+4, "a4" },
2348 { REG_A_BASE+5, "a5" },
2349 { REG_A_BASE+6, "a6" },
2350 { REG_A_BASE+7, "a7" },
2351 { REG_A_BASE+8, "a8" },
2352 { REG_A_BASE+9, "a9" },
2353 { REG_A_BASE+10, "a10" },
2354 { REG_A_BASE+11, "a11" },
2355 { REG_A_BASE+12, "a12" },
2356 { REG_A_BASE+13, "a13" },
2357 { REG_A_BASE+14, "a14" },
2358 { REG_A_BASE+15, "a15" },
2359#endif
2360
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002361 /* Other fields in "struct user" */
2362#if defined(S390) || defined(S390X)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002363 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2364 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2365 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002366 { uoff(start_code), "offsetof(struct user, start_code)" },
2367 /* S390[X] has no start_data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002368 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2369 { uoff(signal), "offsetof(struct user, signal)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002370 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002371 { uoff(magic), "offsetof(struct user, magic)" },
2372 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002373 { sizeof(struct user), "sizeof(struct user)" },
2374#elif defined(POWERPC)
2375 { sizeof(struct user), "sizeof(struct user)" },
2376#elif defined(I386) || defined(X86_64) || defined(X32)
2377 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2378 { uoff(i387), "offsetof(struct user, i387)" },
2379 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2380 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2381 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2382 { uoff(start_code), "offsetof(struct user, start_code)" },
2383 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2384 { uoff(signal), "offsetof(struct user, signal)" },
2385 { uoff(reserved), "offsetof(struct user, reserved)" },
2386 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2387 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2388 { uoff(magic), "offsetof(struct user, magic)" },
2389 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002390 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002391 { sizeof(struct user), "sizeof(struct user)" },
2392#elif defined(IA64)
2393 { sizeof(struct user), "sizeof(struct user)" },
2394#elif defined(ARM)
2395 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2396 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2397 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2398 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2399 { uoff(start_code), "offsetof(struct user, start_code)" },
2400 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2401 { uoff(signal), "offsetof(struct user, signal)" },
2402 { uoff(reserved), "offsetof(struct user, reserved)" },
2403 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2404 { uoff(magic), "offsetof(struct user, magic)" },
2405 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2406 { sizeof(struct user), "sizeof(struct user)" },
2407#elif defined(AARCH64)
2408 /* nothing */
2409#elif defined(M68K)
2410 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2411 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2412 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2413 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2414 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2415 { uoff(start_code), "offsetof(struct user, start_code)" },
2416 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2417 { uoff(signal), "offsetof(struct user, signal)" },
2418 { uoff(reserved), "offsetof(struct user, reserved)" },
2419 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2420 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2421 { uoff(magic), "offsetof(struct user, magic)" },
2422 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2423 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002424#elif defined(MIPS) || defined(LINUX_MIPSN32)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002425 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2426 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2427 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2428 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002429 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002430 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2431 { uoff(signal), "offsetof(struct user, signal)" },
2432 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2433 { uoff(magic), "offsetof(struct user, magic)" },
2434 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2435 { sizeof(struct user), "sizeof(struct user)" },
2436#elif defined(ALPHA)
2437 { sizeof(struct user), "sizeof(struct user)" },
2438#elif defined(SPARC)
2439 { sizeof(struct user), "sizeof(struct user)" },
2440#elif defined(SPARC64)
2441 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2442 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2443 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2444 { uoff(signal), "offsetof(struct user, signal)" },
2445 { uoff(magic), "offsetof(struct user, magic)" },
2446 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2447 { sizeof(struct user), "sizeof(struct user)" },
2448#elif defined(HPPA)
2449 /* nothing */
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002450#elif defined(SH) || defined(SH64)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002451 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2452 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2453 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2454 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2455 { uoff(start_code), "offsetof(struct user, start_code)" },
2456 { uoff(start_data), "offsetof(struct user, start_data)" },
2457 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2458 { uoff(signal), "offsetof(struct user, signal)" },
2459 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2460 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2461 { uoff(magic), "offsetof(struct user, magic)" },
2462 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2463 { sizeof(struct user), "sizeof(struct user)" },
2464#elif defined(CRISV10) || defined(CRISV32)
2465 { sizeof(struct user), "sizeof(struct user)" },
2466#elif defined(TILE)
2467 /* nothing */
2468#elif defined(MICROBLAZE)
2469 { sizeof(struct user), "sizeof(struct user)" },
2470#elif defined(AVR32)
2471 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2472 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2473 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2474 { uoff(start_code), "offsetof(struct user, start_code)" },
2475 { uoff(start_data), "offsetof(struct user, start_data)" },
2476 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2477 { uoff(signal), "offsetof(struct user, signal)" },
2478 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2479 { uoff(magic), "offsetof(struct user, magic)" },
2480 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2481 { sizeof(struct user), "sizeof(struct user)" },
2482#elif defined(BFIN)
2483 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2484 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2485 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2486 { uoff(start_code), "offsetof(struct user, start_code)" },
2487 { uoff(signal), "offsetof(struct user, signal)" },
2488 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2489 { uoff(magic), "offsetof(struct user, magic)" },
2490 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002491 { sizeof(struct user), "sizeof(struct user)" },
Christian Svensson492f81f2013-02-14 13:26:27 +01002492#elif defined(OR1K)
2493 /* nothing */
James Hogan5f999a82013-02-22 14:44:10 +00002494#elif defined(METAG)
2495 /* nothing */
Chris Zankel8f636ed2013-03-25 10:22:07 -07002496#elif defined(XTENSA)
2497 /* nothing */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002498#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002499 { 0, NULL },
2500};
2501
2502int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002503sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002504{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002505 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002506 long addr;
2507
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002508 if (entering(tcp)) {
Denys Vlasenkob7a6dae2012-03-20 16:48:35 +01002509 printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
Roland McGrathbf621d42003-01-14 09:46:21 +00002510 tprintf(", %lu, ", tcp->u_arg[1]);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002511
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002512 addr = tcp->u_arg[2];
2513 if (tcp->u_arg[0] == PTRACE_PEEKUSER
Denys Vlasenkobe994972013-02-13 16:10:10 +01002514 || tcp->u_arg[0] == PTRACE_POKEUSER
2515 ) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002516 for (x = struct_user_offsets; x->str; x++) {
2517 if (x->val >= addr)
2518 break;
2519 }
2520 if (!x->str)
2521 tprintf("%#lx, ", addr);
2522 else if (x->val > addr && x != struct_user_offsets) {
2523 x--;
2524 tprintf("%s + %ld, ", x->str, addr - x->val);
2525 }
2526 else
2527 tprintf("%s, ", x->str);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002528 } else
2529#ifdef PTRACE_GETREGSET
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00002530 if (tcp->u_arg[0] == PTRACE_GETREGSET
2531 || tcp->u_arg[0] == PTRACE_SETREGSET
2532 ) {
2533 printxval(nt_descriptor_types, tcp->u_arg[2], "NT_???");
2534 tprints(", ");
2535 } else
Denys Vlasenkobe994972013-02-13 16:10:10 +01002536#endif
2537 tprintf("%#lx, ", addr);
2538
2539
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002540 switch (tcp->u_arg[0]) {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002541#ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002542 case PTRACE_PEEKDATA:
2543 case PTRACE_PEEKTEXT:
2544 case PTRACE_PEEKUSER:
2545 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002546#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002547 case PTRACE_CONT:
2548 case PTRACE_SINGLESTEP:
2549 case PTRACE_SYSCALL:
2550 case PTRACE_DETACH:
2551 printsignal(tcp->u_arg[3]);
2552 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002553#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002554 case PTRACE_SETOPTIONS:
2555 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2556 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002557#endif
2558#ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002559 case PTRACE_SETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002560 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002561 break;
2562 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002563#endif
2564#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002565 case PTRACE_GETSIGINFO:
2566 /* Don't print anything, do it at syscall return. */
2567 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002568#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002569#ifdef PTRACE_GETREGSET
2570 case PTRACE_GETREGSET:
2571 break;
2572 case PTRACE_SETREGSET:
2573 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2574 break;
2575#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002576 default:
2577 tprintf("%#lx", tcp->u_arg[3]);
2578 break;
2579 }
2580 } else {
2581 switch (tcp->u_arg[0]) {
2582 case PTRACE_PEEKDATA:
2583 case PTRACE_PEEKTEXT:
2584 case PTRACE_PEEKUSER:
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002585#ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002586 return RVAL_HEX;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002587#else
Roland McGratheb285352003-01-14 09:59:00 +00002588 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002589 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002590#endif
2591#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002592 case PTRACE_GETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002593 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002594 break;
2595 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002596#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002597#ifdef PTRACE_GETREGSET
2598 case PTRACE_GETREGSET:
2599 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2600 break;
2601#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002602 }
2603 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002604 return 0;
2605}
2606
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002607#ifndef FUTEX_CMP_REQUEUE
2608# define FUTEX_CMP_REQUEUE 4
2609#endif
2610#ifndef FUTEX_WAKE_OP
2611# define FUTEX_WAKE_OP 5
2612#endif
2613#ifndef FUTEX_LOCK_PI
2614# define FUTEX_LOCK_PI 6
2615# define FUTEX_UNLOCK_PI 7
2616# define FUTEX_TRYLOCK_PI 8
2617#endif
2618#ifndef FUTEX_WAIT_BITSET
2619# define FUTEX_WAIT_BITSET 9
2620#endif
2621#ifndef FUTEX_WAKE_BITSET
2622# define FUTEX_WAKE_BITSET 10
2623#endif
2624#ifndef FUTEX_WAIT_REQUEUE_PI
2625# define FUTEX_WAIT_REQUEUE_PI 11
2626#endif
2627#ifndef FUTEX_CMP_REQUEUE_PI
2628# define FUTEX_CMP_REQUEUE_PI 12
2629#endif
2630#ifndef FUTEX_PRIVATE_FLAG
2631# define FUTEX_PRIVATE_FLAG 128
2632#endif
2633#ifndef FUTEX_CLOCK_REALTIME
2634# define FUTEX_CLOCK_REALTIME 256
2635#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002636static const struct xlat futexops[] = {
Roland McGrath51942a92007-07-05 18:59:11 +00002637 { FUTEX_WAIT, "FUTEX_WAIT" },
2638 { FUTEX_WAKE, "FUTEX_WAKE" },
2639 { FUTEX_FD, "FUTEX_FD" },
2640 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2641 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2642 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2643 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2644 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2645 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002646 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2647 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002648 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2649 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
Roland McGrath51942a92007-07-05 18:59:11 +00002650 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2651 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2652 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2653 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2654 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2655 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2656 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2657 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2658 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002659 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2660 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002661 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2662 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2663 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2664 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2665 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2666 { 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 +00002667 { 0, NULL }
2668};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002669#ifndef FUTEX_OP_SET
2670# define FUTEX_OP_SET 0
2671# define FUTEX_OP_ADD 1
2672# define FUTEX_OP_OR 2
2673# define FUTEX_OP_ANDN 3
2674# define FUTEX_OP_XOR 4
2675# define FUTEX_OP_CMP_EQ 0
2676# define FUTEX_OP_CMP_NE 1
2677# define FUTEX_OP_CMP_LT 2
2678# define FUTEX_OP_CMP_LE 3
2679# define FUTEX_OP_CMP_GT 4
2680# define FUTEX_OP_CMP_GE 5
2681#endif
Roland McGrath51942a92007-07-05 18:59:11 +00002682static const struct xlat futexwakeops[] = {
2683 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2684 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2685 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2686 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2687 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2688 { 0, NULL }
2689};
2690static const struct xlat futexwakecmps[] = {
2691 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2692 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2693 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2694 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2695 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2696 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2697 { 0, NULL }
Roland McGrath5a223472002-12-15 23:58:26 +00002698};
2699
2700int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002701sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002702{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002703 if (entering(tcp)) {
2704 long int cmd = tcp->u_arg[1] & 127;
2705 tprintf("%p, ", (void *) tcp->u_arg[0]);
2706 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2707 tprintf(", %ld", tcp->u_arg[2]);
2708 if (cmd == FUTEX_WAKE_BITSET)
2709 tprintf(", %lx", tcp->u_arg[5]);
2710 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002711 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002712 printtv(tcp, tcp->u_arg[3]);
2713 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002714 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002715 printtv(tcp, tcp->u_arg[3]);
2716 tprintf(", %lx", tcp->u_arg[5]);
2717 } else if (cmd == FUTEX_REQUEUE)
2718 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002719 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002720 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2721 else if (cmd == FUTEX_WAKE_OP) {
2722 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2723 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002724 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002725 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2726 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2727 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002728 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002729 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2730 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002731 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002732 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002733 printtv(tcp, tcp->u_arg[3]);
2734 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002735 }
Roland McGrath51942a92007-07-05 18:59:11 +00002736 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002737 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002738}
2739
2740static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002741print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002742{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002743 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002744 unsigned long w, min_len;
2745
2746 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2747 min_len = len - max_strlen * sizeof(w);
2748 else
2749 min_len = 0;
2750 for (; len >= sizeof(w) && len > min_len;
2751 len -= sizeof(w), list += sizeof(w)) {
2752 if (umove(tcp, list, &w) < 0)
2753 break;
2754 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002755 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002756 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002757 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002758 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002759 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002760 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002761 if (len) {
2762 if (first)
2763 tprintf("%#lx", list);
2764 else
2765 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2766 "???" : "..."));
2767 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002768 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002769 }
Roland McGrath5a223472002-12-15 23:58:26 +00002770}
2771
2772int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002773sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002774{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002775 if (entering(tcp)) {
2776 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2777 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2778 }
2779 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002780}
2781
2782int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002783sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002784{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002785 if (entering(tcp)) {
2786 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2787 } else {
2788 if (tcp->u_rval == -1)
2789 tprintf("%#lx", tcp->u_arg[2]);
2790 else
2791 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2792 }
2793 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002794}
Roland McGrath279d3782004-03-01 20:27:37 +00002795
Dmitry V. Levin1b0bae22012-03-11 22:32:26 +00002796int
2797sys_get_robust_list(struct tcb *tcp)
2798{
2799 if (entering(tcp)) {
2800 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2801 } else {
2802 void *addr;
2803 size_t len;
2804
2805 if (syserror(tcp) ||
2806 !tcp->u_arg[1] ||
2807 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2808 tprintf("%#lx, ", tcp->u_arg[1]);
2809 } else {
2810 tprintf("[%p], ", addr);
2811 }
2812
2813 if (syserror(tcp) ||
2814 !tcp->u_arg[2] ||
2815 umove(tcp, tcp->u_arg[2], &len) < 0) {
2816 tprintf("%#lx", tcp->u_arg[2]);
2817 } else {
2818 tprintf("[%lu]", (unsigned long) len);
2819 }
2820 }
2821 return 0;
2822}
2823
Roland McGrathd9f816f2004-09-04 03:39:20 +00002824static const struct xlat schedulers[] = {
Roland McGrath279d3782004-03-01 20:27:37 +00002825 { SCHED_OTHER, "SCHED_OTHER" },
2826 { SCHED_RR, "SCHED_RR" },
2827 { SCHED_FIFO, "SCHED_FIFO" },
2828 { 0, NULL }
2829};
2830
2831int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002832sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002833{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002834 if (entering(tcp)) {
2835 tprintf("%d", (int) tcp->u_arg[0]);
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002836 } else if (!syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002837 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002838 if (tcp->auxstr != NULL)
2839 return RVAL_STR;
2840 }
2841 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002842}
2843
2844int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002845sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002846{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002847 if (entering(tcp)) {
2848 struct sched_param p;
2849 tprintf("%d, ", (int) tcp->u_arg[0]);
2850 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2851 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2852 tprintf(", %#lx", tcp->u_arg[2]);
2853 else
2854 tprintf(", { %d }", p.__sched_priority);
2855 }
2856 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002857}
2858
2859int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002860sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002861{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002862 if (entering(tcp)) {
2863 tprintf("%d, ", (int) tcp->u_arg[0]);
2864 } else {
2865 struct sched_param p;
2866 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2867 tprintf("%#lx", tcp->u_arg[1]);
2868 else
2869 tprintf("{ %d }", p.__sched_priority);
2870 }
2871 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002872}
2873
2874int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002875sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002876{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002877 if (entering(tcp)) {
2878 struct sched_param p;
2879 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2880 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2881 else
2882 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2883 }
2884 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002885}
2886
2887int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002888sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002889{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002890 if (entering(tcp)) {
2891 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2892 }
2893 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002894}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002895
Dmitry V. Levin1ff463d2012-03-11 23:00:11 +00002896int
2897sys_sched_rr_get_interval(struct tcb *tcp)
2898{
2899 if (entering(tcp)) {
2900 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2901 } else {
2902 if (syserror(tcp))
2903 tprintf("%#lx", tcp->u_arg[1]);
2904 else
2905 print_timespec(tcp, tcp->u_arg[1]);
2906 }
2907 return 0;
2908}
2909
H.J. Lu35be5812012-04-16 13:00:01 +02002910#if defined X86_64 || defined X32
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002911# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002912
2913static const struct xlat archvals[] = {
2914 { ARCH_SET_GS, "ARCH_SET_GS" },
2915 { ARCH_SET_FS, "ARCH_SET_FS" },
2916 { ARCH_GET_FS, "ARCH_GET_FS" },
2917 { ARCH_GET_GS, "ARCH_GET_GS" },
2918 { 0, NULL },
2919};
2920
2921int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002922sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002923{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002924 if (entering(tcp)) {
2925 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2926 if (tcp->u_arg[0] == ARCH_SET_GS
2927 || tcp->u_arg[0] == ARCH_SET_FS
2928 ) {
2929 tprintf(", %#lx", tcp->u_arg[1]);
2930 }
2931 } else {
2932 if (tcp->u_arg[0] == ARCH_GET_GS
2933 || tcp->u_arg[0] == ARCH_GET_FS
2934 ) {
2935 long int v;
2936 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2937 tprintf(", [%#lx]", v);
2938 else
2939 tprintf(", %#lx", tcp->u_arg[1]);
2940 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002941 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002942 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002943}
H.J. Lu35be5812012-04-16 13:00:01 +02002944#endif /* X86_64 || X32 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002945
Roland McGrathdb8319f2007-08-02 01:37:55 +00002946int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002947sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002948{
2949 if (exiting(tcp)) {
2950 unsigned u;
2951 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002952 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002953 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
2954 tprintf("%#lx, ", tcp->u_arg[0]);
2955 else
2956 tprintf("[%u], ", u);
2957 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002958 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002959 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2960 tprintf("%#lx, ", tcp->u_arg[1]);
2961 else
2962 tprintf("[%u], ", u);
2963 tprintf("%#lx", tcp->u_arg[2]);
2964 }
2965 return 0;
2966}
2967
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002968int
2969sys_process_vm_readv(struct tcb *tcp)
2970{
2971 if (entering(tcp)) {
2972 /* arg 1: pid */
2973 tprintf("%ld, ", tcp->u_arg[0]);
2974 } else {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002975 /* arg 2: local iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002976 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002977 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002978 } else {
2979 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2980 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002981 /* arg 3: local iovcnt */
2982 tprintf(", %lu, ", tcp->u_arg[2]);
2983 /* arg 4: remote iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002984 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002985 tprintf("%#lx", tcp->u_arg[3]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002986 } else {
2987 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2988 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002989 /* arg 5: remote iovcnt */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002990 /* arg 6: flags */
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002991 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002992 }
2993 return 0;
2994}
Dmitry V. Levin03952102012-03-10 14:14:49 +00002995
2996int
2997sys_process_vm_writev(struct tcb *tcp)
2998{
2999 if (entering(tcp)) {
3000 /* arg 1: pid */
3001 tprintf("%ld, ", tcp->u_arg[0]);
3002 /* arg 2: local iov */
3003 if (syserror(tcp))
3004 tprintf("%#lx", tcp->u_arg[1]);
3005 else
3006 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
3007 /* arg 3: local iovcnt */
3008 tprintf(", %lu, ", tcp->u_arg[2]);
3009 /* arg 4: remote iov */
3010 if (syserror(tcp))
3011 tprintf("%#lx", tcp->u_arg[3]);
3012 else
3013 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
3014 /* arg 5: remote iovcnt */
3015 /* arg 6: flags */
3016 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
3017 }
3018 return 0;
3019}