]> 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 e6f90f101cad7bdcf33db6ce2d735a08d21c9cbb..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 */
@@ -68,6 +72,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
+#include <time.h>
 #include <sys/time.h>
 #include <errno.h>
 
 #include <stddef.h>
 #endif /* STDC_HEADERS */
 
+#ifdef HAVE_SIGINFO_T
+#include <signal.h>
+#endif
+
 #if defined(LINUX)
 #  if defined(SPARC)
 #     define LINUXSPARC
 #  if defined(ALPHA)
 #     define LINUX_64BIT
 #  endif
-#endif 
+#  if defined(X86_64)
+#     define LINUX_X86_64
+#  endif
+#endif
 
 #if defined(SVR4) || defined(FREEBSD)
 #define USE_PROCFS
 #include <sys/pioctl.h>
 #endif /* FREEBSD */
 #else /* !USE_PROCFS */
-#if defined(LINUXSPARC) && defined(__GLIBC__)
+#if (defined(LINUXSPARC) || defined (LINUX_X86_64)) && defined(__GLIBC__)
 #include <sys/ptrace.h>
 #else
 /* Work around awkward prototype in ptrace.h. */
 #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
@@ -156,6 +163,29 @@ extern int ptrace();
 #  define REG_SP 29
 #  define REG_EPC 64
 #endif /* MIPS */
+#ifdef HPPA
+#  define PT_GR20 (20*4)
+#  define PT_GR26 (26*4)
+#  define PT_GR28 (28*4)
+#  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
@@ -168,6 +198,10 @@ extern int ptrace();
 #define SUPPORTED_PERSONALITIES 2
 #endif /* LINUXSPARC */
 
+#ifdef X86_64
+#undef SUPPORTED_PERSONALITIES
+#define SUPPORTED_PERSONALITIES 2
+#endif
 
 #ifdef SVR4
 #ifdef HAVE_MP_PROCFS
@@ -182,6 +216,8 @@ extern int mp_ioctl (int f, int c, void *a, int s);
 #define PR_WHAT                pr_lwp.pr_what
 #define PR_REG         pr_lwp.pr_context.uc_mcontext.gregs
 #define PR_FLAGS       pr_lwp.pr_flags
+#define PR_SYSCALL     pr_lwp.pr_syscall
+#define PR_INFO                pr_lwp.pr_info
 #define PIOCSTIP       PCSTOP
 #define PIOCSET                PCSET
 #define PIOCRESET      PCRESET
@@ -195,11 +231,13 @@ 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
 #define PR_FLAGS       pr_flags
+#define PR_SYSCALL     pr_syscall
+#define PR_INFO                pr_info
 #endif
 #endif
 #ifdef FREEBSD
@@ -241,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 */
@@ -274,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)
-#define TCB_WAITEXECVE 02000   /* ignore SIGTRAP after exceve */
-#endif /* ALPHA */
+# 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 */
@@ -294,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;
@@ -332,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;
 
@@ -351,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 *));
@@ -366,6 +427,7 @@ extern int printflags P((struct xlat *, int));
 extern int umoven P((struct tcb *, long, int, char *));
 extern int umovestr P((struct tcb *, long, int, char *));
 extern int upeek P((int, long, long *));
+extern void dumpiov P((struct tcb *, int, long));
 extern void dumpstr P((struct tcb *, long, int));
 extern void string_quote P((char *str));
 extern void printstr P((struct tcb *, long, int));
@@ -373,7 +435,11 @@ extern void printnum P((struct tcb *, long, char *));
 extern void printpath P((struct tcb *, long));
 extern void printpathn P((struct tcb *, long, int));
 extern void printtv P((struct tcb *, long));
+#ifdef HAVE_SIGINFO_T
+extern void printsiginfo P((siginfo_t *, int));
+#endif
 extern void printsock P((struct tcb *, long, int));
+extern void print_sock_optmgmt P((struct tcb *, long, int));
 extern void printrusage P((struct tcb *, long));
 extern int clearbpt P((struct tcb *));
 extern int setbpt P((struct tcb *));
@@ -387,6 +453,7 @@ extern void tabto P((int));
 extern void call_summary P((FILE *));
 extern void fake_execve P((struct tcb *, char *, char *[], char *[]));
 extern void printtv32 P((struct tcb*, long));
+extern void tprint_iov P((struct tcb *, int, long));
 
 #ifdef LINUX
 extern int internal_clone P((struct tcb *));
@@ -493,3 +560,38 @@ extern int nioctlents2;
 extern char *signalent2[];
 extern int nsignals2;
 #endif /* SUPPORTED_PERSONALITIES >= 3 */
+
+#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 {                                                                   \
+       if (arg % 2)                                                    \
+           memmove (&tcp->u_arg[arg], &tcp->u_arg[arg + 1],            \
+                    (tcp->u_nargs - arg - 1) * sizeof tcp->u_arg[0]);  \
+} while (0)
+#else
+#define ALIGN64(tcp,arg) do { } while (0)
+#endif
+
+#if HAVE_LONG_LONG
+
+/* _l refers to the lower numbered u_arg,
+ * _h refers to the higher numbered u_arg
+ */
+
+#if HAVE_LITTLE_ENDIAN_LONG_LONG
+#define LONG_LONG(_l,_h) \
+    ((long long)((unsigned long long)(unsigned)(_l) | ((unsigned long long)(_h)<<32)))
+#else
+#define LONG_LONG(_l,_h) \
+    ((long long)((unsigned long long)(unsigned)(_h) | ((unsigned long long)(_l)<<32)))
+#endif
+#endif
+
+#ifdef IA64
+extern long ia32;
+#endif
+
+extern int not_failing_only;