From: Denys Vlasenko Date: Tue, 12 Feb 2013 11:50:10 +0000 (+0100) Subject: Remove old kernel hacks for architectures which require new kernels X-Git-Tag: v4.8~174 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d27809c978f3c8c3271f7d726dc92dd0eefa8a0f;p=strace Remove old kernel hacks for architectures which require new kernels * defs.h: Do not define TCB_WAITEXECVE for AVR32, BFIN and TILE. * util.c (change_syscall): For AVR32, BFIN and TILE, replace code with dummy "return 0" and a comment explaining why that is ok for these architectures. Signed-off-by: Denys Vlasenko --- diff --git a/defs.h b/defs.h index 78df638a..50620b3f 100644 --- a/defs.h +++ b/defs.h @@ -118,8 +118,8 @@ extern char *stpcpy(char *dst, const char *src); #ifndef DEFAULT_SORTBY # define DEFAULT_SORTBY "time" #endif - -/* Experimental code using PTRACE_SEIZE can be enabled here. +/* + * Experimental code using PTRACE_SEIZE can be enabled here. * This needs Linux kernel 3.4.x or later to work. */ #define USE_SEIZE 1 @@ -427,15 +427,23 @@ struct tcb { #define TCB_REPRINT 00200 /* We should reprint this syscall on exit */ #define TCB_FILTERED 00400 /* This system call has been filtered out */ /* x86 does not need TCB_WAITEXECVE. - * It can detect SIGTRAP by looking at eax/rax. - * See "not a syscall entry (eax = %ld)\n" message - * in syscall_fixup_on_sysenter(). + * It can detect post-execve SIGTRAP by looking at eax/rax. + * See "not a syscall entry (eax = %ld)\n" message. + * + * Note! On new kernels (about 2.5.46+), we use PTRACE_O_TRACEEXEC, which + * suppresses post-execve SIGTRAP. If you are adding a new arch which is + * only supported by newer kernels, you most likely don't need to define + * TCB_WAITEXECVE! */ -#if defined(ALPHA) || defined(AVR32) || defined(SPARC) || defined(SPARC64) \ - || defined(POWERPC) || defined(IA64) || defined(HPPA) \ - || defined(SH) || defined(SH64) || defined(S390) || defined(S390X) \ - || defined(ARM) || defined(AARCH64) || defined(MIPS) || defined(BFIN) \ - || defined(TILE) +#if defined(ALPHA) \ + || defined(SPARC) || defined(SPARC64) \ + || defined(POWERPC) \ + || defined(IA64) \ + || defined(HPPA) \ + || defined(SH) || defined(SH64) \ + || defined(S390) || defined(S390X) \ + || defined(ARM) || defined(AARCH64) \ + || defined(MIPS) /* This tracee has entered into execve syscall. Expect post-execve SIGTRAP * to happen. (When it is detected, tracee is continued and this bit is cleared.) */ diff --git a/util.c b/util.c index 93a98f64..ae90c348 100644 --- a/util.c +++ b/util.c @@ -966,6 +966,13 @@ upeek(struct tcb *tcp, long off, long *res) return 0; } +/* Note! On new kernels (about 2.5.46+), we use PTRACE_O_TRACECLONE + * and PTRACE_O_TRACE[V]FORK for tracing children. + * If you are adding a new arch which is only supported by newer kernels, + * you most likely don't need to add any code below + * beside a dummy "return 0" block in change_syscall(). + */ + /* * These #if's are huge, please indent them correctly. * It's easy to get confused otherwise. @@ -1118,9 +1125,6 @@ typedef struct pt_regs arg_setup_state; # elif defined(ALPHA) || defined(MIPS) # define arg0_offset REG_A0 # define arg1_offset (REG_A0+1) -# elif defined(AVR32) -# define arg0_offset (REG_R12) -# define arg1_offset (REG_R11) # elif defined(POWERPC) # define arg0_offset (sizeof(unsigned long)*PT_R3) # define arg1_offset (sizeof(unsigned long)*PT_R4) @@ -1146,11 +1150,6 @@ typedef struct pt_regs arg_setup_state; # define restore_arg1(tcp, state, val) 0 # define arg0_index 1 # define arg1_index 0 -# elif defined TILE -# define arg0_offset PTREGS_OFFSET_REG(0) -# define arg1_offset PTREGS_OFFSET_REG(1) -# define restore_arg0(tcp, state, val) 0 -# define restore_arg1(tcp, state, val) 0 # else # define arg0_offset 0 # define arg1_offset 4 @@ -1229,12 +1228,12 @@ change_syscall(struct tcb *tcp, arg_setup_state *state, int new) return -1; return 0; #elif defined(AVR32) - if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_R8), new) < 0) - return -1; + /* setbpt/clearbpt never used: */ + /* AVR32 is only supported since about linux-2.6.19 */ return 0; #elif defined(BFIN) - if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_P0), new) < 0) - return -1; + /* setbpt/clearbpt never used: */ + /* Blackfin is only supported since about linux-2.6.23 */ return 0; #elif defined(IA64) if (ia32) { @@ -1282,10 +1281,8 @@ change_syscall(struct tcb *tcp, arg_setup_state *state, int new) return -1; return 0; #elif defined(TILE) - if (ptrace(PTRACE_POKEUSER, tcp->pid, - (char*)PTREGS_OFFSET_REG(0), - new) != 0) - return -1; + /* setbpt/clearbpt never used: */ + /* Tilera CPUs are only supported since about linux-2.6.34 */ return 0; #elif defined(MICROBLAZE) if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new) < 0)