Jump to content

Strace: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
→‎History: spelling
→‎History: No sources provided, so it's better to leave out such information
Line 40: Line 40:
</pre>
</pre>


Later, Branko Lankester ported this version to [[Linux]], releasing his version in November 1992 with the second release following in 1993.<ref>{{cite web |url=ftp://ftp.funet.fi/pub/Linux/tools/strace.tar.Z |title=first Linux release of strace |author=Branko Lankester |date=November 5, 1992 }}</ref><ref>{{cite web |url=ftp://ftp.funet.fi/pub/Linux/tools/strace-2.tgz |title=second Linux release of strace |author=Branko Lankester |date=June 18, 1993 }}</ref> The first release required a patch to be applied to the Linux kernel source, bringing the needed ptrace enhancements from SunOS that allow tracing of system calls.{{discuss|Comment about ptrace}} Richard Sladkey combined these separate versions of strace in 1993, and ported the program to [[SVR4]] and [[Solaris (operating system)|Solaris]] in 1994,<ref>{{cite web |url=http://manned.org/strace/e47b83b9 |title=strace |publisher=manned.org |date=June 21, 1994 }}</ref> resulting in strace&nbsp;3.0 that was announced in comp.sources.misc in mid-1994.<ref>{{cite web |url=http://ftp.sunet.se/pub/usenet/ftp.uu.net/comp.sources.misc/index |title=SUNET's Index of /pub/usenet/ftp.uu.net/comp.sources.misc/volume43/strace |accessdate=January 14, 2015}}</ref>
Later, Branko Lankester ported this version to [[Linux]], releasing his version in November 1992 with the second release following in 1993.<ref>{{cite web |url=ftp://ftp.funet.fi/pub/Linux/tools/strace.tar.Z |title=first Linux release of strace |author=Branko Lankester |date=November 5, 1992 }}</ref><ref>{{cite web |url=ftp://ftp.funet.fi/pub/Linux/tools/strace-2.tgz |title=second Linux release of strace |author=Branko Lankester |date=June 18, 1993 }}</ref> Richard Sladkey combined these separate versions of strace in 1993, and ported the program to [[SVR4]] and [[Solaris (operating system)|Solaris]] in 1994,<ref>{{cite web |url=http://manned.org/strace/e47b83b9 |title=strace |publisher=manned.org |date=June 21, 1994 }}</ref> resulting in strace&nbsp;3.0 that was announced in comp.sources.misc in mid-1994.<ref>{{cite web |url=http://ftp.sunet.se/pub/usenet/ftp.uu.net/comp.sources.misc/index |title=SUNET's Index of /pub/usenet/ftp.uu.net/comp.sources.misc/volume43/strace |accessdate=January 14, 2015}}</ref>


==Usage==
==Usage==

Revision as of 13:47, 21 January 2015

strace
Original author(s)Paul Kranenburg
Developer(s)Dmitry Levin
Stable release
4.9 / August 15, 2014; 9 years ago (2014-08-15)
Repository
Written inC
Operating systemLinux
TypeDebugging
LicenseBSD
Websitesourceforge.net/projects/strace/

strace is a diagnostic, debugging and instructional userspace utility. It is used to monitor interactions between processes, which include system calls, signal deliveries, and changes of process state. The operation of strace is made possible by the kernel feature known as ptrace.

Some Unix-like systems provide other diagnostic tools similar to strace, such as truss.

History

Strace was originally written for SunOS by Paul Kranenburg in 1991, according to its copyright notice, and published early in 1992, in the volume three of comp.sources.sun. The initial README file contained the following:[1]

strace(1) is a system call tracer for Sun(tm) systems much like the
Sun supplied program trace(1). strace(1) is a useful utility to sort
of debug programs for which no source is available which unfortunately
includes almost all of the Sun supplied system software.

Later, Branko Lankester ported this version to Linux, releasing his version in November 1992 with the second release following in 1993.[2][3] Richard Sladkey combined these separate versions of strace in 1993, and ported the program to SVR4 and Solaris in 1994,[4] resulting in strace 3.0 that was announced in comp.sources.misc in mid-1994.[5]

Usage

The most common usage is to start a program using strace, which prints a list of system calls made by the program. This is useful if the program continually crashes, or does not behave as expected; for example using strace may reveal that the program is attempting to access a file which does not exist or cannot be read.

An alternative application is to use the -p flag to attach to a running process. This is useful if a process has stopped responding, and might reveal, for example, that the process is blocking whilst attempting to make a network connection.

As strace only details system calls, it cannot be used to detect as many problems as a code debugger such as GNU Debugger (gdb). It is, however, easier to use than a code debugger, and is an extremely useful tool for system administrators. It is also used by researchers to generate system call traces for later system call replay.[6] [7] [8]

Examples

The following is an example of typical output of the strace command:

open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
fcntl64(3, F_GETFD)                     = 0x1 (flags FD_CLOEXEC)
getdents64(3, /* 18 entries */, 4096)   = 496
getdents64(3, /* 0 entries */, 4096)    = 0
close(3)                                = 0
fstat64(1, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f2c000
write(1, "autofs\nbackups\ncache\nflexlm\ngames"..., 86autofsA

The above fragment is only a small part of the output of strace when run on the 'ls' command. It shows that the current working directory is opened, inspected and its contents retrieved. The resulting list of file names is written to standard output.

Other tools

Different operating systems feature other similar (and sometimes more powerful) instrumentation tools, for example:

See also

References

  1. ^ Paul Kranenburg (March 2, 1992). "Strace - an alternative syscall tracer". Newsgroupcomp.sources.sun.
  2. ^ Branko Lankester (November 5, 1992). "first Linux release of strace".
  3. ^ Branko Lankester (June 18, 1993). "second Linux release of strace".
  4. ^ "strace". manned.org. June 21, 1994.
  5. ^ "SUNET's Index of /pub/usenet/ftp.uu.net/comp.sources.misc/volume43/strace". Retrieved January 14, 2015.
  6. ^ Horky, Jiri (2013). "The ioapps IO profiler and IO traces replayer". Retrieved 2013-09-16.
  7. ^ Waterland, Amos (2007). "The sreplay system call replayer". Retrieved 2013-09-16.
  8. ^ Burton, Ariel (1998). "Workload characterization using lightweight system call tracing and reexecution" (PDF). Retrieved 2013-09-16.
  9. ^ "XTrace - trace X protocol connections". xtrace.alioth.debian.org. Retrieved 2014-08-12.
  10. ^ "dtrace(1) Mac OS X Manual Page". Developer.apple.com. Retrieved 2014-07-23.
  11. ^ "Products - StraceNT - Strace for Windows". IntellectualHeaven. Retrieved 2014-07-23.

External links