]> granicus.if.org Git - strace/commitdiff
Move regs-related macros and declarations from defs.h to regs.h
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 13 Feb 2015 02:12:14 +0000 (02:12 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 13 Feb 2015 18:28:08 +0000 (18:28 +0000)
* regs.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/arch_regs.h: New file.
* linux/alpha/arch_regs.h: Likewise.
* linux/arm/arch_regs.h: Likewise.
* linux/hppa/arch_regs.h: Likewise.
* linux/i386/arch_regs.h: Likewise.
* linux/ia64/arch_regs.h: Likewise.
* linux/mips/arch_regs.h: Likewise.
* linux/powerpc/arch_regs.h: Likewise.
* linux/sh64/arch_regs.h: Likewise.
* linux/sparc/arch_regs.h: Likewise.
* linux/sparc64/arch_regs.h: Likewise.
* linux/tile/arch_regs.h: Likewise.
* linux/x86_64/arch_regs.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* defs.h: Remove definitions of PTRACE_*, REG_*, PT_*, U_REG_*,
and ARM_* macros.
Remove declarations of struct pt_regs variables.
[SPARC]: Do not include <asm/psr.h>.
[SPARC64]: Do not include <asm/psrcompat.h>.
* bjm.c: Do not include <sys/user.h>.
* process.c: Include "regs.h".
Do not include <sys/user.h> and <sys/reg.h>.
[IA64]: Do not include <asm/ptrace_offsets.h> and <asm/rse.h>.
* util.c: Likewise.
* syscall.c: Likewise.
[AARCH64]: Define struct arm_pt_regs and ARM_* macros.
[SPARC]: Include <asm/psr.h>.
[SPARC64]: Include <asm/psrcompat.h>.
* signal.c: Include "regs.h".
Do not include <sys/user.h> and <sys/reg.h>.
[IA64]: Do not include <asm/ptrace_offsets.h>.
* strace.c [IA64]: Do not include <asm/ptrace_offsets.h>.

22 files changed:
Makefile.am
bjm.c
defs.h
linux/alpha/arch_regs.h [new file with mode: 0644]
linux/arch_regs.h [new file with mode: 0644]
linux/arm/arch_regs.h [new file with mode: 0644]
linux/hppa/arch_regs.h [new file with mode: 0644]
linux/i386/arch_regs.h [new file with mode: 0644]
linux/ia64/arch_regs.h [new file with mode: 0644]
linux/mips/arch_regs.h [new file with mode: 0644]
linux/powerpc/arch_regs.h [new file with mode: 0644]
linux/sh64/arch_regs.h [new file with mode: 0644]
linux/sparc/arch_regs.h [new file with mode: 0644]
linux/sparc64/arch_regs.h [new file with mode: 0644]
linux/tile/arch_regs.h [new file with mode: 0644]
linux/x86_64/arch_regs.h [new file with mode: 0644]
process.c
regs.h [new file with mode: 0644]
signal.c
strace.c
syscall.c
util.c

index d169a784503b4788c362933e262993d17b240599..ac6df1976db920e5acfc03acf380a2030655db3c 100644 (file)
@@ -83,6 +83,7 @@ strace_SOURCES =      \
        readahead.c     \
        readlink.c      \
        reboot.c        \
+       regs.h          \
        renameat.c      \
        resource.c      \
        sched.c         \
@@ -168,6 +169,7 @@ EXTRA_DIST =                                \
        linux/aarch64/signalent1.h      \
        linux/aarch64/syscallent.h      \
        linux/aarch64/syscallent1.h     \
+       linux/alpha/arch_regs.h         \
        linux/alpha/errnoent.h          \
        linux/alpha/ioctls_arch0.h      \
        linux/alpha/ioctls_inc0.h       \
@@ -177,6 +179,8 @@ EXTRA_DIST =                                \
        linux/arc/ioctls_arch0.h        \
        linux/arc/ioctls_inc0.h         \
        linux/arc/syscallent.h          \
+       linux/arch_regs.h               \
+       linux/arm/arch_regs.h           \
        linux/arm/ioctls_arch0.h        \
        linux/arm/ioctls_inc0.h         \
        linux/arm/syscallent.h          \
@@ -194,16 +198,19 @@ EXTRA_DIST =                              \
        linux/dummy.h                   \
        linux/errnoent.h                \
        linux/fanotify.h                \
+       linux/hppa/arch_regs.h          \
        linux/hppa/errnoent.h           \
        linux/hppa/ioctls_arch0.h       \
        linux/hppa/ioctls_inc0.h        \
        linux/hppa/signalent.h          \
        linux/hppa/syscallent.h         \
+       linux/i386/arch_regs.h          \
        linux/i386/ioctls_arch0.h       \
        linux/i386/ioctls_inc0.h        \
        linux/i386/syscallent.h         \
        linux/i386/userent.h            \
        linux/i386/userent0.h           \
+       linux/ia64/arch_regs.h          \
        linux/ia64/ioctls_arch0.h       \
        linux/ia64/ioctls_inc0.h        \
        linux/ia64/signalent.h          \
@@ -224,6 +231,7 @@ EXTRA_DIST =                                \
        linux/microblaze/ioctls_inc0.h  \
        linux/microblaze/syscallent.h   \
        linux/microblaze/userent.h      \
+       linux/mips/arch_regs.h          \
        linux/mips/errnoent.h           \
        linux/mips/genstub.sh           \
        linux/mips/ioctls_arch0.h       \
@@ -241,6 +249,7 @@ EXTRA_DIST =                                \
        linux/or1k/syscallent.h         \
        linux/or1k/userent.h            \
        linux/personality.h             \
+       linux/powerpc/arch_regs.h       \
        linux/powerpc/ioctls_arch0.h    \
        linux/powerpc/ioctls_inc0.h     \
        linux/powerpc/syscallent.h      \
@@ -271,12 +280,14 @@ EXTRA_DIST =                              \
        linux/sh/syscallent.h           \
        linux/sh/userent.h              \
        linux/sh/userent0.h             \
+       linux/sh64/arch_regs.h          \
        linux/sh64/ioctls_arch0.h       \
        linux/sh64/ioctls_inc0.h        \
        linux/sh64/syscallent.h         \
        linux/sh64/userent.h            \
        linux/signalent.h               \
        linux/sock_diag.h               \
+       linux/sparc/arch_regs.h         \
        linux/sparc/dummy2.h            \
        linux/sparc/errnoent.h          \
        linux/sparc/errnoent1.h         \
@@ -290,6 +301,7 @@ EXTRA_DIST =                                \
        linux/sparc/syscallent.h        \
        linux/sparc/syscallent1.h       \
        linux/sparc/userent.h           \
+       linux/sparc64/arch_regs.h       \
        linux/sparc64/dummy2.h          \
        linux/sparc64/errnoent.h        \
        linux/sparc64/errnoent1.h       \
@@ -309,6 +321,7 @@ EXTRA_DIST =                                \
        linux/sparc64/userent.h         \
        linux/subcall.h                 \
        linux/syscall.h                 \
+       linux/tile/arch_regs.h          \
        linux/tile/errnoent1.h          \
        linux/tile/ioctls_arch0.h       \
        linux/tile/ioctls_arch1.h       \
@@ -333,6 +346,7 @@ EXTRA_DIST =                                \
        linux/x32/syscallent.h          \
        linux/x32/syscallent1.h         \
        linux/x32/userent.h             \
+       linux/x86_64/arch_regs.h        \
        linux/x86_64/errnoent1.h        \
        linux/x86_64/errnoent2.h        \
        linux/x86_64/gentab.pl          \
diff --git a/bjm.c b/bjm.c
index b34c6ed71ecfae7eee8cea10188b7b2418e576f1..c8d72a3090311ffc6ece580360bfad3f21e95698 100644 (file)
--- a/bjm.c
+++ b/bjm.c
@@ -34,7 +34,6 @@
 #include <sys/wait.h>
 #include <sys/resource.h>
 #include <sys/utsname.h>
-#include <sys/user.h>
 
 /* Bits of module.flags.  */
 
diff --git a/defs.h b/defs.h
index 642f1de0829a408e52ee6cafa50cd15c5b6ece2e..49ef2ac8c519c35017c248f5b5ac6d18ab2df6e6 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -163,81 +163,13 @@ extern char *stpcpy(char *dst, const char *src);
 # define ERESTART_RESTARTBLOCK 516
 #endif
 
-#ifdef ALPHA
-# define REG_R0 0
-# define REG_A0 16
-# define REG_A3 19
-# define REG_FP 30
-# define REG_PC 64
-#endif /* ALPHA */
-#ifdef MIPS
-# define REG_V0 2
-# define REG_A0 4
-# define REG_A3 7
-# 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 */
-#ifdef AARCH64
-struct arm_pt_regs {
-        int uregs[18];
-};
-# define ARM_cpsr       uregs[16]
-# define ARM_pc         uregs[15]
-# define ARM_lr         uregs[14]
-# define ARM_sp         uregs[13]
-# define ARM_ip         uregs[12]
-# define ARM_fp         uregs[11]
-# define ARM_r10        uregs[10]
-# define ARM_r9         uregs[9]
-# define ARM_r8         uregs[8]
-# define ARM_r7         uregs[7]
-# define ARM_r6         uregs[6]
-# define ARM_r5         uregs[5]
-# define ARM_r4         uregs[4]
-# define ARM_r3         uregs[3]
-# define ARM_r2         uregs[2]
-# define ARM_r1         uregs[1]
-# define ARM_r0         uregs[0]
-# define ARM_ORIG_r0    uregs[17]
-#endif /* AARCH64 */
-
 #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
-# define U_REG_O0 7
-# define U_REG_O1 8
 # define PERSONALITY0_WORDSIZE 4
 # define PERSONALITY1_WORDSIZE 4
 # if defined(SPARC64)
-#  include <asm/psrcompat.h>
 #  define SUPPORTED_PERSONALITIES 3
 #  define PERSONALITY2_WORDSIZE 8
 # else
-#  include <asm/psr.h>
 #  define SUPPORTED_PERSONALITIES 2
 # endif /* SPARC64 */
 #endif /* SPARC[64] */
@@ -292,20 +224,6 @@ struct arm_pt_regs {
 # define PERSONALITY0_WORDSIZE SIZEOF_LONG
 #endif
 
-#if defined(I386) || defined(X86_64)
-extern uint32_t *const i386_esp_ptr;
-#elif defined(IA64)
-extern bool ia64_ia32mode;
-#elif defined(SPARC) || defined(SPARC64)
-extern struct pt_regs sparc_regs;
-#elif defined(ARM)
-extern struct pt_regs arm_regs;
-#elif defined(TILE)
-extern struct pt_regs tile_regs;
-#elif defined(POWERPC)
-extern struct pt_regs ppc_regs;
-#endif
-
 typedef struct sysent {
        unsigned nargs;
        int     sys_flags;
diff --git a/linux/alpha/arch_regs.h b/linux/alpha/arch_regs.h
new file mode 100644 (file)
index 0000000..66277fd
--- /dev/null
@@ -0,0 +1,5 @@
+#define REG_R0 0
+#define REG_A0 16
+#define REG_A3 19
+#define REG_FP 30
+#define REG_PC 64
diff --git a/linux/arch_regs.h b/linux/arch_regs.h
new file mode 100644 (file)
index 0000000..da84fa5
--- /dev/null
@@ -0,0 +1 @@
+/* nothing */
diff --git a/linux/arm/arch_regs.h b/linux/arm/arch_regs.h
new file mode 100644 (file)
index 0000000..b7638ae
--- /dev/null
@@ -0,0 +1 @@
+extern struct pt_regs arm_regs;
diff --git a/linux/hppa/arch_regs.h b/linux/hppa/arch_regs.h
new file mode 100644 (file)
index 0000000..d42fc14
--- /dev/null
@@ -0,0 +1,5 @@
+#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)
diff --git a/linux/i386/arch_regs.h b/linux/i386/arch_regs.h
new file mode 100644 (file)
index 0000000..eeb4ebe
--- /dev/null
@@ -0,0 +1 @@
+extern uint32_t *const i386_esp_ptr;
diff --git a/linux/ia64/arch_regs.h b/linux/ia64/arch_regs.h
new file mode 100644 (file)
index 0000000..519b24f
--- /dev/null
@@ -0,0 +1,4 @@
+#include <asm/ptrace_offsets.h>
+#include <asm/rse.h>
+
+extern bool ia64_ia32mode;
diff --git a/linux/mips/arch_regs.h b/linux/mips/arch_regs.h
new file mode 100644 (file)
index 0000000..59039c6
--- /dev/null
@@ -0,0 +1,5 @@
+#define REG_V0 2
+#define REG_A0 4
+#define REG_A3 7
+#define REG_SP 29
+#define REG_EPC 64
diff --git a/linux/powerpc/arch_regs.h b/linux/powerpc/arch_regs.h
new file mode 100644 (file)
index 0000000..1296e83
--- /dev/null
@@ -0,0 +1 @@
+extern struct pt_regs ppc_regs;
diff --git a/linux/sh64/arch_regs.h b/linux/sh64/arch_regs.h
new file mode 100644 (file)
index 0000000..7f64b49
--- /dev/null
@@ -0,0 +1,15 @@
+/* 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)
diff --git a/linux/sparc/arch_regs.h b/linux/sparc/arch_regs.h
new file mode 100644 (file)
index 0000000..4dcae3b
--- /dev/null
@@ -0,0 +1,6 @@
+extern struct pt_regs sparc_regs;
+/* 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
+#define U_REG_O0 7
+#define U_REG_O1 8
diff --git a/linux/sparc64/arch_regs.h b/linux/sparc64/arch_regs.h
new file mode 100644 (file)
index 0000000..a49ad53
--- /dev/null
@@ -0,0 +1 @@
+#include "sparc/arch_regs.h"
diff --git a/linux/tile/arch_regs.h b/linux/tile/arch_regs.h
new file mode 100644 (file)
index 0000000..cd3f72b
--- /dev/null
@@ -0,0 +1 @@
+extern struct pt_regs tile_regs;
diff --git a/linux/x86_64/arch_regs.h b/linux/x86_64/arch_regs.h
new file mode 100644 (file)
index 0000000..ced226f
--- /dev/null
@@ -0,0 +1 @@
+#include "i386/arch_regs.h"
index 677c603cbffa439d6d4993ae656f918d67042df1..72c09b7884fafb878eaf2ca0caea6e3c81777e6f 100644 (file)
--- a/process.c
+++ b/process.c
 
 #include "xlat/nt_descriptor_types.h"
 
-#include <sys/user.h>
-#ifdef HAVE_SYS_REG_H
-# include <sys/reg.h>
-#endif
-
 #include "ptrace.h"
-
-#if defined(SPARC64)
-# define r_pc r_tpc
-# undef PTRACE_GETREGS
-# define PTRACE_GETREGS PTRACE_GETREGS64
-# undef PTRACE_SETREGS
-# define PTRACE_SETREGS PTRACE_SETREGS64
-#endif
-
 #include "xlat/ptrace_cmds.h"
 #include "xlat/ptrace_setoptions_flags.h"
 
-#if defined(IA64)
-# include <asm/ptrace_offsets.h>
-# include <asm/rse.h>
-#endif
+#include "regs.h"
 
 #define uoff(member)   offsetof(struct user, member)
 #define XLAT_UOFF(member)      { uoff(member), "offsetof(struct user, " #member ")" }
diff --git a/regs.h b/regs.h
new file mode 100644 (file)
index 0000000..9b0746c
--- /dev/null
+++ b/regs.h
@@ -0,0 +1,7 @@
+#include <sys/user.h>
+
+#ifdef HAVE_SYS_REG_H
+# include <sys/reg.h>
+#endif
+
+#include "arch_regs.h"
index 8fd91b67e2c658464f8bfc8c7794a60d7146c85f..b1a486a60c49149bcb2d566686a9cf4f8794d95d 100644 (file)
--- a/signal.c
+++ b/signal.c
 
 #include "defs.h"
 #include <fcntl.h>
-#include <sys/user.h>
-
-#ifdef HAVE_SYS_REG_H
-# include <sys/reg.h>
-#endif
 
 #include "ptrace.h"
-
-#ifdef IA64
-# include <asm/ptrace_offsets.h>
-#endif
+#include "regs.h"
 
 #if defined(SPARC) || defined(SPARC64) || defined(MIPS)
 typedef struct {
index a02ab040cb209341fca69af5884bfe0251e77118..250f49c2a094a8fe86b3ded4c26ad1db76796335 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -42,9 +42,6 @@
 #ifdef HAVE_PRCTL
 # include <sys/prctl.h>
 #endif
-#if defined(IA64)
-# include <asm/ptrace_offsets.h>
-#endif
 
 #include "ptrace.h"
 
index adc17857f35fbd695c08f5c371d7189d444506de..e2b1626f8a123b57b9be670f4b98c3142082e2e8 100644 (file)
--- a/syscall.c
+++ b/syscall.c
  */
 
 #include "defs.h"
-#include <sys/user.h>
 #include <sys/param.h>
 
-#ifdef HAVE_SYS_REG_H
-# include <sys/reg.h>
+/* for struct iovec */
+#include <sys/uio.h>
+/* for NT_PRSTATUS */
+#ifdef HAVE_ELF_H
+# include <elf.h>
 #endif
 
 #include "ptrace.h"
 # define PTRACE_SETREGS PTRACE_SETREGS64
 #endif
 
-#if defined(IA64)
-# include <asm/ptrace_offsets.h>
-# include <asm/rse.h>
-#endif
+#include "regs.h"
 
-/* for struct iovec */
-#include <sys/uio.h>
-/* for NT_PRSTATUS */
-#ifdef HAVE_ELF_H
-# include <elf.h>
+#if defined SPARC64
+# include <asm/psrcompat.h>
+#elif defined SPARC
+# include <asm/psr.h>
 #endif
 
 #ifndef NSIG
@@ -715,6 +713,27 @@ static long bfin_r0;
 struct pt_regs arm_regs; /* not static */
 # define ARCH_REGS_FOR_GETREGSET arm_regs
 #elif defined(AARCH64)
+struct arm_pt_regs {
+        int uregs[18];
+};
+# define ARM_cpsr       uregs[16]
+# define ARM_pc         uregs[15]
+# define ARM_lr         uregs[14]
+# define ARM_sp         uregs[13]
+# define ARM_ip         uregs[12]
+# define ARM_fp         uregs[11]
+# define ARM_r10        uregs[10]
+# define ARM_r9         uregs[9]
+# define ARM_r8         uregs[8]
+# define ARM_r7         uregs[7]
+# define ARM_r6         uregs[6]
+# define ARM_r5         uregs[5]
+# define ARM_r4         uregs[4]
+# define ARM_r3         uregs[3]
+# define ARM_r2         uregs[2]
+# define ARM_r1         uregs[1]
+# define ARM_r0         uregs[0]
+# define ARM_ORIG_r0    uregs[17]
 static union {
        struct user_pt_regs aarch64_r;
        struct arm_pt_regs  arm_r;
diff --git a/util.c b/util.c
index c96ccdacbf81c58e6ca62575692043e68284260c..caca556d9f66f46b35c62cb7b2b411bb33a09f73 100644 (file)
--- a/util.c
+++ b/util.c
@@ -32,7 +32,6 @@
  */
 
 #include "defs.h"
-#include <sys/user.h>
 #include <sys/param.h>
 #include <fcntl.h>
 #if HAVE_SYS_XATTR_H
 #endif
 #include <sys/uio.h>
 
-#if defined(IA64)
-# include <asm/ptrace_offsets.h>
-# include <asm/rse.h>
-#endif
-
-#ifdef HAVE_SYS_REG_H
-# include <sys/reg.h>
-#endif
-
 #include "ptrace.h"
+#include "regs.h"
 
 int
 string_to_uint(const char *str)