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.
Copyright 2K16 - 2K18 Indonesian Hacker Rulez