blob: 799a314d69f939d6678ee69b3acef3cddad177ab [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
Dmitry V. Levinf7822012013-05-17 22:22:19 +00001326# ifdef PTRACE_O_TRACESECCOMP
1327 { PTRACE_O_TRACESECCOMP,"PTRACE_O_TRACESECCOMP" },
1328# endif
1329# ifdef PTRACE_O_EXITKILL
1330 { PTRACE_O_EXITKILL, "PTRACE_O_EXITKILL" },
1331# endif
Denys Vlasenkof535b542009-01-13 18:30:55 +00001332 { 0, NULL },
1333};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001334#endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001335
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001336static const struct xlat nt_descriptor_types[] = {
1337#ifdef NT_PRSTATUS
1338 { NT_PRSTATUS, "NT_PRSTATUS" },
1339#endif
1340#ifdef NT_FPREGSET
1341 { NT_FPREGSET, "NT_FPREGSET" },
1342#endif
1343#ifdef NT_PRPSINFO
1344 { NT_PRPSINFO, "NT_PRPSINFO" },
1345#endif
1346#ifdef NT_PRXREG
1347 { NT_PRXREG, "NT_PRXREG" },
1348#endif
1349#ifdef NT_TASKSTRUCT
1350 { NT_TASKSTRUCT, "NT_TASKSTRUCT" },
1351#endif
1352#ifdef NT_PLATFORM
1353 { NT_PLATFORM, "NT_PLATFORM" },
1354#endif
1355#ifdef NT_AUXV
1356 { NT_AUXV, "NT_AUXV" },
1357#endif
1358#ifdef NT_GWINDOWS
1359 { NT_GWINDOWS, "NT_GWINDOWS" },
1360#endif
1361#ifdef NT_ASRS
1362 { NT_ASRS, "NT_ASRS" },
1363#endif
1364#ifdef NT_PSTATUS
1365 { NT_PSTATUS, "NT_PSTATUS" },
1366#endif
1367#ifdef NT_PSINFO
1368 { NT_PSINFO, "NT_PSINFO" },
1369#endif
1370#ifdef NT_PRCRED
1371 { NT_PRCRED, "NT_PRCRED" },
1372#endif
1373#ifdef NT_UTSNAME
1374 { NT_UTSNAME, "NT_UTSNAME" },
1375#endif
1376#ifdef NT_LWPSTATUS
1377 { NT_LWPSTATUS, "NT_LWPSTATUS" },
1378#endif
1379#ifdef NT_LWPSINFO
1380 { NT_LWPSINFO, "NT_LWPSINFO" },
1381#endif
1382#ifdef NT_PRFPXREG
1383 { NT_PRFPXREG, "NT_PRFPXREG" },
1384#endif
1385#ifdef NT_PRXFPREG
1386 { NT_PRXFPREG, "NT_PRXFPREG" },
1387#endif
1388#ifdef NT_PPC_VMX
1389 { NT_PPC_VMX, "NT_PPC_VMX" },
1390#endif
1391#ifdef NT_PPC_SPE
1392 { NT_PPC_SPE, "NT_PPC_SPE" },
1393#endif
1394#ifdef NT_PPC_VSX
1395 { NT_PPC_VSX, "NT_PPC_VSX" },
1396#endif
1397#ifdef NT_386_TLS
1398 { NT_386_TLS, "NT_386_TLS" },
1399#endif
1400#ifdef NT_386_IOPERM
1401 { NT_386_IOPERM, "NT_386_IOPERM" },
1402#endif
1403#ifdef NT_X86_XSTATE
1404 { NT_X86_XSTATE, "NT_X86_XSTATE" },
1405#endif
1406 { 0, NULL },
1407};
1408
Denys Vlasenko513e9c22012-03-21 14:39:22 +01001409#define uoff(member) offsetof(struct user, member)
1410
Roland McGrathd9f816f2004-09-04 03:39:20 +00001411const struct xlat struct_user_offsets[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001412#if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001413 { PT_PSWMASK, "psw_mask" },
1414 { PT_PSWADDR, "psw_addr" },
1415 { PT_GPR0, "gpr0" },
1416 { PT_GPR1, "gpr1" },
1417 { PT_GPR2, "gpr2" },
1418 { PT_GPR3, "gpr3" },
1419 { PT_GPR4, "gpr4" },
1420 { PT_GPR5, "gpr5" },
1421 { PT_GPR6, "gpr6" },
1422 { PT_GPR7, "gpr7" },
1423 { PT_GPR8, "gpr8" },
1424 { PT_GPR9, "gpr9" },
1425 { PT_GPR10, "gpr10" },
1426 { PT_GPR11, "gpr11" },
1427 { PT_GPR12, "gpr12" },
1428 { PT_GPR13, "gpr13" },
1429 { PT_GPR14, "gpr14" },
1430 { PT_GPR15, "gpr15" },
1431 { PT_ACR0, "acr0" },
1432 { PT_ACR1, "acr1" },
1433 { PT_ACR2, "acr2" },
1434 { PT_ACR3, "acr3" },
1435 { PT_ACR4, "acr4" },
1436 { PT_ACR5, "acr5" },
1437 { PT_ACR6, "acr6" },
1438 { PT_ACR7, "acr7" },
1439 { PT_ACR8, "acr8" },
1440 { PT_ACR9, "acr9" },
1441 { PT_ACR10, "acr10" },
1442 { PT_ACR11, "acr11" },
1443 { PT_ACR12, "acr12" },
1444 { PT_ACR13, "acr13" },
1445 { PT_ACR14, "acr14" },
1446 { PT_ACR15, "acr15" },
1447 { PT_ORIGGPR2, "orig_gpr2" },
1448 { PT_FPC, "fpc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001449#if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001450 { PT_FPR0_HI, "fpr0.hi" },
1451 { PT_FPR0_LO, "fpr0.lo" },
1452 { PT_FPR1_HI, "fpr1.hi" },
1453 { PT_FPR1_LO, "fpr1.lo" },
1454 { PT_FPR2_HI, "fpr2.hi" },
1455 { PT_FPR2_LO, "fpr2.lo" },
1456 { PT_FPR3_HI, "fpr3.hi" },
1457 { PT_FPR3_LO, "fpr3.lo" },
1458 { PT_FPR4_HI, "fpr4.hi" },
1459 { PT_FPR4_LO, "fpr4.lo" },
1460 { PT_FPR5_HI, "fpr5.hi" },
1461 { PT_FPR5_LO, "fpr5.lo" },
1462 { PT_FPR6_HI, "fpr6.hi" },
1463 { PT_FPR6_LO, "fpr6.lo" },
1464 { PT_FPR7_HI, "fpr7.hi" },
1465 { PT_FPR7_LO, "fpr7.lo" },
1466 { PT_FPR8_HI, "fpr8.hi" },
1467 { PT_FPR8_LO, "fpr8.lo" },
1468 { PT_FPR9_HI, "fpr9.hi" },
1469 { PT_FPR9_LO, "fpr9.lo" },
1470 { PT_FPR10_HI, "fpr10.hi" },
1471 { PT_FPR10_LO, "fpr10.lo" },
1472 { PT_FPR11_HI, "fpr11.hi" },
1473 { PT_FPR11_LO, "fpr11.lo" },
1474 { PT_FPR12_HI, "fpr12.hi" },
1475 { PT_FPR12_LO, "fpr12.lo" },
1476 { PT_FPR13_HI, "fpr13.hi" },
1477 { PT_FPR13_LO, "fpr13.lo" },
1478 { PT_FPR14_HI, "fpr14.hi" },
1479 { PT_FPR14_LO, "fpr14.lo" },
1480 { PT_FPR15_HI, "fpr15.hi" },
1481 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001482#endif
1483#if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001484 { PT_FPR0, "fpr0" },
1485 { PT_FPR1, "fpr1" },
1486 { PT_FPR2, "fpr2" },
1487 { PT_FPR3, "fpr3" },
1488 { PT_FPR4, "fpr4" },
1489 { PT_FPR5, "fpr5" },
1490 { PT_FPR6, "fpr6" },
1491 { PT_FPR7, "fpr7" },
1492 { PT_FPR8, "fpr8" },
1493 { PT_FPR9, "fpr9" },
1494 { PT_FPR10, "fpr10" },
1495 { PT_FPR11, "fpr11" },
1496 { PT_FPR12, "fpr12" },
1497 { PT_FPR13, "fpr13" },
1498 { PT_FPR14, "fpr14" },
1499 { PT_FPR15, "fpr15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001500#endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001501 { PT_CR_9, "cr9" },
1502 { PT_CR_10, "cr10" },
1503 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001504 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001505#elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001506 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001507#elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001508 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001509#elif defined(POWERPC)
1510# ifndef PT_ORIG_R3
1511# define PT_ORIG_R3 34
1512# endif
1513# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001514 { REGSIZE*PT_R0, "r0" },
1515 { REGSIZE*PT_R1, "r1" },
1516 { REGSIZE*PT_R2, "r2" },
1517 { REGSIZE*PT_R3, "r3" },
1518 { REGSIZE*PT_R4, "r4" },
1519 { REGSIZE*PT_R5, "r5" },
1520 { REGSIZE*PT_R6, "r6" },
1521 { REGSIZE*PT_R7, "r7" },
1522 { REGSIZE*PT_R8, "r8" },
1523 { REGSIZE*PT_R9, "r9" },
1524 { REGSIZE*PT_R10, "r10" },
1525 { REGSIZE*PT_R11, "r11" },
1526 { REGSIZE*PT_R12, "r12" },
1527 { REGSIZE*PT_R13, "r13" },
1528 { REGSIZE*PT_R14, "r14" },
1529 { REGSIZE*PT_R15, "r15" },
1530 { REGSIZE*PT_R16, "r16" },
1531 { REGSIZE*PT_R17, "r17" },
1532 { REGSIZE*PT_R18, "r18" },
1533 { REGSIZE*PT_R19, "r19" },
1534 { REGSIZE*PT_R20, "r20" },
1535 { REGSIZE*PT_R21, "r21" },
1536 { REGSIZE*PT_R22, "r22" },
1537 { REGSIZE*PT_R23, "r23" },
1538 { REGSIZE*PT_R24, "r24" },
1539 { REGSIZE*PT_R25, "r25" },
1540 { REGSIZE*PT_R26, "r26" },
1541 { REGSIZE*PT_R27, "r27" },
1542 { REGSIZE*PT_R28, "r28" },
1543 { REGSIZE*PT_R29, "r29" },
1544 { REGSIZE*PT_R30, "r30" },
1545 { REGSIZE*PT_R31, "r31" },
1546 { REGSIZE*PT_NIP, "NIP" },
1547 { REGSIZE*PT_MSR, "MSR" },
1548 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1549 { REGSIZE*PT_CTR, "CTR" },
1550 { REGSIZE*PT_LNK, "LNK" },
1551 { REGSIZE*PT_XER, "XER" },
1552 { REGSIZE*PT_CCR, "CCR" },
1553 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001554# undef REGSIZE
1555#elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001556 { 0, "r0" },
1557 { 1, "r1" },
1558 { 2, "r2" },
1559 { 3, "r3" },
1560 { 4, "r4" },
1561 { 5, "r5" },
1562 { 6, "r6" },
1563 { 7, "r7" },
1564 { 8, "r8" },
1565 { 9, "r9" },
1566 { 10, "r10" },
1567 { 11, "r11" },
1568 { 12, "r12" },
1569 { 13, "r13" },
1570 { 14, "r14" },
1571 { 15, "r15" },
1572 { 16, "r16" },
1573 { 17, "r17" },
1574 { 18, "r18" },
1575 { 19, "r19" },
1576 { 20, "r20" },
1577 { 21, "r21" },
1578 { 22, "r22" },
1579 { 23, "r23" },
1580 { 24, "r24" },
1581 { 25, "r25" },
1582 { 26, "r26" },
1583 { 27, "r27" },
1584 { 28, "r28" },
1585 { 29, "gp" },
1586 { 30, "fp" },
1587 { 31, "zero" },
1588 { 32, "fp0" },
1589 { 33, "fp" },
1590 { 34, "fp2" },
1591 { 35, "fp3" },
1592 { 36, "fp4" },
1593 { 37, "fp5" },
1594 { 38, "fp6" },
1595 { 39, "fp7" },
1596 { 40, "fp8" },
1597 { 41, "fp9" },
1598 { 42, "fp10" },
1599 { 43, "fp11" },
1600 { 44, "fp12" },
1601 { 45, "fp13" },
1602 { 46, "fp14" },
1603 { 47, "fp15" },
1604 { 48, "fp16" },
1605 { 49, "fp17" },
1606 { 50, "fp18" },
1607 { 51, "fp19" },
1608 { 52, "fp20" },
1609 { 53, "fp21" },
1610 { 54, "fp22" },
1611 { 55, "fp23" },
1612 { 56, "fp24" },
1613 { 57, "fp25" },
1614 { 58, "fp26" },
1615 { 59, "fp27" },
1616 { 60, "fp28" },
1617 { 61, "fp29" },
1618 { 62, "fp30" },
1619 { 63, "fp31" },
1620 { 64, "pc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001621#elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001622 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1623 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1624 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1625 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1626 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1627 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1628 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1629 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1630 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1631 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1632 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1633 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1634 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1635 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1636 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1637 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1638 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1639 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1640 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1641 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1642 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1643 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1644 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1645 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1646 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1647 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1648 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1649 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1650 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1651 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1652 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1653 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1654 /* switch stack: */
1655 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1656 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1657 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1658 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1659 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1660 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1661 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1662 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1663 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1664 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001665 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1666 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001667 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001668 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001669 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1670 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001671 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1672 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1673 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1674 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1675 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1676 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1677 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1678 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1679 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1680 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1681 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1682 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1683 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1684 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1685 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001686# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001687 { PT_AR_CSD, "ar.csd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001688# endif
1689# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001690 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001691# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001692 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001693#elif defined(I386)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001694 { 4*EBX, "4*EBX" },
1695 { 4*ECX, "4*ECX" },
1696 { 4*EDX, "4*EDX" },
1697 { 4*ESI, "4*ESI" },
1698 { 4*EDI, "4*EDI" },
1699 { 4*EBP, "4*EBP" },
1700 { 4*EAX, "4*EAX" },
1701 { 4*DS, "4*DS" },
1702 { 4*ES, "4*ES" },
1703 { 4*FS, "4*FS" },
1704 { 4*GS, "4*GS" },
1705 { 4*ORIG_EAX, "4*ORIG_EAX" },
1706 { 4*EIP, "4*EIP" },
1707 { 4*CS, "4*CS" },
1708 { 4*EFL, "4*EFL" },
1709 { 4*UESP, "4*UESP" },
1710 { 4*SS, "4*SS" },
H.J. Lu35be5812012-04-16 13:00:01 +02001711#elif defined(X86_64) || defined(X32)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001712 { 8*R15, "8*R15" },
1713 { 8*R14, "8*R14" },
1714 { 8*R13, "8*R13" },
1715 { 8*R12, "8*R12" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001716 { 8*RBP, "8*RBP" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001717 { 8*RBX, "8*RBX" },
1718 { 8*R11, "8*R11" },
1719 { 8*R10, "8*R10" },
1720 { 8*R9, "8*R9" },
1721 { 8*R8, "8*R8" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001722 { 8*RAX, "8*RAX" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001723 { 8*RCX, "8*RCX" },
1724 { 8*RDX, "8*RDX" },
1725 { 8*RSI, "8*RSI" },
1726 { 8*RDI, "8*RDI" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001727 { 8*ORIG_RAX, "8*ORIG_RAX" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001728 { 8*RIP, "8*RIP" },
1729 { 8*CS, "8*CS" },
1730 { 8*EFLAGS, "8*EFL" },
Roland McGratha4f9f2d2005-06-07 23:21:20 +00001731 { 8*RSP, "8*RSP" },
Michal Ludvig0e035502002-09-23 15:41:01 +00001732 { 8*SS, "8*SS" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001733#elif defined(M68K)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001734 { 4*PT_D1, "4*PT_D1" },
1735 { 4*PT_D2, "4*PT_D2" },
1736 { 4*PT_D3, "4*PT_D3" },
1737 { 4*PT_D4, "4*PT_D4" },
1738 { 4*PT_D5, "4*PT_D5" },
1739 { 4*PT_D6, "4*PT_D6" },
1740 { 4*PT_D7, "4*PT_D7" },
1741 { 4*PT_A0, "4*PT_A0" },
1742 { 4*PT_A1, "4*PT_A1" },
1743 { 4*PT_A2, "4*PT_A2" },
1744 { 4*PT_A3, "4*PT_A3" },
1745 { 4*PT_A4, "4*PT_A4" },
1746 { 4*PT_A5, "4*PT_A5" },
1747 { 4*PT_A6, "4*PT_A6" },
1748 { 4*PT_D0, "4*PT_D0" },
1749 { 4*PT_USP, "4*PT_USP" },
1750 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1751 { 4*PT_SR, "4*PT_SR" },
1752 { 4*PT_PC, "4*PT_PC" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001753#elif defined(SH)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001754 { 4*REG_REG0, "4*REG_REG0" },
1755 { 4*(REG_REG0+1), "4*REG_REG1" },
1756 { 4*(REG_REG0+2), "4*REG_REG2" },
1757 { 4*(REG_REG0+3), "4*REG_REG3" },
1758 { 4*(REG_REG0+4), "4*REG_REG4" },
1759 { 4*(REG_REG0+5), "4*REG_REG5" },
1760 { 4*(REG_REG0+6), "4*REG_REG6" },
1761 { 4*(REG_REG0+7), "4*REG_REG7" },
1762 { 4*(REG_REG0+8), "4*REG_REG8" },
1763 { 4*(REG_REG0+9), "4*REG_REG9" },
1764 { 4*(REG_REG0+10), "4*REG_REG10" },
1765 { 4*(REG_REG0+11), "4*REG_REG11" },
1766 { 4*(REG_REG0+12), "4*REG_REG12" },
1767 { 4*(REG_REG0+13), "4*REG_REG13" },
1768 { 4*(REG_REG0+14), "4*REG_REG14" },
1769 { 4*REG_REG15, "4*REG_REG15" },
1770 { 4*REG_PC, "4*REG_PC" },
1771 { 4*REG_PR, "4*REG_PR" },
1772 { 4*REG_SR, "4*REG_SR" },
1773 { 4*REG_GBR, "4*REG_GBR" },
1774 { 4*REG_MACH, "4*REG_MACH" },
1775 { 4*REG_MACL, "4*REG_MACL" },
1776 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1777 { 4*REG_FPUL, "4*REG_FPUL" },
1778 { 4*REG_FPREG0, "4*REG_FPREG0" },
1779 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1780 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1781 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1782 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1783 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1784 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1785 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1786 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1787 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1788 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1789 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1790 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1791 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1792 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1793 { 4*REG_FPREG15, "4*REG_FPREG15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001794# ifdef REG_XDREG0
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001795 { 4*REG_XDREG0, "4*REG_XDREG0" },
1796 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1797 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1798 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1799 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1800 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1801 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1802 { 4*REG_XDREG14, "4*REG_XDREG14" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001803# endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001804 { 4*REG_FPSCR, "4*REG_FPSCR" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001805#elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001806 { 0, "PC(L)" },
1807 { 4, "PC(U)" },
1808 { 8, "SR(L)" },
1809 { 12, "SR(U)" },
1810 { 16, "syscall no.(L)" },
1811 { 20, "syscall_no.(U)" },
1812 { 24, "R0(L)" },
1813 { 28, "R0(U)" },
1814 { 32, "R1(L)" },
1815 { 36, "R1(U)" },
1816 { 40, "R2(L)" },
1817 { 44, "R2(U)" },
1818 { 48, "R3(L)" },
1819 { 52, "R3(U)" },
1820 { 56, "R4(L)" },
1821 { 60, "R4(U)" },
1822 { 64, "R5(L)" },
1823 { 68, "R5(U)" },
1824 { 72, "R6(L)" },
1825 { 76, "R6(U)" },
1826 { 80, "R7(L)" },
1827 { 84, "R7(U)" },
1828 { 88, "R8(L)" },
1829 { 92, "R8(U)" },
1830 { 96, "R9(L)" },
1831 { 100, "R9(U)" },
1832 { 104, "R10(L)" },
1833 { 108, "R10(U)" },
1834 { 112, "R11(L)" },
1835 { 116, "R11(U)" },
1836 { 120, "R12(L)" },
1837 { 124, "R12(U)" },
1838 { 128, "R13(L)" },
1839 { 132, "R13(U)" },
1840 { 136, "R14(L)" },
1841 { 140, "R14(U)" },
1842 { 144, "R15(L)" },
1843 { 148, "R15(U)" },
1844 { 152, "R16(L)" },
1845 { 156, "R16(U)" },
1846 { 160, "R17(L)" },
1847 { 164, "R17(U)" },
1848 { 168, "R18(L)" },
1849 { 172, "R18(U)" },
1850 { 176, "R19(L)" },
1851 { 180, "R19(U)" },
1852 { 184, "R20(L)" },
1853 { 188, "R20(U)" },
1854 { 192, "R21(L)" },
1855 { 196, "R21(U)" },
1856 { 200, "R22(L)" },
1857 { 204, "R22(U)" },
1858 { 208, "R23(L)" },
1859 { 212, "R23(U)" },
1860 { 216, "R24(L)" },
1861 { 220, "R24(U)" },
1862 { 224, "R25(L)" },
1863 { 228, "R25(U)" },
1864 { 232, "R26(L)" },
1865 { 236, "R26(U)" },
1866 { 240, "R27(L)" },
1867 { 244, "R27(U)" },
1868 { 248, "R28(L)" },
1869 { 252, "R28(U)" },
1870 { 256, "R29(L)" },
1871 { 260, "R29(U)" },
1872 { 264, "R30(L)" },
1873 { 268, "R30(U)" },
1874 { 272, "R31(L)" },
1875 { 276, "R31(U)" },
1876 { 280, "R32(L)" },
1877 { 284, "R32(U)" },
1878 { 288, "R33(L)" },
1879 { 292, "R33(U)" },
1880 { 296, "R34(L)" },
1881 { 300, "R34(U)" },
1882 { 304, "R35(L)" },
1883 { 308, "R35(U)" },
1884 { 312, "R36(L)" },
1885 { 316, "R36(U)" },
1886 { 320, "R37(L)" },
1887 { 324, "R37(U)" },
1888 { 328, "R38(L)" },
1889 { 332, "R38(U)" },
1890 { 336, "R39(L)" },
1891 { 340, "R39(U)" },
1892 { 344, "R40(L)" },
1893 { 348, "R40(U)" },
1894 { 352, "R41(L)" },
1895 { 356, "R41(U)" },
1896 { 360, "R42(L)" },
1897 { 364, "R42(U)" },
1898 { 368, "R43(L)" },
1899 { 372, "R43(U)" },
1900 { 376, "R44(L)" },
1901 { 380, "R44(U)" },
1902 { 384, "R45(L)" },
1903 { 388, "R45(U)" },
1904 { 392, "R46(L)" },
1905 { 396, "R46(U)" },
1906 { 400, "R47(L)" },
1907 { 404, "R47(U)" },
1908 { 408, "R48(L)" },
1909 { 412, "R48(U)" },
1910 { 416, "R49(L)" },
1911 { 420, "R49(U)" },
1912 { 424, "R50(L)" },
1913 { 428, "R50(U)" },
1914 { 432, "R51(L)" },
1915 { 436, "R51(U)" },
1916 { 440, "R52(L)" },
1917 { 444, "R52(U)" },
1918 { 448, "R53(L)" },
1919 { 452, "R53(U)" },
1920 { 456, "R54(L)" },
1921 { 460, "R54(U)" },
1922 { 464, "R55(L)" },
1923 { 468, "R55(U)" },
1924 { 472, "R56(L)" },
1925 { 476, "R56(U)" },
1926 { 480, "R57(L)" },
1927 { 484, "R57(U)" },
1928 { 488, "R58(L)" },
1929 { 492, "R58(U)" },
1930 { 496, "R59(L)" },
1931 { 500, "R59(U)" },
1932 { 504, "R60(L)" },
1933 { 508, "R60(U)" },
1934 { 512, "R61(L)" },
1935 { 516, "R61(U)" },
1936 { 520, "R62(L)" },
1937 { 524, "R62(U)" },
1938 { 528, "TR0(L)" },
1939 { 532, "TR0(U)" },
1940 { 536, "TR1(L)" },
1941 { 540, "TR1(U)" },
1942 { 544, "TR2(L)" },
1943 { 548, "TR2(U)" },
1944 { 552, "TR3(L)" },
1945 { 556, "TR3(U)" },
1946 { 560, "TR4(L)" },
1947 { 564, "TR4(U)" },
1948 { 568, "TR5(L)" },
1949 { 572, "TR5(U)" },
1950 { 576, "TR6(L)" },
1951 { 580, "TR6(U)" },
1952 { 584, "TR7(L)" },
1953 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00001954 /* This entry is in case pt_regs contains dregs (depends on
1955 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001956 { uoff(regs), "offsetof(struct user, regs)" },
1957 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001958#elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00001959 { uoff(regs.ARM_r0), "r0" },
1960 { uoff(regs.ARM_r1), "r1" },
1961 { uoff(regs.ARM_r2), "r2" },
1962 { uoff(regs.ARM_r3), "r3" },
1963 { uoff(regs.ARM_r4), "r4" },
1964 { uoff(regs.ARM_r5), "r5" },
1965 { uoff(regs.ARM_r6), "r6" },
1966 { uoff(regs.ARM_r7), "r7" },
1967 { uoff(regs.ARM_r8), "r8" },
1968 { uoff(regs.ARM_r9), "r9" },
1969 { uoff(regs.ARM_r10), "r10" },
1970 { uoff(regs.ARM_fp), "fp" },
1971 { uoff(regs.ARM_ip), "ip" },
1972 { uoff(regs.ARM_sp), "sp" },
1973 { uoff(regs.ARM_lr), "lr" },
1974 { uoff(regs.ARM_pc), "pc" },
1975 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001976#elif defined(AVR32)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001977 { uoff(regs.sr), "sr" },
1978 { uoff(regs.pc), "pc" },
1979 { uoff(regs.lr), "lr" },
1980 { uoff(regs.sp), "sp" },
1981 { uoff(regs.r12), "r12" },
1982 { uoff(regs.r11), "r11" },
1983 { uoff(regs.r10), "r10" },
1984 { uoff(regs.r9), "r9" },
1985 { uoff(regs.r8), "r8" },
1986 { uoff(regs.r7), "r7" },
1987 { uoff(regs.r6), "r6" },
1988 { uoff(regs.r5), "r5" },
1989 { uoff(regs.r4), "r4" },
1990 { uoff(regs.r3), "r3" },
1991 { uoff(regs.r2), "r2" },
1992 { uoff(regs.r1), "r1" },
1993 { uoff(regs.r0), "r0" },
1994 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001995#elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00001996 { 0, "r0" },
1997 { 1, "r1" },
1998 { 2, "r2" },
1999 { 3, "r3" },
2000 { 4, "r4" },
2001 { 5, "r5" },
2002 { 6, "r6" },
2003 { 7, "r7" },
2004 { 8, "r8" },
2005 { 9, "r9" },
2006 { 10, "r10" },
2007 { 11, "r11" },
2008 { 12, "r12" },
2009 { 13, "r13" },
2010 { 14, "r14" },
2011 { 15, "r15" },
2012 { 16, "r16" },
2013 { 17, "r17" },
2014 { 18, "r18" },
2015 { 19, "r19" },
2016 { 20, "r20" },
2017 { 21, "r21" },
2018 { 22, "r22" },
2019 { 23, "r23" },
2020 { 24, "r24" },
2021 { 25, "r25" },
2022 { 26, "r26" },
2023 { 27, "r27" },
2024 { 28, "r28" },
2025 { 29, "r29" },
2026 { 30, "r30" },
2027 { 31, "r31" },
2028 { 32, "f0" },
2029 { 33, "f1" },
2030 { 34, "f2" },
2031 { 35, "f3" },
2032 { 36, "f4" },
2033 { 37, "f5" },
2034 { 38, "f6" },
2035 { 39, "f7" },
2036 { 40, "f8" },
2037 { 41, "f9" },
2038 { 42, "f10" },
2039 { 43, "f11" },
2040 { 44, "f12" },
2041 { 45, "f13" },
2042 { 46, "f14" },
2043 { 47, "f15" },
2044 { 48, "f16" },
2045 { 49, "f17" },
2046 { 50, "f18" },
2047 { 51, "f19" },
2048 { 52, "f20" },
2049 { 53, "f21" },
2050 { 54, "f22" },
2051 { 55, "f23" },
2052 { 56, "f24" },
2053 { 57, "f25" },
2054 { 58, "f26" },
2055 { 59, "f27" },
2056 { 60, "f28" },
2057 { 61, "f29" },
2058 { 62, "f30" },
2059 { 63, "f31" },
2060 { 64, "pc" },
2061 { 65, "cause" },
2062 { 66, "badvaddr" },
2063 { 67, "mmhi" },
2064 { 68, "mmlo" },
2065 { 69, "fpcsr" },
2066 { 70, "fpeir" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002067#elif defined(TILE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05002068 { PTREGS_OFFSET_REG(0), "r0" },
2069 { PTREGS_OFFSET_REG(1), "r1" },
2070 { PTREGS_OFFSET_REG(2), "r2" },
2071 { PTREGS_OFFSET_REG(3), "r3" },
2072 { PTREGS_OFFSET_REG(4), "r4" },
2073 { PTREGS_OFFSET_REG(5), "r5" },
2074 { PTREGS_OFFSET_REG(6), "r6" },
2075 { PTREGS_OFFSET_REG(7), "r7" },
2076 { PTREGS_OFFSET_REG(8), "r8" },
2077 { PTREGS_OFFSET_REG(9), "r9" },
2078 { PTREGS_OFFSET_REG(10), "r10" },
2079 { PTREGS_OFFSET_REG(11), "r11" },
2080 { PTREGS_OFFSET_REG(12), "r12" },
2081 { PTREGS_OFFSET_REG(13), "r13" },
2082 { PTREGS_OFFSET_REG(14), "r14" },
2083 { PTREGS_OFFSET_REG(15), "r15" },
2084 { PTREGS_OFFSET_REG(16), "r16" },
2085 { PTREGS_OFFSET_REG(17), "r17" },
2086 { PTREGS_OFFSET_REG(18), "r18" },
2087 { PTREGS_OFFSET_REG(19), "r19" },
2088 { PTREGS_OFFSET_REG(20), "r20" },
2089 { PTREGS_OFFSET_REG(21), "r21" },
2090 { PTREGS_OFFSET_REG(22), "r22" },
2091 { PTREGS_OFFSET_REG(23), "r23" },
2092 { PTREGS_OFFSET_REG(24), "r24" },
2093 { PTREGS_OFFSET_REG(25), "r25" },
2094 { PTREGS_OFFSET_REG(26), "r26" },
2095 { PTREGS_OFFSET_REG(27), "r27" },
2096 { PTREGS_OFFSET_REG(28), "r28" },
2097 { PTREGS_OFFSET_REG(29), "r29" },
2098 { PTREGS_OFFSET_REG(30), "r30" },
2099 { PTREGS_OFFSET_REG(31), "r31" },
2100 { PTREGS_OFFSET_REG(32), "r32" },
2101 { PTREGS_OFFSET_REG(33), "r33" },
2102 { PTREGS_OFFSET_REG(34), "r34" },
2103 { PTREGS_OFFSET_REG(35), "r35" },
2104 { PTREGS_OFFSET_REG(36), "r36" },
2105 { PTREGS_OFFSET_REG(37), "r37" },
2106 { PTREGS_OFFSET_REG(38), "r38" },
2107 { PTREGS_OFFSET_REG(39), "r39" },
2108 { PTREGS_OFFSET_REG(40), "r40" },
2109 { PTREGS_OFFSET_REG(41), "r41" },
2110 { PTREGS_OFFSET_REG(42), "r42" },
2111 { PTREGS_OFFSET_REG(43), "r43" },
2112 { PTREGS_OFFSET_REG(44), "r44" },
2113 { PTREGS_OFFSET_REG(45), "r45" },
2114 { PTREGS_OFFSET_REG(46), "r46" },
2115 { PTREGS_OFFSET_REG(47), "r47" },
2116 { PTREGS_OFFSET_REG(48), "r48" },
2117 { PTREGS_OFFSET_REG(49), "r49" },
2118 { PTREGS_OFFSET_REG(50), "r50" },
2119 { PTREGS_OFFSET_REG(51), "r51" },
2120 { PTREGS_OFFSET_REG(52), "r52" },
2121 { PTREGS_OFFSET_TP, "tp" },
2122 { PTREGS_OFFSET_SP, "sp" },
2123 { PTREGS_OFFSET_LR, "lr" },
2124 { PTREGS_OFFSET_PC, "pc" },
2125 { PTREGS_OFFSET_EX1, "ex1" },
2126 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2127 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2128 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002129#endif
2130#ifdef CRISV10
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002131 { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
2132 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2133 { 4*PT_R13, "4*PT_R13" },
2134 { 4*PT_R12, "4*PT_R12" },
2135 { 4*PT_R11, "4*PT_R11" },
2136 { 4*PT_R10, "4*PT_R10" },
2137 { 4*PT_R9, "4*PT_R9" },
2138 { 4*PT_R8, "4*PT_R8" },
2139 { 4*PT_R7, "4*PT_R7" },
2140 { 4*PT_R6, "4*PT_R6" },
2141 { 4*PT_R5, "4*PT_R5" },
2142 { 4*PT_R4, "4*PT_R4" },
2143 { 4*PT_R3, "4*PT_R3" },
2144 { 4*PT_R2, "4*PT_R2" },
2145 { 4*PT_R1, "4*PT_R1" },
2146 { 4*PT_R0, "4*PT_R0" },
2147 { 4*PT_MOF, "4*PT_MOF" },
2148 { 4*PT_DCCR, "4*PT_DCCR" },
2149 { 4*PT_SRP, "4*PT_SRP" },
2150 { 4*PT_IRP, "4*PT_IRP" },
2151 { 4*PT_CSRINSTR, "4*PT_CSRINSTR" },
2152 { 4*PT_CSRADDR, "4*PT_CSRADDR" },
2153 { 4*PT_CSRDATA, "4*PT_CSRDATA" },
2154 { 4*PT_USP, "4*PT_USP" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002155#endif
2156#ifdef CRISV32
Denys Vlasenkoea0e6e82009-02-25 17:08:40 +00002157 { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
2158 { 4*PT_R0, "4*PT_R0" },
2159 { 4*PT_R1, "4*PT_R1" },
2160 { 4*PT_R2, "4*PT_R2" },
2161 { 4*PT_R3, "4*PT_R3" },
2162 { 4*PT_R4, "4*PT_R4" },
2163 { 4*PT_R5, "4*PT_R5" },
2164 { 4*PT_R6, "4*PT_R6" },
2165 { 4*PT_R7, "4*PT_R7" },
2166 { 4*PT_R8, "4*PT_R8" },
2167 { 4*PT_R9, "4*PT_R9" },
2168 { 4*PT_R10, "4*PT_R10" },
2169 { 4*PT_R11, "4*PT_R11" },
2170 { 4*PT_R12, "4*PT_R12" },
2171 { 4*PT_R13, "4*PT_R13" },
2172 { 4*PT_ACR, "4*PT_ACR" },
2173 { 4*PT_SRS, "4*PT_SRS" },
2174 { 4*PT_MOF, "4*PT_MOF" },
2175 { 4*PT_SPC, "4*PT_SPC" },
2176 { 4*PT_CCS, "4*PT_CCS" },
2177 { 4*PT_SRP, "4*PT_SRP" },
2178 { 4*PT_ERP, "4*PT_ERP" },
2179 { 4*PT_EXS, "4*PT_EXS" },
2180 { 4*PT_EDA, "4*PT_EDA" },
2181 { 4*PT_USP, "4*PT_USP" },
2182 { 4*PT_PPC, "4*PT_PPC" },
2183 { 4*PT_BP_CTRL, "4*PT_BP_CTRL" },
2184 { 4*PT_BP+4, "4*PT_BP+4" },
2185 { 4*PT_BP+8, "4*PT_BP+8" },
2186 { 4*PT_BP+12, "4*PT_BP+12" },
2187 { 4*PT_BP+16, "4*PT_BP+16" },
2188 { 4*PT_BP+20, "4*PT_BP+20" },
2189 { 4*PT_BP+24, "4*PT_BP+24" },
2190 { 4*PT_BP+28, "4*PT_BP+28" },
2191 { 4*PT_BP+32, "4*PT_BP+32" },
2192 { 4*PT_BP+36, "4*PT_BP+36" },
2193 { 4*PT_BP+40, "4*PT_BP+40" },
2194 { 4*PT_BP+44, "4*PT_BP+44" },
2195 { 4*PT_BP+48, "4*PT_BP+48" },
2196 { 4*PT_BP+52, "4*PT_BP+52" },
2197 { 4*PT_BP+56, "4*PT_BP+56" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002198#endif
2199#ifdef MICROBLAZE
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002200 { PT_GPR(0), "r0" },
2201 { PT_GPR(1), "r1" },
2202 { PT_GPR(2), "r2" },
2203 { PT_GPR(3), "r3" },
2204 { PT_GPR(4), "r4" },
2205 { PT_GPR(5), "r5" },
2206 { PT_GPR(6), "r6" },
2207 { PT_GPR(7), "r7" },
2208 { PT_GPR(8), "r8" },
2209 { PT_GPR(9), "r9" },
2210 { PT_GPR(10), "r10" },
2211 { PT_GPR(11), "r11" },
2212 { PT_GPR(12), "r12" },
2213 { PT_GPR(13), "r13" },
2214 { PT_GPR(14), "r14" },
2215 { PT_GPR(15), "r15" },
2216 { PT_GPR(16), "r16" },
2217 { PT_GPR(17), "r17" },
2218 { PT_GPR(18), "r18" },
2219 { PT_GPR(19), "r19" },
2220 { PT_GPR(20), "r20" },
2221 { PT_GPR(21), "r21" },
2222 { PT_GPR(22), "r22" },
2223 { PT_GPR(23), "r23" },
2224 { PT_GPR(24), "r24" },
2225 { PT_GPR(25), "r25" },
2226 { PT_GPR(26), "r26" },
2227 { PT_GPR(27), "r27" },
2228 { PT_GPR(28), "r28" },
2229 { PT_GPR(29), "r29" },
2230 { PT_GPR(30), "r30" },
2231 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002232 { PT_PC, "rpc", },
2233 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002234 { PT_EAR, "rear", },
2235 { PT_ESR, "resr", },
2236 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002237 { PT_KERNEL_MODE, "kernel_mode", },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002238#endif
Christian Svensson492f81f2013-02-14 13:26:27 +01002239#ifdef OR1K
2240 { 4*0, "r0" },
2241 { 4*1, "r1" },
2242 { 4*2, "r2" },
2243 { 4*3, "r3" },
2244 { 4*4, "r4" },
2245 { 4*5, "r5" },
2246 { 4*6, "r6" },
2247 { 4*7, "r7" },
2248 { 4*8, "r8" },
2249 { 4*9, "r9" },
2250 { 4*10, "r10" },
2251 { 4*11, "r11" },
2252 { 4*12, "r12" },
2253 { 4*13, "r13" },
2254 { 4*14, "r14" },
2255 { 4*15, "r15" },
2256 { 4*16, "r16" },
2257 { 4*17, "r17" },
2258 { 4*18, "r18" },
2259 { 4*19, "r19" },
2260 { 4*20, "r20" },
2261 { 4*21, "r21" },
2262 { 4*22, "r22" },
2263 { 4*23, "r23" },
2264 { 4*24, "r24" },
2265 { 4*25, "r25" },
2266 { 4*26, "r26" },
2267 { 4*27, "r27" },
2268 { 4*28, "r28" },
2269 { 4*29, "r29" },
2270 { 4*30, "r30" },
2271 { 4*31, "r31" },
2272 { 4*32, "pc" },
2273 { 4*33, "sr" },
2274#endif
Chris Zankel8f636ed2013-03-25 10:22:07 -07002275#ifdef XTENSA
2276 { SYSCALL_NR, "syscall_nr" },
2277 { REG_AR_BASE, "ar0" },
2278 { REG_AR_BASE+1, "ar1" },
2279 { REG_AR_BASE+2, "ar2" },
2280 { REG_AR_BASE+3, "ar3" },
2281 { REG_AR_BASE+4, "ar4" },
2282 { REG_AR_BASE+5, "ar5" },
2283 { REG_AR_BASE+6, "ar6" },
2284 { REG_AR_BASE+7, "ar7" },
2285 { REG_AR_BASE+8, "ar8" },
2286 { REG_AR_BASE+9, "ar9" },
2287 { REG_AR_BASE+10, "ar10" },
2288 { REG_AR_BASE+11, "ar11" },
2289 { REG_AR_BASE+12, "ar12" },
2290 { REG_AR_BASE+13, "ar13" },
2291 { REG_AR_BASE+14, "ar14" },
2292 { REG_AR_BASE+15, "ar15" },
2293 { REG_AR_BASE+16, "ar16" },
2294 { REG_AR_BASE+17, "ar17" },
2295 { REG_AR_BASE+18, "ar18" },
2296 { REG_AR_BASE+19, "ar19" },
2297 { REG_AR_BASE+20, "ar20" },
2298 { REG_AR_BASE+21, "ar21" },
2299 { REG_AR_BASE+22, "ar22" },
2300 { REG_AR_BASE+23, "ar23" },
2301 { REG_AR_BASE+24, "ar24" },
2302 { REG_AR_BASE+25, "ar25" },
2303 { REG_AR_BASE+26, "ar26" },
2304 { REG_AR_BASE+27, "ar27" },
2305 { REG_AR_BASE+28, "ar28" },
2306 { REG_AR_BASE+29, "ar29" },
2307 { REG_AR_BASE+30, "ar30" },
2308 { REG_AR_BASE+31, "ar31" },
2309 { REG_AR_BASE+32, "ar32" },
2310 { REG_AR_BASE+33, "ar33" },
2311 { REG_AR_BASE+34, "ar34" },
2312 { REG_AR_BASE+35, "ar35" },
2313 { REG_AR_BASE+36, "ar36" },
2314 { REG_AR_BASE+37, "ar37" },
2315 { REG_AR_BASE+38, "ar38" },
2316 { REG_AR_BASE+39, "ar39" },
2317 { REG_AR_BASE+40, "ar40" },
2318 { REG_AR_BASE+41, "ar41" },
2319 { REG_AR_BASE+42, "ar42" },
2320 { REG_AR_BASE+43, "ar43" },
2321 { REG_AR_BASE+44, "ar44" },
2322 { REG_AR_BASE+45, "ar45" },
2323 { REG_AR_BASE+46, "ar46" },
2324 { REG_AR_BASE+47, "ar47" },
2325 { REG_AR_BASE+48, "ar48" },
2326 { REG_AR_BASE+49, "ar49" },
2327 { REG_AR_BASE+50, "ar50" },
2328 { REG_AR_BASE+51, "ar51" },
2329 { REG_AR_BASE+52, "ar52" },
2330 { REG_AR_BASE+53, "ar53" },
2331 { REG_AR_BASE+54, "ar54" },
2332 { REG_AR_BASE+55, "ar55" },
2333 { REG_AR_BASE+56, "ar56" },
2334 { REG_AR_BASE+57, "ar57" },
2335 { REG_AR_BASE+58, "ar58" },
2336 { REG_AR_BASE+59, "ar59" },
2337 { REG_AR_BASE+60, "ar60" },
2338 { REG_AR_BASE+61, "ar61" },
2339 { REG_AR_BASE+62, "ar62" },
2340 { REG_AR_BASE+63, "ar63" },
2341 { REG_LBEG, "lbeg" },
2342 { REG_LEND, "lend" },
2343 { REG_LCOUNT, "lcount" },
2344 { REG_SAR, "sar" },
2345 { REG_WB, "wb" },
2346 { REG_WS, "ws" },
2347 { REG_PS, "ps" },
2348 { REG_PC, "pc" },
2349 { REG_A_BASE, "a0" },
2350 { REG_A_BASE+1, "a1" },
2351 { REG_A_BASE+2, "a2" },
2352 { REG_A_BASE+3, "a3" },
2353 { REG_A_BASE+4, "a4" },
2354 { REG_A_BASE+5, "a5" },
2355 { REG_A_BASE+6, "a6" },
2356 { REG_A_BASE+7, "a7" },
2357 { REG_A_BASE+8, "a8" },
2358 { REG_A_BASE+9, "a9" },
2359 { REG_A_BASE+10, "a10" },
2360 { REG_A_BASE+11, "a11" },
2361 { REG_A_BASE+12, "a12" },
2362 { REG_A_BASE+13, "a13" },
2363 { REG_A_BASE+14, "a14" },
2364 { REG_A_BASE+15, "a15" },
2365#endif
2366
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002367 /* Other fields in "struct user" */
2368#if defined(S390) || defined(S390X)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002369 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2370 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2371 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002372 { uoff(start_code), "offsetof(struct user, start_code)" },
2373 /* S390[X] has no start_data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002374 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2375 { uoff(signal), "offsetof(struct user, signal)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002376 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002377 { uoff(magic), "offsetof(struct user, magic)" },
2378 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002379 { sizeof(struct user), "sizeof(struct user)" },
2380#elif defined(POWERPC)
2381 { sizeof(struct user), "sizeof(struct user)" },
2382#elif defined(I386) || defined(X86_64) || defined(X32)
2383 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2384 { uoff(i387), "offsetof(struct user, i387)" },
2385 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2386 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2387 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2388 { uoff(start_code), "offsetof(struct user, start_code)" },
2389 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2390 { uoff(signal), "offsetof(struct user, signal)" },
2391 { uoff(reserved), "offsetof(struct user, reserved)" },
2392 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2393 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2394 { uoff(magic), "offsetof(struct user, magic)" },
2395 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002396 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002397 { sizeof(struct user), "sizeof(struct user)" },
2398#elif defined(IA64)
2399 { sizeof(struct user), "sizeof(struct user)" },
2400#elif defined(ARM)
2401 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2402 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2403 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2404 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2405 { uoff(start_code), "offsetof(struct user, start_code)" },
2406 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2407 { uoff(signal), "offsetof(struct user, signal)" },
2408 { uoff(reserved), "offsetof(struct user, reserved)" },
2409 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2410 { uoff(magic), "offsetof(struct user, magic)" },
2411 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2412 { sizeof(struct user), "sizeof(struct user)" },
2413#elif defined(AARCH64)
2414 /* nothing */
2415#elif defined(M68K)
2416 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2417 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2418 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2419 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2420 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2421 { uoff(start_code), "offsetof(struct user, start_code)" },
2422 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2423 { uoff(signal), "offsetof(struct user, signal)" },
2424 { uoff(reserved), "offsetof(struct user, reserved)" },
2425 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2426 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2427 { uoff(magic), "offsetof(struct user, magic)" },
2428 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2429 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002430#elif defined(MIPS) || defined(LINUX_MIPSN32)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002431 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2432 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2433 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2434 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002435 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002436 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2437 { uoff(signal), "offsetof(struct user, signal)" },
2438 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2439 { uoff(magic), "offsetof(struct user, magic)" },
2440 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2441 { sizeof(struct user), "sizeof(struct user)" },
2442#elif defined(ALPHA)
2443 { sizeof(struct user), "sizeof(struct user)" },
2444#elif defined(SPARC)
2445 { sizeof(struct user), "sizeof(struct user)" },
2446#elif defined(SPARC64)
2447 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2448 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2449 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2450 { uoff(signal), "offsetof(struct user, signal)" },
2451 { uoff(magic), "offsetof(struct user, magic)" },
2452 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2453 { sizeof(struct user), "sizeof(struct user)" },
2454#elif defined(HPPA)
2455 /* nothing */
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002456#elif defined(SH) || defined(SH64)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002457 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2458 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2459 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2460 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2461 { uoff(start_code), "offsetof(struct user, start_code)" },
2462 { uoff(start_data), "offsetof(struct user, start_data)" },
2463 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2464 { uoff(signal), "offsetof(struct user, signal)" },
2465 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2466 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2467 { uoff(magic), "offsetof(struct user, magic)" },
2468 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2469 { sizeof(struct user), "sizeof(struct user)" },
2470#elif defined(CRISV10) || defined(CRISV32)
2471 { sizeof(struct user), "sizeof(struct user)" },
2472#elif defined(TILE)
2473 /* nothing */
2474#elif defined(MICROBLAZE)
2475 { sizeof(struct user), "sizeof(struct user)" },
2476#elif defined(AVR32)
2477 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2478 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2479 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2480 { uoff(start_code), "offsetof(struct user, start_code)" },
2481 { uoff(start_data), "offsetof(struct user, start_data)" },
2482 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2483 { uoff(signal), "offsetof(struct user, signal)" },
2484 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2485 { uoff(magic), "offsetof(struct user, magic)" },
2486 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2487 { sizeof(struct user), "sizeof(struct user)" },
2488#elif defined(BFIN)
2489 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2490 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2491 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2492 { uoff(start_code), "offsetof(struct user, start_code)" },
2493 { uoff(signal), "offsetof(struct user, signal)" },
2494 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2495 { uoff(magic), "offsetof(struct user, magic)" },
2496 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002497 { sizeof(struct user), "sizeof(struct user)" },
Christian Svensson492f81f2013-02-14 13:26:27 +01002498#elif defined(OR1K)
2499 /* nothing */
James Hogan5f999a82013-02-22 14:44:10 +00002500#elif defined(METAG)
2501 /* nothing */
Chris Zankel8f636ed2013-03-25 10:22:07 -07002502#elif defined(XTENSA)
2503 /* nothing */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002504#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002505 { 0, NULL },
2506};
2507
2508int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002509sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002510{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002511 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002512 long addr;
2513
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002514 if (entering(tcp)) {
Denys Vlasenkob7a6dae2012-03-20 16:48:35 +01002515 printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
Roland McGrathbf621d42003-01-14 09:46:21 +00002516 tprintf(", %lu, ", tcp->u_arg[1]);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002517
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002518 addr = tcp->u_arg[2];
2519 if (tcp->u_arg[0] == PTRACE_PEEKUSER
Denys Vlasenkobe994972013-02-13 16:10:10 +01002520 || tcp->u_arg[0] == PTRACE_POKEUSER
2521 ) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002522 for (x = struct_user_offsets; x->str; x++) {
2523 if (x->val >= addr)
2524 break;
2525 }
2526 if (!x->str)
2527 tprintf("%#lx, ", addr);
2528 else if (x->val > addr && x != struct_user_offsets) {
2529 x--;
2530 tprintf("%s + %ld, ", x->str, addr - x->val);
2531 }
2532 else
2533 tprintf("%s, ", x->str);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002534 } else
2535#ifdef PTRACE_GETREGSET
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00002536 if (tcp->u_arg[0] == PTRACE_GETREGSET
2537 || tcp->u_arg[0] == PTRACE_SETREGSET
2538 ) {
2539 printxval(nt_descriptor_types, tcp->u_arg[2], "NT_???");
2540 tprints(", ");
2541 } else
Denys Vlasenkobe994972013-02-13 16:10:10 +01002542#endif
2543 tprintf("%#lx, ", addr);
2544
2545
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002546 switch (tcp->u_arg[0]) {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002547#ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002548 case PTRACE_PEEKDATA:
2549 case PTRACE_PEEKTEXT:
2550 case PTRACE_PEEKUSER:
2551 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002552#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002553 case PTRACE_CONT:
2554 case PTRACE_SINGLESTEP:
2555 case PTRACE_SYSCALL:
2556 case PTRACE_DETACH:
2557 printsignal(tcp->u_arg[3]);
2558 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002559#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002560 case PTRACE_SETOPTIONS:
2561 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2562 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002563#endif
2564#ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002565 case PTRACE_SETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002566 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002567 break;
2568 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002569#endif
2570#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002571 case PTRACE_GETSIGINFO:
2572 /* Don't print anything, do it at syscall return. */
2573 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002574#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002575#ifdef PTRACE_GETREGSET
2576 case PTRACE_GETREGSET:
2577 break;
2578 case PTRACE_SETREGSET:
2579 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2580 break;
2581#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002582 default:
2583 tprintf("%#lx", tcp->u_arg[3]);
2584 break;
2585 }
2586 } else {
2587 switch (tcp->u_arg[0]) {
2588 case PTRACE_PEEKDATA:
2589 case PTRACE_PEEKTEXT:
2590 case PTRACE_PEEKUSER:
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002591#ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002592 return RVAL_HEX;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002593#else
Roland McGratheb285352003-01-14 09:59:00 +00002594 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002595 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002596#endif
2597#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002598 case PTRACE_GETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002599 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002600 break;
2601 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002602#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002603#ifdef PTRACE_GETREGSET
2604 case PTRACE_GETREGSET:
2605 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2606 break;
2607#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002608 }
2609 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002610 return 0;
2611}
2612
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002613#ifndef FUTEX_CMP_REQUEUE
2614# define FUTEX_CMP_REQUEUE 4
2615#endif
2616#ifndef FUTEX_WAKE_OP
2617# define FUTEX_WAKE_OP 5
2618#endif
2619#ifndef FUTEX_LOCK_PI
2620# define FUTEX_LOCK_PI 6
2621# define FUTEX_UNLOCK_PI 7
2622# define FUTEX_TRYLOCK_PI 8
2623#endif
2624#ifndef FUTEX_WAIT_BITSET
2625# define FUTEX_WAIT_BITSET 9
2626#endif
2627#ifndef FUTEX_WAKE_BITSET
2628# define FUTEX_WAKE_BITSET 10
2629#endif
2630#ifndef FUTEX_WAIT_REQUEUE_PI
2631# define FUTEX_WAIT_REQUEUE_PI 11
2632#endif
2633#ifndef FUTEX_CMP_REQUEUE_PI
2634# define FUTEX_CMP_REQUEUE_PI 12
2635#endif
2636#ifndef FUTEX_PRIVATE_FLAG
2637# define FUTEX_PRIVATE_FLAG 128
2638#endif
2639#ifndef FUTEX_CLOCK_REALTIME
2640# define FUTEX_CLOCK_REALTIME 256
2641#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002642static const struct xlat futexops[] = {
Roland McGrath51942a92007-07-05 18:59:11 +00002643 { FUTEX_WAIT, "FUTEX_WAIT" },
2644 { FUTEX_WAKE, "FUTEX_WAKE" },
2645 { FUTEX_FD, "FUTEX_FD" },
2646 { FUTEX_REQUEUE, "FUTEX_REQUEUE" },
2647 { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" },
2648 { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" },
2649 { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" },
2650 { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" },
2651 { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002652 { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" },
2653 { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002654 { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" },
2655 { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" },
Roland McGrath51942a92007-07-05 18:59:11 +00002656 { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" },
2657 { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" },
2658 { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" },
2659 { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" },
2660 { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" },
2661 { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" },
2662 { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" },
2663 { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" },
2664 { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" },
Roland McGrath1aeaf742008-07-18 01:27:39 +00002665 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" },
2666 { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" },
Andreas Schwab85f58322009-08-12 09:54:42 +02002667 { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" },
2668 { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" },
2669 { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" },
2670 { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" },
2671 { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" },
2672 { 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 +00002673 { 0, NULL }
2674};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002675#ifndef FUTEX_OP_SET
2676# define FUTEX_OP_SET 0
2677# define FUTEX_OP_ADD 1
2678# define FUTEX_OP_OR 2
2679# define FUTEX_OP_ANDN 3
2680# define FUTEX_OP_XOR 4
2681# define FUTEX_OP_CMP_EQ 0
2682# define FUTEX_OP_CMP_NE 1
2683# define FUTEX_OP_CMP_LT 2
2684# define FUTEX_OP_CMP_LE 3
2685# define FUTEX_OP_CMP_GT 4
2686# define FUTEX_OP_CMP_GE 5
2687#endif
Roland McGrath51942a92007-07-05 18:59:11 +00002688static const struct xlat futexwakeops[] = {
2689 { FUTEX_OP_SET, "FUTEX_OP_SET" },
2690 { FUTEX_OP_ADD, "FUTEX_OP_ADD" },
2691 { FUTEX_OP_OR, "FUTEX_OP_OR" },
2692 { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" },
2693 { FUTEX_OP_XOR, "FUTEX_OP_XOR" },
2694 { 0, NULL }
2695};
2696static const struct xlat futexwakecmps[] = {
2697 { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" },
2698 { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" },
2699 { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" },
2700 { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" },
2701 { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" },
2702 { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" },
2703 { 0, NULL }
Roland McGrath5a223472002-12-15 23:58:26 +00002704};
2705
2706int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002707sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002708{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002709 if (entering(tcp)) {
2710 long int cmd = tcp->u_arg[1] & 127;
2711 tprintf("%p, ", (void *) tcp->u_arg[0]);
2712 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2713 tprintf(", %ld", tcp->u_arg[2]);
2714 if (cmd == FUTEX_WAKE_BITSET)
2715 tprintf(", %lx", tcp->u_arg[5]);
2716 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002717 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002718 printtv(tcp, tcp->u_arg[3]);
2719 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002720 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002721 printtv(tcp, tcp->u_arg[3]);
2722 tprintf(", %lx", tcp->u_arg[5]);
2723 } else if (cmd == FUTEX_REQUEUE)
2724 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002725 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002726 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2727 else if (cmd == FUTEX_WAKE_OP) {
2728 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2729 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002730 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002731 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2732 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2733 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002734 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002735 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2736 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002737 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002738 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002739 printtv(tcp, tcp->u_arg[3]);
2740 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002741 }
Roland McGrath51942a92007-07-05 18:59:11 +00002742 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002743 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002744}
2745
2746static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002747print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002748{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002749 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002750 unsigned long w, min_len;
2751
2752 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2753 min_len = len - max_strlen * sizeof(w);
2754 else
2755 min_len = 0;
2756 for (; len >= sizeof(w) && len > min_len;
2757 len -= sizeof(w), list += sizeof(w)) {
2758 if (umove(tcp, list, &w) < 0)
2759 break;
2760 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002761 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002762 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002763 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002764 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002765 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002766 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002767 if (len) {
2768 if (first)
2769 tprintf("%#lx", list);
2770 else
2771 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2772 "???" : "..."));
2773 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002774 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002775 }
Roland McGrath5a223472002-12-15 23:58:26 +00002776}
2777
2778int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002779sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002780{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002781 if (entering(tcp)) {
2782 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2783 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2784 }
2785 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002786}
2787
2788int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002789sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002790{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002791 if (entering(tcp)) {
2792 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2793 } else {
2794 if (tcp->u_rval == -1)
2795 tprintf("%#lx", tcp->u_arg[2]);
2796 else
2797 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2798 }
2799 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002800}
Roland McGrath279d3782004-03-01 20:27:37 +00002801
Dmitry V. Levin1b0bae22012-03-11 22:32:26 +00002802int
2803sys_get_robust_list(struct tcb *tcp)
2804{
2805 if (entering(tcp)) {
2806 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2807 } else {
2808 void *addr;
2809 size_t len;
2810
2811 if (syserror(tcp) ||
2812 !tcp->u_arg[1] ||
2813 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2814 tprintf("%#lx, ", tcp->u_arg[1]);
2815 } else {
2816 tprintf("[%p], ", addr);
2817 }
2818
2819 if (syserror(tcp) ||
2820 !tcp->u_arg[2] ||
2821 umove(tcp, tcp->u_arg[2], &len) < 0) {
2822 tprintf("%#lx", tcp->u_arg[2]);
2823 } else {
2824 tprintf("[%lu]", (unsigned long) len);
2825 }
2826 }
2827 return 0;
2828}
2829
Roland McGrathd9f816f2004-09-04 03:39:20 +00002830static const struct xlat schedulers[] = {
Roland McGrath279d3782004-03-01 20:27:37 +00002831 { SCHED_OTHER, "SCHED_OTHER" },
2832 { SCHED_RR, "SCHED_RR" },
2833 { SCHED_FIFO, "SCHED_FIFO" },
2834 { 0, NULL }
2835};
2836
2837int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002838sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002839{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002840 if (entering(tcp)) {
2841 tprintf("%d", (int) tcp->u_arg[0]);
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002842 } else if (!syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002843 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002844 if (tcp->auxstr != NULL)
2845 return RVAL_STR;
2846 }
2847 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002848}
2849
2850int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002851sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002852{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002853 if (entering(tcp)) {
2854 struct sched_param p;
2855 tprintf("%d, ", (int) tcp->u_arg[0]);
2856 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2857 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2858 tprintf(", %#lx", tcp->u_arg[2]);
2859 else
2860 tprintf(", { %d }", p.__sched_priority);
2861 }
2862 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002863}
2864
2865int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002866sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002867{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002868 if (entering(tcp)) {
2869 tprintf("%d, ", (int) tcp->u_arg[0]);
2870 } else {
2871 struct sched_param p;
2872 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2873 tprintf("%#lx", tcp->u_arg[1]);
2874 else
2875 tprintf("{ %d }", p.__sched_priority);
2876 }
2877 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002878}
2879
2880int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002881sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002882{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002883 if (entering(tcp)) {
2884 struct sched_param p;
2885 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2886 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2887 else
2888 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority);
2889 }
2890 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002891}
2892
2893int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002894sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002895{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002896 if (entering(tcp)) {
2897 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2898 }
2899 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002900}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002901
Dmitry V. Levin1ff463d2012-03-11 23:00:11 +00002902int
2903sys_sched_rr_get_interval(struct tcb *tcp)
2904{
2905 if (entering(tcp)) {
2906 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2907 } else {
2908 if (syserror(tcp))
2909 tprintf("%#lx", tcp->u_arg[1]);
2910 else
2911 print_timespec(tcp, tcp->u_arg[1]);
2912 }
2913 return 0;
2914}
2915
H.J. Lu35be5812012-04-16 13:00:01 +02002916#if defined X86_64 || defined X32
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002917# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002918
2919static const struct xlat archvals[] = {
2920 { ARCH_SET_GS, "ARCH_SET_GS" },
2921 { ARCH_SET_FS, "ARCH_SET_FS" },
2922 { ARCH_GET_FS, "ARCH_GET_FS" },
2923 { ARCH_GET_GS, "ARCH_GET_GS" },
2924 { 0, NULL },
2925};
2926
2927int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002928sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002929{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002930 if (entering(tcp)) {
2931 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2932 if (tcp->u_arg[0] == ARCH_SET_GS
2933 || tcp->u_arg[0] == ARCH_SET_FS
2934 ) {
2935 tprintf(", %#lx", tcp->u_arg[1]);
2936 }
2937 } else {
2938 if (tcp->u_arg[0] == ARCH_GET_GS
2939 || tcp->u_arg[0] == ARCH_GET_FS
2940 ) {
2941 long int v;
2942 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2943 tprintf(", [%#lx]", v);
2944 else
2945 tprintf(", %#lx", tcp->u_arg[1]);
2946 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002947 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002948 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002949}
H.J. Lu35be5812012-04-16 13:00:01 +02002950#endif /* X86_64 || X32 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002951
Roland McGrathdb8319f2007-08-02 01:37:55 +00002952int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002953sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00002954{
2955 if (exiting(tcp)) {
2956 unsigned u;
2957 if (tcp->u_arg[0] == 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[0], &u) < 0)
2960 tprintf("%#lx, ", tcp->u_arg[0]);
2961 else
2962 tprintf("[%u], ", u);
2963 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002964 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00002965 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
2966 tprintf("%#lx, ", tcp->u_arg[1]);
2967 else
2968 tprintf("[%u], ", u);
2969 tprintf("%#lx", tcp->u_arg[2]);
2970 }
2971 return 0;
2972}
2973
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002974int
2975sys_process_vm_readv(struct tcb *tcp)
2976{
2977 if (entering(tcp)) {
2978 /* arg 1: pid */
2979 tprintf("%ld, ", tcp->u_arg[0]);
2980 } else {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002981 /* arg 2: local iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002982 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002983 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002984 } else {
2985 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
2986 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002987 /* arg 3: local iovcnt */
2988 tprintf(", %lu, ", tcp->u_arg[2]);
2989 /* arg 4: remote iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002990 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002991 tprintf("%#lx", tcp->u_arg[3]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002992 } else {
2993 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
2994 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002995 /* arg 5: remote iovcnt */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002996 /* arg 6: flags */
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00002997 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01002998 }
2999 return 0;
3000}
Dmitry V. Levin03952102012-03-10 14:14:49 +00003001
3002int
3003sys_process_vm_writev(struct tcb *tcp)
3004{
3005 if (entering(tcp)) {
3006 /* arg 1: pid */
3007 tprintf("%ld, ", tcp->u_arg[0]);
3008 /* arg 2: local iov */
3009 if (syserror(tcp))
3010 tprintf("%#lx", tcp->u_arg[1]);
3011 else
3012 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
3013 /* arg 3: local iovcnt */
3014 tprintf(", %lu, ", tcp->u_arg[2]);
3015 /* arg 4: remote iov */
3016 if (syserror(tcp))
3017 tprintf("%#lx", tcp->u_arg[3]);
3018 else
3019 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
3020 /* arg 5: remote iovcnt */
3021 /* arg 6: flags */
3022 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
3023 }
3024 return 0;
3025}