]> granicus.if.org Git - strace/log
strace
11 years agoFixes in "new" mmap
Denys Vlasenko [Mon, 18 Feb 2013 02:13:07 +0000 (03:13 +0100)]
Fixes in "new" mmap

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoPreliminary simplifications in mmap functions
Denys Vlasenko [Mon, 18 Feb 2013 01:36:36 +0000 (02:36 +0100)]
Preliminary simplifications in mmap functions

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRemove broken HAVE_LONG_LONG conditionals
Denys Vlasenko [Sun, 17 Feb 2013 21:41:33 +0000 (22:41 +0100)]
Remove broken HAVE_LONG_LONG conditionals

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

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoUse explicit long type instead of off_t
Denys Vlasenko [Sun, 17 Feb 2013 19:08:50 +0000 (20:08 +0100)]
Use explicit long type instead of off_t

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoMerge two identical tables
Denys Vlasenko [Sun, 17 Feb 2013 13:31:55 +0000 (14:31 +0100)]
Merge two identical tables

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRemove wrong x32-specific lseek
Denys Vlasenko [Sun, 17 Feb 2013 12:17:49 +0000 (13:17 +0100)]
Remove wrong x32-specific lseek

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

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix SEGV in lseek
Denys Vlasenko [Sun, 17 Feb 2013 11:47:44 +0000 (12:47 +0100)]
Fix SEGV in lseek

I found hard way why the code was using "_whence" name.

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoComment inner workings of sys_[l]lseek
Denys Vlasenko [Sun, 17 Feb 2013 00:38:14 +0000 (01:38 +0100)]
Comment inner workings of sys_[l]lseek

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

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoCosmetic fixes to syscall tables, no code changes
Denys Vlasenko [Sun, 17 Feb 2013 00:37:35 +0000 (01:37 +0100)]
Cosmetic fixes to syscall tables, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoMake linux/mips/syscallent.h smaller
Denys Vlasenko [Sat, 16 Feb 2013 13:44:31 +0000 (14:44 +0100)]
Make linux/mips/syscallent.h smaller

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoSimple optimization in get_error
Denys Vlasenko [Sat, 16 Feb 2013 13:25:56 +0000 (14:25 +0100)]
Simple optimization in get_error

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoMass rename of SCNO_IN_RANGE define to SCNO_IS_VALID
Denys Vlasenko [Sat, 16 Feb 2013 12:22:38 +0000 (13:22 +0100)]
Mass rename of SCNO_IN_RANGE define to SCNO_IS_VALID

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFinish prefixing regs struct names with arch_
Denys Vlasenko [Sat, 16 Feb 2013 07:23:40 +0000 (08:23 +0100)]
Finish prefixing regs struct names with arch_

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

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoUse the same type for i386_regs on 32-bit and 64-bit x86.
Denys Vlasenko [Fri, 15 Feb 2013 20:04:28 +0000 (21:04 +0100)]
Use the same type for i386_regs on 32-bit and 64-bit x86.

* defs.h: Stop including <asm/ptrace.h> for x86.
Change i386_regs from "struct pt_regs" to "struct user_regs_struct".
* syscall.c: Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix build error on Tile
Denys Vlasenko [Fri, 15 Feb 2013 14:25:37 +0000 (15:25 +0100)]
Fix build error on Tile

* syscall.c (get_scno): [TILE] Remove TCB_WAITEXECVE check,
it is never true on Tile, and stopped compiling when
TCB_WAITEXECVE define was removed for Tile.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agox86: zero-extend 32-bit args in syscall entry instead of sign-extension
Denys Vlasenko [Fri, 15 Feb 2013 14:01:38 +0000 (15:01 +0100)]
x86: zero-extend 32-bit args in syscall entry instead of sign-extension

Zero-extension is slightly more common that sign-extension:
all pointers are zero-extended, and some other params are unsigned.

Whereas signed ones (fds, pids, etc) are often treated as
_32-bit ints_ even by kernel, so just unconditionally casting
such tcp->u_arg[N] to int works.

* syscall.c (get_syscall_args): [X86] Zero-extend 32-bit args
instead of sign-extension.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoMacroize conditional signed widening operation
Denys Vlasenko [Fri, 15 Feb 2013 13:58:52 +0000 (14:58 +0100)]
Macroize conditional signed widening operation

* defs.h: Define widen_to_long() macro.
* signal.c (sys_kill): Use it instead of open-coding it.
(sys_tgkill): Use widen_to_long() on pids.
* resource.c (decode_rlimit): Formatting fix.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoA better handling of current_wordsize
Denys Vlasenko [Fri, 15 Feb 2013 13:55:14 +0000 (14:55 +0100)]
A better handling of current_wordsize

On x86_64:
  text    data     bss     dec     hex filename
435661   26628   47424  509713   7c711 strace_old
435501   26612   47440  509553   7c671 strace_new_clever_wordsize

On x32 and arm it should be even better, current_wordsize becomes
a constant there.

* defs.h: Declare current_wordsize as a variable if needed,
else declare as a constant define.
Remove declatation of personality_wordsize[].
* syscall.c: Make personality_wordsize[] static.
Declare current_wordsize as a variable if needed.
(set_personality): Set current_wordsize only if non-constant.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRemove unnecessary "return 0" statements
Denys Vlasenko [Fri, 15 Feb 2013 10:43:08 +0000 (11:43 +0100)]
Remove unnecessary "return 0" statements

* util.c (change_syscall): Remove dummy "return 0"s.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agox86: fix required kernel version for GETREGSET
Denys Vlasenko [Thu, 14 Feb 2013 23:24:19 +0000 (00:24 +0100)]
x86: fix required kernel version for GETREGSET

* syscall.c (get_regs): [X86] Use GETREGSET only if kernel >= 2.6.35

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoWhitespace fix, no code changes
Denys Vlasenko [Thu, 14 Feb 2013 12:39:53 +0000 (13:39 +0100)]
Whitespace fix, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoAdd support for the OpenRISC 1000 platform
Christian Svensson [Thu, 14 Feb 2013 12:26:27 +0000 (13:26 +0100)]
Add support for the OpenRISC 1000 platform

* configure.ac: Added or1k architecture..
* defs.h: Added or1k to use register reading system.
* linux/or1k/ioctlent.h.in: Use i386 ioctls.
* linux/or1k/syscallent.h: New file.
* process.c: Added or1k register defs to struct_user_offsets[].
* syscall.c: Added or1k_io iovec for or1k GETREGSET,
  regset structure for or1k.
  (printcall): Added handling for or1k.
  (get_regs): Likewise.
  (get_scno): Likewise.
  (get_syscall_args): Likewise.
  (get_syscall_result): Likewise.
  (get_error): Likewise.
* util.c (change_syscall): Added dummy handling for or1k.
* system.c (sys_or1k_atomic): New function (or1k specific syscall).

Signed-off-by: Christian Svensson <blue@cmd.nu>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years ago[X86] Use ptrace(PTRACE_GETREGSET, NT_PRSTATUS) to get registers.
Denys Vlasenko [Thu, 14 Feb 2013 02:29:48 +0000 (03:29 +0100)]
[X86] Use ptrace(PTRACE_GETREGSET, NT_PRSTATUS) to get registers.

Unlike PTRACE_GETREGS, this new method detects 32-bit processes
reliably, without checking segment register values which
are undocumented and aren't part of any sort of API.
While at it, also fixed x32 detection to use __X32_SYSCALL_BIT,
as it should have been from the beginning.

* defs.h: Declare os_release and KERNEL_VERSION.
* strace.c: Make os_release non-static, remove KERNEL_VERSION define.
* syscall.c: New struct i386_user_regs_struct,
static union x86_regs_union and struct iovec x86_io.
(printcall): Use i386_regs or x86_64_regs depending on x86_io.iov_len.
(get_regs): On x86 and kernels 2.6.30+, use PTRACE_GETREGSET,
on earlier kernels fall back to old method.
(get_scno): [X86] Determine personality based on regset size
on scno & __X32_SYSCALL_BIT.
(syscall_fixup_on_sysenter): Use i386_regs or x86_64_regs depending
on x86_io.iov_len.
(get_syscall_args): Likewise.
(get_error): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRename some register statics by prefixing their names with arch.
Denys Vlasenko [Wed, 13 Feb 2013 16:52:31 +0000 (17:52 +0100)]
Rename some register statics by prefixing their names with arch.

This makes it easier to grep for them.

* syscall.c: Rename variables:
r0 -> bfin_r0,alpha_r0,sh_r0.
a3 -> mips_a3.
r2 -> mips_r2.
(get_scno): Use new variable names.
(get_syscall_result): Likewise.
(get_error): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFactor out code to check addr, fetch and print siginfo
Denys Vlasenko [Wed, 13 Feb 2013 15:31:32 +0000 (16:31 +0100)]
Factor out code to check addr, fetch and print siginfo

* defs.h: Declare new function printsiginfo_at(tcp, addr).
* process.c (sys_waitid): Use printsiginfo_at().
(sys_ptrace): Likewise.
* signal.c: (printsiginfo_at): Implement this new function.
(sys_rt_sigsuspend): Use printsiginfo_at().
(sys_rt_sigtimedwait): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoDecode struct iov in PTRACE_GET/SETREGSET
Denys Vlasenko [Wed, 13 Feb 2013 15:10:10 +0000 (16:10 +0100)]
Decode struct iov in PTRACE_GET/SETREGSET

* process.c (sys_ptrace): Decode struct iov in PTRACE_GET/SETREGSET.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoUnify representations of struct user fields for subarchitectures
Denys Vlasenko [Tue, 12 Feb 2013 16:15:19 +0000 (17:15 +0100)]
Unify representations of struct user fields for subarchitectures

* process.c: Unify MIPS and LINUX_MIPSN32, and SH and SH64 parts of
struct_user_offsets[].

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoAdd start_code and start_data members of struct user
Denys Vlasenko [Tue, 12 Feb 2013 16:10:05 +0000 (17:10 +0100)]
Add start_code and start_data members of struct user

* process.c: Add start_code and start_data members of struct user
in struct_user_offsets[], where appropriate.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRemove hacks for old kernels for architectures which require new kernels
Denys Vlasenko [Tue, 12 Feb 2013 15:07:54 +0000 (16:07 +0100)]
Remove hacks for old kernels for architectures which require new kernels

* util.c (change_syscall): For MICROBLAZE, replace code
with dummy "return 0" and a comment explaining why that is ok
for this architecture.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRemove stray syscall result reading code on syscall entry for s390
Denys Vlasenko [Tue, 12 Feb 2013 14:57:37 +0000 (15:57 +0100)]
Remove stray syscall result reading code on syscall entry for s390

This is a leftover from sysenter/sysexit split.
I can't run-test it, but from code inspection it seems to be correct.

* syscall.c (get_scno): Remove stray syscall result reading for s390[x].

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoDeobfuscate definitions of struct user offsets
Denys Vlasenko [Tue, 12 Feb 2013 14:51:58 +0000 (15:51 +0100)]
Deobfuscate definitions of struct user offsets

The maze of ifdefs/ifndefs was scaring new contributors.
Format it so that every arch has its own ifdef block.

* process.c: Deobfuscate definitions of struct user offsets.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRemove hacks for old kernels for architectures which require new kernels
Denys Vlasenko [Tue, 12 Feb 2013 12:06:51 +0000 (13:06 +0100)]
Remove hacks for old kernels for architectures which require new kernels

* defs.h: Do not define TCB_WAITEXECVE for AARCH64.
* util.c (change_syscall): For AARCH64 and X32, replace code
with dummy "return 0" and a comment explaining why that is ok
for these architectures.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRemove old kernel hacks for architectures which require new kernels
Denys Vlasenko [Tue, 12 Feb 2013 11:50:10 +0000 (12:50 +0100)]
Remove old kernel hacks for architectures which require new kernels

* defs.h: Do not define TCB_WAITEXECVE for AVR32, BFIN and TILE.
* util.c (change_syscall): For AVR32, BFIN and TILE, replace code
with dummy "return 0" and a comment explaining why that is ok
for these architectures.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoHandle recv[m]msg for non-native 32-bit personality syscalls
Denys Vlasenko [Tue, 12 Feb 2013 10:57:48 +0000 (11:57 +0100)]
Handle recv[m]msg for non-native 32-bit personality syscalls

* net.c (printmsghdr): If current_wordsize is 4 and long is wider than it,
read 32-bit struct msghdr and expand it into a native one before using it.
(printmmsghdr): Likewise for struct mmsghdr.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix is_negated_errno() check for X32
Denys Vlasenko [Tue, 12 Feb 2013 10:52:35 +0000 (11:52 +0100)]
Fix is_negated_errno() check for X32

X32's return value is 64-bit. We were truncating it to 32-bit long
before checking for -errno.

* syscall.c (is_negated_errno_x32): New function.
(get_error): Use is_negated_errno_x32 for X32 architecture.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRemove unused / ambiguously used defines
Denys Vlasenko [Tue, 12 Feb 2013 10:43:46 +0000 (11:43 +0100)]
Remove unused / ambiguously used defines

We sometimes use LINUXSPARC and sometimes (more often)
use "defined(SPARC) || defined(SPARC64)". Better to use
one construct consistently.
LINUX_MIPS64 is altogether unused.

* defs.h: Remove LINUXSPARC and LINUX_MIPS64 defines.
Move PTRACE_xxx compat defines up, before arch-specific
machinery. Use defined(SPARC) || defined(SPARC64)
instead of LINUXSPARC.
* file.c: Use defined(SPARC) || defined(SPARC64) instead of LINUXSPARC.
* signal.c: Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoPreparatory patch for "new" x86 personality detection
Denys Vlasenko [Mon, 11 Feb 2013 11:29:36 +0000 (12:29 +0100)]
Preparatory patch for "new" x86 personality detection

* syscall.c: Move PT_FLAGS_COMPAT define to its only user, get_scno().
Rename arm_regs_union's fields to names less likely to collide with
system defines.
(get_regs): Use sizeof(arm_regs_union) instead of sizeof(aarch64_regs).
This should be the same, but htis way it's cleaner.
Remove __X32_SYSCALL_MASK and use __X32_SYSCALL_BIT instead.
Explain 64-bit check in X32 build better.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix sigaltstack decoder
Dmitry V. Levin [Sat, 9 Feb 2013 02:03:04 +0000 (02:03 +0000)]
Fix sigaltstack decoder

strace used to hang when decoding sigaltstack called with invalid
stack_t pointers because of mishandling umove() return code.

* signal.c (print_stack_t): Handle unfetchable stack_t properly.
Change return type to void.
(sys_sigaltstack): Update print_stack_t() usage.

Reported-by: kawillia@ucalgary.ca
11 years agoFix decoding of sysctl() when oldval fields are NULL
Mike Frysinger [Sat, 9 Feb 2013 00:10:07 +0000 (19:10 -0500)]
Fix decoding of sysctl() when oldval fields are NULL

If you call glibc's syscall wrapper like so:
static int name[] = { CTL_NET, NET_IPV4, NET_IPV4_LOCAL_PORT_RANGE };
int buffer[2] = { 32768, 61000 };
size_t size = sizeof(buffer);
sysctl(name, 3, 0, 0, buffer, size);
(note that oldval/oldlenp are NULL).

The current strace code complains like so:
_sysctl({{CTL_NET, NET_IPV4, NET_IPV4_LOCAL_PORT_RANGE, 38}, 3, process_vm_readv: Bad address
(nil), 0, 0x7fffe23c3960, 8}) = -1 EACCES (Permission denied)

Since passing NULL for the old values is valid, handle that explicitly.
This also simplifies the code a bit by splitting up the handling of the
new and old args so that we only handle the new args once.

Now the output looks like:
_sysctl({{CTL_NET, NET_IPV4, NET_IPV4_LOCAL_PORT_RANGE, 38}, 3, NULL, 0, 0x7fff8c0c91b0, 8) = -1 EACCES (Permission denied)

* system.c (sys_sysctl): Check if info.oldval is NULL first.  Move the
processing of oldlen/info.newval/info.newlen out so they always get
executed.  Fix the format strings so we use %lu for unsigned long rather
than a mix of %ld and %lu.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
11 years agoIf we are on a glibc system, assume it's at least glibc 2.1
Denys Vlasenko [Fri, 8 Feb 2013 17:49:06 +0000 (18:49 +0100)]
If we are on a glibc system, assume it's at least glibc 2.1

It is not likely anyone uses glibc older that that:
glibc 2.1.1 was released in 1999

* net.c: Remove test for glibc >= 2.1.
* signal.c: Remove code which is compiled only for glibc < 2.1.
* util.c: Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoS390: stop using needlessly static long pc variable
Denys Vlasenko [Fri, 8 Feb 2013 14:50:05 +0000 (15:50 +0100)]
S390: stop using needlessly static long pc variable

* syscall.c: Remove "static long pc" variable.
(get_scno): Use an automatic long variable instead of a static.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoDying suddenly with abort() is rude, avoid if possible
Denys Vlasenko [Fri, 8 Feb 2013 14:34:46 +0000 (15:34 +0100)]
Dying suddenly with abort() is rude, avoid if possible

* file.c (sys_utime): Don't call abort() if wordsize is strange.
Instead, warn user about it.
* desc.c (printflock): Use the same message string as in sys_utime.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRemove vestigial hacks around non-Linux struct sigactions
Denys Vlasenko [Fri, 8 Feb 2013 11:59:13 +0000 (12:59 +0100)]
Remove vestigial hacks around non-Linux struct sigactions

* signal.c: Stop using __sighandler_t glibc'ism. Remove SA_HANDLER macro.
Explain why we can't use "sa_handler" as a field name.
(sys_sigaction): Use __sa_handler instead of SA_HANDLER macro.
(sys_rt_sigaction): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoOptimize AArch64 handling of 32-bit personality
Denys Vlasenko [Fri, 8 Feb 2013 11:38:51 +0000 (12:38 +0100)]
Optimize AArch64 handling of 32-bit personality

By putting aarch64_regs and arm_regs into a union,
register copying is eliminated.
No need to check and change personality on syscall exit.

* defs.h: Remove unused NUM_ARM_REGS define. Fix indentation.
* syscall.c: Put aarch64_regs and arm_regs into a union.
(update_personality): Shorten bitness message.
(printcall): Add commented-out PC printing.
(get_regs): Remove now-unnecessary 64-to-32 bits register copying.
(get_syscall_result): Drop personality changing code.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRename some register statics by prefixing their names with arch.
Denys Vlasenko [Thu, 7 Feb 2013 12:14:48 +0000 (13:14 +0100)]
Rename some register statics by prefixing their names with arch.

This makes it easier to grep for them.

* syscall.c: Make IA64's r8, r10 global variables static.
Rename variables:
r8,r10 -> ia64_r8,ia64_r10.
d0 -> m68k_d0.
a3 -> alpha_a3.
r28 -> hppa_r28.
r9 -> sh64_r9.
r10 -> cris_r10.
r3 -> microblaze_r3.
(get_scno): Use new variable names.
(syscall_fixup_on_sysenter): Likewise.
(get_syscall_result): Likewise.
(get_error): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoRename ARM's regs structure to arm_regs
Denys Vlasenko [Wed, 6 Feb 2013 17:24:39 +0000 (18:24 +0100)]
Rename ARM's regs structure to arm_regs

Compile-tested.

* defs.h: Rename regs structure to arm_regs.
* syscall.c: Likewise.
(printcall): Use new name instead of old one.
(get_regs): Likewise.
(get_scno): Likewise.
(get_syscall_args): Likewise.
(get_error): Likewise.
* signal.c (sys_sigreturn): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoStop needlessly using static variable
Denys Vlasenko [Wed, 6 Feb 2013 17:09:31 +0000 (18:09 +0100)]
Stop needlessly using static variable

* syscall.c: Remove static long psr.
(get_scno): Use local psr variable.
(get_syscall_result): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoShortcut tests for fork/exec syscalls
Denys Vlasenko [Wed, 6 Feb 2013 12:18:42 +0000 (13:18 +0100)]
Shortcut tests for fork/exec syscalls

This change should speed up strace by a tiny bit.

More importantly, it makes it much more clear that
fork and exec fixups are not necessary for any reasonably
recent kernels. IOW: syscall_fixup_for_fork_exec() and its callees
are all dead code.

* defs.h: Declare new need_fork_exec_workarounds flag variable.
* strace.c: Define need_fork_exec_workarounds flag variable.
(test_ptrace_setoptions_followfork): Return 0/1 as success/fail indicator.
(test_ptrace_setoptions_for_all): Likewise.
(init): Set need_fork_exec_workarounds to TRUE if needed.
* syscall.c: Rename internal_syscall() to syscall_fixup_for_fork_exec().
(trace_syscall_entering): Call syscall_fixup_for_fork_exec() only if
need_fork_exec_workarounds == TRUE.
(trace_syscall_exiting): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoImprove perf_event_open argument decoding
Ben Noordhuis [Sun, 3 Feb 2013 23:04:57 +0000 (00:04 +0100)]
Improve perf_event_open argument decoding

* configure.ac (AC_CHECK_HEADERS): Add linux/perf_event.h.
* desc.c [HAVE_LINUX_PERF_EVENT_H]: Include <linux/perf_event.h>.
(perf_event_open_flags): New xlat structure.
(sys_perf_event_open): New function.
* linux/dummy.h (sys_perf_event_open): Remove.
* linux/syscall.h (sys_perf_event_open): New prototype.

Signed-off-by: Ben Noordhuis <info@bnoordhuis.nl>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
11 years agotile: fix merge skew with new get_regs architecture
Chris Metcalf [Tue, 5 Feb 2013 18:02:42 +0000 (13:02 -0500)]
tile: fix merge skew with new get_regs architecture

* defs.h [TILE]: Declare clear_regs(), get_regs() and get_regs_error.
* syscall.c (get_regs) [TILE]: Fix merge skew.
(printcall) [TILE]: fix a compiler warning about pt_reg_t in
a printf expression.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
11 years agomount: decode MS_NOSEC
Bernhard Reutner-Fischer [Tue, 5 Feb 2013 18:31:56 +0000 (19:31 +0100)]
mount: decode MS_NOSEC

* system.c (MS_NOSEC): Define.
(mount_flags): Add MS_NOSEC.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
11 years agommap: decode MAP_UNINITIALIZED
Bernhard Reutner-Fischer [Tue, 5 Feb 2013 18:31:55 +0000 (19:31 +0100)]
mmap: decode MAP_UNINITIALIZED

* mem.c (mmap_flags): Add MAP_UNINITIALIZED.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
11 years agoPrint 64-bit instruction pointers zero padded
Dmitry V. Levin [Tue, 5 Feb 2013 19:01:58 +0000 (19:01 +0000)]
Print 64-bit instruction pointers zero padded

* syscall.c (printcall): Print 64-bit instruction pointers zero padded.

11 years agox86_64: fix compilation warning introduced in previous commit
Dmitry V. Levin [Tue, 5 Feb 2013 18:57:16 +0000 (18:57 +0000)]
x86_64: fix compilation warning introduced in previous commit

* syscall.c (printcall): Cast x86_64_regs.rip to the type being printed.

11 years agoSimple bug fix for x86_86
Denys Vlasenko [Tue, 5 Feb 2013 17:18:07 +0000 (18:18 +0100)]
Simple bug fix for x86_86

* syscall.c (printcall): Use x86_64_regs.rip, not x86_64_regs.ip.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoAdd tilegx support to strace
Chris Metcalf [Tue, 5 Feb 2013 16:48:33 +0000 (17:48 +0100)]
Add tilegx support to strace

tilegx support has been in the kernel since 3.0.
In addition, fix some issues with the tilepro support already
present in strace, primarily the decision to use the
<asm/unistd.h> numbering space for system calls.

* defs.h [TILE]: Include <asm/ptrace.h> and provide an extern
struct pt_regs tile_regs for efficiency.  Provide compat 32-bit
personality via SUPPORTED_PERSONALITIES, PERSONALITY0_WORDSIZE,
PERSONALITY1_WORDSIZE, and DEFAULT_PERSONALITY.
* linux/tile/errnoent1.h: New file, includes linux/errnoent.h.
* linux/tile/ioctlent1.h: New file, includes linux/ioctlent.h.
* linux/tile/signalent1.h: New file, includes linux/signalent.h.
* linux/tile/syscallent.h: Update with new asm-generic syscalls.
The version previously committed was the from the first tile patch
to LKML, which subsequently was changed to use <asm-generic/unistd.h>.
* linux/tile/syscallent1.h: Copy from linux/tile/syscallent.h.
* mem.c (addtileflags) [TILE]: use %ld properly for a "long" variable.
* process.c [TILE]: Choose clone arguments correctly and properly
suppress all "struct user" related offsets in user_struct_offsets.
* signal.c [TILE]: Use tile_regs not upeek.
* syscall.c (update_personality) [TILE]: Print mode.
(PT_FLAGS_COMPAT) [TILE]: Provide if not in system headers.
(tile_regs) [TILE]: Define 'struct pt_regs' variable to hold state.
(get_regs) [TILE]: use PTRACE_GETREGS to set tile_regs rather than using upeek.
(get_scno) [TILE]: Set personality.
(get_syscall_args) [TILE]: Use tile_regs.
(get_syscall_result) [TILE]: Update tile_regs.
(get_error) [TILE]: Use tile_regs.
(printcall) [TILE]: Print pc.
(arg0_offset, arg1_offset, restore_arg0, restore_arg1) [TILE]:
Properly handle tile call semantics and support tilegx.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoSmall optimization for SPARC[64] get_scno
Denys Vlasenko [Tue, 5 Feb 2013 16:02:59 +0000 (17:02 +0100)]
Small optimization for SPARC[64] get_scno

* syscall.c: Remove static unsigned long trap veriable.
(get_scno): Use local trap variable.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoDo not compile getrval2() if not needed
Denys Vlasenko [Tue, 5 Feb 2013 15:55:23 +0000 (16:55 +0100)]
Do not compile getrval2() if not needed

* syscall.c (getrval2): Do not compile it for architetures where
it isn't ever used.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoOptimize out PTRACE_PEEKUSER with -i
Denys Vlasenko [Tue, 5 Feb 2013 15:36:13 +0000 (16:36 +0100)]
Optimize out PTRACE_PEEKUSER with -i

strace -i was fetching PC with a separate PEEKUSER
despite having GETREGS data:

ptrace(PTRACE_GETREGS, 22331, 0, 0x8087f00) = 0
ptrace(PTRACE_PEEKUSER, 22331, 4*EIP, [0x80dd7b7]) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22331, 0, SIG_0) = 0

Now it does this:

ptrace(PTRACE_GETREGS, 22549, 0, 0x8087ea0) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22549, 0, SIG_0) = 0

Analogous improvement in sys_sigreturn() is also implemented.

* defs.h: Declare extern struct pt_regs regs for SPARC[64] and ARM.
Declare clear_regs(), get_regs() and get_regs_error flag variable.
* strace.c (trace): Call get_regs(pid) as soon as we know the tcb
and that it is stopped.
* syscall.c (get_regs): New function. Used to fetch registers early,
just after tracee has stopped.
(printcall): Move it here from util.c. Use global regs.REG data,
if available on the arch, instead of re-fetching it.
(get_scno): Use global regs.REG data.
(get_syscall_result): Likewise.
* signal.c (sys_sigreturn): Likewise.
* util.c (printcall): Moved to syscall.c.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 years agoFix sys_semtimedop decoding on s390x
Stanislav Brabec [Mon, 10 Dec 2012 19:18:49 +0000 (20:18 +0100)]
Fix sys_semtimedop decoding on s390x

The s390 and s390x pass semtimedop arguments differently from other
architectures.  sys_semtimedop parser was fixed for s390 by commit
v4.6-177-ge0f5fd8, and s390x requires the same fix.

* linux/ipc.c (sys_semtimedop): Fix timespec decoding on s390x.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
11 years agoFix *xattr decoding
Dmitry V. Levin [Fri, 7 Dec 2012 21:38:52 +0000 (21:38 +0000)]
Fix *xattr decoding

* file.c (print_xattr_val): Do not attempt to decode a zero sized array.
Fixes RH#885233.

11 years agosys_semtimedop: fix timeval argument index in wrapped call
Stanislav Brabec [Fri, 7 Dec 2012 20:30:51 +0000 (21:30 +0100)]
sys_semtimedop: fix timeval argument index in wrapped call

Looking at the implementation of wrapped semtimedop() call inside glibc
and kernel, I started to believe that timeval should be located in
tcp->u_arg[4] and not tcp->u_arg[5].  Fortunately, tcp->u_arg[5] now
works correctly as well, due to side effects of decode_ipc_subcall().

declaration in header:
int semtimedop(semid, *sops, nsops, *timeout);
                 0      1      2        3

sys_ipc arguments in glibc on all patforms except s390*:
semid, (int) nsops, 0, CHECK_N (sops, nsops), timeout
  0            1    2            3                4
We have to use indexes: 0 3 1 4

sys_ipc arguments on s390*:
semid, (int) nsops, timeout, sops
  0            1       2       3
We have to use indexes: 0 3 1 2

* ipc.c (sys_semtimedop) [!S390]: Fix timeval argument index in
indirect_ipccall case.

11 years agoFix glibc version checks
John Spencer [Sun, 2 Dec 2012 23:27:22 +0000 (00:27 +0100)]
Fix glibc version checks

* util.c: Check if __GLIBC__ is defined before using it.
* signal.c: Likewise.  Fix __GLIBC_MINOR__ checks.

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>
11 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>
11 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.

11 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>
11 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>