]> granicus.if.org Git - strace/log
strace
5 years agoaio: fix off-by-one error in indexed xlat lookup
Dmitry V. Levin [Sun, 23 Dec 2018 22:12:36 +0000 (22:12 +0000)]
aio: fix off-by-one error in indexed xlat lookup

* aio.c (tprint_lio_opcode): Decrement xlat size by one to account
for XLAT_END as other users of indexed xlats do.

Fixes: v4.24~71 "aio: print IOCB_CMD_* using xlat"
5 years agonlattr: fix off-by-one error in indexed xlat lookup
Dmitry V. Levin [Sun, 23 Dec 2018 22:12:36 +0000 (22:12 +0000)]
nlattr: fix off-by-one error in indexed xlat lookup

* nlattr.c (decode_nla_meminfo): Decrement xlat size by one
to account for XLAT_END as other users of indexed xlats do.

Fixes: v4.23~89 "nlattr: print index names in netlink meminfo array"
5 years agoevdev: fix off-by-one error in decode_bitset
Eugene Syromiatnikov [Thu, 20 Dec 2018 15:35:27 +0000 (16:35 +0100)]
evdev: fix off-by-one error in decode_bitset

* evdev.c (decode_bitset): Decrement sorted/indexed xlat's size by one
in order to account for guarding XLAT_END, as other sorted/indexed xlat
wrappers do.

Fixes: v4.23~261 "evdev: support various types of xlats in decode_bitset"
5 years agostrace: terminate itself if interrupted by a signal
Dmitry V. Levin [Sat, 22 Dec 2018 22:16:03 +0000 (22:16 +0000)]
strace: terminate itself if interrupted by a signal

* strace.c (terminate): Terminate itself if interrupted by a signal.
* NEWS: Mention this change.
* tests/detach-running.test: Check it.
* tests/detach-sleeping.test: Likewise.
* tests/detach-stopped.test: Likewise.

5 years agotests: check that printsignal handles xlat styles properly
Shankara Pailoor [Thu, 20 Dec 2018 13:27:40 +0000 (05:27 -0800)]
tests: check that printsignal handles xlat styles properly

* tests/printsignal.c: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/printsignal-Xabbrev.c: New file.
* tests/printsignal-Xraw.c: Likewise.
* tests/printsignal-Xverbose.c: Likewise.
* tests/gen_tests.in (printsignal-Xabbrev, printsignal-Xraw,
printsignal-Xverbose): New tests.
* tests/pure_executables.list: Add printsignal-Xabbrev,
* printsignal-Xraw, and printsignal-Xverbose.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agosignal: return NULL if signal number has no string representation
Eugene Syromyatnikov [Sun, 7 Oct 2018 03:25:33 +0000 (05:25 +0200)]
signal: return NULL if signal number has no string representation

Also return NULL if signal number is 0.

* signal.c (signame): Return NULL if signal name has not been found.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agofilter_qualify: prepare for the change of signame semantics
Dmitry V. Levin [Sat, 22 Dec 2018 18:58:51 +0000 (18:58 +0000)]
filter_qualify: prepare for the change of signame semantics

* filter_qualify.c (sigstr_to_uint): Check signame return value.

5 years agoUse sprintsigname for converting signal number to string
Eugene Syromyatnikov [Sun, 7 Oct 2018 03:23:09 +0000 (05:23 +0200)]
Use sprintsigname for converting signal number to string

As signame is being converted to an xlookup-like function, a separate
routine is needed in order to get string representation of signal.

* defs.h (sprintsigname): New prototype.
* signal.c (sprintsigname): New function.
* strace.c (print_debug_info, print_signalled, print_stopped): Use it
instead of signame.
* wait.c (printstatus): Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoUse printsignal instead of signame
Eugene Syromyatnikov [Sun, 7 Oct 2018 03:12:42 +0000 (05:12 +0200)]
Use printsignal instead of signame

As the former respects xlat styles while the latter doesn't.

* clone.c (SYS_FUNC(clone)): Use printsignal for printing termination
signal in printflags.
* fcntl.c (print_fcntl) <case F_SETSIG>: Use printsignal.
* prctl.c (SYS_FUNC(prctl)) <case PR_GET_PDEATHSIG,
case PR_SET_PDEATHSIG>: Likewise.
* print_sigevent.c (print_sigevent): Likewise.
* s390.c (s390_runtime_instr): Likewise.
* signal.c (SYS_FUNC(kill), SYS_FUNC(tgkill)): Likewise.

5 years agosignal: make printisgnal honor xlat style
Eugene Syromyatnikov [Sun, 7 Oct 2018 03:09:09 +0000 (05:09 +0200)]
signal: make printisgnal honor xlat style

* signal.c (printsignal): Respect current xlat style.

5 years agoAlways define WCOREDUMP
Eugene Syromyatnikov [Wed, 3 Oct 2018 08:31:30 +0000 (10:31 +0200)]
Always define WCOREDUMP

wait.c does it already, now strace.c also does.

* wait.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* strace.c: Replace <sys/wait.h> with "wait.h".
[!WCOREDUMP]: Remove.
* wait.c: Replace <sys/wait.h> with "wait.h".
[!WCOREFLAG] (WCOREFLAG), [!WCOREDUMP] (WCOREDUMP): Move to wait.h,
rework.
[!W_STOPCODE] (W_STOPCODE), [!W_EXITCODE] (W_EXITCODE),
[!W_CONTINUED] (W_CONTINUED): Move to wait.h.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agonet: enhance decoding of getsockopt(SO_ERROR)
Masatake YAMATO [Mon, 17 Dec 2018 19:16:11 +0000 (04:16 +0900)]
net: enhance decoding of getsockopt(SO_ERROR)

* net.c (print_get_error): New function decoding error
number returned as option value for SO_ERROR option.
(print_getsockopt) <case SO_ERROR>: Call print_get_error.

* tests/so_error.c: New test.
* tests/gen_tests.in (so_error): Likewise.
* tests/pure_executables.list: Add so_error.
* tests/.gitignore: Likewise.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoia64: do not clobber r12 for raw syscalls
Dmitry V. Levin [Mon, 17 Dec 2018 17:30:24 +0000 (17:30 +0000)]
ia64: do not clobber r12 for raw syscalls

According to
https://sourceware.org/ml/libc-alpha/2018-12/msg00470.html
GCC mainline now gives errors for an asm that clobbers the stack
pointer.

According to
https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00932.html>
GCC previously ignored such a clobber; thus, this patch removes it
from the clobbers for ia64 raw syscalls.

* linux/ia64/raw_syscall.h (raw_syscall_0): Remove "r12" from clobbers.

5 years agoblock: decode BLKGETZONESZ and BLKGETNRZONES ioctls
Dmitry V. Levin [Mon, 17 Dec 2018 13:45:05 +0000 (13:45 +0000)]
block: decode BLKGETZONESZ and BLKGETNRZONES ioctls

These ioctls were introduced by linux kernel commits v4.20-rc1~17^2~16
and v4.20-rc1~17^2~15, respectively.

* block.c (block_ioctl): Handle BLKGETZONESZ and BLKGETNRZONES.
* xlat/block_ioctl_cmds.in (BLKGETZONESZ, BLKGETNRZONES): New entries.

5 years agoImplement PTRACE_GET_SYSCALL_INFO decoder
Dmitry V. Levin [Thu, 13 Dec 2018 22:07:26 +0000 (22:07 +0000)]
Implement PTRACE_GET_SYSCALL_INFO decoder

* defs.h (audit_arch): New prototype.
* process.c: Include "ptrace_syscall_info.h".
(SYS_FUNC(ptrace)) <PTRACE_GET_SYSCALL_INFO>: Call
print_ptrace_syscall_info on exiting syscall.
* ptrace_syscall_info.h (print_ptrace_syscall_info): New prototype.
* ptrace_syscall_info.c: Include "print_fields.h" and
"xlat/ptrace_syscall_info_op.h".
(print_ptrace_syscall_info): New function.
* xlat/ptrace_syscall_info_op.in: New file.
* tests/ptrace_syscall_info.c: New file.
* tests/gen_tests.in (ptrace_syscall_info): New test.
* tests/pure_executables.list: Add ptrace_syscall_info.
* tests/.gitignore: Likewise.

5 years agoIntroduce PTRACE_GET_SYSCALL_INFO support
Dmitry V. Levin [Wed, 21 Nov 2018 01:44:16 +0000 (01:44 +0000)]
Introduce PTRACE_GET_SYSCALL_INFO support

When PTRACE_GET_SYSCALL_INFO API works,
use it instead of traditional upeek/get_regs API.

Tested on x86_64 and x86.

* get_personality.c: New file.
* get_personality.h: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* linux/aarch64/arch_get_personality.c: New file.
* linux/powerpc64/arch_get_personality.c: Likewise.
* linux/riscv/arch_get_personality.c: Likewise.
* linux/s390x/arch_get_personality.c: Likewise.
* linux/sparc64/arch_get_personality.c: Likewise.
* linux/tile/arch_get_personality.c: Likewise.
* linux/x32/arch_get_personality.c: Likewise.
* linux/x86_64/arch_get_personality.c: Likewise.
* linux/check_scno.c: Likewise.
* linux/x32/check_scno.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* linux/ia64/arch_getrval2.c (getrval2): Invoke get_regs()
if ptrace_syscall_info is in use.
* linux/mips/arch_getrval2.c: Likewise.
* linux/sparc/arch_getrval2.c: Likewise.
* defs.h (get_personality_from_syscall_info): New prototype.
* syscall.c: Include "get_personality.h" and "ptrace_syscall_info.h".
(get_regs_error): Define unconditionally.
(ptrace_sci): New static variable.
(clear_regs): Reset ptrace_sci.op.
(ptrace_syscall_info_is_valid, ptrace_get_syscall_info,
get_syscall_regs): New functions.
(get_syscall_result_regs): Change to get_syscall_regs.
(get_instruction_pointer, get_stack_pointer, get_scno, get_syscall_args,
get_error, set_error, set_success): Add ptrace_syscall_info support.
* tests/int_0x80.test: New test.
* tests/Makefile.am (DECODER_TESTS): Add int_0x80.test.
(XFAIL_TESTS_x86_64, XFAIL_TESTS_x32): Remove.
* tests/gen_tests.in (int_0x80): Remove.

5 years agoCheck whether PTRACE_GET_SYSCALL_INFO is supported by the kernel
Dmitry V. Levin [Wed, 21 Nov 2018 01:44:16 +0000 (01:44 +0000)]
Check whether PTRACE_GET_SYSCALL_INFO is supported by the kernel

The result of this check is going to be used by subsequent commits.

* ptrace_syscall_info.c: New file.
* ptrace_syscall_info.h: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* strace.c: Include "ptrace_syscall_info.h".
(init): Call test_ptrace_get_syscall_info.

5 years agoAdd definitions for PTRACE_GET_SYSCALL_INFO API
Dmitry V. Levin [Wed, 21 Nov 2018 01:44:16 +0000 (01:44 +0000)]
Add definitions for PTRACE_GET_SYSCALL_INFO API

Provide fallback definitions for PTRACE_GET_SYSCALL_INFO API.
Add very basic PTRACE_GET_SYSCALL_INFO support in the parser
of ptrace syscall.

* ptrace.h: Include <stdint.h>.
[!PTRACE_GET_SYSCALL_INFO] (PTRACE_GET_SYSCALL_INFO,
PTRACE_SYSCALL_INFO_NONE, PTRACE_SYSCALL_INFO_ENTRY,
PTRACE_SYSCALL_INFO_EXIT, PTRACE_SYSCALL_INFO_SECCOMP,
struct ptrace_syscall_info): Define.
* xlat/ptrace_cmds.in: Add PTRACE_GET_SYSCALL_INFO.
* process.c (SYS_FUNC(ptrace)): Handle it.

5 years agoChange the license of strace to LGPL-2.1-or-later
Dmitry V. Levin [Mon, 10 Dec 2018 00:00:00 +0000 (00:00 +0000)]
Change the license of strace to LGPL-2.1-or-later

strace is now provided under the terms of the GNU Lesser General
Public License version 2.1 or later, see COPYING for more details.

strace test suite is now provided under the terms of the GNU General
Public License version 2 or later, see tests/COPYING for more details.

5 years agotests: change the license to GPL-2.0-or-later
Dmitry V. Levin [Mon, 10 Dec 2018 00:00:00 +0000 (00:00 +0000)]
tests: change the license to GPL-2.0-or-later

strace test suite is now provided under the terms of the GNU General
Public License version 2 or later, see tests/COPYING for more details.

5 years agobpf: honor xlat styles when printing kernel version
Shankara Pailoor [Sun, 9 Dec 2018 15:41:43 +0000 (07:41 -0800)]
bpf: honor xlat styles when printing kernel version

* print_kernel_version.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (print_kernel_version): New prototype.
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)):
Use print_kernel_version.
* tests/kernel_version.c: New file.
* tests/kernel_version-Xabbrev.c: Likewise.
* tests/kernel_version-Xraw.c: Likewise.
* tests/kernel_version-Xverbose.c: Likewise.
* tests/gen_tests.in (kernel_version, kernel_version-Xabbrev,
kernel_version-Xraw, kernel_version-Xverbose): New tests.
* tests/pure_executables.list: Add kernel_version,
kernel_version-Xabbrev, kernel_version-Xraw, and kernel_version-Xverbose.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoprint_dev_t: add xlat styles support
Shankara Pailoor [Sat, 8 Dec 2018 22:12:42 +0000 (14:12 -0800)]
print_dev_t: add xlat styles support

* print_dev_t.c (print_dev_t): Respect xlat_verbosity.
* tests/btrfs.c (sprint_makedev): New function.
(btrfs_print_balance_args, btrfs_test_dev_info_ioctl,
btrfs_test_dev_replace_ioctl, btrfs_test_get_dev_stats_ioctl,
btrfs_test_scrub_ioctls): Use it to update expected output.
* tests/xstatx.c (print_st_mode, sprint_makedev): New functions.
(print_stat): Use them.
* tests/fstat-Xabbrev.c: New file.
* tests/fstat-Xraw.c: Likewise.
* tests/fstat-Xverbose.c: Likewise.
* tests/fstat64-Xabbrev.c: Likewise.
* tests/fstat64-Xraw.c: Likewise.
* tests/fstat64-Xverbose.c: Likewise.
* tests/gen_tests.in (fstat-Xabbrev, fstat-Xraw, fstat-Xverbose,
fstat64-Xabbrev, fstat64-Xraw, fstat64-Xverbose): New entries.
* tests/trace_fstat.in: Likewise.
* tests/trace_stat_like.in: Likewise.
* tests/pure_executables.list: Add fstat-Xabbrev, fstat-Xraw,
fstat-Xverbose, fstat64-Xabbrev, fstat64-Xraw, and fstat64-Xverbose.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoi386, x32: use upoke() instead of set_regs()
Dmitry V. Levin [Wed, 5 Dec 2018 18:37:34 +0000 (18:37 +0000)]
i386, x32: use upoke() instead of set_regs()

This brings i386 and x32 in line with x86_64
and removes redundant HAVE_GETREGS_OLD checks.
Besides that, use of PTRACE_GET_SYSCALL_INFO would require
an extra get_regs() invocation before set_regs().

* syscall.c (ARCH_MIGHT_USE_SET_REGS): Define to 1.
[HAVE_GETREGS_OLD] (ARCH_MIGHT_USE_SET_REGS): Redefine to 0.
(ptrace_setregset_or_setregs): Check ARCH_MIGHT_USE_SET_REGS instead
of HAVE_GETREGS_OLD.
* linux/i386/arch_regs.c (ARCH_MIGHT_USE_SET_REGS): Redefine to 0.
* linux/powerpc/arch_regs.c: Likewise.
* linux/x86_64/arch_regs.c: Likewise.
* linux/i386/set_error.c (arch_set_error, arch_set_success)
[!HAVE_GETREGS_OLD]: Remove.
* linux/i386/set_scno.c (arch_set_scno) [!HAVE_GETREGS_OLD]: Remove.
* linux/powerpc/set_error.c (arch_set_error, arch_set_success)
[!HAVE_GETREGS_OLD]: Remove.
* linux/powerpc/set_scno.c (arch_set_scno) [!HAVE_GETREGS_OLD]: Remove.
* linux/x86_64/set_error.c [!HAVE_GETREGS_OLD]: Remove.
* linux/x86_64/set_scno.c: Likewise.

5 years agoupoke: workaround crippled x32
Dmitry V. Levin [Wed, 5 Dec 2018 18:37:34 +0000 (18:37 +0000)]
upoke: workaround crippled x32

As PTRACE_POKEUSER is crippled on x32 by design from the very first
linux kernel commit v3.4-rc1~33^2~2 when it was introduced,
workaround this by using the raw x86_64 syscall instead.

* linux/ptrace_pokeuser.c: New file.
* linux/x32/ptrace_pokeuser.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* upoke.c: Include "ptrace_pokeuser.c".
(upoke): Use ptrace_pokeuser instead of ptrace.

5 years agox86_64: remove some annoying pieces of unused code
Dmitry V. Levin [Wed, 5 Dec 2018 18:37:34 +0000 (18:37 +0000)]
x86_64: remove some annoying pieces of unused code

* linux/x86_64/get_scno.c (X32_PERSONALITY_NUMBER): Remove.
(arch_get_scno): Remove ifdefed archeological artefacts.

5 years agoRefactor tamper_with_syscall_exiting()
Dmitry V. Levin [Wed, 5 Dec 2018 16:10:05 +0000 (16:10 +0000)]
Refactor tamper_with_syscall_exiting()

Move the code than deals with updating the return and error values
to separate functions.

* syscall.c (set_error, set_success): New functions.
(tamper_with_syscall_exiting): Use them.

5 years agoRefactor get_syscall_args() and get_error()
Dmitry V. Levin [Wed, 5 Dec 2018 06:47:35 +0000 (06:47 +0000)]
Refactor get_syscall_args() and get_error()

* linux/*/get_error.c: Rename all arch-specific implementations
of get_error() to arch_get_error().
* linux/*/get_syscall_args.c: Rename all arch-specific implementations
of get_syscall_args() to arch_get_syscall_args().
* syscall.c (get_syscall_args, get_error): New functions.
(tamper_with_syscall_exiting, get_syscall_result): Do not clear
tcp->u_error before get_error() invocation as the latter does it now.

5 years agoRefactor stack pointers
Dmitry V. Levin [Tue, 4 Dec 2018 22:31:41 +0000 (22:31 +0000)]
Refactor stack pointers

Change all linux/*/arch_regs.c to provide either ARCH_SP_REG
or ARCH_SP_PEEK_ADDR.  Introduce get_stack_pointer(), rewrite
all code accessing stack pointers to use get_stack_pointer().
On some architectures stack pointers were referred to as frame pointers,
clean up this confusion.

* defs.h (get_stack_pointer): New prototype.
* syscall.c (get_stack_pointer): New function.
* linux/arch_rt_sigframe.c: New file.
* linux/aarch64/arch_regs.c (aarch64_sp_ptr, arm_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/alpha/arch_regs.c: Import linux/alpha/arch_regs.h.
(REG_FP): Rename to REG_SP.
(ARCH_SP_PEEK_ADDR): New macro.
* linux/alpha/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/arc/arch_regs.c (arc_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/arm/arch_regs.c (arm_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/arm/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/avr32/arch_regs.c (avr32_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/bfin/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/hppa/arch_regs.c: Import linux/hppa/arch_regs.h.
(PT_GR30, ARCH_SP_PEEK_ADDR): New macros.
* linux/hppa/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/i386/arch_regs.c (i386_esp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/i386/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/i386/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/ia64/arch_regs.c (ia64_frame_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/ia64/arch_regs.h (ia64_frame_ptr): Remove.
* linux/ia64/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/m68k/arch_regs.c (m68k_usp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/m68k/arch_rt_sigframe.c: Link to i386/arch_rt_sigframe.c.
* linux/m68k/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/metag/arch_regs.c (metag_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/metag/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/microblaze/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/mips/arch_regs.c: Import linux/mips/arch_regs.h.
(mips_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/mips/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/nios2/arch_regs.c (nios2_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/or1k/arch_regs.c (or1k_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/powerpc/arch_regs.c (ppc_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/powerpc/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/powerpc/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/powerpc64/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/riscv/arch_regs.c (riscv_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/s390/arch_regs.c (s390_frame_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/s390/arch_sigreturn.c (S390_FRAME_PTR): Remove.
(arch_sigreturn): Use get_stack_pointer.
* linux/s390x/arch_regs.c (s390_frame_ptr, s390x_frame_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/s390x/arch_sigreturn.c (S390_FRAME_PTR): Remove.
* linux/sh/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/sh64/arch_regs.c: Likewise.
* linux/sparc/arch_regs.c: Import linux/sparc/arch_regs.h.
(sparc_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/sparc/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/sparc64/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/tile/arch_regs.c (tile_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/tile/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/x86_64/arch_regs.c (i386_esp_ptr, x86_64_rsp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/x86_64/arch_regs.h (i386_esp_ptr, x86_64_rsp_ptr): Remove.
* linux/x86_64/arch_rt_sigframe.c: Link to i386/arch_rt_sigframe.c.
* linux/xtensa/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/aarch64/arch_regs.h: Remove.
* linux/aarch64/arch_rt_sigframe.c: Remove.
* linux/alpha/arch_regs.h: Remove.
* linux/alpha/arch_rt_sigframe.c: Remove.
* linux/arc/arch_regs.h: Remove.
* linux/arc/arch_rt_sigframe.c: Remove.
* linux/arm/arch_regs.h: Remove.
* linux/arm/arch_rt_sigframe.c: Remove.
* linux/avr32/arch_regs.h: Remove.
* linux/avr32/arch_rt_sigframe.c: Remove.
* linux/bfin/arch_rt_sigframe.c: Remove.
* linux/hppa/arch_regs.h: Remove.
* linux/i386/arch_regs.h: Remove.
* linux/m68k/arch_regs.h: Remove.
* linux/metag/arch_regs.h: Remove.
* linux/microblaze/arch_rt_sigframe.c: Remove.
* linux/mips/arch_regs.h: Remove.
* linux/mips/arch_rt_sigframe.c: Remove.
* linux/nios2/arch_regs.h: Remove.
* linux/nios2/arch_rt_sigframe.c: Remove.
* linux/or1k/arch_regs.h: Remove.
* linux/or1k/arch_rt_sigframe.c: Remove.
* linux/powerpc/arch_regs.h: Remove.
* linux/powerpc64/arch_regs.h: Remove.
* linux/riscv/arch_regs.h: Remove.
* linux/riscv/arch_rt_sigframe.c: Remove.
* linux/s390/arch_regs.h: Remove.
* linux/s390/arch_rt_sigframe.c: Remove.
* linux/s390x/arch_regs.h: Remove.
* linux/s390x/arch_rt_sigframe.c: Remove.
* linux/sh/arch_rt_sigframe.c: Remove.
* linux/sh64/arch_rt_sigframe.c: Remove.
* linux/sparc/arch_regs.h: Remove.
* linux/sparc/arch_rt_sigframe.c: Remove.
* linux/sparc64/arch_regs.h: Remove.
* linux/tile/arch_regs.h: Remove.
* linux/tile/arch_rt_sigframe.c: Remove.
* linux/xtensa/arch_rt_sigframe.c: Remove.
* Makefile.am (EXTRA_DIST): Remove them, add linux/arch_rt_sigframe.c.

5 years agoRefactor print_pc()
Dmitry V. Levin [Mon, 3 Dec 2018 19:45:02 +0000 (19:45 +0000)]
Refactor print_pc()

Split print_pc() into arch-independent print_instruction_pointer()
and arch-specific get_instruction_pointer().

* print_instruction_pointer.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (print_pc): Remove.
(get_instruction_pointer, print_instruction_pointer): New prototypes.
* syscall.c (print_pc): Remove.
(get_instruction_pointer): New function.
* strace.c (printleader): Replace print_pc with
print_instruction_pointer.

5 years agoppc64: remove redundant redefinition
Dmitry V. Levin [Tue, 4 Dec 2018 22:31:41 +0000 (22:31 +0000)]
ppc64: remove redundant redefinition

* linux/powerpc64/arch_regs.c (ARCH_PC_REG): Remove.

5 years agoprint_dev_t: print major and minor numbers in hex like stat(1)
Shankara Pailoor [Sun, 2 Dec 2018 19:57:10 +0000 (11:57 -0800)]
print_dev_t: print major and minor numbers in hex like stat(1)

* print_dev_t.c (print_dev_t): Print major and minor numbers in hex.
* strace.1.in: Update makedev example.
* tests/bpf-obj_get_info_by_fd.c (main): Update expected output.
* tests/btrfs.c (btrfs_print_balance_args, btrfs_test_scrub_ioctls,
btrfs_test_dev_info_ioctl, btrfs_test_get_dev_stats_ioctl,
btrfs_test_dev_replace_ioctl): Update expected output.
* tests/ioctl_dm.c (main): Likewise.
* tests/ioctl_loop.c (print_loop_info, print_loop_info64): Likewise.
* tests/mknod.c (main): Likewise.
* tests/mknodat.c (main): Likewise.
* tests/nlattr_unix_diag_msg.c (main): Likewise.
* tests/ustat.c (main): Likewise.
* tests/xstatx.c (print_stat): Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agos390x: beautify sthyi data tail prints
Janosch Frank [Fri, 30 Nov 2018 15:41:39 +0000 (16:41 +0100)]
s390x: beautify sthyi data tail prints

The test already expects a ", " before the print of struct
padding. Let's add it to s390.c to make the output look a bit nicer and
fix test runs on z/VM that have padding at the end of the STHYI structs.

* s390.c (decode_ebcdic): Add missing comma.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
5 years agoStop using SIG_0
Dmitry V. Levin [Tue, 27 Nov 2018 01:13:40 +0000 (01:13 +0000)]
Stop using SIG_0

Number 0 is not a valid signal number, and SIG_0 is not a valid
description for a signal.

* linux/signalent.h: Replace SIG_0 with 0.
* linux/alpha/signalent.h: Likewise.
* linux/hppa/signalent.h: Likewise.
* linux/mips/signalent.h: Likewise.
* linux/sparc/signalent.h: Likewise.
* filter_qualify.c (sigstr_to_uint): Start iterations with number 1.
* tests/fcntl-common.c (test_fcntl_others): Update expected output.
* tests/kill.c (main): Likewise.
* tests/ptrace.c (test_peeksiginfo): Likewise.
* tests/s390_runtime_instr.c (main): Likewise.

5 years agomem: fix build on architectures where kernel_ulong_t is bigger than long
Dmitry V. Levin [Mon, 26 Nov 2018 20:49:05 +0000 (20:49 +0000)]
mem: fix build on architectures where kernel_ulong_t is bigger than long

* mem.c (print_mmap_flags): Fix format string.

Fixes: v4.25-26-g0933b3086 "mem: add xlat styles support to print_mmap_flags"
5 years agotests: add remap_file_pages test variants with different xlat verbosity levels
Dmitry V. Levin [Mon, 26 Nov 2018 02:04:04 +0000 (02:04 +0000)]
tests: add remap_file_pages test variants with different xlat verbosity levels

* tests/remap_file_pages-Xabbrev.c: New file.
* tests/remap_file_pages-Xraw.c: Likewise.
* tests/remap_file_pages-Xverbose.c: Likewise.
* tests/remap_file_pages.c: Add handling of XLAT_RAW and XLAT_VERBOSE flags.
* tests/pure_executables.list: Add remap_file_pages-Xabbrev,
remap_file_pages-Xraw, and remap_file_pages-Xverbose.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (remap_file_pages-Xabbrev, remap_file_pages-Xraw,
remap_file_pages-Xverbose): New tests.

5 years agomem: add xlat styles support to print_mmap_flags
Shankara Pailoor [Mon, 26 Nov 2018 01:10:44 +0000 (17:10 -0800)]
mem: add xlat styles support to print_mmap_flags

* mem.c (print_mmap_flags): Respect xlat_verbosity.
* tests/mmap.c (main): Update expected output.
* tests/old_mmap.c (main): Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agotests: add memfd_create test variants with different xlat verbosity levels
Dmitry V. Levin [Mon, 26 Nov 2018 02:04:04 +0000 (02:04 +0000)]
tests: add memfd_create test variants with different xlat verbosity levels

* tests/memfd_create-Xabbrev.c: New file.
* tests/memfd_create-Xraw.c: Likewise.
* tests/memfd_create-Xverbose.c: Likewise.
* tests/memfd_create.c: Add handling of XLAT_RAW and XLAT_VERBOSE flags.
* tests/pure_executables.list: Add memfd_create-Xabbrev, memfd_create-Xraw,
and memfd_create-Xverbose.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (memfd_create-Xabbrev, memfd_create-Xraw,
memfd_create-Xverbose): New tests.

5 years agomemfd_create: add xlat styles support
Shankara Pailoor [Mon, 26 Nov 2018 01:10:44 +0000 (17:10 -0800)]
memfd_create: add xlat styles support

* memfd_create.c (SYS_FUNC(memfd_create)): Respect xlat_verbosity.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoEnhance error diagnostics when the first exec fails
Dmitry V. Levin [Sat, 24 Nov 2018 23:56:38 +0000 (23:56 +0000)]
Enhance error diagnostics when the first exec fails

When the first exec fails, strace used to print the trace of the child
process till its end, producing a lot of confusing output.
Enhance the diagnostics by hiding irrelevant parts of the trace.

* defs.h (TCB_CHECK_EXEC_SYSCALL): New macro.  Change values of TCB_*
macros listed after TCB_CHECK_EXEC_SYSCALL.
(check_exec_syscall): New macro.
* strace.c (dispatch_event) <TE_STOP_BEFORE_EXECVE>: Clear
TCB_CHECK_EXEC_SYSCALL flag.
* syscall.c (syscall_entering_trace): Do not clear TCB_HIDE_LOG when
TCB_CHECK_EXEC_SYSCALL is set, set TCB_CHECK_EXEC_SYSCALL along with
clearing TCB_HIDE_LOG.
(syscall_exiting_decode): Set TCB_HIDE_LOG if TCB_CHECK_EXEC_SYSCALL
is set.
* tests/first_exec_failure.test: New file.
* tests/Makefile.am (MISC_TESTS): Add first_exec_failure.test.

Closes: https://github.com/strace/strace/issues/88
5 years agobuild: use more traditional git options
Dmitry V. Levin [Sat, 24 Nov 2018 01:22:13 +0000 (01:22 +0000)]
build: use more traditional git options

The support of --no-patch alias to -s option in "git diff" and related
git commands was added in git v1.8.4.

* copyright-year-gen: Use "git show -s" instead of "git show --no-patch".
* file-date-gen: Use "git log -s" instead of "git log --no-patch".

Closes: https://github.com/strace/strace/issues/80
5 years agobasic_filters: add %net as a possible designation for network syscalls
Eugene Syromyatnikov [Sun, 7 Oct 2018 03:05:44 +0000 (05:05 +0200)]
basic_filters: add %net as a possible designation for network syscalls

* basic_filters.c (lookup_class) <syscall_class>: Add %net as an alias
for TRACE_NETWORK.

5 years agohppa: add a comment about old name of syscall number 102
Eugene Syromyatnikov [Thu, 25 Oct 2018 23:59:26 +0000 (01:59 +0200)]
hppa: add a comment about old name of syscall number 102

Also, remove empty definition.

* linux/hppa/syscallent.h ([102]): Remove empty definition,
add a comment that it was socketcall.

5 years agomips: update syscall entry for reserved221 syscall
Eugene Syromyatnikov [Thu, 25 Oct 2018 23:58:39 +0000 (01:58 +0200)]
mips: update syscall entry for reserved221 syscall

The syscall number 4221 is actually called "reserved221" on mips.

* linux/mips/syscallent-o32.h ([4221]): Set to "reserved221".

5 years agoarm: add a comment that __ARM_NR_cmpxchg was removed in 4.4
Eugene Syromyatnikov [Mon, 24 Sep 2018 18:35:18 +0000 (20:35 +0200)]
arm: add a comment that __ARM_NR_cmpxchg was removed in 4.4

* linux/arm/syscallent.h: Add a comment about __ARM_NR_cmpxchg.

5 years agoarm: replace empty syscall entry definitions with comments
Eugene Syromyatnikov [Mon, 24 Sep 2018 18:32:45 +0000 (20:32 +0200)]
arm: replace empty syscall entry definitions with comments

* linux/arm/syscallent.h ([222]): Remove definition, add a comment
that it was tux syscall.
([223]): Remove definition, add comment that it was unused.
([254]): Remove definition, add comment that it was reserved
for set_thread_area.
([255]): Remove definition, add comment that it was reserved
for get_thread_area.

5 years agolinux/dummy.h: remove unused sys_phys definition
Eugene Syromyatnikov [Mon, 15 Oct 2018 15:55:56 +0000 (17:55 +0200)]
linux/dummy.h: remove unused sys_phys definition

* linux/dummy.h (sys_phys): Remove.

5 years agonuma: use already existing array item printing function
Eugene Syromyatnikov [Thu, 27 Sep 2018 05:31:23 +0000 (07:31 +0200)]
numa: use already existing array item printing function

* numa.c (print_int): Remove.
(SYS_FUNC(move_pages)): Use print_int32_array_member instead of
print_int.

5 years agonet: use already existing array item printing function
Eugene Syromyatnikov [Mon, 24 Sep 2018 18:30:27 +0000 (20:30 +0200)]
net: use already existing array item printing function

* net.c (print_uint32): Remove.
(print_getsockopt): Use print_uint32_array_member instead of
print_uint32.

5 years agoRemove HAVE_LINUX_GENETLINK_H ifdefs
Eugene Syromyatnikov [Mon, 24 Sep 2018 17:56:08 +0000 (19:56 +0200)]
Remove HAVE_LINUX_GENETLINK_H ifdefs

<linux/netlink.h> is available since Linux 2.6.15 (commit
v2.6.15-rc1~53^2).

* configure.ac (AC_CHECK_HEADERS): Remove linux/genetlink.h.
* socketutils.c [!HAVE_LINUX_GENETLINK_H]: Remove.
* tests/netlink_generic.c [!HAVE_LINUX_GENETLINK_H]: Likewise.

5 years agoDocument -X option in strace -h output
Dmitry V. Levin [Wed, 21 Nov 2018 22:51:49 +0000 (22:51 +0000)]
Document -X option in strace -h output

* strace.c (usage): Mention -X option.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Complements: v4.23~308 "Add user interface for configuring xlat output style"

5 years agoMove kill_save_errno to a separate header file
Dmitry V. Levin [Wed, 21 Nov 2018 01:44:16 +0000 (01:44 +0000)]
Move kill_save_errno to a separate header file

This function is going to be used outside strace.c,
so make it globally available and move it to a separate header file.

* strace.c (kill_save_errno): Add "inline" keyword, change return type
from "void" to "int", move the function ...
* kill_save_errno.h: ... to this new file.
* Makefile.am (strace_SOURCES): Add it.

5 years agosyscall_entering_trace: set TCB_FILTERED along with TCB_HIDE_LOG
Dmitry V. Levin [Tue, 20 Nov 2018 04:56:30 +0000 (04:56 +0000)]
syscall_entering_trace: set TCB_FILTERED along with TCB_HIDE_LOG

This allows to remove some of hide_log() checks that became redundant.

* syscall.c (syscall_entering_trace): Set TCB_FILTERED along with
TCB_HIDE_LOG, remove now redundant hide_log(tcp) check.
(syscall_exiting_decode): Replace "filtered(tcp) || hide_log(tcp)"
with "filtered(tcp)".

5 years agosyscall_entering_trace: optimize clearing of TCB_HIDE_LOG flag
Dmitry V. Levin [Tue, 20 Nov 2018 04:56:30 +0000 (04:56 +0000)]
syscall_entering_trace: optimize clearing of TCB_HIDE_LOG flag

* syscall.c (syscall_entering_trace): Since we check for TCB_HIDE_LOG
flag anyway, do not clean it unless it is set.

5 years agoprint_inet_addr: print nameless and named addresses using the same style
Dmitry V. Levin [Mon, 12 Nov 2018 13:42:11 +0000 (13:42 +0000)]
print_inet_addr: print nameless and named addresses using the same style

* sockaddr.c (print_inet_addr): Handle var_name == NULL case in a more
structured way: use inet_addr("%s") form to print AF_INET addresses
in structureless contexts where no structure field name is available.
Likewise, use inet_pton(AF_INET6, "%s") that case.
* tests/nlattr_ifaddrmsg.c (main): Update expected output.
* tests/nlattr_ifla_af_spec.c (main): Likewise.

Complements: v4.19~76 "print_inet_addr: add support of invocations without field name"

5 years agotests: extend test coverage of RND* ioctl commands
Dmitry V. Levin [Mon, 5 Nov 2018 17:40:36 +0000 (17:40 +0000)]
tests: extend test coverage of RND* ioctl commands

* tests/ioctl_random.c (main): Check the error path of RNDADDENTROPY
parser.  Check decoding of unrecognized RND* ioctl commands.

5 years agoAdd support for /dev/[u]random ioctls
Rasmus Villemoes [Mon, 5 Nov 2018 17:29:00 +0000 (17:29 +0000)]
Add support for /dev/[u]random ioctls

* random_ioctl.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (DECL_IOCTL): Add random.
* ioctl.c (ioctl_decode): Add 'R' case.
* xlat/random_ioctl_cmds.in: New file.
* tests/ioctl_random.c: New file.
* tests/.gitignore: Add ioctl_random.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (ioctl_random): New entry.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
5 years agoAdd dist/INSTALL
Eugene Syromyatnikov [Wed, 16 May 2018 00:22:44 +0000 (02:22 +0200)]
Add dist/INSTALL

* dist/INSTALL: New file.
* bootstrap: Copy it.
* .gitignore: Add /INSTALL.

References: https://github.com/strace/strace/issues/17
References: https://github.com/strace/strace/issues/55
Closes: https://github.com/strace/strace/issues/67
5 years agoRename INSTALL to README-configure
Eugene Syromyatnikov [Tue, 13 Mar 2018 13:11:01 +0000 (14:11 +0100)]
Rename INSTALL to README-configure

* INSTALL-git.md: Replace INSTALL with README-configure.
* maint/install.texi: Likewise.
* INSTALL: Rename to README-configure, regenerate.
* Makefile.am (EXTRA_DIST): Add README-configure.

References: https://github.com/strace/strace/issues/85
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agodist/README: add more references
Eugene Syromyatnikov [Tue, 4 Sep 2018 14:32:25 +0000 (16:32 +0200)]
dist/README: add more references

* dist/README: Mention README-hacking, add links to repositories
and the mailing list archive.

Suggested-by: Jamal Hadi Salim <jhs@mojatatu.com>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoREADME.md: add a link to the new contributors guide
Eugene Syromyatnikov [Tue, 4 Sep 2018 13:54:30 +0000 (15:54 +0200)]
README.md: add a link to the new contributors guide

* README.md: Add a link to the Guide of new contributors.

Suggested-by: Jamal Hadi Salim <jhs@mojatatu.com>
5 years agoPost-release administrivia
Dmitry V. Levin [Tue, 30 Oct 2018 10:43:31 +0000 (10:43 +0000)]
Post-release administrivia

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

5 years agoPrepare for 4.25 release v4.25
Dmitry V. Levin [Tue, 30 Oct 2018 08:09:10 +0000 (08:09 +0000)]
Prepare for 4.25 release

* NEWS: Update for 4.25 release.

5 years agoUpdate copyright headers
Dmitry V. Levin [Tue, 30 Oct 2018 08:09:10 +0000 (08:09 +0000)]
Update copyright headers

Headers updated automatically using maint/update_copyright_years.sh
script.

5 years agoUpdate NEWS
Dmitry V. Levin [Thu, 25 Oct 2018 10:37:49 +0000 (10:37 +0000)]
Update NEWS

5 years agoImplement decoding of NBD_* ioctl commands
Elvira Khabirova [Sat, 22 Sep 2018 13:09:50 +0000 (15:09 +0200)]
Implement decoding of NBD_* ioctl commands

* nbd_ioctl.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (DECL_IOCTL): Add nbd.
* ioctl.c (ioctl_decode): Add 0xab (nbd) case.
* xlat/nbd_ioctl_cmds.in: Likewise.
* xlat/nbd_ioctl_flags.in: Likewise.
* tests/ioctl_nbd.c: Likewise.
* tests/.gitignore: Add ioctl_nbd.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (ioctl_nbd): New entry.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agotests: fix build with recent kernel headers
Dmitry V. Levin [Thu, 25 Oct 2018 13:36:54 +0000 (13:36 +0000)]
tests: fix build with recent kernel headers

Linux commit v4.19-rc2-5-g2ecefa0a15fd0ef88b9cd5d15ceb813008136431
changed the definition of struct keyctl_dh_params in an incompatible
way again.  Workaround this issue by using designated initializers.

* tests/keyctl.c (main): Use designated initializers for
struct keyctl_dh_params.

5 years agoarm, sparc, sparc64: wire up io_pgetevents
Dmitry V. Levin [Wed, 24 Oct 2018 09:05:38 +0000 (09:05 +0000)]
arm, sparc, sparc64: wire up io_pgetevents

* linux/arm/syscallent.h ([399]): Wire up io_pgetevents syscall
introduced by Linux commit v4.19-rc7~24^2~1.
(ARM_FIRST_SHUFFLED_SYSCALL, SYS_socket_subcall): Raise from 400 to 500,
to make room for new syscalls.
* linux/sparc/syscallent.h ([361]): Wire up io_pgetevents syscall
introduced by Linux commit v4.19~31^2~5.
* linux/sparc64/syscallent.h: Likewise.

5 years agoUpdate ioctl entries from linux v4.19
Gleb Fotengauer-Malinovskiy [Sun, 21 Oct 2018 08:47:44 +0000 (11:47 +0300)]
Update ioctl entries from linux v4.19

* linux/32/ioctls_inc_align16.h: Update from linux v4.19-rc8
using ioctls_gen.sh.
* linux/32/ioctls_inc_align32.h: Likewise.
* linux/32/ioctls_inc_align64.h: Likewise.
* linux/64/ioctls_inc.h: Likewise.
* linux/x32/ioctls_inc0.h: Likewise.
* linux/i386/ioctls_arch0.h: Likewise.
* linux/x86_64/ioctls_arch0.h: Likewise.
* NEWS: Mention this.

5 years agomaint: update for linux 4.19-rc8
Gleb Fotengauer-Malinovskiy [Sun, 21 Oct 2018 08:47:06 +0000 (11:47 +0300)]
maint: update for linux 4.19-rc8

* maint/ioctls_sym.sh (x86_list): Add KVM_[GS]ET_NESTED_STATE.

5 years agoRemove redundant VIDIOC_SUBDEV_* constants
Dmitry V. Levin [Wed, 24 Oct 2018 07:48:56 +0000 (07:48 +0000)]
Remove redundant VIDIOC_SUBDEV_* constants

Remove those of VIDIOC_SUBDEV_* constants are defined exactly the same
way by the Linux kernel as their VIDIOC_* origins.

Linux kernel commit v4.19-rc1~137^2~248 introduced more of such
duplicates, forward remove them as well.

* linux/32/ioctls_inc_align16.h: Remove VIDIOC_SUBDEV_DV_TIMINGS_CAP,
VIDIOC_SUBDEV_ENUM_DV_TIMINGS, VIDIOC_SUBDEV_G_DV_TIMINGS,
VIDIOC_SUBDEV_G_EDID, VIDIOC_SUBDEV_QUERY_DV_TIMINGS,
VIDIOC_SUBDEV_S_DV_TIMINGS, and VIDIOC_SUBDEV_S_EDID.
* linux/32/ioctls_inc_align32.h: Likewise.
* linux/32/ioctls_inc_align64.h: Likewise.
* linux/64/ioctls_inc.h: Likewise.
* linux/x32/ioctls_inc0.h: Likewise.
* maint/ioctls_sym.sh: Remove VIDIOC_SUBDEV_DV_TIMINGS_CAP,
VIDIOC_SUBDEV_ENUM_DV_TIMINGS, VIDIOC_SUBDEV_ENUMSTD,
VIDIOC_SUBDEV_G_DV_TIMINGS, VIDIOC_SUBDEV_G_EDID, VIDIOC_SUBDEV_G_STD,
VIDIOC_SUBDEV_QUERY_DV_TIMINGS, VIDIOC_SUBDEV_QUERYSTD,
VIDIOC_SUBDEV_S_DV_TIMINGS, VIDIOC_SUBDEV_S_EDID, and
VIDIOC_SUBDEV_S_STD.

5 years agoxtensa: fix typo in pkey_alloc syscall number
Dmitry V. Levin [Thu, 27 Sep 2018 19:46:36 +0000 (19:46 +0000)]
xtensa: fix typo in pkey_alloc syscall number

* linux/xtensa/syscallent.h (pkey_alloc): Change from 249 to 349.

5 years agoxlat: print _IOC_NONE in symbolic form even if it is equal to 0
Dmitry V. Levin [Sun, 23 Sep 2018 09:54:55 +0000 (09:54 +0000)]
xlat: print _IOC_NONE in symbolic form even if it is equal to 0

On some architectures _IOC_NONE equals to 1, on others it is 0.
Change the way how ioctl direction flags are printed so that
_IOC_NONE is printed in symbolic form even if it is equal to 0.

* xlat/ioctl_dirs.in (_IOC_NONE): Move to the head of the list.
* tests/ioctl_inotify.c (main): Update expected output.
* tests/ioctl_loop. (main): Likewise.c
* tests/ioctl_perf.c (main): Likewise.
* tests/ioctl_scsi.c (main): Likewise.

5 years agoDisable git-archive
Dmitry V. Levin [Tue, 18 Sep 2018 21:54:17 +0000 (21:54 +0000)]
Disable git-archive

Since configure uses git-version-gen which in turn depends
on "git describe" or  a .tarball-version file, raw archives
generated by "git archive" cannot be built.

* .gitattributes: New file.
* README-github_gitlab-autogenerated-archives.txt: Likewise.

5 years agoWorkaround signedness bugs in system NLMSG_OK reported by -Wsign-compare
Dmitry V. Levin [Sun, 16 Sep 2018 21:32:37 +0000 (21:32 +0000)]
Workaround signedness bugs in system NLMSG_OK reported by -Wsign-compare

Introduce a replacement for NLMSG_OK provided by <linux/netlink.h> since
that system macro contains signedness bugs that are not going to be fixed.

* netlink.h: Include <stdbool.h>.
(is_nlmsg_ok): New static inline function.
* socketutils.c (receive_responses): Use it instead of NLMSG_OK.
* tests/netlink_inet_diag.c (check_responses): Likewise.
* tests/netlink_netlink_diag.c (check_responses): Likewise.
* tests/netlink_unix_diag.c (check_responses): Likewise.

Closes: https://github.com/strace/strace/issues/79
5 years agotests/sprintrc.c: drop redundant check
Dmitry V. Levin [Sun, 16 Sep 2018 16:45:24 +0000 (16:45 +0000)]
tests/sprintrc.c: drop redundant check

* tests/sprintrc.c (sprintrc_ex): Remove fmt check, this also fixes the
warning reported by clang -Wtautological-constant-out-of-range-compare.

5 years agobuild: enable gcc -Woverride-init and clang -Winitializer-overrides
Dmitry V. Levin [Sun, 16 Sep 2018 11:44:01 +0000 (11:44 +0000)]
build: enable gcc -Woverride-init and clang -Winitializer-overrides

* m4/st_warn_cflags.m4 (gl_WARN_ADD): Add -Winitializer-overrides
and -Woverride-init.

5 years agotests: exclude arm_sync_file_range from ksysent test
Dmitry V. Levin [Sun, 16 Sep 2018 11:44:01 +0000 (11:44 +0000)]
tests: exclude arm_sync_file_range from ksysent test

arm_sync_file_range is better known as sync_file_range2.

* tests/ksysent.sed: Filter out arm_sync_file_range.

5 years agoIgnore warnings about overridden initialization of hwaddr_sizes
Dmitry V. Levin [Sun, 16 Sep 2018 11:44:01 +0000 (11:44 +0000)]
Ignore warnings about overridden initialization of hwaddr_sizes

As hwaddr_sizes array is explicitly initialized this way,
ignore potential warnings reported by gcc -Woverride-init
and clang -Winitializer-overrides.

* gcc_compat.h (CLANG_PREREQ): New macro.
(DIAG_PUSH_IGNORE_OVERRIDE_INIT, DIAG_POP_IGNORE_OVERRIDE_INIT): New
macros non-trivially defined for gcc >= 4.2 and clang >= 2.8.
* sock.c (print_ifreq): Use them to ignore warnings about overridden
initialization of hwaddr_sizes array.

Closes: https://github.com/strace/strace/issues/77
5 years agotests: workaround clang -Wunneeded-internal-declaration bug
Dmitry V. Levin [Sun, 16 Sep 2018 09:48:16 +0000 (09:48 +0000)]
tests: workaround clang -Wunneeded-internal-declaration bug

* tests/execve.c (main): Explicitly mark q_envp variable as used
to workaround clang -Wunneeded-internal-declaration bug.
* tests/execveat.c (main): Likewise.
* tests/nsyscalls.c (main): Explicitly mark syscallent variable as used
to workaround clang -Wunneeded-internal-declaration bug.

Closes: https://github.com/strace/strace/issues/78
5 years agoprocess: honor xlat style in print_user_offset_addr
Eugene Syromyatnikov [Fri, 31 Aug 2018 07:01:24 +0000 (09:01 +0200)]
process: honor xlat style in print_user_offset_addr

* process.c (print_user_offset_addr): Print in accordance with xlat
verbosity setting.

5 years agotime: add xlat styles support to printclockname
Eugene Syromyatnikov [Fri, 31 Aug 2018 04:42:28 +0000 (06:42 +0200)]
time: add xlat styles support to printclockname

* time.c (printclockname): Respectl xlat_verbosity.

5 years agoperf: rewrite print_perf_event_attr using PRINT_FIELD_* macros
Eugene Syromyatnikov [Fri, 31 Aug 2018 04:05:08 +0000 (06:05 +0200)]
perf: rewrite print_perf_event_attr using PRINT_FIELD_* macros

* perf.c: Include "print_fields.h".
(PRINT_XLAT): Remove.
(print_perf_event_attr): Use PRINT_FIELD_* macros.

5 years agotests: check stack unwinding for signals
Eugene Syromyatnikov [Fri, 31 Aug 2018 14:04:16 +0000 (16:04 +0200)]
tests: check stack unwinding for signals

* tests/stack-fcall-3.c: Include <signal.h>.
(f3): Call getpid or kill depending on the argument, store getpid result.
* tests/stack-fcall.c (main): Remove arguments, call f0(0) and f0(1).
* tests/strace-k-demangle.expected: Update expected output.
* tests/strace-k.expected: Likewise.
* tests/strace-k.test: Rewrite pattern matching code.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
5 years agoPrint stack traces on signals
Eugene Syromyatnikov [Wed, 29 Aug 2018 16:09:57 +0000 (18:09 +0200)]
Print stack traces on signals

I don't know why it hasn't been done earlier.

* strace.c (print_stopped) [ENABLE_STACKTRACE]: Call unwind_tcb_print
if stack trace printing is enabled.

5 years agoxlat: provide fallback definitions for open_access_modes constants
Eugene Syromyatnikov [Fri, 31 Aug 2018 07:08:08 +0000 (09:08 +0200)]
xlat: provide fallback definitions for open_access_modes constants

* xlat/open_access_modes.in: Add fallback values.

5 years agoxlat: update resources
Eugene Syromyatnikov [Fri, 31 Aug 2018 03:22:29 +0000 (05:22 +0200)]
xlat: update resources

* xlat/resources.in: Declare as #value indexed, provide fallback values.
(RLIMIT_VMEM): Remove.

5 years agonlattr: ignore nla_type flags when selecting nlattr decoder
Eugene Syromyatnikov [Tue, 28 Aug 2018 01:07:59 +0000 (03:07 +0200)]
nlattr: ignore nla_type flags when selecting nlattr decoder

* nlattr.c (decode_nlattr_with_data): Apply NLA_TYPE_MASK to nla_type
before decoder selection.

5 years agonetlink_packet_diag: assorted decoding fixes
Eugene Syromyatnikov [Mon, 27 Aug 2018 19:34:06 +0000 (21:34 +0200)]
netlink_packet_diag: assorted decoding fixes

* xlat/af_packet_versions.in: New file.
* netlink_packet_diag.c: Include "xlat/af_packet_versions.h".
(decode_packet_diag_req): sdiag_protocol shouldn't be decoded as a protocol,
currently it should be set to 0.
(decode_packet_diag_info): Decode pdi_version field using af_packet_versions
xlat; decode pdi_index field as an interface index.
(packet_diag_msg_nla_decoders) <PACKET_DIAG_UID>: Decode using
decode_nla_uid.
(decode_packet_diag_msg): Decode pdiag_num as an low-level protocol.
* tests/netlink_sock_diag.c: Update expected output.
* tests/nlattr_packet_diag_msg.c: Likewise.

5 years agosockaddr: add X.25 socket address decoding support
Eugene Syromyatnikov [Mon, 27 Aug 2018 04:26:56 +0000 (06:26 +0200)]
sockaddr: add X.25 socket address decoding support

* sockaddr.c: Include <linux/x25.h>.
(print_sockaddr_data_x25): New function.
(sa_printers) <[AF_X25]>: New socket address handler.
* tests/net-sockaddr.c (check_x25): New function.
(main): Use it to check X.25 socket address decoding.

5 years agonet: add support for AX.25 protocols and socket option names decoding
Eugene Syromyatnikov [Mon, 27 Aug 2018 04:22:52 +0000 (06:22 +0200)]
net: add support for AX.25 protocols and socket option names decoding

* xlat/ax25_protocols.in: New file.
* xlat/sock_ax25_options.in: Likewise.
* net.c: Include "xlat/ax25_protocols.h" and "xlat/sock_ax25_options.h".
* (SYS_FUNC(socket)): <[AF_AX25]>: Print protocol name using
ax25_protocols xlat.
(print_sockopt_fd_level_name) <[SOL_AX25]>: Print socket option name
using sock_ax25_options xlat.

5 years agosockaddr: decode AX.25 socket addresses
Eugene Syromyatnikov [Mon, 27 Aug 2018 01:13:04 +0000 (03:13 +0200)]
sockaddr: decode AX.25 socket addresses

* defs.h (print_ax25_addr): New prototype.
* print_fields.h (PRINT_FIELD_AX25_ADDR): New macro.
* sockaddr.c: Include <linux/ax25.h>.
(check_ax25_address, ax25_addr2str, print_ax25_addr_raw,
print_ax25_addr, print_sockaddr_data_ax25): New functions.
(sa_printers) <[AF_AX25]>: New printer.
* tests/net-sockaddr.c (AX25_ADDR): New macro.
(check_ax25): New function.
(main): Use it to check AX.25 socket address decoding.

5 years agomacros: add ROUNDUP macro
Eugene Syromyatnikov [Sun, 2 Sep 2018 16:15:40 +0000 (18:15 +0200)]
macros: add ROUNDUP macro

* macros.h (ROUNDUP): New macro.

5 years agofutex: recognise FUTEX_BITSET_MATCH_ANY bitmask
Eugene Syromyatnikov [Wed, 29 Aug 2018 20:18:36 +0000 (22:18 +0200)]
futex: recognise FUTEX_BITSET_MATCH_ANY bitmask

* xlat/futexbitset.in: New file.
* futex.c: Include "xlat/futexbitset.h".
(futex) <FUTEX_WAIT_BITSET, FUTEX_WAKE_BITSET>: Decode val3 using
futexbitset xlat.
* tests/futex.c: Add checks for 0xffffffff bitset mask printing.

Closes: Linux commit v4.16-rc1~166^2^2~2
5 years agoioprio: move constant definitions to xlat
Eugene Syromyatnikov [Mon, 27 Aug 2018 19:26:04 +0000 (21:26 +0200)]
ioprio: move constant definitions to xlat

* xlat/ioprio_class.in: Add fallback values.
* xlat/ioprio_who.in: Likewise.
* ioprio.c: Remove IOPRIO_WHO_* and IOPRIO_CLASS_* enums.

5 years agonet: decode AF_PACKET protocols in socket syscall
Eugene Syromyatnikov [Mon, 27 Aug 2018 13:20:33 +0000 (15:20 +0200)]
net: decode AF_PACKET protocols in socket syscall

* net.c: Include "xlat/ethernet_protocols.h" in XLAT_MACROS_ONLY mode.
(SYS_FUNC(socket)) <AF_PACKET>: Decode using ethernet_protocols xlat.

5 years agoprint_ifindex: add public get_ifname method
Eugene Syromyatnikov [Mon, 27 Aug 2018 13:16:10 +0000 (15:16 +0200)]
print_ifindex: add public get_ifname method

In order to be able to obtain sanitised device name internally.

* defs.h (get_ifname): New declaration.
* print_ifindex.c (get_ifname): Refactor, leaving out addition
of if_nametoindex("") part.
(sprint_ifname): New function, adds if_nametoindex("")
to get_ifname's output.
(print_ifindex): Use sprint_ifname instead of get_ifname.

5 years agosocketutils: introduce get_family_by_proto
Eugene Syromyatnikov [Mon, 27 Aug 2018 10:49:20 +0000 (12:49 +0200)]
socketutils: introduce get_family_by_proto

Add a helper function that returns address family based on the internal
notion of the socket protocol using protocols table.

* defs.h (get_family_by_proto): New declaration.
* socketutils.c (get_family_by_proto): New function.

5 years agosocketutils: add more IP/IPv6 transport protocols
Eugene Syromyatnikov [Mon, 27 Aug 2018 10:46:34 +0000 (12:46 +0200)]
socketutils: add more IP/IPv6 transport protocols

* defs.h (sock_proto): Add SOCK_PROTO_UDPLITE, SOCK_PROTO_DCCP,
SOCK_PROTO_SCTP, SOCK_PROTO_L2TP_IP, SOCK_PROTO_PING, SOCK_PROTO_RAW,
SOCK_PROTO_UDPLITEv6, SOCK_PROTO_DCCPv6, SOCK_PROTO_L2TP_IPv6,
SOCK_PROTO_SCTPv6, SOCK_PROTO_PINGv6, and SOCK_PROTO_RAWv6.
* socketutils.c: Include "xlat/inet_protocols.h" in XLAT_MACROS_ONLY
mode.
(protocols): Add protocol descriptions for them.

5 years agosocketutils: store more information in protocols table
Eugene Syromyatnikov [Mon, 27 Aug 2018 10:41:48 +0000 (12:41 +0200)]
socketutils: store more information in protocols table

This also allows getting rid of all these *_v[46]_get calls.

* socketutils.c (unix_get, inet_get, netlink_gen): Add family, protocol,
and proto_name paramteres, use them where appropriate.
(tcp_v4_get, udp_v4_get, tcp_v6_get, udp_v6_get): Remove.
(protocols): Add family and proto fields to the structure, call inet_get
for IP/IPv6 protocols.
(get_sockaddr_by_inode_uncached): Update protocols->get calls.

5 years agosockaddr: whitespace cleanup, fix typo in comment
Eugene Syromyatnikov [Mon, 27 Aug 2018 01:16:18 +0000 (03:16 +0200)]
sockaddr: whitespace cleanup, fix typo in comment

* sockaddr.c (print_sockaddr_data_bt): Fix typo, remove excess
indentation from the switch statement.