blob: 4347a872b003de75b700c4de360cfa2572f79bd2 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Linux for s390 port by D.J. Barrow
8 * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
Wichert Akkermanccef6372002-05-01 16:39:22 +00009 * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH
10 * port by Greg Banks <gbanks@pocketpenguins.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +000011 *
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000012 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. The name of the author may not be used to endorse or promote products
23 * derived from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000035 */
36
37#include "defs.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000038#include <fcntl.h>
39#include <sys/stat.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000040#include <sys/wait.h>
41#include <sys/resource.h>
42#include <sys/utsname.h>
43#include <sys/user.h>
Dmitry V. Levinc41808b2013-03-18 00:52:29 +000044#ifdef HAVE_ELF_H
45# include <elf.h>
46#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047
Wichert Akkerman36915a11999-07-13 15:45:02 +000048#ifdef HAVE_SYS_REG_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000049# include <sys/reg.h>
Wichert Akkerman15dea971999-10-06 13:06:34 +000050#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000051
Roland McGrath5bd7cf82003-01-24 04:31:18 +000052#ifdef HAVE_LINUX_PTRACE_H
Denys Vlasenko84703742012-02-25 02:38:52 +010053# undef PTRACE_SYSCALL
Roland McGrathfb1bc072004-03-01 21:29:24 +000054# ifdef HAVE_STRUCT_IA64_FPREG
55# define ia64_fpreg XXX_ia64_fpreg
56# endif
57# ifdef HAVE_STRUCT_PT_ALL_USER_REGS
58# define pt_all_user_regs XXX_pt_all_user_regs
59# endif
Ali Polatel0b4060f2013-09-24 20:04:32 +030060# ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS
61# define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args
62# endif
Denys Vlasenko84703742012-02-25 02:38:52 +010063# include <linux/ptrace.h>
Ali Polatel0b4060f2013-09-24 20:04:32 +030064# undef ptrace_peeksiginfo_args
Roland McGrathfb1bc072004-03-01 21:29:24 +000065# undef ia64_fpreg
66# undef pt_all_user_regs
Roland McGrath5bd7cf82003-01-24 04:31:18 +000067#endif
68
Denys Vlasenko84703742012-02-25 02:38:52 +010069#if defined(SPARC64)
Roland McGrath6d1a65c2004-07-12 07:44:08 +000070# define r_pc r_tpc
71# undef PTRACE_GETREGS
72# define PTRACE_GETREGS PTRACE_GETREGS64
73# undef PTRACE_SETREGS
74# define PTRACE_SETREGS PTRACE_SETREGS64
Denys Vlasenko84703742012-02-25 02:38:52 +010075#endif
Roland McGrath6d1a65c2004-07-12 07:44:08 +000076
Roland McGrath5a223472002-12-15 23:58:26 +000077#ifdef HAVE_LINUX_FUTEX_H
Dmitry V. Levine5e60852009-12-31 22:50:49 +000078# include <linux/futex.h>
Roland McGrath5a223472002-12-15 23:58:26 +000079#endif
Denys Vlasenko84703742012-02-25 02:38:52 +010080#ifndef FUTEX_WAIT
81# define FUTEX_WAIT 0
82#endif
83#ifndef FUTEX_WAKE
84# define FUTEX_WAKE 1
85#endif
86#ifndef FUTEX_FD
87# define FUTEX_FD 2
88#endif
89#ifndef FUTEX_REQUEUE
90# define FUTEX_REQUEUE 3
91#endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000092
Roland McGrath279d3782004-03-01 20:27:37 +000093#include <sched.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000094#include <asm/posix_types.h>
95#undef GETGROUPS_T
96#define GETGROUPS_T __kernel_gid_t
Roland McGrath83bd47a2003-11-13 22:32:26 +000097#undef GETGROUPS32_T
98#define GETGROUPS32_T __kernel_gid32_t
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000099
Denys Vlasenko84703742012-02-25 02:38:52 +0100100#if defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000101# include <asm/ptrace_offsets.h>
102# include <asm/rse.h>
103#endif
104
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000105#ifdef HAVE_PRCTL
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000106# include <sys/prctl.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000107
Roland McGrathd9f816f2004-09-04 03:39:20 +0000108static const struct xlat prctl_options[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000109#ifdef PR_MAXPROCS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000110 XLAT(PR_MAXPROCS),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000111#endif
112#ifdef PR_ISBLOCKED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000113 XLAT(PR_ISBLOCKED),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000114#endif
115#ifdef PR_SETSTACKSIZE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000116 XLAT(PR_SETSTACKSIZE),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000117#endif
118#ifdef PR_GETSTACKSIZE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000119 XLAT(PR_GETSTACKSIZE),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000120#endif
121#ifdef PR_MAXPPROCS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000122 XLAT(PR_MAXPPROCS),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000123#endif
124#ifdef PR_UNBLKONEXEC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000125 XLAT(PR_UNBLKONEXEC),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000126#endif
127#ifdef PR_ATOMICSIM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000128 XLAT(PR_ATOMICSIM),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000129#endif
130#ifdef PR_SETEXITSIG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000131 XLAT(PR_SETEXITSIG),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000132#endif
133#ifdef PR_RESIDENT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000134 XLAT(PR_RESIDENT),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000135#endif
136#ifdef PR_ATTACHADDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000137 XLAT(PR_ATTACHADDR),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000138#endif
139#ifdef PR_DETACHADDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000140 XLAT(PR_DETACHADDR),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000141#endif
142#ifdef PR_TERMCHILD
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000143 XLAT(PR_TERMCHILD),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000144#endif
145#ifdef PR_GETSHMASK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000146 XLAT(PR_GETSHMASK),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000147#endif
148#ifdef PR_GETNSHARE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000149 XLAT(PR_GETNSHARE),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000150#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +0000151#ifdef PR_COREPID
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000152 XLAT(PR_COREPID),
Wichert Akkerman8829a551999-06-11 13:18:40 +0000153#endif
154#ifdef PR_ATTACHADDRPERM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000155 XLAT(PR_ATTACHADDRPERM),
Wichert Akkerman8829a551999-06-11 13:18:40 +0000156#endif
157#ifdef PR_PTHREADEXIT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000158 XLAT(PR_PTHREADEXIT),
Wichert Akkerman8829a551999-06-11 13:18:40 +0000159#endif
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000160
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000161#ifdef PR_SET_PDEATHSIG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000162 XLAT(PR_SET_PDEATHSIG),
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000163#endif
164#ifdef PR_GET_PDEATHSIG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000165 XLAT(PR_GET_PDEATHSIG),
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000166#endif
Dmitry V. Levinf02cf212008-09-03 00:54:40 +0000167#ifdef PR_GET_DUMPABLE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000168 XLAT(PR_GET_DUMPABLE),
Dmitry V. Levinf02cf212008-09-03 00:54:40 +0000169#endif
170#ifdef PR_SET_DUMPABLE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000171 XLAT(PR_SET_DUMPABLE),
Dmitry V. Levinf02cf212008-09-03 00:54:40 +0000172#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000173#ifdef PR_GET_UNALIGN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000174 XLAT(PR_GET_UNALIGN),
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000175#endif
176#ifdef PR_SET_UNALIGN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000177 XLAT(PR_SET_UNALIGN),
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000178#endif
179#ifdef PR_GET_KEEPCAPS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000180 XLAT(PR_GET_KEEPCAPS),
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000181#endif
182#ifdef PR_SET_KEEPCAPS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000183 XLAT(PR_SET_KEEPCAPS),
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000184#endif
Roland McGrathe5039fb2007-11-03 23:58:07 +0000185#ifdef PR_GET_FPEMU
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000186 XLAT(PR_GET_FPEMU),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000187#endif
188#ifdef PR_SET_FPEMU
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000189 XLAT(PR_SET_FPEMU),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000190#endif
191#ifdef PR_GET_FPEXC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000192 XLAT(PR_GET_FPEXC),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000193#endif
194#ifdef PR_SET_FPEXC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000195 XLAT(PR_SET_FPEXC),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000196#endif
197#ifdef PR_GET_TIMING
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000198 XLAT(PR_GET_TIMING),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000199#endif
200#ifdef PR_SET_TIMING
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000201 XLAT(PR_SET_TIMING),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000202#endif
203#ifdef PR_SET_NAME
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000204 XLAT(PR_SET_NAME),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000205#endif
206#ifdef PR_GET_NAME
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000207 XLAT(PR_GET_NAME),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000208#endif
209#ifdef PR_GET_ENDIAN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000210 XLAT(PR_GET_ENDIAN),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000211#endif
212#ifdef PR_SET_ENDIAN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000213 XLAT(PR_SET_ENDIAN),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000214#endif
215#ifdef PR_GET_SECCOMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000216 XLAT(PR_GET_SECCOMP),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000217#endif
218#ifdef PR_SET_SECCOMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000219 XLAT(PR_SET_SECCOMP),
Roland McGrathe5039fb2007-11-03 23:58:07 +0000220#endif
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000221#ifdef PR_CAPBSET_READ
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000222 XLAT(PR_CAPBSET_READ),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000223#endif
224#ifdef PR_CAPBSET_DROP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000225 XLAT(PR_CAPBSET_DROP),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000226#endif
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000227#ifdef PR_GET_TSC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000228 XLAT(PR_GET_TSC),
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000229#endif
230#ifdef PR_SET_TSC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000231 XLAT(PR_SET_TSC),
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000232#endif
233#ifdef PR_GET_SECUREBITS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000234 XLAT(PR_GET_SECUREBITS),
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000235#endif
236#ifdef PR_SET_SECUREBITS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000237 XLAT(PR_SET_SECUREBITS),
Dmitry V. Levin8dd31dd2008-11-11 00:25:22 +0000238#endif
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000239#ifdef PR_SET_TIMERSLACK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000240 XLAT(PR_SET_TIMERSLACK),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000241#endif
242#ifdef PR_GET_TIMERSLACK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000243 XLAT(PR_GET_TIMERSLACK),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000244#endif
245#ifdef PR_TASK_PERF_EVENTS_DISABLE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000246 XLAT(PR_TASK_PERF_EVENTS_DISABLE),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000247#endif
248#ifdef PR_TASK_PERF_EVENTS_ENABLE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000249 XLAT(PR_TASK_PERF_EVENTS_ENABLE),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000250#endif
251#ifdef PR_MCE_KILL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000252 XLAT(PR_MCE_KILL),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000253#endif
254#ifdef PR_MCE_KILL_GET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000255 XLAT(PR_MCE_KILL_GET),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000256#endif
257#ifdef PR_SET_MM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000258 XLAT(PR_SET_MM),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000259#endif
Dmitry V. Levin7a0fb382013-05-13 18:34:15 +0000260#ifdef PR_SET_PTRACER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000261 XLAT(PR_SET_PTRACER),
Dmitry V. Levin7a0fb382013-05-13 18:34:15 +0000262#endif
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000263#ifdef PR_SET_CHILD_SUBREAPER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000264 XLAT(PR_SET_CHILD_SUBREAPER),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000265#endif
266#ifdef PR_GET_CHILD_SUBREAPER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000267 XLAT(PR_GET_CHILD_SUBREAPER),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000268#endif
269#ifdef PR_SET_NO_NEW_PRIVS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000270 XLAT(PR_SET_NO_NEW_PRIVS),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000271#endif
272#ifdef PR_GET_NO_NEW_PRIVS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000273 XLAT(PR_GET_NO_NEW_PRIVS),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000274#endif
275#ifdef PR_GET_TID_ADDRESS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000276 XLAT(PR_GET_TID_ADDRESS),
Dmitry V. Levinb6593de2013-03-27 14:57:39 +0000277#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000278 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000279};
280
Roland McGratha4d48532005-06-08 20:45:28 +0000281static const char *
Denys Vlasenko12014262011-05-30 14:00:14 +0200282unalignctl_string(unsigned int ctl)
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000283{
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100284 static char buf[sizeof(int)*2 + 2];
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000285
286 switch (ctl) {
287#ifdef PR_UNALIGN_NOPRINT
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100288 case PR_UNALIGN_NOPRINT:
289 return "NOPRINT";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000290#endif
291#ifdef PR_UNALIGN_SIGBUS
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100292 case PR_UNALIGN_SIGBUS:
293 return "SIGBUS";
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000294#endif
Denys Vlasenkob237b1b2012-02-27 13:56:59 +0100295 default:
296 break;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000297 }
298 sprintf(buf, "%x", ctl);
299 return buf;
300}
301
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000302int
Denys Vlasenko12014262011-05-30 14:00:14 +0200303sys_prctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000304{
305 int i;
306
307 if (entering(tcp)) {
308 printxval(prctl_options, tcp->u_arg[0], "PR_???");
309 switch (tcp->u_arg[0]) {
310#ifdef PR_GETNSHARE
311 case PR_GETNSHARE:
312 break;
313#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000314#ifdef PR_SET_PDEATHSIG
315 case PR_SET_PDEATHSIG:
316 tprintf(", %lu", tcp->u_arg[1]);
317 break;
318#endif
319#ifdef PR_GET_PDEATHSIG
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000320 case PR_GET_PDEATHSIG:
321 break;
322#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000323#ifdef PR_SET_DUMPABLE
324 case PR_SET_DUMPABLE:
325 tprintf(", %lu", tcp->u_arg[1]);
326 break;
327#endif
328#ifdef PR_GET_DUMPABLE
329 case PR_GET_DUMPABLE:
330 break;
331#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000332#ifdef PR_SET_UNALIGN
333 case PR_SET_UNALIGN:
334 tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
335 break;
336#endif
337#ifdef PR_GET_UNALIGN
338 case PR_GET_UNALIGN:
339 tprintf(", %#lx", tcp->u_arg[1]);
340 break;
341#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000342#ifdef PR_SET_KEEPCAPS
343 case PR_SET_KEEPCAPS:
344 tprintf(", %lu", tcp->u_arg[1]);
345 break;
346#endif
347#ifdef PR_GET_KEEPCAPS
348 case PR_GET_KEEPCAPS:
349 break;
350#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000351 default:
Denys Vlasenko74ec14f2013-02-21 16:13:47 +0100352 for (i = 1; i < tcp->s_ent->nargs; i++)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000353 tprintf(", %#lx", tcp->u_arg[i]);
354 break;
355 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000356 } else {
357 switch (tcp->u_arg[0]) {
358#ifdef PR_GET_PDEATHSIG
359 case PR_GET_PDEATHSIG:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000360 if (umove(tcp, tcp->u_arg[1], &i) < 0)
361 tprintf(", %#lx", tcp->u_arg[1]);
362 else
363 tprintf(", {%u}", i);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000364 break;
365#endif
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000366#ifdef PR_GET_DUMPABLE
367 case PR_GET_DUMPABLE:
368 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000369#endif
370#ifdef PR_GET_UNALIGN
371 case PR_GET_UNALIGN:
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000372 if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
373 break;
374 tcp->auxstr = unalignctl_string(i);
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000375 return RVAL_STR;
Dmitry V. Levin50f60132008-09-03 00:56:52 +0000376#endif
377#ifdef PR_GET_KEEPCAPS
378 case PR_GET_KEEPCAPS:
379 return RVAL_UDECIMAL;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000380#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000381 default:
382 break;
383 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000384 }
385 return 0;
386}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000387#endif /* HAVE_PRCTL */
388
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000389int
Denys Vlasenko12014262011-05-30 14:00:14 +0200390sys_sethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000391{
392 if (entering(tcp)) {
393 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
394 tprintf(", %lu", tcp->u_arg[1]);
395 }
396 return 0;
397}
398
Denys Vlasenko84703742012-02-25 02:38:52 +0100399#if defined(ALPHA)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000400int
Denys Vlasenko12014262011-05-30 14:00:14 +0200401sys_gethostname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000402{
403 if (exiting(tcp)) {
404 if (syserror(tcp))
405 tprintf("%#lx", tcp->u_arg[0]);
406 else
407 printpath(tcp, tcp->u_arg[0]);
408 tprintf(", %lu", tcp->u_arg[1]);
409 }
410 return 0;
411}
Denys Vlasenko84703742012-02-25 02:38:52 +0100412#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000413
414int
Denys Vlasenko12014262011-05-30 14:00:14 +0200415sys_setdomainname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000416{
417 if (entering(tcp)) {
418 printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
419 tprintf(", %lu", tcp->u_arg[1]);
420 }
421 return 0;
422}
423
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000424int
Denys Vlasenko12014262011-05-30 14:00:14 +0200425sys_exit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000426{
427 if (exiting(tcp)) {
428 fprintf(stderr, "_exit returned!\n");
429 return -1;
430 }
431 /* special case: we stop tracing this process, finish line now */
432 tprintf("%ld) ", tcp->u_arg[0]);
Denys Vlasenko102ec492011-08-25 01:27:59 +0200433 tabto();
Denys Vlasenko000b6012012-01-28 01:25:03 +0100434 tprints("= ?\n");
Denys Vlasenko7de265d2012-03-13 11:44:31 +0100435 line_ended();
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000436 return 0;
437}
438
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000439/* defines copied from linux/sched.h since we can't include that
440 * ourselves (it conflicts with *lots* of libc includes)
441 */
442#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
443#define CLONE_VM 0x00000100 /* set if VM shared between processes */
444#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
445#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
446#define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
Roland McGrath909875b2002-12-22 03:34:36 +0000447#define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000448#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
449#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
450#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
Roland McGrath909875b2002-12-22 03:34:36 +0000451#define CLONE_THREAD 0x00010000 /* Same thread group? */
452#define CLONE_NEWNS 0x00020000 /* New namespace group? */
453#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
454#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
455#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
456#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
Roland McGrath909875b2002-12-22 03:34:36 +0000457#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
458#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
Dmitry V. Levine3d4b682010-12-03 17:19:51 +0000459#define CLONE_STOPPED 0x02000000 /* Start in stopped state */
460#define CLONE_NEWUTS 0x04000000 /* New utsname group? */
461#define CLONE_NEWIPC 0x08000000 /* New ipcs */
462#define CLONE_NEWUSER 0x10000000 /* New user namespace */
463#define CLONE_NEWPID 0x20000000 /* New pid namespace */
464#define CLONE_NEWNET 0x40000000 /* New network namespace */
465#define CLONE_IO 0x80000000 /* Clone io context */
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000466
Roland McGrathd9f816f2004-09-04 03:39:20 +0000467static const struct xlat clone_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000468 XLAT(CLONE_VM),
469 XLAT(CLONE_FS),
470 XLAT(CLONE_FILES),
471 XLAT(CLONE_SIGHAND),
472 XLAT(CLONE_IDLETASK),
473 XLAT(CLONE_PTRACE),
474 XLAT(CLONE_VFORK),
475 XLAT(CLONE_PARENT),
476 XLAT(CLONE_THREAD),
477 XLAT(CLONE_NEWNS),
478 XLAT(CLONE_SYSVSEM),
479 XLAT(CLONE_SETTLS),
480 XLAT(CLONE_PARENT_SETTID),
481 XLAT(CLONE_CHILD_CLEARTID),
482 XLAT(CLONE_UNTRACED),
483 XLAT(CLONE_CHILD_SETTID),
484 XLAT(CLONE_STOPPED),
485 XLAT(CLONE_NEWUTS),
486 XLAT(CLONE_NEWIPC),
487 XLAT(CLONE_NEWUSER),
488 XLAT(CLONE_NEWPID),
489 XLAT(CLONE_NEWNET),
490 XLAT(CLONE_IO),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000491 XLAT_END
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000492};
493
Dmitry V. Levinf94e8472014-04-09 12:30:38 +0000494#if defined I386 || defined X86_64 || defined X32
Dmitry V. Levin99a05442014-04-10 14:10:17 +0000495extern void print_user_desc(struct tcb *, long);
Dmitry V. Levinf94e8472014-04-09 12:30:38 +0000496#endif /* I386 || X86_64 || X32 */
Roland McGrath909875b2002-12-22 03:34:36 +0000497
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +0100498#if defined IA64
499# define ARG_FLAGS 0
500# define ARG_STACK 1
501# define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
502# define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
503# define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
504# define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
505#elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
506# define ARG_STACK 0
507# define ARG_FLAGS 1
508# define ARG_PTID 2
509# define ARG_CTID 3
510# define ARG_TLS 4
Dmitry V. Levin2c4fb252014-04-09 12:34:58 +0000511#elif defined X86_64 || defined X32
Elliott Hughesb5633252014-04-05 11:56:17 -0700512/* x86 personality processes have the last two arguments flipped. */
513# define ARG_FLAGS 0
514# define ARG_STACK 1
515# define ARG_PTID 2
516# define ARG_CTID ((current_personality != 1) ? 3 : 4)
517# define ARG_TLS ((current_personality != 1) ? 4 : 3)
Dmitry V. Levin2c4fb252014-04-09 12:34:58 +0000518#elif defined ALPHA || defined TILE || 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) {
Dmitry V. Levinf94e8472014-04-09 12:30:38 +0000555#if defined I386 || defined X86_64 || defined X32
Elliott Hughes44655a42014-04-05 11:56:17 -0700556# ifndef I386
557 if (current_personality == 1)
558# endif
559 {
Dmitry V. Levin99a05442014-04-10 14:10:17 +0000560 tprints(", tls=");
561 print_user_desc(tcp, tcp->u_arg[ARG_TLS]);
Roland McGrath909875b2002-12-22 03:34:36 +0000562 }
Dmitry V. Levin99a05442014-04-10 14:10:17 +0000563# ifndef I386
Roland McGrath909875b2002-12-22 03:34:36 +0000564 else
Dmitry V. Levin99a05442014-04-10 14:10:17 +0000565# endif
Dmitry V. Levinf94e8472014-04-09 12:30:38 +0000566#endif /* I386 || X86_64 || X32 */
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 }
Denys Vlasenkod0830162013-06-28 18:57:27 +0200572 /* TODO on syscall entry:
573 * We can clear CLONE_PTRACE here since it is an ancient hack
574 * to allow us to catch children, and we use another hack for that.
575 * But CLONE_PTRACE can conceivably be used by malicious programs
576 * to subvert us. By clearing this bit, we can defend against it:
577 * in untraced execution, CLONE_PTRACE should have no effect.
578 *
579 * We can also clear CLONE_UNTRACED, since it allows to start
580 * children outside of our control. At the moment
581 * I'm trying to figure out whether there is a *legitimate*
582 * use of this flag which we should respect.
583 */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000584 return 0;
585}
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000586
587int
Masatake YAMATOb2ede142014-05-14 01:46:04 +0900588sys_setns(struct tcb *tcp)
589{
590 if (entering(tcp)) {
591 printfd(tcp, tcp->u_arg[0]);
592 tprints(", ");
593 printflags(clone_flags, tcp->u_arg[1], "CLONE_???");
594 }
595 return 0;
596}
597
598int
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000599sys_unshare(struct tcb *tcp)
600{
601 if (entering(tcp))
602 printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
603 return 0;
604}
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000605
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000606int
Denys Vlasenko081533c2012-03-17 02:17:51 +0100607sys_fork(struct tcb *tcp)
608{
609 if (exiting(tcp))
610 return RVAL_UDECIMAL;
611 return 0;
612}
613
Dmitry V. Levin50a218d2011-01-18 17:36:20 +0000614int sys_getuid(struct tcb *tcp)
615{
616 if (exiting(tcp))
617 tcp->u_rval = (uid_t) tcp->u_rval;
618 return RVAL_UDECIMAL;
619}
620
621int sys_setfsuid(struct tcb *tcp)
622{
623 if (entering(tcp))
624 tprintf("%u", (uid_t) tcp->u_arg[0]);
625 else
626 tcp->u_rval = (uid_t) tcp->u_rval;
627 return RVAL_UDECIMAL;
628}
629
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000630int
Denys Vlasenko12014262011-05-30 14:00:14 +0200631sys_setuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000632{
633 if (entering(tcp)) {
634 tprintf("%u", (uid_t) tcp->u_arg[0]);
635 }
636 return 0;
637}
638
639int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000640sys_getresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000641{
642 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000643 __kernel_uid_t uid;
644 if (syserror(tcp))
645 tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
646 tcp->u_arg[1], tcp->u_arg[2]);
647 else {
648 if (umove(tcp, tcp->u_arg[0], &uid) < 0)
649 tprintf("%#lx, ", tcp->u_arg[0]);
650 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000651 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000652 if (umove(tcp, tcp->u_arg[1], &uid) < 0)
653 tprintf("%#lx, ", tcp->u_arg[1]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000654 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000655 tprintf("[%lu], ", (unsigned long) uid);
Roland McGrath9bd6b422003-02-24 07:13:51 +0000656 if (umove(tcp, tcp->u_arg[2], &uid) < 0)
657 tprintf("%#lx", tcp->u_arg[2]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000658 else
Roland McGrath83bd47a2003-11-13 22:32:26 +0000659 tprintf("[%lu]", (unsigned long) uid);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000660 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000661 }
662 return 0;
663}
664
665int
Denys Vlasenko12014262011-05-30 14:00:14 +0200666sys_setreuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000667{
668 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000669 printuid("", tcp->u_arg[0]);
670 printuid(", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000671 }
672 return 0;
673}
674
675int
Denys Vlasenko12014262011-05-30 14:00:14 +0200676sys_setresuid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000677{
678 if (entering(tcp)) {
Roland McGrath83bd47a2003-11-13 22:32:26 +0000679 printuid("", tcp->u_arg[0]);
680 printuid(", ", tcp->u_arg[1]);
681 printuid(", ", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000682 }
683 return 0;
684}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000685
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000686int
Denys Vlasenko12014262011-05-30 14:00:14 +0200687sys_setgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000688{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000689 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000690 unsigned long len, size, start, cur, end, abbrev_end;
691 GETGROUPS_T gid;
692 int failed = 0;
693
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000694 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000695 tprintf("%lu, ", len);
696 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200697 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000698 return 0;
699 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000700 start = tcp->u_arg[1];
701 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200702 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000703 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000704 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000705 size = len * sizeof(gid);
706 end = start + size;
707 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
708 tprintf("%#lx", start);
709 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000710 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000711 if (abbrev(tcp)) {
712 abbrev_end = start + max_strlen * sizeof(gid);
713 if (abbrev_end < start)
714 abbrev_end = end;
715 } else {
716 abbrev_end = end;
717 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200718 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000719 for (cur = start; cur < end; cur += sizeof(gid)) {
720 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200721 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000722 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200723 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000724 break;
725 }
726 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200727 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000728 failed = 1;
729 break;
730 }
731 tprintf("%lu", (unsigned long) gid);
732 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200733 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000734 if (failed)
735 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000736 }
737 return 0;
738}
739
740int
Denys Vlasenko12014262011-05-30 14:00:14 +0200741sys_getgroups(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000742{
Roland McGrathaa524c82005-06-01 19:22:06 +0000743 unsigned long len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000744
745 if (entering(tcp)) {
746 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000747 tprintf("%lu, ", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000748 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000749 unsigned long size, start, cur, end, abbrev_end;
750 GETGROUPS_T gid;
751 int failed = 0;
752
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000753 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000754 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200755 tprints("[]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000756 return 0;
757 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000758 start = tcp->u_arg[1];
759 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200760 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000761 return 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000762 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000763 if (tcp->u_arg[0] == 0) {
764 tprintf("%#lx", start);
765 return 0;
766 }
767 size = len * sizeof(gid);
768 end = start + size;
769 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
770 size / sizeof(gid) != len || end < start) {
771 tprintf("%#lx", start);
772 return 0;
773 }
774 if (abbrev(tcp)) {
775 abbrev_end = start + max_strlen * sizeof(gid);
776 if (abbrev_end < start)
777 abbrev_end = end;
778 } else {
779 abbrev_end = end;
780 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200781 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000782 for (cur = start; cur < end; cur += sizeof(gid)) {
783 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200784 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000785 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200786 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000787 break;
788 }
789 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200790 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000791 failed = 1;
792 break;
793 }
794 tprintf("%lu", (unsigned long) gid);
795 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200796 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000797 if (failed)
798 tprintf(" %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000799 }
800 return 0;
801}
802
Roland McGrath83bd47a2003-11-13 22:32:26 +0000803int
Denys Vlasenko12014262011-05-30 14:00:14 +0200804sys_setgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000805{
Roland McGrath83bd47a2003-11-13 22:32:26 +0000806 if (entering(tcp)) {
Roland McGrathaa524c82005-06-01 19:22:06 +0000807 unsigned long len, size, start, cur, end, abbrev_end;
808 GETGROUPS32_T gid;
809 int failed = 0;
810
Roland McGrath83bd47a2003-11-13 22:32:26 +0000811 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000812 tprintf("%lu, ", len);
813 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200814 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000815 return 0;
816 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000817 start = tcp->u_arg[1];
818 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200819 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000820 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000821 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000822 size = len * sizeof(gid);
823 end = start + size;
824 if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
825 tprintf("%#lx", start);
826 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000827 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000828 if (abbrev(tcp)) {
829 abbrev_end = start + max_strlen * sizeof(gid);
830 if (abbrev_end < start)
831 abbrev_end = end;
832 } else {
833 abbrev_end = end;
834 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200835 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000836 for (cur = start; cur < end; cur += sizeof(gid)) {
837 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200838 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000839 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200840 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000841 break;
842 }
843 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200844 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000845 failed = 1;
846 break;
847 }
848 tprintf("%lu", (unsigned long) gid);
849 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200850 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000851 if (failed)
852 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000853 }
854 return 0;
855}
856
857int
Denys Vlasenko12014262011-05-30 14:00:14 +0200858sys_getgroups32(struct tcb *tcp)
Roland McGrath83bd47a2003-11-13 22:32:26 +0000859{
Roland McGrathaa524c82005-06-01 19:22:06 +0000860 unsigned long len;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000861
862 if (entering(tcp)) {
863 len = tcp->u_arg[0];
Roland McGrathaa524c82005-06-01 19:22:06 +0000864 tprintf("%lu, ", len);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000865 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000866 unsigned long size, start, cur, end, abbrev_end;
867 GETGROUPS32_T gid;
868 int failed = 0;
869
Roland McGrath83bd47a2003-11-13 22:32:26 +0000870 len = tcp->u_rval;
Roland McGrathaa524c82005-06-01 19:22:06 +0000871 if (len == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200872 tprints("[]");
Roland McGrath83bd47a2003-11-13 22:32:26 +0000873 return 0;
874 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000875 start = tcp->u_arg[1];
876 if (start == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200877 tprints("NULL");
Roland McGrathaa524c82005-06-01 19:22:06 +0000878 return 0;
Roland McGrath83bd47a2003-11-13 22:32:26 +0000879 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000880 size = len * sizeof(gid);
881 end = start + size;
882 if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
883 size / sizeof(gid) != len || end < start) {
884 tprintf("%#lx", start);
885 return 0;
886 }
887 if (abbrev(tcp)) {
888 abbrev_end = start + max_strlen * sizeof(gid);
889 if (abbrev_end < start)
890 abbrev_end = end;
891 } else {
892 abbrev_end = end;
893 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200894 tprints("[");
Roland McGrathaa524c82005-06-01 19:22:06 +0000895 for (cur = start; cur < end; cur += sizeof(gid)) {
896 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200897 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000898 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200899 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000900 break;
901 }
902 if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200903 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000904 failed = 1;
905 break;
906 }
907 tprintf("%lu", (unsigned long) gid);
908 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200909 tprints("]");
Roland McGrathaa524c82005-06-01 19:22:06 +0000910 if (failed)
911 tprintf(" %#lx", tcp->u_arg[1]);
Roland McGrath83bd47a2003-11-13 22:32:26 +0000912 }
913 return 0;
914}
Roland McGrath83bd47a2003-11-13 22:32:26 +0000915
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000916static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000917printargv(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000918{
Roland McGrath85a3bc42007-08-02 02:13:05 +0000919 union {
Andreas Schwab99c85692009-08-28 19:36:20 +0200920 unsigned int p32;
921 unsigned long p64;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000922 char data[sizeof(long)];
923 } cp;
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000924 const char *sep;
Roland McGrath85a3bc42007-08-02 02:13:05 +0000925 int n = 0;
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100926 unsigned wordsize = current_wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000927
Roland McGrath85a3bc42007-08-02 02:13:05 +0000928 cp.p64 = 1;
929 for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100930 if (umoven(tcp, addr, wordsize, cp.data) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000931 tprintf("%#lx", addr);
932 return;
933 }
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100934 if (wordsize == 4)
Roland McGrath85a3bc42007-08-02 02:13:05 +0000935 cp.p64 = cp.p32;
936 if (cp.p64 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000937 break;
Denys Vlasenko5940e652011-09-01 09:55:05 +0200938 tprints(sep);
Roland McGrath85a3bc42007-08-02 02:13:05 +0000939 printstr(tcp, cp.p64, -1);
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100940 addr += wordsize;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000941 }
Roland McGrath85a3bc42007-08-02 02:13:05 +0000942 if (cp.p64)
943 tprintf("%s...", sep);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000944}
945
946static void
Dmitry V. Levin30145dd2010-09-06 22:08:24 +0000947printargc(const char *fmt, struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000948{
949 int count;
950 char *cp;
951
952 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
953 addr += sizeof(char *);
954 }
955 tprintf(fmt, count, count == 1 ? "" : "s");
956}
957
Denys Vlasenko84703742012-02-25 02:38:52 +0100958#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000959int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000960sys_execv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000961{
962 if (entering(tcp)) {
963 printpath(tcp, tcp->u_arg[0]);
964 if (!verbose(tcp))
965 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000966 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200967 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000968 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200969 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000970 }
971 }
972 return 0;
973}
Denys Vlasenko84703742012-02-25 02:38:52 +0100974#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000975
976int
Dmitry V. Levine5e60852009-12-31 22:50:49 +0000977sys_execve(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000978{
979 if (entering(tcp)) {
980 printpath(tcp, tcp->u_arg[0]);
981 if (!verbose(tcp))
982 tprintf(", %#lx", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000983 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200984 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000985 printargv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200986 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000987 }
988 if (!verbose(tcp))
989 tprintf(", %#lx", tcp->u_arg[2]);
990 else if (abbrev(tcp))
991 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
992 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200993 tprints(", [");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000994 printargv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200995 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000996 }
997 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000998 return 0;
999}
1000
Roland McGrath7ec1d352002-12-17 04:50:44 +00001001#ifndef __WNOTHREAD
1002#define __WNOTHREAD 0x20000000
1003#endif
1004#ifndef __WALL
1005#define __WALL 0x40000000
1006#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001007#ifndef __WCLONE
Roland McGrath7ec1d352002-12-17 04:50:44 +00001008#define __WCLONE 0x80000000
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001009#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001010
Roland McGrathd9f816f2004-09-04 03:39:20 +00001011static const struct xlat wait4_options[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001012 XLAT(WNOHANG),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001013#ifndef WSTOPPED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001014 XLAT(WUNTRACED),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001015#endif
1016#ifdef WEXITED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001017 XLAT(WEXITED),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001018#endif
1019#ifdef WTRAPPED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001020 XLAT(WTRAPPED),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001021#endif
1022#ifdef WSTOPPED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001023 XLAT(WSTOPPED),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001024#endif
1025#ifdef WCONTINUED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001026 XLAT(WCONTINUED),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001027#endif
1028#ifdef WNOWAIT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001029 XLAT(WNOWAIT),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001030#endif
1031#ifdef __WCLONE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001032 XLAT(__WCLONE),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001033#endif
Roland McGrath7ec1d352002-12-17 04:50:44 +00001034#ifdef __WALL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001035 XLAT(__WALL),
Roland McGrath7ec1d352002-12-17 04:50:44 +00001036#endif
1037#ifdef __WNOTHREAD
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001038 XLAT(__WNOTHREAD),
Roland McGrath7ec1d352002-12-17 04:50:44 +00001039#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001040 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001041};
1042
Roland McGrath5e02a572004-10-19 23:33:47 +00001043#if !defined WCOREFLAG && defined WCOREFLG
1044# define WCOREFLAG WCOREFLG
1045#endif
1046#ifndef WCOREFLAG
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001047# define WCOREFLAG 0x80
Roland McGrath5e02a572004-10-19 23:33:47 +00001048#endif
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001049#ifndef WCOREDUMP
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001050# define WCOREDUMP(status) ((status) & 0200)
Dmitry V. Levine5e60852009-12-31 22:50:49 +00001051#endif
Roland McGrath5e02a572004-10-19 23:33:47 +00001052#ifndef W_STOPCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001053# define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
Roland McGrath5e02a572004-10-19 23:33:47 +00001054#endif
1055#ifndef W_EXITCODE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001056# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
Roland McGrath5e02a572004-10-19 23:33:47 +00001057#endif
1058
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001059static int
Denys Vlasenko12014262011-05-30 14:00:14 +02001060printstatus(int status)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001061{
1062 int exited = 0;
1063
1064 /*
1065 * Here is a tricky presentation problem. This solution
1066 * is still not entirely satisfactory but since there
1067 * are no wait status constructors it will have to do.
1068 */
Roland McGrath79fbda52004-04-14 02:45:55 +00001069 if (WIFSTOPPED(status)) {
1070 tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001071 signame(WSTOPSIG(status)));
Roland McGrath79fbda52004-04-14 02:45:55 +00001072 status &= ~W_STOPCODE(WSTOPSIG(status));
1073 }
1074 else if (WIFSIGNALED(status)) {
1075 tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001076 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001077 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
Roland McGrath79fbda52004-04-14 02:45:55 +00001078 status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
1079 }
1080 else if (WIFEXITED(status)) {
1081 tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001082 WEXITSTATUS(status));
1083 exited = 1;
Roland McGrath79fbda52004-04-14 02:45:55 +00001084 status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001085 }
Roland McGrath79fbda52004-04-14 02:45:55 +00001086 else {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001087 tprintf("[%#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001088 return 0;
1089 }
1090
1091 if (status == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001092 tprints("]");
Roland McGrath79fbda52004-04-14 02:45:55 +00001093 else
Roland McGrathf8cc83c2004-06-04 01:24:07 +00001094 tprintf(" | %#x]", status);
Roland McGrath79fbda52004-04-14 02:45:55 +00001095
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001096 return exited;
1097}
1098
1099static int
Denys Vlasenko59432db2009-01-26 19:09:35 +00001100printwaitn(struct tcb *tcp, int n, int bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001101{
1102 int status;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001103
1104 if (entering(tcp)) {
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001105 /* On Linux, kernel-side pid_t is typedef'ed to int
1106 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
Denys Vlasenko59432db2009-01-26 19:09:35 +00001107 * pid argument to int on 64bit arches, producing,
1108 * for example, wait4(4294967295, ...) instead of -1
Denys Vlasenkoe740fd32009-04-16 12:06:16 +00001109 * in strace. We have to use int here, not long.
1110 */
1111 int pid = tcp->u_arg[0];
1112 tprintf("%d, ", pid);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001113 } else {
1114 /* status */
1115 if (!tcp->u_arg[1])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001116 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001117 else if (syserror(tcp) || tcp->u_rval == 0)
1118 tprintf("%#lx", tcp->u_arg[1]);
1119 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001120 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001121 else
Dmitry V. Levind9a4b0a2011-02-23 00:27:12 +00001122 printstatus(status);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001123 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001124 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001125 printflags(wait4_options, tcp->u_arg[2], "W???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001126 if (n == 4) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001127 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001128 /* usage */
1129 if (!tcp->u_arg[3])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001130 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001131 else if (tcp->u_rval > 0) {
Denys Vlasenko59432db2009-01-26 19:09:35 +00001132#ifdef ALPHA
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001133 if (bitness)
1134 printrusage32(tcp, tcp->u_arg[3]);
1135 else
1136#endif
1137 printrusage(tcp, tcp->u_arg[3]);
1138 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001139 else
1140 tprintf("%#lx", tcp->u_arg[3]);
1141 }
1142 }
1143 return 0;
1144}
1145
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001146int
Denys Vlasenko12014262011-05-30 14:00:14 +02001147sys_waitpid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001148{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001149 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001150}
1151
1152int
Denys Vlasenko12014262011-05-30 14:00:14 +02001153sys_wait4(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001154{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001155 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001156}
1157
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001158#ifdef ALPHA
1159int
Denys Vlasenko12014262011-05-30 14:00:14 +02001160sys_osf_wait4(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001161{
1162 return printwaitn(tcp, 4, 1);
1163}
1164#endif
1165
Roland McGrathd9f816f2004-09-04 03:39:20 +00001166static const struct xlat waitid_types[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001167 XLAT(P_PID),
Roland McGrathc74c0b72004-09-01 19:39:46 +00001168#ifdef P_PPID
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001169 XLAT(P_PPID),
Roland McGrathc74c0b72004-09-01 19:39:46 +00001170#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001171 XLAT(P_PGID),
Roland McGrathc74c0b72004-09-01 19:39:46 +00001172#ifdef P_SID
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001173 XLAT(P_SID),
Roland McGrathc74c0b72004-09-01 19:39:46 +00001174#endif
1175#ifdef P_CID
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001176 XLAT(P_CID),
Roland McGrathc74c0b72004-09-01 19:39:46 +00001177#endif
1178#ifdef P_UID
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001179 XLAT(P_UID),
Roland McGrathc74c0b72004-09-01 19:39:46 +00001180#endif
1181#ifdef P_GID
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001182 XLAT(P_GID),
Roland McGrathc74c0b72004-09-01 19:39:46 +00001183#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001184 XLAT(P_ALL),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001185#ifdef P_LWPID
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001186 XLAT(P_LWPID),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001187#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001188 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001189};
1190
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001191int
Dmitry V. Levin3eb94912010-09-09 23:08:59 +00001192sys_waitid(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001193{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001194 if (entering(tcp)) {
1195 printxval(waitid_types, tcp->u_arg[0], "P_???");
1196 tprintf(", %ld, ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001197 }
1198 else {
1199 /* siginfo */
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01001200 printsiginfo_at(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001201 /* options */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001202 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001203 printflags(wait4_options, tcp->u_arg[3], "W???");
Denys Vlasenko74ec14f2013-02-21 16:13:47 +01001204 if (tcp->s_ent->nargs > 4) {
Roland McGrath39426a32004-10-06 22:02:59 +00001205 /* usage */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001206 tprints(", ");
Roland McGrath39426a32004-10-06 22:02:59 +00001207 if (!tcp->u_arg[4])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001208 tprints("NULL");
Roland McGrath39426a32004-10-06 22:02:59 +00001209 else if (tcp->u_error)
1210 tprintf("%#lx", tcp->u_arg[4]);
1211 else
1212 printrusage(tcp, tcp->u_arg[4]);
1213 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001214 }
1215 return 0;
1216}
1217
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001218int
Denys Vlasenko12014262011-05-30 14:00:14 +02001219sys_uname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001220{
1221 struct utsname uname;
1222
1223 if (exiting(tcp)) {
1224 if (syserror(tcp) || !verbose(tcp))
1225 tprintf("%#lx", tcp->u_arg[0]);
1226 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001227 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001228 else if (!abbrev(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001229 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1230 uname.sysname, uname.nodename);
1231 tprintf("release=\"%s\", version=\"%s\", ",
1232 uname.release, uname.version);
1233 tprintf("machine=\"%s\"", uname.machine);
Dmitry V. Levinea22e972012-05-01 20:56:32 +00001234#ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001235 tprintf(", domainname=\"%s\"", uname.domainname);
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00001236#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001237 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001238 }
1239 else
1240 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1241 uname.sysname, uname.nodename);
1242 }
1243 return 0;
1244}
1245
Roland McGratheb9e2e82009-06-02 16:49:22 -07001246static const struct xlat ptrace_cmds[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001247 XLAT(PTRACE_TRACEME),
1248 XLAT(PTRACE_PEEKTEXT),
1249 XLAT(PTRACE_PEEKDATA),
1250 XLAT(PTRACE_PEEKUSER),
1251 XLAT(PTRACE_POKETEXT),
1252 XLAT(PTRACE_POKEDATA),
1253 XLAT(PTRACE_POKEUSER),
1254 XLAT(PTRACE_CONT),
1255 XLAT(PTRACE_KILL),
1256 XLAT(PTRACE_SINGLESTEP),
1257 XLAT(PTRACE_ATTACH),
1258 XLAT(PTRACE_DETACH),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001259#ifdef PTRACE_GETREGS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001260 XLAT(PTRACE_GETREGS),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001261#endif
1262#ifdef PTRACE_SETREGS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001263 XLAT(PTRACE_SETREGS),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001264#endif
1265#ifdef PTRACE_GETFPREGS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001266 XLAT(PTRACE_GETFPREGS),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001267#endif
1268#ifdef PTRACE_SETFPREGS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001269 XLAT(PTRACE_SETFPREGS),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001270#endif
1271#ifdef PTRACE_GETFPXREGS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001272 XLAT(PTRACE_GETFPXREGS),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001273#endif
1274#ifdef PTRACE_SETFPXREGS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001275 XLAT(PTRACE_SETFPXREGS),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001276#endif
1277#ifdef PTRACE_GETVRREGS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001278 XLAT(PTRACE_GETVRREGS),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001279#endif
1280#ifdef PTRACE_SETVRREGS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001281 XLAT(PTRACE_SETVRREGS),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001282#endif
1283#ifdef PTRACE_SETOPTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001284 XLAT(PTRACE_SETOPTIONS),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001285#endif
1286#ifdef PTRACE_GETEVENTMSG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001287 XLAT(PTRACE_GETEVENTMSG),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001288#endif
1289#ifdef PTRACE_GETSIGINFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001290 XLAT(PTRACE_GETSIGINFO),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001291#endif
1292#ifdef PTRACE_SETSIGINFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001293 XLAT(PTRACE_SETSIGINFO),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001294#endif
1295#ifdef PTRACE_GETREGSET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001296 XLAT(PTRACE_GETREGSET),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001297#endif
1298#ifdef PTRACE_SETREGSET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001299 XLAT(PTRACE_SETREGSET),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001300#endif
1301#ifdef PTRACE_SET_SYSCALL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001302 XLAT(PTRACE_SET_SYSCALL),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001303#endif
1304#ifdef PTRACE_SEIZE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001305 XLAT(PTRACE_SEIZE),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001306#endif
1307#ifdef PTRACE_INTERRUPT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001308 XLAT(PTRACE_INTERRUPT),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001309#endif
1310#ifdef PTRACE_LISTEN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001311 XLAT(PTRACE_LISTEN),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001312#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001313 XLAT(PTRACE_SYSCALL),
Denys Vlasenkof535b542009-01-13 18:30:55 +00001314
Dmitry V. Levin59452732014-02-05 02:20:51 +00001315 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001316};
1317
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001318#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00001319static const struct xlat ptrace_setoptions_flags[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001320# ifdef PTRACE_O_TRACESYSGOOD
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001321 XLAT(PTRACE_O_TRACESYSGOOD),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001322# endif
1323# ifdef PTRACE_O_TRACEFORK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001324 XLAT(PTRACE_O_TRACEFORK),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001325# endif
1326# ifdef PTRACE_O_TRACEVFORK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001327 XLAT(PTRACE_O_TRACEVFORK),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001328# endif
1329# ifdef PTRACE_O_TRACECLONE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001330 XLAT(PTRACE_O_TRACECLONE),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001331# endif
1332# ifdef PTRACE_O_TRACEEXEC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001333 XLAT(PTRACE_O_TRACEEXEC),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001334# endif
1335# ifdef PTRACE_O_TRACEVFORKDONE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001336 XLAT(PTRACE_O_TRACEVFORKDONE),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001337# endif
1338# ifdef PTRACE_O_TRACEEXIT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001339 XLAT(PTRACE_O_TRACEEXIT),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001340# endif
Dmitry V. Levinf7822012013-05-17 22:22:19 +00001341# ifdef PTRACE_O_TRACESECCOMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001342 XLAT(PTRACE_O_TRACESECCOMP),
Dmitry V. Levinf7822012013-05-17 22:22:19 +00001343# endif
1344# ifdef PTRACE_O_EXITKILL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001345 XLAT(PTRACE_O_EXITKILL),
Dmitry V. Levinf7822012013-05-17 22:22:19 +00001346# endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001347 XLAT_END
Denys Vlasenkof535b542009-01-13 18:30:55 +00001348};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001349#endif /* PTRACE_SETOPTIONS */
Denys Vlasenkof535b542009-01-13 18:30:55 +00001350
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001351static const struct xlat nt_descriptor_types[] = {
1352#ifdef NT_PRSTATUS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001353 XLAT(NT_PRSTATUS),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001354#endif
1355#ifdef NT_FPREGSET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001356 XLAT(NT_FPREGSET),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001357#endif
1358#ifdef NT_PRPSINFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001359 XLAT(NT_PRPSINFO),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001360#endif
1361#ifdef NT_PRXREG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001362 XLAT(NT_PRXREG),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001363#endif
1364#ifdef NT_TASKSTRUCT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001365 XLAT(NT_TASKSTRUCT),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001366#endif
1367#ifdef NT_PLATFORM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001368 XLAT(NT_PLATFORM),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001369#endif
1370#ifdef NT_AUXV
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001371 XLAT(NT_AUXV),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001372#endif
1373#ifdef NT_GWINDOWS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001374 XLAT(NT_GWINDOWS),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001375#endif
1376#ifdef NT_ASRS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001377 XLAT(NT_ASRS),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001378#endif
1379#ifdef NT_PSTATUS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001380 XLAT(NT_PSTATUS),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001381#endif
1382#ifdef NT_PSINFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001383 XLAT(NT_PSINFO),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001384#endif
1385#ifdef NT_PRCRED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001386 XLAT(NT_PRCRED),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001387#endif
1388#ifdef NT_UTSNAME
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001389 XLAT(NT_UTSNAME),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001390#endif
1391#ifdef NT_LWPSTATUS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001392 XLAT(NT_LWPSTATUS),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001393#endif
1394#ifdef NT_LWPSINFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001395 XLAT(NT_LWPSINFO),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001396#endif
1397#ifdef NT_PRFPXREG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001398 XLAT(NT_PRFPXREG),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001399#endif
1400#ifdef NT_PRXFPREG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001401 XLAT(NT_PRXFPREG),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001402#endif
1403#ifdef NT_PPC_VMX
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001404 XLAT(NT_PPC_VMX),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001405#endif
1406#ifdef NT_PPC_SPE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001407 XLAT(NT_PPC_SPE),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001408#endif
1409#ifdef NT_PPC_VSX
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001410 XLAT(NT_PPC_VSX),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001411#endif
1412#ifdef NT_386_TLS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001413 XLAT(NT_386_TLS),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001414#endif
1415#ifdef NT_386_IOPERM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001416 XLAT(NT_386_IOPERM),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001417#endif
1418#ifdef NT_X86_XSTATE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001419 XLAT(NT_X86_XSTATE),
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001420#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001421 XLAT_END
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00001422};
1423
Denys Vlasenko513e9c22012-03-21 14:39:22 +01001424#define uoff(member) offsetof(struct user, member)
1425
Roland McGrathd9f816f2004-09-04 03:39:20 +00001426const struct xlat struct_user_offsets[] = {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001427#if defined(S390) || defined(S390X)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001428 { PT_PSWMASK, "psw_mask" },
1429 { PT_PSWADDR, "psw_addr" },
1430 { PT_GPR0, "gpr0" },
1431 { PT_GPR1, "gpr1" },
1432 { PT_GPR2, "gpr2" },
1433 { PT_GPR3, "gpr3" },
1434 { PT_GPR4, "gpr4" },
1435 { PT_GPR5, "gpr5" },
1436 { PT_GPR6, "gpr6" },
1437 { PT_GPR7, "gpr7" },
1438 { PT_GPR8, "gpr8" },
1439 { PT_GPR9, "gpr9" },
1440 { PT_GPR10, "gpr10" },
1441 { PT_GPR11, "gpr11" },
1442 { PT_GPR12, "gpr12" },
1443 { PT_GPR13, "gpr13" },
1444 { PT_GPR14, "gpr14" },
1445 { PT_GPR15, "gpr15" },
1446 { PT_ACR0, "acr0" },
1447 { PT_ACR1, "acr1" },
1448 { PT_ACR2, "acr2" },
1449 { PT_ACR3, "acr3" },
1450 { PT_ACR4, "acr4" },
1451 { PT_ACR5, "acr5" },
1452 { PT_ACR6, "acr6" },
1453 { PT_ACR7, "acr7" },
1454 { PT_ACR8, "acr8" },
1455 { PT_ACR9, "acr9" },
1456 { PT_ACR10, "acr10" },
1457 { PT_ACR11, "acr11" },
1458 { PT_ACR12, "acr12" },
1459 { PT_ACR13, "acr13" },
1460 { PT_ACR14, "acr14" },
1461 { PT_ACR15, "acr15" },
1462 { PT_ORIGGPR2, "orig_gpr2" },
1463 { PT_FPC, "fpc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001464#if defined(S390)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001465 { PT_FPR0_HI, "fpr0.hi" },
1466 { PT_FPR0_LO, "fpr0.lo" },
1467 { PT_FPR1_HI, "fpr1.hi" },
1468 { PT_FPR1_LO, "fpr1.lo" },
1469 { PT_FPR2_HI, "fpr2.hi" },
1470 { PT_FPR2_LO, "fpr2.lo" },
1471 { PT_FPR3_HI, "fpr3.hi" },
1472 { PT_FPR3_LO, "fpr3.lo" },
1473 { PT_FPR4_HI, "fpr4.hi" },
1474 { PT_FPR4_LO, "fpr4.lo" },
1475 { PT_FPR5_HI, "fpr5.hi" },
1476 { PT_FPR5_LO, "fpr5.lo" },
1477 { PT_FPR6_HI, "fpr6.hi" },
1478 { PT_FPR6_LO, "fpr6.lo" },
1479 { PT_FPR7_HI, "fpr7.hi" },
1480 { PT_FPR7_LO, "fpr7.lo" },
1481 { PT_FPR8_HI, "fpr8.hi" },
1482 { PT_FPR8_LO, "fpr8.lo" },
1483 { PT_FPR9_HI, "fpr9.hi" },
1484 { PT_FPR9_LO, "fpr9.lo" },
1485 { PT_FPR10_HI, "fpr10.hi" },
1486 { PT_FPR10_LO, "fpr10.lo" },
1487 { PT_FPR11_HI, "fpr11.hi" },
1488 { PT_FPR11_LO, "fpr11.lo" },
1489 { PT_FPR12_HI, "fpr12.hi" },
1490 { PT_FPR12_LO, "fpr12.lo" },
1491 { PT_FPR13_HI, "fpr13.hi" },
1492 { PT_FPR13_LO, "fpr13.lo" },
1493 { PT_FPR14_HI, "fpr14.hi" },
1494 { PT_FPR14_LO, "fpr14.lo" },
1495 { PT_FPR15_HI, "fpr15.hi" },
1496 { PT_FPR15_LO, "fpr15.lo" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001497#endif
1498#if defined(S390X)
Michal Ludvig10a88d02002-10-07 14:31:00 +00001499 { PT_FPR0, "fpr0" },
1500 { PT_FPR1, "fpr1" },
1501 { PT_FPR2, "fpr2" },
1502 { PT_FPR3, "fpr3" },
1503 { PT_FPR4, "fpr4" },
1504 { PT_FPR5, "fpr5" },
1505 { PT_FPR6, "fpr6" },
1506 { PT_FPR7, "fpr7" },
1507 { PT_FPR8, "fpr8" },
1508 { PT_FPR9, "fpr9" },
1509 { PT_FPR10, "fpr10" },
1510 { PT_FPR11, "fpr11" },
1511 { PT_FPR12, "fpr12" },
1512 { PT_FPR13, "fpr13" },
1513 { PT_FPR14, "fpr14" },
1514 { PT_FPR15, "fpr15" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001515#endif
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001516 { PT_CR_9, "cr9" },
1517 { PT_CR_10, "cr10" },
1518 { PT_CR_11, "cr11" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001519 { PT_IEEE_IP, "ieee_exception_ip" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001520#elif defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001521 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001522#elif defined(HPPA)
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001523 /* XXX No support for these offsets yet. */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001524#elif defined(POWERPC)
1525# ifndef PT_ORIG_R3
1526# define PT_ORIG_R3 34
1527# endif
1528# define REGSIZE (sizeof(unsigned long))
Roland McGratheb285352003-01-14 09:59:00 +00001529 { REGSIZE*PT_R0, "r0" },
1530 { REGSIZE*PT_R1, "r1" },
1531 { REGSIZE*PT_R2, "r2" },
1532 { REGSIZE*PT_R3, "r3" },
1533 { REGSIZE*PT_R4, "r4" },
1534 { REGSIZE*PT_R5, "r5" },
1535 { REGSIZE*PT_R6, "r6" },
1536 { REGSIZE*PT_R7, "r7" },
1537 { REGSIZE*PT_R8, "r8" },
1538 { REGSIZE*PT_R9, "r9" },
1539 { REGSIZE*PT_R10, "r10" },
1540 { REGSIZE*PT_R11, "r11" },
1541 { REGSIZE*PT_R12, "r12" },
1542 { REGSIZE*PT_R13, "r13" },
1543 { REGSIZE*PT_R14, "r14" },
1544 { REGSIZE*PT_R15, "r15" },
1545 { REGSIZE*PT_R16, "r16" },
1546 { REGSIZE*PT_R17, "r17" },
1547 { REGSIZE*PT_R18, "r18" },
1548 { REGSIZE*PT_R19, "r19" },
1549 { REGSIZE*PT_R20, "r20" },
1550 { REGSIZE*PT_R21, "r21" },
1551 { REGSIZE*PT_R22, "r22" },
1552 { REGSIZE*PT_R23, "r23" },
1553 { REGSIZE*PT_R24, "r24" },
1554 { REGSIZE*PT_R25, "r25" },
1555 { REGSIZE*PT_R26, "r26" },
1556 { REGSIZE*PT_R27, "r27" },
1557 { REGSIZE*PT_R28, "r28" },
1558 { REGSIZE*PT_R29, "r29" },
1559 { REGSIZE*PT_R30, "r30" },
1560 { REGSIZE*PT_R31, "r31" },
1561 { REGSIZE*PT_NIP, "NIP" },
1562 { REGSIZE*PT_MSR, "MSR" },
1563 { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
1564 { REGSIZE*PT_CTR, "CTR" },
1565 { REGSIZE*PT_LNK, "LNK" },
1566 { REGSIZE*PT_XER, "XER" },
1567 { REGSIZE*PT_CCR, "CCR" },
1568 { REGSIZE*PT_FPR0, "FPR0" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001569# undef REGSIZE
1570#elif defined(ALPHA)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001571 { 0, "r0" },
1572 { 1, "r1" },
1573 { 2, "r2" },
1574 { 3, "r3" },
1575 { 4, "r4" },
1576 { 5, "r5" },
1577 { 6, "r6" },
1578 { 7, "r7" },
1579 { 8, "r8" },
1580 { 9, "r9" },
1581 { 10, "r10" },
1582 { 11, "r11" },
1583 { 12, "r12" },
1584 { 13, "r13" },
1585 { 14, "r14" },
1586 { 15, "r15" },
1587 { 16, "r16" },
1588 { 17, "r17" },
1589 { 18, "r18" },
1590 { 19, "r19" },
1591 { 20, "r20" },
1592 { 21, "r21" },
1593 { 22, "r22" },
1594 { 23, "r23" },
1595 { 24, "r24" },
1596 { 25, "r25" },
1597 { 26, "r26" },
1598 { 27, "r27" },
1599 { 28, "r28" },
1600 { 29, "gp" },
1601 { 30, "fp" },
1602 { 31, "zero" },
1603 { 32, "fp0" },
1604 { 33, "fp" },
1605 { 34, "fp2" },
1606 { 35, "fp3" },
1607 { 36, "fp4" },
1608 { 37, "fp5" },
1609 { 38, "fp6" },
1610 { 39, "fp7" },
1611 { 40, "fp8" },
1612 { 41, "fp9" },
1613 { 42, "fp10" },
1614 { 43, "fp11" },
1615 { 44, "fp12" },
1616 { 45, "fp13" },
1617 { 46, "fp14" },
1618 { 47, "fp15" },
1619 { 48, "fp16" },
1620 { 49, "fp17" },
1621 { 50, "fp18" },
1622 { 51, "fp19" },
1623 { 52, "fp20" },
1624 { 53, "fp21" },
1625 { 54, "fp22" },
1626 { 55, "fp23" },
1627 { 56, "fp24" },
1628 { 57, "fp25" },
1629 { 58, "fp26" },
1630 { 59, "fp27" },
1631 { 60, "fp28" },
1632 { 61, "fp29" },
1633 { 62, "fp30" },
1634 { 63, "fp31" },
1635 { 64, "pc" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001636#elif defined(IA64)
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001637 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1638 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1639 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1640 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1641 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1642 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1643 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1644 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1645 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1646 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1647 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1648 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1649 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1650 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1651 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1652 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1653 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1654 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1655 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1656 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1657 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1658 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1659 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1660 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1661 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1662 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1663 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1664 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1665 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1666 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1667 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1668 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1669 /* switch stack: */
1670 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1671 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1672 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1673 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1674 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1675 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1676 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1677 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1678 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1679 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001680 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1681 { PT_B4, "b4" }, { PT_B5, "b5" },
Roland McGrathca4e10c2004-01-13 10:13:20 +00001682 { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001683 /* pt_regs */
Roland McGrathca4e10c2004-01-13 10:13:20 +00001684 { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
1685 { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001686 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1687 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1688 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1689 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1690 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1691 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1692 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1693 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1694 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1695 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1696 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1697 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1698 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1699 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1700 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001701# ifdef PT_AR_CSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001702 { PT_AR_CSD, "ar.csd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001703# endif
1704# ifdef PT_AR_SSD
Roland McGrathfb1bc072004-03-01 21:29:24 +00001705 { PT_AR_SSD, "ar.ssd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001706# endif
Roland McGrathca4e10c2004-01-13 10:13:20 +00001707 { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001708#elif defined(I386)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001709 XLAT(4*EBX),
1710 XLAT(4*ECX),
1711 XLAT(4*EDX),
1712 XLAT(4*ESI),
1713 XLAT(4*EDI),
1714 XLAT(4*EBP),
1715 XLAT(4*EAX),
1716 XLAT(4*DS),
1717 XLAT(4*ES),
1718 XLAT(4*FS),
1719 XLAT(4*GS),
1720 XLAT(4*ORIG_EAX),
1721 XLAT(4*EIP),
1722 XLAT(4*CS),
1723 XLAT(4*EFL),
1724 XLAT(4*UESP),
1725 XLAT(4*SS),
H.J. Lu35be5812012-04-16 13:00:01 +02001726#elif defined(X86_64) || defined(X32)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001727 XLAT(8*R15),
1728 XLAT(8*R14),
1729 XLAT(8*R13),
1730 XLAT(8*R12),
1731 XLAT(8*RBP),
1732 XLAT(8*RBX),
1733 XLAT(8*R11),
1734 XLAT(8*R10),
1735 XLAT(8*R9),
1736 XLAT(8*R8),
1737 XLAT(8*RAX),
1738 XLAT(8*RCX),
1739 XLAT(8*RDX),
1740 XLAT(8*RSI),
1741 XLAT(8*RDI),
1742 XLAT(8*ORIG_RAX),
1743 XLAT(8*RIP),
1744 XLAT(8*CS),
Michal Ludvig0e035502002-09-23 15:41:01 +00001745 { 8*EFLAGS, "8*EFL" },
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001746 XLAT(8*RSP),
1747 XLAT(8*SS),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001748#elif defined(M68K)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001749 XLAT(4*PT_D1),
1750 XLAT(4*PT_D2),
1751 XLAT(4*PT_D3),
1752 XLAT(4*PT_D4),
1753 XLAT(4*PT_D5),
1754 XLAT(4*PT_D6),
1755 XLAT(4*PT_D7),
1756 XLAT(4*PT_A0),
1757 XLAT(4*PT_A1),
1758 XLAT(4*PT_A2),
1759 XLAT(4*PT_A3),
1760 XLAT(4*PT_A4),
1761 XLAT(4*PT_A5),
1762 XLAT(4*PT_A6),
1763 XLAT(4*PT_D0),
1764 XLAT(4*PT_USP),
1765 XLAT(4*PT_ORIG_D0),
1766 XLAT(4*PT_SR),
1767 XLAT(4*PT_PC),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001768#elif defined(SH)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001769 XLAT(4*REG_REG0),
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001770 { 4*(REG_REG0+1), "4*REG_REG1" },
1771 { 4*(REG_REG0+2), "4*REG_REG2" },
1772 { 4*(REG_REG0+3), "4*REG_REG3" },
1773 { 4*(REG_REG0+4), "4*REG_REG4" },
1774 { 4*(REG_REG0+5), "4*REG_REG5" },
1775 { 4*(REG_REG0+6), "4*REG_REG6" },
1776 { 4*(REG_REG0+7), "4*REG_REG7" },
1777 { 4*(REG_REG0+8), "4*REG_REG8" },
1778 { 4*(REG_REG0+9), "4*REG_REG9" },
1779 { 4*(REG_REG0+10), "4*REG_REG10" },
1780 { 4*(REG_REG0+11), "4*REG_REG11" },
1781 { 4*(REG_REG0+12), "4*REG_REG12" },
1782 { 4*(REG_REG0+13), "4*REG_REG13" },
1783 { 4*(REG_REG0+14), "4*REG_REG14" },
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001784 XLAT(4*REG_REG15),
1785 XLAT(4*REG_PC),
1786 XLAT(4*REG_PR),
1787 XLAT(4*REG_SR),
1788 XLAT(4*REG_GBR),
1789 XLAT(4*REG_MACH),
1790 XLAT(4*REG_MACL),
1791 XLAT(4*REG_SYSCALL),
1792 XLAT(4*REG_FPUL),
1793 XLAT(4*REG_FPREG0),
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001794 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1795 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1796 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1797 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1798 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1799 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1800 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1801 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1802 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1803 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1804 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1805 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1806 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1807 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001808 XLAT(4*REG_FPREG15),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001809# ifdef REG_XDREG0
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001810 XLAT(4*REG_XDREG0),
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001811 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1812 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1813 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1814 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1815 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1816 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001817 XLAT(4*REG_XDREG14),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001818# endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001819 XLAT(4*REG_FPSCR),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001820#elif defined(SH64)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001821 { 0, "PC(L)" },
1822 { 4, "PC(U)" },
1823 { 8, "SR(L)" },
1824 { 12, "SR(U)" },
1825 { 16, "syscall no.(L)" },
1826 { 20, "syscall_no.(U)" },
1827 { 24, "R0(L)" },
1828 { 28, "R0(U)" },
1829 { 32, "R1(L)" },
1830 { 36, "R1(U)" },
1831 { 40, "R2(L)" },
1832 { 44, "R2(U)" },
1833 { 48, "R3(L)" },
1834 { 52, "R3(U)" },
1835 { 56, "R4(L)" },
1836 { 60, "R4(U)" },
1837 { 64, "R5(L)" },
1838 { 68, "R5(U)" },
1839 { 72, "R6(L)" },
1840 { 76, "R6(U)" },
1841 { 80, "R7(L)" },
1842 { 84, "R7(U)" },
1843 { 88, "R8(L)" },
1844 { 92, "R8(U)" },
1845 { 96, "R9(L)" },
1846 { 100, "R9(U)" },
1847 { 104, "R10(L)" },
1848 { 108, "R10(U)" },
1849 { 112, "R11(L)" },
1850 { 116, "R11(U)" },
1851 { 120, "R12(L)" },
1852 { 124, "R12(U)" },
1853 { 128, "R13(L)" },
1854 { 132, "R13(U)" },
1855 { 136, "R14(L)" },
1856 { 140, "R14(U)" },
1857 { 144, "R15(L)" },
1858 { 148, "R15(U)" },
1859 { 152, "R16(L)" },
1860 { 156, "R16(U)" },
1861 { 160, "R17(L)" },
1862 { 164, "R17(U)" },
1863 { 168, "R18(L)" },
1864 { 172, "R18(U)" },
1865 { 176, "R19(L)" },
1866 { 180, "R19(U)" },
1867 { 184, "R20(L)" },
1868 { 188, "R20(U)" },
1869 { 192, "R21(L)" },
1870 { 196, "R21(U)" },
1871 { 200, "R22(L)" },
1872 { 204, "R22(U)" },
1873 { 208, "R23(L)" },
1874 { 212, "R23(U)" },
1875 { 216, "R24(L)" },
1876 { 220, "R24(U)" },
1877 { 224, "R25(L)" },
1878 { 228, "R25(U)" },
1879 { 232, "R26(L)" },
1880 { 236, "R26(U)" },
1881 { 240, "R27(L)" },
1882 { 244, "R27(U)" },
1883 { 248, "R28(L)" },
1884 { 252, "R28(U)" },
1885 { 256, "R29(L)" },
1886 { 260, "R29(U)" },
1887 { 264, "R30(L)" },
1888 { 268, "R30(U)" },
1889 { 272, "R31(L)" },
1890 { 276, "R31(U)" },
1891 { 280, "R32(L)" },
1892 { 284, "R32(U)" },
1893 { 288, "R33(L)" },
1894 { 292, "R33(U)" },
1895 { 296, "R34(L)" },
1896 { 300, "R34(U)" },
1897 { 304, "R35(L)" },
1898 { 308, "R35(U)" },
1899 { 312, "R36(L)" },
1900 { 316, "R36(U)" },
1901 { 320, "R37(L)" },
1902 { 324, "R37(U)" },
1903 { 328, "R38(L)" },
1904 { 332, "R38(U)" },
1905 { 336, "R39(L)" },
1906 { 340, "R39(U)" },
1907 { 344, "R40(L)" },
1908 { 348, "R40(U)" },
1909 { 352, "R41(L)" },
1910 { 356, "R41(U)" },
1911 { 360, "R42(L)" },
1912 { 364, "R42(U)" },
1913 { 368, "R43(L)" },
1914 { 372, "R43(U)" },
1915 { 376, "R44(L)" },
1916 { 380, "R44(U)" },
1917 { 384, "R45(L)" },
1918 { 388, "R45(U)" },
1919 { 392, "R46(L)" },
1920 { 396, "R46(U)" },
1921 { 400, "R47(L)" },
1922 { 404, "R47(U)" },
1923 { 408, "R48(L)" },
1924 { 412, "R48(U)" },
1925 { 416, "R49(L)" },
1926 { 420, "R49(U)" },
1927 { 424, "R50(L)" },
1928 { 428, "R50(U)" },
1929 { 432, "R51(L)" },
1930 { 436, "R51(U)" },
1931 { 440, "R52(L)" },
1932 { 444, "R52(U)" },
1933 { 448, "R53(L)" },
1934 { 452, "R53(U)" },
1935 { 456, "R54(L)" },
1936 { 460, "R54(U)" },
1937 { 464, "R55(L)" },
1938 { 468, "R55(U)" },
1939 { 472, "R56(L)" },
1940 { 476, "R56(U)" },
1941 { 480, "R57(L)" },
1942 { 484, "R57(U)" },
1943 { 488, "R58(L)" },
1944 { 492, "R58(U)" },
1945 { 496, "R59(L)" },
1946 { 500, "R59(U)" },
1947 { 504, "R60(L)" },
1948 { 508, "R60(U)" },
1949 { 512, "R61(L)" },
1950 { 516, "R61(U)" },
1951 { 520, "R62(L)" },
1952 { 524, "R62(U)" },
1953 { 528, "TR0(L)" },
1954 { 532, "TR0(U)" },
1955 { 536, "TR1(L)" },
1956 { 540, "TR1(U)" },
1957 { 544, "TR2(L)" },
1958 { 548, "TR2(U)" },
1959 { 552, "TR3(L)" },
1960 { 556, "TR3(U)" },
1961 { 560, "TR4(L)" },
1962 { 564, "TR4(U)" },
1963 { 568, "TR5(L)" },
1964 { 572, "TR5(U)" },
1965 { 576, "TR6(L)" },
1966 { 580, "TR6(U)" },
1967 { 584, "TR7(L)" },
1968 { 588, "TR7(U)" },
Denys Vlasenkoadedb512008-12-30 18:47:55 +00001969 /* This entry is in case pt_regs contains dregs (depends on
1970 the kernel build options). */
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001971 { uoff(regs), "offsetof(struct user, regs)" },
1972 { uoff(fpu), "offsetof(struct user, fpu)" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001973#elif defined(ARM)
Roland McGrath0f87c492003-06-03 23:29:04 +00001974 { uoff(regs.ARM_r0), "r0" },
1975 { uoff(regs.ARM_r1), "r1" },
1976 { uoff(regs.ARM_r2), "r2" },
1977 { uoff(regs.ARM_r3), "r3" },
1978 { uoff(regs.ARM_r4), "r4" },
1979 { uoff(regs.ARM_r5), "r5" },
1980 { uoff(regs.ARM_r6), "r6" },
1981 { uoff(regs.ARM_r7), "r7" },
1982 { uoff(regs.ARM_r8), "r8" },
1983 { uoff(regs.ARM_r9), "r9" },
1984 { uoff(regs.ARM_r10), "r10" },
1985 { uoff(regs.ARM_fp), "fp" },
1986 { uoff(regs.ARM_ip), "ip" },
1987 { uoff(regs.ARM_sp), "sp" },
1988 { uoff(regs.ARM_lr), "lr" },
1989 { uoff(regs.ARM_pc), "pc" },
1990 { uoff(regs.ARM_cpsr), "cpsr" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01001991#elif defined(AVR32)
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +00001992 { uoff(regs.sr), "sr" },
1993 { uoff(regs.pc), "pc" },
1994 { uoff(regs.lr), "lr" },
1995 { uoff(regs.sp), "sp" },
1996 { uoff(regs.r12), "r12" },
1997 { uoff(regs.r11), "r11" },
1998 { uoff(regs.r10), "r10" },
1999 { uoff(regs.r9), "r9" },
2000 { uoff(regs.r8), "r8" },
2001 { uoff(regs.r7), "r7" },
2002 { uoff(regs.r6), "r6" },
2003 { uoff(regs.r5), "r5" },
2004 { uoff(regs.r4), "r4" },
2005 { uoff(regs.r3), "r3" },
2006 { uoff(regs.r2), "r2" },
2007 { uoff(regs.r1), "r1" },
2008 { uoff(regs.r0), "r0" },
2009 { uoff(regs.r12_orig), "orig_r12" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002010#elif defined(MIPS)
Roland McGrath542c2c62008-05-20 01:11:56 +00002011 { 0, "r0" },
2012 { 1, "r1" },
2013 { 2, "r2" },
2014 { 3, "r3" },
2015 { 4, "r4" },
2016 { 5, "r5" },
2017 { 6, "r6" },
2018 { 7, "r7" },
2019 { 8, "r8" },
2020 { 9, "r9" },
2021 { 10, "r10" },
2022 { 11, "r11" },
2023 { 12, "r12" },
2024 { 13, "r13" },
2025 { 14, "r14" },
2026 { 15, "r15" },
2027 { 16, "r16" },
2028 { 17, "r17" },
2029 { 18, "r18" },
2030 { 19, "r19" },
2031 { 20, "r20" },
2032 { 21, "r21" },
2033 { 22, "r22" },
2034 { 23, "r23" },
2035 { 24, "r24" },
2036 { 25, "r25" },
2037 { 26, "r26" },
2038 { 27, "r27" },
2039 { 28, "r28" },
2040 { 29, "r29" },
2041 { 30, "r30" },
2042 { 31, "r31" },
2043 { 32, "f0" },
2044 { 33, "f1" },
2045 { 34, "f2" },
2046 { 35, "f3" },
2047 { 36, "f4" },
2048 { 37, "f5" },
2049 { 38, "f6" },
2050 { 39, "f7" },
2051 { 40, "f8" },
2052 { 41, "f9" },
2053 { 42, "f10" },
2054 { 43, "f11" },
2055 { 44, "f12" },
2056 { 45, "f13" },
2057 { 46, "f14" },
2058 { 47, "f15" },
2059 { 48, "f16" },
2060 { 49, "f17" },
2061 { 50, "f18" },
2062 { 51, "f19" },
2063 { 52, "f20" },
2064 { 53, "f21" },
2065 { 54, "f22" },
2066 { 55, "f23" },
2067 { 56, "f24" },
2068 { 57, "f25" },
2069 { 58, "f26" },
2070 { 59, "f27" },
2071 { 60, "f28" },
2072 { 61, "f29" },
2073 { 62, "f30" },
2074 { 63, "f31" },
2075 { 64, "pc" },
2076 { 65, "cause" },
2077 { 66, "badvaddr" },
2078 { 67, "mmhi" },
2079 { 68, "mmlo" },
2080 { 69, "fpcsr" },
2081 { 70, "fpeir" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002082#elif defined(TILE)
Chris Metcalfc8c66982009-12-28 10:00:15 -05002083 { PTREGS_OFFSET_REG(0), "r0" },
2084 { PTREGS_OFFSET_REG(1), "r1" },
2085 { PTREGS_OFFSET_REG(2), "r2" },
2086 { PTREGS_OFFSET_REG(3), "r3" },
2087 { PTREGS_OFFSET_REG(4), "r4" },
2088 { PTREGS_OFFSET_REG(5), "r5" },
2089 { PTREGS_OFFSET_REG(6), "r6" },
2090 { PTREGS_OFFSET_REG(7), "r7" },
2091 { PTREGS_OFFSET_REG(8), "r8" },
2092 { PTREGS_OFFSET_REG(9), "r9" },
2093 { PTREGS_OFFSET_REG(10), "r10" },
2094 { PTREGS_OFFSET_REG(11), "r11" },
2095 { PTREGS_OFFSET_REG(12), "r12" },
2096 { PTREGS_OFFSET_REG(13), "r13" },
2097 { PTREGS_OFFSET_REG(14), "r14" },
2098 { PTREGS_OFFSET_REG(15), "r15" },
2099 { PTREGS_OFFSET_REG(16), "r16" },
2100 { PTREGS_OFFSET_REG(17), "r17" },
2101 { PTREGS_OFFSET_REG(18), "r18" },
2102 { PTREGS_OFFSET_REG(19), "r19" },
2103 { PTREGS_OFFSET_REG(20), "r20" },
2104 { PTREGS_OFFSET_REG(21), "r21" },
2105 { PTREGS_OFFSET_REG(22), "r22" },
2106 { PTREGS_OFFSET_REG(23), "r23" },
2107 { PTREGS_OFFSET_REG(24), "r24" },
2108 { PTREGS_OFFSET_REG(25), "r25" },
2109 { PTREGS_OFFSET_REG(26), "r26" },
2110 { PTREGS_OFFSET_REG(27), "r27" },
2111 { PTREGS_OFFSET_REG(28), "r28" },
2112 { PTREGS_OFFSET_REG(29), "r29" },
2113 { PTREGS_OFFSET_REG(30), "r30" },
2114 { PTREGS_OFFSET_REG(31), "r31" },
2115 { PTREGS_OFFSET_REG(32), "r32" },
2116 { PTREGS_OFFSET_REG(33), "r33" },
2117 { PTREGS_OFFSET_REG(34), "r34" },
2118 { PTREGS_OFFSET_REG(35), "r35" },
2119 { PTREGS_OFFSET_REG(36), "r36" },
2120 { PTREGS_OFFSET_REG(37), "r37" },
2121 { PTREGS_OFFSET_REG(38), "r38" },
2122 { PTREGS_OFFSET_REG(39), "r39" },
2123 { PTREGS_OFFSET_REG(40), "r40" },
2124 { PTREGS_OFFSET_REG(41), "r41" },
2125 { PTREGS_OFFSET_REG(42), "r42" },
2126 { PTREGS_OFFSET_REG(43), "r43" },
2127 { PTREGS_OFFSET_REG(44), "r44" },
2128 { PTREGS_OFFSET_REG(45), "r45" },
2129 { PTREGS_OFFSET_REG(46), "r46" },
2130 { PTREGS_OFFSET_REG(47), "r47" },
2131 { PTREGS_OFFSET_REG(48), "r48" },
2132 { PTREGS_OFFSET_REG(49), "r49" },
2133 { PTREGS_OFFSET_REG(50), "r50" },
2134 { PTREGS_OFFSET_REG(51), "r51" },
2135 { PTREGS_OFFSET_REG(52), "r52" },
2136 { PTREGS_OFFSET_TP, "tp" },
2137 { PTREGS_OFFSET_SP, "sp" },
2138 { PTREGS_OFFSET_LR, "lr" },
2139 { PTREGS_OFFSET_PC, "pc" },
2140 { PTREGS_OFFSET_EX1, "ex1" },
2141 { PTREGS_OFFSET_FAULTNUM, "faultnum" },
2142 { PTREGS_OFFSET_ORIG_R0, "orig_r0" },
2143 { PTREGS_OFFSET_FLAGS, "flags" },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002144#endif
2145#ifdef CRISV10
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00002146 XLAT(4*PT_FRAMETYPE),
2147 XLAT(4*PT_ORIG_R10),
2148 XLAT(4*PT_R13),
2149 XLAT(4*PT_R12),
2150 XLAT(4*PT_R11),
2151 XLAT(4*PT_R10),
2152 XLAT(4*PT_R9),
2153 XLAT(4*PT_R8),
2154 XLAT(4*PT_R7),
2155 XLAT(4*PT_R6),
2156 XLAT(4*PT_R5),
2157 XLAT(4*PT_R4),
2158 XLAT(4*PT_R3),
2159 XLAT(4*PT_R2),
2160 XLAT(4*PT_R1),
2161 XLAT(4*PT_R0),
2162 XLAT(4*PT_MOF),
2163 XLAT(4*PT_DCCR),
2164 XLAT(4*PT_SRP),
2165 XLAT(4*PT_IRP),
2166 XLAT(4*PT_CSRINSTR),
2167 XLAT(4*PT_CSRADDR),
2168 XLAT(4*PT_CSRDATA),
2169 XLAT(4*PT_USP),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002170#endif
2171#ifdef CRISV32
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00002172 XLAT(4*PT_ORIG_R10),
2173 XLAT(4*PT_R0),
2174 XLAT(4*PT_R1),
2175 XLAT(4*PT_R2),
2176 XLAT(4*PT_R3),
2177 XLAT(4*PT_R4),
2178 XLAT(4*PT_R5),
2179 XLAT(4*PT_R6),
2180 XLAT(4*PT_R7),
2181 XLAT(4*PT_R8),
2182 XLAT(4*PT_R9),
2183 XLAT(4*PT_R10),
2184 XLAT(4*PT_R11),
2185 XLAT(4*PT_R12),
2186 XLAT(4*PT_R13),
2187 XLAT(4*PT_ACR),
2188 XLAT(4*PT_SRS),
2189 XLAT(4*PT_MOF),
2190 XLAT(4*PT_SPC),
2191 XLAT(4*PT_CCS),
2192 XLAT(4*PT_SRP),
2193 XLAT(4*PT_ERP),
2194 XLAT(4*PT_EXS),
2195 XLAT(4*PT_EDA),
2196 XLAT(4*PT_USP),
2197 XLAT(4*PT_PPC),
2198 XLAT(4*PT_BP_CTRL),
2199 XLAT(4*PT_BP+4),
2200 XLAT(4*PT_BP+8),
2201 XLAT(4*PT_BP+12),
2202 XLAT(4*PT_BP+16),
2203 XLAT(4*PT_BP+20),
2204 XLAT(4*PT_BP+24),
2205 XLAT(4*PT_BP+28),
2206 XLAT(4*PT_BP+32),
2207 XLAT(4*PT_BP+36),
2208 XLAT(4*PT_BP+40),
2209 XLAT(4*PT_BP+44),
2210 XLAT(4*PT_BP+48),
2211 XLAT(4*PT_BP+52),
2212 XLAT(4*PT_BP+56),
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002213#endif
2214#ifdef MICROBLAZE
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002215 { PT_GPR(0), "r0" },
2216 { PT_GPR(1), "r1" },
2217 { PT_GPR(2), "r2" },
2218 { PT_GPR(3), "r3" },
2219 { PT_GPR(4), "r4" },
2220 { PT_GPR(5), "r5" },
2221 { PT_GPR(6), "r6" },
2222 { PT_GPR(7), "r7" },
2223 { PT_GPR(8), "r8" },
2224 { PT_GPR(9), "r9" },
2225 { PT_GPR(10), "r10" },
2226 { PT_GPR(11), "r11" },
2227 { PT_GPR(12), "r12" },
2228 { PT_GPR(13), "r13" },
2229 { PT_GPR(14), "r14" },
2230 { PT_GPR(15), "r15" },
2231 { PT_GPR(16), "r16" },
2232 { PT_GPR(17), "r17" },
2233 { PT_GPR(18), "r18" },
2234 { PT_GPR(19), "r19" },
2235 { PT_GPR(20), "r20" },
2236 { PT_GPR(21), "r21" },
2237 { PT_GPR(22), "r22" },
2238 { PT_GPR(23), "r23" },
2239 { PT_GPR(24), "r24" },
2240 { PT_GPR(25), "r25" },
2241 { PT_GPR(26), "r26" },
2242 { PT_GPR(27), "r27" },
2243 { PT_GPR(28), "r28" },
2244 { PT_GPR(29), "r29" },
2245 { PT_GPR(30), "r30" },
2246 { PT_GPR(31), "r31" },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002247 { PT_PC, "rpc", },
2248 { PT_MSR, "rmsr", },
Edgar E. Iglesias939caba2010-07-06 14:21:07 +02002249 { PT_EAR, "rear", },
2250 { PT_ESR, "resr", },
2251 { PT_FSR, "rfsr", },
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002252 { PT_KERNEL_MODE, "kernel_mode", },
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002253#endif
Christian Svensson492f81f2013-02-14 13:26:27 +01002254#ifdef OR1K
2255 { 4*0, "r0" },
2256 { 4*1, "r1" },
2257 { 4*2, "r2" },
2258 { 4*3, "r3" },
2259 { 4*4, "r4" },
2260 { 4*5, "r5" },
2261 { 4*6, "r6" },
2262 { 4*7, "r7" },
2263 { 4*8, "r8" },
2264 { 4*9, "r9" },
2265 { 4*10, "r10" },
2266 { 4*11, "r11" },
2267 { 4*12, "r12" },
2268 { 4*13, "r13" },
2269 { 4*14, "r14" },
2270 { 4*15, "r15" },
2271 { 4*16, "r16" },
2272 { 4*17, "r17" },
2273 { 4*18, "r18" },
2274 { 4*19, "r19" },
2275 { 4*20, "r20" },
2276 { 4*21, "r21" },
2277 { 4*22, "r22" },
2278 { 4*23, "r23" },
2279 { 4*24, "r24" },
2280 { 4*25, "r25" },
2281 { 4*26, "r26" },
2282 { 4*27, "r27" },
2283 { 4*28, "r28" },
2284 { 4*29, "r29" },
2285 { 4*30, "r30" },
2286 { 4*31, "r31" },
2287 { 4*32, "pc" },
2288 { 4*33, "sr" },
2289#endif
Chris Zankel8f636ed2013-03-25 10:22:07 -07002290#ifdef XTENSA
2291 { SYSCALL_NR, "syscall_nr" },
2292 { REG_AR_BASE, "ar0" },
2293 { REG_AR_BASE+1, "ar1" },
2294 { REG_AR_BASE+2, "ar2" },
2295 { REG_AR_BASE+3, "ar3" },
2296 { REG_AR_BASE+4, "ar4" },
2297 { REG_AR_BASE+5, "ar5" },
2298 { REG_AR_BASE+6, "ar6" },
2299 { REG_AR_BASE+7, "ar7" },
2300 { REG_AR_BASE+8, "ar8" },
2301 { REG_AR_BASE+9, "ar9" },
2302 { REG_AR_BASE+10, "ar10" },
2303 { REG_AR_BASE+11, "ar11" },
2304 { REG_AR_BASE+12, "ar12" },
2305 { REG_AR_BASE+13, "ar13" },
2306 { REG_AR_BASE+14, "ar14" },
2307 { REG_AR_BASE+15, "ar15" },
2308 { REG_AR_BASE+16, "ar16" },
2309 { REG_AR_BASE+17, "ar17" },
2310 { REG_AR_BASE+18, "ar18" },
2311 { REG_AR_BASE+19, "ar19" },
2312 { REG_AR_BASE+20, "ar20" },
2313 { REG_AR_BASE+21, "ar21" },
2314 { REG_AR_BASE+22, "ar22" },
2315 { REG_AR_BASE+23, "ar23" },
2316 { REG_AR_BASE+24, "ar24" },
2317 { REG_AR_BASE+25, "ar25" },
2318 { REG_AR_BASE+26, "ar26" },
2319 { REG_AR_BASE+27, "ar27" },
2320 { REG_AR_BASE+28, "ar28" },
2321 { REG_AR_BASE+29, "ar29" },
2322 { REG_AR_BASE+30, "ar30" },
2323 { REG_AR_BASE+31, "ar31" },
2324 { REG_AR_BASE+32, "ar32" },
2325 { REG_AR_BASE+33, "ar33" },
2326 { REG_AR_BASE+34, "ar34" },
2327 { REG_AR_BASE+35, "ar35" },
2328 { REG_AR_BASE+36, "ar36" },
2329 { REG_AR_BASE+37, "ar37" },
2330 { REG_AR_BASE+38, "ar38" },
2331 { REG_AR_BASE+39, "ar39" },
2332 { REG_AR_BASE+40, "ar40" },
2333 { REG_AR_BASE+41, "ar41" },
2334 { REG_AR_BASE+42, "ar42" },
2335 { REG_AR_BASE+43, "ar43" },
2336 { REG_AR_BASE+44, "ar44" },
2337 { REG_AR_BASE+45, "ar45" },
2338 { REG_AR_BASE+46, "ar46" },
2339 { REG_AR_BASE+47, "ar47" },
2340 { REG_AR_BASE+48, "ar48" },
2341 { REG_AR_BASE+49, "ar49" },
2342 { REG_AR_BASE+50, "ar50" },
2343 { REG_AR_BASE+51, "ar51" },
2344 { REG_AR_BASE+52, "ar52" },
2345 { REG_AR_BASE+53, "ar53" },
2346 { REG_AR_BASE+54, "ar54" },
2347 { REG_AR_BASE+55, "ar55" },
2348 { REG_AR_BASE+56, "ar56" },
2349 { REG_AR_BASE+57, "ar57" },
2350 { REG_AR_BASE+58, "ar58" },
2351 { REG_AR_BASE+59, "ar59" },
2352 { REG_AR_BASE+60, "ar60" },
2353 { REG_AR_BASE+61, "ar61" },
2354 { REG_AR_BASE+62, "ar62" },
2355 { REG_AR_BASE+63, "ar63" },
2356 { REG_LBEG, "lbeg" },
2357 { REG_LEND, "lend" },
2358 { REG_LCOUNT, "lcount" },
2359 { REG_SAR, "sar" },
2360 { REG_WB, "wb" },
2361 { REG_WS, "ws" },
2362 { REG_PS, "ps" },
2363 { REG_PC, "pc" },
2364 { REG_A_BASE, "a0" },
2365 { REG_A_BASE+1, "a1" },
2366 { REG_A_BASE+2, "a2" },
2367 { REG_A_BASE+3, "a3" },
2368 { REG_A_BASE+4, "a4" },
2369 { REG_A_BASE+5, "a5" },
2370 { REG_A_BASE+6, "a6" },
2371 { REG_A_BASE+7, "a7" },
2372 { REG_A_BASE+8, "a8" },
2373 { REG_A_BASE+9, "a9" },
2374 { REG_A_BASE+10, "a10" },
2375 { REG_A_BASE+11, "a11" },
2376 { REG_A_BASE+12, "a12" },
2377 { REG_A_BASE+13, "a13" },
2378 { REG_A_BASE+14, "a14" },
2379 { REG_A_BASE+15, "a15" },
2380#endif
2381
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002382 /* Other fields in "struct user" */
2383#if defined(S390) || defined(S390X)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002384 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2385 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2386 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002387 { uoff(start_code), "offsetof(struct user, start_code)" },
2388 /* S390[X] has no start_data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002389 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2390 { uoff(signal), "offsetof(struct user, signal)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002391 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002392 { uoff(magic), "offsetof(struct user, magic)" },
2393 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002394 { sizeof(struct user), "sizeof(struct user)" },
2395#elif defined(POWERPC)
2396 { sizeof(struct user), "sizeof(struct user)" },
2397#elif defined(I386) || defined(X86_64) || defined(X32)
2398 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2399 { uoff(i387), "offsetof(struct user, i387)" },
2400 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2401 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2402 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2403 { uoff(start_code), "offsetof(struct user, start_code)" },
2404 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2405 { uoff(signal), "offsetof(struct user, signal)" },
2406 { uoff(reserved), "offsetof(struct user, reserved)" },
2407 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2408 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2409 { uoff(magic), "offsetof(struct user, magic)" },
2410 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002411 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002412 { sizeof(struct user), "sizeof(struct user)" },
2413#elif defined(IA64)
2414 { sizeof(struct user), "sizeof(struct user)" },
2415#elif defined(ARM)
2416 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2417 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2418 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2419 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2420 { uoff(start_code), "offsetof(struct user, start_code)" },
2421 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2422 { uoff(signal), "offsetof(struct user, signal)" },
2423 { uoff(reserved), "offsetof(struct user, reserved)" },
2424 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2425 { uoff(magic), "offsetof(struct user, magic)" },
2426 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2427 { sizeof(struct user), "sizeof(struct user)" },
2428#elif defined(AARCH64)
2429 /* nothing */
2430#elif defined(M68K)
2431 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2432 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
2433 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2434 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2435 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2436 { uoff(start_code), "offsetof(struct user, start_code)" },
2437 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2438 { uoff(signal), "offsetof(struct user, signal)" },
2439 { uoff(reserved), "offsetof(struct user, reserved)" },
2440 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2441 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2442 { uoff(magic), "offsetof(struct user, magic)" },
2443 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2444 { sizeof(struct user), "sizeof(struct user)" },
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002445#elif defined(MIPS) || defined(LINUX_MIPSN32)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002446 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2447 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2448 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2449 { uoff(start_code), "offsetof(struct user, start_code)" },
Denys Vlasenko74307a62013-02-12 17:10:05 +01002450 { uoff(start_data), "offsetof(struct user, start_data)" },
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002451 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2452 { uoff(signal), "offsetof(struct user, signal)" },
2453 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2454 { uoff(magic), "offsetof(struct user, magic)" },
2455 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2456 { sizeof(struct user), "sizeof(struct user)" },
2457#elif defined(ALPHA)
2458 { sizeof(struct user), "sizeof(struct user)" },
2459#elif defined(SPARC)
2460 { sizeof(struct user), "sizeof(struct user)" },
2461#elif defined(SPARC64)
2462 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2463 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2464 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2465 { uoff(signal), "offsetof(struct user, signal)" },
2466 { uoff(magic), "offsetof(struct user, magic)" },
2467 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2468 { sizeof(struct user), "sizeof(struct user)" },
2469#elif defined(HPPA)
2470 /* nothing */
Denys Vlasenko873e5a52013-02-12 17:15:19 +01002471#elif defined(SH) || defined(SH64)
Denys Vlasenko729e18d2013-02-12 15:51:58 +01002472 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
2473 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2474 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2475 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2476 { uoff(start_code), "offsetof(struct user, start_code)" },
2477 { uoff(start_data), "offsetof(struct user, start_data)" },
2478 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2479 { uoff(signal), "offsetof(struct user, signal)" },
2480 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2481 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
2482 { uoff(magic), "offsetof(struct user, magic)" },
2483 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2484 { sizeof(struct user), "sizeof(struct user)" },
2485#elif defined(CRISV10) || defined(CRISV32)
2486 { sizeof(struct user), "sizeof(struct user)" },
2487#elif defined(TILE)
2488 /* nothing */
2489#elif defined(MICROBLAZE)
2490 { sizeof(struct user), "sizeof(struct user)" },
2491#elif defined(AVR32)
2492 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2493 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2494 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2495 { uoff(start_code), "offsetof(struct user, start_code)" },
2496 { uoff(start_data), "offsetof(struct user, start_data)" },
2497 { uoff(start_stack), "offsetof(struct user, start_stack)" },
2498 { uoff(signal), "offsetof(struct user, signal)" },
2499 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2500 { uoff(magic), "offsetof(struct user, magic)" },
2501 { uoff(u_comm), "offsetof(struct user, u_comm)" },
2502 { sizeof(struct user), "sizeof(struct user)" },
2503#elif defined(BFIN)
2504 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
2505 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
2506 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
2507 { uoff(start_code), "offsetof(struct user, start_code)" },
2508 { uoff(signal), "offsetof(struct user, signal)" },
2509 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2510 { uoff(magic), "offsetof(struct user, magic)" },
2511 { uoff(u_comm), "offsetof(struct user, u_comm)" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002512 { sizeof(struct user), "sizeof(struct user)" },
Christian Svensson492f81f2013-02-14 13:26:27 +01002513#elif defined(OR1K)
2514 /* nothing */
James Hogan5f999a82013-02-22 14:44:10 +00002515#elif defined(METAG)
2516 /* nothing */
Chris Zankel8f636ed2013-03-25 10:22:07 -07002517#elif defined(XTENSA)
2518 /* nothing */
Vineet Gupta7daacbb2013-08-16 12:47:06 +05302519#elif defined(ARC)
2520 /* nothing */
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002521#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00002522 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002523};
2524
2525int
Denys Vlasenkoc7e83712009-02-24 12:59:47 +00002526sys_ptrace(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002527{
Roland McGrathd9f816f2004-09-04 03:39:20 +00002528 const struct xlat *x;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002529 long addr;
2530
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002531 if (entering(tcp)) {
Denys Vlasenkob7a6dae2012-03-20 16:48:35 +01002532 printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???");
Roland McGrathbf621d42003-01-14 09:46:21 +00002533 tprintf(", %lu, ", tcp->u_arg[1]);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002534
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002535 addr = tcp->u_arg[2];
2536 if (tcp->u_arg[0] == PTRACE_PEEKUSER
Denys Vlasenkobe994972013-02-13 16:10:10 +01002537 || tcp->u_arg[0] == PTRACE_POKEUSER
2538 ) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002539 for (x = struct_user_offsets; x->str; x++) {
2540 if (x->val >= addr)
2541 break;
2542 }
2543 if (!x->str)
2544 tprintf("%#lx, ", addr);
2545 else if (x->val > addr && x != struct_user_offsets) {
2546 x--;
2547 tprintf("%s + %ld, ", x->str, addr - x->val);
2548 }
2549 else
2550 tprintf("%s, ", x->str);
Denys Vlasenkobe994972013-02-13 16:10:10 +01002551 } else
2552#ifdef PTRACE_GETREGSET
Dmitry V. Levinc41808b2013-03-18 00:52:29 +00002553 if (tcp->u_arg[0] == PTRACE_GETREGSET
2554 || tcp->u_arg[0] == PTRACE_SETREGSET
2555 ) {
2556 printxval(nt_descriptor_types, tcp->u_arg[2], "NT_???");
2557 tprints(", ");
2558 } else
Denys Vlasenkobe994972013-02-13 16:10:10 +01002559#endif
2560 tprintf("%#lx, ", addr);
2561
2562
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002563 switch (tcp->u_arg[0]) {
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002564#ifndef IA64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002565 case PTRACE_PEEKDATA:
2566 case PTRACE_PEEKTEXT:
2567 case PTRACE_PEEKUSER:
2568 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002569#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002570 case PTRACE_CONT:
2571 case PTRACE_SINGLESTEP:
2572 case PTRACE_SYSCALL:
2573 case PTRACE_DETACH:
2574 printsignal(tcp->u_arg[3]);
2575 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002576#ifdef PTRACE_SETOPTIONS
Denys Vlasenkof535b542009-01-13 18:30:55 +00002577 case PTRACE_SETOPTIONS:
2578 printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
2579 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002580#endif
2581#ifdef PTRACE_SETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002582 case PTRACE_SETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002583 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002584 break;
2585 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002586#endif
2587#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002588 case PTRACE_GETSIGINFO:
2589 /* Don't print anything, do it at syscall return. */
2590 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002591#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002592#ifdef PTRACE_GETREGSET
2593 case PTRACE_GETREGSET:
2594 break;
2595 case PTRACE_SETREGSET:
2596 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2597 break;
2598#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002599 default:
2600 tprintf("%#lx", tcp->u_arg[3]);
2601 break;
2602 }
2603 } else {
2604 switch (tcp->u_arg[0]) {
2605 case PTRACE_PEEKDATA:
2606 case PTRACE_PEEKTEXT:
2607 case PTRACE_PEEKUSER:
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002608#ifdef IA64
Roland McGrath1e868062007-11-19 22:11:45 +00002609 return RVAL_HEX;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002610#else
Roland McGratheb285352003-01-14 09:59:00 +00002611 printnum(tcp, tcp->u_arg[3], "%#lx");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002612 break;
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002613#endif
2614#ifdef PTRACE_GETSIGINFO
Denys Vlasenkof535b542009-01-13 18:30:55 +00002615 case PTRACE_GETSIGINFO: {
Denys Vlasenkod4d3ede2013-02-13 16:31:32 +01002616 printsiginfo_at(tcp, tcp->u_arg[3]);
Denys Vlasenkof535b542009-01-13 18:30:55 +00002617 break;
2618 }
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002619#endif
Denys Vlasenkobe994972013-02-13 16:10:10 +01002620#ifdef PTRACE_GETREGSET
2621 case PTRACE_GETREGSET:
2622 tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0);
2623 break;
2624#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002625 }
2626 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002627 return 0;
2628}
2629
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002630#ifndef FUTEX_CMP_REQUEUE
2631# define FUTEX_CMP_REQUEUE 4
2632#endif
2633#ifndef FUTEX_WAKE_OP
2634# define FUTEX_WAKE_OP 5
2635#endif
2636#ifndef FUTEX_LOCK_PI
2637# define FUTEX_LOCK_PI 6
2638# define FUTEX_UNLOCK_PI 7
2639# define FUTEX_TRYLOCK_PI 8
2640#endif
2641#ifndef FUTEX_WAIT_BITSET
2642# define FUTEX_WAIT_BITSET 9
2643#endif
2644#ifndef FUTEX_WAKE_BITSET
2645# define FUTEX_WAKE_BITSET 10
2646#endif
2647#ifndef FUTEX_WAIT_REQUEUE_PI
2648# define FUTEX_WAIT_REQUEUE_PI 11
2649#endif
2650#ifndef FUTEX_CMP_REQUEUE_PI
2651# define FUTEX_CMP_REQUEUE_PI 12
2652#endif
2653#ifndef FUTEX_PRIVATE_FLAG
2654# define FUTEX_PRIVATE_FLAG 128
2655#endif
2656#ifndef FUTEX_CLOCK_REALTIME
2657# define FUTEX_CLOCK_REALTIME 256
2658#endif
Dmitry V. Levin9f56d872014-02-05 02:01:16 +00002659#ifndef FUTEX_WAIT_PRIVATE
2660# define FUTEX_WAIT_PRIVATE (FUTEX_WAIT | FUTEX_PRIVATE_FLAG)
2661#endif
2662#ifndef FUTEX_WAKE_PRIVATE
2663# define FUTEX_WAKE_PRIVATE (FUTEX_WAKE | FUTEX_PRIVATE_FLAG)
2664#endif
2665#ifndef FUTEX_REQUEUE_PRIVATE
2666# define FUTEX_REQUEUE_PRIVATE (FUTEX_REQUEUE | FUTEX_PRIVATE_FLAG)
2667#endif
2668#ifndef FUTEX_CMP_REQUEUE_PRIVATE
2669# define FUTEX_CMP_REQUEUE_PRIVATE (FUTEX_CMP_REQUEUE | FUTEX_PRIVATE_FLAG)
2670#endif
2671#ifndef FUTEX_WAKE_OP_PRIVATE
2672# define FUTEX_WAKE_OP_PRIVATE (FUTEX_WAKE_OP | FUTEX_PRIVATE_FLAG)
2673#endif
2674#ifndef FUTEX_LOCK_PI_PRIVATE
2675# define FUTEX_LOCK_PI_PRIVATE (FUTEX_LOCK_PI | FUTEX_PRIVATE_FLAG)
2676#endif
2677#ifndef FUTEX_UNLOCK_PI_PRIVATE
2678# define FUTEX_UNLOCK_PI_PRIVATE (FUTEX_UNLOCK_PI | FUTEX_PRIVATE_FLAG)
2679#endif
2680#ifndef FUTEX_TRYLOCK_PI_PRIVATE
2681# define FUTEX_TRYLOCK_PI_PRIVATE (FUTEX_TRYLOCK_PI | FUTEX_PRIVATE_FLAG)
2682#endif
2683#ifndef FUTEX_WAIT_BITSET_PRIVATE
2684# define FUTEX_WAIT_BITSET_PRIVATE (FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG)
2685#endif
2686#ifndef FUTEX_WAKE_BITSET_PRIVATE
2687# define FUTEX_WAKE_BITSET_PRIVATE (FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG)
2688#endif
2689#ifndef FUTEX_WAIT_REQUEUE_PI_PRIVATE
2690# define FUTEX_WAIT_REQUEUE_PI_PRIVATE (FUTEX_WAIT_REQUEUE_PI | FUTEX_PRIVATE_FLAG)
2691#endif
2692#ifndef FUTEX_CMP_REQUEUE_PI_PRIVATE
2693# define FUTEX_CMP_REQUEUE_PI_PRIVATE (FUTEX_CMP_REQUEUE_PI | FUTEX_PRIVATE_FLAG)
2694#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +00002695static const struct xlat futexops[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00002696 XLAT(FUTEX_WAIT),
2697 XLAT(FUTEX_WAKE),
2698 XLAT(FUTEX_FD),
2699 XLAT(FUTEX_REQUEUE),
2700 XLAT(FUTEX_CMP_REQUEUE),
2701 XLAT(FUTEX_WAKE_OP),
2702 XLAT(FUTEX_LOCK_PI),
2703 XLAT(FUTEX_UNLOCK_PI),
2704 XLAT(FUTEX_TRYLOCK_PI),
2705 XLAT(FUTEX_WAIT_BITSET),
2706 XLAT(FUTEX_WAKE_BITSET),
2707 XLAT(FUTEX_WAIT_REQUEUE_PI),
2708 XLAT(FUTEX_CMP_REQUEUE_PI),
Dmitry V. Levin9f56d872014-02-05 02:01:16 +00002709 XLAT(FUTEX_WAIT_PRIVATE),
2710 XLAT(FUTEX_WAKE_PRIVATE),
2711 XLAT(FUTEX_FD|FUTEX_PRIVATE_FLAG),
2712 XLAT(FUTEX_REQUEUE_PRIVATE),
2713 XLAT(FUTEX_CMP_REQUEUE_PRIVATE),
2714 XLAT(FUTEX_WAKE_OP_PRIVATE),
2715 XLAT(FUTEX_LOCK_PI_PRIVATE),
2716 XLAT(FUTEX_UNLOCK_PI_PRIVATE),
2717 XLAT(FUTEX_TRYLOCK_PI_PRIVATE),
2718 XLAT(FUTEX_WAIT_BITSET_PRIVATE),
2719 XLAT(FUTEX_WAKE_BITSET_PRIVATE),
2720 XLAT(FUTEX_WAIT_REQUEUE_PI_PRIVATE),
2721 XLAT(FUTEX_CMP_REQUEUE_PI_PRIVATE),
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00002722 XLAT(FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME),
Dmitry V. Levin9f56d872014-02-05 02:01:16 +00002723 XLAT(FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME),
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00002724 XLAT(FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME),
Dmitry V. Levin9f56d872014-02-05 02:01:16 +00002725 XLAT(FUTEX_WAIT_REQUEUE_PI_PRIVATE|FUTEX_CLOCK_REALTIME),
Dmitry V. Levin59452732014-02-05 02:20:51 +00002726 XLAT_END
Roland McGrath51942a92007-07-05 18:59:11 +00002727};
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002728#ifndef FUTEX_OP_SET
2729# define FUTEX_OP_SET 0
2730# define FUTEX_OP_ADD 1
2731# define FUTEX_OP_OR 2
2732# define FUTEX_OP_ANDN 3
2733# define FUTEX_OP_XOR 4
2734# define FUTEX_OP_CMP_EQ 0
2735# define FUTEX_OP_CMP_NE 1
2736# define FUTEX_OP_CMP_LT 2
2737# define FUTEX_OP_CMP_LE 3
2738# define FUTEX_OP_CMP_GT 4
2739# define FUTEX_OP_CMP_GE 5
2740#endif
Roland McGrath51942a92007-07-05 18:59:11 +00002741static const struct xlat futexwakeops[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00002742 XLAT(FUTEX_OP_SET),
2743 XLAT(FUTEX_OP_ADD),
2744 XLAT(FUTEX_OP_OR),
2745 XLAT(FUTEX_OP_ANDN),
2746 XLAT(FUTEX_OP_XOR),
Dmitry V. Levin59452732014-02-05 02:20:51 +00002747 XLAT_END
Roland McGrath51942a92007-07-05 18:59:11 +00002748};
2749static const struct xlat futexwakecmps[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00002750 XLAT(FUTEX_OP_CMP_EQ),
2751 XLAT(FUTEX_OP_CMP_NE),
2752 XLAT(FUTEX_OP_CMP_LT),
2753 XLAT(FUTEX_OP_CMP_LE),
2754 XLAT(FUTEX_OP_CMP_GT),
2755 XLAT(FUTEX_OP_CMP_GE),
Dmitry V. Levin59452732014-02-05 02:20:51 +00002756 XLAT_END
Roland McGrath5a223472002-12-15 23:58:26 +00002757};
2758
2759int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002760sys_futex(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002761{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002762 if (entering(tcp)) {
2763 long int cmd = tcp->u_arg[1] & 127;
2764 tprintf("%p, ", (void *) tcp->u_arg[0]);
2765 printxval(futexops, tcp->u_arg[1], "FUTEX_???");
2766 tprintf(", %ld", tcp->u_arg[2]);
2767 if (cmd == FUTEX_WAKE_BITSET)
2768 tprintf(", %lx", tcp->u_arg[5]);
2769 else if (cmd == FUTEX_WAIT) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002770 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002771 printtv(tcp, tcp->u_arg[3]);
2772 } else if (cmd == FUTEX_WAIT_BITSET) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002773 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002774 printtv(tcp, tcp->u_arg[3]);
2775 tprintf(", %lx", tcp->u_arg[5]);
2776 } else if (cmd == FUTEX_REQUEUE)
2777 tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]);
Andreas Schwab85f58322009-08-12 09:54:42 +02002778 else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI)
Denys Vlasenko1d632462009-04-14 12:51:00 +00002779 tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]);
2780 else if (cmd == FUTEX_WAKE_OP) {
2781 tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]);
2782 if ((tcp->u_arg[5] >> 28) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002783 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002784 printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???");
2785 tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff);
2786 if ((tcp->u_arg[5] >> 24) & 8)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002787 tprints("FUTEX_OP_OPARG_SHIFT|");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002788 printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???");
2789 tprintf(", %ld}", tcp->u_arg[5] & 0xfff);
Andreas Schwab85f58322009-08-12 09:54:42 +02002790 } else if (cmd == FUTEX_WAIT_REQUEUE_PI) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002791 tprints(", ");
Andreas Schwab85f58322009-08-12 09:54:42 +02002792 printtv(tcp, tcp->u_arg[3]);
2793 tprintf(", %p", (void *) tcp->u_arg[4]);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002794 }
Roland McGrath51942a92007-07-05 18:59:11 +00002795 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00002796 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002797}
2798
2799static void
Denys Vlasenko1d632462009-04-14 12:51:00 +00002800print_affinitylist(struct tcb *tcp, long list, unsigned int len)
Roland McGrath5a223472002-12-15 23:58:26 +00002801{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002802 int first = 1;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002803 unsigned long w, min_len;
2804
2805 if (abbrev(tcp) && len / sizeof(w) > max_strlen)
2806 min_len = len - max_strlen * sizeof(w);
2807 else
2808 min_len = 0;
2809 for (; len >= sizeof(w) && len > min_len;
2810 len -= sizeof(w), list += sizeof(w)) {
2811 if (umove(tcp, list, &w) < 0)
2812 break;
2813 if (first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002814 tprints("{");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002815 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002816 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +00002817 first = 0;
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002818 tprintf("%lx", w);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002819 }
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002820 if (len) {
2821 if (first)
2822 tprintf("%#lx", list);
2823 else
2824 tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
2825 "???" : "..."));
2826 } else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002827 tprints(first ? "{}" : "}");
Dmitry V. Levin62e05962009-11-03 14:38:44 +00002828 }
Roland McGrath5a223472002-12-15 23:58:26 +00002829}
2830
2831int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002832sys_sched_setaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002833{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002834 if (entering(tcp)) {
2835 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2836 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
2837 }
2838 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002839}
2840
2841int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002842sys_sched_getaffinity(struct tcb *tcp)
Roland McGrath5a223472002-12-15 23:58:26 +00002843{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002844 if (entering(tcp)) {
2845 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
2846 } else {
2847 if (tcp->u_rval == -1)
2848 tprintf("%#lx", tcp->u_arg[2]);
2849 else
2850 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
2851 }
2852 return 0;
Roland McGrath5a223472002-12-15 23:58:26 +00002853}
Roland McGrath279d3782004-03-01 20:27:37 +00002854
Dmitry V. Levin1b0bae22012-03-11 22:32:26 +00002855int
2856sys_get_robust_list(struct tcb *tcp)
2857{
2858 if (entering(tcp)) {
2859 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2860 } else {
2861 void *addr;
2862 size_t len;
2863
2864 if (syserror(tcp) ||
2865 !tcp->u_arg[1] ||
2866 umove(tcp, tcp->u_arg[1], &addr) < 0) {
2867 tprintf("%#lx, ", tcp->u_arg[1]);
2868 } else {
2869 tprintf("[%p], ", addr);
2870 }
2871
2872 if (syserror(tcp) ||
2873 !tcp->u_arg[2] ||
2874 umove(tcp, tcp->u_arg[2], &len) < 0) {
2875 tprintf("%#lx", tcp->u_arg[2]);
2876 } else {
2877 tprintf("[%lu]", (unsigned long) len);
2878 }
2879 }
2880 return 0;
2881}
2882
Roland McGrathd9f816f2004-09-04 03:39:20 +00002883static const struct xlat schedulers[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00002884 XLAT(SCHED_OTHER),
2885 XLAT(SCHED_RR),
2886 XLAT(SCHED_FIFO),
Dmitry V. Levin59452732014-02-05 02:20:51 +00002887 XLAT_END
Roland McGrath279d3782004-03-01 20:27:37 +00002888};
2889
2890int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002891sys_sched_getscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002892{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002893 if (entering(tcp)) {
2894 tprintf("%d", (int) tcp->u_arg[0]);
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002895 } else if (!syserror(tcp)) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002896 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002897 if (tcp->auxstr != NULL)
2898 return RVAL_STR;
2899 }
2900 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002901}
2902
2903int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002904sys_sched_setscheduler(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002905{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002906 if (entering(tcp)) {
2907 struct sched_param p;
2908 tprintf("%d, ", (int) tcp->u_arg[0]);
2909 printxval(schedulers, tcp->u_arg[1], "SCHED_???");
2910 if (umove(tcp, tcp->u_arg[2], &p) < 0)
2911 tprintf(", %#lx", tcp->u_arg[2]);
2912 else
Dmitry V. Levine19a7122013-11-12 15:09:56 +00002913 tprintf(", { %d }", p.sched_priority);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002914 }
2915 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002916}
2917
2918int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002919sys_sched_getparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002920{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002921 if (entering(tcp)) {
2922 tprintf("%d, ", (int) tcp->u_arg[0]);
2923 } else {
2924 struct sched_param p;
2925 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2926 tprintf("%#lx", tcp->u_arg[1]);
2927 else
Dmitry V. Levine19a7122013-11-12 15:09:56 +00002928 tprintf("{ %d }", p.sched_priority);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002929 }
2930 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002931}
2932
2933int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002934sys_sched_setparam(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002935{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002936 if (entering(tcp)) {
2937 struct sched_param p;
2938 if (umove(tcp, tcp->u_arg[1], &p) < 0)
2939 tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]);
2940 else
Dmitry V. Levine19a7122013-11-12 15:09:56 +00002941 tprintf("%d, { %d }", (int) tcp->u_arg[0], p.sched_priority);
Denys Vlasenko1d632462009-04-14 12:51:00 +00002942 }
2943 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002944}
2945
2946int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002947sys_sched_get_priority_min(struct tcb *tcp)
Roland McGrath279d3782004-03-01 20:27:37 +00002948{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002949 if (entering(tcp)) {
2950 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
2951 }
2952 return 0;
Roland McGrath279d3782004-03-01 20:27:37 +00002953}
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002954
Dmitry V. Levin1ff463d2012-03-11 23:00:11 +00002955int
2956sys_sched_rr_get_interval(struct tcb *tcp)
2957{
2958 if (entering(tcp)) {
2959 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
2960 } else {
2961 if (syserror(tcp))
2962 tprintf("%#lx", tcp->u_arg[1]);
2963 else
2964 print_timespec(tcp, tcp->u_arg[1]);
2965 }
2966 return 0;
2967}
2968
H.J. Lu35be5812012-04-16 13:00:01 +02002969#if defined X86_64 || defined X32
Denys Vlasenko3e3490a2012-03-17 01:27:37 +01002970# include <asm/prctl.h>
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002971
2972static const struct xlat archvals[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00002973 XLAT(ARCH_SET_GS),
2974 XLAT(ARCH_SET_FS),
2975 XLAT(ARCH_GET_FS),
2976 XLAT(ARCH_GET_GS),
Dmitry V. Levin59452732014-02-05 02:20:51 +00002977 XLAT_END
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002978};
2979
2980int
Denys Vlasenko1d632462009-04-14 12:51:00 +00002981sys_arch_prctl(struct tcb *tcp)
Roland McGrathc2d5eb02005-02-02 04:16:56 +00002982{
Denys Vlasenko1d632462009-04-14 12:51:00 +00002983 if (entering(tcp)) {
2984 printxval(archvals, tcp->u_arg[0], "ARCH_???");
2985 if (tcp->u_arg[0] == ARCH_SET_GS
2986 || tcp->u_arg[0] == ARCH_SET_FS
2987 ) {
2988 tprintf(", %#lx", tcp->u_arg[1]);
2989 }
2990 } else {
2991 if (tcp->u_arg[0] == ARCH_GET_GS
2992 || tcp->u_arg[0] == ARCH_GET_FS
2993 ) {
2994 long int v;
2995 if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
2996 tprintf(", [%#lx]", v);
2997 else
2998 tprintf(", %#lx", tcp->u_arg[1]);
2999 }
Roland McGrathc2d5eb02005-02-02 04:16:56 +00003000 }
Denys Vlasenko1d632462009-04-14 12:51:00 +00003001 return 0;
Roland McGrathc2d5eb02005-02-02 04:16:56 +00003002}
H.J. Lu35be5812012-04-16 13:00:01 +02003003#endif /* X86_64 || X32 */
Roland McGrathc2d5eb02005-02-02 04:16:56 +00003004
Roland McGrathdb8319f2007-08-02 01:37:55 +00003005int
Denys Vlasenko1d632462009-04-14 12:51:00 +00003006sys_getcpu(struct tcb *tcp)
Roland McGrathdb8319f2007-08-02 01:37:55 +00003007{
3008 if (exiting(tcp)) {
3009 unsigned u;
3010 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02003011 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00003012 else if (umove(tcp, tcp->u_arg[0], &u) < 0)
3013 tprintf("%#lx, ", tcp->u_arg[0]);
3014 else
3015 tprintf("[%u], ", u);
3016 if (tcp->u_arg[1] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02003017 tprints("NULL, ");
Roland McGrathdb8319f2007-08-02 01:37:55 +00003018 else if (umove(tcp, tcp->u_arg[1], &u) < 0)
3019 tprintf("%#lx, ", tcp->u_arg[1]);
3020 else
3021 tprintf("[%u], ", u);
3022 tprintf("%#lx", tcp->u_arg[2]);
3023 }
3024 return 0;
3025}
3026
Denys Vlasenko3af224c2012-01-28 01:46:33 +01003027int
3028sys_process_vm_readv(struct tcb *tcp)
3029{
3030 if (entering(tcp)) {
3031 /* arg 1: pid */
3032 tprintf("%ld, ", tcp->u_arg[0]);
3033 } else {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00003034 /* arg 2: local iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01003035 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00003036 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01003037 } else {
3038 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
3039 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00003040 /* arg 3: local iovcnt */
3041 tprintf(", %lu, ", tcp->u_arg[2]);
3042 /* arg 4: remote iov */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01003043 if (syserror(tcp)) {
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00003044 tprintf("%#lx", tcp->u_arg[3]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01003045 } else {
3046 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
3047 }
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00003048 /* arg 5: remote iovcnt */
Denys Vlasenko3af224c2012-01-28 01:46:33 +01003049 /* arg 6: flags */
Dmitry V. Levin0bfd7442012-03-10 14:03:25 +00003050 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
Denys Vlasenko3af224c2012-01-28 01:46:33 +01003051 }
3052 return 0;
3053}
Dmitry V. Levin03952102012-03-10 14:14:49 +00003054
3055int
3056sys_process_vm_writev(struct tcb *tcp)
3057{
3058 if (entering(tcp)) {
3059 /* arg 1: pid */
3060 tprintf("%ld, ", tcp->u_arg[0]);
3061 /* arg 2: local iov */
3062 if (syserror(tcp))
3063 tprintf("%#lx", tcp->u_arg[1]);
3064 else
3065 tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
3066 /* arg 3: local iovcnt */
3067 tprintf(", %lu, ", tcp->u_arg[2]);
3068 /* arg 4: remote iov */
3069 if (syserror(tcp))
3070 tprintf("%#lx", tcp->u_arg[3]);
3071 else
3072 tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
3073 /* arg 5: remote iovcnt */
3074 /* arg 6: flags */
3075 tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
3076 }
3077 return 0;
3078}