Commit Graph

2094 Commits

Author SHA1 Message Date
Denys Vlasenko
c52826c267 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>
2012-05-15 14:28:56 +02:00
d376c92a91 Add configure --enable-gcc-Werror option
* configure.ac: New option --enable-gcc-Werror.
2012-05-15 00:50:26 +00:00
f112d07800 Make x86-64 build free of artificial warnings
* signal.c (sys_sigreturn): Do not issue "no sys_sigreturn" warning
on X86_64.
2012-05-15 00:13:59 +00:00
0dbc80de89 Fix kernel release string parsing
* strace.c (get_os_release): Handle "X.Y-something" utsname.release
strings properly.

Reported-by: Bryce Gibson <bryce@gibson-consulting.com.au>
2012-05-14 23:42:10 +00:00
Denys Vlasenko
55980f5b72 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>
2012-05-14 16:40:28 +02:00
Mike Frysinger
24ee60b836 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>
2012-05-05 00:06:58 +00:00
5700f68471 doc: describe documentation policy
* README-hacking: Describe documentation policy.
2012-05-03 01:44:49 +00:00
503faaae3a maint: post-release administrivia
* NEWS: Add header line for next release.
2012-05-02 23:00:34 +00:00
417eb8861e Prepare for 4.7 release
* configure.ac: Version 4.7.
* debian/changelog: 4.7-1.
* strace.spec: 4.7-1.
2012-05-02 12:34:56 +00:00
cf050db3e8 Fix build with <linux/loop.h> from 2.6.18 kernel headers
* configure.ac: Check for LO_FLAGS_AUTOCLEAR and LO_FLAGS_PARTSCAN
declarations.
* loop.c (loop_flags_options): Use LO_FLAGS_AUTOCLEAR and
LO_FLAGS_PARTSCAN only when appropriate declarations are available.
(loop_ioctl): Use LOOP_SET_CAPACITY only when it is defined.
2012-05-02 10:21:49 +00:00
a5fd66b7b9 * vsprintf.c: Check for USE_CUSTOM_PRINTF earlier. 2012-05-01 22:49:49 +00:00
e263e3b813 Remove duplicate names from CREDITS
* .mailmap: Merge email addresses.
* CREDITS.in: Remove a duplicate name.
2012-05-01 21:51:38 +00:00
823eba28cd 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>
2012-05-01 21:32:09 +00:00
a28fbfd523 Update STA_* constants
* time.c (adjtimex_status): Add STA_NANO, STA_MODE, and STA_CLK.
* NEWS (Improvements): Mention it.
2012-05-01 21:17:51 +00:00
4ef3063c95 NEWS: update for release
* NEWS (Improvements): Mention recent recvmsg/recvmmsg decoders
enhancements.
(Portability): Add a recommendation for the minimum Linux kernel
version to use.
2012-05-01 21:04:18 +00:00
ea22e9753d 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.
2012-05-01 20:56:32 +00:00
5ea97658e7 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.
2012-05-01 20:41:40 +00:00
043b5f8142 Remove recently introduced use of ULONG_MAX
* io.c: Remove limits.h inclusion.
(tprint_iov): Use "(unsigned long) -1L" instead of "ULONG_MAX".
* net.c: Remove limits.h inclusion.
(printmmsghdr, sys_sendmsg): Use "(unsigned long) -1L" instead of
"ULONG_MAX".
2012-05-01 20:30:02 +00:00
Denys Vlasenko
3efa7c7f1b 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>
2012-04-28 16:59:47 +02:00
Denys Vlasenko
b5d43b81a8 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>
2012-04-28 14:58:35 +02:00
Denys Vlasenko
e0bc222263 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>
2012-04-28 14:26:18 +02:00
54432560a8 Package strace-log-merge
* strace.spec (%files): Add strace-log-merge.
2012-04-27 23:38:44 +00:00
Mike Frysinger
9b4fca2853 NEWS: clarify & fix typo
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-04-27 23:38:45 +00:00
Mike Frysinger
aa6d850477 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>
2012-04-27 23:38:24 +00:00
84e50fc764 Update NEWS for upcoming 4.7 release
* NEWS: Update for 4.7 release.
2012-04-20 17:32:50 +00:00
48e95c7b1a Sync strace.spec and debian/ with packages
* debian/changelog: Sync with 4.5.20-2.3.
* debian/control: Likewise.
* strace.spec: Sync with 4.6-2.
2012-04-20 17:31:48 +00:00
Mike Frysinger
ebee04cfb0 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>
2012-04-18 15:27:25 +00:00
H.J. Lu
085e428860 x32: add ia32 support
* Makefile.am (EXTRA_DIST): Add linux/x32/errnoent1.h,
linux/x32/ioctlent1.h, linux/x32/signalent1.h and
linux/x32/syscallent1.h.
* configure.ac: Remove AC_GNU_SOURCE, obsoleted by
AC_USE_SYSTEM_EXTENSIONS.
* defs.h (SUPPORTED_PERSONALITIES): Set to 2 for X32.
(PERSONALITY1_WORDSIZE): Set to 4 for X32.
* file.c (stat64): New struct for X32.
(sys_lseek32): New function for X32.
(stat64): Undef.
(sys_fstat64): Likewise.
(sys_stat64): Likewise.
(realprintstat64): New function for X32.
(sys_fstat64): Likewise.
(sys_stat64): Likewise.
* mem.c (sys_old_mmap): New function for X32.
* pathtrace.c (pathtrace_match): Also check sys_old_mmap for X32.
* syscall.c (update_personality): Add X32 support.
(get_scno): Support currpers == 1 for X32.
* linux/syscall.h (sys_lseek32): New function prototype for X32.
* linux/x32/errnoent1.h: New file.
* linux/x32/ioctlent1.h: Likewise.
* linux/x32/signalent1.h: Likewise.
* linux/x32/syscallent1.h: Likewise.
2012-04-18 15:02:40 +00:00
H.J. Lu
2bb4581ee5 Cast clock_t type to unsigned long long
* resource.c (sys_times): Cast clock_t type to unsigned long long.
* signal.c (printsiginfo): Likewise.
2012-04-17 06:38:17 +04:00
Denys Vlasenko
6e4f3c1fa4 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>
2012-04-16 18:22:19 +02:00
Denys Vlasenko
61d62cf948 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>
2012-04-16 18:16:13 +02:00
Denys Vlasenko
142aee0a59 Trivial speed optimization
* strace.c (tprints): Use fputs_unlocked instead of fputs.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-16 18:10:15 +02:00
H.J. Lu
c933f27a3a 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>
2012-04-16 17:41:13 +02:00
H.J. Lu
35be58119e 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>
2012-04-16 13:00:01 +02:00
H.J. Lu
dd0130b963 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>
2012-04-16 12:16:45 +02:00
Mike Frysinger
0cbed357ab 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>
2012-04-06 14:39:15 +00:00
Mike Frysinger
7ff5ed9325 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>
2012-04-05 14:53:49 +00:00
Denys Vlasenko
f36ede69f7 Makefile.am: whitespace fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-29 17:21:41 +02:00
Anton Blanchard
7015fe4fd2 powerpc: Add syscall entries for direct socket system calls
* linux/powerpc/syscallent.h: Add direct socket system calls.
2012-03-27 00:05:25 +00:00
4372cc956b qual_syscall: fix potential NULL dereference
Fix regression introduced by commit
c1371ebc40

* syscall.c (qual_syscall): Handle null sys_name.

Reported-by: Fr. Br. George <george@altlinux.org>
2012-03-26 14:14:50 +00:00
030d555ce5 strace-log-merge: fix file suffix calculation
* strace-log-merge: Quote file prefix to fix file suffix calculation.

Reported-by: Denys Vlasenko <vda.linux@googlemail.com>
Suggested-by: Andreas Schwab <schwab@linux-m68k.org>
2012-03-26 12:10:01 +00:00
Denys Vlasenko
df790130ff Remove unreachable code
* strace.c (process_opt_p_list): Remove unreachable code.
2012-03-26 13:41:56 +02:00
Denys Vlasenko
94f00e62b4 manpage: remove false info about -p being limited to 32 processes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-26 13:31:11 +02:00
Denys Vlasenko
c5ccfa450b Tweak help text and manpage (added -In to manpage)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-26 13:10:50 +02:00
378f9c5ad0 printstr: check for potential integer overflow
* util.c (printstr): Check for potential integer overflow during outstr
buffer size calculation.
2012-03-25 22:56:53 +00:00
ccee169ab6 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.
2012-03-25 21:49:48 +00:00
20f6b54385 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.
2012-03-25 21:04:57 +00:00
d8879f4206 configure.ac: sort lists and use m4_normalize to ease maintenance
* configure.ac (AC_CHECK_FUNCS, AC_CHECK_HEADERS, AC_CHECK_MEMBERS,
AC_CHECK_DECLS): Sort lists, use m4_normalize.
2012-03-25 15:22:03 +00:00
Denys Vlasenko
e4cc7c58dd 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>
2012-03-23 11:29:01 +01:00
Denys Vlasenko
d63b0d5682 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>
2012-03-23 11:26:36 +01:00