Commit Graph

49 Commits

Author SHA1 Message Date
fa8c286d50 Implement simultaneous use of -p option and tracing of a command
* strace.c (init): Allow -p option along with a command.
(startup_child): In -D mode, record the parent of the tracer process
as strace_child.
(startup_attach): Save trace_tracer_pid before -D mode fork.
When tracing a command in -f mode, do not check for the command's
threads as it has no threads at this moment.
Never attach to the tracer process.
In -D mode, never attach to the parent of the tracer process,
terminate that process only once at the end of startup_attach,
and reset strace_child.
* strace.1: Document that -p option can be used along with tracing
of a command.
* NEWS: Mention it.
* tests/attach-p-cmd-cmd.c: New file.
* tests/attach-p-cmd-p.c: Likewise.
* tests/attach-p-cmd.test: New test.
* tests/.gitignore: Add attach-p-cmd-cmd and attach-p-cmd-p.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add attach-p-cmd.test.

This fixes Debian bug #549942.
2016-01-22 19:37:11 +00:00
38721432de strace.1: fix format of -P description
* strace.1 (-P): Write trailing using regular font.
2016-01-22 14:55:56 +00:00
a5c16b8656 Document that syscall names match kernel __NR_* constants
* strace.1: Note syscall naming difference between architectures
and the rule of choosing the right syscall name in each case.
2015-12-09 15:59:15 +00:00
Giedrius Statkevičius
6a63bfa160 Document that -k is available only with libunwind
Without this users might get confused why `man strace` describes
an option that doesn't work.

* strace.1: Note that -k is available only if strace is built
with libunwind.
2015-03-04 00:56:33 +00:00
2f6510c8a6 Add -yy option: print ip and port associated with socket descriptors
When two ore more -y options are given, print local and remote ip:port
pairs associated with socket descriptors.  This implementation uses
NETLINK_INET_DIAG for sockaddr lookup; it's based on the patch
prepared by Zubin Mithra as a part of his GSoC 2014 strace project.

* Makefile.am (strace_SOURCES): Add socketutils.c
(EXTRA_DIST): Add linux/inet_diag.h and linux/sock_diag.h.
* defs.h (print_sockaddr_by_inode): New prototype.
* linux/inet_diag.h: New file.
* linux/sock_diag.h: Likewise.
* socketutils.c: Likewise.
* strace.1: Document -yy option.
* strace.c (usage): Likewise.
* util.c (printfd): Use print_sockaddr_by_inode.
2014-09-17 20:03:38 +00:00
2734a7010f Document -k option as experimental
strace -k does not produce a reliable output on all supported
configurations yet, even basic strace-k.test is known to fail
on some of them.

* strace.c (usage): Document -k option as experimental.
* strace.1: Likewise.
* NEWS: Likewise.
2014-06-18 15:41:19 +00:00
a197832282 manpage: minor corrections
$ groff -ww -mandoc -z strace.1
strace.1:65: warning: macro `IX' not defined

* strace.1: define IX macro as empty for groff.
Change remaining '-' as minus to '\-'.
Have two word spaces after a full stop as an end of sentence.
Use extra space ('\,' or '\/') between roman and italic characters.
Based on patch by Bjarni Ingi Gislason <bjarniig@rhi.hi.is>.
This fixes Debian bug #725987.
2014-06-03 12:36:14 +00:00
Luca Clementi
327064b637 Add -k option to print stack trace after each syscall
Print the stack trace of the traced process after each system call when
-k option is specified.  It is implemented using libunwind to unwind the
stack and to obtain the function name pointed by the IP.

Based on the code that was originally taken from strace-plus
of Philip J. Guo.

* configure.ac: Add --with-libunwind option.  Check libunwind support.
* Makefile.am: Add libunwind support.
* defs.h (struct tcb) [USE_LIBUNWIND]: Append libunwind specific fields.
[USE_LIBUNWIND] (stack_trace_enabled, alloc_mmap_cache,
delete_mmap_cache, print_stacktrace): New prototypes.
* mem.c (print_mmap, sys_munmap, sys_mprotect): Add libunwind support.
* process.c (sys_execve): Likewise.
* strace.c (usage, alloctcb, droptcb, init): Likewise.
* syscall.c (trace_syscall_exiting): Likewise.
* unwind.c: New file.
* strace.1: Document -k option.
2014-05-30 22:24:31 +00:00
Mark Hills
e53bf23f1c Optionally produce stats on syscall latency
Time spent in system time is not useful where a syscall depends on some
non-CPU resource, eg. typically open() or stat() to a network drive.

This patch adds a new flag (-w) to produce a summary of the time
difference between beginning and end of the system call (ie. latency)

This functionality has been useful to profile slow processes that
are not CPU-bound.

Signed-off-by: Mark Hills <mark.hills@framestore.com>
2014-05-29 18:15:38 +00:00
Denys Vlasenko
711b17c44b Another manpage tweak
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-06-26 15:40:13 +02:00
Denys Vlasenko
b5370530d5 Manpage update
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-06-26 15:35:16 +02:00
e8ff4c6f86 Do not suppress signal delivery messages with -qq
Current implementation of -qq does not allow suppressing exit status
messages without suppressing signal delivery messages, which is not
good.  There is a traditional "-e signal=none" syntax that can be used
to suppress all signal delivery messages.
This partially reverts commit v4.7-222-g01997cf.

* strace.c (trace): Do not suppress signal delivery messages with -qq.
* strace.1: Update documentation about -qq option.
2013-05-28 21:49:16 +00:00
Daniel P. Berrange
01997cf32d Allow -q to be repeated for very quiet output
Even with the -q flag specified, tracing output is still mixed
with messages about signals and process exit status, which is
often irrelevant.  Allow the -q option to be repeated to force
the suppression of signals / exit status info too.

* defs.h: Change 'qflag' from 'bool' to 'unsigned int'.
* strace.1: Document ability to repeat '-q' option.
* strace.c: Allow '-q' to be repeated to quieten process
exit status and signal messages.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-13 14:11:31 +00:00
Denys Vlasenko
7239dbcf2d Use dynamically-sized selected[] array for -P PATH
While at it, added a small optimization of not remembering
the path twice if it happens to be the same.

   text	   data	    bss	    dec	    hex	filename
 245111	    680	  10860	 256651	  3ea8b	strace_old
 245075	    680	   9804	 255559	  3e647	strace

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-05 15:46:34 +01:00
Denys Vlasenko
22efaf0028 Make -b take SYSCALL param, document it in --help and in manpage.
To not waste an option letter for just one trick,
extend -b to take a parameter:
"on which syscalls do you want to detach?".
Currently supports only execve.

While at it, fixed (by removing non-Linux and stale info)
and extended manpage text about -f.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-27 12:15:19 +01:00
Namhyung Kim
9679296d56 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>
2012-10-26 22:45:08 +00: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
Denys Vlasenko
a6d91ded3f Tidy up includes and copyright notices, fix indentation
The files not mentioned in changelog below had only
copyright notices fixes and indentation fixes.

* defs.h: Include <stdint.h> and <inttypes.h>.
* file.c: Do not include <inttypes.h>.
Move struct kernel_dirent declaration below top include block.
* block.c: Do not include <stdint.h> and <inttypes.h>.
* quota.c: Likewise.
* desc.c: Likewise.
* signal.c: Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-16 12:02:22 +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
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
dd762c302d Remove and update documentation
This change is a verbatim part of Dmitry's changes to remove support
for non-Linux architectures.

* PORTING: Deleted.
* INSTALL: Modified.
* README: Modified.
* strace.1: Modified: bugs should be reported to mailing list, not Debian.
* strace.spec: do not install PORTING file.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-25 15:29:21 +01:00
Denys Vlasenko
5afdf12572 Manual removal of non-Linux source, documentation, etc.
Remove non-Linux source directories: freebsd/, svr4/, sunos4/, svr4/.
Remove README-freebsd, README-sunos4, README-svr4, m4/procfs.m4.

linux/sparc/{errnoent1,ioctlent1,signalent1}.h used to point to svr4/ files -
replace their contents with copies of used (and now deleted) files.
Make linux/sparc64/{errnoent1,ioctlent1,signalent1}.h include these files
instead of svr4/* ones.

Makefile.am: remove references to deleted files.
configure.ac: Remove a few tests which make no sense on Linux.
Man page: remove non-Linux quirks information.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-25 02:30:32 +01:00
9b3eb84a85 strace.1: fix a typo
* strace.1: Fix a typo in example description.
This fixes Debian bug #653309.
2012-02-22 00:29:44 +00:00
Grant Edwards
8a08277d13 Add ability to print file descriptor paths and filter by those paths
* pathtrace.c: New file, implements matching syscall arguments to
user-specified file paths.
* Makefile.am (strace_SOURCES): Add pathtrace.c.
* defs.h (TCB_FILTERED, filtered): New defines.
(getfdpath, pathtrace_select, pathtrace_match, show_fd_path,
tracing_paths): New declarations.
* strace.c (show_fd_path, tracing_paths): New global variables.
(usage, main): Implement handling of -y and -P options.
* strace.1: Add descriptions of -y and -P options.
* syscall.c (trace_syscall_entering): Add path matching logic to the
print/noprint decision and set the TCB_FILTERED bit appropriately.
(trace_syscall_exiting): Use filtered() macro that checks the
TCB_FILTERED bit to determine print/noprint status.
* util.c (printfd): Use getfdpath().
2011-04-08 20:47:56 +00:00
1c3031b1f0 strace.1: fix misleading italics
* strace.1: Use bold instead of italics for "-e trace=" keywords.
This fixes Debian bug #589323.
2011-01-14 17:17:20 +00:00
Andreas Schwab
b87d30c785 Document -C/-D
* strace.c (usage): Document -C.
* strace.1: Document -D.
2010-06-24 17:14:01 +02:00
a7835e631a * strace.1: Fix quoting of hyphens and formatting of strace options. 2010-04-07 10:19:26 +00:00
e3a7ef5a2a Implement -C option to combine regular and -c output
* defs.h (cflag_t): New enum.
* strace.1: Document -C option.
* strace.c (cflag): Update type.
(main): Handle -C option.
(trace): Update use of cflag.
* count.c (count_syscall): Move clearing of TCB_INSYSCALL to ...
* syscall.c (trace_syscall): ... here.  Update use of cflag.
Based on patch by Adrien Kunysz.
2010-04-07 10:19:26 +00:00
Roland McGrath
a09353acc6 2008-12-09 Roland McGrath <roland@redhat.com>
* strace.1 (DIAGNOSTICS): New section, describe exit behavior.
2008-12-10 06:09:29 +00:00
Denys Vlasenko
28e81da91c manpage: document new feature of propagating exit code/signal death status. 2008-12-09 14:15:56 +00:00
Jan Kratochvil
14256a7d26 2008-09-12 Tomas Pospisek <tpo@sourcepole.ch>
Jan Kratochvil  <jan.kratochvil@redhat.com>

	* strace.1 (DESCRIPTION): New description of unfinished system calls
	and system calls restarting.
2008-09-12 08:44:30 +00:00
Roland McGrath
98a3ecfa99 2008-08-28 Roland McGrath <roland@redhat.com>
* strace.1 (BUGS): New section, mention SIGTRAP interference.
2008-08-28 23:41:57 +00:00
Roland McGrath
41c48227a8 2008-07-03 Jan Kratochvil <jan.kratochvil@redhat.com>
Trace even VFORK on -f on all the platforms.
	* strace.1 <-f>: Describe Linux catches new children immediately.
	<-F>: Make the option obsolete.  Move the SunOS VFORK comment to the
	`-f' option description.
	* defs.h (followvfork): Declaration removed.
	* strace.c (followvfork): Variable removed.
	(main) <-F>: Merge with the `-f' option.
	(trace): Make !FOLLOWVFORK unconditional.
	* process.c (internal_fork): Make !FOLLOWVFORK unconditional.
2008-07-18 00:25:10 +00:00
Roland McGrath
cb9def6975 2006-04-25 Roland McGrath <roland@redhat.com>
* strace.c (main): Fail when -c is given with -ff.
	* strace.1: Note their incompatibility.
	Fixes RH#187847.
2006-04-25 07:48:03 +00:00
Roland McGrath
7f7f436b77 2005-08-08 Dmitry V. Levin <ldv@altlinux.org>
* strace.1: Update "SEE ALSO" links to reference to valid
	manpages.
	Patch from Michail Litvak <mci@owl.openwall.com>.
	Fixes RH#165375.
2005-12-02 03:59:35 +00:00
Roland McGrath
2fe7b13b2f 2005-06-08 Dmitry V. Levin <ldv@altlinux.org>
Introduce "-e trace=desc".
	* defs.h (TRACE_DESC): New flag.
	* syscall.c: Define TD macro before include of syscallent files
	and undefine it afterwards.
	(lookup_class): Recognize "desc" keyword.
	* strace.1: Document "-e trace=desc".
	* freebsd/i386/syscallent.h: Mark those syscalls which take a
	file descriptor as an argument or return a file descriptor with
	TD flag.
	* linux/alpha/syscallent.h: Likewise.
	* linux/hppa/syscallent.h: Likewise.
	* linux/ia64/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/sparc64/syscallent2.h: Likewise.
	* linux/sparc64/syscallent.h: Likewise.
	* linux/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* sunos4/syscallent.h: Likewise.
	* svr4/syscallent.h: Likewise.
	Fixes RH#159400.
2005-07-05 03:25:35 +00:00
Roland McGrath
4de04aa70f 2004-08-31 Roland McGrath <roland@redhat.com>
* strace.1: Say that -c shows system CPU time, not real time.
	Fixes Debian bug #254438.
2004-08-31 07:47:47 +00:00
Roland McGrath
3766a56ee7 2004-01-13 Roland McGrath <roland@redhat.com>
* strace.1: Remove comment about vfork on Linux.
	Fixes Debian bug #223390.
2004-01-13 09:59:55 +00:00
Roland McGrath
0411b40c2f 2003-10-21 Roland McGrath <roland@redhat.com>
* strace.1: Fixed a few spelling errors.
2003-10-22 06:16:32 +00:00
Roland McGrath
4417fda9ba 2003-01-21 Roland McGrath <roland@redhat.com>
* strace.c (main): Grok new option `-E var=val' or `-E var' to put
	var=val in environ or to remove var, respectively.
	(usage): Mention it.
	* strace.1, NEWS: Document it.
2003-01-24 04:31:20 +00:00
Roland McGrath
4a9b49a96f 2003-01-14 Roland McGrath <roland@redhat.com>
* strace.1: Update bug reporting info.
2003-01-14 23:40:55 +00:00
Wichert Akkerman
4dc8a2aec6 Bunch of stuff 1999-12-23 14:20:14 +00:00
Wichert Akkerman
8dc9a1a3c5 Update versionnumber to 4.0 1999-07-09 14:08:14 +00:00
Wichert Akkerman
8829a55dc2 Various fixes, see ChangeLog for details 1999-06-11 13:18:40 +00:00
Wichert Akkerman
f9d3dcbea2 Update maintainer name in manpage 1999-05-15 00:29:13 +00:00
Nate Sammons
b4aa1139eb Fix a couple of typos in the man page. 1999-03-31 05:59:04 +00:00
Nate Sammons
ccd8f21626 Add capability for Linux to change a vfork call into plain fork, which
can be followed.  (Requires a kernel patch for now.)  Also document it.
1999-03-29 22:57:54 +00:00
Wichert Akkerman
76baf7c9f6 Initial revision 1999-02-19 00:21:36 +00:00