summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-08-19 17:07:38 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-08-23 12:53:01 +0200
commit9aa97968ed75103c1f8a18e079b73328710ebe1e (patch)
tree67f80040815aca748c6f1321b14d6921eff23378 /test
parent31f9cb6f4889c4b3b28993eb259f20ef097b2b6a (diff)
downloadstrace-9aa97968ed75103c1f8a18e079b73328710ebe1e.tar.gz
Optimize sys_old_mmap
* mem.c (sys_old_mmap): For Ia64 and 32-bit personality of x86-64, copy narrow parameters from userspace by single umove, not by six separate ones; then assign them to long u_arg[i]. For SH[64], avoid copying of tcp->u_arg. (sys_mmap): Add FIXME comment - SH64 and i386 seem to be handled differently for no apparent reason. * test/mmap_offset_decode.c: New test program, illustrates FIXME. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/mmap_offset_decode.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/mmap_offset_decode.c b/test/mmap_offset_decode.c
new file mode 100644
index 000000000..875ea9cca
--- /dev/null
+++ b/test/mmap_offset_decode.c
@@ -0,0 +1,31 @@
+/* Should strace show byte or page offsets in mmap syscalls
+ * which take page offset parameters?
+ *
+ * At the time of writing, sys_mmap() converts page to byte offsets,
+ * but only for SH64! But this routine is used on i386 too - by mmap2 syscall,
+ * which uses page offsets too. As it stands now, SH64 and i386 are inconsistent.
+ *
+ * sys_old_mmap() is used for old mmap syscall, which uses byte offset -
+ * should be ok.
+ * sys_mmap64() is currently buggy (should print bogus offset, but I can't
+ * test it right now. What arch/bitness invokes sys_mmap64?)
+ *
+ * This program is intended for testing what strace actually shows. Usage:
+ * $ gcc test/mmap_offset_decode.c -o mmap_offset_decode -static
+ * $ strace ./mmap_offset_decode
+ *
+ * As of today (2011-08), on i386 strace prints page offset.
+ */
+
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+#define _FILE_OFFSET_BITS 64
+#include <sys/mman.h>
+#include <errno.h>
+int main()
+{
+ /* 0x1000 is meant to be page size multiplier */
+ mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
+ 0x7fff0000LL * 0x1000);
+ return errno != 0;
+}