Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > 9ed6f1468be018392a0217a82dc5753e > files > 6

strace-4.9-4.mga5.x86_64.rpm

2014-08-15  Dmitry V. Levin  <ldv@altlinux.org>

	Prepare for 4.9 release.
	* NEWS: Update for 4.9 release.
	* debian/changelog: 4.9-1.
	* strace.spec: 4.9-1.

	Sync strace.spec and debian/ with packages.
	* debian/changelog: Sync with 4.8-1.1.
	* debian/control: Likewise.
	* debian/rules: Likewise.
	* strace.spec: Sync with 4.8-5.

	NEWS: Update for 4.9 release.

2014-08-15  Mike Frysinger  <vapier@gentoo.org>

	Update syscall tables to the point where they include renameat2.
	* linux/dummy.h: Add printargs aliases for sys_sched_getattr and
	sys_sched_setattr.
	* linux/aarch64/syscallent1.h: Add kcmp/finit_module/sched_setattr/
	sched_getattr/renameat2.
	* linux/alpha/syscallent.h: Add kcmp/finit_module.
	* linux/arm/syscallent.h: Add sched_setattr/sched_getattr/renameat2.
	* linux/hppa/syscallent.h: Add sched_setattr/sched_getattr/utimes/renameat2.
	* linux/i386/syscallent.h: Add sched_setattr/sched_getattr/renameat2.
	* linux/ia64/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent-n32.h: Likewise.
	* linux/mips/syscallent-n64.h: Add getdents64/sched_setattr/sched_getattr/
	renameat2.
	* linux/mips/syscallent-o32.h: Add sched_setattr/sched_getattr/renameat2.
	* linux/powerpc/syscallent.h: Fix finit_module/kcmp order.  Add sched_setattr/
	sched_getattr/renameat2.
	* linux/s390/syscallent.h: Add sched_setattr/sched_getattr/renameat2.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/x32/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/xtensa/syscallent.h: Add sched_setattr/sched_getattr.

	renameat2: add decoding support.
	* file.c (decode_renameat, sys_renameat2): New functions.
	(sys_renameat): Use decode_renameat.
	* pathtrace.c (pathtrace_match): Handle sys_renameat2.
	* linux/syscall.h (sys_renameat2): New prototype.
	* xlat/rename_flags.in: New file.

2014-08-14  Mike Frysinger  <vapier@gentoo.org>

	CREDITS: fix generation in out of tree builds.
	The {...} code changes the working dir with `cd`, but the commands outside
	of that block expects to be in the original dir.  Change to a subshell so
	the path outside of this block remains unchanged.

	* Makefile.am ($(srcdir)/CREDITS): Change {...} to (...).

	ia64: add missing syscalls.
	When the preadv/pwritev syscalls were added, the ones before it in the
	ia64 list were missed, so all the syscalls there and later were not in
	the right location (causing things to be decoded incorrectly).

	Add the missing syscalls before preadv which also re-aligns all the
	syscalls after that point.  This fixes the uio.test.

	* linux/ia64/syscallent.h: Add syscalls 1310 through 1318.

	ia64: fix sigaction decoding.
	Looks like ia64 doesn't have sa_restorer either, yet still defines
	SA_RESTORER.  Deploy the same trick that HPPA is using to make the
	test pass.

	* signal.c (SA_RESTORER): Undefine when IA64 is defined.
	(struct new_sigaction) [IA64]: Disable sa_restorer.

2014-08-12  Dmitry V. Levin  <ldv@altlinux.org>

	tests: skip detach-stopped.test when PTRACE_SEIZE doesn't work.
	detach-stopped.test is known to fail when PTRACE_SEIZE is not available,
	so skip the test in that case.

	* tests/detach-stopped.test: Check for "strace -d" output and skip the
	test when it says that PTRACE_SEIZE doesn't work.

2014-08-11  Erik Johansson  <erik@ejohansson.se>

	sh: fix syscall numbering for recv and sendto.
	* linux/sh/syscallent.h: Swap recv and sendto syscall entries.

2014-08-11  Mike Frysinger  <vapier@gentoo.org>

	tests: fix uio building w/out preadv/pwritev.
	The preadv/pwritev symbols weren't added to glibc until the 2.10 release,
	so trying to build the uio test leads to link failures.  Add configure
	tests and update uio.test to handle this.

	* configure.ac (AC_CHECK_FUNCS): Add preadv/pwritev.
	* tests/uio.c: Include config.h.
	(main): Check for HAVE_PREADV and HAVE_PWRITEV.
	* tests/uio.test: Check exit status of uio helper.

	tests: ignore *.tmp files.
	The tests like to generate random .tmp files, so ignore them.

	* tests/.gitignore: Add *.tmp.

	tests: fix shell errors in detach tests.
	The current detach test code does:
		set -e
		...
		cleanup() {
			set +e
			kill ...
			wait ...
		}
		...
		cleanup
		exit 0

	The problem is that while `set -e` is disabled for the body of the
	cleanup function, it isn't necessarily disabled in the caller scope.
	So if the return value of the cleanup function (`wait` in this case)
	is non-zero, the script ends up failing overall.

	Add an explicit return 0 to the cleanup function so that we don't kill
	the overall test pipeline.

	* tests/detach-running.test (cleanup): Add return 0.
	* tests/detach-sleeping.test (cleanup): Likewise.
	* tests/detach-stopped.test (cleanup): Likewise.

	set_ptracer_any: add a little documentation.
	This way I don't have to keep reading up on these options and wondering
	why the code isn't aborting when the call fails.

	* tests/set_ptracer_any.c (main): Note prctl failures are ok.

2014-08-10  Mike Frysinger  <vapier@gentoo.org>

	signal: fix thinko in sa_restorer.
	Previous commit here re-added the bugs trying to be fixed due to a
	logic thinko.  The patches were tested in isolation and hand merged
	later.  Oops.

	* signal.c (struct new_sigaction): Change || to &&.

2014-08-09  Mike Frysinger  <vapier@gentoo.org>

	sigaction test: support arches w/out SA_RESTORER and swapped args.
	Running Linux 3.15 (sparc64) and glibc 2.17 (sparc32) triggers a
	rt_sigaction call that does not use SA_RESTORER and has an order
	where it inserts a restorer and a size.  The current tests don't
	support that ordering, so add another regex.

	* tests/sigaction.awk: Support no SA_RESTORER and swapped args.

	alpha/sparc: fix arg count for rt_sigaction.
	Both these arches have a rt_sigaction syscall that takes 5 args, not 4.

	* linux/alpha/syscallent.h (rt_sigaction): Change nargs to 5.
	* linux/sparc/syscallent.h (rt_sigaction): Change nargs to 5.

	hppa: fix sigaction decoding.
	Since the rt_sigaction syscall on hppa doesn't have a sa_restorer,
	do not include it in the kernel struct.

	We also have to undefine SA_RESTORER so that code doesn't try to
	use it.  The headers will export this, but the syscall doesn't
	actually respect it.

	* signal.c (SA_RESTORER): Undefine when HPPA is defined.
	(struct new_sigaction): Disable sa_restorer on hppa.

	alpha: fix sigaction decoding.
	Since the rt_sigaction syscall on alpha doesn't have a sa_restorer,
	do not include it in the kernel struct.

	* signal.c (struct new_sigaction): Disable sa_restorer on alpha.

2014-08-08  Dmitry V. Levin  <ldv@altlinux.org>

	Prepare for -yy option support.
	* defs.h (show_fd_path): Change type to unsigned int.
	* strace.c (show_fd_path): Likewise.
	(init): Handle repeated -y option.

2014-08-07  Dmitry V. Levin  <ldv@altlinux.org>

	Fix preadv/pwritev offset decoding on ILP32 architectures.
	This fixes regression introduced by the previous commit.

	* io.c (print_llu_from_low_high_val) [SIZEOF_LONG != SIZEOF_LONG_LONG]:
	Cast argument to unsigned long before casting it to unsigned long long.

	Fix preadv/pwritev offset decoding on bigendian architectures.
	This partially reverts commit 7845a42b39e59e904d01e75e21f7bc7eb6462560.

	* util.c (printllval): Remove align argument.
	* defs.h (printllval): Update prototype.
	(printllval_aligned, printllval_unaligned): Remove.
	* file.c (sys_readahead, sys_truncate64, sys_ftruncate64, sys_fadvise64,
	sys_fadvise64_64, sys_sync_file_range, sys_sync_file_range2,
	sys_fallocate): Replace printllval_aligned call with printllval.
	* io.c (sys_pread, sys_pwrite): Likewise.
	(print_llu_from_low_high_val): New function.
	(sys_preadv, sys_pwritev): Use it instead of printllval_unaligned.

2014-08-06  Dmitry V. Levin  <ldv@altlinux.org>

	Decode file descriptors returned by accept and accept4 syscalls.
	* net.c (do_accept): Rename to do_sockname.
	(sys_accept, sys_accept4): Update callers, return RVAL_FD.
	(sys_getsockname, sys_getpeername): Call do_sockname directly.
	* tests/net-fd.test: Update.

2014-08-01  Mike Frysinger  <vapier@gentoo.org>

	x32: update io_{setup,submit} syscalls.
	Starting in 3.16, these two syscalls have gotten their own entry
	point for x32.  See linux 7fd44dacdd803c0bbf38bf478d51d280902bb0f1.

	* linux/x32/syscallent.h: Change existing io_{setup,submit} to 64bit,
	and add new entry points for x32 specifically.

2014-06-18  Max Filippov  <jcmvbkbc@gmail.com>

	xtensa: sort values in struct_user_offsets.
	Otherwise ptrace syscall argument decoding is wrong:
	  ptrace(PTRACE_PEEKUSER, 296, syscall_nr, [0x4048eb]) = 0
	  ptrace(PTRACE_PEEKUSER, 296, syscall_nr, [0x3fa6cd30]) = 0
	  ptrace(PTRACE_PEEKUSER, 296, syscall_nr, [0x8040676d]) = 0
	instead of
	  ptrace(PTRACE_PEEKUSER, 296, pc, [0x4048eb]) = 0
	  ptrace(PTRACE_PEEKUSER, 296, a1, [0x3fa6cd30]) = 0
	  ptrace(PTRACE_PEEKUSER, 296, a0, [0x8040676d]) = 0

	* process.c (struct_user_offsets) [XTENSA]: Sort values.

2014-06-18  Dmitry V. Levin  <ldv@altlinux.org>

	Document -k option as experimental.
	strace -k does not produce a reliable output on all supported
	configurations yet, even basic strace-k.test is known to fail
	on some of them.

	* strace.c (usage): Document -k option as experimental.
	* strace.1: Likewise.
	* NEWS: Likewise.

	tests: robustify -k test.
	Split stack-fcall.c into several compilation units so that intermediate
	function calls would not be optimized out by compiler.

	* tests/stack-fcall.c: Move intermediate functions to ...
	* tests/stack-fcall-*.c: ... new files.
	* tests/Makefile.am (stack_fcall_SOURCES): Add stack-fcall-*.c.

2014-06-13  Dmitry V. Levin  <ldv@altlinux.org>

	tests: enhance -k test.
	Add two more function calls to the stack.  Suggested by Masatake YAMATO.

	* tests/stack-fcall.c (f1): Rename to f3.
	(f1, f2): New functions.
	* tests/strace-k.test: Update.

	unwind: ignore memory mappings that have no PROT_EXEC bit set.
	* unwind.c (build_mmap_cache): For each memory mapping being scanned,
	save its PROT_EXEC bit and skip the mapping if it is not set.

	unwind: cleanup build_mmap_cache.
	* unwind.c (build_mmap_cache): Move local variables to the code branch
	where they are used.  Check return code of sscanf and strdup.  Do not
	treat unusual memory mappings as fatal errors.  Do not skip memory
	mappings with path names starting with "[".

	unwind: remove unused field from mmap_cache_t.
	* unwind.c (mmap_cache_t): Remove "deleted" field.
	(build_mmap_cache): Remove initialization of "deleted" field.

2014-06-12  Dmitry V. Levin  <ldv@altlinux.org>

	unwind: refactor stacktrace_walk.
	* unwind.c (stacktrace_walk): Move stack frame printing code
	to separate function print_stack_frame.

	unwind: constify binary_filename and symbol_name functions arguments.
	* unwind.c (call_action_fn, print_call_cb, sprint_call_or_error,
	queue_put, queue_put_call): Add const qualifier to binary_filename and
	symbol_name arguments.

2014-06-11  Luca Clementi  <luca.clementi@gmail.com>

	unwind: disable stack trace with multiple personalities.
	* unwind.c (unwind_cache_invalidate, unwind_print_stacktrace,
	unwind_capture_stacktrace): Disable stack tracing of non-default
	personality processes.

2014-06-05  Dmitry V. Levin  <ldv@altlinux.org>

	unwind: rename function_off_set to function_offset.
	* unwind.c (call_action_fn, stacktrace_walk, STACK_ENTRY_SYMBOL_FMT,
	print_call_cb, sprint_call_or_error, queue_put, queue_put_call):
	Rename function_off_set to function_offset.

	unwind: fix a bug in range updating of binary search.
	* unwind.c (print_stacktrace): Fix another off-by-one error in binary search.

	unwind: use fopen64 instead of fopen.
	* unwind.c (fopen_for_input): Define to fopen64 iff
	[_LARGEFILE64_SOURCE && HAVE_FOPEN64], otherwise define it to fopen.
	(build_mmap_cache): Use fopen_for_input instead of fopen.

	unwind: fix build on 32-bit architectures.
	Fix compilation warnings in unwind.c on 32-bit architectures.
	On some architectures getuid is actually getuid32, so change the test
	to use getpid instead of getuid.

	* unwind.c (STACK_ENTRY_SYMBOL_FMT): Explicitly cast function_off_set
	to unsigned long.
	(queue_put_error): Change the 3rd argument's type to unsigned long.
	* tests/stack-fcall.c (f1): Use getpid instead of getuid.
	* tests/strace-k.test: Likewise.

	tests: robustify -w option test.
	* tests/count.test: Allow nanosleep to spend a bit less time than 1 second.

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

	Fix delete_module decoding.
	* xlat/delete_module_flags.in: New file.
	* file.c (sys_delete_module): Move ...
	* bjm.c (sys_delete_module): ... to here.
	Decode 1st argument using printstr instead of printpath.
	* NEWS: Mention it.

2014-06-04  Zubin Mithra  <zubin.mithra@gmail.com>

	Decode paths associated with file descriptors returned by syscalls.
	* defs.h (RVAL_FD): New macro.
	(RVAL_MASK, RVAL_STR, RVAL_NONE): Update.
	* desc.c (sys_dup, sys_delete_module): New functions.
	(do_dup2, decode_open, sys_creat): Change return value to RVAL_FD.
	* linux/dummy.h (sys_delete_module, sys_dup): Remove.
	* linux/syscall.h (sys_delete_module, sys_dup): New prototypes.
	* syscall.c (trace_syscall_exiting): Handle RVAL_FD.

2014-06-03  Dmitry V. Levin  <ldv@altlinux.org>

	NEWS: Prepare for 4.9 release.

	Warn about flags that have no effect with -c.
	* strace.c (init): Issue a warning if -i, -k, -r, -t, -T, or -y is used
	along with -c.
	This fixes Debian bug #443895.

	debian: enable security hardening features.
	* debian/rules: Follow the advice in https://wiki.debian.org/Hardening
	and enable maximum hardening as for programs that handle untrusted data.
	Patch by Markus <waldeck@gmx.de>.

	debian: update control file.
	* debian/control (strace64): Fix a typo in package description.
	Patch by Pascal De Vuyst <pascal.devuyst@gmail.com>.
	(strace, strace-udeb): Add x32 to architecture list.
	Patch by Guillaume Morin <guillaume@morinfr.org>.
	(strace, strace-udeb): Add or1k to architecture list.
	Patch by Christian Svensson <debian@cmd.nu>.
	(strace, strace-udeb): Add arm64 to architecture list,
	and remove defunct arm.
	Patch by Wookey <wookey@debian.org>.

	This fixes Debian bugs: #697625, #727018, #742235, #749956.

	manpage: minor corrections.
	$ groff -ww -mandoc -z strace.1
	strace.1:65: warning: macro `IX' not defined

	* strace.1: define IX macro as empty for groff.
	Change remaining '-' as minus to '\-'.
	Have two word spaces after a full stop as an end of sentence.
	Use extra space ('\,' or '\/') between roman and italic characters.
	Based on patch by Bjarni Ingi Gislason <bjarniig@rhi.hi.is>.
	This fixes Debian bug #725987.

2014-05-30  Masatake YAMATO  <yamato@redhat.com>

	unwind: tests: add a test for -k option.
	* tests/stack-fcall.c: New test target.
	* tests/strace-k.test: New test driver.
	* tests/Makefile.am (check_PROGRAMS): Add stack-fcall.
	(TESTS): Add strace-k.test.
	* tests/.gitignore: Add stack-fcall.

	unwind: move stacktrace capturing and mmap cache invalidating to trace_syscall_entering
	Instead of handling stacktrace capturing and mmap cache invalidating in
	sys_* functions, handle them uniformly in trace_syscall_entering using
	new flags introduced by previous two commits.

	The patch is simpler than its older version(v3).  The value of
	hide_log_until_execve is just ignored.  I found the value is nothing
	to do with this patch.  unwind_cache_invalidate is mentioned only
	once in trace_syscall_exiting.
	Both are suggested by Dmitry Levin.

2014-05-30  Dmitry V. Levin  <ldv@altlinux.org>

	unwind: add SE and SI flags to syscall entries for all architectures.
	Add SE flag to execve, exit, and exit_group syscall entries.
	Add SI flag to brk, execve, mmap, mprotect, mremap, munmap,
	remap_file_pages, shmat, and shmdt syscall entries.

2014-05-30  Masatake YAMATO  <yamato@redhat.com>

	unwind: introduce markers specifying the needs of special care in unwinding
	Some system calls require capturing the stack trace before they are
	processed in kernel.  Typical one is execve.  Some system calls require
	invalidating mmap cache after they are processed in kernel.

	In current implementation these requirements are handled directly by
	appropriate syscall handlers.  However, it is difficult to keep the
	source code maintainable using this approach to cover all system calls
	which have such requirements.

	A more generic way to implement this is to flag all syscalls that
	require special processing, and handle these flags right in
	trace_syscall_entering instead of changing syscall handlers.

	This patch just defines new flags: STACKTRACE_INVALIDATE_CACHE and
	STACKTRACE_CAPTURE_ON_ENTER.

	The names of macros are suggested by Dmitry Levin.

	unwind: enable dwarf cache of libunwind.
	Here is the benchmark of the dwarf cache.

	Target program:

	    #include <sched.h>
	    int main(void)
	    {
	      unsigned int max = 0x6fff, i;
	      for (i = 0; i < max; i++)
		sched_yield();
	      return 0;
	    }

	Command line:

		./strace -o /dev/null -k a.out

	With the dwarf cache:

	    real	0m12.081s
	    user	0m3.858s
	    sys 	0m8.194s

	Without the dwarf cache:

	    real	0m22.326s
	    user	0m5.218s
	    sys		0m16.952s

	unwind: report expected backtracing error.
	When a file mmap'ed to the target process is unlink'ed, backtracing the
	stack would fail.  Current implementation reports it as
	"backtracing_error".  To avoid confusion, the message is changed to
	"expected_backtracing_error".

	Here is the reproducer:

	  $ cat ./p-deleted.c
	  #include <unistd.h>

	  int main(int argc, char **argv) {
	    return unlink(argv[0]) < 0;
	  }

	  $ strace -e unlink -k ./p-deleted
	  unlink("./p-deleted")                   = 0
	   > /usr/lib64/libc-2.18.so(unlink+0x7) [0xe7f17]
	   > /home/yamato/var/strace/t_unwind/p-deleted (deleted)(+0x0) [0x575]
	   > /usr/lib64/libc-2.18.so(__libc_start_main+0xf5) [0x21d65]
	   > backtracing_error [0x7ffff1365590]
	  +++ exited with 0 +++

	p-deleted is deleted therefore backtracing_error is reported.  This
	patch records the deleted marker when making mmap cache and refers the
	recorded information in the case "backtracing_error" to switch the
	message.

	Here is the output of this patch:

	  $ strace -e unlink -k ./p-deleted
	  unlink("./p-deleted")                   = 0
	   > /usr/lib64/libc-2.18.so(unlink+0x7) [0xe7f17]
	   > /home/yamato/var/strace/t_unwind/p-deleted (deleted)(+0x0) [0x575]
	   > /usr/lib64/libc-2.18.so(__libc_start_main+0xf5) [0x21d65]
	   > expected_backtracing_error [0x7ffff1365590]
	  +++ exited with 0 +++

	This solution is not perfect: if a file is unlink'ed after making the
	mmap cache and before unwinding, strace cannot have a chance to record
	the deleted marker.

	In this version of patch, hardcoded magic number used in comparing "(delete)"
	string is replaced with strlen as suggested by Dmitry Levin.

	In old version of patch, the deleted entry was thrown away from mmap
	cache to avoid to report "backtracing_error".  In this patch I keep it,
	and just switch the error message.
	Inspired by the review comment from Dmitry Levin.

	unwind: call unwind_tcb_fin before printing detached message.
	captured stacktrace is printed in unwind_tcb_fin if tcp->queue is not
	empty.  This should happen before printing detached message, so
	unwind_tcb_fin is moved to the top of droptcb.

	This is implicitly suggested by Dmitry Levin in patch review process.

	unwind: implement automatic mmap cache invalidation.
	A mmap cache belonging to a tcb was updated when a system call which
	changed the memory mapping was called.  This implementation was assumed
	the mapping was changed only by the tcb.  However, this assumption is
	incorrect if the target application is multi-threaded; more than two
	tcbs can shared the same memory mapping and a tcb can modify it without
	being noticed by the others.

	This change introduces a global integer variable mmap_cache_generation,
	and mmap_cache_generation field to struct tcb.  The variable
	is incremented each time a process enters a syscall that can modify its
	memory mapping.  Each tcb records the value of this variable at the
	moment if  building its mmap cache.  Every mmap cache associated with
	the given tcb can be validated by comparing its mmap_cache_generation
	field with the variable mmap_cache_generation.

	This implementation is inefficient.  If strace attaches two processes
	which don't share the memory mapping, rebuilding mmap cache of a tcb
	triggered by another tcb's mmap system call is not necessary.

	unwind: introduce queue_t for capturing stacktrace.
	This is the second step for splitting capturing from printing.

	New `queue' field is added to tcb.  Captured stacktrace is stored here.
	The field is initialized/finalized at unwind_tcb_init/unwind_tcb_fin.

	New API function unwind_capture_stacktrace is added.  This function
	captures the currest stack using stracktrace_walker and records it in
	tcb.  It's printing is delayed to the next call of
	unwind_print_stacktrace.

	unwind_print_stacktrace is extended.  Now it checks queue field of
	the given tcb at the start of function.  If the function finds a
	captured stack trace, the latter is printed using stracktrace_walker.

	Currently unwind_capture_stacktrace invocations are added directly to
	handlers of mmap, munmap, mprotect, and execve.

	Here is the difference of output with/without patch:

	(without patch)
	  execve("./test-fork", ["./test-fork"], [/* 56 vars */]) = 0
	   > /usr/lib64/ld-2.18.so(check_one_fd.part.0+0x82) [0x11f0]

	(with patch)
	  execve("./test-fork", ["./test-fork"], [/* 54 vars */]) = 0
	   > /usr/lib64/libc-2.18.so(execve+0x7) [0xbcd27]
	   > /home/yamato/var/strace/strace(exec_or_die+0x10c) [0x26ac]
	   > /home/yamato/var/strace/strace(startup_child+0x346) [0x134f6]
	   > /home/yamato/var/strace/strace(init+0x89f) [0x13dff]
	   > /home/yamato/var/strace/strace(main+0xa) [0x26ca]
	   > /usr/lib64/libc-2.18.so(__libc_start_main+0xf5) [0x21d65]
	   > /home/yamato/var/strace/strace(_start+0x29) [0x2799]

	In older version output lines of captured elements were built when
	printing.  In this version they are built when capturing the stack.
	As result, unneeded dynamic memory allocations are avoided.
	Suggested by Luca Clementi.

	In older version the combination of snprintf and realloc were used.
	In this version they are replaced with asprintf.
	Suggested by Dmitry Levin.

	unwind: introduce own debug macro.
	* unwind.c (DPRINTF): New macro, to be utilized in debugging cache
	management code.

	unwind: introduce stacktrace_walker.
	In current implementation, the stack trace is captured and printed at
	the same time, in trace_syscall_exiting.  This approach cannot
	provide user expected information when a system call changes the
	memory mapping.  In such cases, the stack trace should be captured on
	entering syscall and printed on exiting.

	As the initial step for splitting capturing from printing, this change
	introduces stacktrace_walker utility function.  It can be used both for
	capturing in trace_syscall_entering and printing in
	trace_syscall_exiting.

	unwind: give all exported functions "unwind_" prefix.
	* unwind.c (init_unwind_addr_space): Rename to unwind_init.
	(init_libunwind_ui): Rename to unwind_tcb_init.
	(free_libunwind_ui): Rename to unwind_tcb_fin.
	(delete_mmap_cache): Rename to unwind_cache_invalidate.
	(print_stacktrace): Rename to unwind_print_stacktrace.
	* defs.h: Update prototypes.
	* mem.c: All callers updated.
	* process.c: Likewise.
	* strace.c: Likewise.
	* syscall.c: Likewise.

	unwind: delete mmap cache in free_libunwind_ui.
	free_libunwind_ui is expected to release all unwind related resources
	attached to tcp.

	* strace.c (droptcb): Move delete_mmap_cache call ...
	* unwind.c (free_libunwind_ui): ... to here.

	unwind: make alloc_mmap_cache function local.
	* defs.h (alloc_mmap_cache): Remove.
	* unwind.c (alloc_mmap_cache): Add static qualifier.

	unwind: fix a bug in range updating of binary search.
	* unwind.c (print_stacktrace): Fix off-by-one error in binary search.

2014-05-30  Luca Clementi  <luca.clementi@gmail.com>

	Add -k option to print stack trace after each syscall.
	Print the stack trace of the traced process after each system call when
	-k option is specified.  It is implemented using libunwind to unwind the
	stack and to obtain the function name pointed by the IP.

	Based on the code that was originally taken from strace-plus
	of Philip J. Guo.

	* configure.ac: Add --with-libunwind option.  Check libunwind support.
	* Makefile.am: Add libunwind support.
	* defs.h (struct tcb) [USE_LIBUNWIND]: Append libunwind specific fields.
	[USE_LIBUNWIND] (stack_trace_enabled, alloc_mmap_cache,
	delete_mmap_cache, print_stacktrace): New prototypes.
	* mem.c (print_mmap, sys_munmap, sys_mprotect): Add libunwind support.
	* process.c (sys_execve): Likewise.
	* strace.c (usage, alloctcb, droptcb, init): Likewise.
	* syscall.c (trace_syscall_exiting): Likewise.
	* unwind.c: New file.
	* strace.1: Document -k option.

2014-05-30  Dmitry V. Levin  <ldv@altlinux.org>

	sysctl: update CTL_*, KERN_*, NET_*, and VM_* constants.
	* configure.ac (AC_CHECK_DECLS): Add CTL_*, KERN_*, NET_*, and
	VM_* constants.
	* system.c (CTL_PROC, CTL_CPU): Remove definitions.
	* xlat/sysctl_*.in: Update.

	Check for constants used by waitid function.
	* configure.ac (AC_CHECK_DECLS): Add P_* constants.

	Check for LO_FLAGS_READ_ONLY constant.
	* configure.ac (AC_CHECK_DECLS): Add LO_FLAGS_READ_ONLY.

	Compress blank lines.
	Suppress empty lines left after automated xlat conversion.

	xlat: cleanup the aftermath of automatic conversion.

	Generate xlat/*.in files.
	Automatically convert xlat structures from *.c files to xlat/*.in files
	using "./generate_xlat_in.sh *.c" command.

	Rename several xlat structures to avoid collisions.
	* bjm.c (which): Rename to qm_which.
	* ipc.c (msg_flags): Rename to ipc_msg_flags.
	* time.c (which): Rename to itimer_which.

	Enhance xlat generator.
	* xlat/gen.sh: Define all xlat structs not declared in defs.h as static.
	Some symbolic constants are not macros, extend #ifdef check to cover
	symbolic constants checked by AC_CHECK_DECLS.
	Handle complex symbolic constants in SYMBOL|... form.
	Handle symbolic constants in 1<<SYMBOL form.
	Handle numeric constants.
	Implement #unconditional directive that turns off preprocessor checks.
	Implement #unterminated directive that turns off adding XLAT_END.

	Use bootstrap script consistently.
	Now that ./xlat/gen.sh has to be run before autoreconf,
	replace all autoreconf calls with ./bootstrap call.

	* bootstrap: Forward arguments to autoreconf.
	* build_static_example.sh: Replace autoreconf call with bootstrap call.
	* make-dist: Likewise.
	* qemu_multiarch_testing/README: Likewise.

2014-05-30  Mike Frysinger  <vapier@gentoo.org>

	Implement xlat generator.
	* bootstrap: New file.
	* xlat/gen.sh: Likewise.
	* Makefile.am: Include xlat/Makemodule.am
	(EXTRA_DIST): Add $(XLAT_INPUT_FILES), $(XLAT_HEADER_FILES), and
	xlat/gen.sh.

2014-05-30  Dmitry V. Levin  <ldv@altlinux.org>

	tests: fix SCM_RIGHTS test for big-endian systems.
	* tests/scm_rights.c (main): Send zero integer to avoid issues with
	endianness.
	* tests/scm_rights-fd.test: Update grep patterns.

	Decode file descriptors passed via SCM_RIGHTS control messages.
	* net.c (printcmsghdr): Print descriptors from SCM_RIGHTS control
	messages using printfd.
	* tests/scm_rights.c: New file.
	* tests/scm_rights-fd.test: New test.
	* tests/Makefile.am (check_PROGRAMS): Add scm_rights.
	(TESTS): Add scm_rights-fd.test.
	* tests/.gitignore: Add scm_rights and uio.

	tests: add a test for -c and -w options.
	* tests/count.test: New test.
	* tests/Makefile.am (TESTS): Add it.

2014-05-29  Mark Hills  <Mark.Hills@framestore.com>

	Optionally produce stats on syscall latency.
	Time spent in system time is not useful where a syscall depends on some
	non-CPU resource, eg. typically open() or stat() to a network drive.

	This patch adds a new flag (-w) to produce a summary of the time
	difference between beginning and end of the system call (ie. latency)

	This functionality has been useful to profile slow processes that
	are not CPU-bound.

2014-05-29  Dmitry V. Levin  <ldv@altlinux.org>

	Constify count_syscall function.
	* count.c (count_syscall): Add const qualifier to timeval argument and
	rename it.  Store the wall clock time spent while in syscall in separate
	timeval variable.
	* defs.h (count_syscall): Update prototype.
	* syscall.c (trace_syscall_exiting): Update count_syscall invocation.

	Constify tv_* functions.
	* defs.h (tv_nz, tv_cmp, tv_float, tv_add, tv_sub, tv_mul, tv_div): Add
	const qualifier to read only arguments.
	* util.c (tv_nz, tv_cmp, tv_float, tv_add, tv_sub, tv_mul, tv_div):
	Likewise.

2014-05-28  Dmitry V. Levin  <ldv@altlinux.org>

	Use printstr for sethostname, setdomainname, and gethostname decoding.
	The argument passed to sethostname and setdomainname syscalls, as well
	as the string returned by gethostname syscall, is not a pathname, so
	printpathn is not the right method for its decoding.

	* process.c (sys_sethostname, sys_setdomainname): Decode 1st argument
	using printstr instead of printpathn.
	[ALPHA] (sys_gethostname): Likewise.

2014-05-21  James Hogan  <james.hogan@imgtec.com>

	Fix {get,set}rlimit decoding with unreliable SIZEOF_RLIM_T.
	When strace is built with large file support definitions in CFLAGS (as
	may be provided by buildroot) the C library headers may expose a 64-bit
	rlim_t even though the struct rlimit fields used by the system call
	interface are only 32-bit.  The SIZEOF_RLIM_T will then be 8 which
	results in bad decoding of the getrlimit and setrlimit syscalls.

	This is fixed by replacing unreliable SIZEOF_RLIM_T based checks with
	checks for current_wordsize.

2014-05-13  Masatake YAMATO  <yamato@redhat.com>

	Enhance setns syscall decoding.
	* process.c (sys_setns): New function.
	Decode the 2nd syscall argument using clone_flags.
	* linux/syscall.h (sys_setns): New prototype.
	* linux/dummy.h (sys_setns): Remove.

2014-05-12  Dmitry V. Levin  <ldv@altlinux.org>

	mips: fix syscall entries that should have TP flag set.

	xtensa: fix unshare syscall entry.

	alpha, hppa, mips n64: fix waitid syscall entry.

	Add TM flag to shmat and shmdt syscall entries.

	Alias sys_vfork to sys_fork.
	* process.c (sys_vfork): Remove.
	* linux/syscall.h (sys_vfork): Likewise.
	* linux/dummy.h (sys_vfork): Alias to sys_fork.
	* linux/alpha/syscallent.h: Fix vfork entry.
	* util.c (setbpt): Do not check for sys_vfork.
	* syscall.c (syscall_fixup_for_fork_exec): Likewise.

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

	epoll_ctl: fix EPOLL_CTL_DEL argument decoding.
	* desc.c (sys_epoll_ctl): Do not parse the event structure for
	EPOLL_CTL_DEL operation.

	Reported-by: Марк Коренберг <socketpair@gmail.com>

	Update CLOCK_* constants.
	* time.c (clocknames): Add CLOCK_BOOTTIME, CLOCK_REALTIME_ALARM,
	CLOCK_BOOTTIME_ALARM, CLOCK_SGI_CYCLE, and CLOCK_TAI.
	Fixes RH#1088455.

	Fix preadv/pwritev offset decoding.
	* util.c (printllval): Add align argument.
	* defs.h (printllval): Update prototype.
	(printllval_aligned, printllval_unaligned): New macros.
	* file.c (sys_readahead, sys_truncate64, sys_ftruncate64, sys_fadvise64,
	sys_fadvise64_64, sys_sync_file_range, sys_sync_file_range2,
	sys_fallocate): Replace printllval call with printllval_aligned.
	* io.c (sys_pread, sys_pwrite): Likewise.
	(sys_preadv, sys_pwritev): Replace printllval call with
	printllval_unaligned.
	* linux/arm/syscallent.h: Set the number of preadv and pwritev
	arguments to 5.
	* linux/mips/syscallent-o32.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/xtensa/syscallent.h: Likewise.

	Reported-by: Dima Kogan <dima@secretsauce.net>

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

	tests: add a test for pread/pwrite and preadv/pwritev offset decoding.
	* tests/uio.c: New file.
	* tests/uio.test: New test.
	* tests/Makefile.am (check_PROGRAMS): Add uio.
	(uio_CFLAGS): Define.
	(TESTS): Add uio.test.

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

	Refactor LDT decoding.
	* configure.ac (AC_CHECK_TYPES): Remove struct user_desc.
	* ldt.c: New file.
	* Makefile.am (strace_SOURCES): Add ldt.c.
	* mem.c: Do not include <asm/ldt.h>.
	(print_ldt_entry): Remove.
	(sys_modify_ldt, sys_set_thread_area, sys_get_thread_area): Move...
	* ldt.c: ... here.
	* process.c: Do not include <asm/ldt.h>.
	(sys_clone) [I386 || X86_64 || X32]: Use print_user_desc.

2014-04-10  Denys Vlasenko  <dvlasenk@redhat.com>

	Make int3 example in comments more cut-n-pastable.
	I found that I use it quite often. Lets make it so that
	after cut-n-pasting it into a file, there is no need
	to edit the result (e.g. no need to remove C comment
	chars from every line.

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

	mips: enable decoding of set_thread_area.
	* linux/dummy.h [MIPS]: Do not redirect sys_set_thread_area to printargs.
	* mem.c [MIPS] (sys_set_thread_area): Define.

	x86_64, x32: enable decoding of modify_ldt, get_thread_area, and set_thread_area
	* linux/dummy.h [X86_64 || X32]: Do not redirect sys_modify_ldt,
	sys_get_thread_area, and sys_set_thread_area to printargs.

	x32: decode clone LDT user_desc entries for x86 processes.
	* mem.c [X32]: Include asm/ldt.h.
	[X32] (print_ldt_entry, sys_modify_ldt, sys_set_thread_area,
	sys_get_thread_area): Define.
	* process.c [X32]: Include asm/ldt.h.
	(sys_clone) [X32]: Decode LDT entry if current_personality == 1.

2014-04-09  Elliott Hughes  <enh@google.com>

	x86-64: decode clone LDT user_desc entries for x86 processes.
	* mem.c [X86_64]: Include asm/ldt.h.
	[X86_64] (print_ldt_entry, sys_modify_ldt, sys_set_thread_area,
	sys_get_thread_area): Define.
	* process.c [X86_64]: Include asm/ldt.h.
	(sys_clone) [X86_64]: Decode LDT entry if current_personality == 1.

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

	x32: fix clone(2) argument order for x86 processes.
	Apply the same fix that was made for x86_64.

	* process.c [X32] (ARG_CTID, ARG_TLS): Take current
	personality into account.

2014-04-09  Elliott Hughes  <enh@google.com>

	x86-64: fix clone(2) argument order for x86 processes.
	Without this patch, strace claims that parent_tidptr == tls, which is
	clearly wrong.  It is expected that parent_tidptr == child_tidptr.

	* process.c [X86_64] (ARG_CTID, ARG_TLS): Take current
	personality into account.

2014-04-06  Elliott Hughes  <enh@google.com>

	aarch64: Fix decoding of arm struct stat64.
	We need to handle this situation more like x86-64.  32-bit arm and i386
	actually have a common struct stat64, except the arm one must not be
	packed.  Additionally, on aarch64 the 32-bit personality is personality 0.

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

	ARM EABI: disable OABI support by default.
	OABI is rarely used in ARM EABI systems nowadays, so disable its support
	by default.  Add --enable-arm-oabi option to enable ARM OABI support.

	* configure.ac: New option --enable-arm-oabi.
	* syscall.c (get_scno) [ARM]: Check ENABLE_ARM_OABI macro defined by
	configure instead of undocumented STRACE_KNOWS_ONLY_EABI macro.

2014-03-12  Elliott Hughes  <enh@google.com>

	Fix stat decoding for LP64 bionic.
	Patch fb642bb6d63f7ffe2228bf48a6008bc8f56f67ff fixed building with
	HAVE_STAT64 for aarch64 with uapi kernel headers but not x86_64.
	The workaround needed to be applied to all LP64 architectures, not
	just aarch64.  This patch fixes that and adds an explanatory comment.

2014-03-11  Masatake YAMATO  <yamato@redhat.com>

	Decode protocol argument for PF_NETLINK sockets.
	* net.c (protocols): Rename to inet_protocols.
	[PF_NETLINK] (netlink_protocols): New xlat structure.
	(sys_socket): Rename protocols to inet_protocols.
	[PF_NETLINK]: Decode protocol argument using netlink_protocols.

	Acked-by: Mike Frysinger <vapier@gentoo.org>

2014-03-11  Dmitry V. Levin  <ldv@altlinux.org>

	Cleanup socketpair decoding.
	The only supported domain for socketpair syscall is AF_UNIX, so
	no decoding related to other domains is required for socketpair.

	* net.c (sys_socketpair): Remove support for PF_INET and PF_IPX domains,
	print the protocol argument as is.

	printsiginfo: add SIGSYS decoding.
	* configure.ac (AC_CHECK_MEMBERS): Check for siginfo_t.si_syscall.
	* signal.c (SYS_SECCOMP): Define if not yet defined.
	(sigsys_codes): new xlat structure.
	(printsiginfo): Decode SIGSYS.

	Update siginfo codes.
	* signal.c (siginfo_codes): Add SI_DETHREAD.

	Factor out printing of si_pid and si_uid members of siginfo_t.
	* signal.c (printsigsource): New function.
	(printsiginfo): Use it.

2014-03-10  Elliott Hughes  <enh@google.com>

	Improve SI_TIMER decoding.
	Decode siginfo_t more clearly for si_code SI_TIMER.
	The 'pid' is actually a POSIX timer id, and the 'uid' is actually the
	overrun.
	Also factor out the si_value dumping so it's the same for every si_code.

2014-03-03  Elliott Hughes  <enh@google.com>

	aarch64: fix decoding of arm syscall numbers.
	If an aarch64 strace is tracing a process using the arm personality, it
	also needs to call the shuffle_scno function for the ARM-specific
	syscalls.

	* syscall.c (shuffle_scno): Define on AARCH64.
	(get_scno) [AARCH64]: Call shuffle_scno when the tracee is in 32-bit mode.

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

	Fix fcntl decoding.
	Assume that F_SETLK64, F_SETLKW64, and F_GETLK64 are either defined or
	not defined altogether.
	Do not assume that sizeof(off_t) < sizeof(long long) when F_SETLK64 is
	undefined.

	This change fixes build with musl libc on x86.

	* configure.ac: Define SIZEOF_OFF_T.
	* desc.c (USE_PRINTFLOCK64): New macro.
	(struct flock64, printflock64): Do not define on X32.
	(printflock): Replace X32 specific workaround with SIZEOF_OFF_T check.
	Fix printing off_t members of struct flock.
	(sys_fcntl): Use USE_PRINTFLOCK64.

2014-03-01  Dmitry V. Levin  <ldv@altlinux.org>

	sys_fcntl: remove F_FREESP and F_FREESP64 support.
	F_FREESP and F_FREESP64 fcntl commands are not available in Linux
	and therefore the code implementing their decoding is useless.
	Besides that, F_FREESP64 decoding is too complicated to support.

	* desc.c (fcntlcmds): Remove F_FREESP and F_FREESP64.
	Remove F_FREESP64 from the check whether to define struct flock64.
	(sys_fcntl): Remove F_FREESP and F_FREESP64 support.

2014-02-28  Elliott Hughes  <enh@google.com>

	Add multi-personality support to struct old_sigaction decoding.
	struct sigaction is another structure that contains members
	whose size differs between 32-bit and 64-bit personalities.

	* signal.c [HAVE_SIGACTION] (old_sigaction32): New structure.
	[HAVE_SIGACTION] (decode_old_sigaction): Decode 32-bit struct
	old_sigaction on a 64-bit host.

	Fix decoding of arm struct stat64 by aarch64 strace.
	aarch64's uapi header files have a struct stat but no struct stat64.
	To correctly decode a 32-bit process' s struct stat64 we need
	HAVE_STAT64, but then the build fails because there is no struct stat64.
	Luckily, the aarch64 struct stat is structurally equivalent to the arm
	struct stat64, so we can just reuse that.

	* file.c [AARCH64] (stat64): Define to stat.

2014-02-28  Dmitry V. Levin  <ldv@altlinux.org>

	Remove obsolete ioctlsort.c.
	The generic version of ioctlsort.c became obsolete after commit
	v4.6-240-g5afdf12 that removed its last non-Linux users.

	* ioctlsort.c: Remove.
	* Makefile.am (EXTRA_DIST): Remove ioctlsort.c.

	Reported-by: Elliott Hughes <enh@google.com>

2014-02-27  Dmitry V. Levin  <ldv@altlinux.org>

	Add multi-personality support to stack_t decoding.
	stack_t is one of many structures that contain members
	whose size differs between 32-bit and 64-bit personalities.

	* signal.c (print_stack_t): Decode 32-bit stack_t on a 64-bit host.

	Reported-by: Elliott Hughes <enh@google.com>

	Rewrite signal mask decoding without sigset_t.
	The sigset_t provided by libc is not quite convenient.
	In glibc, sigset_t is an array with space for 1024 bits, which is much
	more than required: all architectures supported by Linux have only 64
	signals except MIPS, which has 128.
	In bionic libc, LP32 sigset_t is only 4 bytes long, which is less than
	necessary.

	With this change, signal mask is decoded without use of intermediate
	sigset_t structure, which saves us some cpu cycles in case of glibc with
	its inflated sigset_t, and enables build with libcs where sigset_t is
	broken.

	Old implementation used to check each signal number in the given signal
	mask twice using sigismember().
	New implementation is based on popcount and next_set_bit() so it's
	noticeably faster.

	* configure.ac: Check for __builtin_popcount.
	* signal.c: Ensure that NSIG >= 32.
	(sprintsigmask, sprintsigmask_long, printsigmask): Remove.
	(popcount32, sprintsigmask_n): New functions.
	(tprintsigmask_addr, sprintsigmask_val, tprintsigmask_val): New macros.
	(print_sigset_addr_len, sys_sigsetmask, sys_sigreturn, sys_siggetmask,
	sys_sigsuspend, sys_sigprocmask, decode_new_sigaction): Update to use
	new signal mask decoding interface.
	* tests/sigaction.c (main): Add a test with almost filled signal mask.
	* tests/sigaction.awk: Update.

2014-02-26  Dmitry V. Levin  <ldv@altlinux.org>

	Fix build with Bionic libc.
	Add generic tests for fopen64 and fputs_unlocked functions to fix build
	with Bionic libc that does not provide them.

	* configure.ac (AC_CHECK_FUNCS): Add fopen64 and fputs_unlocked.
	* strace.c [_LARGEFILE64_SOURCE]: Use fopen instead of fopen64
	if !HAVE_FOPEN64.
	Use fputs instead of fputs_unlocked if !HAVE_FPUTS_UNLOCKED.
	* vsprintf.c: Use fputs instead of fputs_unlocked
	if !HAVE_FPUTS_UNLOCKED.

	Reported-by: Elliott Hughes <enh@google.com>

2014-02-25  James Yang  <james.yang@freescale.com>

	powerpc64: fix 64-bit process detection on embedded.
	* syscall.c (get_scno) [POWERPC64]: Fix 64-bit process detection
	on embedded powerpc.

2014-02-25  Dmitry V. Levin  <ldv@altlinux.org>

	Do not compile scsi ioctl decoding if <scsi/sg.h> is not available.
	Add a generic test for <scsi/sg.h> availability to fix build with
	Bionic libc that does not provide <scsi/sg.h>.

	* configure.ac (AC_CHECK_HEADERS): Add scsi/sg.h.
	* ioctl.c (ioctl_decode): Do not call scsi_ioctl if !HAVE_SCSI_SG_H.
	* scsi.c: Do not compile scsi ioctl decoding if !HAVE_SCSI_SG_H.

	Reported-by: Elliott Hughes <enh@google.com>

2014-02-14  Dmitry V. Levin  <ldv@altlinux.org>

	Revert "Add support for Altera's Nios-II softcore architecture"
	The patch originally submitted by Ezequiel García was OK, but I somehow
	managed to mangle it so that most of the patch was not applied.

	According to Ezequiel García, an architecture port based on the generic
	syscall ABI is in progress.

	This reverts commit 61e426e87ac81be4b4ff9de581635b4ea585624f.

2014-02-08  Dmitry V. Levin  <ldv@altlinux.org>

	tests: tighten sigaction check.
	* tests/sigaction.awk: Check that input conatins all expected lines.

	Fix sigaction reporting on non-x86 architectures.
	If SA_RESTORER is not defined by libc headers but defined by kernel
	headers, use the definition provided by kernel headers for proper
	sigaction decoding.

	* signal.c [!SA_RESTORER]: Define to ASM_SA_RESTORER if the latter is
	defined, regardless of architecure.

	Check for SA_RESTORER definition in <asm/signal.h>
	Kernel header <asm/signal.h> cannot be included from regular code
	because it conflicts with libc headers, but SA_RESTORER is needed in
	signal.c, so SA_RESTORER value is forwarded from <asm/signal.h> to
	config.h using a configure check.

	* configure.ac (ASM_SA_RESTORER): Define if SA_RESTORER is defined
	in <asm/signal.h>.

2014-02-07  Dmitry V. Levin  <ldv@altlinux.org>

	arm: fix compilation warning.
	Fix "dereferencing type-punned pointer will break strict-aliasing rules"
	warning introduced by commit v4.8-54-g670b21b.

	* signal.c (sys_sigreturn) [ARM]: Avoid dereferencing type-punned pointers.

2014-02-06  Dmitry V. Levin  <ldv@altlinux.org>

	kexec: fix typo.
	* kexec.c (print_kexec_segments) [SUPPORTED_PERSONALITIES == 1]: Fix typo.

2014-02-06  Ezequiel Garcia  <ezequiel@vanguardiasur.com.ar>

	Add support for Altera's Nios-II softcore architecture.
	This commit adds strace support for Altera's Nios-II official
	kernel port as found in git://git.rocketboards.org/linux-socfpga.git

	Notice that this an out-of-tree kernel architectural port, and uses the
	legacy (non-generic) system call ABI. In particular, the port doesn't
	support PTRACE_GETREGSET, so the implementation is based on PTRACE_GETREGS.

	Given it's mandatory for new architectures to support the generic
	syscall ABI and PTRACE_GETREGSET, if the nios2 architecure is ever
	mainlined, the strace support will have to be re-factored accordingly.

	* linux/nios2/ioctlent.h.in: New file.
	* linux/nios2/syscallent.h: Likewise.
	* Makefile.am (EXTRA_DIST): Add linux/nios2/ioctlent.h.in and
	linux/nios2/syscallent.h.
	* configure.ac: Add NIOS2 to the list of supported architectures.
	* defs.h [NIOS2]: Use register reading system.
	* process.c (struct_user_offsets): Add NIOS2 support.
	* syscall.c (get_regs, get_scno, get_syscall_args,
	get_syscall_result, get_error): Likewise.
	* util.c (change_syscall): Likewise.
	* mem.c (sys_getpagesize): Define on NIOS2.
	* system.c [NIOS2] (sys_cacheflush, sys_nios2cmpxchg): New functions.

	Acked-by: Mike Frysinger <vapier@gentoo.org>

2014-02-05  Dmitry V. Levin  <ldv@altlinux.org>

	Implement add_key, keyctl, and request_key decoding.
	* keyctl.c: New file.
	* linux/keyctl.h: Likewise.
	* Makefile.am (strace_SOURCES): Add keyctl.c.
	(EXTRA_DIST): Add linux/keyctl.h.
	* linux/dummy.h (sys_add_key, sys_keyctl, sys_request_key): Remove.
	* linux/syscall.h (sys_add_key, sys_keyctl, sys_request_key): New
	prototypes.

	Implement ioprio_get and ioprio_set decoding.
	* ioprio.c: New file.
	* Makefile.am (strace_SOURCES): Add ioprio.c.
	* linux/dummy.h (sys_ioprio_get, sys_ioprio_set): Remove.
	* linux/syscall.h (sys_ioprio_get, sys_ioprio_set): New prototypes.

	Implement finit_module decoding.
	* bjm.c (module_init_flags): New xlat structure.
	(sys_finit_module): New function.
	* linux/dummy.h (sys_finit_module): Remove.
	* linux/syscall.h (sys_finit_module): New prototype.

	Cleanup inotify syscalls decoding.
	* linux/inotify.h: New file.
	* file.c (inotify_modes, inotify_init_flags, sys_inotify_add_watch,
	sys_inotify_rm_watch, sys_inotify_init1): Move...
	* inotify.c: ... here.
	(inotify_modes): Rename to inotify_flags, convert to XLAT form.
	(inotify_init_flags): Convert to XLAT form.
	* Makefile.am (strace_SOURCES): Add inotify.c.
	(EXTRA_DIST): Add linux/inotify.h.

	Enhance reboot decoding.
	* linux/reboot.h: New file.
	* system.c (bootflags1, bootflags2, bootflags3, sys_reboot): Move...
	* reboot.c: ... here.
	(bootflags2, bootflags3): Update constants.
	* Makefile.am (strace_SOURCES): Add reboot.c.
	(EXTRA_DIST): Add linux/reboot.h.

	Implement kexec_load decoding.
	* kexec.c: New file.
	* linux/kexec.h: Likewise.
	* Makefile.am (strace_SOURCES): Add kexec.c.
	(EXTRA_DIST): Add linux/kexec.h.
	* linux/dummy.h (sys_kexec_load): Remove.
	* linux/syscall.h (sys_kexec_load): New prototype.

	Use prepared editions of recently imported linux headers.
	* linux/fanotify.h: Replace with edition prepared with headers_install.sh.
	* linux/personality.h: Likewise.

	Implement fanotify_init and fanotify_mark decoding.
	* fanotify.c: New file.
	* linux/fanotify.h: Likewise.
	* Makefile.am (strace_SOURCES): Add fanotify.c.
	(EXTRA_DIST): Add linux/fanotify.h.
	* defs.h (print_dirfd): New prototype.
	* file.c (print_dirfd): Export.
	* linux/dummy.h (sys_fanotify_init, sys_fanotify_mark): Remove.
	* linux/syscall.h (sys_fanotify_init, sys_fanotify_mark): New
	prototypes.
	* pathtrace.c (pathtrace_match): Handle sys_fanotify_init and
	sys_fanotify_mark.

	Use XLAT_END macro.
	Automatically update all xlat structures using the following sed regexp:
	s/^[[:space:]]*{[[:space:]]*0[[:space:]]*,[[:space:]]*NULL[[:space:]]*,\?[[:space:]]*}[[:space:]]*,\?[[:space:]]*/\tXLAT_END/

	Itroduce XLAT_END macro to make xlat structures more compact.
	* defs.h (XLAT_END): New macro.

	Convert personality_options to XLAT form.
	* linux/personality.h: New file.
	* Makefile.am (EXTRA_DIST): Add it.
	* system.c: Include <linux/personality.h>.
	(personality_options): Update PER_* constants, convert to XLAT form.

	Convert futexops to XLAT form.
	* process.c: Define FUTEX_*_PRIVATE macros.
	(futexops): Convert to XLAT form.

	Convert sigev_value to XLAT form.
	* time.c (sigev_value): Convert to XLAT form.
	(printsigevent32, printsigevent): Update use of sigev_value.

	Use XLAT macro.
	Automatically convert all xlat structures to XLAT form
	using the following sed regexp:
	s/^[[:space:]]*{[[:space:]]*\([^",}[:space:]]\+\)[[:space:]]*,[[:space:]]*"\1",\?[[:space:]]*}[[:space:]]*/\tXLAT(\1)/

	Introduce XLAT macro to ease maintenance of xlat structures.
	* defs.h (XLAT): New macro.

	Suggested-by: Mike Frysinger <vapier@gentoo.org>

2014-02-04  Stefan Sørensen  <stefan.sorensen@spectralink.com>

	Decode ptp ioctls.
	* defs.h (ptp_ioctl): New prototype.
	* ioctl.c (ioctl_decode): Call ptp_ioctl when code is '='.
	* Makefile.am (strace_SOURCES): Add ptp.c.
	(EXTRA_DIST): Add linux/ptp_clock.h.
	* ptp.c: New file.
	* linux/ptp_clock.h: New file.

2014-02-03  Stefan Sørensen  <stefan.sorensen@spectralink.com>

	Decode dynamic posix clocks.
	* time.c (cpuclocknames): New xlat structure.
	(printclockname): New function that decodes posix clock names,
	including dynamic fd encoded clocks.
	(sys_clock_settime, sys_clock_gettime, sys_clock_nanosleep,
	sys_clock_adjtime, sys_timer_create, sys_timerfd, sys_timerfd_create):
	Use it.

	Update ADJ_* constants.
	* time.c (adjtimex_modes): Add ADJ_TAI, ADJ_SETOFFSET, ADJ_MICRO,
	ADJ_NANO, ADJ_OFFSET_SS_READ.

2014-02-02  Philippe Ombredanne  <pombredanne@nexb.com>

	Add decoding of sockets descriptor 'paths' for network calls.
	* net.c (sys_bind, sys_listen, do_accept, sys_send, sys_sendto,
	sys_sendmsg, sys_sendmmsg, sys_recv, sys_recvfrom, sys_recvmsg,
	sys_recvmmsg, sys_shutdown, sys_getsockopt, sys_setsockopt): Decode
	socket descriptor arguments using printfd.
	* pathtrace.c (pathtrace_match): Also check TRACE_NETWORK syscalls
	that take socket descriptor arguments.
	* tests/net-fd.test: New test for socket descriptor arguments decoding.
	* tests/Makefile.am (TESTS): Add net-fd.test.
	(net-fd.log): New dependency on net.log.

2014-02-02  Dmitry V. Levin  <ldv@altlinux.org>

	tests: rename all tests so that their names end in .test suffix.
	Due to automake limitations, some features work only for tests
	that end in one of the suffixes listed in TEST_EXTENSIONS.

	* tests/detach-running: Rename to detach-running.test.
	* tests/detach-sleeping: Rename to detach-sleeping.test.
	* tests/detach-stopped: Rename to detach-stopped.test.
	* tests/net: Rename to net.test.
	* tests/ptrace_setoptions: Rename to ptrace_setoptions.test.
	* tests/qual_syscall: Rename to qual_syscall.test.
	* tests/sigaction.sh: Rename to sigaction.test.
	* tests/stat: Rename to stat.test.
	* tests/strace-f: Rename to strace-f.test.
	* tests/Makefile.am (TESTS): Update.
	(LOG_COMPILER): Rename to TEST_LOG_COMPILER.

2014-01-31  Mike Frysinger  <vapier@gentoo.org>

	net: add more sockopt options.
	This syncs with the defines as available in linux-3.13.

	* net.c (sockipoptions): Add IP_IPSEC_POLICY, IP_XFRM_POLICY,
	IP_PASSSEC, IP_TRANSPARENT, IP_ORIGDSTADDR, IP_RECVORIGDSTADDR,
	IP_MINTTL, IP_NODEFRAG, IP_UNBLOCK_SOURCE, IP_BLOCK_SOURCE,
	IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP, MCAST_JOIN_GROUP,
	MCAST_BLOCK_SOURCE, MCAST_UNBLOCK_SOURCE, MCAST_LEAVE_GROUP,
	MCAST_JOIN_SOURCE_GROUP, MCAST_LEAVE_SOURCE_GROUP, IP_MULTICAST_ALL,
	IP_UNICAST_IF.

2014-01-08  Chris Dearman  <chris.dearman@imgtec.com>

	mips: fix sigaction reporting.
	MIPS userland uses the same sigaction structure with a full signal
	mask for old_sigaction and new_sigaction and does does not have
	an sa_restorer field.

	These changes have been tested on MIPS O32 big/little endian, MIPS N64
	big endian and x86-64.

	* signal.c (old_sigaction) [MIPS]: Add definition for MIPS.
	(decode_old_sigaction) [MIPS]: Print sa_mask according to its definition.
	(new_sigaction) [MIPS]: Add definition for MIPS.

2014-01-08  Dmitry V. Levin  <ldv@altlinux.org>

	Factor out struct sigaction printing code.
	* signal.c [HAVE_SIGACTION] (decode_old_sigaction): New function.
	[HAVE_SIGACTION] (sys_sigaction): Use it.
	(decode_new_sigaction): New function.
	(sys_rt_sigaction): Use it.

	tests: add a test for rt_sigaction output.
	Since "struct sigaction" varies between architectures, rt_sigaction
	decoding sometimes produces incorrect output.  This test is expected
	to catch basic rt_sigaction decoding bugs.

	Based on a patch proposed by Chris Dearman.

	* tests/sigaction.c: New file.
	* tests/sigaction.awk: Likewise.
	* tests/sigaction.sh: New test.
	* tests/Makefile.am (check_PROGRAMS): Add sigaction.
	(TESTS): Add sigaction.sh.
	(EXTRA_DIST): Add sigaction.awk.
	* tests/.gitignore: Add sigaction.

2014-01-05  Kirill A. Shutemov  <kirill.shutemov@linux.intel.com>

	mem: add missed MAP_HUGETLB mmap flag.
	* mem.c (mmap_flags): Add MAP_HUGETLB mmap flag.

	Acked-by: Mike Frysinger <vapier@gentoo.org>

2013-12-31  Mike Frysinger  <vapier@gentoo.org>

	Delete old PTRACE_{PEEK,POKE}USR logic.
	The code base has settled on PTRACE_{PEEK,POKE}USER (with an E) and has
	logic in defs.h to make sure it's set sanely.  Delete this old logic as
	the defs.h takes care of it now.

	* process.c: Delete PTRACE_PEEKUSR/PTRACE_POKEUSR defines.
	* signal.c: Likewise.
	* syscall.c: Delete PTRACE_PEEKUSR define.
	* util.c: Likewise.

	Decode the O_PATH flag.
	* file.c (open_mode_flags): Add O_PATH.

2013-11-13  Dmitry V. Levin  <ldv@altlinux.org>

	Remove unused configure checks.
	* configure.ac (AC_CHECK_FUNCS): Remove _sys_siglist and sys_siglist.
	(AC_CHECK_DECLS): Likewise.

	Assume that <sys/ptrace.h> provides a valid ptrace prototype.
	We used to explicitly list architectures where <sys/ptrace.h> from glibc
	is known to provide a valid prototype for ptrace, and use a homegrown
	replacement for all the rest.  Situation seems to be better nowadays,
	glibc is not the only libc available, so let's use ptrace prototype from
	<sys/ptrace.h> by default, leaving the replacement for rare broken cases
	if any.

	* defs.h: Use ptrace prototype workaround iff
	NEED_PTRACE_PROTOTYPE_WORKAROUND is defined.

2013-11-12  Dmitry V. Levin  <ldv@altlinux.org>

	Stop using _LFS64_LARGEFILE.
	There is only one place left in the code where strace guesses whether
	libc provides LFS64 functions and structures.  The most natural thing to
	do there is to check for _LARGEFILE64_SOURCE - the macro provided by
	glibc.  Other libc implementations that provide nondegenerate LFS64
	interfaces are expected to define this macro as well.

	* defs.h (_LFS64_LARGEFILE): Remove.
	* strace.c: Use _LARGEFILE64_SOURCE instead of _LFS64_LARGEFILE.

	Define truncate64, ftruncate64, and getdents64 decoders unconditionally.
	These decoders are referenced by most architectures, there were no
	undefined references so far because _LFS64_LARGEFILE appears to be
	always defined by glibc when _GNU_SOURCE is defined.

	* file.c (sys_truncate64, sys_ftruncate64, sys_getdents64): Define
	unconditionally.

	Define printflock64 only if it is referenced by other code.
	* configure.ac (AC_CHECK_TYPES): Add struct flock64.
	* desc.c (HAVE_F_SETLK64, HAVE_F_SETLKW64, HAVE_F_GETLK64): New macros.
	[!HAVE_STRUCT_FLOCK64] (struct flock64): Define.
	(printflock64): Define only if referenced by other code.
	(sys_fcntl): Handle F_FREESP64, F_SETLK64, F_SETLKW64, and F_GETLK64 iff
	these constants are defined and differ from their non-64bit versions.

	Make PTRACE_PEEKUSER/PTRACE_POKEUSER checks less glibc specific.
	* configure.ac (AC_CHECK_DECLS): Add PTRACE_PEEKUSER and
	PTRACE_POKEUSER.
	* defs.h: Define PTRACE_PEEKUSER and PTRACE_POKEUSER only if
	they are not provided by <sys/ptrace.h>.

	Reported by John Spencer.

	Remove unneeded redefinitions of IPPROTO_* macros.
	IPPROTO_* macros are defined by <netinet/in.h>, no need to redefine
	them.

	* net.c (IPPROTO_EGP, IPPROTO_PUP, IPPROTO_IDP, IPPROTO_IGMP,
	IPPROTO_RAW, IPPROTO_MAX): Remove.

	Reported by John Spencer.

	Remove unused AC_OFF_T_IS_LONG_LONG configure check.
	* configure.ac: Remove AC_OFF_T_IS_LONG_LONG.
	* m4/long_long.m4: Likewise.

	Remove unused code.
	* configure.ac (AC_CHECK_TYPES): Remove struct opthdr and
	struct t_opthdr.
	* net.c (print_sock_optmgmt): Remove.

	Use struct sigcontext instead of struct sigcontext_struct.
	* configure.ac (AC_CHECK_TYPES): Remove struct sigcontext_struct.
	* signal.c (sys_sigreturn) [S390 || S390X || POWERPC || ALPHA): Replace
	struct sigcontext_struct with struct sigcontext.

	Reported by John Spencer.

	Use standard names of sched_param structure members.
	* process.c (sys_sched_setscheduler, sys_sched_getparam,
	sys_sched_setparam): Use portable struct sched_param member name
	sched_priority instead of glibc specific __sched_priority.

	Reported by John Spencer.

	Make SIGEV_THREAD_ID decoding less glibc specific.
	SIGEV_THREAD_ID decoding requires access to an internal member of
	struct sigevent.  There seems to be no portable way to do it besides
	adding a configure check.

	* configure.ac (AC_CHECK_MEMBERS): Check for
	struct sigevent._sigev_un._pad and struct sigevent.__pad.
	* time.c (printsigevent): Use an appropriate struct sigevent member
	to print thread id.

	Reported by John Spencer.

2013-11-11  Dmitry V. Levin  <ldv@altlinux.org>

	Remove unused configure checks.
	* configure.ac (AC_CHECK_MEMBERS): Remove T_conn_res.QUEUE_ptr,
	T_conn_res.ACCEPTOR_id, dqblk.dqb_curblocks, sigcontext.sc_hi2.

	Assume "long long" availability.
	Most of the code already uses long long types unconditionally.

	* configure.ac: Remove the check for long long.
	* file.c (printstat64): Remove HAVE_LONG_LONG checks, use %llu format
	string unconditionally.

	Include <sys/poll.h> only if there is no <poll.h>
	* pathtrace.c: Do not include <sys/poll.h> if <poll.h> is available.
	* stream.c: Likewise.

	Move io_* syscalls decoding to a separate file.
	* desc.c (sys_io_setup, sys_io_destroy, sys_io_submit, sys_io_cancel,
	sys_io_getevents, declarations from libaio.h): Move to ...
	* aio.c: new file.
	* Makefile.am (strace_SOURCES): Add aio.c.

2013-11-11  Denys Vlasenko  <dvlasenk@redhat.com>

	Stop using external libaio.h.
	This change incorporates a partial copy instead
	of using external libaio.h.
	Why?
	Because we want to properly decode 32-bit aio calls
	by 64-bit strace. For that, we need more definitions than
	libaio.h provides.
	(These defs are not done yet, but will eventually be done).
	Keeping our local 32-bit compat defs in sync with libaio.h
	_without seeing libaio structs_ is hard/more bug prone.
	A smaller benefit is that we don't need libaio installed.

	sys_io_submit: simplify iocb_cmd_lookup() helper.
	This helper returns two values (a string and an enum).
	The caller prints the string. It's simpler to just print
	the string in the caller itself. This eliminates
	"return by reference" and more importantly, an intermediate
	static string buffer for the string result.

	Since function of the helper is different now,
	it is renamed to tprint_lio_opcode().

	sys_io_submit: stop traversing iocb vector after first failure.
	The program may use a very large nr but supply either outright
	invalid iocbpp[], or one with far fewer elements than nr.
	We used to try reading iocbpp[i] until i == nr.
	With this change, we stop on the first failure.

2013-11-09  Denys Vlasenko  <dvlasenk@redhat.com>

	Fix pathtrace_match() to match recent fixes to select decoding.

	Fix select decoding on e.g. 32-bit ppc process by 64-bit strace.
	Added next_set_bit() function which finds the next set bit,
	properly taking into account word size of the traced process.
	Use it in decode_select() instead of fd_isset().
	Also, properly round fdsize up to word size of traced process,
	not to strace's word size.

2013-11-06  Denys Vlasenko  <dvlasenk@redhat.com>

	Speed up and explain fd_isset()

2013-11-05  Dr. David Alan Gilbert  <dave@treblig.org>

	Add a test for the latest select decoding fix.
	* test/select.c (main): Add a test for nfds larger than FD_SETSIZE.

2013-11-05  Dmitry V. Levin  <ldv@altlinux.org>

	Fix select decoding for glibc in _FORTIFY_SOURCE mode.
	glibc in _FORTIFY_SOURCE mode raises SIGABRT when descriptor greater
	or equal to FD_SETSIZE is passed to FD_ISSET.  Select family syscalls,
	however, can legitimately accept such descriptors.  To overcome this
	limitation, we have to replace FD_ISSET with an equivalent that imposes
	no such restrictions.

	* desc.c (fd_isset): New function.
	(decode_select): Use it instead of FD_ISSET.

	More select decoding fixes.
	* desc.c (decode_select): Actually print arg[0] as int on entering
	syscall.  When arg[0] is negative, do not attempt to fetch and decode
	descriptor sets on entering syscall, kernel will reject it anyway.
	On exiting syscall, stop checking descriptor sets as soon as all
	returned descriptors are found.

2013-11-05  Denys Vlasenko  <dvlasenk@redhat.com>

	Truncate arg[0] to int in select decoding.
	This matches kernel's behavior.

	test/select.c: make comment more understandable.

2013-11-05  Dr. David Alan Gilbert  <dave@treblig.org>

	Fix select decoding with bogus (huge or negative) nfds.
	We used to allocate and fetch bit arrays using a sanitized
	length, but then iterate over them with "j < arg[0]" condition,
	where arg[0] is not sanitized. This segfaults if arg[0] is huge
	or negative. This change fixes this.

	Add test/select.c to capture the case.

2013-09-26  Ali Polatel  <alip@exherbo.org>

	Work around conflict between <sys/ptrace.h> and <linux/ptrace.h>
	Since glibc-2.18~39 <sys/ptrace.h> defines ptrace_peeksiginfo_args
	which collides with <linux/ptrace.h>.

	* configure.ac: Check for `struct ptrace_peeksiginfo_args' in
	<sys/ptrace.h>.
	* process.c: Work around potential conflict between <sys/ptrace.h>
	and <linux/ptrace.h> by redefining ptrace_peeksiginfo_args.
	* signal.c: Likewise.
	* syscall.c: Likewise.
	* util.c: Likewise.

2013-09-11  Vineet Gupta  <Vineet.Gupta1@synopsys.com>

	Add support for ARC Cores from Synopsys.
	Take #2 on mainlining strace support for ARC (last one was 4.6 based back
	in March 2011), see
	http://sourceforge.net/p/strace/mailman/message/27210168/

	The syscall ABI is asm-generic/unistd.h based (so no legacy syscalls),
	hence very similar to metag port.

	test/* all seem to work well.

	* linux/arc/ioctlent.h.in: New file.
	* linux/arc/syscallent.h: Likewise.
	* Makefile.am (EXTRA_DIST): Add linux/arc/ioctlent.h.in and
	linux/arc/syscallent.h.
	* configure.ac: Add ARC to the list of supported architectures.
	* defs.h: Add ARC support.
	* process.c (struct_user_offsets): Likewise.
	* signal.c (sys_sigreturn): Likewise.
	* syscall.c (print_pc, get_regset, get_regs, get_scno, get_syscall_args,
	get_syscall_result, get_error): Likewise.
	* util.c (change_syscall): Likewise.

	Acked-by: Mike Frysinger <vapier@gentoo.org>

2013-09-11  William Manley  <william.manley@youview.com>

	Add support for decoding sync_file_range.
	* file.c (sync_file_range_flags): New xlat structure.
	(sys_sync_file_range, sys_sync_file_range2): New functions.
	* linux/syscall.h (sys_sync_file_range, sys_sync_file_range2): New
	prototypes.
	* linux/dummy.h (sys_sync_file_range, sys_sync_file_range2): Remove.
	* linux/mips/syscallent-o32.h: Set the number of sync_file_range
	arguments to 7.

2013-09-11  Mike Frysinger  <vapier@gentoo.org>

	fanotify_mark: fix number of args for 32bit arches.
	The fanotify_mark func takes a 64bit mask, so 32bit arches have to split
	it up into two fields.  When the syscall was added, it was listed as only
	having 5 fields total (since that's correct for 64bit systems).

	* linux/arm/syscallent.h: Set the number of fanotify_mark arguments to 6.
	* linux/bfin/syscallent.h: Likewise.
	* linux/hppa/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/metag/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent-o32.h: Likewise.
	* linux/or1k/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent1.h: Likewise.

	Acked-by: Chris Metcalf <cmetcalf@tilera.com> [for tile]

2013-09-11  Dmitry V. Levin  <ldv@altlinux.org>

	x86, x86_64: fix compilation warnings.
	Fix "dereferencing type-punned pointer will break strict-aliasing rules"
	warnings introduced by commit v4.8-52-gb51f364.

	* signal.c (sys_sigreturn): Avoid dereferencing type-punned pointers.

2013-07-18  Denys Vlasenko  <dvlasenk@redhat.com>

	Remove rt parameter from [s]printsigmask()
	In almost all cases, the parameter was 1 ("decode RT sigs too").
	This change hardwires it to be 1.

	The cases where it was 0 are, and why the change to "decode RT sigs too"
	is fine:

	IA64: 64-bit arch, all 64 signals fit in one word in any case.
	S390[x]: sc.oldmask is a sigset_t on kernel side,
		(sigset_t *)&sc.oldmask[0] does contain all 64 signals.
	TILE: uc.uc_sigmask is a sigset_t on kernel side,
		memcpy(&sigm, &uc.uc_sigmask, NSIG / 8) copies all 64 signals.

	Convert some uses of long_to_sigmask+printsigmask to sprintsigmask_long.
	This allows to drop long_to_sigmask function,
	and a whole bunch of sigset_t variables.

	Simplify some sigmask manipulations.

	Add compat support for sys_pselect6.

	I386: fix signedness mismatch warning.
	&i386_regs.esp is a pointer to long, not unsigned long.
	It needs a cast.

	Fix sigset printing via print_sigset().
	Replace print_sigset() with print_sigset_addr_len(),
	which takes not only addr, but also len parameter.
	This allows us to drop "do we need to print RT signals?" parameter,
	and this fixes RT signals printing in many syscalls.

	sys_epoll_pwait: print RT signals too, print sigmask size argument.

	sys_sigprocmask: print_sigset -> print_sigset_addr_len(current_wordsize),
	no change in functionality.

	sys_sigpending: use print_sigset_addr_len(current_wordsize)
	instead of open-coding it.

	sys_rt_sigprocmask: use print_sigset_addr_len instead of open-coding it.
	sys_rt_sigpending: ditto.
	sys_rt_sigsuspend: ditto.
	sys_rt_sigtimedwait: ditto.

	do_signalfd: print_sigset -> print_sigset_addr_len. This fixes
	RT signals printing (wasn't showing them before).

	sys_ppoll: ditto.

	copy_sigset_len() is folded into its only user, print_sigset_addr_len(),
	and copy_sigset() is gone.

	While at it, checked kernel sources and noted where kernel enforces
	sigset_size == NSIG / 8 (== sizeof(kernel_sigset_t)),
	and where it allows word-sized sigset_size ([rt_]sigpending).

	sys_rt_sigaction: fix sigset copying.
	In practice, we always copy as many bytes as syscall param says
	(8, or 16 on mips). However, malicious program can call sigaction
	with wrong sigset size. Such syscall will result in EINVAL,
	but we (strace) end up copying 128 bytes (sizeof(sigset_t)),
	which copyes some garbage from stack after struct sigaction.

	Now we always copy NSIG / 8 bytes (which is 8 bytes, or 16 on mips).

	ARM: remove wrong NSIG = 32 define.
	ARM in fact has 64 signals (1..64), and NSIG should be 65
	(as usual, rememebr that NSIG_libc == NSIG_kernel+1).

	I carefully reviewed all usages of NSIG. In syscall.c,
	the only usage is:
	        for (i = 0; i <= NSIG; i++)
	                if (strcasecmp(s, signame(i) + 3) == 0)...
	which is safe even if NSIG is way too big - signame(i)
	returns a well-formed string for any i.

	In signal.c, memcpy(&sigset, &sc.sc_mask, NSIG / 8) is used by
	IA64 and TILE code, so ARM change can't affect it. And final
	usage is:
	 struct new_sigaction::unsigned long sa_mask[NSIG / sizeof(long)];
	It will grow on ARM (and become correct in the process).
	Its only use is
	 memcpy(&sigset, &sa.sa_mask, NSIG / 8);
	 printsigmask(&sigset, 1);
	which used to copy garbage in high bits, now it will copy actual data.

2013-07-17  Denys Vlasenko  <dvlasenk@redhat.com>

	ARM: fix sigreturn decoding.
	Decoding of test/sigreturn testcase:
	Was:
	sigreturn() (mask [QUIT TRAP ABRT BUS SEGV USR2 PIPE STKFLT STOP XCPU VTALRM PROF WINCH IO PWR RTMIN]) = 0
	Now:
	sigreturn() (mask [CHLD RT_1 RT_3 RT_31 RT_32]) = 0

2013-07-16  Denys Vlasenko  <dvlasenk@redhat.com>

	Group USE_CUSTOM_PRINTF define with other tweakables.
	No code changes.

	Improve sigreturn decoding on x86 to show RT signal bits too.
	This includes decoding of 32-bit sigreturn by 64-bit strace,
	which previously wasn't done.

	Added a test for it.

2013-07-12  Anton Blanchard  <anton@samba.org>

	powerpc: enhance 32/64bit detection.
	We were using uname to determine if userspace was 32 or 64bit.
	This fails when we have a 64bit kernel and a 32bit userspace.

	* configure.ac (powerpc*): Similar to x86, use a runtime test
	to determine if we are 32 or 64bit.

	powerpc: fix some compiler warnings.
	Fix a number of differing signedness warnings when building on
	powerpc.

	powerpc: fix iflag build issue (static -> extern)

2013-07-10  Denys Vlasenko  <dvlasenk@redhat.com>

	PTRACE_SEIZE can set ptrace options immediately, use this feature.
	This eliminates some rare bugs, such as post-execve SIGTRAP
	generation when we attach to a process, and it manages to finish
	execve'ing before we set TRACEEXEC option to suppress that.

2013-07-08  Denys Vlasenko  <dvlasenk@redhat.com>

	If -o|logger is in use, exit trace loop if nprocs == 0.

	Exit trace loop if got ECHILD, not if nprocs == 0.
	Comment gives a testcase which wasn't handled correctly
	by the old code.

2013-07-07  Denys Vlasenko  <dvlasenk@redhat.com>

	s390[x]: get rid of syscall_mode, delete code which never triggers.
	Before this change, the logic was as follows:
	syscall entry:
	  get_scno:
	    syscall_mode = GPR2
	    scno = syscall_mode unless syscall_mode == -ENOSYS
	    (if -ENOSYS, scn is retrieved by decoding current insn)
	  fixup:
	    gpr2 = GPR2
	    syscall_mode = scno unless syscall_mode == -ENOSYS
	    if (gpr2 != syscall_mode) stray_entry
	syscall exit:
	  get_res:
	    gpr2 = GRP2
	  fixup:
	    syscall_mode = scno unless syscall_mode == -ENOSYS
	    if (WAITEXECVE && gpr2 in (-ENOSYS, scno)) gpr2 = 0;
	  get_error:
	    gpr2 is retval

	Entry fixup's if() can never trigger:
	regardless whether GPR2 is -ENOSYS or not, syscall_mode is always
	equal to GRP2 value there. So it can be removed.

	On sysexit path, syscall mode is never used.

	Therefore, syscall_mode variable is deleted. grp2 is read from
	GPR2 register in get_scno, redundant read in entry fixup is removed.
	As a result, entry fixup's s390 code block vanishes completely.

	gpr2 variable is renamed s390_gpr2 to match the convention used
	by other arches.

2013-07-04  Denys Vlasenko  <dvlasenk@redhat.com>

	ARM: add STRACE_KNOWS_ONLY_EABI define which can be used to omit OABI support

	Add paranoia check before passing a long to pid2tcb(int pid)

2013-07-02  Denys Vlasenko  <dvlasenk@redhat.com>

	In debug output, show waitpid status with 6 hex digits, not 4.
	This shows event byte values better (without variable offset):

	 [wait(0x01057f) = 29491] WIFSTOPPED,sig=SIGTRAP,EVENT_FORK (1)
	 [wait(0x80057f) = 29492] WIFSTOPPED,sig=SIGTRAP,EVENT_STOP (128)
	         ^^

	Replace suspicious popen_pid assignment with an obviously correct one.
	popen_pid = vfork() does work correctly, but for a subtle reason
	that wrong assignment of 0 happens in the child _first_,
	and _then_ correct value overwrites it in the parent.

	(And in a hyphothetical system where vfork = fork,
	popen_pid wouldn't be shared, so it will also be ok.)

	However, it's not necessary to be difficult.
	This change makes it so that assignment is done only in parent.

2013-07-01  Denys Vlasenko  <dvlasenk@redhat.com>

	Convert trace() from returning int to returning void.
	The cleanup sequence in error cases, and on normal code path
	was nearly the same, no point in duplicating it.

	Remove ia64-specific printing of current address on signal delivery.
	The address is printed anyway by printleader() if -i is active.

	Rename ia32 to ia64_ia32mode, and make it bool, not long.
	Grepping for just ia32 was turning up many false positives.

2013-06-30  Denys Vlasenko  <dvlasenk@redhat.com>

	Fold is_restart_error() into its sole user.

2013-06-29  Denys Vlasenko  <dvlasenk@redhat.com>

	Update qemu_multiarch_testing/README.

2013-06-28  Denys Vlasenko  <dvlasenk@redhat.com>

	sys_clone: add a comment about CLONE_PTRACE and CLONE_UNTRACED.
	No code changes.

	POWERPC: get rid of "static long ppc_result"

	POWERPC: read ppc_regs.nip if -i.

	POWERPC: if GETREGS fails with EIO, don't try it again.

	Get rid of powerpc_getreg(), it's a copy of upeek()

	Change upeek() to take pid, not full tcp.
	This will be used by next change.

2013-06-26  Anton Blanchard  <anton@samba.org>

	powerpc: Provide a fallback for old kernels without PTRACE_GETREGS.
	PTRACE_GETREGS was added to the ppc kernel in 2.6.23. In order to
	provide backward compatibility for very old kernels, add a manual
	fallback.

	* syscall.c (powerpc_getreg, powerpc_getregs_old): New functions.
	(get_regs): Call powerpc_getregs_old if PTRACE_GETREGS is not supported.

	powerpc: Use PTRACE_GETREGS to fetch all registers.
	* defs.h: declare ppc_regs and get_regs_error.
	* signal.c (sys_sigreturn): Use ppc_regs instead of upeek.
	* syscall.c: define ppc_regs.
	(printcall): Use ppc_regs instead of upeek.
	(get_scno): Replace multiple upeek calls with one PTRACE_GETREGS call.
	(get_syscall_result): Likewise.

2013-06-26  Denys Vlasenko  <dvlasenk@redhat.com>

	Another manpage tweak.

	Manpage update.

	Update build_static_example.sh.
	Now it also contains a tested example of i686 build on 64-bit host.

	In -f mode, do not assume that new pid is stopped - handle exits too.

	Set strace_child only in the right branch.
	"strace_child = pid" assignment was racing in NOMMU case
	because of vfork (no way to know which process would win).

	After this change, strace_child is set to nonzero only
	in one process after [v]fork.

	Get rid of TCB_INUSE and TCB_STRACE_CHILD.
	We can use tcb::pid == 0 as an indicator of free tcb,
	and we already have strace_child variable which holds
	pid of our child, if any.

2013-06-21  Denys Vlasenko  <dvlasenk@redhat.com>

	Fix debug output of wait4 result (was reusing buf[] on unknown events)

	Show PTRACE_EVENT_STOP correctly in debug output.

	Panic a bit less when we see an unknown pid.
	I stumbeld over this case when I used "exec stace ...".

	* strace.c (trace): Do not exit if we see an unknown pid in wait4.

	detach(): Reorganize code. Logic is the same.
	* strace.c (detach): Use goto's instead of excessive nesting.
	Drop sigstop_expected and interrupt_done variables.

	Eat pending SIGSTOP _before_ PTRACE_DETACH in detach()
	* strace.c (detach): If TCB_IGNORE_ONE_SIGSTOP is set,
	di not PTRACE_DETACH - wait for SIGSTOP first.

2013-06-20  Denys Vlasenko  <dvlasenk@redhat.com>

	detach(): warn if we see ECHILD from waitpid.
	* strace.c (detach): Warn if we see ECHILD from waitpid.
	Explain in comments that we don't normally expect !WIFSTOPPED
	either, and also that PTRACE_CONT failure isn't expected
	(the "break" there is a "I'm confused, bailing out" code style)..

	Improve error messages in detach()
	* strace.c (detach): Change return type from int to void.
	Improve error meesages: show PID, tell exactly which operation fails.

	Remove workarounds for ancient kernels lacking __WALL.
	__WALL is available and working at least since 2.4 kernels: 10 years ago.

	* strace (detach): Remove workarounds for ancient kernels lacking __WALL.
	Add missing EINTR check.
	(trace): Remove workarounds for ancient kernels lacking __WALL.
	Remove redundant double error printout.

	USE_SEIZE: fix detaching from stopped processes.
	V3: split SEIZE/!SEIZE code paths to reduce confusion.
	Extensively comment every possible case.
	Verified that all tests/detach* tests work in both SEIZE and !SEIZE
	cases.

	* strace.c (detach): If PTRACE_SEIZE API is in use, stop the tracee
	using PTRACE_INTERRUPT instead of sending it a SIGSTOP.
	In a subsequent waitpid loop, correctly wait and suppress SIGSTOP
	on detach if PTRACE_INTERRUPT wasn't used, or wait for any ptrace
	stop and detach without suppressing signals.

2013-06-19  Dmitry V. Levin  <ldv@altlinux.org>

	tests: disable /proc based checks when /proc is not mounted.
	* tests/detach-running: Disable /proc based checks when
	/proc/self/status is not available.
	* tests/detach-sleeping: Likewise.
	* tests/detach-stopped: Likewise.

2013-06-19  Denys Vlasenko  <dvlasenk@redhat.com>

	tests/detach-{running,sleeping,stopped}: check post-detach state.
	Check that traced process still exists and is in a right state
	after strace detached from it.

2013-06-19  Dmitry V. Levin  <ldv@altlinux.org>

	tests: ensure that strace can detach from running processes.
	* tests/detach-running: New test.
	* tests/Makefile.am (TESTS): Add it.

	tests: ensure that strace does not leave sleeping processes stopped.
	* tests/detach-sleeping: Do not send SIGCONT to the sleeping process.

2013-06-18  Dmitry V. Levin  <ldv@altlinux.org>

	tests: fix parallel-tests support in detach-* tests.
	* tests/detach-sleeping: Use $LOG file for set_ptracer_any output.
	* tests/detach-stopped: Likewise.

	tests: parametrize "sleep 1"
	* tests/init.sh (SLEEP_A_BIT): New variable.
	* tests/detach-sleeping: Use it.
	* tests/detach-stopped: Likewise.

	tests: ensure that strace can detach from sleeping and stopped processes
	* tests/set_ptracer_any.c: New file.
	* tests/detach-sleeping: New test.
	* tests/detach-stopped: Likewise.
	* tests/Makefile.am (check_PROGRAMS): Add set_ptracer_any.
	(TESTS): Add detach-sleeping and detach-stopped.
	* tests/.gitignore: Add set_ptracer_any.

	tests: enhance timeout checks.
	Run each test using a wrapper that does all necessary timeout checks.

	* tests/run.sh: New file.
	* tests/Makefile.am (EXTRA_DIST, LOG_COMPILER): Add it.
	* tests/init.sh (check_strace, check_timeout): Remove.
	* tests/detach-stopped: Update callers.
	* tests/net: Likewise.
	* tests/ptrace_setoptions: Likewise.
	* tests/qual_syscall: Likewise.
	* tests/stat: Likewise.
	* tests/strace-f: Likewise.

	tests: enable parallel-tests support.
	* configure.ac (AM_INIT_AUTOMAKE): Add parallel-tests.

	tests: prepare for parallel-tests support.
	* tests/Makefile.am (CLEANFILES): Calculate dynamically from TESTS.
	* tests/init.sh (LOG): New variable.
	* tests/detach-stopped: Use it.
	* tests/net: Likewise.
	* tests/qual_syscall: Likewise.
	* tests/stat: Likewise.
	* tests/strace-f: Likewise.

2013-06-18  Denys Vlasenko  <dvlasenk@redhat.com>

	Cleanups. No logic changes.
	* defs.h: Define new ptrace constants unconditionally.
	* strace.c (detach): Fix comment.
	(trace): Remove now unnecessary "if USE_SEIZE".

2013-06-05  Dmitry V. Levin  <ldv@altlinux.org>

	maint: post-release administrivia.
	* NEWS: Add header line for next release.

2013-06-03  Dmitry V. Levin  <ldv@altlinux.org>

	ioctlent: add UAPI support.
	* Makefile.am (IOCTLSORT_INCLUDEDIR): Define.
	(ioctlsort): Use it.
	* linux/ioctlent.sh (lookup_ioctls): Look into uapi directory tree.
	Strip "uapi/" prefix from output path names.
	* linux/ioctlent.h.in: Regenerate from v3.9 headers.
	* NEWS: Mention it.

	Prepare for 4.8 release.
	* NEWS: Update for 4.8 release.
	* debian/changelog: 4.8-1.
	* strace.spec: 4.8-1.

2013-06-02  Dmitry V. Levin  <ldv@altlinux.org>

	Fix "make dist" on recently added architectures.
	* Makefile.am (EXTRA_DIST): Add linux/aarch64/errnoent1.h,
	linux/aarch64/ioctlent.h.in, linux/aarch64/ioctlent1.h,
	linux/aarch64/signalent1.h, linux/aarch64/syscallent.h,
	linux/aarch64/syscallent1.h, linux/metag/ioctlent.h.in,
	linux/metag/syscallent.h, linux/or1k/ioctlent.h.in,
	linux/or1k/syscallent.h, linux/tile/errnoent1.h, linux/tile/ioctlent1.h,
	linux/tile/signalent1.h, linux/tile/syscallent1.h, linux/ubi-user.h,
	linux/xtensa/ioctlent.h.in, and linux/xtensa/syscallent.h.

	Fix "make dist" regression introduced by commit v4.7-184-gd648f29.
	* Makefile.am (EXTRA_DIST): Add linux/ubi-user.h.

2013-05-28  Dmitry V. Levin  <ldv@altlinux.org>

	Do not suppress signal delivery messages with -qq.
	Current implementation of -qq does not allow suppressing exit status
	messages without suppressing signal delivery messages, which is not
	good.  There is a traditional "-e signal=none" syntax that can be used
	to suppress all signal delivery messages.
	This partially reverts commit v4.7-222-g01997cf.

	* strace.c (trace): Do not suppress signal delivery messages with -qq.
	* strace.1: Update documentation about -qq option.

2013-05-23  Chris Metcalf  <cmetcalf@tilera.com>

	tile: use siginfo_t, not struct siginfo.
	As of glibc 2.16, "struct siginfo" is no longer supported,
	and "siginfo_t" must be used instead.

	tile: remove MAP_CACHE_xxx support in mem.c.
	These flags support functionality in mmap() that has not been
	pushed back to the community, and which may or may not eventually
	end up being the final community model.  In the interim, having
	these flags unconditionally present for "#ifdef TILE" just means
	that the TILE build breaks if using the community versions of
	the kernel and glibc, so just revert the code until such time
	as it may end up in the community.

2013-05-17  Mike Frysinger  <vapier@gentoo.org>

	Rename COPYRIGHT to COPYING.
	The standard name people have adopted is "COPYING" rather than
	"COPYRIGHT".  Use that as a lot of license scanning tools look for it.

	* COPYRIGHT: Rename to ...
	* COPYING: ... this.
	* Makefile.am (EXTRA_DIST): Rename COPYRIGHT to COPYING.
	* README: Likewise.
	* strace.spec (%files): Likewise.

2013-05-17  Dmitry V. Levin  <ldv@altlinux.org>

	Sync strace.spec and debian/ with packages.
	* debian/changelog: Sync with 4.7-1.
	* debian/strace.docs: Likewise.
	* strace.spec: Sync with 4.7-3.

	Update PTRACE_O_* constants.
	* process.c (ptrace_setoptions_flags): Sync with Linux 3.9.

	Update AF_*, PF_*, MSG_*, and TCP_* constants.
	* net.c (domains, addrfams, protocols, socktcpoptions): Sync with
	Linux 3.9.

2013-05-14  Dmitry V. Levin  <ldv@altlinux.org>

	NOMMU: do not hide startup syscalls unless in -D mode.
	On NOMMU systems in "strace PROG" case, we have no way to attach to
	the tracee before it calls execve unless in -D mode.  That is, the
	first execve call is very likely to be missed, and setting
	hide_log_until_execve just results to empty log.

	* strace.c (init) [NOMMU_SYSTEM]: Do not set hide_log_until_execve
	unless in -D mode.

	Make -D mode work when the Yama LSM is enabled.
	* strace.c [HAVE_PRCTL]: Include sys/prctl.h.
	(startup_child) [HAVE_PRCTL && PR_SET_PTRACER && PR_SET_PTRACER_ANY]:
	In -D mode, allow tracing the process that is going to become the
	tracee.

	Update PR_* constants.
	* process.c (prctl_options): Add PR_SET_PTRACER.

2013-05-14  Denys Vlasenko  <dvlasenk@redhat.com>

	Hide startup syscalls.
	Tested with "./strace [-D] [-q] [-bexecve] env true",
	all cases seem to work.

	* defs.h: Declare new variable: bool hide_log_until_execve.
	* strace.c: Define hide_log_until_execve.
	Rename skip_startup_execve to skip_one_b_execve.
	(startup_child): Do not set skip_one_b_execve = 1 here.
	(init): If "strace PROG" case (as opposed to "strace -pPID"),
	set skip_one_b_execve and hide_log_until_execve to 1.
	(trace): Don't print signal messages if hide_log_until_execve == 1.
	* syscall.c (trace_syscall_entering):
	Skip syscall printing if hide_log_until_execve == 1.
	Reset hide_log_until_execve if we enter execve syscall.
	(trace_syscall_exiting): Skip syscall printing if hide_log_until_execve == 1.

2013-05-13  Daniel P. Berrange  <berrange@redhat.com>

	Allow -q to be repeated for very quiet output.
	Even with the -q flag specified, tracing output is still mixed
	with messages about signals and process exit status, which is
	often irrelevant.  Allow the -q option to be repeated to force
	the suppression of signals / exit status info too.

	* defs.h: Change 'qflag' from 'bool' to 'unsigned int'.
	* strace.1: Document ability to repeat '-q' option.
	* strace.c: Allow '-q' to be repeated to quieten process
	exit status and signal messages.

2013-05-11  Dmitry V. Levin  <ldv@altlinux.org>

	mips o32: fix syscall table.
	* linux/mips/syscallent-o32.h: Add entries for getpmsg, putpmsg,
	get_mempolicy, set_mempolicy and vserver.  Fix names for umount,
	umount2, mmap, mmap2, pread64, pwrite64, sigaltstack and fstatat64
	syscalls.

2013-05-10  Dmitry V. Levin  <ldv@altlinux.org>

	mips n64: fix syscall table.
	* linux/mips/syscallent-n64.h: Add entries for get_mempolicy,
	set_mempolicy and timerfd syscalls.  Fix entry for socket syscall.
	Fix names for pread64, pwrite64, shmat, rt_sigsuspend, sigaltstack
	and umount2 syscalls.

	mips n32: fix syscall table.
	* linux/mips/syscallent-n32.h: Add entries for mbind, get_mempolicy,
	set_mempolicy and timerfd syscalls.  Fix entry for socket syscall.
	Fix handlers for truncate, ftruncate and getdents64 syscalls.
	Fix names for pread64, pwrite64, shmat, rt_sigsuspend, sigaltstack,
	umount2, and getdents64 syscalls.

2013-05-08  Dmitry V. Levin  <ldv@altlinux.org>

	sync_file_range: fix number of syscall arguments.
	* linux/avr32/syscallent.h: Set the number of sync_file_range arguments
	to 6.
	* linux/bfin/syscallent.h: Likewise.
	* linux/hppa/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent-o32.h: Likewise.
	* linux/or1k/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Change sync_file_range to
	sync_file_range2, set the number of sync_file_range2 arguments to 6.
	* linux/tile/syscallent.h: Change sync_file_range to sync_file_range2,
	set the number of sync_file_range2 arguments to 4.
	* linux/tile/syscallent1.h: Change sync_file_range to sync_file_range2.
	update handler.
	* linux/xtensa/syscallent.h: Likewise.

	Add syscall entries for new linux syscalls.
	* linux/dummy.h: Add printargs aliases for sys_finit_module, sys_kcmp
	and sys_sync_file_range2.
	* linux/alpha/syscallent.h: Add entries for process_vm_readv
	and process_vm_writev.
	* linux/bfin/syscallent.h: Likewise.
	* linux/arm/syscallent.h: Add entries for sync_file_range2, kcmp
	and finit_module.
	* linux/hppa/syscallent.h: Add entries for process_vm_readv,
	process_vm_writev, kcmp and finit_module.
	* linux/tile/syscallent.h: Likewise.
	* linux/tile/syscallent1.h: Likewise.
	* linux/ia64/syscallent.h: Add entry for finit_module.
	* linux/i386/syscallent.h: Add entries for kcmp and finit_module.
	* linux/m68k/syscallent.h: Likewise.
	* linux/metag/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent-n32.h: Likewise.
	* linux/mips/syscallent-n64.h: Likewise.
	* linux/mips/syscallent-o32.h: Likewise.
	* linux/or1k/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/x32/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/xtensa/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Add entries for s390_runtime_instr, kcmp
	and finit_module.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Add entries for kern_features, kcmp
	and finit_module.

	tests/net: fix portability issues.
	* tests/net-accept-connect.c: Fix address length passed to bind()
	and connect().
	* tests/net: Update regexps.

	tests: add a test for basic network syscalls.
	* tests/.gitignore: Add net-accept-connect, *.o and *.log.*.
	* tests/Makefile.am (AM_CFLAGS): New variable.
	(check_PROGRAMS): Add net-accept-connect.
	(TESTS): Add net.
	* tests/net-accept-connect.c: New file.
	* tests/net: New file.

	tests: do not skip tests when timeout utility is not available.
	* tests/init.sh (check_timeout): New function.
	* tests/ptrace_setoptions: Use it.
	* tests/qual_syscall: Likewise.
	* tests/stat: Likewise.
	* tests/strace-f: Likewise.

2013-05-07  Dmitry V. Levin  <ldv@altlinux.org>

	Move subcall decoding configuration out of the common code.
	* Makefile.am (EXTRA_DIST): Add linux/subcall.h.
	* linux/syscall.h (SYS_socket_subcall): Remove.
	(SYS_socket_nsubcalls, SYS_ipc_subcall, SYS_ipc_nsubcalls): Move to ...
	* linux/subcall.h: ... new file.
	* linux/arm/syscallent.h: Define SYS_socket_subcall, include subcall.h.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.

	Suggested by Mike Frysinger and Chris Metcalf.

	sparc: remove some unused declarations and macros.
	* linux/syscall.h [SPARC || SPARC64] (sys_msgsys, sys_semsys,
	sys_shmsys): Remove declarations.
	[SPARC || SPARC64] (SYS_semsys_subcall, SYS_semsys_nsubcalls,
	SYS_msgsys_subcall, SYS_msgsys_nsubcalls, SYS_shmsys_subcall,
	SYS_shmsys_nsubcalls): Remove macros.

2013-05-07  Mike Frysinger  <vapier@gentoo.org>

	mips: fix build regression.
	The recent commit (2690fadc8b35190dddd29274a7405bac13adc469) shuffled
	the mips headers around causing it to check the ABI defines before it
	included the header which set those up.  Now all mips builds fail with:
		In file included from count.c:36:0:
		defs.h:48:4: error: #error Unsupported _MIPS_SIM

	* defs.h [MIPS]: Move sgidefs.h above _MIPS_SIM check.

2013-05-07  James Hogan  <james.hogan@imgtec.com>

	metag: rename llseek syscall to _llseek.
	The raw llseek syscall is called _llseek from userland, so fix the
	naming of it for metag to allow the stat test to pass.

	* linux/metag/syscallent.h: Rename llseek syscall to _llseek.

	metag: disable socket and ipc subcall support.
	The metag architecture also uses dedicated syscalls and doesn't need to
	multiplex ipc and socket subcalls.

	* linux/syscall.h [METAG]: Do not define SYS_socket_subcall and
	SYS_ipc_subcall.

2013-05-07  Dmitry V. Levin  <ldv@altlinux.org>

	pread, pwrite: fix number of syscall arguments.
	The number of pread and pwrite arguments depends on architecture and
	personality.  For 64bit and ilp32 it equals to 4, for unaligned
	32bit it equals to 5, and for aligned 32bit it equals to 6.

	* linux/aarch64/syscallent1.h: Change the number of pread and pwrite
	arguments to 4.
	* linux/alpha/syscallent.h: Likewise.
	* linux/mips/syscallent-n32.h: Likewise.
	* linux/mips/syscallent-n64.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x32/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/or1k/syscallent.h: Change the number of pread and pwrite
	arguments to 5.

	preadv, pwritev: fix number of syscall arguments.
	The number of preadv and pwritev arguments depends on architecture and
	personality.  For 64bit and ilp32 it equals to 4, for unaligned 32bit
	it equals to 5, and for aligned 32bit it equals to 6.

	* linux/aarch64/syscallent1.h: Change the number of preadv and pwritev
	arguments to 4.
	* linux/alpha/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/mips/syscallent-n32.h: Likewise.
	* linux/mips/syscallent-n64.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x32/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Change the number of preadv and pwritev
	arguments to 6.
	* linux/sh/syscallent.h: Likewise.
	* linux/xtensa/syscallent.h: Likewise.

	ftruncate64, truncate64: fix number of syscall arguments.
	The number of ftruncate64/truncate64 arguments depends on architecture
	and personality.  For 64bit and ilp32 it equals to 2, for unaligned
	32bit it equals to 3, and for aligned 32bit it equals to 4.

	* linux/or1k/syscallent.h: Change the number of ftruncate64 and
	truncate64 arguments to 3.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Change ftruncate64 and truncate64 handlers.
	* linux/sparc/syscallent.h: Change ftruncate64 handler, change the
	number of its arguments to 3.
	* linux/xtensa/syscallent.h: Change the number of ftruncate64 and
	truncate64 arguments to 4.

	fallocate: fix number of syscall arguments.
	The number of fallocate arguments depends on architecture and
	personality.  For 64bit and ilp32 it equals to 4,
	for 32bit it equals to 6.

	* linux/aarch64/syscallent1.h: Change the number of fallocate arguments
	to 4.
	* linux/alpha/syscallent.h: Likewise.
	* linux/mips/syscallent-n32.h: Likewise.
	* linux/mips/syscallent-n64.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x32/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Set fallocate handler and flags.

	fadvise64, fadvise64_64: fix handlers and number of syscall arguments.
	The number of fadvise64 arguments depends on architecture and
	personality.  For 64bit and ilp32 it equals to 4, for unaligned
	32bit it equals to 5, and for aligned 32bit it equals to 6.

	The number of fadvise64_64 arguments is 4 for 64bit and ilp32, for
	unaligned 32bit and most of aligned 32bit it equals to 6, and for
	mips o32 it equals to 7.

	* linux/alpha/syscallent.h: Set fadvise64 handler.
	* linux/s390/syscallent.h: Likewise.
	* linux/hppa/syscallent.h: Set fadvise64_64 handler, change the number
	of syscall arguments to 6.
	* linux/ia64/syscallent.h: Change the number of fadvise64 arguments
	to 4.
	* linux/mips/syscallent-n32.h: Likewise.
	* linux/tile/syscallent1.h: Change the number of fadvise64 arguments
	to 5.
	* linux/mips/syscallent-o32.h: Change the number of fadvise64_64
	arguments to 7.
	* linux/s390x/syscallent.h: Change fadvise64_64 handler.  Set fadvise64
	handler.  Change numbers of fadvise64 and fadvise64_64 arguments to 4.
	* linux/sh64/syscallent.h: Change fadvise64_64 handler.
	Change numbers of fadvise64 and fadvise64_64 arguments to 4.
	* linux/sparc/syscallent.h: Set fadvise64 and fadvise64_64 handlers,
	change numbers of their arguments to 5 and 6.
	* linux/x86_64/syscallent.h: Change fadvise64 handler.

	mips o32: raise the max number of syscall arguments to 7.
	On mips o32, fadvise64_64 takes 7 arguments.

	* defs.h [LINUX_MIPSO32]: Raise MAX_ARGS to 7.

	mips: split syscallent.h.
	linux/mips/syscallent.h consisted of several parts that had little in
	common.  Split them into separate files to ease maintenance.

	* linux/mips/syscallent-compat.h: New file.
	* linux/mips/syscallent-n32.h: Likewise.
	* linux/mips/syscallent-n64.h: Likewise.
	* linux/mips/syscallent-o32.h: Likewise.
	* linux/mips/syscallent.h: Include them.
	* Makefile.am (EXTRA_DIST): Add them.

	readahead: fix number of syscall arguments.
	The number of readahead arguments depends on architecture and
	personality.  For 64bit and ilp32 it equals to 3, for unaligned 32bit it
	equals to 4, and for aligned 32bit it equals to 5.

	* linux/aarch64/syscallent1.h: Set number of readahead arguments to 3.
	* linux/alpha/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/x32/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/or1k/syscallent.h: Set number of readahead arguments to 4.
	* linux/sh/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/xtensa/syscallent.h: Set number of readahead arguments to 5.

2013-05-06  Dmitry V. Levin  <ldv@altlinux.org>

	linux/syscall.h: make subcall decoding configuration more readable.
	* linux/syscall.h: Inverse and sort the subcall ifdef,
	add a comment why subcall decoding support is not enabled
	on some architectures.

2013-05-06  Chris Zankel  <chris@zankel.net>

	xtensa: disable socket and ipc subcall support.
	The Xtensa architecture also uses dedicated syscalls and doesn't
	need to multiplex ipc and socket subcalls.

	* linux/syscall.h [XTENSA]: Do not define SYS_socket_subcall and
	SYS_ipc_subcall.

2013-05-06  Dmitry V. Levin  <ldv@altlinux.org>

	Fix syscall flags.
	* linux/aarch64/syscallent1.h: Fix syscall flags for send.
	* linux/alpha/syscallent.h: Fix syscall flags for fchdir, getcwd,
	oldumount, sigaltstack, umount, uselib, and utimes.
	* linux/arm/syscallent.h: Fix syscall flags for close, creat, dup, dup2,
	fchdir, fchmod, fchown, fchown32, fcntl, fcntl64, fdatasync, flock,
	fsetxattr, fsync, getdents, getdents64, ioctl, oldfstat, oldselect,
	open, pipe, poll, pread, pwrite, read, readahead, readdir, readv,
	select, socketcall, write, and writev.
	* linux/avr32/syscallent.h: Fix syscall flags for inotify_init and
	unshare.
	* linux/bfin/syscallent.h: Fix syscall flags for pread64 and pwrite64.
	* linux/hppa/syscallent.h: Fix syscall flags for fchdir, flistxattr,
	getcwd, pause, signal, umount2, uselib, utime, and vfork.
	* linux/ia64/syscallent.h: Fix syscall flags for creat, fchdir,
	lstat, umount, uselib, and utimes.  Fix syscall handlers for
	fgetxattr, flistxattr, fremovexattr, and fsetxattr.
	* linux/m68k/syscallent.h: Fix syscall flags for close, creat, dup,
	dup2, fchdir, fchmod, fchown, fchown32, fcntl, fcntl64, fdatasync,
	flock, fsetxattr, getdents, ioctl, oldfstat, oldselect, open, pipe,
	poll, pread64, pwrite64, read, readahead, readdir, readv, select,
	socketcall, write, and writev.
	* linux/metag/syscallent.h: Fix syscall flags for fanotify_init,
	prlimit64, process_vm_readv, process_vm_writev, and quotactl.
	* linux/microblaze/syscallent.h: Fix syscall flags for close, creat,
	dup, dup2, fchdir, fchmod, fchown, fchown32, fcntl, fcntl64,
	fdatasync, flock, fsetxattr, getdents, ioctl, oldfstat, oldselect,
	open, perf_event_open, pipe, poll, pread64, pwrite64, read, readahead,
	readdir, readv, select, socketcall, write, and writev.
	* linux/mips/syscallent.h: Fix syscall flags for close, creat, dup,
	dup2, fchdir, fchmod, fchown, fcntl, fcntl64, fdatasync, flock,
	fsetxattr, getdents, getdents64, getxattr, ioctl, lgetxattr,
	listxattr, llistxattr, lremovexattr, lsetxattr, oldfstat, open, pipe,
	pivot_root, poll, pread, pwrite, read, readahead, readv, removexattr,
	select, setxattr, socketcall, statfs, write, and writev.
	* linux/or1k/syscallent.h: Fix syscall flags for fchdir and quotactl.
	* linux/powerpc/syscallent.h: Fix syscall flags for fchdir.
	* linux/sh/syscallent.h: Fix syscall flags for getcwd.
	* linux/sparc/syscallent.h: Fix syscall flags for getresgid, getresuid,
	setresgid, setresgid32, and setresuid.
	* linux/xtensa/syscallent.h: Fix syscall flags for close, creat, dup,
	dup2, fallocate, fchdir, fchmod, fchown, fcntl, fcntl64, fdatasync,
	flock, fsetxattr, fstatfs, fstatfs64, fsync, getdents, getdents64,
	ioctl, open, pipe, pivot_root, poll, pread64, pwrite64, read,
	readahead, readv, rt_sigreturn, select, setfsgid, setfsuid, setuid,
	swapoff, times, utime, write, and writev.

	tests/stat: enhance regexps.
	* tests/stat: Enhance regexps that check tracing of stat/stat64 and
	fstatat/fstatat64 syscalls.

2013-05-06  Chris Metcalf  <cmetcalf@tilera.com>

	tests/stat: support fstatat syscall for stat()
	Newer Linux architectures don't support the stat/stat64 syscalls.
	Instead they use fstatat() with AT_FDCWD and an extra flags argument.
	Support seeing this output in the 'strace -efile' test.

	As part of this change, use "grep -E -x" syntax consistently for
	all stat tests, since the number of \(foo\)\? expressions was becoming
	pretty unwieldy.

	* tests/stat: Update stat/stat64 check regexp to handle architectures
	that use fstatat instead.  Use "grep -E -x" syntax consistently.

2013-05-06  Dmitry V. Levin  <ldv@altlinux.org>

	ARM OABI: fix 64-bit arguments decoding.
	ARM OABI and ARM EABI have different function parameters passing rules,
	see commit v4.6-11-g7a5b08f for details.

	* util.c (printllval): Do not align argument number in case of ARM OABI.
	* file.c (sys_fadvise64_64): Likewise.

2013-05-06  Mike Frysinger  <vapier@gentoo.org>

	printllval: fix 64bit unpacking on mips/o32 and xtensa.
	The mips/o32 ABI and xtensa arch also do 64bit aligning, so add it to the
	printllval list for this.

	Normally for sys_fadvise64_64 we'd handle the same list of arches, but
	mips/o32 ABI is funky and doesn't shift -- it has 7 args.  So just add
	xtensa to it.

	* file.c (sys_fadvise64_64): Add XTENSA to the shifted list.
	* util.c (printllval): Add LINUX_MIPSO32 and XTENSA to the shifted list.

2013-05-06  Chris Metcalf  <cmetcalf@tilera.com>

	tile: disable socket and ipc subcall support.
	The tile arch just has the dedicated syscalls, so disable
	the logic for parsing subcalls.

	* linux/syscall.h [TILE]: Do not define SYS_socket_subcall and
	SYS_ipc_subcall.

2013-05-06  Mike Frysinger  <vapier@gentoo.org>

	Blackfin: disable socketcall and ipc subcall support.
	The Blackfin arch does not have a socketcall or ipc subcall
	(it has dedicated syscalls broken out), so disable the logic for it.

	* linux/syscall.h [BFIN]: Do not define SYS_socket_subcall and
	SYS_ipc_subcall.

2013-05-05  Mike Frysinger  <vapier@gentoo.org>

	s390: fix # of args truncate64/ftruncate64 takes.
	* linux/s390/syscallent.h: Change nargs to 3 for truncate64/ftruncate64.

	mtd: clamp ubi name strings.
	Since the length fields with the ubi volnames are signed 16bit values,
	make sure we clamp that number to the size of the buffer we've allocated
	on the stack to prevent buffer overflows.

	* mtd.c (ubi_ioctl): Clamp length to string_quote to 0/UBI_MAX_VOLUME_NAME.
	Check the return of string_quote and tweak the output accordingly.

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

	printxval: support more architectures.
	* configure.ac: Define SIZEOF_LONG_LONG.
	* util.c (printllval): Handle all architectures with sizeof(long) > 4
	and sizeof(long) == sizeof(long long).

2013-05-04  Mike Frysinger  <vapier@gentoo.org>

	Fix building for sparc64 targets.
	* util.c (printllval): Handle SPARC64 define.

	Fix building for mips n64 targets.
	* util.c (printllval): Handle LINUX_MIPSN64 define.

2013-05-03  Dmitry V. Levin  <ldv@altlinux.org>

	hppa: fix stat64 and fstat64 decoding.
	* file.c [HPPA]: Do not redefine stat64 to hpux_stat64.

	arm, aarch64, ppc: fix printllval-based decoders.
	* util.c (printllval) [ARM || POWERPC]: Align argument number.
	[AARCH64]: Align argument number in 32bit mode.
	* file.c (sys_fadvise64_64) [ARM || POWERPC]: Remove no longer needed
	printllval workaround.
	[AARCH64]: Fix printing POSIX_FADV_* constants in 32bit mode.

2013-05-02  Mike Frysinger  <vapier@gentoo.org>

	Decode mtd/ubi ioctls.
	Been playing with UBI of late and it'd help if I could see what it was
	doing.  Not entirely sure about the decoding of UBI_IOCVOLUP -- it takes
	a pointer to a 64bit value, not a strict.

	* util.c (MAX, MIN): Move to ...
	* defs.h (MAX, MIN): ... here.
	(CLAMP): Define.
	(ubi_ioctl): New prototype.
	* ioctl.c (ioctl_decode): Call ubi_ioctl when code is 'o' or 'O'.
	* mtd.c: Include ubi user API header.
	(ubi_volume_types): New enum decode.
	(ubi_volume_props): Likewise.
	(ubi_ioctl): Define.
	* linux/ubi-user.h: Import from linux 3.8.

	test: add mtd/ubi test helpers.
	I used these to develop the mtd/ubi ioctl decoders.

	* test/.gitignore: Add mtd/ubi.
	* test/Makefile: Declare all tests in a PROGS var.
	Declare build targets .PHONY.
	(all): Depend on $(PROGS) instead of hardcoded list.
	(clean): Remove $(PROGS) instead of hardcoded list.
	* test/mtd.c: New file.
	* test/ubi.c: Likewise.

	test: include headers for used funcs.
	These funcs use things like wait/write/read/strcmp but sometimes
	don't include the right header for them.

	* test/Makefile: Add -Wall to CFLAGS.
	* test/clone.c: Include unistd.h.
	* test/fork.c: Include sys/wait.h.
	* test/sig.c: Include unistd.h.
	* test/sigkill_rain.c: Include sys/wait.h.
	* test/vfork.c: Include sys/wait.h.
	* test/wait_must_be_interruptible.c: Include string.h

2013-05-02  Dmitry V. Levin  <ldv@altlinux.org>

	ia64: fix compilation warnings introduced by commit v4.7-174-g44f0ed1.
	* linux/ia64/syscallent.h: Undefine sys_oldlstat, sys_lstat and
	sys_lstat64 before redefining them to printargs.

	Reported-by: Mike Frysinger <vapier@gentoo.org>

2013-05-02  Mike Frysinger  <vapier@gentoo.org>

	tests: stat: fix clean up of sample file.
	* tests/stat: Also rm the sample file at the end of the test.

	Ignore more files.
	* .gitignore: Add gdb related files.
	* tests/.gitignore: Ignore test logs.

2013-05-02  Dmitry V. Levin  <ldv@altlinux.org>

	x32: fix decoding of i386 truncate and ftruncate syscalls.
	* linux/x32/syscallent1.h: Remove sys_*truncate64 redirections.

	x32: fix printllval-based decoders of i386 syscalls.
	* util.c (printllval) [X32]: Handle i386 personality.

	tests: add basic test for ftruncate, lseek and stat family syscalls.
	* tests/stat: New test.
	* tests/Makefile.am (TESTS): Add stat.

2013-05-01  Dmitry V. Levin  <ldv@altlinux.org>

	x32: fix build regressions introduced by commit v4.7-96-g8435d67.
	* desc.c (printflock) [X32]: Add special handling required for
	this architecture with sizeof(long) < sizeof(off_t).
	* file.c [X32] (struct stat64): Add __attribute__((packed)).
	[X32] (HAVE_STAT64): Define.
	(printstat) [X32]: Redirect to printstat64.
	(printstat64) [X32]: Use "struct stat" instead of "struct stat64".
	[X32] (realprintstat64): Rename to printstat64_x32.
	(sys_stat64, sys_fstat64) [X32]: Remove second definitions of these
	functions.  Call printstat64_x32 instead of printstat64
	* linux/x32/syscallent.h: Fix handlers for truncate and ftruncate.

	Alias sys_*lstat* syscall printing functions.
	* file.c (sys_lstat, sys_lstat64, sys_oldlstat): Remove.
	* linux/dummy.h: Move !HAVE_STRUCT___OLD_KERNEL_STAT aliases forward.
	(sys_lstat): Alias to sys_stat.
	(sys_lstat64): Alias to sys_stat64.
	(sys_oldlstat): Alias to sys_oldstat.
	* linux/syscall.h (sys_lstat, sys_lstat64, sys_oldlstat): Remove.
	* linux/x32/syscallent1.h (sys_lstat64): Remove.

	x86_64: decode __old_kernel_stat based syscalls.
	* linux/x86_64/syscallent1.h: Remove sys_old*stat redirections.

	x32: fix decoding of __old_kernel_stat based syscalls.
	* file.c [X32] (struct __old_kernel_stat): Define.
	* linux/x32/syscallent1.h: Remove sys_old*stat redirections.

2013-05-01  James Hogan  <james.hogan@imgtec.com>

	test/threaded_execve: fix on metag.
	The metag ABI has stacks growing upwards so clone expects the stack
	argument to point at the bottom of the stack instead of the top.

	* test/threaded_execve.c [__metag__]: Define clone2 differently
	to avoid a segfault at runtime.

	test/skodic: make a bit more portable.
	* test/skodic.c (main): Don't use MAP_FIXED since valid virtual addresses
	vary between architectures (as far as I can tell the use of MAP_FIXED is
	not relevant to the test).  Also don't assume the file desriptor returned
	by open call is 3 when passing it to mmap.

2013-05-01  Mike Frysinger  <vapier@gentoo.org>

	printllval: handle s390x.
	This is a 64bit arch w/no personalities, so fix printing.
	It can now trace a simple call like readahead:
	$ cat test.c
	main(){readahead(-1, (unsigned long long)1 << 50, 0);}
	$ gcc test.c
	$ ./strace -ereadahead ./a.out
	readahead(-1, 1125899906842624, 0)      = -1 EBADF (Bad file descriptor)

	* util.c (printllval): Handle S390X define.

	Stop using old AM_CONFIG_HEADER macro.
	Building with automake-1.13 throws an error:
	configure.ac:6: error: 'AM_CONFIG_HEADER': this macro is obsolete.
	    You should use the 'AC_CONFIG_HEADERS' macro instead.

	* configure.ac (AM_CONFIG_HEADER): Rename to AC_CONFIG_HEADERS.

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

	build: introduce git-version-gen.
	* .gitignore: Add .version.
	* Makefile.am (EXTRA_DIST, BUILT_SOURCES): Add $(srcdir)/.version.
	Add rules to check NEWS, generate $(srcdir)/.version and
	$(distdir)/.tarball-version files.
	Change ChangeLog and CREDITS generation rules to depend on
	$(srcdir)/.version instead of $(srcdir)/.git/refs/heads/*.
	* NEWS: Add dates to recent releases.
	* configure.ac (AC_INIT): Use git-version-gen.
	(AM_INIT_AUTOMAKE): Remove check-news.
	* git-version-gen: Import from gnulib.
	* make-dist: Check NEWS.

	Makefile.am: sort long lists to ease maintenance.
	* Makefile.am (strace_SOURCES, EXTRA_DIST): Sort, place one list element
	per line.

	build: fix "make dist" regression introduced by commit v4.7-105-g7270de5
	* Makefile.am (EXTRA_DIST): Remove linux/arm/syscallent1.h,
	linux/arm/signalent1.h, linux/arm/ioctlent1.h and linux/arm/errnoent1.h.

	build: fix "make dist" regression introduced by commit v4.7-29-g17e3860.
	* Makefile.am (EXTRA_DIST): Add linux/ioctlent-filter.awk.

2013-04-30  Mike Frysinger  <vapier@gentoo.org>

	Blackfin: tweak sram_alloc syscall decode.
	* system.c (sys_sram_alloc): The 2nd argument of sram_alloc syscall
	is a bit field, not a specific value, so decode it as such.

2013-03-31  Zev Weiss  <zev@bewilderbeest.net>

	Print io_submit() offsets in decimal.
	This makes output formatting more consistent with pread()/pwrite(),
	which print their offset parameters in decimal.

	* desc.c (sys_io_submit): Change offset output format from %llx to %lld.

2013-03-30  Andreas Schwab  <schwab@suse.de>

	Fix building outside source directory.
	The file linux/ioctlent.h is generated in the build directory, so
	"../ioctlent.h" won't find it.

	* linux/aarch64/ioctlent1.h: Remove "../" from include file name.
	* linux/powerpc/ioctlent1.h: Likewise.
	* linux/tile/ioctlent1.h: Likewise.
	* linux/x32/ioctlent1.h: Likewise.
	* linux/x86_64/ioctlent1.h: Likewise.
	* linux/x86_64/ioctlent2.h: Likewise.

	AArch64: Fix printing of long long value.
	* util.c (printllval): Fix printing of long long values on
	AArch64.

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

	Update PR_* constants.
	* process.c (prctl_options): Add more PR_* constants from linux/prctl.h.

2013-03-25  Chris Zankel  <chris@zankel.net>

	Add support for the XTENSA architecture.
	* configure.ac: Add XTENSA to the list of supported architectures.
	* defs.h: Add XTENSA support.
	* linux/xtensa/syscallent.h: New file.
	* linux/xtensa/ioctlent.h.in: Likewise.
	* process.c (struct_user_offsets): Add XTENSA support.
	* signal.c (sys_sigreturn): Likewise.
	* syscall.c (printcall, get_scno, get_syscall_args,
	  get_syscall_result, get_error): Likewise.
	* util.c (change_syscall): Likewise.

2013-03-22  Denys Vlasenko  <vda.linux@googlemail.com>

	Add example script which builds static (possibly cross-compiled) strace.

2013-03-21  Dmitry V. Levin  <ldv@altlinux.org>

	Use 64-bit versions of stat, readdir and setrlimit functions when available
	strace already has a mechanism to use fopen64 for output when the 64-bit
	version of fopen is available on 32-bit architectures.  Apply this
	mechanism for other three functions to make strace fully adopted for
	64-bit types.

	* strace.c (struct_stat, stat_file, struct_dirent, read_dir,
	struct_rlimit, set_rlimit): New macros.
	(startup_attach): Use read_dir.
	(startup_child): Use struct_stat and stat_file.
	(main): Use struct_rlimit and set_rlimit.

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

	Do not use struct dirent in readdir decoding.
	struct dirent from libc should not be used for umove'ing into because it
	contains fixed size d_name.

	* file.c (printdir): Rename to print_old_dirent.
	[SH64]: Decode using struct kernel_dirent.
	[!SH64]: Decode using an open-coded struct with 32-bit d_ino and d_off.
	(sys_readdir): Update.

	Do not use off_t in sendfile decoding.
	sendfile parser used to decode off_t* parameter as a pointer to host
	off_t type.  With this change, it is decoded as a pointer to target long
	type.

	* io.c (print_off_t): New function.
	(sys_sendfile): Use it.
	* linux/aarch64/syscallent1.h: Use sys_sendfile64 for sendfile decoding.
	* linux/tile/syscallent.h: Likewise.
	* linux/x32/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/hppa/syscallent.h: Use sys_sendfile64 for sendfile64 decoding.
	* linux/metag/syscallent.h: Correct sendfile syscall name.
	* linux/or1k/syscallent.h: Likewise.

2013-03-18  Dmitry V. Levin  <ldv@altlinux.org>

	Fix build with older versions of libaio.h.
	* configure.ac: When libaio.h is available, check for
	struct iocb.u.c.flags, IO_CMD_PWRITE and IO_CMD_PWRITEV.
	* desc.c (print_common_flags): Check for HAVE_STRUCT_IOCB_U_C_FLAGS.
	(sys_io_submit): Check for HAVE_DECL_IO_CMD_PWRITE and
	HAVE_DECL_IO_CMD_PWRITEV.

	Fix io_submit decoding.
	* desc.c (print_common_flags, sys_io_submit): Add missing ", " to
	SUB_COMMON output, remove extra ", " from SUB_VECTOR output.

2013-03-18  Maxin B. John  <maxin.john@enea.com>

	tests: relax check_prog to allow timeout command provided by busybox.
	Busybox version of timeout doesn't have --version option.
	Relax check_prog to handle those cases.

	* tests/init.sh (check_prog): Use type builtin to check program
	availability.

2013-03-18  Dmitry V. Levin  <ldv@altlinux.org>

	Reorganize get_regs code, hopefully without functional changes.
	* syscall.c [I386 || ARM || OR1K || METAG] (ARCH_REGS_FOR_GETREGSET):
	New macro.
	(get_regset): Implement for AARCH64, METAG, OR1K and X32.
	(get_regs) [AARCH64 || METAG || OR1K || X32]: Use it.

	arm, i386: use PTRACE_GETREGSET if available.
	* syscall.c [ARM || I386 || X86_64] (get_regset): New function.
	(get_regs) [ARM || I386 || X86_64]: Use it.

	Include <sys/uio.h> and <elf.h> on all architectures.
	* syscall.c: Include <sys/uio.h> and <elf.h> on all architectures.

	x86-64: enhance PTRACE_GETREGSET test.
	* syscall.c (get_regs) [X86_64]: Check whether PTRACE_GETREGSET
	works regardless of the kernel version.

	x32: use PTRACE_GETREGSET unconditionally.
	* syscall.c (get_regs) [X32]: Assume that PTRACE_GETREGSET always works
	regardless of the kernel version.

	x86-64, x32: do not include linux/ptrace.h unnecessarily.
	* syscall.c [X86_64 || X32]: Stop including linux/ptrace.h.

	i386, tile, x32: do not redefine ptrace prototype.
	* defs.h [I386 || TILE || X32]: Use ptrace prototype from sys/ptrace.h.

	ptrace: decode note segment descriptor types.
	* configure.ac (AC_CHECK_HEADERS): Add elf.h.
	* process.c: Include elf.h.
	(nt_descriptor_types): New xlat structure.
	(sys_ptrace): Use it.

2013-03-14  Dmitry V. Levin  <ldv@altlinux.org>

	Update MADV_* constants.
	* mem.c (madvise_cmds): Add more MADV_* constants from
	asm-generic/mman-common.h

	Reported-by: Robin Hack <hack.robin@gmail.com>

2013-03-07  Denys Vlasenko  <vda.linux@googlemail.com>

	Tweaks for -c: fixed setitimer/getitimer hack; optimized call_summary_pers()
	count_syscall() was calling setitimer/getitimer once in order to find
	smallest "tick" OS uses in time accounting, in order to use it
	for syscalls which apparently spent less than that time in syscall.
	The code assumed that this "tick" is not zero... but it is zero
	on linux-3.6.11. Which means that this hack doesn't work...

	At least this change prevents this measurement from being done
	_repeatedly_, by initializing one_tick to -1, not 0.

	While at it, added comments in count_syscall() explaining what we are doing.

	Optimized call_summary_pers() a bit, by eliminating redundant tv -> float
	conversions, and prevented 0.0/0.0 which was resulting in "% time"
	being shown as "-nan" if total CPU time spent was 0.000000
	(try "strace -c /bin/true").

	The code seems to seriously underestimate CPU usage:
	"strace -c ls -lR /usr/share >/dev/null" shows total time spent
	in syscalls to be only ~10..20% of what "time ls -lR /usr/share >/dev/null"
	shows.

	It might be useful to have a mode where we show wall clock time
	spent in syscalls, not CPU time. It might also be more accurate.

	   text	   data	    bss	    dec	    hex	filename
	 245019	    676	   5708	 251403	  3d60b	strace_old
	 244923	    684	   5676	 251283	  3d593	strace

2013-03-06  Denys Vlasenko  <vda.linux@googlemail.com>

	Open-code isprint(c) and isspace(c)
	We don't call setlocale, thus we always use C locale.
	But libc supports various other locales, and therefore
	its ctype interface is general and at times inefficient.
	For example, in glibc these macros result in function call,
	whereas for e.g. isprint(c) just c >= ' ' && c <= 0x7e
	suffices.

	By open-coding ctype checks (we have only 4 of them)
	we avoid function calls, we get smaller code:

	   text	   data	    bss	    dec	    hex	filename
	 245127	    680	   5708	 251515	  3d67b	strace_old
	 245019	    676	   5708	 251403	  3d60b	strace

	and we don't link in ctype tables (beneficial for static builds).

	Makefile: add commented-out tweak to generate link map.

	Stop using a large static buffer in getfdpath.
	   text	   data	    bss	    dec	    hex	filename
	 245075	    680	   9836	 255591	  3e667	strace_old
	 245143	    680	   5708	 251531	  3d68b	strace

2013-03-05  Denys Vlasenko  <vda.linux@googlemail.com>

	Fix wrongly indented closing curly brace. No code changes.

	strace_vfprintf: if malloc fails, exit gracefully.

2013-03-05  Dmitry V. Levin  <ldv@altlinux.org>

	Use sysconf(_SC_PAGESIZE) instead of hardcoded PAGE_SHIFT.
	PAGE_SHIFT couldn't be reliably obtained at compile time,
	thanks to Chris Metcalf for the hint.

	* mem.c: Do not include <sys/user.h>.
	[SH64] Do not include <asm/page.h>.
	(get_pagesize): New function.
	(sys_mmap_pgoff, sys_old_mmap_pgoff): Use it.

2013-03-05  Denys Vlasenko  <vda.linux@googlemail.com>

	Emit better message for ERESTARTNOHAND return.

	Disable STREAMS syscalls for non-SPARC.
	   text	   data	    bss	    dec	    hex	filename
	   3002	      0	   1024	   4026	    fba	stream.o.old
	   1729	      0	   1024	   2753	    ac1	stream.o

	Fix printstrbufarg's address argument to be long, not int.

	Remove variable tracing_paths and check in pathtrace_match.

	Use dynamically-sized selected[] array for -P PATH.
	While at it, added a small optimization of not remembering
	the path twice if it happens to be the same.

	   text	   data	    bss	    dec	    hex	filename
	 245111	    680	  10860	 256651	  3ea8b	strace_old
	 245075	    680	   9804	 255559	  3e647	strace

	metag,or1k: whitesace style fix. no code changes.

	Assorted fixes to syscallent.h.
	or1k was missing TM on many memory-related syscalls
	sys_lookup_dcookie is 3-arg on 64-bit arches, and isn't TF
	sys_recvmsg is 3-arg on all arches
	sys_nfsservctl is 3-arg on all arches
	sys_timerfd_create is 2-arg on all arches
	sys_[f]truncate64 is 4-arg or 3-arg, never 5-arg
	truncate64 is TF
	sys_[l]lseek is TD
	fstat[64] is TD

2013-03-05  James Hogan  <james.hogan@imgtec.com>

	Add support for Imagination Technologies Meta.
	Add support for Imagination Technologies Meta architecture (the
	architecture/ABI is usually referred to as metag in code). The Meta
	Linux kernel port is in the process of being upstreamed for v3.9 so it
	uses generic system call numbers.

	sys_lookup_dcookie writes a filename to buffer argument, so I've set
	TF flag.
	nfsservctl appears to be set to sys_ni_syscall in asm-generic/unistd.h
	so I've left it blank.
	truncate64/ftruncate64/pread64/pwrite64/readahead have unaligned 64bit
	args which are packed tightly on metag, so less arguments on metag.
	fchdir/llseek takes a file descriptor so s/TF/TD/
	sync_file_range has 2 64bit args so uses 6 args, so s/4/6/
	timerfd_create/msgget/msgctl/msgrcv/semget/segtimedop/semop/shmget/
	shmctl/shmat/shmdt/recvmsg/migrate_pages have different number of args.
	oldgetrlimit is just getrlimit for metag.
	add TM flag to various memory syscalls.
	metag doesn't directly use sys_mmap_pgoff for mmap2.
	prlimit64/process_vm_readv/process_vm_writev take a pid so add TP flag.
	fanotify_init doesn't appear to take a file descriptor so remove TD.
	Add kcmp syscall.

	Cc: Christian Svensson <blue@cmd.nu>

2013-03-01  Denys Vlasenko  <vda.linux@googlemail.com>

	umovestr: speed up check for NUL byte in the fetched word.

2013-03-01  Dmitry V. Levin  <ldv@altlinux.org>

	Fix trace=set regression introduced by commit v4.7-111-g9cbc15b.
	* syscall.c (qual_syscall, qualify): Pass personality down to
	qualify_one.
	* tests/qual_syscall: New test.
	* tests/Makefile.am (TESTS): Add qual_syscall.

2013-03-01  Chris Metcalf  <cmetcalf@tilera.com>

	tile: handle printllval like x86_64 or powerpc64.
	Without this fix the tilegx build fails when it hits the new #error
	about SIZEOF_LONG > 4.

	* util.c (printllval): Fix printing of long long values on TILE.

2013-02-27  Denys Vlasenko  <vda.linux@googlemail.com>

	Make -b take SYSCALL param, document it in --help and in manpage.
	To not waste an option letter for just one trick,
	extend -b to take a parameter:
	"on which syscalls do you want to detach?".
	Currently supports only execve.

	While at it, fixed (by removing non-Linux and stale info)
	and extended manpage text about -f.

2013-02-26  Dmitry V. Levin  <ldv@altlinux.org>

	Cleanup umoven and umovestr.
	Cleanup sloppy error handling.

	First, EFAULT kind of errors from process_vm_readv by itself is not
	something unusual, so a warning message will not be issued unless a
	short read is detected.

	Second, clients of umoven and umovestr are not prepared to detect and
	handle short reads that can happen in these functions.  The most safe
	way to handle them is to return an error code.

	* util.c (umoven, umovestr): Cleanup handling of errors coming from
	process_vm_readv and PTRACE_PEEKDATA.

	pathtrace: fix umovestr return code check.
	* pathtrace.c (upathmatch): Only NUL-terminated strings can be
	path-matched, so fix the umovestr return code check to filter out
	unsuitable strings.

	Fix compilation errors uncovered by -Werror=enum-compare.
	This fixes regression introduced by commit v4.7-111-g9cbc15b.

	* syscall.c: Merge all nsyscalls* enums into single enum.
	Likewise merge nerrnos*, nsignals*, and nioctlents* into single enums.

2013-02-26  Denys Vlasenko  <vda.linux@googlemail.com>

	Mass replace error_msg("%s", "literal") -> error_msg("literal")
	There is no need to print literal strings through "%s".
	Only untrusted strings such as filenames need that.

2013-02-26  Ben Noordhuis  <info@bnoordhuis.nl>

	Make umoven report success as 0, not >=0, stop returning success on partial reads
	umoven() uses process_vm_readv() when available but it returns the
	return value of that syscall, which is the number of bytes copied,
	while its callers expect it to simply return zero on success.

	It was causing syscalls that take a user-space argument to print
	the abbreviated version, e.g.:

	  epoll_ctl(5, EPOLL_CTL_ADD, 10, {...})

	Instead of:

	  epoll_ctl(5, EPOLL_CTL_ADD, 10, {EPOLLIN, {u32=10, u64=10}})

	* util.c (umoven): Make umove[n] report success as 0, not >=0,
	stop returning "success" on partial reads.

2013-02-26  Denys Vlasenko  <vda.linux@googlemail.com>

	Assorted NOMMU fixes.
	With -D, strdup'ing of pathname is necessary only on NOMMU.

	Don't set skip_startup_execve to 1 if NOMMU and not in daemonized mode
	(try "strace [-D] -b env echo HI" to see whether we detach on correct execve).

	Fix test_ptrace_FOO shortcuts on NOMMU to always assume success
	and _properly_ set all variables.

	Shorten help text - no need to show deprecated option -F.

2013-02-23  Denys Vlasenko  <vda.linux@googlemail.com>

	Merge adjacent tprint's.

	Correct i > MAX_NSYSCALLS commparison: should be i >= MAX_NSYSCALLS.

2013-02-22  Denys Vlasenko  <vda.linux@googlemail.com>

	Fix wrong offset display in dumpstr.
	BTW, the new code from prev commit is 5 times faster
	than old one :)

	Fix a bug in dumpstr (no null termination). Essentially rewrote dumpstr.
	This is a 14 year old bug (!).

	It wasn't biting us merely because outstr[80] was static, thus ended up
	in bss and whatever was after it "accidentally" provided the NUL byte.
	When dumpstr was changed to use on-stack buffer, the bug reared its ugly head.

	This is a rewrite which is smaller and should be significantly faster
	for _long_ strings.

	   text	   data	    bss	    dec	    hex	filename
	 244627	    680	  10860	 256167	  3e8a7	strace.t9/strace
	 244563	    680	  10860	 256103	  3e867	strace.ta/strace

	* util.c (dumpstr): Rewrite to be faster and smaller.

	Eliminate MAX_QUALS, make qualifier array dynamic.
	MAX_QUALS was 2048, even though most arches used less than 500 entries
	in it. MAX_QUALS had to be maintained by hand to be higher than syscall
	count. It also limited the highest possible fd to track.

	This change makes qual_flagsN[] arrays start sized to the required minimum
	(number of syscalls) and grow dynamically if user requested
	-e read=BIGNUM. As a precaution, BIGNUM should be < 2^15, but this limit
	can be raised with no cost for normal strace invocations.

	qual_flags is now a define to qual_vec[current_personality].

	As a bonus, this patch aliases sysent, errnoent, signalent, ioctlent
	names in one-personality arches to their corresponding <foo>0 arrays,
	removing one indirection level.

	  text   data    bss    dec    hex filename
	244471    700  12928 258099  3f033 strace.t7/strace
	244627    680  10860 256167  3e8a7 strace.t8/strace

	Create and use struct_sysent and struct_ioctlent typedefs.
	This is a preparatory mass replace patch with no code changes.

	The future change will need to typedef sysent to sysent0,
	which results in compile failures when "struct sysent" string
	gets mangled into "struct sysent0".

	Use tcp->qual_flg instead of qual_flags[] in verbose() and abbrev()
	We have hundreds of uses of these macros.
	Result is more efficient and 1.1 kbyte shorter code:

	  text	   data	    bss	    dec	    hex	filename
	245579	    700	  12928	 259207	  3f487	strace.t5/strace
	244471	    700	  12928	 258099	  3f033	strace.t6/strace

2013-02-21  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove unused QUAL_FAULT code (was used by non-Linux code only).

	Use uint8_t for qual_flags[] instead of ints.
	Resulting bss reduction is ~6kbytes:

	   text	   data	    bss	    dec	    hex	filename
	 245703	    700	  19072	 265475	  40d03	strace.t4/strace
	 245687	    700	  12928	 259315	  3f4f3	strace.t5/strace

	Eliminate many SCNO_IS_VALID checks.
	By adding tcp->s_ent pointer tot syscall table entry,
	we can replace sysent[tcp->scno] references by tcp->s_ent.
	More importantly, we may ensure that tcp->s_ent is always valid,
	regardless of tcp->scno value. This allows us to drop
	SCNO_IS_VALID(tcp->scno) checks before we access syscall
	table entry.

	We can optimize (qual_flags[tcp->scno] & QUAL_foo) checks
	with a similar technique.

	Resulting code shrink:
	   text    data     bss     dec     hex filename
	 245975     700   19072  265747   40e13 strace.t3/strace
	 245703     700   19072  265475   40d03 strace.t4/strace

	* count.c (count_syscall): Use cheaper SCNO_IN_RANGE() check.
	* defs.h: Add "int qual_flg" and "const struct sysent *s_ent"
	to struct tcb. Remove "int u_nargs" from it.
	Add UNDEFINED_SCNO constant which will mark undefined scnos
	in tcp->qual_flg.
	* pathtrace.c (pathtrace_match): Drop SCNO_IS_VALID check.
	Use tcp->s_ent instead of sysent[tcp->scno].
	* process.c (sys_prctl): Use tcp->s_ent->nargs instead of tcp->u_nargs.
	(sys_waitid): Likewise.
	* strace.c (init): Add compile-time check that DEFAULT_QUAL_FLAGS
	constant is consistent with init code.
	* syscall.c (decode_socket_subcall): Use tcp->s_ent->nargs
	instead of tcp->u_nargs. Set tcp->qual_flg and tcp->s_ent.
	(decode_ipc_subcall): Likewise.
	(printargs): Use tcp->s_ent->nargs instead of tcp->u_nargs.
	(printargs_lu): Likewise.
	(printargs_ld): Likewise.
	(get_scno): [MIPS,ALPHA] Use cheaper SCNO_IN_RANGE() check.
	If !SCNO_IS_VALID, set tcp->s_ent and tcp->qual_flg to default values.
	(internal_fork): Use tcp->s_ent instead of sysent[tcp->scno].
	(syscall_fixup_for_fork_exec): Remove SCNO_IS_VALID check.
	Use tcp->s_ent instead of sysent[tcp->scno].
	(get_syscall_args): Likewise.
	(get_error): Drop SCNO_IS_VALID check where it is redundant.
	(dumpio): Drop SCNO_IS_VALID check where it is redundant.
	Use tcp->s_ent instead of sysent[tcp->scno].
	(trace_syscall_entering): Use (tcp->qual_flg & UNDEFINED_SCNO) instead
	of SCNO_IS_VALID check. Use tcp->s_ent instead of sysent[tcp->scno].
	Drop SCNO_IS_VALID check where it is redundant.
	Print undefined syscall name with undefined_scno_name(tcp).
	(trace_syscall_exiting): Likewise.
	* util.c (setbpt): Use tcp->s_ent instead of sysent[tcp->scno].

	ARM: make it one-personality arch.
	ARM in fact _is_ one personality.

	We had two personalities for it because it has a handful of
	syscalls with huge scnos (0x000f00xx).

	Extending syscall table to have [0x000f0005] index is of course
	not a good idea.

	Someone decided to handle that by having a separate personality
	just for these syscalls.

	But multi-personality arch does a bit more work in other parts.

	This patch is another alternative: "move" 0x000f00nn syscalls
	down to the entries just above last ordinary syscall,
	by manipulating scno if it falls into the 0x000f00xx range.

	In order to not worsen genuine undefined scnos' printing,
	the code remaps scno back to actual value before printing
	"syscall_NNN" string.

	* defs.h: Remove multi-reprsonality defines from ARM.
	* syscall.c (shuffle_scno): New function.
	(undefined_scno_name): New function.
	(get_scno): [ARM] Replace personality setting with scno shuffling.
	(trace_syscall_entering): Print unknown syscall name using
	undefined_scno_name().
	(trace_syscall_exiting): Likewise.
	* linux/arm/syscallent.h: Add ARM specific syscalls at the end.
	* linux/arm/errnoent1.h: Deleted.
	* linux/arm/ioctlent1.h: Deleted.
	* linux/arm/signalent1.h: Deleted.
	* linux/arm/syscallent1.h: Deleted.

2013-02-20  Denys Vlasenko  <vda.linux@googlemail.com>

	arm: shorten syscall table for EABI - no point in storing NULL entries.
	Also, reformatted ARM code in get_scno(), mostly improved comments,
	without code changes.

	Use the same style of includes in linux/*/* files.
	While at it, fix some comments which say
	"we use i386 syscalls/ioctls/errnos" but in reality
	common ones are used.

2013-02-19  Denys Vlasenko  <vda.linux@googlemail.com>

	Fix compiler warnings.
	With constant current_wordsize == 4 and 32-bit longs,
	gcc was spooked by "1ul << (8 * current_wordsize)" = "1ul << 32".

	Make such places conditional on SIZEOF_LONG > 4.

	Improve comment text. No code changes.

	Fix NOMMU + daemonized tracer SEGV.
	pathname[] was getting destroyed, execve of garbage pathname
	failing, and to top it off, the tracer's stack was also
	smashed and trecer segfaulted.

	* strace.c (exec_or_die): New function.
	(startup_child): Don't use pathname[] contents after vfork,
	make a malloced copy instead. Explain "NOMMU + -D bug"
	and how we work around it.

	Make it possible to to do test builds for NOMMU architectures.
	And while using it, I discovered that -D doesn't work too well
	on NOMMU. Added a comment about it.

	Clean up mmap decoding.
	Previous code merges too many similar, but different ways
	of decoding mmap. For example, sys_old_mmap is "params in memory"
	API... except SH[64], where it is "params in regs",
	i.e. what sys_mmap ("new mmap") function does on other arches!

	It's much simpler when every mmap handler has same API regardless
	of arch. Where API means whether params are in regs or in memory,
	and whether offset is in bytes, pages, or 4k blocks.

	Then we just insert correct function pointers into
	arch syscall tables.

	It turns out there are four common mmap APIs over
	all architectures which exist in Linux kernel,
	and one outlier for S390.

	A number of mmap decoders were plain wrong in arch tables.
	For example, BFIN has no old_mmap. It returns ENOSYS.
	I checked kernel sources for all arches nad fixed the tables.

	There was dead code for x86_64 for old_mmap:
	x86_64 has no old_mmap.

	* mem.c: Refactor mmap functions so that we have five mmap syscall
	handlers, each with the fixed API (not varying by arch).
	* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
	* linux/syscall.h: Declare new mmap syscall handler functions.
	* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
	* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
	* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
	* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
	* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
	* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
	* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
	* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
	* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
	* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
	* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
	* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
	* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
	* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent1.h: mmap is TD|TM.
	* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.

2013-02-18  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove unused function sys_mmap64.
	No wonder that it is unused.
	It's code looked quite questionable.

	* mem.c (sys_mmap64): Remove this function.

	Remove code which supports systems with long long off_t.
	While looking at mmap mess, did experimenting in order
	to figure out what gets used when.

	Tried building armv4tl, armv5l, armv6l, mips, mipsel, i686,
	x86_64 and none of they have long long off_t,
	which isn't suprprising: we aren't using glibc defines
	which enable that.

	Moreover, we SHOULD NOT use off_t in syscall decode!
	Its size depends on libc, not on arch! I.e. it is essentially
	unpredictable and can even in theory vary on the same arch
	with different libc.

	We should use longs or long longs, in a way which matches
	architectural ABI for the given syscall. There are usually
	*at most* two permutations, no need to add yet another variable
	(sizeof(off_t)) to the mix.

	This change removes almost all HAVE_LONG_LONG_OFF_T conditionals,
	which will reveal further possible simplifications.

	* mem.c: Remove code conditional on HAVE_LONG_LONG_OFF_T.
	As a result, never remap sys_mmap64 to sys_mmap.
	(print_mmap): Compile unconditionally.
	(sys_old_mmap): Compile unconditionally.
	(sys_mmap): Compile unconditionally.
	* io.c (sys_sendfile): Add a FIXME comment.
	* file.c: Remove code conditional on HAVE_LONG_LONG_OFF_T.
	As a result, never remap sys_*stat64 to sys_*stat etc.
	(sys_truncate): Compile unconditionally.
	(realprintstat): Likewise.
	(sys_stat): Likewise.
	(sys_fstat): Likewise.
	(sys_lstat): Likewise.
	* desc.c (printflock): Likewise.

	Fixes in "new" mmap.
	* mem.c (sys_mmap): Ensure unsigned expansion of tcp->u_arg[5].
	Add page shift of offset for I386.
	Use tcp->ext_arg[5] as offset for X32.
	(sys_old_mmap): [X32] Remove this function, X32 doesn't use is.

	Preliminary simplifications in mmap functions.
	* mem.c: Move "define sys_mmap64 sys_mmap" from the top
	to the only place it affects.
	(print_mmap): Make offset argument unsigned, for safer implicit conversions.
	(sys_old_mmap): [IA64] use unsigned narrow_arg[].
	Cast u_arg[5] (offset param) to unsigned long, to prevent erroneous signed
	expansion.

2013-02-17  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove broken HAVE_LONG_LONG conditionals.
	We use printllval without HAVE_LONG_LONG guards in many places,
	but define it only if HAVE_LONG_LONG. This means that
	on !HAVE_LONG_LONG systems we won't build for some time now.

	* defs.h: Remove HAVE_LONG_LONG guard around LONG_LONG() macro
	and printllval() function declaration.
	* util.c: Remove HAVE_LONG_LONG guard around printllval()
	function definition.
	(printllval): Add compile-time error check for using wrong
	if branch. Explain places where we deliberately use mismatched
	types for printf formats.

	Use explicit long type instead of off_t.
	* file.c (sys_lseek): Use long instead of off_t.

	Merge two identical tables.
	* defs.h: Declare whence_codes[].
	* desc.c: Delete static whence[].
	(printflock[64]): Use whence_codes.
	* file.c: Make whence_codes[] non-static.
	Add SEEK_DATA and SEEK_HOLE to them.

	Remove wrong x32-specific lseek.
	Testing confirmed what I suspected: x32 lseek uses kernel-sized
	(i.e. wide) long for offset parameter.

	* file.c: Delete sys_lseek32.
	* linux/syscall.h: Likewise.
	* linux/x32/syscallent1.h: Likewise.
	* test/x32_lseek.c: New file.

	Fix SEGV in lseek.
	I found hard way why the code was using "_whence" name.

	* file.c: Rename whence[] to whence_codes[].
	(sys_lseek): Fix printxval() to use whence_codes[].
	(sys_lseek32): Likewise.

	Comment inner workings of sys_[l]lseek.
	The code doesn't look fully correct to me, but I need to experiment
	on actual x32 machine before I start "fixing" things.
	For now, add comments, and optimize out one tprints() call...

	* file.c (sys_lseek): Rename '_whence' as 'whence'.
	Merge printing of ", " into subsequent tprintf.
	(sys_lseek32): Likewise.
	(sys_llseek): Likewise.

	Cosmetic fixes to syscall tables, no code changes.

2013-02-16  Denys Vlasenko  <vda.linux@googlemail.com>

	Make linux/mips/syscallent.h smaller.
	* linux/mips/syscallent.h: Remove trailing empty elements.
	Compactify huge stretches of NULL elements in the middle.

	Simple optimization in get_error.
	* defs.h: Define SCNO_IN_RANGE(scno) macro.
	* syscall.c (get_error): Change return type to void.
	Use SCNO_IN_RANGE instead of SCNO_IS_VALID.
	(trace_syscall_exiting): Stop checking get_error() return value.

	Mass rename of SCNO_IN_RANGE define to SCNO_IS_VALID.

	Finish prefixing regs struct names with arch_
	* defs: Rename regs -> sparc_regs.
	* signal.c (sys_sigreturn): Use new variable name.
	* syscall.c: Rename regs -> sparc_regs, regs -> avr32_regs.
	(getrval2): Use new variable names.
	(printcall): Likewise.

2013-02-15  Denys Vlasenko  <vda.linux@googlemail.com>

	Use the same type for i386_regs on 32-bit and 64-bit x86.
	* defs.h: Stop including <asm/ptrace.h> for x86.
	Change i386_regs from "struct pt_regs" to "struct user_regs_struct".
	* syscall.c: Likewise.

	Fix build error on Tile.
	* syscall.c (get_scno): [TILE] Remove TCB_WAITEXECVE check,
	it is never true on Tile, and stopped compiling when
	TCB_WAITEXECVE define was removed for Tile.

	x86: zero-extend 32-bit args in syscall entry instead of sign-extension.
	Zero-extension is slightly more common that sign-extension:
	all pointers are zero-extended, and some other params are unsigned.

	Whereas signed ones (fds, pids, etc) are often treated as
	_32-bit ints_ even by kernel, so just unconditionally casting
	such tcp->u_arg[N] to int works.

	* syscall.c (get_syscall_args): [X86] Zero-extend 32-bit args
	instead of sign-extension.

	Macroize conditional signed widening operation.
	* defs.h: Define widen_to_long() macro.
	* signal.c (sys_kill): Use it instead of open-coding it.
	(sys_tgkill): Use widen_to_long() on pids.
	* resource.c (decode_rlimit): Formatting fix.

	A better handling of current_wordsize.
	On x86_64:
	  text	   data	    bss	    dec	    hex	filename
	435661	  26628	  47424	 509713	  7c711	strace_old
	435501	  26612	  47440	 509553	  7c671	strace_new_clever_wordsize

	On x32 and arm it should be even better, current_wordsize becomes
	a constant there.

	* defs.h: Declare current_wordsize as a variable if needed,
	else declare as a constant define.
	Remove declatation of personality_wordsize[].
	* syscall.c: Make personality_wordsize[] static.
	Declare current_wordsize as a variable if needed.
	(set_personality): Set current_wordsize only if non-constant.

	Remove unnecessary "return 0" statements.
	* util.c (change_syscall): Remove dummy "return 0"s.

2013-02-14  Denys Vlasenko  <vda.linux@googlemail.com>

	x86: fix required kernel version for GETREGSET.
	* syscall.c (get_regs): [X86] Use GETREGSET only if kernel >= 2.6.35

	Whitespace fix, no code changes.

2013-02-14  Christian Svensson  <blue@cmd.nu>

	Add support for the OpenRISC 1000 platform.
	* configure.ac: Added or1k architecture..
	* defs.h: Added or1k to use register reading system.
	* linux/or1k/ioctlent.h.in: Use i386 ioctls.
	* linux/or1k/syscallent.h: New file.
	* process.c: Added or1k register defs to struct_user_offsets[].
	* syscall.c: Added or1k_io iovec for or1k GETREGSET,
	  regset structure for or1k.
	  (printcall): Added handling for or1k.
	  (get_regs): Likewise.
	  (get_scno): Likewise.
	  (get_syscall_args): Likewise.
	  (get_syscall_result): Likewise.
	  (get_error): Likewise.
	* util.c (change_syscall): Added dummy handling for or1k.
	* system.c (sys_or1k_atomic): New function (or1k specific syscall).

2013-02-14  Denys Vlasenko  <vda.linux@googlemail.com>

	[X86] Use ptrace(PTRACE_GETREGSET, NT_PRSTATUS) to get registers.
	Unlike PTRACE_GETREGS, this new method detects 32-bit processes
	reliably, without checking segment register values which
	are undocumented and aren't part of any sort of API.
	While at it, also fixed x32 detection to use __X32_SYSCALL_BIT,
	as it should have been from the beginning.

	* defs.h: Declare os_release and KERNEL_VERSION.
	* strace.c: Make os_release non-static, remove KERNEL_VERSION define.
	* syscall.c: New struct i386_user_regs_struct,
	static union x86_regs_union and struct iovec x86_io.
	(printcall): Use i386_regs or x86_64_regs depending on x86_io.iov_len.
	(get_regs): On x86 and kernels 2.6.30+, use PTRACE_GETREGSET,
	on earlier kernels fall back to old method.
	(get_scno): [X86] Determine personality based on regset size
	on scno & __X32_SYSCALL_BIT.
	(syscall_fixup_on_sysenter): Use i386_regs or x86_64_regs depending
	on x86_io.iov_len.
	(get_syscall_args): Likewise.
	(get_error): Likewise.

2013-02-13  Denys Vlasenko  <vda.linux@googlemail.com>

	Rename some register statics by prefixing their names with arch.
	This makes it easier to grep for them.

	* syscall.c: Rename variables:
	r0 -> bfin_r0,alpha_r0,sh_r0.
	a3 -> mips_a3.
	r2 -> mips_r2.
	(get_scno): Use new variable names.
	(get_syscall_result): Likewise.
	(get_error): Likewise.

	Factor out code to check addr, fetch and print siginfo.
	* defs.h: Declare new function printsiginfo_at(tcp, addr).
	* process.c (sys_waitid): Use printsiginfo_at().
	(sys_ptrace): Likewise.
	* signal.c: (printsiginfo_at): Implement this new function.
	(sys_rt_sigsuspend): Use printsiginfo_at().
	(sys_rt_sigtimedwait): Likewise.

	Decode struct iov in PTRACE_GET/SETREGSET.
	* process.c (sys_ptrace): Decode struct iov in PTRACE_GET/SETREGSET.

2013-02-12  Denys Vlasenko  <vda.linux@googlemail.com>

	Unify representations of struct user fields for subarchitectures.
	* process.c: Unify MIPS and LINUX_MIPSN32, and SH and SH64 parts of
	struct_user_offsets[].

	Add start_code and start_data members of struct user.
	* process.c: Add start_code and start_data members of struct user
	in struct_user_offsets[], where appropriate.

	Remove hacks for old kernels for architectures which require new kernels
	* util.c (change_syscall): For MICROBLAZE, replace code
	with dummy "return 0" and a comment explaining why that is ok
	for this architecture.

	Remove stray syscall result reading code on syscall entry for s390.
	This is a leftover from sysenter/sysexit split.
	I can't run-test it, but from code inspection it seems to be correct.

	* syscall.c (get_scno): Remove stray syscall result reading for s390[x].

	Deobfuscate definitions of struct user offsets.
	The maze of ifdefs/ifndefs was scaring new contributors.
	Format it so that every arch has its own ifdef block.

	* process.c: Deobfuscate definitions of struct user offsets.

	Remove hacks for old kernels for architectures which require new kernels
	* defs.h: Do not define TCB_WAITEXECVE for AARCH64.
	* util.c (change_syscall): For AARCH64 and X32, replace code
	with dummy "return 0" and a comment explaining why that is ok
	for these architectures.

	Remove old kernel hacks for architectures which require new kernels.
	* defs.h: Do not define TCB_WAITEXECVE for AVR32, BFIN and TILE.
	* util.c (change_syscall): For AVR32, BFIN and TILE, replace code
	with dummy "return 0" and a comment explaining why that is ok
	for these architectures.

	Handle recv[m]msg for non-native 32-bit personality syscalls.
	* net.c (printmsghdr): If current_wordsize is 4 and long is wider than it,
	read 32-bit struct msghdr and expand it into a native one before using it.
	(printmmsghdr): Likewise for struct mmsghdr.

	Fix is_negated_errno() check for X32.
	X32's return value is 64-bit. We were truncating it to 32-bit long
	before checking for -errno.

	* syscall.c (is_negated_errno_x32): New function.
	(get_error): Use is_negated_errno_x32 for X32 architecture.

	Remove unused / ambiguously used defines.
	We sometimes use LINUXSPARC and sometimes (more often)
	use "defined(SPARC) || defined(SPARC64)". Better to use
	one construct consistently.
	LINUX_MIPS64 is altogether unused.

	* defs.h: Remove LINUXSPARC and LINUX_MIPS64 defines.
	Move PTRACE_xxx compat defines up, before arch-specific
	machinery. Use defined(SPARC) || defined(SPARC64)
	instead of LINUXSPARC.
	* file.c: Use defined(SPARC) || defined(SPARC64) instead of LINUXSPARC.
	* signal.c: Likewise.

2013-02-11  Denys Vlasenko  <vda.linux@googlemail.com>

	Preparatory patch for "new" x86 personality detection.
	* syscall.c: Move PT_FLAGS_COMPAT define to its only user, get_scno().
	Rename arm_regs_union's fields to names less likely to collide with
	system defines.
	(get_regs): Use sizeof(arm_regs_union) instead of sizeof(aarch64_regs).
	This should be the same, but htis way it's cleaner.
	Remove __X32_SYSCALL_MASK and use __X32_SYSCALL_BIT instead.
	Explain 64-bit check in X32 build better.

2013-02-09  Dmitry V. Levin  <ldv@altlinux.org>

	Fix sigaltstack decoder.
	strace used to hang when decoding sigaltstack called with invalid
	stack_t pointers because of mishandling umove() return code.

	* signal.c (print_stack_t): Handle unfetchable stack_t properly.
	Change return type to void.
	(sys_sigaltstack): Update print_stack_t() usage.

	Reported-by: kawillia@ucalgary.ca

2013-02-09  Mike Frysinger  <vapier@gentoo.org>

	Fix decoding of sysctl() when oldval fields are NULL.
	If you call glibc's syscall wrapper like so:
		static int name[] = { CTL_NET, NET_IPV4, NET_IPV4_LOCAL_PORT_RANGE };
		int buffer[2] = { 32768, 61000 };
		size_t size = sizeof(buffer);
		sysctl(name, 3, 0, 0, buffer, size);
	(note that oldval/oldlenp are NULL).

	The current strace code complains like so:
	_sysctl({{CTL_NET, NET_IPV4, NET_IPV4_LOCAL_PORT_RANGE, 38}, 3, process_vm_readv: Bad address
	(nil), 0, 0x7fffe23c3960, 8}) = -1 EACCES (Permission denied)

	Since passing NULL for the old values is valid, handle that explicitly.
	This also simplifies the code a bit by splitting up the handling of the
	new and old args so that we only handle the new args once.

	Now the output looks like:
	_sysctl({{CTL_NET, NET_IPV4, NET_IPV4_LOCAL_PORT_RANGE, 38}, 3, NULL, 0, 0x7fff8c0c91b0, 8) = -1 EACCES (Permission denied)

	* system.c (sys_sysctl): Check if info.oldval is NULL first.  Move the
	processing of oldlen/info.newval/info.newlen out so they always get
	executed.  Fix the format strings so we use %lu for unsigned long rather
	than a mix of %ld and %lu.

2013-02-08  Denys Vlasenko  <vda.linux@googlemail.com>

	If we are on a glibc system, assume it's at least glibc 2.1.
	It is not likely anyone uses glibc older that that:
	glibc 2.1.1 was released in 1999

	* net.c: Remove test for glibc >= 2.1.
	* signal.c: Remove code which is compiled only for glibc < 2.1.
	* util.c: Likewise.

	S390: stop using needlessly static long pc variable.
	* syscall.c: Remove "static long pc" variable.
	(get_scno): Use an automatic long variable instead of a static.

	Dying suddenly with abort() is rude, avoid if possible.
	* file.c (sys_utime): Don't call abort() if wordsize is strange.
	Instead, warn user about it.
	* desc.c (printflock): Use the same message string as in sys_utime.

	Remove vestigial hacks around non-Linux struct sigactions.
	* signal.c: Stop using __sighandler_t glibc'ism. Remove SA_HANDLER macro.
	Explain why we can't use "sa_handler" as a field name.
	(sys_sigaction): Use __sa_handler instead of SA_HANDLER macro.
	(sys_rt_sigaction): Likewise.

	Optimize AArch64 handling of 32-bit personality.
	By putting aarch64_regs and arm_regs into a union,
	register copying is eliminated.
	No need to check and change personality on syscall exit.

	* defs.h: Remove unused NUM_ARM_REGS define. Fix indentation.
	* syscall.c: Put aarch64_regs and arm_regs into a union.
	(update_personality): Shorten bitness message.
	(printcall): Add commented-out PC printing.
	(get_regs): Remove now-unnecessary 64-to-32 bits register copying.
	(get_syscall_result): Drop personality changing code.

2013-02-07  Denys Vlasenko  <vda.linux@googlemail.com>

	Rename some register statics by prefixing their names with arch.
	This makes it easier to grep for them.

	* syscall.c: Make IA64's r8, r10 global variables static.
	Rename variables:
	r8,r10 -> ia64_r8,ia64_r10.
	d0 -> m68k_d0.
	a3 -> alpha_a3.
	r28 -> hppa_r28.
	r9 -> sh64_r9.
	r10 -> cris_r10.
	r3 -> microblaze_r3.
	(get_scno): Use new variable names.
	(syscall_fixup_on_sysenter): Likewise.
	(get_syscall_result): Likewise.
	(get_error): Likewise.

2013-02-06  Denys Vlasenko  <vda.linux@googlemail.com>

	Rename ARM's regs structure to arm_regs.
	Compile-tested.

	* defs.h: Rename regs structure to arm_regs.
	* syscall.c: Likewise.
	(printcall): Use new name instead of old one.
	(get_regs): Likewise.
	(get_scno): Likewise.
	(get_syscall_args): Likewise.
	(get_error): Likewise.
	* signal.c (sys_sigreturn): Likewise.

	Stop needlessly using static variable.
	* syscall.c: Remove static long psr.
	(get_scno): Use local psr variable.
	(get_syscall_result): Likewise.

	Shortcut tests for fork/exec syscalls.
	This change should speed up strace by a tiny bit.

	More importantly, it makes it much more clear that
	fork and exec fixups are not necessary for any reasonably
	recent kernels. IOW: syscall_fixup_for_fork_exec() and its callees
	are all dead code.

	* defs.h: Declare new need_fork_exec_workarounds flag variable.
	* strace.c: Define need_fork_exec_workarounds flag variable.
	(test_ptrace_setoptions_followfork): Return 0/1 as success/fail indicator.
	(test_ptrace_setoptions_for_all): Likewise.
	(init): Set need_fork_exec_workarounds to TRUE if needed.
	* syscall.c: Rename internal_syscall() to syscall_fixup_for_fork_exec().
	(trace_syscall_entering): Call syscall_fixup_for_fork_exec() only if
	need_fork_exec_workarounds == TRUE.
	(trace_syscall_exiting): Likewise.

2013-02-05  Ben Noordhuis  <info@bnoordhuis.nl>

	Improve perf_event_open argument decoding.
	* configure.ac (AC_CHECK_HEADERS): Add linux/perf_event.h.
	* desc.c [HAVE_LINUX_PERF_EVENT_H]: Include <linux/perf_event.h>.
	(perf_event_open_flags): New xlat structure.
	(sys_perf_event_open): New function.
	* linux/dummy.h (sys_perf_event_open): Remove.
	* linux/syscall.h (sys_perf_event_open): New prototype.

2013-02-05  Chris Metcalf  <cmetcalf@tilera.com>

	tile: fix merge skew with new get_regs architecture.
	* defs.h [TILE]: Declare clear_regs(), get_regs() and get_regs_error.
	* syscall.c (get_regs) [TILE]: Fix merge skew.
	(printcall) [TILE]: fix a compiler warning about pt_reg_t in
	a printf expression.

2013-02-05  Bernhard Reutner-Fischer  <rep.dot.nop@gmail.com>

	mount: decode MS_NOSEC.
	* system.c (MS_NOSEC): Define.
	(mount_flags): Add MS_NOSEC.

	mmap: decode MAP_UNINITIALIZED.
	* mem.c (mmap_flags): Add MAP_UNINITIALIZED.

2013-02-05  Dmitry V. Levin  <ldv@altlinux.org>

	Print 64-bit instruction pointers zero padded.
	* syscall.c (printcall): Print 64-bit instruction pointers zero padded.

	x86_64: fix compilation warning introduced in previous commit.
	* syscall.c (printcall): Cast x86_64_regs.rip to the type being printed.

2013-02-05  Denys Vlasenko  <vda.linux@googlemail.com>

	Simple bug fix for x86_86.
	* syscall.c (printcall): Use x86_64_regs.rip, not x86_64_regs.ip.

2013-02-05  Chris Metcalf  <cmetcalf@tilera.com>

	Add tilegx support to strace.
	tilegx support has been in the kernel since 3.0.
	In addition, fix some issues with the tilepro support already
	present in strace, primarily the decision to use the
	<asm/unistd.h> numbering space for system calls.

	* defs.h [TILE]: Include <asm/ptrace.h> and provide an extern
	struct pt_regs tile_regs for efficiency.  Provide compat 32-bit
	personality via SUPPORTED_PERSONALITIES, PERSONALITY0_WORDSIZE,
	PERSONALITY1_WORDSIZE, and DEFAULT_PERSONALITY.
	* linux/tile/errnoent1.h: New file, includes linux/errnoent.h.
	* linux/tile/ioctlent1.h: New file, includes linux/ioctlent.h.
	* linux/tile/signalent1.h: New file, includes linux/signalent.h.
	* linux/tile/syscallent.h: Update with new asm-generic syscalls.
	The version previously committed was the from the first tile patch
	to LKML, which subsequently was changed to use <asm-generic/unistd.h>.
	* linux/tile/syscallent1.h: Copy from linux/tile/syscallent.h.
	* mem.c (addtileflags) [TILE]: use %ld properly for a "long" variable.
	* process.c [TILE]: Choose clone arguments correctly and properly
	suppress all "struct user" related offsets in user_struct_offsets.
	* signal.c [TILE]: Use tile_regs not upeek.
	* syscall.c (update_personality) [TILE]: Print mode.
	(PT_FLAGS_COMPAT) [TILE]: Provide if not in system headers.
	(tile_regs) [TILE]: Define 'struct pt_regs' variable to hold state.
	(get_regs) [TILE]: use PTRACE_GETREGS to set tile_regs rather than using upeek.
	(get_scno) [TILE]: Set personality.
	(get_syscall_args) [TILE]: Use tile_regs.
	(get_syscall_result) [TILE]: Update tile_regs.
	(get_error) [TILE]: Use tile_regs.
	(printcall) [TILE]: Print pc.
	(arg0_offset, arg1_offset, restore_arg0, restore_arg1) [TILE]:
	Properly handle tile call semantics and support tilegx.

2013-02-05  Denys Vlasenko  <vda.linux@googlemail.com>

	Small optimization for SPARC[64] get_scno.
	* syscall.c: Remove static unsigned long trap veriable.
	(get_scno): Use local trap variable.

	Do not compile getrval2() if not needed.
	* syscall.c (getrval2): Do not compile it for architetures where
	it isn't ever used.

	Optimize out PTRACE_PEEKUSER with -i.
	strace -i was fetching PC with a separate PEEKUSER
	despite having GETREGS data:

	ptrace(PTRACE_GETREGS, 22331, 0, 0x8087f00) = 0
	ptrace(PTRACE_PEEKUSER, 22331, 4*EIP, [0x80dd7b7]) = 0
	write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
	ptrace(PTRACE_SYSCALL, 22331, 0, SIG_0) = 0

	Now it does this:

	ptrace(PTRACE_GETREGS, 22549, 0, 0x8087ea0) = 0
	write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
	ptrace(PTRACE_SYSCALL, 22549, 0, SIG_0) = 0

	Analogous improvement in sys_sigreturn() is also implemented.

	* defs.h: Declare extern struct pt_regs regs for SPARC[64] and ARM.
	Declare clear_regs(), get_regs() and get_regs_error flag variable.
	* strace.c (trace): Call get_regs(pid) as soon as we know the tcb
	and that it is stopped.
	* syscall.c (get_regs): New function. Used to fetch registers early,
	just after tracee has stopped.
	(printcall): Move it here from util.c. Use global regs.REG data,
	if available on the arch, instead of re-fetching it.
	(get_scno): Use global regs.REG data.
	(get_syscall_result): Likewise.
	* signal.c (sys_sigreturn): Likewise.
	* util.c (printcall): Moved to syscall.c.

2012-12-15  Stanislav Brabec  <sbrabec@suse.cz>

	Fix sys_semtimedop decoding on s390x.
	The s390 and s390x pass semtimedop arguments differently from other
	architectures.  sys_semtimedop parser was fixed for s390 by commit
	v4.6-177-ge0f5fd8, and s390x requires the same fix.

	* linux/ipc.c (sys_semtimedop): Fix timespec decoding on s390x.

2012-12-08  Dmitry V. Levin  <ldv@altlinux.org>

	Fix *xattr decoding.
	* file.c (print_xattr_val): Do not attempt to decode a zero sized array.
	Fixes RH#885233.

2012-12-08  Stanislav Brabec  <sbrabec@suse.cz>

	sys_semtimedop: fix timeval argument index in wrapped call.
	Looking at the implementation of wrapped semtimedop() call inside glibc
	and kernel, I started to believe that timeval should be located in
	tcp->u_arg[4] and not tcp->u_arg[5].  Fortunately, tcp->u_arg[5] now
	works correctly as well, due to side effects of decode_ipc_subcall().

	declaration in header:
	int semtimedop(semid, *sops, nsops, *timeout);
	                 0      1      2        3

	sys_ipc arguments in glibc on all patforms except s390*:
	semid, (int) nsops, 0, CHECK_N (sops, nsops), timeout
	  0            1    2            3                4
	We have to use indexes: 0 3 1 4

	sys_ipc arguments on s390*:
	semid, (int) nsops, timeout, sops
	  0            1       2       3
	We have to use indexes: 0 3 1 2

	* ipc.c (sys_semtimedop) [!S390]: Fix timeval argument index in
	indirect_ipccall case.

2012-12-06  John Spencer  <maillist-strace@barfooze.de>

	Fix glibc version checks.
	* util.c: Check if __GLIBC__ is defined before using it.
	* signal.c: Likewise.  Fix __GLIBC_MINOR__ checks.

2012-11-29  James Hogan  <james.hogan@imgtec.com>

	Add state argument to change_syscall and fix SPARC.
	Add a state argument to change_syscall() so that SPARC can modify that
	instead of read-modify-writing the whole register set.  This function is
	always called within an arg_setup/arg_finish_change sequence which on
	certain architectures like SPARC will also be doing a read-modify-write.
	This prevents the second write (from arg_finish_change) from undoing the
	effects of the change_syscall call.

	* util.c (change_syscall): Move below definition of arg_setup_state.
	Add state argument.
	[SPARC || SPARC64] Change to set state->u_regs[U_REG_G1] rather than
	read-modify-writing it with PTRACE_GETREGS and PTRACE_SETREGS.
	(setbpt, clearbpt): Pass state argument to change_syscall.

2012-11-12  Steve McIntyre  <steve.mcintyre@linaro.org>

	Add support for tracing 32-bit ARM EABI binaries on AArch64.
	* defs.h [AARCH64]: Copy in the definition of arm_pt_regs and the
	accessor macros, so it's possible to build on AArch64 without
	ARM system headers.  Set SUPPORTED_PERSONALITIES to 2.
	Define PERSONALITY0_WORDSIZE and PERSONALITY1_WORDSIZE.
	Set DEFAULT_PERSONALITY to 1.
	* linux/aarch64/errnoent1.h: New file, includes generic errnoent.h.
	* linux/aarch64/ioctlent1.h: New file, includes generic ioctlent.h.
	* linux/aarch64/signalent1.h: New file, includes generic signalent.h.
	* linux/aarch64/syscallent1.h: Rename from linux/aarch64/syscallent.h.
	* linux/aarch64/syscallent.h: New file, includes arm/syscallent.h.
	* syscall.c [AARCH64]: Define aarch64_regs.
	(update_personality) [AARCH64]: Add debug output.
	(get_scno) [AARCH64]: Determine if we're in ARM or AArch64 mode by
	checking the size of the returned uio structure from PTRACE_GETREGSET
	and interpret the structure accordingly.
	(get_syscall_result): Likewise.
	(get_syscall_args): Merge the AArch64 and ARM sections so that on
	AArch64 we can fall back to supporting the ARM personality.
	(get_error): Likewise.

2012-11-12  Dmitry V. Levin  <ldv@altlinux.org>

	Move asm-generic ioctl definitions to linux/ioctlent.h.in.
	* linux/ioctlent.h.in: Add asm-generic ioctl entries from all
	linux/*/ioctlent.h.in files.
	* linux/bfin/ioctlent.h.in: Remove asm-generic ioctl entries.
	* linux/i386/ioctlent.h.in: Likewise.
	* linux/powerpc/ioctlent.h.in: Likewise.
	* linux/s390/ioctlent.h.in: Likewise.
	* linux/sparc/ioctlent.h.in: Likewise.

2012-10-27  Dmitry V. Levin  <ldv@altlinux.org>

	Filter out redundant "*32" ioctl entries.
	* linux/ioctlent-filter.awk: New file.
	* Makefile.am: Use it.
	* linux/ioctlent.h.in: Removed redundant "*32" entries.

2012-10-26  Dmitry V. Levin  <ldv@altlinux.org>

	Enhance quotactl decoding.
	* quota.c (sys_quotactl): Decode 2nd syscall argument using printpath.
	* pathtrace.c (pathtrace_match): Add quotactl support.
	* linux/*/syscallent.h: Add TF flag to quotactl entry.

2012-10-26  Steve McIntyre  <steve.mcintyre@linaro.org>

	Add AArch64 support to strace.
	AArch64 has been included in linux from 3.7 onwards.
	Add support for AArch64 in strace, tested on linux in a simulator.

	* configure.ac: Support AArch64.
	* defs.h [AARCH64]: Include <sys/ptrace.h>, define TCB_WAITEXECVE.
	* ipc.c (indirect_ipccall): Support AArch64.
	* process.c (struct_user_offsets): Likewise.
	* syscall.c [AARCH64]: Include <asm/ptrace.h>,  <sys/uio.h>, and
	<elf.h>.  Define struct user_pt_regs regs.
	(get_scno, get_syscall_result): Support AArch64 using PTRACE_GETREGSET.
	(get_syscall_args, get_error): Support AArch64.
	* linux/aarch64/ioctlent.h.in: New file.
	* linux/aarch64/syscallent.h: New file, based on linux 3.7 version of
	asm-generic/unistd.h.

	linux: add new errno values for EPROBE_DEFER and EOPENSTALE.
	New definitions match updates in Linux 3.4 and Linux 3.5 respectively.

	* linux/errnoent.h (ERRNO_517): Change to EPROBE_DEFER.
	(ERRNO_518): Change to EOPENSTALE.

2012-10-26  Namhyung Kim  <namhyung.kim@lge.com>

	Add -e trace=memory option.
	Add a new 'memory' category for tracing memory mapping related syscalls.

	Affected syscalls are: break, brk, get_mempolicy, madvise, mbind,
	migrate_pages, mincore, mlock, mlockall, mmap, move_pages, mprotect,
	mremap, msync, munlock, munlockall, munmap, remap_file_pages, and
	set_mempolicy.

	* defs.h (TRACE_MEMORY): New macro.
	* syscall.c (lookup_class): Handle trace=memory option.
	* strace.1: Document it.
	* linux/alpha/syscallent.h: Add TM flag to memory mapping related syscalls.
	* linux/arm/syscallent.h: Likewise.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/hppa/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x32/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

2012-09-28  Mike Frysinger  <vapier@gentoo.org>

	x32: add 64bit annotation too.
	Since someone can invoke these entry points directly with syscall(),
	at least decode their name and show that they're 64bit versions rather
	than just showing syscall_###.

	* linux/x32/syscallent.h: Sync all missing entries below 312 with x86_64.

2012-09-28  Dmitry V. Levin  <ldv@altlinux.org>

	Ignore fflush(3) return value.
	strace used to honor fflush(3) return value in trace_syscall_entering
	which resulted to tracees not being PTRACE_SYSCALL'ed which in turn
	caused nasty hangups like this one:

	$ strace -o'|:' pwd
	|:: Broken pipe

	There is little strace can do in case of fflush(3) returning EOF, and
	hangup is certainly not the best solution for the issue.

	* syscall.c (trace_syscall_entering): Ignore fflush(3) return value.

	Use perror_msg instead of perror.
	* signal.c (sys_sigreturn): Use perror_msg instead of perror.
	* strace.c (tprintf, tprints, detach, startup_attach): Likewise.
	* syscall.c (get_scno): Likewise.
	* util.c (umoven, umovestr): Likewise.

2012-09-27  Denys Vlasenko  <vda.linux@googlemail.com>

	process_vm_readv may return ESRCH if tracee was killed, don't complain.
	Discovered by running test/sigkill_rain under strace.

	* util.c (umoven): Do not emit error message if process_vm_readv
	fails with ESRCH.
	(umovestr): LikeWise.

2012-09-13  Denys Vlasenko  <vda.linux@googlemail.com>

	Trivial fixes, no code changes.
	* strace.c: Fix compiler warning message about tgkill - we don't use it.
	Fix indentation of preprocessor directives.
	(trace): Remove outdated comment.

2012-08-24  Dmitry V. Levin  <ldv@altlinux.org>

	Always check setreuid return code.
	* strace.c (startup_child): Check setreuid return code.

2012-08-24  Mike Frysinger  <vapier@gentoo.org>

	x32: update {g,s}etsockopt syscall numbers.
	Starting with linux 3.6 (and backported to earlier kernels), these two
	syscalls have changed numbers (moving from native to compat entry points).
	Update the strace syscall list accordingly.

	* linux/x32/syscallent.h: Move setsockopt from 54 to 541, and move
	getsockopt from 55 to 542.

2012-08-16  Dmitry V. Levin  <ldv@altlinux.org>

	Decode file type returned by getdents system call.
	* file.c (sys_getdents): Decode d_type in unabbreviated mode.

2012-07-12  Dmitry V. Levin  <ldv@altlinux.org>

	Close pipe and wait for the pipe process termination.
	In case of normal strace termination, when the trace output is
	redirected to a file or a pipe, close it and wait for the pipe
	process termination.

	* strace.c (main): Before normal exit, close shared_log when it
	differs from stderr, and wait for popen_pid termination.

2012-07-10  Denys Vlasenko  <vda.linux@googlemail.com>

	Enable usage of PTRACE_SEIZE.
	* defs.h: Define USE_SEIZE to 1. Remove PTRACE_SEIZE_DEVEL
	and PTRACE_EVENT_STOP1.
	* strace.c (ptrace_attach_or_seize): Replace PTRACE_SEIZE_DEVEL
	with 0.
	(trace): Do not check for PTRACE_EVENT_STOP1.

2012-06-05  Mike Frysinger  <vapier@gentoo.org>

	x32: update syscall table.
	This syncs with the syscall table as it is in linux 3.4.

	* linux/x32/syscallent.h (59): Fix comment typo.
	(78): Add missing getdents entry.
	(174): Delete create_module entry (not in the kernel).
	(181, 182, 183, 184, 185): Add missing entries.
	(524, 536, 539, 540): Fix spacing.

2012-05-18  Denys Vlasenko  <vda.linux@googlemail.com>

	Merge adjacent printing operations in a few places.
	* file.c (sys_readahead): Merge tprints() with following printllval().
	(sys_ftruncate64): Likewise.
	(sys_fadvise64): Likewise.
	(sys_fadvise64_64): Likewise.
	(sys_fallocate): Merge tprints() with following tprintf().

2012-05-16  Denys Vlasenko  <vda.linux@googlemail.com>

	Use %d printf format instead of %i everywhere.
	* loop.c (loop_ioctl): Use %d instead of %i.
	* mtd.c (mtd_ioctl): Likewise.

	Fix a few goofs in sys_sysctl()
	* system.c (sys_sysctl): Cast pointer to long, not size_t,
	when we intend to use it as an address. Set oldlen to 0 prior
	to reading into it - we want to have deterministic result
	if read fails.

	Stop using non-standard %Zu and %Zd formats for size_t printing.
	The documented formats are %zu and %zd, but since our (normally disabled)
	"fast" printf code doesn't support those too, I convert them to %lu and %ld.

	* bjm.c (sys_query_module): Convert %Zd usages to %lu.
	* system.c (sys_sysctl): Likewise.

2012-05-15  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove outdated comment about suspending new tracees.
	We no longer track parent/child relationship between tracees.
	Therefore, we no longer suspend new tracee until parent is seen
	exiting form [v]fork/clone. The comment is obsolete.

	* strace.c (trace): Remove outdated comment.

	Make sure current_wordsize and PERSONALITY0_WORDSIZE are ints in all arches
	On 64bit systems with a single personality, they used to be sizeof(long),
	which has type "long", not "int", which complicates printf formats.

	* defs.h: Ensure that PERSONALITY0_WORDSIZE;s tyoe is int.
	This in turn makes sure current_wordsize is also an int.
	* count.c (call_summary): Revert the change which added cast to int.

2012-05-15  Dmitry V. Levin  <ldv@altlinux.org>

	Add configure --enable-gcc-Werror option.
	* configure.ac: New option --enable-gcc-Werror.

	Make x86-64 build free of artificial warnings.
	* signal.c (sys_sigreturn): Do not issue "no sys_sigreturn" warning
	on X86_64.

2012-05-14  Dmitry V. Levin  <ldv@altlinux.org>

	Fix kernel release string parsing.
	* strace.c (get_os_release): Handle "X.Y-something" utsname.release
	strings properly.

	Reported-by: Bryce Gibson <bryce@gibson-consulting.com.au>

2012-05-14  Denys Vlasenko  <vda.linux@googlemail.com>

	On clearing "breakpopint", restore syscall number too.
	This fixes Fedora bug 659382.
	Low risk: this code is not supposed to be used on any non-acient kernel.

	* util.c (clearbpt): Restore syscall number too.

2012-05-05  Mike Frysinger  <vapier@gentoo.org>

	util: fix building when glibc has a stub process_vm_readv.
	If you have a newer glibc which provides process_vm_readv, but it is built
	against older kernel headers which lack __NR_process_vm_readv, the library
	will contain a stub implementation that just returns ENOSYS.  Autoconf
	checks for this case explicitly and will declare it as unavailable.  So we
	end up in a case where the headers provide the prototype, but autoconf has
	not defined HAVE_PROCESS_VM_READV, so we hit the same build failure again:

	util.c:738:16: error: static declaration of 'process_vm_readv' follows non-static declaration
	/usr/include/bits/uio.h:58:16: note: previous declaration of 'process_vm_readv' was here

	So rename our local function to something unique, and add a define so the
	callers all hit the right place.

	* util.c (strace_process_vm_readv): Rename from process_vm_readv.
	(process_vm_readv): Define to strace_process_vm_readv.

2012-05-03  Dmitry V. Levin  <ldv@altlinux.org>

	doc: describe documentation policy.
	* README-hacking: Describe documentation policy.

2012-05-02  Dmitry V. Levin  <ldv@altlinux.org>

	maint: post-release administrivia.
	* NEWS: Add header line for next release.

	Prepare for 4.7 release.
	* configure.ac: Version 4.7.
	* debian/changelog: 4.7-1.
	* strace.spec: 4.7-1.

	Fix build with <linux/loop.h> from 2.6.18 kernel headers.
	* configure.ac: Check for LO_FLAGS_AUTOCLEAR and LO_FLAGS_PARTSCAN
	declarations.
	* loop.c (loop_flags_options): Use LO_FLAGS_AUTOCLEAR and
	LO_FLAGS_PARTSCAN only when appropriate declarations are available.
	(loop_ioctl): Use LOOP_SET_CAPACITY only when it is defined.

2012-05-01  Dmitry V. Levin  <ldv@altlinux.org>

	* vsprintf.c: Check for USE_CUSTOM_PRINTF earlier.

	Remove duplicate names from CREDITS.
	* .mailmap: Merge email addresses.
	* CREDITS.in: Remove a duplicate name.

	tests: raise strace check timeout to 60 seconds.
	* tests/init.sh (check_timeout): New variable.
	* tests/ptrace_setoptions: Use it.
	* tests/strace-f: Likewise.

	Reported-by: Mike Frysinger <vapier@gentoo.org>

	Update STA_* constants.
	* time.c (adjtimex_status): Add STA_NANO, STA_MODE, and STA_CLK.
	* NEWS (Improvements): Mention it.

	NEWS: update for release.
	* NEWS (Improvements): Mention recent recvmsg/recvmmsg decoders
	enhancements.
	(Portability): Add a recommendation for the minimum Linux kernel
	version to use.

	Make printing of utsname.domainname more portable.
	* configure.ac: Check for struct utsname.domainname field.
	* process.c (sys_uname): Print utsname.domainname when the field is
	available.

	Fix recvmmsg decode: do not show more data than actually returned.
	This change complements recent fix for recvmsg decoding.

	* net.c (printmmsghdr): Add msg_len parameter to pass down to do_msghdr.
	When this parameter is zero, pass mmsghdr.msg_len to do_msghdr instead.
	(decode_mmsg): Add msg_len parameter, pass it down to printmmsghdr.
	(sys_sendmmsg): Call decode_mmsg with msg_len == (unsigned long) -1L.
	(sys_recvmmsg): Call decode_mmsg with msg_len == 0.

	Remove recently introduced use of ULONG_MAX.
	* io.c: Remove limits.h inclusion.
	(tprint_iov): Use "(unsigned long) -1L" instead of "ULONG_MAX".
	* net.c: Remove limits.h inclusion.
	(printmmsghdr, sys_sendmsg): Use "(unsigned long) -1L" instead of
	"ULONG_MAX".

2012-04-28  Denys Vlasenko  <vda.linux@googlemail.com>

	Enable printing of uts.domainname in uname syscall.
	* process.c (sys_uname): Enable printing of uts.domainname

	Fix printstr's len parameter width.
	We often pass syscall params and other long-sized values
	as printstr(len). Truncating them to int may be a bad thing.

	* defs.h: Change len parameter's type from int to long in
	string_quote and printstr function declarations.
	* util.c (string_quote): Special-case only len==-1, not all len<0.
	(printstr): Likewise.

	Fix recvmsg decode: do not show more data than actually returned.
	I noticed that "hostname -d" talks over netlink and gets 20 bytes
	of response, but we show entire 1024 bytes of iov.
	This changes fixes that.

	* defs.h: New function tprint_iov_upto.
	* io.c (tprint_iov_upto): Definition of this function.
	(tprint_iov): Call tprint_iov_upto.
	* net.c (do_msghdr): Add data_size parameter, pass it down to tprint_iov_upto.
	(printmsghdr): Add data_size parameter, pass it down to do_msghdr.
	(printmmsghdr): Call do_msghdr with data_size==ULONG_MAX.
	(sys_sendmsg): Call printmsghdr with data_size==ULONG_MAX.
	(sys_recvmsg): Call printmsghdr with data_size==tcp->u_rval.

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

	Package strace-log-merge.
	* strace.spec (%files): Add strace-log-merge.

2012-04-27  Mike Frysinger  <vapier@gentoo.org>

	NEWS: clarify & fix typo.

	Cast current_wordsize to an int.
	On 64bit systems with a single personality, we see:
	count.c: In function 'call_summary':
	count.c:223:5: warning: format '%u' expects type 'unsigned int',
		but argument 3 has type 'long unsigned int'

	Since on multi-personality systems this is an array of ints, cast
	the multiplication to an int and update the printf format.

	* count.c (call_summary): Change %u to %d and cast first argument to int.

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

	Update NEWS for upcoming 4.7 release.
	* NEWS: Update for 4.7 release.

	Sync strace.spec and debian/ with packages.
	* debian/changelog: Sync with 4.5.20-2.3.
	* debian/control: Likewise.
	* strace.spec: Sync with 4.6-2.

2012-04-18  Mike Frysinger  <vapier@gentoo.org>

	Decode /dev/loop ioctls.
	Needed to debug some losetup failures, and it's easier when you can see
	what the kernel is getting vs what you think you're sending, so add some
	decoders for those ioctls.

	* loop.c: New file.
	* Makefile.am (strace_SOURCES): Add loop.c.
	* defs.h (loop_ioctl): New prototype.
	(string_quote): Likewise.
	* ioctl.c (ioctl_decode): Call loop_ioctl when code is 'L'.
	* util.c (string_quote): Remove static keyword.

2012-04-18  H.J. Lu  <hongjiu.lu@intel.com>

	x32: add ia32 support.
	* Makefile.am (EXTRA_DIST): Add linux/x32/errnoent1.h,
	linux/x32/ioctlent1.h, linux/x32/signalent1.h and
	linux/x32/syscallent1.h.
	* configure.ac: Remove AC_GNU_SOURCE, obsoleted by
	AC_USE_SYSTEM_EXTENSIONS.
	* defs.h (SUPPORTED_PERSONALITIES): Set to 2 for X32.
	(PERSONALITY1_WORDSIZE): Set to 4 for X32.
	* file.c (stat64): New struct for X32.
	(sys_lseek32): New function for X32.
	(stat64): Undef.
	(sys_fstat64): Likewise.
	(sys_stat64): Likewise.
	(realprintstat64): New function for X32.
	(sys_fstat64): Likewise.
	(sys_stat64): Likewise.
	* mem.c (sys_old_mmap): New function for X32.
	* pathtrace.c (pathtrace_match): Also check sys_old_mmap for X32.
	* syscall.c (update_personality): Add X32 support.
	(get_scno): Support currpers == 1 for X32.
	* linux/syscall.h (sys_lseek32): New function prototype for X32.
	* linux/x32/errnoent1.h: New file.
	* linux/x32/ioctlent1.h: Likewise.
	* linux/x32/signalent1.h: Likewise.
	* linux/x32/syscallent1.h: Likewise.

2012-04-17  H.J. Lu  <hongjiu.lu@intel.com>

	Cast clock_t type to unsigned long long.
	* resource.c (sys_times): Cast clock_t type to unsigned long long.
	* signal.c (printsiginfo): Likewise.

2012-04-16  Denys Vlasenko  <vda.linux@googlemail.com>

	Add custom (faster) vfprintf implementation (disabled by default)
	* defs.h: Declare strace_vfprintf either as a alias to vfprintf
	or as a bona fide function. USE_CUSTOM_PRINTF define controls whether
	we use strace_vfprintf. By default, we don't.
	* strace.c (tprintf): Call strace_vfprintf instead of vfprintf.
	* vsprintf.c: New file, implements strace_vfprintf.

	Stop using %h[h]u format specifiers.
	This is needed for simplified printf, and reduces code size a bit.

	* block.c (block_ioctl): Cast the value to unsinged and use %u
	instead of using %hu.
	* desc.c (sys_io_cancel): Likewise.
	* resource.c (sys_sysinfo): Likewise.

	Trivial speed optimization.
	* strace.c (tprints): Use fputs_unlocked instead of fputs.

2012-04-16  H.J. Lu  <hongjiu.lu@intel.com>

	Fix a problem with sys_lseek on x32.
	* file.c (sys_lseek): Use MIPS-n32 variant also for x32

	Add x32 support to strace.
	X32 support is added to Linux kernel 3.4. In a nutshell, x32 is x86-64 with
	32bit pointers.  At system call level, x32 is also identical to x86-64,
	as shown by many changes like "defined(X86_64) || defined(X32)".  The
	main differerence bewteen x32 and x86-64 is off_t in x32 is long long
	instead of long.

	This patch adds x32 support to strace.  Tested on Linux/x32.

	* configure.ac: Support X32.
	* defs.h: Set SUPPORTED_PERSONALITIES to 3 for X86_64,
	Set PERSONALITY2_WORDSIZE to 4 for X86_64.
	Add tcb::ext_arg for X32.
	* file.c (stat): New for X32.
	(sys_lseek): Use 64-bit version for X32.
	(printstat64): Check current_personality != 1 for X86_64.
	* ipc.c (indirect_ipccall): Check current_personality == 1
	for X86_64.
	* mem.c (sys_mmap64): Also use tcp->u_arg for X32.  Print NULL
	for zero address.  Call printllval for offset for X32.
	* pathtrace.c (pathtrace_match): Don't check sys_old_mmap for
	X32.
	* process.c (ARG_FLAGS): Defined for X32.
	(ARG_STACK): Likewise.
	(ARG_PTID): Likewise.
	(change_syscall): Handle X32.
	(struct_user_offsets): Support X32.
	(sys_arch_prctl): Likewise.
	* signal.c: Include <asm/sigcontext.h> for X32.
	(SA_RESTORER): Also define for X32.
	* syscall.c (update_personality): Support X32 for X86_64.
	(is_restart_error): Likewise.
	(syscall_fixup_on_sysenter): Likewise.
	(get_syscall_args): Likewise.
	(get_syscall_result): Likewise.
	(get_error): Likewise.
	(__X32_SYSCALL_BIT): Define if not defined.
	(__X32_SYSCALL_MASK): Likewise.
	(get_scno): Check DS register value for X32.  Use
	__X32_SYSCALL_MASK on X32 system calls.
	* util.c (printllval): Use ext_arg for X32.
	(printcall): Support X32.
	(change_syscall): Likewise.
	(arg0_offset): Likewise.
	(arg1_offset): Likewise.
	* Makefile.am (EXTRA_DIST): Add linux/x32/errnoent.h,
	linux/x32/ioctlent.h.in, linux/x32/signalent.h,
	linux/x32/syscallent.h, linux/x86_64/errnoent2.h,
	linux/x86_64/ioctlent2.h, linux/x86_64/signalent2.h and
	linux/x86_64/syscallent2.h.
	* linux/x32/errnoent.h: New.
	* linux/x32/ioctlent.h.in: Likewise.
	* linux/x32/signalent.h: Likewise.
	* linux/x32/syscallent.h: Likewise.
	* linux/x86_64/errnoent2.h: Likewise.
	* linux/x86_64/ioctlent2.h: Likewise.
	* linux/x86_64/signalent2.h: Likewise.
	* linux/x86_64/syscallent2.h: Likewise.

	Restore tcb::u_lrval; fix lseek on MIPS-n32.
	Linux kernel v3.4 adds x32 support.  Both x32 and n32 use 64bit offset
	for lseek parameter and return value.  We need u_lrval to handle it
	properly.  Also we shouldn't check HAVE_LONG_LONG_OFF_T for n32 lseek.
	This patch fixes it properly and prepares lseek for x32.

	* defs.h (tcb): Restore tcb::u_lrval field, RVAL_Lfoo constants.
	Set RVAL_MASK to 7.
	* file.c (sys_lseek): Print 64bit offset and return RVAL_LUDECIMAL
	for n32.
	* syscall.c (get_error): Set u_lrval for MIPS-n32.
	(trace_syscall_exiting): Handle RVAL_Lfoo return value types.

2012-04-06  Mike Frysinger  <vapier@gentoo.org>

	Decode mtd ioctls.
	I got tired of figuring out mtd structures (which show up a lot
	in the embedded space), so add decoders for those ioctls.

	* defs.h (mtd_ioctl): New prototype.
	(print_loff_t): Likewise.
	* io.c (print_loff_t): Delete static keyword
	* ioctl.c (ioctl_decode): Call mtd_ioctl when code is 'M'.
	* Makefile.am (strace_SOURCES): Add mtd.c.
	(EXTRA_DIST): Add linux/mtd-abi.h.
	* mtd.c: New file.
	* linux/mtd-abi.h: New file.

2012-04-05  Mike Frysinger  <vapier@gentoo.org>

	Fix indefinite hang on no-mmu systems.
	The ptrace setoptions code will fork a child which goes to sleep and
	expects the parent to continue on to do tests.  Unfortunately, this
	does not work on no-mmu systems as fork() is actually vfork() and any
	vforked children will hang the parent until it exits or execs.

	We might be able to make this test work on no-mmu systems with a bit
	of work, but easier to just disable this for the release so it works
	now.

	* strace.c (test_ptrace_setoptions_for_all): Return if strace_vforked.

2012-03-29  Denys Vlasenko  <vda.linux@googlemail.com>

	Makefile.am: whitespace fix.

2012-03-27  Anton Blanchard  <anton@samba.org>

	powerpc: Add syscall entries for direct socket system calls.
	* linux/powerpc/syscallent.h: Add direct socket system calls.

2012-03-26  Dmitry V. Levin  <ldv@altlinux.org>

	qual_syscall: fix potential NULL dereference.
	Fix regression introduced by commit
	c1371ebc400fe9578908beca87f2bf407daf1506

	* syscall.c (qual_syscall): Handle null sys_name.

	Reported-by: Fr. Br. George <george@altlinux.org>

	strace-log-merge: fix file suffix calculation.
	* strace-log-merge: Quote file prefix to fix file suffix calculation.

	Reported-by: Denys Vlasenko <vda.linux@googlemail.com>
	Suggested-by: Andreas Schwab <schwab@linux-m68k.org>

2012-03-26  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove unreachable code.
	* strace.c (process_opt_p_list): Remove unreachable code.

	manpage: remove false info about -p being limited to 32 processes.

	Tweak help text and manpage (added -In to manpage)

2012-03-25  Dmitry V. Levin  <ldv@altlinux.org>

	printstr: check for potential integer overflow.
	* util.c (printstr): Check for potential integer overflow during outstr
	buffer size calculation.

	Robustify parsing of numbers from strings.
	* defs.h (string_to_uint): New prototype.
	* util.c (string_to_uint): New function.
	* strace.c (error_opt_arg): New function.
	(process_opt_p_list): Use string_to_uint instead of atoi.
	Terminate in case of invalid process id.
	(init): Use string_to_uint instead of atoi.
	Use error_opt_arg in case of invalid option argument.
	* syscall.c (qual_syscall, qual_signal, qual_desc): Use string_to_uint
	instead of atoi.

	strace-log-merge: enhance usage error diagnostics.
	* strace-log-merge: Add --help option.  Check number of arguments.
	Issue an error message when no strace output was merged.

	configure.ac: sort lists and use m4_normalize to ease maintenance.
	* configure.ac (AC_CHECK_FUNCS, AC_CHECK_HEADERS, AC_CHECK_MEMBERS,
	AC_CHECK_DECLS): Sort lists, use m4_normalize.

2012-03-23  Denys Vlasenko  <vda.linux@googlemail.com>

	Simple optimizations.
	Why open-coding isdigit is a good idea?

	Before: call   __ctype_b_loc
	        movzbl (%ebx),%edx
	        mov    (%eax),%eax
	        testb  $0x8,0x1(%eax,%edx,2)
	        je     lbl

	After:  movzbl (%eax),%edx
	        sub    $0x30,%edx
	        cmp    $0x9,%dl
	        ja     lbl

	   text	   data	    bss	    dec	    hex	filename
	 236869	    704	  18944	 256517	  3ea05	strace.before
	 236719	    700	  18944	 256363	  3e96b	strace

	* defs.h: Alias sigemptyset to __sigemptyset on glibc.
	* syscall.c (qual_syscall): Open-code isdigit.
	(qual_desc): Likewise.
	(qual_signal): Open-code isdigit. Remove string copying
	which was done for no apparent reason.

	Reorder declarations in defs.h. No code changes.
	* defs.h: Reorder declarations (such as: keep all printing functions together).

2012-03-22  Denys Vlasenko  <vda.linux@googlemail.com>

	Simplify current tcp switching and current column handling.
	Instead of using "static FILE *outf and static unsigned int curcol"
	to cache current outfile and its position, we can simply
	remember current tcb and use its ->outf and ->curcol.
	This allows to drop numerous "tcp->curcol = curcol" ops in trace().

	Turns out we can't drop "static FILE *outf", but now its role is
	a bit clearer: it newer changes after init, stays == stderr or
	opened to shared log (which may be the same thing if neither -o
	nor -ff was specified). Let's rename it then.

	   text	   data	    bss	    dec	    hex	filename
	 236953	    704	  18944	 256601	  3ea59	strace.before.prev.commit
	 236905	    704	  18944	 256553	  3ea29	strace.before
	 236869	    704	  18944	 256517	  3ea05	strace

	* strace.c: Replace curcol static variable by struct tcb *current_tcp.
	Rename static FILE *outf to shared_log (since it no longer caches tcp->outf).
	(ptrace_restart): Use current_tcp->curcol instead of curcol.
	(tprintf): Check current_tcp != NULL instead of outf != NULL.
	Use current_tcp->outf instead of outf, current_tcp->curcol instead of curcol.
	(tprints): Likewise.
	(line_ended): Likewise.
	(printleader): Switch current tcb by "current_tcp = tcp" istead of
	assignments to outf and curcol.
	(droptcb): Set current_tcp to NULL if we dropped it.
	(startup_child): Rename outf to shared_log.
	(init): Likewise.
	(cleanup): Likewise.
	(trace): Simplify current tcp switching and current column handling.

	Make threaded execve handling code more reabable and somewhat simpler.
	* strace.c (droptcb): Remove outfname check in "outfname && followfork >= 2" -
	with recent changes, followfork >= 2 check guarantees that outfile
	was specified, and _is already opened_.
	(trace): Move tcb existence check before threaded execve handling.
	This allows to remove tcp != NULL checks in threaded execve handling.
	Rewrite threaded execve handling code to be less indented,
	keeping the same logic.

2012-03-21  Denys Vlasenko  <vda.linux@googlemail.com>

	simple cleanups in defs.h. No logic changes.
	* defs.h: Move offsetof macro definition into "libc stuff" section.
	Renumber TCB_foo constants (smaller constants -> sometimes smaller code).
	Remove uoff macro.
	* process.c: Move uoff macro here (sole user).

	Show "+++ exited..." with -C.
	* strace.c (trace): Show "+++ exited..." with -C too.
	Save tcp->curcol after PTRACE_LISTEN failure too, just in case.

	Slight tweak to qemu_multiarch_testing scripts.

	Replace reprinting decision logic.
	After this change, we no longer need to decide when we need
	to set TCB_REPRINT, and when we don't: it's never needed :)

	Well, almost. That pesky pid-changing execve needs special treatment.
	If not it, it'd be possible to nuke TCB_REPRINT...

	While at it, fix a case of mishandled -C.

	* strace.c (printleader): Do not set TCB_REPRINT.
	(trace): Set TCB_REPRINT only for execve with changing pid.
	Fix mishandling of -C.
	* syscall.c (trace_syscall_entering): Do not clear TCB_REPRINT.
	(trace_syscall_exiting): Replace reprinting decision logic.
	Remove call to printargs(): it is known to just return 0 here.

	Report some ptrace failures; nuke tcp->ptrace_errno.
	Report some (not all) ptrace errors, namely,
	errors on ptrace restart operations.

	Before: 10533 sendto(-1, 0x804895e, 17, 0, NULL, 0 <unfinished ...>
	After:  10533 sendto(-1, 0x804895e, 17, 0, NULL, 0 <ptrace(SYSCALL):No such process>

	This tells user that strace failed to let sendto syscall
	to be entered - process was dead at that point of time.
	It is (marginally) better than to always say "<unfinished ...>"

	While at it, patch removes tcp->ptrace_errno.
	I added it many months ago, and it looks that after all
	it is not needed for ptrace error detection: I failed to execute
	a single existing code path which is accessible
	through that variable only.

	* defs.h: Remove struct tcp::ptrace_errno field.
	* strace.c (ptrace_restart): Emit message to log on error.
	(printleader): Remove "if (printing_tcp->ptrace_errno)..." code.
	(trace): Remove !tcp->ptrace_errno check, it's always true.

2012-03-20  Denys Vlasenko  <vda.linux@googlemail.com>

	Eliminate redundant checks of res variable.
	* syscall.c (trace_syscall_entering): Eliminate redundant checks of res variable.
	(trace_syscall_exiting): Likewise.

	Rename POWERPC-specific static variable result to ppc_result.
	* syscall.c: Rename POWERPC-specific static variable result to ppc_result.

	Remove redundant checks in syscall entry/exit, rename badly named function
	* syscall.c (syscall_enter): Rename to get_syscall_args.
	Document its return values.
	(trace_syscall_entering): Don't check get_syscall_args() return
	value for 0, it never returns that.
	(syscall_fixup_on_sysexit): Make it return void.
	(trace_syscall_exiting): Fix up syscall_fixup_on_sysexit()
	call site accordingly.

	Trivial tweaks. No logic changes.
	* process.c (sys_ptrace): Remove unneeded line wrapping.
	* syscall.c (trace_syscall_entering): Use tprints() instead of tprintf().

	Make ptrace_restart() static. No code changes.
	* defs.h: Remove ptrace_restart() declaration.
	* strace.c (ptrace_restart): Move its definition here.
	* util.c (ptrace_restart): Remove its definition.

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

	Do not include limits.h unnecessarily.
	* ioctl.c: Remove limits.h inclusion left after the reverted change.

2012-03-20  Denys Vlasenko  <vda.linux@googlemail.com>

	Partially revert last change.
	Thank you Dmitry for spotting it.

	* ioctl.c (compare): Partially revert last change - the new
	comparison logic was buggy.

	Simplify search in ioctl table.
	   text	   data	    bss	    dec	    hex	filename
	 236973	    704	  18944	 256621	  3ea6d	strace.before
	 236929	    704	  18944	 256577	  3ea41	strace

	* ioctl.c (compare): Simplify generation of compare result.
	(ioctl_lookup): Pass key directly, not as part of dummy struct.
	(ioctl_next_match): More readable code. No logic changes.

2012-03-19  Denys Vlasenko  <vda.linux@googlemail.com>

	Update qemu build script: now tries to upload result back to host.

	Shrink space needed by undefined syscalls in syscall tables.
	Undefined syscall looked like this before this change:
	{ 5,    0,      printargs,              "SYS_53"                },
	That is, "SYS_53" string had to be allocated and stored in strace binary.
	Since now SCNO_IN_RANGE() macro requires sysent[scno].sys_func != NULL
	for valid syscalls, we can replace printargs with NULL in such lines
	and make them "invalid", thus not requiring syscall name string.

	Savings on i386:
	   text	   data	    bss	    dec	    hex	filename
	 237389	    704	  18944	 257037	  3ec0d	strace.before
	 236973	    704	  18944	 256621	  3ea6d	strace
	Savings on mips:
	 336551  153692   38320  528563   810b3 strace.before
	 275543  153688   38320  467551   7225f strace

	Tested to still decode undefined syscalls correctly (syscall no. 222 on i386).

	* linux/*/syscallent.h: Replace 'printargs, "SYS_nnn"' with
	'NULL, NULL'.

	Optimize code if we have only one personality.
	On i386:
	   text	   data	    bss	    dec	    hex	filename
	 238025	    672	  18980	 257677	  3ee8d	strace.before
	 237389	    704	  18944	 257037	  3ec0d	strace

	* defs.h: Define PERSONALITY0_WORDSIZE as sizeof(long) if not defined.
	Introduce new define, current_wordsize as
	(personality_wordsize[current_personality]).
	Make set_personality() no-op, current_personality constant zero,
	current_wordsize as PERSONALITY0_WORDSIZE if we have only one personality.
	* count.c (call_summary): Use current_wordsize instead of
	personality_wordsize[current_personality].
	* desc.c (printflock): Likewise.
	* file.c (sys_utime): Likewise.
	* io.c (tprint_iov): Likewise.
	* process.c (printargv): Likewise.
	* resource.c (decode_rlimit): Likewise.
	* signal.c (sys_kill): Likewise.
	(sys_rt_sigaction): Likewise.
	* time.c (sprinttv): Likewise.
	(sprint_timespec): Likewise.
	(printitv_bitness): Likewise.
	(tprint_timex): Likewise.
	(printsigevent): Likewise.
	* util.c (dumpiov): Likewise.
	(umoven): Likewise.
	(umovestr): Likewise.
	* syscall.c: Initialize sysent to sysent0 etc.
	Make current_personality, personality_wordsize[], set_personality()
	conditional on SUPPORTED_PERSONALITIES > 1.

2012-03-18  Denys Vlasenko  <vda.linux@googlemail.com>

	Fix mips64 build failure: sys_pwrite64 doesn't exist.
	sys_pwrite seems to do the same thing as sys_pwrite64
	which we deleted when we removed non-Linux code.

	* linux/mips/syscallent.h: s/sys_pwrite64/sys_pwrite/

	qemu_multiarch_testing/: a directory with scripts for build testing.

	Make internal_fork and internal_exec static.
	   text	   data	    bss	    dec	    hex	filename
	 237917	    672	  18980	 257569	  3ee21	strace
	 237845	    672	  18980	 257497	  3edd9	strace_new

	* defs.h: Remove declarations of internal_fork and internal_exec.
	* process.c: Remove definitions of internal_fork and internal_exec.
	* syscall.c: Move them here.
	(internal_syscall): Return void instead of int. We were always
	returning zero, and callers weren't checking it anyway.

	Remove code which is not used on Linux.
	Compile tested in qemu on armv4l,armv4tl,armv5l,armv6l,i686,
	mipsel,mips,x86_64

	* syscall.c: Remove code which handles RVAL_Lfoo constants.
	* defs.h: Remove struct tcb::u_lrval member - it is never set.
	Remove RVAL_Lfoo constants which signify return of "long" result -
	they are never used.

	Remove unused version of sys_lseek.
	It is buggy: it returns RVAL_LUDECIMAL, which means the return value
	is in tcp->u_lrval. But tcp->u_lrval is never set
	(on Linux - it used to be set on other OSes).

	* file.c (sys_lseek): Remove a version of this function which is
	supposed to be used if off_t is long long. It appears to be buggy
	and unused.

2012-03-17  Denys Vlasenko  <vda.linux@googlemail.com>

	Revert "Remove underscores from a few syscall names which have them"
	This reverts commit 31972d52b1059d8faca1c5f417c2db1a90b868ae.

	Simplify sys_lseek64 conditional compilation.
	It looks like sys_lseek64() is never used.
	For one, it is buggy (always shows 0 return value), and no one complains.

	From code inspection: sys_lseek64 name is not used anywhere.
	It is defined to sys_lseek if HAVE_LONG_LONG_OFF_T is true.
	Thus, if !HAVE_LONG_LONG_OFF_T, it is never used.
	Therefore "if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T"
	conditional it sits in can be simplified to
	"if HAVE_LONG_LONG_OFF_T".
	Therefore, we can move it a bit up and merge with
	"if !HAVE_LONG_LONG_OFF_T, use this sys_lseek()" code block,
	by addind an "else" clause to it.
	To simplify it more, drop define and just rename sys_lseek64 ->
	sys_lseek.

	Since the function is buggy, I think it is unused and we can
	just drop it. (I checked: at least I386 never uses it).

	* file.c (sys_lseek64): Rename to sys_lseek; don't compile it
	if _LFS64_LARGEFILE but !HAVE_LONG_LONG_OFF_T since in this case
	it is never used.

	Remove underscores from a few syscall names which have them.
	Affected names are "_newselect", "_llseek", "_sysctl".
	I see no apparent reason why they have leading underscores.
	Moreover, some arches have underscored names and some have
	non-underscored ones. This is not consistent.

	I verified that every architectire I touched did not have
	a similarly named syscall without underscore, thus this change
	does not introduce new ambiquities.

	I left "_exit" untouched for now, but the same points stand for it too:
	some architectures use "exit" and no one complains. So why many
	arches are using "_exit"?

	* linux/*/syscallent.h: Remove underscores from displayed
	syscall names for _newselect, _llseek, _sysctl.

	Remove unused struct tcb::baddr field.
	* defs.h: Remove unused struct tcb::baddr field.

	Remove unused PTRACE_WRITE{TEXT,DATA} constants (they are from SunOS)
	* util.c: Remove unused PTRACE_WRITE{TEXT,DATA} constants.

	Reindent case labels. No code changes.
	* net.c (printsockopt): Reindent case labels.
	* signal.c (sys_signal): Likewise.

	Remove unused constants. No code changes.
	* syscall.c: Remove unused ENOIOCTLCMD constant. Fix indentation.
	* util.c: Remove unused CLONE_STOPPED constant.

	Move change_syscall() to its only user and make it static.
	* defs.h: Remove declaration of change_syscall().
	* process.c (change_syscall): Remove definition of this function.
	* util.c (change_syscall): Add definition of change_syscall().

	MAP_ANON is the same as MAP_ANONYMOUS, no need to have the former.
	* mem.c: Do not allocate string for MAP_ANON if it is the same as
	MAP_ANONYMOUS.

	Indentation and whitespace fixes. No code changes.

	test/threaded_execve: make it also test a case when leader is not in syscall

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

	Implement prlimit64 decoding, rewrite [gs]etrlimit decoding.
	* configure.ac: Remove AC_RLIM_T_IS_LONG_LONG call.
	Define SIZEOF_RLIM_T.
	* m4/long_long.m4 (AC_RLIM_T_IS_LONG_LONG): Remove.
	* linux/dummy.h (sys_prlimit64): Remove.
	* linux/syscall.h (sys_prlimit64): New prototype.
	* resource.c (resources): Reindent, add RLIMIT_RTTIME.
	(sprintrlim, print_rlimit32, sys_getrlimit, sys_setrlimit): Remove.
	[HAVE_LONG_LONG_RLIM_T]: Remove dead code.
	[_LFS64_LARGEFILE || HAVE_LONG_LONG_RLIM_T]: Likewise.
	(sprint_rlim64, print_rlimit64, decode_rlimit64, sprint_rlim32,
	print_rlimit32, decode_rlimit, sys_getrlimit, sys_setrlimit,
	sys_prlimit64): New functions.

2012-03-16  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove another "interrupt to quit" message.
	* strace.c (startup_attach): Remove another "interrupt to quit" message.

	Fix "strace -oFILE -ff -p<nonexistant_pid>" behavior.
	* strace.c (newoutf): Set tcp->outf in non-ff mode too.
	(alloctcb): This define is removed.
	(alloc_tcb): Renamed to alloctcb. Does not set tcp->outf anymore.
	Lost 'command_options_parsed' flag parameter.
	(startup_attach): Do not say "interrupt to quit" in attach message -
	^C does not work in all cases, we mislead users.
	Call newoutf(tcp) after successful attach.
	(startup_child): Call newoutf(tcp) after successful attach.
	(trace): Call newoutf(tcp) when we picked up already attached child.

	Make alloc_tcb and droptcb static. No code changes.
	The change is trivial. Diff is large because it is confused
	by function definitions being moved around.

	* defs.h: Remove declarations of alloc_tcb and droptcb.
	* strace.c: Make alloc_tcb and droptcb static.
	Shuffle functions around to make compiler happy.

	Tidy up includes and copyright notices, fix indentation.
	The files not mentioned in changelog below had only
	copyright notices fixes and indentation fixes.

	* defs.h: Include <stdint.h> and <inttypes.h>.
	* file.c: Do not include <inttypes.h>.
	Move struct kernel_dirent declaration below top include block.
	* block.c: Do not include <stdint.h> and <inttypes.h>.
	* quota.c: Likewise.
	* desc.c: Likewise.
	* signal.c: Likewise.

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

	scsi.c: add copyright header.
	* scsi.c: This file was added back in 2007 without a copyright header.
	Add it now.

2012-03-15  Dmitry V. Levin  <ldv@altlinux.org>

	Enhance capget and capset syscalls decoding.
	* system.c (cap_version): New xlat structure.
	(print_cap_header, print_cap_data): New functions.
	(sys_capget, sys_capset): Use them.

	Remove unused code.
	* syscall.c (subcall_style, decode_subcall): Remove.
	[SYS_socket_subcall] (decode_socket_subcall): New function, based on
	decode_subcall in deref_style.
	[SYS_ipc_subcall] (decode_ipc_subcall): New function, based on
	decode_subcall in shift_style.
	(trace_syscall_entering): Use decode_socket_subcall and
	decode_ipc_subcall instead of decode_subcall.

	Fix IPC decoding on alpha and arm.
	* ipc.c (indirect_ipccall): Return 0 on ALPHA and ARM EABI.
	(sys_shmat): Use indirect_ipccall for proper return value decoding.

	arm: fix compilation warnings.
	* configure.ac: Define SIZEOF_LONG.
	* signal.c (sys_rt_sigaction) [SUPPORTED_PERSONALITIES > 1]: Help
	compiler to optimize out unreachable code that is not expected to work
	on platforms where sizeof(long) <= 4.

	tests: robustify again buggy shells.
	* tests/init.sh (check_strace): Use "${parameter:-word}" shell syntax
	instead of "${parameter-word}".

	Reported-by: Mike Frysinger <vapier@gentoo.org>

2012-03-15  Mike Frysinger  <vapier@gentoo.org>

	improve ifdef check with decode_subcall.
	Use the same ifdef logic around the call sites of decode_subcall()
	to protect the definition of the func itself.  This fixes warnings
	for targets like hppa which don't use this func.

	* syscall.c (decode_subcall): Wrap in SYS_socket_subcall and
	SYS_ipc_subcall define checks.

	alpha: fix decode of osf_sigprocmask.
	The alpha sigprocmask syscall is special in that it comes from OSF rather
	than the style that everyone else uses.

	Tested with this simple code:
	$ cat test.c
	#include <signal.h>
	main() {
		sigset_t set, oldset;
		sigemptyset(&set);
		sigaddset(&set, SIGINT);
		sigaddset(&set, SIGHUP);
		sigprocmask(SIG_SETMASK, &set, &oldset);
		sigprocmask(SIG_UNBLOCK, &oldset, &set);
		sleep(3);
	}
	$ gcc test.c && ./strace ./a.out
	...
	osf_sigprocmask(SIG_SETMASK, [HUP INT]) = 0 (old mask [])
	osf_sigprocmask(SIG_UNBLOCK, [])        = 0x3 (old mask [HUP INT])
	osf_sigprocmask(SIG_BLOCK, [CHLD])      = 0x3 (old mask [HUP INT])
	...

	* linux/alpha/syscallent.h: Call sys_sigprocmask for osf_sigprocmask,
	and change number of arguments to two.
	* signal.c (sys_sigprocmask): Fix decoding of alpha osf sigprocmask.

2012-03-15  Denys Vlasenko  <vda.linux@googlemail.com>

	Fix array size calculation in previous commit.
	* pathtrace.c (getfdpath): Fix array size calculation.

	pathtrace_select() is never called with NULL, remove dead code.
	pathtrace_select() is only called for -P FILE options,
	and FILE is never a NULL pointer.

	   text	   data	    bss	    dec	    hex	filename
	 239453	    672	  19012	 259137	  3f441	strace.before
	 239329	    672	  19012	 259013	  3f3c5	strace

	* pathtrace.c (pathtrace_select): Remove "if (path == NULL)...".
	(pathtrace_select): Remove code which only executes if path == NULL.
	The code was also buggy, it can free non-malloced pointer.
	(getfdpath): Simplify snprintf to sprintf.
	(pathmatch): Use strcmp() == 0 idiom for string equality test.
	(pathtrace_match): Likewise.

	manpage: remove bugs which are fixed.
	"A traced process ignores SIGSTOP" - fixed, expected to be in linux-3.4.x.
	"A traced process which tries to block SIGTRAP will be sent a SIGSTOP
	in an attempt to force continuation of tracing." - not needed
	and no longer done.
	"On Linux, exciting as it would be, tracing the init process is forbidden"
	- not true anymore.
	"When a traced process receives a SIGTRAP signal not
	associated with tracing, strace will not report that signal correctly."
	- not true anymore.

	Simplify SIGCHLD handler setting.
	* strace.c (init): Set SIGCHLD to SIG_DFL earlier.
	(startup_child): Do not bother restoring SIGCHLD handler.

	When reporting signals, use short signal names (SIGfoo) instead of strerror
	* defs.h: Remove strsignal declaration.
	* signal.c: Better check for SI_FROMUSER define.
	* strace.c (strerror): Remove this function.
	(trace): Use short signal names (SIGfoo) instead of strerror.

	Remove TODO file: it's eleven years old and completely outdated.

	Clean up defs.h order. No code changes.
	* defs.h: Group together related declarations. No code changes.

	Fix lame kernel version checking code.
	The code "os_release[0] >= '3'" is not good for any
	finer-grained checks such as "kernel >= 3.2.1".
	Let's proactively fix it.

	* strace.c: Change os_release from string to integer.
	(get_os_release): Parse uname.release to KERNEL_VERSION
	representation.
	(init): Convert kernel version check to KERNEL_VERSION.

	Experimental support for "detach on execve" feature.
	* strace.c: Define new detach_on_execve, skip_startup_execve bool variables.
	(init): Set detach_on_execve on -b, set skip_startup_execve if
	"strace PROG" form is used.
	(trace): Detach from process if -b and we see PTRACE_EVENT_EXEC event.

	Simple fixes.
	* strace.c (usage): Document -d; document that -F is deprecated.
	(droptcb): Print "<detached ...>" correctly for non-ff mode too.
	(detach): Suppress a warning.

	Remove an outdated comment.
	* defs.h: Remove an outdated comment.

	Remove extra include directives. No code changes.
	* defs.h: Include <signal.h> unconditionally.
	Other files were doing it unconditionally, so no harm done.
	* bjm.c: Remove system includes which are already included by defs.h.
	* pathtrace.c: Likewise.
	* process.c: Likewise.
	* signal.c: Likewise.
	* strace.c: Likewise.
	* stream.c: Likewise.
	* syscall.c: Likewise.
	* system.c: Likewise.
	* util.c: Likewise.

	Tidy up order of includes; make bool variables explicit.
	Bool variables are more compact in data and (on x86) on code too:

	   text	   data	    bss	    dec	    hex	filename
	 237950	    676	  19044	 257670	  3ee86	strace.before
	 237838	    676	  19012	 257526	  3edf6	strace

	* defs.h: Group library includes at the top of the file.
	Rename dtime to Tflag, debug to debug_flag.
	Change debug_flag,Tflag,qflag,not_failing_only,show_fd_path,tracing_paths
	variable declarations from int to bool.
	* strace.c: Change corresponding definitions. Do the same for static
	variables iflag,rflag,print_pid_pfx.
	Rename dtime to Tflag, debug to debug_flag.
	* syscall.c: Rename dtime to Tflag, debug to debug_flag.

2012-03-15  Dmitry V. Levin  <ldv@altlinux.org>

	Fix compiler warnings about breaking strict-aliasing rules.
	* system.c (sys_capget, sys_capset): Use proxy unions to cast long*
	pointers to cap_user_header_t and cap_user_data_t pointers without
	breaking strict-aliasing rules.

	Reported-by: Mike Frysinger <vapier@gentoo.org>

2012-03-15  Mike Frysinger  <vapier@gentoo.org>

	ppc64: drop unused pid variable.
	* syscall.c (get_scno) [POWERPC64]: Delete unused pid variable.

2012-03-15  Dmitry V. Levin  <ldv@altlinux.org>

	ia64: fix compilation warnings.
	* linux/ia64/syscallent.h: Remove improper defines and undefs.

	Reported-by: Mike Frysinger <vapier@gentoo.org>

	Ensure that SWAP_FLAG_* constants are defined.
	* file.c: Define those of SWAP_FLAG_* constants which are not yet
	provided by <sys/swap.h>.

	Reported-by: Mike Frysinger <vapier@gentoo.org>

2012-03-14  Dmitry V. Levin  <ldv@altlinux.org>

	Enhance *listxattr syscalls decoding.
	* file.c (print_xattr_list): New function.
	(sys_listxattr, sys_flistxattr): Use it.

2012-03-13  Dmitry V. Levin  <ldv@altlinux.org>

	Fix *at syscalls flags decoding.
	Several *at decoders were defining own incomplete *atflags xlat
	structures.  That was error prone, and fchownat decoder actually
	failed to recognize AT_EMPTY_PATH.  Merging these incomplete
	structures into the single at_flags xlat structure will fix
	flags handling in all these decoders altogether.

	* file.c: Define all AT_* constants used by *at decoders.
	(at_flags): New xlat structure, with records for all AT_* constants.
	(fstatatflags, linkat_flags, unlinkatflags): Remove.
	(sys_newfstatat, sys_linkat, sys_unlinkat, sys_fchownat,
	sys_utimensat):  Use at_flags.

	Fix linkat flags decoding.
	* file.c (linkat_flags): New xlat structure.
	(sys_linkat): Decode flags using linkat_flags.

	Implement sys_rt_tgsigqueueinfo syscall decoder.
	* linux/dummy.h (sys_rt_tgsigqueueinfo): Remove.
	* linux/syscall.h (sys_rt_tgsigqueueinfo): New prototype.
	* signal.c (print_sigqueueinfo): New function, based on
	sys_rt_sigqueueinfo.
	(sys_rt_sigqueueinfo): Use print_sigqueueinfo.
	(sys_rt_tgsigqueueinfo): New function.

	Implement syslog syscall decoder.
	* linux/dummy.h (sys_syslog): Remove.
	* linux/syscall.h (sys_syslog): New prototype.
	* system.c (syslog_action_type): New xlat structure.
	(sys_syslog): New function.

2012-03-13  Denys Vlasenko  <vda.linux@googlemail.com>

	Less ugly debug display of ptrace events.
	* strace.c (trace): Less ugly debug display of ptrace events.

	Make manpage mention that -p "`pidof PROG`" works.

	Fix logging for "strace -o FILE -ff test/threaded_execve" test case.
	Our logic which was deciding whether to print "<unfinished ...>"
	thingy wasn't working properly for -ff case.

	* defs.h: Group log generation-related declarations together.
	Add a large comment which explains how it works.
	Add declaration of line_ended() function.
	* strace.c (line_ended): New function which sets up internal data
	to indicate that previous line was finished.
	(printleader): Change logic to fix log generation in -ff mode.
	(newoutf): Make check for -ff mode consistent with other places.
	(droptcb): Print "<detached ...>" if last line for this tcp wasn't finished.
	(cleanup): Remove code to print "<unfinished ...>", printleader()
	or detach() will do it instead.
	(trace): Remove code to print "<unfinished ...>".
	Add code which finishes threaded execve's incomplete line
	with " <pid changed to PID ...>" message. Replace printing_tcp = NULL
	followed by fflush() by line_ended() call.
	* process.c (sys_exit): Call line_ended() to indicate that we finished priting.
	* syscall.c (trace_syscall_exiting): Set printing_tcp to current tcp.
	Call line_ended() to indicate that we finished priting.
	Remove call to fflush(), it is done by line_ended() now.

2012-03-13  Dmitry V. Levin  <ldv@altlinux.org>

	net.c: recognize MSG_WAITFORONE.
	* net.c (msg_flags): Add MSG_WAITFORONE.

2012-03-12  Denys Vlasenko  <vda.linux@googlemail.com>

	Treat -ff without -o FILE as single -f.
	* strace.c (init): Treat -ff without -o FILE as single -f.

	Style fix. No code changes.
	* strace.c (process_opt_p_list): Style fix.

	Reduce stack usage by ~0.5k.
	main() uses ~0.5k of stack for local variables and such. When we enter
	main tracing loop, most of these variables are no longer used.
	But they still take up stack for the entire life of strace.
	We can avoid this wastage if we move init code into a separate function.
	(Need to be careful and not allow automatic inlining).

	* strace.c (init): New function. Most of pre-existing code of
	main is now living here.
	(main): Call init() to do initialization.

	Preparatory cosmetic changes for the next commit.
	* strace.c (tprintf): Move function up in the source file. No code changes.
	(tprints): Likewise.
	(printleader): Likewise.
	(tabto): Likewise.

2012-03-11  Dmitry V. Levin  <ldv@altlinux.org>

	Implement sendmmsg syscall decoder.
	* linux/dummy.h (sys_sendmmsg): Remove.
	* linux/syscall.h (sys_sendmmsg): New prototype.
	* net.c (printmmsghdr): Add index argument specifying the element in
	mmsghdr array to print.
	(decode_mmsg): New function, prints the whole mmsghdr array, its length
	and message flags.
	(sys_sendmmsg): New function.
	(sys_recvmmsg): Use decode_mmsg to fix mmsghdr array decoding.

	Implement sched_rr_get_interval syscall decoder.
	* linux/dummy.h (sys_sched_rr_get_interval): Remove.
	* linux/syscall.h (sys_sched_rr_get_interval): New prototype.
	* process.c (sys_sched_rr_get_interval): New function.

	Implement migrate_pages syscall decoder.
	* linux/dummy.h (sys_migrate_pages): Remove.
	* linux/syscall.h (sys_migrate_pages): New prototype.
	* mem.c (sys_migrate_pages): New function.

	Implement get_robust_list syscall decoder.
	* linux/dummy.h (sys_get_robust_list): Remove.
	* linux/syscall.h (sys_get_robust_list): New prototype.
	* process.c (sys_get_robust_list): New function.

	Define sys_set_robust_list as an alias to sys_munmap.
	* linux/dummy.h (sys_set_robust_list): Redefine to sys_munmap.

	Implement clock_adjtime syscall decoder.
	* linux/dummy.h (sys_clock_adjtime): Remove.
	* linux/syscall.h (sys_clock_adjtime): New prototype.
	* time.c (do_adjtimex): New function, based on sys_adjtimex.
	(sys_adjtimex): Use it.
	(sys_clock_adjtime): New function.

	Define sys_setns as an alias to sys_inotify_rm_watch.
	* linux/dummy.h (sys_setns): Redefine to sys_inotify_rm_watch.

	Sort definitions of dummy parsers.  No code changes.
	* linux/dummy.h: Sort definitions of parsers implemented as aliases.

	Correct inotify_rm_watch decoder.
	* file.c (sys_inotify_rm_watch): Print second argument as int.

	Alias sys_fsync to sys_close.
	* file.c (sys_fsync): Remove.
	* linux/syscall.h (sys_fsync): Likewise.
	* linux/dummy.h (sys_fsync): Alias to sys_close.
	* linux/m68k/syscallent.h: Add TD flag to fsync entry.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.

2012-03-10  Dmitry V. Levin  <ldv@altlinux.org>

	Update ioctl entries.
	* linux/ioctlent.h.in: Regenerate from v3.3 headers.
	* linux/i386/ioctlent.h.in: Likewise.

	strace-log-merge: cleanup.
	* strace-log-merge: Redirect usage to stderr, make the check
	for numeric suffix simpler.

	Add syscall entries for new linux syscalls.
	* linux/i386/syscallent.h: Update process_vm_writev handler.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/alpha/syscallent.h: Add entries for accept4 and sendmmsg.
	* linux/arm/syscallent.h: Add entries for process_vm_readv and
	process_vm_writev.
	* linux/m68k/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Add entries for process_vm_readv,
	process_vm_writev and accept4.
	* linux/microblaze/syscallent.h: Add entries for sendmmsg,
	process_vm_readv and process_vm_writev.

	Implement process_vm_writev decoder.
	* process.c (sys_process_vm_writev): New function.
	* linux/syscall.h (sys_process_vm_writev): New prototype.

	Output iovec length in vmsplice and process_vm_readv decoders.
	* io.c (sys_vmsplice): Output iovec length.
	* process.c (sys_process_vm_readv): Likewise.

2012-03-09  Dmitry V. Levin  <ldv@altlinux.org>

	swapon: decode swap flags.
	* file.c: Include <sys/swap.h>.
	(swap_flags): New xlat structure.
	(sys_swapon): New function.
	* linux/dummy.h (sys_swapon): Remove.
	* linux/syscall.h (sys_swapon): New declaration.

2012-03-09  Denys Vlasenko  <vda.linux@googlemail.com>

	Trivial simplification.
	* strace.c (detach): Use waitpid instead of wait4.

	Don't consider PROG to be our child in "strace -D PROG" case.
	TCB_STRACE_CHILD is used for the case when "strace PROG" is ^C-ed
	or something like that. strace should not just exit - it should
	do something with its child (such as signal it too).

	In -D case, PROG is not really a child of _strace_, it is a child
	of strace's parent. It's ok to handle it exactly as an attached process.

	While we are at it, remove nonsensical special-casing of TCB_STRACE_CHILD
	in printing of "<unfinished ...>" message.

	* strace.c (startup_attach): Don't set TCB_STRACE_CHILD if -D.
	(trace): Print "<unfinished ...>" on error regardless of TCB_STRACE_CHILD.

	Fix the case where we try to detach unattached processes.
	Before this change:
	$ strace -D -p1
	strace: -D and -p are mutually exclusive options
	Process 1 detached  <==== WRONG! (and we try to SIGSTOP it!!!)

	* defs.h: Change the meaning of TCB_ATTACHED: now it means "this tracee
	is attached to us". Add TCB_STRACE_CHILD: "this tracee is our child".
	* strace.c (kill_save_errno): Move up. No code changes.
	(process_opt_p_list): Don't set TCB_ATTACHED on new tcb.
	(startup_attach): Change how we work with TCB_ATTACHED.
	Set TCB_STRACE_CHILD on -D.
	(startup_child): Use kill_save_errno instead of kill.
	Set TCB_ATTACHED and TCB_STRACE_CHILD on attached strace child.
	If we are in -D case, don't set TCB_ATTACHED (we aren't attached yet).
	(detach): do not do PTRACE_DETACH if TCB_ATTACHED is not set.
	(cleanup): Check TCB_STRACE_CHILD instead of TCB_ATTACHED.
	(trace): Likewise.

	Call PTRACE_CONT with addr=0.
	* strace.c (trace): Call PTRACE_CONT with addr=0.

	install strace-log-merge by "make install"

	strace_log_merge: new file. Helper to merge timestamped strace -ff logs.

	Fix PID prefix printing in "strace -oLOG -ff -p1 -p2 -p3" case.
	In this case we were printing PIDs to LOG.* files
	even though it is not necessary.

	The fix is in the addition of "&& followfork < 2" condition.

	* strace.c: Remove pflag_seen variable, add print_pid_pfx one.
	(process_opt_p_list): Do not pflag_seen++.
	(main): Use "nprocs != 0" condition instead of "pflag_seen != 0".
	Set print_pid_pfx before entering main tracing loop.
	(printleader): Use print_pid_pfx to decide whether to print pid prefix.

	Allow -p PID to take comma or whitespace-separated list of PIDs.
	* defs.h: Clarify meaning of TCB_ATTACHED. No code changes.
	* strace.c (process_opt_p_list): New function.
	(main): Call process_opt_p_list to process -p PIDs argument.

2012-03-08  Denys Vlasenko  <vda.linux@googlemail.com>

	Pass addr=0 instead of 1 into restarting ptrace calls.
	While we are at it, fold do_ptrace into its lone caller.
	We no longer set tcp->ptrace_errno = ESRCH on ESRC error in upeek.
	Other code paths where ptrace fails wern't doing it, and the code which
	checks tcp->ptrace_errno even assumes it is never set to ESRCH.
	(It was me who added this code sometime ago, so it was my fault
	that it was a bit messy)

	I ran sigkill_rain test and verified that unfinished syscalls are
	still handled correctly.

	* util.c (ptrace_restart): Do not pass addr=1 to ptrace(), pass 0 instead.
	I have no idea why we were passing 1. Ptrace documentation says
	that addr parameter is ignored.
	(do_ptrace): Remove this function.
	(upeek): Use ptrace() instead of do_ptrace().
	* defs.h: Remove do_ptrace() declaration.

	Trivial tweaks to error messages.
	* strace.c (test_ptrace_setoptions_followfork): Use kill_save_errno
	instead of kill.
	(trace): Use perror_msg instead of perror.
	* count.c (set_sortby): Use error_msg_and_die instead of fprintf.
	* syscall.c (qualify): Likewise.
	* util.c (ptrace_restart): Expand error message.
	(umoven): Likewise.
	(umovestr): Likewise.
	(upeek): Use perror_msg instead of sprintf + perror.

2012-02-28  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove stray sys_swapon() declaration.
	* linux/syscall.h: Remove stray sys_swapon() declaration.
	* linux/mips/syscallent.h: Include dummy.h with correct relative path.
	* linux/dummy.h: Tweak one place where spaces are used instead of tabs.
	* linux/dummy_check.sh: New script. It helps in finding stray syscall
	handler declarations.

2012-02-27  Denys Vlasenko  <vda.linux@googlemail.com>

	Correct syscall entries for t[g]kill.
	* linux/hppa/syscallent.h: Make tgkill use sys_tgkill, not printargs.
	* linux/sh/syscallent.h: Change tkill type TD -> TS.
	* linux/sh64/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Change tkill type 0 -> TS.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/avr32/syscallent.h: Likewise.

	Assorted trivial optimizations.
	   text	   data	    bss	    dec	    hex	filename
	 236448	    672	  19044	 256164	  3e8a4	strace.before
	 236360	    672	  19044	 256076	  3e84c	strace

	* file.c (sprintmode): Use smaller static buffer, eliminate strlen call.
	(sprinttime): Use smaller static buffer.
	(printstat_sparc64): Coalesce two printing calls into one.
	(printstat_powerpc32): Likewise.
	(printcompat_statfs6): Likewise.
	(sys_utime): Do not fetch personality_wordsize[current_personality]
	repeatedly - cache it in local variable instead.
	* process.c (printargv): Likewise.
	* resource.c (sprintrlim): Return const char*, not char*. This allows
	to eliminate sprintf(buf, "RLIM_INFINITY"). Use smaller static buffer.
	(sprintrlim64): Likewise.
	* strace.c (strerror): Use smaller static buffer.
	(strsignal): Likewise.

	Alias a few more syscall printing functions.
	   text	   data	    bss	    dec	    hex	filename
	 237384	    672	  19044	 257100	  3ec4c	strace.before
	 236448	    672	  19044	 256164	  3e8a4	strace

	* defs.h: Declare new functions printargs_lu(), printargs_ld()
	which simply print syscall all args as unsigned or signed longs.
	* desc.c (sys_epoll_create): Call printargs_ld() instead of open-coding it.
	* linux/syscall.h: Remove declarations of the following functions:
	sys_alarm, sys_getresgid, sys_getsid, sys_nice, sys_setgid, sys_setpgid,
	sys_setpgrp, sys_setregid, sys_setresgid.
	* process.c (sys_setgid): Delete this function: now aliased to sys_setuid().
	(sys_getresgid): Delete this function: now aliased to sys_getresuid().
	(sys_setregid): Delete this function: now aliased to sys_setreuid().
	(sys_setresgid): Delete this function: now aliased to sys_setresuid().
	(sys_setpgrp): Delete this function: now aliased to printargs_lu().
	(sys_getsid): Likewise.
	(sys_setpgid): Likewise.
	(sys_alarm): Likewise.
	(sys_getpgrp): Delete this function: was unused - was already shadowed
	by a define in linux/dummy.h.
	(sys_setsid): Likewise.
	(sys_getpgid): Likewise.
	* resource.c (sys_nice): Delete this function: now aliased to printargs_ld().
	* linux/dummy.h: Define new aliases (see above for the list).
	* syscall.c (printargs_lu): New function.
	(printargs_ld): New function.

	Style fixes, no code changes.
	* desc.c (sys_io_getevents): Indentation fix.
	* file.c (sys_xstat): Remove space after function name.
	(decode_mknod): Indentation fix.
	* net.c (printsockopt): Indentation fix.
	* process.c (unalignctl_string): Indentation fix.
	(sys_sched_getscheduler): Remove space after ! operator.

2012-02-25  Dmitry V. Levin  <ldv@altlinux.org>

	Compress blank lines.
	Suppress repeated empty lines left after automated code removal.
	This change was made by filtering every source code file through
	"cat -s".

	Remove parts of automake machinery which are not needed on Linux.
	This change is a verbatim part of Dmitry's changes to remove support
	for non-Linux architectures.

	* Makefile.am: Don't install PORTING file. Install README-linux-ptrace file.
	Set OS variable to linux unconditionally.
	* configure.ac: Remove code to set opsys variable, and its usage.
	Remove checks for headers which are never present on Linux.
	* m4/stat.m4: Remove 'ifdef LINUX' check.
	* m4/statfs.m4: Likewise.

	Remove and update documentation.
	This change is a verbatim part of Dmitry's changes to remove support
	for non-Linux architectures.

	* PORTING: Deleted.
	* INSTALL: Modified.
	* README: Modified.
	* strace.1: Modified: bugs should be reported to mailing list, not Debian.
	* strace.spec: do not install PORTING file.

2012-02-25  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove a few more code parts which are unused on Linux.
	This change is abapted from Dmitry's changes to remove support for
	non-Linux architectures.

	* Makefile.am: Remove if LINUX/endif pairs.
	* defs.h: Remove stream_ioctl() declaration.
	* ioctl.c (ioctl_decode): Remove 'ifdef HAVE_SYS_STREAM_H' block.
	* resource.c: Use 'defined(FOO)' instead of 'defined FOO' form.
	* util.c: Likewise.
	* signal.c: Remove conditional includes which are never used on Linux.
	* stream.c: Likewise.
	* file.c: Remove excessive empty lines.

	Build fixes after non-Linux code removal.
	* configure.ac: Remove calls to proc-based ptrace checks.
	* proc.c: Remove, it's empty now.
	* Makefile.am: Remove reference to proc.c.
	* net.c: Remove trailing newlines.
	* quota.c: Likewise
	* resource.c: Likewise
	* strace.c: Likewise
	* stream.c: Likewise
	* time.c: Likewise

	Fix defined(FOO) style.
	* file.c: Consistently use defined(FOO) instead of defined (FOO).
	* mem.c: Likewise.
	* net.c: Likewise.
	* signal.c: Likewise.
	* sock.c: Likewise.
	* linux/mips/syscallent.h: Likewise.

	Reindent preprocessor directives in util.c; fix style.
	* util.c: Fix indentation of preprocessor directives broken by
	automatic removal of non-Linux code. Fix style to use consistent
	defined(FOO) instead of defined (FOO).

	Reindent preprocessor directives in syscall.c; fix style.
	* syscall.c: Fix indentation of preprocessor directives broken by
	automatic removal of non-Linux code. Fix style to use consistent
	defined(FOO) instead of defined (FOO).

	Reindent defs.h preprocessor directives.
	* defs.h: Fix indentation of preprocessor directives broken by
	automatic removal of non-Linux code.

	Cleanup after non-Linux code removal.
	Conditions such as defined(LINUX) are always true now,
	defined(FREEBSD) etc are always false.
	When if directive has them as subexpressions, it can be simplified.
	Another trivial changes here are fixes for directive indentation.

	Manual removal of non-Linux source, documentation, etc.
	Remove non-Linux source directories: freebsd/, svr4/, sunos4/, svr4/.
	Remove README-freebsd, README-sunos4, README-svr4, m4/procfs.m4.

	linux/sparc/{errnoent1,ioctlent1,signalent1}.h used to point to svr4/ files -
	replace their contents with copies of used (and now deleted) files.
	Make linux/sparc64/{errnoent1,ioctlent1,signalent1}.h include these files
	instead of svr4/* ones.

	Makefile.am: remove references to deleted files.
	configure.ac: Remove a few tests which make no sense on Linux.
	Man page: remove non-Linux quirks information.

	Automated removal of non-Linux code.
	This change is generated by running every source through the following command:

	unifdef -DLINUX -Dlinux -USUNOS4 -USVR4 -UUNIXWARE -UFREEBSD
	-USUNOS4_KERNEL_ARCH_KLUDGE -UHAVE_MP_PROCFS
	-UHAVE_POLLABLE_PROCFS -UHAVE_PR_SYSCALL -UUSE_PROCFS file.c

2012-02-24  Denys Vlasenko  <vda.linux@googlemail.com>

	When accessing data blocks, truncate addr to wordsize.
	* util.c (umoven): Truncate addr to wordsize before use.

2012-02-22  Dmitry V. Levin  <ldv@altlinux.org>

	strace.1: fix a typo.
	* strace.1: Fix a typo in example description.
	This fixes Debian bug #653309.

	Fix sockaddr_un.sun_path name in decoded output.
	* net.c (printsock): Show sockaddr_un.sun_path as "sun_path".
	This fixes Debian bug #554946.

	Avoid potential core file clobbering on exit.
	* strace.c (main): Set RLIMIT_CORE to zero before terminating itself
	with a deadly signal.
	This fixes Debian bug #656398.

2012-02-20  Dmitry V. Levin  <ldv@altlinux.org>

	Eliminate native_scno and known_scno.
	* defs.h (known_scno): Remove.
	(sysent): Remove native_scno field.
	* process.c [IA64]: Replace known_scno(tcp) with tcp->scno.
	(internal_fork) [USE_PROCFS || !LINUX]: Likewise.
	* syscall.c: Do not define NR_SYSCALL_BASE.
	(known_scno): Remove.
	(syscall_fixup_on_sysenter) [USE_PROCFS]: Replace known_scno(tcp)
	with tcp->scno.
	(trace_syscall_entering) [SVR4 || FREEBSD || SUNOS4]: Likewise.
	(syscall_fixup_on_sysexit) [SUNOS4]: Likewise.

	Remove initialization of native_scno field.
	* linux/i386/syscallent.h: Remove native_scno initialization for clone,
	fork and vfork.
	* linux/ia64/syscallent.h (sys_fork, sys_vfork): Remove redirections
	to printargs.
	* linux/syscall.h [IA64]: Do not define SYS_fork and SYS_vfork.
	* util.c (printcall) [IA64]: Likewise.
	(setbpt): Use sys_func to check for clone, fork and vfork syscalls.

	Do not use SYS_ipc and SYS_socketcall.
	* linux/dummy.h (sys_ipc, sys_socketcall): Remove redirections to
	printargs.
	* linux/ia64/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Remove native_scno initialization for "ipc"
	and "socketcall".
	* linux/syscall.h (sys_ipc, sys_socketcall): New prototypes.
	(SYS_ipc, SYS_socketcall): Remove no longer used constants.
	[IA64]: Remove undefining of ipc and socket SYS_* constants.
	[SPARC || SPARC64]: Remove unused ipc SYS_* constants.
	* ipc.c (sys_ipc): New function.
	* sock.c (sys_socketcall): Likewise.
	* syscall.c (trace_syscall_entering): Use sys_func to check for ipc and
	socket subcalls.

	Remove initialization of native_scno field for most of syscalls.
	The native_scno field is not so much used in the code than before.
	In many cases sys_func is checked instead, and for most of syscall
	entries there is no need to initialize native_scno.

	* linux/i386/syscallent.h: Remove native_scno initialization for
	_exit, read, write, waitpid, execve, wait4, sysfs, readv, writev,
	pread64, pwrite64, exit_group, waitid, send, recv, sendto and
	recvfrom syscall entries.
	* linux/syscall.h: Do not define no longer used SYS_waitid and
	SYS_sub_* constants.
	[IA64]: Do not define SYS_waitpid and SYS32_* constants.
	* defs.h: Do not define no longer used  __NR_exit_group constant.
	* strace.c [USE_PROCFS] (proc_open): Use sys_func to check for execve.

2012-02-14  Mike Frysinger  <vapier@gentoo.org>

	util: check for process_vm_readv in C library.
	glibc-2.15 provides process_vm_readv, so trying to provide it ourselves
	with that version fails.

	* configure.ac (AC_CHECK_FUNCS): Add process_vm_readv.
	* util.c: Handle HAVE_PROCESS_VM_READV.

2012-02-09  Denys Vlasenko  <vda.linux@googlemail.com>

	README-linux-ptrace: correct the description of suppressed signals.

2012-02-06  Dmitry V. Levin  <ldv@altlinux.org>

	strace -P: fix handling of invalid syscalls.
	* pathtrace.c (pathtrace_match): Check the given syscall number using
	SCNO_IN_RANGE.

2012-02-06  H.J. Lu  <hongjiu.lu@intel.com>

	Skip the syscall entry if the sys_func field is NULL.
	Avoid NULL dereference when there are holes in sysent tables.
	It can happen with syscall (number, ...) and number is in those holes.
	There are no targets with holey systent tables so far, but at least
	one such a target, x32, is already on the horizon.

	* defs.h (SCNO_IN_RANGE): Also check the sys_func field.

	Define RLIM64_INFINITY only if not defined.
	* resource.c (RLIM64_INFINITY): Define only if it isn't defined.

	Cast to long for %l in printf.
	Cast a value to long for %l in printf to avoid compiler warning
	on systems where it may be long long.

	* count.c (call_summary_pers): Cast to long.
	* ipc.c (sys_mq_open, printmqattr): Likewise.
	* quota.c (decode_cmd_data): Likewise.
	* resource.c (sys_sysinfo): Likewise.
	* time.c (tprint_timex): Likewise.

	Check HAVE_LONG_LONG_OFF_T when printing offset.
	When HAVE_LONG_LONG_OFF_T is defined, we need to use %llu to print
	offset.

	* io.c (sys_sendfile): Check HAVE_LONG_LONG_OFF_T when printing
	offset.

	Define old stat functions only if needed.
	When HAVE_LONG_LONG_OFF_T is defined, those old stat functions aren't
	used and strace won't link since they use realprintstat which isn't
	defined when HAVE_LONG_LONG_OFF_T is defined.

	* file.c (convertoldstat, sys_oldstat, sys_oldfstat, sys_oldlstat):
	Define only if HAVE_LONG_LONG_OFF_T isn't defined.

	Print NULL for zero address in sys_mmap64.
	* mem.c (sys_mmap64): Print NULL for zero address so that it is
	consistent with sys_mmap.

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

	Remove unused sys_pread64 and sys_pwrite64 parsers on Linux.
	* io.c [HAVE_LONG_LONG_OFF_T]: Remove sys_pread64 and sys_pwrite64
	aliases.
	(sys_pread64, sys_pwrite64): Define these functions only on
	[SVR4 && _LFS64_LARGEFILE] platform.
	* linux/mips/syscallent.h: Use sys_pread and sys_pwrite to handle
	appropriate syscalls.
	* linux/syscall.h (sys_pread64, sys_pwrite64): Remove.
	* syscall.c (dumpio): Check sys_pread64 and sys_pwrite64 only on
	[SVR4 && _LFS64_LARGEFILE] platform.

2012-02-03  Denys Vlasenko  <vda.linux@googlemail.com>

	Trivial changes to help text. No code changes.
	* strace.c (usage): Tweak help text: remove unpaired closing brackets,
	make -V and -h sit on separate lines (hard to see them otherwise).

2012-01-29  Denys Vlasenko  <vda.linux@googlemail.com>

	Simple optimizations.
	   text	   data	    bss	    dec	    hex	filename
	 239474	    672	  20484	 260630	  3fa16	strace.before
	 239234	    668	  19044	 258946	  3f382	strace

	* file.c (sprint_open_modes): Reduce static buffer size.
	Simplify separator printing.
	* signal.c (sprintsigmask): Reduce static buffer size.
	Simplify separator printing and printing of almost full masks.
	Use stpcpy instead of sprintf and strcpy+strlen.
	* strace.c (startup_child): Don't strchr() for ':' twice in a row.
	* util.c (sprintflags): Exit loop early if possible.

	Trivial optimization.
	* strace.c (cleanup): Read 'interrupted' volatile variable only once.

	Make interactive-ness directly controllable via command line option.
	Defaults are often ok, but when they are not, people get confused.
	"Why can't I kill strace?" and "Why strace dies on ^C when I want
	to _tracee_ to die instead?" are typical complaints.

	* strace.c: Replace 'interactive' variable with 'opt_intr' variable.
	Define INTR_foo constants for its possible values.
	Define 'interactive' as a macro.
	(usage): Document -I n option.
	(main): Parse -I n option, modify signal handling to accomidate new
	-I 1 and -I 4 modes.

	Suppress compiler warning.
	* strace.c (trace): Frame potentially unused label with ifdef/endif.

	On Ctrl-C induced detach, send SIGINT to child tracee, not SIGTERM.
	* strace.c (interrupt): Remember signal number.
	(cleanup): If we exiting due to signal, send that signal to child tracee.

	Add experimental code to use PTRACE_SEIZE, disabled by default.
	All new code is predicated on "ifdef USE_SEIZE". If it is not defined,
	behavior is not changed.

	If USE_SEIZE is enabled and run-time check shows that PTRACE_SEIZE works, then:
	- All attaching is done with PTRACE_SEIZE + PTRACE_INTERRUPT.
	  This means that we no longer generate (and possibly race with) SIGSTOP.
	- PTRACE_EVENT_STOP will be generated if tracee is group-stopped.
	  When we detect it, we issue PTRACE_LISTEN instead of PTRACE_SYSCALL.
	  This leaves tracee stopped. This fixes the inability to SIGSTOP or ^Z
	  a straced process.

	* defs.h: Add commented-out "define USE_SEIZE 1" and define PTRACE_SEIZE
	and related constants.
	* strace.c: New variable post_attach_sigstop shows whether we age going
	to expect SIGSTOP on attach (IOW: are we going to use PTRACE_SEIZE).
	(ptrace_attach_or_seize): New function. Uses PTRACE_ATTACH or
	PTRACE_SEIZE + PTRACE_INTERRUPT to attach to given pid.
	(startup_attach): Use ptrace_attach_or_seize() instead of ptrace(PTRACE_ATTACH).
	(startup_child): Conditionally use alternative attach method using PTRACE_SEIZE.
	(test_ptrace_setoptions_followfork): More robust parameters to PTRACE_TRACEME.
	(test_ptrace_seize): New function to test whether PTRACE_SEIZE works.
	(main): Call test_ptrace_seize() while initializing.
	(trace): If PTRACE_EVENT_STOP is seen, restart using PTRACE_LISTEN in order
	to not let tracee run.
	* process.c: Decode PTRACE_SEIZE, PTRACE_INTERRUPT, PTRACE_LISTEN.
	* util.c (ptrace_restart): Add "LISTEN" to a possible error message.

2012-01-28  Denys Vlasenko  <vda.linux@googlemail.com>

	process_vm_readv gets EINVAL if process is gone (SIGKILLed). Don't complain.
	* util.c (umoven): Don't complain on EINVAL from process_vm_readv.
	(umovestr): Likewise.

	Revert last change. Add a comment to prevent further misunderstanding.
	* time.c (sys_nanosleep): Display remaining time only on interrupt.

	Fix nanosleep decoding: second argument was not shown after success.
	* time.c (sys_nanosleep): Fix bug - inverted is_restart_error() check.
	* syscall.c (is_restart_error): Remove redundant check.

	Use process_vm_readv instead of PTRACE_PEEKDATA to read data blocks.
	Currently, we use PTRACE_PEEKDATA to read things like filenames and
	data passed by I/O syscalls.
	PTRACE_PEEKDATA gets one word per syscall. This is VERY expensive.
	For example, in order to print fstat syscall, we need to perform
	more than twenty trips into kernel to fetch one struct stat!

	Kernel 3.2 got a new syscall, process_vm_readv(), which can be used to
	copy data blocks out of process' address space.

	This change uses it in umoven() and umovestr() functions if possible,
	with fallback to old method if process_vm_readv() fails.
	If it returns ENOSYS, we don't try to use it anymore, eliminating
	overhead of trying it on older kernels.

	Result of "time strace -oLOG ls -l /usr/lib >/dev/null":
	before patch: 0.372s
	After patch:  0.262s

	* util.c (process_vm_readv): Wrapper to call process_vm_readv syscall.
	(umoven): Use process_vm_readv for block reads of tracee memory.
	(umovestr): Likewise.
	* linux/syscall.h: Declare new function sys_process_vm_readv.
	* process.c (sys_process_vm_readv): Decoder for new syscall.
	* linux/i386/syscallent.h: Add process_vm_readv, process_vm_writev syscalls.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.

	Fix a case of broken output if last seen syscall was exit.
	* defs.h: Rename tcp_last to printing_tcp. Explain what it means.
	Remove printtrailer() function.
	* process.c (sys_exit): Convert printtrailer() call to "printing_tcp = NULL".
	* strace.c: Add new variable printing_tcp.
	(cleanup): Convert printtrailer() call to "printing_tcp = NULL".
	(trace): Likewise.
	(trace): Fix checks for incomplete line - it was working wrongly if last syscall was exit.
	(printleader): Set printing_tcp.
	(printtrailer): Remove this function.
	* syscall.c: Remove tcp_last variable.
	(trace_syscall_entering): Don't set printing_tcp, printleader call now does it.
	(trace_syscall_exiting): Convert printtrailer() call to "printing_tcp = NULL".

	Fix handling of test/threaded_execve.c testcase.
	Since 3.0, Linux has a way to identify which thread execve'ed.
	This patch makes use of it in order to properly dispose
	of disappeared ("superseded") thread leader,
	and replace it with execve'ed thread.

	Before this patch, strace was "leaking" thread which exec'ed.
	It was thinking that it still runs. It would look like this:

	18460 pause( <unfinished ...>     <=== thread leader
	18466 execve("/proc/self/exe", ["exe", "exe"], [/* 47 vars */] <unfinished ...>
	18465 +++ exited with 0 +++       <=== exits from other threads
	18460 <... pause resumed> )             = 0

	The last line is wrong: it's not pause resumed, it's execve resumed.
	If thread leader would do exit instead of pause, it is much worse:
	strace panics because it thinks it sees return from exit syscall!

	And strace isn't aware 18466 (exec'ed thread) is gone.
	It still thinks it's executes execve syscall.

	* strace.c: New variable "static char *os_release".
	(get_os_release): New static function.
	(main): Call get_os_release to retrieve Linux version.
	(trace): If we see PTRACE_EVENT_EXEC, retrieve old pid, and if it
	differs from new one, free one of tcbs and print correct messages.

2012-01-27  Denys Vlasenko  <vda.linux@googlemail.com>

	Fix readlink result display - was printing bogus "..." semi-randomly.
	* file.c (decode_readlink): Use printstr() instead of printpathn().

	Add new test program: test/threaded_execve.c.

	Make pid2tcb static.
	* defs.h: Remove pid2tcb declaration.
	* strace.c (pid2tcb): Make this function static.

2012-01-24  Denys Vlasenko  <vda.linux@googlemail.com>

	Per Dmitry's request, remove paranoid check in verror_msg()
	* strace.c (verror_msg): Remove redundant check for msg != NULL.

	More robust error check for vasprintf.
	* strace.c (verror_msg): More robust error check for vasprintf.

	Slightly more compact handling of argv[]
	   text	   data	    bss	    dec	    hex	filename
	 238274	    672	  20484	 259430	  3f566	strace.before
	 238226	    672	  20484	 259382	  3f536	strace

	* strace.c (main): Slightly more compact handling of argv[]

	Trivial optimization.
	* strace.c: Set default interactive = 1 statically instead
	of doing it in main().

	Allocate -o OUTFILE buffer only if needed.
	   text	   data	    bss	    dec	    hex	filename
	 238258	    668	  28676	 267602	  41552	strace.before
	 238274	    668	  20484	 259426	  3f562	strace

	* strace.c (main): Allocate -o OUTFILE buffer only if needed:
	unused buffer in bss is not entirely free.

	Use single fprintf in verror_msg()
	This change partially reverts commit 44d0532.

	In code before commit 44d0532, single fprintf was used on purpose:
	we want to send entire message as one write() call. Since stderr
	is unbuffered, separate fprintf's to it always result in separate
	writes, they are not coalesced. If we aren't the only program
	which writes to this particular stderr, this may result
	in interleaved messages.

	Since this function is not performance critical, I guess
	it's ok to make it less efficient.

	* strace.c (verror_msg): Attempt to print the message in single
	write operation. Use separate fprintfs as a fallback if malloc fails.

2012-01-21  Denys Vlasenko  <vda.linux@googlemail.com>

	Improve code readability (logic is unchanged)
	* util.c (umoven): Move assignment out of function call. Make assignment
	to a flag variable later, closer to the place where it will be used.
	(umovestr): Likewise.
	(uload): Likewise.

2012-01-20  Denys Vlasenko  <vda.linux@googlemail.com>

	Change umovestr API: return > 0 instead of 0 if NUL was seen.
	* pathtrace.c (upathmatch): Adjust umovestr return value check for new API.
	* util.c (printpathn): Use umovestr() > 0 return value for more efficient
	(and robust - we don't depend on "no overwrote past NUL" behavior anymore)
	handling of terminating NUL.
	(printstr): Remove useless NUL placement before umovestr() call.
	Allocate 1 byte more to outstr[] array - for NUL.
	(umovestr): Change to return 1 if NUL was seen.

	umovestr result may have no NUL, use "%.*s" instead of "%s" to print it.
	* system.c (sys_mount): Be careful when printing umovestr result,
	it may have no terminating NUL.
	(sys_sysmips): Likewise.

	Eliminate code duplication in time printing, reduce a few static buffers
	   text	   data	    bss	    dec	    hex	filename
	 238454	    664	  28772	 267890	  41672	strace.before
	 238106	    664	  28676	 267446	  414b6	strace

	* defs.h: Add TIMESPEC_TEXT_BUFSIZE and TIMEVAL_TEXT_BUFSIZE defines.
	Add 'int special' parameter to sprinttv().
	* time.c (sprinttv): Add 'int special' parameter, and use it
	similarly to 'int special' parameter of printtv_bitness().
	(printtv_bitness): Use sprinttv() instead of duplicating its code.
	(print_timespec): Use sprint_timespec() instead of duplicating
	its code.
	* desc.c (decode_select): Use TIMEVAL_TEXT_BUFSIZE instead of 128
	when checking remaining buffer size.
	* net.c (sys_recvmsg): Use TIMESPEC_TEXT_BUFSIZE instead of 128
	for static buffer size.
	* stream.c (decode_poll): Use TIMESPEC_TEXT_BUFSIZE instead of 128
	when checking remaining buffer size.

2012-01-19  Denys Vlasenko  <dvlasenk@redhat.com>

	Reduce bss usage and speed up string printing.
	   text	   data	    bss	    dec	    hex	filename
	 237913	    660	  49284	 287857	  46471	strace.before
	 237973	    660	  28772	 267405	  4148d	strace

	This reduces L1 D-cache pressure a bit: instead of dirtying
	20k of bss, we will reuse already dirty stack area.

	* util.c (printpathn): Use on-stack buffers instead of static ones.
	Saves 5*MAXPATHLEN in bss.
	(printstr): Use tprints() instead of tprintf("%s") when printing
	formatted string. May be a bit faster, depending on libc.

2012-01-18  Andreas Schwab  <schwab@linux-m68k.org>

	Add support for compat_statfs64.
	* file.c (struct compat_statfs64, printcompat_statfs64): Define.
	(sys_statfs64, sys_fstatfs64): Use it.

	Add support for statfs64.f_flags.
	* file.c (printstatfs64): Print f_flags if available.

	Fix missing parens.
	* signal.c (sys_sigreturn): Add missing parens.

2012-01-18  Denys Vlasenko  <dvlasenk@redhat.com>

	Get rid of TCB_SIGTRAPPED.
	On attempts to block or set SIGTRAP handler,
	for example, using sigaction syscall, we generate
	an additional SIGSTOP.

	This change gets rid of this SIGSTOP sending/ignoring.
	It appears to work just fine.

	It also works if I force strace to not use PTRACE_O_TRACESYSGOOD,
	which means strace stops will be marked with SIGTRAP,
	not (SIGTRAP | 0x80) - I wondered maybe that's when
	this hack is needed.

	So, why we even have TCB_SIGTRAPPED? No one knows. It predates
	version control: this code was present in the initial commit,
	in 1999. No adequate comments, either.

	Moreover, TCB_SIGTRAPPED is not set in sys_rt_sigaction
	and sys_sigprocmask syscalls - the ones which are most usually
	used to implement signal blocking, it is only set in obsolete
	sys_signal, sys_sigaction, sys_sigsetmask, and in some dead
	non-Linux code.

	I think whatever bug it was fixing is gone long ago -
	at least as long as sys_rt_sigaction is used by glibc.
	Again, since glibc (and uclibc) uses sys_rt_sigaction
	and sys_sigprocmask, modified code paths are not used
	by most programs anyway.

	* defs.h: Remove definition of TCB_SIGTRAPPED.
	* signal.c (sys_sigvec): Don't set TCB_SIGTRAPPED and don't send SIGSTOP.
	(sys_sigsetmask): Likewise.
	(sys_sigaction): Likewise.
	(sys_signal): Likewise.
	* strace.c (trace): Remove code which executes if TCB_SIGTRAPPED is set.

	When we write log, flush output buffers in a few more cases.
	I observed a case when signal delivery message was buffered
	by stdio until it was flushed along with the next syscall
	entry message.

	* strace.c (trace): Flush output buffers in a few more cases.

	Fix old sigaction display.
	* signal.c (sys_sigaction): Fix display of sigaction with
	SIG_DFL/SIG_IGN handlers.

	Change x86_64_regs struct type from pt_regs to user_regs_struct.
	* syscall.c: Change x86_64_regs struct type from
	pt_regs to user_regs_struct, and explain the change in comment.

2012-01-17  Dmitry V. Levin  <ldv@altlinux.org>

	Fix struct pt_regs declaration on i386 and x86-64.
	* defs.h [I386] (i386_regs): Replace definition with declaration.
	[X86_64] (x86_64_regs): Remove.
	* syscall.c [X86_64] (x86_64_regs): Make static.

2012-01-12  Denys Vlasenko  <dvlasenk@redhat.com>

	Make ERESTARTxyz messages more descriptive.
	There is widespread confusion about exact meaning
	of ERESTARTxyz codes. Before this change, we were showing
	all four of them the same: as "(To be restarted)".

	This change prints better explanations for these codes,
	and contains verbose comments which explain *why* we display
	codes that way - or else someone confused
	is bound to come later and mangle them again.
	New messages are:

	ERESTARTSYS (To be restarted if SA_RESTART is set)
	ERESTARTNOINTR (To be restarted)
	ERESTARTNOHAND (Interrupted by signal)
	ERESTART_RESTARTBLOCK (Interrupted by signal)

	* syscall.c (trace_syscall_exiting): Make ERESTARTxyz messages
	more descriptive.

2012-01-10  Denys Vlasenko  <dvlasenk@redhat.com>

	Fix sigreturn arg count from 1 to 0 on all architectures.
	* linux/alpha/syscallent.h: Change [rt_]sigreturn's arg count to 0.
	* linux/arm/syscallent.h: Likewise.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.

	Display mask on enter to sigreturn, not on exit.
	sys_sigreturn() performs ugly manipulations in order to show
	signal mask which is restored by this syscall: on syscall entry,
	fetches it from the stack, saves it in tcp->u_arg[]
	(where it used to overflow this array - fixed sometime ago),
	then retrieves the mask and displays it on syscall exit.

	Apparently, the motivation is to make it slightly more obvious
	to user that signal mask is restored only when this syscall returns.
	IMO, this hardly justifies the necessary hacks. It is much easier
	to display the mask at the point when we fetch it - on syscall entry.

	While at it, I made it so that we do display returned value/errno.
	I see no point in hiding it and showing uninformative "= ?" instead.

	Example of pause() being interrupted by ALRM which has installed handler
	which re-arms ALRM:

	Before the patch:

	rt_sigsuspend([INT])                    = ? ERESTARTNOHAND (To be restarted)
	--- {si_signo=SIGALRM, si_code=SI_KERNEL} (Alarm clock) ---
	alarm(1)                                = 0
	sigreturn()                             = ? (mask now [INT])

	After:

	rt_sigsuspend([INT])                    = ? ERESTARTNOHAND (To be restarted)
	--- {si_signo=SIGALRM, si_code=SI_KERNEL} (Alarm clock) ---
	alarm(1)                                = 0
	sigreturn() (mask [INT])                = -1 EINTR (Interrupted system call)

	* defs.h: Declare struct pt_regs i386_regs and struct pt_regs x86_64_regs.
	* syscall.c: Remove "static" keywork from these structures' definitions.
	* signal.c (sys_sigreturn): Display mask on enter, not on exit.

2012-01-04  Denys Vlasenko  <dvlasenk@redhat.com>

	Do not detach from tracee which experienced ptrace error.
	Before this patch, if a thread got nuked by exit in another thread
	and we happened to poke it at the same time, we print "????(" thingy
	and detach the thread. Since we removed "detach before death" logic,
	this no longer matches the behavior of other threads.
	Before patch:
	[pid  1780] exit_group(1)               = ?
	[pid  1778] ????( <unfinished ...>
	Process 1778 detached
	[pid  5860] +++ exited with 1 +++
	After:
	[pid 17765] exit_group(1)               = ?
	[pid 21680] ????( <unfinished ...>
	[pid 17791] +++ exited with 1 +++
	[pid 21680] +++ exited with 1 +++

	* strace (trace): Do not detach from tracee which experienced ptrace error.

	Remove sig parameter from detach()
	* strace.c (detach): Drop sig parameter - it is zero in all calls.
	(cleanup): Don't pass sig = 0 to detach() call.
	(detach): Ditto.

2011-12-26  Dmitry V. Levin  <ldv@altlinux.org>

	Enhance decoding for personalities with small wordsize.
	* util.c (umoven, umovestr) [SUPPORTED_PERSONALITIES > 1]: If current
	personality's wordsize is less than sizeof(long), use only significant
	bits of the given address.

2011-12-23  Dmitry V. Levin  <ldv@altlinux.org>

	Enhance personality switching.
	On syscall entry, save current personality in the tcb structure
	along with scno.
	On syscall exit, restore current personality from the tcb structure.
	* defs.h (struct tcb) [SUPPORTED_PERSONALITIES > 1]: Add currpers
	field.
	* strace.c (alloc_tcb) [SUPPORTED_PERSONALITIES > 1]: Initialize
	tcp->currpers.
	* syscall.c (update_personality) [SUPPORTED_PERSONALITIES > 1]: New
	function.
	(get_scno, trace_syscall_exiting): Use it.

	Reported-by: Michael A Fetterman <mafetter@nvidia.com>

2011-12-01  Dmitry V. Levin  <ldv@altlinux.org>

	* net.c (socktcpoptions): Add more TCP_* constants from linux/tcp.h.
	Reported-by: Rick Jones <rick.jones2@hp.com>

2011-12-01  Heiko Carstens  <heiko.carstens@de.ibm.com>

	Fix sys_ipc/sys_semtimedop decoding on s390.
	The s390 kernel sys_ipc system call only takes five arguments instead of
	six arguments which the common code sys_ipc implementation takes.
	One of the arguments of the sys_semtimedop subcall is therefore passed in
	a different register than in the common code implementation.
	This leads to broken decoding of the timespec argument:

	semtimedop(0, 0x3ffffb43832, 1, {...})  = -1 EAGAIN

	Fixed it looks like this:

	semtimedop(0, 0x3ffffc2c842, 1, {0, 10000000}) = -1 EINTR

	* linux/ipc.c (sys_semtimedop): Fix timespec decoding on s390.

2011-11-29  Dmitry V. Levin  <ldv@altlinux.org>

	strace.c (trace): Fix compilation warning.

2011-11-28  Dmitry V. Levin  <ldv@altlinux.org>

	linux/syscall.h: Remove redundant function declarations.
	Remove 51 function declarations aliased to other declarations in
	linux/dummy.h file.

	linux/syscall.h: Sort function declarations.

	linux/syscall.h: Place one function declaration per line.

	Remove redundant parsers.
	* desc.c (sys_dup): Remove.
	* file.c (sys_pivotroot, sys_rmdir, sys_fchdir, sys_chroot, sys_fchroot,
	sys_unlink, sys_symlink, sys_rename): Remove.
	* linux/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_pivotroot,
	sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
	* linux/dummy.h: Add aliases for sys_chroot, sys_dup, sys_pivotroot,
	sys_rename, sys_rmdir, sys_symlink, sys_unlink.
	* pathtrace.c (pathtrace_match): Update.
	* sunos4/dummy.h: Add aliases for sys_chroot, sys_dup, sys_fchdir,
	sys_fchroot, sys_rename, sys_rmdir, sys_symlink, sys_unlink.
	* svr4/dummy.h: Likewise.
	* sunos4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
	sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
	* svr4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
	sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.

	Reflect the fact that nfsservctl syscall was removed from linux kernels.
	linux/dummy.h: Move nfsservctl to "unimplemented" section.

2011-11-27  Dmitry V. Levin  <ldv@altlinux.org>

	x86_64: add getcpu syscall entry.
	* linux/x86_64/syscallent.h: Add syscall entry for getcpu.

2011-11-26  Dmitry V. Levin  <ldv@altlinux.org>

	Add syscall entries for new linux syscalls.
	* linux/dummy.h: Add printargs parsers for new syscalls.
	* linux/arm/syscallent.h: Add entries for sys_clock_adjtime,
	sys_name_to_handle_at, sys_open_by_handle_at, sys_sendmmsg, sys_setns
	and sys_syncfs.
	* linux/i386/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/alpha/syscallent.h: Add entries for sys_clock_adjtime,
	sys_name_to_handle_at, sys_open_by_handle_at, sys_setns and sys_syncfs.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/avr32/syscallent.h: Add entry for sys_setns.
	* linux/bfin/syscallent.h: Add entries for sys_sendmmsg and sys_setns.
	* linux/hppa/syscallent.h: Add entries for sys_clock_adjtime,
	fanotify_init, fanotify_mark, sys_name_to_handle_at,
	sys_open_by_handle_at, sys_sendmmsg, sys_setns and sys_syncfs.

	Fix prctl syscall entries.
	* linux/mips/syscallent.h: Fix prctl handler.
	* linux/tile/syscallent.h: Likewise.

	arm: fix io_* syscall entries.
	* linux/arm/syscallent.h: Fix handlers for io_setup, io_destroy,
	io_getevents, io_submit and io_cancel.

	Fix mincore syscall entries.
	* linux/arm/syscallent.h: Fix mincore handler.
	* linux/avr32/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.

2011-11-25  Dmitry V. Levin  <ldv@altlinux.org>

	Fix sendmsg syscall entries.
	* linux/arm/syscallent.h: Fix number of sendmsg arguments.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/hppa/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

	Fix epoll_wait syscall entries.
	* linux/arm/syscallent.h: Fix epoll_wait flags and handler.
	* linux/m68k/syscallent.h: Fix epoll_wait flags.
	* linux/microblaze/syscallent.h: Fix number of epoll_wait arguments.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

	Fix epoll_ctl syscall entries.
	* linux/arm/syscallent.h: Fix epoll_ctl flags and handler.
	* linux/m68k/syscallent.h: Fix epoll_ctl flags.
	* linux/x86_64/syscallent.h: Fix number of epoll_ctl arguments.

	arm: fix epoll_create syscall entry.
	* linux/arm/syscallent.h: Fix epoll_create handler.

	Fix mlockall syscall entries.
	* linux/arm/syscallent.h: Fix number of mlockall arguments.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

	Fix epoll_pwait syscall entries.
	* linux/alpha/syscallent.h: Fix number of epoll_pwait arguments.
	* linux/arm/syscallent.h: Likewise.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

	Fix reboot syscall entries.
	* linux/alpha/syscallent.h: Fix number of reboot arguments.
	* linux/arm/syscallent.h: Likewise.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/hppa/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

	Fix swapon syscall entries.
	* linux/arm/syscallent.h: Fix number of swapon arguments.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/alpha/syscallent.h: Fix number of swapon arguments, add TF flag.
	* linux/hppa/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.

	Fix sgetmask and ssetmask syscall entries.
	* linux/hppa/syscallent.h: Fix sgetmask and ssetmask entries.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.

	Rename siggetmask to sgetmask and sigsetmask to ssetmask.
	* linux/arm/syscallent.h: Rename siggetmask to sgetmask and
	sigsetmask to ssetmask.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Rename sys_sgetmask to sys_siggetmask,
	sys_ssetmask to sys_sigsetmask.

	Add TRACE_IPC flag to sys_ipc syscall entries.
	* linux/arm/syscallent.h: Add TI flag to sys_ipc entry.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.

2011-11-05  Dmitry V. Levin  <ldv@altlinux.org>

	gitlog-to-changelog: update from gnulib.
	* gitlog-to-changelog: Update from gnulib.
	* Makefile.am: Add --append-dot to gitlog-to-changelog invocation.

2011-10-22  Denys Vlasenko  <dvlasenk@redhat.com>

	Decode TIOCSCTTY's third parameter.
	* term.c (term_ioctl): Decode TIOCSCTTY's third parameter.

2011-10-14  Dmitry V. Levin  <ldv@altlinux.org>

	Remove useless and obsolete "#if DONE" sections.  No code changes.
	* linux/dummy.h: Remove "#if DONE" section.
	* linux/sparc/dummy2.h: Likewise.
	* linux/sparc64/dummy2.h: Likewise.
	* sunos4/dummy.h: Likewise.
	* svr4/dummy.h: Likewise.

	Add names for dummy parsers.  No code changes.
	* linux/dummy.h: Add aliases to printargs() for those of dummy parsers
	that had no own names before.
	* linux/*/syscallent.h: Use these new names instead of printargs.

	Sort definitions of dummy parsers.  No code changes.
	* linux/dummy.h: Sort definitions of parsers implemented as aliases
	to printargs().

2011-10-14  Mike Frysinger  <vapier@gentoo.org>

	sys_epoll_create1: decode flag arguments correctly.
	* desc.c (epollflags): Define.
	(sys_epoll_create1): Use epollflags to printflags. Change "O" to "EPOLL".

	Reported-by: Марк Коренберг <socketpair@gmail.com>

2011-10-11  Dmitry V. Levin  <ldv@altlinux.org>

	Implement decoding of splice, tee and vmsplice(2) syscalls.
	* io.c (print_loff_t): New function.
	(sys_sendfile64): Use it.
	(splice_flags): New xlat structure.
	(sys_tee, sys_splice, sys_vmsplice): New functions.
	* linux/syscall.h (sys_tee, sys_splice, sys_vmsplice): Declare them.
	* linux/*/syscallent.h: Use them.

	Fix epoll_wait and epoll_pwait decoding.
	* desc.c (epoll_wait_common): Print "maxevents" and "timeout" arguments
	as integers.

	Reported-by: Марк Коренберг <socketpair@gmail.com>

	Decode EPOLLRDHUP.
	* desc.c (epollevents): Add EPOLLRDHUP.

	Reported-by: Марк Коренберг <socketpair@gmail.com>

	Remove unreachable code in umoven() and umovestr().
	* util.c (umoven, umovestr): Remove unreachable code.

	Reported-by: Weichuan Yan <wchyan@marvell.com>

2011-09-05  Denys Vlasenko  <dvlasenk@redhat.com>

	Do post-attach initialization earlier; fix "we ignore SIGSTOP on NOMMU" bug
	We set ptrace options when we see post-attach SIGSTOP.
	This is wrong: it's better to set them right away on the very first
	stop (whichever it will be). It also will make adding SEIZE support easier,
	since SEIZE has no post-attach SIGSTOP.

	We do it by adding a new bit, TCB_IGNORE_ONE_SIGSTOP, and treating
	TCB_STARTUP and TCB_IGNORE_ONE_SIGSTOP as two slightly different things.

	* defs.h: Add a new flag bit, TCB_IGNORE_ONE_SIGSTOP.
	* process.c (internal_fork): Set TCB_IGNORE_ONE_SIGSTOP on a newly added child.
	* strace.c (startup_attach): Set TCB_IGNORE_ONE_SIGSTOP after attach.
	Fix a case when "strace -p PID" found PID dead but sone other of its threads
	still alive.
	(startup_child): Set TCB_IGNORE_ONE_SIGSTOP after attach, _if needed_.
	This fixes a bogus case where we can ignore a _real_ SIGSTOP on NOMMU.
	(detach): Perform anti-SIGSTOP dance only if TCB_IGNORE_ONE_SIGSTOP is set,
	not if TCB_STARTUP is set.
	(trace): Set TCB_IGNORE_ONE_SIGSTOP after attach.
	Clear TCB_STARTUP and initialize tracee on the very first tracee stop.
	Clear TCB_IGNORE_ONE_SIGSTOP when SIGSTOP is seen.

	Get rid of TCB_ATTACH_DONE.
	* defs.h: Remove TCB_ATTACH_DONE constant.
	* strace.c (startup_attach): Use TCB_STARTUP instead of TCB_ATTACH_DONE
	to distinquish attached from not-yet-attached threads.

	Set TCB_STARTUP only _after_ we attached.
	This fixes logic in detach() which thinks that TCB_STARTUP
	means that we are already attached, but did not see SIGSTOP yet.
	This also allows to get rid of TCB_ATTACH_DONE flag.

	* process.c (internal_fork): Set TCB_STARTUP after attach.
	* strace.c (startup_attach): Likewise.
	(startup_child): Likewise.
	(alloc_tcb): Do not set TCB_STARTUP on tcb allocation - we are
	not attached yet.
	(trace): Set TCB_STARTUP when we detech an auto-attached child.

2011-09-02  Denys Vlasenko  <dvlasenk@redhat.com>

	Simple optimizations in trace()
	* strace.c (trace): Calculate WSTOPSIG(status) once,
	unify code paths to ptrace(PTRACE_SYSCALL).

	Trivial fixes on error paths.
	* strace.c (startup_attach): Emit message on fork() failure.
	(startup_child): Remove non-informative comment.
	* util.c (ptrace_restart): use perror_msg() on error instead of fprintf().

2011-09-01  Denys Vlasenko  <dvlasenk@redhat.com>

	Fix compile failure introduced by last commit.
	* desc.c (decode_select): Fix double definition of nfds.

	Roll back "die on malloc failure" behaviour a bit.
	After recent change, select(2^31-1, NULL, NULL, NULL)
	would make strace exit. This change caps fdsize so that
	it is always in [0, 1025*1024], IOW: we will try to allocate at most
	1 megabyte, which in practice will almost always work,
	unlike malloc(2Gig).

	* desc.c (decode_select): Cap fdsize to 1024*1024.
	* pathtrace.c (pathtrace_match): Cap fdsize to 1024*1024.
	* file.c (sys_getdents): Cap len to 1024*1024.
	(sys_getdents64): Cap len to 1024*1024.
	* util.c (dumpiov): Refuse to process iov with more than 1024*1024
	elements. Don't die on malloc failure.
	(dumpstr): Don't die on malloc failure.

	Add stpcpy to autoconf machinery.
	* configure.ac: Add stpcpy to AC_CHECK_FUNCS.
	* defs.h: Frame stpcpy with "if !defined HAVE_STPCPY".
	* util.c: Likewise.

	Simplify sprinttv()
	* time.c (sprinttv): Trivial simplifications.

	* desc.c (decode_select): Set tcp->auxstr as late as possible.

	Reformat setuid-ing code in startup_child()
	New code does the same as old one, but is more readable (I hope).

	* strace.c (startup_child): Reformat setuid-ing code.

	Minor tweaks in startup_child(). Logic isn't changed (but code is)
	* strace.c (startup_attach): Tweak comment.
	(startup_child): Move common code out of ifdef.
	Indent nested ifdefs. Tweak comments. Remove two
	unnecessary calls to getpid().

	Use tprints with literal strings, it may be faster than tprintf.
	* bjm.c: Replace tprintf("str") with tprints("str").
	* block.c: Likewise.
	* desc.c: Likewise.
	* file.c: Likewise.
	* io.c: Likewise.
	* ipc.c: Likewise.
	* mem.c: Likewise.
	* net.c: Likewise.
	* proc.c: Likewise.
	* process.c: Likewise.
	* quota.c: Likewise.
	* resource.c: Likewise.
	* scsi.c: Likewise.
	* signal.c: Likewise.
	* sock.c: Likewise.
	* strace.c: Likewise.
	* stream.c: Likewise.
	* syscall.c: Likewise.
	* system.c: Likewise.
	* term.c: Likewise.
	* time.c: Likewise.
	* util.c: Likewise.

	Fix "format not a string literal" warning caused by tprintf(str)
	* defs.h: Declare tprints().
	* strace.c: Define tprints().
	(tabto): Use tprints(str), since tprintf(str) was throwing a warning.
	* desc.c: Use tprints(str) instead of tprintf("%s", str).
	* file.c: Likewise.
	* io.c: Likewise.
	* net.c: Likewise.
	* process.c: Likewise.
	* signal.c: Likewise.
	* syscall.c: Likewise.
	* util.c: Likewise.

2011-08-31  Denys Vlasenko  <dvlasenk@redhat.com>

	Add README-linux-ptrace file.
	I tried to push this doc to Michael Kerrisk <mtk.manpages@gmail.com>,
	but got no reply. To avoid losing the document, let it live
	in strace tree for now.

	Make out-of-memory handling more uniform.
	This fixes one real bug in dumpstr().

	* defs.h: Declare die_out_of_memory().
	* strace.c (die_out_of_memory): New function.
	(strace_popen): If allocation fails, call die_out_of_memory().
	(main): Likewise.
	(expand_tcbtab): Likewise.
	(rebuild_pollv): Likewise.
	* count.c (count_syscall): Likewise.
	(call_summary_pers): Likewise.
	* desc.c (decode_select): Likewise.
	* file.c (sys_getdents): Likewise.
	(sys_getdents64): Likewise.
	(sys_getdirentries): Likewise.
	* pathtrace.c (pathtrace_match): Likewise.
	* syscall.c (qualify): Likewise.
	* util.c (printstr): Likewise.
	(dumpiov): Likewise.
	(dumpstr): Likewise.
	(fixvfork): Likewise.
	* mem.c (sys_mincore): Don't check free() parameter for NULL.

	Optimization: eliminate all remaining usages of strcat()
	After this change, we don't use strcat() anywhere.

	* defs.h: Change sprinttv() return type to char *.
	* time.c (sprinttv): Return pointer past last stored char.
	* desc.c (decode_select): Change printing logic in order to eliminate
	usage of strcat() - use stpcpy(), *outptr++ = ch, sprintf() instead.
	Also reduce usage of strlen().
	* stream.c (decode_poll): Likewise.

	Optimize string_quote() for speed.
	* util.c (string_quote): Speed up check for terminating NUL.
	Replace strintf() with open-coded binary to hex/oct conversions -
	we potentially do them for every single byte, need to be fast.

	Optimization: eliminate some usages of strcat()
	* defs.h: Declare stpcpy().
	* util.c: Define stpcpy().
	* file.c: Remove static str_append().
	(sprint_open_modes): Use stpcpy() instead of str_append().
	(sprintflags): Use stpcpy() instead of strcat().
	(printpathn): Eliminate usage of strcat().
	(printstr): Eliminate usage of strcat().

2011-08-30  Denys Vlasenko  <dvlasenk@redhat.com>

	Small optimization on AVR32.
	* syscall.c (syscall_enter): Optimize tcp->u_arg[i] setting
	from regs.FOO for AVR32.

	On X86_64 and I386, use PTRACE_GETREGS to fetch all registers.
	Before this change, registers were read with PTRACE_PEEKUSER
	ptrace operation, one per register. This is slower than
	fetching them all in one ptrace operation.

	* defs.h: include asm/ptrace.h on X86_64 and I386.
	* syscall.c: New static variables i386_regs and x86_64_regs.
	Remove static eax/rax variables.
	(get_scno): Fetch all registers with single PTRACE_GETREGS operation.
	(get_syscall_result): Likewise.
	(syscall_fixup_on_sysenter): Use PTRACE_GETREGS results in i386/x86_64_regs.
	(syscall_enter): Set tcp->u_arg[i] from PTRACE_GETREGS results.
	(get_error): Set tcp->u_rval, tcp->u_error from PTRACE_GETREGS results.

2011-08-30  Dmitry V. Levin  <ldv@altlinux.org>

	Do not include <limits.h>
	* strace.c: Do not include <limits.h> explicitly, it is already included
	implicitly by <sys/param.h>.

	Include <sys/param.h> to get PATH_MAX definition.
	* pathtrace.c: Include <sys/param.h> instead of <limits.h> to get
	PATH_MAX definition.

	Reported-by: Steve Bennett <steveb@workware.net.au>

2011-08-26  Denys Vlasenko  <dvlasenk@redhat.com>

	Indent a large set of nested ifdefs/endifs. No code changes.
	* defs.h: Indent a large set of nested ifdefs/endifs

	Rename syscall_fixup to syscall_fixup_on_sysenter.
	* defs.h: Tweak comment.
	* syscall.c: Rename syscall_fixup to syscall_fixup_on_sysenter.
	(trace_syscall_entering): Use new finction name.

	Make syscall result reading more consistent among different arches.
	* syscall.c: Eliminate static flags variable for POWERPC.
	(syscall_fixup): Don't fetch syscall results. Affected arches:
	POWERPC, BFIN, HPPA.
	(syscall_fixup_on_sysexit): Move syscall results fetching code
	for this function to get_syscall_result. Affected arches:
	S390X, POWERPC, BFIN, M68K, HPPA, CRIS, MICROBLAZE.
	(get_syscall_result): Add syscall results fetching.

2011-08-25  Denys Vlasenko  <dvlasenk@redhat.com>

	Simplify syscall_fixup[_on_sysexit]
	* syscall.c (syscall_fixup): Remove checks for entering(tcp).
	Remove code which executes if exiting(tcp).
	(syscall_fixup_on_sysexit): Remove code which executes
	if entering(tcp). Remove checks for exiting(tcp).

	Split syscall_fixup into enter/exit pair of functions.
	* syscall.c: Create syscall_fixup_on_sysexit() which is a copy of
	syscall_fixup().
	(trace_syscall_exiting): Call syscall_fixup_on_sysexit() instead of
	syscall_fixup().

	Remove stray commas in struct initializers. No code changes.
	* process.c: Remove stray commas in struct initializers.

2011-08-24  Denys Vlasenko  <dvlasenk@redhat.com>

	Optimize tabto()
	tabto is used in many lines of strace output.
	On glibc, tprintf("%*s", col - curcol, "") is noticeably slow
	compared to tprintf("                 "). Use the latter.
	Observed ~15% reduction of time spent in userspace.

	* defs.h: Drop extern declaration of acolumn. Make tabto()
	take no parameters.
	* process.c (sys_exit): Call tabto() with no parameters.
	* syscall.c (trace_syscall_exiting): Call tabto() with no parameters.
	* strace.c: Make acolumn static, add static char *acolumn_spaces.
	(main): Allocate acolumn_spaces as a string of spaces.
	(printleader): Call tabto() with no parameters.
	(tabto): Use simpler method to print lots of spaces.

	* syscall.c (sys_indir): Use %ld for printing long, not %u.

	Opotimize "scno >= 0 && scno < nsyscalls" check.
	gcc can't figure out on its own that this check can be done with
	single compare, and does two compares. We can help it by casting
	scno to unsigned long: ((unsigned long)(scno) < nsyscalls)

	* defs.h: New macro SCNO_IN_RANGE(long_var).
	* count.c (count_syscall): Use SCNO_IN_RANGE() instead of open-coded check.
	* syscall.c (getrval2): Use SCNO_IN_RANGE() instead of open-coded check.
	This fixes a bug: missing check for scno < 0 and scno > nsyscalls
	instead of scno >= nsyscalls.
	(get_scno): Use SCNO_IN_RANGE() instead of open-coded check.
	This fixes a bug: scno > nsyscalls instead of scno >= nsyscalls.
	(known_scno): Use SCNO_IN_RANGE() instead of open-coded check.
	(internal_syscall): Likewise.
	(syscall_enter): Likewise.
	(trace_syscall_entering): Likewise.
	(get_error): Likewise.
	(trace_syscall_exiting): Likewise.

	Remove scno_good logic in syscall exit.
	* syscall.c (trace_syscall_exiting): Remove scno_good logic,
	it can't trigger in syscall exit.

	Remove redundant assignments.
	* syscall.c (get_error): Remove redundant "u_error = 0" and redundant
	and unclear comments.

	Group int-sized fields together in struct tcb.
	* defs.h: Group int-sized fields together in struct tcb.

	Reorder functions in syscall.c. No code changes.
	Old order (basically "in no particular order"):
	    dumpio
	    decode_subcall
	    internal_syscall
	    get_scno
	    get_syscall_result
	    known_scno
	    syscall_fixup
	    is_negated_errno
	    get_error
	    syscall_enter
	    trace_syscall_entering
	    trace_syscall_exiting
	    trace_syscall
	    printargs
	    getrval2
	    sys_indir
	    is_restart_error

	New order:
	various utility functions:
	    decode_subcall
	    printargs
	    getrval2
	    sys_indir
	    is_restart_error
	syscall enter handling functions:
	    get_scno
	    known_scno
	    syscall_fixup (also used in syscall exit code)
	    internal_syscall (also used in syscall exit code)
	    syscall_enter
	    trace_syscall_entering
	syscall exit handling functions:
	    get_syscall_result
	    is_negated_errno
	    get_error
	    dumpio
	    trace_syscall_exiting
	main syscall enter/exit function:
	    trace_syscall

	* syscall.c: Reorder functions so that related ones are closer
	in the source.

	Rename some functions, delete unused one. No code changes.
	* defs.h: Rename get_scno_on_sysenter() to get_scno();
	delete force_result() declaration.
	* strace.c (proc_open): Rename get_scno_on_sysenter() to get_scno().
	* syscall.c: Rename get_scno_on_sysenter() to get_scno().
	Rename get_scno_on_sysexit() to get_syscall_result().
	Delete unused force_result().

	Unify per-architecture post-execve SIGTRAP check.
	Move post-execve SIGTRAP check from get_scno_on_sysenter
	(multitude of places on many architectures) to a single location
	in trace_syscall_entering. This loosens the logic for some arches,
	since many of them had additional checks such as scno == 0.
	However, on non-ancient Linux kernels we should never have post-execve
	SIGTRAP in the first place, by virtue of using PTRACE_O_TRACEEXEC.

	* syscall.c (get_scno_on_sysenter): Remove tcp->flags & TCB_WAITEXECVE checks.
	(trace_syscall_entering): Do tcp->flags & TCB_WAITEXECVE check here.
	(get_scno_on_sysexit): Tweak comment.
	(syscall_fixup): Likewise.
	(trace_syscall_exiting): Likewise.

	Speed up x86 by avoiding EAX read on syscall entry.
	on x86, EAX read on syscall entry is not necessary if we know
	that post-execve SIGTRAP is disabled by PTRACE_O_TRACEEXEC ptrace option.
	This patch (a) moves EAX retrieval from syscall_fixup
	to get_scno_on_sysexit, and (b) perform EAX retrieval in syscall_fixup
	only if we are in syscall entry and PTRACE_O_TRACEEXEC option is not on.

	* syscall.c (get_scno_on_sysexit): On I386 and X86_64, read eax/rax
	which contain syscall return value.
	(syscall_fixup): On I386 and X86_64, read eax/rax only on syscall enter
	and only if PTRACE_O_TRACEEXEC is not in effect.

	Do not read syscall no in get_scno_on_sysexit.
	* syscall.c (get_scno_on_sysexit): Remove scno retrieval code, since
	we don't save it anyway. This is the first real logic change
	which should make strace faster: for example, on x64 ORIG_EAX
	is no longer read in each syscall exit.

	Simplify get_scno_on_sysenter/sysexit.
	* syscall.c (get_scno_on_sysenter): Remove "if (exiting(tcp))" code,
	make "if (entering(tcp))" code unconditional.
	(get_scno_on_sysexit): Remove "if (entering(tcp))" code,
	make "if (exiting(tcp))" code unconditional.

	get_scno is an unholy mess, make it less horrible.
	Currently, get_scno does *much* more than "get syscall no".
	It checks for post-execve SIGTRAP. It checks for changes
	in personality. It retrieves params on entry and registers on exit.
	Worse still, it is different in different architectures: for example,
	for AVR32 regs are fetched in get_scno(), while for e.g. I386
	it is done in syscall_enter().

	Another problem is that get_scno() is called on both syscall entry and
	syscall exit, which is stupid: we don't need to know scno on syscall
	exit, it is already known from last syscall entry and stored in
	tcp->scno! In essence, get_scno() does two completely different things
	on syscall entry and on exit, they are just mixed into one bottle, like
	shampoo and conditioner.

	The following patches will try to improve this situation.

	This change duplicates get_scno into identical get_scno_on_sysenter,
	get_scno_on_sysexit functions. Call them in syscall enter and syscall
	exit, correspondingly.

	* defs.h: Rename get_scno to get_scno_on_sysenter; declare it only
	if USE_PROCFS.
	* strace.c (proc_open): Call get_scno_on_sysenter instead of get_scno.
	* syscall.c (get_scno): Split into two (so far identical) functions
	get_scno_on_sysenter and get_scno_on_sysexit.
	(trace_syscall_entering): Call get_scno_on_sysenter instead of get_scno.
	(trace_syscall_exiting): Call get_scno_on_sysexit instead of get_scno.

2011-08-23  Dmitry V. Levin  <ldv@altlinux.org>

	Reduce code redundancy in syscall_enter()
	* syscall.c [LINUX] (syscall_enter): Move tcp->u_nargs initialization
	from arch-specific ifdefs to common code.  Always cache tcp->u_nargs in
	a local variable and use it in for() loops.
	[IA64, AVR32] Rewrite tcp->u_arg[] initialization using a loop.

2011-08-23  Denys Vlasenko  <dvlasenk@redhat.com>

	Define MAX_ARGS to 6 for all Linux arches.
	* defs.h: Define MAX_ARGS to 6 for all Linux arches.
	* linux/ia64/syscallent.h: Change all 8-argument printargs
	to MA (MAX_ARGS).
	linux/mips/syscallent.h: Change all two 7-argument printargs
	to MA (MAX_ARGS).

	Fix argument printing in sys_mmap64.
	* mem.c (sys_mmap64): Fix a bug where we used tcp->u_args[i]
	instead of argument values copied from memory.

	Cache tcp->u_nargs in a local variable for for() loops.
	Loops of the form "for (i = 0; i < tcp->u_nargs; i++) ..."
	need to fetch tcp->u_nargs from memory on every iteration
	if "..." part has a function call (gcc doesn't know that
	tcp->u_nargs won't change). This can be sped up
	by putting tcp->u_nargs in a local variable, which might
	go into a CPU register.

	* syscall.c (decode_subcall): Cache tcp->u_nargs in a local variable
	as for() loop limit value.
	(syscall_enter): Likewise.

	Drop checks for sysent[i].nargs == -1.
	* defs.h: Declare nsyscalls, nerrnos, nioctlents, nsignals as unsigned.
	* syscall.c: Define nsyscalls, nerrnos, nioctlents, nsignals as unsigned.
	(decode_subcall): Drop checks for sysent[i].nargs == -1.
	(syscall_enter): Likewise.

	Stop using nargs == -1 in syscallent tables.
	Usage -1 as argument count in syscallent tables
	necessitates the check for it, a-la:
	if (sysent[tcp->scno].nargs != -1)
	    tcp->u_nargs = sysent[tcp->scno].nargs;
	else
	    tcp->u_nargs = MAX_ARGS;
	which is stupid: we waste cycles checking something which
	is constant and known at compile time.

	* defs.h: Make struct sysent::nargs unsigned.
	* freebsd/i386/syscallent.h: Replace nargs of -1 with MA.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* svr4/syscallent.h: Likewise.
	* freebsd/syscalls.pl: Likewise in generator script.
	* syscallent.sh: Likewise in generator script.
	* syscall.c: Add define MA MAX_ARGS / undef MA around includes
	of syscallent[N].h.

	Move trace_syscall_exiting below trace_syscall_entering. No code changes.
	Syscall enter happens before syscall exit. Having functions
	in opposite order in the source is confusing.

	* syscall.c: Move trace_syscall_exiting below trace_syscall_entering.

	Fix -z display.
	Before this patch, the following:
	    open("qwerty", O_RDONLY)    = -1 ENOENT
	    write(2, "wc: qwerty: No such file or dire"..., 38) = 38
	was shown totally wrongly with -z:
	    open("qwerty", O_RDONLY)    = 38
	(yes, that's right, write syscall is lost!)
	Now it is shown "less wrongly" as:
	    open("qwerty", O_RDONLY <unfinished ...>
	    write(2, "wc: qwerty: No such file or dire"..., 38) = 38

	* syscall.c (trace_syscall_exiting): Use common TCB_INSYSCALL clearing
	via "goto ret". This fixes totally broken display of -z, but even now
	it is not working as intended. Add a comment about that.
	(trace_syscall_entering): Use common TCB_INSYSCALL setting
	via "goto ret".

	Straighten up confused comments/messages about post-execve SIGTRAP handling
	* defs.h: Explain TCB_INSYSCALL and TCB_WAITEXECVE bits in detail.
	* strace.c (choose_pfd): Use entering/exiting macros instead of direct check
	for TCB_INSYSCALL.
	* syscall.c (get_scno): Use entering/exiting macros instead of direct check
	for TCB_INSYSCALL. Fix comments about post-execve SIGTRAP.
	(syscall_fixup): Use entering/exiting instead of direct check
	for TCB_INSYSCALL. Add a comment what "not a syscall entry" message
	usually means. Change wrong "stray syscall exit" messages into
	"not a syscall entry" ones.

	count_syscall() always returns 0, optimize it.
	* defs.h (count_syscall): Change return type from int to void.
	* count.c (count_syscall): Change return type from int to void.
	* syscall.c (trace_syscall_exiting): Change code around call
	to count_syscall accordingly.

	Optimize out dummy PC printing on signal delivery.
	* strace.c (trace): Optimize out dummy PC printing on signal delivery.
	While at it, tweak comments.

	Conditionally optimize out unused code.
	* syscall.c (internal_syscall): Call internal_exec only if
	SUNOS4 || (LINUX && TCB_WAITEXECVE).
	* process.c (internal_exec): Define this function only if
	SUNOS4 || (LINUX && TCB_WAITEXECVE).
	(printwaitn): Don't check wordsize if SUPPORTED_PERSONALITIES == 1.
	* signal.c (sys_kill): Likewise.
	* syscall.c (is_negated_errno): Likewise.
	(trace_syscall_exiting): Fold a tprintf into tprintfs which follow it.

	Cosmetic improvement in ifdefs. No code changes.
	* strace.c (proc_open): Change ifdefs so that braces are properly paired.

	Exclude tcp->pfd from non-procfs systems.
	* defs.h: Make struct tcb::pfd fields conditional on USE_PROCFS.
	* strace.c (alloc_tcb): Use tcp->pfd only if USE_PROCFS.
	(droptcb): Likewise.

	Small optimizations related to memory allocation.
	* strace (expand_tcbtab): Shorten "out of memory" message.
	(rebuild_pollv): Remove unnecessary NULL check before free().
	* util.c (dumpstr): Add a comment about likely bug.

	Improve code readability by avoiding assignments inside if()
	* desc.c (decode_select): Move assignment out of if() condition.
	* file.c (sprinttime): Likewise.
	(sys_getdirentries): Likewise.
	* io.c (sys_ioctl): Likewise.
	* strace.c (test_ptrace_setoptions_followfork): Likewise.
	(main): Likewise.
	(proc_open): Likewise.
	(detach): Likewise.
	(proc_poll): Likewise.
	(trace): Likewise.
	* syscall.c (qualify): Likewise.
	(sys_indir): Likewise.
	* test/procpollable.c (main): Likewise.
	* test/sfd.c (main): Likewise.
	* time.c (printtv_bitness): Likewise.
	(sprinttv): Likewise.
	(print_timespec): Likewise.
	(void sprint_timespec): Likewise.
	(printitv_bitness): Likewise.
	* util.c (dumpstr): Likewise.
	(umovestr): Likewise.
	(fixvfork): Likewise.

	Convert ioctl_next_match() to new-style C function definition.
	* ioctl.c (ioctl_next_match): Convert to new-style C function definition.

	Small optimization in signal and ioctl tables.
	Trivial shuffling of data tables puts them all in one file,
	allowing gcc to see their sizes and eliminate variables
	which store these sizes.

	Surprisingly, in C mode gcc does not optimize out static const int
	variables. Help it by using enums instead.

	* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
	signalent{0,1,2}, nsignals{0,1,2}.
	* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
	* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
	* syscall.c: Move above definitions to this file. Make them static const
	or enums if suitable.

	Don't return int from set_personality(), no one checks it.
	* defs.h (set_personality): Change return type to void.
	* syscall.c (set_personality): Change return type to void.

	Remove unused declaration.
	* defs.h: Remove unused declaration of handle_new_child().

	Use natural-sized integer field for tcb::flags.
	* defs: Change struct tcb::flags type from short to int.
	This results in smaller code at least on x86.

	Make needlessly static data local.
	* syscall.c (get_scno): For POWERPC64 and X86-64, variable currpers
	is declared static. But its old data is never used. Convert it
	to ordinary local variable.

	Optimize get_scno function.
	* syscall.c (get_scno): Make gpr_offset[] array static const.

	Optimize iocb_cmd_lookup.
	* desc.c (iocb_cmd_lookup): Make command table constant.
	Reduce size of static char buffer.

	Correct sys_sendfile[64] type and nargs.
	* freebsd/i386/syscallent.h: Correct sys_sendfile nargs 7->8
	* linux/mips/syscallent.h: Correct sys_sendfile64 nargs 5->4
	* linux/sh/syscallent.h: Correct sys_sendfile64 nargs 5->4
	* linux/sh64/syscallent.h: Correct sys_sendfile64 nargs 5->4
	* linux/m68k/syscallent.h: Correct sys_sendfile64 type TF->TD|TN
	* linux/microblaze/syscallent.h: Correct sys_sendfile64 type TF->TD|TN
	* linux/tile/syscallent.h: Correct sys_sendfile and sys_sendfile64 type TD->TD|TN

	Make addflags return void.
	* defs.h (addflags): Change return type from int to void.
	* util.c (addflags): Change return type from int to void.

	Set saner MAX_ARGS (6 or 8) for X86_64 and I386.
	I noticed that tcp->u_args[MAX_ARGS] array is way larger than
	I'd expect: for all arches except HPPA it has 32 (!) elements.

	I looked at the code and so far I spotted only one abuser of
	this fact: sys_sigreturn. On several arches, it saves sigset_t
	into tcp->u_args[1...N] on entry and prints it on exit, a-la

	memcpy(&tcp->u_arg[1], &sc.oldmask[0], sizeof(sigset_t))

	The problem here is that in glibc sigset_t is insanely large:
	128 bytes, and using sizeof(sigset_t) in memcpy will overrun
	&tcp->u_args[1] even with MAX_ARGS == 32:
	On 32 bits, sizeof(tcp->u_args) == 32*4 == 128 bytes!
	We may already have a bug there!

	This commit changes the code to save NSIG / 8 bytes only.
	NSIG can't ever be > 256, and in practice is <= 129,
	thus NSIG / 8 is <= 16 bytes == 4 32-bit words,
	and even MAX_ARGS == 5 should be enough for saving signal masks.

	* defs.h: Reduce MAX_ARGS for X86_64 and I386 from 32 to 8
	for FreeBSD and to 6 for everyone else. Add comment about current
	state of needed MAX_ARGS.
	* signal.c: Add comment about size of sigset_t.
	(sprintsigmask): Reduce static string buffer from 8k to 2k.
	(sys_sigreturn): Fix sigset saving to save only NSIG / 8 bytes,
	not sizeof(sigset_t) bytes.
	* linux/mips/syscallent.h: Reduce nargs of printargs-type syscall to 7.
	* linux/arm/syscallent.h: Reduce nargs of printargs-type syscall to 6.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.

	Optimize sys_old_mmap.
	* mem.c (sys_old_mmap): For Ia64 and 32-bit personality of x86-64,
	copy narrow parameters from userspace by single umove, not by six
	separate ones; then assign them to long u_arg[i]. For SH[64],
	avoid copying of tcp->u_arg.
	(sys_mmap): Add FIXME comment - SH64 and i386 seem to be handled
	differently for no apparent reason.
	* test/mmap_offset_decode.c: New test program, illustrates FIXME.

	Untangle ifdef forest in sys_mmap64. No code changes.
	After careful analysis, it looks like !LINUX and ALPHA
	pass all seven parameters in registers; and in all other cases
	parameters are on stack (pointed to by tcp->u_arg[0]).
	In light of this, reorganize ifdefs, making them simpler,
	without changing any logic.
	After this, it's apparent we use tcp->u_arg[4,5,6] and possibly
	[7] without checking that it's valid to do so.
	So far, just add a comment about this.

	* mem.c (sys_mmap64): Rewrite ifdefs in a much simpler way.
	Add comments about apparent bugs.

	Style and comment fixes, no code changes.
	* mem.c: Indent includes to show nesting better.
	  (addtileflags): Fix style of this function definition;
	  correct wrong endif comment, add another endif comment.

	Use simpler rounding up to next multiple of 2.
	* util.c (printllval): simpler rounding up to next multiple of 2.

	Cosmetic fixes, no code changes.
	* defs.h: Add/reformat comments.
	* signal.c: Remove wrong comment. Add warning directive
	when we detect that NSIG is undefined. Add comment about
	NSIG on ARM. Fix typo in comment.
	(signame): Reformat code a bit without changes to logic.
	Shorten static buffer.
	(sys_rt_sigprocmask): Remove stray empty line.
	* syscall.c: Add warning directive when we detect that
	NSIG is undefined. Add comment about NSIG on ARM.

2011-08-23  Dmitry V. Levin  <ldv@altlinux.org>

	Fix PTRACE_SETOPTIONS tests.
	* strace.c [LINUX] (kill_save_errno): New function.
	(test_ptrace_setoptions_followfork): Change return type to void.
	Fix and harden error handling.  Use kill_save_errno() to avoid errno
	clobbering.  Treat EIO from ptrace() the same way as EINVAL.
	(test_ptrace_setoptions_for_all): Use kill_save_errno() to avoid errno
	clobbering.  Treat EIO from ptrace() the same way as EINVAL.
	(main): Update use of test_ptrace_setoptions_followfork().

	Fix compilation on linux 2.4.x.
	* configure.ac: Check for BLKGETSIZE64.
	* block.c (block_ioctl): Check for HAVE_BLKGETSIZE64.

2011-08-17  Denys Vlasenko  <dvlasenk@redhat.com>

	Remove tcp->parent and TCB_CLONE_THREAD.
	tcp->parent is used for only two things:
	(1) to send signal on detach via tgkill (need to know tgid).
	Solution: use tkill, it needs only tid.
	(2) to optimize out ptrace options setting for new tracees.
	Not a big deal if we drop this optimization: "set options" op is fast,
	doing it just one extra time once per each tracee is hardly measurable.

	TCB_CLONE_THREAD is a misnomer. It used only to flag sibling we attached to
	in startup_attach. This is used to prevent infinite recursive rescanning
	of /proc/PID/task.
	Despite the name, there is no guarantee it is set only on non-leader:
	if one would run "strace -f -p THREAD_ID" and THREAD_ID is *not*
	a thread leader, strace will happily attach to it and all siblings
	and will think that THREAD_ID is the leader! Which is a bug, but
	since we no longer detach when we think tracee is going to die,
	this bug no longer matters, because we do not use the knowledge
	about thread group leaders for anything. (We used it to delay
	leader's exit).

	IOW: after this patch strace has no need to know about threads, parents
	and children, and so on. Therefore it does not track that information.
	It treats all tracees as independent entities. Overall,
	this simplifies code a lot.

	* defs.h: Add TCB_ATTACH_DONE flag, remove TCB_CLONE_THREAD flag
	and struct tcb::parent field.
	* process.c (internal_fork): Don't set tcpchild->parent.
	* strace.c (startup_attach): Use TCB_ATTACH_DONE flag instead of
	TCB_CLONE_THREAD to avoid attach attempts on already-attached threads.
	Unlike TCB_CLONE_THREAD, TCB_ATTACH_DONE bit is used only temporarily,
	and only in this function. We clear it on every tcb before we return.
	(detach): Use tkill instead of tgkill.
	(trace): Set ptrace options on new tracees unconditionally,
	not only when tcp->parent == NULL.

	Remove TCB_SUSPENDED constant and related code.
	Since we no longer suspend waitpid'ing tracees, we have only one case when
	we suspend tracee: when we pick up a new tracee created by clone/fork/vfork.

	Background: on some other OSes, attach to child is done this way:
	get fork's result (pid), loop ptrace(PTRACE_ATTACH) until you hook up
	new process/thread. This is ugly and not safe, but what matters for us
	is that it doesn't require suspending. Suspending is required
	on Linux only, because on Linux attach to child is done differently.

	On Linux, we use two methods of catching new tracee:
	adding CLONE_THREAD bit to syscall (if needed, we change
	[v]fork into clone before that), or using ptrace options.
	In both cases, it may be so that new tracee appears before one which
	created it returns from syscall. In this case, current code
	suspends new tracee until its creator returns. Only then
	strace can determine who is its parent (it needs child's pid for this,
	which is visible in parent's [v]fork/clone result).
	This is inherently racy. For example, what if SIGKILL kills
	creator after it succeeded creating child, but before it returns?
	Looks like we will have child suspended forever.

	But after previous commit, we DO NOT NEED parent<->child link for anything.
	Therefore we do not need suspending too. Bingo!

	This patch removes suspending code. Now new tracees will be continued
	right away. Next patch will remove tcp->parent member.

	* defs.h: Remove TCB_SUSPENDED constant
	* process.c (handle_new_child): Delete this function.
	  (internal_fork): Do not call handle_new_child on syscall exit.
	* strace.c (handle_ptrace_event): Delete this function.
	  (trace): Do not suspend new child; remove all handling
	  of now impossible TCB_SUSPENDED condition.

	Do not detach when we think tracee is going to die.
	Current code plays some ungodly tricks, trying to not detach
	thread group leader until all threads exit.

	Also, it detaches from a tracee when signal delivery is detected
	which will cause tracee to exit.
	This operation is racy (not to mention the determination
	whether signal is set to SIG_DFL is a horrible hack):
	after we determined that this signal is indeed fatal
	but before we detach and let process die,
	*other thread* may set a handler to this signal, and
	we will leak the process, falsely displaying it as killed!

	I need to look in the past to figure out why we even do it.
	First guess is that it's a workaround for old kernel bugs:
	kernel used to deliver exit notifications to the tracer,
	not to real parent. These workarounds are ancient
	(internal_exit is from 1995).

	The patch deletes the hacks. We no longer need tcp->nclone_threads,
	TCB_EXITING and TCB_GROUP_EXITING. We also lose a few rather
	ugly functions.

	I also added a new message: "+++ exited with EXITCODE +++"
	which shows exact moment strace got exit notification.
	It is analogous to existing "+++ killed by SIG +++" message.

	* defs.h: Delete struct tcb::nclone_threads field,
	  TCB_EXITING and TCB_GROUP_EXITING constants,
	  declarations of sigishandled() and internal_exit().
	* process.c (internal_exit): Delete this function.
	  (handle_new_child): Don't ++tcp->nclone_threads.
	* signal.c (parse_sigset_t): Delete this function.
	  (sigishandled): Delete this function.
	* strace.c (startup_attach): Don't tcbtab[tcbi]->nclone_threads++.
	  (droptcb): Don't delay dropping if tcp->nclone_threads > 0,
	  don't drop parent if its nclone_threads reached 0:
	  just drop (only) this tcb unconditionally.
	  (detach): don't drop parent.
	  (handle_group_exit): Delete this function.
	  (handle_ptrace_event): Instead of handle_group_exit, just drop tcb;
	  do not panic if we see WIFEXITED from an attached pid;
	  print "+++ exited with EXITCODE +++" for every WIFEXITED pid.
	* syscall.c (internal_syscall):	Do not treat sys_exit specially -
	  don't call internal_exit on it.

2011-08-16  Sergei Trofimovich  <slyfox@gentoo.org>

	Declare printrusage32() on Alpha.
	* defs.h [ALPHA] (printrusage32): New declaration.

2011-08-15  Denys Vlasenko  <dvlasenk@redhat.com>

	Slight optimization and cleanup in trace()
	* strace.c (trace): Do not recalculate "cflag ? &ru : NULL"
	again and again. Do not clear errno unnecessarily.
	Consistently check wait errors as pid < 0, not pid == -1.
	Indent ifdefs for better readability.
	Remove comments after endif if ifdef/endif block is really tiny.

	Fix compilation on 2.4.20 kernel based system.
	* block.c (block_ioctl): add ifdef/endif around BLKGETSIZE64 usage
	* strace.c (trace): add ifdef/endif around WIFCONTINUED usage

2011-07-19  Dmitry V. Levin  <ldv@altlinux.org>

	Check for additional PTRACE_* constants.
	* configure.ac (AC_CHECK_DECLS): Add PTRACE_O_TRACESYSGOOD,
	PTRACE_O_TRACEEXEC, PTRACE_O_TRACEEXIT, PTRACE_EVENT_EXEC,
	PTRACE_EVENT_VFORK_DONE and PTRACE_EVENT_EXIT.
	* defs.h [LINUX]: Define these PTRACE_* constants when they are not
	provided by <sys/ptrace.h>.

	Reported-by: Douglas Mencken <dougmencken@gmail.com>
	Reported-by: Steve Bennett <steveb@workware.net.au>

2011-07-19  Denys Vlasenko  <dvlasenk@redhat.com>

	Remove superfluous backslash-continuation in configure.ac.
	* configure.ac: remove superfluous backslash continuation
	in AC_CHECK_DECLS

2011-06-24  Denys Vlasenko  <dvlasenk@redhat.com>

	Make IOCTL_WSTOP more readable.
	* defs.h: Make IOCTL_WSTOP more readable

	Trivial cleanups.
	* strace.c (trace): Change ifdef LINUX to make a bit more sense,
	  remove wrong comment at its endif. Slightly optimize
	  "+++ killed by SIG +++" message for systems without WCOREDUMP macro.

	Remove redundant include <stdarg.h>
	* strace.c: Remove redundant include <stdarg.h>

	Clean up two old comments.
	* strace.c (startup_attach): Remove misplaced comment.
	  (trace) Remove incomplete part of a comment.

	Make a few variables static.
	* defs.h: Remove tcbtab declaration.
	* strace.c: Make run_uid, run_gid, outf, tcbtab, progname
	  global variables static

	Add debug output in initial attachment code.
	* strace.c (startup_attach): If -d, report pid and success/failure
	  of every attach attempt.

	Better debug logging of allocations and waitpit results.
	* strace.c (alloc_tcb): Print number of allocated tcb's if -d.
	  (droptcb): Likewise.
	  (handle_ptrace_event): Remove PTRACE_EVENT_EXEC debug message.
	  (trace): Improve logging of waitpid: show WIFxxx, exitcode/signal,
	  ptrace event name, WCOREDUMP - all on one line.

2011-06-23  Denys Vlasenko  <dvlasenk@redhat.com>

	Optimize arrays of register indexes in syscall_enter.
	* syscall.c (syscall_enter) [BFIN]: Make register no array "static const".
	  [SH]: Make register no array "const", pre-multiply it by 4.
	  [SH64]: Make register no array "const".
	  [X86_64]: Make register no array "const", pre-multiply it by 8.

	Deindent syscall_enter by removing unnecessary braces. No code changes.
	syscall_enter has many long (>80 columns) lines.
	It is aggravated by the fact that it has a lot of {} blocks
	which are not necessary (the code is the same without them).
	This patch removes {}s and deindents affected lines.
	While at it, it indents ifdefs so that nesting is easier to track,
	and adds a few spaces in the expressions, such as
	"tcp->u_nargs*sizeof..." -> "tcp->u_nargs * sizeof...".
	There is no actual changes to the code here.

	* syscall.c (syscall_enter): Remove unnecessary {} blocks.

	Remove dead "ifndef CLONE_PTRACE" branch.
	process.c defines CLONE_PTRACE for Linux, so it can't be undefined.
	Therefore ifndef CLONE_PTRACE code is dead (since at least 2004).
	This patch removes it.

	* process.c (handle_new_child): Remove ifdef CLONE_PTRACE/endif (but not
	  the code inside) and entire ifndef CLONE_PTRACE/endif block.

	Add a comment about setbpt. No code changes.
	* defs.h: Add a comment about setbpt().

	Untangle a particularly badly obfuscated bit of code. No logic changes.
	* util.c (setbpt): Calculate new arg0 in more readable way.

	Remove TCB_FOLLOWFORK.
	TCB_FOLLOWFORK flag seems to be unnecessary, because we either follow
	all [v]forks/clones or don't follow any, therefore global variable
	followfork is an already existing indicator of what we want to do.
	This patch drops all setting/clearing of TCB_FOLLOWFORK bit,
	and replaces checks for this bit by checks of followfork value.
	In internal_fork, check is moved to in front of if(), since
	the check is needed on both "entering" and "exiting" branch.

	* defs.h: Remove TCB_FOLLOWFORK define.
	* process.c (internal_fork): Do not set/clear TCB_FOLLOWFORK,
	  test followfork instead of tcp->flags & TCB_FOLLOWFORK.
	  (handle_new_child): Likewise.
	* strace.c (startup_attach): Likewise.

2011-06-23  Dmitry V. Levin  <ldv@altlinux.org>

	* system.c (sys_capget, sys_capset): Fix pointer arithmetics.

2011-06-23  Denys Vlasenko  <dvlasenk@redhat.com>

	Make initial tcb allocation more readable. No logic changes.
	* strace.c (main): Make initial tcb allocation more readable.

	Do not allocate tiny cap_user_header/data structures, place them on stack.
	This allows us to avoid having code to malloc them, and code to check
	for malloc failure. Resulting code decrease:
	   text	   data	    bss	    dec	    hex	filename
	  10175	      0	     16	  10191	   27cf	system.o.old
	   9797	      0	      0	   9797	   2645	system.o

	* system.c (sys_capget): Put cap_user_header_t and cap_user_data_t
	  on stack, rather than allocating them in heap. These structures
	  are very small (a few integer fields), stack is a better place
	  for them.
	  (sys_capset): Likewise.

	Use [p]error_msg[_and_die] where appropriate. No logic changes.
	Resulting size changes:
	   text    data     bss     dec     hex filename
	  17445      16    8572   26033    65b1 strace.o.old
	  16850      16    8572   25438    635e strace.o

	* strace.c: Replace fprintf[+cleanup]+exit with [p]error_msg_and_die,
	  fprintf("progname: ...") with [p]error_msg where appropriate.

2011-06-22  Denys Vlasenko  <dvlasenk@redhat.com>

	Whitespace cleanups. No code changes.
	* count.c: Place opening curly brace after if (),
	  not on the next line. Almost all strace code alredy
	  uses this style.
	* desc.c: Likewise.
	* file.c: Likewise.
	* net.c: Likewise.
	* pathtrace.c: Likewise.
	* process.c: Likewise.
	* quota.c: Likewise.
	* signal.c: Likewise.
	* strace.c: Likewise.
	* syscall.c: Likewise.
	* time.c: Likewise.

	Make strace_fopen abort on error.
	Error from strace_fopen in main results in call to exit(1).
	Error from strace_fopen in newoutf is propagated to newoutf
	callers: startup_attach (where it results in exit(1))
	and alloc_tcb (where error is ignored). In second case,
	the behavior doesn't seem to be right: it means with -ff
	on open error for new LOGFILE.PID the output will continue
	to go into *the same file as the previous process* - which
	would be confusing. Moreover, on droptcb outf may be closed
	and the output of other, still running process outputting
	to the same outf will be lost. I don't think this is sane.
	IOW: in all cases, error in strace_fopen should be fatal.

	* strace.c (strace_fopen): Abort on error instead of returning NULL.
	  (newoutf): Change return type to void.
	  (startup_attach): Remove error check on newoutf return value.
	  (main): Remove error check on strace_fopen return value.

	Make set_cloexec_flag abort on error.
	set_cloexec_flag() may fail only if we pass it a bad fd,
	such as -1 or non-opened one. If we do, we have a bug
	in the caller. It makes no sense to try to continue
	running when we detect such a blatant bug in our own code.

	* strace (set_cloexec_flag): Abort instead of returning error
	  indicator. Change function to return void.
	  (strace_fopen): Remove error check on set_cloexec_flag return value.
	  (proc_open): Likewise.
	  (proc_poll_open): Likewise.

	Make strace_popen abort on error.
	It makes no sense to postpone abort on strace_popen error
	unti it returns. Moreover, out-of-memory error was exiting
	without any message.
	While at it, use 0 as "none" for popen_pid, as optimization.

	* strace: Initialize popen_pid to 0 - this puts it in bss.
	  (trace): Reset popen_pid to 0 instead of -1.
	  (strace_popen): Never return NULL as error indicator,
	  abort with good error message instead.
	  (main): Remove NULL check of strace_popen result.

	Delete fork_tcb()
	Get rid of fork_tcb() function. It used to do what the comment
	above it says, but now it doesn't do much:
	it only sets tcp->flags |= TCB_FOLLOWFORK and maybe calls
	expand_tcbtab(). The second operation is not necessary, since
	alloc_tcp() will do it itself when needed.
	This patch deletes fork_tcb(), open-coding tcp->flags |= TCB_FOLLOWFORK
	where it was formerly called. It also makes nprocs, tcbtabsize and
	expand_tcbtab() static. (While at it, I nuked redundant
	extern char **environ declaration: strace.c had *two* of them...)

	* defs.h: Remove declarations of nprocs, tcbtabsize and
	  expand_tcbtab.
	* process.c (fork_tcb): Remove this function.
	  (internal_fork): Open-code fork_tcb.
	  (handle_new_child): Likewise.
	* strace.c: Remove redundant "extern char **environ". Declare
	  nprocs and tcbtabsize static.
	  (expand_tcbtab): Make it static.

	Simplify expand_tcbtab and alloc_tcb.
	Get rid of a few intermediate variables, simplifies a few expressions,
	and uses error_msg_and_die instead of more verbose
	fprintf+cleanup+exit sequence.
	In alloc_tcp, I use memset to clear entire new tcp.
	This not only saves a few bytes of code, but lowers the chances
	of future bugs where some data "leaks out" into new tcb's
	from old ones because we forgot to re-initialize it.

	* strace.c (expand_tcbtab): Simplify this function. No logic changes.
	  (alloc_tcb): Likewise.

2011-06-21  Denys Vlasenko  <dvlasenk@redhat.com>

	Trivial fixes.
	* process.c (internal_fork): Remove conditionals which make no difference
	  (we return 0 on both branches of these ifs).
	* util.c: Fix indentation of an ifdef.

2011-06-21  Dmitry V. Levin  <ldv@altlinux.org>

	Fix build when libaio-devel is not available.
	* desc.c: Do not compile code that uses struct iocb unless
	HAVE_LIBAIO_H is set.

	Reported-by: Denys Vlasenko <dvlasenk@redhat.com>

	tests: finish ptrace_setoptions_* merge.
	* tests/Makefile.am (TESTS): Merge ptrace_setoptions_*.
	* tests/ptrace_setoptions: Check for Linux kernel > 2.6.

2011-06-21  Denys Vlasenko  <dvlasenk@redhat.com>

	Remove write-only nchildren member from struct tcb.
	* defs.h: Remove nchildren member from struct tcb.
	* process.c (handle_new_child): Remove inc/decrements of tcp->nchildren.
	  (internal_fork): Likewise.
	* strace.c (startup_attach): Likewise.
	  (droptcb): Likewise.
	  (alloc_tcb): Remove initialization of tcp->nchildren.

	Fix tests/ptrace_setoptions_* to match last fix in ptrace options code.

	Remove write-only nzombies member from struct tcb.
	* defs.h: Remove nzombies member from struct tcb.
	* strace.c (droptcb): Remove "tcp->parent->nzombies++".
	  (alloc_tcb): Remove "tcp->nzombies = 0".

	Fix regression introduced by "Properly handle real SIGTRAPs" change.
	Commit 3454e4b463e6c22c7ea8c5461ef5a077f4650a54
	introduced a bug: sometimes, TRACECLONE/TRACE[V]FORK opts were not set.
	The check (tcp->parent == NULL) in old code was meant to check
	"if we are not a child created by auto-attach" - in this case,
	options need to be set on the child; otherwise they are inherited
	and do not need to be set.
	I misunderstood the check and if tcp->parent is not NULL, I was
	setting only ptrace_setoptions_for_all bits.
	This change fixes the problem. Since the fixed logic makes it
	unnecessary to keep two sets of options in separate variables,
	I merge them back into one variable, ptrace_setoptions.

	* defs.h: Merge ptrace_setoptions_followfork and ptrace_setoptions_for_all
	  into one variable, ptrace_setoptions.
	* strace.c: Likewise.
	  (test_ptrace_setoptions_followfork): Use ptrace_setoptions variable.
	  (test_ptrace_setoptions_for_all): Likewise.
	  (main): Likewise.
	* process.c (internal_fork): Likewise.
	  (internal_exec): Likewise.
	* strace.c (trace): Fix the bug where different options were set
	  depending on "tcp->parent == NULL" condition. Add a comment
	  which makes it more clear why this condition is checked.

2011-06-18  Denys Vlasenko  <dvlasenk@redhat.com>

	Do not suspend waitpid.
	strace used to suspend waitpid until there is a child
	for waitpid'ing process to collect status from.
	Apparently, it was done because in some very old kernels
	(circa 2002 or even earlier) there were ptrace bugs which
	were making waitpid in real parent to not see children.
	This kernel bug is fixed long ago. This change removes the workaround.
	test/wait_must_be_interruptible.c is a test program which
	illustrates why without this change strace changes
	programs's behavior.

	* defs.h: Delete waitpid and nclone_waiting members from from struct tcb.
	  Remove declaration of internal_wait().
	* process.c (internal_wait): Remove this function.
	* strace.c (alloc_tcb): Do not set tcp->nclone_waiting.
	  (resume): Remove this function.
	  (resume_from_tcp): Remove this function.
	  (detach): Do not call resume_from_tcp().
	  (handle_group_exit): Do not call resume_from_tcp().
	* syscall.c (internal_syscall): Do not call internal_wait().

2011-06-13  Andi Kleen  <ak@linux.intel.com>

	Enhance io_submit() decoding.
	strace didn't decode important fields in the iocb passed to io_submit.
	This patch changes the code to dump them all.  Also it prefixes the fields
	with names to make it easier to read.

	* desc.c (iocb_cmd_lookup, print_common_flags): New functions.
	(sys_io_submit): New iocb decoder.

2011-06-13  Dmitry V. Levin  <ldv@altlinux.org>

	Add argument to tprint_iov() specifying whether to decode each iovec.
	* defs.h (tprint_iov): Add decode_iov argument.
	* io.c (tprint_iov): Implement new decode_iov argument.
	(sys_readv, sys_writev, sys_sendfile, sys_preadv, sys_pwritev): Update
	tprint_iov calls.
	* net.c (do_msghdr): Likewise.

	Introduce ARRAY_SIZE() macro.
	* defs.h (ARRAY_SIZE): New macro.
	* ioctl.c: Use it.
	* pathtrace.c (pathmatch, storepath): Likewise.
	* process.c (printpriv): Likewise.
	* signal.c: Likewise.
	* syscall.c: Likewise.

2011-06-13  Andi Kleen  <ak@linux.intel.com>

	Fix decoding of timer id returned by timer_create.
	* time.c (sys_timer_create): The kernel returns a integer, not a
	pointer for the timer id in the memory pointed to by timer_id.

2011-06-09  Dmitry V. Levin  <ldv@altlinux.org>

	Add test for PTRACE_O_TRACESYSGOOD.
	* tests/ptrace_setoptions_for_all: New file.
	* tests/Makefile.am (TESTS): Add ptrace_setoptions_for_all.

	tests: update test for linux kernel version.
	* tests/ptrace_setoptions_followfork: Check for Linux kernel > 2.6.

	Update ptrace_setoptions test.
	The test have to be adjusted after commit v4.6-5-g3454e4b.

	* ptrace_setoptions: Update grep pattern, rename to
	ptrace_setoptions_followfork.
	* tests/Makefile.am (TESTS): Rename ptrace_setoptions to
	ptrace_setoptions_followfork.

	* strace.c (verror_msg): Rewrite without use of heap memory allocation.

	Fix MIPS syscall entries.
	* linux/mips/syscallent.h: Remove duplicate entries for 4336, 4337,
	and 4338 syscall numbers.

	Reported-by: Denys Vlasenko <dvlasenk@redhat.com>

2011-06-08  Denys Vlasenko  <dvlasenk@redhat.com>

	Don't display bogus parameter for sigreturn syscall.
	* linux/*/syscallent.h: For those arches which use sys_sigreturn,
	not printargs, to show [rt_]sigreturn syscall, change number of arguments
	from 1 to 0: sys_sigreturn function doesn't use syscall parameters.
	(I guess kernel doesn't actually _have_ any parameters for this syscall,
	at least on these architectures). Do the same change for I386 and x86-64
	even though they use printargs: I looked at kernel code and syscall
	definitely doesn't have any parameters on these arches.
	(I hesitate to change 1 to 0 params for arches I don't know -
	it is remotely possible some of them do have a parameter for this syscall).

	Optimize sigreturn handling.
	* signal.c (sys_sigreturn): move stack pointer variables,
	and for SPARC and MIPS, stack pointer and sigmask reading code
	into "if (entering) ..." block, because it is only needed
	in this branch; load tcp->u_arg[1] into sigmask for display
	_after_ we know for sure u_arg[1] does contain valid sigmask
	(IOW: perform operation only when we know we will need the result)

	Do not call umoven to fetch parameters if we have zero params.
	* syscall.c [I386] (syscall_enter): Do not call umoven
	to fetch zero bytes. This is just an optimization.

	"Modernize" four old-style function parameter declarations.
	* signal.c (signame, long_to_sigset, printsigmask, printsignal):
	Convert old-style C function definitions to a "modern" form.
	This does not change any actual code.

	Fix sigreturn decoding on MIPS.
	The "return 0" line was accidentally deleted circa 2007,
	which made sigreturn on MIPS always display "= 0" return
	instead of more informative " = ? (mask now [MASK])".

	* strace.c (sys_sigreturn): Add wrongly deleted "return 0" line

	Print at least one space between SYSCALL(ARGS) and = RESULT if tracee is killed
	We already do it in the normal case, but in rare code path where
	tracee is gone (SIGKILLed?) sometimes we were printing this:
	"SYSCALL(ARGS <unavailable>)= ? <unavailable>" - note jammed together ")=".
	test/sigkill_rain.c can be used to verify the fix.

	* strace.c (printleader): add a space after ")" in " <unavailable>)"

	Add fflush after printf in test/sigkill_rain.c.

	Update test/* directory, it seem to be a bit bit-rotted.
	Added README; modified sigkill_rain.c to be more understandable,
	made clone.c compile; added wait_must_be_interruptible.c test;
	updated Makefile and .gitignore.

2011-06-07  Denys Vlasenko  <dvlasenk@redhat.com>

	Whitespace cleanups. no code changes.
	* bjm.c: Fix tabulation (such as extra spaces before tabs),
	convert punctuation where it deviates from prevalent form
	elsewhere in strace code, convert sizeof and offsetof where
	it deviates from from prevalent form, remove space between
	function/macro/array names and (parameters) or [index],
	add space between "if" and (condition), correct non-standard
	or wrong indentaion.
	* defs.h: Likewise
	* desc.c: Likewise
	* file.c: Likewise
	* ipc.c: Likewise
	* linux/arm/syscallent.h: Likewise
	* linux/avr32/syscallent.h: Likewise
	* linux/hppa/syscallent.h: Likewise
	* linux/i386/syscallent.h: Likewise
	* linux/ioctlsort.c: Likewise
	* linux/m68k/syscallent.h: Likewise
	* linux/microblaze/syscallent.h: Likewise
	* linux/powerpc/syscallent.h: Likewise
	* linux/s390/syscallent.h: Likewise
	* linux/s390x/syscallent.h: Likewise
	* linux/sh/syscallent.h: Likewise
	* linux/sh64/syscallent.h: Likewise
	* linux/tile/syscallent.h: Likewise
	* linux/x86_64/syscallent.h: Likewise
	* mem.c: Likewise
	* net.c: Likewise
	* pathtrace.c: Likewise
	* process.c: Likewise
	* signal.c: Likewise
	* sock.c: Likewise
	* strace.c: Likewise
	* stream.c: Likewise
	* sunos4/syscall.h: Likewise
	* sunos4/syscallent.h: Likewise
	* svr4/syscall.h: Likewise
	* svr4/syscallent.h: Likewise
	* syscall.c: Likewise
	* system.c: Likewise
	* test/childthread.c: Likewise
	* test/leaderkill.c: Likewise
	* test/skodic.c: Likewise
	* time.c: Likewise
	* util.c: Likewise

2011-05-30  Dmitry V. Levin  <ldv@altlinux.org>

	ARM EABI: fix 64-bit syscall's arguments decoding.
	ARM OABI and ARM EABI have different function parameters passing rules.
	With EABI, 64-bit function parameters passed in registers are aligned to
	an even-numbered register instead of using the next available pair, see
	http://lkml.org/lkml/2006/1/12/175
	This rule also applies to syscall's arguments.

	* linux/arm/syscallent.h (pread, pwrite, truncate64, ftruncate64,
	readahead, preadv, pwritev): Fix number of arguments.
	* util.c (printllval): Align 64bit argument to 64bit boundary on
	__ARM_EABI__.

	Reported-by: Damir Shayhutdinov <damir@altlinux.org>

2011-05-30  Damir Shayhutdinov  <damir@altlinux.ru>

	Linux: implement decoding of preadv and pwritev syscalls.
	* io.c [LINUX && HAVE_SYS_UIO_H] (sys_preadv, sys_pwritev): New functions.
	* linux/syscall.h (sys_preadv, sys_pwritev): Declare them.
	* linux/*/syscallent.h: Use them.

2011-05-30  Denys Vlasenko  <dvlasenk@redhat.com>

	"Modernize" all old-style function parameter declarations.
	* bjm.c: Convert all remaining old-style C function definitions
	to a "modern" form. This does not change any actual code.
	* io.c: Likewise
	* ioctl.c: Likewise
	* net.c: Likewise
	* proc.c: Likewise
	* process.c: Likewise
	* signal.c: Likewise
	* sock.c: Likewise
	* strace.c: Likewise
	* stream.c: Likewise
	* syscall.c: Likewise
	* system.c: Likewise
	* time.c: Likewise
	* util.c: Likewise

2011-05-27  Denys Vlasenko  <dvlasenk@redhat.com>

	Cleanups on top of "handle SIGTRAP properly" change, based on Dmitry's comments.
	* defs.h ([p]error_msg[_and_die]): Declare new functions.
	* strace.c (SYSCALLTRAP): Rename to syscall_trap_sig.
	([p]error_msg[_and_die]): Define new functions.
	(strace_tracer_pid): New variable, it controls which pid will
	do cleanup on exit via [p]error_msg_and_die.
	(main): Set strace_tracer_pid to our initial pid.
	(startup_attach): Change strace_tracer_pid if we are in -D mode.
	(test_ptrace_setoptions_for_all): Minor changes to logic,
	such as better diagnostic messages.

2011-05-25  Denys Vlasenko  <dvlasenk@redhat.com>

	Identifier "errno" may be a macro, it's unsafe to use it.
	* strace.c (strerror): Rename parameter errno to err_no

2011-05-24  Denys Vlasenko  <dvlasenk@redhat.com>

	Don't perform TCB_WAITEXECVE wait if not needed.
	* defs.h (ptrace_setoptions_for_all): Expose this variable.
	* strace.c (ptrace_setoptions_for_all): Remove "static".
	* process.c (internal_exec): Don't set TCB_WAITEXECVE bit
	if we know that post-execve SIGTRAP is not going to happen.

2011-05-23  Denys Vlasenko  <dvlasenk@redhat.com>

	Properly handle real SIGTRAPs.
	* defs.h (ptrace_setoptions): Variable renamed to ptrace_setoptions_followfork.
	* process.c (internal_fork): Ditto.
	* strace.c (ptrace_setoptions_for_all): New variable.
	(SYSCALLTRAP): New variable.
	(error_msg_and_die): New function.
	(test_ptrace_setoptions_for_all): New function.
	(main): Call test_ptrace_setoptions_for_all() at init.
	(handle_ptrace_event): Handle PTRACE_EVENT_EXEC (by ignoring it).
	(trace): Check events and set ptrace options without -f too.
	Check WSTOPSIG(status) not for SIGTRAP, but for SYSCALLTRAP.

2011-04-24  Mike Frysinger  <vapier@gentoo.org>

	Blackfin: update syscall list.

	* linux/bfin/syscallent.h: Add name_to_handle_at, open_by_handle_at,
	clock_adjtime, and syncfs syscalls.

	linux: add new EHWPOISON errno.

	* linux/errnoent.h: Change ERRNO_133 to EHWPOISON.

2011-04-08  Grant Edwards  <grant.b.edwards@gmail.com>

	Add ability to print file descriptor paths and filter by those paths.
	* pathtrace.c: New file, implements matching syscall arguments to
	user-specified file paths.
	* Makefile.am (strace_SOURCES): Add pathtrace.c.
	* defs.h (TCB_FILTERED, filtered): New defines.
	(getfdpath, pathtrace_select, pathtrace_match, show_fd_path,
	tracing_paths): New declarations.
	* strace.c (show_fd_path, tracing_paths): New global variables.
	(usage, main): Implement handling of -y and -P options.
	* strace.1: Add descriptions of -y and -P options.
	* syscall.c (trace_syscall_entering): Add path matching logic to the
	print/noprint decision and set the TCB_FILTERED bit appropriately.
	(trace_syscall_exiting): Use filtered() macro that checks the
	TCB_FILTERED bit to determine print/noprint status.
	* util.c (printfd): Use getfdpath().

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

	Fix BLKTRACESTOP definition.
	* block.c: Fix typo in the check for BLKTRACESTOP.
	Reported by Gabor Z. Papp.

2011-03-15  Dmitry V. Levin  <ldv@altlinux.org>

	Ensure that PTRACE_GETSIGINFO et al are always defined on Linux.
	* configure.ac (AC_CHECK_DECLS): Add PTRACE_* constants.
	* defs.h [LINUX]: Define those PTRACE_* constants that are not provided
	by <sys/ptrace.h>.

	* CREDITS.in: Fix typo.

2011-03-14  Dmitry V. Levin  <ldv@altlinux.org>

	Update PTRACE_* constants.
	* process.c (ptrace_cmds): Add PTRACE_GETREGSET and PTRACE_SETREGSET.

	Prepare for 4.6 release.
	* NEWS: Update for 4.6 release.
	* configure.ac: Version 4.6.
	* debian/changelog: 4.6-1.
	* strace.spec: 4.6-1.

2011-03-14  Mike Frysinger  <vapier@gentoo.org>

	linux/ioctlent: unify them all.
	This unifies all the ioctlent.h's in the linux subdir while still
	allowing each arch to maintain its own minor list.

	The basic method is:
	- each arch has linux/<arch>/ioctlent.h.in which defines only the
	arch-specific ioctls;
	- linux/ioctlent.h.in which defines only the common ioctls;
	- at build time, these two headers are combined and sorted to produce
	the linux/ioctlent.h file.

	This also requires a little tweaking of the include files since the
	common ioctlent.h is a built file.

	* linux/ioctlent.h: Split into linux/ioctlent.h.in and
	linux/i386/ioctlent.h.in, remove asm entries from the former, remove
	non-asm entries from the latter.
	* linux/alpha/ioctlent.h: Rename to linux/alpha/ioctlent.h.in, remove
	non-asm entries.
	* linux/bfin/ioctlent.h: Rename to linux/bfin/ioctlent.h.in, remove
	non-asm entries.
	* linux/hppa/ioctlent.h: Rename to linux/hppa/ioctlent.h.in, remove
	non-asm entries.
	* linux/ia64/ioctlent.h: Rename to linux/ia64/ioctlent.h.in, remove
	non-asm entries.
	* linux/mips/ioctlent.h: Rename to linux/mips/ioctlent.h.in, remove
	non-asm entries.
	* linux/powerpc/ioctlent.h: Rename to linux/powerpc/ioctlent.h.in,
	remove non-asm entries.
	* linux/s390/ioctlent.h: Rename to linux/s390/ioctlent.h.in, remove
	non-asm entries.
	* linux/sh/ioctlent.h: Rename to linux/sh/ioctlent.h.in, remove
	non-asm entries.
	* linux/sparc/ioctlent.h: Rename to linux/sparc/ioctlent.h.in, remove
	non-asm entries.
	* linux/arm/ioctlent.h.in: New file.
	* linux/avr32/ioctlent.h.in: Likewise.
	* linux/i386/ioctlent.h.in: Likewise.
	* linux/m68k/ioctlent.h.in: Likewise.
	* linux/microblaze/ioctlent.h.in: Likewise.
	* linux/tile/ioctlent.h.in: Likewise.
	* linux/x86_64/ioctlent.h.in: Likewise.
	* linux/s390x/ioctlent.h.in: Include ioctlent.h.in instead of
	ioctlent.h.
	* linux/sh64/ioctlent.h.in: Likewise.
	* linux/sparc64/ioctlent.h.in: Likewise.
	* linux/arm/ioctlent1.h: Update ioctlent.h include.
	* linux/powerpc/ioctlent1.h: Likewise.
	* linux/sparc/ioctlent1.h: Likewise.
	* linux/sparc64/ioctlent1.h: Likewise.
	* linux/x86_64/ioctlent1.h: Likewise.
	* Makefile.am (AM_CPPFLAGS): Add -I$(builddir)/$(OS).
	(EXTRA_DIST): Update.
	[MAINTAINER_MODE && LINUX]: Convert from ioctlent_h to ioctlent_h_in.
	[LINUX]: Add $(builddir)/$(OS)/ioctlent.h generation rules.
	* .gitignore: Add linux/ioctlent.h.

2011-03-10  Dmitry V. Levin  <ldv@altlinux.org>

	Show more details about signals received by traced processess.
	* strace.c [!USE_PROCFS] (trace): Differentiate output format depending
	on PTRACE_GETSIGINFO success or failure.  In the former case, use
	printsiginfo() to show more details about received signal.

	Get rid of PT_GETSIGINFO.
	* strace.c [!USE_PROCFS] (trace): Assume that PTRACE_GETSIGINFO is
	available.  Replace PT_GETSIGINFO with PTRACE_GETSIGINFO.  Use
	PTRACE_GETSIGINFO for all signals.

	Enhance decoding of kernel-generated signals.
	* signal.c (printsiginfo) [LINUX]: Do not print uninteresting
	zero-initialized fields.

	Fix decoding of user-generated signals.
	* signal.c [LINUX] (SI_FROMUSER): Define.
	[LINUX || SVR4] (printsiginfo) [SI_FROMUSER]: Enhance decoding.

	Recognize SI_KERNEL and SI_ASYNCNL.
	* signal.c [LINUX] (SI_KERNEL, SI_ASYNCNL): Define.
	[LINUX || SVR4] (siginfo_codes): Add entries for SI_KERNEL and
	SI_ASYNCNL, reorder entries.

2011-03-05  Sebastian Pipping  <sebastian@pipping.org>

	Take all git branches into account for generation of CREDITS file.
	* Makefile.am: Make CREDITS target depend on all git branches.

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

	Fix decoding of file descriptors.
	* defs.h (printfd): New function prototype.
	* util.c (printfd): New function.
	* file.c (print_dirfd): Update prototype to use printfd().
	(sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat,
	sys_unlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat,
	sys_futimesat, sys_utimensat, sys_mknodat): Update use of print_dirfd().
	(sys_lseek, sys_llseek, sys_readahead, sys_ftruncate, sys_ftruncate64,
	sys_fstat, sys_fstat64, sys_oldfstat, sys_fstatfs, sys_fstatfs64,
	sys_fchdir, sys_fchroot, sys_linkat, sys_fchown, sys_fchmod, sys_fsync,
	sys_readdir, sys_getdents, sys_getdirentries, sys_fsetxattr,
	sys_fgetxattr, sys_flistxattr, sys_fremovexattr, sys_fadvise64,
	sys_fadvise64_64, sys_inotify_add_watch, sys_inotify_rm_watch,
	sys_fallocate): Use printfd() for decoding of file descriptors.
	* desc.c (sys_fcntl, sys_flock, sys_close, sys_dup, do_dup2,
	decode_select, sys_epoll_ctl, epoll_wait_common): Use printfd() for
	decoding of file descriptors.
	* io.c (sys_read, sys_write, sys_readv, sys_writev, sys_pread,
	sys_pwrite, sys_sendfile, sys_sendfile64, sys_pread64, sys_pwrite64,
	sys_ioctl): Likewise.
	* mem.c (print_mmap, sys_mmap64): Likewise.
	* signal.c (do_signalfd): Likewise.
	* stream.c (decode_poll): Likewise.
	* time.c (sys_timerfd_settime, sys_timerfd_gettime): Likewise.
	Based on patch from Grant Edwards <grant.b.edwards@gmail.com>.

2011-03-03  Sebastian Pipping  <sebastian@pipping.org>

	Print shutdown(2) modes as SHUT_* constants.
	* net.c (shutdown_modes): New xlat structure.
	(sys_shutdown): Use shutdown_modes to decode 2nd syscall argument.

	Fix decoding of inotify_init1() flags.
	* file.c (inotify_init_flags): New xlat structure.
	(sys_inotify_init1): Use it instead of open_mode_flags.

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

	Fix struct xlat initialization bugs.
	* file.c (inotify_modes): Terminate with NULL entry.
	* net.c (sock_type_flags): Make this array static.
	(socketlayers): Add a comment that this array should remain not
	NULL-terminated.

	tests: avoid SIGPIPE.
	* tests/ptrace_setoptions: Replace "grep -q" with "grep > /dev/null".
	The former may result to strace being killed by SIGPIPE, which in
	certain configuratons may lead to generation of a core file.
	Suggested by Mike Frysinger.

2011-03-01  Mike Frysinger  <vapier@gentoo.org>

	tests: do not make missing /usr/bin/time a failure.
	* tests/init.sh (framework_skip_): New function.
	(check_prog): Use it instead of framework_failure_.

2011-02-27  Dmitry V. Levin  <ldv@altlinux.org>

	Generate an xz tar archive of the distribution.
	* configure.ac (AM_INIT_AUTOMAKE): Replace dist-bzip2 with dist-xz.
	* Makefile.am: Update srpm target.
	* make-dist: Update for dist-xz.
	* strace.spec: Update Source tag.
	* debian/watch: Update regexp.
	* .gitignore: Add strace-*.tar.xz.

	Use "make check" in debian/rules and strace.spec.
	* debian/control: Update Build-Depends.
	* debian/rules: Run "make check".
	* strace.spec: Update BuildRequires. Run "make check" in %check section.

	Implement two basic "strace -f" tests.
	* Makefile.am (SUBDIRS): Add tests.
	* configure.ac (AC_CONFIG_FILES): Add tests/Makefile.
	* tests/.gitignore: New file.
	* tests/Makefile.am: Likewise.
	* tests/init.sh: Likewise.
	* tests/ptrace_setoptions: Likewise.
	* tests/strace-f: Likewise.

2011-02-26  Dmitry V. Levin  <ldv@altlinux.org>

	ppc, s390, sparc: regenerate ioctlent.h files.
	* linux/powerpc/ioctlent.h: Regenerated using Fedora 15 kernel headers.
	* linux/s390/ioctlent.h: Likewise.
	* linux/sparc/ioctlent.h: Likewise.

	Remove redundant ioctlent.h files.
	* linux/s390x/ioctlent.h: Replace old contents with include of
	s390/ioctlent.h file.
	* linux/sparc64/ioctlent.h: Replace old contents with include of
	sparc/ioctlent.h file.

2011-02-25  Dmitry V. Levin  <ldv@altlinux.org>

	ioctlsort: sync with ioctl_lookup()
	* linux/ioctlsort.c (main): Use NR and TYPE bits only, to sync with
	ioctl_lookup() which looks at these bits only.

	Remove obsolete .cvsignore files.
	* test/.cvsignore: Rename to test/.gitignore.
	* */.cvsignore, */*/.cvsignore: Removed.

	Ignore generated intermediate header files.
	* .gitignore: Add ioctls.h and ioctldefs.h.

2011-02-24  Dmitry V. Levin  <ldv@altlinux.org>

	Generate much of the CREDITS file from git log.
	* CREDITS.in: New file, derived from CREDITS, without names of
	those who are listed as git log 'Author:'s.
	* CREDITS: Remove file.
	* Makefile.am [MAINTAINER_MODE] (CREDITS): New rule.
	* .gitignore: Add CREDITS.
	* .mailmap: New file, required to map git author names and email
	addresses to canonical/preferred form.

2011-02-23  Dmitry V. Levin  <ldv@altlinux.org>

	sparc: fix compilation warning.
	* file.c [!HAVE_LONG_LONG_OFF_T] (realprintstat): Cast st_size
	to unsigned long.

	Update the list of files that must be distributed.
	* Makefile.am (EXTRA_DIST): Add debian/source/format, debian/watch,
	linux/ia64/signalent.h, linux/powerpc/ioctlent1.h,
	linux/powerpc/syscallent1.h, linux/powerpc/errnoent1.h,
	linux/powerpc/signalent1.h.

	Fix compilation warning reported by gcc -Wunused-but-set-variable.
	* process.c (printwaitn) [!SUNOS4]: Do not define "exited" variable.

2011-02-22  Mike Frysinger  <vapier@gentoo.org>

	ioctlsort: zero pad ioctl codes to 4 places.
	Zero padding the ioctl number will allow simple sorting via shell scripts.

	* linux/ioctlsort.c (main): Output ioctl codes zero padded.
	* linux/ioctlent.h: Regenerated.

	Update mount flags to latest linux.
	* system.c (MS_RELATIME, MS_KERNMOUNT, MS_I_VERSION,
	MS_STRICTATIME, MS_BORN): Define.
	(mount_flags): Add MS_RELATIME, MS_KERNMOUNT, MS_I_VERSION,
	MS_STRICTATIME, MS_BORN.

2011-02-22  Dmitry V. Levin  <ldv@altlinux.org>

	Sync debian/changelog and strace.spec with packages.
	* debian/changelog: Sync with 4.5.20-2.
	* strace.spec: Likewise.

2011-02-20  Dmitry V. Levin  <ldv@altlinux.org>

	Add TRACE_DESC|TRACE_FILE flags to fanotify_* sysentries.
	* linux/*/syscallent.h: Add TD flag to fanotify_init.  Add TD|TF flags
	to fanotify_mark.

	Fix flags of fallocate sysentries.
	* linux/*/syscallent.h: Fix sys_fallocate flags.

	Add TRACE_DESC flag to epoll_create* sysentries.
	* linux/*/syscallent.h: Add TD flag to sys_epoll_create and
	sys_epoll_create1.

	Add TRACE_DESC flag to fgetxattr, flistxattr, and fremovexattr sysentries
	* linux/*/syscallent.h: Add TD flag to sys_fgetxattr, sys_flistxattr,
	and fremovexattr.

	Add TRACE_FILE flag to swapoff sysentries.
	* linux/*/syscallent.h: Add TF flag to sys_swapoff.

	Add TRACE_DESC flag to fadvise64* sysentries.
	* linux/*/syscallent.h: Add TD flag to sys_fadvise64 and
	sys_fadvise64_64.

	Add TRACE_DESC flag to mmap, mmap2, and old_mmap sysentries.
	* linux/*/syscallent.h: Add TD flag to sys_mmap and sys_old_mmap.

	Do not initialize native_scno on platforms with only one personality.
	* linux/bfin/syscallent.h: Remove redundant native_scno initialization.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.

	Add LOOP_* ioctls defined in linux/loop.h.
	* linux/ioctlent.sh: Add LOOP_* ioctls (0x4C..) defined in linux/loop.h
	header file.
	* linux/ioctlent.h: Regenerated.
	Reported by Mike Frysinger.

2011-02-19  Dmitry V. Levin  <ldv@altlinux.org>

	Fix PTRACE_GETEVENTMSG usage and enhance test_ptrace_setoptions()
	* strace.c (handle_ptrace_event): Fix PTRACE_GETEVENTMSG usage.
	(test_ptrace_setoptions): Test that PTRACE_GETEVENTMSG works properly.

2011-02-19  Mike Frysinger  <vapier@gentoo.org>

	linux/sparc: move to common syscall.h.
	Rather than constantly deal with the sparc/syscall.h going stale, merge
	the few sparc-specific pieces into the linux/syscall.h header.

	* linux/syscall.h: Add sparc-specific pieces from sparc/syscall.h.
	* Makefile.am (EXTRA_DIST): Remove linux/sparc/syscall.h and
	linux/sparc64/syscall.h.
	* linux/sparc/syscall.h, linux/sparc64/syscall.h: Deleted.

	sparc: add new funcs to syscall.h.
	Sync missing defs from the common syscall.h here.

	* linux/sparc/syscall.h: Add sys_setfsuid, sys_pread64, and
	sys_pwrite64 prototypes.

	sparc: punt unused syscall.h.2.
	I can't find any mention of this header actually being used.
	Seems to be a really old copy of the common syscall.h.

	* Makefile.am (EXTRA_DIST): Remove linux/sparc/syscall.h.2.
	* linux/sparc/syscall.h.2: Deleted.

2011-02-19  Dmitry V. Levin  <ldv@altlinux.org>

	Fix raw exit_group(2) decoding.
	* syscall.c (trace_syscall_entering): Check for sys_exit instead of
	SYS_exit to handle exit_group(2) as well as _exit(2).

2011-02-18  Dmitry V. Levin  <ldv@altlinux.org>

	Optimize known_scno()
	* syscall.c (known_scno): Do not check for native_scno field on
	platforms that support only one personality.

	* process.c (internal_exit) [IA64]: Remove redundant check.

2011-02-09  Dmitry V. Levin  <ldv@altlinux.org>

	Fix biarch support in IO dumping.
	* syscall.c (dumpio): Switch on tcp->sys_func instead of tcp->scno
	for more reliable results.

	Simplify tprintf() declaration.
	* defs.h (tprintf): Simplify declaration.

2011-02-05  Dmitry V. Levin  <ldv@altlinux.org>

	* defs.h (SYSCALL_NEVER_FAILS): Fix typo.

2011-01-19  Dmitry V. Levin  <ldv@altlinux.org>

	Fix decoding of get[ug]id, gete[ug]id and setfs[ug]id return values.
	* defs.h (SYSCALL_NEVER_FAILS): New syscall flag.
	* linux/dummy.h: Change redirection for sys_get[ug]id, sys_gete[ug]id
	and setfs[ug]id.
	* linux/*/syscallent.h: Set SYSCALL_NEVER_FAILS flag for get[ug]id,
	gete[ug]id and setfs[ug]id syscalls.
	* process.c [LINUX] (sys_getuid, sys_setfsuid): New functions.
	* syscall.c (NF): New shorthand macro for use in syscallent.h files.
	(get_error): Check SYSCALL_NEVER_FAILS flag.
	Reported by Марк Коренберг <socketpair@gmail.com>.

	* linux/*/syscallent.h: Fix typo in sys_newfstatat syscall flags.

2011-01-18  Mike Frysinger  <vapier@gentoo.org>

	Blackfin: update ioctl list.
	* linux/bfin/ioctlent.h: Sync with latest kernel sources.

2011-01-17  Dmitry V. Levin  <ldv@altlinux.org>

	Fix stat64 decoding on mips.
	* linux/mips/syscallent.h: Use sys_stat64() to decode stat64 syscall.
	This fixes Debian bug #599028.

	Update linux/*/syscallent.h files to match Linux kernel v2.6.37.
	* linux/alpha/syscallent.h: Add hooks for fanotify_init, fanotify_mark,
	and prlimit64.
	* linux/i386/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/arm/syscallent.h: Add hooks for accept4, fanotify_init,
	fanotify_mark, and prlimit64.
	* linux/hppa/syscallent.h: Add hook for prlimit64.

2011-01-16  Dmitry V. Levin  <ldv@altlinux.org>

	block.c: cleanup.
	* block.c: Include <inttypes.h>.
	(print_blkpg_req): Always decode struct blkpg_ioctl_arg.
	Robustify decoding of strings.
	(block_ioctl): Do not decode return values passed by pointers on exit
	from failed syscalls.
	Use format macros from inttypes.h to print values of type uint64_t.

2011-01-15  Dmitry V. Levin  <ldv@altlinux.org>

	Add block ioctl support.
	* block.c: New file.
	* Makefile.am (strace_SOURCES): Add it.
	* defs.h [LINUX] (block_ioctl): New function.
	* ioctl.c (ioctl_decode) [LINUX]: Use it to decode HDIO_* and BLK*
	ioctls.
	Patch by Jeff Mahoney <jeffm@suse.com>

2011-01-14  Holger Hans Peter Freyther  <zecke@selfish.org>

	Parse SOL_SCTP socket options.
	* configure.ac (AC_CHECK_HEADERS): Add netinet/sctp.h.
	* net.c [HAVE_NETINET_SCTP_H]: Include <netinet/sctp.h>.
	[SOL_SCTP] (socksctpoptions): New xlat structure.
	(sys_getsockopt, printsockopt): Parse SOL_SCTP options.

	* net.c (socketlayers): Add more SOL_* constants from linux/socket.h.

2011-01-14  Dmitry V. Levin  <ldv@altlinux.org>

	strace.1: fix misleading italics.
	* strace.1: Use bold instead of italics for "-e trace=" keywords.
	This fixes Debian bug #589323.

	Update linux/ioctlent.h.
	* linux/ioctlent.h: Regenerate using linux v2.6.37 headers.

	Add HDIO_* ioctls defined in linux/hdreg.h.
	* linux/ioctlent.sh: Add HDIO_* ioctls (0x03..) defined in
	linux/hdreg.h header file.
	This fixes Debian bug #450953.

2011-01-13  Dmitry V. Levin  <ldv@altlinux.org>

	Test PTRACE_O_TRACECLONE and PTRACE_O_TRACEVFORK along with PTRACE_O_TRACEFORK
	* strace.c (test_ptrace_setoptions): Add PTRACE_O_TRACECLONE and
	PTRACE_O_TRACEVFORK to PTRACE_SETOPTIONS call, to test exactly
	the same set of options that is going to be used later in trace().

2011-01-10  Dmitry V. Levin  <ldv@altlinux.org>

	* net.c (protocols): Add more IPPROTO_* constants defined in netinet/in.h

2011-01-10  Holger Hans Peter Freyther  <holger@freyther.de>

	* net.c (protocols): Add IPPROTO_GRE, IPPROTO_SCTP and IPPROTO_UDPLITE.

2011-01-10  Carmelo AMOROSO  <carmelo.amoroso@st.com>

	sh: Add entry for not-multiplexed accept4.
	* linux/sh/syscallent.h: Add specific entry for not-multiplexed accept4
	available in kernel mainline since v2.6.37-rc6, see
	http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=21b6e4c7106b2d68a6710506d8706608272fd78b

2010-12-14  Carmelo AMOROSO  <carmelo.amoroso@st.com>

	sh: Add entries for not-multiplexed socket calls.
	* linux/sh/syscallent.h: Add specific entries for not-multiplexed
	socket calls (available in kernel mainline since v2.6.37-rc1)

	sh: Fix compilation warning in do_pipe due to missing prototype.
	* defs.h [SH]: Make getrval2 prototype visible to do_pipe
	and fix the following compiler warning:
	.../net.c: In function 'do_pipe':
	.../net.c:1632: warning: implicit declaration of function 'getrval2'
	.../net.c:1632: warning: format '%lu' expects type 'long unsigned int',
	but argument 3 has type 'int'

2010-12-14  Dmitry V. Levin  <ldv@altlinux.org>

	Fix build on uClibc.
	* defs.h [LINUX]: Define PTRACE_GETEVENTMSG macro.
	Patch by Douglas Mencken <dougmencken@gmail.com>.

2010-12-07  Dmitry V. Levin  <ldv@altlinux.org>

	Fix strace -f -o '|command' hangup.
	* strace.c (main): Call test_ptrace_setoptions() before parsing
	-o option, otherwise a forked command will cause a hangup inside
	test_ptrace_setoptions().

2010-12-03  Dmitry V. Levin  <ldv@altlinux.org>

	Output diagnostics to stderr.
	* syscall.c (get_scno): Output information about changes in
	personality mode to stderr.  Reported by Pádraig Brady.

	Recognize more clone flags.
	* process.c (CLONE_*): Define more flags from linux v2.6.25.
	(clone_flags): Add entries for them.
	Proposed by <zhangyanfei@cn.fujitsu.com>.

	Decode struct ucred for getsockopt SO_PEERCRED.
	* net.c (sys_getsockopt): Decode SO_PEERCRED.
	Proposed by Arkadiusz Miśkiewicz <arekm@maven.pl>.

2010-12-03  Carmelo AMOROSO  <carmelo.amoroso@st.com>

	sh: Add support for tracing sys_cacheflush system call.
	* linux/sh/syscallent.h: Update sys_cacheflush entry.
	* linux/syscall.h [SH] (sys_cacheflush): New function declaration.
	* system.c [SH] (cacheflush_flags): New xlat structure.
	[SH] (sys_cacheflush): New function.

	Reviewed-by: Angelo Castello <angelo.castello@st.com>

2010-11-30  Dmitry V. Levin  <ldv@altlinux.org>

	Cleanup test_ptrace_setoptions()
	* strace.c (test_ptrace_setoptions): Cleanup.
	(main): Fix test_ptrace_setoptions() error diagnostics message.
	Print ptrace_setoptions value in debug mode.

2010-11-30  Wang Chao  <wang.chao@cn.fujitsu.com>

	Handle followfork using ptrace_setoptions if available.
	If PTRACE_O_TRACECLONE et al options are supported by kernel,
	use them to do followfork rather than the original setbpt
	method that changes registers ourselves.

	* defs.h [LINUX] (handle_new_child): New function prototype.
	* process.c [LINUX] (handle_new_child): New function based on the
	code from internal_fork(), with a trivial change: do reparent only
	for sys_clone.
	[LINUX] (internal_fork): Use handle_new_child().  Do nothing if
	ptrace_setoptions is in effect.
	* strace.c [LINUX] (handle_ptrace_event): New function.
	[LINUX] (trace): If ptrace_setoptions is in effect, then
	call the new function to handle PTRACE_EVENT_* status, and
	set PTRACE_SETOPTIONS when we see the initial stop of tracee.

	Test how PTRACE_SETOPTIONS support works.
	Currently test fork related options only.  Fork a child that uses
	PTRACE_TRACEME at startup and then does a fork so strace can test
	how the PTRACE_SETOPTIONS support works before it handles any real
	tracee.  Since PTRACE_O_TRACECLONE/*FORK were introduced to kernel
	at the same time, this test seems to be enough for these 3 options.

	* defs.h [LINUX]: Define PTRACE_O_TRACECLONE et al macros here.
	(ptrace_setoptions): New variable declaration.
	* strace.c [LINUX] (test_ptrace_setoptions): New function, tests
	whether kernel supports PTRACE_O_CLONE/*FORK, the result is stored
	in the new variable ptrace_setoptions for later use.
	(main): Call test_ptrace_setoptions() if followfork option is set.

2010-09-17  Dmitry V. Levin  <ldv@altlinux.org>

	Enable support for less verbose build rules.
	* configure.ac (AM_INIT_AUTOMAKE): Add silent-rules.

2010-09-17  Wang Chao  <wang.chao@cn.fujitsu.com>

	Do not trace children cloned with CLONE_UNTRACED flag.
	If clone is called with flag CLONE_UNTRACED, to be consistent with
	option PTRACE_O_TRACECLONE, we should not set CLONE_PTRACE flag on
	its arguments.

	* process.c [LINUX] (internal_fork): Check the syscall and arguments.

2010-09-17  Dmitry V. Levin  <ldv@altlinux.org>

	Update the list of CLOCK_* constants to match Linux kernel v2.6.32+
	* time.c (struct xlat clocknames[]): Add more RT clock IDs.
	Reported by Tommi Rantala.

2010-09-16  Dmitry V. Levin  <ldv@altlinux.org>

	Update linux/hppa/syscallent.h to match Linux kernel v2.6.35.
	* linux/hppa/syscallent.h: Add hooks for recvmmsg and accept4.

2010-09-15  Dmitry V. Levin  <ldv@altlinux.org>

	Pass less information to qualify_one and qual_*
	* syscall.c (qualify_one, qual_syscall, qual_signal, qual_fault,
	qual_desc): Take just a bitflag argument instead of pointer to the whole
	qual_options structure.
	(struct qual_options): Update prototype of "qualify" field.
	(qualify): Update use of qualify_one and qual_options->qualify.

2010-09-15  Wang Chao  <wang.chao@cn.fujitsu.com>

	Fix -e option with only one value in qualifier statement.
	Fix regression introduced by commit v4.5.20-19-g30145dd:
	if -e option is used with only one value in qualifier statement,
	e.g. 'strace -e trace=open ls', syscall information would not be
	printed properly.

	* syscall.c (qualify): Remove faulty optimization.

2010-09-15  Mike Frysinger  <vapier@gentoo.org>

	Fix off_t/rlim_t size checks when cross-compiling.
	The current off_t/rlim_t size checks (wrt size of long long) use AC_RUN
	which obviously doesn't work when cross-compiling.  While we don't hit
	any configure errors, the fall back code is pretty dumb (which is to say
	there isn't any).  Considering the code in question though, we can use
	some fun compiler tricks with sizeof and array lengths to turn it into
	a pure build test and avoid the RUN issue completely.

	* m4/long_long.m4 (AC_OFF_T_IS_LONG_LONG, AC_RLIM_T_IS_LONG_LONG):
	Convert from AC_RUN_IFELSE to AC_COMPILE_IFELSE.

	Fix long long little endian detection when cross-compiling.
	The long long endian detection code does an AC_TRY_RUN() and since that
	doesn't work when cross-compiling, it sets a fallback value.  However,
	rather than do any sort of default endian detection, the code simply
	sets it to "no".  This probably breaks most little endian systems out
	there when cross-compiling for them.  It certainly breaks Blackfin
	systems.  So use the common endian detection code provided by autoconf
	and key off of that when cross-compiling.

	* configure.ac: Call AC_C_BIGENDIAN.
	* m4/long_long.m4 (AC_LITTLE_ENDIAN_LONG_LONG): Set cross-compiling
	logic based on ac_cv_c_bigendian.

	Blackfin: decode new syscalls.
	* linux/bfin/syscallent.h: Add fanotify/prlimit/cacheflush syscalls.
	* linux/syscall.h: Add sys_cacheflush() decl.
	* system.c: Decode Blackfin's cacheflush syscall.

	* linux/ioctlent.sh: Search a few non-exported paths.

2010-09-15  Roland McGrath  <roland@redhat.com>

	Clean up pid2tcb usage.
	* strace.c (pid2tcb): Always match pid.  Fail for argument <= 0.
	[USE_PROCFS] (first_used_tcb): New function.
	[USE_PROCFS] (trace): Use that instead of pid2tcb(0).

2010-09-09  Dmitry V. Levin  <ldv@altlinux.org>

	Turn on more compiler warnings.
	* configure.ac: Enable gcc -Wwrite-strings.

	Import warnings.m4 from gnulib.
	* m4/warnings.m4: Replace with warnings.m4 from gnulib.
	* configure.ac: Use gl_WARN_ADD from new warnings.m4.
	* Makefile.am (AM_CFLAGS): Update for new warnings.m4.

	Split acinclude.m4.
	* Makefile.am (ACLOCAL_AMFLAGS): Add "-I m4".
	* acinclude.m4: Remove.
	* m4/includedir.m4: New file, with definition of AC_INCLUDEDIR from
	acinclude.m4.
	* m4/long_long.m4: New file, with definitions of AC_OFF_T_IS_LONG_LONG,
	AC_RLIM_T_IS_LONG_LONG and AC_LITTLE_ENDIAN_LONG_LONG from acinclude.m4.
	* m4/procfs.m4: New file, with definitions of AC_MP_PROCFS,
	AC_POLLABLE_PROCFS and AC_STRUCT_PR_SYSCALL from acinclude.m4.
	* m4/stat.m4: New file, with definition of AC_STAT64 from acinclude.m4.
	* m4/statfs.m4: New file, with definition of AC_STATFS64 from
	acinclude.m4.
	* m4/warnings.m4: New file, with definition of AC_WARNFLAGS from
	acinclude.m4.

	* process.c (sys_waitid): Remove unused variable.

2010-09-07  Dmitry V. Levin  <ldv@altlinux.org>

	Fix const-correctness issues uncovered by gcc -Wwrite-strings.
	* defs.h (struct xlat): Add const qualifier to the field of
	type "char *".
	(set_sortby, qualify, printnum, printnum_int): Add const qualifier to
	arguments of type "char *".
	* count.c (set_sortby): Add const qualifier to the argument and
	automatic variable of type "char *".
	* desc.c (decode_select): Add const qualifier to automatic variables of
	type "char *".
	* ioctlsort.c (struct ioctlent): Add const qualifier to fields of
	type "char *".
	(main):  Add const qualifier to argv.
	* process.c (printargv): Add const qualifier to the argument and
	automatic variable of type "char *".
	(printargc) Add const qualifier to argument of type "char *".
	* signal.c (sprintsigmask, parse_sigset_t): Add const qualifier to
	arguments of type "char *".
	* strace.c (progname): Add const qualifier.
	(detach): Add const qualifier to automatic variable of type "char *".
	* stream.c (struct strbuf): Add const qualifier to the field of
	type "char *".
	* syscall.c (struct qual_options): Add const qualifier to fields of
	type "char *".
	(qual_syscall, qual_fault, qual_desc, lookup_class): Add const qualifier
	to arguments of type "char *".
	(qual_signal): Add const qualifier to the argument of type "char *",
	avoid modification of constant argument.
	(qualify): Likewise.
	* util.c (printflags): Add const qualifier to automatic variable of
	type "char *".
	(printnum, printnum_int): Add const qualifier to arguments of
	type "char *".

2010-09-04  Wang Chao  <wang.chao@cn.fujitsu.com>

	Fix printing clone flags.
	When we trace clone() syscall with only exit signal as clone
	flags, strace would print an unnecessary OR operator.

	* process.c (sys_clone): Fix this.

2010-08-28  Wang Chao  <wang.chao@cn.fujitsu.com>

	Drop nclone_detached and related flags.
	Remove nclone_detached since CLONE_DETACHED flag was no-op for a very
	long time in kernel.

	* defs.h (struct tcb): Remove nclone_detached field.
	Remove TCB_CLONE_DETACHED flag.
	* process.c: Remove CLONE_DETACHED flag.
	(clone_flags): Remove CLONE_DETACHED entry.
	(internal_fork, internal_wait): Remove code dealing with CLONE_DETACHED
	flag and nclone_detached.
	* strace.c (startup_attach, alloc_tcb, droptcb, handle_group_exit):
	Likewise.

2010-08-09  Neil Campbell  <lists@thebatcave.org.uk>

	Correct get/set_robust_list syscall numbers for powerpc.
	* linux/powerpc/syscallent.h: Swap positions of get_ and set_robust_list.

2010-08-09  Wang Chao  <wang.chao@cn.fujitsu.com>

	Handle CLONE_PARENT flag.
	* process.c (internal_fork): The parent of new cloned process is the
	same of the calling process when CLONE_PARENT is set.

	Fix error when judging if process has children.
	* process.c (internal_wait): Processes counted in tcp->nclone_threads
	are tcp's threads, rather than tcp's children.

	Forbid using mutually exclusive options -D and -p together.
	If we use -D and -p option together to trace a multi-thread program, in
	addition to the main thread, other threads could not be traced even if we
	present -f option. Moreover, when executing 'strace -D -p <non-exist pid>',
	strace could not terminate normally.

	* strace.c (main): Check it.

2010-08-05  David Daney  <ddaney@caviumnetworks.com>

	Update Linux MIPS syscalls to match 2.6.35-rc6+
	* linux/mips/syscallent.h: Add and update 405 hooks.

2010-08-05  Edgar E. Iglesias  <edgar.iglesias@gmail.com>

	Add support for the MicroBlaze architecture.
	* configure.ac: Recognize MicroBlaze.
	* linux/microblaze/syscallent.h: New file.
	* Makefile.am (EXTRA_DIST): Add linux/microblaze/syscallent.h
	* process.c (change_syscall, struct_user_offsets): Add MicroBlaze
	support.
	* signal.c (sys_sigreturn): Likewise.
	* syscall.c (internal_syscall, get_scno, syscall_fixup, get_error,
	syscall_enter): Likewise.

2010-08-05  Frederik Schüler  <fs@debian.org>

	linux/sparc: add missing syscall declarations.
	* linux/sparc/syscall.h: Sync with linux/syscall.h

2010-07-17  Andreas Schwab  <schwab@linux-m68k.org>

	Handle biarch get/setrlimit.
	* resource.c (print_rlimit32) [POWERPC64 || X86_64]: Define.
	(sys_getrlimit, sys_setrlimit) [POWERPC64 || X86_64]: Use it.

2010-07-13  Andreas Schwab  <schwab@linux-m68k.org>

	Add biarch support for powerpc64.
	* acinclude.m4 (AC_LITTLE_ENDIAN_LONG_LONG): Use int instead of
	long.
	* configure.ac [$host_cpu = powerpc*]: Also define POWERPC64 if
	$host_cpu = powerpc64.
	* defs.h (SUPPORTED_PERSONALITIES, PERSONALITY0_WORDSIZE)
	(PERSONALITY1_WORDSIZE) [POWERPC64]: Define.
	* file.c: (struct stat_powerpc32, printstat_powerpc32) [POWERPC64]:
	Define.
	(printstat) [LINUX && POWERPC64]: Use printstat_powerpc32 in
	32-bit personality.
	(sys_newfstatat) [POWERPC64]: Handle personalities.
	* signal.c (sys_sigreturn) [POWERPC64]: Likewise.
	* util.c (printllval) [POWERPC64]: Likewise.
	(printcall) [POWERPC64]: Use wider format for IP prefix.
	* syscall.c (get_scno) [POWERPC64]: Check for 64/32 bit mode.
	* linux/powerpc/errnoent1.h: New file.
	* linux/powerpc/ioctlent1.h: New file.
	* linux/powerpc/signalent1.h: New file.
	* linux/powerpc/syscallent1.h: New file.

2010-07-09  Andreas Schwab  <schwab@redhat.com>

	Balance braces.
	* strace.c (proc_open): Avoid unbalanced braces.
	(trace): Likewise.

2010-07-06  Andreas Schwab  <schwab@linux-m68k.org>

	Remove extern declaration at file scope.
	* defs.h (force_result): Declare.
	* process.c (internal_wait): Don't declare force_result.

2010-06-24  Andreas Schwab  <schwab@redhat.com>

	Document -C/-D.
	* strace.c (usage): Document -C.
	* strace.1: Document -D.

2010-06-13  Roland McGrath  <roland@redhat.com>

	Fix sourceforge download URL.

2010-06-05  Andreas Schwab  <schwab@linux-m68k.org>

	M68K: Fix fetching syscall arguments.
	* syscall.c (syscall_enter) [M68K]: Properly handle more than five
	syscall arguments.

2010-05-28  Andreas Schwab  <schwab@linux-m68k.org>

	Decode TLS syscalls on m68k.
	* linux/m68k/syscallent.h: Add entries for get_thread_area,
	set_thread_area, atomic_comxchg_32, atomic_barrier.
	* linux/dummy.h (sys_get_thread_area, sys_set_thread_area) [M68K]:
	Don't redefine.
	* mem.c (sys_get_thread_area, sys_set_thread_area) [LINUX && M68K]: New.

	Fix warning when compiling for m68k.
	* syscall.c (d0): Define as long.

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

	Prepare for 4.5.20 release.
	* NEWS: Update for 4.5.20 release.
	* configure.ac: Version 4.5.20.
	* debian/changelog: 4.5.20-1.
	* strace.spec: 4.5.20-1.

2010-04-13  Frederik Schüler  <fs@debian.org>

	Update debian/* files for the upcoming release.
	* debian/control: update standards-version to 3.8.4.
	* debian/rules: allow parallel building.
	* debian/rules: comment out verbose build, only needed for debugging.
	* debian/rules: clean up clean: target, dh_clean does most of the work
	  already.
	* debian/rules: use *-stamp instead of stamp-*, so dh_clean can tidy
	  up for us.

2010-04-13  Heiko Carstens  <heiko.carstens@de.ibm.com>

	Fix s390 system call table list.
	* linux/s390/syscallent.h: Add the missing entries for preadv and
	pwritev to the system call table list.
	* linux/s390x/syscallent.h: Likewise.

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

	Update linux/ioctlent.h.
	* linux/ioctlent.sh: Search in asm-generic directory as well.
	* linux/ioctlent.h: Regenerated.

	Update linux/*/syscallent.h files to match Linux kernel v2.6.33.
	* linux/alpha/syscallent.h: Add 47 hooks.
	* linux/arm/syscallent.h: Update hooks for pselect6, ppoll,
	epoll_pwait.  Add 11 hooks.
	* linux/bfin/syscallent.h: Update hooks for prctl, fallocate,
	signalfd4, eventfd2, epoll_create1, dup3, pipe2, perf_event_open.
	Hook up recvmmsg.
	* linux/hppa/syscallent.h: Update hooks for signalfd4, eventfd2,
	epoll_create1, dup3, pipe2, perf_event_open.
	* linux/i386/syscallent.h: Fix syscall name for the kexec_load hook.
	Add 5 hooks.
	* linux/ia64/syscallent.h: Fix syscall name for the kexec_load hook.
	Add 4 hooks.
	* linux/m68k/syscallent.h: Add 50 hooks.
	* linux/powerpc/syscallent.h: Fix hook for timerfd_create.  Fix
	6 syscall names to match the kernel.  Use sys_semop to parse semop.
	Add 14 hooks.
	* linux/s390/syscallent.h: Fix syscall name for the kexec_load hook.
	Add 14 hooks.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Add 13 hooks.
	* linux/sh64/syscallent.h: Add 15 hooks.
	* linux/sparc/syscallent.h: Add 22 hooks.
	* linux/x86_64/syscallent.h: Add 5 hooks.

	Enhance recvmmsg parser.
	* net.c (sys_recvmmsg): Decode mmsghdr structure on exit from the
	syscall.  Decode timespec structure both on entrance and on exit.

2010-04-07  Andreas Schwab  <schwab@linux-m68k.org>

	Decode recvmmsg syscall.
	* net.c (do_msghr): New function to print struct msghdr.
	(printmsghdr): Use it.
	(printmmsghdr, sys_recvmmsg): New.
	* linux/syscall.h: Declare sys_recvmmsg.
	(SYS_sub_recvmmsg): Define.
	(SYS_socket_nsubcalls): Bump.
	* linux/sparc/syscall.h: Likewise.
	* linux/arm/syscallent.h: Add sys_recvmmsg.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Adjust.

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

	* strace.1: Fix quoting of hyphens and formatting of strace options.

	Split trace_syscall() for better readability.
	* syscall.c (trace_syscall): Split into trace_syscall_exiting() and
	trace_syscall_entering().

	Implement -C option to combine regular and -c output.
	* defs.h (cflag_t): New enum.
	* strace.1: Document -C option.
	* strace.c (cflag): Update type.
	(main): Handle -C option.
	(trace): Update use of cflag.
	* count.c (count_syscall): Move clearing of TCB_INSYSCALL to ...
	* syscall.c (trace_syscall): ... here.  Update use of cflag.
	Based on patch by Adrien Kunysz.

	Fix "make dist" regression introduced by commit v4.5.19-12-g5078770.
	* Makefile.am (EXTRA_DIST): Rename linux/syscallent.h to linux/i386/syscallent.h

	* desc.c (sys_epoll_pwait): Fix output formatting bug.

	* desc.c (decode_select): Fix potential stack buffer overflow.

2010-03-31  Dmitry V. Levin  <ldv@altlinux.org>

	Fix msgsnd indirect ipccall decoding.
	This regression was introduced by commit v4.5.18-136-g783f5bc.
	* ipc.c (tprint_msgsnd): Add and use "flags" argument.
	(sys_msgsnd): Pass "flags" argument to tprint_msgsnd().
	Patch by Anton Blanchard.

2010-03-23  Mark Wielaard  <mjw@redhat.com>

	Hook up inotify_init1 open mode flags printer.
	* file.c [LINUX] (sys_inotify_init1): New function.
	* linux/syscall.h: Declare new sys_inotify_init1 handler.
	* linux/bfin/syscallent.h: Hook up new handler.
	* linux/hppa/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

2010-03-09  Andreas Schwab  <schwab@redhat.com>

	Avoid spurious error when checking for linux/netlink.h.
	* configure.ac: Include <asm/types.h> when checking for
	linux/netlink.h.

2010-02-23  Andreas Schwab  <schwab@linux-m68k.org>

	Fix reporting signal mask by sigreturn on powerpc.
	* signal.c (sys_sigreturn) [POWERPC]: Skip dummy stack frame when
	locating signal context.

2010-02-09  David Daney  <ddaney@caviumnetworks.com>

	Fix MIPS N32/N64 compile error.
	* syscall.c [LINUX_MIPSN32 || LINUX_MIPSN64] (syscall_enter): Pass
	tcp->pid to ptrace().

2010-02-05  Chris Metcalf  <cmetcalf@tilera.com>

	Add support for the TILE architecture.
	* configure.ac: Add TILE to the list of supported architectures.
	* defs.h: Define TCB_WAITEXECVE for TILE.
	* linux/tile/syscallent.h: New file.
	* Makefile.am (EXTRA_DIST): Add linux/tile/syscallent.h
	* process.c (change_syscall, struct_user_offsets): Add TILE support.
	* syscall.c (get_scno, get_error, syscall_enter): Likewise.
	* mem.c (mmap_flags, print_mmap): Add MAP_CACHE_xxx TILE extensions
	support.
	* signal.c (sigact_flags): Add SA_NOPTRACE.
	(sys_sigreturn): Add TILE support.

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

	Remove dead code.
	* defs.h (tv_tv): Remove.
	* net.c (sys_xsetsockaddr): Remove commented out dead code.
	* process.c (setarg, sys_execv, sys_execve, struct_user_offsets):
	Likewise.
	* signal.c (sys_sigsuspend): Likewise.
	* strace.c (reaper, trace): Likewise.
	* stream.c (internal_stream_ioctl): Likewise.
	* syscall.c (trace_syscall): Likewise.
	* term.c (term_ioctl): Likewise.
	* util.c (tv_tv, umoven, uload, getpc, fixvfork, setbpt, clearbpt):
	Likewise.

	Merge Linux internal_clone() into internal_fork()
	* defs.h (internal_clone): Remove.
	* process.c (internal_clone): Merge into internal_fork().
	(internal_fork) [!LINUX]: Remove dead code.
	* syscall.c (internal_syscall): Replace internal_clone() with
	internal_fork().

	* Makefile.am (INCLUDES): Remove redundant search directories.

2010-02-04  Frederik Schüler  <fs@debian.org>

	Update debian/* files.
	* debian/control: add sparc64 to the architectures list.
	This closes Debian bug #560062
	* Backport commit f0df31e71a58c6e79ba77c1a9d84b2f38d44bec7 to fix FTBFS.
	This closes Debian bug #560516
	* debian/control: Update standards-version to 3.8.3.
	* debian/control: Lower package priority to optional, matching
	the archive override.
	* debian/control: add ${misc:Depends} to Depends: lines where
	appropriate.
	* debian/watch: new file, allows automatic tracking of new
	upstream versions.
	* debian/source/format: new file, adapt to debian source format "quilt"
	* debian/rules: indentation cleanups; use dh_testroot and dh_prep
	in clean target.

2010-01-25  Andreas Schwab  <schwab@redhat.com>

	Fix spurious failure of AC_STAT64 test.
	* acinclude.m4 (AC_STAT64): Include <sys/types.h> first.

2010-01-12  Andreas Schwab  <schwab@redhat.com>

	Don't kill the process when detaching.
	* strace.c (detach): Call clearbpt when TCB_BPTSET is set.

2009-12-25  Dmitry V. Levin  <ldv@altlinux.org>

	Decode fifth argument of mremap syscall.
	* mem.c (sys_mremap): Decode fifth argument.
	* linux/*/syscallent.h: Update the number of mremap syscall arguments.

2009-12-24  Chris Metcalf  <cmetcalf@tilera.com>

	* mem.c (sys_mbind): Display first argument in hex.

	* mem.c (mremap_flags): Add MREMAP_FIXED.

2009-11-16  Mike Frysinger  <vapier@gentoo.org>

	Move i386-specific files out of common linux dir.
	* linux/syscallent.h: Moved to ...
	* linux/i386/syscallent.h: ... here.
	* linux/ia64/syscallent.h: Update i386 syscallent.h include.
	* linux/sparc/gen.pl: Likewise.
	* linux/x86_64/syscallent1.h: Likewise.

2009-11-16  Andreas Schwab  <schwab@redhat.com>

	Remove support for pre-C89.
	* defs.h: Remove references to __STDC__ and P macros.
	* strace.c: Likewise.

2009-11-13  Dmitry V. Levin  <ldv@altlinux.org>

	Decode more SOL_PACKET socket options.
	* net.c (sockpacketoptions): Add more PACKET_* entries.
	(sys_getsockopt): Decode PACKET_STATISTICS.
	(printsockopt): Decode PACKET_RX_RING and PACKET_TX_RING.
	Patch by Gabor Gombas.

2009-11-11  Andreas Schwab  <schwab@redhat.com>

	Ignore errors if a thread is killed.
	* util.c (clearbpt): Ignore ESRCH error.

2009-11-06  Bernhard Reutner-Fischer  <rep.dot.nop@gmail.com>

	Fix handling of Linux systems without struct statfs64.
	* acinclude.m4 (AC_STATFS64): New macro to check for struct statfs64.
	* configure.ac: Call AC_STATFS64.
	* file.c (printstatfs64, sys_statfs64, sys_fstatfs64): Compile only
	  if struct statfs64 is available.

2009-11-06  Dmitry V. Levin  <ldv@altlinux.org>

	Fix getsockopt decoding on architectures where sizeof(long) > sizeof(int)
	* net.c (sys_getsockopt): Optimize output a bit.
	Decode integer argument using printnum_int(), patch by Gabor Gombas.

	Check umove() return code.
	* bjm.c (sys_query_module): Print input parameters when entering
	syscall.  Fix handling of syscall error.  Handle unlikely umove()
	failures.
	* ipc.c (tprint_msgrcv): New function.  Move part of msgrcv parser code
	here, add check umove() return code.
	(sys_msgsnd): Print msqid parameter as int instead of long.
	(sys_msgrcv): Likewise.  Use tprint_msgrcv().
	* process.c (print_affinitylist): Check umove() return code.
	* sock.c (sock_ioctl): Handle unlikely umove() failure in the
	SIOCGIFCONF parser.

	Fix check for linux/netlink.h on Linux 2.6.32-rc5+
	* configure.ac (AC_CHECK_HEADERS): In check for linux/netlink.h, include
	sys/socket.h instead of linux/socket.h beforehand.

2009-11-04  Andreas Schwab  <schwab@redhat.com>

	Decode fallocate on PowerPC.
	* linux/powerpc/syscallent.h: Decode fallocate.

	Factor out printing of 64bit syscall argument.
	* defs.h (ALIGN64): Remove.
	(printllval): Declare.
	* util.c (printllval): Define.
	* file.c (sys_readahead): Use printllval.
	(sys_lseek64): Likewise.
	(sys_truncate64): Likewise.
	(sys_ftruncate64): Likewise.
	(sys_fadvise64): Likewise.
	(sys_fadvise64_64): Likewise.
	(sys_fallocate): Likewise.
	* io.c (sys_pread): Likewise.
	(sys_pwrite): Likewise.
	(sys_pread64): Likewise.
	(sys_pwrite64): Likewise.
	* mem.c (sys_mmap64): Likewise.

2009-11-03  Andreas Schwab  <schwab@redhat.com>

	Correct decoding of readahead and fadvice64(_64) on PowerPC.
	* file.c (sys_readahead): Align 64bit argument.  Handle PowerPC64
	like other 64bit architectures.
	(sys_fadvise64): Likewise.
	(sys_fadvise64_64): Handle PowerPC like ARM.
	* linux/powerpc/syscallent.h (sys_readahead): Account for 64bit
	argument alignment on PowerPC32.

2009-10-27  Andreas Schwab  <schwab@redhat.com>

	Maintain separate print column for each process.
	* defs.h (struct tcp): Add curcol.
	* strace.c: (alloc_tcb): Initialize it.
	(trace): Use curcol from current process and save it before
	continuing.
	(tprintf): Don't modify curcol on output error.

2009-10-21  Roland McGrath  <roland@redhat.com>

	* strace.spec: 4.5.19-1 release.

2009-10-21  Dmitry V. Levin  <ldv@altlinux.org>

	* file.c (printstat64): Cleanup trailing whitespace.

2009-10-16  Andreas Schwab  <schwab@redhat.com>

	Fix decoding of newfstatat syscall on x86-64.
	* file.c (printstat64) [LINUX && X68_64]: If tracing a 64-bit
	process redirect to printstat.
	Fixes RH#529316 "Field values shown for "newfstatat" system
	call are incorrect"

2009-10-12  Dmitry V. Levin  <ldv@altlinux.org>

	* configure.ac (AC_CHECK_HEADERS): Remove asm/reg.h.

2009-10-12  Mike Frysinger  <vapier@gentoo.org>

	sparc/linux: Rewrite to use asm/ptrace.h.
	The current sparc/linux code uses asm/reg.h, but recent Linux kernels
	dropped that header completely.  So switch over to the ptrace headers
	as those should stick around indefinitely as part of the ABI.

	* defs.h [LINUXSPARC] (U_REG_G1, U_REG_O0, U_REG_O1): Define.
	* process.c: Drop asm/regs.h include.
	[SPARC || SPARC64] (change_syscall): Change struct regs to struct pt_regs.
	* signal.c: Drop asm/regs.h include.
	(m_siginfo_t): Unify [SPARC || SPARC64] and [MIPS].
	[SPARC || SPARC64] (sys_sigreturn): Change struct regs to struct pt_regs.
	* syscall.c: Drop asm/regs.h include.
	[SPARC || SPARC64] (internal_syscall, get_scno, get_error, force_result,
	syscall_enter): Change struct regs to struct pt_regs.
	* util.c: Drop asm/regs.h include.
	(_hack_syscall5, _ptrace): Delete.
	[SPARC || SPARC64] (getpc, printcall, arg_setup_state): Change
	struct regs to struct pt_regs.

2009-10-11  Roland McGrath  <roland@redhat.com>

	* make-dist: Clean up.

	* configure.ac: Use AC_CONFIG_AUX_DIR([.]).

2009-10-09  Dmitry V. Levin  <ldv@altlinux.org>

	* make-dist: New script for preparing release tarballs.

	* git-set-file-times: Import from rsync.

	* Makefile.am [MAINTAINER_MODE]: Define and export TAR_OPTIONS.

2009-10-08  Dmitry V. Levin  <ldv@altlinux.org>

	Enhance msgsnd() parser.
	* ipc.c (tprint_msgsnd): New function.  Move msgsnd parser code here,
	add check for umove() return code.
	(sys_msgsnd): Use tprint_msgsnd().

	* NEWS: Update for 4.5.19 release.

	Enhance semop()/semtimedop() sembuf parser.
	* ipc.c (tprint_sembuf): New function. Move sembuf parser code here,
	add abbrev() support.
	(sys_semop, sys_semtimedop): Use tprint_sembuf().

2009-10-08  Jakub Bogusz  <qboosh@pld-linux.org>

	Add pretty printing of sembuf argument to semop() and semtimedop()
	* ipc.c (semop_flags): New xlat structure.
	(sys_semop, sys_semtimedop): Add pretty printing of sembuf argument.

2009-10-08  Mike Frysinger  <vapier@gentoo.org>

	Add support for Linux/no-mmu with vfork.
	* configure.ac (AC_CHECK_FUNCS): Add fork.
	* strace.c (strace_vforked): Define.
	(startup_child): Do not raise SIGSTOP if vforked.
	(trace): Skip first exec when starting up after vforked.
	* syscall.c [BFIN] (get_scno): Drop waitexec checks.

	Avoid malloc(0) in getdents parsers.
	On end of directory, getdents returns 0.  This return value is used to
	then try and do malloc(0), but on some systems this will always return
	NULL.  Since the code won't read the pointer in question if len is 0,
	then don't bother calling malloc(0) and set the pointer to NULL ourself.
	* file.c (sys_getdents, sys_getdents64): Avoid malloc(0) call.

2009-10-07  Mike Frysinger  <vapier@gentoo.org>

	Add sys_nanosleep() prototype for sparc.
	* linux/sparc/syscall.h (sys_nanosleep): New prototype.
	Reported by Frederik Schüler.

	Silence compiler warnings about implicit cast from pointer to integer.
	* util.c (do_ptrace): Cast ptrace() 4th arg to long.
	(ptrace_restart): Drop void* cast on ptrace() 4th arg.

	Ignore .gdb files from FLAT toolchains.
	* .gitignore: Add /*.gdb.

	* configure.ac (AC_CHECK_FUNCS): Sort and expand.

	Blackfin: Update ioctl/syscall lists.
	* linux/bfin/ioctlent.h: Sync list with latest kernel sources.
	* linux/bfin/syscallent.h: Likewise.

	ioctlsort: Check ppc hosts too.
	* linux/ioctlsort.c: Check for __powerpc__.

2009-10-07  Andreas Schwab  <schwab@redhat.com>

	Fix build on ia64.
	* linux/ia64/syscallent.h: Update for addition of accept4 syscall
	in ../syscallent.h.

2009-10-07  Roland McGrath  <roland@redhat.com>

	* strace.spec (%doc): Add ChangeLog-CVS.

	* Makefile.am (srpm): New phony target.

	* Makefile.am (EXTRA_DIST): Add ChangeLog.
	($(srcdir)/ChangeLog): New target, replaces gen-changelog phony target.
	Put it inside [MAINTAINER_MODE].

2009-10-06  Dmitry V. Levin  <ldv@altlinux.org>

	* NEWS: Update for 4.5.19 release.

2009-10-05  Frederik Schüler  <fs@debian.org>

	Prepare debian/* files for release.
	* debian/rules: Do not ship ChangeLog anymore.
	* debian/control: Update to Debian standards version 3.8.1, and remove
	Roland from the Maintainers list.  This closes Debian bug #521458.
	* debian/changelog: Document changes and prepare for release.

2009-10-05  Dmitry V. Levin  <ldv@altlinux.org>

	* defs.h [HPPA]: Lower MAX_ARGS from 32 to 6.

	* ipc.c [LINUX] (sys_shmat): HPPA does not use an IPC multiplexer.
	Based on patch from Carlos O'Donell.

2009-10-05  Carlos O'Donell  <carlos@systemhalted.org>

	* linux/hppa/syscallent.h: Update syscalls.
	Based on work by Kyle McMartin and Helge Deller.

	Fix SA_HANDLER function pointer comparisons for hppa.
	* signal.c (sys_sigaction): Cast SA_HANDLER function pointers to long.
	(sys_rt_sigaction): Likewise.

2009-10-05  Edgar E. Iglesias  <edgar.iglesias@gmail.com>

	CRIS: Correct first argument to upeek()
	This complements commit ea0e6e80260d2b1b7ad40282012b0e47869bcddf.
	* syscall.c [CRISV10 || CRISV32] (syscall_fixup, syscall_enter): Pass
	tcp pointer instead of pid to upeek().
	* util.c [CRISV10 || CRISV32] (printcall): Likewise.

2009-10-05  Dmitry V. Levin  <ldv@altlinux.org>

	* signal.c (do_signalfd): Fix typo in output format.

2009-09-21  Dmitry V. Levin  <ldv@altlinux.org>

	* Makefile.am (gen_changelog_start_date): Fix date.

2009-09-19  Dmitry V. Levin  <ldv@altlinux.org>

	Prepare for 4.5.19 release.
	* NEWS: Update for 4.5.19 release.
	* configure.ac: Version 4.5.19.
	* debian/changelog: 4.5.19-1.
	* strace.spec: 4.5.19-1.

	Update debian/* to 4.5.18-1.
	* debian/changelog: Update to 4.5.18-1.
	* debian/compat: Set compatibility level to 7.
	* debian/control (Build-Depends): Update debhelper requirement.
	(strace, strace64): Add Section and Priority tags.

2009-09-19  Kirill A. Shutemov  <kirill@shutemov.name>

	Fix fadvise64 decoding on ARM.
	* file.c (sys_fadvise64_64) [ARM]: Fix argument ordering.

2009-09-18  Dmitry V. Levin  <ldv@altlinux.org>

	Fix follow fork/vfork on Linux ARM OABI.
	__NR_SYSCALL_BASE eis 0 for EABI and is 0x900000 for OABI.
	* process (change_syscall) [LINUX && ARM]: Mask off the high order bits
	when changing syscall.

	Reviewed-by: Kirill A. Shutemov <kirill@shutemov.name>

2009-09-18  Mike Frysinger  <vapier@gentoo.org>

	Mark shell scripts as executable.

	Ignore ioctlsort helper program.
	* .gitignore: Add ioctlsort.

	linux/errno: Add ERFKILL.
	* linux/errnoent.h: Change ERRNO_132 to ERFKILL according to errno 132
	definition introduced in Linux 2.6.31.

2009-09-01  Paolo Bonzini  <pbonzini@redhat.com>

	Add accept4 socketcall.
	This second patch in the series adds support for accept4 as a socketcall
	sub-call.  Besides the need to renumber all system calls, this poses
	no problem.
	Tested on i686.

	* linux/arm/syscallent.h: Add accept4 socketcall.
	* linux/m68k/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/syscallent.h: Likewise.

	* linux/sparc/syscall.h (SYS_sub_accept4): Declare.
	(SYS_socket_nsubcalls): Update.
	* linux/syscall.h: Likewise.

	Replace x86-64 paccept with accept4.
	This patch changes the paccept syscall to accept4 for x86-64, since
	the former was dropped in Linux kernel commit v2.6.27-rc7-14-g2d4c826.
	At the same time, it adds support for pretty printing its arguments.

	* linux/x86_64/syscallent.h: Replace paccept with accept4,
	hook in sys_accept4.
	* net.c (sys_accept): Leave a small stub calling the new...
	(do_accept): ... function, which also adds a flags_arg argument.
	(sys_accept4): New.

2009-08-28  Andreas Schwab  <schwab@redhat.com>

	Zero-extend 32-bit addresses when printing argv array.
	(printargv): Zero-extend 32-bit addresses.
	Fixes RH#519480 "64-bit strace is lazy on execve of 32-bit
	process".

2009-08-12  Andreas Schwab  <schwab@redhat.com>

	Add more futex decoding.
	* process.c (FUTEX_WAIT_REQUEUE_PI, FUTEX_CMP_REQUEUE_PI)
	(FUTEX_PRIVATE_FLAG, FUTEX_CLOCK_REALTIME): Define.
	(futexops): Add entries for them.
	(sys_futex): Decode FUTEX_CMP_REQUEUE_PI and
	FUTEX_WAIT_REQUEUE_PI.

2009-07-08  Dmitry V. Levin  <ldv@altlinux.org>

	Generate ChangeLog from git log.
	* .gitignore: Add ChangeLog
	* ChangeLog: Rename to ChangeLog-CVS.
	* Makefile.am (gen-changelog): New rule.
	(dist-hook): Depend on it.
	(EXTRA_DIST): Add ChangeLog-CVS.
	* README-hacking: Describe changes.
	* gitlog-to-changelog: Import from gnulib.


See ChangeLog-CVS for older changes.