]> granicus.if.org Git - strace/log
strace
8 years agoAdd RISC-V architecture support
Richard W.M. Jones [Fri, 19 Aug 2016 13:16:41 +0000 (14:16 +0100)]
Add RISC-V architecture support

The original port of strace was done by Palmer Dabbelt
(eecs.berkeley.edu), based on strace 4.9.

* configure.ac: Define RISCV for riscv*.
* clone.c [RISCV]: Define ARG_* macros as for OR1K.
* defs.h [RISCV] (SUPPORTED_PERSONALITIES): Define to 2.
[RISCV] (NEED_UID16_PARSERS): Define to 1.
* linux/riscv/arch_regs.c: New file.
* linux/riscv/errnoent1.h: Likewise.
* linux/riscv/get_error.c: Likewise.
* linux/riscv/get_scno.c: Likewise.
* linux/riscv/get_syscall_args.c: Likewise.
* linux/riscv/ioctls_arch0.h: Likewise.
* linux/riscv/ioctls_arch1.h: Likewise.
* linux/riscv/ioctls_inc0.h: Likewise.
* linux/riscv/ioctls_inc1.h: Likewise.
* linux/riscv/signalent1.h: Likewise.
* linux/riscv/stat32.h: Likewise.
* linux/riscv/syscallent.h: Likewise.
* linux/riscv/syscallent1.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
8 years agoMove SH-specific argument number calculation to getllval
Eugene Syromyatnikov [Sat, 20 Aug 2016 14:02:55 +0000 (17:02 +0300)]
Move SH-specific argument number calculation to getllval

This change prevents scattering of ll-related hacks and simplifies
pread/pwrite syscalls parsers' logic a bit.

* util.c (getllval): Add fixup for arg_no for SuperH when argument
number is equal to 3.
* io.c (PREAD_OFFSET_ARG): Remove.
(SYS_FUNC(pread)): Always use argument number 3 for "count" argument
printing.
(SYS_FUNC(pwrite)): Likewise.

8 years agosparc64: fix sigreturn decoding for sparc personality
Dmitry V. Levin [Sun, 21 Aug 2016 22:02:09 +0000 (22:02 +0000)]
sparc64: fix sigreturn decoding for sparc personality

* linux/sparc/arch_sigreturn.c (arch_sigreturn): Parametrize
member types of struct signal_frame.
* linux/sparc64/arch_sigreturn.c (sparc64_arch_sigreturn,
sparc32_arch_sigreturn): New functions.
(arch_sigreturn): Use them.

8 years agoFix compat decoding of struct sigaction.sa_mask on big endian architectures
Dmitry V. Levin [Sat, 20 Aug 2016 00:08:10 +0000 (00:08 +0000)]
Fix compat decoding of struct sigaction.sa_mask on big endian architectures

* signal.c (decode_new_sigaction) [SUPPORTED_PERSONALITIES > 1 &&
SIZEOF_LONG > 4]: Use LONG_LONG to convert sa_mask from 32-bit
struct sigaction to 64-bit struct sigaction.

8 years agoFix decoding of indirect shmat's return code for non-native personalities
Dmitry V. Levin [Fri, 19 Aug 2016 22:57:27 +0000 (22:57 +0000)]
Fix decoding of indirect shmat's return code for non-native personalities

* ipc_shm.c (SYS_FUNC(shmat)): Fetch current_wordsize bytes of data
to obtain return code of indirect shmat subcall.

8 years agosparc64: fix sparc personality decoding of mmap64's offset argument
Dmitry V. Levin [Thu, 18 Aug 2016 22:33:12 +0000 (22:33 +0000)]
sparc64: fix sparc personality decoding of mmap64's offset argument

* linux/sparc64/syscallent1.h: Remove redirection of sys_mmap_4koff.

8 years agosparc64: fix decoding of the forth argument of semctl syscall
Dmitry V. Levin [Wed, 17 Aug 2016 21:58:37 +0000 (21:58 +0000)]
sparc64: fix decoding of the forth argument of semctl syscall

On sparc64, unlike all other architectures where semctl is an indirect
ipc subcall, the forth argument is passed directly.

* ipc_sem.c (SYS_FUNC(semctl)) [SPARC64]: Print 4th argument without
indirection in case of native personality.

8 years agoAdd sparc64 specific ptrace constants
Dmitry V. Levin [Tue, 16 Aug 2016 09:15:44 +0000 (09:15 +0000)]
Add sparc64 specific ptrace constants

* xlat/ptrace_cmds.in: Add PTRACE_GETREGS64, PTRACE_SETREGS64,
PTRACE_GETFPREGS64, and PTRACE_SETFPREGS64.

8 years agosparc64: fix sign extension bug of syscall args for sparc personality
Dmitry V. Levin [Tue, 16 Aug 2016 09:15:36 +0000 (09:15 +0000)]
sparc64: fix sign extension bug of syscall args for sparc personality

* linux/sparc64/get_syscall_args.c (get_syscall_args): Zero-extend
syscall args from 32 bit for sparc personality.

8 years agosparc64: fix tty ioctl numbers
Dmitry V. Levin [Tue, 16 Aug 2016 09:15:24 +0000 (09:15 +0000)]
sparc64: fix tty ioctl numbers

The structures defined in asm/termbits.h have the same size
on sparc and sparc64.

* linux/sparc64/ioctls_arch0.h (TCGETS, TCGETS2, TCSETS, TCSETS2,
TCSETSF, TCSETSF2, TCSETSW, TCSETSW2): Sync with
linux/sparc/ioctls_arch0.h

8 years agoevdev.c: fix typo in comment
Dmitry V. Levin [Mon, 15 Aug 2016 21:08:16 +0000 (21:08 +0000)]
evdev.c: fix typo in comment

8 years agoDrop support of dummy members of struct stat
Dmitry V. Levin [Mon, 15 Aug 2016 18:33:47 +0000 (18:33 +0000)]
Drop support of dummy members of struct stat

As st_flags, st_fstype, and st_gen members of struct stat are not filled
by the kernel, there is no use supporting them.

* configure.ac (AC_CHECK_MEMBERS): Remove struct stat.st_flags,
struct stat.st_fstype, and struct stat.st_gen.
* file.c [STAT32_PERSONALITY, HAVE_STRUCT_STAT64]: Do not undefine
HAVE_STRUCT_STAT_ST_FLAGS, HAVE_STRUCT_STAT_ST_FSTYPE,
and HAVE_STRUCT_STAT_ST_GEN.
* printstat.h (DO_PRINTSTAT): Do not check for
HAVE_STRUCT_STAT_ST_FLAGS, HAVE_STRUCT_STAT_ST_FSTYPE,
and HAVE_STRUCT_STAT_ST_GEN.

8 years agoAssume that struct stat contains st_blksize, st_blocks, and st_rdev
Dmitry V. Levin [Mon, 15 Aug 2016 17:33:25 +0000 (17:33 +0000)]
Assume that struct stat contains st_blksize, st_blocks, and st_rdev

Our test suite already assumes that struct stat contains st_blksize,
st_blocks, and st_rdev members, and there haven't been any complaints.

* configure.ac (AC_CHECK_MEMBERS): Remove struct stat.st_blksize,
struct stat.st_blocks, and struct stat.st_rdev.
* printstat.h (DO_PRINTSTAT): Do not check for
HAVE_STRUCT_STAT_ST_BLKSIZE, HAVE_STRUCT_STAT_ST_BLOCKS,
and HAVE_STRUCT_STAT_ST_RDEV.

8 years agotests: fix pause.test when pause syscall is not available
Dmitry V. Levin [Mon, 15 Aug 2016 15:20:38 +0000 (15:20 +0000)]
tests: fix pause.test when pause syscall is not available

* tests/pause.c (main): Fix expected output when pause syscall
is not available.

8 years agopowerpc64, sparc64: fix redefinitions of ARCH_PC_REG
Dmitry V. Levin [Sun, 14 Aug 2016 00:03:03 +0000 (00:03 +0000)]
powerpc64, sparc64: fix redefinitions of ARCH_PC_REG

This fixes compilation warning that ARCH_PC_REG is redefined.

* linux/powerpc64/arch_regs.c (ARCH_PC_REG): Undefine before
the new definition.
* linux/sparc64/arch_regs.c (ARCH_PC_REG): Likewise.

8 years agos390x, x32: remove redundant definitions of ARCH_PC_REG
Dmitry V. Levin [Sun, 14 Aug 2016 00:02:55 +0000 (00:02 +0000)]
s390x, x32: remove redundant definitions of ARCH_PC_REG

* linux/s390x/arch_regs.c (ARCH_PC_REG): Remove, it is already defined
in just included linux/s390/arch_regs.c.
* linux/x32/arch_regs.c (ARCH_PC_REG): Remove, it is already defined
in just included linux/x86_64/arch_regs.c.

8 years agotests: check for leaks of placeholder descriptors
Dmitry V. Levin [Sat, 13 Aug 2016 22:05:28 +0000 (22:05 +0000)]
tests: check for leaks of placeholder descriptors

* tests/redirect-fds.c: New file.
* tests/redirect-fds.test: New test.
* tests/.gitignore: Add redirect-fds.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add redirect-fds.test.

8 years agotests/init.sh: print exit code of failed commands
Dmitry V. Levin [Sat, 13 Aug 2016 22:05:20 +0000 (22:05 +0000)]
tests/init.sh: print exit code of failed commands

* init.sh (run_prog, run_prog_skip_if_failed): When the program fails,
add its exit code to the diagnostic message.
(run_strace): When strace fails, add its exit code to the diagnostic
message.
(run_strace_merge): When strace-log-merge fails, add its exit code
to the diagnostic message.

8 years agoFix leakage of placeholder descriptors to tracees
Dmitry V. Levin [Sat, 13 Aug 2016 22:04:59 +0000 (22:04 +0000)]
Fix leakage of placeholder descriptors to tracees

As a side effect of commit v4.11-211-g0736d4e, strace used to leak
placeholders for standard descriptors to tracees thus affecting their
behaviour.  Fix this by setting close-on-exec flag on placeholder
descriptors.

* strace.c (open_dummy_desc): Set close-on-exec flag on the descriptor
that is going to be returned to the caller.
(fd_is_placeholder): New array.
(ensure_standard_fds_opened, redirect_standard_fds): New functions.
(startup_child): Use redirect_standard_fds.
(init): Use ensure_standard_fds_opened.

8 years agosparc64: fix decoding of uid and gid-related syscalls
Dmitry V. Levin [Fri, 12 Aug 2016 01:00:04 +0000 (01:00 +0000)]
sparc64: fix decoding of uid and gid-related syscalls

sparc64 has no native 16-bit uid/gid syscalls.

* linux/sparc64/syscallent.h (chown, lchown, setuid, getuid, setgid,
getgid, geteuid, getegid, getgroups, setgroups, fchown, setreuid,
setregid, setfsuid, setfsgid): Change handlers from 16-bit to 32-bit.

8 years agotests: fix *stat64 tests on alpha
Dmitry V. Levin [Thu, 11 Aug 2016 22:31:08 +0000 (22:31 +0000)]
tests: fix *stat64 tests on alpha

On some architectures including alpha, <asm/stat.h> provides a
definition of struct stat that has no st_atime_nsec, st_mtime_nsec, and
st_ctime_nsec fields.  At the same time, struct stat64 always has these
fields.  Fix tests to take this difference into account.

* tests/fstat64.c (STRUCT_STAT_IS_STAT64): New macro, defined to 1.
* tests/lstat64.c (STRUCT_STAT_IS_STAT64): Likewise.
* tests/stat64.c (STRUCT_STAT_IS_STAT64): Likewise.
* tests/xstatx.c [!STRUCT_STAT] (STRUCT_STAT_IS_STAT64): New macro,
defined to 0.
[USE_ASM_STAT && STRUCT_STAT_IS_STAT64]:
(HAVE_STRUCT_STAT_ST_ATIME_NSEC, HAVE_STRUCT_STAT_ST_CTIME_NSEC,
HAVE_STRUCT_STAT_ST_MTIME_NSEC): Redefine to 1.

8 years agotests: skip rt_tgsigqueueinfo.test when the syscall is not available
Dmitry V. Levin [Thu, 11 Aug 2016 17:58:09 +0000 (17:58 +0000)]
tests: skip rt_tgsigqueueinfo.test when the syscall is not available

* tests/rt_tgsigqueueinfo.c (main): Skip the test when the syscall
is not available.

8 years agotests/fcntl.c: fix fcntl test on mips64
James Cowgill [Thu, 11 Aug 2016 16:33:03 +0000 (16:33 +0000)]
tests/fcntl.c: fix fcntl test on mips64

On mips64 the F_GETLK and F_SETLKW64 constants have identical values which
causes the "wrong" constant to be printed by strace.

tests/fcntl.c (test_flock64): Do not test F_SETLKW64 on mips64.

8 years agotests/nsyscalls.test: only trace the "syscall" syscall on mips o32
James Cowgill [Thu, 11 Aug 2016 16:33:02 +0000 (16:33 +0000)]
tests/nsyscalls.test: only trace the "syscall" syscall on mips o32

The "syscall" syscall only exists on o32 and causes strace to error out on
64-bit mips ABIs. Pass MIPS_ABI from the configure script through to
nsyscalls.test so the MIPS ABI can be checked.

* configure.ac (MIPS_ABI): Substitute into output files.
* tests/Makefile.am (MIPS_ABI): Export via AM_TEST_LOG_FLAGS.
* tests/nsyscalls.test: Restrict special mips handling to mips o32.

8 years agotests/xstatx.c: fix stat syscall tests on mips64
James Cowgill [Thu, 11 Aug 2016 16:33:01 +0000 (16:33 +0000)]
tests/xstatx.c: fix stat syscall tests on mips64

For historical reasons the kernel struct stat represents times as unsigned
32-bit integers on mips64. Therefore, while it's possible to give a file a
timestamp before 1970 with futimens, reading the same timestamp through
struct stat will give a positive time (around 2106).
Workaround by using positive timestamps for testing on mips64.

* tests/xstatx.c (create_sample): Use positive timestamps on mips64.

8 years agotests/mlock2.c: fix test failure on mips64
Dmitry V. Levin [Wed, 10 Aug 2016 22:59:28 +0000 (22:59 +0000)]
tests/mlock2.c: fix test failure on mips64

* tests/mlock2.c (main): Pass unsigned long arguments to mlock2 syscall
explicitly, to avoid unwanted sign extension issues.

Based on patch by James Cowgill <james410@cowgill.org.uk>

8 years agoUse <asm/unistd.h> instead of <sys/syscall.h>
Dmitry V. Levin [Tue, 9 Aug 2016 14:38:29 +0000 (14:38 +0000)]
Use <asm/unistd.h> instead of <sys/syscall.h>

There are no users of SYS_* macros provided by <sys/syscall.h>,
and definitions of __NR_* macros could be obtained directly
from <asm/unistd.h>.

* defs.h: Include <asm/unistd.h> instead of <sys/syscall.h>.
* test/seccomp.c: Likewise.
* test/threaded_execve.c: Likewise.
* test/x32_lseek.c: Likewise.
* test/x32_mmap.c: Likewise.
* tests/_newselect.c: Likewise.
* tests/access.c: Likewise.
* tests/acct.c: Likewise.
* tests/aio.c: Likewise.
* tests/alarm.c: Likewise.
* tests/attach-f-p.c: Likewise.
* tests/bpf.c: Likewise.
* tests/brk.c: Likewise.
* tests/chmod.c: Likewise.
* tests/chown.c: Likewise.
* tests/chown32.c: Likewise.
* tests/chroot.c: Likewise.
* tests/clock_adjtime.c: Likewise.
* tests/clock_nanosleep.c: Likewise.
* tests/clock_xettime.c: Likewise.
* tests/copy_file_range.c: Likewise.
* tests/creat.c: Likewise.
* tests/dup2.c: Likewise.
* tests/dup3.c: Likewise.
* tests/epoll_create.c: Likewise.
* tests/epoll_create1.c: Likewise.
* tests/epoll_ctl.c: Likewise.
* tests/epoll_pwait.c: Likewise.
* tests/epoll_wait.c: Likewise.
* tests/eventfd.c: Likewise.
* tests/execveat.c: Likewise.
* tests/faccessat.c: Likewise.
* tests/fchdir.c: Likewise.
* tests/fchmod.c: Likewise.
* tests/fchmodat.c: Likewise.
* tests/fchown.c: Likewise.
* tests/fchown32.c: Likewise.
* tests/fchownat.c: Likewise.
* tests/fcntl.c: Likewise.
* tests/fcntl64.c: Likewise.
* tests/fdatasync.c: Likewise.
* tests/flock.c: Likewise.
* tests/fstat.c: Likewise.
* tests/fstat64.c: Likewise.
* tests/fstatat64.c: Likewise.
* tests/fstatfs.c: Likewise.
* tests/fstatfs64.c: Likewise.
* tests/fsync.c: Likewise.
* tests/ftruncate.c: Likewise.
* tests/ftruncate64.c: Likewise.
* tests/futimesat.c: Likewise.
* tests/get_mempolicy.c: Likewise.
* tests/getcwd.c: Likewise.
* tests/getdents.c: Likewise.
* tests/getdents64.c: Likewise.
* tests/getegid.c: Likewise.
* tests/getegid32.c: Likewise.
* tests/geteuid.c: Likewise.
* tests/geteuid32.c: Likewise.
* tests/getgid.c: Likewise.
* tests/getgid32.c: Likewise.
* tests/getgroups.c: Likewise.
* tests/getgroups32.c: Likewise.
* tests/getpgrp.c: Likewise.
* tests/getrandom.c: Likewise.
* tests/getresgid.c: Likewise.
* tests/getresgid32.c: Likewise.
* tests/getresuid.c: Likewise.
* tests/getresuid32.c: Likewise.
* tests/getrlimit.c: Likewise.
* tests/getrusage.c: Likewise.
* tests/getuid.c: Likewise.
* tests/getuid32.c: Likewise.
* tests/getxxid.c: Likewise.
* tests/ioctl_uffdio.c: Likewise.
* tests/ioperm.c: Likewise.
* tests/iopl.c: Likewise.
* tests/ipc.c: Likewise.
* tests/kill.c: Likewise.
* tests/lchown.c: Likewise.
* tests/lchown32.c: Likewise.
* tests/libmmsg.c: Likewise.
* tests/libsocketcall.c: Likewise.
* tests/link.c: Likewise.
* tests/linkat.c: Likewise.
* tests/llseek.c: Likewise.
* tests/lseek.c: Likewise.
* tests/lstat.c: Likewise.
* tests/lstat64.c: Likewise.
* tests/mbind.c: Likewise.
* tests/membarrier.c: Likewise.
* tests/memfd_create.c: Likewise.
* tests/migrate_pages.c: Likewise.
* tests/mkdir.c: Likewise.
* tests/mkdirat.c: Likewise.
* tests/mknod.c: Likewise.
* tests/mknodat.c: Likewise.
* tests/mlock.c: Likewise.
* tests/mlock2.c: Likewise.
* tests/move_pages.c: Likewise.
* tests/newfstatat.c: Likewise.
* tests/nsyscalls.c: Likewise.
* tests/old_mmap.c: Likewise.
* tests/oldselect.c: Likewise.
* tests/open.c: Likewise.
* tests/openat.c: Likewise.
* tests/pause.c: Likewise.
* tests/poll.c: Likewise.
* tests/prctl-seccomp-filter-v.c: Likewise.
* tests/prctl-seccomp-strict.c: Likewise.
* tests/preadv2-pwritev2.c: Likewise.
* tests/prlimit64.c: Likewise.
* tests/pselect6.c: Likewise.
* tests/ptrace.c: Likewise.
* tests/readdir.c: Likewise.
* tests/readlink.c: Likewise.
* tests/readlinkat.c: Likewise.
* tests/reboot.c: Likewise.
* tests/remap_file_pages.c: Likewise.
* tests/rename.c: Likewise.
* tests/renameat.c: Likewise.
* tests/renameat2.c: Likewise.
* tests/rmdir.c: Likewise.
* tests/rt_sigpending.c: Likewise.
* tests/rt_sigprocmask.c: Likewise.
* tests/rt_sigsuspend.c: Likewise.
* tests/rt_sigtimedwait.c: Likewise.
* tests/rt_tgsigqueueinfo.c: Likewise.
* tests/sched_get_priority_mxx.c: Likewise.
* tests/sched_rr_get_interval.c: Likewise.
* tests/sched_xetaffinity.c: Likewise.
* tests/sched_xetattr.c: Likewise.
* tests/sched_xetparam.c: Likewise.
* tests/sched_xetscheduler.c: Likewise.
* tests/sched_yield.c: Likewise.
* tests/seccomp-filter-v.c: Likewise.
* tests/seccomp-filter.c: Likewise.
* tests/seccomp-strict.c: Likewise.
* tests/select.c: Likewise.
* tests/sendfile.c: Likewise.
* tests/sendfile64.c: Likewise.
* tests/set_mempolicy.c: Likewise.
* tests/setdomainname.c: Likewise.
* tests/setfsgid.c: Likewise.
* tests/setfsgid32.c: Likewise.
* tests/setfsuid.c: Likewise.
* tests/setfsuid32.c: Likewise.
* tests/setgid.c: Likewise.
* tests/setgid32.c: Likewise.
* tests/setgroups.c: Likewise.
* tests/setgroups32.c: Likewise.
* tests/sethostname.c: Likewise.
* tests/setregid.c: Likewise.
* tests/setregid32.c: Likewise.
* tests/setresgid.c: Likewise.
* tests/setresgid32.c: Likewise.
* tests/setresuid.c: Likewise.
* tests/setresuid32.c: Likewise.
* tests/setreuid.c: Likewise.
* tests/setreuid32.c: Likewise.
* tests/setrlimit.c: Likewise.
* tests/setuid.c: Likewise.
* tests/setuid32.c: Likewise.
* tests/signalfd4.c: Likewise.
* tests/socketcall.c: Likewise.
* tests/splice.c: Likewise.
* tests/stat.c: Likewise.
* tests/stat64.c: Likewise.
* tests/statfs.c: Likewise.
* tests/statfs64.c: Likewise.
* tests/swap.c: Likewise.
* tests/symlink.c: Likewise.
* tests/symlinkat.c: Likewise.
* tests/sync.c: Likewise.
* tests/sync_file_range.c: Likewise.
* tests/sync_file_range2.c: Likewise.
* tests/syslog.c: Likewise.
* tests/tee.c: Likewise.
* tests/time.c: Likewise.
* tests/timer_create.c: Likewise.
* tests/timer_xettime.c: Likewise.
* tests/timerfd_xettime.c: Likewise.
* tests/times-fail.c: Likewise.
* tests/times.c: Likewise.
* tests/truncate.c: Likewise.
* tests/truncate64.c: Likewise.
* tests/ugetrlimit.c: Likewise.
* tests/umount.c: Likewise.
* tests/umount2.c: Likewise.
* tests/uname.c: Likewise.
* tests/unix-pair-send-recv.c: Likewise.
* tests/unlink.c: Likewise.
* tests/unlinkat.c: Likewise.
* tests/userfaultfd.c: Likewise.
* tests/utimes.c: Likewise.
* tests/vhangup.c: Likewise.
* tests/vmsplice.c: Likewise.
* tests/waitid.c: Likewise.
* tests/waitpid.c: Likewise.
* tests/xet_robust_list.c: Likewise.
* tests/xetpgid.c: Likewise.
* tests/xetpriority.c: Likewise.
* tests/xettimeofday.c: Likewise.

8 years agoia64: replace SYS_clone2 with __NR_clone2
Dmitry V. Levin [Tue, 9 Aug 2016 14:35:06 +0000 (14:35 +0000)]
ia64: replace SYS_clone2 with __NR_clone2

Migrate to __NR_* the last user of SYS_* macros provided
by <sys/syscall.h>.

* clone.c [IA64] (ARG_STACKSIZE, ARG_PTID, ARG_CTID, ARG_TLS): Replace
SYS_clone2 with __NR_clone2.

8 years agoMake sure that tcp->s_ent and tcp->s_prev_ent do not point to freed memory
Dmitry V. Levin [Tue, 9 Aug 2016 10:28:22 +0000 (10:28 +0000)]
Make sure that tcp->s_ent and tcp->s_prev_ent do not point to freed memory

This complements commit v4.13-33-g60d7ec8.

* syscall.c (sysent_buf): New structure.
(free_sysent_buf): New function.
(get_scno): Use them.

8 years agofile.c: move definitions of struct stat32 to separate files
Dmitry V. Levin [Tue, 9 Aug 2016 09:50:13 +0000 (09:50 +0000)]
file.c: move definitions of struct stat32 to separate files

* linux/aarch64/stat32.h: New file.
* linux/powerpc64/stat32.h: Likewise.
* linux/sparc64/stat32.h: Likewise.
* linux/tile/stat32.h: Likewise.
* linux/x32/stat32.h: Likewise.
* linux/x86_64/stat32.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* file.c [SUPPORTED_PERSONALITIES > 1]: Remove arch specific definitions
of struct stat32, include "stat32.h" instead.

8 years agosparc, sparc64: remove obsolete code
Dmitry V. Levin [Tue, 9 Aug 2016 09:18:37 +0000 (09:18 +0000)]
sparc, sparc64: remove obsolete code

Remove remains of solaris personality support.
This complements commit v4.10-45-gdf4dd8b.

* file.c [SPARC || SPARC64]: Remove the code related to struct solstat.
(printstat, printoldstat) [SPARC || SPARC64]: Remove.

8 years agosparc64: fix decoding of stat family syscalls
Dmitry V. Levin [Tue, 9 Aug 2016 09:14:11 +0000 (09:14 +0000)]
sparc64: fix decoding of stat family syscalls

This complements commit v4.13-28-gaebfe83.

* file.c [SPARC64]: Change STAT32_PERSONALITY to 1.

8 years agoFix decoding of invalid syscalls mapped to indirect subcalls
Dmitry V. Levin [Tue, 9 Aug 2016 00:07:53 +0000 (00:07 +0000)]
Fix decoding of invalid syscalls mapped to indirect subcalls

When the syscall number returned by arch_get_scno is a mapped indirect
subcall (i.e. mapped subcall of socketcall or ipc syscall), do not
mistakenly treat it as a valid indirect subcall.

* defs.h (SCNO_IS_VALID): Treat scno with TRACE_INDIRECT_SUBCALL flag
as invalid.
* syscall.c (syscall_name): Do no shuffle scno.
(trace_syscall_entering, trace_syscall_exiting): Use
tcp->s_ent->sys_name instead of syscall_name.
(get_scno): In case of invalid syscall, allocate a dynamic struct sysent
containing an appropriate .sys_name.
* tests/nsyscalls.c (main) [SYS_socket_subcall]: Check decoding
of direct syscall number SYS_socket_subcall+1.
(main) [SYS_ipc_subcall]: Check decoding of direct syscall number
SYS_ipc_subcall+1.

8 years agolinux/subcall.h: remove redundant definitions
Dmitry V. Levin [Mon, 8 Aug 2016 23:43:50 +0000 (23:43 +0000)]
linux/subcall.h: remove redundant definitions

* linux/subcall.h: Remove definitions of non-existent socket
and ipc subcalls.

8 years agodefs.h: simplify SUPPORTED_PERSONALITIES definition
Dmitry V. Levin [Mon, 8 Aug 2016 22:00:06 +0000 (22:00 +0000)]
defs.h: simplify SUPPORTED_PERSONALITIES definition

* defs.h: Group definition of SUPPORTED_PERSONALITIES by value.

8 years agodefs.h: simplify PERSONALITY1_WORDSIZE definition
Dmitry V. Levin [Mon, 8 Aug 2016 21:52:05 +0000 (21:52 +0000)]
defs.h: simplify PERSONALITY1_WORDSIZE definition

Move definition of PERSONALITY1_WORDSIZE macro outside arch specific
ifdefs.

* defs.h [SPARC64 || X86_64 || X32 || AARCH64 || POWERPC64 || TILE]
(PERSONALITY1_WORDSIZE): Remove.
[SUPPORTED_PERSONALITIES > 1] (PERSONALITY1_WORDSIZE): Define to 4
unconditionally.

8 years agodefs.h: simplify PERSONALITY0_WORDSIZE definition
Dmitry V. Levin [Mon, 8 Aug 2016 21:41:09 +0000 (21:41 +0000)]
defs.h: simplify PERSONALITY0_WORDSIZE definition

Move definition of PERSONALITY0_WORDSIZE macro outside arch specific
ifdefs.

* defs.h (PERSONALITY0_WORDSIZE): Define to SIZEOF_LONG unconditionally.

8 years agosparc64: swap personality numbers
Dmitry V. Levin [Mon, 8 Aug 2016 21:29:58 +0000 (21:29 +0000)]
sparc64: swap personality numbers

Fix inconsistency between syscall and ioctl entries on sparc64.
Make layout of personalities on sparc64 the same as on other
architectures that support two personalities.

* defs.h [SPARC64] (PERSONALITY0_WORDSIZE): Change to 8.
[SPARC64] (PERSONALITY1_WORDSIZE): Change to 4.
* linux/sparc64/get_scno.c (arch_get_scno): Swap personality numbers.
* linux/sparc64/ioctls_arch1.h: Rename to ioctls_arch0.h.
* linux/sparc64/ioctls_arch0.h: Rename to ioctls_arch1.h.
* linux/sparc64/ioctls_inc0.h: Rename to ioctls_inc1.h.
* linux/sparc64/ioctls_inc1.h: Rename to ioctls_inc0.h.

8 years agodefs.h: cleanup personality specific macro definitions
Dmitry V. Levin [Mon, 8 Aug 2016 21:11:47 +0000 (21:11 +0000)]
defs.h: cleanup personality specific macro definitions

Move the code that defines PERSONALITY[12]_INCLUDE_FUNCS,
PERSONALITY[12]_INCLUDE_PRINTERS_DECLS,
PERSONALITY[12]_INCLUDE_PRINTERS_DEFS, and MPERS_{m,mx}32_IOCTL_MACROS
macros outside arch specific ifdefs.

* defs.h [SPARC] (PERSONALITY0_WORDSIZE): Remove.
[SPARC64 && HAVE_M32_MPERS]: Remove.
[X86_64 && HAVE_M32_MPERS]: Remove.
[X86_64 && HAVE_MX32_MPERS]: Remove.
[X32 && HAVE_M32_MPERS]: Remove.
[AARCH64 && HAVE_M32_MPERS]: Remove.
[POWERPC64 && HAVE_M32_MPERS]: Remove.
[TILE && HAVE_M32_MPERS]: Remove.
(PERSONALITY0_INCLUDE_PRINTERS_DECLS,
PERSONALITY0_INCLUDE_PRINTERS_DEFS): Define unconditionally.
[SUPPORTED_PERSONALITIES > 1 && HAVE_M32_MPERS]
(PERSONALITY1_INCLUDE_PRINTERS_DECLS,
PERSONALITY1_INCLUDE_PRINTERS_DEFS, PERSONALITY1_INCLUDE_FUNCS,
MPERS_m32_IOCTL_MACROS): Define for
[SUPPORTED_PERSONALITIES > 1 && HAVE_M32_MPERS] case.
(PERSONALITY2_INCLUDE_PRINTERS_DECLS,
PERSONALITY2_INCLUDE_PRINTERS_DEFS, PERSONALITY2_INCLUDE_FUNCS,
MPERS_mx32_IOCTL_MACROS): Define for
[SUPPORTED_PERSONALITIES > 2 && HAVE_MX32_MPERS] case.

8 years agoChange #include guard trailing part comments
Dmitry V. Levin [Sun, 7 Aug 2016 22:02:46 +0000 (22:02 +0000)]
Change #include guard trailing part comments

* defs.h: Change comment of the trailing part of #include guard.
* flock.h: Likewise.
* gcc_compat.h: Likewise.
* ipc_defs.h: Likewise.
* kernel_types.h: Likewise.
* mpers_type.h: Likewise.
* msghdr.h: Likewise.
* printsiginfo.h: Likewise.
* ptrace.h: Likewise.
* regs.h: Likewise.
* seccomp_fprog.h: Likewise.
* sigevent.h: Likewise.
* statfs.h: Likewise.
* xlat.h: Likewise.

8 years agoUnify usage of #include guards
Eugene Syromyatnikov [Sun, 7 Aug 2016 03:44:19 +0000 (06:44 +0300)]
Unify usage of #include guards

This commit is an attempt to unify usage of include guards (in top-level
headers, at least).  As a side note, different files with *.h extension
have different semantics: for example, printargs.h is included multiple
times in order to generate slightly varying code depending on values of
macro definitions - maybe it's better to change extension of such files
to something like *.inc.

* defs.h: Add #include guard.
* flock.h: Likewise.
* ipc_defs.h: Likewise.
* mpers_type.h: Likewise.
* printsiginfo.h: Likewise.
* ptrace.h: Likewise.
* regs.h: Likewise.
* seccomp_fprog.h: Likewise.
* gcc_compat.h: Rename the macro used for #include guard.
* msghdr.h: Likewise.
* sigevent.h: Likewise.
* kernel_types.h: Comment the trailing part of #include guard.
* xlat.h: Add missing macro definition for #include guard.

8 years agotests: add #include guards
Dmitry V. Levin [Sat, 6 Aug 2016 21:51:29 +0000 (21:51 +0000)]
tests: add #include guards

* tests/tests.h: Add #include guard.

8 years agolinux: add #include guards
Dmitry V. Levin [Fri, 5 Aug 2016 15:06:43 +0000 (15:06 +0000)]
linux: add #include guards

* linux/dummy.h: Add #include guard.
* linux/inet_diag.h: Likewise.
* linux/netlink_diag.h: Likewise.
* linux/sock_diag.h: Likewise.
* linux/syscall.h: Likewise.
* linux/unix_diag.h: Likewise.

8 years agotests/umode_t.c: guard against libc printf format errors
Dmitry V. Levin [Thu, 4 Aug 2016 12:06:18 +0000 (12:06 +0000)]
tests/umode_t.c: guard against libc printf format errors

* tests/umode_t.c (test_syscall): Use different printf format specifiers
to detect libc printf format errors.

8 years agotravis: use a suitable musl revision
Dmitry V. Levin [Thu, 4 Aug 2016 00:40:33 +0000 (00:40 +0000)]
travis: use a suitable musl revision

There seems to be no readily available binary packages of musl that are
sufficiently up to date to be used to build and test strace, so prepare
a suitable musl from source.

* travis-install.sh (musl-gcc): Do not add an extra repository,
do not install musl-tools and linux-musl-dev packages.
Download, build, and install a suitable musl revision instead.

8 years agoFix printing of mode_t, umode_t, and umask types
Dmitry V. Levin [Wed, 3 Aug 2016 14:05:39 +0000 (14:05 +0000)]
Fix printing of mode_t, umode_t, and umask types

Print numeric umode_t type using %#03ho format.
Print return value of umask syscall using %#03lo format.
When printing symbolic mode_t type, always print lower 9 bits,
and print the numeric part using %#03o format.

* defs.h (sprintmode): Remove.
(print_symbolic_mode_t, print_numeric_umode_t,
print_numeric_long_umask): New prototypes.
* printmode.c (sprintmode): Remove.
(print_symbolic_mode_t, print_numeric_umode_t,
print_numeric_long_umask): New functions.
* chmod.c (decode_chmod): Use print_numeric_umode_t.
* ipc_msg.c (SYS_FUNC(msgget)): Likewise.
* ipc_msgctl.c (print_msqid_ds): Likewise.
* ipc_sem.c (SYS_FUNC(semget)): Likewise.
* ipc_shm.c (SYS_FUNC(shmget)): Likewise.
* ipc_shmctl.c (print_shmid_ds): Likewise.
* mq.c (SYS_FUNC(mq_open)): Likewise.
* open.c (decode_open, SYS_FUNC(creat)): Likewise.
* umask.c (SYS_FUNC(umask)): Likewise.
* mknod.c (decode_mknod): Use print_symbolic_mode_t.
* printstat.h (DO_PRINTSTAT): Likewise.
* syscall.c (trace_syscall_exiting): Use print_numeric_long_umask.
* tests/umode_t.c: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/creat.c: Rewrite as a thin wrapper around umode_t.c
* tests/mkdir.c: Likewise.
* tests/mkdirat.c: Likewise.
* tests/mknod.c: Extend test coverage of mknod syscall.
* tests/mknodat.c: Extend test coverage of mknodat syscall.
* tests/umask.c: Extend test coverage of umask syscall.
* tests/creat.test: Update the value specified for strace -a parameter.
* tests/mkdir.test: Likewise.
* tests/mkdirat.test: Likewise.
* tests/mknodat.test: Likewise.

8 years agotests: simplify attach-f-p.test
Dmitry V. Levin [Tue, 2 Aug 2016 16:47:34 +0000 (16:47 +0000)]
tests: simplify attach-f-p.test

* tests/attach-f-p.c Simplify communications between threads
by replacing per-thread timers with pipes.
* tests/attach-f-p.test: Do not ignore signals.

8 years agotests: cleanup attach-p-cmd.test
Dmitry V. Levin [Tue, 2 Aug 2016 16:43:37 +0000 (16:43 +0000)]
tests: cleanup attach-p-cmd.test

* tests/attach-p-cmd-cmd.c (main): Cleanup expected output.
* tests/attach-p-cmd-p.c (main): Print expected output.
* tests/attach-p-cmd.test: Do not print expected output.

8 years agoip_mreq.test: rewrite from match_grep to match_diff
Dmitry V. Levin [Tue, 2 Aug 2016 16:33:09 +0000 (16:33 +0000)]
ip_mreq.test: rewrite from match_grep to match_diff

* tests/ip_mreq.c (main): Print expected output.
* tests/ip_mreq.test: Use run_strace_match_diff.
* tests/ip_mreq.expected: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove it.

8 years agofanotify_mark.test: rewrite from match_grep to match_diff
Dmitry V. Levin [Mon, 1 Aug 2016 22:10:44 +0000 (22:10 +0000)]
fanotify_mark.test: rewrite from match_grep to match_diff

* tests/fanotify_mark.c (main): Print expected output.
* tests/fanotify_mark.test: Use run_strace_match_diff.
* tests/fanotify_mark.expected: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove it.

8 years agosignalfd4.test: rewrite from match_grep to match_diff
Dmitry V. Levin [Sun, 31 Jul 2016 22:59:25 +0000 (22:59 +0000)]
signalfd4.test: rewrite from match_grep to match_diff

* tests/signalfd4.c (get_sigset_size): New function.
(main): Use it.  Print expected output.
* tests/signalfd4.test: Use run_strace_match_diff.
* tests/signalfd4.expected: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove it.

8 years agotests: rename signalfd.test to signalfd4.test
Dmitry V. Levin [Sun, 31 Jul 2016 21:55:23 +0000 (21:55 +0000)]
tests: rename signalfd.test to signalfd4.test

* tests/signalfd.c: Rename to signalfd4.c.
* tests/signalfd.test: Rename to signalfd4.test.
* tests/signalfd.expected: Rename to signalfd4.expected.
* tests/.gitignore: Replace signalfd with signalfd4.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Replace signalfd.test with signalfd4.test.
(EXTRA_DIST): Replace signalfd.expected with signalfd4.expected.

8 years agomemfd_create.test: rewrite from match_grep to match_diff
Dmitry V. Levin [Sat, 30 Jul 2016 22:52:27 +0000 (22:52 +0000)]
memfd_create.test: rewrite from match_grep to match_diff

* tests/memfd_create.c (main): Print expected output.
* tests/memfd_create.test: Use run_strace_match_diff.
* tests/memfd_create.expected: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove it.

8 years agoSet exit status to 1 if strace has not traced any processes
Dmitry V. Levin [Fri, 29 Jul 2016 17:51:54 +0000 (17:51 +0000)]
Set exit status to 1 if strace has not traced any processes

* strace.c (main): Initialize exit_code with 1 when no processes
has been attached.
* strace.1: Document it.
* NEWS: Mention this change.

8 years agoAttach to the target process before attempting to attach to its siblings
Dmitry V. Levin [Mon, 25 Jul 2016 18:48:50 +0000 (18:48 +0000)]
Attach to the target process before attempting to attach to its siblings

* strace.c (attach_tcb): Attach to tcp->pid first.

8 years agoReport the name of ptrace command when ptrace_attach_or_seize fails.
Dmitry V. Levin [Mon, 25 Jul 2016 17:12:42 +0000 (17:12 +0000)]
Report the name of ptrace command when ptrace_attach_or_seize fails.

* strace.c (ptrace_attach_cmd): New variable.
(ptrace_attach_or_seize): Save last ptrace command's name
to ptrace_attach_cmd.
(attach_tcb, startup_child): Use it in error diagnostics.

8 years agostrace.c: refactor startup_attach
Dmitry V. Levin [Mon, 25 Jul 2016 16:25:12 +0000 (16:25 +0000)]
strace.c: refactor startup_attach

* strace.c (startup_attach): Move the inner part of the big loop
over tcbtab elements ...
(attach_tcb): ... to this new function.

8 years agostartup_attach: do not use atoi
Dmitry V. Levin [Fri, 29 Jul 2016 17:10:50 +0000 (17:10 +0000)]
startup_attach: do not use atoi

* strace.c (startup_attach): Replace atoi with string_to_uint.

8 years agoDo not enable mpers runtime checks if mpers is not enabled
Dmitry V. Levin [Thu, 28 Jul 2016 18:26:03 +0000 (18:26 +0000)]
Do not enable mpers runtime checks if mpers is not enabled

* m4/mpers.m4 (HAVE_RUNTIME): Enable iff both mpers and runtime
work properly.

8 years agolinux/dummy_check.sh: remove obsolete script
Dmitry V. Levin [Thu, 28 Jul 2016 17:46:51 +0000 (17:46 +0000)]
linux/dummy_check.sh: remove obsolete script

Starting with commit v4.10-62-ga0bd374, function prototypes
of syscall parsers are generated at build time.

* linux/dummy_check.sh: Remove.

8 years agogenerate_xlat_in.sh: remove obsolete script
Dmitry V. Levin [Thu, 28 Jul 2016 17:46:39 +0000 (17:46 +0000)]
generate_xlat_in.sh: remove obsolete script

This script has been created by commit v4.8-180-g0ed617b
for the one-shot job of automatic convertion of xlat structures
from *.c files to xlat/*.in files.

* generate_xlat_in.sh: Remove.

8 years agotests: use terse notation in designated initializers where appropriate
Dmitry V. Levin [Thu, 28 Jul 2016 17:07:23 +0000 (17:07 +0000)]
tests: use terse notation in designated initializers where appropriate

* tests/btrfs.c (btrfs_test_dev_replace_ioctl): Initialize
struct btrfs_ioctl_dev_replace_args using terse notation.
* tests/clock_nanosleep.c (main): Initialize struct timespec
using terse notation.
* tests/nanosleep.c (main): Likewise.

8 years agoConsistently use extended regular expressions where appropriate
Dmitry V. Levin [Thu, 28 Jul 2016 16:51:58 +0000 (16:51 +0000)]
Consistently use extended regular expressions where appropriate

When grep or sed is used with basic regular expressions containing
'(', ')', '{', '}', '|', '?', and '+' special characters, convert them
to extended regular expressions for better portability and readability.

* generate_mpers_am.sh: Convert grep and sed BREs to EREs.
* Makefile.am (ioctl_redefs%.h, m%_type_defs.h, m%_funcs.h,
mpers_printer_decl_pattern, printers.h, %_printer_decls.h,
%_printer_defs.h): Convert sed BREs to EREs.
* generate_sen.sh: Likewise.
* linux/mips/genstub.sh: Likewise.
* make-dsc: Likewise.
* mpers.sh: Likewise.
* xlat/gen.sh: Likewise.
* tests/Makefile.am (ksysent.h): Likewise.
* tests/ksysent.sed: Likewise.
* tests/pc.test: Likewise.
* tests/strace-S.test: Likewise.
* tests/strace-V.test: Likewise.
* tests/strace-k.test: Likewise.

8 years agotests: fix extended regexps
Dmitry V. Levin [Wed, 27 Jul 2016 23:56:51 +0000 (23:56 +0000)]
tests: fix extended regexps

* tests/adjtimex.c (main): Consistently quote curly braces
in expected output.
* tests/uio.expected: Likewise.

8 years agoPost-release administrivia
Dmitry V. Levin [Wed, 27 Jul 2016 09:19:37 +0000 (09:19 +0000)]
Post-release administrivia

* NEWS: Add header line for the next release.
* debian/changelog.in: Add a changelog entry for 4.13-1.
* strace.spec.in: Likewise.

8 years agoPrepare for 4.13 release v4.13
Dmitry V. Levin [Tue, 26 Jul 2016 16:17:18 +0000 (16:17 +0000)]
Prepare for 4.13 release

* NEWS: Update for 4.13 release.

8 years agoFix one more code pattern that might break gcc strict aliasing rules
Dmitry V. Levin [Tue, 26 Jul 2016 15:59:28 +0000 (15:59 +0000)]
Fix one more code pattern that might break gcc strict aliasing rules

* btrfs.c (btrfs_ioctl): Add one more expicit cast to "void *",
to avoid breaking strict-aliasing rules reported by some gcc compilers.
* syscall.c (decode_socket_subcall): Likewise.
* util.c (next_set_bit): Likewise.
* tests/btrfs.c (btrfs_test_send_ioctl): Likewise.

8 years agoFix casts of ptrace's third argument
Dmitry V. Levin [Tue, 26 Jul 2016 15:59:28 +0000 (15:59 +0000)]
Fix casts of ptrace's third argument

* strace.c (maybe_allocate_tcb): Replace "(char *) 0" with NULL
as ptrace's third argument.
* linux/sparc64/get_scno.c (arch_get_scno): Cast third argument
of ptrace to "void *'.
* syscall.c (get_regs): Likewise.
* upeek.c (upeek): Likewise.
* util.c (umoven): Likewise.

8 years agotests/btrfs.c: do not include the same header file twice
Dmitry V. Levin [Tue, 26 Jul 2016 15:51:55 +0000 (15:51 +0000)]
tests/btrfs.c: do not include the same header file twice

* tests/btrfs.c: Do not include <sys/fcntl.h>, <fcntl.h> is enough.

8 years agotests: fix accept4.test on systems that lack SOCK_CLOEXEC definition
Dmitry V. Levin [Tue, 26 Jul 2016 14:09:42 +0000 (14:09 +0000)]
tests: fix accept4.test on systems that lack SOCK_CLOEXEC definition

* tests/accept4.c: Check that O_CLOEXEC is defined.  Use O_CLOEXEC
instead of SOCK_CLOEXEC.

8 years agotests: fix vhangup.test
Dmitry V. Levin [Tue, 26 Jul 2016 10:20:24 +0000 (10:20 +0000)]
tests: fix vhangup.test

* tests/vhangup.c (main): Fix expected output for the case when
the calling process has CAP_SYS_TTY_CONFIG capability.

Reported-by: Yun-Chih Chen <b03902074@ntu.edu.tw>
8 years agotests: fix chown.test
Dmitry V. Levin [Tue, 26 Jul 2016 09:58:37 +0000 (09:58 +0000)]
tests: fix chown.test

* tests/chown.test: Fix the value specified for strace -a parameter.

Reported-by: Yun-Chih Chen <b03902074@ntu.edu.tw>
8 years agox32: fix syscall entries for x86_64 variants of io_setup and io_submit
Dmitry V. Levin [Mon, 25 Jul 2016 09:30:02 +0000 (09:30 +0000)]
x32: fix syscall entries for x86_64 variants of io_setup and io_submit

* linux/x32/syscallent.h (64:io_setup, 64:io_submit): Change handler
to printargs.

8 years agotests/ipc.c: fix typo
Dmitry V. Levin [Mon, 25 Jul 2016 09:20:09 +0000 (09:20 +0000)]
tests/ipc.c: fix typo

8 years agoNEWS: Prepare for 4.13 release
Dmitry V. Levin [Sun, 24 Jul 2016 23:40:14 +0000 (23:40 +0000)]
NEWS: Prepare for 4.13 release

8 years agodebian: add gcc-multilib to Build-Depends for relevant architectures
Dmitry V. Levin [Sat, 23 Jul 2016 23:22:40 +0000 (23:22 +0000)]
debian: add gcc-multilib to Build-Depends for relevant architectures

* debian/control (Build-Depends) [amd64, ppc64, sparc64, x32]:
Add gcc-multilib to enable multiple personalities support.

8 years agotests: check decoding of ipc syscall
Dmitry V. Levin [Fri, 22 Jul 2016 14:25:28 +0000 (14:25 +0000)]
tests: check decoding of ipc syscall

* tests/ipc.c: New file.
* tests/ipc.test: New test.
* tests/.gitignore: Add ipc.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add ipc.test.

8 years agoFix corner cases of ipc syscall decoding
Dmitry V. Levin [Fri, 22 Jul 2016 01:17:25 +0000 (01:17 +0000)]
Fix corner cases of ipc syscall decoding

* xlat/ipccalls.in: New file.
* ipc.c: New file.
* Makefile.am (libstrace_a_SOURCES): Add it.
* linux/dummy.h (sys_ipc): Remove stub alias.
* syscall.c (decode_ipc_subcall): Treat 1st argument of ipc syscall
as "unsigned int".
[S390 || S390X]: Skip ipc cubcalls that have non-zero version.
[SPARC64]: Likewise, for the native personality.
Save ipc cubcall version for later use by specific ipc parsers.
* ipc_msg.c (SYS_FUNC(msgrcv)): Handle non-zero ipc subcall version.
[SPARC64]: Handle non-ipc_kludge case for the native personality.
* linux/subcall.h (msgrcv): Change nargs from 4 to 5.
* linux/s390/syscallent.h (ipc): Change nargs from 6 to 5.
* linux/s390x/syscallent.h (ipc): Likewise.

8 years agotests: skip netlink_protocol.test on old systems
Dmitry V. Levin [Thu, 21 Jul 2016 18:18:40 +0000 (18:18 +0000)]
tests: skip netlink_protocol.test on old systems

* tests/netlink_protocol.c: Check that HAVE_SYS_XATTR_H is defined.
Include <stdlib.h> and <sys/xattr.h>.
(main): Check that system.sockprotoname attribute is supported.

8 years agoDo not print too many arguments of socketcall syscall
Dmitry V. Levin [Thu, 21 Jul 2016 11:47:20 +0000 (11:47 +0000)]
Do not print too many arguments of socketcall syscall

* socketcall.c (SYS_FUNC(socketcall)): Print just "call" and "args"
syscall arguments.
* tests/socketcall.c (test_socketcall): Update expected output.
* tests/socketcall.test: Likewise.

8 years agotests/nsyscalls.c: change the type of syscall arguments to kernel_ulong_t
Dmitry V. Levin [Wed, 20 Jul 2016 10:35:56 +0000 (13:35 +0300)]
tests/nsyscalls.c: change the type of syscall arguments to kernel_ulong_t

As most syscalls on x32 and mips n32 are actually 64-bit,
check that 64-bit syscall arguments are decoded properly.

This also workarounds x32 gcc sign extension bug
reported by Eugene Syromyatnikov at
https://sourceforge.net/p/strace/mailman/message/35150860/

* tests/nsyscalls.c: Include "kernel_types.h".
(main): Change the type of syscall arguments to kernel_ulong_t.

8 years agox32, mips n32: make printargs print full 64-bit syscall arguments
Dmitry V. Levin [Wed, 20 Jul 2016 10:35:24 +0000 (13:35 +0300)]
x32, mips n32: make printargs print full 64-bit syscall arguments

As most of x32 syscalls are regular x86_64 syscalls, they should be
printed by default as 64-bit syscalls, and syscall parsers at their
discretion might print syscalls differently.  This is already
implemented in 64-bit strace tracing x32 personality processes,
and now x32 strace will also behave this way.

Similar reasoning applies to mips n32.

* util.c (printargs) [HAVE_STRUCT_TCB_EXT_ARG]: Print syscall arguments
from ext_arg array using %llx format.

8 years agotests: check decoding of socketcall syscall
Dmitry V. Levin [Wed, 20 Jul 2016 02:28:25 +0000 (02:28 +0000)]
tests: check decoding of socketcall syscall

* tests/socketcall.c: New file.
* tests/socketcall.test: New test.
* tests/.gitignore: Add socketcall.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add socketcall.test.

8 years agoFix corner cases of socketcall syscall
Dmitry V. Levin [Wed, 20 Jul 2016 01:49:25 +0000 (01:49 +0000)]
Fix corner cases of socketcall syscall

* xlat/socketcalls.in: New file.
* socketcall.c: New file.
* Makefile.am (libstrace_a_SOURCES): Add it.
* linux/dummy.h (sys_socketcall): Remove stub alias.
* syscall.c (decode_socket_subcall): Treat 1st argument of socketcall
as "int".  Do not substitute syscall until all socketcall arguments
have been fetched successfully.

8 years agotests: check decoding and dumping of send and recv syscalls
Dmitry V. Levin [Tue, 19 Jul 2016 00:24:25 +0000 (00:24 +0000)]
tests: check decoding and dumping of send and recv syscalls

* tests/unix-pair-send-recv.c: New file.
* tests/unix-pair-send-recv.expected: Likewise.
* tests/unix-pair-send-recv.test: New test.
* tests/.gitignore: Add unix-pair-send-recv.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add unix-pair-send-recv.test.
(EXTRA_DIST): Add unix-pair-send-recv.expected.

8 years agotests: rename unix-pair-send-recv to unix-pair-sendto-recvfrom
Dmitry V. Levin [Tue, 19 Jul 2016 00:00:10 +0000 (00:00 +0000)]
tests: rename unix-pair-send-recv to unix-pair-sendto-recvfrom

* dumpio.expected: Rename to unix-pair-sendto-recvfrom.expected.
* dumpio.test: Rename to unix-pair-sendto-recvfrom.test.
* unix-pair-send-recv.c: Rename to unix-pair-sendto-recvfrom.c
* .gitignore: Rename unix-pair-send-recv to unix-pair-sendto-recvfrom.
* Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add unix-pair-sendto-recvfrom.test.
(MISC_TESTS): Remove dumpio.test.
(EXTRA_DIST): Rename dumpio.expected
to unix-pair-sendto-recvfrom.expected.

8 years agotests: check decoding of shutdown syscall
Dmitry V. Levin [Mon, 18 Jul 2016 23:39:18 +0000 (23:39 +0000)]
tests: check decoding of shutdown syscall

* tests/shutdown.c: New file.
* tests/shutdown.test: New test.
* tests/.gitignore: Add shutdown.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add shutdown.test.

8 years agoxlat/shutdown_modes.in: convert to modern syntax
Dmitry V. Levin [Mon, 18 Jul 2016 23:29:40 +0000 (23:29 +0000)]
xlat/shutdown_modes.in: convert to modern syntax

* xlat/shutdown_modes.in: Replace open-coded xlat table with a list
of constants.

8 years agotests: check silent decoding of sendmmsg and recvmmsg syscalls
Dmitry V. Levin [Mon, 18 Jul 2016 23:19:51 +0000 (23:19 +0000)]
tests: check silent decoding of sendmmsg and recvmmsg syscalls

* tests/mmsg-silent.c: New file.
* tests/mmsg-silent.test: New test.
* tests/.gitignore: Add mmsg-silent.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add mmsg-silent.test.

8 years agoPrint unsent messages of failed sendmmsg syscall
Dmitry V. Levin [Mon, 18 Jul 2016 17:48:44 +0000 (17:48 +0000)]
Print unsent messages of failed sendmmsg syscall

* mmsghdr.c (decode_mmsgvec): Clear syserror for the time of printing
struct mmsghdr array in !use_msg_len case.
(SYS_FUNC(sendmmsg)): As failed sendmmsg syscall does not
set msg_len fields, tell this to decode_mmsgvec.
* tests/mmsg_name.c (test_mmsg_name): Check it.

8 years agoPrint unsent messages of sendmmsg syscall
Dmitry V. Levin [Mon, 18 Jul 2016 16:25:25 +0000 (16:25 +0000)]
Print unsent messages of sendmmsg syscall

* defs.h (decode_mmsgvec): Add int argument.
* mmsghdr.c (print_struct_mmsghdr_config): Add msg_len_vlen field.
(print_struct_mmsghdr): Print struct mmsghdr.msg_len only for
msg_len_vlen first elements of struct mmsghdr array.
(decode_mmsgvec): Add msg_len_vlen argument.
(SYS_FUNC(sendmmsg), SYS_FUNC(recvmmsg)): Pass to decode_mmsgvec
the number of elements of struct mmsghdr array that contain meaningful
struct mmsghdr.msg_len.
* tests/mmsg_name.c (test_mmsg_name): Check it.

8 years agotests: check verbose decoding of msg_name* fields of struct mmsghdr array
Dmitry V. Levin [Mon, 18 Jul 2016 10:21:42 +0000 (10:21 +0000)]
tests: check verbose decoding of msg_name* fields of struct mmsghdr array

* tests/mmsg_name-v.c: New file.
* tests/mmsg_name-v.test: New test.
* tests/.gitignore: Add mmsg_name-v.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add mmsg_name-v.test.

8 years agotests: check decoding of msg_name* fields of struct mmsghdr array
Dmitry V. Levin [Mon, 18 Jul 2016 10:20:06 +0000 (10:20 +0000)]
tests: check decoding of msg_name* fields of struct mmsghdr array

* tests/mmsg_name.c: New file.
* tests/mmsg_name.test: New test.
* tests/.gitignore: Add mmsg_name.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add mmsg_name.test.

8 years agoFix decoding of msg_name* fields of recvmmsg syscall's msghdr array argument
Dmitry V. Levin [Sun, 17 Jul 2016 23:51:39 +0000 (23:51 +0000)]
Fix decoding of msg_name* fields of recvmmsg syscall's msghdr array argument

As msg_namelen fields of recvmmsg syscall's struct msghdr array have
the same read-write semantics as struct msghdr argument of recvmsg
syscall, parser of recvmmsg syscall needs a similar fix.

* mmsghdr.c (print_struct_mmsghdr): Increment p_user_msg_namelen field.
(mmsgvec_data): New structure.
(free_mmsgvec_data, save_mmsgvec_namelen): New functions.
(decode_mmsgvec): Take into account the data saved
by save_mmsgvec_namelen function.
(SYS_FUNC(recvmmsg)): Use save_mmsgvec_namelen.

8 years agommsghdr.c: rewrite decode_mmsgvec using print_array
Dmitry V. Levin [Sat, 16 Jul 2016 22:04:24 +0000 (22:04 +0000)]
mmsghdr.c: rewrite decode_mmsgvec using print_array

* fetch_struct_mmsghdr.c (sizeof_struct_mmsghdr): New mpers printer.
* mmsghdr.c: Include <limits.h>.
(print_struct_mmsghdr_config): New structure.
(fetch_struct_mmsghdr_or_printaddr, print_struct_mmsghdr): New functions.
(decode_mmsgvec): Rewrite using them and print_array.

8 years agotests: check decoding of timeout argument of recvmmsg syscall
Dmitry V. Levin [Mon, 18 Jul 2016 11:22:06 +0000 (11:22 +0000)]
tests: check decoding of timeout argument of recvmmsg syscall

* tests/recvmmsg-timeout.c: New file.
* tests/recvmmsg-timeout.test: New test.
* tests/.gitignore: Add recvmmsg-timeout.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add recvmmsg-timeout.test.

8 years agoFix printing of remaining timeout of recvmmsg syscall
Dmitry V. Levin [Mon, 18 Jul 2016 10:34:41 +0000 (10:34 +0000)]
Fix printing of remaining timeout of recvmmsg syscall

* mmsghdr.c (SYS_FUNC(recvmmsg)): Do not print remaining timeout
when the 5th syscall argument is NULL.
* tests/mmsg.c (main): Update expected output.

8 years agoRemove configure checks for recvmmsg and sendmmsg
Dmitry V. Levin [Tue, 19 Jul 2016 15:00:11 +0000 (15:00 +0000)]
Remove configure checks for recvmmsg and sendmmsg

* configure.ac (AC_CHECK_FUNCS): Remove recvmmsg and sendmmsg.

8 years agotests: add recv_mmsg and send_mmsg functions to libtests
Dmitry V. Levin [Tue, 19 Jul 2016 15:09:05 +0000 (15:09 +0000)]
tests: add recv_mmsg and send_mmsg functions to libtests

* tests/tests.h (recv_mmsg, send_mmsg): New prototype.
* tests/libmmsg.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
* tests/mmsg.c Do not check for __NR_sendmmsg, __NR_recvmmsg,
HAVE_SENDMMSG, and HAVE_RECVMMSG.  Do not include unused headers.
(recv_mmsg, send_mmsg): Remove.

8 years agotests: add socketcall function to libtests
Dmitry V. Levin [Tue, 19 Jul 2016 11:18:25 +0000 (11:18 +0000)]
tests: add socketcall function to libtests

* tests/tests.h (socketcall): New prototype.
* tests/libsocketcall.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.