Commit Graph

1852 Commits

Author SHA1 Message Date
3d7b11bf55 Fix IPC decoding on alpha and arm
* ipc.c (indirect_ipccall): Return 0 on ALPHA and ARM EABI.
(sys_shmat): Use indirect_ipccall for proper return value decoding.
2012-03-15 21:19:36 +00:00
63e4f86bd7 arm: fix compilation warnings
* configure.ac: Define SIZEOF_LONG.
* signal.c (sys_rt_sigaction) [SUPPORTED_PERSONALITIES > 1]: Help
compiler to optimize out unreachable code that is not expected to work
on platforms where sizeof(long) <= 4.
2012-03-15 20:42:46 +00:00
84abf70011 tests: robustify again buggy shells
* tests/init.sh (check_strace): Use "${parameter:-word}" shell syntax
instead of "${parameter-word}".

Reported-by: Mike Frysinger <vapier@gentoo.org>
2012-03-15 20:17:49 +00:00
Mike Frysinger
3362e89f66 improve ifdef check with decode_subcall
Use the same ifdef logic around the call sites of decode_subcall()
to protect the definition of the func itself.  This fixes warnings
for targets like hppa which don't use this func.

* syscall.c (decode_subcall): Wrap in SYS_socket_subcall and
SYS_ipc_subcall define checks.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-03-15 20:14:28 +00:00
Mike Frysinger
dde045c13f alpha: fix decode of osf_sigprocmask
The alpha sigprocmask syscall is special in that it comes from OSF rather
than the style that everyone else uses.

Tested with this simple code:
$ cat test.c
#include <signal.h>
main() {
	sigset_t set, oldset;
	sigemptyset(&set);
	sigaddset(&set, SIGINT);
	sigaddset(&set, SIGHUP);
	sigprocmask(SIG_SETMASK, &set, &oldset);
	sigprocmask(SIG_UNBLOCK, &oldset, &set);
	sleep(3);
}
$ gcc test.c && ./strace ./a.out
...
osf_sigprocmask(SIG_SETMASK, [HUP INT]) = 0 (old mask [])
osf_sigprocmask(SIG_UNBLOCK, [])        = 0x3 (old mask [HUP INT])
osf_sigprocmask(SIG_BLOCK, [CHLD])      = 0x3 (old mask [HUP INT])
...

* linux/alpha/syscallent.h: Call sys_sigprocmask for osf_sigprocmask,
and change number of arguments to two.
* signal.c (sys_sigprocmask): Fix decoding of alpha osf sigprocmask.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-03-15 20:14:17 +00:00
Denys Vlasenko
384b0ada7d Fix array size calculation in previous commit
* pathtrace.c (getfdpath): Fix array size calculation.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 18:11:51 +01:00
Denys Vlasenko
29865e77e6 pathtrace_select() is never called with NULL, remove dead code
pathtrace_select() is only called for -P FILE options,
and FILE is never a NULL pointer.

   text	   data	    bss	    dec	    hex	filename
 239453	    672	  19012	 259137	  3f441	strace.before
 239329	    672	  19012	 259013	  3f3c5	strace

* pathtrace.c (pathtrace_select): Remove "if (path == NULL)...".
(pathtrace_select): Remove code which only executes if path == NULL.
The code was also buggy, it can free non-malloced pointer.
(getfdpath): Simplify snprintf to sprintf.
(pathmatch): Use strcmp() == 0 idiom for string equality test.
(pathtrace_match): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 18:03:56 +01:00
Denys Vlasenko
7c2b1a6dd0 manpage: remove bugs which are fixed
"A traced process ignores SIGSTOP" - fixed, expected to be in linux-3.4.x.
"A traced process which tries to block SIGTRAP will be sent a SIGSTOP
in an attempt to force continuation of tracing." - not needed
and no longer done.
"On Linux, exciting as it would be, tracing the init process is forbidden"
- not true anymore.
"When a traced process receives a SIGTRAP signal not
associated with tracing, strace will not report that signal correctly."
- not true anymore.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 17:32:56 +01:00
Denys Vlasenko
a509054aee Simplify SIGCHLD handler setting
* strace.c (init): Set SIGCHLD to SIG_DFL earlier.
(startup_child): Do not bother restoring SIGCHLD handler.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 17:27:49 +01:00
Denys Vlasenko
2c4fb905fe When reporting signals, use short signal names (SIGfoo) instead of strerror
* defs.h: Remove strsignal declaration.
* signal.c: Better check for SI_FROMUSER define.
* strace.c (strerror): Remove this function.
(trace): Use short signal names (SIGfoo) instead of strerror.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 17:24:49 +01:00
Denys Vlasenko
7cba831386 Remove TODO file: it's eleven years old and completely outdated
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 15:55:33 +01:00
Denys Vlasenko
29898149a0 Clean up defs.h order. No code changes
* defs.h: Group together related declarations. No code changes.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 15:02:49 +01:00
Denys Vlasenko
6e0bfd11ac Fix lame kernel version checking code
The code "os_release[0] >= '3'" is not good for any
finer-grained checks such as "kernel >= 3.2.1".
Let's proactively fix it.

* strace.c: Change os_release from string to integer.
(get_os_release): Parse uname.release to KERNEL_VERSION
representation.
(init): Convert kernel version check to KERNEL_VERSION.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 14:36:28 +01:00
Denys Vlasenko
61e7aad9fa Experimental support for "detach on execve" feature
* strace.c: Define new detach_on_execve, skip_startup_execve bool variables.
(init): Set detach_on_execve on -b, set skip_startup_execve if
"strace PROG" form is used.
(trace): Detach from process if -b and we see PTRACE_EVENT_EXEC event.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 13:44:17 +01:00
Denys Vlasenko
3e084ac349 Simple fixes.
* strace.c (usage): Document -d; document that -F is deprecated.
(droptcb): Print "<detached ...>" correctly for non-ff mode too.
(detach): Suppress a warning.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 13:39:05 +01:00
Denys Vlasenko
68269aa29f Remove an outdated comment
* defs.h: Remove an outdated comment.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 13:02:31 +01:00
Denys Vlasenko
bcde70adbc Remove extra include directives. No code changes.
* defs.h: Include <signal.h> unconditionally.
Other files were doing it unconditionally, so no harm done.
* bjm.c: Remove system includes which are already included by defs.h.
* pathtrace.c: Likewise.
* process.c: Likewise.
* signal.c: Likewise.
* strace.c: Likewise.
* stream.c: Likewise.
* syscall.c: Likewise.
* system.c: Likewise.
* util.c: Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 12:56:25 +01:00
Denys Vlasenko
a50d2a87a1 Tidy up order of includes; make bool variables explicit.
Bool variables are more compact in data and (on x86) on code too:

   text	   data	    bss	    dec	    hex	filename
 237950	    676	  19044	 257670	  3ee86	strace.before
 237838	    676	  19012	 257526	  3edf6	strace

* defs.h: Group library includes at the top of the file.
Rename dtime to Tflag, debug to debug_flag.
Change debug_flag,Tflag,qflag,not_failing_only,show_fd_path,tracing_paths
variable declarations from int to bool.
* strace.c: Change corresponding definitions. Do the same for static
variables iflag,rflag,print_pid_pfx.
Rename dtime to Tflag, debug to debug_flag.
* syscall.c: Rename dtime to Tflag, debug to debug_flag.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-15 12:49:52 +01:00
b859e14d20 Fix compiler warnings about breaking strict-aliasing rules
* system.c (sys_capget, sys_capset): Use proxy unions to cast long*
pointers to cap_user_header_t and cap_user_data_t pointers without
breaking strict-aliasing rules.

Reported-by: Mike Frysinger <vapier@gentoo.org>
2012-03-15 02:03:36 +00:00
Mike Frysinger
c96fdfae97 ppc64: drop unused pid variable
* syscall.c (get_scno) [POWERPC64]: Delete unused pid variable.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-03-15 01:04:31 +00:00
8f81e385c7 ia64: fix compilation warnings
* linux/ia64/syscallent.h: Remove improper defines and undefs.

Reported-by: Mike Frysinger <vapier@gentoo.org>
2012-03-15 01:01:25 +00:00
ad0c01eeed Ensure that SWAP_FLAG_* constants are defined
* file.c: Define those of SWAP_FLAG_* constants which are not yet
provided by <sys/swap.h>.

Reported-by: Mike Frysinger <vapier@gentoo.org>
2012-03-15 00:52:22 +00:00
33d24762cd Enhance *listxattr syscalls decoding
* file.c (print_xattr_list): New function.
(sys_listxattr, sys_flistxattr): Use it.
2012-03-14 16:34:32 +00:00
7989ad4208 Fix *at syscalls flags decoding
Several *at decoders were defining own incomplete *atflags xlat
structures.  That was error prone, and fchownat decoder actually
failed to recognize AT_EMPTY_PATH.  Merging these incomplete
structures into the single at_flags xlat structure will fix
flags handling in all these decoders altogether.

* file.c: Define all AT_* constants used by *at decoders.
(at_flags): New xlat structure, with records for all AT_* constants.
(fstatatflags, linkat_flags, unlinkatflags): Remove.
(sys_newfstatat, sys_linkat, sys_unlinkat, sys_fchownat,
sys_utimensat):  Use at_flags.
2012-03-13 23:26:01 +00:00
371e153146 Fix linkat flags decoding
* file.c (linkat_flags): New xlat structure.
(sys_linkat): Decode flags using linkat_flags.
2012-03-13 23:16:37 +00:00
297632be5c Implement sys_rt_tgsigqueueinfo syscall decoder
* linux/dummy.h (sys_rt_tgsigqueueinfo): Remove.
* linux/syscall.h (sys_rt_tgsigqueueinfo): New prototype.
* signal.c (print_sigqueueinfo): New function, based on
sys_rt_sigqueueinfo.
(sys_rt_sigqueueinfo): Use print_sigqueueinfo.
(sys_rt_tgsigqueueinfo): New function.
2012-03-13 15:51:13 +00:00
ee3c22ce55 Implement syslog syscall decoder
* linux/dummy.h (sys_syslog): Remove.
* linux/syscall.h (sys_syslog): New prototype.
* system.c (syslog_action_type): New xlat structure.
(sys_syslog): New function.
2012-03-13 15:28:01 +00:00
Denys Vlasenko
67559ad260 Less ugly debug display of ptrace events
* strace.c (trace): Less ugly debug display of ptrace events.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-13 12:05:27 +01:00
Denys Vlasenko
6bc050cc54 Make manpage mention that -p "pidof PROG" works
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-13 11:48:22 +01:00
Denys Vlasenko
7de265d88a Fix logging for "strace -o FILE -ff test/threaded_execve" test case
Our logic which was deciding whether to print "<unfinished ...>"
thingy wasn't working properly for -ff case.

* defs.h: Group log generation-related declarations together.
Add a large comment which explains how it works.
Add declaration of line_ended() function.
* strace.c (line_ended): New function which sets up internal data
to indicate that previous line was finished.
(printleader): Change logic to fix log generation in -ff mode.
(newoutf): Make check for -ff mode consistent with other places.
(droptcb): Print "<detached ...>" if last line for this tcp wasn't finished.
(cleanup): Remove code to print "<unfinished ...>", printleader()
or detach() will do it instead.
(trace): Remove code to print "<unfinished ...>".
Add code which finishes threaded execve's incomplete line
with " <pid changed to PID ...>" message. Replace printing_tcp = NULL
followed by fflush() by line_ended() call.
* process.c (sys_exit): Call line_ended() to indicate that we finished priting.
* syscall.c (trace_syscall_exiting): Set printing_tcp to current tcp.
Call line_ended() to indicate that we finished priting.
Remove call to fflush(), it is done by line_ended() now.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-13 11:44:31 +01:00
3df080af31 net.c: recognize MSG_WAITFORONE
* net.c (msg_flags): Add MSG_WAITFORONE.
2012-03-13 01:26:26 +00:00
Denys Vlasenko
328bf250bd Treat -ff without -o FILE as single -f
* strace.c (init): Treat -ff without -o FILE as single -f.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-12 23:34:13 +01:00
Denys Vlasenko
558e5127fb Style fix. No code changes
* strace.c (process_opt_p_list): Style fix.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-12 23:32:16 +01:00
Denys Vlasenko
ecc8b97c9b Reduce stack usage by ~0.5k
main() uses ~0.5k of stack for local variables and such. When we enter
main tracing loop, most of these variables are no longer used.
But they still take up stack for the entire life of strace.
We can avoid this wastage if we move init code into a separate function.
(Need to be careful and not allow automatic inlining).

* strace.c (init): New function. Most of pre-existing code of
main is now living here.
(main): Call init() to do initialization.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-12 23:05:25 +01:00
Denys Vlasenko
2e856a1c92 Preparatory cosmetic changes for the next commit
* strace.c (tprintf): Move function up in the source file. No code changes.
(tprints): Likewise.
(printleader): Likewise.
(tabto): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-12 23:02:26 +01:00
7af9f35001 Implement sendmmsg syscall decoder
* linux/dummy.h (sys_sendmmsg): Remove.
* linux/syscall.h (sys_sendmmsg): New prototype.
* net.c (printmmsghdr): Add index argument specifying the element in
mmsghdr array to print.
(decode_mmsg): New function, prints the whole mmsghdr array, its length
and message flags.
(sys_sendmmsg): New function.
(sys_recvmmsg): Use decode_mmsg to fix mmsghdr array decoding.
2012-03-11 23:59:29 +00:00
1ff463d154 Implement sched_rr_get_interval syscall decoder
* linux/dummy.h (sys_sched_rr_get_interval): Remove.
* linux/syscall.h (sys_sched_rr_get_interval): New prototype.
* process.c (sys_sched_rr_get_interval): New function.
2012-03-11 23:00:11 +00:00
64d0e71f8b Implement migrate_pages syscall decoder
* linux/dummy.h (sys_migrate_pages): Remove.
* linux/syscall.h (sys_migrate_pages): New prototype.
* mem.c (sys_migrate_pages): New function.
2012-03-11 22:44:14 +00:00
1b0bae2969 Implement get_robust_list syscall decoder
* linux/dummy.h (sys_get_robust_list): Remove.
* linux/syscall.h (sys_get_robust_list): New prototype.
* process.c (sys_get_robust_list): New function.
2012-03-11 22:32:26 +00:00
1e8ed076ce Define sys_set_robust_list as an alias to sys_munmap
* linux/dummy.h (sys_set_robust_list): Redefine to sys_munmap.
2012-03-11 21:57:57 +00:00
73215473ce Implement clock_adjtime syscall decoder
* linux/dummy.h (sys_clock_adjtime): Remove.
* linux/syscall.h (sys_clock_adjtime): New prototype.
* time.c (do_adjtimex): New function, based on sys_adjtimex.
(sys_adjtimex): Use it.
(sys_clock_adjtime): New function.
2012-03-11 21:25:51 +00:00
51dba35d38 Define sys_setns as an alias to sys_inotify_rm_watch
* linux/dummy.h (sys_setns): Redefine to sys_inotify_rm_watch.
2012-03-11 15:45:20 +00:00
6bbe69609b Sort definitions of dummy parsers. No code changes
* linux/dummy.h: Sort definitions of parsers implemented as aliases.
2012-03-11 15:43:04 +00:00
ab1a70c7a1 Correct inotify_rm_watch decoder
* file.c (sys_inotify_rm_watch): Print second argument as int.
2012-03-11 15:33:34 +00:00
531af48779 Alias sys_fsync to sys_close
* file.c (sys_fsync): Remove.
* linux/syscall.h (sys_fsync): Likewise.
* linux/dummy.h (sys_fsync): Alias to sys_close.
* linux/m68k/syscallent.h: Add TD flag to fsync entry.
* linux/microblaze/syscallent.h: Likewise.
* linux/mips/syscallent.h: Likewise.
2012-03-11 15:28:03 +00:00
eb420ef585 Update ioctl entries
* linux/ioctlent.h.in: Regenerate from v3.3 headers.
* linux/i386/ioctlent.h.in: Likewise.
2012-03-10 21:15:58 +00:00
63c5e63f2c strace-log-merge: cleanup
* strace-log-merge: Redirect usage to stderr, make the check
for numeric suffix simpler.
2012-03-10 16:10:06 +00:00
d92029ef88 Add syscall entries for new linux syscalls
* linux/i386/syscallent.h: Update process_vm_writev handler.
* linux/powerpc/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* linux/alpha/syscallent.h: Add entries for accept4 and sendmmsg.
* linux/arm/syscallent.h: Add entries for process_vm_readv and
process_vm_writev.
* linux/m68k/syscallent.h: Likewise.
* linux/mips/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Add entries for process_vm_readv,
process_vm_writev and accept4.
* linux/microblaze/syscallent.h: Add entries for sendmmsg,
process_vm_readv and process_vm_writev.
2012-03-10 15:04:16 +00:00
039521051e Implement process_vm_writev decoder
* process.c (sys_process_vm_writev): New function.
* linux/syscall.h (sys_process_vm_writev): New prototype.
2012-03-10 14:14:49 +00:00
0bfd74436d Output iovec length in vmsplice and process_vm_readv decoders
* io.c (sys_vmsplice): Output iovec length.
* process.c (sys_process_vm_readv): Likewise.
2012-03-10 14:03:25 +00:00