Commit Graph

4859 Commits

Author SHA1 Message Date
3a838cd31a xlat: provide fallback definitions for NETLINK_* constants
As new constants have been added gradually over kernel releases, define
all constant values to make newer constants decoded properly when strace
is built with older kernel headers.

* xlat/netlink_protocols.in: Add default values for constants.
* net.c [!NETLINK_SOCK_DIAG && NETLINK_INET_DIAG]: Remove.
* socketutils.c: Likewise.
2016-12-14 08:09:10 +00:00
76d4eee640 tests: relax getaffinity return value check in tests/sched_xetaffinity.c
* tests/sched_xetaffinity.c (errstr): New variable.
(getaffinity, setaffinity): Initialize it.
(main): Use it.  Allow getaffinity return value to be less than
its cpusetsize argument.
2016-12-14 02:03:04 +00:00
a3f44329a5 tests: fix threads-execve.test for large pids
* tests/threads-execve.c (main): Fix expected output for large pids.
2016-12-14 01:02:03 +00:00
6dc96f5c75 Prepare for 4.15 release
* NEWS: Update for 4.15 release.
2016-12-13 20:21:22 +00:00
9b96cd97af .mailmap: add addresses of Thomas De Schampheleire
* .mailmap: Add both addresses of Thomas De Schampheleire here to avoid
duplications in CREDITS file.
2016-12-13 20:43:57 +00:00
8ed741fc59 Sync strace.spec and debian/ with packages
* debian/control: Add Vcs-* metadata from 4.13-0.1.
* debian/watch: Sync with 4.13-0.1.
* strace.spec.in: Sync with 4.14.0.100.622a-1.
2016-12-13 20:43:57 +00:00
3dac7272e8 tests: workaround a bug in GNU grep
Workaround a bug introduced in GNU grep 2.27, for details see
https://lists.gnu.org/archive/html/bug-grep/2016-12/msg00011.html

* tests/init.sh (grep_pid_status): New function.
* tests/detach-running.test: Use it instead of grep to search
in /proc/$pid/status.
* tests/detach-sleeping.test: Likewise.
* tests/detach-stopped.test: Likewise.
2016-12-13 20:21:22 +00:00
Eugene Syromyatnikov
34283c2f82 tests: fix typo in comment inside prctl-tsc.c 2016-12-13 20:21:22 +00:00
Sean Stangl
54c7792bfd Fix libunwind segfault when -p is passed before -k
* strace.c (init) [USE_LIBUNWIND]: Call unwind_tcb_init after
unwind_init for all allocated tcb structures if stack trace is enabled.
* unwind.c (unwind_tcb_init): Skip if tcb is already initialized.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2016-12-13 20:21:22 +00:00
Eugene Syromyatnikov
9555f21588 Update NEWS
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2016-12-13 20:10:44 +00:00
ab28d7f1e5 tests: skip fault injection tests on unsupported platforms
* tests/fault_injection.sh: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/fault_injection-exit_group.test: Use it.
* tests/fault_injection.test: Likewise.
2016-12-07 19:46:13 +00:00
5aff0e3c6e tests: introduce require_min_kernel_version_or_skip function
* tests/init.sh (kernel_version_code,
require_min_kernel_version_or_skip): New functions.
* tests/threads-execve.test: Use require_min_kernel_version_or_skip.
2016-12-07 19:46:12 +00:00
Eugene Syromyatnikov
d679dcd6aa tests: add descriptions to prctl-pdeathsig and prctl-tsc tests 2016-12-07 18:28:33 +00:00
a2633e4a59 tests: robustify prctl-pdeathsig.test and prctl-tsc.test
Rrobustify remaining prctl tests against unrelated prctl invocations

* tests/prctl-pdeathsig.test: Filter out unrelated PR_GET_* and PR_SET_*
prctl calls.
* tests/prctl-tsc.test: Likewise.
2016-12-07 16:22:50 +00:00
Thomas De Schampheleire
a3da3c32c1 Makefile.am: don't confuse CFLAGS and CFLAGS_FOR_BUILD
Commit dc427d50d9 enabled a number of extra
warning flags through configure.ac.  The configure script will determine
dynamically if CC supports these flags before adding them to WARN_CFLAGS.

ioctlsort is compiled with CC_FOR_BUILD, rather than CC.  Nevertheless,
the flags passed to this compilation also include WARN_CFLAGS (through
AM_CFLAGS).  This is incorrect: in a cross-compilation use case, CC
and CC_FOR_BUILD are not the same.  The former is the cross-compiler,
the latter is the host compiler.  Both may be of different versions
and support different warning flags.

In particular, this posed a problem when cross-compiling with a host
compiler gcc 4.1, which does not support all the new flags:

    /usr/bin/gcc -DHAVE_CONFIG_H   -I./linux/arm -I./linux/arm -I./linux
    -I./linux -I. -I. -I/host-sysroot/usr/include -Wall -Wempty-body
    -Wformat-security -Wignored-qualifiers -Winit-self -Wlogical-op
    -Wmissing-parameter-type -Wnested-externs -Wold-style-declaration
    -Wold-style-definition -Wsign-compare -Wtype-limits -Wwrite-strings -O2
    -I/host-sysroot/usr/include -DIOCTLSORT_INC=\"ioctls_all0.h\" -c -o
    ioctlsort0.o ./ioctlsort.c
    cc1: error: unrecognized command line option "-Wempty-body"
    cc1: error: unrecognized command line option "-Wignored-qualifiers"
    cc1: error: unrecognized command line option "-Wlogical-op"
    cc1: error: unrecognized command line option "-Wmissing-parameter-type"
    cc1: error: unrecognized command line option "-Wold-style-declaration"
    cc1: error: unrecognized command line option "-Wtype-limits"
    make[2]: *** [ioctlsort0.o] Error 1

* Makefile.am (AM_CFLAGS_FOR_BUILD, AM_CPPFLAGS_FOR_BUILD): New
variables.
(ioctlsort_CPPFLAGS): Use AM_CPPFLAGS_FOR_BUILD instead of AM_CPPFLAGS.
(ioctlsort_CFLAGS): Use AM_CFLAGS_FOR_BUILD instead of AM_CFLAGS.
(ioctlsort_LDFLAGS): Use AM_LDFLAGS_FOR_BUILD instead of AM_LDFLAGS.
* m4/ax_prog_cc_for_build.m4 (AX_PROG_CC_FOR_BUILD): Redirect
WARN_CFLAGS and gl_unknown_warnings_are_errors, call st_WARN_CFLAGS,
substitute WARN_CFLAGS_FOR_BUILD.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
2016-12-07 15:53:13 +00:00
f91def0384 m4: prepare gl_WARN_ADD for simultaneous use of multiple compilers
* m4/warnings.m4 (gl_COMPILER_OPTION_IF): Change gl_Flags to use
_AC_LANG_PREFIX[]FLAGS in unquoted form.  Change gl_Warn to use gl_Flags
instead of _AC_LANG_ABBREV.  Change notification message to mention
the variable name of the compiler.
(gl_UNKNOWN_WARNINGS_ARE_ERRORS): Do nothing if
gl_unknown_warnings_are_errors is set.
(gl_WARN_ADD): Change the use of gl_UNKNOWN_WARNINGS_ARE_ERRORS from
AC_REQUIRE to a regular call.
2016-12-07 15:53:13 +00:00
cdeb5dda0a AX_PROG_CC_FOR_BUILD: redirect more variables related to C compiler
Some of these variables cannot be redirected using traditional
pushdef/popdef mechanism because of complex constructions like
[ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu] employed by autoconf macros.
Use st_SAVE_VAR/st_RESTORE_VAR to workaround this issue.

* m4/ax_prog_cc_for_build.m4: Redirect ac_cv_prog_cc_stdc,
ac_cv_prog_cc_c11, ac_cv_prog_cc_c99, ac_cv_prog_cc_c89,
am_cv_prog_cc_c_o, and am_cv_CC_dependencies_compiler_type using
pushdef/popdef.
Redirect ac_c_decl_warn_flag, ac_c_preproc_warn_flag, ac_c_werror_flag,
ac_compile, ac_compiler_gnu, ac_cpp, ac_cv_c_compiler_gnu,
ac_cv_c_decl_report, and ac_link using st_SAVE_VAR/st_RESTORE_VAR.
2016-12-07 11:14:03 +00:00
9beaf2c3d3 Move all gl_WARN_ADD calls to a separate m4 macro
This is going to be needed for the upcoming AX_PROG_CC_FOR_BUILD
change.

* configure.ac: Call st_WARN_CFLAGS before AX_PROG_CC_FOR_BUILD.
Move all gl_WARN_ADD calls ...
* m4/st_warn_cflags.m4: ... here.
2016-12-07 10:59:52 +00:00
c26d031c1f m4: introduce st_SAVE_VAR and st_RESTORE_VAR macros
These new macros are going to be needed for the upcoming
AX_PROG_CC_FOR_BUILD change.

* m4/st_save_restore_var.m4: New file.
2016-12-07 10:58:24 +00:00
5c20f4aac4 tests: add valgrind support to "make check"
* m4/ax_valgrind_check.m4: Import from the autoconf-archive package.
* configure.ac: Invoke AX_VALGRIND_CHECK.
* valgrind.supp: Move to tests/strace.supp.
* Makefile.am (EXTRA_DIST): Remove valgrind.supp.
* tests/Makefile.am: Add @VALGRIND_CHECK_RULES@.
(VALGRIND_FLAGS, VALGRIND_SUPPRESSIONS_FILES): New variables.
(EXTRA_DIST): Add strace.supp.
* tests/init.sh: Add valgrind command prefix to $STRACE when appropriate.
2016-12-06 16:20:54 +00:00
427e7431ba tests: robustify threads-execve.test against race conditions
Due to probabilistic nature of the test, try it several times.

* tests/threads-execve.c (NUMBER_OF_ITERATIONS): Change to 1.
* tests/threads-execve.test: Iterate up to 10 times.
2016-12-06 16:20:51 +00:00
51694267bd tests: fix expected output in strace-ttt.test
If strace -ttt is running too long, it might happen that time stamps
before and after its invocation differ for more than a second.
Adjust expected output to handle this rare but possible case.

* tests/strace-ttt.test: Allow any time stamp between start and finish
of strace invocation.
2016-12-06 15:27:21 +00:00
52fe35f262 tests: fix expected output in strace-tt.test
If strace -tt is running too long, it might happen that time stamps
before and after its invocation differ for more than a second.
Adjust expected output to handle this rare but possible case.

* tests/strace-tt.test: Allow any time stamp between start and finish
of strace invocation.
2016-12-06 15:27:08 +00:00
a2002a648e tests: robustify redirect.test against race conditions
Introduce a synchronization mechanism between the tracee and its peer.

* tests/redirect.test: Change timeout file to $OUT.  Let the tracee
remove $LOG, wait for $LOG removal in its peer.
2016-12-06 13:16:42 +00:00
997f49f190 tests: robustify attach-f-p.test against race conditions
Introduce a synchronization mechanism between attach-f-p and strace.

* tests/attach-f-p-cmd.c: New file.
* tests/Makefile.am (check_PROGRAMS): Add attach-f-p-cmd.
* tests/attach-f-p.c: Include <sys/stat.h>.
(main): Write to stdout instead of descriptor 3.  Wait for the peer
writing to stdout.
* tests/attach-f-p.test: Assume that ./attach-f-p-cmd works.
Use $OUT for expected output.  Use attach-f-p-cmd for unlocking $OUT.
2016-12-06 09:09:18 +00:00
f91c9fe814 tests: robustify attach-p-cmd.test against race conditions
Introduce a synchronization mechanism between attach-p-cmd-p
and attach-p-cmd-cmd processes.

* tests/attach-p-cmd-cmd.c: Include <errno.h> and <sys/stat.h>.
(main): Wait for the lock directory creation by attach-p-cmd-p.
* tests/attach-p-cmd-p.c: Include <errno.h> and <sys/stat.h>.
(main): Create a lock directory and wait for its removal
by attach-p-cmd-cmd.
* tests/attach-p-cmd.test: Assume that test programs work.
2016-12-06 09:08:36 +00:00
45ed340016 Rewrite remaining qual_* parsers using bit sets
* defs.h (struct fault_opts): Replace forward declaration
with a definition.
(qualbits_t, qualify_read, qualify_write, qualify_signals): Remove.
(qual_flags): New function prototype.
(nsyscall_vec, sysent_vec, fault_vec): New variable prototypes.
* qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set):
New variables.
(qualify_read, qualify_write, qualify_signals): Add static qualifier.
(find_errno_by_name, lookup_class, parse_fault_expression,
parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault,
qualify_raw, qualify_syscall, qualify_syscall_class,
qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens,
qualify_trace, qualify_verbose, strip_prefix): New functions.
* syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier.
(MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags,
qual_fault, qual_syscall, qual_options, fault_opts, qualify_one,
qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name,
qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name,
parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove.
(decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall,
get_scno): Update use of qual_flags.
(inject_syscall_fault_entering): Update per-personality allocation
of tcp->fault_vec.
* tests/fault_injection-exit_group.test: Check parsing of inversed
fault sets.
* tests/fault_injection.test: Check parsing of -efault=none.
* tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-05 20:49:59 +00:00
701792d70c Change qual_vec/qual_fault into static fixed size arrays
* defs.h (qual_vec, num_quals): Remove.
(qual_flags): Move ...
* syscall.c: ... here.
(num_quals, num_faults, MIN_QUALS, reallocate_vec, reallocate_qual,
reallocate_fault): Remove.
(qual_vec, qual_fault): Change into static fixed size arrays.
(qualify_one): Remove reallocate_qual and reallocate_fault calls.
(qualify): Likewise.  Replace num_quals and num_faults with
MAX_NSYSCALLS.
2016-12-05 20:49:59 +00:00
11abfb422a Rewrite qual_signal using bit sets
* defs.h (signal_set): New variable prototypes.
(qualify_signals): New function prototypes.
(QUAL_SIGNAL): Change to a value greater than 0xff.
(QUAL_FAULT): Change to a lower value.
* qualify.c (signal_set): New variable.
(sigstr_to_uint, qualify_signals): New functions.
* syscall.c (qual_signal): Remove.
(qual_options): Replace qual_signal with NULL.
(qualify): Use qualify_signals.
* strace.c (print_signalled, print_stopped): Use is_number_in_set
with signal_set argument.
2016-12-05 20:49:59 +00:00
05ac490cc7 Rewrite qual_desc using bit sets
As a side effect, this also fixes support of negated sets
of descriptors.

* defs.h (struct number_set): New forward declaration.
(read_set, write_set): New variable prototypes.
(is_number_in_set, qualify_read, qualify_write): New function
prototypes.
(QUAL_READ, QUAL_WRITE): Change to values greater than 0xff.
* qualify.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* syscall.c (qual_desc): Remove.
(qual_options): Replace qual_desc with NULL.
(qualify): Use qualify_read and qualify_write.
(dumpio): Use is_number_in_set.
* tests/options-syntax.test: Check invalid sets of descriptors.
* tests/readv.test: Check dumping of negated sets of descriptors.
2016-12-05 10:41:05 +00:00
1ac436f4c3 tests: skip redirect-fds.test when strace is wrapped with valgrind
valgrind is not as transparent as strace wrt standard descriptors,
so if strace is wrapped with valgrind, the test would check valgrind
transparency properties and fail imminently.

* tests/redirect-fds.test: Skip the test when $STRACE shows a presence
of valgrind.
2016-12-05 10:41:05 +00:00
ade6eef6dd Add valgrind.supp
As valgrind is not quite happy about the way how get_cpuset_size uses
sched_getaffinity, add a suppression file for this case.

* valgrind.supp: New file.
* Makefile.am (EXTRA_DIST): Add it.
2016-12-05 03:56:17 +00:00
58d8f96c25 affinity: pass 0 as a pid to sched_getaffinity
* affinity.c (get_cpuset_size): Pass 0 instead of getpid()
to sched_getaffinity.
2016-12-05 03:56:17 +00:00
cec2dc2ab5 affinity: document the method of finding out the cpuset size
* affinity.c (get_cpuset_size): Add a comment about sched_getaffinity.
2016-12-05 03:56:17 +00:00
8c9dc258e0 tests: make options-syntax.test tolerant of strace wrappers
Change the test to allow wrappers like STRACE="valgrind ./strace".

* tests/options-syntax.test: Strip all words but last from $STRACE
variable in all contexts where the name of strace executable is expected
in its output.
2016-12-05 03:56:17 +00:00
2ecb0a0467 Do not allocate memory for line buffered output
libc is perfectly capable of allocating memory for its buffers,
so let it do its job.

* strace.c (init): Do not allocate memory for setvbuf invocation.
2016-12-04 23:09:18 +00:00
Eugene Syromyatnikov
6be0d91285 Update NEWS 2016-12-04 23:09:18 +00:00
Eugene Syromyatnikov
5be0a95d8e tests: use kernel_ulong_t as argument type in setfsuid/setfsgid tests
* setfsugid.c: Include "kernel_types.h".
(main): Change type of entries of the "tests" array from long to
kernel_ulong_t.
2016-12-04 17:42:38 +00:00
Eugene Syromyatnikov
6be94f1772 uid: print size as signed in setgroups/getgroups
As this is the type used in kernel.

* uid.c (SYS_FUNC(setgroups), SYS_FUNC(getgroups)): Print size parameter
as "%d".
* tests/getgroups.c: Update expected output.
* tests/setgroups.c: Likewise.

Co-authored-by: Elvira Khabirova <lineprinter0@gmail.com>
2016-12-04 17:42:38 +00:00
Eugene Syromyatnikov
3304d82108 uid: use printuid for printing UID/GID value
* uid.c (setfsuid, get_print_uid, print_gid): Use printuid.
* tests/setfsugid.c (printuid): New function.
(main): Use it to print UID/GID values.
* tests/setgroups.c: Likewise.
* tests/setugid.c (ugid2int): Remove.
(printuid): New function.
(main): Use it to print UID/GID values.

Co-authored-by: Elvira Khabirova <lineprinter0@gmail.com>
2016-12-04 17:42:38 +00:00
Eugene Syromyatnikov
dcc9b9cdb2 tests: additional check for PTRACE_SETSIGINFO ptrace command
* tests/ptrace.c (main): Add an additional PTRACE_SETSIGINFO check.
2016-12-01 01:23:28 +00:00
3c8b673408 syscall_name: clear __X32_SYSCALL_BIT from syscall number on x32
* linux/x86_64/get_scno.c (X32_PERSONALITY_NUMBER): New macro.
* syscall.c (syscall_name) [X32_PERSONALITY_NUMBER && __X32_SYSCALL_BIT]:
Clear __X32_SYSCALL_BIT from scno on x32 personality.
2016-12-01 01:05:13 +00:00
Eugene Syromyatnikov
9936b91d9f Print syscall names only for defined syscalls
The string literal "__NR_syscall_4294967295" is semantically incorrect
as there is no such constant defined.

* syscall.c (syscall_name): Return NULL if there is no syscall
corresponding to the given number.
* defs.h (syscall_name): Document this behaviour.
* printsiginfo.c (print_si_info): Print syscall name with "__NR_" prefix
only if there is a syscall corresponding to si_syscall number; print
a plain syscall number otherwise.
* tests/ptrace.c (main): Update expected output.
2016-12-01 00:08:39 +00:00
Eugene Syromyatnikov
2432f78415 affinity: print cpu set as an array
* affinity.c: Add comma between elements of cpu set.
* tests/sched_xetaffinity.c (main): Update expected output.
2016-12-01 00:08:06 +00:00
Eugene Syromyatnikov
635638feb3 statfs: fix printing format of f_fsid field
* print_statfs.c: Print f_fsid as a structure containing field "val"
which, in turn, is an array of two elements that used to be printed
as members of f_fsid structure.
* tests/statfs.expected: Update expected output.
* tests/xstatfsx.c (print_statfs): Likewise.
2016-12-01 00:06:39 +00:00
Eugene Syromyatnikov
39c77d45d0 swap: always print priority value
* swapon.c (SYS_FUNC(swapon)): Do not check for non-zero the value
of the prio variable in order to print it.
* tests/swap.c (main): Update expected output.
2016-12-01 00:05:09 +00:00
Elvira Khabirova
3cfe169f37 tests: show pattern line number in match_grep
This makes debugging of failing test  a bit easier.

* tests/init.sh (match_grep): Add the cnt variable, increment it on every
pattern line read, print it as a prefix for non-matched pattern.
2016-12-01 00:02:07 +00:00
Eugene Syromyatnikov
01e9ac81c4 futex: make output of the val3 argument of the FUTEX_WAKE_OP command more structured
It is a number which consists of several xlat values, not a structure.

* futex.c (SYS_FUNC(futex)): Modify output of the val3 argument
of the FUTEX_WAKE_OP futex syscall command.
* tests/futex.c (main): Update expected output.

Co-authored-by: Elvira Khabirova <lineprinter0@gmail.com>
2016-11-30 23:56:47 +00:00
Eugene Syromyatnikov
d872902009 tests: additional checks for prctl-* tests
* tests/prctl-pdeathsig.c (main): Additional checks.
* tests/prctl-tsc.c (main): Likewise.
* tests/prctl-pdeathsig.test: Update value of -a argument.
* tests/prctl-tsc.test: Likewise.
2016-11-30 23:46:20 +00:00
JingPiao Chen
d945e74377 tests: add prctl-pdeathsig.test and prctl-tsc.test
* tests/prctl-pdeathsig.c: New file.
* tests/prctl-tsc.c: Likewise.
* tests/prctl-pdeathsig.test: New test.
* tests/prctl-tsc.test: Likewise.
* tests/.gitignore: Add prctl-pdeathsig and prctl-tsc.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add prctl-pdeathsig.test and prctl-tsc.test.
2016-11-30 23:40:30 +00:00