Commit Graph

6096 Commits

Author SHA1 Message Date
1f0803c366 syscall: rework subcall decoding on mips o32
Move syscall subcall handling to the same switch statement that
handles ipc and socket subcalls.

* linux/mips/syscallent-o32.h [LINUX_MIPSO32] (SYS_syscall_subcall):
Define.
* syscall.c (decode_mips_subcall): Rename to decode_syscall_subcall,
conditionalize on SYS_syscall_subcall instead of LINUX_MIPSO32.
(syscall_entering_decode) [LINUX_MIPSO32]: Remove.
(syscall_entering_decode) [SYS_syscall_subcall]: Handle SEN_syscall
using decode_syscall_subcall.
2017-12-24 15:07:10 +00:00
660f100099 syscall: tweak shuffle_scno ifdefery
* syscall.c (shuffle_scno): Check for ARM_FIRST_SHUFFLED_SYSCALL
instead of ARM || AARCH64.  This does not result to any code change
but looks more comprehensible.
2017-12-24 15:07:10 +00:00
2a09a8cd8a syscall: change get_regs to return an error code
* syscall.c (get_regs_error) [!ptrace_getregset_or_getregs]: Do not
define.
(clear_regs) [!ptrace_getregset_or_getregs]: Do not set get_regs_error.
(get_regs) [ptrace_getregset_or_getregs]: Return get_regs_error, all
callers changed to test get_regs return code instead of get_regs_error
static variable, which is now internally used by get_regs() and
clear_regs() only.
(USE_GET_SYSCALL_RESULT_REGS): Do not define.
Use "#ifndef ptrace_getregset_or_getregs"
instead of "#ifdef USE_GET_SYSCALL_RESULT_REGS".
2017-12-24 12:40:00 +00:00
Harsha Sharma
5453c146dc tests: enhance run.sh usage error diagnostics
* tests/run.sh: Execute timeout command only when invoked with
an argument, otherwise print an error message.

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
2017-12-24 12:40:00 +00:00
67c934bf57 tests: skip nsyscalls-d.test on mips o32
On mips o32, nsyscalls test is implemented using syscall #4000,
so nsyscalls-d cannot work there.

* tests/nsyscalls-d.test: Skip on mips o32.
2017-12-23 14:12:18 +00:00
2c8036a972 Remove linux/ptp_clock.h
As linux kernel provides a compatible linux/ptp_clock.h header since
commit v3.8-rc1~139^2~514, there is no need for a local copy.

* linux/ptp_clock.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* configure.ac (AC_CHECK_TYPES): Check for struct ptp_sys_offset
in <linux/ptp_clock.h>.
* ioctl.c (ioctl_decode) <case '='>: Conditionalize
on [HAVE_STRUCT_PTP_SYS_OFFSET].
* ptp.c: Likewise.
2017-12-23 02:53:54 +00:00
e10a6d0d57 Remove linux/ubi-user.h
As linux kernel provides a compatible mtd/ubi-user.h header since
commit v3.7-rc1~85^2~17, there is no need for a local copy.

* linux/ubi-user.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* configure.ac (AC_CHECK_MEMBERS): Check
for struct ubi_attach_req.max_beb_per1024 in <mtd/ubi-user.h>.
* ioctl.c (ioctl_decode) <case 'o', case 'O'>: Conditionalize
on HAVE_STRUCT_UBI_ATTACH_REQ_MAX_BEB_PER1024.
* ubi.c: Likewise.
2017-12-23 02:53:54 +00:00
a8e20500ca Remove linux/mtd-abi.h
As linux kernel provides a compatible mtd/mtd-abi.h header since
commit v3.2-rc1~14^2~33, there is no need for a local copy.

* linux/mtd-abi.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* configure.ac (AC_CHECK_TYPES): Check for struct mtd_write_req
in <mtd/mtd-abi.h>.
* ioctl.c (ioctl_decode) <case 'M'>: Conditionalize
on [HAVE_STRUCT_MTD_WRITE_REQ].
* mtd.c: Likewise.
* tests/ioctl_mtd.c: Likewise.
* tests/ioctl.c (main): Likewise.
2017-12-23 02:10:13 +00:00
7396fbce27 Remove linux/personality.h
* linux/personality.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* personality.c: Do not include <linux/personality.h>, include
"xlat/personality_flags.h" before "xlat/personality_types.h".
* xlat/personality_flags.in: Provide fallback definitions.
* xlat/personality_types.in: Likewise.
2017-12-23 01:51:29 +00:00
c91f4b400c travis: switch from clang-3.8 to clang
As travis provides a relatively fresh clang by default nowadays,
it makes sense to use default clang in clang-based test builds.

* .travis.yml (matrix): Change clang-3.8 to clang.
2017-12-23 01:26:17 +00:00
Eugene Syromyatnikov
36fd4ce02b strace.1.in: mention perf and ftrace in SEE ALSO
* strace.1.in (.SH SEE ALSO): Add references to perf-trace(1) and
trace-cmd(1).
2017-12-21 13:12:36 +00:00
Eugene Syromyatnikov
138b417723 strace.1.in: clarify -F option behaviour
* strace.1.in <.TP \-F>: Extend deprecation warning.  Describe behaviour
of multiple instances of -F and interoperability of -F and -f.
2017-12-21 13:12:36 +00:00
f236478750 tests: consistently use $STRACE_EXE instead of local alternatives
* tests/get_regs.test: Replace "${STRACE##* }" with "$STRACE_EXE".
* tests/options-syntax.test: Replace "$strace_exp" with "$STRACE_EXE".
* tests/syntax.sh: Likewise.
2017-12-20 22:58:42 +00:00
Eugene Syromyatnikov
fcf4b6afdc strace.c: inform the user about -F option obsolescence
* strace.c (init): Print an error message if the option is used.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-12-20 22:58:42 +00:00
Eugene Syromyatnikov
61c03be596 strace.c: sort option arguments alphabetically
Except for the ones that enabled by configure options.

While we are here, let's also change the indentation of while expression
continuation in order to separate it from the following switch clause.

* strace.c (init): Reorder options in getopt() call.
2017-12-20 22:58:42 +00:00
Eugene Syromiatnikov
67c4b41ed0 strace.c: use _exit() instead of exit() in child's die()
Let's keep child's death routine as minimalistic as possible for the
cases when vfork() is used instead of fork() on systems that lack MMU.

* strace.c (die) <!(strace_tracer_pid == getpid())>: Call _exit().
2017-12-20 22:58:42 +00:00
Harsha Sharma
391446a359 syscall: replace if (debug_flag) ... with debug_msg macro
* syscall.c (get_scno): Use debug_msg instead of
"if (debug_flag) error_msg".

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
2017-12-20 22:58:42 +00:00
Eugene Syromyatnikov
51e1f187f0 tests: check (some) debugging output generated during nsyscalls test
* tests/nsyscalls-d.c: New file.
* tests/.gitignore: Add it.
* tests/nsyscalls-d.test: New test, variant of nsyscalls.test with debug
output check.
* tests/nsyscalls-nd.test: Likewise.
* tests/nsyscalls.c: Add expected debug output.
* tests/Makefile.am (check_PROGRAMS): Add nsyscalls-d.
(DECODER_TESTS): Add nsyscalls-d.test and nsyscalls-nd.test.
2017-12-20 22:58:42 +00:00
Eugene Syromiatnikov
bfbfdf5e37 pathtrace.c: use xgrowarray
* defs.h <struct path_set>: Change type of num_selected field to size_t.
Add size field.
* pathtrace.c (storepath): Rewrite to utilise xgrowarray.
2017-12-20 22:58:42 +00:00
f236207f46 dyxlat: use xgrowarray
* dyxlat.c (dyxlat_alloc): Use xgrowarray instead of xcalloc.
(dyxlat_add_pair): Use xgrowarray instead of xreallocarray.
2017-12-14 00:05:04 +00:00
3763830d0a unwind: use xgrowarray
* unwind.c (get_symbol_name): Use xgrowarray instead of manual
dynamic array management using xreallocarray.
2017-12-14 00:05:04 +00:00
Eugene Syromiatnikov
607b4a6560 strace.c: use xgrowarray
* strace.c (tcbtabsize): Change type to size_t.
(expand_tcbtab): Rewrite in order to utilise xgrowarray
instead of manual dynamic array management.
2017-12-14 00:05:04 +00:00
Eugene Syromiatnikov
81410d414c unwind: use xgrowarray
* unwind.c (build_mmap_cache): Use xgrowarray instead of manual dynamic
array management.
2017-12-14 00:05:04 +00:00
Eugene Syromiatnikov
057a8f2274 xmalloc.c: introduce xgrowarray helper function
In order to simplify dynamic array management code.

* xmalloc.h (xgrowarray): New declaration.
* xmalloc.c (xgrowarray): New function.
2017-12-14 00:05:04 +00:00
d55a53c758 tests: check error diagnostics when exec file name is too long
* tests/options-syntax.test: Check error diagnostics when
exec file name length equals to PATH_MAX.
2017-12-14 00:05:04 +00:00
Eugene Syromiatnikov
146444206c strace.c: minor style fixes
* strace.c (test_ptrace_seize): Remove excess braces.
(init): Wrap overly long string literal.  Add braces
to the else if branch.
2017-12-13 00:35:31 +00:00
Eugene Syromiatnikov
a1d9d66142 strace.c: use *_func_* message printing macros where appropriate
In order to provide some additional bits of information in weird error
cases or just replace existing usages of __func__/literal function name.

* strace.c (detach): Use perror_func_msg() instead of perror_msg().
(startup_attach, open_dummy_desc, startup_child, test_ptrace_seize): Use
perror_func_msg_and_die() instead of perror_msg_and_die().
(test_ptrace_seize): Use error_func_msg_and_die() instead of
error_msg_and_die().
2017-12-13 00:35:31 +00:00
Eugene Syromiatnikov
0eb82b760f unwind.c: more verbose mapping overlapping diagnostic message
* unwind.c (build_mmap_cache): Change error_msg() to debug_msg(), add
information about region names and the respective start and end
addresses.
2017-12-13 00:35:31 +00:00
Eugene Syromiatnikov
243239d41a unwind.c: non-fatal handling of asprintf error
An error returned by asprintf is a poor excuse for dying.

* unwind.c (asprintf_error_str): New string constant.
(sprint_call_or_error): Replace error_msg_and_die() with
perror_func_msg() and usage of asprintf_error_str for a return value.
(queue_print): Free tmp->output line only if it is not
asprintf_error_str.
2017-12-13 00:35:31 +00:00
Eugene Syromiatnikov
cfec0f6e6c unwind.c: eliminate DPRINTF
Since DPRINTF is simply a macro that provides debugging information
along with some information about printing routine call site, now standard
debug_func_* macros are deemed to be a suitable replacement.

* unwind.c (DPRINTF): Remove.
(build_mmap_cache, delete_mmap_cache, unwind_cache_invalidate,
unwind_print_stacktrace, unwind_captiure_stacktrace): Replace
DPRINTF(fmt, str, ...) with debug_func_msg(fmt, ...)/
2017-12-13 00:35:31 +00:00
Eugene Syromiatnikov
dc4831f242 strace.c: replace if (debug_flag) ... with suitable debug printing macros
* strace.c (alloc_tcb, droptcb, detach, attach_tcb, test_ptrace_seize,
init, startup_tcb): Replace if (debug_flag) error_msg(...) occurrences
with debug_error_msg(...).
(attach_tcb): Replace if (debug_flag) perror_msg(...) with
debug_perror_msg(...).
(cleanup, startup_tcb): Replace if (debug_flag) error_msg(...)
occurrences with debug_func_msg() in attempt to provide additional
information.
2017-12-13 00:35:31 +00:00
Eugene Syromiatnikov
41c5738fe6 error_prints.h: add *_func_* printing macros
In order to reduce boilerplate for the cases when __func__ is desired
to be printed.

* error_prints.h (error_func_msg, perror_func_msg, debug_func_msg,
debug_func_perror_msg, error_func_msg_and_die, perror_func_msg_and_die):
New macro definitions.
2017-12-13 00:35:31 +00:00
Eugene Syromiatnikov
859bc3444c error_prints.h: add debug print macros
* defs.h (debug_flag): Move the declaration...
* error_prints.h (debug_flag): ... here.
(debug_msg, debug_perror_msg): New macro definitions.
Include <stdbool.h> for the debug_flag declaration.
2017-12-13 00:35:31 +00:00
Masatake YAMATO
4f47c43ce7 tests: check decoding of KVM ioctl commands
* tests/ioctl_kvm_run.c: New file.
* tests/ioctl_kvm_run.test: New test.
* tests/Makefile.am (DECODER_TESTS): Add ioctl_kvm_run.test.
* tests/pure_executables.list: Add ioctl_kvm_run.
* tests/.gitignore: Likewise.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-12-04 18:29:38 +00:00
Masatake YAMATO
647709d8e5 kvm: decode the argument of KVM_{SET, GET}_SREGS ioctl command
* configure.ac (AC_CHECK_TYPES): Add struct kvm_sregs.
* kvm.c [HAVE_STRUCT_KVM_SREGS] (kvm_ioctl_decode_sregs): New function.
(kvm_ioctl) [HAVE_STRUCT_KVM_SREGS] <KVM_SET_SREGS, KVM_GET_SREGS>:
Use it.
* linux/arch_kvm.c (arch_print_kvm_sregs): New function.
* linux/x86_64/arch_kvm.c (PRINT_FIELD_KVM_SREGS_STRUCT): New macro.
(kvm_ioctl_decode_regs_dtable, kvm_ioctl_decode_regs_segment,
arch_print_kvm_sregs): New functions.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-04 18:29:38 +00:00
Masatake YAMATO
1d3b9b2c94 kvm: decode the argument of KVM_{SET, GET}_REGS ioctl command
* configure.ac (AC_CHECK_TYPES): Add struct kvm_regs.
* linux/arck_kvm.c: New file.
* linux/x86_64/arch_kvm.c: Likewise.
* linux/i386/arch_kvm.c: Likewise.
* linux/x32/arch_kvm.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* kvm.c: Include "arch_kvm.c".
[HAVE_STRUCT_KVM_REGS] (kvm_ioctl_decode_regs): New function.
(kvm_ioctl) [HAVE_STRUCT_KVM_REGS] <KVM_SET_REGS, KVM_GET_REGS>: Use it.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-04 18:29:38 +00:00
Masatake YAMATO
d3cc998a05 kvm: decode the argument of KVM_SET_USER_MEMORY_REGION ioctl command
* configure.ac (AC_CHECK_TYPES): Add struct kvm_userspace_memory_region.
* xlat/kvm_mem_flags.in: New file.
* kvm.c: Include print_fields.h.
[HAVE_STRUCT_KVM_USERSPACE_MEMORY_REGION]: Include xlat/kvm_mem_flags.h,
(kvm_ioctl_set_user_memory_region): New function.
(kvm_ioctl) [HAVE_STRUCT_KVM_USERSPACE_MEMORY_REGION]
<KVM_SET_USER_MEMORY_REGION>: Use it.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-04 18:29:38 +00:00
Eugene Syromyatnikov
722d82e456 Add strace mascot
* strace.svg: New file.

Co-Authored-by: Vitaly Chaykovsky <mgspeker@gmail.com>
2017-12-03 19:53:48 +01:00
a33747a902 tests: robustify attach-p-cmd.test against buggy kernels
From time to time various kernels, old and new, just go nuts
and fail attach-p-cmd.test with the following diagnostics:

 12345 --- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---
-12345 chdir("attach-p-cmd.test -p") = -1 ENOENT (No such file or directory)
+12345 syscall_4294967295(0xffe60934, 0x1c0, 0xffe60934, 0x1, 0xffe609b4, 0xffe60a58) = -1 (errno 38)
+12345 chdir("attach-p-cmd.test -p") = -1 ENOSYS (Function not implemented)

Let's workaround this kernel madness by rewriting the test
without use of SIGALRM.

* tests/attach-p-cmd.h: New file.
* tests/Makefile.am (EXTRA_DIST): Add attach-p-cmd.h.
* tests/attach-p-cmd-cmd.c: Include "attach-p-cmd.h".
(write_pidfile, wait_for_peer_invocation): New functions.
(main): Use them.
* tests/attach-p-cmd-p.c: Include <time.h> and "attach-p-cmd.h".
(wait_for_peer_invocation, wait_for_peer_termination): New functions.
(main): Use them.  Do not raise SIGALRM, use nanosleep after peer
termination.
2017-12-03 00:25:43 +00:00
a6e30c11d2 tests: robustify ipc_msgbuf.test against broken libc
glibc between commits glibc-2.25~130 and glibc-2.26~740 had broken
msgctl(IPC_RMID) on hppa: this operation always failed with EINVAL
because of inappropriate use of IPC_64 flag.  Similar issues were
fixed on other niche architectures.  Let's workaround these issues
by skipping the test in case of msgctl(IPC_RMID) failure.

* tests/ipc_msgbuf.c (cleanup): Change return type to int,
return 77 in case of msgctl(IPC_RMID) failure.
(main): Explicitly invoke cleanup() at the end.
2017-12-03 00:25:43 +00:00
Masatake YAMATO
5f61f158c3 kvm: decode the argument of KVM_CREATE_VCPU ioctl command
* kvm.c (kvm_ioctl_create_vcpu): New function.
(kvm_ioctl) <KVM_CREATE_VCPU>: Use it.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-01 22:27:01 +00:00
Masatake YAMATO
312073760f kvm: handle KVM_CREATE_VM ioctl command
* kvm.c (kvm_ioctl): Handle KVM_CREATE_VM command.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-01 22:27:01 +00:00
Masatake YAMATO
4f1c3c2ba4 kvm: handle KVM_RUN, KVM_GET_VCPU_MMAP_SIZE, and KVM_GET_API_VERSION ioctl commands
* kvm.c (kvm_ioctl): Handle KVM_RUN, KVM_GET_VCPU_MMAP_SIZE,
and KVM_GET_API_VERSION commands.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-01 22:27:01 +00:00
Masatake YAMATO
3f20fe4a30 ioctl: add a stub for decoding kvm related ioctls
* kvm.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* configure.ac (AC_CHECK_HEADERS): Add linux/kvm.h.
* defs.h (kvm_ioctl): New prototype.
* ioctl.c (ioctl_decode) HAVE_LINUX_KVM_H]: Use kvm_ioctl.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-01 22:27:01 +00:00
Eugene Syromyatnikov
b053dd53ed strace-log-merge: work around corner cases of strace -ttt parsing
Employing strace -ttt for the logs destined to be fed to
strace-log-merge is ultimately the best solution except for the logs
that pass the following dates:

Thu Jan  1 00:00:09 UTC 1970
Thu Jan  1 00:01:39 UTC 1970
Thu Jan  1 00:16:39 UTC 1970
Thu Jan  1 02:46:39 UTC 1970
Fri Jan  2 03:46:39 UTC 1970
Mon Jan 12 13:46:39 UTC 1970
Sun Apr 26 17:46:39 UTC 1970
Sat Mar  3 09:46:39 UTC 1973
Sun Sep  9 01:46:39 UTC 2001
Sat Nov 20 17:46:39 UTC 2286
Wed Nov 16 09:46:39 UTC 5138
Fri Sep 27 01:46:39 UTC 33658
Sun May 20 17:46:39 UTC 318857
Sat Nov  7 09:46:39 UTC 3170843
Sun Jul  5 01:46:39 UTC 31690708
Sat Jan 25 17:46:39 UTC 316889355

Let's lift this limitation.

* strace-log-merge: Generate numeric-only key for sorting, use sort -n
option.
2017-11-30 02:45:18 +01:00
Eugene Syromyatnikov
b0c8e3bc4d debian: add strace-log-merge to the list of installed files
* debian/strace.install: Add strace-log-merge.
2017-11-30 02:35:50 +01:00
Eugene Syromyatnikov
60bbdda7c2 Add strace-log-merge man page
* strace-log-merge.1.in: New file.
* NEWS: Mention this.
* .gitignore: Add strace-log-merge.1.
* Makefile.am (man_MANS): Likewise.
* configure.ac (AC_CONFIG_FILES): Likewise.
* debian/strace.manpages: Likewise.
2017-11-30 02:35:50 +01:00
Eugene Syromyatnikov
5cb5d5760a strace-log-merge: add copyright header 2017-11-30 01:06:40 +01:00
66b37bb737 Add initial GitLab CI support
* .gitlab-ci.yml: New file.
* travis-build.sh: Print $CC -print-multi-lib.  Print config.log
in case of configure failure.
* travis-install.sh: Check sudo availability.  Install autoconf,
automake, file, gawk, gcc-multilib, git, gzip, make, and xz-utils
for all targets.
(musl-gcc): Install ca-certificates.
2017-11-29 03:52:27 +00:00
acffeae467 mpers: fix cross-compiling
In cross builds, a target version of readelf has to be used
instead of a native one.

* configure.ac (AC_CHECK_TOOL): Add readelf.
* Makefile.am (READELF): New variable.
(mpers-m%.stamp): Pass it to $(srcdir)/mpers.sh.
* m4/mpers.m4 (st_MPERS): Pass READELF environment variable
to $srcdir/mpers_test.sh.
* mpers.sh (READELF): New variable.
Use it instead of readelf.
* maint/ioctls_sym.sh: Likewise.
* NEWS: Mention this fix.

Reported-by: Rolf Eike Beer <eb@emlix.com>
2017-11-25 01:55:44 +00:00