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 */
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
#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 */
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)
((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]));
* 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);
/* 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
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);
tprintf("= %lld", tcp->u_lrval);
break;
*/
-#endif
+#endif /* HAVE_STRUCT_TCB_EXT_ARG */
default:
error_msg("invalid rval format");
break;
# 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__ || \