]> granicus.if.org Git - strace/commitdiff
Move all ptrace-related macros and declarations from defs.h to ptrace.h
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 13 Feb 2015 00:26:38 +0000 (00:26 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 13 Feb 2015 18:27:58 +0000 (18:27 +0000)
* ptrace.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* configure.ac (AC_CHECK_HEADERS): Remove linux/ptrace.h and sys/ptrace.h.
* defs.h: Do not include <sys/ptrace.h> and <asm/ptrace.h>.
Remove definitions of PTRACE_* macros.
* process.c: Remove <linux/ptrace.h> workarounds, include "ptrace.h".
* signal.c: Likewise.
* syscall.c: Likewise.
* util.c: Likewise.
* strace.c: Include "ptrace.h".
* wait.c: Likewise.

Makefile.am
configure.ac
defs.h
process.c
ptrace.h [new file with mode: 0644]
signal.c
strace.c
syscall.c
util.c
wait.c

index 38cb08b7a6a02a9adf807fe0608102347b1da8fd..d169a784503b4788c362933e262993d17b240599 100644 (file)
@@ -78,6 +78,7 @@ strace_SOURCES =      \
        process.c       \
        process_vm.c    \
        ptp.c           \
+       ptrace.h        \
        quota.c         \
        readahead.c     \
        readlink.c      \
index b3e62bf0c57261f80f3739cb29268c7b9245b1ee..715db95e757cda73680395adf3830d19319f0c66 100644 (file)
@@ -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 <sys/ptrace.h>])
 
 AC_CHECK_DECLS(m4_normalize([
diff --git a/defs.h b/defs.h
index 9fdd3665441a5c44e1371a3f7c90f0f25210eba9..642f1de0829a408e52ee6cafa50cd15c5b6ece2e 100644 (file)
--- 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 <sys/ptrace.h>
-# undef ptrace
-extern long ptrace(int, int, char *, long);
-#else
-# include <sys/ptrace.h>
-#endif
-
-#if defined(POWERPC)
-# include <asm/ptrace.h>
-#endif
-
-#if defined(TILE)
-# include <asm/ptrace.h>  /* 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
index bb888ce89a011f00bbb8db3950ea69b072df79f8..677c603cbffa439d6d4993ae656f918d67042df1 100644 (file)
--- a/process.c
+++ b/process.c
 # include <sys/reg.h>
 #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 <linux/ptrace.h>
-# 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 (file)
index 0000000..1a5414d
--- /dev/null
+++ b/ptrace.h
@@ -0,0 +1,127 @@
+#ifdef NEED_PTRACE_PROTOTYPE_WORKAROUND
+# define ptrace xptrace
+# include <sys/ptrace.h>
+# undef ptrace
+extern long ptrace(int, int, char *, long);
+#else
+# include <sys/ptrace.h>
+#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 <linux/ptrace.h>
+
+#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
index 6dd2469b36baae710e2ebe9b70c747c911629f7e..8fd91b67e2c658464f8bfc8c7794a60d7146c85f 100644 (file)
--- a/signal.c
+++ b/signal.c
  */
 
 #include "defs.h"
-#include <sys/user.h>
 #include <fcntl.h>
+#include <sys/user.h>
 
 #ifdef HAVE_SYS_REG_H
 # include <sys/reg.h>
 #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 <linux/ptrace.h>
-# undef ptrace_peeksiginfo_args
-# undef ia64_fpreg
-# undef pt_all_user_regs
-#endif
+#include "ptrace.h"
 
 #ifdef IA64
 # include <asm/ptrace_offsets.h>
index 9383625da8155e091cb75d19ebc2f3a45f56316b..a02ab040cb209341fca69af5884bfe0251e77118 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -45,6 +45,9 @@
 #if defined(IA64)
 # include <asm/ptrace_offsets.h>
 #endif
+
+#include "ptrace.h"
+
 /* In some libc, these aren't declared. Do it ourself: */
 extern char **environ;
 extern int optind;
index 56da0c0cd25d93f027c7351928e7763de3a551d3..adc17857f35fbd695c08f5c371d7189d444506de 100644 (file)
--- a/syscall.c
+++ b/syscall.c
 # include <sys/reg.h>
 #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 <linux/ptrace.h>
-# undef ptrace_peeksiginfo_args
-# undef ia64_fpreg
-# undef pt_all_user_regs
-#endif
+#include "ptrace.h"
 
 #if defined(SPARC64)
 # undef PTRACE_GETREGS
 # include <elf.h>
 #endif
 
-#if defined(AARCH64)
-# include <asm/ptrace.h>
-#endif
-
-#if defined(XTENSA)
-# include <asm/ptrace.h>
-#endif
-
 #ifndef NSIG
 # warning: NSIG is not defined, using 32
 # define NSIG 32
diff --git a/util.c b/util.c
index ccf687ff1e2a751f39b2af96ab50d429cd45d7f3..c96ccdacbf81c58e6ca62575692043e68284260c 100644 (file)
--- a/util.c
+++ b/util.c
 # include <sys/reg.h>
 #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 <linux/ptrace.h>
-# 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 ad368d2709c171e1050a597a3d361cb0ee2469b9..08e3397693f251ea505411f484508c44ec8b9e44 100644 (file)
--- 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