Denys Vlasenko [Thu, 20 Jun 2013 10:10:21 +0000 (12:10 +0200)]
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)..
Denys Vlasenko [Wed, 19 Jun 2013 13:31:39 +0000 (15:31 +0200)]
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.
Dmitry V. Levin [Wed, 19 Jun 2013 14:57:05 +0000 (14:57 +0000)]
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.
Dmitry V. Levin [Tue, 28 May 2013 20:27:10 +0000 (20:27 +0000)]
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.
Chris Metcalf [Tue, 21 May 2013 20:40:50 +0000 (16:40 -0400)]
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.
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com> Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Dmitry V. Levin [Tue, 14 May 2013 22:35:46 +0000 (22:35 +0000)]
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.
Dmitry V. Levin [Mon, 13 May 2013 18:43:28 +0000 (18:43 +0000)]
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.
Denys Vlasenko [Tue, 14 May 2013 14:07:46 +0000 (16:07 +0200)]
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.
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.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Dmitry V. Levin [Wed, 8 May 2013 17:03:24 +0000 (17:03 +0000)]
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.
Mike Frysinger [Tue, 7 May 2013 14:50:20 +0000 (10:50 -0400)]
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
Dmitry V. Levin [Tue, 7 May 2013 09:35:18 +0000 (09:35 +0000)]
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.
Dmitry V. Levin [Tue, 7 May 2013 09:21:07 +0000 (09:21 +0000)]
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.
Dmitry V. Levin [Tue, 7 May 2013 08:47:46 +0000 (08:47 +0000)]
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.
Dmitry V. Levin [Tue, 7 May 2013 02:27:50 +0000 (02:27 +0000)]
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.
Dmitry V. Levin [Tue, 7 May 2013 01:25:11 +0000 (01:25 +0000)]
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.
Chris Metcalf [Mon, 6 May 2013 15:21:13 +0000 (11:21 -0400)]
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.
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Mike Frysinger [Sun, 5 May 2013 22:30:21 +0000 (18:30 -0400)]
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.
Mike Frysinger [Sun, 5 May 2013 05:21:54 +0000 (01:21 -0400)]
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.
Mike Frysinger [Thu, 2 May 2013 03:35:30 +0000 (23:35 -0400)]
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.
Mike Frysinger [Thu, 2 May 2013 19:44:42 +0000 (15:44 -0400)]
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.
Mike Frysinger [Thu, 2 May 2013 19:43:45 +0000 (15:43 -0400)]
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
Dmitry V. Levin [Wed, 1 May 2013 16:37:08 +0000 (16:37 +0000)]
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.
James Hogan [Wed, 1 May 2013 12:16:49 +0000 (13:16 +0100)]
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.
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Mike Frysinger [Wed, 1 May 2013 03:48:07 +0000 (23:48 -0400)]
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)
Mike Frysinger [Wed, 1 May 2013 02:41:11 +0000 (22:41 -0400)]
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.