]> granicus.if.org Git - strace/commitdiff
Restore tcb::u_lrval; fix lseek on MIPS-n32
authorH.J. Lu <hongjiu.lu@intel.com>
Mon, 16 Apr 2012 10:16:45 +0000 (12:16 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 16 Apr 2012 10:16:45 +0000 (12:16 +0200)
Linux kernel v3.4 adds x32 support.  Both x32 and n32 use 64bit offset
for lseek parameter and return value.  We need u_lrval to handle it
properly.  Also we shouldn't check HAVE_LONG_LONG_OFF_T for n32 lseek.
This patch fixes it properly and prepares lseek for x32.

* defs.h (tcb): Restore tcb::u_lrval field, RVAL_Lfoo constants.
Set RVAL_MASK to 7.
* file.c (sys_lseek): Print 64bit offset and return RVAL_LUDECIMAL
for n32.
* syscall.c (get_error): Set u_lrval for MIPS-n32.
(trace_syscall_exiting): Handle RVAL_Lfoo return value types.

Signed-off-by: H.J. Lu <hongjiu.lu@intel.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
defs.h
file.c
syscall.c

diff --git a/defs.h b/defs.h
index 1ebbd29200c589eb7af0ff4f84d710c3d318e8c0..7cf91b730674fb8cb0f06fe5ef8ccfb28b561021 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -327,7 +327,10 @@ struct tcb {
 #if defined(LINUX_MIPSN32)
        long long ext_arg[MAX_ARGS];    /* System call arguments */
 #endif
-       long u_rval;            /* (first) return value */
+       long u_rval;            /* return value */
+#if defined(LINUX_MIPSN32) || defined(X32)
+       long long u_lrval;      /* long long return value */
+#endif
 #if SUPPORTED_PERSONALITIES > 1
        int currpers;           /* Personality at the time of scno update */
 #endif
@@ -418,7 +421,15 @@ extern const struct xlat open_access_modes[];
 #define RVAL_HEX       001     /* hex format */
 #define RVAL_OCTAL     002     /* octal format */
 #define RVAL_UDECIMAL  003     /* unsigned decimal format */
-#define RVAL_MASK      003     /* mask for these values */
+#if defined(LINUX_MIPSN32) || defined(X32)
+# 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
+#define RVAL_MASK      007     /* mask for these values */
 
 #define RVAL_STR       010     /* Print `auxstr' field after return val */
 #define RVAL_NONE      020     /* Print nothing */
diff --git a/file.c b/file.c
index 1a448cde5dbcf63502c56c939ed19f9a4d6d8eab..fa4b3149b63d3bed1cacc2f3ed9fa1b1909f444f 100644 (file)
--- a/file.c
+++ b/file.c
@@ -478,8 +478,7 @@ static const struct xlat whence[] = {
        { 0,            NULL            },
 };
 
-#if !defined(HAVE_LONG_LONG_OFF_T)
-# if defined(LINUX_MIPSN32)
+#if defined(LINUX_MIPSN32)
 int
 sys_lseek(struct tcb *tcp)
 {
@@ -497,9 +496,9 @@ sys_lseek(struct tcb *tcp)
                        tprintf("%lld, ", offset);
                printxval(whence, _whence, "SEEK_???");
        }
-       return RVAL_UDECIMAL;
+       return RVAL_LUDECIMAL;
 }
-# else /* !LINUX_MIPSN32 */
+#else
 int
 sys_lseek(struct tcb *tcp)
 {
@@ -519,7 +518,6 @@ sys_lseek(struct tcb *tcp)
        }
        return RVAL_UDECIMAL;
 }
-# endif
 #endif
 
 int
index ddc461c78db244f0cfc056b583e84919aa69ce24..7f3ff34667815fd00c2f806a7dca80d062e2649a 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -1735,6 +1735,9 @@ get_error(struct tcb *tcp)
                u_error = r2;
        } else {
                tcp->u_rval = r2;
+# if defined(LINUX_MIPSN32)
+               tcp->u_lrval = r2;
+# endif
        }
 #elif defined(POWERPC)
        if (check_errno && is_negated_errno(ppc_result)) {
@@ -2065,6 +2068,24 @@ trace_syscall_exiting(struct tcb *tcp)
                        case RVAL_DECIMAL:
                                tprintf("= %ld", tcp->u_rval);
                                break;
+#if defined(LINUX_MIPSN32) || defined(X32)
+                       /*
+                       case RVAL_LHEX:
+                               tprintf("= %#llx", tcp->u_lrval);
+                               break;
+                       case RVAL_LOCTAL:
+                               tprintf("= %#llo", tcp->u_lrval);
+                               break;
+                       */
+                       case RVAL_LUDECIMAL:
+                               tprintf("= %llu", tcp->u_lrval);
+                               break;
+                       /*
+                       case RVAL_LDECIMAL:
+                               tprintf("= %lld", tcp->u_lrval);
+                               break;
+                       */
+#endif
                        default:
                                fprintf(stderr,
                                        "invalid rval format\n");