]> granicus.if.org Git - strace/log
strace
11 years agomips: split syscallent.h
Dmitry V. Levin [Tue, 7 May 2013 02:46:46 +0000 (02:46 +0000)]
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.

11 years agoreadahead: fix number of syscall arguments
Dmitry V. Levin [Tue, 7 May 2013 01:25:11 +0000 (01:25 +0000)]
readahead: fix number of syscall arguments

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

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

11 years agolinux/syscall.h: make subcall decoding configuration more readable
Dmitry V. Levin [Mon, 6 May 2013 23:34:03 +0000 (23:34 +0000)]
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.

11 years agoxtensa: disable socket and ipc subcall support
Chris Zankel [Mon, 6 May 2013 22:21:38 +0000 (15:21 -0700)]
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.

Signed-off-by: Chris Zankel <chris@zankel.net>
11 years agoFix syscall flags
Dmitry V. Levin [Mon, 6 May 2013 01:09:15 +0000 (01:09 +0000)]
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.

11 years agotests/stat: enhance regexps
Dmitry V. Levin [Mon, 6 May 2013 18:50:48 +0000 (18:50 +0000)]
tests/stat: enhance regexps

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

11 years agotests/stat: support fstatat syscall for stat()
Chris Metcalf [Mon, 6 May 2013 15:21:13 +0000 (11:21 -0400)]
tests/stat: support fstatat syscall for stat()

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

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

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

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
11 years agoARM OABI: fix 64-bit arguments decoding
Dmitry V. Levin [Mon, 6 May 2013 18:23:01 +0000 (18:23 +0000)]
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.

11 years agoprintllval: fix 64bit unpacking on mips/o32 and xtensa
Mike Frysinger [Sun, 5 May 2013 22:30:21 +0000 (18:30 -0400)]
printllval: fix 64bit unpacking on mips/o32 and xtensa

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

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

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

11 years agotile: disable socket and ipc subcall support
Chris Metcalf [Mon, 6 May 2013 15:41:29 +0000 (11:41 -0400)]
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.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
11 years agoBlackfin: disable socketcall and ipc subcall support
Mike Frysinger [Mon, 6 May 2013 05:49:41 +0000 (01:49 -0400)]
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.

11 years agos390: fix # of args truncate64/ftruncate64 takes
Mike Frysinger [Sun, 5 May 2013 21:03:23 +0000 (17:03 -0400)]
s390: fix # of args truncate64/ftruncate64 takes

* linux/s390/syscallent.h: Change nargs to 3 for truncate64/ftruncate64.

11 years agomtd: clamp ubi name strings
Mike Frysinger [Sun, 5 May 2013 05:21:54 +0000 (01:21 -0400)]
mtd: clamp ubi name strings

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

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

11 years agoprintxval: support more architectures
Dmitry V. Levin [Sat, 4 May 2013 19:51:57 +0000 (19:51 +0000)]
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).

11 years agoFix building for sparc64 targets
Mike Frysinger [Sat, 4 May 2013 17:25:22 +0000 (13:25 -0400)]
Fix building for sparc64 targets

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

11 years agoFix building for mips n64 targets
Mike Frysinger [Sat, 4 May 2013 05:42:54 +0000 (01:42 -0400)]
Fix building for mips n64 targets

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

11 years agohppa: fix stat64 and fstat64 decoding
Dmitry V. Levin [Fri, 3 May 2013 22:10:41 +0000 (22:10 +0000)]
hppa: fix stat64 and fstat64 decoding

* file.c [HPPA]: Do not redefine stat64 to hpux_stat64.

11 years agoarm, aarch64, ppc: fix printllval-based decoders
Dmitry V. Levin [Fri, 3 May 2013 22:27:45 +0000 (22:27 +0000)]
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.

11 years agoDecode mtd/ubi ioctls
Mike Frysinger [Thu, 2 May 2013 03:35:30 +0000 (23:35 -0400)]
Decode mtd/ubi ioctls

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

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

11 years agotest: add mtd/ubi test helpers
Mike Frysinger [Thu, 2 May 2013 19:44:42 +0000 (15:44 -0400)]
test: add mtd/ubi test helpers

I used these to develop the mtd/ubi ioctl decoders.

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

11 years agotest: include headers for used funcs
Mike Frysinger [Thu, 2 May 2013 19:43:45 +0000 (15:43 -0400)]
test: include headers for used funcs

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

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

11 years agoia64: fix compilation warnings introduced by commit v4.7-174-g44f0ed1
Dmitry V. Levin [Thu, 2 May 2013 22:14:21 +0000 (22:14 +0000)]
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>
11 years agotests: stat: fix clean up of sample file
Mike Frysinger [Thu, 2 May 2013 19:35:40 +0000 (15:35 -0400)]
tests: stat: fix clean up of sample file

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

11 years agoIgnore more files
Mike Frysinger [Thu, 2 May 2013 19:35:32 +0000 (15:35 -0400)]
Ignore more files

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

11 years agox32: fix decoding of i386 truncate and ftruncate syscalls
Dmitry V. Levin [Thu, 2 May 2013 08:46:30 +0000 (08:46 +0000)]
x32: fix decoding of i386 truncate and ftruncate syscalls

* linux/x32/syscallent1.h: Remove sys_*truncate64 redirections.

11 years agox32: fix printllval-based decoders of i386 syscalls
Dmitry V. Levin [Thu, 2 May 2013 08:41:27 +0000 (08:41 +0000)]
x32: fix printllval-based decoders of i386 syscalls

* util.c (printllval) [X32]: Handle i386 personality.

11 years agotests: add basic test for ftruncate, lseek and stat family syscalls
Dmitry V. Levin [Thu, 2 May 2013 00:44:57 +0000 (00:44 +0000)]
tests: add basic test for ftruncate, lseek and stat family syscalls

* tests/stat: New test.
* tests/Makefile.am (TESTS): Add stat.

11 years agox32: fix build regressions introduced by commit v4.7-96-g8435d67
Dmitry V. Levin [Wed, 1 May 2013 16:37:08 +0000 (16:37 +0000)]
x32: fix build regressions introduced by commit v4.7-96-g8435d67

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

11 years agoAlias sys_*lstat* syscall printing functions
Dmitry V. Levin [Wed, 1 May 2013 15:56:22 +0000 (15:56 +0000)]
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.

11 years agox86_64: decode __old_kernel_stat based syscalls
Dmitry V. Levin [Wed, 1 May 2013 15:36:13 +0000 (15:36 +0000)]
x86_64: decode __old_kernel_stat based syscalls

* linux/x86_64/syscallent1.h: Remove sys_old*stat redirections.

11 years agox32: fix decoding of __old_kernel_stat based syscalls
Dmitry V. Levin [Wed, 1 May 2013 15:14:25 +0000 (15:14 +0000)]
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.

11 years agotest/threaded_execve: fix on metag
James Hogan [Wed, 1 May 2013 12:16:50 +0000 (13:16 +0100)]
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.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
11 years agotest/skodic: make a bit more portable
James Hogan [Wed, 1 May 2013 12:16:49 +0000 (13:16 +0100)]
test/skodic: make a bit more portable

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

Signed-off-by: James Hogan <james.hogan@imgtec.com>
11 years agoprintllval: handle s390x
Mike Frysinger [Wed, 1 May 2013 03:48:07 +0000 (23:48 -0400)]
printllval: handle s390x

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

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

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
11 years agoStop using old AM_CONFIG_HEADER macro
Mike Frysinger [Wed, 1 May 2013 02:41:11 +0000 (22:41 -0400)]
Stop using old AM_CONFIG_HEADER macro

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

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

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
11 years agobuild: introduce git-version-gen
Dmitry V. Levin [Tue, 30 Apr 2013 23:52:12 +0000 (23:52 +0000)]
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.

11 years agoMakefile.am: sort long lists to ease maintenance
Dmitry V. Levin [Tue, 30 Apr 2013 23:34:51 +0000 (23:34 +0000)]
Makefile.am: sort long lists to ease maintenance

* Makefile.am (strace_SOURCES, EXTRA_DIST): Sort, place one list element
per line.

11 years agobuild: fix "make dist" regression introduced by commit v4.7-105-g7270de5
Dmitry V. Levin [Tue, 30 Apr 2013 23:12:00 +0000 (23:12 +0000)]
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.

11 years agobuild: fix "make dist" regression introduced by commit v4.7-29-g17e3860
Dmitry V. Levin [Tue, 30 Apr 2013 23:18:22 +0000 (23:18 +0000)]
build: fix "make dist" regression introduced by commit v4.7-29-g17e3860

* Makefile.am (EXTRA_DIST): Add linux/ioctlent-filter.awk.

11 years agoBlackfin: tweak sram_alloc syscall decode
Mike Frysinger [Wed, 3 Apr 2013 04:19:31 +0000 (00:19 -0400)]
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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
11 years agoPrint io_submit() offsets in decimal
Zev Weiss [Sun, 31 Mar 2013 00:19:50 +0000 (19:19 -0500)]
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.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
11 years agoFix building outside source directory
Andreas Schwab [Sat, 30 Mar 2013 21:59:36 +0000 (22:59 +0100)]
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.

Signed-off-by: Andreas Schwab <schwab@suse.de>
11 years agoAArch64: Fix printing of long long value
Andreas Schwab [Sat, 30 Mar 2013 21:31:56 +0000 (22:31 +0100)]
AArch64: Fix printing of long long value

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

Signed-off-by: Andreas Schwab <schwab@suse.de>
11 years agoUpdate PR_* constants
Dmitry V. Levin [Wed, 27 Mar 2013 14:57:39 +0000 (14:57 +0000)]
Update PR_* constants

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

11 years agoAdd support for the XTENSA architecture
Chris Zankel [Mon, 25 Mar 2013 17:22:07 +0000 (10:22 -0700)]
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.

Signed-off-by: Chris Zankel <chris@zankel.net>
11 years agoAdd example script which builds static (possibly cross-compiled) strace
Denys Vlasenko [Fri, 22 Mar 2013 14:59:01 +0000 (15:59 +0100)]
Add example script which builds static (possibly cross-compiled) strace

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoUse 64-bit versions of stat, readdir and setrlimit functions when available
Dmitry V. Levin [Wed, 20 Mar 2013 21:40:15 +0000 (21:40 +0000)]
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.

11 years agoDo not use struct dirent in readdir decoding
Dmitry V. Levin [Wed, 20 Mar 2013 12:45:05 +0000 (12:45 +0000)]
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.

11 years agoDo not use off_t in sendfile decoding
Dmitry V. Levin [Wed, 20 Mar 2013 09:48:44 +0000 (09:48 +0000)]
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.

11 years agoFix build with older versions of libaio.h
Dmitry V. Levin [Mon, 18 Mar 2013 23:28:29 +0000 (23:28 +0000)]
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.

11 years agoFix io_submit decoding
Dmitry V. Levin [Mon, 18 Mar 2013 22:58:28 +0000 (22:58 +0000)]
Fix io_submit decoding

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

11 years agotests: relax check_prog to allow timeout command provided by busybox
Maxin B. John [Mon, 18 Mar 2013 10:35:06 +0000 (11:35 +0100)]
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.

Signed-off-by: Maxin B. John <maxin.john@enea.com>
11 years agoReorganize get_regs code, hopefully without functional changes
Dmitry V. Levin [Mon, 18 Mar 2013 10:17:14 +0000 (10:17 +0000)]
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.

11 years agoarm, i386: use PTRACE_GETREGSET if available
Dmitry V. Levin [Sun, 17 Mar 2013 23:48:45 +0000 (23:48 +0000)]
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.

11 years agoInclude <sys/uio.h> and <elf.h> on all architectures
Dmitry V. Levin [Mon, 18 Mar 2013 00:59:27 +0000 (00:59 +0000)]
Include <sys/uio.h> and <elf.h> on all architectures

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

11 years agox86-64: enhance PTRACE_GETREGSET test
Dmitry V. Levin [Sun, 17 Mar 2013 23:18:35 +0000 (23:18 +0000)]
x86-64: enhance PTRACE_GETREGSET test

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

11 years agox32: use PTRACE_GETREGSET unconditionally
Dmitry V. Levin [Sun, 17 Mar 2013 23:15:18 +0000 (23:15 +0000)]
x32: use PTRACE_GETREGSET unconditionally

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

11 years agox86-64, x32: do not include linux/ptrace.h unnecessarily
Dmitry V. Levin [Mon, 18 Mar 2013 00:27:33 +0000 (00:27 +0000)]
x86-64, x32: do not include linux/ptrace.h unnecessarily

* syscall.c [X86_64 || X32]: Stop including linux/ptrace.h.

11 years agoi386, tile, x32: do not redefine ptrace prototype
Dmitry V. Levin [Mon, 18 Mar 2013 00:19:06 +0000 (00:19 +0000)]
i386, tile, x32: do not redefine ptrace prototype

* defs.h [I386 || TILE || X32]: Use ptrace prototype from sys/ptrace.h.

11 years agoptrace: decode note segment descriptor types
Dmitry V. Levin [Mon, 18 Mar 2013 00:52:29 +0000 (00:52 +0000)]
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.

11 years agoUpdate MADV_* constants
Dmitry V. Levin [Thu, 14 Mar 2013 18:55:26 +0000 (18:55 +0000)]
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>
11 years agoTweaks for -c: fixed setitimer/getitimer hack; optimized call_summary_pers()
Denys Vlasenko [Thu, 7 Mar 2013 11:27:40 +0000 (12:27 +0100)]
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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoOpen-code isprint(c) and isspace(c)
Denys Vlasenko [Wed, 6 Mar 2013 22:44:23 +0000 (23:44 +0100)]
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).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoMakefile: add commented-out tweak to generate link map
Denys Vlasenko [Wed, 6 Mar 2013 17:59:09 +0000 (18:59 +0100)]
Makefile: add commented-out tweak to generate link map

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoStop using a large static buffer in getfdpath
Denys Vlasenko [Wed, 6 Mar 2013 17:24:34 +0000 (18:24 +0100)]
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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix wrongly indented closing curly brace. No code changes
Denys Vlasenko [Tue, 5 Mar 2013 16:46:19 +0000 (17:46 +0100)]
Fix wrongly indented closing curly brace. No code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agostrace_vfprintf: if malloc fails, exit gracefully
Denys Vlasenko [Tue, 5 Mar 2013 16:29:18 +0000 (17:29 +0100)]
strace_vfprintf: if malloc fails, exit gracefully

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoUse sysconf(_SC_PAGESIZE) instead of hardcoded PAGE_SHIFT
Dmitry V. Levin [Tue, 5 Mar 2013 14:58:24 +0000 (14:58 +0000)]
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.

11 years agoEmit better message for ERESTARTNOHAND return
Denys Vlasenko [Tue, 5 Mar 2013 15:56:35 +0000 (16:56 +0100)]
Emit better message for ERESTARTNOHAND return

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoDisable STREAMS syscalls for non-SPARC
Denys Vlasenko [Tue, 5 Mar 2013 15:50:12 +0000 (16:50 +0100)]
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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix printstrbufarg's address argument to be long, not int
Denys Vlasenko [Tue, 5 Mar 2013 15:17:46 +0000 (16:17 +0100)]
Fix printstrbufarg's address argument to be long, not int

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRemove variable tracing_paths and check in pathtrace_match
Denys Vlasenko [Tue, 5 Mar 2013 15:01:53 +0000 (16:01 +0100)]
Remove variable tracing_paths and check in pathtrace_match

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoUse dynamically-sized selected[] array for -P PATH
Denys Vlasenko [Tue, 5 Mar 2013 14:46:34 +0000 (15:46 +0100)]
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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agometag,or1k: whitesace style fix. no code changes
Denys Vlasenko [Tue, 5 Mar 2013 13:03:07 +0000 (14:03 +0100)]
metag,or1k: whitesace style fix. no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoAssorted fixes to syscallent.h
Denys Vlasenko [Tue, 5 Mar 2013 12:59:45 +0000 (13:59 +0100)]
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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoAdd support for Imagination Technologies Meta
James Hogan [Fri, 22 Feb 2013 14:44:10 +0000 (14:44 +0000)]
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.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Christian Svensson <blue@cmd.nu>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoumovestr: speed up check for NUL byte in the fetched word
Denys Vlasenko [Fri, 1 Mar 2013 17:52:59 +0000 (18:52 +0100)]
umovestr: speed up check for NUL byte in the fetched word

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix trace=set regression introduced by commit v4.7-111-g9cbc15b
Dmitry V. Levin [Fri, 1 Mar 2013 15:50:22 +0000 (15:50 +0000)]
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.

11 years agotile: handle printllval like x86_64 or powerpc64
Chris Metcalf [Fri, 1 Mar 2013 09:41:02 +0000 (10:41 +0100)]
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.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoMake -b take SYSCALL param, document it in --help and in manpage.
Denys Vlasenko [Wed, 27 Feb 2013 11:15:19 +0000 (12:15 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoCleanup umoven and umovestr
Dmitry V. Levin [Tue, 26 Feb 2013 21:16:22 +0000 (21:16 +0000)]
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.

11 years agopathtrace: fix umovestr return code check
Dmitry V. Levin [Tue, 26 Feb 2013 19:23:27 +0000 (19:23 +0000)]
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.

11 years agoFix compilation errors uncovered by -Werror=enum-compare
Dmitry V. Levin [Tue, 26 Feb 2013 22:02:30 +0000 (22:02 +0000)]
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.

11 years agoMass replace error_msg("%s", "literal") -> error_msg("literal")
Denys Vlasenko [Tue, 26 Feb 2013 11:30:09 +0000 (12:30 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoMake umoven report success as 0, not >=0, stop returning success on partial reads
Ben Noordhuis [Tue, 26 Feb 2013 11:24:25 +0000 (12:24 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoAssorted NOMMU fixes
Denys Vlasenko [Tue, 26 Feb 2013 11:00:34 +0000 (12:00 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoShorten help text - no need to show deprecated option -F
Denys Vlasenko [Tue, 26 Feb 2013 10:33:54 +0000 (11:33 +0100)]
Shorten help text - no need to show deprecated option -F

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoMerge adjacent tprint's
Denys Vlasenko [Sat, 23 Feb 2013 19:07:44 +0000 (20:07 +0100)]
Merge adjacent tprint's

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoCorrect i > MAX_NSYSCALLS commparison: should be i >= MAX_NSYSCALLS
Denys Vlasenko [Sat, 23 Feb 2013 17:19:28 +0000 (18:19 +0100)]
Correct i > MAX_NSYSCALLS commparison: should be i >= MAX_NSYSCALLS

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix wrong offset display in dumpstr
Denys Vlasenko [Fri, 22 Feb 2013 14:00:11 +0000 (15:00 +0100)]
Fix wrong offset display in dumpstr

BTW, the new code from prev commit is 5 times faster
than old one :)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix a bug in dumpstr (no null termination). Essentially rewrote dumpstr
Denys Vlasenko [Fri, 22 Feb 2013 13:47:39 +0000 (14:47 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoEliminate MAX_QUALS, make qualifier array dynamic
Denys Vlasenko [Fri, 22 Feb 2013 12:37:36 +0000 (13:37 +0100)]
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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoCreate and use struct_sysent and struct_ioctlent typedefs.
Denys Vlasenko [Fri, 22 Feb 2013 12:26:10 +0000 (13:26 +0100)]
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".

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoUse tcp->qual_flg instead of qual_flags[] in verbose() and abbrev()
Denys Vlasenko [Fri, 22 Feb 2013 12:23:38 +0000 (13:23 +0100)]
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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRemove unused QUAL_FAULT code (was used by non-Linux code only).
Denys Vlasenko [Thu, 21 Feb 2013 15:17:08 +0000 (16:17 +0100)]
Remove unused QUAL_FAULT code (was used by non-Linux code only).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoUse uint8_t for qual_flags[] instead of ints.
Denys Vlasenko [Thu, 21 Feb 2013 15:15:43 +0000 (16:15 +0100)]
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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoEliminate many SCNO_IS_VALID checks
Denys Vlasenko [Thu, 21 Feb 2013 15:13:47 +0000 (16:13 +0100)]
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].

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoARM: make it one-personality arch
Denys Vlasenko [Thu, 21 Feb 2013 14:46:34 +0000 (15:46 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoarm: shorten syscall table for EABI - no point in storing NULL entries
Denys Vlasenko [Wed, 20 Feb 2013 17:08:25 +0000 (18:08 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoUse the same style of includes in linux/*/* files
Denys Vlasenko [Wed, 20 Feb 2013 11:38:14 +0000 (12:38 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>