]> granicus.if.org Git - strace/log
strace
8 years agoalpha, ppc, sh, sh64: fix fstatat64 syscall entries
Dmitry V. Levin [Tue, 1 Dec 2015 11:11:30 +0000 (11:11 +0000)]
alpha, ppc, sh, sh64: fix fstatat64 syscall entries

* linux/alpha/syscallent.h (newfstatat): Change sys_name to fstatat64.
* linux/powerpc/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.

8 years agoppc64: clone syscallent.h from ppc
Dmitry V. Levin [Tue, 1 Dec 2015 11:13:47 +0000 (11:13 +0000)]
ppc64: clone syscallent.h from ppc

* linux/powerpc64/syscallent.h: Clone from linux/powerpc/syscallent.h
with entries for numbers 192..197, 204, 226, and 254 unassigned.

8 years agotests: add lseek.test and llseek.test
Dmitry V. Levin [Tue, 1 Dec 2015 00:59:26 +0000 (00:59 +0000)]
tests: add lseek.test and llseek.test

* tests/llseek.c: New file.
* tests/lseek.c: Likewise.
* tests/llseek.test: New test.
* tests/lseek.test: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add llseek and lseek.
(TESTS): Add llseek.test and lseek.test.
* tests/.gitignore: Add llseek and lseek.

8 years agotests: add ftruncate64.test and truncate64.test
Dmitry V. Levin [Tue, 1 Dec 2015 00:32:40 +0000 (00:32 +0000)]
tests: add ftruncate64.test and truncate64.test

* tests/ftruncate64.c: New file.
* tests/truncate64.c: Likewise.
* tests/ftruncate64.test: New test.
* tests/truncate64.test: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add ftruncate64 and truncate64.
(ftruncate64_CFLAGS, truncate64_CFLAGS): Define.
(TESTS): Add ftruncate64.test and truncate64.test.
* tests/.gitignore: Add ftruncate64 and truncate64.

8 years agotests: add ftruncate.test and truncate.test
Dmitry V. Levin [Tue, 1 Dec 2015 00:02:45 +0000 (00:02 +0000)]
tests: add ftruncate.test and truncate.test

* tests/ftruncate.c: New file.
* tests/truncate.c: Likewise.
* tests/ftruncate.test: New test.
* tests/truncate.test: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add ftruncate and truncate.
(TESTS): Add ftruncate.test and truncate.test.
* tests/.gitignore: Add ftruncate and truncate.

8 years agobuild: robustify linux/fcntl.h check
Dmitry V. Levin [Mon, 30 Nov 2015 16:20:19 +0000 (16:20 +0000)]
build: robustify linux/fcntl.h check

* configure.ac (AC_CHECK_TYPES): Support older linux kernel headers
by including <sys/types.h> before <linux/fcntl.h>.

8 years agosyscall.c: move inclusion of arch specific files to the end of file
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.

8 years agox86_64: change getregs_old to forward ptrace return code
Dmitry V. Levin [Mon, 30 Nov 2015 15:30:05 +0000 (15:30 +0000)]
x86_64: change getregs_old to forward ptrace return code

* linux/x86_64/getregs_old.c (getregs_old): Change to return ptrace
return code.
* syscall.c (get_regs) [ARCH_REGS_FOR_GETREGSET && X86_64]: Use
getregs_old return code.

8 years agoCleanup print_pc
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.

* Makefile.am (EXTRA_DIST): Remove linux/*/print_pc.c.
* linux/*/print_pc.c: Remove.
* linux/aarch64/arch_regs.c(ARCH_PC_REG): Define macro.
* linux/arc/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/arm/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/avr32/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/i386/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/ia64/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/metag/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/mips/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/nios2/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/or1k/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/powerpc64/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/powerpc/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/s390/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/s390x/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/sparc64/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/sparc/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/tile/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/x32/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/x86_64/arch_regs.c(ARCH_PC_REG): Likewise.
* linux/alpha/arch_regs.c(ARCH_PC_PEEK_ADDR): Define macro.
* linux/bfin/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise.
* linux/crisv10/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise.
* linux/crisv32/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise.
* linux/hppa/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise.
* linux/m68k/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise.
* linux/microblaze/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise.
* linux/sh64/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise.
* linux/sh/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise.
* linux/xtensa/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise.
* syscall.c (print_pc): Stop including "print_pc.c".
Use ARCH_PC_REG or ARCH_PC_PEEK_ADDR.

8 years agocleanup: make get_scno.c files more readable
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.

* linux/aarch64/get_scno.c (arch_get_scno): Define.
* linux/alpha/get_scno.c: Likewise.
* linux/arc/get_scno.c: Likewise.
* linux/arm/get_scno.c: Likewise.
* linux/avr32/get_scno.c: Likewise.
* linux/bfin/get_scno.c: Likewise.
* linux/crisv10/get_scno.c: Likewise.
* linux/hppa/get_scno.c: Likewise.
* linux/i386/get_scno.c: Likewise.
* linux/ia64/get_scno.c: Likewise.
* linux/m68k/get_scno.c: Likewise.
* linux/metag/get_scno.c: Likewise.
* linux/microblaze/get_scno.c: Likewise.
* linux/mips/get_scno.c: Likewise.
* linux/nios2/get_scno.c: Likewise.
* linux/or1k/get_scno.c: Likewise.
* linux/powerpc/get_scno.c: Likewise.
* linux/powerpc64/get_scno.c: Likewise.
* linux/s390/get_scno.c: Likewise.
* linux/sh/get_scno.c: Likewise.
* linux/sh64/get_scno.c: Likewise.
* linux/sparc/get_scno.c: Likewise.
* linux/sparc64/get_scno.c: Likewise.
* linux/tile/get_scno.c: Likewise.
* linux/x86_64/get_scno.c: Likewise.
* linux/xtensa/get_scno.c: Likewise.
* syscall.c (arch_get_scno): New declaration.
Include "get_scno.c" in file scope.
(get_scno): Use arch_get_scno.

Requested-by: Denys Vlasenko <dvlasenk@redhat.com>
8 years agocleanup: make get_syscall_args.c files more readable
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.

* linux/aarch64/get_syscall_args.c: Include "arm/get_syscall_args.c"
with get_syscall_args temporarily defined to arm_get_syscall_args.
(get_syscall_args): Define.
* linux/alpha/get_syscall_args.c (get_syscall_args): Define.
* linux/arc/get_syscall_args.c: Likewise.
* linux/arm/get_syscall_args.c: Likewise.
* linux/avr32/get_syscall_args.c: Likewise.
* linux/bfin/get_syscall_args.c: Likewise.
* linux/crisv10/get_syscall_args.c: Likewise.
* linux/hppa/get_syscall_args.c: Likewise.
* linux/i386/get_syscall_args.c: Likewise.
* linux/ia64/get_syscall_args.c: Likewise.
* linux/m68k/get_syscall_args.c: Likewise.
* linux/metag/get_syscall_args.c: Likewise.
* linux/microblaze/get_syscall_args.c: Likewise.
* linux/mips/get_syscall_args.c: Likewise.
* linux/nios2/get_syscall_args.c: Likewise.
* linux/or1k/get_syscall_args.c: Likewise.
* linux/powerpc/get_syscall_args.c: Likewise.
* linux/s390/get_syscall_args.c: Likewise.
* linux/sh/get_syscall_args.c: Likewise.
* linux/sh64/get_syscall_args.c: Likewise.
* linux/sparc/get_syscall_args.c: Likewise.
* linux/tile/get_syscall_args.c: Likewise.
* linux/x86_64/get_syscall_args.c: Likewise.
* linux/xtensa/get_syscall_args.c: Likewise.
* syscall.c (get_syscall_args): Remove.
Include "get_syscall_args.c" in file scope.

Requested-by: Denys Vlasenko <dvlasenk@redhat.com>
8 years agocleanup: make get_syscall_result.c files more readable
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.

* linux/alpha/get_syscall_result.c (get_syscall_result_regs): Define.
* linux/bfin/get_syscall_result.c: Likewise.
* linux/crisv10/get_syscall_result.c: Likewise.
* linux/hppa/get_syscall_result.c: Likewise.
* linux/m68k/get_syscall_result.c: Likewise.
* linux/microblaze/get_syscall_result.c: Likewise.
* linux/sh/get_syscall_result.c: Likewise.
* linux/sh64/get_syscall_result.c: Likewise.
* linux/xtensa/get_syscall_result.c: Likewise.
* syscall.c [!ARCH_REGS_FOR_GETREGSET && !ARCH_REGS_FOR_GETREGS]:
Define USE_GET_SYSCALL_RESULT_REGS macro.
[USE_GET_SYSCALL_RESULT_REGS]: Include "get_syscall_result.c".
(get_syscall_result) [USE_GET_SYSCALL_RESULT_REGS]: Stop including
"get_syscall_result.c".  Call get_syscall_result_regs.

Requested-by: Denys Vlasenko <dvlasenk@redhat.com>
8 years agocleanup: make get_error.c files more readable
Dmitry V. Levin [Sun, 29 Nov 2015 00:06:45 +0000 (00:06 +0000)]
cleanup: make get_error.c files more readable

Make get_error.c files more self-sustained.  While they are still being
included by syscall.c, the latter no longer defines get_error function.

* linux/aarch64/get_error.c: Include "arm/get_error.c" with get_error
temporarily defined to arm_get_error.
(get_error): Define.
* linux/alpha/get_error.c (get_error): Define.
* linux/arc/get_error.c: Likewise.
* linux/arm/get_error.c: Likewise.
* linux/avr32/get_error.c: Likewise.
* linux/bfin/get_error.c: Likewise.
* linux/crisv10/get_error.c: Likewise.
* linux/hppa/get_error.c: Likewise.
* linux/i386/get_error.c: Likewise.
* linux/ia64/get_error.c: Likewise.
* linux/m68k/get_error.c: Likewise.
* linux/metag/get_error.c: Likewise.
* linux/microblaze/get_error.c: Likewise.
* linux/mips/get_error.c: Likewise.
* linux/nios2/get_error.c: Likewise.
* linux/or1k/get_error.c: Likewise.
* linux/powerpc/get_error.c: Likewise.
* linux/s390/get_error.c: Likewise.
* linux/sh/get_error.c: Likewise.
* linux/sh64/get_error.c: Likewise.
* linux/sparc/get_error.c: Likewise.
* linux/sparc64/get_error.c: Likewise.
* linux/tile/get_error.c: Likewise.
* linux/x86_64/get_error.c: Likewise.
* linux/xtensa/get_error.c: Likewise.
* syscall.c: Include "get_error.c" in file scope.
(get_error): Remove.  Move arch independent code ...
(get_syscall_result): ... here.  Update get_error invocation.

Requested-by: Denys Vlasenko <dvlasenk@redhat.com>
8 years agocleanup: make arch_sigreturn.c files more readable
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.

Requested-by: Denys Vlasenko <dvlasenk@redhat.com>
8 years agoAdd initial Travis CI support
Dmitry V. Levin [Thu, 26 Nov 2015 16:07:57 +0000 (16:07 +0000)]
Add initial Travis CI support

* .travis.yml: New file.
* travis-ci.sh: Likewise.

8 years agotests: remove temporary files left after two tests
Dmitry V. Levin [Fri, 27 Nov 2015 17:24:46 +0000 (17:24 +0000)]
tests: remove temporary files left after two tests

* tests/net-yy.test: Remove "$LOG"-connect and "$LOG"-accept.
* tests/unix-yy.test: Likewise.

8 years agotests: skip stat32-v.test on x32
Dmitry V. Levin [Fri, 27 Nov 2015 17:06:38 +0000 (17:06 +0000)]
tests: skip stat32-v.test on x32

Explicitly skip 32-bit stat test on x32 even if libc pretends
to support it.

* tests/stat.c (main) [__x86_64__ && __ILP32__]: Skip.

8 years agotests: fix ipc_msgbuf.test on x32
Dmitry V. Levin [Fri, 27 Nov 2015 14:15:30 +0000 (14:15 +0000)]
tests: fix ipc_msgbuf.test on x32

* tests/ipc_msgbuf.c: Include "config.h" and "kernel_types.h".
(main): Replace "long" with "kernel_long_t" in struct msgbuf.

8 years agox32: fix pselect6 decoding
Dmitry V. Levin [Fri, 27 Nov 2015 04:37:46 +0000 (04:37 +0000)]
x32: fix pselect6 decoding

* desc.c: Include "kernel_types.h".
(umove_kulong_array_or_printaddr): New function.
(SYS_FUNC(pselect6)): Use it.

8 years agox32: fix sigreturn decoding
Dmitry V. Levin [Fri, 27 Nov 2015 03:34:23 +0000 (03:34 +0000)]
x32: fix sigreturn decoding

* linux/x32/arch_sigreturn.c: Implement x32_rt_sigreturn decoding.
* linux/x86_64/arch_sigreturn.c: Handle (current_personality == 0)
case only.
Include "x32/arch_sigreturn.c" instead of "i386/arch_sigreturn.c".

8 years agox32: fix struct dirent decoding
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.

8 years agoRefer to -h on incorrect usage
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.

8 years agoRearrange flags descriptions in the usage text
Elvira Khabirova [Thu, 26 Nov 2015 03:25:12 +0000 (06:25 +0300)]
Rearrange flags descriptions in the usage text

* strace.c (usage): Rearrange descriptions.
* tests/strace-k.test: Change the option detecting regexp accordingly.

8 years agotests: run in "set -x" mode if VERBOSE variable is non-null
Dmitry V. Levin [Thu, 26 Nov 2015 21:25:31 +0000 (21:25 +0000)]
tests: run in "set -x" mode if VERBOSE variable is non-null

* tests/init.sh: Enter "set -x" mode if $VERBOSE is non-null.

8 years agotests: fix match_diff usage
Dmitry V. Levin [Thu, 26 Nov 2015 20:36:35 +0000 (20:36 +0000)]
tests: fix match_diff usage

Fix argument order in match_diff invocations:
the first argument has to be actual output,
the second argument has to be expected output.

* tests/aio.test: Swap match_diff arguments.
* tests/clock_nanosleep.test: Likewise.
* tests/clock_xettime.test: Likewise.
* tests/file_handle.test: Likewise.
* tests/getdents.test: Likewise.
* tests/getdents64.test: Likewise.
* tests/getrandom.test: Likewise.
* tests/inet-cmsg.test: Likewise.
* tests/ioctl.test: Likewise.
* tests/membarrier.test: Likewise.
* tests/mlock2.test: Likewise.
* tests/nanosleep.test: Likewise.
* tests/pselect6.test: Likewise.
* tests/readdir.test: Likewise.
* tests/readlink.test: Likewise.
* tests/readlinkat.test: Likewise.
* tests/rt_sigqueueinfo.test: Likewise.
* tests/seccomp.test: Likewise.
* tests/select.test: Likewise.
* tests/sendfile.test: Likewise.
* tests/sendfile64.test: Likewise.
* tests/struct_flock.test: Likewise.
* tests/sysinfo.test: Likewise.
* tests/time.test: Likewise.
* tests/timer_create.test: Likewise.
* tests/timer_xettime.test: Likewise.
* tests/timerfd_xettime.test: Likewise.
* tests/times-fail.test: Likewise.
* tests/times.test: Likewise.
* tests/umovestr2.test: Likewise.
* tests/userfaultfd.test: Likewise.
* tests/utime.test: Likewise.
* tests/utimensat.test: Likewise.
* tests/xet_robust_list.test: Likewise.
* tests/xetitimer.test: Likewise.
* tests/xettimeofday.test: Likewise.

8 years agox86_64: fix x32 personality support in print_llu_from_low_high_val
Dmitry V. Levin [Thu, 26 Nov 2015 20:29:25 +0000 (20:29 +0000)]
x86_64: fix x32 personality support in print_llu_from_low_high_val

x86 is the only personality supported on x86_64
that has 32-bit syscall arguments.

* io.c (print_llu_from_low_high_val) [X86_64]: Fix
current_personality == 2 case.

8 years agox86_64: fix x32 personality support in getllval
Dmitry V. Levin [Thu, 26 Nov 2015 18:25:34 +0000 (18:25 +0000)]
x86_64: fix x32 personality support in getllval

x86 is the only personality supported on x86_64
that has 32-bit syscall arguments.

* util.c (getllval) [X86_64]: Fix current_personality == 2 case.

8 years agotests/file_handle: fix expected output
Dmitry V. Levin [Thu, 26 Nov 2015 16:48:23 +0000 (16:48 +0000)]
tests/file_handle: fix expected output

* tests/file_handle.c (main): Parametrize handle_type
in open_by_handle_at parser output.

8 years agostartup_attach: fix compilation warning
Dmitry V. Levin [Thu, 26 Nov 2015 01:54:53 +0000 (01:54 +0000)]
startup_attach: fix compilation warning

* strace.c (startup_attach): Split single error_msg statement with
variable number of arguments to silence a compilation warning.

8 years ago.gitignore: add mpers_xlat.h
Dmitry V. Levin [Thu, 26 Nov 2015 01:45:42 +0000 (01:45 +0000)]
.gitignore: add mpers_xlat.h

Ignore mpers_xlat.h generated since commit v4.10-454-g5cb45b2.

* .gitignore: Add /mpers_xlat.h.

Reported-by: Elvira Khabirova <lineprinter0@gmail.com>
8 years agotests: add struct_flock.test
Dmitry V. Levin [Fri, 9 Oct 2015 00:48:19 +0000 (00:48 +0000)]
tests: add struct_flock.test

* tests/struct_flock.c: New file.
* tests/struct_flock.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add struct_flock.
(TESTS): Add struct_flock.test.
* tests/.gitignore: Add struct_flock.

8 years agoConvert parsers of flock structures to new mpers infrastructure
Dmitry V. Levin [Sat, 19 Sep 2015 23:48:56 +0000 (23:48 +0000)]
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.

8 years agofcntl.c: implement decoding for all known operations
Dmitry V. Levin [Fri, 9 Oct 2015 21:08:43 +0000 (21:08 +0000)]
fcntl.c: implement decoding for all known operations

* xlat/f_owner_types.in: New file.
* xlat/f_seals.in: Likewise.
* fcntl.c: Include "xlat/f_owner_types.h" and "xlat/f_seals.h".
(print_f_owner_ex): New function.
(SYS_FUNC(fcntl)): Use it.
Handle F_SETPIPE_SZ, F_GETPIPE_SZ, F_OFD_SETLKW,
F_OFD_SETLK, F_SETOWN_EX, F_ADD_SEALS, F_SETSIG,
F_OFD_GETLK, F_GETOWN_EX, F_GET_SEALS, F_GETSIG.

8 years agofcntl.c: mark F_DUPFD and F_DUPFD_CLOEXEC return code with RVAL_FD flag
Dmitry V. Levin [Fri, 9 Oct 2015 20:19:25 +0000 (20:19 +0000)]
fcntl.c: mark F_DUPFD and F_DUPFD_CLOEXEC return code with RVAL_FD flag

* fcntl.c (SYS_FUNC(fcntl)): Set RVAL_FD flag in the return code
for F_DUPFD and F_DUPFD_CLOEXEC operations.

8 years agofcntl.c: remove redundant ifdefs
Dmitry V. Levin [Fri, 9 Oct 2015 20:10:31 +0000 (20:10 +0000)]
fcntl.c: remove redundant ifdefs

* fcntl.c (USE_PRINTFLOCK64): Remove macro.
(printflock64): Define unconditionally.
(SYS_FUNC(fcntl)): Do not check for USE_PRINTFLOCK64,
F_DUPFD_CLOEXEC, F_NOTIFY, F_SETLEASE, and F_GETLEASE macros.

8 years agoUpdate F_* constants
Dmitry V. Levin [Fri, 9 Oct 2015 19:59:22 +0000 (19:59 +0000)]
Update F_* constants

* xlat/fcntlcmds.in: Add F_SETOWN_EX, F_GETOWN_EX, F_GETOWNER_UIDS,
F_OFD_GETLK, F_OFD_SETLK, F_OFD_SETLKW, and F_CANCELLK.
Remove F_ALLOCSP, F_BLKSIZE, F_BLOCKS, F_CHKFL, F_CNVT, F_DUP2FD,
F_ISSTREAM, F_NPRIV, F_PRIV, F_QUOTACL, F_REVOKE, F_RGETLK, F_RSETLK,
F_RSETLKW, F_SHARE, and F_UNSHARE.
Add default values.

8 years agoUpdate LOCK_* constants
Dmitry V. Levin [Fri, 9 Oct 2015 19:57:21 +0000 (19:57 +0000)]
Update LOCK_* constants

* xlat/flockcmds.in: Add LOCK_MAND, LOCK_READ, LOCK_WRITE, and LOCK_RW.
Add default values.

8 years agofcntl.c: use <linux/fcntl.h> instead of <fcntl.h>
Dmitry V. Levin [Fri, 9 Oct 2015 01:38:07 +0000 (01:38 +0000)]
fcntl.c: use <linux/fcntl.h> instead of <fcntl.h>

Include <linux/fcntl.h> for proper definitions of F_* constants
and flock structures.

* configure.ac (AC_CHECK_TYPES): Check for struct flock, struct flock64,
struct __kernel_flock, and struct __kernel_flock64 in <linux/fcntl.h>.
* flock.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* fcntl.c: Include it instead of <fcntl.h>.
(struct flock64): Remove.
(printflock): Use struct_kernel_flock instead of struct flock.
(printflock64): Use struct_kernel_flock64 instead of struct flock64.

8 years agompers: fix compound types with arbitrary member alignments
Elvira Khabirova [Thu, 26 Nov 2015 00:03:24 +0000 (03:03 +0300)]
mpers: fix compound types with arbitrary member alignments

* mpers.sh: Compound types are now represented as packed
with character arrays as explicit fillers inbetween members
and at the end.

8 years agoSupport C libraries without System V shared memory/ipc
Mike Frysinger [Sat, 31 Oct 2015 04:47:53 +0000 (00:47 -0400)]
Support C libraries without System V shared memory/ipc

Some systems (like Bionic) omit support for SysV related code.  That
means no C library headers for strace to include.  Add configure tests
to probe the headers from the kernel and use them when they are
available.

It might make more sense to never rely on the C library's headers as
there is no guarantee or requirement that the structure layout between
apps and the C library match that what is passed to the kernel.

* configure.ac (AC_CHECK_HEADERS): Check for linux/ipc.h,
linux/mqueue.h, linux/msg.h, linux/sem.h, linux/shm.h,
sys/ipc.h, sys/msg.h, sys/sem.h, and sys/shm.h.
* ipc_defs.h: Include <sys/ipc.h> or <linux/ipc.h> depending
on what is available.
* ipc_msg.c: Replace <sys/ipc.h> with "ipc_defs.h".
Fallback to <linux/msg.h> when available.
* ipc_msgctl.c: Include <sys/msg.h>, <asm/msgbuf.h>, or <linux/msg.h>
based on what is available.  Note missing support for old ipc structs.
* ipc_sem.c: Include <sys/sem.h> or <linux/sem.h> depending
on what is available.  Only decode sembuf when available.
* ipc_shm.c: Fallback to <linux/shm.h> when available.
* ipc_shmctl.c: Include <sys/shm.h>, <asm/shmbuf.h>, or <linux/shm.h>
based on what is available.  Note missing support for old ipc structs.
* print_mq_attr.c: Fallback to <linux/mqueue.h> when available.

8 years agoCREDITS.in: add Jian Zhen
Dmitry V. Levin [Wed, 25 Nov 2015 19:10:56 +0000 (19:10 +0000)]
CREDITS.in: add Jian Zhen

Thanks to Jian Zhen for donation of https://github.com/strace/ and
strace.io.

* CREDITS.in: Add Jian Zhen.

8 years agoFix syscall entries of unimplemented getpmsg and putpmsg syscalls
Dmitry V. Levin [Tue, 24 Nov 2015 02:45:11 +0000 (02:45 +0000)]
Fix syscall entries of unimplemented getpmsg and putpmsg syscalls

* linux/ia64/syscallent.h (getpmsg): Change SEN(printargs)
to SEN(getpmsg).
(putpmsg): Change SEN(printargs) to SEN(putpmsg).
* linux/mips/syscallent-n32.h: Likewise.
* linux/mips/syscallent-n64.h: Likewise.
* linux/mips/syscallent-o32.h: Likewise.
* linux/arm/syscallent.h (getpmsg, putpmsg): Set sys_flags to TN.
* linux/bfin/syscallent.h (getpmsg, putpmsg): Likewise.
* linux/hppa/syscallent.h (getpmsg, putpmsg): Likewise.
* linux/i386/syscallent.h (getpmsg, putpmsg): Likewise.
* linux/m68k/syscallent.h (getpmsg, putpmsg): Likewise.
* linux/microblaze/syscallent.h (getpmsg, putpmsg): Likewise.
* linux/powerpc/syscallent.h (getpmsg, putpmsg): Likewise.
* linux/s390/syscallent.h (getpmsg, putpmsg): Likewise.
* linux/s390x/syscallent.h (getpmsg, putpmsg): Likewise.
* linux/x32/syscallent.h (getpmsg, putpmsg): Likewise.
* linux/x86_64/syscallent.h (getpmsg, putpmsg): Likewise.

8 years agoRemove parsers of getpmsg and putpmsg syscalls
Dmitry V. Levin [Tue, 24 Nov 2015 02:39:01 +0000 (02:39 +0000)]
Remove parsers of getpmsg and putpmsg syscalls

These system calls are not implemented in the Linux kernel.

* linux/dummy.h(getpmsg, putpmsg): Move to the list of deprecated
syscalls.
* Makefile.am (strace_SOURCES): Remove stream.c.
* stream.c: Remove.
* xlat/pmsgflags.in: Remove.

8 years agoRemove parser of query_module syscall
Dmitry V. Levin [Tue, 24 Nov 2015 02:30:45 +0000 (02:30 +0000)]
Remove parser of query_module syscall

Since query_module syscall is present only in kernels before Linux 2.6
and strace does not support those kernels, there is no use to keep this
parser any longer.

* bjm.c: Do not include <sys/*>, "xlat/qm_which.h",
and "xlat/modflags.h".
(MOD_*, QM_*, module_symbol, module_info, SYS_FUNC(query_module)):
Remove.
* linux/dummy.h (sys_query_module): Add stub alias.
* xlat/modflags.in: Remove.
* xlat/qm_which.in: Remove.

8 years agoFix syscall entries of deprecated sysfs syscall
Dmitry V. Levin [Tue, 24 Nov 2015 02:23:18 +0000 (02:23 +0000)]
Fix syscall entries of deprecated sysfs syscall

* linux/alpha/syscallent.h (sysfs): Change nargs from 5 to 3.
* linux/hppa/syscallent.h (sysfs): Likewise.
* linux/mips/syscallent-n32.h (sysfs): Likewise.
* linux/mips/syscallent-n64.h (sysfs): Likewise.

8 years agoMove sysfs syscall to deprecated category
Dmitry V. Levin [Tue, 24 Nov 2015 02:21:35 +0000 (02:21 +0000)]
Move sysfs syscall to deprecated category

* linux/dummy.h (sys_sysfs): Move to the list of deprecated syscalls.

8 years agoFix syscall entries of deprecated bdflush syscall
Dmitry V. Levin [Tue, 24 Nov 2015 02:17:48 +0000 (02:17 +0000)]
Fix syscall entries of deprecated bdflush syscall

* linux/alpha/syscallent.h (bdflush): Change nargs from 0 to 2.
* linux/arm/syscallent.h (bdflush): Likewise.
* linux/avr32/syscallent.h (bdflush): Likewise.
* linux/bfin/syscallent.h (bdflush): Likewise.
* linux/hppa/syscallent.h (bdflush): Likewise.
* linux/i386/syscallent.h (bdflush): Likewise.
* linux/ia64/syscallent.h (bdflush): Likewise.
* linux/m68k/syscallent.h (bdflush): Likewise.
* linux/microblaze/syscallent.h (bdflush): Likewise.
* linux/powerpc/syscallent.h (bdflush): Likewise.
* linux/s390/syscallent.h (bdflush): Likewise.
* linux/s390x/syscallent.h (bdflush): Likewise.
* linux/sh/syscallent.h (bdflush): Likewise.
* linux/sh64/syscallent.h (bdflush): Likewise.
* linux/sparc/syscallent.h (bdflush): Likewise.

8 years agoImplement name_to_handle_at and open_by_handle_at syscalls decoding
Dmitry V. Levin [Sun, 22 Nov 2015 21:29:32 +0000 (21:29 +0000)]
Implement name_to_handle_at and open_by_handle_at syscalls decoding

* file_handle.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/dummy.h (sys_name_to_handle_at, sys_open_by_handle_at):
Remove stub aliases.
* pathtrace.c (pathtrace_match): Add SEN_name_to_handle_at.
* tests/file_handle.c: New file.
* tests/file_handle.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add file_handle.
(TESTS): Add file_handle.test.
* tests/.gitignore: Add file_handle.

8 years agoImplement lookup_dcookie syscall decoding
Dmitry V. Levin [Sun, 22 Nov 2015 19:28:17 +0000 (19:28 +0000)]
Implement lookup_dcookie syscall decoding

* lookup_dcookie.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/dummy.h (sys_lookup_dcookie): Remove stub alias.

8 years agoImplement kexec_file_load syscall decoding
Dmitry V. Levin [Sun, 22 Nov 2015 18:51:05 +0000 (18:51 +0000)]
Implement kexec_file_load syscall decoding

* xlat/kexec_file_load_flags.in: New file.
* kexec.c: Include "xlat/kexec_file_load_flags.h".
(SYS_FUNC(kexec_file_load)): New function.
* linux/dummy.h (sys_kexec_file_load): Remove stub alias.
* pathtrace.c (pathtrace_match): Add SEN_kexec_file_load.

8 years agoImplement kcmp syscall decoding
Dmitry V. Levin [Sun, 22 Nov 2015 18:35:27 +0000 (18:35 +0000)]
Implement kcmp syscall decoding

* kcmp.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/dummy.h (sys_kcmp): Remove stub alias.
* xlat/kcmp_types.in: New file.

8 years agoImplement iopl syscall decoding
Dmitry V. Levin [Sun, 22 Nov 2015 18:21:54 +0000 (18:21 +0000)]
Implement iopl syscall decoding

* iopl.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/dummy.h (sys_iopl): Remove stub alias.

8 years agoImplement ioperm syscall decoding
Dmitry V. Levin [Sun, 22 Nov 2015 18:18:43 +0000 (18:18 +0000)]
Implement ioperm syscall decoding

* ioperm.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/dummy.h (sys_ioperm): Remove stub alias.

8 years agonet: fix printing of IP_RECVOPTS/IP_RETOPTS cmsg options
Dmitry V. Levin [Sun, 22 Nov 2015 23:07:52 +0000 (23:07 +0000)]
net: fix printing of IP_RECVOPTS/IP_RETOPTS cmsg options

* net.c (print_cmsg_ip_opts): Print each byte as unsigned char.

8 years agouserfaultfd: fix pathtrace support
Dmitry V. Levin [Sun, 22 Nov 2015 19:56:00 +0000 (19:56 +0000)]
userfaultfd: fix pathtrace support

* pathtrace.c (pathtrace_match): Add SEN_userfaultfd.

8 years agoImplement IPPROTO_IP control messages decoding
Dmitry V. Levin [Sat, 21 Nov 2015 00:03:54 +0000 (03:03 +0300)]
Implement IPPROTO_IP control messages decoding

* net.c: Include "xlat/ip_cmsg_types.h".
(print_cmsg_ip_pktinfo, print_cmsg_ip_ttl, print_cmsg_ip_tos,
print_cmsg_ip_opts, print_cmsg_ip_recverr, print_cmsg_ip_checksum,
print_cmsg_ip_origdstaddr): New functions.
(print_cmsg_type_data): Add generic SOL_IP level decoding.
Use these functions for decoding of IP_PKTINFO, IP_TTL, IP_TOS,
IP_RECVOPTS, IP_RETOPTS, IP_RECVERR, IP_ORIGDSTADDR, IP_CHECKSUM,
and SCM_SECURITY type messages.
* xlat/ip_cmsg_types.in: New file.
* xlat/sockipoptions.in: Move IP_RETOPTS before IP_RECVRETOPTS.
* tests/inet-cmsg.c: New file.
* tests/inet-cmsg.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add inet-cmsg.
(TESTS): Add inet-cmsg.test.
* tests/.gitignore: Add inet-cmsg.

Suggested-by: Orion Poplawski <orion@cora.nwra.com>
8 years agoSimplify control messages printers
Dmitry V. Levin [Sat, 21 Nov 2015 03:59:09 +0000 (03:59 +0000)]
Simplify control messages printers

Do not pass sizeof(struct cmsghdr) to every cmsg printer.

* net.c (printcmsghdr): Pass pointer to cmsg_data and length
of cmsg_data to print_cmsg_type_data.
(print_cmsg_type_data): Update prototype.  Pass pointer to cmsg_data
and length of cmsg_data to cmsg printers.
(print_scm_rights, print_scm_creds, print_scm_security): Update.

8 years agonet: factor out address printing code to a separate function
Dmitry V. Levin [Sat, 21 Nov 2015 02:38:59 +0000 (02:38 +0000)]
net: factor out address printing code to a separate function

* net.c (sockaddr_buf_t): New type.
(print_sockaddr): New function.
(printsock, print_group_req): Use it.

8 years agompers: skip xlat struct definitions in mpers mode
Dmitry V. Levin [Fri, 20 Nov 2015 01:43:12 +0000 (01:43 +0000)]
mpers: skip xlat struct definitions in mpers mode

Avoid duplicate definitions of xlat structures in files
compiled in mpers mode.

Each xlat file defines the corresponding xlat struct with
either global or local visibility using the following rules:

- if xlat struct declaration is available in defs.h,
  a global definition is provided in regular mode,
  and nothing is provided in mpers mode;
- otherwise, if xlat file is included by a mpers source file,
  a global definition is provided in regular mode
  (unless no mpers mode is supported on this architecture,
  in that case, a local definition is provided instead),
  and a declaration is provided in mpers mode;
- otherwise, a local definition is provided in regular mode,
  and an error message is printed in mpers mode.

Fallback definitions of constants provided by xlat files
remain available in all modes.

* bootstrap: Invoke generate_mpers_am.sh before xlat/gen.sh.
* defs.h (adjtimex_modes, adjtimex_status, sigev_value): Remove.
* generate_mpers_am.sh: Generate mpers_xlat.h.
* Makefile.am (EXTRA_DIST): Add mpers_xlat.h.
* print_sigevent.c: Include "xlat/sigev_value.h" unconditionally.
* print_timex.c: Include "xlat/adjtimex_modes.h" and
"xlat/adjtimex_status.h" unconditionally.
* xlat/gen.sh (cond_xlat): Move printing of fallback definitions ...
(cond_def): ... here.
(gen_header): Check also mpers_xlat.h for global declarations
of xlat structures.
Process input file twice, first time print directives
only, second time print everything.
Wrap struct xlat into #ifdef IN_MPERS ... #else ... #endif.
* xlat/getrandom_flags.in: Cleanup.

8 years agotests: rewrite getdents test in C for better coverage
Dmitry V. Levin [Thu, 19 Nov 2015 16:39:32 +0000 (16:39 +0000)]
tests: rewrite getdents test in C for better coverage

* tests/getdents.awk: Remove.
* tests/getdents.out: Remove.
* tests/getdents.c: New file.
* tests/getdents.test: Rewrite.
* tests/getdents64.c: New file.
* tests/getdents64.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add getdents and getdents64.
(TESTS): Add getdents64.test.
(EXTRA_DIST): Remove getdents.awk and getdents.out.
* tests/.gitignore: Add getdents and getdents64.

8 years agotests: add readdir.test
Dmitry V. Levin [Thu, 19 Nov 2015 19:04:32 +0000 (19:04 +0000)]
tests: add readdir.test

* tests/readdir.c: New file.
* tests/readdir.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add readdir.
(TESTS): Add readdir.test.
* tests/.gitignore: Add readdir.

8 years agoMpersify parsers of readdir and getdents syscalls
Dmitry V. Levin [Thu, 19 Nov 2015 18:13:53 +0000 (18:13 +0000)]
Mpersify parsers of readdir and getdents syscalls

* defs.h (dirent_types): New xlat prototype.
* dirent.c: Stop including "xlat/direnttypes.h".
(kernel_dirent): New typedef.  Mpersify it.
(print_old_dirent): Use it instead of old_dirent_t.
(SYS_FUNC(getdents)): Use it instead of struct kernel_dirent.
Rename direnttypes to dirent_types.
(SYS_FUNC(getdents64)): Move ...
* dirent64.c: ... here.  Rename direnttypes to dirent_types.
Include "xlat/dirent_types.h".
* Makefile.am (strace_SOURCES): Add dirent64.c.
* xlat/direnttypes.in: Rename to xlat/dirent_types.in.

8 years agogetdents: fix typos in array output
Gabriel Laskar [Thu, 19 Nov 2015 10:44:30 +0000 (11:44 +0100)]
getdents: fix typos in array output

Array should be enclosed by square brakets, and elements should be
separated by commas.

* dirent.c (SYS_FUNC(getdents), SYS_FUNC(getdents64)): Fix typos
in array output.
* tests/getdents.awk: Update regexps to match fixed output.
* tests/getdents.out: Update output.

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
8 years agoprintcmsghdr: move type and data decoders to a separate function
Dmitry V. Levin [Thu, 19 Nov 2015 00:29:19 +0000 (00:29 +0000)]
printcmsghdr: move type and data decoders to a separate function

* net.c (print_scm_rights, print_scm_creds, print_scm_security): Change
to return void.  Move printing of struct cmsghdr closing '}' ...
(printcmsghdr): ... here.  Move type and data decoders to ...
(print_cmsg_type_data): ... new function.

8 years agoAssume that libc provides sendmsg
Dmitry V. Levin [Wed, 18 Nov 2015 23:18:17 +0000 (23:18 +0000)]
Assume that libc provides sendmsg

Starting with commit v4.6-281-g7af9f35, we implicitly assume that
HAVE_SENDMSG is always defined.  Therefore, the check for sendmsg
availability is redundant and could be safely removed.

* configure.ac (AC_CHECK_FUNCS): Remove sendmsg.
* linux/dummy.h [!HAVE_SENDMSG] (sys_recvmsg, sys_sendmsg): Remove
stub aliases.
* net.c [HAVE_SENDMSG]: Define unconditionally.
* syscall.c (dumpio) [HAVE_SENDMSG]: Likewise.

8 years agonet.c: move fallback definition of SCM_SECURITY to xlat/
Dmitry V. Levin [Wed, 18 Nov 2015 23:11:34 +0000 (23:11 +0000)]
net.c: move fallback definition of SCM_SECURITY to xlat/

* net.c: Move fallback definition of SCM_SECURITY ...
* xlat/scmvals.in: ... here.

8 years agoImplement mlock2 syscall decoding
Dmitry V. Levin [Sun, 15 Nov 2015 02:35:57 +0000 (02:35 +0000)]
Implement mlock2 syscall decoding

* mem.c: Include "xlat/mlock_flags.h".
(SYS_FUNC(mlock2)): New function.
* xlat/mlock_flags.in: New file.
* xlat/mlockall_flags.in: Add MCL_ONFAULT, add default values.
* linux/dummy.h (mlock2): Remove.
* tests/mlock2.c: New file.
* tests/mlock2.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add mlock2.
(TESTS): Add mlock2.test.
* tests/.gitignore Add mlock2.

8 years agoImplement membarrier syscall decoding
Dmitry V. Levin [Sun, 15 Nov 2015 02:29:29 +0000 (02:29 +0000)]
Implement membarrier syscall decoding

* membarrier.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/membarrier_cmds.in: New file.
* linux/dummy.h (membarrier): Remove.
* tests/membarrier.c: New file.
* tests/membarrier.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add membarrier.
(TESTS): Add membarrier.test.
* tests/.gitignore: Add membarrier.

8 years agoImplement userfaultfd syscall decoding
Dmitry V. Levin [Sun, 15 Nov 2015 02:22:44 +0000 (02:22 +0000)]
Implement userfaultfd syscall decoding

* userfaultfd.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/uffd_flags.in: New file.
* linux/dummy.h (userfaultfd): Remove.
* tests/userfaultfd.c: New file.
* tests/userfaultfd.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add userfaultfd.
(TESTS): Add userfaultfd.test.
* tests/.gitignore: Add userfaultfd.

8 years agoia64: wire up kcmp syscall
Dmitry V. Levin [Sun, 15 Nov 2015 16:57:15 +0000 (16:57 +0000)]
ia64: wire up kcmp syscall

ia64 has kcmp syscall starting with linux kernel commit
v4.3-rc7-1-gd305c47.

* linux/ia64/syscallent.h (kcmp): New entry.

8 years agopowerpc: wire up direct sysv ipc syscalls
Dmitry V. Levin [Sun, 15 Nov 2015 02:49:03 +0000 (02:49 +0000)]
powerpc: wire up direct sysv ipc syscalls

Starting with linux commit v4.3-rc3-33-ga342361, powerpc has
direct sysv ipc syscalls in addition to traditional ipc syscall.

* linux/powerpc/syscallent.h (semop, semget, semctl, semtimedop, msgsnd,
msgrcv, msgget, msgctl, shmat, shmdt, shmget, shmctl): New entries.

8 years agoWire up userfaultfd, membarrier, and mlock2 syscalls
Dmitry V. Levin [Sun, 15 Nov 2015 02:37:51 +0000 (02:37 +0000)]
Wire up userfaultfd, membarrier, and mlock2 syscalls

* linux/dummy.h (membarrier, mlock2, userfaultfd): New stub aliases.
* linux/32/syscallent.h (userfaultfd, membarrier, mlock2): New entries.
* linux/64/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/arm/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/hppa/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/i386/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/ia64/syscallent.h (userfaultfd, membarrier): Likewise.
* linux/m68k/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/microblaze/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/mips/syscallent-n32.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/mips/syscallent-n64.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/mips/syscallent-o32.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/powerpc/syscallent.h (userfaultfd, membarrier): Likewise.
* linux/s390/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/s390x/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/sparc/syscallent.h (membarrier, userfaultfd, mlock2): Likewise.
* linux/x32/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.
* linux/x86_64/syscallent.h (userfaultfd, membarrier, mlock2): Likewise.

8 years agosprintflags: skip zero flags
Dmitry V. Levin [Sun, 15 Nov 2015 20:44:13 +0000 (20:44 +0000)]
sprintflags: skip zero flags

Tweak sprintflags behaviour to match printflags.

* util.c (sprintflags): Skip zero flags unless the value passed
to sprintflags is also zero.

8 years agoprintflags: handle empty xlats
Mike Frysinger [Sat, 31 Oct 2015 04:47:59 +0000 (00:47 -0400)]
printflags: handle empty xlats

If the set of headers are unable to produce a valid list, printflags
will try to pass NULL to tprints which crashes.  Add a sanity check
for this edge case.

* util.c (printflags): Check xlat->str is not NULL.

8 years agompers: forward mpers_DEFS to mpers.sh
Dmitry V. Levin [Mon, 16 Nov 2015 01:12:18 +0000 (01:12 +0000)]
mpers: forward mpers_DEFS to mpers.sh

mpers_DEFS has to be forwarded to mpers.sh so that config.h would be
properly included by defs.h at preprocessor stage.

* Makefile.am (mpers-m%.stamp): Add the whole $(mpers_sh_opts) set of
options to mpers.sh's CPPFLAGS.

8 years agotests/ioctl: workaround glibc ioctl wrapper on powerpc
Dmitry V. Levin [Mon, 16 Nov 2015 01:53:43 +0000 (01:53 +0000)]
tests/ioctl: workaround glibc ioctl wrapper on powerpc

* tests/ioctl.c (main) [POWERPC] Disable TCGETS test.

8 years agopowerpc: wire up switch_endian syscall
Dmitry V. Levin [Sun, 15 Nov 2015 16:51:55 +0000 (16:51 +0000)]
powerpc: wire up switch_endian syscall

powerpc has switch_endian syscall starting with linux commit
v4.0-rc4-67-g529d235.

* linux/powerpc/syscallent.h (switch_endian): New entry.

8 years agosparc: reserve more space for new syscalls
Dmitry V. Levin [Sun, 15 Nov 2015 16:48:50 +0000 (16:48 +0000)]
sparc: reserve more space for new syscalls

Move socket subcalls further down the table to make room
for new syscalls.

* linux/sparc/syscallent.h (SYS_socket_subcall): Raise from 353 to 400.

8 years agom68k: wire up direct socket syscalls
Dmitry V. Levin [Sun, 15 Nov 2015 01:46:51 +0000 (01:46 +0000)]
m68k: wire up direct socket syscalls

Starting with linux commit v4.3-rc3-1-g5b3f33e, m68k has direct
socket syscalls in addition to traditional socketcall syscall.

* linux/m68k/syscallent.h (socket, socketpair, bind, connect, listen,
accept4, getsockopt, setsockopt, getsockname, getpeername, sendto,
sendmsg, recvfrom, recvmsg, shutdown, recvmmsg, sendmmsg): New entries.

8 years agoi386: wire up direct socket syscalls
Dmitry V. Levin [Sun, 15 Nov 2015 01:40:26 +0000 (01:40 +0000)]
i386: wire up direct socket syscalls

Starting with linux commit v4.2-rc1-64-g9dea5dc, x86 has direct
socket syscalls in addition to traditional socketcall syscall.

* linux/i386/syscallent.h (socket, socketpair, bind, connect, listen,
accept4, getsockopt, setsockopt, getsockname, getpeername, sendto,
sendmsg, recvfrom, recvmsg, shutdown): New entries.

8 years agos390, s390x: update syscall tables
Heiko Carstens [Tue, 10 Nov 2015 11:39:41 +0000 (12:39 +0100)]
s390, s390x: update syscall tables

* linux/s390/syscallent.h: Add new syscalls available with kernel 4.3.0.
* linux/s390x/syscallent.h: Likewise.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
8 years agoFix *_printer_defs.h rules ambiguousness
Dmitry V. Levin [Sat, 7 Nov 2015 23:22:24 +0000 (23:22 +0000)]
Fix *_printer_defs.h rules ambiguousness

There is an ambiguousness in *_printer_defs.h rules definition:

$ grep '^[^ ]*_defs\.h: ' Makefile.am
m%_defs.h: $(srcdir_mpers_source_files)
%_printer_defs.h: $(srcdir_mpers_source_files)

While it appears to work with GNU make, it has to be fixed nevertheless.

* Makefile.am (m%_defs.h): Rename to m%_type_defs.h.
(mpers_m32_targets): Rename m32_defs.h to m32_type_defs.h.
(mpers_mx32_targets): Rename mx32_defs.h to mx32_type_defs.h.
* mpers_type.h: Rename m32_defs.h to m32_type_defs.h,
mx32_defs.h to mx32_type_defs.h.
* .gitignore: Likewise.

Reported-by: Elliott Hughes <enh@google.com>
8 years agofcntl.c: make use of RVAL_DECODED
Dmitry V. Levin [Fri, 9 Oct 2015 01:55:46 +0000 (01:55 +0000)]
fcntl.c: make use of RVAL_DECODED

* fcntl.c (SYS_FUNC(fcntl)): Return RVAL_DECODED for write-only operations.

8 years agodesc.c: move parser of fcntl syscall to a separate file
Dmitry V. Levin [Thu, 1 Oct 2015 12:24:01 +0000 (12:24 +0000)]
desc.c: move parser of fcntl syscall to a separate file

* fcntl.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* desc.c (printflock64, printflock, SYS_FUNC(fcntl)): Move to fcntl.c.

8 years agodesc.c: move parser of flock syscall to a separate file
Dmitry V. Levin [Thu, 1 Oct 2015 12:20:11 +0000 (12:20 +0000)]
desc.c: move parser of flock syscall to a separate file

* flock.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* desc.c (SYS_FUNC(flock)): Move to flock.c.

8 years agotests: fix false uio.test failures
Dmitry V. Levin [Thu, 8 Oct 2015 14:44:15 +0000 (14:44 +0000)]
tests: fix false uio.test failures

* tests/uio.c (main): Use descriptor number 0 in pread/pwrite
and preadv/pwritev syscalls.
* tests/uio.expected: Update regexps.

Reported-by: Lennart Sorensen <lsorense@csclub.uwaterloo.ca>
8 years agoFix make -j builds
Gabriel Laskar [Thu, 1 Oct 2015 12:49:25 +0000 (14:49 +0200)]
Fix make -j builds

In files generated by mpers scripts, includes directives are taken from
original files where the type definition was done.  This causes to
include defs.h in multiple files.  defs.h includes printers.h header,
which is a generated header.

This patch add an explicit dependency to printers.h for the mpers
scripts.

* Makefile.am (mpers-m%.stamp): Add printers.h to order-only
prerequisites.

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
8 years agompers: fix shell code to conform better to POSIX
Mike Frysinger [Tue, 29 Sep 2015 19:02:35 +0000 (15:02 -0400)]
mpers: fix shell code to conform better to POSIX

The `echo -n` behavior is non-portable, so use printf instead.

* generate_mpers_am.sh: Change `echo -n` to `printf`.

8 years agoioctl: fix ioctl command number decoding in case of conflicts
Gabriel Laskar [Wed, 23 Sep 2015 08:11:55 +0000 (10:11 +0200)]
ioctl: fix ioctl command number decoding in case of conflicts

When a command number was decoded through ioctl_decode_command_number(),
there was no check for conflicts with other potential ioctls numbers.

For example:
ioctl(fd, MCE_GET_RECORD_LEN, &i);
output:
ioctl(3, MIXER_READ(1), 0x7ffddce74a58) = 0
instead of:
ioctl(3, MIXER_READ(1) or MCE_GET_RECORD_LEN, 0x7ffee435ce08) = 0

* ioctl.c (SYS_FUNC(ioctl)): Fix ioctl command number decoding
in case of conflicts.
* tests/ioctl.c (main): Add a case for command number conflicts.

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
8 years agotests: convert ioctl.test from match_grep to match_diff
Dmitry V. Levin [Tue, 22 Sep 2015 21:22:37 +0000 (21:22 +0000)]
tests: convert ioctl.test from match_grep to match_diff

* tests/ioctl.c (main): Print expected output.
* tests/ioctl.test: Use match_diff instead of match_grep.
* tests/ioctl.expected: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove ioctl.expected.

8 years agoConvert parser of seccomp filter program to new mpers infrastructure
Dmitry V. Levin [Sat, 19 Sep 2015 21:28:23 +0000 (21:28 +0000)]
Convert parser of seccomp filter program to new mpers infrastructure

* seccomp_fprog.h: New file.
* fetch_seccomp_fprog.c: New file.
* Makefile.am (strace_SOURCES): Add them.
* seccomp.c: Include "seccomp_fprog.h".
(print_seccomp_filter): Use fetch_seccomp_fprog.

8 years agotests/init.sh: enhance match_grep error diagnostics
Dmitry V. Levin [Sat, 19 Sep 2015 00:11:07 +0000 (00:11 +0000)]
tests/init.sh: enhance match_grep error diagnostics

* tests/init.sh (match_grep): Check patterns one by one,
output only those patterns that didn't match.

8 years agotests/init.sh: fix comment
Dmitry V. Levin [Sat, 19 Sep 2015 00:01:35 +0000 (00:01 +0000)]
tests/init.sh: fix comment

* tests/init.sh (match_awk): Fix usage description.

8 years agotests: add one more case to select.test
Dmitry V. Levin [Fri, 18 Sep 2015 21:54:52 +0000 (21:54 +0000)]
tests: add one more case to select.test

* tests/select.c (main): Check how timeout is printed
on exiting syscall.

8 years agotests: uncouple pselect6 from select.test
Dmitry V. Levin [Fri, 18 Sep 2015 21:45:36 +0000 (21:45 +0000)]
tests: uncouple pselect6 from select.test

* tests/select.c Do not include <string.h>.
Include <sys/syscall.h>.
[!__NR_select]: Skip the test.
(main): Remove pselect6 support, test just select syscall.
* tests/select.test: Remove all pselect6 checks, test just
select syscall.

8 years agotests: robustify select test
Dmitry V. Levin [Fri, 18 Sep 2015 21:37:09 +0000 (21:37 +0000)]
tests: robustify select test

* tests/select.c: Do not include <assert.h>.
(main): Skip the test instead of assertions.
Add some padding to the timeval structure.

8 years agotests: add one more case to pselect6.test
Dmitry V. Levin [Fri, 18 Sep 2015 21:20:56 +0000 (21:20 +0000)]
tests: add one more case to pselect6.test

* tests/pselect6.c (main): Check how timeout is printed
on exiting syscall.

8 years agotests: robustify pselect6 test
Dmitry V. Levin [Fri, 18 Sep 2015 21:20:56 +0000 (21:20 +0000)]
tests: robustify pselect6 test

* tests/pselect6.c: Do not include <assert.h> and <string.h>.
Include <sys/syscall.h>.
[!__NR_pselect6]: Skip the test.
(main): Skip the test instead of assertions.
Add some padding to the timespec structure.

8 years agoConvert another parser of struct timeval to new mpers infrastructure
Dmitry V. Levin [Fri, 18 Sep 2015 18:02:50 +0000 (18:02 +0000)]
Convert another parser of struct timeval to new mpers infrastructure

* print_time.c (sprint_timeval): New mpers printer.
[ALPHA] (sprint_timeval32): New function.
* defs.h [ALPHA] (sprint_timeval32): New prototype.
(bitness_t, TIMEVAL_TEXT_BUFSIZE, printtv_bitness, sprinttv): Remove.
* desc.c (decode_select): Replace bitness parameter with two printers.
Use them instead of printtv_bitness and sprinttv.
(sys_oldselect, sys_select): Pass print_timeval and sprint_timeval
to decode_select.
[ALPHA] (sys_osf_select): Pass print_timeval32 and sprint_timeval32
to decode_select.
(pselect6): Pass print_timespec and sprint_timespec to decode_select.
* time.c (UTIME_NOW, UTIME_OMIT, current_time_t_is_compat,
struct timeval32, printtv_bitness, do_sprinttv, sprinttv): Remove.

8 years agoConvert another parser of struct timespec to new mpers infrastructure
Dmitry V. Levin [Fri, 18 Sep 2015 17:44:16 +0000 (17:44 +0000)]
Convert another parser of struct timespec to new mpers infrastructure

* print_time.c (sprint_timespec): New mpers printer.
* defs.h (TIMESPEC_TEXT_BUFSIZE): Update.
(sprint_timespec): Remove.
* time.c (sprint_timespec): Remove.
* net.c (sys_recvmmsg): Update callers.
* poll.c (decode_poll_exiting): Likewise.