]> granicus.if.org Git - strace/log
strace
11 years agoAdd state argument to change_syscall and fix SPARC
James Hogan [Thu, 29 Nov 2012 17:37:37 +0000 (17:37 +0000)]
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.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
11 years agoAdd support for tracing 32-bit ARM EABI binaries on AArch64
Steve McIntyre [Sat, 10 Nov 2012 11:24:48 +0000 (11:24 +0000)]
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.

Signed-off-by: Steve McIntyre <steve.mcintyre@linaro.org>
11 years agoMove asm-generic ioctl definitions to linux/ioctlent.h.in
Dmitry V. Levin [Mon, 12 Nov 2012 14:04:46 +0000 (14:04 +0000)]
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.

11 years agoFilter out redundant "*32" ioctl entries
Dmitry V. Levin [Sat, 27 Oct 2012 01:11:13 +0000 (01:11 +0000)]
Filter out redundant "*32" ioctl entries

* linux/ioctlent-filter.awk: New file.
* Makefile.am: Use it.
* linux/ioctlent.h.in: Removed redundant "*32" entries.

11 years agoEnhance quotactl decoding
Dmitry V. Levin [Fri, 26 Oct 2012 23:43:13 +0000 (23:43 +0000)]
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.

11 years agoAdd AArch64 support to strace
Steve McIntyre [Wed, 24 Oct 2012 16:58:16 +0000 (17:58 +0100)]
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.

Signed-off-by: Steve McIntyre <steve.mcintyre@linaro.org>
11 years agolinux: add new errno values for EPROBE_DEFER and EOPENSTALE
Steve McIntyre [Wed, 24 Oct 2012 13:49:20 +0000 (14:49 +0100)]
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.

Signed-off-by: Steve McIntyre <steve.mcintyre@linaro.org>
11 years agoAdd -e trace=memory option
Namhyung Kim [Wed, 24 Oct 2012 02:41:57 +0000 (11:41 +0900)]
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.

Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
11 years agox32: add 64bit annotation too
Mike Frysinger [Thu, 27 Sep 2012 05:12:39 +0000 (01:12 -0400)]
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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
11 years agoIgnore fflush(3) return value
Dmitry V. Levin [Mon, 17 Sep 2012 22:40:12 +0000 (22:40 +0000)]
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.

11 years agoUse perror_msg instead of perror
Dmitry V. Levin [Mon, 17 Sep 2012 23:20:54 +0000 (23:20 +0000)]
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.

11 years agoprocess_vm_readv may return ESRCH if tracee was killed, don't complain
Denys Vlasenko [Thu, 27 Sep 2012 11:53:37 +0000 (13:53 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoTrivial fixes, no code changes.
Denys Vlasenko [Thu, 13 Sep 2012 08:28:43 +0000 (10:28 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoAlways check setreuid return code
Dmitry V. Levin [Fri, 24 Aug 2012 17:56:53 +0000 (17:56 +0000)]
Always check setreuid return code

* strace.c (startup_child): Check setreuid return code.

12 years agox32: update {g,s}etsockopt syscall numbers
Mike Frysinger [Wed, 22 Aug 2012 15:56:15 +0000 (11:56 -0400)]
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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
12 years agoDecode file type returned by getdents system call
Dmitry V. Levin [Thu, 16 Aug 2012 19:29:55 +0000 (19:29 +0000)]
Decode file type returned by getdents system call

* file.c (sys_getdents): Decode d_type in unabbreviated mode.

12 years agoClose pipe and wait for the pipe process termination
Dmitry V. Levin [Thu, 12 Jul 2012 20:54:46 +0000 (20:54 +0000)]
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.

12 years agoEnable usage of PTRACE_SEIZE
Denys Vlasenko [Tue, 10 Jul 2012 14:36:32 +0000 (16:36 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agox32: update syscall table
Mike Frysinger [Mon, 4 Jun 2012 18:01:59 +0000 (14:01 -0400)]
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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
12 years agoMerge adjacent printing operations in a few places
Denys Vlasenko [Fri, 18 May 2012 00:03:24 +0000 (02:03 +0200)]
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().

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoUse %d printf format instead of %i everywhere
Denys Vlasenko [Wed, 16 May 2012 10:29:09 +0000 (12:29 +0200)]
Use %d printf format instead of %i everywhere

* loop.c (loop_ioctl): Use %d instead of %i.
* mtd.c (mtd_ioctl): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoFix a few goofs in sys_sysctl()
Denys Vlasenko [Wed, 16 May 2012 10:23:58 +0000 (12:23 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoStop using non-standard %Zu and %Zd formats for size_t printing
Denys Vlasenko [Wed, 16 May 2012 10:20:17 +0000 (12:20 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoRemove outdated comment about suspending new tracees
Denys Vlasenko [Tue, 15 May 2012 13:35:52 +0000 (15:35 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoMake sure current_wordsize and PERSONALITY0_WORDSIZE are ints in all arches
Denys Vlasenko [Tue, 15 May 2012 12:28:56 +0000 (14:28 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoAdd configure --enable-gcc-Werror option
Dmitry V. Levin [Tue, 15 May 2012 00:50:26 +0000 (00:50 +0000)]
Add configure --enable-gcc-Werror option

* configure.ac: New option --enable-gcc-Werror.

12 years agoMake x86-64 build free of artificial warnings
Dmitry V. Levin [Tue, 15 May 2012 00:13:59 +0000 (00:13 +0000)]
Make x86-64 build free of artificial warnings

* signal.c (sys_sigreturn): Do not issue "no sys_sigreturn" warning
on X86_64.

12 years agoFix kernel release string parsing
Dmitry V. Levin [Mon, 14 May 2012 23:42:10 +0000 (23:42 +0000)]
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>
12 years agoOn clearing "breakpopint", restore syscall number too
Denys Vlasenko [Mon, 14 May 2012 14:40:28 +0000 (16:40 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoutil: fix building when glibc has a stub process_vm_readv
Mike Frysinger [Fri, 4 May 2012 23:37:29 +0000 (19:37 -0400)]
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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
12 years agodoc: describe documentation policy
Dmitry V. Levin [Thu, 3 May 2012 01:44:49 +0000 (01:44 +0000)]
doc: describe documentation policy

* README-hacking: Describe documentation policy.

12 years agomaint: post-release administrivia
Dmitry V. Levin [Wed, 2 May 2012 23:00:34 +0000 (23:00 +0000)]
maint: post-release administrivia

* NEWS: Add header line for next release.

12 years agoPrepare for 4.7 release v4.7
Dmitry V. Levin [Wed, 2 May 2012 12:34:56 +0000 (12:34 +0000)]
Prepare for 4.7 release

* configure.ac: Version 4.7.
* debian/changelog: 4.7-1.
* strace.spec: 4.7-1.

12 years agoFix build with <linux/loop.h> from 2.6.18 kernel headers
Dmitry V. Levin [Wed, 2 May 2012 10:21:49 +0000 (10:21 +0000)]
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.

12 years ago* vsprintf.c: Check for USE_CUSTOM_PRINTF earlier.
Dmitry V. Levin [Tue, 1 May 2012 22:49:49 +0000 (22:49 +0000)]
* vsprintf.c: Check for USE_CUSTOM_PRINTF earlier.

12 years agoRemove duplicate names from CREDITS
Dmitry V. Levin [Tue, 1 May 2012 21:51:38 +0000 (21:51 +0000)]
Remove duplicate names from CREDITS

* .mailmap: Merge email addresses.
* CREDITS.in: Remove a duplicate name.

12 years agotests: raise strace check timeout to 60 seconds
Dmitry V. Levin [Tue, 1 May 2012 21:32:09 +0000 (21:32 +0000)]
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>
12 years agoUpdate STA_* constants
Dmitry V. Levin [Tue, 1 May 2012 21:17:51 +0000 (21:17 +0000)]
Update STA_* constants

* time.c (adjtimex_status): Add STA_NANO, STA_MODE, and STA_CLK.
* NEWS (Improvements): Mention it.

12 years agoNEWS: update for release
Dmitry V. Levin [Tue, 1 May 2012 21:04:18 +0000 (21:04 +0000)]
NEWS: update for release

* NEWS (Improvements): Mention recent recvmsg/recvmmsg decoders
enhancements.
(Portability): Add a recommendation for the minimum Linux kernel
version to use.

12 years agoMake printing of utsname.domainname more portable
Dmitry V. Levin [Tue, 1 May 2012 20:56:32 +0000 (20:56 +0000)]
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.

12 years agoFix recvmmsg decode: do not show more data than actually returned
Dmitry V. Levin [Tue, 1 May 2012 20:41:40 +0000 (20:41 +0000)]
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.

12 years agoRemove recently introduced use of ULONG_MAX
Dmitry V. Levin [Tue, 1 May 2012 20:30:02 +0000 (20:30 +0000)]
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".

12 years agoEnable printing of uts.domainname in uname syscall
Denys Vlasenko [Sat, 28 Apr 2012 14:59:47 +0000 (16:59 +0200)]
Enable printing of uts.domainname in uname syscall

* process.c (sys_uname): Enable printing of uts.domainname

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoFix printstr's len parameter width
Denys Vlasenko [Sat, 28 Apr 2012 12:58:35 +0000 (14:58 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoFix recvmsg decode: do not show more data than actually returned
Denys Vlasenko [Sat, 28 Apr 2012 12:26:18 +0000 (14:26 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoPackage strace-log-merge
Dmitry V. Levin [Fri, 27 Apr 2012 23:38:44 +0000 (23:38 +0000)]
Package strace-log-merge

* strace.spec (%files): Add strace-log-merge.

12 years agoNEWS: clarify & fix typo
Mike Frysinger [Fri, 27 Apr 2012 23:13:55 +0000 (19:13 -0400)]
NEWS: clarify & fix typo

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
12 years agoCast current_wordsize to an int
Mike Frysinger [Fri, 27 Apr 2012 22:58:20 +0000 (18:58 -0400)]
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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
12 years agoUpdate NEWS for upcoming 4.7 release
Dmitry V. Levin [Fri, 20 Apr 2012 17:32:50 +0000 (17:32 +0000)]
Update NEWS for upcoming 4.7 release

* NEWS: Update for 4.7 release.

12 years agoSync strace.spec and debian/ with packages
Dmitry V. Levin [Fri, 20 Apr 2012 17:31:48 +0000 (17:31 +0000)]
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.

12 years agoDecode /dev/loop ioctls
Mike Frysinger [Wed, 18 Apr 2012 02:19:31 +0000 (22:19 -0400)]
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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
12 years agox32: add ia32 support
H.J. Lu [Tue, 17 Apr 2012 18:05:04 +0000 (11:05 -0700)]
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.

12 years agoCast clock_t type to unsigned long long
H.J. Lu [Sun, 15 Apr 2012 18:17:13 +0000 (11:17 -0700)]
Cast clock_t type to unsigned long long

* resource.c (sys_times): Cast clock_t type to unsigned long long.
* signal.c (printsiginfo): Likewise.

12 years agoAdd custom (faster) vfprintf implementation (disabled by default)
Denys Vlasenko [Mon, 16 Apr 2012 16:22:19 +0000 (18:22 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoStop using %h[h]u format specifiers
Denys Vlasenko [Mon, 16 Apr 2012 16:12:27 +0000 (18:12 +0200)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoTrivial speed optimization
Denys Vlasenko [Mon, 16 Apr 2012 16:10:15 +0000 (18:10 +0200)]
Trivial speed optimization

* strace.c (tprints): Use fputs_unlocked instead of fputs.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoFix a problem with sys_lseek on x32
H.J. Lu [Mon, 16 Apr 2012 15:41:13 +0000 (17:41 +0200)]
Fix a problem with sys_lseek on x32

* file.c (sys_lseek): Use MIPS-n32 variant also for x32

Signed-off-by: H.J. Lu <hongjiu.lu@intel.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoAdd x32 support to strace
H.J. Lu [Mon, 16 Apr 2012 11:00:01 +0000 (13:00 +0200)]
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.

Signed-off-by: H.J. Lu <hongjiu.lu@intel.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoRestore tcb::u_lrval; fix lseek on MIPS-n32
H.J. Lu [Mon, 16 Apr 2012 10:16:45 +0000 (12:16 +0200)]
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.

Signed-off-by: H.J. Lu <hongjiu.lu@intel.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoDecode mtd ioctls
Mike Frysinger [Thu, 5 Apr 2012 02:22:01 +0000 (22:22 -0400)]
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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
12 years agoFix indefinite hang on no-mmu systems
Mike Frysinger [Thu, 5 Apr 2012 05:52:25 +0000 (01:52 -0400)]
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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
12 years agoMakefile.am: whitespace fix
Denys Vlasenko [Thu, 29 Mar 2012 15:21:41 +0000 (17:21 +0200)]
Makefile.am: whitespace fix

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agopowerpc: Add syscall entries for direct socket system calls
Anton Blanchard [Mon, 26 Mar 2012 23:34:54 +0000 (10:34 +1100)]
powerpc: Add syscall entries for direct socket system calls

* linux/powerpc/syscallent.h: Add direct socket system calls.

12 years agoqual_syscall: fix potential NULL dereference
Dmitry V. Levin [Mon, 26 Mar 2012 14:14:50 +0000 (14:14 +0000)]
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>
12 years agostrace-log-merge: fix file suffix calculation
Dmitry V. Levin [Mon, 26 Mar 2012 12:10:01 +0000 (12:10 +0000)]
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>
12 years agoRemove unreachable code
Denys Vlasenko [Mon, 26 Mar 2012 11:41:56 +0000 (13:41 +0200)]
Remove unreachable code

* strace.c (process_opt_p_list): Remove unreachable code.

12 years agomanpage: remove false info about -p being limited to 32 processes
Denys Vlasenko [Mon, 26 Mar 2012 11:31:11 +0000 (13:31 +0200)]
manpage: remove false info about -p being limited to 32 processes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoTweak help text and manpage (added -In to manpage)
Denys Vlasenko [Mon, 26 Mar 2012 11:10:50 +0000 (13:10 +0200)]
Tweak help text and manpage (added -In to manpage)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoprintstr: check for potential integer overflow
Dmitry V. Levin [Sun, 25 Mar 2012 22:56:53 +0000 (22:56 +0000)]
printstr: check for potential integer overflow

* util.c (printstr): Check for potential integer overflow during outstr
buffer size calculation.

12 years agoRobustify parsing of numbers from strings
Dmitry V. Levin [Sun, 25 Mar 2012 21:49:48 +0000 (21:49 +0000)]
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.

12 years agostrace-log-merge: enhance usage error diagnostics
Dmitry V. Levin [Sun, 25 Mar 2012 21:04:57 +0000 (21:04 +0000)]
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.

12 years agoconfigure.ac: sort lists and use m4_normalize to ease maintenance
Dmitry V. Levin [Sun, 25 Mar 2012 15:12:16 +0000 (15:12 +0000)]
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.

12 years agoSimple optimizations
Denys Vlasenko [Fri, 23 Mar 2012 10:29:01 +0000 (11:29 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoReorder declarations in defs.h. No code changes
Denys Vlasenko [Fri, 23 Mar 2012 10:26:36 +0000 (11:26 +0100)]
Reorder declarations in defs.h. No code changes

* defs.h: Reorder declarations (such as: keep all printing functions together).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoSimplify current tcp switching and current column handling
Denys Vlasenko [Thu, 22 Mar 2012 08:56:20 +0000 (09:56 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoMake threaded execve handling code more reabable and somewhat simpler
Denys Vlasenko [Thu, 22 Mar 2012 08:35:51 +0000 (09:35 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agosimple cleanups in defs.h. No logic changes.
Denys Vlasenko [Wed, 21 Mar 2012 13:39:22 +0000 (14:39 +0100)]
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).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoShow "+++ exited..." with -C
Denys Vlasenko [Wed, 21 Mar 2012 13:27:40 +0000 (14:27 +0100)]
Show "+++ exited..." with -C

* strace.c (trace): Show "+++ exited..." with -C too.
Save tcp->curcol after PTRACE_LISTEN failure too, just in case.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoSlight tweak to qemu_multiarch_testing scripts
Denys Vlasenko [Wed, 21 Mar 2012 10:32:55 +0000 (11:32 +0100)]
Slight tweak to qemu_multiarch_testing scripts

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoReplace reprinting decision logic
Denys Vlasenko [Wed, 21 Mar 2012 10:06:20 +0000 (11:06 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoReport some ptrace failures; nuke tcp->ptrace_errno
Denys Vlasenko [Wed, 21 Mar 2012 09:32:49 +0000 (10:32 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoEliminate redundant checks of res variable
Denys Vlasenko [Tue, 20 Mar 2012 23:23:16 +0000 (00:23 +0100)]
Eliminate redundant checks of res variable

* syscall.c (trace_syscall_entering): Eliminate redundant checks of res variable.
(trace_syscall_exiting): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoRename POWERPC-specific static variable result to ppc_result
Denys Vlasenko [Tue, 20 Mar 2012 23:07:25 +0000 (00:07 +0100)]
Rename POWERPC-specific static variable result to ppc_result

* syscall.c: Rename POWERPC-specific static variable result to ppc_result.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoRemove redundant checks in syscall entry/exit, rename badly named function
Denys Vlasenko [Tue, 20 Mar 2012 16:10:35 +0000 (17:10 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoTrivial tweaks. No logic changes
Denys Vlasenko [Tue, 20 Mar 2012 15:48:35 +0000 (16:48 +0100)]
Trivial tweaks. No logic changes

* process.c (sys_ptrace): Remove unneeded line wrapping.
* syscall.c (trace_syscall_entering): Use tprints() instead of tprintf().

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoMake ptrace_restart() static. No code changes
Denys Vlasenko [Tue, 20 Mar 2012 15:26:25 +0000 (16:26 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoDo not include limits.h unnecessarily
Dmitry V. Levin [Tue, 20 Mar 2012 14:02:51 +0000 (14:02 +0000)]
Do not include limits.h unnecessarily

* ioctl.c: Remove limits.h inclusion left after the reverted change.

12 years agoPartially revert last change
Denys Vlasenko [Tue, 20 Mar 2012 12:11:51 +0000 (13:11 +0100)]
Partially revert last change

Thank you Dmitry for spotting it.

* ioctl.c (compare): Partially revert last change - the new
comparison logic was buggy.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoSimplify search in ioctl table
Denys Vlasenko [Tue, 20 Mar 2012 09:57:41 +0000 (10:57 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoUpdate qemu build script: now tries to upload result back to host
Denys Vlasenko [Mon, 19 Mar 2012 11:20:32 +0000 (12:20 +0100)]
Update qemu build script: now tries to upload result back to host

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoShrink space needed by undefined syscalls in syscall tables.
Denys Vlasenko [Mon, 19 Mar 2012 08:51:42 +0000 (09:51 +0100)]
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'.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoOptimize code if we have only one personality
Denys Vlasenko [Mon, 19 Mar 2012 08:36:42 +0000 (09:36 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoFix mips64 build failure: sys_pwrite64 doesn't exist.
Denys Vlasenko [Sun, 18 Mar 2012 22:49:07 +0000 (23:49 +0100)]
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/

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoqemu_multiarch_testing/: a directory with scripts for build testing
Denys Vlasenko [Sun, 18 Mar 2012 22:27:23 +0000 (23:27 +0100)]
qemu_multiarch_testing/: a directory with scripts for build testing

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoMake internal_fork and internal_exec static
Denys Vlasenko [Sun, 18 Mar 2012 21:10:48 +0000 (22:10 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoRemove code which is not used on Linux
Denys Vlasenko [Sun, 18 Mar 2012 03:16:59 +0000 (04:16 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoRemove unused version of sys_lseek
Denys Vlasenko [Sun, 18 Mar 2012 03:13:14 +0000 (04:13 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoRevert "Remove underscores from a few syscall names which have them"
Denys Vlasenko [Sat, 17 Mar 2012 17:00:14 +0000 (18:00 +0100)]
Revert "Remove underscores from a few syscall names which have them"

This reverts commit 31972d52b1059d8faca1c5f417c2db1a90b868ae.

12 years agoSimplify sys_lseek64 conditional compilation.
Denys Vlasenko [Sat, 17 Mar 2012 15:26:47 +0000 (16:26 +0100)]
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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 years agoRemove underscores from a few syscall names which have them
Denys Vlasenko [Sat, 17 Mar 2012 12:23:00 +0000 (13:23 +0100)]
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.

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