blob: afc8f4b91258f0fcd536db6e7bbac5772018ab92 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Linux for s390 port by D.J. Barrow
8 * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
Wichert Akkermanccef6372002-05-01 16:39:22 +00009 * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH
10 * port by Greg Banks <gbanks@pocketpenguins.com>
11
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +000012 *
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000013 * 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 Akkermanbf79f2e2000-09-01 21:03:06 +000055#ifdef FREEBSD
56#include <sys/ptrace.h>
57#endif
58
Wichert Akkerman00a82ee2001-03-28 20:29:17 +000059#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 Akkerman36915a11999-07-13 15:45:02 +000073#ifdef HAVE_SYS_REG_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000074# include <sys/reg.h>
Wichert Akkerman15dea971999-10-06 13:06:34 +000075#ifndef PTRACE_PEEKUSR
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000076# define PTRACE_PEEKUSR PTRACE_PEEKUSER
Wichert Akkerman15dea971999-10-06 13:06:34 +000077#endif
78#ifndef PTRACE_POKEUSR
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000079# define PTRACE_POKEUSR PTRACE_POKEUSER
80#endif
Wichert Akkermanfaf72222000-02-19 23:59:03 +000081#elif defined(HAVE_LINUX_PTRACE_H)
82#undef PTRACE_SYSCALL
83#include <linux/ptrace.h>
Wichert Akkerman15dea971999-10-06 13:06:34 +000084#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000085
Wichert Akkermanfaf72222000-02-19 23:59:03 +000086
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000087#ifdef LINUX
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000088#include <asm/posix_types.h>
89#undef GETGROUPS_T
90#define GETGROUPS_T __kernel_gid_t
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000091#endif /* LINUX */
92
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +000093#if defined(LINUX) && defined(IA64)
94# include <asm/ptrace_offsets.h>
95# include <asm/rse.h>
96#endif
97
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000098#ifdef HAVE_PRCTL
99#include <sys/prctl.h>
100#endif
101
102#ifndef WCOREDUMP
103#define WCOREDUMP(status) ((status) & 0200)
104#endif
105
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000106/* WTA: this was `&& !defined(LINUXSPARC)', this seems unneeded though? */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000107#if defined(HAVE_PRCTL)
108static 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 Akkerman8829a551999-06-11 13:18:40 +0000154#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 Akkermanf5eeabb1999-11-18 17:09:47 +0000163#ifdef PR_SET_PDEATHSIG
164 { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
165#endif
166#ifdef PR_GET_PDEATHSIG
167 { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
168#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000169#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 Akkerman76baf7c1999-02-19 00:21:36 +0000181 { 0, NULL },
182};
183
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000184
185const char *
186unalignctl_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 Akkerman76baf7c1999-02-19 00:21:36 +0000207int
208sys_prctl(tcp)
209struct 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 Akkermanf5eeabb1999-11-18 17:09:47 +0000220#ifdef PR_SET_DEATHSIG
221 case PR_GET_PDEATHSIG:
222 break;
223#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000224#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 Akkerman76baf7c1999-02-19 00:21:36 +0000234 default:
235 for (i = 1; i < tcp->u_nargs; i++)
236 tprintf(", %#lx", tcp->u_arg[i]);
237 break;
238 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000239 } 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 Akkerman4dc8a2a1999-12-23 14:20:14 +0000244 tprintf(", %#lx", tcp->u_arg[i]);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000245 break;
246#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000247#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 Akkermanf5eeabb1999-11-18 17:09:47 +0000261 default:
262 break;
263 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000264 }
265 return 0;
266}
267
268#endif /* HAVE_PRCTL */
269
270int
271sys_gethostid(tcp)
272struct tcb *tcp;
273{
274 if (exiting(tcp))
275 return RVAL_HEX;
276 return 0;
277}
278
279int
280sys_sethostname(tcp)
281struct 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
290int
291sys_gethostname(tcp)
292struct 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
304int
305sys_setdomainname(tcp)
306struct 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 Akkerman5daa0281999-03-15 19:49:42 +0000315#if !defined(LINUX)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000316
317int
318sys_getdomainname(tcp)
319struct 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
332int
333sys_exit(tcp)
334struct 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
348int
349internal_exit(tcp)
350struct tcb *tcp;
351{
352 if (entering(tcp))
353 tcp->flags |= TCB_EXITING;
354 return 0;
355}
356
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000357#ifdef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000358
359int
360sys_fork(tcp)
361struct 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 Hughes4e36a812001-04-18 15:11:51 +0000372#if UNIXWARE > 2
373
374int
375sys_rfork(tcp)
376struct 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 Akkerman76baf7c1999-02-19 00:21:36 +0000392int
393internal_fork(tcp)
394struct 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 Akkerman2e4ffe52000-09-03 23:57:48 +0000416 if (proc_open(tcpchild, 2) < 0)
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000417 droptcb(tcpchild);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000418 }
419 return 0;
420}
421
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000422#else /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000423
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000424#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
439static 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 Akkerman8b1b40c2000-02-03 21:58:30 +0000451int
452sys_clone(tcp)
453struct 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 Akkerman7b3346b2001-10-09 23:47:38 +0000463int
464sys_clone2(tcp)
465struct 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 Akkerman7a0b6491999-12-23 15:08:17 +0000476#endif
477
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000478int
479sys_fork(tcp)
480struct tcb *tcp;
481{
482 if (exiting(tcp))
483 return RVAL_UDECIMAL;
484 return 0;
485}
486
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000487int
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000488change_syscall(tcp, new)
489struct tcb *tcp;
490int 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 Akkerman5c4c69b2001-04-12 09:00:47 +0000499 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R0), new) < 0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000500 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 Akkermanc7926982000-04-10 22:22:31 +0000509 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_ORIG_D0), new)<0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000510 return -1;
511 return 0;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000512#elif defined(SPARC)
Wichert Akkerman00a82ee2001-03-28 20:29:17 +0000513 struct regs regs;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000514 if (ptrace(PTRACE_GETREGS, tcp->pid, (char*)&regs, 0)<0)
515 return -1;
Wichert Akkerman00a82ee2001-03-28 20:29:17 +0000516 regs.r_g1=new;
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000517 if (ptrace(PTRACE_SETREGS, tcp->pid, (char*)&regs, 0)<0)
518 return -1;
519 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000520#elif defined(MIPS)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000521 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new)<0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000522 return -1;
523 return 0;
524#elif defined(ALPHA)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000525 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new)<0)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000526 return -1;
527 return 0;
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000528#elif defined(IA64)
529 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_R15), new)<0)
530 return -1;
531 return 0;
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000532#elif defined(HPPA)
533 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GR20), new)<0)
534 return -1;
535 return 0;
Wichert Akkermanccef6372002-05-01 16:39:22 +0000536#elif defined(SH)
537 if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_SYSCALL), new)<0)
538 return -1;
539 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000540#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
547int
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000548setarg(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 Akkerman7b3346b2001-10-09 23:47:38 +0000561 ptrace(PTRACE_POKEDATA, tcp->pid, (char *) ap, tcp->u_arg[argnum]);
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000562 if (errno)
563 return -1;
564
565 }
Wichert Akkerman12f75d12000-02-14 16:23:40 +0000566#elif defined(I386)
567 {
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000568 ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*argnum), tcp->u_arg[argnum]);
Wichert Akkerman12f75d12000-02-14 16:23:40 +0000569 if (errno)
570 return -1;
571 }
Ralf Baechlee3816102000-08-01 00:06:06 +0000572#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 Akkerman8b1b40c2000-02-03 21:58:30 +0000590#else
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000591# warning Sorry, setargs not implemented for this architecture.
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000592#endif
593 return 0;
594}
595
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000596#ifdef SYS_clone
597int
598internal_clone(tcp)
599struct tcb *tcp;
600{
Ulrich Drepper90512f01999-12-24 07:22:25 +0000601 struct tcb *tcpchild;
602 int pid;
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000603 if (entering(tcp)) {
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000604 if (!followfork)
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000605 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 Akkerman9b0c31d2000-09-03 21:56:29 +0000613
614 if (setbpt(tcp) < 0)
615 return 0;
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000616 } else {
Wichert Akkerman9b0c31d2000-09-03 21:56:29 +0000617 int bpt = tcp->flags & TCB_BPTSET;
618
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000619 if (!(tcp->flags & TCB_FOLLOWFORK))
620 return 0;
621
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000622 if (syserror(tcp)) {
623 if (bpt)
624 clearbpt(tcp);
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000625 return 0;
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000626 }
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000627
628 pid = tcp->u_rval;
629 if ((tcpchild = alloctcb(pid)) == NULL) {
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000630 if (bpt)
631 clearbpt(tcp);
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000632 fprintf(stderr, " [tcb table full]\n");
633 kill(pid, SIGKILL); /* XXX */
634 return 0;
635 }
636
Wichert Akkerman9b0c31d2000-09-03 21:56:29 +0000637 /* Attach to the new child */
638 if (ptrace(PTRACE_ATTACH, pid, (char *) 1, 0) < 0) {
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000639 if (bpt)
640 clearbpt(tcp);
Wichert Akkerman9b0c31d2000-09-03 21:56:29 +0000641 perror("PTRACE_ATTACH");
642 fprintf(stderr, "Too late?\n");
643 droptcb(tcpchild);
644 return 0;
645 }
646
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000647 if (bpt)
648 clearbpt(tcp);
649
Ulrich Drepper90512f01999-12-24 07:22:25 +0000650 tcpchild->flags |= TCB_ATTACHED;
Wichert Akkerman9b0c31d2000-09-03 21:56:29 +0000651 if (bpt) {
652 tcpchild->flags |= TCB_BPTSET;
653 tcpchild->baddr = tcp->baddr;
654 memcpy(tcpchild->inst, tcp->inst,
655 sizeof tcpchild->inst);
656 }
Ulrich Drepper90512f01999-12-24 07:22:25 +0000657 newoutf(tcpchild);
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000658 tcpchild->parent = tcp;
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000659 tcp->nchildren++;
660 if (!qflag)
661 fprintf(stderr, "Process %d attached\n", pid);
662 }
663 return 0;
664}
665#endif
666
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000667int
668internal_fork(tcp)
669struct tcb *tcp;
670{
671 struct tcb *tcpchild;
672 int pid;
Nate Sammonsccd8f211999-03-29 22:57:54 +0000673 int dont_follow = 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000674
675#ifdef SYS_vfork
Nate Sammonsccd8f211999-03-29 22:57:54 +0000676 if (tcp->scno == SYS_vfork) {
Nate Sammonsccd8f211999-03-29 22:57:54 +0000677 /* Attempt to make vfork into fork, which we can follow. */
678 if (!followvfork ||
Pavel Machek9a9f10b2000-02-01 16:22:52 +0000679 change_syscall(tcp, SYS_fork) < 0)
Nate Sammonsccd8f211999-03-29 22:57:54 +0000680 dont_follow = 1;
Nate Sammonsccd8f211999-03-29 22:57:54 +0000681 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000682#endif
683 if (entering(tcp)) {
Nate Sammonsccd8f211999-03-29 22:57:54 +0000684 if (!followfork || dont_follow)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000685 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 Akkerman7a0b6491999-12-23 15:08:17 +0000694 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000695 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 Akkermanc1652e22001-03-27 12:17:16 +0000713#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 Akkerman76baf7c1999-02-19 00:21:36 +0000731 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 Akkermanbf79f2e2000-09-01 21:03:06 +0000786#endif /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000787
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000788#if defined(SUNOS4) || defined(LINUX) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000789
790int
791sys_vfork(tcp)
792struct tcb *tcp;
793{
794 if (exiting(tcp))
795 return RVAL_UDECIMAL;
796 return 0;
797}
798
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000799#endif /* SUNOS4 || LINUX || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000800
801#ifndef LINUX
802
803static char idstr[16];
804
805int
806sys_getpid(tcp)
807struct 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
817int
818sys_getuid(tcp)
819struct 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
829int
830sys_getgid(tcp)
831struct 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
845int
846sys_setuid(tcp)
847struct tcb *tcp;
848{
849 if (entering(tcp)) {
850 tprintf("%u", (uid_t) tcp->u_arg[0]);
851 }
852 return 0;
853}
854
855int
856sys_setgid(tcp)
857struct tcb *tcp;
858{
859 if (entering(tcp)) {
860 tprintf("%u", (gid_t) tcp->u_arg[0]);
861 }
862 return 0;
863}
864
865int
866sys_getresuid(tcp)
867 struct tcb *tcp;
868{
869 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000870 __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 Akkerman76baf7c1999-02-19 00:21:36 +0000888 }
889 return 0;
890}
891
892int
893sys_getresgid(tcp)
894struct tcb *tcp;
895{
896 if (exiting(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000897 __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 Akkerman76baf7c1999-02-19 00:21:36 +0000915 }
916 return 0;
917}
918
919#endif /* LINUX */
920
921int
922sys_setreuid(tcp)
923struct 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
933int
934sys_setregid(tcp)
935struct 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 Akkermanbf79f2e2000-09-01 21:03:06 +0000945#if defined(LINUX) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000946int
947sys_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}
958int
959sys_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 Akkermanbf79f2e2000-09-01 21:03:06 +0000971#endif /* LINUX || FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000972
973int
974sys_setgroups(tcp)
975struct 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
1009int
1010sys_getgroups(tcp)
1011struct 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
1049int
1050sys_setpgrp(tcp)
1051struct 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
1061int
1062sys_getpgrp(tcp)
1063struct 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
1073int
1074sys_getsid(tcp)
1075struct tcb *tcp;
1076{
1077 if (entering(tcp)) {
1078 tprintf("%lu", tcp->u_arg[0]);
1079 }
1080 return 0;
1081}
1082
1083int
1084sys_setsid(tcp)
1085struct tcb *tcp;
1086{
1087 return 0;
1088}
1089
1090int
1091sys_getpgid(tcp)
1092struct tcb *tcp;
1093{
1094 if (entering(tcp)) {
1095 tprintf("%lu", tcp->u_arg[0]);
1096 }
1097 return 0;
1098}
1099
1100int
1101sys_setpgid(tcp)
1102struct 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
1110void
1111fake_execve(tcp, program, argv, envp)
1112struct tcb *tcp;
1113char *program;
1114char *argv[];
1115char *envp[];
1116{
1117 int i;
1118
1119#ifdef ARM
1120 if (!(qual_flags[SYS_execve - __NR_SYSCALL_BASE] & QUAL_TRACE))
1121 return;
1122#else
1123 if (!(qual_flags[SYS_execve] & QUAL_TRACE))
1124 return;
1125#endif /* !ARM */
1126 printleader(tcp);
1127 tprintf("execve(");
1128 string_quote(program);
1129 tprintf(", [");
1130 for (i = 0; argv[i] != NULL; i++) {
1131 if (i != 0)
1132 tprintf(", ");
1133 string_quote(argv[i]);
1134 }
1135 for (i = 0; envp[i] != NULL; i++)
1136 ;
1137 tprintf("], [/* %d var%s */]) ", i, (i != 1) ? "s" : "");
1138 tabto(acolumn);
1139 tprintf("= 0");
1140 printtrailer(tcp);
1141}
1142
1143static void
1144printargv(tcp, addr)
1145struct tcb *tcp;
1146long addr;
1147{
1148 char *cp;
1149 char *sep;
1150 int max = max_strlen / 2;
1151
1152 for (sep = ""; --max >= 0; sep = ", ") {
1153 if (!abbrev(tcp))
1154 max++;
1155 if (umove(tcp, addr, &cp) < 0) {
1156 tprintf("%#lx", addr);
1157 return;
1158 }
1159 if (cp == 0)
1160 break;
1161 tprintf(sep);
1162 printstr(tcp, (long) cp, -1);
1163 addr += sizeof(char *);
1164 }
1165 if (cp)
1166 tprintf(", ...");
1167}
1168
1169static void
1170printargc(fmt, tcp, addr)
1171char *fmt;
1172struct tcb *tcp;
1173long addr;
1174{
1175 int count;
1176 char *cp;
1177
1178 for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
1179 addr += sizeof(char *);
1180 }
1181 tprintf(fmt, count, count == 1 ? "" : "s");
1182}
1183
1184int
1185sys_execv(tcp)
1186struct tcb *tcp;
1187{
1188 if (entering(tcp)) {
1189 printpath(tcp, tcp->u_arg[0]);
1190 if (!verbose(tcp))
1191 tprintf(", %#lx", tcp->u_arg[1]);
1192#if 0
1193 else if (abbrev(tcp))
1194 printargc(", [/* %d arg%s */]", tcp, tcp->u_arg[1]);
1195#endif
1196 else {
1197 tprintf(", [");
1198 printargv(tcp, tcp->u_arg[1]);
1199 tprintf("]");
1200 }
1201 }
1202 return 0;
1203}
1204
1205int
1206sys_execve(tcp)
1207struct tcb *tcp;
1208{
1209 if (entering(tcp)) {
1210 printpath(tcp, tcp->u_arg[0]);
1211 if (!verbose(tcp))
1212 tprintf(", %#lx", tcp->u_arg[1]);
1213#if 0
1214 else if (abbrev(tcp))
1215 printargc(", [/* %d arg%s */]", tcp, tcp->u_arg[1]);
1216#endif
1217 else {
1218 tprintf(", [");
1219 printargv(tcp, tcp->u_arg[1]);
1220 tprintf("]");
1221 }
1222 if (!verbose(tcp))
1223 tprintf(", %#lx", tcp->u_arg[2]);
1224 else if (abbrev(tcp))
1225 printargc(", [/* %d var%s */]", tcp, tcp->u_arg[2]);
1226 else {
1227 tprintf(", [");
1228 printargv(tcp, tcp->u_arg[2]);
1229 tprintf("]");
1230 }
1231 }
1232#ifdef LINUX
Wichert Akkermanccef6372002-05-01 16:39:22 +00001233#if defined(ALPHA) || defined(SPARC) || defined(POWERPC) || defined(IA64) || defined(HPPA) || defined(SH)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001234 tcp->flags |= TCB_WAITEXECVE;
Wichert Akkermanccef6372002-05-01 16:39:22 +00001235#endif /* ALPHA || SPARC || POWERPC || IA64 || HPPA || SH */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001236#endif /* LINUX */
1237 return 0;
1238}
1239
John Hughes4e36a812001-04-18 15:11:51 +00001240#if UNIXWARE > 2
1241
1242int sys_rexecve(tcp)
1243struct tcb *tcp;
1244{
1245 if (entering (tcp)) {
1246 sys_execve (tcp);
1247 tprintf (", %ld", tcp->u_arg[3]);
1248 }
1249 return 0;
1250}
1251
1252#endif
1253
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001254int
1255internal_exec(tcp)
1256struct tcb *tcp;
1257{
1258#ifdef SUNOS4
1259 if (exiting(tcp) && !syserror(tcp) && followfork)
1260 fixvfork(tcp);
1261#endif /* SUNOS4 */
1262 return 0;
1263}
1264
1265#ifdef LINUX
1266#ifndef __WCLONE
1267#define __WCLONE 0x8000000
1268#endif
1269#endif /* LINUX */
1270
1271static struct xlat wait4_options[] = {
1272 { WNOHANG, "WNOHANG" },
1273#ifndef WSTOPPED
1274 { WUNTRACED, "WUNTRACED" },
1275#endif
1276#ifdef WEXITED
1277 { WEXITED, "WEXITED" },
1278#endif
1279#ifdef WTRAPPED
1280 { WTRAPPED, "WTRAPPED" },
1281#endif
1282#ifdef WSTOPPED
1283 { WSTOPPED, "WSTOPPED" },
1284#endif
1285#ifdef WCONTINUED
1286 { WCONTINUED, "WCONTINUED" },
1287#endif
1288#ifdef WNOWAIT
1289 { WNOWAIT, "WNOWAIT" },
1290#endif
1291#ifdef __WCLONE
1292 { __WCLONE, "__WCLONE" },
1293#endif
1294 { 0, NULL },
1295};
1296
1297static int
1298printstatus(status)
1299int status;
1300{
1301 int exited = 0;
1302
1303 /*
1304 * Here is a tricky presentation problem. This solution
1305 * is still not entirely satisfactory but since there
1306 * are no wait status constructors it will have to do.
1307 */
1308 if (WIFSTOPPED(status))
1309 tprintf("[WIFSTOPPED(s) && WSTOPSIG(s) == %s]",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001310 signame(WSTOPSIG(status)));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001311 else if WIFSIGNALED(status)
1312 tprintf("[WIFSIGNALED(s) && WTERMSIG(s) == %s%s]",
Nate Sammonsce780fc1999-03-29 23:23:13 +00001313 signame(WTERMSIG(status)),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001314 WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
1315 else if WIFEXITED(status) {
1316 tprintf("[WIFEXITED(s) && WEXITSTATUS(s) == %d]",
1317 WEXITSTATUS(status));
1318 exited = 1;
1319 }
1320 else
1321 tprintf("[%#x]", status);
1322 return exited;
1323}
1324
1325static int
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001326printwaitn(tcp, n, bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001327struct tcb *tcp;
1328int n;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001329int bitness;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001330{
1331 int status;
1332 int exited = 0;
1333
1334 if (entering(tcp)) {
1335 tprintf("%ld, ", tcp->u_arg[0]);
1336 } else {
1337 /* status */
1338 if (!tcp->u_arg[1])
1339 tprintf("NULL");
1340 else if (syserror(tcp) || tcp->u_rval == 0)
1341 tprintf("%#lx", tcp->u_arg[1]);
1342 else if (umove(tcp, tcp->u_arg[1], &status) < 0)
1343 tprintf("[?]");
1344 else
1345 exited = printstatus(status);
1346 /* options */
1347 tprintf(", ");
1348 if (!printflags(wait4_options, tcp->u_arg[2]))
1349 tprintf("0");
1350 if (n == 4) {
1351 tprintf(", ");
1352 /* usage */
1353 if (!tcp->u_arg[3])
1354 tprintf("NULL");
1355#ifdef LINUX
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001356 else if (tcp->u_rval > 0) {
1357#ifdef LINUX_64BIT
1358 if (bitness)
1359 printrusage32(tcp, tcp->u_arg[3]);
1360 else
1361#endif
1362 printrusage(tcp, tcp->u_arg[3]);
1363 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001364#endif /* LINUX */
1365#ifdef SUNOS4
1366 else if (tcp->u_rval > 0 && exited)
1367 printrusage(tcp, tcp->u_arg[3]);
1368#endif /* SUNOS4 */
1369 else
1370 tprintf("%#lx", tcp->u_arg[3]);
1371 }
1372 }
1373 return 0;
1374}
1375
1376int
1377internal_wait(tcp)
1378struct tcb *tcp;
1379{
1380 if (entering(tcp)) {
Wichert Akkerman5daa0281999-03-15 19:49:42 +00001381 /* WTA: fix bug with hanging children */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001382 if (!(tcp->u_arg[2] & WNOHANG) && tcp->nchildren > 0) {
1383 /* There are traced children */
1384 tcp->flags |= TCB_SUSPENDED;
1385 tcp->waitpid = tcp->u_arg[0];
1386 }
1387 }
1388 return 0;
1389}
1390
1391#ifdef SVR4
1392
1393int
1394sys_wait(tcp)
1395struct tcb *tcp;
1396{
1397 if (exiting(tcp)) {
1398 /* The library wrapper stuffs this into the user variable. */
1399 if (!syserror(tcp))
1400 printstatus(getrval2(tcp));
1401 }
1402 return 0;
1403}
1404
1405#endif /* SVR4 */
1406
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001407#ifdef FREEBSD
1408int
1409sys_wait(tcp)
1410struct tcb *tcp;
1411{
1412 int status;
1413
1414 if (exiting(tcp)) {
1415 if (!syserror(tcp)) {
1416 if (umove(tcp, tcp->u_arg[0], &status) < 0)
1417 tprintf("%#lx", tcp->u_arg[0]);
1418 else
1419 printstatus(status);
1420 }
1421 }
1422 return 0;
1423}
1424#endif
1425
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001426int
1427sys_waitpid(tcp)
1428struct tcb *tcp;
1429{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001430 return printwaitn(tcp, 3, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001431}
1432
1433int
1434sys_wait4(tcp)
1435struct tcb *tcp;
1436{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001437 return printwaitn(tcp, 4, 0);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001438}
1439
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001440#ifdef ALPHA
1441int
1442sys_osf_wait4(tcp)
1443struct tcb *tcp;
1444{
1445 return printwaitn(tcp, 4, 1);
1446}
1447#endif
1448
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001449#ifdef SVR4
1450
1451static struct xlat waitid_types[] = {
1452 { P_PID, "P_PID" },
1453 { P_PPID, "P_PPID" },
1454 { P_PGID, "P_PGID" },
1455 { P_SID, "P_SID" },
1456 { P_CID, "P_CID" },
1457 { P_UID, "P_UID" },
1458 { P_GID, "P_GID" },
1459 { P_ALL, "P_ALL" },
1460#ifdef P_LWPID
1461 { P_LWPID, "P_LWPID" },
1462#endif
1463 { 0, NULL },
1464};
1465
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001466int
1467sys_waitid(tcp)
1468struct tcb *tcp;
1469{
1470 siginfo_t si;
1471 int exited;
1472
1473 if (entering(tcp)) {
1474 printxval(waitid_types, tcp->u_arg[0], "P_???");
1475 tprintf(", %ld, ", tcp->u_arg[1]);
1476 if (tcp->nchildren > 0) {
1477 /* There are traced children */
1478 tcp->flags |= TCB_SUSPENDED;
1479 tcp->waitpid = tcp->u_arg[0];
1480 }
1481 }
1482 else {
1483 /* siginfo */
1484 exited = 0;
1485 if (!tcp->u_arg[2])
1486 tprintf("NULL");
1487 else if (syserror(tcp))
1488 tprintf("%#lx", tcp->u_arg[2]);
1489 else if (umove(tcp, tcp->u_arg[2], &si) < 0)
1490 tprintf("{???}");
1491 else
John Hughes58265892001-10-18 15:13:53 +00001492 printsiginfo(&si, verbose (tcp));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001493 /* options */
1494 tprintf(", ");
1495 if (!printflags(wait4_options, tcp->u_arg[3]))
1496 tprintf("0");
1497 }
1498 return 0;
1499}
1500
1501#endif /* SVR4 */
1502
1503int
1504sys_alarm(tcp)
1505struct tcb *tcp;
1506{
1507 if (entering(tcp))
1508 tprintf("%lu", tcp->u_arg[0]);
1509 return 0;
1510}
1511
1512int
1513sys_uname(tcp)
1514struct tcb *tcp;
1515{
1516 struct utsname uname;
1517
1518 if (exiting(tcp)) {
1519 if (syserror(tcp) || !verbose(tcp))
1520 tprintf("%#lx", tcp->u_arg[0]);
1521 else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
1522 tprintf("{...}");
1523 else if (!abbrev(tcp)) {
1524
1525 tprintf("{sysname=\"%s\", nodename=\"%s\", ",
1526 uname.sysname, uname.nodename);
1527 tprintf("release=\"%s\", version=\"%s\", ",
1528 uname.release, uname.version);
1529 tprintf("machine=\"%s\"", uname.machine);
1530#ifdef LINUX
1531#ifndef __GLIBC__
1532 tprintf(", domainname=\"%s\"", uname.domainname);
1533#endif /* __GLIBC__ */
1534#endif /* LINUX */
1535 tprintf("}");
1536 }
1537 else
1538 tprintf("{sys=\"%s\", node=\"%s\", ...}",
1539 uname.sysname, uname.nodename);
1540 }
1541 return 0;
1542}
1543
1544#ifndef SVR4
1545
1546static struct xlat ptrace_cmds[] = {
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001547#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001548 { PTRACE_TRACEME, "PTRACE_TRACEME" },
1549 { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT", },
1550 { PTRACE_PEEKDATA, "PTRACE_PEEKDATA", },
1551 { PTRACE_PEEKUSER, "PTRACE_PEEKUSER", },
1552 { PTRACE_POKETEXT, "PTRACE_POKETEXT", },
1553 { PTRACE_POKEDATA, "PTRACE_POKEDATA", },
1554 { PTRACE_POKEUSER, "PTRACE_POKEUSER", },
1555 { PTRACE_CONT, "PTRACE_CONT" },
1556 { PTRACE_KILL, "PTRACE_KILL" },
1557 { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
1558 { PTRACE_ATTACH, "PTRACE_ATTACH" },
1559 { PTRACE_DETACH, "PTRACE_DETACH" },
1560#ifdef SUNOS4
1561 { PTRACE_GETREGS, "PTRACE_GETREGS" },
1562 { PTRACE_SETREGS, "PTRACE_SETREGS" },
1563 { PTRACE_GETFPREGS, "PTRACE_GETFPREGS", },
1564 { PTRACE_SETFPREGS, "PTRACE_SETFPREGS", },
1565 { PTRACE_READDATA, "PTRACE_READDATA" },
1566 { PTRACE_WRITEDATA, "PTRACE_WRITEDATA" },
1567 { PTRACE_READTEXT, "PTRACE_READTEXT" },
1568 { PTRACE_WRITETEXT, "PTRACE_WRITETEXT" },
1569 { PTRACE_GETFPAREGS, "PTRACE_GETFPAREGS" },
1570 { PTRACE_SETFPAREGS, "PTRACE_SETFPAREGS" },
1571#ifdef SPARC
1572 { PTRACE_GETWINDOW, "PTRACE_GETWINDOW" },
1573 { PTRACE_SETWINDOW, "PTRACE_SETWINDOW" },
1574#else /* !SPARC */
1575 { PTRACE_22, "PTRACE_PTRACE_22" },
1576 { PTRACE_23, "PTRACE_PTRACE_23" },
1577#endif /* !SPARC */
1578#endif /* SUNOS4 */
1579 { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
1580#ifdef SUNOS4
1581 { PTRACE_DUMPCORE, "PTRACE_DUMPCORE" },
1582#ifdef I386
1583 { PTRACE_SETWRBKPT, "PTRACE_SETWRBKPT" },
1584 { PTRACE_SETACBKPT, "PTRACE_SETACBKPT" },
1585 { PTRACE_CLRDR7, "PTRACE_CLRDR7" },
1586#else /* !I386 */
1587 { PTRACE_26, "PTRACE_26" },
1588 { PTRACE_27, "PTRACE_27" },
1589 { PTRACE_28, "PTRACE_28" },
1590#endif /* !I386 */
1591 { PTRACE_GETUCODE, "PTRACE_GETUCODE" },
1592#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001593#else /* FREEBSD */
1594 { PT_TRACE_ME, "PT_TRACE_ME" },
1595 { PT_READ_I, "PT_READ_I" },
1596 { PT_READ_D, "PT_READ_D" },
1597 { PT_WRITE_I, "PT_WRITE_I" },
1598 { PT_WRITE_D, "PT_WRITE_D" },
John Hughesa2278142001-09-28 16:21:30 +00001599#ifdef PT_READ_U
1600 { PT_READ_U, "PT_READ_U" },
1601#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001602 { PT_CONTINUE, "PT_CONTINUE" },
1603 { PT_KILL, "PT_KILL" },
1604 { PT_STEP, "PT_STEP" },
1605 { PT_ATTACH, "PT_ATTACH" },
1606 { PT_DETACH, "PT_DETACH" },
1607 { PT_GETREGS, "PT_GETREGS" },
1608 { PT_SETREGS, "PT_SETREGS" },
1609 { PT_GETFPREGS, "PT_GETFPREGS" },
1610 { PT_SETFPREGS, "PT_SETFPREGS" },
1611 { PT_GETDBREGS, "PT_GETDBREGS" },
1612 { PT_SETDBREGS, "PT_SETDBREGS" },
1613#endif /* FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001614 { 0, NULL },
1615};
1616
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00001617#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001618#ifndef SUNOS4_KERNEL_ARCH_KLUDGE
1619static
1620#endif /* !SUNOS4_KERNEL_ARCH_KLUDGE */
1621struct xlat struct_user_offsets[] = {
1622#ifdef LINUX
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001623#ifdef S390
1624 { PT_PSWMASK, "psw_mask" },
1625 { PT_PSWADDR, "psw_addr" },
1626 { PT_GPR0, "gpr0" },
1627 { PT_GPR1, "gpr1" },
1628 { PT_GPR2, "gpr2" },
1629 { PT_GPR3, "gpr3" },
1630 { PT_GPR4, "gpr4" },
1631 { PT_GPR5, "gpr5" },
1632 { PT_GPR6, "gpr6" },
1633 { PT_GPR7, "gpr7" },
1634 { PT_GPR8, "gpr8" },
1635 { PT_GPR9, "gpr9" },
1636 { PT_GPR10, "gpr10" },
1637 { PT_GPR11, "gpr11" },
1638 { PT_GPR12, "gpr12" },
1639 { PT_GPR13, "gpr13" },
1640 { PT_GPR14, "gpr14" },
1641 { PT_GPR15, "gpr15" },
1642 { PT_ACR0, "acr0" },
1643 { PT_ACR1, "acr1" },
1644 { PT_ACR2, "acr2" },
1645 { PT_ACR3, "acr3" },
1646 { PT_ACR4, "acr4" },
1647 { PT_ACR5, "acr5" },
1648 { PT_ACR6, "acr6" },
1649 { PT_ACR7, "acr7" },
1650 { PT_ACR8, "acr8" },
1651 { PT_ACR9, "acr9" },
1652 { PT_ACR10, "acr10" },
1653 { PT_ACR11, "acr11" },
1654 { PT_ACR12, "acr12" },
1655 { PT_ACR13, "acr13" },
1656 { PT_ACR14, "acr14" },
1657 { PT_ACR15, "acr15" },
1658 { PT_ORIGGPR2, "orig_gpr2" },
1659 { PT_FPC, "fpc" },
1660 { PT_FPR0_HI, "fpr0.hi" },
1661 { PT_FPR0_LO, "fpr0.lo" },
1662 { PT_FPR1_HI, "fpr1.hi" },
1663 { PT_FPR1_LO, "fpr1.lo" },
1664 { PT_FPR2_HI, "fpr2.hi" },
1665 { PT_FPR2_LO, "fpr2.lo" },
1666 { PT_FPR3_HI, "fpr3.hi" },
1667 { PT_FPR3_LO, "fpr3.lo" },
1668 { PT_FPR4_HI, "fpr4.hi" },
1669 { PT_FPR4_LO, "fpr4.lo" },
1670 { PT_FPR5_HI, "fpr5.hi" },
1671 { PT_FPR5_LO, "fpr5.lo" },
1672 { PT_FPR6_HI, "fpr6.hi" },
1673 { PT_FPR6_LO, "fpr6.lo" },
1674 { PT_FPR7_HI, "fpr7.hi" },
1675 { PT_FPR7_LO, "fpr7.lo" },
1676 { PT_FPR8_HI, "fpr8.hi" },
1677 { PT_FPR8_LO, "fpr8.lo" },
1678 { PT_FPR9_HI, "fpr9.hi" },
1679 { PT_FPR9_LO, "fpr9.lo" },
1680 { PT_FPR10_HI, "fpr10.hi" },
1681 { PT_FPR10_LO, "fpr10.lo" },
1682 { PT_FPR11_HI, "fpr11.hi" },
1683 { PT_FPR11_LO, "fpr11.lo" },
1684 { PT_FPR12_HI, "fpr12.hi" },
1685 { PT_FPR12_LO, "fpr12.lo" },
1686 { PT_FPR13_HI, "fpr13.hi" },
1687 { PT_FPR13_LO, "fpr13.lo" },
1688 { PT_FPR14_HI, "fpr14.hi" },
1689 { PT_FPR14_LO, "fpr14.lo" },
1690 { PT_FPR15_HI, "fpr15.hi" },
1691 { PT_FPR15_LO, "fpr15.lo" },
1692 { PT_CR_9, "cr9" },
1693 { PT_CR_10, "cr10" },
1694 { PT_CR_11, "cr11" },
1695#endif
1696#if defined(SPARC)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001697 /* XXX No support for these offsets yet. */
Wichert Akkermanc1652e22001-03-27 12:17:16 +00001698#elif defined(HPPA)
1699 /* XXX No support for these offsets yet. */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001700#elif defined(POWERPC)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001701 { 4*PT_R0, "4*PT_R0" },
1702 { 4*PT_R1, "4*PT_R1" },
1703 { 4*PT_R2, "4*PT_R2" },
1704 { 4*PT_R3, "4*PT_R3" },
1705 { 4*PT_R4, "4*PT_R4" },
1706 { 4*PT_R5, "4*PT_R5" },
1707 { 4*PT_R6, "4*PT_R6" },
1708 { 4*PT_R7, "4*PT_R7" },
1709 { 4*PT_R8, "4*PT_R8" },
1710 { 4*PT_R9, "4*PT_R9" },
1711 { 4*PT_R10, "4*PT_R10" },
1712 { 4*PT_R11, "4*PT_R11" },
1713 { 4*PT_R12, "4*PT_R12" },
1714 { 4*PT_R13, "4*PT_R13" },
1715 { 4*PT_R14, "4*PT_R14" },
1716 { 4*PT_R15, "4*PT_R15" },
1717 { 4*PT_R16, "4*PT_R16" },
1718 { 4*PT_R17, "4*PT_R17" },
1719 { 4*PT_R18, "4*PT_R18" },
1720 { 4*PT_R19, "4*PT_R19" },
1721 { 4*PT_R20, "4*PT_R20" },
1722 { 4*PT_R21, "4*PT_R21" },
1723 { 4*PT_R22, "4*PT_R22" },
1724 { 4*PT_R23, "4*PT_R23" },
1725 { 4*PT_R24, "4*PT_R24" },
1726 { 4*PT_R25, "4*PT_R25" },
1727 { 4*PT_R26, "4*PT_R26" },
1728 { 4*PT_R27, "4*PT_R27" },
1729 { 4*PT_R28, "4*PT_R28" },
1730 { 4*PT_R29, "4*PT_R29" },
1731 { 4*PT_R30, "4*PT_R30" },
1732 { 4*PT_R31, "4*PT_R31" },
1733 { 4*PT_NIP, "4*PT_NIP" },
1734 { 4*PT_MSR, "4*PT_MSR" },
1735 { 4*PT_ORIG_R3, "4*PT_ORIG_R3" },
1736 { 4*PT_CTR, "4*PT_CTR" },
1737 { 4*PT_LNK, "4*PT_LNK" },
1738 { 4*PT_XER, "4*PT_XER" },
1739 { 4*PT_CCR, "4*PT_CCR" },
1740 { 4*PT_FPR0, "4*PT_FPR0" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001741#else
1742#ifdef ALPHA
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001743 { 0, "r0" },
1744 { 1, "r1" },
1745 { 2, "r2" },
1746 { 3, "r3" },
1747 { 4, "r4" },
1748 { 5, "r5" },
1749 { 6, "r6" },
1750 { 7, "r7" },
1751 { 8, "r8" },
1752 { 9, "r9" },
1753 { 10, "r10" },
1754 { 11, "r11" },
1755 { 12, "r12" },
1756 { 13, "r13" },
1757 { 14, "r14" },
1758 { 15, "r15" },
1759 { 16, "r16" },
1760 { 17, "r17" },
1761 { 18, "r18" },
1762 { 19, "r19" },
1763 { 20, "r20" },
1764 { 21, "r21" },
1765 { 22, "r22" },
1766 { 23, "r23" },
1767 { 24, "r24" },
1768 { 25, "r25" },
1769 { 26, "r26" },
1770 { 27, "r27" },
1771 { 28, "r28" },
1772 { 29, "gp" },
1773 { 30, "fp" },
1774 { 31, "zero" },
1775 { 32, "fp0" },
1776 { 33, "fp" },
1777 { 34, "fp2" },
1778 { 35, "fp3" },
1779 { 36, "fp4" },
1780 { 37, "fp5" },
1781 { 38, "fp6" },
1782 { 39, "fp7" },
1783 { 40, "fp8" },
1784 { 41, "fp9" },
1785 { 42, "fp10" },
1786 { 43, "fp11" },
1787 { 44, "fp12" },
1788 { 45, "fp13" },
1789 { 46, "fp14" },
1790 { 47, "fp15" },
1791 { 48, "fp16" },
1792 { 49, "fp17" },
1793 { 50, "fp18" },
1794 { 51, "fp19" },
1795 { 52, "fp20" },
1796 { 53, "fp21" },
1797 { 54, "fp22" },
1798 { 55, "fp23" },
1799 { 56, "fp24" },
1800 { 57, "fp25" },
1801 { 58, "fp26" },
1802 { 59, "fp27" },
1803 { 60, "fp28" },
1804 { 61, "fp29" },
1805 { 62, "fp30" },
1806 { 63, "fp31" },
1807 { 64, "pc" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001808#else /* !ALPHA */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001809#ifdef IA64
1810 { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
1811 { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
1812 { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
1813 { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
1814 { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
1815 { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
1816 { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
1817 { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
1818 { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
1819 { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
1820 { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
1821 { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
1822 { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
1823 { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
1824 { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
1825 { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
1826 { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
1827 { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
1828 { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
1829 { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
1830 { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
1831 { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
1832 { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
1833 { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
1834 { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
1835 { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
1836 { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
1837 { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
1838 { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
1839 { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
1840 { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
1841 { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
1842 /* switch stack: */
1843 { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
1844 { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
1845 { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
1846 { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
1847 { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
1848 { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
1849 { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
1850 { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
1851 { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
1852 { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
Wichert Akkerman82b162e2001-08-03 11:51:28 +00001853 { PT_B0, "kb0" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001854 { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
1855 { PT_B4, "b4" }, { PT_B5, "b5" },
Wichert Akkerman82b162e2001-08-03 11:51:28 +00001856 { PT_AR_PFS, "kar.pfs" },
1857 { PT_AR_LC, "ar.lc" }, { PT_AR_UNAT, "kar.unat" },
1858 { PT_AR_RNAT, "kar.rnat" }, { PT_AR_BSPSTORE, "kar.bspstore" },
1859 { PT_PR, "k.pr" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001860 /* pt_regs */
1861 { PT_CR_IPSR, "cr.ipsr" }, { PT_CR_IIP, "cr.iip" },
Wichert Akkerman82b162e2001-08-03 11:51:28 +00001862 /*{ PT_CR_IFS, "cr.ifs" },*/ { PT_AR_UNAT, "ar.unat" },
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00001863 { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
1864 { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
1865 { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
1866 { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
1867 { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
1868 { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
1869 { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
1870 { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
1871 { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
1872 { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
1873 { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
1874 { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
1875 { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
1876 { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
1877 { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
1878#else /* !IA64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001879#ifdef I386
1880 { 4*EBX, "4*EBX" },
1881 { 4*ECX, "4*ECX" },
1882 { 4*EDX, "4*EDX" },
1883 { 4*ESI, "4*ESI" },
1884 { 4*EDI, "4*EDI" },
1885 { 4*EBP, "4*EBP" },
1886 { 4*EAX, "4*EAX" },
1887 { 4*DS, "4*DS" },
1888 { 4*ES, "4*ES" },
1889 { 4*FS, "4*FS" },
1890 { 4*GS, "4*GS" },
1891 { 4*ORIG_EAX, "4*ORIG_EAX" },
1892 { 4*EIP, "4*EIP" },
1893 { 4*CS, "4*CS" },
1894 { 4*EFL, "4*EFL" },
1895 { 4*UESP, "4*UESP" },
1896 { 4*SS, "4*SS" },
1897#else /* !I386 */
1898#ifdef M68K
1899 { 4*PT_D1, "4*PT_D1" },
1900 { 4*PT_D2, "4*PT_D2" },
1901 { 4*PT_D3, "4*PT_D3" },
1902 { 4*PT_D4, "4*PT_D4" },
1903 { 4*PT_D5, "4*PT_D5" },
1904 { 4*PT_D6, "4*PT_D6" },
1905 { 4*PT_D7, "4*PT_D7" },
1906 { 4*PT_A0, "4*PT_A0" },
1907 { 4*PT_A1, "4*PT_A1" },
1908 { 4*PT_A2, "4*PT_A2" },
1909 { 4*PT_A3, "4*PT_A3" },
1910 { 4*PT_A4, "4*PT_A4" },
1911 { 4*PT_A5, "4*PT_A5" },
1912 { 4*PT_A6, "4*PT_A6" },
1913 { 4*PT_D0, "4*PT_D0" },
1914 { 4*PT_USP, "4*PT_USP" },
1915 { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
1916 { 4*PT_SR, "4*PT_SR" },
1917 { 4*PT_PC, "4*PT_PC" },
1918#endif /* M68K */
1919#endif /* !I386 */
Wichert Akkermanccef6372002-05-01 16:39:22 +00001920#ifdef SH
1921 { 4*REG_REG0, "4*REG_REG0" },
1922 { 4*(REG_REG0+1), "4*REG_REG1" },
1923 { 4*(REG_REG0+2), "4*REG_REG2" },
1924 { 4*(REG_REG0+3), "4*REG_REG3" },
1925 { 4*(REG_REG0+4), "4*REG_REG4" },
1926 { 4*(REG_REG0+5), "4*REG_REG5" },
1927 { 4*(REG_REG0+6), "4*REG_REG6" },
1928 { 4*(REG_REG0+7), "4*REG_REG7" },
1929 { 4*(REG_REG0+8), "4*REG_REG8" },
1930 { 4*(REG_REG0+9), "4*REG_REG9" },
1931 { 4*(REG_REG0+10), "4*REG_REG10" },
1932 { 4*(REG_REG0+11), "4*REG_REG11" },
1933 { 4*(REG_REG0+12), "4*REG_REG12" },
1934 { 4*(REG_REG0+13), "4*REG_REG13" },
1935 { 4*(REG_REG0+14), "4*REG_REG14" },
1936 { 4*REG_REG15, "4*REG_REG15" },
1937 { 4*REG_PC, "4*REG_PC" },
1938 { 4*REG_PR, "4*REG_PR" },
1939 { 4*REG_SR, "4*REG_SR" },
1940 { 4*REG_GBR, "4*REG_GBR" },
1941 { 4*REG_MACH, "4*REG_MACH" },
1942 { 4*REG_MACL, "4*REG_MACL" },
1943 { 4*REG_SYSCALL, "4*REG_SYSCALL" },
1944 { 4*REG_FPUL, "4*REG_FPUL" },
1945 { 4*REG_FPREG0, "4*REG_FPREG0" },
1946 { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
1947 { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
1948 { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
1949 { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
1950 { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
1951 { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
1952 { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
1953 { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
1954 { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
1955 { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
1956 { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
1957 { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
1958 { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
1959 { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
1960 { 4*REG_FPREG15, "4*REG_FPREG15" },
1961 { 4*REG_XDREG0, "4*REG_XDREG0" },
1962 { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
1963 { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
1964 { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
1965 { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
1966 { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
1967 { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
1968 { 4*REG_XDREG14, "4*REG_XDREG14" },
1969 { 4*REG_FPSCR, "4*REG_FPSCR" },
1970#endif /* SH */
1971
Wichert Akkerman12f75d12000-02-14 16:23:40 +00001972#if !defined(S390) && !defined(MIPS)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001973 { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
Wichert Akkermanf90da011999-10-31 21:15:38 +00001974#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001975#ifdef I386
1976 { uoff(i387), "offsetof(struct user, i387)" },
1977#else /* !I386 */
1978#ifdef M68K
1979 { uoff(m68kfp), "offsetof(struct user, m68kfp)" },
1980#endif /* M68K */
1981#endif /* !I386 */
1982 { uoff(u_tsize), "offsetof(struct user, u_tsize)" },
1983 { uoff(u_dsize), "offsetof(struct user, u_dsize)" },
1984 { uoff(u_ssize), "offsetof(struct user, u_ssize)" },
1985 { uoff(start_code), "offsetof(struct user, start_code)" },
1986 { uoff(start_stack), "offsetof(struct user, start_stack)" },
1987 { uoff(signal), "offsetof(struct user, signal)" },
Wichert Akkermanccef6372002-05-01 16:39:22 +00001988#if !defined(S390) && !defined(MIPS) && !defined(SH)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001989 { uoff(reserved), "offsetof(struct user, reserved)" },
Wichert Akkermanf90da011999-10-31 21:15:38 +00001990#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001991 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00001992#if !defined(ARM) && !defined(MIPS) && !defined(S390)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001993 { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
1994#endif
1995 { uoff(magic), "offsetof(struct user, magic)" },
1996 { uoff(u_comm), "offsetof(struct user, u_comm)" },
1997#ifdef I386
1998 { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
1999#endif /* I386 */
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +00002000#endif /* !IA64 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002001#endif /* !ALPHA */
2002#endif /* !POWERPC/!SPARC */
2003#endif /* LINUX */
2004#ifdef SUNOS4
2005 { uoff(u_pcb), "offsetof(struct user, u_pcb)" },
2006 { uoff(u_procp), "offsetof(struct user, u_procp)" },
2007 { uoff(u_ar0), "offsetof(struct user, u_ar0)" },
2008 { uoff(u_comm[0]), "offsetof(struct user, u_comm[0])" },
2009 { uoff(u_arg[0]), "offsetof(struct user, u_arg[0])" },
2010 { uoff(u_ap), "offsetof(struct user, u_ap)" },
2011 { uoff(u_qsave), "offsetof(struct user, u_qsave)" },
2012 { uoff(u_rval1), "offsetof(struct user, u_rval1)" },
2013 { uoff(u_rval2), "offsetof(struct user, u_rval2)" },
2014 { uoff(u_error), "offsetof(struct user, u_error)" },
2015 { uoff(u_eosys), "offsetof(struct user, u_eosys)" },
2016 { uoff(u_ssave), "offsetof(struct user, u_ssave)" },
2017 { uoff(u_signal[0]), "offsetof(struct user, u_signal)" },
2018 { uoff(u_sigmask[0]), "offsetof(struct user, u_sigmask)" },
2019 { uoff(u_sigonstack), "offsetof(struct user, u_sigonstack)" },
2020 { uoff(u_sigintr), "offsetof(struct user, u_sigintr)" },
2021 { uoff(u_sigreset), "offsetof(struct user, u_sigreset)" },
2022 { uoff(u_oldmask), "offsetof(struct user, u_oldmask)" },
2023 { uoff(u_code), "offsetof(struct user, u_code)" },
2024 { uoff(u_addr), "offsetof(struct user, u_addr)" },
2025 { uoff(u_sigstack), "offsetof(struct user, u_sigstack)" },
2026 { uoff(u_ofile), "offsetof(struct user, u_ofile)" },
2027 { uoff(u_pofile), "offsetof(struct user, u_pofile)" },
2028 { uoff(u_ofile_arr[0]), "offsetof(struct user, u_ofile_arr[0])" },
2029 { uoff(u_pofile_arr[0]),"offsetof(struct user, u_pofile_arr[0])"},
2030 { uoff(u_lastfile), "offsetof(struct user, u_lastfile)" },
2031 { uoff(u_cwd), "offsetof(struct user, u_cwd)" },
2032 { uoff(u_cdir), "offsetof(struct user, u_cdir)" },
2033 { uoff(u_rdir), "offsetof(struct user, u_rdir)" },
2034 { uoff(u_cmask), "offsetof(struct user, u_cmask)" },
2035 { uoff(u_ru), "offsetof(struct user, u_ru)" },
2036 { uoff(u_cru), "offsetof(struct user, u_cru)" },
2037 { uoff(u_timer[0]), "offsetof(struct user, u_timer[0])" },
2038 { uoff(u_XXX[0]), "offsetof(struct user, u_XXX[0])" },
2039 { uoff(u_ioch), "offsetof(struct user, u_ioch)" },
2040 { uoff(u_start), "offsetof(struct user, u_start)" },
2041 { uoff(u_acflag), "offsetof(struct user, u_acflag)" },
2042 { uoff(u_prof.pr_base), "offsetof(struct user, u_prof.pr_base)" },
2043 { uoff(u_prof.pr_size), "offsetof(struct user, u_prof.pr_size)" },
2044 { uoff(u_prof.pr_off), "offsetof(struct user, u_prof.pr_off)" },
2045 { uoff(u_prof.pr_scale),"offsetof(struct user, u_prof.pr_scale)"},
2046 { uoff(u_rlimit[0]), "offsetof(struct user, u_rlimit)" },
2047 { uoff(u_exdata.Ux_A), "offsetof(struct user, u_exdata.Ux_A)" },
2048 { uoff(u_exdata.ux_shell[0]),"offsetof(struct user, u_exdata.ux_shell[0])"},
2049 { uoff(u_lofault), "offsetof(struct user, u_lofault)" },
2050#endif /* SUNOS4 */
Wichert Akkermanc1652e22001-03-27 12:17:16 +00002051#ifndef HPPA
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002052 { sizeof(struct user), "sizeof(struct user)" },
Wichert Akkermanc1652e22001-03-27 12:17:16 +00002053#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002054 { 0, NULL },
2055};
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002056#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002057
2058int
2059sys_ptrace(tcp)
2060struct tcb *tcp;
2061{
2062 char *cmd;
2063 struct xlat *x;
2064 long addr;
2065
2066 cmd = xlookup(ptrace_cmds, tcp->u_arg[0]);
2067 if (!cmd)
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002068#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002069 cmd = "PTRACE_???";
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002070#else
2071 cmd = "PT_???";
2072#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002073 if (entering(tcp)) {
2074 tprintf("%s, %lu, ", cmd, tcp->u_arg[1]);
2075 addr = tcp->u_arg[2];
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002076#ifndef FREEBSD
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002077 if (tcp->u_arg[0] == PTRACE_PEEKUSER
2078 || tcp->u_arg[0] == PTRACE_POKEUSER) {
2079 for (x = struct_user_offsets; x->str; x++) {
2080 if (x->val >= addr)
2081 break;
2082 }
2083 if (!x->str)
2084 tprintf("%#lx, ", addr);
2085 else if (x->val > addr && x != struct_user_offsets) {
2086 x--;
2087 tprintf("%s + %ld, ", x->str, addr - x->val);
2088 }
2089 else
2090 tprintf("%s, ", x->str);
2091 }
2092 else
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002093#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002094 tprintf("%#lx, ", tcp->u_arg[2]);
2095#ifdef LINUX
2096 switch (tcp->u_arg[0]) {
2097 case PTRACE_PEEKDATA:
2098 case PTRACE_PEEKTEXT:
2099 case PTRACE_PEEKUSER:
2100 break;
2101 case PTRACE_CONT:
2102 case PTRACE_SINGLESTEP:
2103 case PTRACE_SYSCALL:
2104 case PTRACE_DETACH:
2105 printsignal(tcp->u_arg[3]);
2106 break;
2107 default:
2108 tprintf("%#lx", tcp->u_arg[3]);
2109 break;
2110 }
2111 } else {
2112 switch (tcp->u_arg[0]) {
2113 case PTRACE_PEEKDATA:
2114 case PTRACE_PEEKTEXT:
2115 case PTRACE_PEEKUSER:
2116 printnum(tcp, tcp->u_arg[3], "%#x");
2117 break;
2118 }
2119 }
2120#endif /* LINUX */
2121#ifdef SUNOS4
2122 if (tcp->u_arg[0] == PTRACE_WRITEDATA ||
2123 tcp->u_arg[0] == PTRACE_WRITETEXT) {
2124 tprintf("%lu, ", tcp->u_arg[3]);
2125 printstr(tcp, tcp->u_arg[4], tcp->u_arg[3]);
2126 } else if (tcp->u_arg[0] != PTRACE_READDATA &&
2127 tcp->u_arg[0] != PTRACE_READTEXT) {
2128 tprintf("%#lx", tcp->u_arg[3]);
2129 }
2130 } else {
2131 if (tcp->u_arg[0] == PTRACE_READDATA ||
2132 tcp->u_arg[0] == PTRACE_READTEXT) {
2133 tprintf("%lu, ", tcp->u_arg[3]);
2134 printstr(tcp, tcp->u_arg[4], tcp->u_arg[3]);
2135 }
2136 }
2137#endif /* SUNOS4 */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +00002138#ifdef FREEBSD
2139 tprintf("%lu", tcp->u_arg[3]);
2140 }
2141#endif /* FREEBSD */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002142 return 0;
2143}
2144
2145#endif /* !SVR4 */