]> granicus.if.org Git - strace/commitdiff
Introduce HAVE_STRUCT_TCB_EXT_ARG macro
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 17 Jun 2016 16:12:13 +0000 (16:12 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 17 Jun 2016 16:12:13 +0000 (16:12 +0000)
Check for "if HAVE_STRUCT_TCB_EXT_ARG" instead of
"if defined LINUX_MIPSN32 || defined X32".

* defs.h (HAVE_STRUCT_TCB_EXT_ARG): Define for LINUX_MIPSN32 || X32.
(struct tcb): Check it instead of LINUX_MIPSN32 || X32.
(RVAL_LUDECIMAL): Likewise.
* io.c (print_lld_from_low_high_val): Likewise.
* lseek.c (SYS_FUNC(lseek)): Likewise.
* mem.c (SYS_FUNC(mmap)): Likewise.
* syscall.c (trace_syscall_exiting): Likewise.
* util.c (getllval): Likewise.

defs.h
io.c
lseek.c
mem.c
syscall.c
util.c

diff --git a/defs.h b/defs.h
index 724d4f3c47fd3fb06dfa78a3a137d431fbfef232..61794d4a785dfb7fad2a747921bdfa3ba648712e 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -288,6 +288,12 @@ typedef struct ioctlent {
        unsigned int code;
 } struct_ioctlent;
 
+#if defined LINUX_MIPSN32 || defined X32
+# define HAVE_STRUCT_TCB_EXT_ARG 1
+#else
+# define HAVE_STRUCT_TCB_EXT_ARG 0
+#endif
+
 /* Trace Control Block */
 struct tcb {
        int flags;              /* See below for TCB_ values */
@@ -296,7 +302,7 @@ struct tcb {
        int u_error;            /* Error code */
        long scno;              /* System call number */
        long u_arg[MAX_ARGS];   /* System call arguments */
-#if defined(LINUX_MIPSN32) || defined(X32)
+#if HAVE_STRUCT_TCB_EXT_ARG
        long long ext_arg[MAX_ARGS];
        long long u_lrval;      /* long long return value */
 #endif
@@ -382,14 +388,14 @@ extern const struct xlat whence_codes[];
 #define RVAL_HEX       001     /* hex format */
 #define RVAL_OCTAL     002     /* octal format */
 #define RVAL_UDECIMAL  003     /* unsigned decimal format */
-#if defined(LINUX_MIPSN32) || defined(X32)
+#if HAVE_STRUCT_TCB_EXT_ARG
 # if 0 /* unused so far */
 #  define RVAL_LDECIMAL        004     /* long decimal format */
 #  define RVAL_LHEX    005     /* long hex format */
 #  define RVAL_LOCTAL  006     /* long octal format */
 # endif
 # define RVAL_LUDECIMAL        007     /* long unsigned decimal format */
-#endif
+#endif /* HAVE_STRUCT_TCB_EXT_ARG */
 #define RVAL_FD                010     /* file descriptor */
 #define RVAL_MASK      017     /* mask for these values */
 
diff --git a/io.c b/io.c
index 87b5f47f4feee35998abce59f47ca2e3cc1c40b7..3025486bed60535a62245e36388077bf1c71005b 100644 (file)
--- a/io.c
+++ b/io.c
@@ -180,7 +180,7 @@ SYS_FUNC(pwrite)
 static void
 print_lld_from_low_high_val(struct tcb *tcp, int arg)
 {
-#if SIZEOF_LONG == SIZEOF_LONG_LONG
+#if SIZEOF_LONG > 4 && SIZEOF_LONG == SIZEOF_LONG_LONG
 # if SUPPORTED_PERSONALITIES > 1
 #  ifdef X86_64
        if (current_personality != 1)
@@ -195,12 +195,20 @@ print_lld_from_low_high_val(struct tcb *tcp, int arg)
                        ((unsigned long) tcp->u_arg[arg + 1] << current_wordsize * 8)
                        | (unsigned long) tcp->u_arg[arg]);
 # endif
-#else
-# ifdef X32
-       if (current_personality == 0)
-               tprintf("%lld", tcp->ext_arg[arg]);
-       else
+#elif SIZEOF_LONG > 4
+# error Unsupported configuration: SIZEOF_LONG > 4 && SIZEOF_LONG_LONG > SIZEOF_LONG
+#elif HAVE_STRUCT_TCB_EXT_ARG
+# if SUPPORTED_PERSONALITIES > 1
+       if (current_personality == 1) {
+               tprintf("%lld",
+                       (widen_to_ull(tcp->u_arg[arg + 1]) << sizeof(long) * 8)
+                       | widen_to_ull(tcp->u_arg[arg]));
+       } else
 # endif
+       {
+               tprintf("%lld", tcp->ext_arg[arg]);
+       }
+#else /* SIZEOF_LONG_LONG > SIZEOF_LONG && !HAVE_STRUCT_TCB_EXT_ARG */
        tprintf("%lld",
                (widen_to_ull(tcp->u_arg[arg + 1]) << sizeof(long) * 8)
                | widen_to_ull(tcp->u_arg[arg]));
diff --git a/lseek.c b/lseek.c
index 133ddd853bda373bc38726b607ceb8348f8d36f8..8d05dc1a5d265d96e41d519af0fa3e8fe1565d6c 100644 (file)
--- a/lseek.c
+++ b/lseek.c
  * which means that on x32 we need to use tcp->ext_arg[N] to get offset argument.
  * Use test/x32_lseek.c to test lseek decoding.
  */
-#if defined(LINUX_MIPSN32) || defined(X32)
+#if HAVE_STRUCT_TCB_EXT_ARG
 SYS_FUNC(lseek)
 {
        printfd(tcp, tcp->u_arg[0]);
 
        long long offset;
-# ifdef X32
-       /* tcp->ext_arg is not initialized for i386 personality */
-       if (current_personality == 1)
+# if SUPPORTED_PERSONALITIES > 1
+       /* tcp->ext_arg is not initialized for compat personality */
+       if (current_personality == 1) {
                offset = tcp->u_arg[1];
-       else
+       else
 # endif
-       offset = tcp->ext_arg[1];
+       {
+               offset = tcp->ext_arg[1];
+       }
        int whence = tcp->u_arg[2];
 
        tprintf(", %lld, ", offset);
diff --git a/mem.c b/mem.c
index b2c7abbc76043bc16b13d459f8cf50d0c584a1a9..affc9355c256227303cd909701e175180fd075e7 100644 (file)
--- a/mem.c
+++ b/mem.c
@@ -135,10 +135,11 @@ SYS_FUNC(old_mmap_pgoff)
 /* Params are passed directly, offset is in bytes */
 SYS_FUNC(mmap)
 {
-       unsigned long long offset = (unsigned long) tcp->u_arg[5];
-#if defined(LINUX_MIPSN32) || defined(X32)
-       /* Try test/x32_mmap.c */
-       offset = tcp->ext_arg[5];
+       unsigned long long offset =
+#if HAVE_STRUCT_TCB_EXT_ARG
+               tcp->ext_arg[5];        /* try test/x32_mmap.c */
+#else
+               (unsigned long) tcp->u_arg[5];
 #endif
        /* Example of kernel-side handling of this variety of mmap:
         * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls
index 01e4b31d577c869c4522a30ce681620337cc46de..c61f827ee153d0638547902323eb670a07523245 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -1042,7 +1042,7 @@ trace_syscall_exiting(struct tcb *tcp)
                                else
                                        tprintf("= %ld", tcp->u_rval);
                                break;
-#if defined(LINUX_MIPSN32) || defined(X32)
+#if HAVE_STRUCT_TCB_EXT_ARG
                        /*
                        case RVAL_LHEX:
                                tprintf("= %#llx", tcp->u_lrval);
@@ -1059,7 +1059,7 @@ trace_syscall_exiting(struct tcb *tcp)
                                tprintf("= %lld", tcp->u_lrval);
                                break;
                        */
-#endif
+#endif /* HAVE_STRUCT_TCB_EXT_ARG */
                        default:
                                error_msg("invalid rval format");
                                break;
diff --git a/util.c b/util.c
index ea2e8699beb5cd120ba74ffb4b2dc8ff0f0a92de..bb23eeb5eae99e6e11b4d2bc53b6bc1066453864 100644 (file)
--- a/util.c
+++ b/util.c
@@ -257,16 +257,16 @@ getllval(struct tcb *tcp, unsigned long long *val, int arg_no)
 # endif /* SUPPORTED_PERSONALITIES > 1 */
 #elif SIZEOF_LONG > 4
 #  error Unsupported configuration: SIZEOF_LONG > 4 && SIZEOF_LONG_LONG > SIZEOF_LONG
-#elif defined LINUX_MIPSN32
-       *val = tcp->ext_arg[arg_no];
-       arg_no++;
-#elif defined X32
-       if (current_personality == 0) {
-               *val = tcp->ext_arg[arg_no];
-               arg_no++;
-       } else {
+#elif HAVE_STRUCT_TCB_EXT_ARG
+# if SUPPORTED_PERSONALITIES > 1
+       if (current_personality == 1) {
                *val = LONG_LONG(tcp->u_arg[arg_no], tcp->u_arg[arg_no + 1]);
                arg_no += 2;
+       } else
+# endif
+       {
+               *val = tcp->ext_arg[arg_no];
+               arg_no++;
        }
 #else
 # if defined __ARM_EABI__ || \