Commit Graph

4827 Commits

Author SHA1 Message Date
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
ec8f783356 syscall: Simplify strip_prefix
* syscall.c (strip_prefix): Use strncmp instead of strlen+memcmp.
2016-11-30 16:52:28 +00:00
9f2980bd2c util: fix integer overflow check in string_to_uint_ex
* util.c (string_to_uint_ex): Fix the check for integer overflow
on systems where LONG_MAX == INT_MAX.
2016-11-30 16:52:05 +00:00
c422618120 Check dumping of io syscalls when descriptor arguments are sensibly large
* tests/tests.h (pipe_maxfd): New prototype.
* tests/pipe_maxfd.c: New file.
* tests/print_maxfd.c: Likewise.
* tests/.gitignore: Add print_maxfd.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(libtests_a_SOURCES): Add pipe_maxfd.c.
* tests/readv.c (main): Use pipe_maxfd() instead of pipe(),
fds[0] instead of 0, fds[1] instead of 1.
* tests/readv.test: Use print_maxfd to specify dump descriptor numbers.
2016-11-30 00:56:04 +00:00
1c599b4f3d dumpio: remove useless check
* syscall.c (dumpio): Remove SEN_printargs check.  Use tcp->s_ent->sen
directly.
2016-11-30 00:04:03 +00:00
07586a5b64 Fix dumping of io syscalls when descriptor argument has unused bits set
* syscall.c (dumpio): Explicitly cast the first argument of syscall
to "int", the same way as the kernel does.
* tests/read-write.c: Include <asm/unistd.h> and "kernel_types.h".
(k_read, k_write): New functions.
(test_dump, main): Use them.
2016-11-29 22:56:49 +00:00
54e164f630 x32: fix preadv2-pwritev2.test
* tests/preadv2-pwritev2.c: Include "kernel_types.h".
(main): Use kernel_ulong_t instead of unsigned long as types
of arguments of preadv2 and pwritev2 syscalls.
2016-11-29 19:51:15 +00:00
aad1e4a0bb x32: wire up preadv2 and pwritev2 syscalls
* linux/x32/syscallent.h [546]: Add preadv2 entry.
[547]: Add pwritev2 entry.
2016-11-29 10:05:16 +00:00
Eugene Syromyatnikov
d454dac0dc signal: fix omission of field names in sigaction printers
* signal.c (decode_old_sigaction, decode_new_sigaction): Add printing
of the field names.
* tests/sigaction.awk: Update expected output.

Co-authored-by: Elvira Khabirova <lineprinter0@gmail.com>
2016-11-29 10:05:16 +00:00
Elvira Khabirova
ad53524377 Make date output format conform to ISO 8601
* util.c (sprinttime): Make date output conform to ISO 8601.
* tests/utime.c (print_tm): Update expected output.
* tests/xstatx.c (print_time): Likewise.
2016-11-29 10:05:16 +00:00
50e267c420 tests: rewrite utime.test without relying on libc utime wrapper
* tests/utime.c (k_utime): New function, a thin wrapper around
syscall(__NR_utime).
(main): Use it instead of utime.
* tests/utime.test: Update.
2016-11-29 04:08:47 +00:00
4399fa976a Fix meaning of negated sets in fault expressions
Change the parser of fault expression to follow the POLA:
-e fault=!SET
means that all syscalls except those from SET are subject to fault
injection;
-e fault=!SET1:error=ERRNO1, -e fault=!SET2:error=ERRNO2
means that all syscalls except those from SET2 are subject to fault
injection with error code ERRNO2, and all syscalls from SET2 that are
not in SET1 are subject to fault injection with error code ERRNO1.

* syscall.c (qualify_scno, qualify_syscall_class, qualify_syscall_name):
Handle negated QUAL_FAULT case differently.
* tests/fault_syntax.test: Add checks of negated sets.
2016-11-29 02:11:48 +00:00
Eugene Syromyatnikov
c84536f975 print_sigevent: fix field names of sigev_value structure
* print_sigevent.c (print_sigevent): Change "int" to "sival_int", "ptr"
to "sival_ptr".
* tests/mq_sendrecv.c (main): Update expected output in accordance with
fixed field names.
* tests/timer_create.c (main): Likewise.
2016-11-29 00:33:01 +00:00
Eugene Syromyatnikov
6602da1b90 tests: add more utime checks
* tests/utime.c: Include <unistd.h> and <asm/unistd.h>.
(main): Add checks for invalid pointers.
2016-11-29 00:27:51 +00:00
Eugene Syromyatnikov
922712f8ff utime: fix omission of field names in utimbuf structure printing
* utime.c (SYS_FUNC(utime)): Print struct utimbuf as a structure,
not as an array (use curly brackets instead of square ones).
Add field names to the output.
* tests/utime.c (main): Update expected output.
2016-11-29 00:26:20 +00:00
Eugene Syromyatnikov
d4d5aaa560 mem: print mincore output as an array
* mem.c (SYS_FUNC(minore)): Print commas between elements.
* tests/mincore.c (print_mincore): Update expected output in accordance
with syscall decoder formatting change.
2016-11-29 00:25:55 +00:00
Eugene Syromyatnikov
a938b441d6 util: provide information whether xlat value has been found
This is necessary for the upcoming change in the output format
of the val3 argument of the FUTEX_WAKE_OP futex command.

* defs.h (printxvals, printxval_searchn): Change return type to int.
(printxval64, printxval, printxval_long): Likewise.  Forward the value
returned by printxvals call.
* util.c (printxvals, printxval_searchn): Change return type to int,
return 1 if xlat value has been found, 0 otherwise.
2016-11-29 00:23:13 +00:00
Eugene Syromyatnikov
c1271b7341 util: check dflt argument for NULL in printxvals
This is necessary for the upcoming change in the output format
of the val3 argument of the FUTEX_WAKE_OP futex command.

* util.c (printxvals): Do not print dflt if it is NULL.
2016-11-29 00:22:05 +00:00
Eugene Syromyatnikov
827b170b72 capability: fix omission of capability structure field names
* capability.c (print_cap_header, print_cap_data): Add field names
to the output.
* tests/caps.awk: Update test output.
2016-11-29 00:21:06 +00:00
447bdc55bf tests: fix "comparison between signed and unsigned" compilation warnings
* tests/readv.c (main): Cast r_len to int.
* tests/preadv2-pwritev2.c (dumpio): Likewise.
2016-11-28 20:55:10 +00:00
7b3b12b793 aarch64, arm, sparc: add comments on fault injection support in kernel
* linux/aarch64/set_scno.c: Note the kernel commit that introduced
NT_ARM_SYSTEM_CALL support.
* linux/arm/set_scno.c: Note the kernel commit that introduced
PTRACE_SET_SYSCALL support.
* linux/sparc/set_scno.c: Note the kernel commit that introduced
reloading from the syscall number register.
2016-11-28 19:46:50 +00:00
f3b5837608 tests: check -C option
* tests/strace-C.expected: New file.
* tests/strace-C.test: New test.
* tests/Makefile.am (MISC_TESTS): Add strace-C.test.
(EXTRA_DIST): Add strace-C.expected.
2016-11-28 16:57:30 +00:00
7e6f0b7b0c tests: check basic options syntax
* tests/options-syntax.test: New file.
* tests/Makefile.am (MISC_TESTS): Add it.
2016-11-28 15:13:25 +00:00
0b98d8213e Fix -r option syntax
While -r option implies -t, it should not literally have the effect
of -t option, e.g. -rr should not increment tflag twice.

* strace.c (init): In the getopt loop, do not increment tflag for each
occurrence of -r option.  After the getopt loop, if rflag is set, set
tflag to 1.  Issue a warning that -tt has no effect with -r.
2016-11-28 15:13:25 +00:00
Eugene Syromyatnikov
1aa0697738 Print timeval pair as an array of timeval entries
* print_timeval.c (print_timeval_item): New function.
(print_timeval_pair): Use it as a print_function in print_array call.
* tests/futimesat.c (main): Update to test new behaviour.
* tests/utimes.c (main): Likewise.
2016-11-28 04:38:42 +00:00
Eugene Syromyatnikov
0bf550423c tests: treat tv_sec/tv_usec as signed types in futimesat and utimes tests
* tests/futimesat.c: Print tv_sec and tv_usec fields as signed types.
* tests/utimes.c: Likewise.
2016-11-28 04:26:35 +00:00
7491519823 alpha: print struct timeval32 consistently
* defs.h [ALPHA] (timeval32_t): New type.
[ALPHA] (print_timeval32_t): New prototype.
* print_timeval.c [ALPHA] (timeval32_t): Remove.
[ALPHA] (print_timeval32_t): Remove static keyword.
* printrusage.c [ALPHA] (printrusage32): Use timeval32_t instead
of local definition of struct timeval32.  Use print_timeval32_t.
2016-11-28 04:21:11 +00:00
70864ce6e0 Print struct timeval consistently
Use print_struct_timeval interface to print struct timeval.

* print_timeval.c (print_struct_timeval): New mpers printer.
* print_timex.c (print_timex): Use it.
* printrusage.c (printrusage): Likewise.
* v4l2.c (print_v4l2_buffer): Likewise.
* tests/getrusage.c (main): Print tv_sec and tv_usec fields as signed.
* tests/waitid.c (sprint_rusage): Likewise.

Suggested-by: Eugene Syromyatnikov <evgsyr@gmail.com>
2016-11-28 04:07:37 +00:00
5f6a839d23 Split print_time.c
After commit v4.14-136-g151d1d1 that removed the last object common
for timespec and timeval parsers there is no need to keep them all
in a single file.

* print_timespec.c: New file.
* print_timeval.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* print_time.c: Move all timespec related code to print_timespec.c.
Move all timeval related code to print_timeval.c.
2016-11-28 02:45:13 +00:00
0aaa6976dd tests: check decoding of threads when a non-leader thread invokes execve
* tests/threads-execve.c: New file.
* tests/threads-execve.test: New test.
* tests/.gitignore: Add threads-execve.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(threads_execve_LDADD): New variable.
(MISC_TESTS): Add threads-execve.test.
2016-11-28 00:31:59 +00:00
f6c14637a3 tests: check decoding of fault injected exit_group syscall
* tests/answer.c: New file.
* tests/fault_injection-exit_group.expected: Likewise.
* tests/fault_injection-exit_group.test: New test.
* tests/.gitignore: Add answer.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add fault_injection-exit_group.test.
(EXTRA_DIST): Add fault_injection-exit_group.expected.
2016-11-27 19:40:33 +00:00
2f948b9231 Set PTRACE_O_TRACEEXIT option and handle PTRACE_EVENT_EXIT events
Do not assume that some syscalls do not generate syscall-exit-stops.
When syscalls fail for any reason they may generate syscall-exit-stops.

The solution is to wait for an actual exit reported by PTRACE_EVENT_EXIT
and print the end of unfinished exiting syscall properly.

* exit.c: Remove.
* Makefile.am (strace_SOURCES): Remove exit.c.
* linux/dummy.h (sys_exit): Alias to printargs_d.
* strace.c (ptrace_setoptions): Add PTRACE_O_TRACEEXIT bit.
(print_event_exit): New function.
(trace): Use it in case of PTRACE_EVENT_EXIT.
* syscall.c (trace_syscall_entering): Remove special handling
of SEN_exit.
2016-11-27 14:22:58 +00:00
37c4d4bcfc Change printargs to return RVAL_DECODED
As printargs is invoked as a generic syscall decoder only and
it is not supposed to print anything on exiting, change printargs
to return RVAL_DECODED so it would not be called on exiting at all.

* util.c (printargs): Print args unconditionally, return RVAL_DECODED.
2016-11-27 14:22:58 +00:00