2018-04-05  Dmitry V. Levin  <ldv@altlinux.org>

	Prepare for 4.22 release.
	* NEWS: Update for 4.22 release.

	Update copyright headers.
	Headers updated automatically using maint/update_copyright_years.sh
	script.

2018-04-05  Eugene Syromyatnikov  <evgsyr@gmail.com>

	Update NEWS.

2018-04-05  Masatake YAMATO  <yamato@redhat.com>

	unwind: split unwind code into front-end and back-end.
	This opens the way for alternative unwinder back-ends.

	* unwind.h: New file, defines the unwinder back-end interface.
	* unwind.c: Move all libunwind related code ...
	* unwind-libunwind.c: ... here.
	* Makefile.am [USE_LIBUNWIND] (strace_SOURCES): Add unwind.h
	and unwind-libunwind.c.

2018-04-05  Masatake YAMATO  <yamato@redhat.com>

	unwind: rename public functions in an object-oriented fashion.
	This change renames functions exported to strace core part from unwind
	subsystem.

	The new names imply that unwind subsystem exports two types of
	functions.  One is for manipulating back-end itself, "unwind_" prefix
	is used for this type.  Another is for manipulating back-end private data
	structure (unwind_ctx) attached to tcb, "unwind_tcb_" is used for this
	type.

	This naming should help people to understand unwind subsystem
	and the relation between unwind subsystem and back-ends.

	* defs.h (unwind_print_stacktrace): Rename to unwind_tcb_print.
	(unwind_capture_stacktrace): Rename to unwind_tcb_capture.
	* unwind.c: Ditto.
	* syscall.c (syscall_entering_trace, syscall_exiting_trace): Use
	new names.

2018-04-05  Masatake YAMATO  <yamato@redhat.com>

	unwind: add unwind_ prefix to struct tcb.queue field and its type.
	The names given to struct tcb.queue field and its type are too common,
	this may cause conflicts in the future if new fields are added
	to struct tcb.

	* defs.h (struct tcb): Rename queue field to unwind_queue,
	rename its type queue_t to unwind_queue_t.
	* unwind.c (struct unwind_queue_t): Rename to unwind_queue_t.
	All users updated.

2018-04-05  Masatake YAMATO  <yamato@redhat.com>

	unwind: make the field type of struct tcb independent from libunwind.
	Narrowing the area where the code refers to names associated with
	libunwind is needed to utilize libdw of elfutils as an alternative
	unwinder.

	* defs.h (struct tcb): Rename libunwind_ui field to unwind_ctx, change
	its type to "void *".
	* unwind.c (unwind_tcb_init, unwind_tcb_fin, stracetrace_walk): Reflect
	* the above field renaming.

2018-04-04  Dmitry V. Levin  <ldv@altlinux.org>

	tests: robustify options-syntax.test against ash.
	* tests/options-syntax.test: Do not assume that shell provides $UID,
	use "id -u" if it doesn't.

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	strace.c: add support for opening output file in append mode.
	* strace.c (open_append): New variable.
	(init): Handle -A option.
	(strace_fopen): Open file in "a" mode if open_append is set to true.
	* strace.1.in: Document this.
	* NEWS: Mention this.

	Suggested-by: Philipp Marek <philipp.marek@emerion.com>
	Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=528488

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	strace.c: support simultaneous usage of -r and -t options.
	* strace.c (init): Do not set tflag when rflag is set.
	(printleader): Handle rflag and tflag separately.
	* strace.1.in (.SH OPTIONS): Add a note about differences between
	the monotonic clock time  and the wall clock time.
	* tests/options-syntax.test: Remove the check for
	"-tt has no effect with -r" warning.
	* NEWS: Mention this.

	Suggested-by: Josh Triplett <josh@freedesktop.org>
	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
	Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466195

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	syscall.c: dump write I/O even if error is returned.
	It makes sense to try to dump the argument of write syscalls as they can
	be readily available despite the fact that error has been returned.

	* syscall.c (dumpio): Move check for syserror and check for fd in
	read_set to the end of the function.
	* tests/read-write.c: Add a check for this behaviour.
	* tests/pread64-pwrite64.c: Update expected output.
	* NEWS: Mention this.

	Suggested-by: J. Bruce Fields <bfields@fieldses.org>
	Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=436284

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	strace: handle possible NULL from localtime() call.
	* strace.c (printleader): Print raw tv_sec value if localtime() returned
	NULL.
	* tests/localtime.c: New file.
	* tests/localtime.test: New test.
	* tests/Makefile.am (check_PROGRAMS): Add localtime.
	(MISC_TESTS): Add localtime.test.
	(localtime_LDADD): New variable.
	* tests/.gitignore: Add localtime.
	* ci/install-dependencies.sh (common_packages): Add faketime.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
	Closes: https://github.com/strace/strace/issues/42

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	Return RVAL_STR unconditionally.
	There is no reason to check for auxstr being non-NULL
	because syscall_exiting_trace already does the check.

	* sched.c (SYS_FUNC(sched_getscheduler)): Do not check tcp->auxstr,
	return RVAL_STR unconditionally.
	* time.c (do_adjtimex): Likewise.

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	dist/README: s/linux/Linux/
	* dist/README: Replace "linux" with "Linux".

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	strace.1.in: fix formatting of -e trace class descriptions.
	Use .TP instead .PP as it is ought to be.

	* strace.1.in (.SS Filtering): Use .TP instead .PP as it is ought to be.

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	nlattr: check NLA_TYPE_MASK at compile time.
	* nlattr.c: Include "static_assert.h"
	(print_nlattr): Check the expectations about NLA_TYPE_MASK.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	bpf: add a comment about bpf_attr decoding.
	* bpf.c: Add comment.

2018-04-04  Dmitry V. Levin  <ldv@altlinux.org>

	tests: check decoding of bpf_attr of size 1.
	* tests/bpf.c (BPF_PROG_GET_NEXT_ID_checks): New entry.

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	bpf: use print_big_u64_addr.
	Since pointers stored in the bpf_attr union are 64-bit regardless
	of architecture bitness.

	* bpf.c (DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)): Call print_big_u64_addr
	for attr.license.
	(DEF_BPF_CMD_DECODER(BPF_OBJ_PIN)): Call print_big_u64_addr
	for attr.pathname.
	* tests/bpf.c (BPF_OBJ_PIN_checks): Check it.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	bpf: add support for file mode flags.
	These were introduced by Linux commit v4.15-rc1~84^2~384^2~4.

	* bpf_attr.h (struct BPF_OBJ_PIN_struct): Add file_flags field.
	(struct BPF_PROG_GET_NEXT_ID_struct, struct BPF_PROG_GET_FD_BY_ID_struct,
	struct BPF_MAP_GET_FD_BY_ID_struct): Add open_flags field.
	(BPF_OBJ_PIN_struct_size, expected_BPF_OBJ_PIN_struct_size,
	expected_BPF_PROG_GET_NEXT_ID_struct_size,
	expected_BPF_PROG_GET_FD_BY_ID_struct_size,
	expected_BPF_MAP_GET_FD_BY_ID_struct_size): Update.
	* bpf.c (DEF_BPF_CMD_DECODER(BPF_OBJ_PIN)): Check the length, skip
	printing the rest of attributes if it is less than offset of the
	end of the bpf_fd field, print file_flags field otherwise.
	(DEF_BPF_CMD_DECODER(BPF_PROG_GET_NEXT_ID),
	DEF_BPF_CMD_DECODER(BPF_PROG_GET_FD_BY_ID),
	DEF_BPF_CMD_DECODER(BPF_MAP_GET_FD_BY_ID)): Check the length, skip
	printing the rest of attributes if it is less than offset of the
	end of the next_id field, print open_flags field otherwise.
	* xlat/bpf_file_mode_flags.in: New file.
	* tests/bpf.c (BPF_OBJ_PIN_checks, BPF_PROG_GET_NEXT_ID_checks,
	BPF_PROG_GET_FD_BY_ID_checks, BPF_MAP_GET_FD_BY_ID_checks): Check it.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	tests: refactor bpf test.
	The aim of this change is to introduce an ability to perform multiple
	checks for a specific bpf command.  In order to achieve so, all the
	related data is stored in check descriptor, and test_bpf iterates over
	it.  There are also some provisions made in regard to future changes
	(specifically, the way bpf_attr_data union is defined).

	* tests/bpf.c (print_bpf_attr): New function, a wrapper around
	struct bpf_check.printer.
	(test_bpf_): Rename to...
	(test_bpf): ...this.  Replace arguments with struct bpf_check pointer.
	Iterate over possible attribute variants. Account for changes in
	attribute initialisation routine: provide a pointer to locally defined
	union bpf_attr_data and perform memcpy afterwards. Initialise memory
	from data each time before a bpf call.
	(TEST_BPF, DEF_*, init_*, print_*): Remove.
	(init_BPF_PROG_LOAD_attr, print_BPF_PROG_LOAD_attr,
	init_BPF_OBJ_PIN_attr): New functions.
	(license, pathname): New variables.
	(BPF_MAP_CREATE_checks, BPF_MAP_LOOKUP_ELEM_checks,
	BPF_MAP_UPDATE_ELEM_checks, BPF_MAP_DELETE_ELEM_checks,
	BPF_MAP_GET_NEXT_KEY_checks, BPF_PROG_LOAD_checks, BPF_OBJ_PIN_checks,
	BPF_PROG_ATTACH_checks, BPF_PROG_DETACH_checks,
	BPF_PROG_TEST_RUN_checks, BPF_PROG_GET_NEXT_ID_checks,
	BPF_PROG_GET_FD_BY_ID_checks, BPF_MAP_GET_FD_BY_ID_checks,
	BPF_OBJ_GET_INFO_BY_FD_checks): New arrays.
	(BPF_OBJ_GET_checks, BPF_MAP_GET_NEXT_ID_checks): New macros.
	(CHK): New macro, a shorthand for initialising array of struct bpf_check.
	(main): New static constant checks, iterate over checks and run test_bpf
	with each element.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	print_fields.h: introduce PRINT_FIELD_ADDR and PRINT_FIELD_ADDR64 macros
	* print_fields.h (PRINT_FIELD_ADDR, PRINT_FIELD_ADDR64): New macro.

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	print_fields.h: introduce PRINT_FIELD_CSTRING_SZ macro.
	A variant of PRINT_FIELD_CSTRING with an ability to pass string size
	explicitly.

	* print_fields.h (PRINT_FIELD_CSTRING_SZ): New macro.

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	print_fields.h: check whether passed field is an array in PRINT_FIELD_CSTRING
	* print_fields.h (PRINT_FIELD_CSTRING): Add MUST_BE_ARRAY to the size
	value in order to check whether (where_).field_ is an array in compile
	time.

	print_fields.h: whitespace fix in PRINT_FIELD_HEX_ARRAY.

2018-04-04  Dmitry V. Levin  <ldv@altlinux.org>

	bpf_attr: add more size checks.
	* bpf_attr.h: Add expected sizes of structures.
	* gen_bpf_attr_check.sh: Check them.

	tests: check bpf syscall decoder unconditionally.
	* configure.ac (AC_CHECK_HEADERS([linux/bpf.h])): Check for
	struct bpf_insn.
	* tests/bpf.c: Remove the test guard, include "scno.h", "bpf_attr.h",
	"xlat.h", and "xlat/bpf_commands.h".  Conditionalize inclusion of
	<linux/bpf.h> on HAVE_LINUX_BPF_H.  Remove all HAVE_UNION_* checks.
	(BPF_ATTR_DATA_FIELD): New macro.
	(bpf_attr_data): New union.  Note that it is larger than modern
	union bpf_attr, this allows more checks to be implemented in the future.
	(sizeof_attr, test_bpf_): Replace union bpf_attr with
	union bpf_attr_data.
	(DEF_BPF_INIT_FIRST): Replace union bpf_attr with the corresponding
	structure.
	(init_BPF_MAP_CREATE_attr): Replace union bpf_attr with
	struct BPF_MAP_CREATE_struct.
	(init_BPF_MAP_LOOKUP_ELEM_attr): Replace union bpf_attr with
	struct BPF_MAP_LOOKUP_ELEM_struct.
	(init_BPF_MAP_UPDATE_ELEM_attr): Replace union bpf_attr with
	struct BPF_MAP_UPDATE_ELEM_struct.
	(init_BPF_MAP_DELETE_ELEM_attr): Replace union bpf_attr with
	struct BPF_MAP_DELETE_ELEM_struct.
	(init_BPF_MAP_GET_NEXT_KEY_attr): Replace union bpf_attr with
	struct BPF_MAP_GET_NEXT_KEY_struct.
	(init_BPF_PROG_LOAD_attr): Replace union bpf_attr with
	struct BPF_PROG_LOAD_struct.
	(init_BPF_OBJ_PIN_attr): Replace union bpf_attr with
	struct BPF_OBJ_PIN_struct.
	(init_BPF_PROG_ATTACH_attr): Replace union bpf_attr with
	struct BPF_PROG_ATTACH_struct.
	(init_BPF_PROG_DETACH_attr): Replace union bpf_attr with
	struct BPF_PROG_DETACH_struct.
	(init_BPF_PROG_GET_NEXT_ID_attr): Replace union bpf_attr with
	struct BPF_PROG_GET_NEXT_ID_struct.
	(sample_BPF_PROG_TEST_RUN_attr): Change type from union bpf_attr to
	struct BPF_PROG_TEST_RUN_struct, all users updated.
	(sample_BPF_OBJ_GET_INFO_BY_FD_attr): Change type from union bpf_attr
	to struct BPF_OBJ_GET_INFO_BY_FD_struct, all users updated.

	Check that structures defined by bpf_attr.h match system union bpf_attr.
	* gen_bpf_attr_check.sh: New file.
	* Makefile.am (EXTRA_DIST): Add it.
	(strace_SOURCES_check): New variable.
	(strace_SOURCES): Add $(strace_SOURCES_check).
	(BUILT_SOURCES, CLEANFILES): Add bpf_attr_check.c.
	(bpf_attr_check.c): New rule.
	(sys_func_h_sources): New variable.
	(sys_func.h): Use it instead of strace_SOURCES_c.
	* .gitignore: Add /bpf_attr_check.c.

2018-04-04  Dmitry V. Levin  <ldv@altlinux.org>

	build: generate all union bpf_attr checks automatically.
	Rather than list by hand some members of union bpf_attr that we check
	for availability, automatically list all members of union bpf_attr we
	are aware of.

	* m4/gen_bpf_attr_m4.sh: New file.
	* bootstrap: Invoke it.
	* configure.ac (AC_CHECK_HEADERS([linux/bpf.h])): Use st_BPF_ATTR.
	* m4/.gitignore: New file.

2018-04-04  Dmitry V. Levin  <ldv@altlinux.org>

	bpf: move definitions of bpf_attr structures to separate header file.
	This also unifies decoders of bpf commands by moving common code
	to new macros.

	* bpf_attr.h: New file.
	* Makefile.am (strace_SOURCES): Add it.
	* bpf.c: Include it.
	(DEF_BPF_CMD_DECODER): Rename to BEGIN_BPF_CMD_DECODER, add code common
	to all decoders.  All users updated.
	(END_BPF_CMD_DECODER): New macro, add its invocation to all users
	of BEGIN_BPF_CMD_DECODER macro.

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	Introduce print_big_u64_addr.
	This is needed at least for bpf, btrfs, and sg_io, as 32-bit tracer
	cannot figure out whether the kernel is 32-bit or 64-bit,
	and its behaviour differs when it handles u64 as a pointer.

	* linux/arch_defs_.h [!CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL]
	(CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL): New definition, default to 0.
	* linux/arm/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
	Define to 1.
	* linux/i386/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
	Likewise.
	* linux/mips/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
	Likewise.
	* linux/powerpc/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
	Likewise.
	* linux/riscv/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
	Likewise.
	* linux/s390/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
	Likewise.
	* linux/sparc/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
	Likewise.
	* linux/tile/arch_defs_.h (CAN_ARCH_BE_COMPAT_ON_64BIT_KERNEL):
	Likewise.
	* defs.h (print_big_u64_addr): New function.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-04-04  Eugene Syromyatnikov  <evgsyr@gmail.com>

	defs.h: introduce max_addr and max_kaddr macros.
	In order to check an address against maximum addr/kaddr value
	for the current personality.

	* degs.h (max_addr, max_kaddr): New macros.

2018-04-04  Dmitry V. Levin  <ldv@altlinux.org>

	Introduce static_assert.
	We are going to use static_assert provided by <assert.h> or,
	if it doesn't work, our cheap imitation that doesn't display
	the message specified as the second argument of static_assert.

	* configure.ac (AC_CACHE_CHECK): Check for static_assert in <assert.h>,
	define HAVE_STATIC_ASSERT if it is available.
	* static_assert.h: New file.
	* Makefile.am (strace_SOURCES): Add it.

2018-04-04  Dmitry V. Levin  <ldv@altlinux.org>

	tests: forward SIZEOF_KERNEL_LONG_T and SIZEOF_LONG to C preprocessor.
	* tests/Makefile.am (AM_CPPFLAGS): Forward SIZEOF_KERNEL_LONG_T
	and SIZEOF_LONG as TESTS_SIZEOF_KERNEL_LONG_T and TESTS_SIZEOF_LONG.
	* tests/tests.h [TESTS_SIZEOF_KERNEL_LONG_T] (SIZEOF_KERNEL_LONG_T):
	Redefine to TESTS_SIZEOF_KERNEL_LONG_T.
	[TESTS_SIZEOF_LONG] (SIZEOF_LONG): Redefine to TESTS_SIZEOF_LONG.

	Complements: v4.21~5 ("Export SIZEOF_LONG and SIZEOF_KERNEL_LONG_T to tests")

2018-04-04  Dmitry V. Levin  <ldv@altlinux.org>

	tests/tests.h: fix indentation.

	tests: fix potential errno clobbering in netlink_kobject_uevent.test.
	* tests/netlink_kobject_uevent.c (errstr): New variable.
	(sys_send): New function.
	(main): Use them.

2018-04-03  Gleb Fotengauer-Malinovskiy  <glebfm@altlinux.org>

	Restore kvm ioctl definitions for aarch64 and mips architectures.
	* maint/ioctls_sym.sh: Add aarch64 and mips architectures to the list
	of kvm-capable architectures.
	* linux/aarch64/ioctls_arch0.h: Regenerate.
	* linux/mips/ioctls_arch0.h: Regenerate.

	Fixes: v4.15~92 ("Move KVM_* ioctl entries from ioctls_inc*.h to ioctls_arch*.h")

2018-04-03  Gleb Fotengauer-Malinovskiy  <glebfm@altlinux.org>

	Update ioctl entries from linux v4.16.
	* linux/32/ioctls_inc_align16.h: Update from linux v4.16
	using ioctls_gen.sh.
	* linux/32/ioctls_inc_align32.h: Likewise.
	* linux/32/ioctls_inc_align64.h: Likewise.
	* linux/64/ioctls_inc.h: Likewise.
	* linux/x32/ioctls_inc0.h: Likewise.
	* linux/arm/ioctls_arch0.h: Likewise.
	* linux/i386/ioctls_arch0.h: Likewise.
	* linux/powerpc/ioctls_arch0.h: Likewise.
	* linux/s390/ioctls_arch0.h: Likewise.
	* linux/s390x/ioctls_arch0.h: Likewise.
	* linux/x86_64/ioctls_arch0.h: Likewise.
	* NEWS: Mention this.

	maint: update for linux 4.16.
	* maint/ioctls_sym.sh: Add workaround for linux/ndctl.h file.
	Update workaround for media/v4l2-common.h file.
	(x86_list): Add KVM_GET_MSR_FEATURE_INDEX_LIST.

2018-04-01  Eugene Syromyatnikov  <evgsyr@gmail.com>

	util.c: amend sprinttime_ex description a bit.
	* util.c (sprinttime_ex): Document return value.

	tests/bpf.c: add a check for NULL bpf_attr pointer.
	* tests/bpf.c (main): Add a check with 0 passed in the third argument.

2018-04-01  Eugene Syromyatnikov  <evgsyr@gmail.com>

	bpf: print byte range for extra data.
	As it could be not entirely clear what bytes are printed.

	* bpf.c (decode_attr_extra_data): Print a comment about the byte range
	to be printed.
	* tests/bpf.c: Update expected output.

2018-04-01  Eugene Syromyatnikov  <evgsyr@gmail.com>

	Remove addflags.
	It has only single user and implementation of xlat styles for it would
	lead to lots of code duplication.

	* defs.h (addflags): Remove declaration.
	* mem.c (print_mmap_flags): Convert addflags call into printflags64 with
	non-zeroeness flags check.
	* xlat.c (addflags): Remove.

2018-04-01  Dmitry V. Levin  <ldv@altlinux.org>

	Add i18n support.
	Let's make a step towards the growing strace userbase all around
	the world and translate something to the language of their choice.

	This change enables translation of error messages corresponding
	to errno codes, making it consistent with error diagnostics of other
	i18n-aware tools, e.g.

	$ LANG=es_ES strace -qq -a38 -P /missing unlink /missing
	unlink("/missing")                    = -1 ENOENT (No existe el fichero o el directorio)
	unlink: no se puede deshacer el enlace '/missing': No existe el fichero o el directorio

	* strace.c: Include <locale.h>.
	(main): Invoke setlocale.
	* tests/init.sh: Export LC_ALL=C.
	* NEWS: Mention this enhancement.

2018-03-29  Dmitry V. Levin  <ldv@altlinux.org>

	Remove RVAL_PRINT_ERR_VAL.
	* defs.h (RVAL_PRINT_ERR_VAL): Remove.
	* ldt.c (SYS_FUNC(modify_ldt)): Return 0.
	* syscall.c (syscall_exiting_trace): When printing an error,
	always print struct tcb.u_rval as if RVAL_PRINT_ERR_VAL was set.

2018-03-29  Dmitry V. Levin  <ldv@altlinux.org>

	Treat RVAL_DECIMAL the same way as RVAL_UDECIMAL.
	Assuming that syscalls may return negative values only as error codes,
	always print non-error syscall return codes as unsigned.

	* defs.h (RVAL_UDECIMAL): Remove.
	(RVAL_DECIMAL): Rename to RVAL_UDECIMAL.
	* syscall.c (syscall_exiting_trace) <case RVAL_DECIMAL>: Remove.
	* clone.c (SYS_FUNC(fork)): Remove RVAL_UDECIMAL.
	* lseek.c (SYS_FUNC(lseek)): Likewise.
	* prctl.c (SYS_FUNC(prctl)): Likewise.
	* uid.c (SYS_FUNC(getuid), SYS_FUNC(setfsuid)): Likewise.
	* times.c (SYS_FUNC(times)): Always return 0.
	* tests/inject-nf.c (main): Update expected output.

2018-03-29  Dmitry V. Levin  <ldv@altlinux.org>

	tests: check handling of some invalid delay injection parameters.
	* tests/qual_inject-syntax.test: Check for negative delay injection
	parameters.  Check for overriding delay injection parameters.

2018-03-29  Eugene Syromyatnikov  <evgsyr@gmail.com>

	Implement injection of negative return values.
	Extend the range of injected return value to the maximum, print warnings
	if negative injection value can be clipped in compat personality or can
	inadvertently turn into a fault injection.

	* defs.h (INJECT_F_ERROR): New macro.
	* filter_qualify.c (parse_inject_token): Revert type of intval local
	variable back to int, check INJECT_F_ERROR along with INJECT_F_RETVAL,
	use strtoull to parse retval argument, print warnings in case of retval
	clipping and inadvertent fault injection.
	(qualify_inject_common): Set INJECT_F_ERROR instead of INJECT_F_RETVAL.
	* syscall.c (tamper_with_syscall_exiting): Check inject_data.flags
	to determine whether a fault injection or retval injection has to be
	performed.
	(syscall_exiting_trace) <case RVAL_DECIMAL>: Explicitly print
	tcp->u_rval as int if current_klongsize < sizeof(tcp->u_rval).
	* tests/inject-nf.c (main): Update.
	* tests/inject-nf.test: Test injection of negative return values.
	* tests/qual_inject-syntax.test: Remove retval=-1 check as it is now
	allowed, add checks for invalid retval parameters.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-28  Dmitry V. Levin  <ldv@altlinux.org>

	arch_defs.h: fix typo in comment.

	Move delay interface from defs.h to delay.h.
	* defs.h (alloc_delay_data, fill_delay_data, is_delay_timer_armed,
	delay_timer_expired, arm_delay_timer, delay_tcb): Move...
	* delay.h: ... to new file.
	* Makefile.am (strace_SOURCES): Add it.
	* filter_qualify.c: Include it.
	* strace.c: Likewise.
	* syscall.c: Likewise.

2018-03-28  Dmitry V. Levin  <ldv@altlinux.org>

	Turn struct inject_data.rval into an index.
	Add one level of indirection to decrease the size of struct inject_data
	as hundreds of these structures are created for each process when
	injection mechanism is activated.

	* retval.h: New file.
	* retval.c: Likewise.
	* Makefile.am (strace_SOURCES): Add them.
	* defs.h (struct inject_data): Replace rval field with rval_idx.
	* filter_qualify.c: Include "retval.h".
	(parse_inject_token, qualify_inject_common): Initialize
	struct inject_data.rval_idx using retval_new.
	* syscall.c: Include "retval.h".
	(tamper_with_syscall_exiting): Obtain the value that has to be injected
	using retval_get.

2018-03-27  Dmitry V. Levin  <ldv@altlinux.org>

	defs.h: update comment.
	* defs.h (struct inject_data): Update comment about flags.

	Complements: v4.21-108-gba8e768 ("Implement delay injection")

2018-03-27  Eugene Syromyatnikov  <evgsyr@gmail.com>

	xlat: cleanup mmap_flags.in.
	* xlat/mmap_flags.in (_MAP_NEW): Remove SunOS-specific comment, add
	a comment that this is a SPARC-specific constant (from
	arch/sparc/include/uapi/asm/mman.h).
	(MAP_GROWSUP): IA-64-specific constant (from
	arch/ia64/include/uapi/asm/mman.h).
	(MAP_INHERIT): Add a comment that this is a SPARC-specific constant
	(from arch/sparc/include/uapi/asm/mman.h).
	(_MAP_INHERIT): Add a comment that this is an Alpha-specific constant
	(from arch/alpha/include/uapi/asm/mman.h).
	(MAP_ANON): Remove, FreeBSD-specific constant.
	(MAP_HASSEMAPHORE): Rename to...
	(_MAP_HASSEMAPHORE): ...this, add a comment that this is an
	Alpha-specific constant (from arch/alpha/include/uapi/asm/mman.h).
	(MAP_NOSYNC, MAP_NOCORE): Remove.
	(MAP_AUTOGROW, MAP_AUTORSRV, MAP_LOCAL): Add a comment that this is
	an architecture-specific constant (from
	arch/mips/include/uapi/asm/mman.h, arch/xtensa/include/uapi/asm/mman.h).
	(_MAP_UNALIGNED): Add a comment that this is an Alpha-specific constant
	(from arch/alpha/include/uapi/asm/mman.h).

2018-03-27  Eugene Syromyatnikov  <evgsyr@gmail.com>

	tests: check decoding of kern_features syscall.
	* tests/kern_features.c: New file.
	* tests/kern_features-fault.test: New test.
	* tests/gen_tests.in (kern_features): New entry.
	* tests/Makefile.am (DECODER_TESTS): Add kern_features-fault.test.
	* tests/pure_executables.list: Add kern_features.
	* tests/.gitignore: Likewise.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-27  Eugene Syromyatnikov  <evgsyr@gmail.com>

	sparc, sparc64: implement kern_features decoder.
	* sparc.c: New file.
	* Makefile.am (EXTRA_DIST): Add it.
	* linux/sparc/syscallent.h ([340]): Remove NF flag, set kern_features
	decoder.
	* linux/sparc64/syscallent.h ([340]): Likewise.
	* xlat/sparc_kern_features.in: New file.
	* NEWS: Mention this enhancement.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-27  Dmitry V. Levin  <ldv@altlinux.org>

	evdev: move mpers-specific parsers to a separate file.
	This change reduces binary code duplication on mpers platforms
	and prepares evdev parsers to use printxval_bsearch.

	* defs.h (evdev_ioctl, print_evdev_ff_type): New prototypes.
	* evdev.c (evdev_ioctl): Un-mpersify.
	(evdev_write_ioctl) Remove EVIOCSFF case, forward default case
	to evdev_write_ioctl_mpers.
	(decode_envelope, ff_effect_ioctl): Move to...
	* evdev_mpers.c: ... new file.
	* Makefile.am (strace_SOURCES): Add evdev_mpers.c.

2018-03-26  Eugene Syromyatnikov  <evgsyr@gmail.com>

	ci: install libunwind8-dev.
	While in debian/control we use libunwind-dev in Build-Depends, in case
	of ci we have to be more conservative and use the name portable across
	different ci implementations.

	* ci/install-dependencies.sh (common_packages): Add libunwind8-dev.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-23  Eugene Syromyatnikov  <evgsyr@gmail.com>

	tests: check injection of return values into a "never fails" syscall.
	* tests/inject-nf.c: New file.
	* tests/inject-nf.test: New test.
	* tests/.gitignore: Add inject-nf.
	* tests/Makefile.am (check_PROGRAMS): Likewise.
	(MISC_TESTS): Add inject-nf.test.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-23  Dmitry V. Levin  <ldv@altlinux.org>

	Introduce raw syscall invocation wrappers.
	Unfortunately, syscall(3) provided by libc is too smart
	for some of our needs.

	* linux/raw_syscall.h: New file.
	* linux/aarch64/raw_syscall.h: Likewise.
	* linux/alpha/raw_syscall.h: Likewise.
	* linux/arc/raw_syscall.h: Likewise.
	* linux/arm/raw_syscall.h: Likewise.
	* linux/avr32/raw_syscall.h: Likewise.
	* linux/bfin/raw_syscall.h: Likewise.
	* linux/hppa/raw_syscall.h: Likewise.
	* linux/i386/raw_syscall.h: Likewise.
	* linux/ia64/raw_syscall.h: Likewise.
	* linux/m68k/raw_syscall.h: Likewise.
	* linux/metag/raw_syscall.h: Likewise.
	* linux/microblaze/raw_syscall.h: Likewise.
	* linux/mips/raw_syscall.h: Likewise.
	* linux/nios2/raw_syscall.h: Likewise.
	* linux/or1k/raw_syscall.h: Likewise.
	* linux/powerpc/raw_syscall.h: Likewise.
	* linux/powerpc64/raw_syscall.h: Likewise.
	* linux/riscv/raw_syscall.h: Likewise.
	* linux/s390/raw_syscall.h: Likewise.
	* linux/s390x/raw_syscall.h: Likewise.
	* linux/sh/raw_syscall.h: Likewise.
	* linux/sh64/raw_syscall.h: Likewise.
	* linux/sparc/raw_syscall.h: Likewise.
	* linux/sparc64/raw_syscall.h: Likewise.
	* linux/tile/raw_syscall.h: Likewise.
	* linux/x32/raw_syscall.h: Likewise.
	* linux/x86_64/raw_syscall.h: Likewise.
	* linux/xtensa/raw_syscall.h: Likewise.
	* Makefile.am (EXTRA_DIST): Add them.

2018-03-23  Dmitry V. Levin  <ldv@altlinux.org>

	tests: fix potentially unbound variable in kernel_version_code.
	Fix the following use case:

		$ sh -uc '. tests/init.sh; kernel_version_code 4.5'
		tests/init.sh: line 242: 3: unbound variable

	* tests/init.sh (kernel_version_code): Fix potentially unbound variable.

2018-03-23  Dmitry V. Levin  <ldv@altlinux.org>

	strace: further optimize unblocking of the delay signal handler.
	Do not unblock the delay signal handler unless the delay timer is armed.

	* defs.h (is_delay_timer_created): Remove.
	(is_delay_timer_armed, delay_timer_expired): New prototypes.
	* delay.c (delay_timer_is_armed): New static variable.
	(is_delay_timer_created): Add static qualifier.
	(is_delay_timer_armed, delay_timer_expired): New functions.
	(arm_delay_timer): Set delay_timer_is_armed.
	* strace.c (next_event): Use is_delay_timer_armed instead of
	is_delay_timer_created to check whether the delay signal handler
	has to be unblocked.
	(timer_sighandler): Invoke delay_timer_expired.

2018-03-23  Dmitry V. Levin  <ldv@altlinux.org>

	strace: rewrite restart error handling without sigsetjmp/siglongjmp.
	Further simplify and optimize error handling of the delay signal handler
	by replacing sigsetjmp/siglongjmp mechanism with an error flag.

	* strace.c: Do not include <setjmp.h>.
	(restart_failed): New volatile variable.
	(timer_jmp_buf): Remove.
	(next_event): Cache is_delay_timer_created() return value,
	remove sigsetjmp invocation, check restart_failed instead.
	(timer_sighandler): Replace siglongjmp with setting restart_failed.

2018-03-23  Dmitry V. Levin  <ldv@altlinux.org>

	strace: do not call sigsetjmp without a delay timer.
	As sigsetjmp costs a syscall, do not call it unless a delay timer
	is already created and its signal handler is going to be unblocked.

	* strace.c (next_event): Move sigsetjmp invocation under
	is_delay_timer_created() condition.

	Optimizes: v4.21-108-gba8e768 ("Implement delay injection")

2018-03-22  Eugene Syromyatnikov  <evgsyr@gmail.com>

	tests/bpf.c: convert TEST_BPF_ macro to a function.
	As it looks like there's no compelling reason to keep it as a macro and
	leaving it so quite complicates modification of the routine and makes
	them error-prone.

	* tests/bpf.c (TEST_BPF_): Convert it to...
	(test_bpf): ...this.  Rename cmd_ to cmd, cmd_str_ to cmd_str,
	init_first_ to init_first, print_first_ to print_first, init_attr_
	to init_attr, print_attr_ to print_attr.
	(TEST_BPF): Call test_bpf_ instead of TEST_BPF_.

2018-03-22  Eugene Syromyatnikov  <evgsyr@gmail.com>

	tests: btrfs.c whitespace cleanup.
	* tests/btrfs.c: Add spaces after PRI* format specifiers.

2018-03-22  Elvira Khabirova  <lineprinter@altlinux.org>

	tests: check delay injection.
	* tests/delay.c: New file.
	* tests/delay.test: New test.
	* tests/.gitignore: Add delay.
	* tests/Makefile.am (check_PROGRAMS): Likewise.
	(delay_LDADD): New variable.
	(MISC_TESTS): Add delay.test.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-22  Elvira Khabirova  <lineprinter@altlinux.org>

	Implement delay injection.
	Add -e inject=SET:delay_enter= and -e inject=SET:delay_exit= options.

	* configure.ac (AC_SEARCH_LIBS): Check for timer_create -lrt.
	* delay.c: New file.
	* Makefile.am (strace_SOURCES): Add it.
	(strace_LDADD): Add $(timer_LIBS).
	* defs.h (INJECT_F_DELAY_ENTER, INJECT_F_DELAY_EXIT,
	TCB_INJECT_DELAY_EXIT, TCB_DELAYED, inject_delay_exit, syscall_delayed):
	New macros.
	(alloc_delay_data, fill_delay_data, is_delay_timer_created,
	arm_delay_timer, delay_tcb): New prototypes.
	(struct inject_data): Replace reserved field with delay_idx.
	(struct tcb): Add delay_expiration_time field.
	* filter_qualify.c (parse_delay_token): New function.
	(parse_inject_token): Use it.
	(qualify_inject_common): Initialize struct inject_opts.data.delay_idx.
	* strace.c: Include <setjmp.h>
	(timer_jmp_buf, timer_set): New static variables.
	(timer_sighandler, restart_delayed_tcb, restart_delayed_tcbs): New
	functions.
	(init): Block SIGALRM, set SIGALRM handler.
	(dispatch_event): Do not restart delayed syscalls.
	(next_event): Unblock SIGALRM during wait4 invocation.
	* syscall.c (tamper_with_syscall_entering): Arm delay timer if
	INJECT_F_DELAY_ENTER injection flag is set, set TCB_INJECT_DELAY_EXIT
	flag if INJECT_F_DELAY_EXIT injection flag is set.
	tamper_with_syscall_exiting): Arm delay timer if inject_delay_exit.
	(syscall_exiting_trace): Call tamper_with_syscall_exiting in case of
	inject_delay_exit.
	(syscall_exiting_finish): Clear TCB_INJECT_DELAY_EXIT flag.
	* strace.1.in: Document delay injection.
	* NEWS: Mention this improvement.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-22  Dmitry V. Levin  <ldv@altlinux.org>

	Do not block handled signals in interactive mode.
	Let these signals be handled asynchronously as they are acted on
	only when waiting for process state changes.

	* strace.c (start_set, blocked_set): Remove.
	(set_sighandler): Do not update blocked_set.
	(startup_attach, init, next_event): Remove all sigprocmask calls.

2018-03-21  Eugene Syromyatnikov  <evgsyr@gmail.com>

	bpf: improve handling of various sizes of bpf_prog_attr structure.
	As program attributes have been added gradually over kernel versions,
	attribute size less than expected should be printed accordingly.

	* bpf.c (DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)): Do not print structure
	fields if their size is less than the initially introduced (in Linux
	commit v3.18-rc1~52^2~1^2~7) version.  Print fields of union bpf_attr
	introduced in various kernel versions when the length is big enough
	(new fields were introduced in Linux commits v3.18-rc1~52^2~1^2~4,
	v4.1-rc1~84^2~50, and v4.12-rc2~34^2~29^2~2).
	* tests/bpf.c (print_BPF_PROG_LOAD_first): Update expected output.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-20  Eugene Syromyatnikov  <evgsyr@gmail.com>

	btrfs: print struct btrfs_ioctl_logical_ino_args.reserved if non-zero.
	* btrfs.c (btrfs_ioctl) <case BTRFS_IOC_LOGICAL_INO>: Print
	struct btrfs_ioctl_logical_ino_args.reserved field if it is not zero.
	* tests/btrfs.c (btrfs_test_ino_path_ioctls): Check it.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-20  Eugene Syromyatnikov  <evgsyr@gmail.com>

	Move is_filled and IS_ZERO to macros.h, rename IS_ZERO to IS_ARRAY_ZERO.
	* s390.c: Replace all IS_ZERO invocations with IS_ARRAY_ZERO.
	(is_filled, IS_ZERO): Move...
	* macros.h: ...here.
	(is_filled): Add inline qualifier, add const qualifier to ptr.
	(IS_ZERO): Rename to IS_ARRAY_ZERO, cast arr_ to "const char *".

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-20  Dmitry V. Levin  <ldv@altlinux.org>

	mpers.m4: enhance workaround for missing gnu/stubs-*.h files.
	Make generated empty gnu stub files available for mpers_test.sh check.

	* m4/mpers.m4 (st_MPERS): Add $IFLAG to CPPFLAGS for mpers_test.sh
	invocation.

	Complements: v4.11~223 ("mpers.m4: workaround missing gnu/stubs-*.h files")

2018-03-20  Eugene Syromyatnikov  <evgsyr@gmail.com>

	README.md: add references to binary strace packages.
	* README.md: Add references to binary strace packages in OBS,
	Fedora rawhide, and Sisyphus.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-20  Eugene Syromyatnikov  <evgsyr@gmail.com>

	INSTALL-git.md: enhance phrasing.
	* INSTALL-git.md: Enhance phrasing.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-20  Dmitry V. Levin  <ldv@altlinux.org>

	bootstrap: distribute README.
	* bootstrap: Install README before invoking autoreconf to get README
	included into distributed tarball.

	Fixes: v4.21-93-g4bb8454 ("Move README to dist subdirectory")

2018-03-20  Dmitry V. Levin  <ldv@altlinux.org>

	Replace struct timeval with struct timespec in time measurements.
	This is required to implement more precise time measurements.

	* Makefile.am (strace_LDADD): Add $(clock_LIBS).
	* defs.h (struct tcb): Change the type of stime, dtime, and etime fields
	from struct timeval to struct timespec, all users updated.
	(syscall_exiting_decode, syscall_exiting_trace, count_syscall): Change
	the type of "struct timeval *" argument to "struct timespec *", all
	users updated.
	(tv_nz, tv_cmp, tv_float, tv_add, tv_sub, tv_div, tv_mul): Rename to
	ts_nz, ts_cmp, ts_float, ts_add, ts_sub, ts_div, and ts_mul.  Change
	the type of all "struct timeval *" arguments to "struct timespec *",
	all users updated.
	* util.c (tv_nz, tv_cmp, tv_float, tv_add, tv_sub, tv_div, tv_mul):
	Rename to ts_nz, ts_cmp, ts_float, ts_add, ts_sub, ts_div, and ts_mul.
	Change the type of all "struct timeval *" arguments to "struct timespec *".
	* count.c (struct call_counts): Change the type of "time" field
	from struct timeval to struct timespec, all users updated.
	(overhead): Change type from struct timeval to struct timespec, all
	users updated.
	(count_syscall): Change the type of "struct timeval *" argument to
	"struct timespec *".
	* strace.c (printleader): Change the type of struct timeval variables
	to struct timespec, call clock_gettime instead of gettimeofday.
	(next_event, trace_syscall): Change the type of struct timeval variables
	to struct timespec.
	* syscall.c (syscall_entering_finish, syscall_exiting_decode): Call
	clock_gettime instead of gettimeofday.

2018-03-20  Dmitry V. Levin  <ldv@altlinux.org>

	Fix -O option handling.
	Fast syscalls usually take less than a microsecond of system cpu time
	nowadays, making -O option almost useless.

	* count.c (call_summary_pers): Avoid negative time counts.
	* tests/count.test: Check it.
	* NEWS: Mention it.

2018-03-16  Dmitry V. Levin  <ldv@altlinux.org>

	count: cleanup count_syscall.
	* count.c (shortest): Remove.
	(overhead): Initialize to zero.
	(call_summary_pers): Remove shortest handling.
	(count_syscall): Remove dead code.  The remaining code does the same
	wrong calculations as before the change, though.

	printleader: cleanup tflag handling.
	* strace.c (printleader): Move declarations of variables closer
	to their first use.

2018-03-16  Dmitry V. Levin  <ldv@altlinux.org>

	Move install.texi to maint subdirectory.
	This file comes from GNU Autoconf and is used to generate INSTALL file.

	* install.texi: Move...
	* maint/install.texi: ...here.

2018-03-16  Eugene Syromyatnikov  <evgsyr@gmail.com>

	doc: update commit requirements.
	* README-hacking (Requirements): Enhance phrasing.
	(Commit log requirements): Rename to "Commit requirements",
	describe "absence of whitespace errors" requirement, add references
	to the Linux kernel coding style and scripts/checkpatch.pl script.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>

2018-03-16  Eugene Syromyatnikov  <evgsyr@gmail.com>

	Move README to dist subdirectory.
	README was originally written for users of distribution tarballs.
	Nowadays it appears to be confusing for those who build strace
	using a GIT version of strace source code.

	* README: Move...
	* dist/README: ...here.
	* bootstrap: Copy README from dist subdirectory to the toplevel
	directory after successful autoreconf.

	Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
	References: https://github.com/strace/strace/issues/56

2018-03-15  Eugene Syromyatnikov  <evgsyr@gmail.com>

	README: synchronise with README.md.
