Szabolcs Nagy [Tue, 15 Dec 2015 18:32:17 +0000 (18:32 +0000)]
Fix SYS_FUNC and SEN macros for musl
The syscall_name argument was subject to macro expansion because
it was passed down to other macros before it was prefixed.
musl libc defines lfs64 names as macros (e.g. fstat64 as fstat)
so SYS_FUNC(fstat64) was expanded to sys_fstat.
This change adds the prefix before the name is passed to other macros,
i.e. the argument of SYS_FUNC_NAME is already prefixed with sys_.
* defs.h (SYS_FUNC): Add sys_ prefix to SYS_FUNC_NAME's argument.
(SYS_FUNC_NAME): Do not add sys_ prefix to MPERS_FUNC_NAME's argument.
* linux/ia64/syscallent.h (SYS_FUNC_NAME): Do not add sys_ prefix
to MPERS_FUNC_NAME's argument.
* syscall.c (SEN_NAME): Remove.
(SEN): Replace SEN_NAME call with its definition. Add sys_ prefix
to SYS_FUNC_NAME's argument.
Dmitry V. Levin [Tue, 15 Dec 2015 12:58:42 +0000 (12:58 +0000)]
mpers.awk: make fillers added to the output structure more predictable
* mpers.awk (array_seq): New function.
(what_is): Use it for printing filler names. Tweak return types.
* mpers_test.sh: Use a more complicated sample type to test mpers
machinery.
The only platform which is known at this moment to fail the test
is CentOS-5 provided by OBS. On x86_64 instance it fails with
error: "prlimit64" syscall #300 is "fanotify_init" in syscallent.h
and on i586 it similarly fails with
error: "prlimit64" syscall #338 is "fanotify_init" in syscallent.h
So this is a real platform bug that is not likely to be worked around
on the strace side.
Dmitry V. Levin [Wed, 9 Dec 2015 02:07:44 +0000 (02:07 +0000)]
ia64: print all ia32 syscalls using printargs
Printing of ia32 syscalls on ia64 must have been broken for a long time.
Do not pretend that it works, print ia32 syscalls using printargs
instead.
* linux/ia64/syscallent.h: Remove all redefinitions of sys_* macros.
Stop including"../dummy.h". Include "../i386/syscallent.h" with
SYS_FUNC_NAME macro temporarily redirected to printargs.
Dmitry V. Levin [Wed, 9 Dec 2015 00:43:39 +0000 (00:43 +0000)]
aarch64: swap 64-bit and 32-bit personalities
Let native 64-bit personality be personality 0, and 32-bit personality
be personality 1, to follow the traditional layout used for other
architectures.
* defs.h [AARCH64]: Swap PERSONALITY0_WORDSIZE and
PERSONALITY1_WORDSIZE, remove DEFAULT_PERSONALITY.
[AARCH64 && HAVE_M32_MPERS]: Rename PERSONALITY1_* to PERSONALITY0_*.
* file.c [AARCH64 || defined X86_64 || defined X32]: Define
STAT32_PERSONALITY for AARCH64 as well.
* syscall.c (update_personality) [AARCH64]: Adjust PERSONALITY_NAMES.
* linux/aarch64/errnoent1.h: Adjust comment.
* linux/aarch64/get_error.c (get_error): Adjust tcp->currpers check.
* linux/aarch64/get_syscall_args.c (get_syscall_args): Likewise.
* linux/arm/arch_sigreturn.c (arch_sigreturn) [AARCH64]: Likewise.
* linux/aarch64/get_scno.c (arch_get_scno): Adjust update_personality
invocations.
* linux/aarch64/ioctls_arch0.h: Swap with ...
* linux/aarch64/ioctls_arch1.h: ... this file.
* linux/aarch64/ioctls_inc0.h: Swap with ...
* linux/aarch64/ioctls_inc1.h: ... this file.
* linux/aarch64/syscallent.h: Swap with ...
* linux/aarch64/syscallent1.h: ... this file.
Dmitry V. Levin [Tue, 8 Dec 2015 00:24:53 +0000 (00:24 +0000)]
build: add -D_FILE_OFFSET_BITS=64 to _CPPFLAGS instead of _CFLAGS
* tests/Makefile.am (fstat64_CFLAGS): Rename to fstat64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(fstatat64_CFLAGS): Rename to fstatat64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(ftruncate64_CFLAGS): Rename to ftruncate64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(lstat64_CFLAGS): Rename to lstat64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(mmap64_CFLAGS): Rename to mmap64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(newfstatat_CFLAGS): Rename to newfstatat_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(stat64_CFLAGS): Rename to stat64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(statfs_CFLAGS): Rename to statfs_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(truncate64_CFLAGS): Rename to truncate64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(uio_CFLAGS): Rename to uio_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
Dmitry V. Levin [Tue, 8 Dec 2015 00:14:26 +0000 (00:14 +0000)]
Move x32 <asm/stat.h> replacement to x32 specific directory
As tests-m*32/Makefile.am files now refer to proper arch specific
directories, it's possible to relocate x32 <asm/stat.h> replacement
to its arch specific directory.
Dmitry V. Levin [Tue, 8 Dec 2015 00:14:10 +0000 (00:14 +0000)]
build: set arch specific -m switches in tests-m*32/Makefile.am files properly
* tests/Makefile.am (ARCH_MFLAGS, AM_LDFLAGS): New variables.
(AM_CPPFLAGS): Use ARCH_MFLAGS.
* bootstrap: In tests-m32/Makefile.am and tests-mx32/Makefile.am,
add -m32 and -mx32, respectively, to ARCH_MFLAGS instead of AM_CFLAGS.
Dmitry V. Levin [Tue, 8 Dec 2015 00:13:38 +0000 (00:13 +0000)]
build: initialize ARCH variable in tests-m*32/Makefile.am files properly
* configure.ac (arch_m32): Set to sparc on sparc64, powerpc on
powerpc64, arm on aarch64, i386 on x86_64 and x32, $arch in other cases.
(arch_mx32): Set to x32 on x86_64, $arch in other cases.
(AC_SUBST): Add arch_m32 and arch_mx32.
* bootstrap: Substitute @arch@ with @arch_m32@ in tests-m32/Makefile.am.
Substitute @arch@ with @arch_mx32@ in tests-mx32/Makefile.am.
Dmitry V. Levin [Sun, 6 Dec 2015 05:28:11 +0000 (05:28 +0000)]
times.test: workaround buggy libc
* tests/times.c: Include <sys/syscall.h>.
(main): On systems where user's and kernel's long types are the same,
prefer direct times syscall over libc's times function because
the latter is more prone to return value truncation.
Dmitry V. Levin [Sun, 6 Dec 2015 04:51:57 +0000 (04:51 +0000)]
times.test: reduce cpu time consumption, increase struct tms diversity
* tests/times.c (main): Reduce cpu time consumption fourfold,
make the parent process consume less cpu time than the child process
so that members of the structure returned by times syscall would be
more likely to contain different values.
Dmitry V. Levin [Sat, 5 Dec 2015 00:03:49 +0000 (00:03 +0000)]
tests: replace old stat tests with stat.test and stat64.test
* tests/stat.c: Replace with a wrapper around lstatx.c
* tests/stat.test: Replace with a wrapper around statx.sh.
* tests/stat32-v.test: Remove.
* tests/stat32.c: Remove.
* tests/stat64-v.test: Remove.
* tests/stat64.c: New file.
* tests/stat64.test: New test.
* tests/Makefile.am (check_PROGRAMS): Replace stat32 with stat64.
(stat_CFLAGS): Rename to stat64_CFLAGS.
(TESTS): Replace stat32-v.test and stat64-v.test with stat64.test.
* tests/.gitignore: Replace stat32 with stat64.
Dmitry V. Levin [Sat, 5 Dec 2015 00:01:56 +0000 (00:01 +0000)]
tests: prepare for detailed testing of stat family syscalls
Parametrize code from fstatat.c to support <asm/stat.h>
as an alternative to <sys/stat.h> and move it to a separate file.
* tests/statx.sh: New file, based on fstatat64.test.
* tests/fstatat64.test: Use it.
* tests/newfstatat.test: Likewise.
* tests/xstatx.c: New file, based on fstatat.c.
* tests/fstatat.c: Use it.
* tests/Makefile.am (EXTRA_DIST): Add statx.sh and xstatx.c.
* tests/fstatat64.c (FSTATAT_NAME): Change to TEST_SYSCALL_NAME.
* tests/newfstatat.c: Likewise.
Gabriel Laskar [Fri, 4 Dec 2015 00:07:33 +0000 (01:07 +0100)]
ioctl: allow to stop decoding number
For some ioctls, like from drm, the identification of the correct ioctl
is done by custom code. Specifying IOCTL_NUMBER_STOP_LOOKUP on
return of ioctl_decode_command_number() disables further calls to
ioctl_lookup().
* defs.h (IOCTL_NUMBER_UNKNOWN, IOCTL_NUMBER_HANDLED,
IOCTL_NUMBER_STOP_LOOKUP): Add macros representing ioctl number state
decoding.
* ioctl.c (SYS_FUNC(ioctl)): Skip ioctl_lookup() when
ioctl_decode_command_number() returns a value with
IOCTL_NUMBER_STOP_LOOKUP flag is set.
Suggested-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Dmitry V. Levin [Fri, 4 Dec 2015 16:51:11 +0000 (16:51 +0000)]
tests: skip restart_syscall.test on x32
The syscall number of restart_syscall returned by the kernel in case
of ERESTART_RESTARTBLOCK is broken on x32 from the beginning, see
https://lkml.org/lkml/2015/11/30/790
Dmitry V. Levin [Fri, 4 Dec 2015 15:00:37 +0000 (15:00 +0000)]
x86_64, x32: add a replacement for <asm/stat.h>
Some old kernel headers, Ubuntu 14.04 in particular, provide
<asm/stat.h> editions that are completely wrong for x32.
Workaround this issue by providing a replacement.
Dmitry V. Levin [Thu, 3 Dec 2015 15:48:43 +0000 (15:48 +0000)]
fstatat64.test: lift /proc requirement
While -P option needs /proc to match descriptors, it does not use
/proc to match pathnames. As this test does not need descriptor
match, the /proc requirement can be safely lifted.
Dmitry V. Levin [Mon, 30 Nov 2015 13:57:51 +0000 (13:57 +0000)]
syscall.c: move inclusion of arch specific files to the end of file
Move inclusion of arch specific files that define static functions to
the end of syscall.c.
* syscall.c (get_syscall_result_regs, get_error, getregs_old):
New forward declarations.
(arch_get_scno): Move forward.
Move inclusion of "get_scno.c", "get_syscall_args.c",
"get_syscall_result.c", "get_error.c", and "getregs_old.c"
to the end of file.
Dmitry V. Levin [Mon, 30 Nov 2015 03:30:51 +0000 (03:30 +0000)]
Cleanup print_pc
Apparently, there are only two types of instruction pointer printers
depending on the architecture: those that print a register that was
fetched earlier, and those that fetch a register themselves using upeek.
With this change, architectures of the first type have ARCH_PC_REG
defined in their arch_regs.c file, architectures of the first type
have ARCH_PC_PEEK_ADDR defined there, and the common code in syscall.c
uses these macros to print the instruction pointer.
Dmitry V. Levin [Mon, 30 Nov 2015 01:46:52 +0000 (01:46 +0000)]
cleanup: make get_scno.c files more readable
Make get_scno.c files more self-contained. While they are still
being included by syscall.c, the latter no longer provides
a function framework for them.
Dmitry V. Levin [Mon, 30 Nov 2015 00:57:14 +0000 (00:57 +0000)]
cleanup: make get_syscall_args.c files more readable
Make get_syscall_args.c files more self-contained. While they are
still being included by syscall.c, the latter no longer defines
get_syscall_args function.
Dmitry V. Levin [Mon, 30 Nov 2015 00:01:01 +0000 (00:01 +0000)]
cleanup: make get_syscall_result.c files more readable
Make get_syscall_result.c files more self-contained. While they are
still being included by syscall.c, the latter no longer provides
a function framework for them.
Dmitry V. Levin [Sat, 28 Nov 2015 02:58:29 +0000 (02:58 +0000)]
cleanup: make arch_sigreturn.c files more readable
Make arch_sigreturn.c files more self-sustained. While they are
still being included by sigreturn.c, the latter no longer defines
arch_sigreturn function.
* linux/alpha/arch_sigreturn.c (arch_sigreturn): Define.
* linux/arm/arch_sigreturn.c: Likewise.
* linux/crisv10/arch_sigreturn.c: Likewise.
* linux/i386/arch_sigreturn.c: Likewise.
* linux/ia64/arch_sigreturn.c: Likewise.
* linux/m68k/arch_sigreturn.c: Likewise.
* linux/microblaze/arch_sigreturn.c: Likewise.
* linux/mips/arch_sigreturn.c: Likewise.
* linux/powerpc/arch_sigreturn.c: Likewise.
* linux/s390/arch_sigreturn.c: Likewise.
* linux/sparc/arch_sigreturn.c: Likewise.
* linux/tile/arch_sigreturn.c: Likewise.
* linux/x32/arch_sigreturn.c: Remove code.
Include "x86_64/arch_sigreturn.c".
* linux/x86_64/arch_sigreturn.c: Stop including "x32/arch_sigreturn.c".
Include "i386/arch_sigreturn.c" with arch_sigreturn temporarily defined
to i386_arch_sigreturn.
(arch_sigreturn): Define. Add x32 personality support there.
* sigreturn.c: Remove arch_sigreturn header and footer.
Dmitry V. Levin [Fri, 27 Nov 2015 01:51:22 +0000 (01:51 +0000)]
x32: fix struct dirent decoding
* kernel_types.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* configure.ac (AC_CHECK_TYPES): Check for __kernel_long_t
and __kernel_ulong_t in <asm/posix_types.h>.
* dirent.c: Stop including <dirent.h>.
(kernel_dirent): Remove.
Include "kernel_types.h".
(print_old_dirent, SYS_FUNC(getdents)): Print variables
of kernel_ulong_t type using %Lu format.
* syscall.c (kernel_long_t, kernel_ulong_t): Remove.
Include "kernel_types.h".
* tests/getdents.c (kernel_dirent): Remove.
Include "kernel_types.h".
(print_dirent): Print variables of kernel_ulong_t type using %Lu format.
Elvira Khabirova [Thu, 26 Nov 2015 14:18:00 +0000 (17:18 +0300)]
Refer to -h on incorrect usage
* defs.h (error_msg_and_help): New prototype.
* strace.c (error_msg_and_help): New function.
(error_opt_arg, init): Use it.
(usage): Remove unnecessary arguments.
* count.c: Use the new function.
Convert parsers of flock structures to new mpers infrastructure
* fetch_struct_flock.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* fcntl.c (print_struct_flock64): New function.
(printflock64): Use fetch_struct_flock64 and print_struct_flock64.
(printflock): Use fetch_struct_flock and print_struct_flock64.