diff --git a/defs.h b/defs.h index 97561796..78df638a 100644 --- a/defs.h +++ b/defs.h @@ -119,22 +119,26 @@ extern char *stpcpy(char *dst, const char *src); # define DEFAULT_SORTBY "time" #endif -#if defined(SPARC) || defined(SPARC64) -# define LINUXSPARC -#endif +/* Experimental code using PTRACE_SEIZE can be enabled here. + * This needs Linux kernel 3.4.x or later to work. + */ +#define USE_SEIZE 1 + #if defined(MIPS) && _MIPS_SIM == _MIPS_SIM_ABI32 # define LINUX_MIPSO32 #endif #if defined(MIPS) && _MIPS_SIM == _MIPS_SIM_NABI32 # define LINUX_MIPSN32 -# define LINUX_MIPS64 #endif #if defined(MIPS) && _MIPS_SIM == _MIPS_SIM_ABI64 # define LINUX_MIPSN64 -# define LINUX_MIPS64 #endif -#if (defined(LINUXSPARC) || defined(X86_64) || defined(ARM) || defined(AARCH64) || defined(AVR32)) && defined(__GLIBC__) +#if (defined(SPARC) || defined(SPARC64) \ + || defined(X86_64) \ + || defined(ARM) || defined(AARCH64) \ + || defined(AVR32) \ + ) && defined(__GLIBC__) # include #else /* Work around awkward prototype in ptrace.h. */ @@ -149,10 +153,70 @@ extern char *stpcpy(char *dst, const char *src); extern long ptrace(int, int, char *, long); #endif +#if !HAVE_DECL_PTRACE_SETOPTIONS +# define PTRACE_SETOPTIONS 0x4200 +#endif +#if !HAVE_DECL_PTRACE_GETEVENTMSG +# define PTRACE_GETEVENTMSG 0x4201 +#endif +#if !HAVE_DECL_PTRACE_GETSIGINFO +# define PTRACE_GETSIGINFO 0x4202 +#endif + +#if !HAVE_DECL_PTRACE_O_TRACESYSGOOD +# define PTRACE_O_TRACESYSGOOD 0x00000001 +#endif +#if !HAVE_DECL_PTRACE_O_TRACEFORK +# define PTRACE_O_TRACEFORK 0x00000002 +#endif +#if !HAVE_DECL_PTRACE_O_TRACEVFORK +# define PTRACE_O_TRACEVFORK 0x00000004 +#endif +#if !HAVE_DECL_PTRACE_O_TRACECLONE +# define PTRACE_O_TRACECLONE 0x00000008 +#endif +#if !HAVE_DECL_PTRACE_O_TRACEEXEC +# define PTRACE_O_TRACEEXEC 0x00000010 +#endif +#if !HAVE_DECL_PTRACE_O_TRACEEXIT +# define PTRACE_O_TRACEEXIT 0x00000040 +#endif + +#if !HAVE_DECL_PTRACE_EVENT_FORK +# define PTRACE_EVENT_FORK 1 +#endif +#if !HAVE_DECL_PTRACE_EVENT_VFORK +# define PTRACE_EVENT_VFORK 2 +#endif +#if !HAVE_DECL_PTRACE_EVENT_CLONE +# define PTRACE_EVENT_CLONE 3 +#endif +#if !HAVE_DECL_PTRACE_EVENT_EXEC +# define PTRACE_EVENT_EXEC 4 +#endif +#if !HAVE_DECL_PTRACE_EVENT_VFORK_DONE +# define PTRACE_EVENT_VFORK_DONE 5 +#endif +#if !HAVE_DECL_PTRACE_EVENT_EXIT +# define PTRACE_EVENT_EXIT 6 +#endif + #if !defined(__GLIBC__) # define PTRACE_PEEKUSER PTRACE_PEEKUSR # define PTRACE_POKEUSER PTRACE_POKEUSR #endif + +#ifdef USE_SEIZE +# undef PTRACE_SEIZE +# define PTRACE_SEIZE 0x4206 +# undef PTRACE_INTERRUPT +# define PTRACE_INTERRUPT 0x4207 +# undef PTRACE_LISTEN +# define PTRACE_LISTEN 0x4208 +# undef PTRACE_EVENT_STOP +# define PTRACE_EVENT_STOP 128 +#endif + #if defined(X86_64) || defined(X32) || defined(I386) || defined(TILE) /* For struct pt_regs. x86 strace uses PTRACE_GETREGS. * PTRACE_GETREGS returns registers in the layout of this struct. @@ -220,10 +284,7 @@ struct arm_pt_regs { # define ARM_ORIG_r0 uregs[17] #endif /* AARCH64 */ -#define SUPPORTED_PERSONALITIES 1 -#define DEFAULT_PERSONALITY 0 - -#ifdef LINUXSPARC +#if defined(SPARC) || defined(SPARC64) /* Indexes into the pt_regs.u_reg[] array -- UREG_XX from kernel are all off * by 1 and use Ix instead of Ox. These work for both 32 and 64 bit Linux. */ # define U_REG_G1 0 @@ -231,7 +292,6 @@ struct arm_pt_regs { # define U_REG_O1 8 # define PERSONALITY0_WORDSIZE 4 # define PERSONALITY1_WORDSIZE 4 -# undef SUPPORTED_PERSONALITIES # if defined(SPARC64) # include # define SUPPORTED_PERSONALITIES 3 @@ -240,10 +300,9 @@ struct arm_pt_regs { # include # define SUPPORTED_PERSONALITIES 2 # endif /* SPARC64 */ -#endif /* LINUXSPARC */ +#endif /* SPARC[64] */ #ifdef X86_64 -# undef SUPPORTED_PERSONALITIES # define SUPPORTED_PERSONALITIES 3 # define PERSONALITY0_WORDSIZE 8 # define PERSONALITY1_WORDSIZE 4 @@ -251,115 +310,50 @@ struct arm_pt_regs { #endif #ifdef X32 -# undef SUPPORTED_PERSONALITIES # define SUPPORTED_PERSONALITIES 2 # define PERSONALITY0_WORDSIZE 4 # define PERSONALITY1_WORDSIZE 4 #endif #ifdef ARM -# undef SUPPORTED_PERSONALITIES # define SUPPORTED_PERSONALITIES 2 # define PERSONALITY0_WORDSIZE 4 # define PERSONALITY1_WORDSIZE 4 #endif #ifdef AARCH64 -# undef SUPPORTED_PERSONALITIES /* The existing ARM personality, then AArch64 */ # define SUPPORTED_PERSONALITIES 2 # define PERSONALITY0_WORDSIZE 4 # define PERSONALITY1_WORDSIZE 8 -# undef DEFAULT_PERSONALITY # define DEFAULT_PERSONALITY 1 #endif #ifdef POWERPC64 -# undef SUPPORTED_PERSONALITIES # define SUPPORTED_PERSONALITIES 2 # define PERSONALITY0_WORDSIZE 8 # define PERSONALITY1_WORDSIZE 4 #endif #ifdef TILE -# undef SUPPORTED_PERSONALITIES # define SUPPORTED_PERSONALITIES 2 # define PERSONALITY0_WORDSIZE 8 # define PERSONALITY1_WORDSIZE 4 # ifdef __tilepro__ -# undef DEFAULT_PERSONALITY # define DEFAULT_PERSONALITY 1 # endif #endif +#ifndef SUPPORTED_PERSONALITIES +# define SUPPORTED_PERSONALITIES 1 +#endif +#ifndef DEFAULT_PERSONALITY +# define DEFAULT_PERSONALITY 0 +#endif #ifndef PERSONALITY0_WORDSIZE # define PERSONALITY0_WORDSIZE (int)(sizeof(long)) #endif -#if !HAVE_DECL_PTRACE_SETOPTIONS -# define PTRACE_SETOPTIONS 0x4200 -#endif -#if !HAVE_DECL_PTRACE_GETEVENTMSG -# define PTRACE_GETEVENTMSG 0x4201 -#endif -#if !HAVE_DECL_PTRACE_GETSIGINFO -# define PTRACE_GETSIGINFO 0x4202 -#endif - -#if !HAVE_DECL_PTRACE_O_TRACESYSGOOD -# define PTRACE_O_TRACESYSGOOD 0x00000001 -#endif -#if !HAVE_DECL_PTRACE_O_TRACEFORK -# define PTRACE_O_TRACEFORK 0x00000002 -#endif -#if !HAVE_DECL_PTRACE_O_TRACEVFORK -# define PTRACE_O_TRACEVFORK 0x00000004 -#endif -#if !HAVE_DECL_PTRACE_O_TRACECLONE -# define PTRACE_O_TRACECLONE 0x00000008 -#endif -#if !HAVE_DECL_PTRACE_O_TRACEEXEC -# define PTRACE_O_TRACEEXEC 0x00000010 -#endif -#if !HAVE_DECL_PTRACE_O_TRACEEXIT -# define PTRACE_O_TRACEEXIT 0x00000040 -#endif - -#if !HAVE_DECL_PTRACE_EVENT_FORK -# define PTRACE_EVENT_FORK 1 -#endif -#if !HAVE_DECL_PTRACE_EVENT_VFORK -# define PTRACE_EVENT_VFORK 2 -#endif -#if !HAVE_DECL_PTRACE_EVENT_CLONE -# define PTRACE_EVENT_CLONE 3 -#endif -#if !HAVE_DECL_PTRACE_EVENT_EXEC -# define PTRACE_EVENT_EXEC 4 -#endif -#if !HAVE_DECL_PTRACE_EVENT_VFORK_DONE -# define PTRACE_EVENT_VFORK_DONE 5 -#endif -#if !HAVE_DECL_PTRACE_EVENT_EXIT -# define PTRACE_EVENT_EXIT 6 -#endif - -/* Experimental code using PTRACE_SEIZE can be enabled here. - * This needs Linux kernel 3.4.x or later to work. - */ -#define USE_SEIZE 1 - -#ifdef USE_SEIZE -# undef PTRACE_SEIZE -# define PTRACE_SEIZE 0x4206 -# undef PTRACE_INTERRUPT -# define PTRACE_INTERRUPT 0x4207 -# undef PTRACE_LISTEN -# define PTRACE_LISTEN 0x4208 -# undef PTRACE_EVENT_STOP -# define PTRACE_EVENT_STOP 128 -#endif - #if defined(I386) extern struct pt_regs i386_regs; #endif @@ -385,12 +379,10 @@ struct tcb { long scno; /* System call number */ long u_arg[MAX_ARGS]; /* System call arguments */ #if defined(LINUX_MIPSN32) || defined(X32) - long long ext_arg[MAX_ARGS]; /* System call arguments */ -#endif - long u_rval; /* return value */ -#if defined(LINUX_MIPSN32) || defined(X32) + long long ext_arg[MAX_ARGS]; long long u_lrval; /* long long return value */ #endif + long u_rval; /* Return value */ #if SUPPORTED_PERSONALITIES > 1 int currpers; /* Personality at the time of scno update */ #endif diff --git a/file.c b/file.c index 151fc31c..e7792223 100644 --- a/file.c +++ b/file.c @@ -32,7 +32,7 @@ #include #include -#ifdef LINUXSPARC +#if defined(SPARC) || defined(SPARC64) struct stat { unsigned short st_dev; unsigned int st_ino; @@ -421,7 +421,7 @@ sys_openat(struct tcb *tcp) return decode_open(tcp, 1); } -#ifdef LINUXSPARC +#if defined(SPARC) || defined(SPARC64) static const struct xlat openmodessol[] = { { 0, "O_RDWR" }, { 1, "O_RDONLY" }, @@ -736,7 +736,7 @@ sprinttime(time_t t) return buf; } -#ifdef LINUXSPARC +#if defined(SPARC) || defined(SPARC64) typedef struct { int tv_sec; int tv_nsec; @@ -806,7 +806,7 @@ printstatsol(struct tcb *tcp, long addr) tprints("...}"); } -#if defined(SPARC64) +# if defined(SPARC64) static void printstat_sparc64(struct tcb *tcp, long addr) { @@ -852,8 +852,8 @@ printstat_sparc64(struct tcb *tcp, long addr) else tprints("...}"); } -#endif /* SPARC64 */ -#endif /* LINUXSPARC */ +# endif /* SPARC64 */ +#endif /* SPARC[64] */ #if defined POWERPC64 struct stat_powerpc32 { @@ -1003,7 +1003,7 @@ printstat(struct tcb *tcp, long addr) return; } -#ifdef LINUXSPARC +#if defined(SPARC) || defined(SPARC64) if (current_personality == 1) { printstatsol(tcp, addr); return; @@ -1014,7 +1014,7 @@ printstat(struct tcb *tcp, long addr) return; } #endif -#endif /* LINUXSPARC */ +#endif /* SPARC[64] */ #if defined POWERPC64 if (current_personality == 1) { @@ -1083,7 +1083,7 @@ printstat64(struct tcb *tcp, long addr) return; } -#ifdef LINUXSPARC +#if defined(SPARC) || defined(SPARC64) if (current_personality == 1) { printstatsol(tcp, addr); return; @@ -1094,7 +1094,7 @@ printstat64(struct tcb *tcp, long addr) return; } # endif -#endif /* LINUXSPARC */ +#endif /* SPARC[64] */ #if defined X86_64 if (current_personality != 1) { @@ -1218,7 +1218,7 @@ printoldstat(struct tcb *tcp, long addr) return; } -# ifdef LINUXSPARC +# if defined(SPARC) || defined(SPARC64) if (current_personality == 1) { printstatsol(tcp, addr); return; @@ -1416,7 +1416,7 @@ sys_oldlstat(struct tcb *tcp) } #endif -#if defined(LINUXSPARC) +#if defined(SPARC) || defined(SPARC64) int sys_xstat(struct tcb *tcp) @@ -1592,7 +1592,7 @@ sys_aclipc(struct tcb *tcp) # endif /* HAVE_SYS_ACL_H */ -#endif /* LINUXSPARC */ +#endif /* SPARC[64] */ static const struct xlat fsmagic[] = { { 0x73757245, "CODA_SUPER_MAGIC" }, @@ -2162,7 +2162,7 @@ decode_mknod(struct tcb *tcp, int offset) switch (mode & S_IFMT) { case S_IFCHR: case S_IFBLK: -#ifdef LINUXSPARC +#if defined(SPARC) || defined(SPARC64) if (current_personality == 1) tprintf(", makedev(%lu, %lu)", (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff), diff --git a/signal.c b/signal.c index 5a4a8d5e..5e862ad9 100644 --- a/signal.c +++ b/signal.c @@ -1261,7 +1261,7 @@ sys_rt_sigaction(struct tcb *tcp) * therefore tcp->u_arg[3(4)] _must_ be NSIG / 8 here, * and we always use smaller memcpy. */ sigemptyset(&sigset); -#ifdef LINUXSPARC +#if defined(SPARC) || defined(SPARC64) if (tcp->u_arg[4] <= sizeof(sigset)) memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]); #else @@ -1283,7 +1283,7 @@ sys_rt_sigaction(struct tcb *tcp) if (entering(tcp)) tprints(", "); else -#ifdef LINUXSPARC +#if defined(SPARC) || defined(SPARC64) tprintf(", %#lx, %lu", tcp->u_arg[3], tcp->u_arg[4]); #elif defined(ALPHA) tprintf(", %lu, %#lx", tcp->u_arg[3], tcp->u_arg[4]);