blob: aff8f412e1a376e009fedadada78e38286aebee5 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001.\" Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
2.\" Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
3.\" Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. The name of the author may not be used to endorse or promote products
15.\" derived from this software without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.\" $Id$
29.\"
30.de CW
31.sp
32.nf
33.ft CW
34..
35.de CE
Wichert Akkerman8829a551999-06-11 13:18:40 +000036.ft R
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000037.fi
38.sp
39..
Roland McGrath4417fda2003-01-24 04:31:20 +000040.TH STRACE 1 "2003-01-21"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000041.SH NAME
42strace \- trace system calls and signals
43.SH SYNOPSIS
44.B strace
45[
Dmitry V. Levine3a7ef52010-03-28 19:24:54 +000046.B \-CdffhiqrtttTvxx
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047]
48[
49.BI \-a column
50]
51[
52.BI \-e expr
53]
54\&...
55[
56.BI \-o file
57]
58[
59.BI \-p pid
60]
61\&...
62[
63.BI \-s strsize
64]
65[
66.BI \-u username
67]
68[
Roland McGrath4417fda2003-01-24 04:31:20 +000069.BI \-E var=val
70]
71\&...
72[
73.BI \-E var
74]
75\&...
76[
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000077.I command
78[
79.I arg
80\&...
81]
82]
83.sp
84.B strace
85.B \-c
86[
87.BI \-e expr
88]
89\&...
90[
91.BI \-O overhead
92]
93[
94.BI \-S sortby
95]
96[
97.I command
98[
99.I arg
100\&...
101]
102]
103.SH DESCRIPTION
104.IX "strace command" "" "\fLstrace\fR command"
105.LP
106In the simplest case
107.B strace
108runs the specified
109.I command
110until it exits.
111It intercepts and records the system calls which are called
112by a process and the signals which are received by a process.
113The name of each system call, its arguments and its return value
114are printed on standard error or to the file specified with the
115.B \-o
Roland McGratha09353a2008-12-10 06:09:29 +0000116option.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000117.LP
118.B strace
Nate Sammonsb4aa1131999-03-31 05:59:04 +0000119is a useful diagnostic, instructional, and debugging tool.
Roland McGrath0411b402003-10-22 06:16:32 +0000120System administrators, diagnosticians and trouble-shooters will find
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000121it invaluable for solving problems with
122programs for which the source is not readily available since
123they do not need to be recompiled in order to trace them.
124Students, hackers and the overly-curious will find that
125a great deal can be learned about a system and its system calls by
126tracing even ordinary programs. And programmers will find that
127since system calls and signals are events that happen at the user/kernel
128interface, a close examination of this boundary is very
129useful for bug isolation, sanity checking and
130attempting to capture race conditions.
131.LP
132Each line in the trace contains the system call name, followed
133by its arguments in parentheses and its return value.
134An example from stracing the command ``cat /dev/null'' is:
135.CW
136open("/dev/null", O_RDONLY) = 3
137.CE
138Errors (typically a return value of \-1) have the errno symbol
139and error string appended.
140.CW
141open("/foo/bar", O_RDONLY) = -1 ENOENT (No such file or directory)
142.CE
143Signals are printed as a signal symbol and a signal string.
144An excerpt from stracing and interrupting the command ``sleep 666'' is:
145.CW
146sigsuspend([] <unfinished ...>
147--- SIGINT (Interrupt) ---
148+++ killed by SIGINT +++
149.CE
Jan Kratochvil14256a72008-09-12 08:44:30 +0000150If a system call is being executed and meanwhile another one is being called
151from a different thread/process then
152.B strace
153will try to preserve the order of those events and mark the ongoing call as
154being \fIunfinished\fP. When the call returns it will be marked as
155\fIresumed\fP.
156.CW
157[pid 28772] select(4, [3], NULL, NULL, NULL <unfinished ...>
158[pid 28779] clock_gettime(CLOCK_REALTIME, {1130322148, 939977000}) = 0
159[pid 28772] <... select resumed> ) = 1 (in [3])
160.CE
161Interruption of a (restartable) system call by a signal delivery is processed
162differently as kernel terminates the system call and also arranges its
163immediate reexecution after the signal handler completes.
164.CW
165read(0, 0x7ffff72cf5cf, 1) = ? ERESTARTSYS (To be restarted)
166--- SIGALRM (Alarm clock) @ 0 (0) ---
167rt_sigreturn(0xe) = 0
168read(0, ""..., 1) = 0
169.CE
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000170Arguments are printed in symbolic form with a passion.
Roland McGrath0411b402003-10-22 06:16:32 +0000171This example shows the shell performing ``>>xyzzy'' output redirection:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000172.CW
173open("xyzzy", O_WRONLY|O_APPEND|O_CREAT, 0666) = 3
174.CE
175Here the three argument form of open is decoded by breaking down the
176flag argument into its three bitwise-OR constituents and printing the
177mode value in octal by tradition. Where traditional or native
178usage differs from ANSI or POSIX, the latter forms are preferred.
Wichert Akkerman8829a551999-06-11 13:18:40 +0000179In some cases,
180.B strace
181output has proven to be more readable than the source.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000182.LP
183Structure pointers are dereferenced and the members are displayed
184as appropriate. In all cases arguments are formatted in the most C-like
185fashion possible.
186For example, the essence of the command ``ls \-l /dev/null'' is captured as:
187.CW
188lstat("/dev/null", {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0
189.CE
190Notice how the `struct stat' argument is dereferenced and how each member is
191displayed symbolically. In particular, observe how the st_mode member
192is carefully decoded into a bitwise-OR of symbolic and numeric values.
193Also notice in this example that the first argument to lstat is an input
194to the system call and the second argument is an output. Since output
Wichert Akkerman8829a551999-06-11 13:18:40 +0000195arguments are not modified if the system call fails, arguments may not
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000196always be dereferenced. For example, retrying the ``ls \-l'' example
197with a non-existent file produces the following line:
198.CW
199lstat("/foo/bar", 0xb004) = -1 ENOENT (No such file or directory)
200.CE
201In this case the porch light is on but nobody is home.
202.LP
203Character pointers are dereferenced and printed as C strings.
204Non-printing characters in strings are normally represented by
205ordinary C escape codes.
206Only the first
207.I strsize
208(32 by default) bytes of strings are printed;
209longer strings have an ellipsis appended following the closing quote.
Wichert Akkerman8829a551999-06-11 13:18:40 +0000210Here is a line from ``ls \-l'' where the
211.B getpwuid
212library routine is reading the password file:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000213.CW
214read(3, "root::0:0:System Administrator:/"..., 1024) = 422
215.CE
216While structures are annotated using curly braces, simple pointers
217and arrays are printed using square brackets with commas separating
218elements. Here is an example from the command ``id'' on a system with
219supplementary group ids:
220.CW
221getgroups(32, [100, 0]) = 2
222.CE
223On the other hand, bit-sets are also shown using square brackets
224but set elements are separated only by a space. Here is the shell
225preparing to execute an external command:
226.CW
227sigprocmask(SIG_BLOCK, [CHLD TTOU], []) = 0
228.CE
229Here the second argument is a bit-set of two signals, SIGCHLD and SIGTTOU.
230In some cases the bit-set is so full that printing out the unset
231elements is more valuable. In that case, the bit-set is prefixed by
232a tilde like this:
233.CW
234sigprocmask(SIG_UNBLOCK, ~[], NULL) = 0
235.CE
236Here the second argument represents the full set of all signals.
237.SH OPTIONS
238.TP 12
239.TP
240.B \-c
Roland McGrath4de04aa2004-08-31 07:47:47 +0000241Count time, calls, and errors for each system call and report a summary on
242program exit. On Linux, this attempts to show system time (CPU time spent
Roland McGrathcb9def62006-04-25 07:48:03 +0000243running in the kernel) independent of wall clock time. If -c is used with
244-f or -F (below), only aggregate totals for all traced processes are kept.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000245.TP
Dmitry V. Levine3a7ef52010-03-28 19:24:54 +0000246.B \-C
247Like
248.B \-c
249but also print regular output while processes are running.
250.TP
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000251.B \-d
Wichert Akkerman8829a551999-06-11 13:18:40 +0000252Show some debugging output of
253.B strace
254itself on the standard error.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000255.TP
256.B \-f
257Trace child processes as they are created by currently traced
Wichert Akkerman8829a551999-06-11 13:18:40 +0000258processes as a result of the
259.BR fork (2)
Roland McGrath41c48222008-07-18 00:25:10 +0000260system call.
261.IP
262On non-Linux platforms the new process is
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000263attached to as soon as its pid is known (through the return value of
Wichert Akkerman8829a551999-06-11 13:18:40 +0000264.BR fork (2)
265in the parent process). This means that such children may run
266uncontrolled for a while (especially in the case of a
267.BR vfork (2)),
268until the parent is scheduled again to complete its
269.RB ( v ) fork (2)
Roland McGrath41c48222008-07-18 00:25:10 +0000270call. On Linux the child is traced from its first instruction with no delay.
Wichert Akkerman8829a551999-06-11 13:18:40 +0000271If the parent process decides to
272.BR wait (2)
273for a child that is currently
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000274being traced, it is suspended until an appropriate child process either
275terminates or incurs a signal that would cause it to terminate (as
276determined from the child's current signal disposition).
Roland McGrath41c48222008-07-18 00:25:10 +0000277.IP
278On SunOS 4.x the tracing of
279.BR vfork s
280is accomplished with some dynamic linking trickery.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000281.TP
282.B \-ff
283If the
284.B \-o
285.I filename
286option is in effect, each processes trace is written to
287.I filename.pid
288where pid is the numeric process id of each process.
Roland McGrathcb9def62006-04-25 07:48:03 +0000289This is incompatible with -c, since no per-process counts are kept.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000290.TP
291.B \-F
Roland McGrath41c48222008-07-18 00:25:10 +0000292This option is now obsolete and it has the same functionality as
293.BR -f .
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000294.TP
295.B \-h
296Print the help summary.
297.TP
298.B \-i
299Print the instruction pointer at the time of the system call.
300.TP
301.B \-q
302Suppress messages about attaching, detaching etc. This happens
303automatically when output is redirected to a file and the command
304is run directly instead of attaching.
305.TP
306.B \-r
307Print a relative timestamp upon entry to each system call. This
308records the time difference between the beginning of successive
309system calls.
310.TP
311.B \-t
312Prefix each line of the trace with the time of day.
313.TP
314.B \-tt
315If given twice, the time printed will include the microseconds.
316.TP
317.B \-ttt
318If given thrice, the time printed will include the microseconds
319and the leading portion will be printed as the number
320of seconds since the epoch.
321.TP
322.B \-T
323Show the time spent in system calls. This records the time
324difference between the beginning and the end of each system call.
325.TP
326.B \-v
327Print unabbreviated versions of environment, stat, termios, etc.
328calls. These structures are very common in calls and so the default
329behavior displays a reasonable subset of structure members. Use
330this option to get all of the gory details.
331.TP
332.B \-V
Wichert Akkerman8829a551999-06-11 13:18:40 +0000333Print the version number of
334.BR strace .
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000335.TP
336.B \-x
Wichert Akkerman8829a551999-06-11 13:18:40 +0000337Print all non-ASCII strings in hexadecimal string format.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000338.TP
339.B \-xx
340Print all strings in hexadecimal string format.
341.TP
342.BI "\-a " column
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000343Align return values in a specific column (default column 40).
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000344.TP
345.BI "\-e " expr
346A qualifying expression which modifies which events to trace
347or how to trace them. The format of the expression is:
Wichert Akkerman8829a551999-06-11 13:18:40 +0000348.RS 15
349.IP
350[\fIqualifier\fB=\fR][\fB!\fR]\fIvalue1\fR[\fB,\fIvalue2\fR]...
351.RE
352.IP
353where
354.I qualifier
355is one of
356.BR trace ,
357.BR abbrev ,
358.BR verbose ,
359.BR raw ,
360.BR signal ,
361.BR read ,
362or
363.B write
364and
365.I value
366is a qualifier-dependent symbol or number. The default
367qualifier is
368.BR trace .
369Using an exclamation mark negates the set of values. For example,
370.B \-eopen
371means literally
372.B "\-e trace=open"
373which in turn means trace only the
374.B open
375system call. By contrast,
376.B "\-etrace=!open"
377means to trace every system call except
378.BR open .
379In addition, the special values
380.B all
381and
382.B none
383have the obvious meanings.
384.IP
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000385Note that some shells use the exclamation point for history
Wichert Akkerman8829a551999-06-11 13:18:40 +0000386expansion even inside quoted arguments. If so, you must escape
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000387the exclamation point with a backslash.
388.TP
389.BI "\-e trace=" set
390Trace only the specified set of system calls. The
391.B \-c
392option is useful for determining which system calls might be useful
Wichert Akkerman8829a551999-06-11 13:18:40 +0000393to trace. For example,
394.B trace=open,close,read,write
395means to only
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000396trace those four system calls. Be careful when making inferences
397about the user/kernel boundary if only a subset of system calls
Wichert Akkerman8829a551999-06-11 13:18:40 +0000398are being monitored. The default is
399.BR trace=all .
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000400.TP
401.B "\-e trace=file"
402Trace all system calls which take a file name as an argument. You
403can think of this as an abbreviation for
Wichert Akkerman8829a551999-06-11 13:18:40 +0000404.BR "\-e\ trace=open,stat,chmod,unlink," ...
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000405which is useful to seeing what files the process is referencing.
406Furthermore, using the abbreviation will ensure that you don't
407accidentally forget to include a call like
408.B lstat
409in the list. Betchya woulda forgot that one.
410.TP
411.B "\-e trace=process"
412Trace all system calls which involve process management. This
413is useful for watching the fork, wait, and exec steps of a process.
414.TP
415.B "\-e trace=network"
416Trace all the network related system calls.
417.TP
418.B "\-e trace=signal"
419Trace all signal related system calls.
420.TP
421.B "\-e trace=ipc"
422Trace all IPC related system calls.
423.TP
Roland McGrath2fe7b132005-07-05 03:25:35 +0000424.B "\-e trace=desc"
425Trace all file descriptor related system calls.
426.TP
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000427.BI "\-e abbrev=" set
428Abbreviate the output from printing each member of large structures.
Wichert Akkerman8829a551999-06-11 13:18:40 +0000429The default is
430.BR abbrev=all .
431The
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000432.B \-v
Wichert Akkerman8829a551999-06-11 13:18:40 +0000433option has the effect of
434.BR abbrev=none .
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000435.TP
436.BI "\-e verbose=" set
437Dereference structures for the specified set of system calls. The
Wichert Akkerman8829a551999-06-11 13:18:40 +0000438default is
439.BR verbose=all .
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000440.TP
441.BI "\-e raw=" set
Roland McGrath0411b402003-10-22 06:16:32 +0000442Print raw, undecoded arguments for the specified set of system calls.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000443This option has the effect of causing all arguments to be printed
444in hexadecimal. This is mostly useful if you don't trust the
445decoding or you need to know the actual numeric value of an
446argument.
447.TP
448.BI "\-e signal=" set
Wichert Akkerman8829a551999-06-11 13:18:40 +0000449Trace only the specified subset of signals. The default is
450.BR signal=all .
451For example,
452.B signal=!SIGIO
453(or
454.BR signal=!io )
455causes SIGIO signals not to be traced.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000456.TP
457.BI "\-e read=" set
Wichert Akkerman8829a551999-06-11 13:18:40 +0000458Perform a full hexadecimal and ASCII dump of all the data read from
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000459file descriptors listed in the specified set. For example, to see
460all input activity on file descriptors 3 and 5 use
461.BR "\-e read=3,5" .
Wichert Akkerman8829a551999-06-11 13:18:40 +0000462Note that this is independent from the normal tracing of the
463.BR read (2)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000464system call which is controlled by the option
465.BR "\-e trace=read" .
466.TP
467.BI "\-e write=" set
Wichert Akkerman8829a551999-06-11 13:18:40 +0000468Perform a full hexadecimal and ASCII dump of all the data written to
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000469file descriptors listed in the specified set. For example, to see
470all output activity on file descriptors 3 and 5 use
471.BR "\-e write=3,5" .
Wichert Akkerman8829a551999-06-11 13:18:40 +0000472Note that this is independent from the normal tracing of the
473.BR write (2)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000474system call which is controlled by the option
475.BR "\-e trace=write" .
476.TP
477.BI "\-o " filename
478Write the trace output to the file
479.I filename
480rather than to stderr.
481Use
482.I filename.pid
483if
484.B \-ff
485is used.
486If the argument begins with `|' or with `!' then the rest of the
487argument is treated as a command and all output is piped to it.
488This is convenient for piping the debugging output to a program
489without affecting the redirections of executed programs.
490.TP
491.BI "\-O " overhead
Wichert Akkerman8829a551999-06-11 13:18:40 +0000492Set the overhead for tracing system calls to
493.I overhead
494microseconds.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000495This is useful for overriding the default heuristic for guessing
496how much time is spent in mere measuring when timing system calls using
497the
498.B \-c
Roland McGrath0411b402003-10-22 06:16:32 +0000499option. The accuracy of the heuristic can be gauged by timing a given
Wichert Akkerman8829a551999-06-11 13:18:40 +0000500program run without tracing (using
501.BR time (1))
502and comparing the accumulated
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000503system call time to the total produced using
Wichert Akkerman8829a551999-06-11 13:18:40 +0000504.BR \-c .
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000505.TP
506.BI "\-p " pid
507Attach to the process with the process
508.SM ID
509.I pid
510and begin tracing.
511The trace may be terminated
512at any time by a keyboard interrupt signal (\c
513.SM CTRL\s0-C).
514.B strace
515will respond by detaching itself from the traced process(es)
516leaving it (them) to continue running.
517Multiple
518.B \-p
519options can be used to attach to up to 32 processes in addition to
520.I command
521(which is optional if at least one
522.B \-p
523option is given).
524.TP
525.BI "\-s " strsize
526Specify the maximum string size to print (the default is 32). Note
527that filenames are not considered strings and are always printed in
528full.
529.TP
530.BI "\-S " sortby
531Sort the output of the histogram printed by the
532.B \-c
Roland McGrath0411b402003-10-22 06:16:32 +0000533option by the specified criterion. Legal values are
Wichert Akkerman8829a551999-06-11 13:18:40 +0000534.BR time ,
535.BR calls ,
536.BR name ,
537and
538.B nothing
539(default
540.BR time ).
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000541.TP
542.BI "\-u " username
Wichert Akkerman8829a551999-06-11 13:18:40 +0000543Run command with the user \s-1ID\s0, group \s-2ID\s0, and
544supplementary groups of
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000545.IR username .
546This option is only useful when running as root and enables the
547correct execution of setuid and/or setgid binaries.
548Unless this option is used setuid and setgid programs are executed
549without effective privileges.
Roland McGrath4417fda2003-01-24 04:31:20 +0000550.TP
551.BI "\-E " var=val
552Run command with
553.IR var=val
554in its list of environment variables.
555.TP
556.BI "\-E " var
557Remove
558.IR var
559from the inherited list of environment variables before passing it on to
560the command.
Roland McGratha09353a2008-12-10 06:09:29 +0000561.SH DIAGNOSTICS
562When
563.I command
564exits,
565.B strace
566exits with the same exit status.
567If
568.I command
569is terminated by a signal,
570.B strace
571terminates itself with the same signal, so that
572.B strace
573can be used as a wrapper process transparent to the invoking parent process.
574.LP
575When using
576.BR -p ,
577the exit status of
578.B strace
579is zero unless there was an unexpected error in doing the tracing.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000580.SH "SETUID INSTALLATION"
581If
582.B strace
583is installed setuid to root then the invoking user will be able to
584attach to and trace processes owned by any user.
585In addition setuid and setgid programs will be executed and traced
586with the correct effective privileges.
587Since only users trusted with full root privileges should be allowed
588to do these things,
589it only makes sense to install
590.B strace
591as setuid to root when the users who can execute it are restricted
592to those users who have this trust.
593For example, it makes sense to install a special version of
Wichert Akkerman8829a551999-06-11 13:18:40 +0000594.B strace
595with mode `rwsr-xr--', user
596.B root
597and group
598.BR trace ,
599where members of the
600.B trace
601group are trusted users.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000602If you do use this feature, please remember to install
Wichert Akkerman8829a551999-06-11 13:18:40 +0000603a non-setuid version of
604.B strace
605for ordinary lusers to use.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000606.SH "SEE ALSO"
Roland McGrath7f7f4362005-12-02 03:59:35 +0000607.BR ltrace (1),
Wichert Akkerman8829a551999-06-11 13:18:40 +0000608.BR time (1),
Roland McGrath7f7f4362005-12-02 03:59:35 +0000609.BR ptrace (2),
610.BR proc (5)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000611.SH NOTES
612It is a pity that so much tracing clutter is produced by systems
613employing shared libraries.
614.LP
615It is instructive to think about system call inputs and outputs
616as data-flow across the user/kernel boundary. Because user-space
617and kernel-space are separate and address-protected, it is
618sometimes possible to make deductive inferences about process
619behavior using inputs and outputs as propositions.
620.LP
621In some cases, a system call will differ from the documented behavior
Wichert Akkerman8829a551999-06-11 13:18:40 +0000622or have a different name. For example, on System V-derived systems
623the true
624.BR time (2)
625system call does not take an argument and the
626.B stat
627function is called
628.B xstat
629and takes an extra leading argument. These
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000630discrepancies are normal but idiosyncratic characteristics of the
631system call interface and are accounted for by C library wrapper
632functions.
633.LP
634On some platforms a process that has a system call trace applied
635to it with the
636.B \-p
637option will receive a
638.BR \s-1SIGSTOP\s0 .
639This signal may interrupt a system call that is not restartable.
640This may have an unpredictable effect on the process
641if the process takes no action to restart the system call.
642.SH BUGS
643Programs that use the
644.I setuid
645bit do not have
646effective user
647.SM ID
648privileges while being traced.
649.LP
650A traced process ignores
651.SM SIGSTOP
Nate Sammonsb4aa1131999-03-31 05:59:04 +0000652except on SVR4 platforms.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000653.LP
654A traced process which tries to block SIGTRAP will be sent a SIGSTOP
655in an attempt to force continuation of tracing.
656.LP
657A traced process runs slowly.
658.LP
659Traced processes which are descended from
660.I command
661may be left running after an interrupt signal (\c
662.SM CTRL\s0-C).
663.LP
664On Linux, exciting as it would be, tracing the init process is forbidden.
665.LP
666The
667.B \-i
668option is weakly supported.
669.SH HISTORY
670.B strace
Wichert Akkerman8829a551999-06-11 13:18:40 +0000671The original
672.B strace
673was written by Paul Kranenburg
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000674for SunOS and was inspired by its trace utility.
Wichert Akkerman8829a551999-06-11 13:18:40 +0000675The SunOS version of
676.B strace
677was ported to Linux and enhanced
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000678by Branko Lankester, who also wrote the Linux kernel support.
Wichert Akkerman8829a551999-06-11 13:18:40 +0000679Even though Paul released
680.B strace
6812.5 in 1992,
682Branko's work was based on Paul's
683.B strace
6841.5 release from 1991.
685In 1993, Rick Sladkey merged
686.B strace
6872.5 for SunOS and the second release of
688.B strace
689for Linux, added many of the features of
690.BR truss (1)
691from SVR4, and produced an
692.B strace
693that worked on both platforms. In 1994 Rick ported
694.B strace
695to SVR4 and Solaris and wrote the
696automatic configuration support. In 1995 he ported
697.B strace
698to Irix
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000699and tired of writing about himself in the third person.
Roland McGrath98a3ecf2008-08-28 23:41:57 +0000700.SH BUGS
701The SIGTRAP signal is used internally by the kernel implementation of
702system call tracing. When a traced process receives a SIGTRAP signal not
703associated with tracing, strace will not report that signal correctly.
704This signal is not normally used by programs, but could be via a hard-coded
705break instruction or via kill(2).
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000706.SH PROBLEMS
707Problems with
708.B strace
Roland McGrath4a9b49a2003-01-14 23:40:55 +0000709should be reported via the Debian Bug Tracking System,
710or to the
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000711.B strace
Roland McGrath4a9b49a2003-01-14 23:40:55 +0000712mailing list at <strace-devel@lists.sourceforge.net>.