Fix printing of negative offsets in preadv and pwritev syscalls
* io.c (print_llu_from_low_high_val): Rename to
print_lld_from_low_high_val, all callers changed.
Print value as a signed integer.
* tests/preadv.c: New file.
* tests/preadv.test: New test.
* tests/pwritev.c: New file.
* tests/pwritev.test: New test.
* tests/.gitignore: Add preadv and pwritev.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(preadv_CPPFLAGS, pwritev_CPPFLAGS): New variables.
(DECODER_TESTS): Add preadv.test and pwritev.test.
diff --git a/io.c b/io.c
index aac93ea..cda5f92 100644
--- a/io.c
+++ b/io.c
@@ -186,7 +186,7 @@
}
static void
-print_llu_from_low_high_val(struct tcb *tcp, int arg)
+print_lld_from_low_high_val(struct tcb *tcp, int arg)
{
#if SIZEOF_LONG == SIZEOF_LONG_LONG
# if SUPPORTED_PERSONALITIES > 1
@@ -196,20 +196,20 @@
if (current_wordsize == sizeof(long))
# endif
# endif
- tprintf("%lu", (unsigned long) tcp->u_arg[arg]);
+ tprintf("%ld", tcp->u_arg[arg]);
# if SUPPORTED_PERSONALITIES > 1
else
- tprintf("%lu",
+ tprintf("%ld",
((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("%llu", (unsigned long long) tcp->ext_arg[arg]);
+ tprintf("%lld", tcp->ext_arg[arg]);
else
# endif
- tprintf("%llu",
+ tprintf("%lld",
((unsigned long long) (unsigned long) tcp->u_arg[arg + 1] << sizeof(long) * 8)
| (unsigned long long) (unsigned long) tcp->u_arg[arg]);
#endif
@@ -223,7 +223,7 @@
} else {
tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
tprintf(", %lu, ", tcp->u_arg[2]);
- print_llu_from_low_high_val(tcp, 3);
+ print_lld_from_low_high_val(tcp, 3);
}
return 0;
}
@@ -234,7 +234,7 @@
tprints(", ");
tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
tprintf(", %lu, ", tcp->u_arg[2]);
- print_llu_from_low_high_val(tcp, 3);
+ print_lld_from_low_high_val(tcp, 3);
return RVAL_DECODED;
}