]> granicus.if.org Git - strace/commitdiff
Move SH-specific argument number calculation to getllval
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sat, 20 Aug 2016 14:02:55 +0000 (17:02 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 21 Aug 2016 22:02:20 +0000 (22:02 +0000)
This change prevents scattering of ll-related hacks and simplifies
pread/pwrite syscalls parsers' logic a bit.

* util.c (getllval): Add fixup for arg_no for SuperH when argument
number is equal to 3.
* io.c (PREAD_OFFSET_ARG): Remove.
(SYS_FUNC(pread)): Always use argument number 3 for "count" argument
printing.
(SYS_FUNC(pwrite)): Likewise.

io.c
util.c

diff --git a/io.c b/io.c
index 58323a7c708435bb005b9c1972ed646b66db01e3..ee849733a592beaeb7afaf52c745c4fb0491bfee 100644 (file)
--- a/io.c
+++ b/io.c
@@ -150,17 +150,6 @@ SYS_FUNC(writev)
        return RVAL_DECODED;
 }
 
-/* The SH4 ABI does allow long longs in odd-numbered registers, but
-   does not allow them to be split between registers and memory - and
-   there are only four argument registers for normal functions.  As a
-   result pread takes an extra padding argument before the offset.  This
-   was changed late in the 2.4 series (around 2.4.20).  */
-#if defined(SH)
-#define PREAD_OFFSET_ARG 4
-#else
-#define PREAD_OFFSET_ARG 3
-#endif
-
 SYS_FUNC(pread)
 {
        if (entering(tcp)) {
@@ -172,7 +161,7 @@ SYS_FUNC(pread)
                else
                        printstr(tcp, tcp->u_arg[1], tcp->u_rval);
                tprintf(", %lu, ", tcp->u_arg[2]);
-               printllval(tcp, "%lld", PREAD_OFFSET_ARG);
+               printllval(tcp, "%lld", 3);
        }
        return 0;
 }
@@ -183,7 +172,7 @@ SYS_FUNC(pwrite)
        tprints(", ");
        printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
        tprintf(", %lu, ", tcp->u_arg[2]);
-       printllval(tcp, "%lld", PREAD_OFFSET_ARG);
+       printllval(tcp, "%lld", 3);
 
        return RVAL_DECODED;
 }
diff --git a/util.c b/util.c
index afa32903b71a6fda6db2169ab264626f7df335f0..056711d107c66f96503c49e501b9f24940c58182 100644 (file)
--- a/util.c
+++ b/util.c
@@ -275,7 +275,17 @@ getllval(struct tcb *tcp, unsigned long long *val, int arg_no)
      defined XTENSA
        /* Align arg_no to the next even number. */
        arg_no = (arg_no + 1) & 0xe;
-# endif
+# elif defined SH
+       /*
+        * The SH4 ABI does allow long longs in odd-numbered registers, but
+        * does not allow them to be split between registers and memory - and
+        * there are only four argument registers for normal functions.  As a
+        * result, pread, for example, takes an extra padding argument before
+        * the offset.  This was changed late in the 2.4 series (around 2.4.20).
+        */
+       if (arg_no == 3)
+               arg_no++;
+# endif /* __ARM_EABI__ || LINUX_MIPSO32 || POWERPC || XTENSA || SH */
        *val = LONG_LONG(tcp->u_arg[arg_no], tcp->u_arg[arg_no + 1]);
        arg_no += 2;
 #endif