]> granicus.if.org Git - strace/blobdiff - defs.h
2003-07-28 Daniel Jacobowitz <drow@mvista.com>
[strace] / defs.h
diff --git a/defs.h b/defs.h
index 43036852aef7dfed7174a544e136d417635ceb9e..504cbf5f0bfc6a36b6dbef9fcc330f38598effde 100644 (file)
--- a/defs.h
+++ b/defs.h
 #include <features.h>
 #endif
 
+#ifdef _LARGEFILE64_SOURCE
+/* This is the macro everything checks before using foo64 names.  */
+# ifndef _LFS64_LARGEFILE
+#  define _LFS64_LARGEFILE 1
+# endif
+#endif
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 /* configuration section */
 #ifndef MAX_QUALS
-#if defined(linux) && defined(MIPS)
-#define MAX_QUALS      4999    /* maximum number of syscalls, signals, etc. */
+#if defined(LINUX) && defined(MIPS)
+#define MAX_QUALS      5000    /* maximum number of syscalls, signals, etc. */
 #else
 #define MAX_QUALS      2048    /* maximum number of syscalls, signals, etc. */
 #endif
 #endif
-#ifndef MAX_PROCS
-#define MAX_PROCS      64      /* maximum number of processes tracable */
-#endif
 #ifndef DEFAULT_STRLEN
 #define DEFAULT_STRLEN 32      /* default maximum # of bytes printed in
                                  `printstr', change with `-s' switch */
@@ -90,7 +94,7 @@
 #  if defined(X86_64)
 #     define LINUX_X86_64
 #  endif
-#endif 
+#endif
 
 #if defined(SVR4) || defined(FREEBSD)
 #define USE_PROCFS
 #define __KERNEL__
 #include <asm/ptrace.h>
 #undef __KERNEL__
-/* TEMP */
-#define UESP   PT_R1
-#define EIP    PT_NIP
-#define EAX    PT_R3
-#define ORIG_EAX PT_ORIG_R3
 #endif
 #ifdef __STDC__
 #ifdef LINUX
@@ -171,6 +170,22 @@ extern int ptrace();
 #  define PT_IAOQ0 (106*4)
 #  define PT_IAOQ1 (107*4)
 #endif /* HPPA */
+#ifdef SH64
+   /* SH64 Linux - this code assumes the following kernel API for system calls:
+          PC           Offset 0
+          System Call  Offset 16 (actually, (syscall no.) | (0x1n << 16),
+                       where n = no. of parameters.
+          Other regs   Offset 24+
+
+          On entry:    R2-7 = parameters 1-6 (as many as necessary)
+          On return:   R9   = result. */
+
+   /* Offset for peeks of registers */
+#  define REG_OFFSET         (24)
+#  define REG_GENERAL(x)     (8*(x)+REG_OFFSET)
+#  define REG_PC             (0*8)
+#  define REG_SYSCALL        (2*8)
+#endif /* SH64 */
 #endif /* LINUX */
 
 #define SUPPORTED_PERSONALITIES 1
@@ -186,8 +201,8 @@ extern int ptrace();
 #ifdef X86_64
 #undef SUPPORTED_PERSONALITIES
 #define SUPPORTED_PERSONALITIES 2
-#endif 
-  
+#endif
+
 #ifdef SVR4
 #ifdef HAVE_MP_PROCFS
 extern int mp_ioctl (int f, int c, void *a, int s);
@@ -216,7 +231,7 @@ extern int mp_ioctl (int f, int c, void *a, int s);
 #else
 #define IOCTL          ioctl
 #define IOCTL_STATUS(t)        ioctl (t->pfd, PIOCSTATUS, &t->status)
-#define IOCTL_WSTOP(t) ioctl (t->pfd, PIOCWSTOP, &t->status)   
+#define IOCTL_WSTOP(t) ioctl (t->pfd, PIOCWSTOP, &t->status)
 #define PR_WHY         pr_why
 #define PR_WHAT                pr_what
 #define PR_REG         pr_reg
@@ -264,6 +279,12 @@ struct tcb {
        struct tcb *parent;     /* Parent of this process */
        int nchildren;          /* # of traced children */
        int waitpid;            /* pid(s) this process is waiting for */
+       int nzombies;           /* # of formerly traced children now dead */
+#ifdef LINUX
+       int nclone_threads;     /* # of nchildren with CLONE_THREAD */
+       int nclone_detached;    /* # of nchildren with CLONE_DETACHED */
+       int nclone_waiting;     /* clone threads in wait4 (TCB_SUSPENDED) */
+#endif
                                /* (1st arg of wait4()) */
        long baddr;             /* `Breakpoint' address */
        long inst[2];           /* Instructions on above */
@@ -297,9 +318,29 @@ struct tcb {
 #define TCB_FOLLOWFORK 00400   /* Process should have forks followed */
 #define TCB_REPRINT    01000   /* We should reprint this syscall on exit */
 #ifdef LINUX
-# if defined(ALPHA) || defined(SPARC) || defined(POWERPC) || defined(IA64) || defined(HPPA) || defined(SH)
+# if defined(ALPHA) || defined(SPARC) || defined(POWERPC) || defined(IA64) || defined(HPPA) || defined(SH) || defined(SH64) || defined(S390) || defined(S390X) || defined(ARM)
 #  define TCB_WAITEXECVE 02000 /* ignore SIGTRAP after exceve */
 # endif
+# define TCB_CLONE_DETACHED 04000 /* CLONE_DETACHED set in creating syscall */
+# define TCB_CLONE_THREAD  010000 /* CLONE_THREAD set in creating syscall */
+# define TCB_GROUP_EXITING 020000 /* TCB_EXITING was exit_group, not _exit */
+# include <sys/syscall.h>
+# ifndef __NR_exit_group
+# /* Hack: Most headers around are too old to have __NR_exit_group.  */
+#  ifdef ALPHA
+#   define __NR_exit_group 405
+#  elif defined I386
+#   define __NR_exit_group 252
+#  elif defined IA64
+#   define __NR_exit_group 1236
+#  elif defined POWERPC
+#   define __NR_exit_group 234
+#  elif defined S390 || defined S390X
+#   define __NR_exit_group 248
+#  elif defined SPARC
+#   define __NR_exit_group 188
+#  endif /* ALPHA et al */
+# endif        /* !__NR_exit_group */
 #endif /* LINUX */
 
 /* qualifier flags */
@@ -317,10 +358,6 @@ struct tcb {
 #define syserror(tcp)  ((tcp)->u_error != 0)
 #define verbose(tcp)   (qual_flags[(tcp)->scno] & QUAL_VERBOSE)
 #define abbrev(tcp)    (qual_flags[(tcp)->scno] & QUAL_ABBREV)
-#define waiting_parent(tcp) \
-               (tcp->parent && \
-               (tcp->parent->flags & TCB_SUSPENDED) && \
-               (tcp->parent->waitpid <= 0 || tcp->parent->waitpid == tcp->pid))
 
 struct xlat {
        int val;
@@ -355,13 +392,13 @@ struct xlat {
 #define TRACE_PROCESS  010     /* Trace process-related syscalls. */
 #define TRACE_SIGNAL   020     /* Trace signal-related syscalls. */
 
-extern struct tcb tcbtab[];
+extern struct tcb **tcbtab;
 extern int qual_flags[];
 extern int debug, followfork, followvfork;
 extern int rflag, tflag, dtime, cflag, xflag, qflag;
 extern int acolumn;
 extern char *outfname;
-extern int nprocs;
+extern unsigned int nprocs, tcbtabsize;
 extern int max_strlen;
 extern struct tcb *tcp_last;
 
@@ -374,6 +411,7 @@ extern struct tcb *tcp_last;
 extern int set_personality P((int personality));
 extern char *xlookup P((struct xlat *, int));
 extern struct tcb *alloctcb P((int));
+extern struct tcb *pid2tcb P((int));
 extern void droptcb P((struct tcb *));
 
 extern void set_sortby P((char *));
@@ -523,7 +561,9 @@ extern char *signalent2[];
 extern int nsignals2;
 #endif /* SUPPORTED_PERSONALITIES >= 3 */
 
-#if FREEBSD
+#if defined(FREEBSD) || (defined(LINUX) \
+                        && defined(POWERPC) && !defined(__powerpc64__)) \
+  || (defined (LINUX) && defined (MIPS) && !defined(__mips64))
 /* ARRGH!  off_t args are aligned on 64 bit boundaries! */
 #define ALIGN64(tcp,arg)                                               \
 do {                                                                   \