From: H.J. Lu Date: Mon, 16 Apr 2012 10:16:45 +0000 (+0200) Subject: Restore tcb::u_lrval; fix lseek on MIPS-n32 X-Git-Tag: v4.7~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dd0130b963151e37cffc8b593bebe3e3de58dfd4;p=strace Restore tcb::u_lrval; fix lseek on MIPS-n32 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 Signed-off-by: Denys Vlasenko --- diff --git a/defs.h b/defs.h index 1ebbd292..7cf91b73 100644 --- 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 1a448cde..fa4b3149 100644 --- 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 diff --git a/syscall.c b/syscall.c index ddc461c7..7f3ff346 100644 --- 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");