From: Dmitry V. Levin Date: Mon, 26 Dec 2016 02:59:36 +0000 (+0000) Subject: Remove HAVE_STRUCT_TCB_EXT_ARG, ext_arg, and u_lrval X-Git-Tag: v4.16~153 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1e94e9c7af845c06cd447ca12eec2641ceb4e7c;p=strace Remove HAVE_STRUCT_TCB_EXT_ARG, ext_arg, and u_lrval After transition from long to kernel_ulong_t these fields are no longer needed. * defs.h (HAVE_STRUCT_TCB_EXT_ARG): Remove. (struct tcb) [HAVE_STRUCT_TCB_EXT_ARG]: Remove. [HAVE_STRUCT_TCB_EXT_ARG]: Remove. (RVAL_MASK): Update. * io.c (print_lld_from_low_high_val): Check [SIZEOF_KERNEL_LONG_T > SIZEOF_LONG] instead of [HAVE_STRUCT_TCB_EXT_ARG]. Use u_arg instead of ext_arg. * linux/mips/get_error.c (get_error) [LINUX_MIPSN32]: Remove. * linux/mips/get_syscall_args.c (get_syscall_args) [LINUX_MIPSN32]: Remove. [LINUX_MIPSN64]: Extend to [LINUX_MIPSN32]. * linux/x86_64/get_error.c (get_error) [X32]: Remove. * linux/x86_64/get_syscall_args.c (get_syscall_args) [X32]: Remove. * lseek.c: Check [SIZEOF_KERNEL_LONG_T > SIZEOF_LONG] instead of [HAVE_STRUCT_TCB_EXT_ARG]. [SIZEOF_KERNEL_LONG_T > SIZEOF_LONG] (SYS_FUNC(lseek)): Use u_arg instead of ext_arg. Use RVAL_UDECIMAL instead of RVAL_LUDECIMAL. * mem.c (SYS_FUNC(mmap)): Pass offset syscall argument directly to print_mmap. * syscall.c (trace_syscall_exiting) [HAVE_STRUCT_TCB_EXT_ARG]: Remove. * times.c (SYS_FUNC(times)): Use RVAL_UDECIMAL instead of RVAL_LUDECIMAL. * util.c (getllval): Check [SIZEOF_KERNEL_LONG_T > SIZEOF_LONG] instead of [HAVE_STRUCT_TCB_EXT_ARG]. Use u_arg instead of ext_arg. --- diff --git a/defs.h b/defs.h index 71c1d7a1..61a5e120 100644 --- a/defs.h +++ b/defs.h @@ -220,12 +220,6 @@ struct fault_opts { uint16_t err; }; -#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 */ @@ -234,10 +228,6 @@ struct tcb { unsigned long u_error; /* Error code */ kernel_ulong_t scno; /* System call number */ kernel_ulong_t u_arg[MAX_ARGS]; /* System call arguments */ -#if HAVE_STRUCT_TCB_EXT_ARG - unsigned long long ext_arg[MAX_ARGS]; - long long u_lrval; /* long long return value */ -#endif kernel_long_t u_rval; /* Return value */ #if SUPPORTED_PERSONALITIES > 1 unsigned int currpers; /* Personality at the time of scno update */ @@ -329,16 +319,8 @@ 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 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 /* HAVE_STRUCT_TCB_EXT_ARG */ #define RVAL_FD 010 /* file descriptor */ -#define RVAL_MASK 017 /* mask for these values */ +#define RVAL_MASK 013 /* mask for these values */ #define RVAL_STR 020 /* Print `auxstr' field after return val */ #define RVAL_NONE 040 /* Print nothing */ diff --git a/io.c b/io.c index 7088e856..dbef2e65 100644 --- a/io.c +++ b/io.c @@ -189,7 +189,7 @@ print_lld_from_low_high_val(struct tcb *tcp, int arg) } #elif SIZEOF_LONG > 4 # error Unsupported configuration: SIZEOF_LONG > 4 && SIZEOF_LONG_LONG > SIZEOF_LONG -#elif HAVE_STRUCT_TCB_EXT_ARG +#elif SIZEOF_KERNEL_LONG_T > SIZEOF_LONG # ifndef current_klongsize if (current_klongsize < SIZEOF_LONG_LONG) { tprintf("%lld", @@ -198,9 +198,9 @@ print_lld_from_low_high_val(struct tcb *tcp, int arg) } else # endif /* !current_klongsize */ { - tprintf("%lld", tcp->ext_arg[arg]); + tprintf("%" PRI_kld, tcp->u_arg[arg]); } -#else /* SIZEOF_LONG_LONG > SIZEOF_LONG && !HAVE_STRUCT_TCB_EXT_ARG */ +#else /* SIZEOF_LONG_LONG > SIZEOF_LONG && SIZEOF_KERNEL_LONG_T == SIZEOF_LONG */ tprintf("%lld", (zero_extend_signed_to_ull(tcp->u_arg[arg + 1]) << sizeof(long) * 8) | zero_extend_signed_to_ull(tcp->u_arg[arg])); diff --git a/linux/mips/get_error.c b/linux/mips/get_error.c index 42a282b4..4096de26 100644 --- a/linux/mips/get_error.c +++ b/linux/mips/get_error.c @@ -6,9 +6,5 @@ get_error(struct tcb *tcp, const bool check_errno) tcp->u_error = mips_REG_V0; } else { tcp->u_rval = mips_REG_V0; -#ifdef LINUX_MIPSN32 - /* tcp->u_rval contains a truncated value */ - tcp->u_lrval = mips_REG_V0; -#endif } } diff --git a/linux/mips/get_syscall_args.c b/linux/mips/get_syscall_args.c index a20be8de..ca2819bf 100644 --- a/linux/mips/get_syscall_args.c +++ b/linux/mips/get_syscall_args.c @@ -2,20 +2,13 @@ static int get_syscall_args(struct tcb *tcp) { -#if defined LINUX_MIPSN64 +#if defined LINUX_MIPSN64 || defined LINUX_MIPSN32 tcp->u_arg[0] = mips_REG_A0; tcp->u_arg[1] = mips_REG_A1; tcp->u_arg[2] = mips_REG_A2; tcp->u_arg[3] = mips_REG_A3; tcp->u_arg[4] = mips_REG_A4; tcp->u_arg[5] = mips_REG_A5; -#elif defined LINUX_MIPSN32 - tcp->u_arg[0] = tcp->ext_arg[0] = mips_REG_A0; - tcp->u_arg[1] = tcp->ext_arg[1] = mips_REG_A1; - tcp->u_arg[2] = tcp->ext_arg[2] = mips_REG_A2; - tcp->u_arg[3] = tcp->ext_arg[3] = mips_REG_A3; - tcp->u_arg[4] = tcp->ext_arg[4] = mips_REG_A4; - tcp->u_arg[5] = tcp->ext_arg[5] = mips_REG_A5; #elif defined LINUX_MIPSO32 tcp->u_arg[0] = mips_REG_A0; tcp->u_arg[1] = mips_REG_A1; diff --git a/linux/x86_64/get_error.c b/linux/x86_64/get_error.c index ddf78b7c..9411625b 100644 --- a/linux/x86_64/get_error.c +++ b/linux/x86_64/get_error.c @@ -19,9 +19,5 @@ get_error(struct tcb *tcp, const bool check_errno) tcp->u_error = -rax; } else { tcp->u_rval = rax; -#ifdef X32 - /* tcp->u_rval contains a truncated value */ - tcp->u_lrval = rax; -#endif } } diff --git a/linux/x86_64/get_syscall_args.c b/linux/x86_64/get_syscall_args.c index 51d03f5d..df3691a6 100644 --- a/linux/x86_64/get_syscall_args.c +++ b/linux/x86_64/get_syscall_args.c @@ -10,37 +10,19 @@ get_syscall_args(struct tcb *tcp) * Use widen_to_long(tcp->u_arg[N]) in syscall handlers * if you need to use *sign-extended* parameter. */ -#ifdef X32 - tcp->u_arg[0] = tcp->ext_arg[0] = (uint32_t) x86_64_regs.rdi; - tcp->u_arg[1] = tcp->ext_arg[1] = (uint32_t) x86_64_regs.rsi; - tcp->u_arg[2] = tcp->ext_arg[2] = (uint32_t) x86_64_regs.rdx; - tcp->u_arg[3] = tcp->ext_arg[3] = (uint32_t) x86_64_regs.r10; - tcp->u_arg[4] = tcp->ext_arg[4] = (uint32_t) x86_64_regs.r8; - tcp->u_arg[5] = tcp->ext_arg[5] = (uint32_t) x86_64_regs.r9; -#else tcp->u_arg[0] = (uint32_t) x86_64_regs.rdi; tcp->u_arg[1] = (uint32_t) x86_64_regs.rsi; tcp->u_arg[2] = (uint32_t) x86_64_regs.rdx; tcp->u_arg[3] = (uint32_t) x86_64_regs.r10; tcp->u_arg[4] = (uint32_t) x86_64_regs.r8; tcp->u_arg[5] = (uint32_t) x86_64_regs.r9; -#endif } else { -#ifdef X32 - tcp->u_arg[0] = tcp->ext_arg[0] = x86_64_regs.rdi; - tcp->u_arg[1] = tcp->ext_arg[1] = x86_64_regs.rsi; - tcp->u_arg[2] = tcp->ext_arg[2] = x86_64_regs.rdx; - tcp->u_arg[3] = tcp->ext_arg[3] = x86_64_regs.r10; - tcp->u_arg[4] = tcp->ext_arg[4] = x86_64_regs.r8; - tcp->u_arg[5] = tcp->ext_arg[5] = x86_64_regs.r9; -#else tcp->u_arg[0] = x86_64_regs.rdi; tcp->u_arg[1] = x86_64_regs.rsi; tcp->u_arg[2] = x86_64_regs.rdx; tcp->u_arg[3] = x86_64_regs.r10; tcp->u_arg[4] = x86_64_regs.r8; tcp->u_arg[5] = x86_64_regs.r9; -#endif } } else { /* diff --git a/lseek.c b/lseek.c index f23708e6..cc0b375f 100644 --- a/lseek.c +++ b/lseek.c @@ -44,27 +44,26 @@ * 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 HAVE_STRUCT_TCB_EXT_ARG +#if SIZEOF_KERNEL_LONG_T > SIZEOF_LONG SYS_FUNC(lseek) { printfd(tcp, tcp->u_arg[0]); long long offset; # ifndef current_klongsize - /* tcp->ext_arg is not initialized for compat personality */ - if (current_klongsize < sizeof(*tcp->ext_arg)) { + if (current_klongsize < sizeof(*tcp->u_arg)) { offset = (long) tcp->u_arg[1]; } else # endif /* !current_klongsize */ { - offset = tcp->ext_arg[1]; + offset = tcp->u_arg[1]; } int whence = tcp->u_arg[2]; tprintf(", %lld, ", offset); printxval(whence_codes, whence, "SEEK_???"); - return RVAL_DECODED | RVAL_LUDECIMAL; + return RVAL_DECODED | RVAL_UDECIMAL; } #else SYS_FUNC(lseek) diff --git a/mem.c b/mem.c index 350475da..6a541cfb 100644 --- a/mem.c +++ b/mem.c @@ -135,18 +135,12 @@ SYS_FUNC(old_mmap_pgoff) /* Params are passed directly, offset is in bytes */ SYS_FUNC(mmap) { - unsigned long long offset = -#if HAVE_STRUCT_TCB_EXT_ARG - tcp->ext_arg[5]; /* try test/x32_mmap.c */ -#else - 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 * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes, * since the above code converts off to pages. */ - print_mmap(tcp, tcp->u_arg, offset); + print_mmap(tcp, tcp->u_arg, tcp->u_arg[5]); return RVAL_DECODED | RVAL_HEX; } diff --git a/syscall.c b/syscall.c index bc92e567..6178fdab 100644 --- a/syscall.c +++ b/syscall.c @@ -933,24 +933,6 @@ trace_syscall_exiting(struct tcb *tcp) else tprintf("= %" PRI_kld, tcp->u_rval); break; -#if HAVE_STRUCT_TCB_EXT_ARG - /* - 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 /* HAVE_STRUCT_TCB_EXT_ARG */ default: error_msg("invalid rval format"); break; diff --git a/times.c b/times.c index 6af4f95a..b165a2b0 100644 --- a/times.c +++ b/times.c @@ -53,10 +53,5 @@ SYS_FUNC(times) zero_extend_signed_to_ull(tbuf.tms_cstime)); } - return syserror(tcp) ? RVAL_DECIMAL : -#if defined(RVAL_LUDECIMAL) && !defined(IN_MPERS) - RVAL_LUDECIMAL; -#else - RVAL_UDECIMAL; -#endif + return syserror(tcp) ? RVAL_DECIMAL : RVAL_UDECIMAL; } diff --git a/util.c b/util.c index 49a5c4b7..73c8fd49 100644 --- a/util.c +++ b/util.c @@ -313,15 +313,15 @@ getllval(struct tcb *tcp, unsigned long long *val, int arg_no) } #elif SIZEOF_LONG > 4 # error Unsupported configuration: SIZEOF_LONG > 4 && SIZEOF_LONG_LONG > SIZEOF_LONG -#elif HAVE_STRUCT_TCB_EXT_ARG +#elif SIZEOF_KERNEL_LONG_T > SIZEOF_LONG # ifndef current_klongsize - if (current_klongsize < SIZEOF_LONG_LONG) { + if (current_klongsize < SIZEOF_KERNEL_LONG_T) { *val = ULONG_LONG(tcp->u_arg[arg_no], tcp->u_arg[arg_no + 1]); arg_no += 2; } else # endif /* !current_klongsize */ { - *val = tcp->ext_arg[arg_no]; + *val = tcp->u_arg[arg_no]; arg_no++; } #else