3553 Commits

Author SHA1 Message Date
e714b87064 Fix struct sigevent decoding for musl
Do not rely on "struct sigevent.__pad" being located at the same address
as "struct sigevent.sigev_notify_thread_id", it's not the case with musl
libc.  Do not rely on struct sigevent definition at all to access
sigev_notify_thread_id.

* configure.ac (AC_CHECK_MEMBERS): Remove struct sigevent._sigev_un._pad
and struct sigevent.__pad.
* sigevent.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* print_sigevent.c: Include it.
* print_sigevent.c (struct_sigevent): Remove.
(print_sigevent): Update all struct_sigevent users.
* tests/timer_create.c: Include "sigevent.h".
(main): Use struct_sigevent instead of struct sigevent,
all struct sigevent clients changed.
2016-01-12 03:07:39 +00:00
2a6ac9473c syscall.c: include <signal.h>
All users of NSIG macro must include <signal.h>.
This complements commit v4.10-184-g0e946ab.

* syscall.c: Include <signal.h>.
2016-01-12 03:07:39 +00:00
07572c68dd signal.c: fix musl libc compilation warning
musl libc defines SIGRTMAX to a function that returns signed int,
which obviously makes gcc -Wsign-compare unhappy.

* signal.c (signame): Cast ASM_SIGRTMAX to unsigned int.
2016-01-12 03:07:39 +00:00
7bbf8b54cd tests: fix TEST_SYSCALL_{NR,STR} and STRUCT_STAT_STR macros for musl
The contents of TEST_SYSCALL_NAME and STRUCT_STAT macros was subject
to macro expansion when used in definitions of TEST_SYSCALL_NR,
TEST_SYSCALL_STR, and STRUCT_STAT_STR macros.

As some libcs, e.g. musl libc, define lfs64 names as macros
(stat64 as stat, lstat64 as lstat, etc.), this might result to incorrect
expansion of TEST_SYSCALL_NR, TEST_SYSCALL_STR, and STRUCT_STAT_STR
macros.  To avoid this problem, define these macros directly and remove
TEST_SYSCALL_NAME macro.

* tests/_newselect.c (TEST_SYSCALL_NAME): Remove.
(TEST_SYSCALL_NR, TEST_SYSCALL_STR): New macros.
* tests/fcntl.c: Likewise.
* tests/fcntl64.c: Likewise.
* tests/fstat.c: Likewise.
* tests/fstatat64.c: Likewise.
* tests/lstat.c: Likewise.
* tests/newfstatat.c: Likewise.
* tests/select.c: Likewise.
* tests/stat.c: Likewise.
* tests/fstat64.c (TEST_SYSCALL_NAME): Remove.
(TEST_SYSCALL_NR, TEST_SYSCALL_STR, STRUCT_STAT_STR): New macros.
* tests/lstat64.c: Likewise.
* tests/stat64.c: Likewise.
* tests/fstatx.c (TEST_SYSCALL_NR, nrify, nrify_): Remove.
* tests/lstatx.c: Likewise.
* tests/struct_flock.c (TEST_SYSCALL_NR, TEST_SYSCALL_STR, nrify,
nrify_, stringify, stringify_): Remove.
* tests/xselect.c: Likewise.
* tests/xstatx.c: Check TEST_SYSCALL_STR instead of TEST_SYSCALL_NAME.
(STRUCT_STAT_STR, TEST_SYSCALL_STR, stringify, stringify_): Remove.
[!STRUCT_STAT] (STRUCT_STAT_STR): New macro.
2016-01-12 03:07:39 +00:00
2165a359fd tests/struct_flock.c: fix musl libc compilation warnings
The size of off_t is not something one can rely upon.  For example,
musl libc unconditionally defines it as an int64_t type on x86.
A cast to the target type helps to avoid these libc differences.

* configure.ac: Call AC_C_TYPEOF.
* tests/struct_flock.c (TYPEOF_FLOCK_OFF_T): New macro.
(test_flock_einval): Use it instead of off_t.
2016-01-12 03:07:38 +00:00
4776e3366f tests/inet-cmsg.c: fix musl libc compilation warnings
The types that are used to define msg_namelen member of struct msghdr
and cmsg_len member of struct cmsghdr differ between libcs.
For example, glibc defines them as size_t, while musl libc - as type
socklen_t.  Print these fields using %lu format to avoid issues caused
by libc differences.

* tests/inet-cmsg.c (main): Cast mh.msg_controllen and c->cmsg_len
to unsigned long and print them using %lu format.
2016-01-12 00:00:47 +00:00
c36270a28e aio.test: include <fcntl.h> instead of <sys/fcntl.h>
* tests/aio.c: Include <fcntl.h> instead of <sys/fcntl.h>.
2016-01-11 02:20:04 +00:00
35eb03fdf7 mmsg.test: check memory access by sendmmsg and recvmmsg decoders
* tests/tests.h (tail_memdup): New prototype.
* tests/tail_alloc.c (tail_memdup): New function.
* tests/mmsg.c (main): Place all objects passed to sendmmsg and recvmmsg
at the end of memory pages followed by inaccessible pages.
2016-01-11 01:05:34 +00:00
3a184fe9cc mmsg.test: check decoding of flags passed to sendmmsg and recvmmsg
* tests/mmsg.c (main): Pass MSG_DONTROUTE|MSG_NOSIGNAL to sendmmsg.
Pass MSG_DONTWAIT to recvmmsg.
* tests/mmsg.expected: Update.
2016-01-11 01:05:34 +00:00
6e815ce640 mmsg.test: prefer direct sendmmsg/recvmmsg syscalls to libc wrappers
* tests/mmsg.c: Include <sys/syscall.h>.
Check for __NR_sendmmsg as an alternative to HAVE_SENDMMSG.
[!HAVE_STRUCT_MMSGHDR] (struct mmsghdr): Define.
(send_mmsg, recv_mmsg): New functions.
(main): Use them instead of sendmmsg and recvmmsg.

Reported-by: Szabolcs Nagy <nsz@port70.net>
2016-01-11 01:03:19 +00:00
8df07e1039 sigreturn.test: use RT_5 signal number instead of RT_2
Make the test compatible with musl libc that uses RT_2 internally.

* tests/sigreturn.c (main): Replace RT_2 with RT_5.
* tests/sigreturn.test: Likewise.

Reported-by: Szabolcs Nagy <nsz@port70.net>
2016-01-10 22:48:51 +00:00
5b87572952 avr32: wire up accept4 syscall
* linux/avr32/syscallent.h [321]: Add accept4 entry.
2016-01-10 21:38:03 +00:00
7de53317ab sparc64: fix names of {s,g}etres{u,g}id syscalls
* linux/sparc64/syscallent.h [108 ... 111]: Use sparc64 syscall names.
2016-01-09 22:54:53 +00:00
b663fd990b sparc64: remove sparc32 syscall entries
* linux/sparc64/syscallent.h [31, 32, 35, 44, 53, 56, 69, 70, 72, 77,
82, 84, 87, 89, 91, 94, 112, 115, 155, 231]: Unassign.
2016-01-09 22:53:33 +00:00
f77c4e6d25 sparc: remove sparc64 syscall entries
* linux/sparc/syscallent.h [52, 163]: Unassign.
2016-01-09 22:47:25 +00:00
f5fb0a7249 sparc64: clone syscallent.h from sparc
* linux/sparc64/syscallent.h: Clone from linux/sparc/syscallent.h.
2016-01-09 22:44:00 +00:00
b1110543d9 sparc: fix mlock2 sysentry, wire up bind, listen, and setsockopt syscalls
* linux/sparc/syscallent.h [353]: Move mlock2 entry to 356.
[353, 354, 355]: Add bind, listen, and setsockopt entries.
* NEWS: Mention this.
2016-01-09 21:58:44 +00:00
8249eeb5d4 tests: do not use settimeofday wrapper provided by libc
Workaround limitations of settimeofday wrapper provided by musl libc.

* tests/xettimeofday.c (main): Call settimeofday using syscall().

Reported-by: Szabolcs Nagy <nsz@port70.net>
2016-01-09 13:06:31 +00:00
19ff2b2ee7 ioctl.test: robustify against libcs invoking ioctl syscall on their own
* tests/ioctl.test: Filter out from the log ioctl calls with standard
descriptor arguments.

Reported-by: Szabolcs Nagy <nsz@port70.net>
2016-01-09 01:44:19 +00:00
2720a61832 alpha: enhance decoding of getxpid, getxuid, and getxgid syscalls
Print the second return value of getxpid, getxuid, and getxgid syscalls
that return a pair of values using the same mechanism as pipe syscall.

* alpha.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/alpha/syscallent.h [20]: Change SEN(getpid) to SEN(getxpid).
[24]: Change SEN(getuid) to SEN(getxuid).
[47]: Change SEN(getgid) to SEN(getxgid).
* NEWS: Mention this enhancement.
* tests/uid.awk: Update for getxgid output change.
* tests/uid.test: Cleanup.
* tests/getxxid.c: New file.
* tests/getxxid.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add getxxid.
(TESTS): Add getxxid.test.
* tests/.gitignore: Add getxxid.
2016-01-09 00:09:04 +00:00
b61b2d820f Cleanup parser of getpagesize syscall
* mem.c (SYS_FUNC(getpagesize)): Decode on entering syscall.
2016-01-08 19:20:05 +00:00
fbec510297 alpha: alias getdtablesize to printargs
* linux/dummy.h [ALPHA] (sys_getdtablesize): Alias to printargs.
* desc.c [ALPHA] (SYS_FUNC(getdtablesize)): Remove.
2016-01-08 18:53:27 +00:00
6833d61090 tests: change text marker in fork-f and vfork-f tests
Use chdir syscalls instead of pwrite64 syscalls as a method of inserting
text markers into strace output because the former are more portable.

* tests/fork-f.c (logit): Rename to logit_. Use chdir instead of pwrite.
(logit): New macro wrapper around logit_.
(main): Update expected output.
* tests/vfork-f.c: Likewise.
* tests/fork-f.test: Update.
2016-01-08 02:45:05 +00:00
be1cb92c72 Fix printing of 32-bit times syscall return value on 64-bit architectures
This change complements commit v4.9-359-gd93d9f8 by fixing
RVAL_UDECIMAL case.
The only syscall that appears to be affected is the times syscall.

* syscall.c (trace_syscall_exiting): In case of RVAL_UDECIMAL,
when current personality is 32-bit, print 32-bit return code.
* NEWS: Mention this fix.

Reported-by: Steve McIntyre <steve@einval.com>
2016-01-07 19:47:23 +00:00
1eabdb3c99 tests/vfork-f.c: support platforms without vfork
On some platforms, e.g. hppa glibc, vfork() is implemented using fork
syscall, so the test cannot rely on the parent process remaining blocked
until the child process either terminates or calls execve.

* tests/vfork-f.c (main): Explicitly block the parent until the child
either terminates or calls execve.
2016-01-07 02:11:58 +00:00
6bf08e3e4a Fix and enhance decoding of sched_[gs]etaffinity syscalls
Print cpu_set_t as a set of integers, similar to the way
fd_set is printed as a set of descriptors.

* affinity.c: Include <sched.h>.
(get_cpuset_size): New function.
(print_affinitylist): Rewrite using get_cpuset_size and next_set_bit.
(sched_getaffinity, sched_setaffinity): Print first two args as ints.
* NEWS: Mention this enhancement.
* tests/sched_xetaffinity.c: New file.
* tests/sched_xetaffinity.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add sched_xetaffinity.
(TESTS): Add sched_xetaffinity.test.
* tests/.gitignore: Add sched_xetaffinity.

Reported-by: Joe Korty <joe.korty@ccur.com>
2016-01-07 02:11:55 +00:00
6267e4b0e3 tests: convert epoll_create1.test from match_grep to match_diff
* tests/epoll_create1.c (main): Print expected output.
* tests/epoll_create1.test: Use match_diff instead of match_grep.
* tests/epoll_create1.expected: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove epoll_create1.expected.
2016-01-06 16:08:07 +00:00
6e65922a32 tests/struct_flock.c: use libtests
* tests/struct_flock.c (create_sample): Return void,
all callers changed.  Use perror_msg_and_fail.
* tests/fcntl.c: Use SKIP_MAIN_UNDEFINED.
* tests/fcntl64.c: Likewise.
2016-01-06 16:06:35 +00:00
c83746acf7 tests/file_handle.c: use libtests
* tests/file_handle.c: Use SKIP_MAIN_UNDEFINED.
(main): Use assert and perror_msg_and_skip.
2016-01-06 16:01:46 +00:00
6feccf199e tests/uid32.c: use libtests
* tests/uid32.c: Use SKIP_MAIN_UNDEFINED.
2016-01-06 15:58:14 +00:00
67c998b7d4 tests/uid16.c: use libtests
* tests/uid16.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_skip.
2016-01-06 15:57:45 +00:00
eb81ecf033 tests/uid.c: use libtests
* tests/uid.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_skip.
2016-01-06 15:57:17 +00:00
ea56b5ba3f tests/netlink_unix_diag.c: use libtests
* tests/netlink_unix_diag.c (send_query, check_responses, main):
Use perror_msg_and_skip.
2016-01-06 15:55:12 +00:00
285c3f453a tests/netlink_inet_diag.c: use libtests
* tests/netlink_inet_diag.c (send_query, check_responses, main):
Use perror_msg_and_skip.
2016-01-06 15:53:45 +00:00
82d1fd14f1 tests/readdir.c: use libtests
* tests/readdir.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_skip.
2016-01-06 12:03:57 +00:00
2e00fe9155 tests/getdents64.c: use libtests
* tests/getdents64.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_skip.
2016-01-06 12:03:37 +00:00
74769e99cd tests/getdents.c: use libtests
* tests/getdents.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_skip.
2016-01-06 12:02:55 +00:00
29e5bde776 tests/ipc_shm.c: use libtests
* tests/ipc_shm.c (cleanup): New function.
(main): Use it and perror_msg_and_skip.
2016-01-06 11:59:58 +00:00
efb134041e tests/ipc_sem.c: use libtests
* tests/ipc_sem.c (cleanup): New function.
(main): Use it and perror_msg_and_skip.
2016-01-06 11:59:29 +00:00
3ba7feca53 tests/ipc_msg.c: use libtests
* tests/ipc_msg.c (cleanup): New function.
(main): Use it and perror_msg_and_skip.
2016-01-06 11:59:06 +00:00
4e4958e0f9 tests/ipc_msgbuf.c: use libtests
* tests/ipc_msgbuf.c (cleanup): New function.
(main): Use it and perror_msg_and_skip.
2016-01-06 11:55:13 +00:00
bbbb97fb30 tests/mq.c: use libtests
* tests/mq.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_skip.
2016-01-06 11:52:43 +00:00
00777042c4 tests/utimensat.c: use libtests
* tests/utimensat.c: Use SKIP_MAIN_UNDEFINED.
(main): Use assert and perror_msg_and_skip.
2016-01-06 11:49:27 +00:00
647e7953ce tests/ppoll.c: use libtests
* tests/ppoll.c (main): Use assert, perror_msg_and_skip,
and perror_msg_and_fail.
2016-01-06 11:44:32 +00:00
4e66672923 tests/mmsg.c: use libtests
* tests/mmsg.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_skip.
2016-01-06 11:43:08 +00:00
2c59f1e482 tests/ip_mreq.c: use libtests
* tests/ip_mreq.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_skip.
2016-01-06 11:42:10 +00:00
cf40111be1 tests/ioctl.c: use libtests
* tests/ioctl.c: Use SKIP_MAIN_UNDEFINED.
(main): Use %m printf format specifier.
2016-01-06 11:40:00 +00:00
b736a05c56 tests/pipe.c: use libtests
* tests/pipe.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_fail and perror_msg_and_skip.
2016-01-06 11:38:05 +00:00
a380ba0f9b tests/getrandom.c: use libtests
* tests/getrandom.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_skip.
2016-01-06 11:36:54 +00:00
0b75320910 tests/signalfd.c: use libtests
* tests/signalfd.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_skip.
2016-01-06 11:35:23 +00:00