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> |
| 51 | #ifdef SUNOS4 |
| 52 | #include <machine/reg.h> |
| 53 | #endif /* SUNOS4 */ |
| 54 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 55 | #ifdef FREEBSD |
| 56 | #include <sys/ptrace.h> |
| 57 | #endif |
| 58 | |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 59 | #ifdef HAVE_SYS_REG_H |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 60 | # include <sys/reg.h> |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 61 | #ifndef PTRACE_PEEKUSR |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 62 | # define PTRACE_PEEKUSR PTRACE_PEEKUSER |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 63 | #endif |
| 64 | #ifndef PTRACE_POKEUSR |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 65 | # define PTRACE_POKEUSR PTRACE_POKEUSER |
| 66 | #endif |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 67 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 68 | |
Roland McGrath | 5bd7cf8 | 2003-01-24 04:31:18 +0000 | [diff] [blame] | 69 | #ifdef HAVE_LINUX_PTRACE_H |
| 70 | #undef PTRACE_SYSCALL |
Roland McGrath | fb1bc07 | 2004-03-01 21:29:24 +0000 | [diff] [blame] | 71 | # ifdef HAVE_STRUCT_IA64_FPREG |
| 72 | # define ia64_fpreg XXX_ia64_fpreg |
| 73 | # endif |
| 74 | # ifdef HAVE_STRUCT_PT_ALL_USER_REGS |
| 75 | # define pt_all_user_regs XXX_pt_all_user_regs |
| 76 | # endif |
Roland McGrath | 5bd7cf8 | 2003-01-24 04:31:18 +0000 | [diff] [blame] | 77 | #include <linux/ptrace.h> |
Roland McGrath | fb1bc07 | 2004-03-01 21:29:24 +0000 | [diff] [blame] | 78 | # undef ia64_fpreg |
| 79 | # undef pt_all_user_regs |
Roland McGrath | 5bd7cf8 | 2003-01-24 04:31:18 +0000 | [diff] [blame] | 80 | #endif |
| 81 | |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 82 | #if defined (LINUX) && defined (SPARC64) |
| 83 | # define r_pc r_tpc |
| 84 | # undef PTRACE_GETREGS |
| 85 | # define PTRACE_GETREGS PTRACE_GETREGS64 |
| 86 | # undef PTRACE_SETREGS |
| 87 | # define PTRACE_SETREGS PTRACE_SETREGS64 |
| 88 | #endif /* LINUX && SPARC64 */ |
| 89 | |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 90 | #ifdef HAVE_LINUX_FUTEX_H |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 91 | # include <linux/futex.h> |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 92 | #endif |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 93 | #ifdef LINUX |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 94 | # ifndef FUTEX_WAIT |
| 95 | # define FUTEX_WAIT 0 |
| 96 | # endif |
| 97 | # ifndef FUTEX_WAKE |
| 98 | # define FUTEX_WAKE 1 |
| 99 | # endif |
| 100 | # ifndef FUTEX_FD |
| 101 | # define FUTEX_FD 2 |
| 102 | # endif |
Roland McGrath | 88812d6 | 2003-06-26 22:27:23 +0000 | [diff] [blame] | 103 | # ifndef FUTEX_REQUEUE |
| 104 | # define FUTEX_REQUEUE 3 |
| 105 | # endif |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 106 | #endif /* LINUX */ |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 107 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 108 | #ifdef LINUX |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 109 | #include <sched.h> |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 110 | #include <asm/posix_types.h> |
| 111 | #undef GETGROUPS_T |
| 112 | #define GETGROUPS_T __kernel_gid_t |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 113 | #undef GETGROUPS32_T |
| 114 | #define GETGROUPS32_T __kernel_gid32_t |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 115 | #endif /* LINUX */ |
| 116 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 117 | #if defined(LINUX) && defined(IA64) |
| 118 | # include <asm/ptrace_offsets.h> |
| 119 | # include <asm/rse.h> |
| 120 | #endif |
| 121 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 122 | #ifdef HAVE_PRCTL |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 123 | # include <sys/prctl.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 124 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 125 | static const struct xlat prctl_options[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 126 | #ifdef PR_MAXPROCS |
| 127 | { PR_MAXPROCS, "PR_MAXPROCS" }, |
| 128 | #endif |
| 129 | #ifdef PR_ISBLOCKED |
| 130 | { PR_ISBLOCKED, "PR_ISBLOCKED" }, |
| 131 | #endif |
| 132 | #ifdef PR_SETSTACKSIZE |
| 133 | { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" }, |
| 134 | #endif |
| 135 | #ifdef PR_GETSTACKSIZE |
| 136 | { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" }, |
| 137 | #endif |
| 138 | #ifdef PR_MAXPPROCS |
| 139 | { PR_MAXPPROCS, "PR_MAXPPROCS" }, |
| 140 | #endif |
| 141 | #ifdef PR_UNBLKONEXEC |
| 142 | { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" }, |
| 143 | #endif |
| 144 | #ifdef PR_ATOMICSIM |
| 145 | { PR_ATOMICSIM, "PR_ATOMICSIM" }, |
| 146 | #endif |
| 147 | #ifdef PR_SETEXITSIG |
| 148 | { PR_SETEXITSIG, "PR_SETEXITSIG" }, |
| 149 | #endif |
| 150 | #ifdef PR_RESIDENT |
| 151 | { PR_RESIDENT, "PR_RESIDENT" }, |
| 152 | #endif |
| 153 | #ifdef PR_ATTACHADDR |
| 154 | { PR_ATTACHADDR, "PR_ATTACHADDR" }, |
| 155 | #endif |
| 156 | #ifdef PR_DETACHADDR |
| 157 | { PR_DETACHADDR, "PR_DETACHADDR" }, |
| 158 | #endif |
| 159 | #ifdef PR_TERMCHILD |
| 160 | { PR_TERMCHILD, "PR_TERMCHILD" }, |
| 161 | #endif |
| 162 | #ifdef PR_GETSHMASK |
| 163 | { PR_GETSHMASK, "PR_GETSHMASK" }, |
| 164 | #endif |
| 165 | #ifdef PR_GETNSHARE |
| 166 | { PR_GETNSHARE, "PR_GETNSHARE" }, |
| 167 | #endif |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 168 | #ifdef PR_COREPID |
| 169 | { PR_COREPID, "PR_COREPID" }, |
| 170 | #endif |
| 171 | #ifdef PR_ATTACHADDRPERM |
| 172 | { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" }, |
| 173 | #endif |
| 174 | #ifdef PR_PTHREADEXIT |
| 175 | { PR_PTHREADEXIT, "PR_PTHREADEXIT" }, |
| 176 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 177 | #ifdef PR_SET_PDEATHSIG |
| 178 | { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" }, |
| 179 | #endif |
| 180 | #ifdef PR_GET_PDEATHSIG |
| 181 | { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" }, |
| 182 | #endif |
Dmitry V. Levin | f02cf21 | 2008-09-03 00:54:40 +0000 | [diff] [blame] | 183 | #ifdef PR_GET_DUMPABLE |
| 184 | { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" }, |
| 185 | #endif |
| 186 | #ifdef PR_SET_DUMPABLE |
| 187 | { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" }, |
| 188 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 189 | #ifdef PR_GET_UNALIGN |
| 190 | { PR_GET_UNALIGN, "PR_GET_UNALIGN" }, |
| 191 | #endif |
| 192 | #ifdef PR_SET_UNALIGN |
| 193 | { PR_SET_UNALIGN, "PR_SET_UNALIGN" }, |
| 194 | #endif |
| 195 | #ifdef PR_GET_KEEPCAPS |
Dmitry V. Levin | 8dd31dd | 2008-11-11 00:25:22 +0000 | [diff] [blame] | 196 | { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" }, |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 197 | #endif |
| 198 | #ifdef PR_SET_KEEPCAPS |
Dmitry V. Levin | 8dd31dd | 2008-11-11 00:25:22 +0000 | [diff] [blame] | 199 | { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" }, |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 200 | #endif |
Roland McGrath | e5039fb | 2007-11-03 23:58:07 +0000 | [diff] [blame] | 201 | #ifdef PR_GET_FPEMU |
| 202 | { PR_GET_FPEMU, "PR_GET_FPEMU" }, |
| 203 | #endif |
| 204 | #ifdef PR_SET_FPEMU |
| 205 | { PR_SET_FPEMU, "PR_SET_FPEMU" }, |
| 206 | #endif |
| 207 | #ifdef PR_GET_FPEXC |
| 208 | { PR_GET_FPEXC, "PR_GET_FPEXC" }, |
| 209 | #endif |
| 210 | #ifdef PR_SET_FPEXC |
| 211 | { PR_SET_FPEXC, "PR_SET_FPEXC" }, |
| 212 | #endif |
| 213 | #ifdef PR_GET_TIMING |
| 214 | { PR_GET_TIMING, "PR_GET_TIMING" }, |
| 215 | #endif |
| 216 | #ifdef PR_SET_TIMING |
| 217 | { PR_SET_TIMING, "PR_SET_TIMING" }, |
| 218 | #endif |
| 219 | #ifdef PR_SET_NAME |
| 220 | { PR_SET_NAME, "PR_SET_NAME" }, |
| 221 | #endif |
| 222 | #ifdef PR_GET_NAME |
| 223 | { PR_GET_NAME, "PR_GET_NAME" }, |
| 224 | #endif |
| 225 | #ifdef PR_GET_ENDIAN |
| 226 | { PR_GET_ENDIAN, "PR_GET_ENDIAN" }, |
| 227 | #endif |
| 228 | #ifdef PR_SET_ENDIAN |
| 229 | { PR_SET_ENDIAN, "PR_SET_ENDIAN" }, |
| 230 | #endif |
| 231 | #ifdef PR_GET_SECCOMP |
| 232 | { PR_GET_SECCOMP, "PR_GET_SECCOMP" }, |
| 233 | #endif |
| 234 | #ifdef PR_SET_SECCOMP |
| 235 | { PR_SET_SECCOMP, "PR_SET_SECCOMP" }, |
| 236 | #endif |
Dmitry V. Levin | 8dd31dd | 2008-11-11 00:25:22 +0000 | [diff] [blame] | 237 | #ifdef PR_GET_TSC |
| 238 | { PR_GET_TSC, "PR_GET_TSC" }, |
| 239 | #endif |
| 240 | #ifdef PR_SET_TSC |
| 241 | { PR_SET_TSC, "PR_SET_TSC" }, |
| 242 | #endif |
| 243 | #ifdef PR_GET_SECUREBITS |
| 244 | { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" }, |
| 245 | #endif |
| 246 | #ifdef PR_SET_SECUREBITS |
| 247 | { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" }, |
| 248 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 249 | { 0, NULL }, |
| 250 | }; |
| 251 | |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 252 | |
Roland McGrath | a4d4853 | 2005-06-08 20:45:28 +0000 | [diff] [blame] | 253 | static const char * |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 254 | unalignctl_string (unsigned int ctl) |
| 255 | { |
| 256 | static char buf[16]; |
| 257 | |
| 258 | switch (ctl) { |
| 259 | #ifdef PR_UNALIGN_NOPRINT |
| 260 | case PR_UNALIGN_NOPRINT: |
| 261 | return "NOPRINT"; |
| 262 | #endif |
| 263 | #ifdef PR_UNALIGN_SIGBUS |
| 264 | case PR_UNALIGN_SIGBUS: |
| 265 | return "SIGBUS"; |
| 266 | #endif |
| 267 | default: |
| 268 | break; |
| 269 | } |
| 270 | sprintf(buf, "%x", ctl); |
| 271 | return buf; |
| 272 | } |
| 273 | |
| 274 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 275 | int |
| 276 | sys_prctl(tcp) |
| 277 | struct tcb *tcp; |
| 278 | { |
| 279 | int i; |
| 280 | |
| 281 | if (entering(tcp)) { |
| 282 | printxval(prctl_options, tcp->u_arg[0], "PR_???"); |
| 283 | switch (tcp->u_arg[0]) { |
| 284 | #ifdef PR_GETNSHARE |
| 285 | case PR_GETNSHARE: |
| 286 | break; |
| 287 | #endif |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 288 | #ifdef PR_SET_PDEATHSIG |
| 289 | case PR_SET_PDEATHSIG: |
| 290 | tprintf(", %lu", tcp->u_arg[1]); |
| 291 | break; |
| 292 | #endif |
| 293 | #ifdef PR_GET_PDEATHSIG |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 294 | case PR_GET_PDEATHSIG: |
| 295 | break; |
| 296 | #endif |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 297 | #ifdef PR_SET_DUMPABLE |
| 298 | case PR_SET_DUMPABLE: |
| 299 | tprintf(", %lu", tcp->u_arg[1]); |
| 300 | break; |
| 301 | #endif |
| 302 | #ifdef PR_GET_DUMPABLE |
| 303 | case PR_GET_DUMPABLE: |
| 304 | break; |
| 305 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 306 | #ifdef PR_SET_UNALIGN |
| 307 | case PR_SET_UNALIGN: |
| 308 | tprintf(", %s", unalignctl_string(tcp->u_arg[1])); |
| 309 | break; |
| 310 | #endif |
| 311 | #ifdef PR_GET_UNALIGN |
| 312 | case PR_GET_UNALIGN: |
| 313 | tprintf(", %#lx", tcp->u_arg[1]); |
| 314 | break; |
| 315 | #endif |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 316 | #ifdef PR_SET_KEEPCAPS |
| 317 | case PR_SET_KEEPCAPS: |
| 318 | tprintf(", %lu", tcp->u_arg[1]); |
| 319 | break; |
| 320 | #endif |
| 321 | #ifdef PR_GET_KEEPCAPS |
| 322 | case PR_GET_KEEPCAPS: |
| 323 | break; |
| 324 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 325 | default: |
| 326 | for (i = 1; i < tcp->u_nargs; i++) |
| 327 | tprintf(", %#lx", tcp->u_arg[i]); |
| 328 | break; |
| 329 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 330 | } else { |
| 331 | switch (tcp->u_arg[0]) { |
| 332 | #ifdef PR_GET_PDEATHSIG |
| 333 | case PR_GET_PDEATHSIG: |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 334 | if (umove(tcp, tcp->u_arg[1], &i) < 0) |
| 335 | tprintf(", %#lx", tcp->u_arg[1]); |
| 336 | else |
| 337 | tprintf(", {%u}", i); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 338 | break; |
| 339 | #endif |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 340 | #ifdef PR_GET_DUMPABLE |
| 341 | case PR_GET_DUMPABLE: |
| 342 | return RVAL_UDECIMAL; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 343 | #endif |
| 344 | #ifdef PR_GET_UNALIGN |
| 345 | case PR_GET_UNALIGN: |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 346 | if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0) |
| 347 | break; |
| 348 | tcp->auxstr = unalignctl_string(i); |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 349 | return RVAL_STR; |
Dmitry V. Levin | 50f6013 | 2008-09-03 00:56:52 +0000 | [diff] [blame] | 350 | #endif |
| 351 | #ifdef PR_GET_KEEPCAPS |
| 352 | case PR_GET_KEEPCAPS: |
| 353 | return RVAL_UDECIMAL; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 354 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 355 | default: |
| 356 | break; |
| 357 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 358 | } |
| 359 | return 0; |
| 360 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 361 | #endif /* HAVE_PRCTL */ |
| 362 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 363 | #if defined(FREEBSD) || defined(SUNOS4) || defined(SVR4) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 364 | int |
| 365 | sys_gethostid(tcp) |
| 366 | struct tcb *tcp; |
| 367 | { |
| 368 | if (exiting(tcp)) |
| 369 | return RVAL_HEX; |
| 370 | return 0; |
| 371 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 372 | #endif /* FREEBSD || SUNOS4 || SVR4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 373 | |
| 374 | int |
| 375 | sys_sethostname(tcp) |
| 376 | struct tcb *tcp; |
| 377 | { |
| 378 | if (entering(tcp)) { |
| 379 | printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]); |
| 380 | tprintf(", %lu", tcp->u_arg[1]); |
| 381 | } |
| 382 | return 0; |
| 383 | } |
| 384 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 385 | #if defined(ALPHA) || defined(FREEBSD) || defined(SUNOS4) || defined(SVR4) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 386 | int |
| 387 | sys_gethostname(tcp) |
| 388 | struct tcb *tcp; |
| 389 | { |
| 390 | if (exiting(tcp)) { |
| 391 | if (syserror(tcp)) |
| 392 | tprintf("%#lx", tcp->u_arg[0]); |
| 393 | else |
| 394 | printpath(tcp, tcp->u_arg[0]); |
| 395 | tprintf(", %lu", tcp->u_arg[1]); |
| 396 | } |
| 397 | return 0; |
| 398 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 399 | #endif /* ALPHA || FREEBSD || SUNOS4 || SVR4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 400 | |
| 401 | int |
| 402 | sys_setdomainname(tcp) |
| 403 | struct tcb *tcp; |
| 404 | { |
| 405 | if (entering(tcp)) { |
| 406 | printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]); |
| 407 | tprintf(", %lu", tcp->u_arg[1]); |
| 408 | } |
| 409 | return 0; |
| 410 | } |
| 411 | |
Wichert Akkerman | 5daa028 | 1999-03-15 19:49:42 +0000 | [diff] [blame] | 412 | #if !defined(LINUX) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 413 | |
| 414 | int |
| 415 | sys_getdomainname(tcp) |
| 416 | struct tcb *tcp; |
| 417 | { |
| 418 | if (exiting(tcp)) { |
| 419 | if (syserror(tcp)) |
| 420 | tprintf("%#lx", tcp->u_arg[0]); |
| 421 | else |
| 422 | printpath(tcp, tcp->u_arg[0]); |
| 423 | tprintf(", %lu", tcp->u_arg[1]); |
| 424 | } |
| 425 | return 0; |
| 426 | } |
| 427 | #endif /* !LINUX */ |
| 428 | |
| 429 | int |
| 430 | sys_exit(tcp) |
| 431 | struct tcb *tcp; |
| 432 | { |
| 433 | if (exiting(tcp)) { |
| 434 | fprintf(stderr, "_exit returned!\n"); |
| 435 | return -1; |
| 436 | } |
| 437 | /* special case: we stop tracing this process, finish line now */ |
| 438 | tprintf("%ld) ", tcp->u_arg[0]); |
| 439 | tabto(acolumn); |
| 440 | tprintf("= ?"); |
Denys Vlasenko | ef2fbf8 | 2009-01-06 21:45:06 +0000 | [diff] [blame] | 441 | printtrailer(); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 442 | return 0; |
| 443 | } |
| 444 | |
| 445 | int |
| 446 | internal_exit(tcp) |
| 447 | struct tcb *tcp; |
| 448 | { |
Roland McGrath | e85bbfe | 2003-01-09 06:53:31 +0000 | [diff] [blame] | 449 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 450 | tcp->flags |= TCB_EXITING; |
Roland McGrath | e85bbfe | 2003-01-09 06:53:31 +0000 | [diff] [blame] | 451 | #ifdef __NR_exit_group |
Roland McGrath | 08267b8 | 2004-02-20 22:56:43 +0000 | [diff] [blame] | 452 | # ifdef IA64 |
| 453 | if (ia32) { |
| 454 | if (tcp->scno == 252) |
| 455 | tcp->flags |= TCB_GROUP_EXITING; |
| 456 | } else |
| 457 | # endif |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 458 | if (known_scno(tcp) == __NR_exit_group) |
Roland McGrath | e85bbfe | 2003-01-09 06:53:31 +0000 | [diff] [blame] | 459 | tcp->flags |= TCB_GROUP_EXITING; |
| 460 | #endif |
| 461 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 462 | return 0; |
| 463 | } |
| 464 | |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 465 | /* TCP is creating a child we want to follow. |
| 466 | If there will be space in tcbtab for it, set TCB_FOLLOWFORK and return 0. |
| 467 | If not, clear TCB_FOLLOWFORK, print an error, and return 1. */ |
| 468 | static void |
| 469 | fork_tcb(struct tcb *tcp) |
| 470 | { |
| 471 | if (nprocs == tcbtabsize) |
| 472 | expand_tcbtab(); |
| 473 | |
| 474 | tcp->flags |= TCB_FOLLOWFORK; |
| 475 | } |
| 476 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 477 | #ifdef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 478 | |
| 479 | int |
Denys Vlasenko | 418d66a | 2009-01-17 01:52:54 +0000 | [diff] [blame] | 480 | sys_fork(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 481 | { |
Dmitry V. Levin | 21a7534 | 2008-09-03 01:22:18 +0000 | [diff] [blame] | 482 | if (exiting(tcp) && !syserror(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 483 | if (getrval2(tcp)) { |
| 484 | tcp->auxstr = "child process"; |
| 485 | return RVAL_UDECIMAL | RVAL_STR; |
| 486 | } |
| 487 | } |
| 488 | return 0; |
| 489 | } |
| 490 | |
John Hughes | 4e36a81 | 2001-04-18 15:11:51 +0000 | [diff] [blame] | 491 | #if UNIXWARE > 2 |
| 492 | |
| 493 | int |
| 494 | sys_rfork(tcp) |
| 495 | struct tcb *tcp; |
| 496 | { |
| 497 | if (entering(tcp)) { |
| 498 | tprintf ("%ld", tcp->u_arg[0]); |
| 499 | } |
Dmitry V. Levin | 21a7534 | 2008-09-03 01:22:18 +0000 | [diff] [blame] | 500 | else if (!syserror(tcp)) { |
John Hughes | 4e36a81 | 2001-04-18 15:11:51 +0000 | [diff] [blame] | 501 | if (getrval2(tcp)) { |
| 502 | tcp->auxstr = "child process"; |
| 503 | return RVAL_UDECIMAL | RVAL_STR; |
| 504 | } |
| 505 | } |
| 506 | return 0; |
| 507 | } |
| 508 | |
| 509 | #endif |
| 510 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 511 | int |
| 512 | internal_fork(tcp) |
| 513 | struct tcb *tcp; |
| 514 | { |
| 515 | struct tcb *tcpchild; |
| 516 | |
| 517 | if (exiting(tcp)) { |
Roland McGrath | f3a0e1b | 2003-02-20 02:45:22 +0000 | [diff] [blame] | 518 | #ifdef SYS_rfork |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 519 | if (known_scno(tcp) == SYS_rfork && !(tcp->u_arg[0]&RFPROC)) |
Roland McGrath | f3a0e1b | 2003-02-20 02:45:22 +0000 | [diff] [blame] | 520 | return 0; |
| 521 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 522 | if (getrval2(tcp)) |
| 523 | return 0; |
| 524 | if (!followfork) |
| 525 | return 0; |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 526 | fork_tcb(tcp); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 527 | if (syserror(tcp)) |
| 528 | return 0; |
Denys Vlasenko | 418d66a | 2009-01-17 01:52:54 +0000 | [diff] [blame] | 529 | tcpchild = alloctcb(tcp->u_rval); |
Wichert Akkerman | 2e4ffe5 | 2000-09-03 23:57:48 +0000 | [diff] [blame] | 530 | if (proc_open(tcpchild, 2) < 0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 531 | droptcb(tcpchild); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 532 | } |
| 533 | return 0; |
| 534 | } |
| 535 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 536 | #else /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 537 | |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 538 | #ifdef LINUX |
| 539 | |
| 540 | /* defines copied from linux/sched.h since we can't include that |
| 541 | * ourselves (it conflicts with *lots* of libc includes) |
| 542 | */ |
| 543 | #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ |
| 544 | #define CLONE_VM 0x00000100 /* set if VM shared between processes */ |
| 545 | #define CLONE_FS 0x00000200 /* set if fs info shared between processes */ |
| 546 | #define CLONE_FILES 0x00000400 /* set if open files shared between processes */ |
| 547 | #define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */ |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 548 | #define CLONE_IDLETASK 0x00001000 /* kernel-only flag */ |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 549 | #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */ |
| 550 | #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ |
| 551 | #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] | 552 | #define CLONE_THREAD 0x00010000 /* Same thread group? */ |
| 553 | #define CLONE_NEWNS 0x00020000 /* New namespace group? */ |
| 554 | #define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */ |
| 555 | #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */ |
| 556 | #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */ |
| 557 | #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */ |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 558 | #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */ |
| 559 | #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */ |
Dmitry V. Levin | e3d4b68 | 2010-12-03 17:19:51 +0000 | [diff] [blame] | 560 | #define CLONE_STOPPED 0x02000000 /* Start in stopped state */ |
| 561 | #define CLONE_NEWUTS 0x04000000 /* New utsname group? */ |
| 562 | #define CLONE_NEWIPC 0x08000000 /* New ipcs */ |
| 563 | #define CLONE_NEWUSER 0x10000000 /* New user namespace */ |
| 564 | #define CLONE_NEWPID 0x20000000 /* New pid namespace */ |
| 565 | #define CLONE_NEWNET 0x40000000 /* New network namespace */ |
| 566 | #define CLONE_IO 0x80000000 /* Clone io context */ |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 567 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 568 | static const struct xlat clone_flags[] = { |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 569 | { CLONE_VM, "CLONE_VM" }, |
| 570 | { CLONE_FS, "CLONE_FS" }, |
| 571 | { CLONE_FILES, "CLONE_FILES" }, |
| 572 | { CLONE_SIGHAND, "CLONE_SIGHAND" }, |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 573 | { CLONE_IDLETASK, "CLONE_IDLETASK"}, |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 574 | { CLONE_PTRACE, "CLONE_PTRACE" }, |
| 575 | { CLONE_VFORK, "CLONE_VFORK" }, |
| 576 | { CLONE_PARENT, "CLONE_PARENT" }, |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 577 | { CLONE_THREAD, "CLONE_THREAD" }, |
| 578 | { CLONE_NEWNS, "CLONE_NEWNS" }, |
| 579 | { CLONE_SYSVSEM, "CLONE_SYSVSEM" }, |
| 580 | { CLONE_SETTLS, "CLONE_SETTLS" }, |
| 581 | { CLONE_PARENT_SETTID,"CLONE_PARENT_SETTID" }, |
| 582 | { CLONE_CHILD_CLEARTID,"CLONE_CHILD_CLEARTID" }, |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 583 | { CLONE_UNTRACED, "CLONE_UNTRACED" }, |
| 584 | { CLONE_CHILD_SETTID,"CLONE_CHILD_SETTID" }, |
Dmitry V. Levin | e3d4b68 | 2010-12-03 17:19:51 +0000 | [diff] [blame] | 585 | { CLONE_STOPPED, "CLONE_STOPPED" }, |
| 586 | { CLONE_NEWUTS, "CLONE_NEWUTS" }, |
| 587 | { CLONE_NEWIPC, "CLONE_NEWIPC" }, |
| 588 | { CLONE_NEWUSER, "CLONE_NEWUSER" }, |
| 589 | { CLONE_NEWPID, "CLONE_NEWPID" }, |
| 590 | { CLONE_NEWNET, "CLONE_NEWNET" }, |
| 591 | { CLONE_IO, "CLONE_IO" }, |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 592 | { 0, NULL }, |
| 593 | }; |
| 594 | |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 595 | # ifdef I386 |
| 596 | # include <asm/ldt.h> |
Roland McGrath | 7decfb2 | 2004-03-01 22:10:52 +0000 | [diff] [blame] | 597 | # ifdef HAVE_STRUCT_USER_DESC |
| 598 | # define modify_ldt_ldt_s user_desc |
| 599 | # endif |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 600 | extern void print_ldt_entry(); |
| 601 | # endif |
| 602 | |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 603 | # if defined IA64 |
| 604 | # define ARG_FLAGS 0 |
| 605 | # define ARG_STACK 1 |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 606 | # define ARG_STACKSIZE (known_scno(tcp) == SYS_clone2 ? 2 : -1) |
| 607 | # define ARG_PTID (known_scno(tcp) == SYS_clone2 ? 3 : 2) |
| 608 | # define ARG_CTID (known_scno(tcp) == SYS_clone2 ? 4 : 3) |
| 609 | # define ARG_TLS (known_scno(tcp) == SYS_clone2 ? 5 : 4) |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 610 | # elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32 |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 611 | # define ARG_STACK 0 |
| 612 | # define ARG_FLAGS 1 |
| 613 | # define ARG_PTID 2 |
Roland McGrath | fe5fdb2 | 2003-05-23 00:29:05 +0000 | [diff] [blame] | 614 | # define ARG_CTID 3 |
| 615 | # define ARG_TLS 4 |
Roland McGrath | 9c555e7 | 2003-07-09 09:47:59 +0000 | [diff] [blame] | 616 | # elif defined X86_64 || defined ALPHA |
Roland McGrath | 361aac5 | 2003-03-18 07:43:42 +0000 | [diff] [blame] | 617 | # define ARG_FLAGS 0 |
| 618 | # define ARG_STACK 1 |
| 619 | # define ARG_PTID 2 |
| 620 | # define ARG_CTID 3 |
| 621 | # define ARG_TLS 4 |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 622 | # else |
| 623 | # define ARG_FLAGS 0 |
| 624 | # define ARG_STACK 1 |
| 625 | # define ARG_PTID 2 |
| 626 | # define ARG_TLS 3 |
| 627 | # define ARG_CTID 4 |
| 628 | # endif |
| 629 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 630 | int |
| 631 | sys_clone(tcp) |
| 632 | struct tcb *tcp; |
| 633 | { |
| 634 | if (exiting(tcp)) { |
Wang Chao | cbdd190 | 2010-09-02 15:08:59 +0800 | [diff] [blame] | 635 | const char *sep = "|"; |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 636 | unsigned long flags = tcp->u_arg[ARG_FLAGS]; |
| 637 | tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]); |
| 638 | # ifdef ARG_STACKSIZE |
| 639 | if (ARG_STACKSIZE != -1) |
| 640 | tprintf("stack_size=%#lx, ", |
| 641 | tcp->u_arg[ARG_STACKSIZE]); |
Roland McGrath | b4968be | 2003-01-20 09:04:33 +0000 | [diff] [blame] | 642 | # endif |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 643 | tprintf("flags="); |
Wang Chao | cbdd190 | 2010-09-02 15:08:59 +0800 | [diff] [blame] | 644 | if (!printflags(clone_flags, flags &~ CSIGNAL, NULL)) |
| 645 | sep = ""; |
Roland McGrath | 984154d | 2003-05-23 01:08:42 +0000 | [diff] [blame] | 646 | if ((flags & CSIGNAL) != 0) |
Wang Chao | cbdd190 | 2010-09-02 15:08:59 +0800 | [diff] [blame] | 647 | tprintf("%s%s", sep, signame(flags & CSIGNAL)); |
Roland McGrath | b4968be | 2003-01-20 09:04:33 +0000 | [diff] [blame] | 648 | if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 649 | |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0) |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 650 | return 0; |
Roland McGrath | 6f67a98 | 2003-03-21 07:33:15 +0000 | [diff] [blame] | 651 | if (flags & CLONE_PARENT_SETTID) |
| 652 | tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]); |
Roland McGrath | b4968be | 2003-01-20 09:04:33 +0000 | [diff] [blame] | 653 | if (flags & CLONE_SETTLS) { |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 654 | # ifdef I386 |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 655 | struct modify_ldt_ldt_s copy; |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 656 | if (umove(tcp, tcp->u_arg[ARG_TLS], ©) != -1) { |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 657 | tprintf(", {entry_number:%d, ", |
| 658 | copy.entry_number); |
| 659 | if (!verbose(tcp)) |
| 660 | tprintf("...}"); |
| 661 | else |
| 662 | print_ldt_entry(©); |
| 663 | } |
| 664 | else |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 665 | # endif |
Roland McGrath | 43f2c84 | 2003-03-12 09:58:14 +0000 | [diff] [blame] | 666 | tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]); |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 667 | } |
Roland McGrath | 9677b3a | 2003-03-12 09:54:36 +0000 | [diff] [blame] | 668 | if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID)) |
| 669 | tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 670 | } |
| 671 | return 0; |
| 672 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 673 | |
| 674 | int |
| 675 | sys_unshare(struct tcb *tcp) |
| 676 | { |
| 677 | if (entering(tcp)) |
| 678 | printflags(clone_flags, tcp->u_arg[0], "CLONE_???"); |
| 679 | return 0; |
| 680 | } |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 681 | #endif /* LINUX */ |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 682 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 683 | int |
| 684 | sys_fork(tcp) |
| 685 | struct tcb *tcp; |
| 686 | { |
| 687 | if (exiting(tcp)) |
| 688 | return RVAL_UDECIMAL; |
| 689 | return 0; |
| 690 | } |
| 691 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 692 | int |
Denys Vlasenko | 418d66a | 2009-01-17 01:52:54 +0000 | [diff] [blame] | 693 | change_syscall(struct tcb *tcp, int new) |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 694 | { |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 695 | #ifdef LINUX |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 696 | #if defined(I386) |
| 697 | /* Attempt to make vfork into fork, which we can follow. */ |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 698 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0) |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 699 | return -1; |
| 700 | return 0; |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 701 | #elif defined(X86_64) |
| 702 | /* Attempt to make vfork into fork, which we can follow. */ |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 703 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_RAX * 8), new) < 0) |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 704 | return -1; |
| 705 | return 0; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 706 | #elif defined(POWERPC) |
Roland McGrath | eb28535 | 2003-01-14 09:59:00 +0000 | [diff] [blame] | 707 | if (ptrace(PTRACE_POKEUSER, tcp->pid, |
| 708 | (char*)(sizeof(unsigned long)*PT_R0), new) < 0) |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 709 | return -1; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 710 | return 0; |
Michal Ludvig | 10a88d0 | 2002-10-07 14:31:00 +0000 | [diff] [blame] | 711 | #elif defined(S390) || defined(S390X) |
| 712 | /* s390 linux after 2.4.7 has a hook in entry.S to allow this */ |
| 713 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR2), new)<0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 714 | return -1; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 715 | return 0; |
| 716 | #elif defined(M68K) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 717 | 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] | 718 | return -1; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 719 | return 0; |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 720 | #elif defined(SPARC) || defined(SPARC64) |
Mike Frysinger | 8566c50 | 2009-10-12 11:05:14 -0400 | [diff] [blame] | 721 | struct pt_regs regs; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 722 | if (ptrace(PTRACE_GETREGS, tcp->pid, (char*)®s, 0)<0) |
| 723 | return -1; |
Mike Frysinger | 8566c50 | 2009-10-12 11:05:14 -0400 | [diff] [blame] | 724 | regs.u_regs[U_REG_G1] = new; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 725 | if (ptrace(PTRACE_SETREGS, tcp->pid, (char*)®s, 0)<0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 726 | return -1; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 727 | return 0; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 728 | #elif defined(MIPS) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 729 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new)<0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 730 | return -1; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 731 | return 0; |
| 732 | #elif defined(ALPHA) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 733 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new)<0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 734 | return -1; |
| 735 | return 0; |
| 736 | #elif defined(AVR32) |
| 737 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_R8), new) < 0) |
| 738 | return -1; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 739 | return 0; |
Dmitry V. Levin | 87ea1f4 | 2008-11-10 22:21:41 +0000 | [diff] [blame] | 740 | #elif defined(BFIN) |
| 741 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_P0), new)<0) |
| 742 | return -1; |
| 743 | return 0; |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 744 | #elif defined(IA64) |
Roland McGrath | 08267b8 | 2004-02-20 22:56:43 +0000 | [diff] [blame] | 745 | if (ia32) { |
| 746 | switch (new) { |
Denys Vlasenko | 418d66a | 2009-01-17 01:52:54 +0000 | [diff] [blame] | 747 | case 2: |
| 748 | break; /* x86 SYS_fork */ |
| 749 | case SYS_clone: |
| 750 | new = 120; |
| 751 | break; |
| 752 | default: |
Roland McGrath | 08267b8 | 2004-02-20 22:56:43 +0000 | [diff] [blame] | 753 | fprintf(stderr, "%s: unexpected syscall %d\n", |
| 754 | __FUNCTION__, new); |
| 755 | return -1; |
| 756 | } |
| 757 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R1), new)<0) |
| 758 | return -1; |
| 759 | } else if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R15), new)<0) |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 760 | return -1; |
| 761 | return 0; |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 762 | #elif defined(HPPA) |
| 763 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR20), new)<0) |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 764 | return -1; |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 765 | return 0; |
Wichert Akkerman | ccef637 | 2002-05-01 16:39:22 +0000 | [diff] [blame] | 766 | #elif defined(SH) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 767 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*(REG_REG0+3)), new)<0) |
| 768 | return -1; |
| 769 | return 0; |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 770 | #elif defined(SH64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 771 | /* Top half of reg encodes the no. of args n as 0x1n. |
| 772 | Assume 0 args as kernel never actually checks... */ |
| 773 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_SYSCALL), |
| 774 | 0x100000 | new) < 0) |
| 775 | return -1; |
| 776 | return 0; |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 777 | #elif defined(CRISV10) || defined(CRISV32) |
| 778 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R9), new) < 0) |
| 779 | return -1; |
| 780 | return 0; |
Roland McGrath | f691bd2 | 2006-04-25 07:34:41 +0000 | [diff] [blame] | 781 | #elif defined(ARM) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 782 | /* 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] | 783 | # ifndef PTRACE_SET_SYSCALL |
| 784 | # define PTRACE_SET_SYSCALL 23 |
| 785 | # endif |
| 786 | |
Dmitry V. Levin | 7674006 | 2009-09-18 11:30:14 +0000 | [diff] [blame] | 787 | if (ptrace (PTRACE_SET_SYSCALL, tcp->pid, 0, new & 0xffff) != 0) |
Roland McGrath | f691bd2 | 2006-04-25 07:34:41 +0000 | [diff] [blame] | 788 | return -1; |
| 789 | |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 790 | return 0; |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 791 | #elif defined(TILE) |
| 792 | if (ptrace(PTRACE_POKEUSER, tcp->pid, |
| 793 | (char*)PTREGS_OFFSET_REG(0), |
| 794 | new) != 0) |
| 795 | return -1; |
| 796 | return 0; |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 797 | #elif defined(MICROBLAZE) |
| 798 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new)<0) |
| 799 | return -1; |
| 800 | return 0; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 801 | #else |
| 802 | #warning Do not know how to handle change_syscall for this architecture |
| 803 | #endif /* architecture */ |
| 804 | #endif /* LINUX */ |
| 805 | return -1; |
| 806 | } |
| 807 | |
Dmitry V. Levin | 257e157 | 2009-12-26 17:55:24 +0000 | [diff] [blame] | 808 | #ifdef LINUX |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 809 | int |
Wang Chao | ca8ab8d | 2010-11-12 17:26:08 +0800 | [diff] [blame] | 810 | handle_new_child(struct tcb *tcp, int pid, int bpt) |
| 811 | { |
| 812 | struct tcb *tcpchild; |
| 813 | |
| 814 | #ifdef CLONE_PTRACE /* See new setbpt code. */ |
| 815 | tcpchild = pid2tcb(pid); |
| 816 | if (tcpchild != NULL) { |
| 817 | /* The child already reported its startup trap |
| 818 | before the parent reported its syscall return. */ |
| 819 | if ((tcpchild->flags |
| 820 | & (TCB_STARTUP|TCB_ATTACHED|TCB_SUSPENDED)) |
| 821 | != (TCB_STARTUP|TCB_ATTACHED|TCB_SUSPENDED)) |
| 822 | fprintf(stderr, "\ |
| 823 | [preattached child %d of %d in weird state!]\n", |
| 824 | pid, tcp->pid); |
| 825 | } |
| 826 | else |
| 827 | #endif /* CLONE_PTRACE */ |
| 828 | { |
| 829 | fork_tcb(tcp); |
| 830 | tcpchild = alloctcb(pid); |
| 831 | } |
| 832 | |
| 833 | #ifndef CLONE_PTRACE |
| 834 | /* Attach to the new child */ |
| 835 | if (ptrace(PTRACE_ATTACH, pid, (char *) 1, 0) < 0) { |
| 836 | if (bpt) |
| 837 | clearbpt(tcp); |
| 838 | perror("PTRACE_ATTACH"); |
| 839 | fprintf(stderr, "Too late?\n"); |
| 840 | droptcb(tcpchild); |
| 841 | return 0; |
| 842 | } |
| 843 | #endif /* !CLONE_PTRACE */ |
| 844 | |
| 845 | if (bpt) |
| 846 | clearbpt(tcp); |
| 847 | |
| 848 | tcpchild->flags |= TCB_ATTACHED; |
| 849 | /* Child has BPT too, must be removed on first occasion. */ |
| 850 | if (bpt) { |
| 851 | tcpchild->flags |= TCB_BPTSET; |
| 852 | tcpchild->baddr = tcp->baddr; |
| 853 | memcpy(tcpchild->inst, tcp->inst, |
| 854 | sizeof tcpchild->inst); |
| 855 | } |
| 856 | tcpchild->parent = tcp; |
| 857 | tcp->nchildren++; |
| 858 | if (tcpchild->flags & TCB_SUSPENDED) { |
| 859 | /* The child was born suspended, due to our having |
| 860 | forced CLONE_PTRACE. */ |
| 861 | if (bpt) |
| 862 | clearbpt(tcpchild); |
| 863 | |
| 864 | tcpchild->flags &= ~(TCB_SUSPENDED|TCB_STARTUP); |
| 865 | if (ptrace_restart(PTRACE_SYSCALL, tcpchild, 0) < 0) |
| 866 | return -1; |
| 867 | |
| 868 | if (!qflag) |
| 869 | fprintf(stderr, "\ |
| 870 | Process %u resumed (parent %d ready)\n", |
| 871 | pid, tcp->pid); |
| 872 | } |
| 873 | else { |
| 874 | if (!qflag) |
| 875 | fprintf(stderr, "Process %d attached\n", pid); |
| 876 | } |
| 877 | |
| 878 | #ifdef TCB_CLONE_THREAD |
| 879 | if (sysent[tcp->scno].sys_func == sys_clone) |
| 880 | { |
| 881 | /* |
| 882 | * Save the flags used in this call, |
| 883 | * in case we point TCP to our parent below. |
| 884 | */ |
| 885 | int call_flags = tcp->u_arg[ARG_FLAGS]; |
| 886 | if ((tcp->flags & TCB_CLONE_THREAD) && |
| 887 | tcp->parent != NULL) { |
| 888 | /* The parent in this clone is itself a |
| 889 | thread belonging to another process. |
| 890 | There is no meaning to the parentage |
| 891 | relationship of the new child with the |
| 892 | thread, only with the process. We |
| 893 | associate the new thread with our |
| 894 | parent. Since this is done for every |
| 895 | new thread, there will never be a |
| 896 | TCB_CLONE_THREAD process that has |
| 897 | children. */ |
| 898 | --tcp->nchildren; |
| 899 | tcp = tcp->parent; |
| 900 | tcpchild->parent = tcp; |
| 901 | ++tcp->nchildren; |
| 902 | } |
| 903 | if (call_flags & CLONE_THREAD) { |
| 904 | tcpchild->flags |= TCB_CLONE_THREAD; |
| 905 | ++tcp->nclone_threads; |
| 906 | } |
| 907 | if ((call_flags & CLONE_PARENT) && |
| 908 | !(call_flags & CLONE_THREAD)) { |
| 909 | --tcp->nchildren; |
| 910 | tcpchild->parent = NULL; |
| 911 | if (tcp->parent != NULL) { |
| 912 | tcp = tcp->parent; |
| 913 | tcpchild->parent = tcp; |
| 914 | ++tcp->nchildren; |
| 915 | } |
| 916 | } |
| 917 | } |
| 918 | #endif /* TCB_CLONE_THREAD */ |
| 919 | return 0; |
| 920 | } |
| 921 | |
| 922 | int |
Dmitry V. Levin | 257e157 | 2009-12-26 17:55:24 +0000 | [diff] [blame] | 923 | internal_fork(struct tcb *tcp) |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 924 | { |
Wang Chao | ca8ab8d | 2010-11-12 17:26:08 +0800 | [diff] [blame] | 925 | if ((ptrace_setoptions |
| 926 | & (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK)) |
| 927 | == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK)) |
| 928 | return 0; |
| 929 | |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 930 | if (entering(tcp)) { |
Wang Chao | e636c85 | 2010-09-16 11:20:56 +0800 | [diff] [blame] | 931 | tcp->flags &= ~TCB_FOLLOWFORK; |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 932 | if (!followfork) |
| 933 | return 0; |
Wang Chao | e636c85 | 2010-09-16 11:20:56 +0800 | [diff] [blame] | 934 | /* |
| 935 | * In occasion of using PTRACE_O_TRACECLONE, we won't see the |
| 936 | * new child if clone is called with flag CLONE_UNTRACED, so |
| 937 | * we keep the same logic with that option and don't trace it. |
| 938 | */ |
| 939 | if ((sysent[tcp->scno].sys_func == sys_clone) && |
| 940 | (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED)) |
| 941 | return 0; |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 942 | fork_tcb(tcp); |
| 943 | if (setbpt(tcp) < 0) |
| 944 | return 0; |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 945 | } else { |
Dmitry V. Levin | 257e157 | 2009-12-26 17:55:24 +0000 | [diff] [blame] | 946 | int pid; |
| 947 | int bpt; |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 948 | |
| 949 | if (!(tcp->flags & TCB_FOLLOWFORK)) |
| 950 | return 0; |
Wichert Akkerman | 9b0c31d | 2000-09-03 21:56:29 +0000 | [diff] [blame] | 951 | |
Dmitry V. Levin | 257e157 | 2009-12-26 17:55:24 +0000 | [diff] [blame] | 952 | bpt = tcp->flags & TCB_BPTSET; |
| 953 | |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 954 | if (syserror(tcp)) { |
| 955 | if (bpt) |
| 956 | clearbpt(tcp); |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 957 | return 0; |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 958 | } |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 959 | |
| 960 | pid = tcp->u_rval; |
Roland McGrath | e85bbfe | 2003-01-09 06:53:31 +0000 | [diff] [blame] | 961 | |
Wang Chao | ca8ab8d | 2010-11-12 17:26:08 +0800 | [diff] [blame] | 962 | return handle_new_child(tcp, pid, bpt); |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 963 | } |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 964 | return 0; |
| 965 | } |
Dmitry V. Levin | 257e157 | 2009-12-26 17:55:24 +0000 | [diff] [blame] | 966 | |
| 967 | #else /* !LINUX */ |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 968 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 969 | int |
| 970 | internal_fork(tcp) |
| 971 | struct tcb *tcp; |
| 972 | { |
| 973 | struct tcb *tcpchild; |
| 974 | int pid; |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 975 | int dont_follow = 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 976 | |
| 977 | #ifdef SYS_vfork |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 978 | if (known_scno(tcp) == SYS_vfork) { |
Nate Sammons | ccd8f21 | 1999-03-29 22:57:54 +0000 | [diff] [blame] | 979 | /* Attempt to make vfork into fork, which we can follow. */ |
Roland McGrath | 41c4822 | 2008-07-18 00:25:10 +0000 | [diff] [blame] | 980 | if (change_syscall(tcp, SYS_fork) < 0) |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 981 | dont_follow = 1; |
Nate Sammons | ccd8f21 | 1999-03-29 22:57:54 +0000 | [diff] [blame] | 982 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 983 | #endif |
| 984 | if (entering(tcp)) { |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 985 | if (!followfork || dont_follow) |
| 986 | return 0; |
| 987 | fork_tcb(tcp); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 988 | if (setbpt(tcp) < 0) |
| 989 | return 0; |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 990 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 991 | else { |
| 992 | int bpt = tcp->flags & TCB_BPTSET; |
| 993 | |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 994 | if (!(tcp->flags & TCB_FOLLOWFORK)) |
| 995 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 996 | if (bpt) |
| 997 | clearbpt(tcp); |
| 998 | |
| 999 | if (syserror(tcp)) |
| 1000 | return 0; |
| 1001 | |
| 1002 | pid = tcp->u_rval; |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 1003 | fork_tcb(tcp); |
Denys Vlasenko | 418d66a | 2009-01-17 01:52:54 +0000 | [diff] [blame] | 1004 | tcpchild = alloctcb(pid); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1005 | #ifdef SUNOS4 |
| 1006 | #ifdef oldway |
| 1007 | /* The child must have run before it can be attached. */ |
| 1008 | { |
| 1009 | struct timeval tv; |
| 1010 | tv.tv_sec = 0; |
| 1011 | tv.tv_usec = 10000; |
| 1012 | select(0, NULL, NULL, NULL, &tv); |
| 1013 | } |
| 1014 | if (ptrace(PTRACE_ATTACH, pid, (char *)1, 0) < 0) { |
| 1015 | perror("PTRACE_ATTACH"); |
| 1016 | fprintf(stderr, "Too late?\n"); |
| 1017 | droptcb(tcpchild); |
| 1018 | return 0; |
| 1019 | } |
| 1020 | #else /* !oldway */ |
| 1021 | /* Try to catch the new process as soon as possible. */ |
| 1022 | { |
| 1023 | int i; |
| 1024 | for (i = 0; i < 1024; i++) |
| 1025 | if (ptrace(PTRACE_ATTACH, pid, (char *) 1, 0) >= 0) |
| 1026 | break; |
| 1027 | if (i == 1024) { |
| 1028 | perror("PTRACE_ATTACH"); |
| 1029 | fprintf(stderr, "Too late?\n"); |
| 1030 | droptcb(tcpchild); |
| 1031 | return 0; |
| 1032 | } |
| 1033 | } |
| 1034 | #endif /* !oldway */ |
| 1035 | #endif /* SUNOS4 */ |
| 1036 | tcpchild->flags |= TCB_ATTACHED; |
| 1037 | /* Child has BPT too, must be removed on first occasion */ |
| 1038 | if (bpt) { |
| 1039 | tcpchild->flags |= TCB_BPTSET; |
| 1040 | tcpchild->baddr = tcp->baddr; |
| 1041 | memcpy(tcpchild->inst, tcp->inst, |
| 1042 | sizeof tcpchild->inst); |
| 1043 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1044 | tcpchild->parent = tcp; |
| 1045 | tcp->nchildren++; |
| 1046 | if (!qflag) |
| 1047 | fprintf(stderr, "Process %d attached\n", pid); |
| 1048 | } |
| 1049 | return 0; |
| 1050 | } |
| 1051 | |
Dmitry V. Levin | 257e157 | 2009-12-26 17:55:24 +0000 | [diff] [blame] | 1052 | #endif /* !LINUX */ |
| 1053 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1054 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1055 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1056 | #if defined(SUNOS4) || defined(LINUX) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1057 | |
| 1058 | int |
| 1059 | sys_vfork(tcp) |
| 1060 | struct tcb *tcp; |
| 1061 | { |
| 1062 | if (exiting(tcp)) |
| 1063 | return RVAL_UDECIMAL; |
| 1064 | return 0; |
| 1065 | } |
| 1066 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1067 | #endif /* SUNOS4 || LINUX || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1068 | |
| 1069 | #ifndef LINUX |
| 1070 | |
| 1071 | static char idstr[16]; |
| 1072 | |
| 1073 | int |
| 1074 | sys_getpid(tcp) |
| 1075 | struct tcb *tcp; |
| 1076 | { |
| 1077 | if (exiting(tcp)) { |
| 1078 | sprintf(idstr, "ppid %lu", getrval2(tcp)); |
| 1079 | tcp->auxstr = idstr; |
| 1080 | return RVAL_STR; |
| 1081 | } |
| 1082 | return 0; |
| 1083 | } |
| 1084 | |
| 1085 | int |
| 1086 | sys_getuid(tcp) |
| 1087 | struct tcb *tcp; |
| 1088 | { |
| 1089 | if (exiting(tcp)) { |
| 1090 | sprintf(idstr, "euid %lu", getrval2(tcp)); |
| 1091 | tcp->auxstr = idstr; |
| 1092 | return RVAL_STR; |
| 1093 | } |
| 1094 | return 0; |
| 1095 | } |
| 1096 | |
| 1097 | int |
| 1098 | sys_getgid(tcp) |
| 1099 | struct tcb *tcp; |
| 1100 | { |
| 1101 | if (exiting(tcp)) { |
| 1102 | sprintf(idstr, "egid %lu", getrval2(tcp)); |
| 1103 | tcp->auxstr = idstr; |
| 1104 | return RVAL_STR; |
| 1105 | } |
| 1106 | return 0; |
| 1107 | } |
| 1108 | |
| 1109 | #endif /* !LINUX */ |
| 1110 | |
| 1111 | #ifdef LINUX |
| 1112 | |
| 1113 | int |
| 1114 | sys_setuid(tcp) |
| 1115 | struct tcb *tcp; |
| 1116 | { |
| 1117 | if (entering(tcp)) { |
| 1118 | tprintf("%u", (uid_t) tcp->u_arg[0]); |
| 1119 | } |
| 1120 | return 0; |
| 1121 | } |
| 1122 | |
| 1123 | int |
| 1124 | sys_setgid(tcp) |
| 1125 | struct tcb *tcp; |
| 1126 | { |
| 1127 | if (entering(tcp)) { |
| 1128 | tprintf("%u", (gid_t) tcp->u_arg[0]); |
| 1129 | } |
| 1130 | return 0; |
| 1131 | } |
| 1132 | |
| 1133 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 1134 | sys_getresuid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1135 | { |
| 1136 | if (exiting(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1137 | __kernel_uid_t uid; |
| 1138 | if (syserror(tcp)) |
| 1139 | tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0], |
| 1140 | tcp->u_arg[1], tcp->u_arg[2]); |
| 1141 | else { |
| 1142 | if (umove(tcp, tcp->u_arg[0], &uid) < 0) |
| 1143 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 1144 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1145 | tprintf("[%lu], ", (unsigned long) uid); |
Roland McGrath | 9bd6b42 | 2003-02-24 07:13:51 +0000 | [diff] [blame] | 1146 | if (umove(tcp, tcp->u_arg[1], &uid) < 0) |
| 1147 | tprintf("%#lx, ", tcp->u_arg[1]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1148 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1149 | tprintf("[%lu], ", (unsigned long) uid); |
Roland McGrath | 9bd6b42 | 2003-02-24 07:13:51 +0000 | [diff] [blame] | 1150 | if (umove(tcp, tcp->u_arg[2], &uid) < 0) |
| 1151 | tprintf("%#lx", tcp->u_arg[2]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1152 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1153 | tprintf("[%lu]", (unsigned long) uid); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1154 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1155 | } |
| 1156 | return 0; |
| 1157 | } |
| 1158 | |
| 1159 | int |
| 1160 | sys_getresgid(tcp) |
| 1161 | struct tcb *tcp; |
| 1162 | { |
| 1163 | if (exiting(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1164 | __kernel_gid_t gid; |
| 1165 | if (syserror(tcp)) |
| 1166 | tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0], |
| 1167 | tcp->u_arg[1], tcp->u_arg[2]); |
| 1168 | else { |
| 1169 | if (umove(tcp, tcp->u_arg[0], &gid) < 0) |
| 1170 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 1171 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1172 | tprintf("[%lu], ", (unsigned long) gid); |
Roland McGrath | d245092 | 2003-02-24 10:18:07 +0000 | [diff] [blame] | 1173 | if (umove(tcp, tcp->u_arg[1], &gid) < 0) |
| 1174 | tprintf("%#lx, ", tcp->u_arg[1]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1175 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1176 | tprintf("[%lu], ", (unsigned long) gid); |
Roland McGrath | d245092 | 2003-02-24 10:18:07 +0000 | [diff] [blame] | 1177 | if (umove(tcp, tcp->u_arg[2], &gid) < 0) |
| 1178 | tprintf("%#lx", tcp->u_arg[2]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1179 | else |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1180 | tprintf("[%lu]", (unsigned long) gid); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1181 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1182 | } |
| 1183 | return 0; |
| 1184 | } |
| 1185 | |
| 1186 | #endif /* LINUX */ |
| 1187 | |
| 1188 | int |
| 1189 | sys_setreuid(tcp) |
| 1190 | struct tcb *tcp; |
| 1191 | { |
| 1192 | if (entering(tcp)) { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1193 | printuid("", tcp->u_arg[0]); |
| 1194 | printuid(", ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1195 | } |
| 1196 | return 0; |
| 1197 | } |
| 1198 | |
| 1199 | int |
| 1200 | sys_setregid(tcp) |
| 1201 | struct tcb *tcp; |
| 1202 | { |
| 1203 | if (entering(tcp)) { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1204 | printuid("", tcp->u_arg[0]); |
| 1205 | printuid(", ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1206 | } |
| 1207 | return 0; |
| 1208 | } |
| 1209 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1210 | #if defined(LINUX) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1211 | int |
| 1212 | sys_setresuid(tcp) |
| 1213 | struct tcb *tcp; |
| 1214 | { |
| 1215 | if (entering(tcp)) { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1216 | printuid("", tcp->u_arg[0]); |
| 1217 | printuid(", ", tcp->u_arg[1]); |
| 1218 | printuid(", ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1219 | } |
| 1220 | return 0; |
| 1221 | } |
| 1222 | int |
| 1223 | sys_setresgid(tcp) |
| 1224 | struct tcb *tcp; |
| 1225 | { |
| 1226 | if (entering(tcp)) { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1227 | printuid("", tcp->u_arg[0]); |
| 1228 | printuid(", ", tcp->u_arg[1]); |
| 1229 | printuid(", ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1230 | } |
| 1231 | return 0; |
| 1232 | } |
| 1233 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1234 | #endif /* LINUX || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1235 | |
| 1236 | int |
| 1237 | sys_setgroups(tcp) |
| 1238 | struct tcb *tcp; |
| 1239 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1240 | if (entering(tcp)) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1241 | unsigned long len, size, start, cur, end, abbrev_end; |
| 1242 | GETGROUPS_T gid; |
| 1243 | int failed = 0; |
| 1244 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1245 | len = tcp->u_arg[0]; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1246 | tprintf("%lu, ", len); |
| 1247 | if (len == 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1248 | tprintf("[]"); |
| 1249 | return 0; |
| 1250 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1251 | start = tcp->u_arg[1]; |
| 1252 | if (start == 0) { |
| 1253 | tprintf("NULL"); |
| 1254 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1255 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1256 | size = len * sizeof(gid); |
| 1257 | end = start + size; |
| 1258 | if (!verbose(tcp) || size / sizeof(gid) != len || end < start) { |
| 1259 | tprintf("%#lx", start); |
| 1260 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1261 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1262 | if (abbrev(tcp)) { |
| 1263 | abbrev_end = start + max_strlen * sizeof(gid); |
| 1264 | if (abbrev_end < start) |
| 1265 | abbrev_end = end; |
| 1266 | } else { |
| 1267 | abbrev_end = end; |
| 1268 | } |
| 1269 | tprintf("["); |
| 1270 | for (cur = start; cur < end; cur += sizeof(gid)) { |
| 1271 | if (cur > start) |
| 1272 | tprintf(", "); |
| 1273 | if (cur >= abbrev_end) { |
| 1274 | tprintf("..."); |
| 1275 | break; |
| 1276 | } |
| 1277 | if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) { |
| 1278 | tprintf("?"); |
| 1279 | failed = 1; |
| 1280 | break; |
| 1281 | } |
| 1282 | tprintf("%lu", (unsigned long) gid); |
| 1283 | } |
| 1284 | tprintf("]"); |
| 1285 | if (failed) |
| 1286 | tprintf(" %#lx", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1287 | } |
| 1288 | return 0; |
| 1289 | } |
| 1290 | |
| 1291 | int |
| 1292 | sys_getgroups(tcp) |
| 1293 | struct tcb *tcp; |
| 1294 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1295 | unsigned long len; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1296 | |
| 1297 | if (entering(tcp)) { |
| 1298 | len = tcp->u_arg[0]; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1299 | tprintf("%lu, ", len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1300 | } else { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1301 | unsigned long size, start, cur, end, abbrev_end; |
| 1302 | GETGROUPS_T gid; |
| 1303 | int failed = 0; |
| 1304 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1305 | len = tcp->u_rval; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1306 | if (len == 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1307 | tprintf("[]"); |
| 1308 | return 0; |
| 1309 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1310 | start = tcp->u_arg[1]; |
| 1311 | if (start == 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1312 | tprintf("NULL"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1313 | return 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1314 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1315 | if (tcp->u_arg[0] == 0) { |
| 1316 | tprintf("%#lx", start); |
| 1317 | return 0; |
| 1318 | } |
| 1319 | size = len * sizeof(gid); |
| 1320 | end = start + size; |
| 1321 | if (!verbose(tcp) || tcp->u_arg[0] == 0 || |
| 1322 | size / sizeof(gid) != len || end < start) { |
| 1323 | tprintf("%#lx", start); |
| 1324 | return 0; |
| 1325 | } |
| 1326 | if (abbrev(tcp)) { |
| 1327 | abbrev_end = start + max_strlen * sizeof(gid); |
| 1328 | if (abbrev_end < start) |
| 1329 | abbrev_end = end; |
| 1330 | } else { |
| 1331 | abbrev_end = end; |
| 1332 | } |
| 1333 | tprintf("["); |
| 1334 | for (cur = start; cur < end; cur += sizeof(gid)) { |
| 1335 | if (cur > start) |
| 1336 | tprintf(", "); |
| 1337 | if (cur >= abbrev_end) { |
| 1338 | tprintf("..."); |
| 1339 | break; |
| 1340 | } |
| 1341 | if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) { |
| 1342 | tprintf("?"); |
| 1343 | failed = 1; |
| 1344 | break; |
| 1345 | } |
| 1346 | tprintf("%lu", (unsigned long) gid); |
| 1347 | } |
| 1348 | tprintf("]"); |
| 1349 | if (failed) |
| 1350 | tprintf(" %#lx", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1351 | } |
| 1352 | return 0; |
| 1353 | } |
| 1354 | |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1355 | #ifdef LINUX |
| 1356 | int |
| 1357 | sys_setgroups32(tcp) |
| 1358 | struct tcb *tcp; |
| 1359 | { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1360 | if (entering(tcp)) { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1361 | unsigned long len, size, start, cur, end, abbrev_end; |
| 1362 | GETGROUPS32_T gid; |
| 1363 | int failed = 0; |
| 1364 | |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1365 | len = tcp->u_arg[0]; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1366 | tprintf("%lu, ", len); |
| 1367 | if (len == 0) { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1368 | tprintf("[]"); |
| 1369 | return 0; |
| 1370 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1371 | start = tcp->u_arg[1]; |
| 1372 | if (start == 0) { |
| 1373 | tprintf("NULL"); |
| 1374 | return 0; |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1375 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1376 | size = len * sizeof(gid); |
| 1377 | end = start + size; |
| 1378 | if (!verbose(tcp) || size / sizeof(gid) != len || end < start) { |
| 1379 | tprintf("%#lx", start); |
| 1380 | return 0; |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1381 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1382 | if (abbrev(tcp)) { |
| 1383 | abbrev_end = start + max_strlen * sizeof(gid); |
| 1384 | if (abbrev_end < start) |
| 1385 | abbrev_end = end; |
| 1386 | } else { |
| 1387 | abbrev_end = end; |
| 1388 | } |
| 1389 | tprintf("["); |
| 1390 | for (cur = start; cur < end; cur += sizeof(gid)) { |
| 1391 | if (cur > start) |
| 1392 | tprintf(", "); |
| 1393 | if (cur >= abbrev_end) { |
| 1394 | tprintf("..."); |
| 1395 | break; |
| 1396 | } |
| 1397 | if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) { |
| 1398 | tprintf("?"); |
| 1399 | failed = 1; |
| 1400 | break; |
| 1401 | } |
| 1402 | tprintf("%lu", (unsigned long) gid); |
| 1403 | } |
| 1404 | tprintf("]"); |
| 1405 | if (failed) |
| 1406 | tprintf(" %#lx", tcp->u_arg[1]); |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1407 | } |
| 1408 | return 0; |
| 1409 | } |
| 1410 | |
| 1411 | int |
| 1412 | sys_getgroups32(tcp) |
| 1413 | struct tcb *tcp; |
| 1414 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1415 | unsigned long len; |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1416 | |
| 1417 | if (entering(tcp)) { |
| 1418 | len = tcp->u_arg[0]; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1419 | tprintf("%lu, ", len); |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1420 | } else { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1421 | unsigned long size, start, cur, end, abbrev_end; |
| 1422 | GETGROUPS32_T gid; |
| 1423 | int failed = 0; |
| 1424 | |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1425 | len = tcp->u_rval; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1426 | if (len == 0) { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1427 | tprintf("[]"); |
| 1428 | return 0; |
| 1429 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1430 | start = tcp->u_arg[1]; |
| 1431 | if (start == 0) { |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1432 | tprintf("NULL"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1433 | return 0; |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1434 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1435 | size = len * sizeof(gid); |
| 1436 | end = start + size; |
| 1437 | if (!verbose(tcp) || tcp->u_arg[0] == 0 || |
| 1438 | size / sizeof(gid) != len || end < start) { |
| 1439 | tprintf("%#lx", start); |
| 1440 | return 0; |
| 1441 | } |
| 1442 | if (abbrev(tcp)) { |
| 1443 | abbrev_end = start + max_strlen * sizeof(gid); |
| 1444 | if (abbrev_end < start) |
| 1445 | abbrev_end = end; |
| 1446 | } else { |
| 1447 | abbrev_end = end; |
| 1448 | } |
| 1449 | tprintf("["); |
| 1450 | for (cur = start; cur < end; cur += sizeof(gid)) { |
| 1451 | if (cur > start) |
| 1452 | tprintf(", "); |
| 1453 | if (cur >= abbrev_end) { |
| 1454 | tprintf("..."); |
| 1455 | break; |
| 1456 | } |
| 1457 | if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) { |
| 1458 | tprintf("?"); |
| 1459 | failed = 1; |
| 1460 | break; |
| 1461 | } |
| 1462 | tprintf("%lu", (unsigned long) gid); |
| 1463 | } |
| 1464 | tprintf("]"); |
| 1465 | if (failed) |
| 1466 | tprintf(" %#lx", tcp->u_arg[1]); |
Roland McGrath | 83bd47a | 2003-11-13 22:32:26 +0000 | [diff] [blame] | 1467 | } |
| 1468 | return 0; |
| 1469 | } |
| 1470 | #endif /* LINUX */ |
| 1471 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1472 | #if defined(ALPHA) || defined(SUNOS4) || defined(SVR4) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1473 | int |
| 1474 | sys_setpgrp(tcp) |
| 1475 | struct tcb *tcp; |
| 1476 | { |
| 1477 | if (entering(tcp)) { |
| 1478 | #ifndef SVR4 |
| 1479 | tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 1480 | #endif /* !SVR4 */ |
| 1481 | } |
| 1482 | return 0; |
| 1483 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1484 | #endif /* ALPHA || SUNOS4 || SVR4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1485 | |
| 1486 | int |
| 1487 | sys_getpgrp(tcp) |
| 1488 | struct tcb *tcp; |
| 1489 | { |
| 1490 | if (entering(tcp)) { |
| 1491 | #ifndef SVR4 |
| 1492 | tprintf("%lu", tcp->u_arg[0]); |
| 1493 | #endif /* !SVR4 */ |
| 1494 | } |
| 1495 | return 0; |
| 1496 | } |
| 1497 | |
| 1498 | int |
| 1499 | sys_getsid(tcp) |
| 1500 | struct tcb *tcp; |
| 1501 | { |
| 1502 | if (entering(tcp)) { |
| 1503 | tprintf("%lu", tcp->u_arg[0]); |
| 1504 | } |
| 1505 | return 0; |
| 1506 | } |
| 1507 | |
| 1508 | int |
| 1509 | sys_setsid(tcp) |
| 1510 | struct tcb *tcp; |
| 1511 | { |
| 1512 | return 0; |
| 1513 | } |
| 1514 | |
| 1515 | int |
| 1516 | sys_getpgid(tcp) |
| 1517 | struct tcb *tcp; |
| 1518 | { |
| 1519 | if (entering(tcp)) { |
| 1520 | tprintf("%lu", tcp->u_arg[0]); |
| 1521 | } |
| 1522 | return 0; |
| 1523 | } |
| 1524 | |
| 1525 | int |
| 1526 | sys_setpgid(tcp) |
| 1527 | struct tcb *tcp; |
| 1528 | { |
| 1529 | if (entering(tcp)) { |
| 1530 | tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 1531 | } |
| 1532 | return 0; |
| 1533 | } |
| 1534 | |
John Hughes | c61eb3d | 2002-05-17 11:37:50 +0000 | [diff] [blame] | 1535 | #if UNIXWARE >= 2 |
| 1536 | |
| 1537 | #include <sys/privilege.h> |
| 1538 | |
| 1539 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1540 | static const struct xlat procpriv_cmds [] = { |
John Hughes | c61eb3d | 2002-05-17 11:37:50 +0000 | [diff] [blame] | 1541 | { SETPRV, "SETPRV" }, |
| 1542 | { CLRPRV, "CLRPRV" }, |
| 1543 | { PUTPRV, "PUTPRV" }, |
| 1544 | { GETPRV, "GETPRV" }, |
| 1545 | { CNTPRV, "CNTPRV" }, |
| 1546 | { 0, NULL }, |
| 1547 | }; |
| 1548 | |
| 1549 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1550 | static const struct xlat procpriv_priv [] = { |
John Hughes | c61eb3d | 2002-05-17 11:37:50 +0000 | [diff] [blame] | 1551 | { P_OWNER, "P_OWNER" }, |
| 1552 | { P_AUDIT, "P_AUDIT" }, |
| 1553 | { P_COMPAT, "P_COMPAT" }, |
| 1554 | { P_DACREAD, "P_DACREAD" }, |
| 1555 | { P_DACWRITE, "P_DACWRITE" }, |
| 1556 | { P_DEV, "P_DEV" }, |
| 1557 | { P_FILESYS, "P_FILESYS" }, |
| 1558 | { P_MACREAD, "P_MACREAD" }, |
| 1559 | { P_MACWRITE, "P_MACWRITE" }, |
| 1560 | { P_MOUNT, "P_MOUNT" }, |
| 1561 | { P_MULTIDIR, "P_MULTIDIR" }, |
| 1562 | { P_SETPLEVEL, "P_SETPLEVEL" }, |
| 1563 | { P_SETSPRIV, "P_SETSPRIV" }, |
| 1564 | { P_SETUID, "P_SETUID" }, |
| 1565 | { P_SYSOPS, "P_SYSOPS" }, |
| 1566 | { P_SETUPRIV, "P_SETUPRIV" }, |
| 1567 | { P_DRIVER, "P_DRIVER" }, |
| 1568 | { P_RTIME, "P_RTIME" }, |
| 1569 | { P_MACUPGRADE, "P_MACUPGRADE" }, |
| 1570 | { P_FSYSRANGE, "P_FSYSRANGE" }, |
| 1571 | { P_SETFLEVEL, "P_SETFLEVEL" }, |
| 1572 | { P_AUDITWR, "P_AUDITWR" }, |
| 1573 | { P_TSHAR, "P_TSHAR" }, |
| 1574 | { P_PLOCK, "P_PLOCK" }, |
| 1575 | { P_CORE, "P_CORE" }, |
| 1576 | { P_LOADMOD, "P_LOADMOD" }, |
| 1577 | { P_BIND, "P_BIND" }, |
| 1578 | { P_ALLPRIVS, "P_ALLPRIVS" }, |
| 1579 | { 0, NULL }, |
| 1580 | }; |
| 1581 | |
| 1582 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1583 | static const struct xlat procpriv_type [] = { |
John Hughes | c61eb3d | 2002-05-17 11:37:50 +0000 | [diff] [blame] | 1584 | { PS_FIX, "PS_FIX" }, |
| 1585 | { PS_INH, "PS_INH" }, |
| 1586 | { PS_MAX, "PS_MAX" }, |
| 1587 | { PS_WKG, "PS_WKG" }, |
| 1588 | { 0, NULL }, |
| 1589 | }; |
| 1590 | |
| 1591 | |
| 1592 | static void |
Dmitry V. Levin | ab9008b | 2007-01-11 22:05:04 +0000 | [diff] [blame] | 1593 | printpriv(struct tcb *tcp, long addr, int len, const struct xlat *opt) |
John Hughes | c61eb3d | 2002-05-17 11:37:50 +0000 | [diff] [blame] | 1594 | { |
| 1595 | priv_t buf [128]; |
| 1596 | int max = verbose (tcp) ? sizeof buf / sizeof buf [0] : 10; |
| 1597 | int dots = len > max; |
| 1598 | int i; |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 1599 | |
John Hughes | c61eb3d | 2002-05-17 11:37:50 +0000 | [diff] [blame] | 1600 | if (len > max) len = max; |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 1601 | |
John Hughes | c61eb3d | 2002-05-17 11:37:50 +0000 | [diff] [blame] | 1602 | if (len <= 0 || |
| 1603 | umoven (tcp, addr, len * sizeof buf[0], (char *) buf) < 0) |
| 1604 | { |
| 1605 | tprintf ("%#lx", addr); |
| 1606 | return; |
| 1607 | } |
| 1608 | |
| 1609 | tprintf ("["); |
| 1610 | |
| 1611 | for (i = 0; i < len; ++i) { |
Dmitry V. Levin | ab9008b | 2007-01-11 22:05:04 +0000 | [diff] [blame] | 1612 | const char *t, *p; |
John Hughes | c61eb3d | 2002-05-17 11:37:50 +0000 | [diff] [blame] | 1613 | |
| 1614 | if (i) tprintf (", "); |
| 1615 | |
| 1616 | if ((t = xlookup (procpriv_type, buf [i] & PS_TYPE)) && |
| 1617 | (p = xlookup (procpriv_priv, buf [i] & ~PS_TYPE))) |
| 1618 | { |
| 1619 | tprintf ("%s|%s", t, p); |
| 1620 | } |
| 1621 | else { |
| 1622 | tprintf ("%#lx", buf [i]); |
| 1623 | } |
| 1624 | } |
| 1625 | |
| 1626 | if (dots) tprintf (" ..."); |
| 1627 | |
| 1628 | tprintf ("]"); |
| 1629 | } |
| 1630 | |
| 1631 | |
| 1632 | int |
| 1633 | sys_procpriv(tcp) |
| 1634 | struct tcb *tcp; |
| 1635 | { |
| 1636 | if (entering(tcp)) { |
| 1637 | printxval(procpriv_cmds, tcp->u_arg[0], "???PRV"); |
| 1638 | switch (tcp->u_arg[0]) { |
| 1639 | case CNTPRV: |
| 1640 | tprintf(", %#lx, %ld", tcp->u_arg[1], tcp->u_arg[2]); |
| 1641 | break; |
| 1642 | |
| 1643 | case GETPRV: |
| 1644 | break; |
| 1645 | |
| 1646 | default: |
| 1647 | tprintf (", "); |
| 1648 | printpriv (tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1649 | tprintf (", %ld", tcp->u_arg[2]); |
| 1650 | } |
| 1651 | } |
| 1652 | else if (tcp->u_arg[0] == GETPRV) { |
| 1653 | if (syserror (tcp)) { |
| 1654 | tprintf(", %#lx, %ld", tcp->u_arg[1], tcp->u_arg[2]); |
| 1655 | } |
| 1656 | else { |
| 1657 | tprintf (", "); |
| 1658 | printpriv (tcp, tcp->u_arg[1], tcp->u_rval); |
| 1659 | tprintf (", %ld", tcp->u_arg[2]); |
| 1660 | } |
| 1661 | } |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 1662 | |
John Hughes | c61eb3d | 2002-05-17 11:37:50 +0000 | [diff] [blame] | 1663 | return 0; |
| 1664 | } |
| 1665 | |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 1666 | #endif /* UNIXWARE */ |
John Hughes | c61eb3d | 2002-05-17 11:37:50 +0000 | [diff] [blame] | 1667 | |
| 1668 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1669 | static void |
Dmitry V. Levin | 30145dd | 2010-09-06 22:08:24 +0000 | [diff] [blame] | 1670 | printargv(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1671 | { |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1672 | union { |
Andreas Schwab | 99c8569 | 2009-08-28 19:36:20 +0200 | [diff] [blame] | 1673 | unsigned int p32; |
| 1674 | unsigned long p64; |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1675 | char data[sizeof(long)]; |
| 1676 | } cp; |
Dmitry V. Levin | 30145dd | 2010-09-06 22:08:24 +0000 | [diff] [blame] | 1677 | const char *sep; |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1678 | int n = 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1679 | |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1680 | cp.p64 = 1; |
| 1681 | for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) { |
| 1682 | if (umoven(tcp, addr, personality_wordsize[current_personality], |
| 1683 | cp.data) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1684 | tprintf("%#lx", addr); |
| 1685 | return; |
| 1686 | } |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1687 | if (personality_wordsize[current_personality] == 4) |
| 1688 | cp.p64 = cp.p32; |
| 1689 | if (cp.p64 == 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1690 | break; |
Dmitry V. Levin | 4bcd5ef | 2009-06-01 10:32:27 +0000 | [diff] [blame] | 1691 | tprintf("%s", sep); |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1692 | printstr(tcp, cp.p64, -1); |
| 1693 | addr += personality_wordsize[current_personality]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1694 | } |
Roland McGrath | 85a3bc4 | 2007-08-02 02:13:05 +0000 | [diff] [blame] | 1695 | if (cp.p64) |
| 1696 | tprintf("%s...", sep); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1697 | } |
| 1698 | |
| 1699 | static void |
Dmitry V. Levin | 30145dd | 2010-09-06 22:08:24 +0000 | [diff] [blame] | 1700 | printargc(const char *fmt, struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1701 | { |
| 1702 | int count; |
| 1703 | char *cp; |
| 1704 | |
| 1705 | for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) { |
| 1706 | addr += sizeof(char *); |
| 1707 | } |
| 1708 | tprintf(fmt, count, count == 1 ? "" : "s"); |
| 1709 | } |
| 1710 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1711 | #if defined(SPARC) || defined(SPARC64) || defined(SUNOS4) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1712 | int |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 1713 | sys_execv(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1714 | { |
| 1715 | if (entering(tcp)) { |
| 1716 | printpath(tcp, tcp->u_arg[0]); |
| 1717 | if (!verbose(tcp)) |
| 1718 | tprintf(", %#lx", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1719 | else { |
| 1720 | tprintf(", ["); |
| 1721 | printargv(tcp, tcp->u_arg[1]); |
| 1722 | tprintf("]"); |
| 1723 | } |
| 1724 | } |
| 1725 | return 0; |
| 1726 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1727 | #endif /* SPARC || SPARC64 || SUNOS4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1728 | |
| 1729 | int |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 1730 | sys_execve(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1731 | { |
| 1732 | if (entering(tcp)) { |
| 1733 | printpath(tcp, tcp->u_arg[0]); |
| 1734 | if (!verbose(tcp)) |
| 1735 | tprintf(", %#lx", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1736 | else { |
| 1737 | tprintf(", ["); |
| 1738 | printargv(tcp, tcp->u_arg[1]); |
| 1739 | tprintf("]"); |
| 1740 | } |
| 1741 | if (!verbose(tcp)) |
| 1742 | tprintf(", %#lx", tcp->u_arg[2]); |
| 1743 | else if (abbrev(tcp)) |
| 1744 | printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]); |
| 1745 | else { |
| 1746 | tprintf(", ["); |
| 1747 | printargv(tcp, tcp->u_arg[2]); |
| 1748 | tprintf("]"); |
| 1749 | } |
| 1750 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1751 | return 0; |
| 1752 | } |
| 1753 | |
Roland McGrath | 5ef24ab | 2004-02-20 02:22:35 +0000 | [diff] [blame] | 1754 | #if UNIXWARE > 2 |
John Hughes | 4e36a81 | 2001-04-18 15:11:51 +0000 | [diff] [blame] | 1755 | |
| 1756 | int sys_rexecve(tcp) |
| 1757 | struct tcb *tcp; |
| 1758 | { |
| 1759 | if (entering (tcp)) { |
| 1760 | sys_execve (tcp); |
| 1761 | tprintf (", %ld", tcp->u_arg[3]); |
| 1762 | } |
| 1763 | return 0; |
| 1764 | } |
| 1765 | |
Roland McGrath | 5ef24ab | 2004-02-20 02:22:35 +0000 | [diff] [blame] | 1766 | #endif |
John Hughes | 4e36a81 | 2001-04-18 15:11:51 +0000 | [diff] [blame] | 1767 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1768 | int |
| 1769 | internal_exec(tcp) |
| 1770 | struct tcb *tcp; |
| 1771 | { |
| 1772 | #ifdef SUNOS4 |
| 1773 | if (exiting(tcp) && !syserror(tcp) && followfork) |
| 1774 | fixvfork(tcp); |
| 1775 | #endif /* SUNOS4 */ |
Roland McGrath | fdb097f | 2004-07-12 07:38:55 +0000 | [diff] [blame] | 1776 | #if defined LINUX && defined TCB_WAITEXECVE |
| 1777 | if (exiting(tcp) && syserror(tcp)) |
| 1778 | tcp->flags &= ~TCB_WAITEXECVE; |
| 1779 | else |
| 1780 | tcp->flags |= TCB_WAITEXECVE; |
| 1781 | #endif /* LINUX && TCB_WAITEXECVE */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1782 | return 0; |
| 1783 | } |
| 1784 | |
| 1785 | #ifdef LINUX |
Roland McGrath | 7ec1d35 | 2002-12-17 04:50:44 +0000 | [diff] [blame] | 1786 | #ifndef __WNOTHREAD |
| 1787 | #define __WNOTHREAD 0x20000000 |
| 1788 | #endif |
| 1789 | #ifndef __WALL |
| 1790 | #define __WALL 0x40000000 |
| 1791 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1792 | #ifndef __WCLONE |
Roland McGrath | 7ec1d35 | 2002-12-17 04:50:44 +0000 | [diff] [blame] | 1793 | #define __WCLONE 0x80000000 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1794 | #endif |
| 1795 | #endif /* LINUX */ |
| 1796 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1797 | static const struct xlat wait4_options[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1798 | { WNOHANG, "WNOHANG" }, |
| 1799 | #ifndef WSTOPPED |
| 1800 | { WUNTRACED, "WUNTRACED" }, |
| 1801 | #endif |
| 1802 | #ifdef WEXITED |
| 1803 | { WEXITED, "WEXITED" }, |
| 1804 | #endif |
| 1805 | #ifdef WTRAPPED |
| 1806 | { WTRAPPED, "WTRAPPED" }, |
| 1807 | #endif |
| 1808 | #ifdef WSTOPPED |
| 1809 | { WSTOPPED, "WSTOPPED" }, |
| 1810 | #endif |
| 1811 | #ifdef WCONTINUED |
| 1812 | { WCONTINUED, "WCONTINUED" }, |
| 1813 | #endif |
| 1814 | #ifdef WNOWAIT |
| 1815 | { WNOWAIT, "WNOWAIT" }, |
| 1816 | #endif |
| 1817 | #ifdef __WCLONE |
| 1818 | { __WCLONE, "__WCLONE" }, |
| 1819 | #endif |
Roland McGrath | 7ec1d35 | 2002-12-17 04:50:44 +0000 | [diff] [blame] | 1820 | #ifdef __WALL |
| 1821 | { __WALL, "__WALL" }, |
| 1822 | #endif |
| 1823 | #ifdef __WNOTHREAD |
| 1824 | { __WNOTHREAD, "__WNOTHREAD" }, |
| 1825 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1826 | { 0, NULL }, |
| 1827 | }; |
| 1828 | |
Roland McGrath | 5e02a57 | 2004-10-19 23:33:47 +0000 | [diff] [blame] | 1829 | #if !defined WCOREFLAG && defined WCOREFLG |
| 1830 | # define WCOREFLAG WCOREFLG |
| 1831 | #endif |
| 1832 | #ifndef WCOREFLAG |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 1833 | # define WCOREFLAG 0x80 |
Roland McGrath | 5e02a57 | 2004-10-19 23:33:47 +0000 | [diff] [blame] | 1834 | #endif |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 1835 | #ifndef WCOREDUMP |
| 1836 | # define WCOREDUMP(status) ((status) & 0200) |
| 1837 | #endif |
| 1838 | |
Roland McGrath | 5e02a57 | 2004-10-19 23:33:47 +0000 | [diff] [blame] | 1839 | |
| 1840 | #ifndef W_STOPCODE |
| 1841 | #define W_STOPCODE(sig) ((sig) << 8 | 0x7f) |
| 1842 | #endif |
| 1843 | #ifndef W_EXITCODE |
| 1844 | #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) |
| 1845 | #endif |
| 1846 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1847 | static int |
| 1848 | printstatus(status) |
| 1849 | int status; |
| 1850 | { |
| 1851 | int exited = 0; |
| 1852 | |
| 1853 | /* |
| 1854 | * Here is a tricky presentation problem. This solution |
| 1855 | * is still not entirely satisfactory but since there |
| 1856 | * are no wait status constructors it will have to do. |
| 1857 | */ |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1858 | if (WIFSTOPPED(status)) { |
| 1859 | tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}", |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 1860 | signame(WSTOPSIG(status))); |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1861 | status &= ~W_STOPCODE(WSTOPSIG(status)); |
| 1862 | } |
| 1863 | else if (WIFSIGNALED(status)) { |
| 1864 | tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}", |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 1865 | signame(WTERMSIG(status)), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1866 | WCOREDUMP(status) ? " && WCOREDUMP(s)" : ""); |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1867 | status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG); |
| 1868 | } |
| 1869 | else if (WIFEXITED(status)) { |
| 1870 | tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}", |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1871 | WEXITSTATUS(status)); |
| 1872 | exited = 1; |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1873 | status &= ~W_EXITCODE(WEXITSTATUS(status), 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1874 | } |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1875 | else { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1876 | tprintf("[%#x]", status); |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1877 | return 0; |
| 1878 | } |
| 1879 | |
| 1880 | if (status == 0) |
| 1881 | tprintf("]"); |
| 1882 | else |
Roland McGrath | f8cc83c | 2004-06-04 01:24:07 +0000 | [diff] [blame] | 1883 | tprintf(" | %#x]", status); |
Roland McGrath | 79fbda5 | 2004-04-14 02:45:55 +0000 | [diff] [blame] | 1884 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1885 | return exited; |
| 1886 | } |
| 1887 | |
| 1888 | static int |
Denys Vlasenko | 59432db | 2009-01-26 19:09:35 +0000 | [diff] [blame] | 1889 | printwaitn(struct tcb *tcp, int n, int bitness) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1890 | { |
| 1891 | int status; |
| 1892 | int exited = 0; |
| 1893 | |
| 1894 | if (entering(tcp)) { |
Denys Vlasenko | e740fd3 | 2009-04-16 12:06:16 +0000 | [diff] [blame] | 1895 | #ifdef LINUX |
| 1896 | /* On Linux, kernel-side pid_t is typedef'ed to int |
| 1897 | * on all arches. Also, glibc-2.8 truncates wait3 and wait4 |
Denys Vlasenko | 59432db | 2009-01-26 19:09:35 +0000 | [diff] [blame] | 1898 | * pid argument to int on 64bit arches, producing, |
| 1899 | * for example, wait4(4294967295, ...) instead of -1 |
Denys Vlasenko | e740fd3 | 2009-04-16 12:06:16 +0000 | [diff] [blame] | 1900 | * in strace. We have to use int here, not long. |
| 1901 | */ |
| 1902 | int pid = tcp->u_arg[0]; |
| 1903 | tprintf("%d, ", pid); |
| 1904 | #else |
| 1905 | /* |
| 1906 | * Sign-extend a 32-bit value when that's what it is. |
Roland McGrath | 5b63d96 | 2008-07-18 02:16:47 +0000 | [diff] [blame] | 1907 | */ |
| 1908 | long pid = tcp->u_arg[0]; |
| 1909 | if (personality_wordsize[current_personality] < sizeof pid) |
| 1910 | pid = (long) (int) pid; |
| 1911 | tprintf("%ld, ", pid); |
Denys Vlasenko | e740fd3 | 2009-04-16 12:06:16 +0000 | [diff] [blame] | 1912 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1913 | } else { |
| 1914 | /* status */ |
| 1915 | if (!tcp->u_arg[1]) |
| 1916 | tprintf("NULL"); |
| 1917 | else if (syserror(tcp) || tcp->u_rval == 0) |
| 1918 | tprintf("%#lx", tcp->u_arg[1]); |
| 1919 | else if (umove(tcp, tcp->u_arg[1], &status) < 0) |
| 1920 | tprintf("[?]"); |
| 1921 | else |
| 1922 | exited = printstatus(status); |
| 1923 | /* options */ |
| 1924 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1925 | printflags(wait4_options, tcp->u_arg[2], "W???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1926 | if (n == 4) { |
| 1927 | tprintf(", "); |
| 1928 | /* usage */ |
| 1929 | if (!tcp->u_arg[3]) |
| 1930 | tprintf("NULL"); |
| 1931 | #ifdef LINUX |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1932 | else if (tcp->u_rval > 0) { |
Denys Vlasenko | 59432db | 2009-01-26 19:09:35 +0000 | [diff] [blame] | 1933 | #ifdef ALPHA |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1934 | if (bitness) |
| 1935 | printrusage32(tcp, tcp->u_arg[3]); |
| 1936 | else |
| 1937 | #endif |
| 1938 | printrusage(tcp, tcp->u_arg[3]); |
| 1939 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1940 | #endif /* LINUX */ |
| 1941 | #ifdef SUNOS4 |
| 1942 | else if (tcp->u_rval > 0 && exited) |
| 1943 | printrusage(tcp, tcp->u_arg[3]); |
| 1944 | #endif /* SUNOS4 */ |
| 1945 | else |
| 1946 | tprintf("%#lx", tcp->u_arg[3]); |
| 1947 | } |
| 1948 | } |
| 1949 | return 0; |
| 1950 | } |
| 1951 | |
| 1952 | int |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 1953 | internal_wait(tcp, flagarg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1954 | struct tcb *tcp; |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 1955 | int flagarg; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1956 | { |
Roland McGrath | e85bbfe | 2003-01-09 06:53:31 +0000 | [diff] [blame] | 1957 | int got_kids; |
| 1958 | |
| 1959 | #ifdef TCB_CLONE_THREAD |
| 1960 | if (tcp->flags & TCB_CLONE_THREAD) |
| 1961 | /* The children we wait for are our parent's children. */ |
| 1962 | got_kids = (tcp->parent->nchildren |
Wang Chao | 21b8db4 | 2010-08-27 17:43:16 +0800 | [diff] [blame] | 1963 | > tcp->parent->nclone_threads); |
Roland McGrath | e85bbfe | 2003-01-09 06:53:31 +0000 | [diff] [blame] | 1964 | else |
Wang Chao | 21b8db4 | 2010-08-27 17:43:16 +0800 | [diff] [blame] | 1965 | got_kids = (tcp->nchildren > tcp->nclone_threads); |
Roland McGrath | e85bbfe | 2003-01-09 06:53:31 +0000 | [diff] [blame] | 1966 | #else |
| 1967 | got_kids = tcp->nchildren > 0; |
| 1968 | #endif |
| 1969 | |
| 1970 | if (entering(tcp) && got_kids) { |
Roland McGrath | b69f81b | 2002-12-21 23:25:18 +0000 | [diff] [blame] | 1971 | /* There are children that this parent should block for. |
| 1972 | But ptrace made us the parent of the traced children |
| 1973 | and the real parent will get ECHILD from the wait call. |
| 1974 | |
| 1975 | XXX If we attached with strace -f -p PID, then there |
| 1976 | may be untraced dead children the parent could be reaping |
| 1977 | now, but we make him block. */ |
| 1978 | |
| 1979 | /* ??? WTA: fix bug with hanging children */ |
| 1980 | |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 1981 | if (!(tcp->u_arg[flagarg] & WNOHANG)) { |
Roland McGrath | 0962345 | 2003-05-23 02:27:13 +0000 | [diff] [blame] | 1982 | /* |
| 1983 | * There are traced children. We'll make the parent |
| 1984 | * block to avoid a false ECHILD error due to our |
| 1985 | * ptrace having stolen the children. However, |
| 1986 | * we shouldn't block if there are zombies to reap. |
| 1987 | * XXX doesn't handle pgrp matches (u_arg[0]==0,<-1) |
| 1988 | */ |
Roland McGrath | fccfb94 | 2003-10-01 21:59:44 +0000 | [diff] [blame] | 1989 | struct tcb *child = NULL; |
Roland McGrath | 0962345 | 2003-05-23 02:27:13 +0000 | [diff] [blame] | 1990 | if (tcp->nzombies > 0 && |
| 1991 | (tcp->u_arg[0] == -1 || |
Roland McGrath | fccfb94 | 2003-10-01 21:59:44 +0000 | [diff] [blame] | 1992 | (child = pid2tcb(tcp->u_arg[0])) == NULL)) |
Roland McGrath | 0962345 | 2003-05-23 02:27:13 +0000 | [diff] [blame] | 1993 | return 0; |
Roland McGrath | fccfb94 | 2003-10-01 21:59:44 +0000 | [diff] [blame] | 1994 | if (tcp->u_arg[0] > 0) { |
| 1995 | /* |
| 1996 | * If the parent waits for a specified child |
| 1997 | * PID, then it must get ECHILD right away |
| 1998 | * if that PID is not one of its children. |
| 1999 | * Make sure that the requested PID matches |
| 2000 | * one of the parent's children that we are |
| 2001 | * tracing, and don't suspend it otherwise. |
| 2002 | */ |
| 2003 | if (child == NULL) |
| 2004 | child = pid2tcb(tcp->u_arg[0]); |
| 2005 | if (child == NULL || child->parent != ( |
| 2006 | #ifdef TCB_CLONE_THREAD |
| 2007 | (tcp->flags & TCB_CLONE_THREAD) |
| 2008 | ? tcp->parent : |
| 2009 | #endif |
Roland McGrath | d56a656 | 2005-08-03 11:23:43 +0000 | [diff] [blame] | 2010 | tcp) || |
| 2011 | (child->flags & TCB_EXITING)) |
Roland McGrath | fccfb94 | 2003-10-01 21:59:44 +0000 | [diff] [blame] | 2012 | return 0; |
| 2013 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2014 | tcp->flags |= TCB_SUSPENDED; |
| 2015 | tcp->waitpid = tcp->u_arg[0]; |
Roland McGrath | e85bbfe | 2003-01-09 06:53:31 +0000 | [diff] [blame] | 2016 | #ifdef TCB_CLONE_THREAD |
| 2017 | if (tcp->flags & TCB_CLONE_THREAD) |
| 2018 | tcp->parent->nclone_waiting++; |
| 2019 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2020 | } |
| 2021 | } |
Roland McGrath | e85bbfe | 2003-01-09 06:53:31 +0000 | [diff] [blame] | 2022 | if (exiting(tcp) && tcp->u_error == ECHILD && got_kids) { |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 2023 | if (tcp->u_arg[flagarg] & WNOHANG) { |
Roland McGrath | b69f81b | 2002-12-21 23:25:18 +0000 | [diff] [blame] | 2024 | /* We must force a fake result of 0 instead of |
| 2025 | the ECHILD error. */ |
Roland McGrath | b69f81b | 2002-12-21 23:25:18 +0000 | [diff] [blame] | 2026 | return force_result(tcp, 0, 0); |
| 2027 | } |
Roland McGrath | b69f81b | 2002-12-21 23:25:18 +0000 | [diff] [blame] | 2028 | } |
Roland McGrath | 0962345 | 2003-05-23 02:27:13 +0000 | [diff] [blame] | 2029 | else if (exiting(tcp) && tcp->u_error == 0 && tcp->u_rval > 0 && |
| 2030 | tcp->nzombies > 0 && pid2tcb(tcp->u_rval) == NULL) { |
| 2031 | /* |
| 2032 | * We just reaped a child we don't know about, |
| 2033 | * presumably a zombie we already droptcb'd. |
| 2034 | */ |
| 2035 | tcp->nzombies--; |
| 2036 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2037 | return 0; |
| 2038 | } |
| 2039 | |
| 2040 | #ifdef SVR4 |
| 2041 | |
| 2042 | int |
| 2043 | sys_wait(tcp) |
| 2044 | struct tcb *tcp; |
| 2045 | { |
| 2046 | if (exiting(tcp)) { |
| 2047 | /* The library wrapper stuffs this into the user variable. */ |
| 2048 | if (!syserror(tcp)) |
| 2049 | printstatus(getrval2(tcp)); |
| 2050 | } |
| 2051 | return 0; |
| 2052 | } |
| 2053 | |
| 2054 | #endif /* SVR4 */ |
| 2055 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2056 | #ifdef FREEBSD |
| 2057 | int |
| 2058 | sys_wait(tcp) |
| 2059 | struct tcb *tcp; |
| 2060 | { |
| 2061 | int status; |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 2062 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2063 | if (exiting(tcp)) { |
| 2064 | if (!syserror(tcp)) { |
| 2065 | if (umove(tcp, tcp->u_arg[0], &status) < 0) |
| 2066 | tprintf("%#lx", tcp->u_arg[0]); |
| 2067 | else |
| 2068 | printstatus(status); |
| 2069 | } |
| 2070 | } |
| 2071 | return 0; |
| 2072 | } |
| 2073 | #endif |
| 2074 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2075 | int |
| 2076 | sys_waitpid(tcp) |
| 2077 | struct tcb *tcp; |
| 2078 | { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 2079 | return printwaitn(tcp, 3, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2080 | } |
| 2081 | |
| 2082 | int |
| 2083 | sys_wait4(tcp) |
| 2084 | struct tcb *tcp; |
| 2085 | { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 2086 | return printwaitn(tcp, 4, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2087 | } |
| 2088 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 2089 | #ifdef ALPHA |
| 2090 | int |
| 2091 | sys_osf_wait4(tcp) |
| 2092 | struct tcb *tcp; |
| 2093 | { |
| 2094 | return printwaitn(tcp, 4, 1); |
| 2095 | } |
| 2096 | #endif |
| 2097 | |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 2098 | #if defined SVR4 || defined LINUX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2099 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 2100 | static const struct xlat waitid_types[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2101 | { P_PID, "P_PID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 2102 | #ifdef P_PPID |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2103 | { P_PPID, "P_PPID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 2104 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2105 | { P_PGID, "P_PGID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 2106 | #ifdef P_SID |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2107 | { P_SID, "P_SID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 2108 | #endif |
| 2109 | #ifdef P_CID |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2110 | { P_CID, "P_CID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 2111 | #endif |
| 2112 | #ifdef P_UID |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2113 | { P_UID, "P_UID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 2114 | #endif |
| 2115 | #ifdef P_GID |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2116 | { P_GID, "P_GID" }, |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 2117 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2118 | { P_ALL, "P_ALL" }, |
| 2119 | #ifdef P_LWPID |
| 2120 | { P_LWPID, "P_LWPID" }, |
| 2121 | #endif |
| 2122 | { 0, NULL }, |
| 2123 | }; |
| 2124 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2125 | int |
Dmitry V. Levin | 3eb9491 | 2010-09-09 23:08:59 +0000 | [diff] [blame] | 2126 | sys_waitid(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2127 | { |
| 2128 | siginfo_t si; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2129 | |
| 2130 | if (entering(tcp)) { |
| 2131 | printxval(waitid_types, tcp->u_arg[0], "P_???"); |
| 2132 | tprintf(", %ld, ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2133 | } |
| 2134 | else { |
| 2135 | /* siginfo */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2136 | if (!tcp->u_arg[2]) |
| 2137 | tprintf("NULL"); |
| 2138 | else if (syserror(tcp)) |
| 2139 | tprintf("%#lx", tcp->u_arg[2]); |
| 2140 | else if (umove(tcp, tcp->u_arg[2], &si) < 0) |
| 2141 | tprintf("{???}"); |
| 2142 | else |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2143 | printsiginfo(&si, verbose(tcp)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2144 | /* options */ |
| 2145 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 2146 | printflags(wait4_options, tcp->u_arg[3], "W???"); |
Roland McGrath | 39426a3 | 2004-10-06 22:02:59 +0000 | [diff] [blame] | 2147 | if (tcp->u_nargs > 4) { |
| 2148 | /* usage */ |
| 2149 | tprintf(", "); |
| 2150 | if (!tcp->u_arg[4]) |
| 2151 | tprintf("NULL"); |
| 2152 | else if (tcp->u_error) |
| 2153 | tprintf("%#lx", tcp->u_arg[4]); |
| 2154 | else |
| 2155 | printrusage(tcp, tcp->u_arg[4]); |
| 2156 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2157 | } |
| 2158 | return 0; |
| 2159 | } |
| 2160 | |
Roland McGrath | c74c0b7 | 2004-09-01 19:39:46 +0000 | [diff] [blame] | 2161 | #endif /* SVR4 or LINUX */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2162 | |
| 2163 | int |
| 2164 | sys_alarm(tcp) |
| 2165 | struct tcb *tcp; |
| 2166 | { |
| 2167 | if (entering(tcp)) |
| 2168 | tprintf("%lu", tcp->u_arg[0]); |
| 2169 | return 0; |
| 2170 | } |
| 2171 | |
| 2172 | int |
| 2173 | sys_uname(tcp) |
| 2174 | struct tcb *tcp; |
| 2175 | { |
| 2176 | struct utsname uname; |
| 2177 | |
| 2178 | if (exiting(tcp)) { |
| 2179 | if (syserror(tcp) || !verbose(tcp)) |
| 2180 | tprintf("%#lx", tcp->u_arg[0]); |
| 2181 | else if (umove(tcp, tcp->u_arg[0], &uname) < 0) |
| 2182 | tprintf("{...}"); |
| 2183 | else if (!abbrev(tcp)) { |
| 2184 | |
| 2185 | tprintf("{sysname=\"%s\", nodename=\"%s\", ", |
| 2186 | uname.sysname, uname.nodename); |
| 2187 | tprintf("release=\"%s\", version=\"%s\", ", |
| 2188 | uname.release, uname.version); |
| 2189 | tprintf("machine=\"%s\"", uname.machine); |
| 2190 | #ifdef LINUX |
| 2191 | #ifndef __GLIBC__ |
| 2192 | tprintf(", domainname=\"%s\"", uname.domainname); |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2193 | #endif |
| 2194 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2195 | tprintf("}"); |
| 2196 | } |
| 2197 | else |
| 2198 | tprintf("{sys=\"%s\", node=\"%s\", ...}", |
| 2199 | uname.sysname, uname.nodename); |
| 2200 | } |
| 2201 | return 0; |
| 2202 | } |
| 2203 | |
| 2204 | #ifndef SVR4 |
| 2205 | |
Roland McGrath | eb9e2e8 | 2009-06-02 16:49:22 -0700 | [diff] [blame] | 2206 | static const struct xlat ptrace_cmds[] = { |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2207 | # ifndef FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2208 | { PTRACE_TRACEME, "PTRACE_TRACEME" }, |
| 2209 | { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT", }, |
| 2210 | { PTRACE_PEEKDATA, "PTRACE_PEEKDATA", }, |
| 2211 | { PTRACE_PEEKUSER, "PTRACE_PEEKUSER", }, |
| 2212 | { PTRACE_POKETEXT, "PTRACE_POKETEXT", }, |
| 2213 | { PTRACE_POKEDATA, "PTRACE_POKEDATA", }, |
| 2214 | { PTRACE_POKEUSER, "PTRACE_POKEUSER", }, |
| 2215 | { PTRACE_CONT, "PTRACE_CONT" }, |
| 2216 | { PTRACE_KILL, "PTRACE_KILL" }, |
| 2217 | { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" }, |
| 2218 | { PTRACE_ATTACH, "PTRACE_ATTACH" }, |
| 2219 | { PTRACE_DETACH, "PTRACE_DETACH" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2220 | # ifdef PTRACE_GETREGS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2221 | { PTRACE_GETREGS, "PTRACE_GETREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2222 | # endif |
| 2223 | # ifdef PTRACE_SETREGS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2224 | { PTRACE_SETREGS, "PTRACE_SETREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2225 | # endif |
| 2226 | # ifdef PTRACE_GETFPREGS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2227 | { PTRACE_GETFPREGS, "PTRACE_GETFPREGS", }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2228 | # endif |
| 2229 | # ifdef PTRACE_SETFPREGS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2230 | { PTRACE_SETFPREGS, "PTRACE_SETFPREGS", }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2231 | # endif |
| 2232 | # ifdef PTRACE_GETFPXREGS |
Roland McGrath | bf621d4 | 2003-01-14 09:46:21 +0000 | [diff] [blame] | 2233 | { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS", }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2234 | # endif |
| 2235 | # ifdef PTRACE_SETFPXREGS |
Roland McGrath | bf621d4 | 2003-01-14 09:46:21 +0000 | [diff] [blame] | 2236 | { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS", }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2237 | # endif |
| 2238 | # ifdef PTRACE_GETVRREGS |
Roland McGrath | f04bb48 | 2005-05-09 07:45:33 +0000 | [diff] [blame] | 2239 | { PTRACE_GETVRREGS, "PTRACE_GETVRREGS", }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2240 | # endif |
| 2241 | # ifdef PTRACE_SETVRREGS |
Roland McGrath | f04bb48 | 2005-05-09 07:45:33 +0000 | [diff] [blame] | 2242 | { PTRACE_SETVRREGS, "PTRACE_SETVRREGS", }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2243 | # endif |
| 2244 | # ifdef PTRACE_SETOPTIONS |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2245 | { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS", }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2246 | # endif |
| 2247 | # ifdef PTRACE_GETEVENTMSG |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2248 | { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG", }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2249 | # endif |
| 2250 | # ifdef PTRACE_GETSIGINFO |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2251 | { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO", }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2252 | # endif |
| 2253 | # ifdef PTRACE_SETSIGINFO |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2254 | { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO", }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2255 | # endif |
| 2256 | # ifdef PTRACE_SET_SYSCALL |
| 2257 | { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL", }, |
| 2258 | # endif |
| 2259 | # ifdef SUNOS4 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2260 | { PTRACE_READDATA, "PTRACE_READDATA" }, |
| 2261 | { PTRACE_WRITEDATA, "PTRACE_WRITEDATA" }, |
| 2262 | { PTRACE_READTEXT, "PTRACE_READTEXT" }, |
| 2263 | { PTRACE_WRITETEXT, "PTRACE_WRITETEXT" }, |
| 2264 | { PTRACE_GETFPAREGS, "PTRACE_GETFPAREGS" }, |
| 2265 | { PTRACE_SETFPAREGS, "PTRACE_SETFPAREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2266 | # ifdef SPARC |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2267 | { PTRACE_GETWINDOW, "PTRACE_GETWINDOW" }, |
| 2268 | { PTRACE_SETWINDOW, "PTRACE_SETWINDOW" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2269 | # else /* !SPARC */ |
| 2270 | { PTRACE_22, "PTRACE_22" }, |
| 2271 | { PTRACE_23, "PTRACE_3" }, |
| 2272 | # endif /* !SPARC */ |
| 2273 | # endif /* SUNOS4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2274 | { PTRACE_SYSCALL, "PTRACE_SYSCALL" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2275 | # ifdef SUNOS4 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2276 | { PTRACE_DUMPCORE, "PTRACE_DUMPCORE" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2277 | # ifdef I386 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2278 | { PTRACE_SETWRBKPT, "PTRACE_SETWRBKPT" }, |
| 2279 | { PTRACE_SETACBKPT, "PTRACE_SETACBKPT" }, |
| 2280 | { PTRACE_CLRDR7, "PTRACE_CLRDR7" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2281 | # else /* !I386 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2282 | { PTRACE_26, "PTRACE_26" }, |
| 2283 | { PTRACE_27, "PTRACE_27" }, |
| 2284 | { PTRACE_28, "PTRACE_28" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2285 | # endif /* !I386 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2286 | { PTRACE_GETUCODE, "PTRACE_GETUCODE" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2287 | # endif /* SUNOS4 */ |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2288 | |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2289 | # else /* FREEBSD */ |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2290 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2291 | { PT_TRACE_ME, "PT_TRACE_ME" }, |
| 2292 | { PT_READ_I, "PT_READ_I" }, |
| 2293 | { PT_READ_D, "PT_READ_D" }, |
| 2294 | { PT_WRITE_I, "PT_WRITE_I" }, |
| 2295 | { PT_WRITE_D, "PT_WRITE_D" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2296 | # ifdef PT_READ_U |
John Hughes | a227814 | 2001-09-28 16:21:30 +0000 | [diff] [blame] | 2297 | { PT_READ_U, "PT_READ_U" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2298 | # endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2299 | { PT_CONTINUE, "PT_CONTINUE" }, |
| 2300 | { PT_KILL, "PT_KILL" }, |
| 2301 | { PT_STEP, "PT_STEP" }, |
| 2302 | { PT_ATTACH, "PT_ATTACH" }, |
| 2303 | { PT_DETACH, "PT_DETACH" }, |
| 2304 | { PT_GETREGS, "PT_GETREGS" }, |
| 2305 | { PT_SETREGS, "PT_SETREGS" }, |
| 2306 | { PT_GETFPREGS, "PT_GETFPREGS" }, |
| 2307 | { PT_SETFPREGS, "PT_SETFPREGS" }, |
| 2308 | { PT_GETDBREGS, "PT_GETDBREGS" }, |
| 2309 | { PT_SETDBREGS, "PT_SETDBREGS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2310 | # endif /* FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2311 | { 0, NULL }, |
| 2312 | }; |
| 2313 | |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2314 | # ifndef FREEBSD |
| 2315 | # ifdef PTRACE_SETOPTIONS |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2316 | static const struct xlat ptrace_setoptions_flags[] = { |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2317 | # ifdef PTRACE_O_TRACESYSGOOD |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2318 | { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2319 | # endif |
| 2320 | # ifdef PTRACE_O_TRACEFORK |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2321 | { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2322 | # endif |
| 2323 | # ifdef PTRACE_O_TRACEVFORK |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2324 | { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2325 | # endif |
| 2326 | # ifdef PTRACE_O_TRACECLONE |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2327 | { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2328 | # endif |
| 2329 | # ifdef PTRACE_O_TRACEEXEC |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2330 | { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2331 | # endif |
| 2332 | # ifdef PTRACE_O_TRACEVFORKDONE |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2333 | { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"}, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2334 | # endif |
| 2335 | # ifdef PTRACE_O_TRACEEXIT |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2336 | { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2337 | # endif |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2338 | { 0, NULL }, |
| 2339 | }; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2340 | # endif /* PTRACE_SETOPTIONS */ |
| 2341 | # endif /* !FREEBSD */ |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 2342 | |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2343 | # ifndef FREEBSD |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 2344 | const struct xlat struct_user_offsets[] = { |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2345 | # ifdef LINUX |
| 2346 | # if defined(S390) || defined(S390X) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 2347 | { PT_PSWMASK, "psw_mask" }, |
| 2348 | { PT_PSWADDR, "psw_addr" }, |
| 2349 | { PT_GPR0, "gpr0" }, |
| 2350 | { PT_GPR1, "gpr1" }, |
| 2351 | { PT_GPR2, "gpr2" }, |
| 2352 | { PT_GPR3, "gpr3" }, |
| 2353 | { PT_GPR4, "gpr4" }, |
| 2354 | { PT_GPR5, "gpr5" }, |
| 2355 | { PT_GPR6, "gpr6" }, |
| 2356 | { PT_GPR7, "gpr7" }, |
| 2357 | { PT_GPR8, "gpr8" }, |
| 2358 | { PT_GPR9, "gpr9" }, |
| 2359 | { PT_GPR10, "gpr10" }, |
| 2360 | { PT_GPR11, "gpr11" }, |
| 2361 | { PT_GPR12, "gpr12" }, |
| 2362 | { PT_GPR13, "gpr13" }, |
| 2363 | { PT_GPR14, "gpr14" }, |
| 2364 | { PT_GPR15, "gpr15" }, |
| 2365 | { PT_ACR0, "acr0" }, |
| 2366 | { PT_ACR1, "acr1" }, |
| 2367 | { PT_ACR2, "acr2" }, |
| 2368 | { PT_ACR3, "acr3" }, |
| 2369 | { PT_ACR4, "acr4" }, |
| 2370 | { PT_ACR5, "acr5" }, |
| 2371 | { PT_ACR6, "acr6" }, |
| 2372 | { PT_ACR7, "acr7" }, |
| 2373 | { PT_ACR8, "acr8" }, |
| 2374 | { PT_ACR9, "acr9" }, |
| 2375 | { PT_ACR10, "acr10" }, |
| 2376 | { PT_ACR11, "acr11" }, |
| 2377 | { PT_ACR12, "acr12" }, |
| 2378 | { PT_ACR13, "acr13" }, |
| 2379 | { PT_ACR14, "acr14" }, |
| 2380 | { PT_ACR15, "acr15" }, |
| 2381 | { PT_ORIGGPR2, "orig_gpr2" }, |
| 2382 | { PT_FPC, "fpc" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2383 | # if defined(S390) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 2384 | { PT_FPR0_HI, "fpr0.hi" }, |
| 2385 | { PT_FPR0_LO, "fpr0.lo" }, |
| 2386 | { PT_FPR1_HI, "fpr1.hi" }, |
| 2387 | { PT_FPR1_LO, "fpr1.lo" }, |
| 2388 | { PT_FPR2_HI, "fpr2.hi" }, |
| 2389 | { PT_FPR2_LO, "fpr2.lo" }, |
| 2390 | { PT_FPR3_HI, "fpr3.hi" }, |
| 2391 | { PT_FPR3_LO, "fpr3.lo" }, |
| 2392 | { PT_FPR4_HI, "fpr4.hi" }, |
| 2393 | { PT_FPR4_LO, "fpr4.lo" }, |
| 2394 | { PT_FPR5_HI, "fpr5.hi" }, |
| 2395 | { PT_FPR5_LO, "fpr5.lo" }, |
| 2396 | { PT_FPR6_HI, "fpr6.hi" }, |
| 2397 | { PT_FPR6_LO, "fpr6.lo" }, |
| 2398 | { PT_FPR7_HI, "fpr7.hi" }, |
| 2399 | { PT_FPR7_LO, "fpr7.lo" }, |
| 2400 | { PT_FPR8_HI, "fpr8.hi" }, |
| 2401 | { PT_FPR8_LO, "fpr8.lo" }, |
| 2402 | { PT_FPR9_HI, "fpr9.hi" }, |
| 2403 | { PT_FPR9_LO, "fpr9.lo" }, |
| 2404 | { PT_FPR10_HI, "fpr10.hi" }, |
| 2405 | { PT_FPR10_LO, "fpr10.lo" }, |
| 2406 | { PT_FPR11_HI, "fpr11.hi" }, |
| 2407 | { PT_FPR11_LO, "fpr11.lo" }, |
| 2408 | { PT_FPR12_HI, "fpr12.hi" }, |
| 2409 | { PT_FPR12_LO, "fpr12.lo" }, |
| 2410 | { PT_FPR13_HI, "fpr13.hi" }, |
| 2411 | { PT_FPR13_LO, "fpr13.lo" }, |
| 2412 | { PT_FPR14_HI, "fpr14.hi" }, |
| 2413 | { PT_FPR14_LO, "fpr14.lo" }, |
| 2414 | { PT_FPR15_HI, "fpr15.hi" }, |
| 2415 | { PT_FPR15_LO, "fpr15.lo" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2416 | # endif |
| 2417 | # if defined(S390X) |
Michal Ludvig | 10a88d0 | 2002-10-07 14:31:00 +0000 | [diff] [blame] | 2418 | { PT_FPR0, "fpr0" }, |
| 2419 | { PT_FPR1, "fpr1" }, |
| 2420 | { PT_FPR2, "fpr2" }, |
| 2421 | { PT_FPR3, "fpr3" }, |
| 2422 | { PT_FPR4, "fpr4" }, |
| 2423 | { PT_FPR5, "fpr5" }, |
| 2424 | { PT_FPR6, "fpr6" }, |
| 2425 | { PT_FPR7, "fpr7" }, |
| 2426 | { PT_FPR8, "fpr8" }, |
| 2427 | { PT_FPR9, "fpr9" }, |
| 2428 | { PT_FPR10, "fpr10" }, |
| 2429 | { PT_FPR11, "fpr11" }, |
| 2430 | { PT_FPR12, "fpr12" }, |
| 2431 | { PT_FPR13, "fpr13" }, |
| 2432 | { PT_FPR14, "fpr14" }, |
| 2433 | { PT_FPR15, "fpr15" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2434 | # endif |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 2435 | { PT_CR_9, "cr9" }, |
| 2436 | { PT_CR_10, "cr10" }, |
| 2437 | { PT_CR_11, "cr11" }, |
Michal Ludvig | 10a88d0 | 2002-10-07 14:31:00 +0000 | [diff] [blame] | 2438 | { PT_IEEE_IP, "ieee_exception_ip" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2439 | # elif defined(SPARC) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2440 | /* XXX No support for these offsets yet. */ |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2441 | # elif defined(HPPA) |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 2442 | /* XXX No support for these offsets yet. */ |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2443 | # elif defined(POWERPC) |
| 2444 | # ifndef PT_ORIG_R3 |
| 2445 | # define PT_ORIG_R3 34 |
| 2446 | # endif |
| 2447 | # define REGSIZE (sizeof(unsigned long)) |
Roland McGrath | eb28535 | 2003-01-14 09:59:00 +0000 | [diff] [blame] | 2448 | { REGSIZE*PT_R0, "r0" }, |
| 2449 | { REGSIZE*PT_R1, "r1" }, |
| 2450 | { REGSIZE*PT_R2, "r2" }, |
| 2451 | { REGSIZE*PT_R3, "r3" }, |
| 2452 | { REGSIZE*PT_R4, "r4" }, |
| 2453 | { REGSIZE*PT_R5, "r5" }, |
| 2454 | { REGSIZE*PT_R6, "r6" }, |
| 2455 | { REGSIZE*PT_R7, "r7" }, |
| 2456 | { REGSIZE*PT_R8, "r8" }, |
| 2457 | { REGSIZE*PT_R9, "r9" }, |
| 2458 | { REGSIZE*PT_R10, "r10" }, |
| 2459 | { REGSIZE*PT_R11, "r11" }, |
| 2460 | { REGSIZE*PT_R12, "r12" }, |
| 2461 | { REGSIZE*PT_R13, "r13" }, |
| 2462 | { REGSIZE*PT_R14, "r14" }, |
| 2463 | { REGSIZE*PT_R15, "r15" }, |
| 2464 | { REGSIZE*PT_R16, "r16" }, |
| 2465 | { REGSIZE*PT_R17, "r17" }, |
| 2466 | { REGSIZE*PT_R18, "r18" }, |
| 2467 | { REGSIZE*PT_R19, "r19" }, |
| 2468 | { REGSIZE*PT_R20, "r20" }, |
| 2469 | { REGSIZE*PT_R21, "r21" }, |
| 2470 | { REGSIZE*PT_R22, "r22" }, |
| 2471 | { REGSIZE*PT_R23, "r23" }, |
| 2472 | { REGSIZE*PT_R24, "r24" }, |
| 2473 | { REGSIZE*PT_R25, "r25" }, |
| 2474 | { REGSIZE*PT_R26, "r26" }, |
| 2475 | { REGSIZE*PT_R27, "r27" }, |
| 2476 | { REGSIZE*PT_R28, "r28" }, |
| 2477 | { REGSIZE*PT_R29, "r29" }, |
| 2478 | { REGSIZE*PT_R30, "r30" }, |
| 2479 | { REGSIZE*PT_R31, "r31" }, |
| 2480 | { REGSIZE*PT_NIP, "NIP" }, |
| 2481 | { REGSIZE*PT_MSR, "MSR" }, |
| 2482 | { REGSIZE*PT_ORIG_R3, "ORIG_R3" }, |
| 2483 | { REGSIZE*PT_CTR, "CTR" }, |
| 2484 | { REGSIZE*PT_LNK, "LNK" }, |
| 2485 | { REGSIZE*PT_XER, "XER" }, |
| 2486 | { REGSIZE*PT_CCR, "CCR" }, |
| 2487 | { REGSIZE*PT_FPR0, "FPR0" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2488 | # undef REGSIZE |
| 2489 | # elif defined(ALPHA) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 2490 | { 0, "r0" }, |
| 2491 | { 1, "r1" }, |
| 2492 | { 2, "r2" }, |
| 2493 | { 3, "r3" }, |
| 2494 | { 4, "r4" }, |
| 2495 | { 5, "r5" }, |
| 2496 | { 6, "r6" }, |
| 2497 | { 7, "r7" }, |
| 2498 | { 8, "r8" }, |
| 2499 | { 9, "r9" }, |
| 2500 | { 10, "r10" }, |
| 2501 | { 11, "r11" }, |
| 2502 | { 12, "r12" }, |
| 2503 | { 13, "r13" }, |
| 2504 | { 14, "r14" }, |
| 2505 | { 15, "r15" }, |
| 2506 | { 16, "r16" }, |
| 2507 | { 17, "r17" }, |
| 2508 | { 18, "r18" }, |
| 2509 | { 19, "r19" }, |
| 2510 | { 20, "r20" }, |
| 2511 | { 21, "r21" }, |
| 2512 | { 22, "r22" }, |
| 2513 | { 23, "r23" }, |
| 2514 | { 24, "r24" }, |
| 2515 | { 25, "r25" }, |
| 2516 | { 26, "r26" }, |
| 2517 | { 27, "r27" }, |
| 2518 | { 28, "r28" }, |
| 2519 | { 29, "gp" }, |
| 2520 | { 30, "fp" }, |
| 2521 | { 31, "zero" }, |
| 2522 | { 32, "fp0" }, |
| 2523 | { 33, "fp" }, |
| 2524 | { 34, "fp2" }, |
| 2525 | { 35, "fp3" }, |
| 2526 | { 36, "fp4" }, |
| 2527 | { 37, "fp5" }, |
| 2528 | { 38, "fp6" }, |
| 2529 | { 39, "fp7" }, |
| 2530 | { 40, "fp8" }, |
| 2531 | { 41, "fp9" }, |
| 2532 | { 42, "fp10" }, |
| 2533 | { 43, "fp11" }, |
| 2534 | { 44, "fp12" }, |
| 2535 | { 45, "fp13" }, |
| 2536 | { 46, "fp14" }, |
| 2537 | { 47, "fp15" }, |
| 2538 | { 48, "fp16" }, |
| 2539 | { 49, "fp17" }, |
| 2540 | { 50, "fp18" }, |
| 2541 | { 51, "fp19" }, |
| 2542 | { 52, "fp20" }, |
| 2543 | { 53, "fp21" }, |
| 2544 | { 54, "fp22" }, |
| 2545 | { 55, "fp23" }, |
| 2546 | { 56, "fp24" }, |
| 2547 | { 57, "fp25" }, |
| 2548 | { 58, "fp26" }, |
| 2549 | { 59, "fp27" }, |
| 2550 | { 60, "fp28" }, |
| 2551 | { 61, "fp29" }, |
| 2552 | { 62, "fp30" }, |
| 2553 | { 63, "fp31" }, |
| 2554 | { 64, "pc" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2555 | # elif defined(IA64) |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 2556 | { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" }, |
| 2557 | { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" }, |
| 2558 | { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" }, |
| 2559 | { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" }, |
| 2560 | { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" }, |
| 2561 | { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" }, |
| 2562 | { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" }, |
| 2563 | { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" }, |
| 2564 | { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" }, |
| 2565 | { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" }, |
| 2566 | { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" }, |
| 2567 | { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" }, |
| 2568 | { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" }, |
| 2569 | { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" }, |
| 2570 | { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" }, |
| 2571 | { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" }, |
| 2572 | { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" }, |
| 2573 | { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" }, |
| 2574 | { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" }, |
| 2575 | { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" }, |
| 2576 | { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" }, |
| 2577 | { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" }, |
| 2578 | { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" }, |
| 2579 | { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" }, |
| 2580 | { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" }, |
| 2581 | { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" }, |
| 2582 | { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" }, |
| 2583 | { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" }, |
| 2584 | { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" }, |
| 2585 | { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" }, |
| 2586 | { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" }, |
| 2587 | { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" }, |
| 2588 | /* switch stack: */ |
| 2589 | { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" }, |
| 2590 | { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" }, |
| 2591 | { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" }, |
| 2592 | { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" }, |
| 2593 | { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" }, |
| 2594 | { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" }, |
| 2595 | { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" }, |
| 2596 | { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" }, |
| 2597 | { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" }, |
| 2598 | { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" }, |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 2599 | { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" }, |
| 2600 | { PT_B4, "b4" }, { PT_B5, "b5" }, |
Roland McGrath | ca4e10c | 2004-01-13 10:13:20 +0000 | [diff] [blame] | 2601 | { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" }, |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 2602 | /* pt_regs */ |
Roland McGrath | ca4e10c | 2004-01-13 10:13:20 +0000 | [diff] [blame] | 2603 | { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" }, |
| 2604 | { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" }, |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 2605 | { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" }, |
| 2606 | { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" }, |
| 2607 | { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" }, |
| 2608 | { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" }, |
| 2609 | { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" }, |
| 2610 | { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" }, |
| 2611 | { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" }, |
| 2612 | { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" }, |
| 2613 | { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" }, |
| 2614 | { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" }, |
| 2615 | { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" }, |
| 2616 | { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" }, |
| 2617 | { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" }, |
| 2618 | { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" }, |
| 2619 | { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2620 | # ifdef PT_AR_CSD |
Roland McGrath | fb1bc07 | 2004-03-01 21:29:24 +0000 | [diff] [blame] | 2621 | { PT_AR_CSD, "ar.csd" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2622 | # endif |
| 2623 | # ifdef PT_AR_SSD |
Roland McGrath | fb1bc07 | 2004-03-01 21:29:24 +0000 | [diff] [blame] | 2624 | { PT_AR_SSD, "ar.ssd" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2625 | # endif |
Roland McGrath | ca4e10c | 2004-01-13 10:13:20 +0000 | [diff] [blame] | 2626 | { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2627 | # elif defined(I386) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2628 | { 4*EBX, "4*EBX" }, |
| 2629 | { 4*ECX, "4*ECX" }, |
| 2630 | { 4*EDX, "4*EDX" }, |
| 2631 | { 4*ESI, "4*ESI" }, |
| 2632 | { 4*EDI, "4*EDI" }, |
| 2633 | { 4*EBP, "4*EBP" }, |
| 2634 | { 4*EAX, "4*EAX" }, |
| 2635 | { 4*DS, "4*DS" }, |
| 2636 | { 4*ES, "4*ES" }, |
| 2637 | { 4*FS, "4*FS" }, |
| 2638 | { 4*GS, "4*GS" }, |
| 2639 | { 4*ORIG_EAX, "4*ORIG_EAX" }, |
| 2640 | { 4*EIP, "4*EIP" }, |
| 2641 | { 4*CS, "4*CS" }, |
| 2642 | { 4*EFL, "4*EFL" }, |
| 2643 | { 4*UESP, "4*UESP" }, |
| 2644 | { 4*SS, "4*SS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2645 | # elif defined(X86_64) |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 2646 | { 8*R15, "8*R15" }, |
| 2647 | { 8*R14, "8*R14" }, |
| 2648 | { 8*R13, "8*R13" }, |
| 2649 | { 8*R12, "8*R12" }, |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 2650 | { 8*RBP, "8*RBP" }, |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 2651 | { 8*RBX, "8*RBX" }, |
| 2652 | { 8*R11, "8*R11" }, |
| 2653 | { 8*R10, "8*R10" }, |
| 2654 | { 8*R9, "8*R9" }, |
| 2655 | { 8*R8, "8*R8" }, |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 2656 | { 8*RAX, "8*RAX" }, |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 2657 | { 8*RCX, "8*RCX" }, |
| 2658 | { 8*RDX, "8*RDX" }, |
| 2659 | { 8*RSI, "8*RSI" }, |
| 2660 | { 8*RDI, "8*RDI" }, |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 2661 | { 8*ORIG_RAX, "8*ORIG_RAX" }, |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 2662 | { 8*RIP, "8*RIP" }, |
| 2663 | { 8*CS, "8*CS" }, |
| 2664 | { 8*EFLAGS, "8*EFL" }, |
Roland McGrath | a4f9f2d | 2005-06-07 23:21:20 +0000 | [diff] [blame] | 2665 | { 8*RSP, "8*RSP" }, |
Michal Ludvig | 0e03550 | 2002-09-23 15:41:01 +0000 | [diff] [blame] | 2666 | { 8*SS, "8*SS" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2667 | # elif defined(M68K) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2668 | { 4*PT_D1, "4*PT_D1" }, |
| 2669 | { 4*PT_D2, "4*PT_D2" }, |
| 2670 | { 4*PT_D3, "4*PT_D3" }, |
| 2671 | { 4*PT_D4, "4*PT_D4" }, |
| 2672 | { 4*PT_D5, "4*PT_D5" }, |
| 2673 | { 4*PT_D6, "4*PT_D6" }, |
| 2674 | { 4*PT_D7, "4*PT_D7" }, |
| 2675 | { 4*PT_A0, "4*PT_A0" }, |
| 2676 | { 4*PT_A1, "4*PT_A1" }, |
| 2677 | { 4*PT_A2, "4*PT_A2" }, |
| 2678 | { 4*PT_A3, "4*PT_A3" }, |
| 2679 | { 4*PT_A4, "4*PT_A4" }, |
| 2680 | { 4*PT_A5, "4*PT_A5" }, |
| 2681 | { 4*PT_A6, "4*PT_A6" }, |
| 2682 | { 4*PT_D0, "4*PT_D0" }, |
| 2683 | { 4*PT_USP, "4*PT_USP" }, |
| 2684 | { 4*PT_ORIG_D0, "4*PT_ORIG_D0" }, |
| 2685 | { 4*PT_SR, "4*PT_SR" }, |
| 2686 | { 4*PT_PC, "4*PT_PC" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2687 | # elif defined(SH) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 2688 | { 4*REG_REG0, "4*REG_REG0" }, |
| 2689 | { 4*(REG_REG0+1), "4*REG_REG1" }, |
| 2690 | { 4*(REG_REG0+2), "4*REG_REG2" }, |
| 2691 | { 4*(REG_REG0+3), "4*REG_REG3" }, |
| 2692 | { 4*(REG_REG0+4), "4*REG_REG4" }, |
| 2693 | { 4*(REG_REG0+5), "4*REG_REG5" }, |
| 2694 | { 4*(REG_REG0+6), "4*REG_REG6" }, |
| 2695 | { 4*(REG_REG0+7), "4*REG_REG7" }, |
| 2696 | { 4*(REG_REG0+8), "4*REG_REG8" }, |
| 2697 | { 4*(REG_REG0+9), "4*REG_REG9" }, |
| 2698 | { 4*(REG_REG0+10), "4*REG_REG10" }, |
| 2699 | { 4*(REG_REG0+11), "4*REG_REG11" }, |
| 2700 | { 4*(REG_REG0+12), "4*REG_REG12" }, |
| 2701 | { 4*(REG_REG0+13), "4*REG_REG13" }, |
| 2702 | { 4*(REG_REG0+14), "4*REG_REG14" }, |
| 2703 | { 4*REG_REG15, "4*REG_REG15" }, |
| 2704 | { 4*REG_PC, "4*REG_PC" }, |
| 2705 | { 4*REG_PR, "4*REG_PR" }, |
| 2706 | { 4*REG_SR, "4*REG_SR" }, |
| 2707 | { 4*REG_GBR, "4*REG_GBR" }, |
| 2708 | { 4*REG_MACH, "4*REG_MACH" }, |
| 2709 | { 4*REG_MACL, "4*REG_MACL" }, |
| 2710 | { 4*REG_SYSCALL, "4*REG_SYSCALL" }, |
| 2711 | { 4*REG_FPUL, "4*REG_FPUL" }, |
| 2712 | { 4*REG_FPREG0, "4*REG_FPREG0" }, |
| 2713 | { 4*(REG_FPREG0+1), "4*REG_FPREG1" }, |
| 2714 | { 4*(REG_FPREG0+2), "4*REG_FPREG2" }, |
| 2715 | { 4*(REG_FPREG0+3), "4*REG_FPREG3" }, |
| 2716 | { 4*(REG_FPREG0+4), "4*REG_FPREG4" }, |
| 2717 | { 4*(REG_FPREG0+5), "4*REG_FPREG5" }, |
| 2718 | { 4*(REG_FPREG0+6), "4*REG_FPREG6" }, |
| 2719 | { 4*(REG_FPREG0+7), "4*REG_FPREG7" }, |
| 2720 | { 4*(REG_FPREG0+8), "4*REG_FPREG8" }, |
| 2721 | { 4*(REG_FPREG0+9), "4*REG_FPREG9" }, |
| 2722 | { 4*(REG_FPREG0+10), "4*REG_FPREG10" }, |
| 2723 | { 4*(REG_FPREG0+11), "4*REG_FPREG11" }, |
| 2724 | { 4*(REG_FPREG0+12), "4*REG_FPREG12" }, |
| 2725 | { 4*(REG_FPREG0+13), "4*REG_FPREG13" }, |
| 2726 | { 4*(REG_FPREG0+14), "4*REG_FPREG14" }, |
| 2727 | { 4*REG_FPREG15, "4*REG_FPREG15" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2728 | # ifdef REG_XDREG0 |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 2729 | { 4*REG_XDREG0, "4*REG_XDREG0" }, |
| 2730 | { 4*(REG_XDREG0+2), "4*REG_XDREG2" }, |
| 2731 | { 4*(REG_XDREG0+4), "4*REG_XDREG4" }, |
| 2732 | { 4*(REG_XDREG0+6), "4*REG_XDREG6" }, |
| 2733 | { 4*(REG_XDREG0+8), "4*REG_XDREG8" }, |
| 2734 | { 4*(REG_XDREG0+10), "4*REG_XDREG10" }, |
| 2735 | { 4*(REG_XDREG0+12), "4*REG_XDREG12" }, |
| 2736 | { 4*REG_XDREG14, "4*REG_XDREG14" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2737 | # endif |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 2738 | { 4*REG_FPSCR, "4*REG_FPSCR" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2739 | # elif defined(SH64) |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 2740 | { 0, "PC(L)" }, |
| 2741 | { 4, "PC(U)" }, |
| 2742 | { 8, "SR(L)" }, |
| 2743 | { 12, "SR(U)" }, |
| 2744 | { 16, "syscall no.(L)" }, |
| 2745 | { 20, "syscall_no.(U)" }, |
| 2746 | { 24, "R0(L)" }, |
| 2747 | { 28, "R0(U)" }, |
| 2748 | { 32, "R1(L)" }, |
| 2749 | { 36, "R1(U)" }, |
| 2750 | { 40, "R2(L)" }, |
| 2751 | { 44, "R2(U)" }, |
| 2752 | { 48, "R3(L)" }, |
| 2753 | { 52, "R3(U)" }, |
| 2754 | { 56, "R4(L)" }, |
| 2755 | { 60, "R4(U)" }, |
| 2756 | { 64, "R5(L)" }, |
| 2757 | { 68, "R5(U)" }, |
| 2758 | { 72, "R6(L)" }, |
| 2759 | { 76, "R6(U)" }, |
| 2760 | { 80, "R7(L)" }, |
| 2761 | { 84, "R7(U)" }, |
| 2762 | { 88, "R8(L)" }, |
| 2763 | { 92, "R8(U)" }, |
| 2764 | { 96, "R9(L)" }, |
| 2765 | { 100, "R9(U)" }, |
| 2766 | { 104, "R10(L)" }, |
| 2767 | { 108, "R10(U)" }, |
| 2768 | { 112, "R11(L)" }, |
| 2769 | { 116, "R11(U)" }, |
| 2770 | { 120, "R12(L)" }, |
| 2771 | { 124, "R12(U)" }, |
| 2772 | { 128, "R13(L)" }, |
| 2773 | { 132, "R13(U)" }, |
| 2774 | { 136, "R14(L)" }, |
| 2775 | { 140, "R14(U)" }, |
| 2776 | { 144, "R15(L)" }, |
| 2777 | { 148, "R15(U)" }, |
| 2778 | { 152, "R16(L)" }, |
| 2779 | { 156, "R16(U)" }, |
| 2780 | { 160, "R17(L)" }, |
| 2781 | { 164, "R17(U)" }, |
| 2782 | { 168, "R18(L)" }, |
| 2783 | { 172, "R18(U)" }, |
| 2784 | { 176, "R19(L)" }, |
| 2785 | { 180, "R19(U)" }, |
| 2786 | { 184, "R20(L)" }, |
| 2787 | { 188, "R20(U)" }, |
| 2788 | { 192, "R21(L)" }, |
| 2789 | { 196, "R21(U)" }, |
| 2790 | { 200, "R22(L)" }, |
| 2791 | { 204, "R22(U)" }, |
| 2792 | { 208, "R23(L)" }, |
| 2793 | { 212, "R23(U)" }, |
| 2794 | { 216, "R24(L)" }, |
| 2795 | { 220, "R24(U)" }, |
| 2796 | { 224, "R25(L)" }, |
| 2797 | { 228, "R25(U)" }, |
| 2798 | { 232, "R26(L)" }, |
| 2799 | { 236, "R26(U)" }, |
| 2800 | { 240, "R27(L)" }, |
| 2801 | { 244, "R27(U)" }, |
| 2802 | { 248, "R28(L)" }, |
| 2803 | { 252, "R28(U)" }, |
| 2804 | { 256, "R29(L)" }, |
| 2805 | { 260, "R29(U)" }, |
| 2806 | { 264, "R30(L)" }, |
| 2807 | { 268, "R30(U)" }, |
| 2808 | { 272, "R31(L)" }, |
| 2809 | { 276, "R31(U)" }, |
| 2810 | { 280, "R32(L)" }, |
| 2811 | { 284, "R32(U)" }, |
| 2812 | { 288, "R33(L)" }, |
| 2813 | { 292, "R33(U)" }, |
| 2814 | { 296, "R34(L)" }, |
| 2815 | { 300, "R34(U)" }, |
| 2816 | { 304, "R35(L)" }, |
| 2817 | { 308, "R35(U)" }, |
| 2818 | { 312, "R36(L)" }, |
| 2819 | { 316, "R36(U)" }, |
| 2820 | { 320, "R37(L)" }, |
| 2821 | { 324, "R37(U)" }, |
| 2822 | { 328, "R38(L)" }, |
| 2823 | { 332, "R38(U)" }, |
| 2824 | { 336, "R39(L)" }, |
| 2825 | { 340, "R39(U)" }, |
| 2826 | { 344, "R40(L)" }, |
| 2827 | { 348, "R40(U)" }, |
| 2828 | { 352, "R41(L)" }, |
| 2829 | { 356, "R41(U)" }, |
| 2830 | { 360, "R42(L)" }, |
| 2831 | { 364, "R42(U)" }, |
| 2832 | { 368, "R43(L)" }, |
| 2833 | { 372, "R43(U)" }, |
| 2834 | { 376, "R44(L)" }, |
| 2835 | { 380, "R44(U)" }, |
| 2836 | { 384, "R45(L)" }, |
| 2837 | { 388, "R45(U)" }, |
| 2838 | { 392, "R46(L)" }, |
| 2839 | { 396, "R46(U)" }, |
| 2840 | { 400, "R47(L)" }, |
| 2841 | { 404, "R47(U)" }, |
| 2842 | { 408, "R48(L)" }, |
| 2843 | { 412, "R48(U)" }, |
| 2844 | { 416, "R49(L)" }, |
| 2845 | { 420, "R49(U)" }, |
| 2846 | { 424, "R50(L)" }, |
| 2847 | { 428, "R50(U)" }, |
| 2848 | { 432, "R51(L)" }, |
| 2849 | { 436, "R51(U)" }, |
| 2850 | { 440, "R52(L)" }, |
| 2851 | { 444, "R52(U)" }, |
| 2852 | { 448, "R53(L)" }, |
| 2853 | { 452, "R53(U)" }, |
| 2854 | { 456, "R54(L)" }, |
| 2855 | { 460, "R54(U)" }, |
| 2856 | { 464, "R55(L)" }, |
| 2857 | { 468, "R55(U)" }, |
| 2858 | { 472, "R56(L)" }, |
| 2859 | { 476, "R56(U)" }, |
| 2860 | { 480, "R57(L)" }, |
| 2861 | { 484, "R57(U)" }, |
| 2862 | { 488, "R58(L)" }, |
| 2863 | { 492, "R58(U)" }, |
| 2864 | { 496, "R59(L)" }, |
| 2865 | { 500, "R59(U)" }, |
| 2866 | { 504, "R60(L)" }, |
| 2867 | { 508, "R60(U)" }, |
| 2868 | { 512, "R61(L)" }, |
| 2869 | { 516, "R61(U)" }, |
| 2870 | { 520, "R62(L)" }, |
| 2871 | { 524, "R62(U)" }, |
| 2872 | { 528, "TR0(L)" }, |
| 2873 | { 532, "TR0(U)" }, |
| 2874 | { 536, "TR1(L)" }, |
| 2875 | { 540, "TR1(U)" }, |
| 2876 | { 544, "TR2(L)" }, |
| 2877 | { 548, "TR2(U)" }, |
| 2878 | { 552, "TR3(L)" }, |
| 2879 | { 556, "TR3(U)" }, |
| 2880 | { 560, "TR4(L)" }, |
| 2881 | { 564, "TR4(U)" }, |
| 2882 | { 568, "TR5(L)" }, |
| 2883 | { 572, "TR5(U)" }, |
| 2884 | { 576, "TR6(L)" }, |
| 2885 | { 580, "TR6(U)" }, |
| 2886 | { 584, "TR7(L)" }, |
| 2887 | { 588, "TR7(U)" }, |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 2888 | /* This entry is in case pt_regs contains dregs (depends on |
| 2889 | the kernel build options). */ |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 2890 | { uoff(regs), "offsetof(struct user, regs)" }, |
| 2891 | { uoff(fpu), "offsetof(struct user, fpu)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2892 | # elif defined(ARM) |
Roland McGrath | 0f87c49 | 2003-06-03 23:29:04 +0000 | [diff] [blame] | 2893 | { uoff(regs.ARM_r0), "r0" }, |
| 2894 | { uoff(regs.ARM_r1), "r1" }, |
| 2895 | { uoff(regs.ARM_r2), "r2" }, |
| 2896 | { uoff(regs.ARM_r3), "r3" }, |
| 2897 | { uoff(regs.ARM_r4), "r4" }, |
| 2898 | { uoff(regs.ARM_r5), "r5" }, |
| 2899 | { uoff(regs.ARM_r6), "r6" }, |
| 2900 | { uoff(regs.ARM_r7), "r7" }, |
| 2901 | { uoff(regs.ARM_r8), "r8" }, |
| 2902 | { uoff(regs.ARM_r9), "r9" }, |
| 2903 | { uoff(regs.ARM_r10), "r10" }, |
| 2904 | { uoff(regs.ARM_fp), "fp" }, |
| 2905 | { uoff(regs.ARM_ip), "ip" }, |
| 2906 | { uoff(regs.ARM_sp), "sp" }, |
| 2907 | { uoff(regs.ARM_lr), "lr" }, |
| 2908 | { uoff(regs.ARM_pc), "pc" }, |
| 2909 | { uoff(regs.ARM_cpsr), "cpsr" }, |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 2910 | # elif defined(AVR32) |
| 2911 | { uoff(regs.sr), "sr" }, |
| 2912 | { uoff(regs.pc), "pc" }, |
| 2913 | { uoff(regs.lr), "lr" }, |
| 2914 | { uoff(regs.sp), "sp" }, |
| 2915 | { uoff(regs.r12), "r12" }, |
| 2916 | { uoff(regs.r11), "r11" }, |
| 2917 | { uoff(regs.r10), "r10" }, |
| 2918 | { uoff(regs.r9), "r9" }, |
| 2919 | { uoff(regs.r8), "r8" }, |
| 2920 | { uoff(regs.r7), "r7" }, |
| 2921 | { uoff(regs.r6), "r6" }, |
| 2922 | { uoff(regs.r5), "r5" }, |
| 2923 | { uoff(regs.r4), "r4" }, |
| 2924 | { uoff(regs.r3), "r3" }, |
| 2925 | { uoff(regs.r2), "r2" }, |
| 2926 | { uoff(regs.r1), "r1" }, |
| 2927 | { uoff(regs.r0), "r0" }, |
| 2928 | { uoff(regs.r12_orig), "orig_r12" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 2929 | # elif defined(MIPS) |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 2930 | { 0, "r0" }, |
| 2931 | { 1, "r1" }, |
| 2932 | { 2, "r2" }, |
| 2933 | { 3, "r3" }, |
| 2934 | { 4, "r4" }, |
| 2935 | { 5, "r5" }, |
| 2936 | { 6, "r6" }, |
| 2937 | { 7, "r7" }, |
| 2938 | { 8, "r8" }, |
| 2939 | { 9, "r9" }, |
| 2940 | { 10, "r10" }, |
| 2941 | { 11, "r11" }, |
| 2942 | { 12, "r12" }, |
| 2943 | { 13, "r13" }, |
| 2944 | { 14, "r14" }, |
| 2945 | { 15, "r15" }, |
| 2946 | { 16, "r16" }, |
| 2947 | { 17, "r17" }, |
| 2948 | { 18, "r18" }, |
| 2949 | { 19, "r19" }, |
| 2950 | { 20, "r20" }, |
| 2951 | { 21, "r21" }, |
| 2952 | { 22, "r22" }, |
| 2953 | { 23, "r23" }, |
| 2954 | { 24, "r24" }, |
| 2955 | { 25, "r25" }, |
| 2956 | { 26, "r26" }, |
| 2957 | { 27, "r27" }, |
| 2958 | { 28, "r28" }, |
| 2959 | { 29, "r29" }, |
| 2960 | { 30, "r30" }, |
| 2961 | { 31, "r31" }, |
| 2962 | { 32, "f0" }, |
| 2963 | { 33, "f1" }, |
| 2964 | { 34, "f2" }, |
| 2965 | { 35, "f3" }, |
| 2966 | { 36, "f4" }, |
| 2967 | { 37, "f5" }, |
| 2968 | { 38, "f6" }, |
| 2969 | { 39, "f7" }, |
| 2970 | { 40, "f8" }, |
| 2971 | { 41, "f9" }, |
| 2972 | { 42, "f10" }, |
| 2973 | { 43, "f11" }, |
| 2974 | { 44, "f12" }, |
| 2975 | { 45, "f13" }, |
| 2976 | { 46, "f14" }, |
| 2977 | { 47, "f15" }, |
| 2978 | { 48, "f16" }, |
| 2979 | { 49, "f17" }, |
| 2980 | { 50, "f18" }, |
| 2981 | { 51, "f19" }, |
| 2982 | { 52, "f20" }, |
| 2983 | { 53, "f21" }, |
| 2984 | { 54, "f22" }, |
| 2985 | { 55, "f23" }, |
| 2986 | { 56, "f24" }, |
| 2987 | { 57, "f25" }, |
| 2988 | { 58, "f26" }, |
| 2989 | { 59, "f27" }, |
| 2990 | { 60, "f28" }, |
| 2991 | { 61, "f29" }, |
| 2992 | { 62, "f30" }, |
| 2993 | { 63, "f31" }, |
| 2994 | { 64, "pc" }, |
| 2995 | { 65, "cause" }, |
| 2996 | { 66, "badvaddr" }, |
| 2997 | { 67, "mmhi" }, |
| 2998 | { 68, "mmlo" }, |
| 2999 | { 69, "fpcsr" }, |
| 3000 | { 70, "fpeir" }, |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 3001 | # elif defined(TILE) |
| 3002 | { PTREGS_OFFSET_REG(0), "r0" }, |
| 3003 | { PTREGS_OFFSET_REG(1), "r1" }, |
| 3004 | { PTREGS_OFFSET_REG(2), "r2" }, |
| 3005 | { PTREGS_OFFSET_REG(3), "r3" }, |
| 3006 | { PTREGS_OFFSET_REG(4), "r4" }, |
| 3007 | { PTREGS_OFFSET_REG(5), "r5" }, |
| 3008 | { PTREGS_OFFSET_REG(6), "r6" }, |
| 3009 | { PTREGS_OFFSET_REG(7), "r7" }, |
| 3010 | { PTREGS_OFFSET_REG(8), "r8" }, |
| 3011 | { PTREGS_OFFSET_REG(9), "r9" }, |
| 3012 | { PTREGS_OFFSET_REG(10), "r10" }, |
| 3013 | { PTREGS_OFFSET_REG(11), "r11" }, |
| 3014 | { PTREGS_OFFSET_REG(12), "r12" }, |
| 3015 | { PTREGS_OFFSET_REG(13), "r13" }, |
| 3016 | { PTREGS_OFFSET_REG(14), "r14" }, |
| 3017 | { PTREGS_OFFSET_REG(15), "r15" }, |
| 3018 | { PTREGS_OFFSET_REG(16), "r16" }, |
| 3019 | { PTREGS_OFFSET_REG(17), "r17" }, |
| 3020 | { PTREGS_OFFSET_REG(18), "r18" }, |
| 3021 | { PTREGS_OFFSET_REG(19), "r19" }, |
| 3022 | { PTREGS_OFFSET_REG(20), "r20" }, |
| 3023 | { PTREGS_OFFSET_REG(21), "r21" }, |
| 3024 | { PTREGS_OFFSET_REG(22), "r22" }, |
| 3025 | { PTREGS_OFFSET_REG(23), "r23" }, |
| 3026 | { PTREGS_OFFSET_REG(24), "r24" }, |
| 3027 | { PTREGS_OFFSET_REG(25), "r25" }, |
| 3028 | { PTREGS_OFFSET_REG(26), "r26" }, |
| 3029 | { PTREGS_OFFSET_REG(27), "r27" }, |
| 3030 | { PTREGS_OFFSET_REG(28), "r28" }, |
| 3031 | { PTREGS_OFFSET_REG(29), "r29" }, |
| 3032 | { PTREGS_OFFSET_REG(30), "r30" }, |
| 3033 | { PTREGS_OFFSET_REG(31), "r31" }, |
| 3034 | { PTREGS_OFFSET_REG(32), "r32" }, |
| 3035 | { PTREGS_OFFSET_REG(33), "r33" }, |
| 3036 | { PTREGS_OFFSET_REG(34), "r34" }, |
| 3037 | { PTREGS_OFFSET_REG(35), "r35" }, |
| 3038 | { PTREGS_OFFSET_REG(36), "r36" }, |
| 3039 | { PTREGS_OFFSET_REG(37), "r37" }, |
| 3040 | { PTREGS_OFFSET_REG(38), "r38" }, |
| 3041 | { PTREGS_OFFSET_REG(39), "r39" }, |
| 3042 | { PTREGS_OFFSET_REG(40), "r40" }, |
| 3043 | { PTREGS_OFFSET_REG(41), "r41" }, |
| 3044 | { PTREGS_OFFSET_REG(42), "r42" }, |
| 3045 | { PTREGS_OFFSET_REG(43), "r43" }, |
| 3046 | { PTREGS_OFFSET_REG(44), "r44" }, |
| 3047 | { PTREGS_OFFSET_REG(45), "r45" }, |
| 3048 | { PTREGS_OFFSET_REG(46), "r46" }, |
| 3049 | { PTREGS_OFFSET_REG(47), "r47" }, |
| 3050 | { PTREGS_OFFSET_REG(48), "r48" }, |
| 3051 | { PTREGS_OFFSET_REG(49), "r49" }, |
| 3052 | { PTREGS_OFFSET_REG(50), "r50" }, |
| 3053 | { PTREGS_OFFSET_REG(51), "r51" }, |
| 3054 | { PTREGS_OFFSET_REG(52), "r52" }, |
| 3055 | { PTREGS_OFFSET_TP, "tp" }, |
| 3056 | { PTREGS_OFFSET_SP, "sp" }, |
| 3057 | { PTREGS_OFFSET_LR, "lr" }, |
| 3058 | { PTREGS_OFFSET_PC, "pc" }, |
| 3059 | { PTREGS_OFFSET_EX1, "ex1" }, |
| 3060 | { PTREGS_OFFSET_FAULTNUM, "faultnum" }, |
| 3061 | { PTREGS_OFFSET_ORIG_R0, "orig_r0" }, |
| 3062 | { PTREGS_OFFSET_FLAGS, "flags" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3063 | # endif |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 3064 | # ifdef CRISV10 |
| 3065 | { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" }, |
| 3066 | { 4*PT_ORIG_R10, "4*PT_ORIG_R10" }, |
| 3067 | { 4*PT_R13, "4*PT_R13" }, |
| 3068 | { 4*PT_R12, "4*PT_R12" }, |
| 3069 | { 4*PT_R11, "4*PT_R11" }, |
| 3070 | { 4*PT_R10, "4*PT_R10" }, |
| 3071 | { 4*PT_R9, "4*PT_R9" }, |
| 3072 | { 4*PT_R8, "4*PT_R8" }, |
| 3073 | { 4*PT_R7, "4*PT_R7" }, |
| 3074 | { 4*PT_R6, "4*PT_R6" }, |
| 3075 | { 4*PT_R5, "4*PT_R5" }, |
| 3076 | { 4*PT_R4, "4*PT_R4" }, |
| 3077 | { 4*PT_R3, "4*PT_R3" }, |
| 3078 | { 4*PT_R2, "4*PT_R2" }, |
| 3079 | { 4*PT_R1, "4*PT_R1" }, |
| 3080 | { 4*PT_R0, "4*PT_R0" }, |
| 3081 | { 4*PT_MOF, "4*PT_MOF" }, |
| 3082 | { 4*PT_DCCR, "4*PT_DCCR" }, |
| 3083 | { 4*PT_SRP, "4*PT_SRP" }, |
| 3084 | { 4*PT_IRP, "4*PT_IRP" }, |
| 3085 | { 4*PT_CSRINSTR, "4*PT_CSRINSTR" }, |
| 3086 | { 4*PT_CSRADDR, "4*PT_CSRADDR" }, |
| 3087 | { 4*PT_CSRDATA, "4*PT_CSRDATA" }, |
| 3088 | { 4*PT_USP, "4*PT_USP" }, |
| 3089 | # endif |
| 3090 | # ifdef CRISV32 |
| 3091 | { 4*PT_ORIG_R10, "4*PT_ORIG_R10" }, |
| 3092 | { 4*PT_R0, "4*PT_R0" }, |
| 3093 | { 4*PT_R1, "4*PT_R1" }, |
| 3094 | { 4*PT_R2, "4*PT_R2" }, |
| 3095 | { 4*PT_R3, "4*PT_R3" }, |
| 3096 | { 4*PT_R4, "4*PT_R4" }, |
| 3097 | { 4*PT_R5, "4*PT_R5" }, |
| 3098 | { 4*PT_R6, "4*PT_R6" }, |
| 3099 | { 4*PT_R7, "4*PT_R7" }, |
| 3100 | { 4*PT_R8, "4*PT_R8" }, |
| 3101 | { 4*PT_R9, "4*PT_R9" }, |
| 3102 | { 4*PT_R10, "4*PT_R10" }, |
| 3103 | { 4*PT_R11, "4*PT_R11" }, |
| 3104 | { 4*PT_R12, "4*PT_R12" }, |
| 3105 | { 4*PT_R13, "4*PT_R13" }, |
| 3106 | { 4*PT_ACR, "4*PT_ACR" }, |
| 3107 | { 4*PT_SRS, "4*PT_SRS" }, |
| 3108 | { 4*PT_MOF, "4*PT_MOF" }, |
| 3109 | { 4*PT_SPC, "4*PT_SPC" }, |
| 3110 | { 4*PT_CCS, "4*PT_CCS" }, |
| 3111 | { 4*PT_SRP, "4*PT_SRP" }, |
| 3112 | { 4*PT_ERP, "4*PT_ERP" }, |
| 3113 | { 4*PT_EXS, "4*PT_EXS" }, |
| 3114 | { 4*PT_EDA, "4*PT_EDA" }, |
| 3115 | { 4*PT_USP, "4*PT_USP" }, |
| 3116 | { 4*PT_PPC, "4*PT_PPC" }, |
| 3117 | { 4*PT_BP_CTRL, "4*PT_BP_CTRL" }, |
| 3118 | { 4*PT_BP+4, "4*PT_BP+4" }, |
| 3119 | { 4*PT_BP+8, "4*PT_BP+8" }, |
| 3120 | { 4*PT_BP+12, "4*PT_BP+12" }, |
| 3121 | { 4*PT_BP+16, "4*PT_BP+16" }, |
| 3122 | { 4*PT_BP+20, "4*PT_BP+20" }, |
| 3123 | { 4*PT_BP+24, "4*PT_BP+24" }, |
| 3124 | { 4*PT_BP+28, "4*PT_BP+28" }, |
| 3125 | { 4*PT_BP+32, "4*PT_BP+32" }, |
| 3126 | { 4*PT_BP+36, "4*PT_BP+36" }, |
| 3127 | { 4*PT_BP+40, "4*PT_BP+40" }, |
| 3128 | { 4*PT_BP+44, "4*PT_BP+44" }, |
| 3129 | { 4*PT_BP+48, "4*PT_BP+48" }, |
| 3130 | { 4*PT_BP+52, "4*PT_BP+52" }, |
| 3131 | { 4*PT_BP+56, "4*PT_BP+56" }, |
| 3132 | # endif |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 3133 | # ifdef MICROBLAZE |
| 3134 | { PT_GPR(0), "r0" }, |
| 3135 | { PT_GPR(1), "r1" }, |
| 3136 | { PT_GPR(2), "r2" }, |
| 3137 | { PT_GPR(3), "r3" }, |
| 3138 | { PT_GPR(4), "r4" }, |
| 3139 | { PT_GPR(5), "r5" }, |
| 3140 | { PT_GPR(6), "r6" }, |
| 3141 | { PT_GPR(7), "r7" }, |
| 3142 | { PT_GPR(8), "r8" }, |
| 3143 | { PT_GPR(9), "r9" }, |
| 3144 | { PT_GPR(10), "r10" }, |
| 3145 | { PT_GPR(11), "r11" }, |
| 3146 | { PT_GPR(12), "r12" }, |
| 3147 | { PT_GPR(13), "r13" }, |
| 3148 | { PT_GPR(14), "r14" }, |
| 3149 | { PT_GPR(15), "r15" }, |
| 3150 | { PT_GPR(16), "r16" }, |
| 3151 | { PT_GPR(17), "r17" }, |
| 3152 | { PT_GPR(18), "r18" }, |
| 3153 | { PT_GPR(19), "r19" }, |
| 3154 | { PT_GPR(20), "r20" }, |
| 3155 | { PT_GPR(21), "r21" }, |
| 3156 | { PT_GPR(22), "r22" }, |
| 3157 | { PT_GPR(23), "r23" }, |
| 3158 | { PT_GPR(24), "r24" }, |
| 3159 | { PT_GPR(25), "r25" }, |
| 3160 | { PT_GPR(26), "r26" }, |
| 3161 | { PT_GPR(27), "r27" }, |
| 3162 | { PT_GPR(28), "r28" }, |
| 3163 | { PT_GPR(29), "r29" }, |
| 3164 | { PT_GPR(30), "r30" }, |
| 3165 | { PT_GPR(31), "r31" }, |
| 3166 | { PT_PC, "rpc", }, |
| 3167 | { PT_MSR, "rmsr", }, |
| 3168 | { PT_EAR, "rear", }, |
| 3169 | { PT_ESR, "resr", }, |
| 3170 | { PT_FSR, "rfsr", }, |
| 3171 | { PT_KERNEL_MODE, "kernel_mode", }, |
| 3172 | # endif |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 3173 | |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 3174 | # if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \ |
| 3175 | && !defined(ALPHA) && !defined(IA64) \ |
Edgar E. Iglesias | 939caba | 2010-07-06 14:21:07 +0200 | [diff] [blame] | 3176 | && !defined(CRISV10) && !defined(CRISV32) && !defined(MICROBLAZE) |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 3177 | # 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] | 3178 | { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3179 | # endif |
| 3180 | # if defined(I386) || defined(X86_64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3181 | { uoff(i387), "offsetof(struct user, i387)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3182 | # endif |
| 3183 | # if defined(M68K) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3184 | { uoff(m68kfp), "offsetof(struct user, m68kfp)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3185 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3186 | { uoff(u_tsize), "offsetof(struct user, u_tsize)" }, |
| 3187 | { uoff(u_dsize), "offsetof(struct user, u_dsize)" }, |
| 3188 | { uoff(u_ssize), "offsetof(struct user, u_ssize)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3189 | # if !defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3190 | { uoff(start_code), "offsetof(struct user, start_code)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3191 | # endif |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 3192 | # if defined(AVR32) || defined(SH64) |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 3193 | { uoff(start_data), "offsetof(struct user, start_data)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3194 | # endif |
| 3195 | # if !defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3196 | { uoff(start_stack), "offsetof(struct user, start_stack)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3197 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3198 | { uoff(signal), "offsetof(struct user, signal)" }, |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 3199 | # 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] | 3200 | { uoff(reserved), "offsetof(struct user, reserved)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3201 | # endif |
| 3202 | # if !defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3203 | { uoff(u_ar0), "offsetof(struct user, u_ar0)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3204 | # endif |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 3205 | # 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] | 3206 | { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3207 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3208 | { uoff(magic), "offsetof(struct user, magic)" }, |
| 3209 | { uoff(u_comm), "offsetof(struct user, u_comm)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3210 | # if defined(I386) || defined(X86_64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3211 | { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3212 | # endif |
Denys Vlasenko | ea0e6e8 | 2009-02-25 17:08:40 +0000 | [diff] [blame] | 3213 | # endif /* !defined(many arches) */ |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3214 | |
| 3215 | # endif /* LINUX */ |
| 3216 | |
| 3217 | # ifdef SUNOS4 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3218 | { uoff(u_pcb), "offsetof(struct user, u_pcb)" }, |
| 3219 | { uoff(u_procp), "offsetof(struct user, u_procp)" }, |
| 3220 | { uoff(u_ar0), "offsetof(struct user, u_ar0)" }, |
| 3221 | { uoff(u_comm[0]), "offsetof(struct user, u_comm[0])" }, |
| 3222 | { uoff(u_arg[0]), "offsetof(struct user, u_arg[0])" }, |
| 3223 | { uoff(u_ap), "offsetof(struct user, u_ap)" }, |
| 3224 | { uoff(u_qsave), "offsetof(struct user, u_qsave)" }, |
| 3225 | { uoff(u_rval1), "offsetof(struct user, u_rval1)" }, |
| 3226 | { uoff(u_rval2), "offsetof(struct user, u_rval2)" }, |
| 3227 | { uoff(u_error), "offsetof(struct user, u_error)" }, |
| 3228 | { uoff(u_eosys), "offsetof(struct user, u_eosys)" }, |
| 3229 | { uoff(u_ssave), "offsetof(struct user, u_ssave)" }, |
| 3230 | { uoff(u_signal[0]), "offsetof(struct user, u_signal)" }, |
| 3231 | { uoff(u_sigmask[0]), "offsetof(struct user, u_sigmask)" }, |
| 3232 | { uoff(u_sigonstack), "offsetof(struct user, u_sigonstack)" }, |
| 3233 | { uoff(u_sigintr), "offsetof(struct user, u_sigintr)" }, |
| 3234 | { uoff(u_sigreset), "offsetof(struct user, u_sigreset)" }, |
| 3235 | { uoff(u_oldmask), "offsetof(struct user, u_oldmask)" }, |
| 3236 | { uoff(u_code), "offsetof(struct user, u_code)" }, |
| 3237 | { uoff(u_addr), "offsetof(struct user, u_addr)" }, |
| 3238 | { uoff(u_sigstack), "offsetof(struct user, u_sigstack)" }, |
| 3239 | { uoff(u_ofile), "offsetof(struct user, u_ofile)" }, |
| 3240 | { uoff(u_pofile), "offsetof(struct user, u_pofile)" }, |
| 3241 | { uoff(u_ofile_arr[0]), "offsetof(struct user, u_ofile_arr[0])" }, |
| 3242 | { uoff(u_pofile_arr[0]),"offsetof(struct user, u_pofile_arr[0])"}, |
| 3243 | { uoff(u_lastfile), "offsetof(struct user, u_lastfile)" }, |
| 3244 | { uoff(u_cwd), "offsetof(struct user, u_cwd)" }, |
| 3245 | { uoff(u_cdir), "offsetof(struct user, u_cdir)" }, |
| 3246 | { uoff(u_rdir), "offsetof(struct user, u_rdir)" }, |
| 3247 | { uoff(u_cmask), "offsetof(struct user, u_cmask)" }, |
| 3248 | { uoff(u_ru), "offsetof(struct user, u_ru)" }, |
| 3249 | { uoff(u_cru), "offsetof(struct user, u_cru)" }, |
| 3250 | { uoff(u_timer[0]), "offsetof(struct user, u_timer[0])" }, |
| 3251 | { uoff(u_XXX[0]), "offsetof(struct user, u_XXX[0])" }, |
| 3252 | { uoff(u_ioch), "offsetof(struct user, u_ioch)" }, |
| 3253 | { uoff(u_start), "offsetof(struct user, u_start)" }, |
| 3254 | { uoff(u_acflag), "offsetof(struct user, u_acflag)" }, |
| 3255 | { uoff(u_prof.pr_base), "offsetof(struct user, u_prof.pr_base)" }, |
| 3256 | { uoff(u_prof.pr_size), "offsetof(struct user, u_prof.pr_size)" }, |
| 3257 | { uoff(u_prof.pr_off), "offsetof(struct user, u_prof.pr_off)" }, |
| 3258 | { uoff(u_prof.pr_scale),"offsetof(struct user, u_prof.pr_scale)"}, |
| 3259 | { uoff(u_rlimit[0]), "offsetof(struct user, u_rlimit)" }, |
| 3260 | { uoff(u_exdata.Ux_A), "offsetof(struct user, u_exdata.Ux_A)" }, |
| 3261 | { uoff(u_exdata.ux_shell[0]),"offsetof(struct user, u_exdata.ux_shell[0])"}, |
| 3262 | { uoff(u_lofault), "offsetof(struct user, u_lofault)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3263 | # endif /* SUNOS4 */ |
| 3264 | # ifndef HPPA |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3265 | { sizeof(struct user), "sizeof(struct user)" }, |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3266 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3267 | { 0, NULL }, |
| 3268 | }; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3269 | # endif /* !FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3270 | |
| 3271 | int |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3272 | sys_ptrace(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3273 | { |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 3274 | const struct xlat *x; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3275 | long addr; |
| 3276 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3277 | if (entering(tcp)) { |
Roland McGrath | bf621d4 | 2003-01-14 09:46:21 +0000 | [diff] [blame] | 3278 | printxval(ptrace_cmds, tcp->u_arg[0], |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3279 | # ifndef FREEBSD |
Roland McGrath | bf621d4 | 2003-01-14 09:46:21 +0000 | [diff] [blame] | 3280 | "PTRACE_???" |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3281 | # else |
Roland McGrath | bf621d4 | 2003-01-14 09:46:21 +0000 | [diff] [blame] | 3282 | "PT_???" |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3283 | # endif |
Roland McGrath | bf621d4 | 2003-01-14 09:46:21 +0000 | [diff] [blame] | 3284 | ); |
| 3285 | tprintf(", %lu, ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3286 | addr = tcp->u_arg[2]; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3287 | # ifndef FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3288 | if (tcp->u_arg[0] == PTRACE_PEEKUSER |
| 3289 | || tcp->u_arg[0] == PTRACE_POKEUSER) { |
| 3290 | for (x = struct_user_offsets; x->str; x++) { |
| 3291 | if (x->val >= addr) |
| 3292 | break; |
| 3293 | } |
| 3294 | if (!x->str) |
| 3295 | tprintf("%#lx, ", addr); |
| 3296 | else if (x->val > addr && x != struct_user_offsets) { |
| 3297 | x--; |
| 3298 | tprintf("%s + %ld, ", x->str, addr - x->val); |
| 3299 | } |
| 3300 | else |
| 3301 | tprintf("%s, ", x->str); |
| 3302 | } |
| 3303 | else |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3304 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3305 | tprintf("%#lx, ", tcp->u_arg[2]); |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3306 | # ifdef LINUX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3307 | switch (tcp->u_arg[0]) { |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3308 | # ifndef IA64 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3309 | case PTRACE_PEEKDATA: |
| 3310 | case PTRACE_PEEKTEXT: |
| 3311 | case PTRACE_PEEKUSER: |
| 3312 | break; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3313 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3314 | case PTRACE_CONT: |
| 3315 | case PTRACE_SINGLESTEP: |
| 3316 | case PTRACE_SYSCALL: |
| 3317 | case PTRACE_DETACH: |
| 3318 | printsignal(tcp->u_arg[3]); |
| 3319 | break; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3320 | # ifdef PTRACE_SETOPTIONS |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 3321 | case PTRACE_SETOPTIONS: |
| 3322 | printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???"); |
| 3323 | break; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3324 | # endif |
| 3325 | # ifdef PTRACE_SETSIGINFO |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 3326 | case PTRACE_SETSIGINFO: { |
| 3327 | siginfo_t si; |
| 3328 | if (!tcp->u_arg[3]) |
| 3329 | tprintf("NULL"); |
| 3330 | else if (syserror(tcp)) |
| 3331 | tprintf("%#lx", tcp->u_arg[3]); |
| 3332 | else if (umove(tcp, tcp->u_arg[3], &si) < 0) |
| 3333 | tprintf("{???}"); |
| 3334 | else |
| 3335 | printsiginfo(&si, verbose(tcp)); |
| 3336 | break; |
| 3337 | } |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3338 | # endif |
| 3339 | # ifdef PTRACE_GETSIGINFO |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 3340 | case PTRACE_GETSIGINFO: |
| 3341 | /* Don't print anything, do it at syscall return. */ |
| 3342 | break; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3343 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3344 | default: |
| 3345 | tprintf("%#lx", tcp->u_arg[3]); |
| 3346 | break; |
| 3347 | } |
| 3348 | } else { |
| 3349 | switch (tcp->u_arg[0]) { |
| 3350 | case PTRACE_PEEKDATA: |
| 3351 | case PTRACE_PEEKTEXT: |
| 3352 | case PTRACE_PEEKUSER: |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3353 | # ifdef IA64 |
Roland McGrath | 1e86806 | 2007-11-19 22:11:45 +0000 | [diff] [blame] | 3354 | return RVAL_HEX; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3355 | # else |
Roland McGrath | eb28535 | 2003-01-14 09:59:00 +0000 | [diff] [blame] | 3356 | printnum(tcp, tcp->u_arg[3], "%#lx"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3357 | break; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3358 | # endif |
| 3359 | # ifdef PTRACE_GETSIGINFO |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 3360 | case PTRACE_GETSIGINFO: { |
| 3361 | siginfo_t si; |
| 3362 | if (!tcp->u_arg[3]) |
| 3363 | tprintf("NULL"); |
| 3364 | else if (syserror(tcp)) |
| 3365 | tprintf("%#lx", tcp->u_arg[3]); |
| 3366 | else if (umove(tcp, tcp->u_arg[3], &si) < 0) |
| 3367 | tprintf("{???}"); |
| 3368 | else |
| 3369 | printsiginfo(&si, verbose(tcp)); |
| 3370 | break; |
| 3371 | } |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3372 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3373 | } |
| 3374 | } |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3375 | # endif /* LINUX */ |
| 3376 | # ifdef SUNOS4 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3377 | if (tcp->u_arg[0] == PTRACE_WRITEDATA || |
| 3378 | tcp->u_arg[0] == PTRACE_WRITETEXT) { |
| 3379 | tprintf("%lu, ", tcp->u_arg[3]); |
| 3380 | printstr(tcp, tcp->u_arg[4], tcp->u_arg[3]); |
| 3381 | } else if (tcp->u_arg[0] != PTRACE_READDATA && |
| 3382 | tcp->u_arg[0] != PTRACE_READTEXT) { |
| 3383 | tprintf("%#lx", tcp->u_arg[3]); |
| 3384 | } |
| 3385 | } else { |
| 3386 | if (tcp->u_arg[0] == PTRACE_READDATA || |
| 3387 | tcp->u_arg[0] == PTRACE_READTEXT) { |
| 3388 | tprintf("%lu, ", tcp->u_arg[3]); |
| 3389 | printstr(tcp, tcp->u_arg[4], tcp->u_arg[3]); |
| 3390 | } |
| 3391 | } |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3392 | # endif /* SUNOS4 */ |
| 3393 | # ifdef FREEBSD |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 3394 | tprintf("%lu", tcp->u_arg[3]); |
| 3395 | } |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3396 | # endif /* FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 3397 | return 0; |
| 3398 | } |
| 3399 | |
| 3400 | #endif /* !SVR4 */ |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 3401 | |
| 3402 | #ifdef LINUX |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 3403 | # ifndef FUTEX_CMP_REQUEUE |
| 3404 | # define FUTEX_CMP_REQUEUE 4 |
| 3405 | # endif |
| 3406 | # ifndef FUTEX_WAKE_OP |
| 3407 | # define FUTEX_WAKE_OP 5 |
| 3408 | # endif |
| 3409 | # ifndef FUTEX_LOCK_PI |
| 3410 | # define FUTEX_LOCK_PI 6 |
| 3411 | # define FUTEX_UNLOCK_PI 7 |
| 3412 | # define FUTEX_TRYLOCK_PI 8 |
| 3413 | # endif |
Roland McGrath | 1aeaf74 | 2008-07-18 01:27:39 +0000 | [diff] [blame] | 3414 | # ifndef FUTEX_WAIT_BITSET |
| 3415 | # define FUTEX_WAIT_BITSET 9 |
| 3416 | # endif |
| 3417 | # ifndef FUTEX_WAKE_BITSET |
| 3418 | # define FUTEX_WAKE_BITSET 10 |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 3419 | # endif |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 3420 | # ifndef FUTEX_WAIT_REQUEUE_PI |
| 3421 | # define FUTEX_WAIT_REQUEUE_PI 11 |
| 3422 | # endif |
| 3423 | # ifndef FUTEX_CMP_REQUEUE_PI |
| 3424 | # define FUTEX_CMP_REQUEUE_PI 12 |
| 3425 | # endif |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 3426 | # ifndef FUTEX_PRIVATE_FLAG |
| 3427 | # define FUTEX_PRIVATE_FLAG 128 |
| 3428 | # endif |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 3429 | # ifndef FUTEX_CLOCK_REALTIME |
| 3430 | # define FUTEX_CLOCK_REALTIME 256 |
| 3431 | # endif |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 3432 | static const struct xlat futexops[] = { |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 3433 | { FUTEX_WAIT, "FUTEX_WAIT" }, |
| 3434 | { FUTEX_WAKE, "FUTEX_WAKE" }, |
| 3435 | { FUTEX_FD, "FUTEX_FD" }, |
| 3436 | { FUTEX_REQUEUE, "FUTEX_REQUEUE" }, |
| 3437 | { FUTEX_CMP_REQUEUE, "FUTEX_CMP_REQUEUE" }, |
| 3438 | { FUTEX_WAKE_OP, "FUTEX_WAKE_OP" }, |
| 3439 | { FUTEX_LOCK_PI, "FUTEX_LOCK_PI" }, |
| 3440 | { FUTEX_UNLOCK_PI, "FUTEX_UNLOCK_PI" }, |
| 3441 | { FUTEX_TRYLOCK_PI, "FUTEX_TRYLOCK_PI" }, |
Roland McGrath | 1aeaf74 | 2008-07-18 01:27:39 +0000 | [diff] [blame] | 3442 | { FUTEX_WAIT_BITSET, "FUTEX_WAIT_BITSET" }, |
| 3443 | { FUTEX_WAKE_BITSET, "FUTEX_WAKE_BITSET" }, |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 3444 | { FUTEX_WAIT_REQUEUE_PI, "FUTEX_WAIT_REQUEUE_PI" }, |
| 3445 | { FUTEX_CMP_REQUEUE_PI, "FUTEX_CMP_REQUEUE_PI" }, |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 3446 | { FUTEX_WAIT|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_PRIVATE" }, |
| 3447 | { FUTEX_WAKE|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_PRIVATE" }, |
| 3448 | { FUTEX_FD|FUTEX_PRIVATE_FLAG, "FUTEX_FD_PRIVATE" }, |
| 3449 | { FUTEX_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_REQUEUE_PRIVATE" }, |
| 3450 | { FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PRIVATE" }, |
| 3451 | { FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_OP_PRIVATE" }, |
| 3452 | { FUTEX_LOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_LOCK_PI_PRIVATE" }, |
| 3453 | { FUTEX_UNLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_UNLOCK_PI_PRIVATE" }, |
| 3454 | { FUTEX_TRYLOCK_PI|FUTEX_PRIVATE_FLAG, "FUTEX_TRYLOCK_PI_PRIVATE" }, |
Roland McGrath | 1aeaf74 | 2008-07-18 01:27:39 +0000 | [diff] [blame] | 3455 | { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_BITSET_PRIVATE" }, |
| 3456 | { FUTEX_WAKE_BITSET|FUTEX_PRIVATE_FLAG, "FUTEX_WAKE_BITSET_PRIVATE" }, |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 3457 | { FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_WAIT_REQUEUE_PI_PRIVATE" }, |
| 3458 | { FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG, "FUTEX_CMP_REQUEUE_PI_PRIVATE" }, |
| 3459 | { FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME" }, |
| 3460 | { FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME" }, |
| 3461 | { FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME, "FUTEX_WAIT_REQUEUE_PI|FUTEX_CLOCK_REALTIME" }, |
| 3462 | { 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] | 3463 | { 0, NULL } |
| 3464 | }; |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3465 | # ifndef FUTEX_OP_SET |
| 3466 | # define FUTEX_OP_SET 0 |
| 3467 | # define FUTEX_OP_ADD 1 |
| 3468 | # define FUTEX_OP_OR 2 |
| 3469 | # define FUTEX_OP_ANDN 3 |
| 3470 | # define FUTEX_OP_XOR 4 |
| 3471 | # define FUTEX_OP_CMP_EQ 0 |
| 3472 | # define FUTEX_OP_CMP_NE 1 |
| 3473 | # define FUTEX_OP_CMP_LT 2 |
| 3474 | # define FUTEX_OP_CMP_LE 3 |
| 3475 | # define FUTEX_OP_CMP_GT 4 |
| 3476 | # define FUTEX_OP_CMP_GE 5 |
| 3477 | # endif |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 3478 | static const struct xlat futexwakeops[] = { |
| 3479 | { FUTEX_OP_SET, "FUTEX_OP_SET" }, |
| 3480 | { FUTEX_OP_ADD, "FUTEX_OP_ADD" }, |
| 3481 | { FUTEX_OP_OR, "FUTEX_OP_OR" }, |
| 3482 | { FUTEX_OP_ANDN, "FUTEX_OP_ANDN" }, |
| 3483 | { FUTEX_OP_XOR, "FUTEX_OP_XOR" }, |
| 3484 | { 0, NULL } |
| 3485 | }; |
| 3486 | static const struct xlat futexwakecmps[] = { |
| 3487 | { FUTEX_OP_CMP_EQ, "FUTEX_OP_CMP_EQ" }, |
| 3488 | { FUTEX_OP_CMP_NE, "FUTEX_OP_CMP_NE" }, |
| 3489 | { FUTEX_OP_CMP_LT, "FUTEX_OP_CMP_LT" }, |
| 3490 | { FUTEX_OP_CMP_LE, "FUTEX_OP_CMP_LE" }, |
| 3491 | { FUTEX_OP_CMP_GT, "FUTEX_OP_CMP_GT" }, |
| 3492 | { FUTEX_OP_CMP_GE, "FUTEX_OP_CMP_GE" }, |
| 3493 | { 0, NULL } |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 3494 | }; |
| 3495 | |
| 3496 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3497 | sys_futex(struct tcb *tcp) |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 3498 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3499 | if (entering(tcp)) { |
| 3500 | long int cmd = tcp->u_arg[1] & 127; |
| 3501 | tprintf("%p, ", (void *) tcp->u_arg[0]); |
| 3502 | printxval(futexops, tcp->u_arg[1], "FUTEX_???"); |
| 3503 | tprintf(", %ld", tcp->u_arg[2]); |
| 3504 | if (cmd == FUTEX_WAKE_BITSET) |
| 3505 | tprintf(", %lx", tcp->u_arg[5]); |
| 3506 | else if (cmd == FUTEX_WAIT) { |
| 3507 | tprintf(", "); |
| 3508 | printtv(tcp, tcp->u_arg[3]); |
| 3509 | } else if (cmd == FUTEX_WAIT_BITSET) { |
| 3510 | tprintf(", "); |
| 3511 | printtv(tcp, tcp->u_arg[3]); |
| 3512 | tprintf(", %lx", tcp->u_arg[5]); |
| 3513 | } else if (cmd == FUTEX_REQUEUE) |
| 3514 | tprintf(", %ld, %p", tcp->u_arg[3], (void *) tcp->u_arg[4]); |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 3515 | else if (cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI) |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3516 | tprintf(", %ld, %p, %ld", tcp->u_arg[3], (void *) tcp->u_arg[4], tcp->u_arg[5]); |
| 3517 | else if (cmd == FUTEX_WAKE_OP) { |
| 3518 | tprintf(", %ld, %p, {", tcp->u_arg[3], (void *) tcp->u_arg[4]); |
| 3519 | if ((tcp->u_arg[5] >> 28) & 8) |
| 3520 | tprintf("FUTEX_OP_OPARG_SHIFT|"); |
| 3521 | printxval(futexwakeops, (tcp->u_arg[5] >> 28) & 0x7, "FUTEX_OP_???"); |
| 3522 | tprintf(", %ld, ", (tcp->u_arg[5] >> 12) & 0xfff); |
| 3523 | if ((tcp->u_arg[5] >> 24) & 8) |
| 3524 | tprintf("FUTEX_OP_OPARG_SHIFT|"); |
| 3525 | printxval(futexwakecmps, (tcp->u_arg[5] >> 24) & 0x7, "FUTEX_OP_CMP_???"); |
| 3526 | tprintf(", %ld}", tcp->u_arg[5] & 0xfff); |
Andreas Schwab | 85f5832 | 2009-08-12 09:54:42 +0200 | [diff] [blame] | 3527 | } else if (cmd == FUTEX_WAIT_REQUEUE_PI) { |
| 3528 | tprintf(", "); |
| 3529 | printtv(tcp, tcp->u_arg[3]); |
| 3530 | tprintf(", %p", (void *) tcp->u_arg[4]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3531 | } |
Roland McGrath | 51942a9 | 2007-07-05 18:59:11 +0000 | [diff] [blame] | 3532 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3533 | return 0; |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 3534 | } |
| 3535 | |
| 3536 | static void |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3537 | print_affinitylist(struct tcb *tcp, long list, unsigned int len) |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 3538 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3539 | int first = 1; |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 3540 | unsigned long w, min_len; |
| 3541 | |
| 3542 | if (abbrev(tcp) && len / sizeof(w) > max_strlen) |
| 3543 | min_len = len - max_strlen * sizeof(w); |
| 3544 | else |
| 3545 | min_len = 0; |
| 3546 | for (; len >= sizeof(w) && len > min_len; |
| 3547 | len -= sizeof(w), list += sizeof(w)) { |
| 3548 | if (umove(tcp, list, &w) < 0) |
| 3549 | break; |
| 3550 | if (first) |
| 3551 | tprintf("{"); |
| 3552 | else |
| 3553 | tprintf(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3554 | first = 0; |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 3555 | tprintf("%lx", w); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3556 | } |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 3557 | if (len) { |
| 3558 | if (first) |
| 3559 | tprintf("%#lx", list); |
| 3560 | else |
| 3561 | tprintf(", %s}", (len >= sizeof(w) && len > min_len ? |
| 3562 | "???" : "...")); |
| 3563 | } else { |
| 3564 | tprintf(first ? "{}" : "}"); |
| 3565 | } |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 3566 | } |
| 3567 | |
| 3568 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3569 | sys_sched_setaffinity(struct tcb *tcp) |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 3570 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3571 | if (entering(tcp)) { |
| 3572 | tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 3573 | print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]); |
| 3574 | } |
| 3575 | return 0; |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 3576 | } |
| 3577 | |
| 3578 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3579 | sys_sched_getaffinity(struct tcb *tcp) |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 3580 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3581 | if (entering(tcp)) { |
| 3582 | tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 3583 | } else { |
| 3584 | if (tcp->u_rval == -1) |
| 3585 | tprintf("%#lx", tcp->u_arg[2]); |
| 3586 | else |
| 3587 | print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval); |
| 3588 | } |
| 3589 | return 0; |
Roland McGrath | 5a22347 | 2002-12-15 23:58:26 +0000 | [diff] [blame] | 3590 | } |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3591 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 3592 | static const struct xlat schedulers[] = { |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3593 | { SCHED_OTHER, "SCHED_OTHER" }, |
| 3594 | { SCHED_RR, "SCHED_RR" }, |
| 3595 | { SCHED_FIFO, "SCHED_FIFO" }, |
| 3596 | { 0, NULL } |
| 3597 | }; |
| 3598 | |
| 3599 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3600 | sys_sched_getscheduler(struct tcb *tcp) |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3601 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3602 | if (entering(tcp)) { |
| 3603 | tprintf("%d", (int) tcp->u_arg[0]); |
| 3604 | } else if (! syserror(tcp)) { |
| 3605 | tcp->auxstr = xlookup (schedulers, tcp->u_rval); |
| 3606 | if (tcp->auxstr != NULL) |
| 3607 | return RVAL_STR; |
| 3608 | } |
| 3609 | return 0; |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3610 | } |
| 3611 | |
| 3612 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3613 | sys_sched_setscheduler(struct tcb *tcp) |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3614 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3615 | if (entering(tcp)) { |
| 3616 | struct sched_param p; |
| 3617 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 3618 | printxval(schedulers, tcp->u_arg[1], "SCHED_???"); |
| 3619 | if (umove(tcp, tcp->u_arg[2], &p) < 0) |
| 3620 | tprintf(", %#lx", tcp->u_arg[2]); |
| 3621 | else |
| 3622 | tprintf(", { %d }", p.__sched_priority); |
| 3623 | } |
| 3624 | return 0; |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3625 | } |
| 3626 | |
| 3627 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3628 | sys_sched_getparam(struct tcb *tcp) |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3629 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3630 | if (entering(tcp)) { |
| 3631 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 3632 | } else { |
| 3633 | struct sched_param p; |
| 3634 | if (umove(tcp, tcp->u_arg[1], &p) < 0) |
| 3635 | tprintf("%#lx", tcp->u_arg[1]); |
| 3636 | else |
| 3637 | tprintf("{ %d }", p.__sched_priority); |
| 3638 | } |
| 3639 | return 0; |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3640 | } |
| 3641 | |
| 3642 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3643 | sys_sched_setparam(struct tcb *tcp) |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3644 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3645 | if (entering(tcp)) { |
| 3646 | struct sched_param p; |
| 3647 | if (umove(tcp, tcp->u_arg[1], &p) < 0) |
| 3648 | tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]); |
| 3649 | else |
| 3650 | tprintf("%d, { %d }", (int) tcp->u_arg[0], p.__sched_priority); |
| 3651 | } |
| 3652 | return 0; |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3653 | } |
| 3654 | |
| 3655 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3656 | sys_sched_get_priority_min(struct tcb *tcp) |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3657 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3658 | if (entering(tcp)) { |
| 3659 | printxval(schedulers, tcp->u_arg[0], "SCHED_???"); |
| 3660 | } |
| 3661 | return 0; |
Roland McGrath | 279d378 | 2004-03-01 20:27:37 +0000 | [diff] [blame] | 3662 | } |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 3663 | |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3664 | # ifdef X86_64 |
| 3665 | # include <asm/prctl.h> |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 3666 | |
| 3667 | static const struct xlat archvals[] = { |
| 3668 | { ARCH_SET_GS, "ARCH_SET_GS" }, |
| 3669 | { ARCH_SET_FS, "ARCH_SET_FS" }, |
| 3670 | { ARCH_GET_FS, "ARCH_GET_FS" }, |
| 3671 | { ARCH_GET_GS, "ARCH_GET_GS" }, |
| 3672 | { 0, NULL }, |
| 3673 | }; |
| 3674 | |
| 3675 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3676 | sys_arch_prctl(struct tcb *tcp) |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 3677 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3678 | if (entering(tcp)) { |
| 3679 | printxval(archvals, tcp->u_arg[0], "ARCH_???"); |
| 3680 | if (tcp->u_arg[0] == ARCH_SET_GS |
| 3681 | || tcp->u_arg[0] == ARCH_SET_FS |
| 3682 | ) { |
| 3683 | tprintf(", %#lx", tcp->u_arg[1]); |
| 3684 | } |
| 3685 | } else { |
| 3686 | if (tcp->u_arg[0] == ARCH_GET_GS |
| 3687 | || tcp->u_arg[0] == ARCH_GET_FS |
| 3688 | ) { |
| 3689 | long int v; |
| 3690 | if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1) |
| 3691 | tprintf(", [%#lx]", v); |
| 3692 | else |
| 3693 | tprintf(", %#lx", tcp->u_arg[1]); |
| 3694 | } |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 3695 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3696 | return 0; |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 3697 | } |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3698 | # endif /* X86_64 */ |
Roland McGrath | c2d5eb0 | 2005-02-02 04:16:56 +0000 | [diff] [blame] | 3699 | |
Roland McGrath | db8319f | 2007-08-02 01:37:55 +0000 | [diff] [blame] | 3700 | |
| 3701 | int |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 3702 | sys_getcpu(struct tcb *tcp) |
Roland McGrath | db8319f | 2007-08-02 01:37:55 +0000 | [diff] [blame] | 3703 | { |
| 3704 | if (exiting(tcp)) { |
| 3705 | unsigned u; |
| 3706 | if (tcp->u_arg[0] == 0) |
| 3707 | tprintf("NULL, "); |
| 3708 | else if (umove(tcp, tcp->u_arg[0], &u) < 0) |
| 3709 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 3710 | else |
| 3711 | tprintf("[%u], ", u); |
| 3712 | if (tcp->u_arg[1] == 0) |
| 3713 | tprintf("NULL, "); |
| 3714 | else if (umove(tcp, tcp->u_arg[1], &u) < 0) |
| 3715 | tprintf("%#lx, ", tcp->u_arg[1]); |
| 3716 | else |
| 3717 | tprintf("[%u], ", u); |
| 3718 | tprintf("%#lx", tcp->u_arg[2]); |
| 3719 | } |
| 3720 | return 0; |
| 3721 | } |
| 3722 | |
Denys Vlasenko | c7e8371 | 2009-02-24 12:59:47 +0000 | [diff] [blame] | 3723 | #endif /* LINUX */ |