diff --git a/Makefile.am b/Makefile.am index 38cb08b7..d169a784 100644 --- a/Makefile.am +++ b/Makefile.am @@ -78,6 +78,7 @@ strace_SOURCES = \ process.c \ process_vm.c \ ptp.c \ + ptrace.h \ quota.c \ readahead.c \ readlink.c \ diff --git a/configure.ac b/configure.ac index b3e62bf0..715db95e 100644 --- a/configure.ac +++ b/configure.ac @@ -229,7 +229,6 @@ AC_CHECK_HEADERS(m4_normalize([ linux/input.h linux/mmtimer.h linux/perf_event.h - linux/ptrace.h linux/seccomp.h linux/utsname.h mqueue.h @@ -243,7 +242,6 @@ AC_CHECK_HEADERS(m4_normalize([ sys/filio.h sys/ioctl.h sys/poll.h - sys/ptrace.h sys/reg.h sys/vfs.h sys/xattr.h @@ -288,23 +286,8 @@ AC_CHECK_HEADERS([libaio.h], [ AC_CHECK_DECLS([sys_errlist]) AC_CHECK_DECLS(m4_normalize([ - PTRACE_EVENT_CLONE, - PTRACE_EVENT_EXEC, - PTRACE_EVENT_EXIT, - PTRACE_EVENT_FORK, - PTRACE_EVENT_VFORK, - PTRACE_EVENT_VFORK_DONE, - PTRACE_GETEVENTMSG, - PTRACE_GETSIGINFO, - PTRACE_O_TRACECLONE, - PTRACE_O_TRACEEXEC, - PTRACE_O_TRACEEXIT, - PTRACE_O_TRACEFORK, - PTRACE_O_TRACESYSGOOD, - PTRACE_O_TRACEVFORK, PTRACE_PEEKUSER, - PTRACE_POKEUSER, - PTRACE_SETOPTIONS + PTRACE_POKEUSER ]),,, [#include ]) AC_CHECK_DECLS(m4_normalize([ diff --git a/defs.h b/defs.h index 9fdd3665..642f1de0 100644 --- a/defs.h +++ b/defs.h @@ -150,23 +150,6 @@ extern char *stpcpy(char *dst, const char *src); */ #define USE_CUSTOM_PRINTF 0 -#ifdef NEED_PTRACE_PROTOTYPE_WORKAROUND -# define ptrace xptrace -# include -# undef ptrace -extern long ptrace(int, int, char *, long); -#else -# include -#endif - -#if defined(POWERPC) -# include -#endif - -#if defined(TILE) -# include /* struct pt_regs */ -#endif - #ifndef ERESTARTSYS # define ERESTARTSYS 512 #endif @@ -180,70 +163,6 @@ extern long ptrace(int, int, char *, long); # define ERESTART_RESTARTBLOCK 516 #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 !HAVE_DECL_PTRACE_PEEKUSER -# define PTRACE_PEEKUSER PTRACE_PEEKUSR -#endif -#if !HAVE_DECL_PTRACE_POKEUSER -# define PTRACE_POKEUSER PTRACE_POKEUSR -#endif - -#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 - #ifdef ALPHA # define REG_R0 0 # define REG_A0 16 diff --git a/process.c b/process.c index bb888ce8..677c603c 100644 --- a/process.c +++ b/process.c @@ -47,22 +47,7 @@ # include #endif -#ifdef HAVE_LINUX_PTRACE_H -# undef PTRACE_SYSCALL -# ifdef HAVE_STRUCT_IA64_FPREG -# define ia64_fpreg XXX_ia64_fpreg -# endif -# ifdef HAVE_STRUCT_PT_ALL_USER_REGS -# define pt_all_user_regs XXX_pt_all_user_regs -# endif -# ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS -# define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args -# endif -# include -# undef ptrace_peeksiginfo_args -# undef ia64_fpreg -# undef pt_all_user_regs -#endif +#include "ptrace.h" #if defined(SPARC64) # define r_pc r_tpc @@ -115,14 +100,12 @@ sys_ptrace(struct tcb *tcp) else tprintf("%s, ", x->str); } else -#ifdef PTRACE_GETREGSET if (tcp->u_arg[0] == PTRACE_GETREGSET || tcp->u_arg[0] == PTRACE_SETREGSET ) { printxval(nt_descriptor_types, tcp->u_arg[2], "NT_???"); tprints(", "); } else -#endif tprintf("%#lx, ", addr); @@ -139,29 +122,20 @@ sys_ptrace(struct tcb *tcp) case PTRACE_DETACH: printsignal(tcp->u_arg[3]); break; -#ifdef PTRACE_SETOPTIONS case PTRACE_SETOPTIONS: printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???"); break; -#endif -#ifdef PTRACE_SETSIGINFO case PTRACE_SETSIGINFO: { printsiginfo_at(tcp, tcp->u_arg[3]); break; } -#endif -#ifdef PTRACE_GETSIGINFO - case PTRACE_GETSIGINFO: - /* Don't print anything, do it at syscall return. */ - break; -#endif -#ifdef PTRACE_GETREGSET - case PTRACE_GETREGSET: - break; case PTRACE_SETREGSET: tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0); break; -#endif + case PTRACE_GETSIGINFO: + case PTRACE_GETREGSET: + /* Don't print anything, do it at syscall return. */ + break; default: tprintf("%#lx", tcp->u_arg[3]); break; @@ -177,17 +151,13 @@ sys_ptrace(struct tcb *tcp) printnum(tcp, tcp->u_arg[3], "%#lx"); break; #endif -#ifdef PTRACE_GETSIGINFO case PTRACE_GETSIGINFO: { printsiginfo_at(tcp, tcp->u_arg[3]); break; } -#endif -#ifdef PTRACE_GETREGSET case PTRACE_GETREGSET: tprint_iov(tcp, /*len:*/ 1, tcp->u_arg[3], /*as string:*/ 0); break; -#endif } } return 0; diff --git a/ptrace.h b/ptrace.h new file mode 100644 index 00000000..1a5414db --- /dev/null +++ b/ptrace.h @@ -0,0 +1,127 @@ +#ifdef NEED_PTRACE_PROTOTYPE_WORKAROUND +# define ptrace xptrace +# include +# undef ptrace +extern long ptrace(int, int, char *, long); +#else +# include +#endif + +#ifdef HAVE_STRUCT_IA64_FPREG +# define ia64_fpreg XXX_ia64_fpreg +#endif +#ifdef HAVE_STRUCT_PT_ALL_USER_REGS +# define pt_all_user_regs XXX_pt_all_user_regs +#endif +#ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS +# define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args +#endif + +#include + +#ifdef HAVE_STRUCT_IA64_FPREG +# undef ia64_fpreg +#endif +#ifdef HAVE_STRUCT_PT_ALL_USER_REGS +# undef pt_all_user_regs +#endif +#ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS +# undef ptrace_peeksiginfo_args +#endif + +#ifndef PTRACE_EVENT_FORK +# define PTRACE_EVENT_FORK 1 +#endif +#ifndef PTRACE_EVENT_VFORK +# define PTRACE_EVENT_VFORK 2 +#endif +#ifndef PTRACE_EVENT_CLONE +# define PTRACE_EVENT_CLONE 3 +#endif +#ifndef PTRACE_EVENT_EXEC +# define PTRACE_EVENT_EXEC 4 +#endif +#ifndef PTRACE_EVENT_VFORK_DONE +# define PTRACE_EVENT_VFORK_DONE 5 +#endif +#ifndef PTRACE_EVENT_EXIT +# define PTRACE_EVENT_EXIT 6 +#endif +#ifndef PTRACE_EVENT_SECCOMP +# define PTRACE_EVENT_SECCOMP 7 +#endif +#ifndef PTRACE_EVENT_STOP +# define PTRACE_EVENT_STOP 128 +#endif + +#ifndef PTRACE_O_TRACESYSGOOD +# define PTRACE_O_TRACESYSGOOD 1 +#endif +#ifndef PTRACE_O_TRACEFORK +# define PTRACE_O_TRACEFORK (1 << PTRACE_EVENT_FORK) +#endif +#ifndef PTRACE_O_TRACEVFORK +# define PTRACE_O_TRACEVFORK (1 << PTRACE_EVENT_VFORK) +#endif +#ifndef PTRACE_O_TRACECLONE +# define PTRACE_O_TRACECLONE (1 << PTRACE_EVENT_CLONE) +#endif +#ifndef PTRACE_O_TRACEEXEC +# define PTRACE_O_TRACEEXEC (1 << PTRACE_EVENT_EXEC) +#endif +#ifndef PTRACE_O_TRACEVFORKDONE +# define PTRACE_O_TRACEVFORKDONE (1 << PTRACE_EVENT_VFORK_DONE) +#endif +#ifndef PTRACE_O_TRACEEXIT +# define PTRACE_O_TRACEEXIT (1 << PTRACE_EVENT_EXIT) +#endif +#ifndef PTRACE_O_TRACESECCOMP +# define PTRACE_O_TRACESECCOMP (1 << PTRACE_EVENT_SECCOMP) +#endif +#ifndef PTRACE_O_EXITKILL +# define PTRACE_O_EXITKILL (1 << 20) +#endif + +#ifndef PTRACE_SETOPTIONS +# define PTRACE_SETOPTIONS 0x4200 +#endif +#ifndef PTRACE_GETEVENTMSG +# define PTRACE_GETEVENTMSG 0x4201 +#endif +#ifndef PTRACE_GETSIGINFO +# define PTRACE_GETSIGINFO 0x4202 +#endif +#ifndef PTRACE_SETSIGINFO +# define PTRACE_SETSIGINFO 0x4203 +#endif +#ifndef PTRACE_GETREGSET +# define PTRACE_GETREGSET 0x4204 +#endif +#ifndef PTRACE_SETREGSET +# define PTRACE_SETREGSET 0x4205 +#endif +#ifndef PTRACE_SEIZE +# define PTRACE_SEIZE 0x4206 +#endif +#ifndef PTRACE_INTERRUPT +# define PTRACE_INTERRUPT 0x4207 +#endif +#ifndef PTRACE_LISTEN +# define PTRACE_LISTEN 0x4208 +#endif +#ifndef PTRACE_PEEKSIGINFO +# define PTRACE_PEEKSIGINFO 0x4209 +#endif +#ifndef PTRACE_GETSIGMASK +# define PTRACE_GETSIGMASK 0x420a +#endif +#ifndef PTRACE_SETSIGMASK +# define PTRACE_SETSIGMASK 0x420b +#endif + +#if !HAVE_DECL_PTRACE_PEEKUSER +# define PTRACE_PEEKUSER PTRACE_PEEKUSR +#endif +#if !HAVE_DECL_PTRACE_POKEUSER +# define PTRACE_POKEUSER PTRACE_POKEUSR +#endif diff --git a/signal.c b/signal.c index 6dd2469b..8fd91b67 100644 --- a/signal.c +++ b/signal.c @@ -32,29 +32,14 @@ */ #include "defs.h" -#include #include +#include #ifdef HAVE_SYS_REG_H # include #endif -#ifdef HAVE_LINUX_PTRACE_H -# undef PTRACE_SYSCALL -# ifdef HAVE_STRUCT_IA64_FPREG -# define ia64_fpreg XXX_ia64_fpreg -# endif -# ifdef HAVE_STRUCT_PT_ALL_USER_REGS -# define pt_all_user_regs XXX_pt_all_user_regs -# endif -# ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS -# define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args -# endif -# include -# undef ptrace_peeksiginfo_args -# undef ia64_fpreg -# undef pt_all_user_regs -#endif +#include "ptrace.h" #ifdef IA64 # include diff --git a/strace.c b/strace.c index 9383625d..a02ab040 100644 --- a/strace.c +++ b/strace.c @@ -45,6 +45,9 @@ #if defined(IA64) # include #endif + +#include "ptrace.h" + /* In some libc, these aren't declared. Do it ourself: */ extern char **environ; extern int optind; diff --git a/syscall.c b/syscall.c index 56da0c0c..adc17857 100644 --- a/syscall.c +++ b/syscall.c @@ -39,22 +39,7 @@ # include #endif -#ifdef HAVE_LINUX_PTRACE_H -# undef PTRACE_SYSCALL -# ifdef HAVE_STRUCT_IA64_FPREG -# define ia64_fpreg XXX_ia64_fpreg -# endif -# ifdef HAVE_STRUCT_PT_ALL_USER_REGS -# define pt_all_user_regs XXX_pt_all_user_regs -# endif -# ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS -# define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args -# endif -# include -# undef ptrace_peeksiginfo_args -# undef ia64_fpreg -# undef pt_all_user_regs -#endif +#include "ptrace.h" #if defined(SPARC64) # undef PTRACE_GETREGS @@ -75,14 +60,6 @@ # include #endif -#if defined(AARCH64) -# include -#endif - -#if defined(XTENSA) -# include -#endif - #ifndef NSIG # warning: NSIG is not defined, using 32 # define NSIG 32 diff --git a/util.c b/util.c index ccf687ff..c96ccdac 100644 --- a/util.c +++ b/util.c @@ -49,22 +49,7 @@ # include #endif -#ifdef HAVE_LINUX_PTRACE_H -# undef PTRACE_SYSCALL -# ifdef HAVE_STRUCT_IA64_FPREG -# define ia64_fpreg XXX_ia64_fpreg -# endif -# ifdef HAVE_STRUCT_PT_ALL_USER_REGS -# define pt_all_user_regs XXX_pt_all_user_regs -# endif -# ifdef HAVE_STRUCT_PTRACE_PEEKSIGINFO_ARGS -# define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args -# endif -# include -# undef ptrace_peeksiginfo_args -# undef ia64_fpreg -# undef pt_all_user_regs -#endif +#include "ptrace.h" int string_to_uint(const char *str) diff --git a/wait.c b/wait.c index ad368d27..08e33976 100644 --- a/wait.c +++ b/wait.c @@ -33,6 +33,7 @@ # define W_CONTINUED 0xffff #endif +#include "ptrace.h" #include "xlat/ptrace_events.h" static int