strace/test
Denys Vlasenko 1ba85436de Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!

It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.

Then we just insert correct function pointers into
arch syscall tables.

It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.

A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.

There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.

* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 11:54:36 +01:00
..
.gitignore Add new test program: test/threaded_execve.c 2012-01-27 15:37:13 +01:00
childthread.c Whitespace cleanups. no code changes. 2011-06-07 12:13:24 +02:00
clone.c Update test/* directory, it seem to be a bit bit-rotted 2011-06-08 14:08:59 +02:00
fork.c By Hans-Christian Egtvedt (hans-christian.egtvedt AT atmel.com): 2009-02-25 14:24:02 +00:00
leaderkill.c Whitespace cleanups. no code changes. 2011-06-07 12:13:24 +02:00
Makefile Tidy up includes and copyright notices, fix indentation 2012-03-16 12:02:22 +01:00
mmap_offset_decode.c Clean up mmap decoding 2013-02-19 11:54:36 +01:00
procpollable.c Improve code readability by avoiding assignments inside if() 2011-08-23 12:53:01 +02:00
README Update test/* directory, it seem to be a bit bit-rotted 2011-06-08 14:08:59 +02:00
sfd.c Improve code readability by avoiding assignments inside if() 2011-08-23 12:53:01 +02:00
sig.c By Hans-Christian Egtvedt (hans-christian.egtvedt AT atmel.com): 2009-02-25 14:24:02 +00:00
sigkill_rain.c Add fflush after printf in test/sigkill_rain.c 2011-06-08 16:07:03 +02:00
skodic.c Whitespace cleanups. no code changes. 2011-06-07 12:13:24 +02:00
threaded_execve.c test/threaded_execve: make it also test a case when leader is not in syscall 2012-03-17 01:24:25 +01:00
vfork.c By Hans-Christian Egtvedt (hans-christian.egtvedt AT atmel.com): 2009-02-25 14:24:02 +00:00
wait_must_be_interruptible.c Update test/* directory, it seem to be a bit bit-rotted 2011-06-08 14:08:59 +02:00
x32_lseek.c Remove wrong x32-specific lseek 2013-02-17 13:17:49 +01:00
x32_mmap.c Fixes in "new" mmap 2013-02-18 03:13:07 +01:00

To run a test:
* Run make
* Run resulting executable(s) under strace
* Check strace output and/or program's output and exitcode

To add a new test:
* Add its .c source to this dir
* Add it to "all" and "clean" targets in Makefile
* Add it to .gitignore file

Please spend some time making your testcase understandable.
For example, it may print an explanation how it should be used
(which strace options to use, and what to look for in strace output).

If possible, make it so that your testcase detects error/bug
it is intended to test for, and prints error message and exits with 1
if the bug is detected, instead of relying on user to peruse strace output.