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 | 00a82ee | 2001-03-28 20:29:17 +0000 | [diff] [blame] | 59 | #if HAVE_ASM_REG_H |
| 60 | #ifdef SPARC |
| 61 | # define fpq kernel_fpq |
| 62 | # define fq kernel_fq |
| 63 | # define fpu kernel_fpu |
| 64 | #endif |
| 65 | #include <asm/reg.h> |
| 66 | #ifdef SPARC |
| 67 | # undef fpq |
| 68 | # undef fq |
| 69 | # undef fpu |
| 70 | #endif |
| 71 | #endif /* HAVE_ASM_REG_H */ |
| 72 | |
Wichert Akkerman | 36915a1 | 1999-07-13 15:45:02 +0000 | [diff] [blame] | 73 | #ifdef HAVE_SYS_REG_H |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 74 | # include <sys/reg.h> |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 75 | #ifndef PTRACE_PEEKUSR |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 76 | # define PTRACE_PEEKUSR PTRACE_PEEKUSER |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 77 | #endif |
| 78 | #ifndef PTRACE_POKEUSR |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 79 | # define PTRACE_POKEUSR PTRACE_POKEUSER |
| 80 | #endif |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 81 | #elif defined(HAVE_LINUX_PTRACE_H) |
| 82 | #undef PTRACE_SYSCALL |
| 83 | #include <linux/ptrace.h> |
Wichert Akkerman | 15dea97 | 1999-10-06 13:06:34 +0000 | [diff] [blame] | 84 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 85 | |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 86 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 87 | #ifdef LINUX |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 88 | #include <asm/posix_types.h> |
| 89 | #undef GETGROUPS_T |
| 90 | #define GETGROUPS_T __kernel_gid_t |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 91 | #endif /* LINUX */ |
| 92 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 93 | #if defined(LINUX) && defined(IA64) |
| 94 | # include <asm/ptrace_offsets.h> |
| 95 | # include <asm/rse.h> |
| 96 | #endif |
| 97 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 98 | #ifdef HAVE_PRCTL |
| 99 | #include <sys/prctl.h> |
| 100 | #endif |
| 101 | |
| 102 | #ifndef WCOREDUMP |
| 103 | #define WCOREDUMP(status) ((status) & 0200) |
| 104 | #endif |
| 105 | |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 106 | /* WTA: this was `&& !defined(LINUXSPARC)', this seems unneeded though? */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 107 | #if defined(HAVE_PRCTL) |
| 108 | static struct xlat prctl_options[] = { |
| 109 | #ifdef PR_MAXPROCS |
| 110 | { PR_MAXPROCS, "PR_MAXPROCS" }, |
| 111 | #endif |
| 112 | #ifdef PR_ISBLOCKED |
| 113 | { PR_ISBLOCKED, "PR_ISBLOCKED" }, |
| 114 | #endif |
| 115 | #ifdef PR_SETSTACKSIZE |
| 116 | { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" }, |
| 117 | #endif |
| 118 | #ifdef PR_GETSTACKSIZE |
| 119 | { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" }, |
| 120 | #endif |
| 121 | #ifdef PR_MAXPPROCS |
| 122 | { PR_MAXPPROCS, "PR_MAXPPROCS" }, |
| 123 | #endif |
| 124 | #ifdef PR_UNBLKONEXEC |
| 125 | { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" }, |
| 126 | #endif |
| 127 | #ifdef PR_ATOMICSIM |
| 128 | { PR_ATOMICSIM, "PR_ATOMICSIM" }, |
| 129 | #endif |
| 130 | #ifdef PR_SETEXITSIG |
| 131 | { PR_SETEXITSIG, "PR_SETEXITSIG" }, |
| 132 | #endif |
| 133 | #ifdef PR_RESIDENT |
| 134 | { PR_RESIDENT, "PR_RESIDENT" }, |
| 135 | #endif |
| 136 | #ifdef PR_ATTACHADDR |
| 137 | { PR_ATTACHADDR, "PR_ATTACHADDR" }, |
| 138 | #endif |
| 139 | #ifdef PR_DETACHADDR |
| 140 | { PR_DETACHADDR, "PR_DETACHADDR" }, |
| 141 | #endif |
| 142 | #ifdef PR_TERMCHILD |
| 143 | { PR_TERMCHILD, "PR_TERMCHILD" }, |
| 144 | #endif |
| 145 | #ifdef PR_GETSHMASK |
| 146 | { PR_GETSHMASK, "PR_GETSHMASK" }, |
| 147 | #endif |
| 148 | #ifdef PR_GETNSHARE |
| 149 | { PR_GETNSHARE, "PR_GETNSHARE" }, |
| 150 | #endif |
| 151 | #if defined(PR_SET_PDEATHSIG) |
| 152 | { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" }, |
| 153 | #endif |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 154 | #ifdef PR_COREPID |
| 155 | { PR_COREPID, "PR_COREPID" }, |
| 156 | #endif |
| 157 | #ifdef PR_ATTACHADDRPERM |
| 158 | { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" }, |
| 159 | #endif |
| 160 | #ifdef PR_PTHREADEXIT |
| 161 | { PR_PTHREADEXIT, "PR_PTHREADEXIT" }, |
| 162 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 163 | #ifdef PR_SET_PDEATHSIG |
| 164 | { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" }, |
| 165 | #endif |
| 166 | #ifdef PR_GET_PDEATHSIG |
| 167 | { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" }, |
| 168 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 169 | #ifdef PR_GET_UNALIGN |
| 170 | { PR_GET_UNALIGN, "PR_GET_UNALIGN" }, |
| 171 | #endif |
| 172 | #ifdef PR_SET_UNALIGN |
| 173 | { PR_SET_UNALIGN, "PR_SET_UNALIGN" }, |
| 174 | #endif |
| 175 | #ifdef PR_GET_KEEPCAPS |
| 176 | { PR_GET_KEEPCAPS, "PR_GET_KEEP_CAPS" }, |
| 177 | #endif |
| 178 | #ifdef PR_SET_KEEPCAPS |
| 179 | { PR_SET_KEEPCAPS, "PR_SET_KEEP_CAPS" }, |
| 180 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 181 | { 0, NULL }, |
| 182 | }; |
| 183 | |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 184 | |
| 185 | const char * |
| 186 | unalignctl_string (unsigned int ctl) |
| 187 | { |
| 188 | static char buf[16]; |
| 189 | |
| 190 | switch (ctl) { |
| 191 | #ifdef PR_UNALIGN_NOPRINT |
| 192 | case PR_UNALIGN_NOPRINT: |
| 193 | return "NOPRINT"; |
| 194 | #endif |
| 195 | #ifdef PR_UNALIGN_SIGBUS |
| 196 | case PR_UNALIGN_SIGBUS: |
| 197 | return "SIGBUS"; |
| 198 | #endif |
| 199 | default: |
| 200 | break; |
| 201 | } |
| 202 | sprintf(buf, "%x", ctl); |
| 203 | return buf; |
| 204 | } |
| 205 | |
| 206 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 207 | int |
| 208 | sys_prctl(tcp) |
| 209 | struct tcb *tcp; |
| 210 | { |
| 211 | int i; |
| 212 | |
| 213 | if (entering(tcp)) { |
| 214 | printxval(prctl_options, tcp->u_arg[0], "PR_???"); |
| 215 | switch (tcp->u_arg[0]) { |
| 216 | #ifdef PR_GETNSHARE |
| 217 | case PR_GETNSHARE: |
| 218 | break; |
| 219 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 220 | #ifdef PR_SET_DEATHSIG |
| 221 | case PR_GET_PDEATHSIG: |
| 222 | break; |
| 223 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 224 | #ifdef PR_SET_UNALIGN |
| 225 | case PR_SET_UNALIGN: |
| 226 | tprintf(", %s", unalignctl_string(tcp->u_arg[1])); |
| 227 | break; |
| 228 | #endif |
| 229 | #ifdef PR_GET_UNALIGN |
| 230 | case PR_GET_UNALIGN: |
| 231 | tprintf(", %#lx", tcp->u_arg[1]); |
| 232 | break; |
| 233 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 234 | default: |
| 235 | for (i = 1; i < tcp->u_nargs; i++) |
| 236 | tprintf(", %#lx", tcp->u_arg[i]); |
| 237 | break; |
| 238 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 239 | } else { |
| 240 | switch (tcp->u_arg[0]) { |
| 241 | #ifdef PR_GET_PDEATHSIG |
| 242 | case PR_GET_PDEATHSIG: |
| 243 | for (i=1; i<tcp->u_nargs; i++) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 244 | tprintf(", %#lx", tcp->u_arg[i]); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 245 | break; |
| 246 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 247 | #ifdef PR_SET_UNALIGN |
| 248 | case PR_SET_UNALIGN: |
| 249 | break; |
| 250 | #endif |
| 251 | #ifdef PR_GET_UNALIGN |
| 252 | case PR_GET_UNALIGN: |
| 253 | { |
| 254 | int ctl; |
| 255 | |
| 256 | umove(tcp, tcp->u_arg[1], &ctl); |
| 257 | tcp->auxstr = unalignctl_string(ctl); |
| 258 | return RVAL_STR; |
| 259 | } |
| 260 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 261 | default: |
| 262 | break; |
| 263 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 264 | } |
| 265 | return 0; |
| 266 | } |
| 267 | |
| 268 | #endif /* HAVE_PRCTL */ |
| 269 | |
| 270 | int |
| 271 | sys_gethostid(tcp) |
| 272 | struct tcb *tcp; |
| 273 | { |
| 274 | if (exiting(tcp)) |
| 275 | return RVAL_HEX; |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | int |
| 280 | sys_sethostname(tcp) |
| 281 | struct tcb *tcp; |
| 282 | { |
| 283 | if (entering(tcp)) { |
| 284 | printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]); |
| 285 | tprintf(", %lu", tcp->u_arg[1]); |
| 286 | } |
| 287 | return 0; |
| 288 | } |
| 289 | |
| 290 | int |
| 291 | sys_gethostname(tcp) |
| 292 | struct tcb *tcp; |
| 293 | { |
| 294 | if (exiting(tcp)) { |
| 295 | if (syserror(tcp)) |
| 296 | tprintf("%#lx", tcp->u_arg[0]); |
| 297 | else |
| 298 | printpath(tcp, tcp->u_arg[0]); |
| 299 | tprintf(", %lu", tcp->u_arg[1]); |
| 300 | } |
| 301 | return 0; |
| 302 | } |
| 303 | |
| 304 | int |
| 305 | sys_setdomainname(tcp) |
| 306 | struct tcb *tcp; |
| 307 | { |
| 308 | if (entering(tcp)) { |
| 309 | printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]); |
| 310 | tprintf(", %lu", tcp->u_arg[1]); |
| 311 | } |
| 312 | return 0; |
| 313 | } |
| 314 | |
Wichert Akkerman | 5daa028 | 1999-03-15 19:49:42 +0000 | [diff] [blame] | 315 | #if !defined(LINUX) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 316 | |
| 317 | int |
| 318 | sys_getdomainname(tcp) |
| 319 | struct tcb *tcp; |
| 320 | { |
| 321 | if (exiting(tcp)) { |
| 322 | if (syserror(tcp)) |
| 323 | tprintf("%#lx", tcp->u_arg[0]); |
| 324 | else |
| 325 | printpath(tcp, tcp->u_arg[0]); |
| 326 | tprintf(", %lu", tcp->u_arg[1]); |
| 327 | } |
| 328 | return 0; |
| 329 | } |
| 330 | #endif /* !LINUX */ |
| 331 | |
| 332 | int |
| 333 | sys_exit(tcp) |
| 334 | struct tcb *tcp; |
| 335 | { |
| 336 | if (exiting(tcp)) { |
| 337 | fprintf(stderr, "_exit returned!\n"); |
| 338 | return -1; |
| 339 | } |
| 340 | /* special case: we stop tracing this process, finish line now */ |
| 341 | tprintf("%ld) ", tcp->u_arg[0]); |
| 342 | tabto(acolumn); |
| 343 | tprintf("= ?"); |
| 344 | printtrailer(tcp); |
| 345 | return 0; |
| 346 | } |
| 347 | |
| 348 | int |
| 349 | internal_exit(tcp) |
| 350 | struct tcb *tcp; |
| 351 | { |
| 352 | if (entering(tcp)) |
| 353 | tcp->flags |= TCB_EXITING; |
| 354 | return 0; |
| 355 | } |
| 356 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 357 | #ifdef USE_PROCFS |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 358 | |
| 359 | int |
| 360 | sys_fork(tcp) |
| 361 | struct tcb *tcp; |
| 362 | { |
| 363 | if (exiting(tcp)) { |
| 364 | if (getrval2(tcp)) { |
| 365 | tcp->auxstr = "child process"; |
| 366 | return RVAL_UDECIMAL | RVAL_STR; |
| 367 | } |
| 368 | } |
| 369 | return 0; |
| 370 | } |
| 371 | |
John Hughes | 4e36a81 | 2001-04-18 15:11:51 +0000 | [diff] [blame] | 372 | #if UNIXWARE > 2 |
| 373 | |
| 374 | int |
| 375 | sys_rfork(tcp) |
| 376 | struct tcb *tcp; |
| 377 | { |
| 378 | if (entering(tcp)) { |
| 379 | tprintf ("%ld", tcp->u_arg[0]); |
| 380 | } |
| 381 | else { |
| 382 | if (getrval2(tcp)) { |
| 383 | tcp->auxstr = "child process"; |
| 384 | return RVAL_UDECIMAL | RVAL_STR; |
| 385 | } |
| 386 | } |
| 387 | return 0; |
| 388 | } |
| 389 | |
| 390 | #endif |
| 391 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 392 | int |
| 393 | internal_fork(tcp) |
| 394 | struct tcb *tcp; |
| 395 | { |
| 396 | struct tcb *tcpchild; |
| 397 | |
| 398 | if (exiting(tcp)) { |
| 399 | if (getrval2(tcp)) |
| 400 | return 0; |
| 401 | if (!followfork) |
| 402 | return 0; |
| 403 | if (nprocs == MAX_PROCS) { |
| 404 | tcp->flags &= ~TCB_FOLLOWFORK; |
| 405 | fprintf(stderr, "sys_fork: tcb table full\n"); |
| 406 | return 0; |
| 407 | } |
| 408 | else |
| 409 | tcp->flags |= TCB_FOLLOWFORK; |
| 410 | if (syserror(tcp)) |
| 411 | return 0; |
| 412 | if ((tcpchild = alloctcb(tcp->u_rval)) == NULL) { |
| 413 | fprintf(stderr, "sys_fork: tcb table full\n"); |
| 414 | return 0; |
| 415 | } |
Wichert Akkerman | 2e4ffe5 | 2000-09-03 23:57:48 +0000 | [diff] [blame] | 416 | if (proc_open(tcpchild, 2) < 0) |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 417 | droptcb(tcpchild); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 418 | } |
| 419 | return 0; |
| 420 | } |
| 421 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 422 | #else /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 423 | |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 424 | #ifdef LINUX |
| 425 | |
| 426 | /* defines copied from linux/sched.h since we can't include that |
| 427 | * ourselves (it conflicts with *lots* of libc includes) |
| 428 | */ |
| 429 | #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ |
| 430 | #define CLONE_VM 0x00000100 /* set if VM shared between processes */ |
| 431 | #define CLONE_FS 0x00000200 /* set if fs info shared between processes */ |
| 432 | #define CLONE_FILES 0x00000400 /* set if open files shared between processes */ |
| 433 | #define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */ |
| 434 | #define CLONE_PID 0x00001000 /* set if pid shared */ |
| 435 | #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */ |
| 436 | #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ |
| 437 | #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */ |
| 438 | |
| 439 | static struct xlat clone_flags[] = { |
| 440 | { CLONE_VM, "CLONE_VM" }, |
| 441 | { CLONE_FS, "CLONE_FS" }, |
| 442 | { CLONE_FILES, "CLONE_FILES" }, |
| 443 | { CLONE_SIGHAND, "CLONE_SIGHAND" }, |
| 444 | { CLONE_PID, "CLONE_PID" }, |
| 445 | { CLONE_PTRACE, "CLONE_PTRACE" }, |
| 446 | { CLONE_VFORK, "CLONE_VFORK" }, |
| 447 | { CLONE_PARENT, "CLONE_PARENT" }, |
| 448 | { 0, NULL }, |
| 449 | }; |
| 450 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 451 | int |
| 452 | sys_clone(tcp) |
| 453 | struct tcb *tcp; |
| 454 | { |
| 455 | if (exiting(tcp)) { |
| 456 | tprintf("child_stack=%#lx, flags=", tcp->u_arg[1]); |
| 457 | if (printflags(clone_flags, tcp->u_arg[0]) == 0) |
| 458 | tprintf("0"); |
| 459 | } |
| 460 | return 0; |
| 461 | } |
| 462 | |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 463 | int |
| 464 | sys_clone2(tcp) |
| 465 | struct tcb *tcp; |
| 466 | { |
| 467 | if (exiting(tcp)) { |
| 468 | tprintf("child_stack=%#lx, stack_size=%#lx, flags=", |
| 469 | tcp->u_arg[1], tcp->u_arg[2]); |
| 470 | if (printflags(clone_flags, tcp->u_arg[0]) == 0) |
| 471 | tprintf("0"); |
| 472 | } |
| 473 | return 0; |
| 474 | } |
| 475 | |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 476 | #endif |
| 477 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 478 | int |
| 479 | sys_fork(tcp) |
| 480 | struct tcb *tcp; |
| 481 | { |
| 482 | if (exiting(tcp)) |
| 483 | return RVAL_UDECIMAL; |
| 484 | return 0; |
| 485 | } |
| 486 | |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 487 | int |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 488 | change_syscall(tcp, new) |
| 489 | struct tcb *tcp; |
| 490 | int new; |
| 491 | { |
| 492 | #if defined(LINUX) |
| 493 | #if defined(I386) |
| 494 | /* Attempt to make vfork into fork, which we can follow. */ |
| 495 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0) |
| 496 | return -1; |
| 497 | return 0; |
| 498 | #elif defined(POWERPC) |
Wichert Akkerman | 5c4c69b | 2001-04-12 09:00:47 +0000 | [diff] [blame] | 499 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R0), new) < 0) |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 500 | return -1; |
| 501 | #elif defined(S390) |
| 502 | long pc; |
| 503 | if (upeek(tcp->pid, PT_PSWADDR,&pc)<0) |
| 504 | return -1; |
| 505 | if (ptrace(PTRACE_POKETEXT, tcp->pid, (char*)(pc-4), new)<0) |
| 506 | return -1; |
| 507 | return 0; |
| 508 | #elif defined(M68K) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 509 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_ORIG_D0), new)<0) |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 510 | return -1; |
| 511 | return 0; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 512 | #elif defined(SPARC) |
Wichert Akkerman | 00a82ee | 2001-03-28 20:29:17 +0000 | [diff] [blame] | 513 | struct regs regs; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 514 | if (ptrace(PTRACE_GETREGS, tcp->pid, (char*)®s, 0)<0) |
| 515 | return -1; |
Wichert Akkerman | 00a82ee | 2001-03-28 20:29:17 +0000 | [diff] [blame] | 516 | regs.r_g1=new; |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 517 | if (ptrace(PTRACE_SETREGS, tcp->pid, (char*)®s, 0)<0) |
| 518 | return -1; |
| 519 | return 0; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 520 | #elif defined(MIPS) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 521 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new)<0) |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 522 | return -1; |
| 523 | return 0; |
| 524 | #elif defined(ALPHA) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 525 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new)<0) |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 526 | return -1; |
| 527 | return 0; |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 528 | #elif defined(IA64) |
| 529 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R15), new)<0) |
| 530 | return -1; |
| 531 | return 0; |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 532 | #elif defined(HPPA) |
| 533 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR20), new)<0) |
| 534 | return -1; |
| 535 | return 0; |
Wichert Akkerman | ccef637 | 2002-05-01 16:39:22 +0000 | [diff] [blame] | 536 | #elif defined(SH) |
| 537 | if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_SYSCALL), new)<0) |
| 538 | return -1; |
| 539 | return 0; |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 540 | #else |
| 541 | #warning Do not know how to handle change_syscall for this architecture |
| 542 | #endif /* architecture */ |
| 543 | #endif /* LINUX */ |
| 544 | return -1; |
| 545 | } |
| 546 | |
| 547 | int |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 548 | setarg(tcp, argnum) |
| 549 | struct tcb *tcp; |
| 550 | int argnum; |
| 551 | { |
| 552 | #if defined (IA64) |
| 553 | { |
| 554 | unsigned long *bsp, *ap; |
| 555 | |
| 556 | if (upeek(tcp->pid, PT_AR_BSP, (long *) &bsp) , 0) |
| 557 | return -1; |
| 558 | |
| 559 | ap = ia64_rse_skip_regs(bsp, argnum); |
| 560 | errno = 0; |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 561 | ptrace(PTRACE_POKEDATA, tcp->pid, (char *) ap, tcp->u_arg[argnum]); |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 562 | if (errno) |
| 563 | return -1; |
| 564 | |
| 565 | } |
Wichert Akkerman | 12f75d1 | 2000-02-14 16:23:40 +0000 | [diff] [blame] | 566 | #elif defined(I386) |
| 567 | { |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 568 | ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*argnum), tcp->u_arg[argnum]); |
Wichert Akkerman | 12f75d1 | 2000-02-14 16:23:40 +0000 | [diff] [blame] | 569 | if (errno) |
| 570 | return -1; |
| 571 | } |
Ralf Baechle | e381610 | 2000-08-01 00:06:06 +0000 | [diff] [blame] | 572 | #elif defined(MIPS) |
| 573 | { |
| 574 | errno = 0; |
| 575 | if (argnum < 4) |
| 576 | ptrace(PTRACE_POKEUSER, tcp->pid, |
| 577 | (char*)(REG_A0 + argnum), tcp->u_arg[argnum]); |
| 578 | else { |
| 579 | unsigned long *sp; |
| 580 | |
| 581 | if (upeek(tcp->pid, REG_SP, (long *) &sp) , 0) |
| 582 | return -1; |
| 583 | |
| 584 | ptrace(PTRACE_POKEDATA, tcp->pid, |
| 585 | (char*)(sp + argnum - 4), tcp->u_arg[argnum]); |
| 586 | } |
| 587 | if (errno) |
| 588 | return -1; |
| 589 | } |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 590 | #else |
Wichert Akkerman | faf7222 | 2000-02-19 23:59:03 +0000 | [diff] [blame] | 591 | # warning Sorry, setargs not implemented for this architecture. |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 592 | #endif |
| 593 | return 0; |
| 594 | } |
| 595 | |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 596 | #ifdef SYS_clone |
| 597 | int |
| 598 | internal_clone(tcp) |
| 599 | struct tcb *tcp; |
| 600 | { |
Ulrich Drepper | 90512f0 | 1999-12-24 07:22:25 +0000 | [diff] [blame] | 601 | struct tcb *tcpchild; |
| 602 | int pid; |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 603 | if (entering(tcp)) { |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 604 | if (!followfork) |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 605 | return 0; |
| 606 | if (nprocs == MAX_PROCS) { |
| 607 | tcp->flags &= ~TCB_FOLLOWFORK; |
| 608 | fprintf(stderr, "sys_fork: tcb table full\n"); |
| 609 | return 0; |
| 610 | } |
| 611 | tcp->flags |= TCB_FOLLOWFORK; |
| 612 | |
Wichert Akkerman | 9b0c31d | 2000-09-03 21:56:29 +0000 | [diff] [blame] | 613 | |
| 614 | if (setbpt(tcp) < 0) |
| 615 | return 0; |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 616 | } else { |
Wichert Akkerman | 9b0c31d | 2000-09-03 21:56:29 +0000 | [diff] [blame] | 617 | int bpt = tcp->flags & TCB_BPTSET; |
| 618 | |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 619 | if (!(tcp->flags & TCB_FOLLOWFORK)) |
| 620 | return 0; |
| 621 | |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 622 | if (syserror(tcp)) { |
| 623 | if (bpt) |
| 624 | clearbpt(tcp); |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 625 | return 0; |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 626 | } |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 627 | |
| 628 | pid = tcp->u_rval; |
| 629 | if ((tcpchild = alloctcb(pid)) == NULL) { |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 630 | if (bpt) |
| 631 | clearbpt(tcp); |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 632 | fprintf(stderr, " [tcb table full]\n"); |
| 633 | kill(pid, SIGKILL); /* XXX */ |
| 634 | return 0; |
| 635 | } |
| 636 | |
Wichert Akkerman | 9b0c31d | 2000-09-03 21:56:29 +0000 | [diff] [blame] | 637 | /* Attach to the new child */ |
| 638 | if (ptrace(PTRACE_ATTACH, pid, (char *) 1, 0) < 0) { |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 639 | if (bpt) |
| 640 | clearbpt(tcp); |
Wichert Akkerman | 9b0c31d | 2000-09-03 21:56:29 +0000 | [diff] [blame] | 641 | perror("PTRACE_ATTACH"); |
| 642 | fprintf(stderr, "Too late?\n"); |
| 643 | droptcb(tcpchild); |
| 644 | return 0; |
| 645 | } |
| 646 | |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 647 | if (bpt) |
| 648 | clearbpt(tcp); |
| 649 | |
Ulrich Drepper | 90512f0 | 1999-12-24 07:22:25 +0000 | [diff] [blame] | 650 | tcpchild->flags |= TCB_ATTACHED; |
Wichert Akkerman | 9b0c31d | 2000-09-03 21:56:29 +0000 | [diff] [blame] | 651 | if (bpt) { |
| 652 | tcpchild->flags |= TCB_BPTSET; |
| 653 | tcpchild->baddr = tcp->baddr; |
| 654 | memcpy(tcpchild->inst, tcp->inst, |
| 655 | sizeof tcpchild->inst); |
| 656 | } |
Ulrich Drepper | 90512f0 | 1999-12-24 07:22:25 +0000 | [diff] [blame] | 657 | newoutf(tcpchild); |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 658 | tcpchild->parent = tcp; |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 659 | tcp->nchildren++; |
| 660 | if (!qflag) |
| 661 | fprintf(stderr, "Process %d attached\n", pid); |
| 662 | } |
| 663 | return 0; |
| 664 | } |
| 665 | #endif |
| 666 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 667 | int |
| 668 | internal_fork(tcp) |
| 669 | struct tcb *tcp; |
| 670 | { |
| 671 | struct tcb *tcpchild; |
| 672 | int pid; |
Nate Sammons | ccd8f21 | 1999-03-29 22:57:54 +0000 | [diff] [blame] | 673 | int dont_follow = 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 674 | |
| 675 | #ifdef SYS_vfork |
Nate Sammons | ccd8f21 | 1999-03-29 22:57:54 +0000 | [diff] [blame] | 676 | if (tcp->scno == SYS_vfork) { |
Nate Sammons | ccd8f21 | 1999-03-29 22:57:54 +0000 | [diff] [blame] | 677 | /* Attempt to make vfork into fork, which we can follow. */ |
| 678 | if (!followvfork || |
Pavel Machek | 9a9f10b | 2000-02-01 16:22:52 +0000 | [diff] [blame] | 679 | change_syscall(tcp, SYS_fork) < 0) |
Nate Sammons | ccd8f21 | 1999-03-29 22:57:54 +0000 | [diff] [blame] | 680 | dont_follow = 1; |
Nate Sammons | ccd8f21 | 1999-03-29 22:57:54 +0000 | [diff] [blame] | 681 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 682 | #endif |
| 683 | if (entering(tcp)) { |
Nate Sammons | ccd8f21 | 1999-03-29 22:57:54 +0000 | [diff] [blame] | 684 | if (!followfork || dont_follow) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 685 | return 0; |
| 686 | if (nprocs == MAX_PROCS) { |
| 687 | tcp->flags &= ~TCB_FOLLOWFORK; |
| 688 | fprintf(stderr, "sys_fork: tcb table full\n"); |
| 689 | return 0; |
| 690 | } |
| 691 | tcp->flags |= TCB_FOLLOWFORK; |
| 692 | if (setbpt(tcp) < 0) |
| 693 | return 0; |
Wichert Akkerman | 7a0b649 | 1999-12-23 15:08:17 +0000 | [diff] [blame] | 694 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 695 | else { |
| 696 | int bpt = tcp->flags & TCB_BPTSET; |
| 697 | |
| 698 | if (!(tcp->flags & TCB_FOLLOWFORK)) |
| 699 | return 0; |
| 700 | if (bpt) |
| 701 | clearbpt(tcp); |
| 702 | |
| 703 | if (syserror(tcp)) |
| 704 | return 0; |
| 705 | |
| 706 | pid = tcp->u_rval; |
| 707 | if ((tcpchild = alloctcb(pid)) == NULL) { |
| 708 | fprintf(stderr, " [tcb table full]\n"); |
| 709 | kill(pid, SIGKILL); /* XXX */ |
| 710 | return 0; |
| 711 | } |
| 712 | #ifdef LINUX |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 713 | #ifdef HPPA |
| 714 | /* The child must have run before it can be attached. */ |
| 715 | /* This must be a bug in the parisc kernel, but I havn't |
| 716 | * identified it yet. Seems to be an issue associated |
| 717 | * with attaching to a process (which sends it a signal) |
| 718 | * before that process has ever been scheduled. When |
| 719 | * debugging, I started seeing crashes in |
| 720 | * arch/parisc/kernel/signal.c:do_signal(), apparently |
| 721 | * caused by r8 getting corrupt over the dequeue_signal() |
| 722 | * call. Didn't make much sense though... |
| 723 | */ |
| 724 | { |
| 725 | struct timeval tv; |
| 726 | tv.tv_sec = 0; |
| 727 | tv.tv_usec = 10000; |
| 728 | select(0, NULL, NULL, NULL, &tv); |
| 729 | } |
| 730 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 731 | if (ptrace(PTRACE_ATTACH, pid, (char *) 1, 0) < 0) { |
| 732 | perror("PTRACE_ATTACH"); |
| 733 | fprintf(stderr, "Too late?\n"); |
| 734 | droptcb(tcpchild); |
| 735 | return 0; |
| 736 | } |
| 737 | #endif /* LINUX */ |
| 738 | #ifdef SUNOS4 |
| 739 | #ifdef oldway |
| 740 | /* The child must have run before it can be attached. */ |
| 741 | { |
| 742 | struct timeval tv; |
| 743 | tv.tv_sec = 0; |
| 744 | tv.tv_usec = 10000; |
| 745 | select(0, NULL, NULL, NULL, &tv); |
| 746 | } |
| 747 | if (ptrace(PTRACE_ATTACH, pid, (char *)1, 0) < 0) { |
| 748 | perror("PTRACE_ATTACH"); |
| 749 | fprintf(stderr, "Too late?\n"); |
| 750 | droptcb(tcpchild); |
| 751 | return 0; |
| 752 | } |
| 753 | #else /* !oldway */ |
| 754 | /* Try to catch the new process as soon as possible. */ |
| 755 | { |
| 756 | int i; |
| 757 | for (i = 0; i < 1024; i++) |
| 758 | if (ptrace(PTRACE_ATTACH, pid, (char *) 1, 0) >= 0) |
| 759 | break; |
| 760 | if (i == 1024) { |
| 761 | perror("PTRACE_ATTACH"); |
| 762 | fprintf(stderr, "Too late?\n"); |
| 763 | droptcb(tcpchild); |
| 764 | return 0; |
| 765 | } |
| 766 | } |
| 767 | #endif /* !oldway */ |
| 768 | #endif /* SUNOS4 */ |
| 769 | tcpchild->flags |= TCB_ATTACHED; |
| 770 | /* Child has BPT too, must be removed on first occasion */ |
| 771 | if (bpt) { |
| 772 | tcpchild->flags |= TCB_BPTSET; |
| 773 | tcpchild->baddr = tcp->baddr; |
| 774 | memcpy(tcpchild->inst, tcp->inst, |
| 775 | sizeof tcpchild->inst); |
| 776 | } |
| 777 | newoutf(tcpchild); |
| 778 | tcpchild->parent = tcp; |
| 779 | tcp->nchildren++; |
| 780 | if (!qflag) |
| 781 | fprintf(stderr, "Process %d attached\n", pid); |
| 782 | } |
| 783 | return 0; |
| 784 | } |
| 785 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 786 | #endif /* !USE_PROCFS */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 787 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 788 | #if defined(SUNOS4) || defined(LINUX) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 789 | |
| 790 | int |
| 791 | sys_vfork(tcp) |
| 792 | struct tcb *tcp; |
| 793 | { |
| 794 | if (exiting(tcp)) |
| 795 | return RVAL_UDECIMAL; |
| 796 | return 0; |
| 797 | } |
| 798 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 799 | #endif /* SUNOS4 || LINUX || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 800 | |
| 801 | #ifndef LINUX |
| 802 | |
| 803 | static char idstr[16]; |
| 804 | |
| 805 | int |
| 806 | sys_getpid(tcp) |
| 807 | struct tcb *tcp; |
| 808 | { |
| 809 | if (exiting(tcp)) { |
| 810 | sprintf(idstr, "ppid %lu", getrval2(tcp)); |
| 811 | tcp->auxstr = idstr; |
| 812 | return RVAL_STR; |
| 813 | } |
| 814 | return 0; |
| 815 | } |
| 816 | |
| 817 | int |
| 818 | sys_getuid(tcp) |
| 819 | struct tcb *tcp; |
| 820 | { |
| 821 | if (exiting(tcp)) { |
| 822 | sprintf(idstr, "euid %lu", getrval2(tcp)); |
| 823 | tcp->auxstr = idstr; |
| 824 | return RVAL_STR; |
| 825 | } |
| 826 | return 0; |
| 827 | } |
| 828 | |
| 829 | int |
| 830 | sys_getgid(tcp) |
| 831 | struct tcb *tcp; |
| 832 | { |
| 833 | if (exiting(tcp)) { |
| 834 | sprintf(idstr, "egid %lu", getrval2(tcp)); |
| 835 | tcp->auxstr = idstr; |
| 836 | return RVAL_STR; |
| 837 | } |
| 838 | return 0; |
| 839 | } |
| 840 | |
| 841 | #endif /* !LINUX */ |
| 842 | |
| 843 | #ifdef LINUX |
| 844 | |
| 845 | int |
| 846 | sys_setuid(tcp) |
| 847 | struct tcb *tcp; |
| 848 | { |
| 849 | if (entering(tcp)) { |
| 850 | tprintf("%u", (uid_t) tcp->u_arg[0]); |
| 851 | } |
| 852 | return 0; |
| 853 | } |
| 854 | |
| 855 | int |
| 856 | sys_setgid(tcp) |
| 857 | struct tcb *tcp; |
| 858 | { |
| 859 | if (entering(tcp)) { |
| 860 | tprintf("%u", (gid_t) tcp->u_arg[0]); |
| 861 | } |
| 862 | return 0; |
| 863 | } |
| 864 | |
| 865 | int |
| 866 | sys_getresuid(tcp) |
| 867 | struct tcb *tcp; |
| 868 | { |
| 869 | if (exiting(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 870 | __kernel_uid_t uid; |
| 871 | if (syserror(tcp)) |
| 872 | tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0], |
| 873 | tcp->u_arg[1], tcp->u_arg[2]); |
| 874 | else { |
| 875 | if (umove(tcp, tcp->u_arg[0], &uid) < 0) |
| 876 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 877 | else |
| 878 | tprintf("ruid %lu, ", (unsigned long) uid); |
| 879 | if (umove(tcp, tcp->u_arg[0], &uid) < 0) |
| 880 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 881 | else |
| 882 | tprintf("euid %lu, ", (unsigned long) uid); |
| 883 | if (umove(tcp, tcp->u_arg[0], &uid) < 0) |
| 884 | tprintf("%#lx", tcp->u_arg[0]); |
| 885 | else |
| 886 | tprintf("suid %lu", (unsigned long) uid); |
| 887 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 888 | } |
| 889 | return 0; |
| 890 | } |
| 891 | |
| 892 | int |
| 893 | sys_getresgid(tcp) |
| 894 | struct tcb *tcp; |
| 895 | { |
| 896 | if (exiting(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 897 | __kernel_gid_t gid; |
| 898 | if (syserror(tcp)) |
| 899 | tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0], |
| 900 | tcp->u_arg[1], tcp->u_arg[2]); |
| 901 | else { |
| 902 | if (umove(tcp, tcp->u_arg[0], &gid) < 0) |
| 903 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 904 | else |
| 905 | tprintf("rgid %lu, ", (unsigned long) gid); |
| 906 | if (umove(tcp, tcp->u_arg[0], &gid) < 0) |
| 907 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 908 | else |
| 909 | tprintf("egid %lu, ", (unsigned long) gid); |
| 910 | if (umove(tcp, tcp->u_arg[0], &gid) < 0) |
| 911 | tprintf("%#lx", tcp->u_arg[0]); |
| 912 | else |
| 913 | tprintf("sgid %lu", (unsigned long) gid); |
| 914 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 915 | } |
| 916 | return 0; |
| 917 | } |
| 918 | |
| 919 | #endif /* LINUX */ |
| 920 | |
| 921 | int |
| 922 | sys_setreuid(tcp) |
| 923 | struct tcb *tcp; |
| 924 | { |
| 925 | if (entering(tcp)) { |
| 926 | tprintf("%lu, %lu", |
| 927 | (unsigned long) (uid_t) tcp->u_arg[0], |
| 928 | (unsigned long) (uid_t) tcp->u_arg[1]); |
| 929 | } |
| 930 | return 0; |
| 931 | } |
| 932 | |
| 933 | int |
| 934 | sys_setregid(tcp) |
| 935 | struct tcb *tcp; |
| 936 | { |
| 937 | if (entering(tcp)) { |
| 938 | tprintf("%lu, %lu", |
| 939 | (unsigned long) (gid_t) tcp->u_arg[0], |
| 940 | (unsigned long) (gid_t) tcp->u_arg[1]); |
| 941 | } |
| 942 | return 0; |
| 943 | } |
| 944 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 945 | #if defined(LINUX) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 946 | int |
| 947 | sys_setresuid(tcp) |
| 948 | struct tcb *tcp; |
| 949 | { |
| 950 | if (entering(tcp)) { |
| 951 | tprintf("ruid %u, euid %u, suid %u", |
| 952 | (uid_t) tcp->u_arg[0], |
| 953 | (uid_t) tcp->u_arg[1], |
| 954 | (uid_t) tcp->u_arg[2]); |
| 955 | } |
| 956 | return 0; |
| 957 | } |
| 958 | int |
| 959 | sys_setresgid(tcp) |
| 960 | struct tcb *tcp; |
| 961 | { |
| 962 | if (entering(tcp)) { |
| 963 | tprintf("rgid %u, egid %u, sgid %u", |
| 964 | (uid_t) tcp->u_arg[0], |
| 965 | (uid_t) tcp->u_arg[1], |
| 966 | (uid_t) tcp->u_arg[2]); |
| 967 | } |
| 968 | return 0; |
| 969 | } |
| 970 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 971 | #endif /* LINUX || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 972 | |
| 973 | int |
| 974 | sys_setgroups(tcp) |
| 975 | struct tcb *tcp; |
| 976 | { |
| 977 | int i, len; |
| 978 | GETGROUPS_T *gidset; |
| 979 | |
| 980 | if (entering(tcp)) { |
| 981 | len = tcp->u_arg[0]; |
| 982 | tprintf("%u, ", len); |
| 983 | if (len <= 0) { |
| 984 | tprintf("[]"); |
| 985 | return 0; |
| 986 | } |
| 987 | gidset = (GETGROUPS_T *) malloc(len * sizeof(GETGROUPS_T)); |
| 988 | if (gidset == NULL) { |
| 989 | fprintf(stderr, "sys_setgroups: out of memory\n"); |
| 990 | return -1; |
| 991 | } |
| 992 | if (!verbose(tcp)) |
| 993 | tprintf("%#lx", tcp->u_arg[1]); |
| 994 | else if (umoven(tcp, tcp->u_arg[1], |
| 995 | len * sizeof(GETGROUPS_T), (char *) gidset) < 0) |
| 996 | tprintf("[?]"); |
| 997 | else { |
| 998 | tprintf("["); |
| 999 | for (i = 0; i < len; i++) |
| 1000 | tprintf("%s%lu", i ? ", " : "", |
| 1001 | (unsigned long) gidset[i]); |
| 1002 | tprintf("]"); |
| 1003 | } |
| 1004 | free((char *) gidset); |
| 1005 | } |
| 1006 | return 0; |
| 1007 | } |
| 1008 | |
| 1009 | int |
| 1010 | sys_getgroups(tcp) |
| 1011 | struct tcb *tcp; |
| 1012 | { |
| 1013 | int i, len; |
| 1014 | GETGROUPS_T *gidset; |
| 1015 | |
| 1016 | if (entering(tcp)) { |
| 1017 | len = tcp->u_arg[0]; |
| 1018 | tprintf("%u, ", len); |
| 1019 | } else { |
| 1020 | len = tcp->u_rval; |
| 1021 | if (len <= 0) { |
| 1022 | tprintf("[]"); |
| 1023 | return 0; |
| 1024 | } |
| 1025 | gidset = (GETGROUPS_T *) malloc(len * sizeof(GETGROUPS_T)); |
| 1026 | if (gidset == NULL) { |
| 1027 | fprintf(stderr, "sys_getgroups: out of memory\n"); |
| 1028 | return -1; |
| 1029 | } |
| 1030 | if (!tcp->u_arg[1]) |
| 1031 | tprintf("NULL"); |
| 1032 | else if (!verbose(tcp) || tcp->u_arg[0] == 0) |
| 1033 | tprintf("%#lx", tcp->u_arg[1]); |
| 1034 | else if (umoven(tcp, tcp->u_arg[1], |
| 1035 | len * sizeof(GETGROUPS_T), (char *) gidset) < 0) |
| 1036 | tprintf("[?]"); |
| 1037 | else { |
| 1038 | tprintf("["); |
| 1039 | for (i = 0; i < len; i++) |
| 1040 | tprintf("%s%lu", i ? ", " : "", |
| 1041 | (unsigned long) gidset[i]); |
| 1042 | tprintf("]"); |
| 1043 | } |
| 1044 | free((char *)gidset); |
| 1045 | } |
| 1046 | return 0; |
| 1047 | } |
| 1048 | |
| 1049 | int |
| 1050 | sys_setpgrp(tcp) |
| 1051 | struct tcb *tcp; |
| 1052 | { |
| 1053 | if (entering(tcp)) { |
| 1054 | #ifndef SVR4 |
| 1055 | tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 1056 | #endif /* !SVR4 */ |
| 1057 | } |
| 1058 | return 0; |
| 1059 | } |
| 1060 | |
| 1061 | int |
| 1062 | sys_getpgrp(tcp) |
| 1063 | struct tcb *tcp; |
| 1064 | { |
| 1065 | if (entering(tcp)) { |
| 1066 | #ifndef SVR4 |
| 1067 | tprintf("%lu", tcp->u_arg[0]); |
| 1068 | #endif /* !SVR4 */ |
| 1069 | } |
| 1070 | return 0; |
| 1071 | } |
| 1072 | |
| 1073 | int |
| 1074 | sys_getsid(tcp) |
| 1075 | struct tcb *tcp; |
| 1076 | { |
| 1077 | if (entering(tcp)) { |
| 1078 | tprintf("%lu", tcp->u_arg[0]); |
| 1079 | } |
| 1080 | return 0; |
| 1081 | } |
| 1082 | |
| 1083 | int |
| 1084 | sys_setsid(tcp) |
| 1085 | struct tcb *tcp; |
| 1086 | { |
| 1087 | return 0; |
| 1088 | } |
| 1089 | |
| 1090 | int |
| 1091 | sys_getpgid(tcp) |
| 1092 | struct tcb *tcp; |
| 1093 | { |
| 1094 | if (entering(tcp)) { |
| 1095 | tprintf("%lu", tcp->u_arg[0]); |
| 1096 | } |
| 1097 | return 0; |
| 1098 | } |
| 1099 | |
| 1100 | int |
| 1101 | sys_setpgid(tcp) |
| 1102 | struct tcb *tcp; |
| 1103 | { |
| 1104 | if (entering(tcp)) { |
| 1105 | tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 1106 | } |
| 1107 | return 0; |
| 1108 | } |
| 1109 | |
John Hughes | c61eb3d | 2002-05-17 11:37:50 +0000 | [diff] [blame] | 1110 | #if UNIXWARE >= 2 |
| 1111 | |
| 1112 | #include <sys/privilege.h> |
| 1113 | |
| 1114 | |
| 1115 | static struct xlat procpriv_cmds [] = { |
| 1116 | { SETPRV, "SETPRV" }, |
| 1117 | { CLRPRV, "CLRPRV" }, |
| 1118 | { PUTPRV, "PUTPRV" }, |
| 1119 | { GETPRV, "GETPRV" }, |
| 1120 | { CNTPRV, "CNTPRV" }, |
| 1121 | { 0, NULL }, |
| 1122 | }; |
| 1123 | |
| 1124 | |
| 1125 | static struct xlat procpriv_priv [] = { |
| 1126 | { P_OWNER, "P_OWNER" }, |
| 1127 | { P_AUDIT, "P_AUDIT" }, |
| 1128 | { P_COMPAT, "P_COMPAT" }, |
| 1129 | { P_DACREAD, "P_DACREAD" }, |
| 1130 | { P_DACWRITE, "P_DACWRITE" }, |
| 1131 | { P_DEV, "P_DEV" }, |
| 1132 | { P_FILESYS, "P_FILESYS" }, |
| 1133 | { P_MACREAD, "P_MACREAD" }, |
| 1134 | { P_MACWRITE, "P_MACWRITE" }, |
| 1135 | { P_MOUNT, "P_MOUNT" }, |
| 1136 | { P_MULTIDIR, "P_MULTIDIR" }, |
| 1137 | { P_SETPLEVEL, "P_SETPLEVEL" }, |
| 1138 | { P_SETSPRIV, "P_SETSPRIV" }, |
| 1139 | { P_SETUID, "P_SETUID" }, |
| 1140 | { P_SYSOPS, "P_SYSOPS" }, |
| 1141 | { P_SETUPRIV, "P_SETUPRIV" }, |
| 1142 | { P_DRIVER, "P_DRIVER" }, |
| 1143 | { P_RTIME, "P_RTIME" }, |
| 1144 | { P_MACUPGRADE, "P_MACUPGRADE" }, |
| 1145 | { P_FSYSRANGE, "P_FSYSRANGE" }, |
| 1146 | { P_SETFLEVEL, "P_SETFLEVEL" }, |
| 1147 | { P_AUDITWR, "P_AUDITWR" }, |
| 1148 | { P_TSHAR, "P_TSHAR" }, |
| 1149 | { P_PLOCK, "P_PLOCK" }, |
| 1150 | { P_CORE, "P_CORE" }, |
| 1151 | { P_LOADMOD, "P_LOADMOD" }, |
| 1152 | { P_BIND, "P_BIND" }, |
| 1153 | { P_ALLPRIVS, "P_ALLPRIVS" }, |
| 1154 | { 0, NULL }, |
| 1155 | }; |
| 1156 | |
| 1157 | |
| 1158 | static struct xlat procpriv_type [] = { |
| 1159 | { PS_FIX, "PS_FIX" }, |
| 1160 | { PS_INH, "PS_INH" }, |
| 1161 | { PS_MAX, "PS_MAX" }, |
| 1162 | { PS_WKG, "PS_WKG" }, |
| 1163 | { 0, NULL }, |
| 1164 | }; |
| 1165 | |
| 1166 | |
| 1167 | static void |
| 1168 | printpriv(tcp, addr, len, opt) |
| 1169 | struct tcb *tcp; |
| 1170 | long addr; |
| 1171 | int len; |
| 1172 | struct xlat *opt; |
| 1173 | { |
| 1174 | priv_t buf [128]; |
| 1175 | int max = verbose (tcp) ? sizeof buf / sizeof buf [0] : 10; |
| 1176 | int dots = len > max; |
| 1177 | int i; |
| 1178 | |
| 1179 | if (len > max) len = max; |
| 1180 | |
| 1181 | if (len <= 0 || |
| 1182 | umoven (tcp, addr, len * sizeof buf[0], (char *) buf) < 0) |
| 1183 | { |
| 1184 | tprintf ("%#lx", addr); |
| 1185 | return; |
| 1186 | } |
| 1187 | |
| 1188 | tprintf ("["); |
| 1189 | |
| 1190 | for (i = 0; i < len; ++i) { |
| 1191 | char *t, *p; |
| 1192 | |
| 1193 | if (i) tprintf (", "); |
| 1194 | |
| 1195 | if ((t = xlookup (procpriv_type, buf [i] & PS_TYPE)) && |
| 1196 | (p = xlookup (procpriv_priv, buf [i] & ~PS_TYPE))) |
| 1197 | { |
| 1198 | tprintf ("%s|%s", t, p); |
| 1199 | } |
| 1200 | else { |
| 1201 | tprintf ("%#lx", buf [i]); |
| 1202 | } |
| 1203 | } |
| 1204 | |
| 1205 | if (dots) tprintf (" ..."); |
| 1206 | |
| 1207 | tprintf ("]"); |
| 1208 | } |
| 1209 | |
| 1210 | |
| 1211 | int |
| 1212 | sys_procpriv(tcp) |
| 1213 | struct tcb *tcp; |
| 1214 | { |
| 1215 | if (entering(tcp)) { |
| 1216 | printxval(procpriv_cmds, tcp->u_arg[0], "???PRV"); |
| 1217 | switch (tcp->u_arg[0]) { |
| 1218 | case CNTPRV: |
| 1219 | tprintf(", %#lx, %ld", tcp->u_arg[1], tcp->u_arg[2]); |
| 1220 | break; |
| 1221 | |
| 1222 | case GETPRV: |
| 1223 | break; |
| 1224 | |
| 1225 | default: |
| 1226 | tprintf (", "); |
| 1227 | printpriv (tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1228 | tprintf (", %ld", tcp->u_arg[2]); |
| 1229 | } |
| 1230 | } |
| 1231 | else if (tcp->u_arg[0] == GETPRV) { |
| 1232 | if (syserror (tcp)) { |
| 1233 | tprintf(", %#lx, %ld", tcp->u_arg[1], tcp->u_arg[2]); |
| 1234 | } |
| 1235 | else { |
| 1236 | tprintf (", "); |
| 1237 | printpriv (tcp, tcp->u_arg[1], tcp->u_rval); |
| 1238 | tprintf (", %ld", tcp->u_arg[2]); |
| 1239 | } |
| 1240 | } |
| 1241 | |
| 1242 | return 0; |
| 1243 | } |
| 1244 | |
| 1245 | #endif |
| 1246 | |
| 1247 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1248 | void |
| 1249 | fake_execve(tcp, program, argv, envp) |
| 1250 | struct tcb *tcp; |
| 1251 | char *program; |
| 1252 | char *argv[]; |
| 1253 | char *envp[]; |
| 1254 | { |
| 1255 | int i; |
| 1256 | |
| 1257 | #ifdef ARM |
| 1258 | if (!(qual_flags[SYS_execve - __NR_SYSCALL_BASE] & QUAL_TRACE)) |
| 1259 | return; |
| 1260 | #else |
| 1261 | if (!(qual_flags[SYS_execve] & QUAL_TRACE)) |
| 1262 | return; |
| 1263 | #endif /* !ARM */ |
| 1264 | printleader(tcp); |
| 1265 | tprintf("execve("); |
| 1266 | string_quote(program); |
| 1267 | tprintf(", ["); |
| 1268 | for (i = 0; argv[i] != NULL; i++) { |
| 1269 | if (i != 0) |
| 1270 | tprintf(", "); |
| 1271 | string_quote(argv[i]); |
| 1272 | } |
| 1273 | for (i = 0; envp[i] != NULL; i++) |
| 1274 | ; |
| 1275 | tprintf("], [/* %d var%s */]) ", i, (i != 1) ? "s" : ""); |
| 1276 | tabto(acolumn); |
| 1277 | tprintf("= 0"); |
| 1278 | printtrailer(tcp); |
| 1279 | } |
| 1280 | |
| 1281 | static void |
| 1282 | printargv(tcp, addr) |
| 1283 | struct tcb *tcp; |
| 1284 | long addr; |
| 1285 | { |
| 1286 | char *cp; |
| 1287 | char *sep; |
| 1288 | int max = max_strlen / 2; |
| 1289 | |
| 1290 | for (sep = ""; --max >= 0; sep = ", ") { |
| 1291 | if (!abbrev(tcp)) |
| 1292 | max++; |
| 1293 | if (umove(tcp, addr, &cp) < 0) { |
| 1294 | tprintf("%#lx", addr); |
| 1295 | return; |
| 1296 | } |
| 1297 | if (cp == 0) |
| 1298 | break; |
| 1299 | tprintf(sep); |
| 1300 | printstr(tcp, (long) cp, -1); |
| 1301 | addr += sizeof(char *); |
| 1302 | } |
| 1303 | if (cp) |
| 1304 | tprintf(", ..."); |
| 1305 | } |
| 1306 | |
| 1307 | static void |
| 1308 | printargc(fmt, tcp, addr) |
| 1309 | char *fmt; |
| 1310 | struct tcb *tcp; |
| 1311 | long addr; |
| 1312 | { |
| 1313 | int count; |
| 1314 | char *cp; |
| 1315 | |
| 1316 | for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) { |
| 1317 | addr += sizeof(char *); |
| 1318 | } |
| 1319 | tprintf(fmt, count, count == 1 ? "" : "s"); |
| 1320 | } |
| 1321 | |
| 1322 | int |
| 1323 | sys_execv(tcp) |
| 1324 | struct tcb *tcp; |
| 1325 | { |
| 1326 | if (entering(tcp)) { |
| 1327 | printpath(tcp, tcp->u_arg[0]); |
| 1328 | if (!verbose(tcp)) |
| 1329 | tprintf(", %#lx", tcp->u_arg[1]); |
| 1330 | #if 0 |
| 1331 | else if (abbrev(tcp)) |
| 1332 | printargc(", [/* %d arg%s */]", tcp, tcp->u_arg[1]); |
| 1333 | #endif |
| 1334 | else { |
| 1335 | tprintf(", ["); |
| 1336 | printargv(tcp, tcp->u_arg[1]); |
| 1337 | tprintf("]"); |
| 1338 | } |
| 1339 | } |
| 1340 | return 0; |
| 1341 | } |
| 1342 | |
| 1343 | int |
| 1344 | sys_execve(tcp) |
| 1345 | struct tcb *tcp; |
| 1346 | { |
| 1347 | if (entering(tcp)) { |
| 1348 | printpath(tcp, tcp->u_arg[0]); |
| 1349 | if (!verbose(tcp)) |
| 1350 | tprintf(", %#lx", tcp->u_arg[1]); |
| 1351 | #if 0 |
| 1352 | else if (abbrev(tcp)) |
| 1353 | printargc(", [/* %d arg%s */]", tcp, tcp->u_arg[1]); |
| 1354 | #endif |
| 1355 | else { |
| 1356 | tprintf(", ["); |
| 1357 | printargv(tcp, tcp->u_arg[1]); |
| 1358 | tprintf("]"); |
| 1359 | } |
| 1360 | if (!verbose(tcp)) |
| 1361 | tprintf(", %#lx", tcp->u_arg[2]); |
| 1362 | else if (abbrev(tcp)) |
| 1363 | printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]); |
| 1364 | else { |
| 1365 | tprintf(", ["); |
| 1366 | printargv(tcp, tcp->u_arg[2]); |
| 1367 | tprintf("]"); |
| 1368 | } |
| 1369 | } |
| 1370 | #ifdef LINUX |
Wichert Akkerman | ccef637 | 2002-05-01 16:39:22 +0000 | [diff] [blame] | 1371 | #if defined(ALPHA) || defined(SPARC) || defined(POWERPC) || defined(IA64) || defined(HPPA) || defined(SH) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1372 | tcp->flags |= TCB_WAITEXECVE; |
Wichert Akkerman | ccef637 | 2002-05-01 16:39:22 +0000 | [diff] [blame] | 1373 | #endif /* ALPHA || SPARC || POWERPC || IA64 || HPPA || SH */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1374 | #endif /* LINUX */ |
| 1375 | return 0; |
| 1376 | } |
| 1377 | |
John Hughes | 4e36a81 | 2001-04-18 15:11:51 +0000 | [diff] [blame] | 1378 | #if UNIXWARE > 2 |
| 1379 | |
| 1380 | int sys_rexecve(tcp) |
| 1381 | struct tcb *tcp; |
| 1382 | { |
| 1383 | if (entering (tcp)) { |
| 1384 | sys_execve (tcp); |
| 1385 | tprintf (", %ld", tcp->u_arg[3]); |
| 1386 | } |
| 1387 | return 0; |
| 1388 | } |
| 1389 | |
| 1390 | #endif |
| 1391 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1392 | int |
| 1393 | internal_exec(tcp) |
| 1394 | struct tcb *tcp; |
| 1395 | { |
| 1396 | #ifdef SUNOS4 |
| 1397 | if (exiting(tcp) && !syserror(tcp) && followfork) |
| 1398 | fixvfork(tcp); |
| 1399 | #endif /* SUNOS4 */ |
| 1400 | return 0; |
| 1401 | } |
| 1402 | |
| 1403 | #ifdef LINUX |
| 1404 | #ifndef __WCLONE |
| 1405 | #define __WCLONE 0x8000000 |
| 1406 | #endif |
| 1407 | #endif /* LINUX */ |
| 1408 | |
| 1409 | static struct xlat wait4_options[] = { |
| 1410 | { WNOHANG, "WNOHANG" }, |
| 1411 | #ifndef WSTOPPED |
| 1412 | { WUNTRACED, "WUNTRACED" }, |
| 1413 | #endif |
| 1414 | #ifdef WEXITED |
| 1415 | { WEXITED, "WEXITED" }, |
| 1416 | #endif |
| 1417 | #ifdef WTRAPPED |
| 1418 | { WTRAPPED, "WTRAPPED" }, |
| 1419 | #endif |
| 1420 | #ifdef WSTOPPED |
| 1421 | { WSTOPPED, "WSTOPPED" }, |
| 1422 | #endif |
| 1423 | #ifdef WCONTINUED |
| 1424 | { WCONTINUED, "WCONTINUED" }, |
| 1425 | #endif |
| 1426 | #ifdef WNOWAIT |
| 1427 | { WNOWAIT, "WNOWAIT" }, |
| 1428 | #endif |
| 1429 | #ifdef __WCLONE |
| 1430 | { __WCLONE, "__WCLONE" }, |
| 1431 | #endif |
| 1432 | { 0, NULL }, |
| 1433 | }; |
| 1434 | |
| 1435 | static int |
| 1436 | printstatus(status) |
| 1437 | int status; |
| 1438 | { |
| 1439 | int exited = 0; |
| 1440 | |
| 1441 | /* |
| 1442 | * Here is a tricky presentation problem. This solution |
| 1443 | * is still not entirely satisfactory but since there |
| 1444 | * are no wait status constructors it will have to do. |
| 1445 | */ |
| 1446 | if (WIFSTOPPED(status)) |
| 1447 | tprintf("[WIFSTOPPED(s) && WSTOPSIG(s) == %s]", |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 1448 | signame(WSTOPSIG(status))); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1449 | else if WIFSIGNALED(status) |
| 1450 | tprintf("[WIFSIGNALED(s) && WTERMSIG(s) == %s%s]", |
Nate Sammons | ce780fc | 1999-03-29 23:23:13 +0000 | [diff] [blame] | 1451 | signame(WTERMSIG(status)), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1452 | WCOREDUMP(status) ? " && WCOREDUMP(s)" : ""); |
| 1453 | else if WIFEXITED(status) { |
| 1454 | tprintf("[WIFEXITED(s) && WEXITSTATUS(s) == %d]", |
| 1455 | WEXITSTATUS(status)); |
| 1456 | exited = 1; |
| 1457 | } |
| 1458 | else |
| 1459 | tprintf("[%#x]", status); |
| 1460 | return exited; |
| 1461 | } |
| 1462 | |
| 1463 | static int |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1464 | printwaitn(tcp, n, bitness) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1465 | struct tcb *tcp; |
| 1466 | int n; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1467 | int bitness; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1468 | { |
| 1469 | int status; |
| 1470 | int exited = 0; |
| 1471 | |
| 1472 | if (entering(tcp)) { |
| 1473 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1474 | } else { |
| 1475 | /* status */ |
| 1476 | if (!tcp->u_arg[1]) |
| 1477 | tprintf("NULL"); |
| 1478 | else if (syserror(tcp) || tcp->u_rval == 0) |
| 1479 | tprintf("%#lx", tcp->u_arg[1]); |
| 1480 | else if (umove(tcp, tcp->u_arg[1], &status) < 0) |
| 1481 | tprintf("[?]"); |
| 1482 | else |
| 1483 | exited = printstatus(status); |
| 1484 | /* options */ |
| 1485 | tprintf(", "); |
| 1486 | if (!printflags(wait4_options, tcp->u_arg[2])) |
| 1487 | tprintf("0"); |
| 1488 | if (n == 4) { |
| 1489 | tprintf(", "); |
| 1490 | /* usage */ |
| 1491 | if (!tcp->u_arg[3]) |
| 1492 | tprintf("NULL"); |
| 1493 | #ifdef LINUX |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1494 | else if (tcp->u_rval > 0) { |
| 1495 | #ifdef LINUX_64BIT |
| 1496 | if (bitness) |
| 1497 | printrusage32(tcp, tcp->u_arg[3]); |
| 1498 | else |
| 1499 | #endif |
| 1500 | printrusage(tcp, tcp->u_arg[3]); |
| 1501 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1502 | #endif /* LINUX */ |
| 1503 | #ifdef SUNOS4 |
| 1504 | else if (tcp->u_rval > 0 && exited) |
| 1505 | printrusage(tcp, tcp->u_arg[3]); |
| 1506 | #endif /* SUNOS4 */ |
| 1507 | else |
| 1508 | tprintf("%#lx", tcp->u_arg[3]); |
| 1509 | } |
| 1510 | } |
| 1511 | return 0; |
| 1512 | } |
| 1513 | |
| 1514 | int |
| 1515 | internal_wait(tcp) |
| 1516 | struct tcb *tcp; |
| 1517 | { |
| 1518 | if (entering(tcp)) { |
Wichert Akkerman | 5daa028 | 1999-03-15 19:49:42 +0000 | [diff] [blame] | 1519 | /* WTA: fix bug with hanging children */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1520 | if (!(tcp->u_arg[2] & WNOHANG) && tcp->nchildren > 0) { |
| 1521 | /* There are traced children */ |
| 1522 | tcp->flags |= TCB_SUSPENDED; |
| 1523 | tcp->waitpid = tcp->u_arg[0]; |
| 1524 | } |
| 1525 | } |
| 1526 | return 0; |
| 1527 | } |
| 1528 | |
| 1529 | #ifdef SVR4 |
| 1530 | |
| 1531 | int |
| 1532 | sys_wait(tcp) |
| 1533 | struct tcb *tcp; |
| 1534 | { |
| 1535 | if (exiting(tcp)) { |
| 1536 | /* The library wrapper stuffs this into the user variable. */ |
| 1537 | if (!syserror(tcp)) |
| 1538 | printstatus(getrval2(tcp)); |
| 1539 | } |
| 1540 | return 0; |
| 1541 | } |
| 1542 | |
| 1543 | #endif /* SVR4 */ |
| 1544 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1545 | #ifdef FREEBSD |
| 1546 | int |
| 1547 | sys_wait(tcp) |
| 1548 | struct tcb *tcp; |
| 1549 | { |
| 1550 | int status; |
| 1551 | |
| 1552 | if (exiting(tcp)) { |
| 1553 | if (!syserror(tcp)) { |
| 1554 | if (umove(tcp, tcp->u_arg[0], &status) < 0) |
| 1555 | tprintf("%#lx", tcp->u_arg[0]); |
| 1556 | else |
| 1557 | printstatus(status); |
| 1558 | } |
| 1559 | } |
| 1560 | return 0; |
| 1561 | } |
| 1562 | #endif |
| 1563 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1564 | int |
| 1565 | sys_waitpid(tcp) |
| 1566 | struct tcb *tcp; |
| 1567 | { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1568 | return printwaitn(tcp, 3, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1569 | } |
| 1570 | |
| 1571 | int |
| 1572 | sys_wait4(tcp) |
| 1573 | struct tcb *tcp; |
| 1574 | { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1575 | return printwaitn(tcp, 4, 0); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1576 | } |
| 1577 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1578 | #ifdef ALPHA |
| 1579 | int |
| 1580 | sys_osf_wait4(tcp) |
| 1581 | struct tcb *tcp; |
| 1582 | { |
| 1583 | return printwaitn(tcp, 4, 1); |
| 1584 | } |
| 1585 | #endif |
| 1586 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1587 | #ifdef SVR4 |
| 1588 | |
| 1589 | static struct xlat waitid_types[] = { |
| 1590 | { P_PID, "P_PID" }, |
| 1591 | { P_PPID, "P_PPID" }, |
| 1592 | { P_PGID, "P_PGID" }, |
| 1593 | { P_SID, "P_SID" }, |
| 1594 | { P_CID, "P_CID" }, |
| 1595 | { P_UID, "P_UID" }, |
| 1596 | { P_GID, "P_GID" }, |
| 1597 | { P_ALL, "P_ALL" }, |
| 1598 | #ifdef P_LWPID |
| 1599 | { P_LWPID, "P_LWPID" }, |
| 1600 | #endif |
| 1601 | { 0, NULL }, |
| 1602 | }; |
| 1603 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1604 | int |
| 1605 | sys_waitid(tcp) |
| 1606 | struct tcb *tcp; |
| 1607 | { |
| 1608 | siginfo_t si; |
| 1609 | int exited; |
| 1610 | |
| 1611 | if (entering(tcp)) { |
| 1612 | printxval(waitid_types, tcp->u_arg[0], "P_???"); |
| 1613 | tprintf(", %ld, ", tcp->u_arg[1]); |
| 1614 | if (tcp->nchildren > 0) { |
| 1615 | /* There are traced children */ |
| 1616 | tcp->flags |= TCB_SUSPENDED; |
| 1617 | tcp->waitpid = tcp->u_arg[0]; |
| 1618 | } |
| 1619 | } |
| 1620 | else { |
| 1621 | /* siginfo */ |
| 1622 | exited = 0; |
| 1623 | if (!tcp->u_arg[2]) |
| 1624 | tprintf("NULL"); |
| 1625 | else if (syserror(tcp)) |
| 1626 | tprintf("%#lx", tcp->u_arg[2]); |
| 1627 | else if (umove(tcp, tcp->u_arg[2], &si) < 0) |
| 1628 | tprintf("{???}"); |
| 1629 | else |
John Hughes | 5826589 | 2001-10-18 15:13:53 +0000 | [diff] [blame] | 1630 | printsiginfo(&si, verbose (tcp)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1631 | /* options */ |
| 1632 | tprintf(", "); |
| 1633 | if (!printflags(wait4_options, tcp->u_arg[3])) |
| 1634 | tprintf("0"); |
| 1635 | } |
| 1636 | return 0; |
| 1637 | } |
| 1638 | |
| 1639 | #endif /* SVR4 */ |
| 1640 | |
| 1641 | int |
| 1642 | sys_alarm(tcp) |
| 1643 | struct tcb *tcp; |
| 1644 | { |
| 1645 | if (entering(tcp)) |
| 1646 | tprintf("%lu", tcp->u_arg[0]); |
| 1647 | return 0; |
| 1648 | } |
| 1649 | |
| 1650 | int |
| 1651 | sys_uname(tcp) |
| 1652 | struct tcb *tcp; |
| 1653 | { |
| 1654 | struct utsname uname; |
| 1655 | |
| 1656 | if (exiting(tcp)) { |
| 1657 | if (syserror(tcp) || !verbose(tcp)) |
| 1658 | tprintf("%#lx", tcp->u_arg[0]); |
| 1659 | else if (umove(tcp, tcp->u_arg[0], &uname) < 0) |
| 1660 | tprintf("{...}"); |
| 1661 | else if (!abbrev(tcp)) { |
| 1662 | |
| 1663 | tprintf("{sysname=\"%s\", nodename=\"%s\", ", |
| 1664 | uname.sysname, uname.nodename); |
| 1665 | tprintf("release=\"%s\", version=\"%s\", ", |
| 1666 | uname.release, uname.version); |
| 1667 | tprintf("machine=\"%s\"", uname.machine); |
| 1668 | #ifdef LINUX |
| 1669 | #ifndef __GLIBC__ |
| 1670 | tprintf(", domainname=\"%s\"", uname.domainname); |
| 1671 | #endif /* __GLIBC__ */ |
| 1672 | #endif /* LINUX */ |
| 1673 | tprintf("}"); |
| 1674 | } |
| 1675 | else |
| 1676 | tprintf("{sys=\"%s\", node=\"%s\", ...}", |
| 1677 | uname.sysname, uname.nodename); |
| 1678 | } |
| 1679 | return 0; |
| 1680 | } |
| 1681 | |
| 1682 | #ifndef SVR4 |
| 1683 | |
| 1684 | static struct xlat ptrace_cmds[] = { |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1685 | #ifndef FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1686 | { PTRACE_TRACEME, "PTRACE_TRACEME" }, |
| 1687 | { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT", }, |
| 1688 | { PTRACE_PEEKDATA, "PTRACE_PEEKDATA", }, |
| 1689 | { PTRACE_PEEKUSER, "PTRACE_PEEKUSER", }, |
| 1690 | { PTRACE_POKETEXT, "PTRACE_POKETEXT", }, |
| 1691 | { PTRACE_POKEDATA, "PTRACE_POKEDATA", }, |
| 1692 | { PTRACE_POKEUSER, "PTRACE_POKEUSER", }, |
| 1693 | { PTRACE_CONT, "PTRACE_CONT" }, |
| 1694 | { PTRACE_KILL, "PTRACE_KILL" }, |
| 1695 | { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" }, |
| 1696 | { PTRACE_ATTACH, "PTRACE_ATTACH" }, |
| 1697 | { PTRACE_DETACH, "PTRACE_DETACH" }, |
| 1698 | #ifdef SUNOS4 |
| 1699 | { PTRACE_GETREGS, "PTRACE_GETREGS" }, |
| 1700 | { PTRACE_SETREGS, "PTRACE_SETREGS" }, |
| 1701 | { PTRACE_GETFPREGS, "PTRACE_GETFPREGS", }, |
| 1702 | { PTRACE_SETFPREGS, "PTRACE_SETFPREGS", }, |
| 1703 | { PTRACE_READDATA, "PTRACE_READDATA" }, |
| 1704 | { PTRACE_WRITEDATA, "PTRACE_WRITEDATA" }, |
| 1705 | { PTRACE_READTEXT, "PTRACE_READTEXT" }, |
| 1706 | { PTRACE_WRITETEXT, "PTRACE_WRITETEXT" }, |
| 1707 | { PTRACE_GETFPAREGS, "PTRACE_GETFPAREGS" }, |
| 1708 | { PTRACE_SETFPAREGS, "PTRACE_SETFPAREGS" }, |
| 1709 | #ifdef SPARC |
| 1710 | { PTRACE_GETWINDOW, "PTRACE_GETWINDOW" }, |
| 1711 | { PTRACE_SETWINDOW, "PTRACE_SETWINDOW" }, |
| 1712 | #else /* !SPARC */ |
| 1713 | { PTRACE_22, "PTRACE_PTRACE_22" }, |
| 1714 | { PTRACE_23, "PTRACE_PTRACE_23" }, |
| 1715 | #endif /* !SPARC */ |
| 1716 | #endif /* SUNOS4 */ |
| 1717 | { PTRACE_SYSCALL, "PTRACE_SYSCALL" }, |
| 1718 | #ifdef SUNOS4 |
| 1719 | { PTRACE_DUMPCORE, "PTRACE_DUMPCORE" }, |
| 1720 | #ifdef I386 |
| 1721 | { PTRACE_SETWRBKPT, "PTRACE_SETWRBKPT" }, |
| 1722 | { PTRACE_SETACBKPT, "PTRACE_SETACBKPT" }, |
| 1723 | { PTRACE_CLRDR7, "PTRACE_CLRDR7" }, |
| 1724 | #else /* !I386 */ |
| 1725 | { PTRACE_26, "PTRACE_26" }, |
| 1726 | { PTRACE_27, "PTRACE_27" }, |
| 1727 | { PTRACE_28, "PTRACE_28" }, |
| 1728 | #endif /* !I386 */ |
| 1729 | { PTRACE_GETUCODE, "PTRACE_GETUCODE" }, |
| 1730 | #endif /* SUNOS4 */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1731 | #else /* FREEBSD */ |
| 1732 | { PT_TRACE_ME, "PT_TRACE_ME" }, |
| 1733 | { PT_READ_I, "PT_READ_I" }, |
| 1734 | { PT_READ_D, "PT_READ_D" }, |
| 1735 | { PT_WRITE_I, "PT_WRITE_I" }, |
| 1736 | { PT_WRITE_D, "PT_WRITE_D" }, |
John Hughes | a227814 | 2001-09-28 16:21:30 +0000 | [diff] [blame] | 1737 | #ifdef PT_READ_U |
| 1738 | { PT_READ_U, "PT_READ_U" }, |
| 1739 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1740 | { PT_CONTINUE, "PT_CONTINUE" }, |
| 1741 | { PT_KILL, "PT_KILL" }, |
| 1742 | { PT_STEP, "PT_STEP" }, |
| 1743 | { PT_ATTACH, "PT_ATTACH" }, |
| 1744 | { PT_DETACH, "PT_DETACH" }, |
| 1745 | { PT_GETREGS, "PT_GETREGS" }, |
| 1746 | { PT_SETREGS, "PT_SETREGS" }, |
| 1747 | { PT_GETFPREGS, "PT_GETFPREGS" }, |
| 1748 | { PT_SETFPREGS, "PT_SETFPREGS" }, |
| 1749 | { PT_GETDBREGS, "PT_GETDBREGS" }, |
| 1750 | { PT_SETDBREGS, "PT_SETDBREGS" }, |
| 1751 | #endif /* FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1752 | { 0, NULL }, |
| 1753 | }; |
| 1754 | |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 1755 | #ifndef FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1756 | #ifndef SUNOS4_KERNEL_ARCH_KLUDGE |
| 1757 | static |
| 1758 | #endif /* !SUNOS4_KERNEL_ARCH_KLUDGE */ |
| 1759 | struct xlat struct_user_offsets[] = { |
| 1760 | #ifdef LINUX |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 1761 | #ifdef S390 |
| 1762 | { PT_PSWMASK, "psw_mask" }, |
| 1763 | { PT_PSWADDR, "psw_addr" }, |
| 1764 | { PT_GPR0, "gpr0" }, |
| 1765 | { PT_GPR1, "gpr1" }, |
| 1766 | { PT_GPR2, "gpr2" }, |
| 1767 | { PT_GPR3, "gpr3" }, |
| 1768 | { PT_GPR4, "gpr4" }, |
| 1769 | { PT_GPR5, "gpr5" }, |
| 1770 | { PT_GPR6, "gpr6" }, |
| 1771 | { PT_GPR7, "gpr7" }, |
| 1772 | { PT_GPR8, "gpr8" }, |
| 1773 | { PT_GPR9, "gpr9" }, |
| 1774 | { PT_GPR10, "gpr10" }, |
| 1775 | { PT_GPR11, "gpr11" }, |
| 1776 | { PT_GPR12, "gpr12" }, |
| 1777 | { PT_GPR13, "gpr13" }, |
| 1778 | { PT_GPR14, "gpr14" }, |
| 1779 | { PT_GPR15, "gpr15" }, |
| 1780 | { PT_ACR0, "acr0" }, |
| 1781 | { PT_ACR1, "acr1" }, |
| 1782 | { PT_ACR2, "acr2" }, |
| 1783 | { PT_ACR3, "acr3" }, |
| 1784 | { PT_ACR4, "acr4" }, |
| 1785 | { PT_ACR5, "acr5" }, |
| 1786 | { PT_ACR6, "acr6" }, |
| 1787 | { PT_ACR7, "acr7" }, |
| 1788 | { PT_ACR8, "acr8" }, |
| 1789 | { PT_ACR9, "acr9" }, |
| 1790 | { PT_ACR10, "acr10" }, |
| 1791 | { PT_ACR11, "acr11" }, |
| 1792 | { PT_ACR12, "acr12" }, |
| 1793 | { PT_ACR13, "acr13" }, |
| 1794 | { PT_ACR14, "acr14" }, |
| 1795 | { PT_ACR15, "acr15" }, |
| 1796 | { PT_ORIGGPR2, "orig_gpr2" }, |
| 1797 | { PT_FPC, "fpc" }, |
| 1798 | { PT_FPR0_HI, "fpr0.hi" }, |
| 1799 | { PT_FPR0_LO, "fpr0.lo" }, |
| 1800 | { PT_FPR1_HI, "fpr1.hi" }, |
| 1801 | { PT_FPR1_LO, "fpr1.lo" }, |
| 1802 | { PT_FPR2_HI, "fpr2.hi" }, |
| 1803 | { PT_FPR2_LO, "fpr2.lo" }, |
| 1804 | { PT_FPR3_HI, "fpr3.hi" }, |
| 1805 | { PT_FPR3_LO, "fpr3.lo" }, |
| 1806 | { PT_FPR4_HI, "fpr4.hi" }, |
| 1807 | { PT_FPR4_LO, "fpr4.lo" }, |
| 1808 | { PT_FPR5_HI, "fpr5.hi" }, |
| 1809 | { PT_FPR5_LO, "fpr5.lo" }, |
| 1810 | { PT_FPR6_HI, "fpr6.hi" }, |
| 1811 | { PT_FPR6_LO, "fpr6.lo" }, |
| 1812 | { PT_FPR7_HI, "fpr7.hi" }, |
| 1813 | { PT_FPR7_LO, "fpr7.lo" }, |
| 1814 | { PT_FPR8_HI, "fpr8.hi" }, |
| 1815 | { PT_FPR8_LO, "fpr8.lo" }, |
| 1816 | { PT_FPR9_HI, "fpr9.hi" }, |
| 1817 | { PT_FPR9_LO, "fpr9.lo" }, |
| 1818 | { PT_FPR10_HI, "fpr10.hi" }, |
| 1819 | { PT_FPR10_LO, "fpr10.lo" }, |
| 1820 | { PT_FPR11_HI, "fpr11.hi" }, |
| 1821 | { PT_FPR11_LO, "fpr11.lo" }, |
| 1822 | { PT_FPR12_HI, "fpr12.hi" }, |
| 1823 | { PT_FPR12_LO, "fpr12.lo" }, |
| 1824 | { PT_FPR13_HI, "fpr13.hi" }, |
| 1825 | { PT_FPR13_LO, "fpr13.lo" }, |
| 1826 | { PT_FPR14_HI, "fpr14.hi" }, |
| 1827 | { PT_FPR14_LO, "fpr14.lo" }, |
| 1828 | { PT_FPR15_HI, "fpr15.hi" }, |
| 1829 | { PT_FPR15_LO, "fpr15.lo" }, |
| 1830 | { PT_CR_9, "cr9" }, |
| 1831 | { PT_CR_10, "cr10" }, |
| 1832 | { PT_CR_11, "cr11" }, |
| 1833 | #endif |
| 1834 | #if defined(SPARC) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1835 | /* XXX No support for these offsets yet. */ |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 1836 | #elif defined(HPPA) |
| 1837 | /* XXX No support for these offsets yet. */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1838 | #elif defined(POWERPC) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 1839 | { 4*PT_R0, "4*PT_R0" }, |
| 1840 | { 4*PT_R1, "4*PT_R1" }, |
| 1841 | { 4*PT_R2, "4*PT_R2" }, |
| 1842 | { 4*PT_R3, "4*PT_R3" }, |
| 1843 | { 4*PT_R4, "4*PT_R4" }, |
| 1844 | { 4*PT_R5, "4*PT_R5" }, |
| 1845 | { 4*PT_R6, "4*PT_R6" }, |
| 1846 | { 4*PT_R7, "4*PT_R7" }, |
| 1847 | { 4*PT_R8, "4*PT_R8" }, |
| 1848 | { 4*PT_R9, "4*PT_R9" }, |
| 1849 | { 4*PT_R10, "4*PT_R10" }, |
| 1850 | { 4*PT_R11, "4*PT_R11" }, |
| 1851 | { 4*PT_R12, "4*PT_R12" }, |
| 1852 | { 4*PT_R13, "4*PT_R13" }, |
| 1853 | { 4*PT_R14, "4*PT_R14" }, |
| 1854 | { 4*PT_R15, "4*PT_R15" }, |
| 1855 | { 4*PT_R16, "4*PT_R16" }, |
| 1856 | { 4*PT_R17, "4*PT_R17" }, |
| 1857 | { 4*PT_R18, "4*PT_R18" }, |
| 1858 | { 4*PT_R19, "4*PT_R19" }, |
| 1859 | { 4*PT_R20, "4*PT_R20" }, |
| 1860 | { 4*PT_R21, "4*PT_R21" }, |
| 1861 | { 4*PT_R22, "4*PT_R22" }, |
| 1862 | { 4*PT_R23, "4*PT_R23" }, |
| 1863 | { 4*PT_R24, "4*PT_R24" }, |
| 1864 | { 4*PT_R25, "4*PT_R25" }, |
| 1865 | { 4*PT_R26, "4*PT_R26" }, |
| 1866 | { 4*PT_R27, "4*PT_R27" }, |
| 1867 | { 4*PT_R28, "4*PT_R28" }, |
| 1868 | { 4*PT_R29, "4*PT_R29" }, |
| 1869 | { 4*PT_R30, "4*PT_R30" }, |
| 1870 | { 4*PT_R31, "4*PT_R31" }, |
| 1871 | { 4*PT_NIP, "4*PT_NIP" }, |
| 1872 | { 4*PT_MSR, "4*PT_MSR" }, |
| 1873 | { 4*PT_ORIG_R3, "4*PT_ORIG_R3" }, |
| 1874 | { 4*PT_CTR, "4*PT_CTR" }, |
| 1875 | { 4*PT_LNK, "4*PT_LNK" }, |
| 1876 | { 4*PT_XER, "4*PT_XER" }, |
| 1877 | { 4*PT_CCR, "4*PT_CCR" }, |
| 1878 | { 4*PT_FPR0, "4*PT_FPR0" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1879 | #else |
| 1880 | #ifdef ALPHA |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 1881 | { 0, "r0" }, |
| 1882 | { 1, "r1" }, |
| 1883 | { 2, "r2" }, |
| 1884 | { 3, "r3" }, |
| 1885 | { 4, "r4" }, |
| 1886 | { 5, "r5" }, |
| 1887 | { 6, "r6" }, |
| 1888 | { 7, "r7" }, |
| 1889 | { 8, "r8" }, |
| 1890 | { 9, "r9" }, |
| 1891 | { 10, "r10" }, |
| 1892 | { 11, "r11" }, |
| 1893 | { 12, "r12" }, |
| 1894 | { 13, "r13" }, |
| 1895 | { 14, "r14" }, |
| 1896 | { 15, "r15" }, |
| 1897 | { 16, "r16" }, |
| 1898 | { 17, "r17" }, |
| 1899 | { 18, "r18" }, |
| 1900 | { 19, "r19" }, |
| 1901 | { 20, "r20" }, |
| 1902 | { 21, "r21" }, |
| 1903 | { 22, "r22" }, |
| 1904 | { 23, "r23" }, |
| 1905 | { 24, "r24" }, |
| 1906 | { 25, "r25" }, |
| 1907 | { 26, "r26" }, |
| 1908 | { 27, "r27" }, |
| 1909 | { 28, "r28" }, |
| 1910 | { 29, "gp" }, |
| 1911 | { 30, "fp" }, |
| 1912 | { 31, "zero" }, |
| 1913 | { 32, "fp0" }, |
| 1914 | { 33, "fp" }, |
| 1915 | { 34, "fp2" }, |
| 1916 | { 35, "fp3" }, |
| 1917 | { 36, "fp4" }, |
| 1918 | { 37, "fp5" }, |
| 1919 | { 38, "fp6" }, |
| 1920 | { 39, "fp7" }, |
| 1921 | { 40, "fp8" }, |
| 1922 | { 41, "fp9" }, |
| 1923 | { 42, "fp10" }, |
| 1924 | { 43, "fp11" }, |
| 1925 | { 44, "fp12" }, |
| 1926 | { 45, "fp13" }, |
| 1927 | { 46, "fp14" }, |
| 1928 | { 47, "fp15" }, |
| 1929 | { 48, "fp16" }, |
| 1930 | { 49, "fp17" }, |
| 1931 | { 50, "fp18" }, |
| 1932 | { 51, "fp19" }, |
| 1933 | { 52, "fp20" }, |
| 1934 | { 53, "fp21" }, |
| 1935 | { 54, "fp22" }, |
| 1936 | { 55, "fp23" }, |
| 1937 | { 56, "fp24" }, |
| 1938 | { 57, "fp25" }, |
| 1939 | { 58, "fp26" }, |
| 1940 | { 59, "fp27" }, |
| 1941 | { 60, "fp28" }, |
| 1942 | { 61, "fp29" }, |
| 1943 | { 62, "fp30" }, |
| 1944 | { 63, "fp31" }, |
| 1945 | { 64, "pc" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1946 | #else /* !ALPHA */ |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1947 | #ifdef IA64 |
| 1948 | { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" }, |
| 1949 | { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" }, |
| 1950 | { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" }, |
| 1951 | { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" }, |
| 1952 | { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" }, |
| 1953 | { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" }, |
| 1954 | { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" }, |
| 1955 | { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" }, |
| 1956 | { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" }, |
| 1957 | { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" }, |
| 1958 | { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" }, |
| 1959 | { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" }, |
| 1960 | { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" }, |
| 1961 | { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" }, |
| 1962 | { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" }, |
| 1963 | { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" }, |
| 1964 | { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" }, |
| 1965 | { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" }, |
| 1966 | { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" }, |
| 1967 | { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" }, |
| 1968 | { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" }, |
| 1969 | { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" }, |
| 1970 | { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" }, |
| 1971 | { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" }, |
| 1972 | { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" }, |
| 1973 | { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" }, |
| 1974 | { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" }, |
| 1975 | { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" }, |
| 1976 | { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" }, |
| 1977 | { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" }, |
| 1978 | { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" }, |
| 1979 | { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" }, |
| 1980 | /* switch stack: */ |
| 1981 | { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" }, |
| 1982 | { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" }, |
| 1983 | { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" }, |
| 1984 | { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" }, |
| 1985 | { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" }, |
| 1986 | { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" }, |
| 1987 | { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" }, |
| 1988 | { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" }, |
| 1989 | { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" }, |
| 1990 | { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" }, |
Wichert Akkerman | 82b162e | 2001-08-03 11:51:28 +0000 | [diff] [blame] | 1991 | { PT_B0, "kb0" }, |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1992 | { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" }, |
| 1993 | { PT_B4, "b4" }, { PT_B5, "b5" }, |
Wichert Akkerman | 82b162e | 2001-08-03 11:51:28 +0000 | [diff] [blame] | 1994 | { PT_AR_PFS, "kar.pfs" }, |
| 1995 | { PT_AR_LC, "ar.lc" }, { PT_AR_UNAT, "kar.unat" }, |
| 1996 | { PT_AR_RNAT, "kar.rnat" }, { PT_AR_BSPSTORE, "kar.bspstore" }, |
| 1997 | { PT_PR, "k.pr" }, |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 1998 | /* pt_regs */ |
| 1999 | { PT_CR_IPSR, "cr.ipsr" }, { PT_CR_IIP, "cr.iip" }, |
Wichert Akkerman | 82b162e | 2001-08-03 11:51:28 +0000 | [diff] [blame] | 2000 | /*{ PT_CR_IFS, "cr.ifs" },*/ { PT_AR_UNAT, "ar.unat" }, |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 2001 | { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" }, |
| 2002 | { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" }, |
| 2003 | { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" }, |
| 2004 | { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" }, |
| 2005 | { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" }, |
| 2006 | { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" }, |
| 2007 | { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" }, |
| 2008 | { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" }, |
| 2009 | { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" }, |
| 2010 | { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" }, |
| 2011 | { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" }, |
| 2012 | { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" }, |
| 2013 | { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" }, |
| 2014 | { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" }, |
| 2015 | { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" }, |
| 2016 | #else /* !IA64 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2017 | #ifdef I386 |
| 2018 | { 4*EBX, "4*EBX" }, |
| 2019 | { 4*ECX, "4*ECX" }, |
| 2020 | { 4*EDX, "4*EDX" }, |
| 2021 | { 4*ESI, "4*ESI" }, |
| 2022 | { 4*EDI, "4*EDI" }, |
| 2023 | { 4*EBP, "4*EBP" }, |
| 2024 | { 4*EAX, "4*EAX" }, |
| 2025 | { 4*DS, "4*DS" }, |
| 2026 | { 4*ES, "4*ES" }, |
| 2027 | { 4*FS, "4*FS" }, |
| 2028 | { 4*GS, "4*GS" }, |
| 2029 | { 4*ORIG_EAX, "4*ORIG_EAX" }, |
| 2030 | { 4*EIP, "4*EIP" }, |
| 2031 | { 4*CS, "4*CS" }, |
| 2032 | { 4*EFL, "4*EFL" }, |
| 2033 | { 4*UESP, "4*UESP" }, |
| 2034 | { 4*SS, "4*SS" }, |
| 2035 | #else /* !I386 */ |
| 2036 | #ifdef M68K |
| 2037 | { 4*PT_D1, "4*PT_D1" }, |
| 2038 | { 4*PT_D2, "4*PT_D2" }, |
| 2039 | { 4*PT_D3, "4*PT_D3" }, |
| 2040 | { 4*PT_D4, "4*PT_D4" }, |
| 2041 | { 4*PT_D5, "4*PT_D5" }, |
| 2042 | { 4*PT_D6, "4*PT_D6" }, |
| 2043 | { 4*PT_D7, "4*PT_D7" }, |
| 2044 | { 4*PT_A0, "4*PT_A0" }, |
| 2045 | { 4*PT_A1, "4*PT_A1" }, |
| 2046 | { 4*PT_A2, "4*PT_A2" }, |
| 2047 | { 4*PT_A3, "4*PT_A3" }, |
| 2048 | { 4*PT_A4, "4*PT_A4" }, |
| 2049 | { 4*PT_A5, "4*PT_A5" }, |
| 2050 | { 4*PT_A6, "4*PT_A6" }, |
| 2051 | { 4*PT_D0, "4*PT_D0" }, |
| 2052 | { 4*PT_USP, "4*PT_USP" }, |
| 2053 | { 4*PT_ORIG_D0, "4*PT_ORIG_D0" }, |
| 2054 | { 4*PT_SR, "4*PT_SR" }, |
| 2055 | { 4*PT_PC, "4*PT_PC" }, |
| 2056 | #endif /* M68K */ |
| 2057 | #endif /* !I386 */ |
Wichert Akkerman | ccef637 | 2002-05-01 16:39:22 +0000 | [diff] [blame] | 2058 | #ifdef SH |
| 2059 | { 4*REG_REG0, "4*REG_REG0" }, |
| 2060 | { 4*(REG_REG0+1), "4*REG_REG1" }, |
| 2061 | { 4*(REG_REG0+2), "4*REG_REG2" }, |
| 2062 | { 4*(REG_REG0+3), "4*REG_REG3" }, |
| 2063 | { 4*(REG_REG0+4), "4*REG_REG4" }, |
| 2064 | { 4*(REG_REG0+5), "4*REG_REG5" }, |
| 2065 | { 4*(REG_REG0+6), "4*REG_REG6" }, |
| 2066 | { 4*(REG_REG0+7), "4*REG_REG7" }, |
| 2067 | { 4*(REG_REG0+8), "4*REG_REG8" }, |
| 2068 | { 4*(REG_REG0+9), "4*REG_REG9" }, |
| 2069 | { 4*(REG_REG0+10), "4*REG_REG10" }, |
| 2070 | { 4*(REG_REG0+11), "4*REG_REG11" }, |
| 2071 | { 4*(REG_REG0+12), "4*REG_REG12" }, |
| 2072 | { 4*(REG_REG0+13), "4*REG_REG13" }, |
| 2073 | { 4*(REG_REG0+14), "4*REG_REG14" }, |
| 2074 | { 4*REG_REG15, "4*REG_REG15" }, |
| 2075 | { 4*REG_PC, "4*REG_PC" }, |
| 2076 | { 4*REG_PR, "4*REG_PR" }, |
| 2077 | { 4*REG_SR, "4*REG_SR" }, |
| 2078 | { 4*REG_GBR, "4*REG_GBR" }, |
| 2079 | { 4*REG_MACH, "4*REG_MACH" }, |
| 2080 | { 4*REG_MACL, "4*REG_MACL" }, |
| 2081 | { 4*REG_SYSCALL, "4*REG_SYSCALL" }, |
| 2082 | { 4*REG_FPUL, "4*REG_FPUL" }, |
| 2083 | { 4*REG_FPREG0, "4*REG_FPREG0" }, |
| 2084 | { 4*(REG_FPREG0+1), "4*REG_FPREG1" }, |
| 2085 | { 4*(REG_FPREG0+2), "4*REG_FPREG2" }, |
| 2086 | { 4*(REG_FPREG0+3), "4*REG_FPREG3" }, |
| 2087 | { 4*(REG_FPREG0+4), "4*REG_FPREG4" }, |
| 2088 | { 4*(REG_FPREG0+5), "4*REG_FPREG5" }, |
| 2089 | { 4*(REG_FPREG0+6), "4*REG_FPREG6" }, |
| 2090 | { 4*(REG_FPREG0+7), "4*REG_FPREG7" }, |
| 2091 | { 4*(REG_FPREG0+8), "4*REG_FPREG8" }, |
| 2092 | { 4*(REG_FPREG0+9), "4*REG_FPREG9" }, |
| 2093 | { 4*(REG_FPREG0+10), "4*REG_FPREG10" }, |
| 2094 | { 4*(REG_FPREG0+11), "4*REG_FPREG11" }, |
| 2095 | { 4*(REG_FPREG0+12), "4*REG_FPREG12" }, |
| 2096 | { 4*(REG_FPREG0+13), "4*REG_FPREG13" }, |
| 2097 | { 4*(REG_FPREG0+14), "4*REG_FPREG14" }, |
| 2098 | { 4*REG_FPREG15, "4*REG_FPREG15" }, |
| 2099 | { 4*REG_XDREG0, "4*REG_XDREG0" }, |
| 2100 | { 4*(REG_XDREG0+2), "4*REG_XDREG2" }, |
| 2101 | { 4*(REG_XDREG0+4), "4*REG_XDREG4" }, |
| 2102 | { 4*(REG_XDREG0+6), "4*REG_XDREG6" }, |
| 2103 | { 4*(REG_XDREG0+8), "4*REG_XDREG8" }, |
| 2104 | { 4*(REG_XDREG0+10), "4*REG_XDREG10" }, |
| 2105 | { 4*(REG_XDREG0+12), "4*REG_XDREG12" }, |
| 2106 | { 4*REG_XDREG14, "4*REG_XDREG14" }, |
| 2107 | { 4*REG_FPSCR, "4*REG_FPSCR" }, |
| 2108 | #endif /* SH */ |
| 2109 | |
Wichert Akkerman | 12f75d1 | 2000-02-14 16:23:40 +0000 | [diff] [blame] | 2110 | #if !defined(S390) && !defined(MIPS) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2111 | { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" }, |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 2112 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2113 | #ifdef I386 |
| 2114 | { uoff(i387), "offsetof(struct user, i387)" }, |
| 2115 | #else /* !I386 */ |
| 2116 | #ifdef M68K |
| 2117 | { uoff(m68kfp), "offsetof(struct user, m68kfp)" }, |
| 2118 | #endif /* M68K */ |
| 2119 | #endif /* !I386 */ |
| 2120 | { uoff(u_tsize), "offsetof(struct user, u_tsize)" }, |
| 2121 | { uoff(u_dsize), "offsetof(struct user, u_dsize)" }, |
| 2122 | { uoff(u_ssize), "offsetof(struct user, u_ssize)" }, |
| 2123 | { uoff(start_code), "offsetof(struct user, start_code)" }, |
| 2124 | { uoff(start_stack), "offsetof(struct user, start_stack)" }, |
| 2125 | { uoff(signal), "offsetof(struct user, signal)" }, |
Wichert Akkerman | ccef637 | 2002-05-01 16:39:22 +0000 | [diff] [blame] | 2126 | #if !defined(S390) && !defined(MIPS) && !defined(SH) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2127 | { uoff(reserved), "offsetof(struct user, reserved)" }, |
Wichert Akkerman | f90da01 | 1999-10-31 21:15:38 +0000 | [diff] [blame] | 2128 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2129 | { uoff(u_ar0), "offsetof(struct user, u_ar0)" }, |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 2130 | #if !defined(ARM) && !defined(MIPS) && !defined(S390) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2131 | { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" }, |
| 2132 | #endif |
| 2133 | { uoff(magic), "offsetof(struct user, magic)" }, |
| 2134 | { uoff(u_comm), "offsetof(struct user, u_comm)" }, |
| 2135 | #ifdef I386 |
| 2136 | { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" }, |
| 2137 | #endif /* I386 */ |
Wichert Akkerman | 8b1b40c | 2000-02-03 21:58:30 +0000 | [diff] [blame] | 2138 | #endif /* !IA64 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2139 | #endif /* !ALPHA */ |
| 2140 | #endif /* !POWERPC/!SPARC */ |
| 2141 | #endif /* LINUX */ |
| 2142 | #ifdef SUNOS4 |
| 2143 | { uoff(u_pcb), "offsetof(struct user, u_pcb)" }, |
| 2144 | { uoff(u_procp), "offsetof(struct user, u_procp)" }, |
| 2145 | { uoff(u_ar0), "offsetof(struct user, u_ar0)" }, |
| 2146 | { uoff(u_comm[0]), "offsetof(struct user, u_comm[0])" }, |
| 2147 | { uoff(u_arg[0]), "offsetof(struct user, u_arg[0])" }, |
| 2148 | { uoff(u_ap), "offsetof(struct user, u_ap)" }, |
| 2149 | { uoff(u_qsave), "offsetof(struct user, u_qsave)" }, |
| 2150 | { uoff(u_rval1), "offsetof(struct user, u_rval1)" }, |
| 2151 | { uoff(u_rval2), "offsetof(struct user, u_rval2)" }, |
| 2152 | { uoff(u_error), "offsetof(struct user, u_error)" }, |
| 2153 | { uoff(u_eosys), "offsetof(struct user, u_eosys)" }, |
| 2154 | { uoff(u_ssave), "offsetof(struct user, u_ssave)" }, |
| 2155 | { uoff(u_signal[0]), "offsetof(struct user, u_signal)" }, |
| 2156 | { uoff(u_sigmask[0]), "offsetof(struct user, u_sigmask)" }, |
| 2157 | { uoff(u_sigonstack), "offsetof(struct user, u_sigonstack)" }, |
| 2158 | { uoff(u_sigintr), "offsetof(struct user, u_sigintr)" }, |
| 2159 | { uoff(u_sigreset), "offsetof(struct user, u_sigreset)" }, |
| 2160 | { uoff(u_oldmask), "offsetof(struct user, u_oldmask)" }, |
| 2161 | { uoff(u_code), "offsetof(struct user, u_code)" }, |
| 2162 | { uoff(u_addr), "offsetof(struct user, u_addr)" }, |
| 2163 | { uoff(u_sigstack), "offsetof(struct user, u_sigstack)" }, |
| 2164 | { uoff(u_ofile), "offsetof(struct user, u_ofile)" }, |
| 2165 | { uoff(u_pofile), "offsetof(struct user, u_pofile)" }, |
| 2166 | { uoff(u_ofile_arr[0]), "offsetof(struct user, u_ofile_arr[0])" }, |
| 2167 | { uoff(u_pofile_arr[0]),"offsetof(struct user, u_pofile_arr[0])"}, |
| 2168 | { uoff(u_lastfile), "offsetof(struct user, u_lastfile)" }, |
| 2169 | { uoff(u_cwd), "offsetof(struct user, u_cwd)" }, |
| 2170 | { uoff(u_cdir), "offsetof(struct user, u_cdir)" }, |
| 2171 | { uoff(u_rdir), "offsetof(struct user, u_rdir)" }, |
| 2172 | { uoff(u_cmask), "offsetof(struct user, u_cmask)" }, |
| 2173 | { uoff(u_ru), "offsetof(struct user, u_ru)" }, |
| 2174 | { uoff(u_cru), "offsetof(struct user, u_cru)" }, |
| 2175 | { uoff(u_timer[0]), "offsetof(struct user, u_timer[0])" }, |
| 2176 | { uoff(u_XXX[0]), "offsetof(struct user, u_XXX[0])" }, |
| 2177 | { uoff(u_ioch), "offsetof(struct user, u_ioch)" }, |
| 2178 | { uoff(u_start), "offsetof(struct user, u_start)" }, |
| 2179 | { uoff(u_acflag), "offsetof(struct user, u_acflag)" }, |
| 2180 | { uoff(u_prof.pr_base), "offsetof(struct user, u_prof.pr_base)" }, |
| 2181 | { uoff(u_prof.pr_size), "offsetof(struct user, u_prof.pr_size)" }, |
| 2182 | { uoff(u_prof.pr_off), "offsetof(struct user, u_prof.pr_off)" }, |
| 2183 | { uoff(u_prof.pr_scale),"offsetof(struct user, u_prof.pr_scale)"}, |
| 2184 | { uoff(u_rlimit[0]), "offsetof(struct user, u_rlimit)" }, |
| 2185 | { uoff(u_exdata.Ux_A), "offsetof(struct user, u_exdata.Ux_A)" }, |
| 2186 | { uoff(u_exdata.ux_shell[0]),"offsetof(struct user, u_exdata.ux_shell[0])"}, |
| 2187 | { uoff(u_lofault), "offsetof(struct user, u_lofault)" }, |
| 2188 | #endif /* SUNOS4 */ |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 2189 | #ifndef HPPA |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2190 | { sizeof(struct user), "sizeof(struct user)" }, |
Wichert Akkerman | c1652e2 | 2001-03-27 12:17:16 +0000 | [diff] [blame] | 2191 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2192 | { 0, NULL }, |
| 2193 | }; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2194 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2195 | |
| 2196 | int |
| 2197 | sys_ptrace(tcp) |
| 2198 | struct tcb *tcp; |
| 2199 | { |
| 2200 | char *cmd; |
| 2201 | struct xlat *x; |
| 2202 | long addr; |
| 2203 | |
| 2204 | cmd = xlookup(ptrace_cmds, tcp->u_arg[0]); |
| 2205 | if (!cmd) |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2206 | #ifndef FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2207 | cmd = "PTRACE_???"; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2208 | #else |
| 2209 | cmd = "PT_???"; |
| 2210 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2211 | if (entering(tcp)) { |
| 2212 | tprintf("%s, %lu, ", cmd, tcp->u_arg[1]); |
| 2213 | addr = tcp->u_arg[2]; |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2214 | #ifndef FREEBSD |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2215 | if (tcp->u_arg[0] == PTRACE_PEEKUSER |
| 2216 | || tcp->u_arg[0] == PTRACE_POKEUSER) { |
| 2217 | for (x = struct_user_offsets; x->str; x++) { |
| 2218 | if (x->val >= addr) |
| 2219 | break; |
| 2220 | } |
| 2221 | if (!x->str) |
| 2222 | tprintf("%#lx, ", addr); |
| 2223 | else if (x->val > addr && x != struct_user_offsets) { |
| 2224 | x--; |
| 2225 | tprintf("%s + %ld, ", x->str, addr - x->val); |
| 2226 | } |
| 2227 | else |
| 2228 | tprintf("%s, ", x->str); |
| 2229 | } |
| 2230 | else |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2231 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2232 | tprintf("%#lx, ", tcp->u_arg[2]); |
| 2233 | #ifdef LINUX |
| 2234 | switch (tcp->u_arg[0]) { |
| 2235 | case PTRACE_PEEKDATA: |
| 2236 | case PTRACE_PEEKTEXT: |
| 2237 | case PTRACE_PEEKUSER: |
| 2238 | break; |
| 2239 | case PTRACE_CONT: |
| 2240 | case PTRACE_SINGLESTEP: |
| 2241 | case PTRACE_SYSCALL: |
| 2242 | case PTRACE_DETACH: |
| 2243 | printsignal(tcp->u_arg[3]); |
| 2244 | break; |
| 2245 | default: |
| 2246 | tprintf("%#lx", tcp->u_arg[3]); |
| 2247 | break; |
| 2248 | } |
| 2249 | } else { |
| 2250 | switch (tcp->u_arg[0]) { |
| 2251 | case PTRACE_PEEKDATA: |
| 2252 | case PTRACE_PEEKTEXT: |
| 2253 | case PTRACE_PEEKUSER: |
| 2254 | printnum(tcp, tcp->u_arg[3], "%#x"); |
| 2255 | break; |
| 2256 | } |
| 2257 | } |
| 2258 | #endif /* LINUX */ |
| 2259 | #ifdef SUNOS4 |
| 2260 | if (tcp->u_arg[0] == PTRACE_WRITEDATA || |
| 2261 | tcp->u_arg[0] == PTRACE_WRITETEXT) { |
| 2262 | tprintf("%lu, ", tcp->u_arg[3]); |
| 2263 | printstr(tcp, tcp->u_arg[4], tcp->u_arg[3]); |
| 2264 | } else if (tcp->u_arg[0] != PTRACE_READDATA && |
| 2265 | tcp->u_arg[0] != PTRACE_READTEXT) { |
| 2266 | tprintf("%#lx", tcp->u_arg[3]); |
| 2267 | } |
| 2268 | } else { |
| 2269 | if (tcp->u_arg[0] == PTRACE_READDATA || |
| 2270 | tcp->u_arg[0] == PTRACE_READTEXT) { |
| 2271 | tprintf("%lu, ", tcp->u_arg[3]); |
| 2272 | printstr(tcp, tcp->u_arg[4], tcp->u_arg[3]); |
| 2273 | } |
| 2274 | } |
| 2275 | #endif /* SUNOS4 */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 2276 | #ifdef FREEBSD |
| 2277 | tprintf("%lu", tcp->u_arg[3]); |
| 2278 | } |
| 2279 | #endif /* FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2280 | return 0; |
| 2281 | } |
| 2282 | |
| 2283 | #endif /* !SVR4 */ |