]> granicus.if.org Git - strace/log
strace
7 years agoprint_array: change tracee address type from unsigned long to kernel_ureg_t
Dmitry V. Levin [Tue, 20 Dec 2016 21:46:10 +0000 (21:46 +0000)]
print_array: change tracee address type from unsigned long to kernel_ureg_t

* defs.h (print_array): Change start_addr type from unsigned long
to kernel_ureg_t.
* util.c (print_array): Likewise.  Change the type of all tracee
address variables from unsigned long to kernel_ureg_t.

7 years agoRename LONG_LONG to ULONG_LONG and change it to return unsigned long long
Dmitry V. Levin [Fri, 23 Dec 2016 19:12:38 +0000 (19:12 +0000)]
Rename LONG_LONG to ULONG_LONG and change it to return unsigned long long

In all places where LONG_LONG is used the destination already has type
unsigned long long, so it is quite natural to change LONG_LONG as well.

* defs.h (LONG_LONG): Rename to ULONG_LONG, change return type
from long long to unsigned long long.  All callers updated.

7 years agomem: remove redundant casts
Dmitry V. Levin [Fri, 23 Dec 2016 11:16:11 +0000 (11:16 +0000)]
mem: remove redundant casts

* mem.c (SYS_FUNC(old_mmap)): Remove redundant cast
from kernel_ureg_t to unsigned long.
[S390] (SYS_FUNC(old_mmap_pgoff)): Remove redundant cast
from unsigned int to unsigned long.

7 years agodesc: remove redundant casts
Dmitry V. Levin [Thu, 22 Dec 2016 23:36:32 +0000 (23:36 +0000)]
desc: remove redundant casts

* desc.c (umove_kulong_array_or_printaddr): Remove redundant cast
from uint32_t to kernel_ulong_t.
(SYS_FUNC(pselect6)): Remove redundant casts from kernel_ulong_t
to unsigned long.

7 years agoprint_sigevent: remove redundant cast
Dmitry V. Levin [Thu, 22 Dec 2016 17:07:24 +0000 (17:07 +0000)]
print_sigevent: remove redundant cast

* print_sigevent.c (print_sigevent): Remove redundant cast from
struct_sigevent.sigev_value.sival_ptr to unsigned long as the former
is not a pointer but an unsigned integer.

7 years agotests: fix xattr.test for the case when listxattr returns a long list
Dmitry V. Levin [Thu, 22 Dec 2016 22:34:23 +0000 (22:34 +0000)]
tests: fix xattr.test for the case when listxattr returns a long list

* tests/xattr.c (DEFAULT_STRLEN): New macro.
(main): Use it to limit the length passed to print_quoted_memory.
Print ellipsis when the list returned by listxattr is too long.

7 years agotests: test for correct ellipsis with -s in xattr
Gabriel Laskar [Thu, 22 Dec 2016 15:10:52 +0000 (16:10 +0100)]
tests: test for correct ellipsis with -s in xattr

* tests/xattr-strings.c: New file.
* tests/xattr-strings.test: New test.
* tests/.gitignore: Add xattr-string.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add xattr-string.test.

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
7 years agoxattr: use printstr_ex instead of print_quoted_string
Gabriel Laskar [Thu, 22 Dec 2016 15:10:51 +0000 (16:10 +0100)]
xattr: use printstr_ex instead of print_quoted_string

This fixes the display when using `-s` to limit the string size
of the values displayed by {get,set}xattr.

* xattr.c (print_xattr_val): Remove static buffer.  Use printstr_ex
instead of print_quoted_string.

Reported-by: Марк Коренберг <socketpair@gmail.com>
Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
7 years agotests: use scno.h in finit_module, kcmp, renameat2 tests
Eugene Syromyatnikov [Tue, 20 Dec 2016 23:49:04 +0000 (02:49 +0300)]
tests: use scno.h in finit_module, kcmp, renameat2 tests

* tests/finit_module.c: Include "scno.h".
* tests/kcmp.c: Likewise.
* tests/renameat2.c: Likewise.

7 years agosock: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 14:12:17 +0000 (14:12 +0000)]
sock: cast pointers to kernel_ureg_t instead of unsigned long

* sock.c (decode_ifconf): Cast ifconf.ifc_buf pointer to kernel_ureg_t
instead of unsigned long.

7 years agoscsi: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 13:59:02 +0000 (13:59 +0000)]
scsi: cast pointers to kernel_ureg_t instead of unsigned long

* scsi.c (print_sg_io_v3_req, print_sg_io_v3_res): Cast sg_io_hdr.cmdp,
sg_io_hdr.dxferp, and sg_io_hdr.sbp pointers to kernel_ureg_t instead
of unsigned long.

7 years agomtd: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 16:38:02 +0000 (16:38 +0000)]
mtd: cast pointers to kernel_ureg_t instead of unsigned long

* mtd.c (decode_mtd_oob_buf): Cast mtd_oob_buf.ptr pointer
to kernel_ureg_t instead of unsigned long.

7 years agomsghdr: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 00:04:06 +0000 (00:04 +0000)]
msghdr: cast pointers to kernel_ureg_t instead of unsigned long

* msghdr.c (print_struct_msghdr): Cast msghdr.msg_iov and
msghdr.msg_control pointers to kernel_ureg_t instead of unsigned long.

7 years agoevdev: cast tcp->u_rval to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 14:12:17 +0000 (14:12 +0000)]
evdev: cast tcp->u_rval to kernel_ureg_t instead of unsigned long

* evdev.c (decode_bitset): Cast tcp->u_rval to kernel_ureg_t
instead of unsigned long.

7 years agoevdev: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 13:13:08 +0000 (13:13 +0000)]
evdev: cast pointers to kernel_ureg_t instead of unsigned long

* evdev.c (ff_effect_ioctl): Cast ff_periodic_effect.custom_data
pointer to kernel_ureg_t instead of unsigned long.

7 years agobtrfs: cast pointers to kernel_ureg_t instead of unsigned long
Dmitry V. Levin [Wed, 21 Dec 2016 13:11:11 +0000 (13:11 +0000)]
btrfs: cast pointers to kernel_ureg_t instead of unsigned long

* btrfs.c (btrfs_ioctl): Cast btrfs_ioctl_send_args.clone_sources
and btrfs_ioctl_vol_args_v2.qgroup_inherit pointers to kernel_ureg_t
instead of unsigned long.

7 years agoRework ifdefery around print_user_desc
Dmitry V. Levin [Wed, 21 Dec 2016 18:01:21 +0000 (18:01 +0000)]
Rework ifdefery around print_user_desc

* configure.ac (AC_CHECK_TYPES): Check for struct user_desc
in <asm/ldt.h>.
* clone.c (print_tls_arg): New function.
(SYS_FUNC(clone)): Use it.
(print_user_desc): Move prototype ...
* defs.h [HAVE_STRUCT_USER_DESC]: ... here.
* ldt.c: Check for HAVE_STRUCT_USER_DESC instead of architectures.
* linux/dummy.h: Likewise.

7 years agoIntroduce DECL_IOCTL macro to declare *_ioctl functions
Dmitry V. Levin [Wed, 21 Dec 2016 00:21:10 +0000 (00:21 +0000)]
Introduce DECL_IOCTL macro to declare *_ioctl functions

* defs.h (DECL_IOCTL): New macro.
(dm_ioctl, file_ioctl, fs_x_ioctl, loop_ioctl, ptp_ioctl, scsi_ioctl,
sock_ioctl, term_ioctl, ubi_ioctl, uffdio_ioctl): Rewrite prototypes
using DECL_IOCTL.

7 years agoIntroduce DECL_PRINT* macros to declare printnum_* and printpair_*
Dmitry V. Levin [Tue, 20 Dec 2016 22:28:20 +0000 (22:28 +0000)]
Introduce DECL_PRINT* macros to declare printnum_* and printpair_*

* defs.h (DECL_PRINTNUM, DECL_PRINTPAIR): New macros.
(printnum_short, printnum_int, printnum_int64): Rewrite prototypes
using DECL_PRINTNUM.
(printpair_int, printpair_int64): Rewrite prototypes
using DECL_PRINTPAIR.

7 years agoioctl: use uintptr_t for casts between 32-bit integers and pointers
Dmitry V. Levin [Wed, 21 Dec 2016 00:26:06 +0000 (00:26 +0000)]
ioctl: use uintptr_t for casts between 32-bit integers and pointers

* ioctl.c (compare): Cast pointer to uintptr_t before assigning
it to an integer.
(ioctl_lookup): Cast integer to uintptr_t before passing it
as a pointer.

7 years agoscsi: use umove_or_printaddr
Dmitry V. Levin [Wed, 21 Dec 2016 00:37:57 +0000 (00:37 +0000)]
scsi: use umove_or_printaddr

* scsi.c (scsi_ioctl): Use umove_or_printaddr.

7 years agoRemove dumpiov wrapper
Dmitry V. Levin [Wed, 21 Dec 2016 02:16:35 +0000 (02:16 +0000)]
Remove dumpiov wrapper

* defs.h (dumpiov): Remove.
* syscall.c (dumpio): Use dumpiov_upto instead of dumpiov.

7 years agotravis: fix enabling of gcc -Werror builds
Dmitry V. Levin [Wed, 21 Dec 2016 22:20:29 +0000 (22:20 +0000)]
travis: fix enabling of gcc -Werror builds

* travis-build.sh: Use DISTCHECK_CONFIGURE_FLAGS instead
of CHECK_CONFIGURE_FLAGS and ENABLE_GCC_WERROR.
[$CC == gcc]: Add --enable-gcc-Werror to DISTCHECK_CONFIGURE_FLAGS
instead of ENABLE_GCC_WERROR.
[$CHECK == coverage]: Add --enable-code-coverage
to DISTCHECK_CONFIGURE_FLAGS instead of CHECK_CONFIGURE_FLAGS.

7 years agoprintaddr: change argument type to kernel_ureg_t
Dmitry V. Levin [Tue, 20 Dec 2016 15:10:48 +0000 (15:10 +0000)]
printaddr: change argument type to kernel_ureg_t

* defs.h (printaddr): Change argument type from unsigned long
to kernel_ureg_t.

7 years agotests: check decoding of unreadable ip_mreq and ipv6_mreq structures
Dmitry V. Levin [Tue, 20 Dec 2016 20:19:35 +0000 (20:19 +0000)]
tests: check decoding of unreadable ip_mreq and ipv6_mreq structures

* tests/ip_mreq.c (main): Check short read.

7 years agotests: rewrite ip_mreq.c using arrays and iterators
Dmitry V. Levin [Tue, 20 Dec 2016 20:17:18 +0000 (20:17 +0000)]
tests: rewrite ip_mreq.c using arrays and iterators

* tests/ip_mreq.c (main): Create arrays of setsockopt arguments to test.
Iterate over these arrays invoking setsockopt and printing expected
output.

7 years agotests: rewrite ip_mreq.c using tail_alloc
Dmitry V. Levin [Tue, 20 Dec 2016 20:13:18 +0000 (20:13 +0000)]
tests: rewrite ip_mreq.c using tail_alloc

* tests/ip_mreq.c (main): Allocate objects of struct ip_mreq
and struct ipv6_mreq using tail_alloc instead of using stack.

7 years agotests: rewrite ip_mreq.c without asserts
Dmitry V. Levin [Tue, 20 Dec 2016 17:55:04 +0000 (17:55 +0000)]
tests: rewrite ip_mreq.c without asserts

* tests/ip_mreq.c: Do not include <assert.h>.
(main): Do not use assert.  Use sprintrc instead of errno2name.

7 years agoRemove NEED_PTRACE_PROTOTYPE_WORKAROUND
Dmitry V. Levin [Tue, 20 Dec 2016 14:58:57 +0000 (14:58 +0000)]
Remove NEED_PTRACE_PROTOTYPE_WORKAROUND

Remove the workaround for broken ptrace prototypes
that seems to be unneeded for quite a long time.

* defs.h [NEED_PTRACE_PROTOTYPE_WORKAROUND]: Remove.

7 years agotests: use scno.h in tests of relatively new syscalls
Dmitry V. Levin [Tue, 20 Dec 2016 00:06:15 +0000 (00:06 +0000)]
tests: use scno.h in tests of relatively new syscalls

* tests/add_key.c: Include "scno.h" after <asm/unistd.h>.
* tests/copy_file_range.c: Likewise.
* tests/execveat.c: Likewise.
* tests/kexec_file_load.c: Likewise.
* tests/membarrier.c: Likewise.
* tests/memfd_create.c: Likewise.
* tests/mlock2.c: Likewise.
* tests/pkey_alloc.c: Likewise.
* tests/pkey_free.c: Likewise.
* tests/pkey_mprotect.c: Likewise.
* tests/preadv2-pwritev2.c: Likewise.
* tests/userfaultfd.c: Likewise.

7 years agotests: generate scno.h from syscallent.h for use by other tests
Dmitry V. Levin [Mon, 19 Dec 2016 23:37:57 +0000 (23:37 +0000)]
tests: generate scno.h from syscallent.h for use by other tests

Provide scno.h with fallback definitions of all __NR_* constants known
to strace for the personbality being tested.

Some tests need just __NR_* constants without any kernel support.
Such tests can include "scno.h" after <asm/unistd.h> to get definitions
of these constants when system headers are too old.

* tests/generate_scno.c: New file.
* tests/.gitignore: Add generate_scno.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(scno.h): New rule.
(BUILT_SOURCES, CLEANFILES): Add scno.h.

7 years agotests: fix potential errno clobbering in membarrier test
Dmitry V. Levin [Tue, 20 Dec 2016 02:27:22 +0000 (02:27 +0000)]
tests: fix potential errno clobbering in membarrier test

* tests/membarrier.c (main): Save errno.

7 years agoDo not use widen_to_ulong in kexec.c and process_vm.c
Dmitry V. Levin [Tue, 20 Dec 2016 02:04:09 +0000 (02:04 +0000)]
Do not use widen_to_ulong in kexec.c and process_vm.c

Automatic argument truncation makes use of this function redundant.

* kexec.c (SYS_FUNC(kexec_load)): Do not invoke widen_to_ulong.
* process_vm.c (SYS_FUNC(process_vm_readv),
SYS_FUNC(process_vm_writev)): Likewise.

7 years agox32: implement automatic argument truncation for compat syscalls
Dmitry V. Levin [Tue, 20 Dec 2016 01:52:20 +0000 (01:52 +0000)]
x32: implement automatic argument truncation for compat syscalls

x32 syscalls starting with number 512 are compat syscalls that operate
on compat types.  Set COMPAT_SYSCALL_TYPES flag to these syscall entries
and make get_syscall_args truncate arguments of syscalls that have this
flag set, to avoid unpleasant alternative of adding multiple
widen_to_ulong invocations to individual syscall parsers.

preadv, pwritev, preadv2, and pwritev2 are exceptions: while these
syscalls operate on compat types, the offset argument has a regular
64-bit type, so the automatic argument truncation cannot be applied.

* defs.h (COMPAT_SYSCALL_TYPES): New macro.
* syscall.c (CST): New macro, defined to COMPAT_SYSCALL_TYPES.
* linux/ia64/syscallent.h: Do not include "../i386/syscallent.h"
unless [CST > 0].
* linux/x32/syscallent.h [512..533, 536..545]: Add CST flag.
* linux/x86_64/get_syscall_args.c (get_syscall_args): Truncate arguments
of compat syscalls to 32-bit values.
* tests/ksysent.c (CST): New macro, defined to 0.
* tests/nsyscalls.c (CST): Likewise.

7 years agox32: fix decoding of mprotect and pkey_mprotect syscall arguments
Dmitry V. Levin [Tue, 20 Dec 2016 01:11:53 +0000 (01:11 +0000)]
x32: fix decoding of mprotect and pkey_mprotect syscall arguments

As there are no compat versions of mprotect or pkey_mprotect syscalls
in x32 personality, "addr", "len", and "prot" syscall arguments have
kernel_ulong_t type and should be printed accordingly.

* mem.c (do_mprotect): Retrieve 1st, 2nd and 3rd arguments using
getarg_klu, print them using printaddr_klu, PRI_klu format,
and printflags64, correspondingly.

7 years agoMake tprint_iov function a static inline wrapper
Dmitry V. Levin [Mon, 19 Dec 2016 21:17:13 +0000 (21:17 +0000)]
Make tprint_iov function a static inline wrapper

* io.c (tprint_iov): Move ...
* defs.h: ... here, add static inline keywords.

7 years agox32: fix decoding of 3rd argument of preadv* and pwritev* syscalls
Eugene Syromyatnikov [Mon, 19 Dec 2016 22:13:21 +0000 (01:13 +0300)]
x32: fix decoding of 3rd argument of preadv* and pwritev* syscalls

In x32 personality these syscalls use compat type for the 3rd argument,
therefore it has to be truncated there.

* io.c (do_preadv, do_pwritev): Truncate tcp->u_arg[2] using
widen_to_ulong.

7 years agotests: fix preadv2-pwritev2 test on x32
Eugene Syromyatnikov [Mon, 19 Dec 2016 21:32:40 +0000 (00:32 +0300)]
tests: fix preadv2-pwritev2 test on x32

On x32 p(read|write)v(|2) syscalls are implemented via compat, which
truncates len argument to unsigned int.

* tests/preadv2-pwritev2.c (main): Print vlen argument as unsigned long.

7 years agokexec: fix for the x32 ABI
Eugene Syromyatnikov [Mon, 19 Dec 2016 21:13:27 +0000 (00:13 +0300)]
kexec: fix for the x32 ABI

There is no compat (and no 32-bit version, ever) for x32 ABI, so
kernel's long type should be used for arguments' values.

The only remaining thing is a pointer to cmdline string, but it is
currently broken on x32 anyway.

* kexec.c (SYS_FUNC(kexec_file_load)): Print the cmdline_len argument
as kernel long, retrieve it via getarg_klu; use printflags64 for
printing the flags argument, retrieve it via getarg_klu.

7 years agoCheck for current_klongsize instead of current_personality where appropriate
Dmitry V. Levin [Mon, 19 Dec 2016 18:30:22 +0000 (18:30 +0000)]
Check for current_klongsize instead of current_personality where appropriate

current_klongsize checks are more universal, therefore they are usually
shorter and easier to comprehend.

* desc.c (umove_kulong_array_or_printaddr): Check for current_klongsize
instead of current_personality and current_wordsize.
* io.c (print_lld_from_low_high_val): Likewise.
* lseek.c (SYS_FUNC(lseek)): Likewise.
* resource.c (decode_rlimit): Likewise.
* syscall.c (is_negated_errno): Likewise.
* util.c (getllval, getarg_klu): Likewise.

7 years agoUse kernel_ulong_t instead of unsigned long long where appropriate
Dmitry V. Levin [Mon, 19 Dec 2016 16:56:45 +0000 (16:56 +0000)]
Use kernel_ulong_t instead of unsigned long long where appropriate

* defs.h (printaddr_ull): Rename to printaddr_klu, change argument
type from unsigned long long to kernel_ulong_t.  All callers updated.
(getarg_ull): Rename to getarg_klu, change return value type
from unsigned long long to kernel_ulong_t.  All callers updated.
(PRI_kl, PRI_kld, PRI_klu, PRI_klx): New macros.
* bjm.c (SYS_FUNC(init_module)): Print kernel_ulong_t type using
PRI_klu format.
* desc.c (SYS_FUNC(pselect6)): Likewise.
* fadvise.c (SYS_FUNC(fadvise64)): Likewise.
* lookup_dcookie.c (SYS_FUNC(lookup_dcookie)): Likewise.
* mq.c (SYS_FUNC(mq_timedsend), SYS_FUNC(mq_timedreceive)): Likewise.
* kcmp.c (SYS_FUNC(kcmp)): Print kernel_ulong_t type using
PRI_klx format.
* keyctl.c (SYS_FUNC(keyctl)): Likewise.
* pkeys.c (SYS_FUNC(pkey_alloc)): Likewise.
* prctl.c (print_prctl_args, SYS_FUNC(prctl), SYS_FUNC(arch_prctl)):
Print kernel_ulong_t type using PRI_kld, PRI_klu, or PRI_klx format.
* util.c (printaddr_ull): Rename to printaddr_klu, change argument
type from unsigned long long to kernel_ulong_t, print it using
PRI_klx format.
(getarg_ull): Rename to getarg_klu, change return value type
from unsigned long long to kernel_ulong_t, print it using
PRI_klx format.

7 years agofcntl.c: print 64-bit fields of struct_kernel_flock64 using PRId64 format
Dmitry V. Levin [Mon, 19 Dec 2016 16:46:51 +0000 (16:46 +0000)]
fcntl.c: print 64-bit fields of struct_kernel_flock64 using PRId64 format

* fcntl.c (print_struct_flock64): Print l_start and l_len fields
of struct_kernel_flock64 using PRId64 format.

7 years agov4l2.c: print v4l2_ext_control.value64 using PRId64 format
Dmitry V. Levin [Mon, 19 Dec 2016 16:19:40 +0000 (16:19 +0000)]
v4l2.c: print v4l2_ext_control.value64 using PRId64 format

* v4l2.c (print_v4l2_ext_control): Print value64 field
of struct_v4l2_ext_control using PRId64 format.

7 years agoperf.c: print perf_event_attr.__reserved_1 using PRIx64 format
Dmitry V. Levin [Mon, 19 Dec 2016 16:11:55 +0000 (16:11 +0000)]
perf.c: print perf_event_attr.__reserved_1 using PRIx64 format

* perf.c (print_perf_event_attr): Print __reserved_1 field
of perf_event_attr using PRIx64 format.

7 years agobtrfs.c: print 64-bit fields of btrfs_ioctl_vol_args_v2 using PRIu64 format
Dmitry V. Levin [Mon, 19 Dec 2016 16:05:16 +0000 (16:05 +0000)]
btrfs.c: print 64-bit fields of btrfs_ioctl_vol_args_v2 using PRIu64 format

* block.c (btrfs_ioctl): Print size and transid fields
of struct_btrfs_ioctl_vol_args_v2 using PRIu64 format.

7 years agoblock.c: change type of long long fileds to int64_t
Dmitry V. Levin [Mon, 19 Dec 2016 15:59:47 +0000 (15:59 +0000)]
block.c: change type of long long fileds to int64_t

* block.c (struct_blkpg_partition): Change type of start and length
fields from long long to int64_t.
(print_blkpg_req): Print them using PRId64 format.

7 years agoIntroduce current_klongsize in addition to current_wordsize
Eugene Syromyatnikov [Sun, 11 Dec 2016 13:30:30 +0000 (16:30 +0300)]
Introduce current_klongsize in addition to current_wordsize

Subsequent commits are going to use current_klongsize
as the tracee's size of kernel_ulong_t type.

* defs.h (PERSONALITY0_KLONGSIZE): New macro.
[X86_64] (PERSONALITY2_KLONGSIZE): Likewise.
[SUPPORTED_PERSONALITIES > 1] (PERSONALITY1_KLONGSIZE): Likewise.
[SUPPORTED_PERSONALITIES == 1] (current_klongsize): Likewise.
[SUPPORTED_PERSONALITIES == 2 && PERSONALITY0_KLONGSIZE ==
PERSONALITY1_KLONGSIZE] (current_klongsize): Likewise.
[SUPPORTED_PERSONALITIES != 1 && (SUPPORTED_PERSONALITIES != 2 ||
PERSONALITY0_KLONGSIZE != PERSONALITY1_KLONGSIZE)] (current_klongsize):
New variable prototype.
* syscall.c [!current_klongsize] (current_klongsize): New variable.
[!current_klongsize] (personality_klongsize): New array.
(set_personality) [!current_klongsize]: Update current_klongsize
with the appropriate value from personality_klongsize.

7 years agoconfigure: define SIZEOF_KERNEL_LONG_T macro
Dmitry V. Levin [Fri, 16 Dec 2016 20:28:09 +0000 (20:28 +0000)]
configure: define SIZEOF_KERNEL_LONG_T macro

Provide SIZEOF_KERNEL_LONG_T macro in addition to SIZEOF_LONG and
SIZEOF_LONG_LONG for checking of kernel_long_t and kernel_ulong_t
types at the time of preprocessing.

* configure.ac (AC_CHECK_SIZEOF): Add kernel_long_t.

7 years agoRemove getarg_ll
Dmitry V. Levin [Mon, 19 Dec 2016 14:21:40 +0000 (14:21 +0000)]
Remove getarg_ll

This function has never been used in the code, and in perspective
the whole ext_arg thing will go away.

* defs.h (getarg_ll): Remove prototype.
* util.c (getarg_ll): Remove.

7 years agostruct tcb: make types of syscall arguments unsigned
Dmitry V. Levin [Mon, 19 Dec 2016 12:05:31 +0000 (12:05 +0000)]
struct tcb: make types of syscall arguments unsigned

This is the first step in the direction of revisiting current practice
of indiscriminate use of signed types for syscall arguments and memory
addresses.

* kernel_types.h (kernel_ureg_t): New type, typedef to unsigned long.
* defs.h (struct tcb): Change type of u_arg from long to kernel_ureg_t.
[HAVE_STRUCT_TCB_EXT_ARG]: Change type of ext_arg from long long
to unsigned long long.
* desc.c (decode_select): Change type of syscall arguments from long
to kernel_ureg_t.
(SYS_FUNC(oldselect)): Change type of select_args from long
to kernel_ureg_t.
* io.c (print_lld_from_low_high_val): Remove no longer needed cast
of syscall arguments to unsigned long.
* lseek.c (SYS_FUNC(lseek)): Cast syscall argument from unsigned long
to long.
* mem.c (print_mmap): Change type of syscall arguments from long
to kernel_ureg_t.
(SYS_FUNC(old_mmap), SYS_FUNC(old_mmap_pgoff)): Change type of u_arg
from long to kernel_ureg_t.
(SYS_FUNC(mmap), SYS_FUNC(mmap_pgoff), SYS_FUNC(mmap_pgoff)): Remove
no longer needed cast of syscall arguments to unsigned long.
* pathtrace.c (pathtrace_match): Change type of args and select_args
from long to kernel_ureg_t.
* util.c (getarg_ull): Remove no longer needed casts of syscall
arguments to unsigned types.

7 years agos390: fix decoding of mmap2 syscall when arguments are not available
Dmitry V. Levin [Mon, 19 Dec 2016 12:34:51 +0000 (12:34 +0000)]
s390: fix decoding of mmap2 syscall when arguments are not available

* mem.c [S390] (SYS_FUNC(old_mmap_pgoff)): Use umove_or_printaddr
instead of umoven to fetch mmap arguments, fix return value when this
fetch fails.

7 years agoFix pathmatch of oldselect syscall on 64-bit architectures
Dmitry V. Levin [Mon, 19 Dec 2016 11:49:58 +0000 (11:49 +0000)]
Fix pathmatch of oldselect syscall on 64-bit architectures

* pathtrace.c (pathtrace_match): Fix fetching of 32-bit oldselect
arguments on 64-bit architectures.

7 years agoCleanup oldselect
Dmitry V. Levin [Mon, 19 Dec 2016 11:40:43 +0000 (11:40 +0000)]
Cleanup oldselect

* desc.c (SYS_FUNC(oldselect)): Rewrite without use of macros.

7 years agoChange scno type from long to unsigned long
Dmitry V. Levin [Sun, 18 Dec 2016 17:20:44 +0000 (17:20 +0000)]
Change scno type from long to unsigned long

Use an unsigned type for syscall numbers as they are not intended
for signed arithmetics.  Introduce kernel_scno_t as a typedef
to unsigned long, that could be changed later to kernel_ulong_t.

* kernel_types.h (kernel_scno_t): New type, typedef to unsigned long.
* defs.h (struct tcb): Change type of scno field from long
to kernel_scno_t.
(syscall_name): Change argument type from long to kernel_scno_t.
(scno_in_range, scno_is_valid): Change argument type from unsigned long
to kernel_scno_t.
* linux/aarch64/set_scno.c (arch_set_scno): Change scno argument type
from long to kernel_scno_t.
* linux/alpha/set_scno.c (arch_set_scno): Likewise.
* linux/arc/set_scno.c (arch_set_scno): Likewise.
* linux/arm/set_scno.c (arch_set_scno): Likewise.
* linux/avr32/set_scno.c (arch_set_scno): Likewise.
* linux/bfin/set_scno.c (arch_set_scno): Likewise.
* linux/crisv10/set_scno.c (arch_set_scno): Likewise.
* linux/hppa/set_scno.c (arch_set_scno): Likewise.
* linux/i386/set_scno.c (arch_set_scno): Likewise.
* linux/ia64/set_scno.c (arch_set_scno): Likewise.
* linux/m68k/set_scno.c (arch_set_scno): Likewise.
* linux/metag/set_scno.c (arch_set_scno): Likewise.
* linux/microblaze/set_scno.c (arch_set_scno): Likewise.
* linux/mips/set_scno.c (arch_set_scno): Likewise.
* linux/nios2/set_scno.c (arch_set_scno): Likewise.
* linux/or1k/set_scno.c (arch_set_scno): Likewise.
* linux/powerpc/set_scno.c (arch_set_scno): Likewise.
* linux/riscv/set_scno.c (arch_set_scno): Likewise.
* linux/s390/set_scno.c (arch_set_scno): Likewise.
* linux/sh/set_scno.c (arch_set_scno): Likewise.
* linux/sh64/set_scno.c (arch_set_scno): Likewise.
* linux/sparc/set_scno.c (arch_set_scno): Likewise.
* linux/tile/set_scno.c (arch_set_scno): Likewise.
* linux/x86_64/set_scno.c (arch_set_scno): Likewise.
* linux/xtensa/set_scno.c (arch_set_scno): Likewise.
* linux/aarch64/get_scno.c (arch_get_scno): Change scno variable type
from long to kernel_scno_t.
* linux/alpha/get_scno.c (arch_get_scno): Likewise.
* linux/arm/get_scno.c (arch_get_scno): Likewise.
* linux/sh/get_scno.c (arch_get_scno): Likewise.
* linux/x86_64/get_scno.c (arch_get_scno): Likewise.
* syscall.c (arch_set_scno): Likewise.
(shuffle_scno): Change return type from long to kernel_scno_t.
(syscall_name): Change argument type from long to kernel_scno_t.

7 years agoLowercase SCNO_IN_RANGE and SCNO_IS_VALID
Dmitry V. Levin [Sun, 18 Dec 2016 17:12:27 +0000 (17:12 +0000)]
Lowercase SCNO_IN_RANGE and SCNO_IS_VALID

* defs.h (SCNO_IN_RANGE): Rename to scno_in_range.  All callers updated.
(SCNO_IS_VALID): Rename to scno_is_valid.  All callers updated.

7 years agoTurn SCNO_IN_RANGE and SCNO_IS_VALID into static inline functions
Dmitry V. Levin [Sun, 18 Dec 2016 17:06:29 +0000 (17:06 +0000)]
Turn SCNO_IN_RANGE and SCNO_IS_VALID into static inline functions

* defs.h (SCNO_IN_RANGE, SCNO_IS_VALID): Transform into static inline
functions.

7 years agocount.c: use syserror instead of direct u_error access
Dmitry V. Levin [Sun, 18 Dec 2016 22:57:57 +0000 (22:57 +0000)]
count.c: use syserror instead of direct u_error access

* count.c (count_syscall): Use syserror instead of u_error.

7 years agoReplace "(unsigned long) -1L" with -1UL
Dmitry V. Levin [Sun, 18 Dec 2016 14:09:51 +0000 (14:09 +0000)]
Replace "(unsigned long) -1L" with -1UL

* defs.h (dumpiov): Replace "(unsigned long) -1L" with -1UL.
* io.c (print_iovec, tprint_iov): Likewise.
* msghdr.c (SYS_FUNC(sendmsg)): Likewise.
* syscall.c (dumpio): Likewise.
* poll.c (decode_poll_exiting): Replace "(unsigned int) -1" with -1U.

7 years agoAdd toplevel recursive check-valgrind rule
Dmitry V. Levin [Sun, 18 Dec 2016 11:58:34 +0000 (11:58 +0000)]
Add toplevel recursive check-valgrind rule

* Makefile.am (.PHONY): Add check-valgrind-local.
(check-valgrind): New rule.
* configure.ac (AM_EXTRA_RECURSIVE_TARGETS): Add it.

7 years agom4: fix check-valgrind-* rules generated by AX_VALGRIND_CHECK
Dmitry V. Levin [Sun, 18 Dec 2016 11:56:28 +0000 (11:56 +0000)]
m4: fix check-valgrind-* rules generated by AX_VALGRIND_CHECK

* m4/ax_valgrind_check.m4 (check-valgrind-$(1)): Depend
on $(BUILT_SOURCES), honor $(AM_MAKEFLAGS), build check-am
instead of check-TESTS.

7 years agotravis: do coverage using a dedicated build
Dmitry V. Levin [Sun, 18 Dec 2016 00:12:48 +0000 (00:12 +0000)]
travis: do coverage using a dedicated build

* .travis.yml (after_success): Remove.
(matrix): Create an entry for the regular x86_64 target.
* travis-success.sh: Merge into ...
* travis-build.sh: ... this file.  Disable optimization
for coverage builds.
* travis-install.sh: Rename COVERAGE=true to CHECK=coverage.

7 years agomips n32: provide fallback definitions of kernel_long_t/kernel_ulong_t
Dmitry V. Levin [Sat, 17 Dec 2016 01:01:55 +0000 (01:01 +0000)]
mips n32: provide fallback definitions of kernel_long_t/kernel_ulong_t

* kernel_types.h [!(HAVE___KERNEL_LONG_T && HAVE___KERNEL_ULONG_T) &&
LINUX_MIPSN32] (kernel_long_t, kernel_ulong_t): Define to long long types.

7 years agoutil: simplify definitions of bit mask constants in umovestr
Eugene Syromyatnikov [Thu, 15 Dec 2016 15:51:26 +0000 (18:51 +0300)]
util: simplify definitions of bit mask constants in umovestr

* util.c (umovestr): Do not check for SIZEOF_LONG in definitions
of bit mask constants.

7 years agotests: check decoding of prctl operations without arguments
Eugene Syromyatnikov [Sat, 10 Dec 2016 04:05:10 +0000 (07:05 +0300)]
tests: check decoding of prctl operations without arguments

* tests/prctl-no-args.c: New file.
* tests/prctl-no-args.test: New test.
* tests/.gitignore: Add prctl-no-args.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add prctl-no-args.test.

7 years agotests: check decoding of prctl PR_[GS]ET_SECUREBITS operations
Eugene Syromyatnikov [Sat, 10 Dec 2016 04:05:31 +0000 (07:05 +0300)]
tests: check decoding of prctl PR_[GS]ET_SECUREBITS operations

* tests/prctl-securebits.c: New file.
* tests/prctl-securebits.test: New test.
* tests/.gitignore: Add prctl-securebits.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add prctl-securebits.test.

7 years agotests: check decoding of prctl PR_[GS]ET_DUMPABLE operations
Eugene Syromyatnikov [Sat, 10 Dec 2016 04:04:31 +0000 (07:04 +0300)]
tests: check decoding of prctl PR_[GS]ET_DUMPABLE operations

* tests/prctl-dumpable.c: New file.
* tests/prctl-dumpable.test: New test.
* tests/.gitignore: Add prctl-dumpable.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add prctl-dumpable.test.

7 years agoprctl: implement decoding of SUID_DUMP_* constants in PR_[GS]ET_DUMPABLE
Eugene Syromyatnikov [Tue, 6 Dec 2016 19:14:48 +0000 (22:14 +0300)]
prctl: implement decoding of SUID_DUMP_* constants in PR_[GS]ET_DUMPABLE

* xlat/pr_dumpable.in: New file.
* prctl.c: Include "xlat/pr_dumpable.h".
(SYS_FUNC(prctl)): Decode returned value of PR_GET_DUMPABLE operation
and the second syscall argument of PR_SET_DUMPABLE operation
as SUID_DUMP_* constants.

7 years agoInclude "kernel_types.h" in defs.h and tests/tests.h
Dmitry V. Levin [Fri, 16 Dec 2016 12:01:44 +0000 (12:01 +0000)]
Include "kernel_types.h" in defs.h and tests/tests.h

As kernel_ulong_t type is going to be used in the definition
of struct tcb and in many function prototypes, make it readily
available for every source file by including "kernel_types.h"
in defs.h and tests/tests.h files.

* defs.h: Include "kernel_types.h".
* tests/tests.h: Likewise.
* desc.c: Do not include "kernel_types.h".
* dirent.c: Likewise.
* keyctl.c: Likewise.
* syscall.c: Likewise.
* linux/asm_stat.h: Likewise.
* tests/answer.c: Likewise.
* tests/epoll_pwait.c: Likewise.
* tests/fanotify_init.c: Likewise.
* tests/fanotify_mark.c: Likewise.
* tests/file_handle.c: Likewise.
* tests/ftruncate.c: Likewise.
* tests/getdents.c: Likewise.
* tests/init_delete_module.h: Likewise.
* tests/inotify.c: Likewise.
* tests/inotify_init1.c: Likewise.
* tests/ioprio.c: Likewise.
* tests/ipc_msgbuf.c: Likewise.
* tests/kcmp.c: Likewise.
* tests/kexec_file_load.c: Likewise.
* tests/kexec_load.c: Likewise.
* tests/keyctl.c: Likewise.
* tests/lookup_dcookie.c: Likewise.
* tests/lseek.c: Likewise.
* tests/mq_sendrecv.c: Likewise.
* tests/nsyscalls.c: Likewise.
* tests/pkey_alloc.c: Likewise.
* tests/pkey_free.c: Likewise.
* tests/pkey_mprotect.c: Likewise.
* tests/prctl-pdeathsig.c: Likewise.
* tests/prctl-tsc.c: Likewise.
* tests/preadv2-pwritev2.c: Likewise.
* tests/process_vm_readv_writev.c: Likewise.
* tests/read-write.c: Likewise.
* tests/setfsugid.c: Likewise.
* tests/setns.c: Likewise.
* tests/truncate.c: Likewise.
* tests/unshare.c: Likewise.
* tests/xgetrlimit.c: Likewise.

7 years agoPost-release administrivia
Dmitry V. Levin [Thu, 15 Dec 2016 00:08:06 +0000 (00:08 +0000)]
Post-release administrivia

* NEWS: Add a header line for the next release.
* debian/changelog.in: Add a changelog entry for 4.15-1.
* strace.spec.in: Likewise.

7 years agoxlat: provide fallback definitions for NETLINK_* constants v4.15
Dmitry V. Levin [Wed, 14 Dec 2016 08:09:10 +0000 (08:09 +0000)]
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.

7 years agotests: relax getaffinity return value check in tests/sched_xetaffinity.c
Dmitry V. Levin [Wed, 14 Dec 2016 02:03:04 +0000 (02:03 +0000)]
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.

7 years agotests: fix threads-execve.test for large pids
Dmitry V. Levin [Wed, 14 Dec 2016 01:02:03 +0000 (01:02 +0000)]
tests: fix threads-execve.test for large pids

* tests/threads-execve.c (main): Fix expected output for large pids.

7 years agoPrepare for 4.15 release
Dmitry V. Levin [Tue, 13 Dec 2016 20:21:22 +0000 (20:21 +0000)]
Prepare for 4.15 release

* NEWS: Update for 4.15 release.

7 years ago.mailmap: add addresses of Thomas De Schampheleire
Dmitry V. Levin [Tue, 13 Dec 2016 20:43:57 +0000 (20:43 +0000)]
.mailmap: add addresses of Thomas De Schampheleire

* .mailmap: Add both addresses of Thomas De Schampheleire here to avoid
duplications in CREDITS file.

7 years agoSync strace.spec and debian/ with packages
Dmitry V. Levin [Tue, 13 Dec 2016 20:40:48 +0000 (20:40 +0000)]
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.

7 years agotests: workaround a bug in GNU grep
Dmitry V. Levin [Tue, 13 Dec 2016 19:59:47 +0000 (19:59 +0000)]
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.

7 years agotests: fix typo in comment inside prctl-tsc.c
Eugene Syromyatnikov [Sat, 10 Dec 2016 00:12:15 +0000 (03:12 +0300)]
tests: fix typo in comment inside prctl-tsc.c

7 years agoFix libunwind segfault when -p is passed before -k
Sean Stangl [Thu, 8 Dec 2016 19:54:24 +0000 (09:54 -1000)]
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>
7 years agoUpdate NEWS
Eugene Syromyatnikov [Tue, 6 Dec 2016 01:33:32 +0000 (04:33 +0300)]
Update NEWS

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
7 years agotests: skip fault injection tests on unsupported platforms
Dmitry V. Levin [Wed, 7 Dec 2016 16:57:42 +0000 (16:57 +0000)]
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.

7 years agotests: introduce require_min_kernel_version_or_skip function
Dmitry V. Levin [Wed, 7 Dec 2016 18:05:28 +0000 (18:05 +0000)]
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.

7 years agotests: add descriptions to prctl-pdeathsig and prctl-tsc tests
Eugene Syromyatnikov [Tue, 6 Dec 2016 19:12:35 +0000 (22:12 +0300)]
tests: add descriptions to prctl-pdeathsig and prctl-tsc tests

7 years agotests: robustify prctl-pdeathsig.test and prctl-tsc.test
Dmitry V. Levin [Wed, 7 Dec 2016 16:22:50 +0000 (16:22 +0000)]
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.

7 years agoMakefile.am: don't confuse CFLAGS and CFLAGS_FOR_BUILD
Thomas De Schampheleire [Tue, 18 Oct 2016 11:42:44 +0000 (13:42 +0200)]
Makefile.am: don't confuse CFLAGS and CFLAGS_FOR_BUILD

Commit dc427d50d96b15c9a64d7e78d97ce4d194622a63 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>
7 years agom4: prepare gl_WARN_ADD for simultaneous use of multiple compilers
Dmitry V. Levin [Wed, 7 Dec 2016 01:08:44 +0000 (01:08 +0000)]
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.

7 years agoAX_PROG_CC_FOR_BUILD: redirect more variables related to C compiler
Dmitry V. Levin [Wed, 7 Dec 2016 00:59:12 +0000 (00:59 +0000)]
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.

7 years agoMove all gl_WARN_ADD calls to a separate m4 macro
Dmitry V. Levin [Wed, 7 Dec 2016 00:47:50 +0000 (00:47 +0000)]
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.

7 years agom4: introduce st_SAVE_VAR and st_RESTORE_VAR macros
Dmitry V. Levin [Wed, 7 Dec 2016 10:58:24 +0000 (10:58 +0000)]
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.

7 years agotests: add valgrind support to "make check"
Dmitry V. Levin [Tue, 6 Dec 2016 02:31:31 +0000 (02:31 +0000)]
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.

7 years agotests: robustify threads-execve.test against race conditions
Dmitry V. Levin [Tue, 6 Dec 2016 15:46:34 +0000 (15:46 +0000)]
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.

7 years agotests: fix expected output in strace-ttt.test
Dmitry V. Levin [Tue, 6 Dec 2016 08:55:41 +0000 (08:55 +0000)]
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.

7 years agotests: fix expected output in strace-tt.test
Dmitry V. Levin [Tue, 6 Dec 2016 08:50:31 +0000 (08:50 +0000)]
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.

7 years agotests: robustify redirect.test against race conditions
Dmitry V. Levin [Tue, 6 Dec 2016 02:55:49 +0000 (02:55 +0000)]
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.

7 years agotests: robustify attach-f-p.test against race conditions
Dmitry V. Levin [Tue, 6 Dec 2016 01:54:13 +0000 (01:54 +0000)]
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.

7 years agotests: robustify attach-p-cmd.test against race conditions
Dmitry V. Levin [Tue, 6 Dec 2016 00:32:06 +0000 (00:32 +0000)]
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.

7 years agoRewrite remaining qual_* parsers using bit sets
Dmitry V. Levin [Sun, 4 Dec 2016 14:39:48 +0000 (14:39 +0000)]
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.

7 years agoChange qual_vec/qual_fault into static fixed size arrays
Dmitry V. Levin [Sat, 3 Dec 2016 22:39:19 +0000 (22:39 +0000)]
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.

7 years agoRewrite qual_signal using bit sets
Dmitry V. Levin [Sat, 3 Dec 2016 22:37:19 +0000 (22:37 +0000)]
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.

7 years agoRewrite qual_desc using bit sets
Dmitry V. Levin [Fri, 2 Dec 2016 22:16:40 +0000 (22:16 +0000)]
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.

7 years agotests: skip redirect-fds.test when strace is wrapped with valgrind
Dmitry V. Levin [Mon, 5 Dec 2016 10:34:33 +0000 (10:34 +0000)]
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.