Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 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 Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * 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 Akkerman | ccef637 | 2002-05-01 16:39:22 +0000 | [diff] [blame] | 9 | * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH |
| 10 | * port by Greg Banks <gbanks@pocketpenguins.com> |
| 11 | |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 12 | * |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 13 | * All rights reserved. |
| 14 | * |
| 15 | * Redistribution and use in source and binary forms, with or without |
| 16 | * modification, are permitted provided that the following conditions |
| 17 | * are met: |
| 18 | * 1. Redistributions of source code must retain the above copyright |
| 19 | * notice, this list of conditions and the following disclaimer. |
| 20 | * 2. Redistributions in binary form must reproduce the above copyright |
| 21 | * notice, this list of conditions and the following disclaimer in the |
| 22 | * documentation and/or other materials provided with the distribution. |
| 23 | * 3. The name of the author may not be used to endorse or promote products |
| 24 | * derived from this software without specific prior written permission. |
| 25 | * |
| 26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 27 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 28 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 29 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 30 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 32 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 35 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 36 | * |
| 37 | * $Id$ |
| 38 | */ |
| 39 | |
| 40 | #include "defs.h" |
| 41 | |
| 42 | #include <fcntl.h> |
| 43 | #include <sys/stat.h> |
| 44 | #include <sys/time.h> |
| 45 | #include <sys/wait.h> |
| 46 | #include <sys/resource.h> |
| 47 | #include <sys/utsname.h> |
| 48 | #include <sys/user.h> |
| 49 | #include <sys/syscall.h> |
| 50 | #include <signal.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 51 | |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 52 | #ifdef HAVE_SYS_REG_H |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 53 | # include <sys/reg.h> |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 54 | # ifndef PTRACE_PEEKUSR |
| 55 | # define PTRACE_PEEKUSR PTRACE_PEEKUSER |
| 56 | # endif |
| 57 | # ifndef PTRACE_POKEUSR |
| 58 | # define PTRACE_POKEUSR PTRACE_POKEUSER |
| 59 | # endif |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 60 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 61 | |
Roland McGrath | 5bd7cf8 | 2003-01-24 04:31:18 +0000 | [diff] [blame] | 62 | #ifdef HAVE_LINUX_PTRACE_H |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 63 | # undef PTRACE_SYSCALL |
Roland McGrath | fb1bc07 | 2004-03-01 21:29:24 +0000 | [diff] [blame] | 64 | # ifdef HAVE_STRUCT_IA64_FPREG |
| 65 | # define ia64_fpreg XXX_ia64_fpreg |
| 66 | # endif |
| 67 | # ifdef HAVE_STRUCT_PT_ALL_USER_REGS |
| 68 | # define pt_all_user_regs XXX_pt_all_user_regs |
| 69 | # endif |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 70 | # include <linux/ptrace.h> |
Roland McGrath | fb1bc07 | 2004-03-01 21:29:24 +0000 | [diff] [blame] | 71 | # undef ia64_fpreg |
| 72 | # undef pt_all_user_regs |
Roland McGrath | 5bd7cf8 | 2003-01-24 04:31:18 +0000 | [diff] [blame] | 73 | #endif |
| 74 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 75 | #if defined(SPARC64) |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 76 | # define r_pc r_tpc |
| 77 | # undef PTRACE_GETREGS |
| 78 | # define PTRACE_GETREGS PTRACE_GETREGS64 |
| 79 | # undef PTRACE_SETREGS |
| 80 | # define PTRACE_SETREGS PTRACE_SETREGS64 |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 81 | #endif |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 82 | |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 83 | #ifdef HAVE_LINUX_FUTEX_H |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 84 | # include <linux/futex.h> |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 85 | #endif |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 86 | #ifndef FUTEX_WAIT |
| 87 | # define FUTEX_WAIT 0 |
| 88 | #endif |
| 89 | #ifndef FUTEX_WAKE |
| 90 | # define FUTEX_WAKE 1 |
| 91 | #endif |
| 92 | #ifndef FUTEX_FD |
| 93 | # define FUTEX_FD 2 |
| 94 | #endif |
| 95 | #ifndef FUTEX_REQUEUE |
| 96 | # define FUTEX_REQUEUE 3 |
| 97 | #endif |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 98 | |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 99 | #include <sched.h> |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 100 | #include <asm/posix_types.h> |
| 101 | #undef GETGROUPS_T |
| 102 | #define GETGROUPS_T __kernel_gid_t |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 103 | #undef GETGROUPS32_T |
| 104 | #define GETGROUPS32_T __kernel_gid32_t |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 105 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 106 | #if defined(IA64) |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 107 | # include <asm/ptrace_offsets.h> |
| 108 | # include <asm/rse.h> |
| 109 | #endif |
| 110 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 111 | #ifdef HAVE_PRCTL |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 112 | # include <sys/prctl.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 113 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 114 | static const struct xlat prctl_options[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 115 | #ifdef PR_MAXPROCS |
| 116 | { PR_MAXPROCS, "PR_MAXPROCS" }, |
| 117 | #endif |
| 118 | #ifdef PR_ISBLOCKED |
| 119 | { PR_ISBLOCKED, "PR_ISBLOCKED" }, |
| 120 | #endif |
| 121 | #ifdef PR_SETSTACKSIZE |
| 122 | { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" }, |
| 123 | #endif |
| 124 | #ifdef PR_GETSTACKSIZE |
| 125 | { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" }, |
| 126 | #endif |
| 127 | #ifdef PR_MAXPPROCS |
| 128 | { PR_MAXPPROCS, "PR_MAXPPROCS" }, |
| 129 | #endif |
| 130 | #ifdef PR_UNBLKONEXEC |
| 131 | { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" }, |
| 132 | #endif |
| 133 | #ifdef PR_ATOMICSIM |
| 134 | { PR_ATOMICSIM, "PR_ATOMICSIM" }, |
| 135 | #endif |
| 136 | #ifdef PR_SETEXITSIG |
| 137 | { PR_SETEXITSIG, "PR_SETEXITSIG" }, |
| 138 | #endif |
| 139 | #ifdef PR_RESIDENT |
| 140 | { PR_RESIDENT, "PR_RESIDENT" }, |
| 141 | #endif |
| 142 | #ifdef PR_ATTACHADDR |
| 143 | { PR_ATTACHADDR, "PR_ATTACHADDR" }, |
| 144 | #endif |
| 145 | #ifdef PR_DETACHADDR |
| 146 | { PR_DETACHADDR, "PR_DETACHADDR" }, |
| 147 | #endif |
| 148 | #ifdef PR_TERMCHILD |
| 149 | { PR_TERMCHILD, "PR_TERMCHILD" }, |
| 150 | #endif |
| 151 | #ifdef PR_GETSHMASK |
| 152 | { PR_GETSHMASK, "PR_GETSHMASK" }, |
| 153 | #endif |
| 154 | #ifdef PR_GETNSHARE |
| 155 | { PR_GETNSHARE, "PR_GETNSHARE" }, |
| 156 | #endif |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 157 | #ifdef PR_COREPID |
| 158 | { PR_COREPID, "PR_COREPID" }, |
| 159 | #endif |
| 160 | #ifdef PR_ATTACHADDRPERM |
| 161 | { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" }, |
| 162 | #endif |
| 163 | #ifdef PR_PTHREADEXIT |
| 164 | { PR_PTHREADEXIT, "PR_PTHREADEXIT" }, |
| 165 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 166 | #ifdef PR_SET_PDEATHSIG |
| 167 | { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" }, |
| 168 | #endif |
| 169 | #ifdef PR_GET_PDEATHSIG |
| 170 | { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" }, |
| 171 | #endif |
Dmitry V. Levin | f02cf21 | 2008-09-03 00:54:40 +0000 | [diff] [blame] | 172 | #ifdef PR_GET_DUMPABLE |
| 173 | { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" }, |
| 174 | #endif |
| 175 | #ifdef PR_SET_DUMPABLE |
| 176 | { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" }, |
| 177 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 178 | #ifdef PR_GET_UNALIGN |
| 179 | { PR_GET_UNALIGN, "PR_GET_UNALIGN" }, |
| 180 | #endif |
| 181 | #ifdef PR_SET_UNALIGN |
| 182 | { PR_SET_UNALIGN, "PR_SET_UNALIGN" }, |
| 183 | #endif |
| 184 | #ifdef PR_GET_KEEPCAPS |
Dmitry V. Levin | 8dd31dd | 2008-11-11 00:25:22 +0000 | [diff] [blame] | 185 | { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" }, |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 186 | #endif |
| 187 | #ifdef PR_SET_KEEPCAPS |
Dmitry V. Levin | 8dd31dd | 2008-11-11 00:25:22 +0000 | [diff] [blame] | 188 | { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" }, |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 189 | #endif |
Roland McGrath | e5039fb | 2007-11-03 23:58:07 +0000 | [diff] [blame] | 190 | #ifdef PR_GET_FPEMU |
| 191 | { PR_GET_FPEMU, "PR_GET_FPEMU" }, |
| 192 | #endif |
| 193 | #ifdef PR_SET_FPEMU |
| 194 | { PR_SET_FPEMU, "PR_SET_FPEMU" }, |
| 195 | #endif |
| 196 | #ifdef PR_GET_FPEXC |
| 197 | { PR_GET_FPEXC, "PR_GET_FPEXC" }, |
| 198 | #endif |
| 199 | #ifdef PR_SET_FPEXC |
| 200 | { PR_SET_FPEXC, "PR_SET_FPEXC" }, |
| 201 | #endif |
| 202 | #ifdef PR_GET_TIMING |
| 203 | { PR_GET_TIMING, "PR_GET_TIMING" }, |
| 204 | #endif |
| 205 | #ifdef PR_SET_TIMING |
| 206 | { PR_SET_TIMING, "PR_SET_TIMING" }, |
| 207 | #endif |
| 208 | #ifdef PR_SET_NAME |
| 209 | { PR_SET_NAME, "PR_SET_NAME" }, |
| 210 | #endif |
| 211 | #ifdef PR_GET_NAME |
| 212 | { PR_GET_NAME, "PR_GET_NAME" }, |
| 213 | #endif |
| 214 | #ifdef PR_GET_ENDIAN |
| 215 | { PR_GET_ENDIAN, "PR_GET_ENDIAN" }, |
| 216 | #endif |
| 217 | #ifdef PR_SET_ENDIAN |
| 218 | { PR_SET_ENDIAN, "PR_SET_ENDIAN" }, |
| 219 | #endif |
| 220 | #ifdef PR_GET_SECCOMP |
| 221 | { PR_GET_SECCOMP, "PR_GET_SECCOMP" }, |
| 222 | #endif |
| 223 | #ifdef PR_SET_SECCOMP |
| 224 | { PR_SET_SECCOMP, "PR_SET_SECCOMP" }, |
| 225 | #endif |
Dmitry V. Levin | 8dd31dd | 2008-11-11 00:25:22 +0000 | [diff] [blame] | 226 | #ifdef PR_GET_TSC |
| 227 | { PR_GET_TSC, "PR_GET_TSC" }, |
| 228 | #endif |
| 229 | #ifdef PR_SET_TSC |
| 230 | { PR_SET_TSC, "PR_SET_TSC" }, |
| 231 | #endif |
| 232 | #ifdef PR_GET_SECUREBITS |
| 233 | { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" }, |
| 234 | #endif |
| 235 | #ifdef PR_SET_SECUREBITS |
| 236 | { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" }, |
| 237 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 238 | { 0, NULL }, |
| 239 | }; |
| 240 | |
Roland McGrath | a4d4853 | 2005-06-08 20:45:28 +0000 | [diff] [blame] | 241 | static const char * |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 242 | unalignctl_string(unsigned int ctl) |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 243 | { |
| 244 | static char buf[16]; |
| 245 | |
| 246 | switch (ctl) { |
| 247 | #ifdef PR_UNALIGN_NOPRINT |
| 248 | case PR_UNALIGN_NOPRINT: |
| 249 | return "NOPRINT"; |
| 250 | #endif |
| 251 | #ifdef PR_UNALIGN_SIGBUS |
| 252 | case PR_UNALIGN_SIGBUS: |
| 253 | return "SIGBUS"; |
| 254 | #endif |
| 255 | default: |
| 256 | break; |
| 257 | } |
| 258 | sprintf(buf, "%x", ctl); |
| 259 | return buf; |
| 260 | } |
| 261 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 262 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 263 | sys_prctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 264 | { |
| 265 | int i; |
| 266 | |
| 267 | if (entering(tcp)) { |
| 268 | printxval(prctl_options, tcp->u_arg[0], "PR_???"); |
| 269 | switch (tcp->u_arg[0]) { |
| 270 | #ifdef PR_GETNSHARE |
| 271 | case PR_GETNSHARE: |
| 272 | break; |
| 273 | #endif |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 274 | #ifdef PR_SET_PDEATHSIG |
| 275 | case PR_SET_PDEATHSIG: |
| 276 | tprintf(", %lu", tcp->u_arg[1]); |
| 277 | break; |
| 278 | #endif |
| 279 | #ifdef PR_GET_PDEATHSIG |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 280 | case PR_GET_PDEATHSIG: |
| 281 | break; |
| 282 | #endif |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 283 | #ifdef PR_SET_DUMPABLE |
| 284 | case PR_SET_DUMPABLE: |
| 285 | tprintf(", %lu", tcp->u_arg[1]); |
| 286 | break; |
| 287 | #endif |
| 288 | #ifdef PR_GET_DUMPABLE |
| 289 | case PR_GET_DUMPABLE: |
| 290 | break; |
| 291 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 292 | #ifdef PR_SET_UNALIGN |
| 293 | case PR_SET_UNALIGN: |
| 294 | tprintf(", %s", unalignctl_string(tcp->u_arg[1])); |
| 295 | break; |
| 296 | #endif |
| 297 | #ifdef PR_GET_UNALIGN |
| 298 | case PR_GET_UNALIGN: |
| 299 | tprintf(", %#lx", tcp->u_arg[1]); |
| 300 | break; |
| 301 | #endif |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 302 | #ifdef PR_SET_KEEPCAPS |
| 303 | case PR_SET_KEEPCAPS: |
| 304 | tprintf(", %lu", tcp->u_arg[1]); |
| 305 | break; |
| 306 | #endif |
| 307 | #ifdef PR_GET_KEEPCAPS |
| 308 | case PR_GET_KEEPCAPS: |
| 309 | break; |
| 310 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 311 | default: |
| 312 | for (i = 1; i < tcp->u_nargs; i++) |
| 313 | tprintf(", %#lx", tcp->u_arg[i]); |
| 314 | break; |
| 315 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 316 | } else { |
| 317 | switch (tcp->u_arg[0]) { |
| 318 | #ifdef PR_GET_PDEATHSIG |
| 319 | case PR_GET_PDEATHSIG: |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 320 | if (umove(tcp, tcp->u_arg[1], &i) < 0) |
| 321 | tprintf(", %#lx", tcp->u_arg[1]); |
| 322 | else |
| 323 | tprintf(", {%u}", i); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 324 | break; |
| 325 | #endif |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 326 | #ifdef PR_GET_DUMPABLE |
| 327 | case PR_GET_DUMPABLE: |
| 328 | return RVAL_UDECIMAL; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 329 | #endif |
| 330 | #ifdef PR_GET_UNALIGN |
| 331 | case PR_GET_UNALIGN: |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 332 | if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0) |
| 333 | break; |
| 334 | tcp->auxstr = unalignctl_string(i); |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 335 | return RVAL_STR; |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 336 | #endif |
| 337 | #ifdef PR_GET_KEEPCAPS |
| 338 | case PR_GET_KEEPCAPS: |
| 339 | return RVAL_UDECIMAL; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 340 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 341 | default: |
| 342 | break; |
| 343 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 344 | } |
| 345 | return 0; |
| 346 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 347 | #endif /* HAVE_PRCTL */ |
| 348 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 349 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 350 | sys_sethostname(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 351 | { |
| 352 | if (entering(tcp)) { |
| 353 | printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]); |
| 354 | tprintf(", %lu", tcp->u_arg[1]); |
| 355 | } |
| 356 | return 0; |
| 357 | } |
| 358 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 359 | #if defined(ALPHA) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 360 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 361 | sys_gethostname(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 362 | { |
| 363 | if (exiting(tcp)) { |
| 364 | if (syserror(tcp)) |
| 365 | tprintf("%#lx", tcp->u_arg[0]); |
| 366 | else |
| 367 | printpath(tcp, tcp->u_arg[0]); |
| 368 | tprintf(", %lu", tcp->u_arg[1]); |
| 369 | } |
| 370 | return 0; |
| 371 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 372 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 373 | |
| 374 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 375 | sys_setdomainname(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 376 | { |
| 377 | if (entering(tcp)) { |
| 378 | printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]); |
| 379 | tprintf(", %lu", tcp->u_arg[1]); |
| 380 | } |
| 381 | return 0; |
| 382 | } |
| 383 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 384 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 385 | sys_exit(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 386 | { |
| 387 | if (exiting(tcp)) { |
| 388 | fprintf(stderr, "_exit returned!\n"); |
| 389 | return -1; |
| 390 | } |
| 391 | /* special case: we stop tracing this process, finish line now */ |
| 392 | tprintf("%ld) ", tcp->u_arg[0]); |
Denys Vlasenko | 102ec49 | 2011-08-25 01:27:59 +0200 | [diff] [blame] | 393 | tabto(); |
Denys Vlasenko | 000b601 | 2012-01-28 01:25:03 +0100 | [diff] [blame] | 394 | tprints("= ?\n"); |
| 395 | printing_tcp = NULL; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 396 | return 0; |
| 397 | } |
| 398 | |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 399 | /* defines copied from linux/sched.h since we can't include that |
| 400 | * ourselves (it conflicts with *lots* of libc includes) |
| 401 | */ |
| 402 | #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ |
| 403 | #define CLONE_VM 0x00000100 /* set if VM shared between processes */ |
| 404 | #define CLONE_FS 0x00000200 /* set if fs info shared between processes */ |
| 405 | #define CLONE_FILES 0x00000400 /* set if open files shared between processes */ |
| 406 | #define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */ |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 407 | #define CLONE_IDLETASK 0x00001000 /* kernel-only flag */ |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 408 | #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */ |
| 409 | #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ |
| 410 | #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */ |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 411 | #define CLONE_THREAD 0x00010000 /* Same thread group? */ |
| 412 | #define CLONE_NEWNS 0x00020000 /* New namespace group? */ |
| 413 | #define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */ |
| 414 | #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */ |
| 415 | #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */ |
| 416 | #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */ |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 417 | #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */ |
| 418 | #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */ |
Dmitry V. Levin | e3d4b68 | 2010-12-03 17:19:51 +0000 | [diff] [blame] | 419 | #define CLONE_STOPPED 0x02000000 /* Start in stopped state */ |
| 420 | #define CLONE_NEWUTS 0x04000000 /* New utsname group? */ |
| 421 | #define CLONE_NEWIPC 0x08000000 /* New ipcs */ |
| 422 | #define CLONE_NEWUSER 0x10000000 /* New user namespace */ |
| 423 | #define CLONE_NEWPID 0x20000000 /* New pid namespace */ |
| 424 | #define CLONE_NEWNET 0x40000000 /* New network namespace */ |
| 425 | #define CLONE_IO 0x80000000 /* Clone io context */ |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 426 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 427 | static const struct xlat clone_flags[] = { |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 428 | { CLONE_VM, "CLONE_VM" }, |
| 429 | { CLONE_FS, "CLONE_FS" }, |
| 430 | { CLONE_FILES, "CLONE_FILES" }, |
| 431 | { CLONE_SIGHAND, "CLONE_SIGHAND" }, |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 432 | { CLONE_IDLETASK, "CLONE_IDLETASK"}, |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 433 | { CLONE_PTRACE, "CLONE_PTRACE" }, |
| 434 | { CLONE_VFORK, "CLONE_VFORK" }, |
| 435 | { CLONE_PARENT, "CLONE_PARENT" }, |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 436 | { CLONE_THREAD, "CLONE_THREAD" }, |
| 437 | { CLONE_NEWNS, "CLONE_NEWNS" }, |
| 438 | { CLONE_SYSVSEM, "CLONE_SYSVSEM" }, |
| 439 | { CLONE_SETTLS, "CLONE_SETTLS" }, |
| 440 | { CLONE_PARENT_SETTID,"CLONE_PARENT_SETTID" }, |
| 441 | { CLONE_CHILD_CLEARTID,"CLONE_CHILD_CLEARTID" }, |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 442 | { CLONE_UNTRACED, "CLONE_UNTRACED" }, |
| 443 | { CLONE_CHILD_SETTID,"CLONE_CHILD_SETTID" }, |
Dmitry V. Levin | e3d4b68 | 2010-12-03 17:19:51 +0000 | [diff] [blame] | 444 | { CLONE_STOPPED, "CLONE_STOPPED" }, |
| 445 | { CLONE_NEWUTS, "CLONE_NEWUTS" }, |
| 446 | { CLONE_NEWIPC, "CLONE_NEWIPC" }, |
| 447 | { CLONE_NEWUSER, "CLONE_NEWUSER" }, |
| 448 | { CLONE_NEWPID, "CLONE_NEWPID" }, |
| 449 | { CLONE_NEWNET, "CLONE_NEWNET" }, |
| 450 | { CLONE_IO, "CLONE_IO" }, |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 451 | { 0, NULL }, |
| 452 | }; |
| 453 | |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 454 | # ifdef I386 |
| 455 | # include <asm/ldt.h> |
Roland McGrath | 7decfb2 | 2004-03-01 22:10:52 +0000 | [diff] [blame] | 456 | # ifdef HAVE_STRUCT_USER_DESC |
| 457 | # define modify_ldt_ldt_s user_desc |
| 458 | # endif |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 459 | extern void print_ldt_entry(); |
| 460 | # endif |
| 461 | |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 462 | # if defined IA64 |
| 463 | # define ARG_FLAGS 0 |
| 464 | # define ARG_STACK 1 |
Dmitry V. Levin | 44824b9 | 2012-02-20 21:44:53 +0000 | [diff] [blame] | 465 | # define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1) |
| 466 | # define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2) |
| 467 | # define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3) |
| 468 | # define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4) |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 469 | # elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32 |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 470 | # define ARG_STACK 0 |
| 471 | # define ARG_FLAGS 1 |
| 472 | # define ARG_PTID 2 |
Roland McGrath | fe5fdb2 | 2003-05-23 00:29:05 +0000 | [diff] [blame] | 473 | # define ARG_CTID 3 |
| 474 | # define ARG_TLS 4 |
Roland McGrath | 9c555e7 | 2003-07-09 09:47:59 +0000 | [diff] [blame] | 475 | # elif defined X86_64 || defined ALPHA |
Roland McGrath | 361aac5 | 2003-03-18 07:43:42 +0000 | [diff] [blame] | 476 | # define ARG_FLAGS 0 |
| 477 | # define ARG_STACK 1 |
| 478 | # define ARG_PTID 2 |
| 479 | # define ARG_CTID 3 |
| 480 | # define ARG_TLS 4 |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 481 | # else |
| 482 | # define ARG_FLAGS 0 |
| 483 | # define ARG_STACK 1 |
| 484 | # define ARG_PTID 2 |
| 485 | # define ARG_TLS 3 |
| 486 | # define ARG_CTID 4 |
| 487 | # endif |
| 488 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 489 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 490 | sys_clone(struct tcb *tcp) |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 491 | { |
| 492 | if (exiting(tcp)) { |
Wang Chao | cbdd190 | 2010-09-02 15:08:59 +0800 | [diff] [blame] | 493 | const char *sep = "|"; |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 494 | unsigned long flags = tcp->u_arg[ARG_FLAGS]; |
| 495 | tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]); |
| 496 | # ifdef ARG_STACKSIZE |
| 497 | if (ARG_STACKSIZE != -1) |
| 498 | tprintf("stack_size=%#lx, ", |
| 499 | tcp->u_arg[ARG_STACKSIZE]); |
Roland McGrath | b4968be | 2003-01-20 09:04:33 +0000 | [diff] [blame] | 500 | # endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 501 | tprints("flags="); |
Wang Chao | cbdd190 | 2010-09-02 15:08:59 +0800 | [diff] [blame] | 502 | if (!printflags(clone_flags, flags &~ CSIGNAL, NULL)) |
| 503 | sep = ""; |
Roland McGrath | 984154d | 2003-05-23 01:08:42 +0000 | [diff] [blame] | 504 | if ((flags & CSIGNAL) != 0) |
Wang Chao | cbdd190 | 2010-09-02 15:08:59 +0800 | [diff] [blame] | 505 | tprintf("%s%s", sep, signame(flags & CSIGNAL)); |
Roland McGrath | b4968be | 2003-01-20 09:04:33 +0000 | [diff] [blame] | 506 | if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 507 | |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0) |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 508 | return 0; |
Roland McGrath | 6f67a98 | 2003-03-21 07:33:15 +0000 | [diff] [blame] | 509 | if (flags & CLONE_PARENT_SETTID) |
| 510 | tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]); |
Roland McGrath | b4968be | 2003-01-20 09:04:33 +0000 | [diff] [blame] | 511 | if (flags & CLONE_SETTLS) { |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 512 | # ifdef I386 |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 513 | struct modify_ldt_ldt_s copy; |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 514 | if (umove(tcp, tcp->u_arg[ARG_TLS], ©) != -1) { |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 515 | tprintf(", {entry_number:%d, ", |
| 516 | copy.entry_number); |
| 517 | if (!verbose(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 518 | tprints("...}"); |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 519 | else |
| 520 | print_ldt_entry(©); |
| 521 | } |
| 522 | else |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 523 | # endif |
Roland McGrath | 43f2c84 | 2003-03-12 09:58:14 +0000 | [diff] [blame] | 524 | tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]); |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 525 | } |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 526 | if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID)) |
| 527 | tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 528 | } |
| 529 | return 0; |
| 530 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 531 | |
| 532 | int |
| 533 | sys_unshare(struct tcb *tcp) |
| 534 | { |
| 535 | if (entering(tcp)) |
| 536 | printflags(clone_flags, tcp->u_arg[0], "CLONE_???"); |
| 537 | return 0; |
| 538 | } |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 539 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 540 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 541 | sys_fork(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 542 | { |
| 543 | if (exiting(tcp)) |
| 544 | return RVAL_UDECIMAL; |
| 545 | return 0; |
| 546 | } |
| 547 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 548 | int |
Denys Vlasenko | 418d66a | 2009-01-17 01:52:54 +0000 | [diff] [blame] | 549 | change_syscall(struct tcb *tcp, int new) |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 550 | { |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 551 | #if defined(I386) |
| 552 | /* Attempt to make vfork into fork, which we can follow. */ |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 553 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0) |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 554 | return -1; |
| 555 | return 0; |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 556 | #elif defined(X86_64) |
| 557 | /* Attempt to make vfork into fork, which we can follow. */ |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 558 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_RAX * 8), new) < 0) |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 559 | return -1; |
| 560 | return 0; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 561 | #elif defined(POWERPC) |
Roland McGrath | eb28535 | 2003-01-14 09:59:00 +0000 | [diff] [blame] | 562 | if (ptrace(PTRACE_POKEUSER, tcp->pid, |
| 563 | (char*)(sizeof(unsigned long)*PT_R0), new) < 0) |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 564 | return -1; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 565 | return 0; |
Michal Ludvig | 10a88d0 | 2002-10-07 14:31:00 +0000 | [diff] [blame] | 566 | #elif defined(S390) || defined(S390X) |
| 567 | /* s390 linux after 2.4.7 has a hook in entry.S to allow this */ |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 568 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR2), new) < 0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 569 | return -1; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 570 | return 0; |
| 571 | #elif defined(M68K) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 572 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_ORIG_D0), new) < 0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 573 | return -1; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 574 | return 0; |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 575 | #elif defined(SPARC) || defined(SPARC64) |
Mike Frysinger | 8566c50 | 2009-10-12 11:05:14 -0400 | [diff] [blame] | 576 | struct pt_regs regs; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 577 | if (ptrace(PTRACE_GETREGS, tcp->pid, (char*)®s, 0) < 0) |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 578 | return -1; |
Mike Frysinger | 8566c50 | 2009-10-12 11:05:14 -0400 | [diff] [blame] | 579 | regs.u_regs[U_REG_G1] = new; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 580 | if (ptrace(PTRACE_SETREGS, tcp->pid, (char*)®s, 0) < 0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 581 | return -1; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 582 | return 0; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 583 | #elif defined(MIPS) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 584 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new) < 0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 585 | return -1; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 586 | return 0; |
| 587 | #elif defined(ALPHA) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 588 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new) < 0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 589 | return -1; |
| 590 | return 0; |
| 591 | #elif defined(AVR32) |
| 592 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_R8), new) < 0) |
| 593 | return -1; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 594 | return 0; |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 595 | #elif defined(BFIN) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 596 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_P0), new) < 0) |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 597 | return -1; |
| 598 | return 0; |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 599 | #elif defined(IA64) |
Roland McGrath | 08267b8 | 2004-02-20 22:56:43 +0000 | [diff] [blame] | 600 | if (ia32) { |
| 601 | switch (new) { |
Denys Vlasenko | 418d66a | 2009-01-17 01:52:54 +0000 | [diff] [blame] | 602 | case 2: |
| 603 | break; /* x86 SYS_fork */ |
| 604 | case SYS_clone: |
| 605 | new = 120; |
| 606 | break; |
| 607 | default: |
Roland McGrath | 08267b8 | 2004-02-20 22:56:43 +0000 | [diff] [blame] | 608 | fprintf(stderr, "%s: unexpected syscall %d\n", |
| 609 | __FUNCTION__, new); |
| 610 | return -1; |
| 611 | } |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 612 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R1), new) < 0) |
Roland McGrath | 08267b8 | 2004-02-20 22:56:43 +0000 | [diff] [blame] | 613 | return -1; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 614 | } else if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R15), new) < 0) |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 615 | return -1; |
| 616 | return 0; |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 617 | #elif defined(HPPA) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 618 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR20), new) < 0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 619 | return -1; |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 620 | return 0; |
Wichert Akkerman | ccef637 | 2002-05-01 16:39:22 +0000 | [diff] [blame] | 621 | #elif defined(SH) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 622 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*(REG_REG0+3)), new) < 0) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 623 | return -1; |
| 624 | return 0; |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 625 | #elif defined(SH64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 626 | /* Top half of reg encodes the no. of args n as 0x1n. |
| 627 | Assume 0 args as kernel never actually checks... */ |
| 628 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_SYSCALL), |
| 629 | 0x100000 | new) < 0) |
| 630 | return -1; |
| 631 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 632 | #elif defined(CRISV10) || defined(CRISV32) |
| 633 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R9), new) < 0) |
| 634 | return -1; |
| 635 | return 0; |
Roland McGrath | f691bd2 | 2006-04-25 07:34:41 +0000 | [diff] [blame] | 636 | #elif defined(ARM) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 637 | /* Some kernels support this, some (pre-2.6.16 or so) don't. */ |
Roland McGrath | f691bd2 | 2006-04-25 07:34:41 +0000 | [diff] [blame] | 638 | # ifndef PTRACE_SET_SYSCALL |
| 639 | # define PTRACE_SET_SYSCALL 23 |
| 640 | # endif |
| 641 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 642 | if (ptrace(PTRACE_SET_SYSCALL, tcp->pid, 0, new & 0xffff) != 0) |
Roland McGrath | f691bd2 | 2006-04-25 07:34:41 +0000 | [diff] [blame] | 643 | return -1; |
| 644 | |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 645 | return 0; |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 646 | #elif defined(TILE) |
| 647 | if (ptrace(PTRACE_POKEUSER, tcp->pid, |
| 648 | (char*)PTREGS_OFFSET_REG(0), |
| 649 | new) != 0) |
| 650 | return -1; |
| 651 | return 0; |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 652 | #elif defined(MICROBLAZE) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 653 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new) < 0) |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 654 | return -1; |
| 655 | return 0; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 656 | #else |
| 657 | #warning Do not know how to handle change_syscall for this architecture |
| 658 | #endif /* architecture */ |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 659 | return -1; |
| 660 | } |
| 661 | |
Wang Chao | ca8ab8d | 2010-11-12 17:26:08 +0800 | [diff] [blame] | 662 | int |
Dmitry V. Levin | 257e157 | 2009-12-26 17:55:24 +0000 | [diff] [blame] | 663 | internal_fork(struct tcb *tcp) |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 664 | { |
Denys Vlasenko | f44cce4 | 2011-06-21 14:34:10 +0200 | [diff] [blame] | 665 | if ((ptrace_setoptions |
Wang Chao | ca8ab8d | 2010-11-12 17:26:08 +0800 | [diff] [blame] | 666 | & (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK)) |
| 667 | == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK)) |
| 668 | return 0; |
| 669 | |
Denys Vlasenko | 65d7c4d | 2011-06-23 21:46:37 +0200 | [diff] [blame] | 670 | if (!followfork) |
| 671 | return 0; |
| 672 | |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 673 | if (entering(tcp)) { |
Wang Chao | e636c85 | 2010-09-16 11:20:56 +0800 | [diff] [blame] | 674 | /* |
Denys Vlasenko | 833fb13 | 2011-08-17 11:30:56 +0200 | [diff] [blame] | 675 | * We won't see the new child if clone is called with |
| 676 | * CLONE_UNTRACED, so we keep the same logic with that option |
| 677 | * and don't trace it. |
Wang Chao | e636c85 | 2010-09-16 11:20:56 +0800 | [diff] [blame] | 678 | */ |
| 679 | if ((sysent[tcp->scno].sys_func == sys_clone) && |
| 680 | (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED)) |
| 681 | return 0; |
Denys Vlasenko | e7c9024 | 2011-06-22 00:09:25 +0200 | [diff] [blame] | 682 | setbpt(tcp); |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 683 | } else { |
Denys Vlasenko | 833fb13 | 2011-08-17 11:30:56 +0200 | [diff] [blame] | 684 | if (tcp->flags & TCB_BPTSET) |
| 685 | clearbpt(tcp); |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 686 | } |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 687 | return 0; |
| 688 | } |
Dmitry V. Levin | 257e157 | 2009-12-26 17:55:24 +0000 | [diff] [blame] | 689 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 690 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 691 | sys_vfork(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 692 | { |
| 693 | if (exiting(tcp)) |
| 694 | return RVAL_UDECIMAL; |
| 695 | return 0; |
| 696 | } |
| 697 | |
Dmitry V. Levin | 50a218d | 2011-01-18 17:36:20 +0000 | [diff] [blame] | 698 | int sys_getuid(struct tcb *tcp) |
| 699 | { |
| 700 | if (exiting(tcp)) |
| 701 | tcp->u_rval = (uid_t) tcp->u_rval; |
| 702 | return RVAL_UDECIMAL; |
| 703 | } |
| 704 | |
| 705 | int sys_setfsuid(struct tcb *tcp) |
| 706 | { |
| 707 | if (entering(tcp)) |
| 708 | tprintf("%u", (uid_t) tcp->u_arg[0]); |
| 709 | else |
| 710 | tcp->u_rval = (uid_t) tcp->u_rval; |
| 711 | return RVAL_UDECIMAL; |
| 712 | } |
| 713 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 714 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 715 | sys_setuid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 716 | { |
| 717 | if (entering(tcp)) { |
| 718 | tprintf("%u", (uid_t) tcp->u_arg[0]); |
| 719 | } |
| 720 | return 0; |
| 721 | } |
| 722 | |
| 723 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 724 | sys_setgid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 725 | { |
| 726 | if (entering(tcp)) { |
| 727 | tprintf("%u", (gid_t) tcp->u_arg[0]); |
| 728 | } |
| 729 | return 0; |
| 730 | } |
| 731 | |
| 732 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 733 | sys_getresuid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 734 | { |
| 735 | if (exiting(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 736 | __kernel_uid_t uid; |
| 737 | if (syserror(tcp)) |
| 738 | tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0], |
| 739 | tcp->u_arg[1], tcp->u_arg[2]); |
| 740 | else { |
| 741 | if (umove(tcp, tcp->u_arg[0], &uid) < 0) |
| 742 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 743 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 744 | tprintf("[%lu], ", (unsigned long) uid); |
Roland McGrath | 9bd6b42 | 2003-02-24 07:13:51 +0000 | [diff] [blame] | 745 | if (umove(tcp, tcp->u_arg[1], &uid) < 0) |
| 746 | tprintf("%#lx, ", tcp->u_arg[1]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 747 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 748 | tprintf("[%lu], ", (unsigned long) uid); |
Roland McGrath | 9bd6b42 | 2003-02-24 07:13:51 +0000 | [diff] [blame] | 749 | if (umove(tcp, tcp->u_arg[2], &uid) < 0) |
| 750 | tprintf("%#lx", tcp->u_arg[2]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 751 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 752 | tprintf("[%lu]", (unsigned long) uid); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 753 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 754 | } |
| 755 | return 0; |
| 756 | } |
| 757 | |
| 758 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 759 | sys_getresgid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 760 | { |
| 761 | if (exiting(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 762 | __kernel_gid_t gid; |
| 763 | if (syserror(tcp)) |
| 764 | tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0], |
| 765 | tcp->u_arg[1], tcp->u_arg[2]); |
| 766 | else { |
| 767 | if (umove(tcp, tcp->u_arg[0], &gid) < 0) |
| 768 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 769 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 770 | tprintf("[%lu], ", (unsigned long) gid); |
Roland McGrath | d245092 | 2003-02-24 10:18:07 +0000 | [diff] [blame] | 771 | if (umove(tcp, tcp->u_arg[1], &gid) < 0) |
| 772 | tprintf("%#lx, ", tcp->u_arg[1]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 773 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 774 | tprintf("[%lu], ", (unsigned long) gid); |
Roland McGrath | d245092 | 2003-02-24 10:18:07 +0000 | [diff] [blame] | 775 | if (umove(tcp, tcp->u_arg[2], &gid) < 0) |
| 776 | tprintf("%#lx", tcp->u_arg[2]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 777 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 778 | tprintf("[%lu]", (unsigned long) gid); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 779 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 780 | } |
| 781 | return 0; |
| 782 | } |
| 783 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 784 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 785 | sys_setreuid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 786 | { |
| 787 | if (entering(tcp)) { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 788 | printuid("", tcp->u_arg[0]); |
| 789 | printuid(", ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 790 | } |
| 791 | return 0; |
| 792 | } |
| 793 | |
| 794 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 795 | sys_setregid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 796 | { |
| 797 | if (entering(tcp)) { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 798 | printuid("", tcp->u_arg[0]); |
| 799 | printuid(", ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 800 | } |
| 801 | return 0; |
| 802 | } |
| 803 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 804 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 805 | sys_setresuid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 806 | { |
| 807 | if (entering(tcp)) { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 808 | printuid("", tcp->u_arg[0]); |
| 809 | printuid(", ", tcp->u_arg[1]); |
| 810 | printuid(", ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 811 | } |
| 812 | return 0; |
| 813 | } |
| 814 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 815 | sys_setresgid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 816 | { |
| 817 | if (entering(tcp)) { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 818 | printuid("", tcp->u_arg[0]); |
| 819 | printuid(", ", tcp->u_arg[1]); |
| 820 | printuid(", ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 821 | } |
| 822 | return 0; |
| 823 | } |
| 824 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 825 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 826 | sys_setgroups(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 827 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 828 | if (entering(tcp)) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 829 | unsigned long len, size, start, cur, end, abbrev_end; |
| 830 | GETGROUPS_T gid; |
| 831 | int failed = 0; |
| 832 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 833 | len = tcp->u_arg[0]; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 834 | tprintf("%lu, ", len); |
| 835 | if (len == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 836 | tprints("[]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 837 | return 0; |
| 838 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 839 | start = tcp->u_arg[1]; |
| 840 | if (start == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 841 | tprints("NULL"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 842 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 843 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 844 | size = len * sizeof(gid); |
| 845 | end = start + size; |
| 846 | if (!verbose(tcp) || size / sizeof(gid) != len || end < start) { |
| 847 | tprintf("%#lx", start); |
| 848 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 849 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 850 | if (abbrev(tcp)) { |
| 851 | abbrev_end = start + max_strlen * sizeof(gid); |
| 852 | if (abbrev_end < start) |
| 853 | abbrev_end = end; |
| 854 | } else { |
| 855 | abbrev_end = end; |
| 856 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 857 | tprints("["); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 858 | for (cur = start; cur < end; cur += sizeof(gid)) { |
| 859 | if (cur > start) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 860 | tprints(", "); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 861 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 862 | tprints("..."); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 863 | break; |
| 864 | } |
| 865 | if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 866 | tprints("?"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 867 | failed = 1; |
| 868 | break; |
| 869 | } |
| 870 | tprintf("%lu", (unsigned long) gid); |
| 871 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 872 | tprints("]"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 873 | if (failed) |
| 874 | tprintf(" %#lx", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 875 | } |
| 876 | return 0; |
| 877 | } |
| 878 | |
| 879 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 880 | sys_getgroups(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 881 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 882 | unsigned long len; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 883 | |
| 884 | if (entering(tcp)) { |
| 885 | len = tcp->u_arg[0]; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 886 | tprintf("%lu, ", len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 887 | } else { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 888 | unsigned long size, start, cur, end, abbrev_end; |
| 889 | GETGROUPS_T gid; |
| 890 | int failed = 0; |
| 891 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 892 | len = tcp->u_rval; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 893 | if (len == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 894 | tprints("[]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 895 | return 0; |
| 896 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 897 | start = tcp->u_arg[1]; |
| 898 | if (start == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 899 | tprints("NULL"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 900 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 901 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 902 | if (tcp->u_arg[0] == 0) { |
| 903 | tprintf("%#lx", start); |
| 904 | return 0; |
| 905 | } |
| 906 | size = len * sizeof(gid); |
| 907 | end = start + size; |
| 908 | if (!verbose(tcp) || tcp->u_arg[0] == 0 || |
| 909 | size / sizeof(gid) != len || end < start) { |
| 910 | tprintf("%#lx", start); |
| 911 | return 0; |
| 912 | } |
| 913 | if (abbrev(tcp)) { |
| 914 | abbrev_end = start + max_strlen * sizeof(gid); |
| 915 | if (abbrev_end < start) |
| 916 | abbrev_end = end; |
| 917 | } else { |
| 918 | abbrev_end = end; |
| 919 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 920 | tprints("["); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 921 | for (cur = start; cur < end; cur += sizeof(gid)) { |
| 922 | if (cur > start) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 923 | tprints(", "); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 924 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 925 | tprints("..."); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 926 | break; |
| 927 | } |
| 928 | if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 929 | tprints("?"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 930 | failed = 1; |
| 931 | break; |
| 932 | } |
| 933 | tprintf("%lu", (unsigned long) gid); |
| 934 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 935 | tprints("]"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 936 | if (failed) |
| 937 | tprintf(" %#lx", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 938 | } |
| 939 | return 0; |
| 940 | } |
| 941 | |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 942 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 943 | sys_setgroups32(struct tcb *tcp) |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 944 | { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 945 | if (entering(tcp)) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 946 | unsigned long len, size, start, cur, end, abbrev_end; |
| 947 | GETGROUPS32_T gid; |
| 948 | int failed = 0; |
| 949 | |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 950 | len = tcp->u_arg[0]; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 951 | tprintf("%lu, ", len); |
| 952 | if (len == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 953 | tprints("[]"); |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 954 | return 0; |
| 955 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 956 | start = tcp->u_arg[1]; |
| 957 | if (start == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 958 | tprints("NULL"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 959 | return 0; |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 960 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 961 | size = len * sizeof(gid); |
| 962 | end = start + size; |
| 963 | if (!verbose(tcp) || size / sizeof(gid) != len || end < start) { |
| 964 | tprintf("%#lx", start); |
| 965 | return 0; |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 966 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 967 | if (abbrev(tcp)) { |
| 968 | abbrev_end = start + max_strlen * sizeof(gid); |
| 969 | if (abbrev_end < start) |
| 970 | abbrev_end = end; |
| 971 | } else { |
| 972 | abbrev_end = end; |
| 973 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 974 | tprints("["); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 975 | for (cur = start; cur < end; cur += sizeof(gid)) { |
| 976 | if (cur > start) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 977 | tprints(", "); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 978 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 979 | tprints("..."); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 980 | break; |
| 981 | } |
| 982 | if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 983 | tprints("?"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 984 | failed = 1; |
| 985 | break; |
| 986 | } |
| 987 | tprintf("%lu", (unsigned long) gid); |
| 988 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 989 | tprints("]"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 990 | if (failed) |
| 991 | tprintf(" %#lx", tcp->u_arg[1]); |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 992 | } |
| 993 | return 0; |
| 994 | } |
| 995 | |
| 996 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 997 | sys_getgroups32(struct tcb *tcp) |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 998 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 999 | unsigned long len; |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1000 | |
| 1001 | if (entering(tcp)) { |
| 1002 | len = tcp->u_arg[0]; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1003 | tprintf("%lu, ", len); |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1004 | } else { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1005 | unsigned long size, start, cur, end, abbrev_end; |
| 1006 | GETGROUPS32_T gid; |
| 1007 | int failed = 0; |
| 1008 | |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1009 | len = tcp->u_rval; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1010 | if (len == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1011 | tprints("[]"); |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1012 | return 0; |
| 1013 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1014 | start = tcp->u_arg[1]; |
| 1015 | if (start == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1016 | tprints("NULL"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1017 | return 0; |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1018 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1019 | size = len * sizeof(gid); |
| 1020 | end = start + size; |
| 1021 | if (!verbose(tcp) || tcp->u_arg[0] == 0 || |
| 1022 | size / sizeof(gid) != len || end < start) { |
| 1023 | tprintf("%#lx", start); |
| 1024 | return 0; |
| 1025 | } |
| 1026 | if (abbrev(tcp)) { |
| 1027 | abbrev_end = start + max_strlen * sizeof(gid); |
| 1028 | if (abbrev_end < start) |
| 1029 | abbrev_end = end; |
| 1030 | } else { |
| 1031 | abbrev_end = end; |
| 1032 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1033 | tprints("["); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1034 | for (cur = start; cur < end; cur += sizeof(gid)) { |
| 1035 | if (cur > start) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1036 | tprints(", "); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1037 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1038 | tprints("..."); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1039 | break; |
| 1040 | } |
| 1041 | if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1042 | tprints("?"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1043 | failed = 1; |
| 1044 | break; |
| 1045 | } |
| 1046 | tprintf("%lu", (unsigned long) gid); |
| 1047 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1048 | tprints("]"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1049 | if (failed) |
| 1050 | tprintf(" %#lx", tcp->u_arg[1]); |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1051 | } |
| 1052 | return 0; |
| 1053 | } |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1054 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1055 | #if defined(ALPHA) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1056 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1057 | sys_setpgrp(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1058 | { |
| 1059 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1060 | tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1061 | } |
| 1062 | return 0; |
| 1063 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1064 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1065 | |
| 1066 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1067 | sys_getpgrp(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1068 | { |
| 1069 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1070 | tprintf("%lu", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1071 | } |
| 1072 | return 0; |
| 1073 | } |
| 1074 | |
| 1075 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1076 | sys_getsid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1077 | { |
| 1078 | if (entering(tcp)) { |
| 1079 | tprintf("%lu", tcp->u_arg[0]); |
| 1080 | } |
| 1081 | return 0; |
| 1082 | } |
| 1083 | |
| 1084 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1085 | sys_setsid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1086 | { |
| 1087 | return 0; |
| 1088 | } |
| 1089 | |
| 1090 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1091 | sys_getpgid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1092 | { |
| 1093 | if (entering(tcp)) { |
| 1094 | tprintf("%lu", tcp->u_arg[0]); |
| 1095 | } |
| 1096 | return 0; |
| 1097 | } |
| 1098 | |
| 1099 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1100 | sys_setpgid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1101 | { |
| 1102 | if (entering(tcp)) { |
| 1103 | tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 1104 | } |
| 1105 | return 0; |
| 1106 | } |
| 1107 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1108 | static void |
Dmitry V. Levin | 30145dd | 2010-09-06 22:08:24 +0000 | [diff] [blame] | 1109 | printargv(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1110 | { |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1111 | union { |
Andreas Schwab | 99c8569 | 2009-08-28 19:36:20 +0200 | [diff] [blame] | 1112 | unsigned int p32; |
| 1113 | unsigned long p64; |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1114 | char data[sizeof(long)]; |
| 1115 | } cp; |
Dmitry V. Levin | 30145dd | 2010-09-06 22:08:24 +0000 | [diff] [blame] | 1116 | const char *sep; |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1117 | int n = 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1118 | |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1119 | cp.p64 = 1; |
| 1120 | for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) { |
| 1121 | if (umoven(tcp, addr, personality_wordsize[current_personality], |
| 1122 | cp.data) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1123 | tprintf("%#lx", addr); |
| 1124 | return; |
| 1125 | } |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1126 | if (personality_wordsize[current_personality] == 4) |
| 1127 | cp.p64 = cp.p32; |
| 1128 | if (cp.p64 == 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1129 | break; |
Denys Vlasenko | 5940e65 | 2011-09-01 09:55:05 +0200 | [diff] [blame] | 1130 | tprints(sep); |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1131 | printstr(tcp, cp.p64, -1); |
| 1132 | addr += personality_wordsize[current_personality]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1133 | } |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1134 | if (cp.p64) |
| 1135 | tprintf("%s...", sep); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1136 | } |
| 1137 | |
| 1138 | static void |
Dmitry V. Levin | 30145dd | 2010-09-06 22:08:24 +0000 | [diff] [blame] | 1139 | printargc(const char *fmt, struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1140 | { |
| 1141 | int count; |
| 1142 | char *cp; |
| 1143 | |
| 1144 | for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) { |
| 1145 | addr += sizeof(char *); |
| 1146 | } |
| 1147 | tprintf(fmt, count, count == 1 ? "" : "s"); |
| 1148 | } |
| 1149 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1150 | #if defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1151 | int |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 1152 | sys_execv(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1153 | { |
| 1154 | if (entering(tcp)) { |
| 1155 | printpath(tcp, tcp->u_arg[0]); |
| 1156 | if (!verbose(tcp)) |
| 1157 | tprintf(", %#lx", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1158 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1159 | tprints(", ["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1160 | printargv(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1161 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1162 | } |
| 1163 | } |
| 1164 | return 0; |
| 1165 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1166 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1167 | |
| 1168 | int |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 1169 | sys_execve(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1170 | { |
| 1171 | if (entering(tcp)) { |
| 1172 | printpath(tcp, tcp->u_arg[0]); |
| 1173 | if (!verbose(tcp)) |
| 1174 | tprintf(", %#lx", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1175 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1176 | tprints(", ["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1177 | printargv(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1178 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1179 | } |
| 1180 | if (!verbose(tcp)) |
| 1181 | tprintf(", %#lx", tcp->u_arg[2]); |
| 1182 | else if (abbrev(tcp)) |
| 1183 | printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]); |
| 1184 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1185 | tprints(", ["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1186 | printargv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1187 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1188 | } |
| 1189 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1190 | return 0; |
| 1191 | } |
| 1192 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1193 | #if defined(TCB_WAITEXECVE) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1194 | int |
Denys Vlasenko | f8bc065 | 2011-05-24 20:30:24 +0200 | [diff] [blame] | 1195 | internal_exec(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1196 | { |
Roland McGrath | fdb097f | 2004-07-12 07:38:55 +0000 | [diff] [blame] | 1197 | if (exiting(tcp) && syserror(tcp)) |
| 1198 | tcp->flags &= ~TCB_WAITEXECVE; |
Denys Vlasenko | f8bc065 | 2011-05-24 20:30:24 +0200 | [diff] [blame] | 1199 | else { |
| 1200 | /* Maybe we have post-execve SIGTRAP suppressed? */ |
Denys Vlasenko | f44cce4 | 2011-06-21 14:34:10 +0200 | [diff] [blame] | 1201 | if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC)) |
Denys Vlasenko | f8bc065 | 2011-05-24 20:30:24 +0200 | [diff] [blame] | 1202 | tcp->flags |= TCB_WAITEXECVE; /* no */ |
| 1203 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1204 | return 0; |
| 1205 | } |
Denys Vlasenko | a794974 | 2011-08-21 17:26:55 +0200 | [diff] [blame] | 1206 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1207 | |
Roland McGrath | 7ec1d35 | 2002-12-17 04:50:44 +0000 | [diff] [blame] | 1208 | #ifndef __WNOTHREAD |
| 1209 | #define __WNOTHREAD 0x20000000 |
| 1210 | #endif |
| 1211 | #ifndef __WALL |
| 1212 | #define __WALL 0x40000000 |
| 1213 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1214 | #ifndef __WCLONE |
Roland McGrath | 7ec1d35 | 2002-12-17 04:50:44 +0000 | [diff] [blame] | 1215 | #define __WCLONE 0x80000000 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1216 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1217 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1218 | static const struct xlat wait4_options[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1219 | { WNOHANG, "WNOHANG" }, |
| 1220 | #ifndef WSTOPPED |
| 1221 | { WUNTRACED, "WUNTRACED" }, |
| 1222 | #endif |
| 1223 | #ifdef WEXITED |
| 1224 | { WEXITED, "WEXITED" }, |
| 1225 | #endif |
| 1226 | #ifdef WTRAPPED |
| 1227 | { WTRAPPED, "WTRAPPED" }, |
| 1228 | #endif |
| 1229 | #ifdef WSTOPPED |
| 1230 | { WSTOPPED, "WSTOPPED" }, |
| 1231 | #endif |
| 1232 | #ifdef WCONTINUED |
| 1233 | { WCONTINUED, "WCONTINUED" }, |
| 1234 | #endif |
| 1235 | #ifdef WNOWAIT |
| 1236 | { WNOWAIT, "WNOWAIT" }, |
| 1237 | #endif |
| 1238 | #ifdef __WCLONE |
| 1239 | { __WCLONE, "__WCLONE" }, |
| 1240 | #endif |
Roland McGrath | 7ec1d35 | 2002-12-17 04:50:44 +0000 | [diff] [blame] | 1241 | #ifdef __WALL |
| 1242 | { __WALL, "__WALL" }, |
| 1243 | #endif |
| 1244 | #ifdef __WNOTHREAD |
| 1245 | { __WNOTHREAD, "__WNOTHREAD" }, |
| 1246 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1247 | { 0, NULL }, |
| 1248 | }; |
| 1249 | |
Roland McGrath | 5e02a57 | 2004-10-19 23:33:47 +0000 | [diff] [blame] | 1250 | #if !defined WCOREFLAG && defined WCOREFLG |
| 1251 | # define WCOREFLAG WCOREFLG |
| 1252 | #endif |
| 1253 | #ifndef WCOREFLAG |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 1254 | # define WCOREFLAG 0x80 |
Roland McGrath | 5e02a57 | 2004-10-19 23:33:47 +0000 | [diff] [blame] | 1255 | #endif |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 1256 | #ifndef WCOREDUMP |
| 1257 | # define WCOREDUMP(status) ((status) & 0200) |
| 1258 | #endif |
| 1259 | |
Roland McGrath | 5e02a57 | 2004-10-19 23:33:47 +0000 | [diff] [blame] | 1260 | #ifndef W_STOPCODE |
| 1261 | #define W_STOPCODE(sig) ((sig) << 8 | 0x7f) |
| 1262 | #endif |
| 1263 | #ifndef W_EXITCODE |
| 1264 | #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) |
| 1265 | #endif |
| 1266 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1267 | static int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1268 | printstatus(int status) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1269 | { |
| 1270 | int exited = 0; |
| 1271 | |
| 1272 | /* |
| 1273 | * Here is a tricky presentation problem. This solution |
| 1274 | * is still not entirely satisfactory but since there |
| 1275 | * are no wait status constructors it will have to do. |
| 1276 | */ |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1277 | if (WIFSTOPPED(status)) { |
| 1278 | tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}", |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 1279 | signame(WSTOPSIG(status))); |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1280 | status &= ~W_STOPCODE(WSTOPSIG(status)); |
| 1281 | } |
| 1282 | else if (WIFSIGNALED(status)) { |
| 1283 | tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}", |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 1284 | signame(WTERMSIG(status)), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1285 | WCOREDUMP(status) ? " && WCOREDUMP(s)" : ""); |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1286 | status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG); |
| 1287 | } |
| 1288 | else if (WIFEXITED(status)) { |
| 1289 | tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}", |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1290 | WEXITSTATUS(status)); |
| 1291 | exited = 1; |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1292 | status &= ~W_EXITCODE(WEXITSTATUS(status), 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1293 | } |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1294 | else { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1295 | tprintf("[%#x]", status); |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1296 | return 0; |
| 1297 | } |
| 1298 | |
| 1299 | if (status == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1300 | tprints("]"); |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1301 | else |
Roland McGrath | f8cc83c | 2004-06-04 01:24:07 +0000 | [diff] [blame] | 1302 | tprintf(" | %#x]", status); |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1303 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1304 | return exited; |
| 1305 | } |
| 1306 | |
| 1307 | static int |
Denys Vlasenko | 59432db | 2009-01-26 19:09:35 +0000 | [diff] [blame] | 1308 | printwaitn(struct tcb *tcp, int n, int bitness) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1309 | { |
| 1310 | int status; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1311 | |
| 1312 | if (entering(tcp)) { |
Denys Vlasenko | e740fd3 | 2009-04-16 12:06:16 +0000 | [diff] [blame] | 1313 | /* On Linux, kernel-side pid_t is typedef'ed to int |
| 1314 | * on all arches. Also, glibc-2.8 truncates wait3 and wait4 |
Denys Vlasenko | 59432db | 2009-01-26 19:09:35 +0000 | [diff] [blame] | 1315 | * pid argument to int on 64bit arches, producing, |
| 1316 | * for example, wait4(4294967295, ...) instead of -1 |
Denys Vlasenko | e740fd3 | 2009-04-16 12:06:16 +0000 | [diff] [blame] | 1317 | * in strace. We have to use int here, not long. |
| 1318 | */ |
| 1319 | int pid = tcp->u_arg[0]; |
| 1320 | tprintf("%d, ", pid); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1321 | } else { |
| 1322 | /* status */ |
| 1323 | if (!tcp->u_arg[1]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1324 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1325 | else if (syserror(tcp) || tcp->u_rval == 0) |
| 1326 | tprintf("%#lx", tcp->u_arg[1]); |
| 1327 | else if (umove(tcp, tcp->u_arg[1], &status) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1328 | tprints("[?]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1329 | else |
Dmitry V. Levin | d9a4b0a | 2011-02-23 00:27:12 +0000 | [diff] [blame] | 1330 | printstatus(status); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1331 | /* options */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1332 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1333 | printflags(wait4_options, tcp->u_arg[2], "W???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1334 | if (n == 4) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1335 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1336 | /* usage */ |
| 1337 | if (!tcp->u_arg[3]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1338 | tprints("NULL"); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1339 | else if (tcp->u_rval > 0) { |
Denys Vlasenko | 59432db | 2009-01-26 19:09:35 +0000 | [diff] [blame] | 1340 | #ifdef ALPHA |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1341 | if (bitness) |
| 1342 | printrusage32(tcp, tcp->u_arg[3]); |
| 1343 | else |
| 1344 | #endif |
| 1345 | printrusage(tcp, tcp->u_arg[3]); |
| 1346 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1347 | else |
| 1348 | tprintf("%#lx", tcp->u_arg[3]); |
| 1349 | } |
| 1350 | } |
| 1351 | return 0; |
| 1352 | } |
| 1353 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1354 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1355 | sys_waitpid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1356 | { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1357 | return printwaitn(tcp, 3, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1358 | } |
| 1359 | |
| 1360 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1361 | sys_wait4(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1362 | { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1363 | return printwaitn(tcp, 4, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1364 | } |
| 1365 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1366 | #ifdef ALPHA |
| 1367 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1368 | sys_osf_wait4(struct tcb *tcp) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1369 | { |
| 1370 | return printwaitn(tcp, 4, 1); |
| 1371 | } |
| 1372 | #endif |
| 1373 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1374 | static const struct xlat waitid_types[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1375 | { P_PID, "P_PID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 1376 | #ifdef P_PPID |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1377 | { P_PPID, "P_PPID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 1378 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1379 | { P_PGID, "P_PGID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 1380 | #ifdef P_SID |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1381 | { P_SID, "P_SID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 1382 | #endif |
| 1383 | #ifdef P_CID |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1384 | { P_CID, "P_CID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 1385 | #endif |
| 1386 | #ifdef P_UID |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1387 | { P_UID, "P_UID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 1388 | #endif |
| 1389 | #ifdef P_GID |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1390 | { P_GID, "P_GID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 1391 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1392 | { P_ALL, "P_ALL" }, |
| 1393 | #ifdef P_LWPID |
| 1394 | { P_LWPID, "P_LWPID" }, |
| 1395 | #endif |
| 1396 | { 0, NULL }, |
| 1397 | }; |
| 1398 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1399 | int |
Dmitry V. Levin | 3eb9491 | 2010-09-09 23:08:59 +0000 | [diff] [blame] | 1400 | sys_waitid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1401 | { |
| 1402 | siginfo_t si; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1403 | |
| 1404 | if (entering(tcp)) { |
| 1405 | printxval(waitid_types, tcp->u_arg[0], "P_???"); |
| 1406 | tprintf(", %ld, ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1407 | } |
| 1408 | else { |
| 1409 | /* siginfo */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1410 | if (!tcp->u_arg[2]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1411 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1412 | else if (syserror(tcp)) |
| 1413 | tprintf("%#lx", tcp->u_arg[2]); |
| 1414 | else if (umove(tcp, tcp->u_arg[2], &si) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1415 | tprints("{???}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1416 | else |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1417 | printsiginfo(&si, verbose(tcp)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1418 | /* options */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1419 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1420 | printflags(wait4_options, tcp->u_arg[3], "W???"); |
Roland McGrath | 39426a3 | 2004-10-06 22:02:59 +0000 | [diff] [blame] | 1421 | if (tcp->u_nargs > 4) { |
| 1422 | /* usage */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1423 | tprints(", "); |
Roland McGrath | 39426a3 | 2004-10-06 22:02:59 +0000 | [diff] [blame] | 1424 | if (!tcp->u_arg[4]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1425 | tprints("NULL"); |
Roland McGrath | 39426a3 | 2004-10-06 22:02:59 +0000 | [diff] [blame] | 1426 | else if (tcp->u_error) |
| 1427 | tprintf("%#lx", tcp->u_arg[4]); |
| 1428 | else |
| 1429 | printrusage(tcp, tcp->u_arg[4]); |
| 1430 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1431 | } |
| 1432 | return 0; |
| 1433 | } |
| 1434 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1435 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1436 | sys_alarm(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1437 | { |
| 1438 | if (entering(tcp)) |
| 1439 | tprintf("%lu", tcp->u_arg[0]); |
| 1440 | return 0; |
| 1441 | } |
| 1442 | |
| 1443 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1444 | sys_uname(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1445 | { |
| 1446 | struct utsname uname; |
| 1447 | |
| 1448 | if (exiting(tcp)) { |
| 1449 | if (syserror(tcp) || !verbose(tcp)) |
| 1450 | tprintf("%#lx", tcp->u_arg[0]); |
| 1451 | else if (umove(tcp, tcp->u_arg[0], &uname) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1452 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1453 | else if (!abbrev(tcp)) { |
| 1454 | |
| 1455 | tprintf("{sysname=\"%s\", nodename=\"%s\", ", |
| 1456 | uname.sysname, uname.nodename); |
| 1457 | tprintf("release=\"%s\", version=\"%s\", ", |
| 1458 | uname.release, uname.version); |
| 1459 | tprintf("machine=\"%s\"", uname.machine); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1460 | #ifndef __GLIBC__ |
| 1461 | tprintf(", domainname=\"%s\"", uname.domainname); |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1462 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1463 | tprints("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1464 | } |
| 1465 | else |
| 1466 | tprintf("{sys=\"%s\", node=\"%s\", ...}", |
| 1467 | uname.sysname, uname.nodename); |
| 1468 | } |
| 1469 | return 0; |
| 1470 | } |
| 1471 | |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 1472 | static const struct xlat ptrace_cmds[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1473 | { PTRACE_TRACEME, "PTRACE_TRACEME" }, |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1474 | { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" }, |
| 1475 | { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" }, |
| 1476 | { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" }, |
| 1477 | { PTRACE_POKETEXT, "PTRACE_POKETEXT" }, |
| 1478 | { PTRACE_POKEDATA, "PTRACE_POKEDATA" }, |
| 1479 | { PTRACE_POKEUSER, "PTRACE_POKEUSER" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1480 | { PTRACE_CONT, "PTRACE_CONT" }, |
| 1481 | { PTRACE_KILL, "PTRACE_KILL" }, |
| 1482 | { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" }, |
| 1483 | { PTRACE_ATTACH, "PTRACE_ATTACH" }, |
| 1484 | { PTRACE_DETACH, "PTRACE_DETACH" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1485 | # ifdef PTRACE_GETREGS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1486 | { PTRACE_GETREGS, "PTRACE_GETREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1487 | # endif |
| 1488 | # ifdef PTRACE_SETREGS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1489 | { PTRACE_SETREGS, "PTRACE_SETREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1490 | # endif |
| 1491 | # ifdef PTRACE_GETFPREGS |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1492 | { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1493 | # endif |
| 1494 | # ifdef PTRACE_SETFPREGS |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1495 | { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1496 | # endif |
| 1497 | # ifdef PTRACE_GETFPXREGS |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1498 | { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1499 | # endif |
| 1500 | # ifdef PTRACE_SETFPXREGS |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1501 | { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1502 | # endif |
| 1503 | # ifdef PTRACE_GETVRREGS |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1504 | { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1505 | # endif |
| 1506 | # ifdef PTRACE_SETVRREGS |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1507 | { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1508 | # endif |
| 1509 | # ifdef PTRACE_SETOPTIONS |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1510 | { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1511 | # endif |
| 1512 | # ifdef PTRACE_GETEVENTMSG |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1513 | { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1514 | # endif |
| 1515 | # ifdef PTRACE_GETSIGINFO |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1516 | { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1517 | # endif |
| 1518 | # ifdef PTRACE_SETSIGINFO |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1519 | { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1520 | # endif |
Dmitry V. Levin | bb668a5 | 2011-03-14 21:58:59 +0000 | [diff] [blame] | 1521 | # ifdef PTRACE_GETREGSET |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1522 | { PTRACE_GETREGSET, "PTRACE_GETREGSET" }, |
Dmitry V. Levin | bb668a5 | 2011-03-14 21:58:59 +0000 | [diff] [blame] | 1523 | # endif |
| 1524 | # ifdef PTRACE_SETREGSET |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1525 | { PTRACE_SETREGSET, "PTRACE_SETREGSET" }, |
Dmitry V. Levin | bb668a5 | 2011-03-14 21:58:59 +0000 | [diff] [blame] | 1526 | # endif |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1527 | # ifdef PTRACE_SET_SYSCALL |
Denys Vlasenko | 61526c6 | 2011-08-25 10:21:13 +0200 | [diff] [blame] | 1528 | { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1529 | # endif |
Denys Vlasenko | 31fa8a2 | 2012-01-29 02:01:44 +0100 | [diff] [blame] | 1530 | # ifdef PTRACE_SEIZE |
| 1531 | { PTRACE_SEIZE, "PTRACE_SEIZE" }, |
| 1532 | # endif |
| 1533 | # ifdef PTRACE_INTERRUPT |
| 1534 | { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" }, |
| 1535 | # endif |
| 1536 | # ifdef PTRACE_LISTEN |
| 1537 | { PTRACE_LISTEN, "PTRACE_LISTEN" }, |
| 1538 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1539 | { PTRACE_SYSCALL, "PTRACE_SYSCALL" }, |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1540 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1541 | { 0, NULL }, |
| 1542 | }; |
| 1543 | |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1544 | # ifdef PTRACE_SETOPTIONS |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1545 | static const struct xlat ptrace_setoptions_flags[] = { |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1546 | # ifdef PTRACE_O_TRACESYSGOOD |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1547 | { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1548 | # endif |
| 1549 | # ifdef PTRACE_O_TRACEFORK |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1550 | { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1551 | # endif |
| 1552 | # ifdef PTRACE_O_TRACEVFORK |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1553 | { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1554 | # endif |
| 1555 | # ifdef PTRACE_O_TRACECLONE |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1556 | { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1557 | # endif |
| 1558 | # ifdef PTRACE_O_TRACEEXEC |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1559 | { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1560 | # endif |
| 1561 | # ifdef PTRACE_O_TRACEVFORKDONE |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1562 | { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"}, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1563 | # endif |
| 1564 | # ifdef PTRACE_O_TRACEEXIT |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1565 | { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1566 | # endif |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1567 | { 0, NULL }, |
| 1568 | }; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1569 | # endif /* PTRACE_SETOPTIONS */ |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 1570 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1571 | const struct xlat struct_user_offsets[] = { |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1572 | # if defined(S390) || defined(S390X) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 1573 | { PT_PSWMASK, "psw_mask" }, |
| 1574 | { PT_PSWADDR, "psw_addr" }, |
| 1575 | { PT_GPR0, "gpr0" }, |
| 1576 | { PT_GPR1, "gpr1" }, |
| 1577 | { PT_GPR2, "gpr2" }, |
| 1578 | { PT_GPR3, "gpr3" }, |
| 1579 | { PT_GPR4, "gpr4" }, |
| 1580 | { PT_GPR5, "gpr5" }, |
| 1581 | { PT_GPR6, "gpr6" }, |
| 1582 | { PT_GPR7, "gpr7" }, |
| 1583 | { PT_GPR8, "gpr8" }, |
| 1584 | { PT_GPR9, "gpr9" }, |
| 1585 | { PT_GPR10, "gpr10" }, |
| 1586 | { PT_GPR11, "gpr11" }, |
| 1587 | { PT_GPR12, "gpr12" }, |
| 1588 | { PT_GPR13, "gpr13" }, |
| 1589 | { PT_GPR14, "gpr14" }, |
| 1590 | { PT_GPR15, "gpr15" }, |
| 1591 | { PT_ACR0, "acr0" }, |
| 1592 | { PT_ACR1, "acr1" }, |
| 1593 | { PT_ACR2, "acr2" }, |
| 1594 | { PT_ACR3, "acr3" }, |
| 1595 | { PT_ACR4, "acr4" }, |
| 1596 | { PT_ACR5, "acr5" }, |
| 1597 | { PT_ACR6, "acr6" }, |
| 1598 | { PT_ACR7, "acr7" }, |
| 1599 | { PT_ACR8, "acr8" }, |
| 1600 | { PT_ACR9, "acr9" }, |
| 1601 | { PT_ACR10, "acr10" }, |
| 1602 | { PT_ACR11, "acr11" }, |
| 1603 | { PT_ACR12, "acr12" }, |
| 1604 | { PT_ACR13, "acr13" }, |
| 1605 | { PT_ACR14, "acr14" }, |
| 1606 | { PT_ACR15, "acr15" }, |
| 1607 | { PT_ORIGGPR2, "orig_gpr2" }, |
| 1608 | { PT_FPC, "fpc" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1609 | # if defined(S390) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 1610 | { PT_FPR0_HI, "fpr0.hi" }, |
| 1611 | { PT_FPR0_LO, "fpr0.lo" }, |
| 1612 | { PT_FPR1_HI, "fpr1.hi" }, |
| 1613 | { PT_FPR1_LO, "fpr1.lo" }, |
| 1614 | { PT_FPR2_HI, "fpr2.hi" }, |
| 1615 | { PT_FPR2_LO, "fpr2.lo" }, |
| 1616 | { PT_FPR3_HI, "fpr3.hi" }, |
| 1617 | { PT_FPR3_LO, "fpr3.lo" }, |
| 1618 | { PT_FPR4_HI, "fpr4.hi" }, |
| 1619 | { PT_FPR4_LO, "fpr4.lo" }, |
| 1620 | { PT_FPR5_HI, "fpr5.hi" }, |
| 1621 | { PT_FPR5_LO, "fpr5.lo" }, |
| 1622 | { PT_FPR6_HI, "fpr6.hi" }, |
| 1623 | { PT_FPR6_LO, "fpr6.lo" }, |
| 1624 | { PT_FPR7_HI, "fpr7.hi" }, |
| 1625 | { PT_FPR7_LO, "fpr7.lo" }, |
| 1626 | { PT_FPR8_HI, "fpr8.hi" }, |
| 1627 | { PT_FPR8_LO, "fpr8.lo" }, |
| 1628 | { PT_FPR9_HI, "fpr9.hi" }, |
| 1629 | { PT_FPR9_LO, "fpr9.lo" }, |
| 1630 | { PT_FPR10_HI, "fpr10.hi" }, |
| 1631 | { PT_FPR10_LO, "fpr10.lo" }, |
| 1632 | { PT_FPR11_HI, "fpr11.hi" }, |
| 1633 | { PT_FPR11_LO, "fpr11.lo" }, |
| 1634 | { PT_FPR12_HI, "fpr12.hi" }, |
| 1635 | { PT_FPR12_LO, "fpr12.lo" }, |
| 1636 | { PT_FPR13_HI, "fpr13.hi" }, |
| 1637 | { PT_FPR13_LO, "fpr13.lo" }, |
| 1638 | { PT_FPR14_HI, "fpr14.hi" }, |
| 1639 | { PT_FPR14_LO, "fpr14.lo" }, |
| 1640 | { PT_FPR15_HI, "fpr15.hi" }, |
| 1641 | { PT_FPR15_LO, "fpr15.lo" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1642 | # endif |
| 1643 | # if defined(S390X) |
Michal Ludvig | 10a88d0 | 2002-10-07 14:31:00 +0000 | [diff] [blame] | 1644 | { PT_FPR0, "fpr0" }, |
| 1645 | { PT_FPR1, "fpr1" }, |
| 1646 | { PT_FPR2, "fpr2" }, |
| 1647 | { PT_FPR3, "fpr3" }, |
| 1648 | { PT_FPR4, "fpr4" }, |
| 1649 | { PT_FPR5, "fpr5" }, |
| 1650 | { PT_FPR6, "fpr6" }, |
| 1651 | { PT_FPR7, "fpr7" }, |
| 1652 | { PT_FPR8, "fpr8" }, |
| 1653 | { PT_FPR9, "fpr9" }, |
| 1654 | { PT_FPR10, "fpr10" }, |
| 1655 | { PT_FPR11, "fpr11" }, |
| 1656 | { PT_FPR12, "fpr12" }, |
| 1657 | { PT_FPR13, "fpr13" }, |
| 1658 | { PT_FPR14, "fpr14" }, |
| 1659 | { PT_FPR15, "fpr15" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1660 | # endif |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 1661 | { PT_CR_9, "cr9" }, |
| 1662 | { PT_CR_10, "cr10" }, |
| 1663 | { PT_CR_11, "cr11" }, |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1664 | { PT_IEEE_IP, "ieee_exception_ip" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1665 | # elif defined(SPARC) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1666 | /* XXX No support for these offsets yet. */ |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1667 | # elif defined(HPPA) |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 1668 | /* XXX No support for these offsets yet. */ |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1669 | # elif defined(POWERPC) |
| 1670 | # ifndef PT_ORIG_R3 |
| 1671 | # define PT_ORIG_R3 34 |
| 1672 | # endif |
| 1673 | # define REGSIZE (sizeof(unsigned long)) |
Roland McGrath | eb28535 | 2003-01-14 09:59:00 +0000 | [diff] [blame] | 1674 | { REGSIZE*PT_R0, "r0" }, |
| 1675 | { REGSIZE*PT_R1, "r1" }, |
| 1676 | { REGSIZE*PT_R2, "r2" }, |
| 1677 | { REGSIZE*PT_R3, "r3" }, |
| 1678 | { REGSIZE*PT_R4, "r4" }, |
| 1679 | { REGSIZE*PT_R5, "r5" }, |
| 1680 | { REGSIZE*PT_R6, "r6" }, |
| 1681 | { REGSIZE*PT_R7, "r7" }, |
| 1682 | { REGSIZE*PT_R8, "r8" }, |
| 1683 | { REGSIZE*PT_R9, "r9" }, |
| 1684 | { REGSIZE*PT_R10, "r10" }, |
| 1685 | { REGSIZE*PT_R11, "r11" }, |
| 1686 | { REGSIZE*PT_R12, "r12" }, |
| 1687 | { REGSIZE*PT_R13, "r13" }, |
| 1688 | { REGSIZE*PT_R14, "r14" }, |
| 1689 | { REGSIZE*PT_R15, "r15" }, |
| 1690 | { REGSIZE*PT_R16, "r16" }, |
| 1691 | { REGSIZE*PT_R17, "r17" }, |
| 1692 | { REGSIZE*PT_R18, "r18" }, |
| 1693 | { REGSIZE*PT_R19, "r19" }, |
| 1694 | { REGSIZE*PT_R20, "r20" }, |
| 1695 | { REGSIZE*PT_R21, "r21" }, |
| 1696 | { REGSIZE*PT_R22, "r22" }, |
| 1697 | { REGSIZE*PT_R23, "r23" }, |
| 1698 | { REGSIZE*PT_R24, "r24" }, |
| 1699 | { REGSIZE*PT_R25, "r25" }, |
| 1700 | { REGSIZE*PT_R26, "r26" }, |
| 1701 | { REGSIZE*PT_R27, "r27" }, |
| 1702 | { REGSIZE*PT_R28, "r28" }, |
| 1703 | { REGSIZE*PT_R29, "r29" }, |
| 1704 | { REGSIZE*PT_R30, "r30" }, |
| 1705 | { REGSIZE*PT_R31, "r31" }, |
| 1706 | { REGSIZE*PT_NIP, "NIP" }, |
| 1707 | { REGSIZE*PT_MSR, "MSR" }, |
| 1708 | { REGSIZE*PT_ORIG_R3, "ORIG_R3" }, |
| 1709 | { REGSIZE*PT_CTR, "CTR" }, |
| 1710 | { REGSIZE*PT_LNK, "LNK" }, |
| 1711 | { REGSIZE*PT_XER, "XER" }, |
| 1712 | { REGSIZE*PT_CCR, "CCR" }, |
| 1713 | { REGSIZE*PT_FPR0, "FPR0" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1714 | # undef REGSIZE |
| 1715 | # elif defined(ALPHA) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 1716 | { 0, "r0" }, |
| 1717 | { 1, "r1" }, |
| 1718 | { 2, "r2" }, |
| 1719 | { 3, "r3" }, |
| 1720 | { 4, "r4" }, |
| 1721 | { 5, "r5" }, |
| 1722 | { 6, "r6" }, |
| 1723 | { 7, "r7" }, |
| 1724 | { 8, "r8" }, |
| 1725 | { 9, "r9" }, |
| 1726 | { 10, "r10" }, |
| 1727 | { 11, "r11" }, |
| 1728 | { 12, "r12" }, |
| 1729 | { 13, "r13" }, |
| 1730 | { 14, "r14" }, |
| 1731 | { 15, "r15" }, |
| 1732 | { 16, "r16" }, |
| 1733 | { 17, "r17" }, |
| 1734 | { 18, "r18" }, |
| 1735 | { 19, "r19" }, |
| 1736 | { 20, "r20" }, |
| 1737 | { 21, "r21" }, |
| 1738 | { 22, "r22" }, |
| 1739 | { 23, "r23" }, |
| 1740 | { 24, "r24" }, |
| 1741 | { 25, "r25" }, |
| 1742 | { 26, "r26" }, |
| 1743 | { 27, "r27" }, |
| 1744 | { 28, "r28" }, |
| 1745 | { 29, "gp" }, |
| 1746 | { 30, "fp" }, |
| 1747 | { 31, "zero" }, |
| 1748 | { 32, "fp0" }, |
| 1749 | { 33, "fp" }, |
| 1750 | { 34, "fp2" }, |
| 1751 | { 35, "fp3" }, |
| 1752 | { 36, "fp4" }, |
| 1753 | { 37, "fp5" }, |
| 1754 | { 38, "fp6" }, |
| 1755 | { 39, "fp7" }, |
| 1756 | { 40, "fp8" }, |
| 1757 | { 41, "fp9" }, |
| 1758 | { 42, "fp10" }, |
| 1759 | { 43, "fp11" }, |
| 1760 | { 44, "fp12" }, |
| 1761 | { 45, "fp13" }, |
| 1762 | { 46, "fp14" }, |
| 1763 | { 47, "fp15" }, |
| 1764 | { 48, "fp16" }, |
| 1765 | { 49, "fp17" }, |
| 1766 | { 50, "fp18" }, |
| 1767 | { 51, "fp19" }, |
| 1768 | { 52, "fp20" }, |
| 1769 | { 53, "fp21" }, |
| 1770 | { 54, "fp22" }, |
| 1771 | { 55, "fp23" }, |
| 1772 | { 56, "fp24" }, |
| 1773 | { 57, "fp25" }, |
| 1774 | { 58, "fp26" }, |
| 1775 | { 59, "fp27" }, |
| 1776 | { 60, "fp28" }, |
| 1777 | { 61, "fp29" }, |
| 1778 | { 62, "fp30" }, |
| 1779 | { 63, "fp31" }, |
| 1780 | { 64, "pc" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1781 | # elif defined(IA64) |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1782 | { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" }, |
| 1783 | { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" }, |
| 1784 | { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" }, |
| 1785 | { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" }, |
| 1786 | { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" }, |
| 1787 | { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" }, |
| 1788 | { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" }, |
| 1789 | { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" }, |
| 1790 | { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" }, |
| 1791 | { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" }, |
| 1792 | { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" }, |
| 1793 | { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" }, |
| 1794 | { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" }, |
| 1795 | { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" }, |
| 1796 | { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" }, |
| 1797 | { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" }, |
| 1798 | { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" }, |
| 1799 | { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" }, |
| 1800 | { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" }, |
| 1801 | { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" }, |
| 1802 | { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" }, |
| 1803 | { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" }, |
| 1804 | { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" }, |
| 1805 | { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" }, |
| 1806 | { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" }, |
| 1807 | { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" }, |
| 1808 | { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" }, |
| 1809 | { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" }, |
| 1810 | { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" }, |
| 1811 | { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" }, |
| 1812 | { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" }, |
| 1813 | { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" }, |
| 1814 | /* switch stack: */ |
| 1815 | { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" }, |
| 1816 | { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" }, |
| 1817 | { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" }, |
| 1818 | { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" }, |
| 1819 | { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" }, |
| 1820 | { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" }, |
| 1821 | { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" }, |
| 1822 | { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" }, |
| 1823 | { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" }, |
| 1824 | { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" }, |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1825 | { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" }, |
| 1826 | { PT_B4, "b4" }, { PT_B5, "b5" }, |
Roland McGrath | ca4e10c | 2004-01-13 10:13:20 +0000 | [diff] [blame] | 1827 | { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" }, |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1828 | /* pt_regs */ |
Roland McGrath | ca4e10c | 2004-01-13 10:13:20 +0000 | [diff] [blame] | 1829 | { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" }, |
| 1830 | { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" }, |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1831 | { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" }, |
| 1832 | { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" }, |
| 1833 | { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" }, |
| 1834 | { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" }, |
| 1835 | { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" }, |
| 1836 | { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" }, |
| 1837 | { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" }, |
| 1838 | { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" }, |
| 1839 | { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" }, |
| 1840 | { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" }, |
| 1841 | { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" }, |
| 1842 | { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" }, |
| 1843 | { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" }, |
| 1844 | { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" }, |
| 1845 | { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1846 | # ifdef PT_AR_CSD |
Roland McGrath | fb1bc07 | 2004-03-01 21:29:24 +0000 | [diff] [blame] | 1847 | { PT_AR_CSD, "ar.csd" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1848 | # endif |
| 1849 | # ifdef PT_AR_SSD |
Roland McGrath | fb1bc07 | 2004-03-01 21:29:24 +0000 | [diff] [blame] | 1850 | { PT_AR_SSD, "ar.ssd" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1851 | # endif |
Roland McGrath | ca4e10c | 2004-01-13 10:13:20 +0000 | [diff] [blame] | 1852 | { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1853 | # elif defined(I386) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1854 | { 4*EBX, "4*EBX" }, |
| 1855 | { 4*ECX, "4*ECX" }, |
| 1856 | { 4*EDX, "4*EDX" }, |
| 1857 | { 4*ESI, "4*ESI" }, |
| 1858 | { 4*EDI, "4*EDI" }, |
| 1859 | { 4*EBP, "4*EBP" }, |
| 1860 | { 4*EAX, "4*EAX" }, |
| 1861 | { 4*DS, "4*DS" }, |
| 1862 | { 4*ES, "4*ES" }, |
| 1863 | { 4*FS, "4*FS" }, |
| 1864 | { 4*GS, "4*GS" }, |
| 1865 | { 4*ORIG_EAX, "4*ORIG_EAX" }, |
| 1866 | { 4*EIP, "4*EIP" }, |
| 1867 | { 4*CS, "4*CS" }, |
| 1868 | { 4*EFL, "4*EFL" }, |
| 1869 | { 4*UESP, "4*UESP" }, |
| 1870 | { 4*SS, "4*SS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1871 | # elif defined(X86_64) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1872 | { 8*R15, "8*R15" }, |
| 1873 | { 8*R14, "8*R14" }, |
| 1874 | { 8*R13, "8*R13" }, |
| 1875 | { 8*R12, "8*R12" }, |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 1876 | { 8*RBP, "8*RBP" }, |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 1877 | { 8*RBX, "8*RBX" }, |
| 1878 | { 8*R11, "8*R11" }, |
| 1879 | { 8*R10, "8*R10" }, |
| 1880 | { 8*R9, "8*R9" }, |
| 1881 | { 8*R8, "8*R8" }, |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 1882 | { 8*RAX, "8*RAX" }, |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 1883 | { 8*RCX, "8*RCX" }, |
| 1884 | { 8*RDX, "8*RDX" }, |
| 1885 | { 8*RSI, "8*RSI" }, |
| 1886 | { 8*RDI, "8*RDI" }, |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 1887 | { 8*ORIG_RAX, "8*ORIG_RAX" }, |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 1888 | { 8*RIP, "8*RIP" }, |
| 1889 | { 8*CS, "8*CS" }, |
| 1890 | { 8*EFLAGS, "8*EFL" }, |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 1891 | { 8*RSP, "8*RSP" }, |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 1892 | { 8*SS, "8*SS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1893 | # elif defined(M68K) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1894 | { 4*PT_D1, "4*PT_D1" }, |
| 1895 | { 4*PT_D2, "4*PT_D2" }, |
| 1896 | { 4*PT_D3, "4*PT_D3" }, |
| 1897 | { 4*PT_D4, "4*PT_D4" }, |
| 1898 | { 4*PT_D5, "4*PT_D5" }, |
| 1899 | { 4*PT_D6, "4*PT_D6" }, |
| 1900 | { 4*PT_D7, "4*PT_D7" }, |
| 1901 | { 4*PT_A0, "4*PT_A0" }, |
| 1902 | { 4*PT_A1, "4*PT_A1" }, |
| 1903 | { 4*PT_A2, "4*PT_A2" }, |
| 1904 | { 4*PT_A3, "4*PT_A3" }, |
| 1905 | { 4*PT_A4, "4*PT_A4" }, |
| 1906 | { 4*PT_A5, "4*PT_A5" }, |
| 1907 | { 4*PT_A6, "4*PT_A6" }, |
| 1908 | { 4*PT_D0, "4*PT_D0" }, |
| 1909 | { 4*PT_USP, "4*PT_USP" }, |
| 1910 | { 4*PT_ORIG_D0, "4*PT_ORIG_D0" }, |
| 1911 | { 4*PT_SR, "4*PT_SR" }, |
| 1912 | { 4*PT_PC, "4*PT_PC" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1913 | # elif defined(SH) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1914 | { 4*REG_REG0, "4*REG_REG0" }, |
| 1915 | { 4*(REG_REG0+1), "4*REG_REG1" }, |
| 1916 | { 4*(REG_REG0+2), "4*REG_REG2" }, |
| 1917 | { 4*(REG_REG0+3), "4*REG_REG3" }, |
| 1918 | { 4*(REG_REG0+4), "4*REG_REG4" }, |
| 1919 | { 4*(REG_REG0+5), "4*REG_REG5" }, |
| 1920 | { 4*(REG_REG0+6), "4*REG_REG6" }, |
| 1921 | { 4*(REG_REG0+7), "4*REG_REG7" }, |
| 1922 | { 4*(REG_REG0+8), "4*REG_REG8" }, |
| 1923 | { 4*(REG_REG0+9), "4*REG_REG9" }, |
| 1924 | { 4*(REG_REG0+10), "4*REG_REG10" }, |
| 1925 | { 4*(REG_REG0+11), "4*REG_REG11" }, |
| 1926 | { 4*(REG_REG0+12), "4*REG_REG12" }, |
| 1927 | { 4*(REG_REG0+13), "4*REG_REG13" }, |
| 1928 | { 4*(REG_REG0+14), "4*REG_REG14" }, |
| 1929 | { 4*REG_REG15, "4*REG_REG15" }, |
| 1930 | { 4*REG_PC, "4*REG_PC" }, |
| 1931 | { 4*REG_PR, "4*REG_PR" }, |
| 1932 | { 4*REG_SR, "4*REG_SR" }, |
| 1933 | { 4*REG_GBR, "4*REG_GBR" }, |
| 1934 | { 4*REG_MACH, "4*REG_MACH" }, |
| 1935 | { 4*REG_MACL, "4*REG_MACL" }, |
| 1936 | { 4*REG_SYSCALL, "4*REG_SYSCALL" }, |
| 1937 | { 4*REG_FPUL, "4*REG_FPUL" }, |
| 1938 | { 4*REG_FPREG0, "4*REG_FPREG0" }, |
| 1939 | { 4*(REG_FPREG0+1), "4*REG_FPREG1" }, |
| 1940 | { 4*(REG_FPREG0+2), "4*REG_FPREG2" }, |
| 1941 | { 4*(REG_FPREG0+3), "4*REG_FPREG3" }, |
| 1942 | { 4*(REG_FPREG0+4), "4*REG_FPREG4" }, |
| 1943 | { 4*(REG_FPREG0+5), "4*REG_FPREG5" }, |
| 1944 | { 4*(REG_FPREG0+6), "4*REG_FPREG6" }, |
| 1945 | { 4*(REG_FPREG0+7), "4*REG_FPREG7" }, |
| 1946 | { 4*(REG_FPREG0+8), "4*REG_FPREG8" }, |
| 1947 | { 4*(REG_FPREG0+9), "4*REG_FPREG9" }, |
| 1948 | { 4*(REG_FPREG0+10), "4*REG_FPREG10" }, |
| 1949 | { 4*(REG_FPREG0+11), "4*REG_FPREG11" }, |
| 1950 | { 4*(REG_FPREG0+12), "4*REG_FPREG12" }, |
| 1951 | { 4*(REG_FPREG0+13), "4*REG_FPREG13" }, |
| 1952 | { 4*(REG_FPREG0+14), "4*REG_FPREG14" }, |
| 1953 | { 4*REG_FPREG15, "4*REG_FPREG15" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1954 | # ifdef REG_XDREG0 |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1955 | { 4*REG_XDREG0, "4*REG_XDREG0" }, |
| 1956 | { 4*(REG_XDREG0+2), "4*REG_XDREG2" }, |
| 1957 | { 4*(REG_XDREG0+4), "4*REG_XDREG4" }, |
| 1958 | { 4*(REG_XDREG0+6), "4*REG_XDREG6" }, |
| 1959 | { 4*(REG_XDREG0+8), "4*REG_XDREG8" }, |
| 1960 | { 4*(REG_XDREG0+10), "4*REG_XDREG10" }, |
| 1961 | { 4*(REG_XDREG0+12), "4*REG_XDREG12" }, |
| 1962 | { 4*REG_XDREG14, "4*REG_XDREG14" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1963 | # endif |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1964 | { 4*REG_FPSCR, "4*REG_FPSCR" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 1965 | # elif defined(SH64) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1966 | { 0, "PC(L)" }, |
| 1967 | { 4, "PC(U)" }, |
| 1968 | { 8, "SR(L)" }, |
| 1969 | { 12, "SR(U)" }, |
| 1970 | { 16, "syscall no.(L)" }, |
| 1971 | { 20, "syscall_no.(U)" }, |
| 1972 | { 24, "R0(L)" }, |
| 1973 | { 28, "R0(U)" }, |
| 1974 | { 32, "R1(L)" }, |
| 1975 | { 36, "R1(U)" }, |
| 1976 | { 40, "R2(L)" }, |
| 1977 | { 44, "R2(U)" }, |
| 1978 | { 48, "R3(L)" }, |
| 1979 | { 52, "R3(U)" }, |
| 1980 | { 56, "R4(L)" }, |
| 1981 | { 60, "R4(U)" }, |
| 1982 | { 64, "R5(L)" }, |
| 1983 | { 68, "R5(U)" }, |
| 1984 | { 72, "R6(L)" }, |
| 1985 | { 76, "R6(U)" }, |
| 1986 | { 80, "R7(L)" }, |
| 1987 | { 84, "R7(U)" }, |
| 1988 | { 88, "R8(L)" }, |
| 1989 | { 92, "R8(U)" }, |
| 1990 | { 96, "R9(L)" }, |
| 1991 | { 100, "R9(U)" }, |
| 1992 | { 104, "R10(L)" }, |
| 1993 | { 108, "R10(U)" }, |
| 1994 | { 112, "R11(L)" }, |
| 1995 | { 116, "R11(U)" }, |
| 1996 | { 120, "R12(L)" }, |
| 1997 | { 124, "R12(U)" }, |
| 1998 | { 128, "R13(L)" }, |
| 1999 | { 132, "R13(U)" }, |
| 2000 | { 136, "R14(L)" }, |
| 2001 | { 140, "R14(U)" }, |
| 2002 | { 144, "R15(L)" }, |
| 2003 | { 148, "R15(U)" }, |
| 2004 | { 152, "R16(L)" }, |
| 2005 | { 156, "R16(U)" }, |
| 2006 | { 160, "R17(L)" }, |
| 2007 | { 164, "R17(U)" }, |
| 2008 | { 168, "R18(L)" }, |
| 2009 | { 172, "R18(U)" }, |
| 2010 | { 176, "R19(L)" }, |
| 2011 | { 180, "R19(U)" }, |
| 2012 | { 184, "R20(L)" }, |
| 2013 | { 188, "R20(U)" }, |
| 2014 | { 192, "R21(L)" }, |
| 2015 | { 196, "R21(U)" }, |
| 2016 | { 200, "R22(L)" }, |
| 2017 | { 204, "R22(U)" }, |
| 2018 | { 208, "R23(L)" }, |
| 2019 | { 212, "R23(U)" }, |
| 2020 | { 216, "R24(L)" }, |
| 2021 | { 220, "R24(U)" }, |
| 2022 | { 224, "R25(L)" }, |
| 2023 | { 228, "R25(U)" }, |
| 2024 | { 232, "R26(L)" }, |
| 2025 | { 236, "R26(U)" }, |
| 2026 | { 240, "R27(L)" }, |
| 2027 | { 244, "R27(U)" }, |
| 2028 | { 248, "R28(L)" }, |
| 2029 | { 252, "R28(U)" }, |
| 2030 | { 256, "R29(L)" }, |
| 2031 | { 260, "R29(U)" }, |
| 2032 | { 264, "R30(L)" }, |
| 2033 | { 268, "R30(U)" }, |
| 2034 | { 272, "R31(L)" }, |
| 2035 | { 276, "R31(U)" }, |
| 2036 | { 280, "R32(L)" }, |
| 2037 | { 284, "R32(U)" }, |
| 2038 | { 288, "R33(L)" }, |
| 2039 | { 292, "R33(U)" }, |
| 2040 | { 296, "R34(L)" }, |
| 2041 | { 300, "R34(U)" }, |
| 2042 | { 304, "R35(L)" }, |
| 2043 | { 308, "R35(U)" }, |
| 2044 | { 312, "R36(L)" }, |
| 2045 | { 316, "R36(U)" }, |
| 2046 | { 320, "R37(L)" }, |
| 2047 | { 324, "R37(U)" }, |
| 2048 | { 328, "R38(L)" }, |
| 2049 | { 332, "R38(U)" }, |
| 2050 | { 336, "R39(L)" }, |
| 2051 | { 340, "R39(U)" }, |
| 2052 | { 344, "R40(L)" }, |
| 2053 | { 348, "R40(U)" }, |
| 2054 | { 352, "R41(L)" }, |
| 2055 | { 356, "R41(U)" }, |
| 2056 | { 360, "R42(L)" }, |
| 2057 | { 364, "R42(U)" }, |
| 2058 | { 368, "R43(L)" }, |
| 2059 | { 372, "R43(U)" }, |
| 2060 | { 376, "R44(L)" }, |
| 2061 | { 380, "R44(U)" }, |
| 2062 | { 384, "R45(L)" }, |
| 2063 | { 388, "R45(U)" }, |
| 2064 | { 392, "R46(L)" }, |
| 2065 | { 396, "R46(U)" }, |
| 2066 | { 400, "R47(L)" }, |
| 2067 | { 404, "R47(U)" }, |
| 2068 | { 408, "R48(L)" }, |
| 2069 | { 412, "R48(U)" }, |
| 2070 | { 416, "R49(L)" }, |
| 2071 | { 420, "R49(U)" }, |
| 2072 | { 424, "R50(L)" }, |
| 2073 | { 428, "R50(U)" }, |
| 2074 | { 432, "R51(L)" }, |
| 2075 | { 436, "R51(U)" }, |
| 2076 | { 440, "R52(L)" }, |
| 2077 | { 444, "R52(U)" }, |
| 2078 | { 448, "R53(L)" }, |
| 2079 | { 452, "R53(U)" }, |
| 2080 | { 456, "R54(L)" }, |
| 2081 | { 460, "R54(U)" }, |
| 2082 | { 464, "R55(L)" }, |
| 2083 | { 468, "R55(U)" }, |
| 2084 | { 472, "R56(L)" }, |
| 2085 | { 476, "R56(U)" }, |
| 2086 | { 480, "R57(L)" }, |
| 2087 | { 484, "R57(U)" }, |
| 2088 | { 488, "R58(L)" }, |
| 2089 | { 492, "R58(U)" }, |
| 2090 | { 496, "R59(L)" }, |
| 2091 | { 500, "R59(U)" }, |
| 2092 | { 504, "R60(L)" }, |
| 2093 | { 508, "R60(U)" }, |
| 2094 | { 512, "R61(L)" }, |
| 2095 | { 516, "R61(U)" }, |
| 2096 | { 520, "R62(L)" }, |
| 2097 | { 524, "R62(U)" }, |
| 2098 | { 528, "TR0(L)" }, |
| 2099 | { 532, "TR0(U)" }, |
| 2100 | { 536, "TR1(L)" }, |
| 2101 | { 540, "TR1(U)" }, |
| 2102 | { 544, "TR2(L)" }, |
| 2103 | { 548, "TR2(U)" }, |
| 2104 | { 552, "TR3(L)" }, |
| 2105 | { 556, "TR3(U)" }, |
| 2106 | { 560, "TR4(L)" }, |
| 2107 | { 564, "TR4(U)" }, |
| 2108 | { 568, "TR5(L)" }, |
| 2109 | { 572, "TR5(U)" }, |
| 2110 | { 576, "TR6(L)" }, |
| 2111 | { 580, "TR6(U)" }, |
| 2112 | { 584, "TR7(L)" }, |
| 2113 | { 588, "TR7(U)" }, |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 2114 | /* This entry is in case pt_regs contains dregs (depends on |
| 2115 | the kernel build options). */ |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2116 | { uoff(regs), "offsetof(struct user, regs)" }, |
| 2117 | { uoff(fpu), "offsetof(struct user, fpu)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2118 | # elif defined(ARM) |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 2119 | { uoff(regs.ARM_r0), "r0" }, |
| 2120 | { uoff(regs.ARM_r1), "r1" }, |
| 2121 | { uoff(regs.ARM_r2), "r2" }, |
| 2122 | { uoff(regs.ARM_r3), "r3" }, |
| 2123 | { uoff(regs.ARM_r4), "r4" }, |
| 2124 | { uoff(regs.ARM_r5), "r5" }, |
| 2125 | { uoff(regs.ARM_r6), "r6" }, |
| 2126 | { uoff(regs.ARM_r7), "r7" }, |
| 2127 | { uoff(regs.ARM_r8), "r8" }, |
| 2128 | { uoff(regs.ARM_r9), "r9" }, |
| 2129 | { uoff(regs.ARM_r10), "r10" }, |
| 2130 | { uoff(regs.ARM_fp), "fp" }, |
| 2131 | { uoff(regs.ARM_ip), "ip" }, |
| 2132 | { uoff(regs.ARM_sp), "sp" }, |
| 2133 | { uoff(regs.ARM_lr), "lr" }, |
| 2134 | { uoff(regs.ARM_pc), "pc" }, |
| 2135 | { uoff(regs.ARM_cpsr), "cpsr" }, |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 2136 | # elif defined(AVR32) |
| 2137 | { uoff(regs.sr), "sr" }, |
| 2138 | { uoff(regs.pc), "pc" }, |
| 2139 | { uoff(regs.lr), "lr" }, |
| 2140 | { uoff(regs.sp), "sp" }, |
| 2141 | { uoff(regs.r12), "r12" }, |
| 2142 | { uoff(regs.r11), "r11" }, |
| 2143 | { uoff(regs.r10), "r10" }, |
| 2144 | { uoff(regs.r9), "r9" }, |
| 2145 | { uoff(regs.r8), "r8" }, |
| 2146 | { uoff(regs.r7), "r7" }, |
| 2147 | { uoff(regs.r6), "r6" }, |
| 2148 | { uoff(regs.r5), "r5" }, |
| 2149 | { uoff(regs.r4), "r4" }, |
| 2150 | { uoff(regs.r3), "r3" }, |
| 2151 | { uoff(regs.r2), "r2" }, |
| 2152 | { uoff(regs.r1), "r1" }, |
| 2153 | { uoff(regs.r0), "r0" }, |
| 2154 | { uoff(regs.r12_orig), "orig_r12" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2155 | # elif defined(MIPS) |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 2156 | { 0, "r0" }, |
| 2157 | { 1, "r1" }, |
| 2158 | { 2, "r2" }, |
| 2159 | { 3, "r3" }, |
| 2160 | { 4, "r4" }, |
| 2161 | { 5, "r5" }, |
| 2162 | { 6, "r6" }, |
| 2163 | { 7, "r7" }, |
| 2164 | { 8, "r8" }, |
| 2165 | { 9, "r9" }, |
| 2166 | { 10, "r10" }, |
| 2167 | { 11, "r11" }, |
| 2168 | { 12, "r12" }, |
| 2169 | { 13, "r13" }, |
| 2170 | { 14, "r14" }, |
| 2171 | { 15, "r15" }, |
| 2172 | { 16, "r16" }, |
| 2173 | { 17, "r17" }, |
| 2174 | { 18, "r18" }, |
| 2175 | { 19, "r19" }, |
| 2176 | { 20, "r20" }, |
| 2177 | { 21, "r21" }, |
| 2178 | { 22, "r22" }, |
| 2179 | { 23, "r23" }, |
| 2180 | { 24, "r24" }, |
| 2181 | { 25, "r25" }, |
| 2182 | { 26, "r26" }, |
| 2183 | { 27, "r27" }, |
| 2184 | { 28, "r28" }, |
| 2185 | { 29, "r29" }, |
| 2186 | { 30, "r30" }, |
| 2187 | { 31, "r31" }, |
| 2188 | { 32, "f0" }, |
| 2189 | { 33, "f1" }, |
| 2190 | { 34, "f2" }, |
| 2191 | { 35, "f3" }, |
| 2192 | { 36, "f4" }, |
| 2193 | { 37, "f5" }, |
| 2194 | { 38, "f6" }, |
| 2195 | { 39, "f7" }, |
| 2196 | { 40, "f8" }, |
| 2197 | { 41, "f9" }, |
| 2198 | { 42, "f10" }, |
| 2199 | { 43, "f11" }, |
| 2200 | { 44, "f12" }, |
| 2201 | { 45, "f13" }, |
| 2202 | { 46, "f14" }, |
| 2203 | { 47, "f15" }, |
| 2204 | { 48, "f16" }, |
| 2205 | { 49, "f17" }, |
| 2206 | { 50, "f18" }, |
| 2207 | { 51, "f19" }, |
| 2208 | { 52, "f20" }, |
| 2209 | { 53, "f21" }, |
| 2210 | { 54, "f22" }, |
| 2211 | { 55, "f23" }, |
| 2212 | { 56, "f24" }, |
| 2213 | { 57, "f25" }, |
| 2214 | { 58, "f26" }, |
| 2215 | { 59, "f27" }, |
| 2216 | { 60, "f28" }, |
| 2217 | { 61, "f29" }, |
| 2218 | { 62, "f30" }, |
| 2219 | { 63, "f31" }, |
| 2220 | { 64, "pc" }, |
| 2221 | { 65, "cause" }, |
| 2222 | { 66, "badvaddr" }, |
| 2223 | { 67, "mmhi" }, |
| 2224 | { 68, "mmlo" }, |
| 2225 | { 69, "fpcsr" }, |
| 2226 | { 70, "fpeir" }, |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 2227 | # elif defined(TILE) |
| 2228 | { PTREGS_OFFSET_REG(0), "r0" }, |
| 2229 | { PTREGS_OFFSET_REG(1), "r1" }, |
| 2230 | { PTREGS_OFFSET_REG(2), "r2" }, |
| 2231 | { PTREGS_OFFSET_REG(3), "r3" }, |
| 2232 | { PTREGS_OFFSET_REG(4), "r4" }, |
| 2233 | { PTREGS_OFFSET_REG(5), "r5" }, |
| 2234 | { PTREGS_OFFSET_REG(6), "r6" }, |
| 2235 | { PTREGS_OFFSET_REG(7), "r7" }, |
| 2236 | { PTREGS_OFFSET_REG(8), "r8" }, |
| 2237 | { PTREGS_OFFSET_REG(9), "r9" }, |
| 2238 | { PTREGS_OFFSET_REG(10), "r10" }, |
| 2239 | { PTREGS_OFFSET_REG(11), "r11" }, |
| 2240 | { PTREGS_OFFSET_REG(12), "r12" }, |
| 2241 | { PTREGS_OFFSET_REG(13), "r13" }, |
| 2242 | { PTREGS_OFFSET_REG(14), "r14" }, |
| 2243 | { PTREGS_OFFSET_REG(15), "r15" }, |
| 2244 | { PTREGS_OFFSET_REG(16), "r16" }, |
| 2245 | { PTREGS_OFFSET_REG(17), "r17" }, |
| 2246 | { PTREGS_OFFSET_REG(18), "r18" }, |
| 2247 | { PTREGS_OFFSET_REG(19), "r19" }, |
| 2248 | { PTREGS_OFFSET_REG(20), "r20" }, |
| 2249 | { PTREGS_OFFSET_REG(21), "r21" }, |
| 2250 | { PTREGS_OFFSET_REG(22), "r22" }, |
| 2251 | { PTREGS_OFFSET_REG(23), "r23" }, |
| 2252 | { PTREGS_OFFSET_REG(24), "r24" }, |
| 2253 | { PTREGS_OFFSET_REG(25), "r25" }, |
| 2254 | { PTREGS_OFFSET_REG(26), "r26" }, |
| 2255 | { PTREGS_OFFSET_REG(27), "r27" }, |
| 2256 | { PTREGS_OFFSET_REG(28), "r28" }, |
| 2257 | { PTREGS_OFFSET_REG(29), "r29" }, |
| 2258 | { PTREGS_OFFSET_REG(30), "r30" }, |
| 2259 | { PTREGS_OFFSET_REG(31), "r31" }, |
| 2260 | { PTREGS_OFFSET_REG(32), "r32" }, |
| 2261 | { PTREGS_OFFSET_REG(33), "r33" }, |
| 2262 | { PTREGS_OFFSET_REG(34), "r34" }, |
| 2263 | { PTREGS_OFFSET_REG(35), "r35" }, |
| 2264 | { PTREGS_OFFSET_REG(36), "r36" }, |
| 2265 | { PTREGS_OFFSET_REG(37), "r37" }, |
| 2266 | { PTREGS_OFFSET_REG(38), "r38" }, |
| 2267 | { PTREGS_OFFSET_REG(39), "r39" }, |
| 2268 | { PTREGS_OFFSET_REG(40), "r40" }, |
| 2269 | { PTREGS_OFFSET_REG(41), "r41" }, |
| 2270 | { PTREGS_OFFSET_REG(42), "r42" }, |
| 2271 | { PTREGS_OFFSET_REG(43), "r43" }, |
| 2272 | { PTREGS_OFFSET_REG(44), "r44" }, |
| 2273 | { PTREGS_OFFSET_REG(45), "r45" }, |
| 2274 | { PTREGS_OFFSET_REG(46), "r46" }, |
| 2275 | { PTREGS_OFFSET_REG(47), "r47" }, |
| 2276 | { PTREGS_OFFSET_REG(48), "r48" }, |
| 2277 | { PTREGS_OFFSET_REG(49), "r49" }, |
| 2278 | { PTREGS_OFFSET_REG(50), "r50" }, |
| 2279 | { PTREGS_OFFSET_REG(51), "r51" }, |
| 2280 | { PTREGS_OFFSET_REG(52), "r52" }, |
| 2281 | { PTREGS_OFFSET_TP, "tp" }, |
| 2282 | { PTREGS_OFFSET_SP, "sp" }, |
| 2283 | { PTREGS_OFFSET_LR, "lr" }, |
| 2284 | { PTREGS_OFFSET_PC, "pc" }, |
| 2285 | { PTREGS_OFFSET_EX1, "ex1" }, |
| 2286 | { PTREGS_OFFSET_FAULTNUM, "faultnum" }, |
| 2287 | { PTREGS_OFFSET_ORIG_R0, "orig_r0" }, |
| 2288 | { PTREGS_OFFSET_FLAGS, "flags" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2289 | # endif |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 2290 | # ifdef CRISV10 |
| 2291 | { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" }, |
| 2292 | { 4*PT_ORIG_R10, "4*PT_ORIG_R10" }, |
| 2293 | { 4*PT_R13, "4*PT_R13" }, |
| 2294 | { 4*PT_R12, "4*PT_R12" }, |
| 2295 | { 4*PT_R11, "4*PT_R11" }, |
| 2296 | { 4*PT_R10, "4*PT_R10" }, |
| 2297 | { 4*PT_R9, "4*PT_R9" }, |
| 2298 | { 4*PT_R8, "4*PT_R8" }, |
| 2299 | { 4*PT_R7, "4*PT_R7" }, |
| 2300 | { 4*PT_R6, "4*PT_R6" }, |
| 2301 | { 4*PT_R5, "4*PT_R5" }, |
| 2302 | { 4*PT_R4, "4*PT_R4" }, |
| 2303 | { 4*PT_R3, "4*PT_R3" }, |
| 2304 | { 4*PT_R2, "4*PT_R2" }, |
| 2305 | { 4*PT_R1, "4*PT_R1" }, |
| 2306 | { 4*PT_R0, "4*PT_R0" }, |
| 2307 | { 4*PT_MOF, "4*PT_MOF" }, |
| 2308 | { 4*PT_DCCR, "4*PT_DCCR" }, |
| 2309 | { 4*PT_SRP, "4*PT_SRP" }, |
| 2310 | { 4*PT_IRP, "4*PT_IRP" }, |
| 2311 | { 4*PT_CSRINSTR, "4*PT_CSRINSTR" }, |
| 2312 | { 4*PT_CSRADDR, "4*PT_CSRADDR" }, |
| 2313 | { 4*PT_CSRDATA, "4*PT_CSRDATA" }, |
| 2314 | { 4*PT_USP, "4*PT_USP" }, |
| 2315 | # endif |
| 2316 | # ifdef CRISV32 |
| 2317 | { 4*PT_ORIG_R10, "4*PT_ORIG_R10" }, |
| 2318 | { 4*PT_R0, "4*PT_R0" }, |
| 2319 | { 4*PT_R1, "4*PT_R1" }, |
| 2320 | { 4*PT_R2, "4*PT_R2" }, |
| 2321 | { 4*PT_R3, "4*PT_R3" }, |
| 2322 | { 4*PT_R4, "4*PT_R4" }, |
| 2323 | { 4*PT_R5, "4*PT_R5" }, |
| 2324 | { 4*PT_R6, "4*PT_R6" }, |
| 2325 | { 4*PT_R7, "4*PT_R7" }, |
| 2326 | { 4*PT_R8, "4*PT_R8" }, |
| 2327 | { 4*PT_R9, "4*PT_R9" }, |
| 2328 | { 4*PT_R10, "4*PT_R10" }, |
| 2329 | { 4*PT_R11, "4*PT_R11" }, |
| 2330 | { 4*PT_R12, "4*PT_R12" }, |
| 2331 | { 4*PT_R13, "4*PT_R13" }, |
| 2332 | { 4*PT_ACR, "4*PT_ACR" }, |
| 2333 | { 4*PT_SRS, "4*PT_SRS" }, |
| 2334 | { 4*PT_MOF, "4*PT_MOF" }, |
| 2335 | { 4*PT_SPC, "4*PT_SPC" }, |
| 2336 | { 4*PT_CCS, "4*PT_CCS" }, |
| 2337 | { 4*PT_SRP, "4*PT_SRP" }, |
| 2338 | { 4*PT_ERP, "4*PT_ERP" }, |
| 2339 | { 4*PT_EXS, "4*PT_EXS" }, |
| 2340 | { 4*PT_EDA, "4*PT_EDA" }, |
| 2341 | { 4*PT_USP, "4*PT_USP" }, |
| 2342 | { 4*PT_PPC, "4*PT_PPC" }, |
| 2343 | { 4*PT_BP_CTRL, "4*PT_BP_CTRL" }, |
| 2344 | { 4*PT_BP+4, "4*PT_BP+4" }, |
| 2345 | { 4*PT_BP+8, "4*PT_BP+8" }, |
| 2346 | { 4*PT_BP+12, "4*PT_BP+12" }, |
| 2347 | { 4*PT_BP+16, "4*PT_BP+16" }, |
| 2348 | { 4*PT_BP+20, "4*PT_BP+20" }, |
| 2349 | { 4*PT_BP+24, "4*PT_BP+24" }, |
| 2350 | { 4*PT_BP+28, "4*PT_BP+28" }, |
| 2351 | { 4*PT_BP+32, "4*PT_BP+32" }, |
| 2352 | { 4*PT_BP+36, "4*PT_BP+36" }, |
| 2353 | { 4*PT_BP+40, "4*PT_BP+40" }, |
| 2354 | { 4*PT_BP+44, "4*PT_BP+44" }, |
| 2355 | { 4*PT_BP+48, "4*PT_BP+48" }, |
| 2356 | { 4*PT_BP+52, "4*PT_BP+52" }, |
| 2357 | { 4*PT_BP+56, "4*PT_BP+56" }, |
| 2358 | # endif |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 2359 | # ifdef MICROBLAZE |
| 2360 | { PT_GPR(0), "r0" }, |
| 2361 | { PT_GPR(1), "r1" }, |
| 2362 | { PT_GPR(2), "r2" }, |
| 2363 | { PT_GPR(3), "r3" }, |
| 2364 | { PT_GPR(4), "r4" }, |
| 2365 | { PT_GPR(5), "r5" }, |
| 2366 | { PT_GPR(6), "r6" }, |
| 2367 | { PT_GPR(7), "r7" }, |
| 2368 | { PT_GPR(8), "r8" }, |
| 2369 | { PT_GPR(9), "r9" }, |
| 2370 | { PT_GPR(10), "r10" }, |
| 2371 | { PT_GPR(11), "r11" }, |
| 2372 | { PT_GPR(12), "r12" }, |
| 2373 | { PT_GPR(13), "r13" }, |
| 2374 | { PT_GPR(14), "r14" }, |
| 2375 | { PT_GPR(15), "r15" }, |
| 2376 | { PT_GPR(16), "r16" }, |
| 2377 | { PT_GPR(17), "r17" }, |
| 2378 | { PT_GPR(18), "r18" }, |
| 2379 | { PT_GPR(19), "r19" }, |
| 2380 | { PT_GPR(20), "r20" }, |
| 2381 | { PT_GPR(21), "r21" }, |
| 2382 | { PT_GPR(22), "r22" }, |
| 2383 | { PT_GPR(23), "r23" }, |
| 2384 | { PT_GPR(24), "r24" }, |
| 2385 | { PT_GPR(25), "r25" }, |
| 2386 | { PT_GPR(26), "r26" }, |
| 2387 | { PT_GPR(27), "r27" }, |
| 2388 | { PT_GPR(28), "r28" }, |
| 2389 | { PT_GPR(29), "r29" }, |
| 2390 | { PT_GPR(30), "r30" }, |
| 2391 | { PT_GPR(31), "r31" }, |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2392 | { PT_PC, "rpc", }, |
| 2393 | { PT_MSR, "rmsr", }, |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 2394 | { PT_EAR, "rear", }, |
| 2395 | { PT_ESR, "resr", }, |
| 2396 | { PT_FSR, "rfsr", }, |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2397 | { PT_KERNEL_MODE, "kernel_mode", }, |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 2398 | # endif |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 2399 | |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 2400 | # if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \ |
| 2401 | && !defined(ALPHA) && !defined(IA64) \ |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 2402 | && !defined(CRISV10) && !defined(CRISV32) && !defined(MICROBLAZE) |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 2403 | # if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(AVR32) && !defined(BFIN) && !defined(TILE) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2404 | { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2405 | # endif |
| 2406 | # if defined(I386) || defined(X86_64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2407 | { uoff(i387), "offsetof(struct user, i387)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2408 | # endif |
| 2409 | # if defined(M68K) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2410 | { uoff(m68kfp), "offsetof(struct user, m68kfp)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2411 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2412 | { uoff(u_tsize), "offsetof(struct user, u_tsize)" }, |
| 2413 | { uoff(u_dsize), "offsetof(struct user, u_dsize)" }, |
| 2414 | { uoff(u_ssize), "offsetof(struct user, u_ssize)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2415 | # if !defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2416 | { uoff(start_code), "offsetof(struct user, start_code)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2417 | # endif |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 2418 | # if defined(AVR32) || defined(SH64) |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 2419 | { uoff(start_data), "offsetof(struct user, start_data)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2420 | # endif |
| 2421 | # if !defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2422 | { uoff(start_stack), "offsetof(struct user, start_stack)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2423 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2424 | { uoff(signal), "offsetof(struct user, signal)" }, |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 2425 | # if !defined(AVR32) && !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SH) && !defined(SH64) && !defined(SPARC64) && !defined(TILE) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2426 | { uoff(reserved), "offsetof(struct user, reserved)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2427 | # endif |
| 2428 | # if !defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2429 | { uoff(u_ar0), "offsetof(struct user, u_ar0)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2430 | # endif |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 2431 | # if !defined(ARM) && !defined(AVR32) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) && !defined(BFIN) && !defined(TILE) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2432 | { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2433 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2434 | { uoff(magic), "offsetof(struct user, magic)" }, |
| 2435 | { uoff(u_comm), "offsetof(struct user, u_comm)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2436 | # if defined(I386) || defined(X86_64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2437 | { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2438 | # endif |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 2439 | # endif /* !defined(many arches) */ |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2440 | |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2441 | # ifndef HPPA |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2442 | { sizeof(struct user), "sizeof(struct user)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2443 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2444 | { 0, NULL }, |
| 2445 | }; |
| 2446 | |
| 2447 | int |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2448 | sys_ptrace(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2449 | { |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 2450 | const struct xlat *x; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2451 | long addr; |
| 2452 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2453 | if (entering(tcp)) { |
Roland McGrath | bf621d4 | 2003-01-14 09:46:21 +0000 | [diff] [blame] | 2454 | printxval(ptrace_cmds, tcp->u_arg[0], |
Roland McGrath | bf621d4 | 2003-01-14 09:46:21 +0000 | [diff] [blame] | 2455 | "PTRACE_???" |
Roland McGrath | bf621d4 | 2003-01-14 09:46:21 +0000 | [diff] [blame] | 2456 | ); |
| 2457 | tprintf(", %lu, ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2458 | addr = tcp->u_arg[2]; |
| 2459 | if (tcp->u_arg[0] == PTRACE_PEEKUSER |
| 2460 | || tcp->u_arg[0] == PTRACE_POKEUSER) { |
| 2461 | for (x = struct_user_offsets; x->str; x++) { |
| 2462 | if (x->val >= addr) |
| 2463 | break; |
| 2464 | } |
| 2465 | if (!x->str) |
| 2466 | tprintf("%#lx, ", addr); |
| 2467 | else if (x->val > addr && x != struct_user_offsets) { |
| 2468 | x--; |
| 2469 | tprintf("%s + %ld, ", x->str, addr - x->val); |
| 2470 | } |
| 2471 | else |
| 2472 | tprintf("%s, ", x->str); |
| 2473 | } |
| 2474 | else |
| 2475 | tprintf("%#lx, ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2476 | switch (tcp->u_arg[0]) { |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2477 | # ifndef IA64 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2478 | case PTRACE_PEEKDATA: |
| 2479 | case PTRACE_PEEKTEXT: |
| 2480 | case PTRACE_PEEKUSER: |
| 2481 | break; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2482 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2483 | case PTRACE_CONT: |
| 2484 | case PTRACE_SINGLESTEP: |
| 2485 | case PTRACE_SYSCALL: |
| 2486 | case PTRACE_DETACH: |
| 2487 | printsignal(tcp->u_arg[3]); |
| 2488 | break; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2489 | # ifdef PTRACE_SETOPTIONS |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2490 | case PTRACE_SETOPTIONS: |
| 2491 | printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???"); |
| 2492 | break; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2493 | # endif |
| 2494 | # ifdef PTRACE_SETSIGINFO |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2495 | case PTRACE_SETSIGINFO: { |
| 2496 | siginfo_t si; |
| 2497 | if (!tcp->u_arg[3]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2498 | tprints("NULL"); |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2499 | else if (syserror(tcp)) |
| 2500 | tprintf("%#lx", tcp->u_arg[3]); |
| 2501 | else if (umove(tcp, tcp->u_arg[3], &si) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2502 | tprints("{???}"); |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2503 | else |
| 2504 | printsiginfo(&si, verbose(tcp)); |
| 2505 | break; |
| 2506 | } |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2507 | # endif |
| 2508 | # ifdef PTRACE_GETSIGINFO |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2509 | case PTRACE_GETSIGINFO: |
| 2510 | /* Don't print anything, do it at syscall return. */ |
| 2511 | break; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2512 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2513 | default: |
| 2514 | tprintf("%#lx", tcp->u_arg[3]); |
| 2515 | break; |
| 2516 | } |
| 2517 | } else { |
| 2518 | switch (tcp->u_arg[0]) { |
| 2519 | case PTRACE_PEEKDATA: |
| 2520 | case PTRACE_PEEKTEXT: |
| 2521 | case PTRACE_PEEKUSER: |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2522 | # ifdef IA64 |
Roland McGrath | 1e86806 | 2007-11-19 22:11:45 +0000 | [diff] [blame] | 2523 | return RVAL_HEX; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2524 | # else |
Roland McGrath | eb28535 | 2003-01-14 09:59:00 +0000 | [diff] [blame] | 2525 | printnum(tcp, tcp->u_arg[3], "%#lx"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2526 | break; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2527 | # endif |
| 2528 | # ifdef PTRACE_GETSIGINFO |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2529 | case PTRACE_GETSIGINFO: { |
| 2530 | siginfo_t si; |
| 2531 | if (!tcp->u_arg[3]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2532 | tprints("NULL"); |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2533 | else if (syserror(tcp)) |
| 2534 | tprintf("%#lx", tcp->u_arg[3]); |
| 2535 | else if (umove(tcp, tcp->u_arg[3], &si) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2536 | tprints("{???}"); |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2537 | else |
| 2538 | printsiginfo(&si, verbose(tcp)); |
| 2539 | break; |
| 2540 | } |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2541 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2542 | } |
| 2543 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2544 | return 0; |
| 2545 | } |
| 2546 | |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 2547 | # ifndef FUTEX_CMP_REQUEUE |
| 2548 | # define FUTEX_CMP_REQUEUE 4 |
| 2549 | # endif |
| 2550 | # ifndef FUTEX_WAKE_OP |
| 2551 | # define FUTEX_WAKE_OP 5 |
| 2552 | # endif |
| 2553 | # ifndef FUTEX_LOCK_PI |
| 2554 | # define FUTEX_LOCK_PI 6 |
| 2555 | # define FUTEX_UNLOCK_PI 7 |
| 2556 | # define FUTEX_TRYLOCK_PI 8 |
| 2557 | # endif |
Roland McGrath | 1aeaf74 | 2008-07-18 01:27:39 +0000 | [diff] [blame] | 2558 | # ifndef FUTEX_WAIT_BITSET |
| 2559 | # define FUTEX_WAIT_BITSET 9 |
| 2560 | # endif |
| 2561 | # ifndef FUTEX_WAKE_BITSET |
| 2562 | # define FUTEX_WAKE_BITSET 10 |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 2563 | # endif |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 2564 | # ifndef FUTEX_WAIT_REQUEUE_PI |
| 2565 | # define FUTEX_WAIT_REQUEUE_PI 11 |
| 2566 | # endif |
| 2567 | # ifndef FUTEX_CMP_REQUEUE_PI |
| 2568 | # define FUTEX_CMP_REQUEUE_PI 12 |
| 2569 | # endif |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 2570 | # ifndef FUTEX_PRIVATE_FLAG |
| 2571 | # define FUTEX_PRIVATE_FLAG 128 |
| 2572 | # endif |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 2573 | # ifndef FUTEX_CLOCK_REALTIME |
| 2574 | # define FUTEX_CLOCK_REALTIME 256 |
| 2575 | # endif |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 2576 | static const struct xlat futexops[] = { |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 2577 | { FUTEX_WAIT, "FUTEX_WAIT" }, |
| 2578 | { FUTEX_WAKE, "FUTEX_WAKE" }, |
| 2579 | { FUTEX_FD, "FUTEX_FD" }, |
| 2580 | { FUTEX_REQUEUE, "FUTEX_REQUEUE" }, |
| 2581 | { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" }, |
| 2582 | { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" }, |
| 2583 | { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" }, |
| 2584 | { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" }, |
| 2585 | { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" }, |
Roland McGrath | 1aeaf74 | 2008-07-18 01:27:39 +0000 | [diff] [blame] | 2586 | { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" }, |
| 2587 | { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" }, |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 2588 | { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" }, |
| 2589 | { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" }, |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 2590 | { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" }, |
| 2591 | { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" }, |
| 2592 | { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" }, |
| 2593 | { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" }, |
| 2594 | { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" }, |
| 2595 | { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" }, |
| 2596 | { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" }, |
| 2597 | { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" }, |
| 2598 | { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" }, |
Roland McGrath | 1aeaf74 | 2008-07-18 01:27:39 +0000 | [diff] [blame] | 2599 | { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" }, |
| 2600 | { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" }, |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 2601 | { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" }, |
| 2602 | { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" }, |
| 2603 | { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" }, |
| 2604 | { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" }, |
| 2605 | { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" }, |
| 2606 | { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI_PRIVATE|FUTEX_CLOCK_REALTIME" }, |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 2607 | { 0, NULL } |
| 2608 | }; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2609 | # ifndef FUTEX_OP_SET |
| 2610 | # define FUTEX_OP_SET 0 |
| 2611 | # define FUTEX_OP_ADD 1 |
| 2612 | # define FUTEX_OP_OR 2 |
| 2613 | # define FUTEX_OP_ANDN 3 |
| 2614 | # define FUTEX_OP_XOR 4 |
| 2615 | # define FUTEX_OP_CMP_EQ 0 |
| 2616 | # define FUTEX_OP_CMP_NE 1 |
| 2617 | # define FUTEX_OP_CMP_LT 2 |
| 2618 | # define FUTEX_OP_CMP_LE 3 |
| 2619 | # define FUTEX_OP_CMP_GT 4 |
| 2620 | # define FUTEX_OP_CMP_GE 5 |
| 2621 | # endif |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 2622 | static const struct xlat futexwakeops[] = { |
| 2623 | { FUTEX_OP_SET, "FUTEX_OP_SET" }, |
| 2624 | { FUTEX_OP_ADD, "FUTEX_OP_ADD" }, |
| 2625 | { FUTEX_OP_OR, "FUTEX_OP_OR" }, |
| 2626 | { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" }, |
| 2627 | { FUTEX_OP_XOR, "FUTEX_OP_XOR" }, |
| 2628 | { 0, NULL } |
| 2629 | }; |
| 2630 | static const struct xlat futexwakecmps[] = { |
| 2631 | { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" }, |
| 2632 | { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" }, |
| 2633 | { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" }, |
| 2634 | { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" }, |
| 2635 | { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" }, |
| 2636 | { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" }, |
| 2637 | { 0, NULL } |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 2638 | }; |
| 2639 | |
| 2640 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2641 | sys_futex(struct tcb *tcp) |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 2642 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2643 | if (entering(tcp)) { |
| 2644 | long int cmd = tcp->u_arg[1] & 127; |
| 2645 | tprintf("%p, ", (void *) tcp->u_arg[0]); |
| 2646 | printxval(futexops, tcp->u_arg[1], "FUTEX_???"); |
| 2647 | tprintf(", %ld", tcp->u_arg[2]); |
| 2648 | if (cmd == FUTEX_WAKE_BITSET) |
| 2649 | tprintf(", %lx", tcp->u_arg[5]); |
| 2650 | else if (cmd == FUTEX_WAIT) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2651 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2652 | printtv(tcp, tcp->u_arg[3]); |
| 2653 | } else if (cmd == FUTEX_WAIT_BITSET) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2654 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2655 | printtv(tcp, tcp->u_arg[3]); |
| 2656 | tprintf(", %lx", tcp->u_arg[5]); |
| 2657 | } else if (cmd == FUTEX_REQUEUE) |
| 2658 | tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]); |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 2659 | else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI) |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2660 | tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]); |
| 2661 | else if (cmd == FUTEX_WAKE_OP) { |
| 2662 | tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]); |
| 2663 | if ((tcp->u_arg[5] >> 28) & 8) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2664 | tprints("FUTEX_OP_OPARG_SHIFT|"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2665 | printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???"); |
| 2666 | tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff); |
| 2667 | if ((tcp->u_arg[5] >> 24) & 8) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2668 | tprints("FUTEX_OP_OPARG_SHIFT|"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2669 | printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???"); |
| 2670 | tprintf(", %ld}", tcp->u_arg[5] & 0xfff); |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 2671 | } else if (cmd == FUTEX_WAIT_REQUEUE_PI) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2672 | tprints(", "); |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 2673 | printtv(tcp, tcp->u_arg[3]); |
| 2674 | tprintf(", %p", (void *) tcp->u_arg[4]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2675 | } |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 2676 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2677 | return 0; |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 2678 | } |
| 2679 | |
| 2680 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2681 | print_affinitylist(struct tcb *tcp, long list, unsigned int len) |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 2682 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2683 | int first = 1; |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 2684 | unsigned long w, min_len; |
| 2685 | |
| 2686 | if (abbrev(tcp) && len / sizeof(w) > max_strlen) |
| 2687 | min_len = len - max_strlen * sizeof(w); |
| 2688 | else |
| 2689 | min_len = 0; |
| 2690 | for (; len >= sizeof(w) && len > min_len; |
| 2691 | len -= sizeof(w), list += sizeof(w)) { |
| 2692 | if (umove(tcp, list, &w) < 0) |
| 2693 | break; |
| 2694 | if (first) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2695 | tprints("{"); |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 2696 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2697 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2698 | first = 0; |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 2699 | tprintf("%lx", w); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2700 | } |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 2701 | if (len) { |
| 2702 | if (first) |
| 2703 | tprintf("%#lx", list); |
| 2704 | else |
| 2705 | tprintf(", %s}", (len >= sizeof(w) && len > min_len ? |
| 2706 | "???" : "...")); |
| 2707 | } else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2708 | tprints(first ? "{}" : "}"); |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 2709 | } |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 2710 | } |
| 2711 | |
| 2712 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2713 | sys_sched_setaffinity(struct tcb *tcp) |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 2714 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2715 | if (entering(tcp)) { |
| 2716 | tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 2717 | print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]); |
| 2718 | } |
| 2719 | return 0; |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 2720 | } |
| 2721 | |
| 2722 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2723 | sys_sched_getaffinity(struct tcb *tcp) |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 2724 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2725 | if (entering(tcp)) { |
| 2726 | tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 2727 | } else { |
| 2728 | if (tcp->u_rval == -1) |
| 2729 | tprintf("%#lx", tcp->u_arg[2]); |
| 2730 | else |
| 2731 | print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval); |
| 2732 | } |
| 2733 | return 0; |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 2734 | } |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2735 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 2736 | static const struct xlat schedulers[] = { |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2737 | { SCHED_OTHER, "SCHED_OTHER" }, |
| 2738 | { SCHED_RR, "SCHED_RR" }, |
| 2739 | { SCHED_FIFO, "SCHED_FIFO" }, |
| 2740 | { 0, NULL } |
| 2741 | }; |
| 2742 | |
| 2743 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2744 | sys_sched_getscheduler(struct tcb *tcp) |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2745 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2746 | if (entering(tcp)) { |
| 2747 | tprintf("%d", (int) tcp->u_arg[0]); |
| 2748 | } else if (! syserror(tcp)) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2749 | tcp->auxstr = xlookup(schedulers, tcp->u_rval); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2750 | if (tcp->auxstr != NULL) |
| 2751 | return RVAL_STR; |
| 2752 | } |
| 2753 | return 0; |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2754 | } |
| 2755 | |
| 2756 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2757 | sys_sched_setscheduler(struct tcb *tcp) |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2758 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2759 | if (entering(tcp)) { |
| 2760 | struct sched_param p; |
| 2761 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 2762 | printxval(schedulers, tcp->u_arg[1], "SCHED_???"); |
| 2763 | if (umove(tcp, tcp->u_arg[2], &p) < 0) |
| 2764 | tprintf(", %#lx", tcp->u_arg[2]); |
| 2765 | else |
| 2766 | tprintf(", { %d }", p.__sched_priority); |
| 2767 | } |
| 2768 | return 0; |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2769 | } |
| 2770 | |
| 2771 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2772 | sys_sched_getparam(struct tcb *tcp) |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2773 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2774 | if (entering(tcp)) { |
| 2775 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 2776 | } else { |
| 2777 | struct sched_param p; |
| 2778 | if (umove(tcp, tcp->u_arg[1], &p) < 0) |
| 2779 | tprintf("%#lx", tcp->u_arg[1]); |
| 2780 | else |
| 2781 | tprintf("{ %d }", p.__sched_priority); |
| 2782 | } |
| 2783 | return 0; |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2784 | } |
| 2785 | |
| 2786 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2787 | sys_sched_setparam(struct tcb *tcp) |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2788 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2789 | if (entering(tcp)) { |
| 2790 | struct sched_param p; |
| 2791 | if (umove(tcp, tcp->u_arg[1], &p) < 0) |
| 2792 | tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]); |
| 2793 | else |
| 2794 | tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority); |
| 2795 | } |
| 2796 | return 0; |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2797 | } |
| 2798 | |
| 2799 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2800 | sys_sched_get_priority_min(struct tcb *tcp) |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2801 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2802 | if (entering(tcp)) { |
| 2803 | printxval(schedulers, tcp->u_arg[0], "SCHED_???"); |
| 2804 | } |
| 2805 | return 0; |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 2806 | } |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 2807 | |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2808 | # ifdef X86_64 |
| 2809 | # include <asm/prctl.h> |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 2810 | |
| 2811 | static const struct xlat archvals[] = { |
| 2812 | { ARCH_SET_GS, "ARCH_SET_GS" }, |
| 2813 | { ARCH_SET_FS, "ARCH_SET_FS" }, |
| 2814 | { ARCH_GET_FS, "ARCH_GET_FS" }, |
| 2815 | { ARCH_GET_GS, "ARCH_GET_GS" }, |
| 2816 | { 0, NULL }, |
| 2817 | }; |
| 2818 | |
| 2819 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2820 | sys_arch_prctl(struct tcb *tcp) |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 2821 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2822 | if (entering(tcp)) { |
| 2823 | printxval(archvals, tcp->u_arg[0], "ARCH_???"); |
| 2824 | if (tcp->u_arg[0] == ARCH_SET_GS |
| 2825 | || tcp->u_arg[0] == ARCH_SET_FS |
| 2826 | ) { |
| 2827 | tprintf(", %#lx", tcp->u_arg[1]); |
| 2828 | } |
| 2829 | } else { |
| 2830 | if (tcp->u_arg[0] == ARCH_GET_GS |
| 2831 | || tcp->u_arg[0] == ARCH_GET_FS |
| 2832 | ) { |
| 2833 | long int v; |
| 2834 | if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1) |
| 2835 | tprintf(", [%#lx]", v); |
| 2836 | else |
| 2837 | tprintf(", %#lx", tcp->u_arg[1]); |
| 2838 | } |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 2839 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2840 | return 0; |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 2841 | } |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2842 | # endif /* X86_64 */ |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 2843 | |
Roland McGrath | db8319f | 2007-08-02 01:37:55 +0000 | [diff] [blame] | 2844 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 2845 | sys_getcpu(struct tcb *tcp) |
Roland McGrath | db8319f | 2007-08-02 01:37:55 +0000 | [diff] [blame] | 2846 | { |
| 2847 | if (exiting(tcp)) { |
| 2848 | unsigned u; |
| 2849 | if (tcp->u_arg[0] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2850 | tprints("NULL, "); |
Roland McGrath | db8319f | 2007-08-02 01:37:55 +0000 | [diff] [blame] | 2851 | else if (umove(tcp, tcp->u_arg[0], &u) < 0) |
| 2852 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 2853 | else |
| 2854 | tprintf("[%u], ", u); |
| 2855 | if (tcp->u_arg[1] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2856 | tprints("NULL, "); |
Roland McGrath | db8319f | 2007-08-02 01:37:55 +0000 | [diff] [blame] | 2857 | else if (umove(tcp, tcp->u_arg[1], &u) < 0) |
| 2858 | tprintf("%#lx, ", tcp->u_arg[1]); |
| 2859 | else |
| 2860 | tprintf("[%u], ", u); |
| 2861 | tprintf("%#lx", tcp->u_arg[2]); |
| 2862 | } |
| 2863 | return 0; |
| 2864 | } |
| 2865 | |
Denys Vlasenko | 3af224c | 2012-01-28 01:46:33 +0100 | [diff] [blame] | 2866 | int |
| 2867 | sys_process_vm_readv(struct tcb *tcp) |
| 2868 | { |
| 2869 | if (entering(tcp)) { |
| 2870 | /* arg 1: pid */ |
| 2871 | tprintf("%ld, ", tcp->u_arg[0]); |
| 2872 | } else { |
| 2873 | /* args 2,3: local iov,cnt */ |
| 2874 | if (syserror(tcp)) { |
| 2875 | tprintf("%#lx, %lu", |
| 2876 | tcp->u_arg[1], tcp->u_arg[2]); |
| 2877 | } else { |
| 2878 | tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); |
| 2879 | } |
| 2880 | tprints(", "); |
| 2881 | /* args 4,5: remote iov,cnt */ |
| 2882 | if (syserror(tcp)) { |
| 2883 | tprintf("%#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]); |
| 2884 | } else { |
| 2885 | tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0); |
| 2886 | } |
| 2887 | /* arg 6: flags */ |
| 2888 | tprintf(", %lu", tcp->u_arg[5]); |
| 2889 | } |
| 2890 | return 0; |
| 2891 | } |