Commit Graph

7121 Commits

Author SHA1 Message Date
62b47db1ac Update NEWS 2018-12-24 20:11:43 +00:00
Eugene Syromyatnikov
e95c9ec4d1 strace.1.in: consistently use CTRL-combinations 2018-12-24 20:11:43 +00:00
Eugene Syromyatnikov
2479d313e7 strace.1.in: print names of entities in bold, provide man page sections
* strace.1.in (.SH DESCRIPTION, .SH OPTIONS): Add man page section
numbers.  Make mentions of strace and other entities bold.
2018-12-24 20:11:43 +00:00
00d0c29d14 strace.1.in: document %net
* strace.1.in: Mention %net as a synonym to %network.

Complements: v4.25-21-g97c3deca5 "basic_filters: add %net as a possible designation for network syscalls"
2018-12-24 20:00:11 +00:00
Shankara Pailoor
1448070a00 quotactl: add xlat styles support
* quota.c (print_qcmd): New function.
(SYS_FUNC(quotactl)): Use it to print the quotactl command.
* tests/quotactl.c (print_dqinfo, print_dqfmt): Handle XLAT_RAW
and XLAT_VERBOSE.
(QUOTA_STR, QUOTA_ID_STR, QUOTA_STR_INVALID): New macros.
(gen_quotacmd, gen_quotaid): New functions.
(main): Use them.
* tests/quotactl-Xabbrev.c: New file.
* tests/quotactl-Xraw.c: Likewise.
* tests/quotactl-Xverbose.c: Likewise.
* tests/gen_tests.in (quotactl-Xabbrev, quotactl-Xraw,
quotactl-Xverbose): New tests.
* tests/pure_executables.list: Add quotactl-Xabbrev, quotactl-Xraw,
and quotactl-Xverbose.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-12-24 10:19:24 +00:00
b967e34d70 xlat_idx: do not issue warnings for holes in indices
Some xlat indices like evdev_abs have holes, avoid issuing warnings
about them.

* xlat.c (xlat_idx): Do not issue warnings for holes in the index.
2018-12-24 10:19:24 +00:00
d0ae0b3dca rtnl_link: fix off-by-one errors in indexed and sorted xlat lookups
* rtnl_link.c (decode_nla_tun_type, decode_ifla_xdp_attached,
decode_ifla_inet_conf, decode_ifla_inet6_flags, decode_ifla_inet6_conf,
decode_ifla_inet6_stats, decode_ifla_inet6_icmp6_stats,
decode_ifla_inet6_agm): Decrement xlat size by one to account
for XLAT_END as other users of indexed and sorted xlats do.

Fixes: v4.25~71 "rtnl_link: decode named constants for IFLA_XDP_ATTACHED attribute value"
Fixes: v4.23~41 "rtnl_link: decode IFLA_AF_SPEC"
Fixes: v4.23~37 "rtnl_link: implement IFLA_INFO_DATA for tun devices"
2018-12-23 22:12:36 +00:00
476b03b33a net: fix off-by-one error in sorted xlat lookup
* net.c (ax25_protocols): Decrement xlat size by one to account
for XLAT_END as other users of sorted xlats do.

Fixes: v4.25~28 "net: add support for AX.25 protocols and socket option names decoding"
2018-12-23 22:12:36 +00:00
73f565d1b8 netlink_smc_diag: fix off-by-one error in xlat lookup
* netlink_smc_diag.c (decode_smc_diag_shutdown): Decrement xlat size
by one to account for XLAT_END as other users of xlats do.

Fixes: v4.25~54 "netlink_smc_diag: decode SMC_DIAG_SHUTDOWN attribute value"
2018-12-23 22:12:36 +00:00
986a55423e 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"
2018-12-23 22:12:36 +00:00
b2c63fa897 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"
2018-12-23 22:12:36 +00:00
Eugene Syromiatnikov
8a5feb1cb3 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"
2018-12-23 22:12:36 +00:00
f6869581d4 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.
2018-12-22 22:16:03 +00:00
Shankara Pailoor
fa35f3e87d 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>
2018-12-17 19:19:23 +00:00
Eugene Syromyatnikov
2b84c24551 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>
2018-12-17 19:19:23 +00:00
4964cf3765 filter_qualify: prepare for the change of signame semantics
* filter_qualify.c (sigstr_to_uint): Check signame return value.
2018-12-17 19:19:23 +00:00
Eugene Syromyatnikov
63144af13f 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>
2018-12-17 19:19:23 +00:00
Eugene Syromyatnikov
b3f92b39f1 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.
2018-12-17 19:19:23 +00:00
Eugene Syromyatnikov
8c3b410bac signal: make printisgnal honor xlat style
* signal.c (printsignal): Respect current xlat style.
2018-12-17 19:19:23 +00:00
Eugene Syromyatnikov
d1a0f700f1 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>
2018-12-17 19:19:23 +00:00
Masatake YAMATO
692dbd2c3d 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>
2018-12-17 19:19:23 +00:00
004e6b5b7a 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.
2018-12-17 17:30:24 +00:00
bc04bb238c 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.
2018-12-17 13:45:05 +00:00
7273c6fb3c 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.
2018-12-13 22:07:26 +00:00
e3b80cb65f 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.
2018-12-13 22:07:26 +00:00
7488ce9e23 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.
2018-12-13 22:07:26 +00:00
86d073674e 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.
2018-12-13 22:07:26 +00:00
b93d52fe3d 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.
2018-12-10 00:00:00 +00:00
c6782f144a 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.
2018-12-10 00:00:00 +00:00
Shankara Pailoor
bf195a8455 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>
2018-12-10 23:45:11 +00:00
Shankara Pailoor
e1f15583e0 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>
2018-12-10 23:45:11 +00:00
c40270dd87 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.
2018-12-05 18:37:34 +00:00
5be511bf86 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.
2018-12-05 18:37:34 +00:00
1f84eefc40 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.
2018-12-05 18:37:34 +00:00
217eccfba5 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.
2018-12-05 16:10:05 +00:00
51d89ef0a0 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.
2018-12-05 16:10:05 +00:00
917c2ccf3a 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.
2018-12-05 16:10:05 +00:00
bcd5cdddec 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.
2018-12-05 16:10:05 +00:00
afc80cdb3f ppc64: remove redundant redefinition
* linux/powerpc64/arch_regs.c (ARCH_PC_REG): Remove.
2018-12-05 16:10:05 +00:00
Shankara Pailoor
26e1435f91 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>
2018-12-05 16:10:05 +00:00
Janosch Frank
f476724ea1 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>
2018-12-05 16:10:05 +00:00
1dc2a5313c 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.
2018-11-27 01:13:40 +00:00
114249603e 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"
2018-11-26 20:49:05 +00:00
a4fb2fbdde 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.
2018-11-26 02:04:04 +00:00
Shankara Pailoor
0933b30869 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>
2018-11-26 02:04:04 +00:00
956dc3ed36 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.
2018-11-26 02:04:04 +00:00
Shankara Pailoor
f11fb909d7 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>
2018-11-26 02:04:04 +00:00
6f9cf06b99 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
2018-11-24 23:56:38 +00:00
c4c993b642 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
2018-11-24 01:22:13 +00:00
Eugene Syromyatnikov
97c3deca54 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.
2018-11-24 01:22:13 +00:00