blob: 7eb90fd5123112129a4d83962c202f1d882beeef [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>
Elliott Hughes39bac052017-05-25 16:56:11 -07004.\" Copyright (c) 1996-2017 The strace developers.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00005.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\" 3. The name of the author may not be used to endorse or promote products
16.\" derived from this software without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000028.de CW
29.sp
Elliott Hughes77c3ff82017-09-08 17:11:00 -070030.in +4n
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000031.nf
32.ft CW
33..
34.de CE
Wichert Akkerman8829a551999-06-11 13:18:40 +000035.ft R
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000036.fi
Elliott Hughes77c3ff82017-09-08 17:11:00 -070037.in
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000038.sp
39..
Elliott Hughes77c3ff82017-09-08 17:11:00 -070040.\" Like .OP, but with ellipsis at the end in order to signify that option
41.\" can be provided multiple times. Based on .OP definition in groff's
42.\" an-ext.tmac.
43.de OM
44. ie \\n(.$-1 \
45. RI "[\fB\\$1\fP" "\ \\$2" "]...\&"
46. el \
47. RB "[" "\\$1" "]...\&"
Dmitry V. Levina1978322014-06-03 12:03:41 +000048..
Elliott Hughes77c3ff82017-09-08 17:11:00 -070049.\" Required option.
50.de OR
51. ie \\n(.$-1 \
52. RI "\fB\\$1\fP" "\ \\$2"
53. el \
54. BR "\\$1"
55..
Elliott Hughesc1873762018-12-19 15:13:36 -080056.TH STRACE 1 "2018-07-07" "strace 4.25"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000057.SH NAME
58strace \- trace system calls and signals
59.SH SYNOPSIS
Elliott Hughes77c3ff82017-09-08 17:11:00 -070060.SY strace
Elliott Hughesc1873762018-12-19 15:13:36 -080061.if ''#' .ig end_unwind_opt
Elliott Hughes28e98bc2018-06-14 16:59:04 -070062.OP \-ACdffhikqrtttTvVxxy
Elliott Hughes03a418e2018-06-15 13:11:40 -070063.end_unwind_opt
Elliott Hughesc1873762018-12-19 15:13:36 -080064.if '#'#' .ig end_no_unwind_opt
Elliott Hughes03a418e2018-06-15 13:11:40 -070065.OP \-ACdffhiqrtttTvVxxy
66.end_no_unwind_opt
Elliott Hughes77c3ff82017-09-08 17:11:00 -070067.OP \-I n
68.OP \-b execve
69.OM \-e expr
70.OP \-a column
71.OP \-o file
72.OP \-s strsize
Elliott Hughes03a418e2018-06-15 13:11:40 -070073.OP \-X format
Elliott Hughes77c3ff82017-09-08 17:11:00 -070074.OM \-P path
75.OM \-p pid
76.BR "" {
77.OR \-p pid
78.BR "" |
79.OP \-D
80.OM \-E var\fR[=\fIval\fR]
81.OP \-u username
82.IR command " [" args ]
83.BR "" }
84.YS
85.SY strace
86.B \-c
87.OP \-df
88.OP \-I n
89.OP \-b execve
90.OM \-e expr
91.OP \-O overhead
92.OP \-S sortby
93.OM \-P path
94.OM \-p pid
95.BR "" {
96.OR \-p pid
97.BR "" |
98.OP \-D
99.OM \-E var\fR[=\fIval\fR]
100.OP -u username
101.IR command " [" args ]
102.BR "" }
103.YS
104
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000105.SH DESCRIPTION
106.IX "strace command" "" "\fLstrace\fR command"
107.LP
108In the simplest case
109.B strace
110runs the specified
111.I command
112until it exits.
113It intercepts and records the system calls which are called
114by a process and the signals which are received by a process.
115The name of each system call, its arguments and its return value
116are printed on standard error or to the file specified with the
117.B \-o
Roland McGratha09353a2008-12-10 06:09:29 +0000118option.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000119.LP
120.B strace
Nate Sammonsb4aa1131999-03-31 05:59:04 +0000121is a useful diagnostic, instructional, and debugging tool.
Roland McGrath0411b402003-10-22 06:16:32 +0000122System administrators, diagnosticians and trouble-shooters will find
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000123it invaluable for solving problems with
124programs for which the source is not readily available since
125they do not need to be recompiled in order to trace them.
126Students, hackers and the overly-curious will find that
127a great deal can be learned about a system and its system calls by
128tracing even ordinary programs. And programmers will find that
129since system calls and signals are events that happen at the user/kernel
130interface, a close examination of this boundary is very
131useful for bug isolation, sanity checking and
132attempting to capture race conditions.
133.LP
134Each line in the trace contains the system call name, followed
135by its arguments in parentheses and its return value.
Denys Vlasenkob5370532013-06-26 15:35:16 +0200136An example from stracing the command "cat /dev/null" is:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000137.CW
138open("/dev/null", O_RDONLY) = 3
139.CE
140Errors (typically a return value of \-1) have the errno symbol
141and error string appended.
142.CW
Dmitry V. Levina1978322014-06-03 12:03:41 +0000143open("/foo/bar", O_RDONLY) = \-1 ENOENT (No such file or directory)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000144.CE
Denys Vlasenkob5370532013-06-26 15:35:16 +0200145Signals are printed as signal symbol and decoded siginfo structure.
146An excerpt from stracing and interrupting the command "sleep 666" is:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000147.CW
148sigsuspend([] <unfinished ...>
Denys Vlasenkob5370532013-06-26 15:35:16 +0200149--- SIGINT {si_signo=SIGINT, si_code=SI_USER, si_pid=...} ---
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000150+++ killed by SIGINT +++
151.CE
Jan Kratochvil14256a72008-09-12 08:44:30 +0000152If a system call is being executed and meanwhile another one is being called
153from a different thread/process then
154.B strace
155will try to preserve the order of those events and mark the ongoing call as
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000156being
157.IR unfinished .
158When the call returns it will be marked as
159.IR resumed .
Jan Kratochvil14256a72008-09-12 08:44:30 +0000160.CW
161[pid 28772] select(4, [3], NULL, NULL, NULL <unfinished ...>
162[pid 28779] clock_gettime(CLOCK_REALTIME, {1130322148, 939977000}) = 0
163[pid 28772] <... select resumed> ) = 1 (in [3])
164.CE
165Interruption of a (restartable) system call by a signal delivery is processed
166differently as kernel terminates the system call and also arranges its
167immediate reexecution after the signal handler completes.
168.CW
169read(0, 0x7ffff72cf5cf, 1) = ? ERESTARTSYS (To be restarted)
Denys Vlasenkob5370532013-06-26 15:35:16 +0200170--- SIGALRM ... ---
Jan Kratochvil14256a72008-09-12 08:44:30 +0000171rt_sigreturn(0xe) = 0
Denys Vlasenkob5370532013-06-26 15:35:16 +0200172read(0, "", 1) = 0
Jan Kratochvil14256a72008-09-12 08:44:30 +0000173.CE
Elliott Hughesb7556142018-02-20 17:03:16 -0800174Arguments are printed in symbolic form with passion.
Denys Vlasenkob5370532013-06-26 15:35:16 +0200175This example shows the shell performing ">>xyzzy" output redirection:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000176.CW
177open("xyzzy", O_WRONLY|O_APPEND|O_CREAT, 0666) = 3
178.CE
Elliott Hughes03a418e2018-06-15 13:11:40 -0700179Here, the third argument of
180.B open
181is decoded by breaking down the
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000182flag argument into its three bitwise-OR constituents and printing the
Elliott Hughesb7556142018-02-20 17:03:16 -0800183mode value in octal by tradition. Where the traditional or native
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000184usage differs from ANSI or POSIX, the latter forms are preferred.
Wichert Akkerman8829a551999-06-11 13:18:40 +0000185In some cases,
186.B strace
Elliott Hughesb7556142018-02-20 17:03:16 -0800187output is proven to be more readable than the source.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000188.LP
189Structure pointers are dereferenced and the members are displayed
Elliott Hughesb7556142018-02-20 17:03:16 -0800190as appropriate. In most cases, arguments are formatted in the most C-like
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000191fashion possible.
Denys Vlasenkob5370532013-06-26 15:35:16 +0200192For example, the essence of the command "ls \-l /dev/null" is captured as:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000193.CW
194lstat("/dev/null", {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0
195.CE
Denys Vlasenkob5370532013-06-26 15:35:16 +0200196Notice how the 'struct stat' argument is dereferenced and how each member is
Elliott Hughesb7556142018-02-20 17:03:16 -0800197displayed symbolically. In particular, observe how the
198.B st_mode
199member is carefully decoded into a bitwise-OR of symbolic and numeric values.
200Also notice in this example that the first argument to
201.B lstat
202is an input to the system call and the second argument is an output.
203Since output arguments are not modified if the system call fails, arguments may
204not always be dereferenced. For example, retrying the "ls \-l" example
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000205with a non-existent file produces the following line:
206.CW
Dmitry V. Levina1978322014-06-03 12:03:41 +0000207lstat("/foo/bar", 0xb004) = \-1 ENOENT (No such file or directory)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000208.CE
209In this case the porch light is on but nobody is home.
210.LP
Elliott Hughesb7556142018-02-20 17:03:16 -0800211Syscalls unknown to
212.B strace
213are printed raw, with the unknown system call number printed in hexadecimal form
214and prefixed with "syscall_":
215.CW
Elliott Hughes03a418e2018-06-15 13:11:40 -0700216syscall_0xbad(0x1, 0x2, 0x3, 0x4, 0x5, 0x6) = -1 ENOSYS (Function not implemented)
Elliott Hughesb7556142018-02-20 17:03:16 -0800217.CE
218.LP
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000219Character pointers are dereferenced and printed as C strings.
220Non-printing characters in strings are normally represented by
221ordinary C escape codes.
222Only the first
223.I strsize
224(32 by default) bytes of strings are printed;
225longer strings have an ellipsis appended following the closing quote.
Denys Vlasenkob5370532013-06-26 15:35:16 +0200226Here is a line from "ls \-l" where the
Wichert Akkerman8829a551999-06-11 13:18:40 +0000227.B getpwuid
228library routine is reading the password file:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000229.CW
230read(3, "root::0:0:System Administrator:/"..., 1024) = 422
231.CE
232While structures are annotated using curly braces, simple pointers
233and arrays are printed using square brackets with commas separating
Denys Vlasenkob5370532013-06-26 15:35:16 +0200234elements. Here is an example from the command "id" on a system with
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000235supplementary group ids:
236.CW
237getgroups(32, [100, 0]) = 2
238.CE
239On the other hand, bit-sets are also shown using square brackets
Elliott Hughesb7556142018-02-20 17:03:16 -0800240but set elements are separated only by a space. Here is the shell,
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000241preparing to execute an external command:
242.CW
243sigprocmask(SIG_BLOCK, [CHLD TTOU], []) = 0
244.CE
Elliott Hughesb7556142018-02-20 17:03:16 -0800245Here, the second argument is a bit-set of two signals,
246.BR SIGCHLD " and " SIGTTOU .
247In some cases, the bit-set is so full that printing out the unset
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000248elements is more valuable. In that case, the bit-set is prefixed by
249a tilde like this:
250.CW
251sigprocmask(SIG_UNBLOCK, ~[], NULL) = 0
252.CE
Elliott Hughesb7556142018-02-20 17:03:16 -0800253Here, the second argument represents the full set of all signals.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000254.SH OPTIONS
Elliott Hughesd35df492017-02-15 15:19:05 -0800255.SS Output format
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000256.TP 12
Elliott Hughesd35df492017-02-15 15:19:05 -0800257.BI "\-a " column
258Align return values in a specific column (default column 40).
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259.TP
260.B \-i
261Print the instruction pointer at the time of the system call.
Elliott Hughesc1873762018-12-19 15:13:36 -0800262.if ''#' .ig end_unwind
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000263.TP
Luca Clementi327064b2013-07-23 00:11:35 -0700264.B \-k
Elliott Hughes03a418e2018-06-15 13:11:40 -0700265Print the execution stack trace of the traced processes after each system call.
266.end_unwind
Luca Clementi327064b2013-07-23 00:11:35 -0700267.TP
Elliott Hughesd35df492017-02-15 15:19:05 -0800268.BI "\-o " filename
269Write the trace output to the file
270.I filename
271rather than to stderr.
Elliott Hughesb7556142018-02-20 17:03:16 -0800272.IR filename . pid
273form is used if
Elliott Hughesd35df492017-02-15 15:19:05 -0800274.B \-ff
Elliott Hughesb7556142018-02-20 17:03:16 -0800275option is supplied.
276If the argument begins with '|' or '!', the rest of the
Elliott Hughesd35df492017-02-15 15:19:05 -0800277argument is treated as a command and all output is piped to it.
278This is convenient for piping the debugging output to a program
279without affecting the redirections of executed programs.
Elliott Hughesb7556142018-02-20 17:03:16 -0800280The latter is not compatible with
281.B \-ff
282option currently.
Elliott Hughes03a418e2018-06-15 13:11:40 -0700283.TP
284.B \-A
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700285Open the file provided in the
286.B \-o
287option in append mode.
Elliott Hughesd35df492017-02-15 15:19:05 -0800288.TP
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000289.B \-q
290Suppress messages about attaching, detaching etc. This happens
291automatically when output is redirected to a file and the command
292is run directly instead of attaching.
293.TP
Daniel P. Berrange01997cf2013-05-13 11:30:55 +0100294.B \-qq
Dmitry V. Levine8ff4c62013-05-28 20:27:10 +0000295If given twice, suppress messages about process exit status.
Daniel P. Berrange01997cf2013-05-13 11:30:55 +0100296.TP
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000297.B \-r
298Print a relative timestamp upon entry to each system call. This
299records the time difference between the beginning of successive
300system calls.
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700301Note that since
302.B \-r
303option uses the monotonic clock time for measuring time difference and not the
304wall clock time, its measurements can differ from the difference in time
305reported by the
306.B \-t
307option.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000308.TP
Elliott Hughesd35df492017-02-15 15:19:05 -0800309.BI "\-s " strsize
310Specify the maximum string size to print (the default is 32). Note
311that filenames are not considered strings and are always printed in
312full.
313.TP
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000314.B \-t
Elliott Hughesb7556142018-02-20 17:03:16 -0800315Prefix each line of the trace with the wall clock time.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000316.TP
317.B \-tt
318If given twice, the time printed will include the microseconds.
319.TP
320.B \-ttt
321If given thrice, the time printed will include the microseconds
322and the leading portion will be printed as the number
323of seconds since the epoch.
324.TP
325.B \-T
Dmitry V. Levina1978322014-06-03 12:03:41 +0000326Show the time spent in system calls. This records the time
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000327difference between the beginning and the end of each system call.
328.TP
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000329.B \-x
Wichert Akkerman8829a551999-06-11 13:18:40 +0000330Print all non-ASCII strings in hexadecimal string format.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000331.TP
332.B \-xx
333Print all strings in hexadecimal string format.
334.TP
Elliott Hughes03a418e2018-06-15 13:11:40 -0700335.BI "\-X " format
336Set the format for printing of named constants and flags.
337Supported
338.I format
339values are:
340.RS
341.TP 10
342.B raw
343Raw number output, without decoding.
344.TP
345.B abbrev
346Output a named constant or a set of flags instead of the raw number if they are
347found.
348This is the default
349.B strace
350behaviour.
351.TP
352.B verbose
353Output both the raw value and the decoded string (as a comment).
354.RE
355.TP
Grant Edwards8a082772011-04-07 20:25:40 +0000356.B \-y
357Print paths associated with file descriptor arguments.
358.TP
Dmitry V. Levin2f6510c2014-08-21 03:17:48 +0000359.B \-yy
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700360Print protocol specific information associated with socket file descriptors,
361and block/character device number associated with device file descriptors.
Elliott Hughesd35df492017-02-15 15:19:05 -0800362.SS Statistics
363.TP 12
364.B \-c
365Count time, calls, and errors for each system call and report a summary on
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700366program exit, suppressing the regular output.
367This attempts to show system time (CPU time spent running
Elliott Hughesb7556142018-02-20 17:03:16 -0800368in the kernel) independent of wall clock time. If
Elliott Hughesd35df492017-02-15 15:19:05 -0800369.B \-c
370is used with
Elliott Hughesb7556142018-02-20 17:03:16 -0800371.BR \-f ,
372only aggregate totals for all traced processes are kept.
Dmitry V. Levin2f6510c2014-08-21 03:17:48 +0000373.TP
Elliott Hughesd35df492017-02-15 15:19:05 -0800374.B \-C
375Like
376.B \-c
377but also print regular output while processes are running.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000378.TP
Elliott Hughesd35df492017-02-15 15:19:05 -0800379.BI "\-O " overhead
380Set the overhead for tracing system calls to
381.I overhead
382microseconds.
383This is useful for overriding the default heuristic for guessing
384how much time is spent in mere measuring when timing system calls using
385the
386.B \-c
387option. The accuracy of the heuristic can be gauged by timing a given
388program run without tracing (using
389.BR time (1))
390and comparing the accumulated
391system call time to the total produced using
392.BR \-c .
Denys Vlasenko22efaf02013-02-27 12:15:19 +0100393.TP
Elliott Hughesd35df492017-02-15 15:19:05 -0800394.BI "\-S " sortby
395Sort the output of the histogram printed by the
396.B \-c
397option by the specified criterion. Legal values are
398.BR time ,
399.BR calls ,
400.BR name ,
401and
402.B nothing
403(default is
404.BR time ).
405.TP
406.B \-w
407Summarise the time difference between the beginning and end of
408each system call. The default is to summarise the system time.
409.SS Filtering
410.TP 12
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000411.BI "\-e " expr
412A qualifying expression which modifies which events to trace
413or how to trace them. The format of the expression is:
Wichert Akkerman8829a551999-06-11 13:18:40 +0000414.RS 15
415.IP
Elliott Hughes39bac052017-05-25 16:56:11 -0700416[\,\fIqualifier\/\fB=\fR][\fB!\fR][\fB?\fR]\,\fIvalue1\/\fR[\fB,\fR[\fB?\fR]\,\fIvalue2\/\fR]...
Wichert Akkerman8829a551999-06-11 13:18:40 +0000417.RE
418.IP
419where
420.I qualifier
421is one of
422.BR trace ,
423.BR abbrev ,
424.BR verbose ,
425.BR raw ,
426.BR signal ,
427.BR read ,
Elliott Hughesd35df492017-02-15 15:19:05 -0800428.BR write ,
429.BR fault ,
Elliott Hughesc1873762018-12-19 15:13:36 -0800430.BR inject ,
Wichert Akkerman8829a551999-06-11 13:18:40 +0000431or
Elliott Hughesc1873762018-12-19 15:13:36 -0800432.B kvm
Wichert Akkerman8829a551999-06-11 13:18:40 +0000433and
434.I value
435is a qualifier-dependent symbol or number. The default
436qualifier is
437.BR trace .
438Using an exclamation mark negates the set of values. For example,
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000439.BR \-e "\ " open
Wichert Akkerman8829a551999-06-11 13:18:40 +0000440means literally
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000441.BR \-e "\ " trace = open
Wichert Akkerman8829a551999-06-11 13:18:40 +0000442which in turn means trace only the
443.B open
444system call. By contrast,
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000445.BR \-e "\ " trace "=!" open
Wichert Akkerman8829a551999-06-11 13:18:40 +0000446means to trace every system call except
447.BR open .
Elliott Hughes39bac052017-05-25 16:56:11 -0700448Question mark before the syscall qualification allows suppression of error
449in case no syscalls matched the qualification provided.
Elliott Hughes03a418e2018-06-15 13:11:40 -0700450Appending one of "@64", "@32", or "@x32" suffixes to the syscall qualification
451allows specifying syscalls only for the 64-bit, 32-bit, or 32-on-64-bit
452personality, respectively.
Wichert Akkerman8829a551999-06-11 13:18:40 +0000453In addition, the special values
454.B all
455and
456.B none
457have the obvious meanings.
458.IP
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000459Note that some shells use the exclamation point for history
Wichert Akkerman8829a551999-06-11 13:18:40 +0000460expansion even inside quoted arguments. If so, you must escape
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000461the exclamation point with a backslash.
462.TP
Dmitry V. Levina1978322014-06-03 12:03:41 +0000463\fB\-e\ trace\fR=\,\fIset\fR
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000464Trace only the specified set of system calls. The
465.B \-c
466option is useful for determining which system calls might be useful
Wichert Akkerman8829a551999-06-11 13:18:40 +0000467to trace. For example,
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000468.BR trace = open,close,read,write
Wichert Akkerman8829a551999-06-11 13:18:40 +0000469means to only
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000470trace those four system calls. Be careful when making inferences
471about the user/kernel boundary if only a subset of system calls
Wichert Akkerman8829a551999-06-11 13:18:40 +0000472are being monitored. The default is
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000473.BR trace = all .
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000474.TP
Elliott Hughes39bac052017-05-25 16:56:11 -0700475\fB\-e\ trace\fR=/\,\fIregex\fR
476Trace only those system calls that match the
477.IR regex .
478You can use
479.B POSIX
480Extended Regular Expression syntax (see
481.BR regex (7)).
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700482.TP
Elliott Hughes39bac052017-05-25 16:56:11 -0700483.BR "\-e\ trace" = %file
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700484.TQ
Elliott Hughes39bac052017-05-25 16:56:11 -0700485.BR "\-e\ trace" = file " (deprecated)"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000486Trace all system calls which take a file name as an argument. You
487can think of this as an abbreviation for
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000488.BR "\-e\ trace" = open , stat , chmod , unlink ,...
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000489which is useful to seeing what files the process is referencing.
490Furthermore, using the abbreviation will ensure that you don't
491accidentally forget to include a call like
492.B lstat
493in the list. Betchya woulda forgot that one.
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700494.TP
Elliott Hughes39bac052017-05-25 16:56:11 -0700495.BR "\-e\ trace" = %process
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700496.TQ
Elliott Hughes39bac052017-05-25 16:56:11 -0700497.BR "\-e\ trace" = process " (deprecated)"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000498Trace all system calls which involve process management. This
499is useful for watching the fork, wait, and exec steps of a process.
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700500.TP
Elliott Hughes39bac052017-05-25 16:56:11 -0700501.BR "\-e\ trace" = %network
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700502.TQ
Elliott Hughes39bac052017-05-25 16:56:11 -0700503.BR "\-e\ trace" = network " (deprecated)"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000504Trace all the network related system calls.
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700505.TP
Elliott Hughes39bac052017-05-25 16:56:11 -0700506.BR "\-e\ trace" = %signal
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700507.TQ
Elliott Hughes39bac052017-05-25 16:56:11 -0700508.BR "\-e\ trace" = signal " (deprecated)"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000509Trace all signal related system calls.
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700510.TP
Elliott Hughes39bac052017-05-25 16:56:11 -0700511.BR "\-e\ trace" = %ipc
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700512.TQ
Elliott Hughes39bac052017-05-25 16:56:11 -0700513.BR "\-e\ trace" = ipc " (deprecated)"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000514Trace all IPC related system calls.
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700515.TP
Elliott Hughes39bac052017-05-25 16:56:11 -0700516.BR "\-e\ trace" = %desc
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700517.TQ
Elliott Hughes39bac052017-05-25 16:56:11 -0700518.BR "\-e\ trace" = desc " (deprecated)"
Roland McGrath2fe7b132005-07-05 03:25:35 +0000519Trace all file descriptor related system calls.
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700520.TP
Elliott Hughes39bac052017-05-25 16:56:11 -0700521.BR "\-e\ trace" = %memory
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700522.TQ
Elliott Hughes39bac052017-05-25 16:56:11 -0700523.BR "\-e\ trace" = memory " (deprecated)"
Namhyung Kim96792962012-10-24 11:41:57 +0900524Trace all memory mapping related system calls.
525.TP
Elliott Hughes39bac052017-05-25 16:56:11 -0700526.BR "\-e\ trace" = %stat
527Trace stat syscall variants.
528.TP
529.BR "\-e\ trace" = %lstat
530Trace lstat syscall variants.
531.TP
532.BR "\-e\ trace" = %fstat
533Trace fstat and fstatat syscall variants.
534.TP
535.BR "\-e\ trace" = %%stat
536Trace syscalls used for requesting file status (stat, lstat, fstat, fstatat,
537statx, and their variants).
538.TP
539.BR "\-e\ trace" = %statfs
540Trace statfs, statfs64, statvfs, osf_statfs, and osf_statfs64 system calls.
541The same effect can be achieved with
542.BR "\-e\ trace" = /^(.*_)?statv?fs
543regular expression.
544.TP
545.BR "\-e\ trace" = %fstatfs
546Trace fstatfs, fstatfs64, fstatvfs, osf_fstatfs, and osf_fstatfs64 system calls.
547The same effect can be achieved with
548.BR "\-e\ trace" = /fstatv?fs
549regular expression.
550.TP
551.BR "\-e\ trace" = %%statfs
552Trace syscalls related to file system statistics (statfs-like, fstatfs-like,
553and ustat). The same effect can be achieved with
554.BR "\-e\ trace" = /statv?fs|fsstat|ustat
555regular expression.
556.TP
Elliott Hughesb7556142018-02-20 17:03:16 -0800557.BR "\-e\ trace" = %pure
558Trace syscalls that always succeed and have no arguments.
559Currently, this list includes
560.BR arc_gettls "(2), " getdtablesize "(2), " getegid "(2), " getegid32 "(2),"
561.BR geteuid "(2), " geteuid32 "(2), " getgid "(2), " getgid32 "(2),"
562.BR getpagesize "(2), " getpgrp "(2), " getpid "(2), " getppid "(2),"
563.BR get_thread_area (2)
564(on architectures other than x86),
565.BR gettid "(2), " get_tls "(2), " getuid "(2), " getuid32 "(2),"
566.BR getxgid "(2), " getxpid "(2), " getxuid "(2), " kern_features "(2), and"
567.BR metag_get_tls "(2)"
568syscalls.
569.TP
Dmitry V. Levina1978322014-06-03 12:03:41 +0000570\fB\-e\ abbrev\fR=\,\fIset\fR
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000571Abbreviate the output from printing each member of large structures.
Wichert Akkerman8829a551999-06-11 13:18:40 +0000572The default is
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000573.BR abbrev = all .
Wichert Akkerman8829a551999-06-11 13:18:40 +0000574The
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000575.B \-v
Wichert Akkerman8829a551999-06-11 13:18:40 +0000576option has the effect of
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000577.BR abbrev = none .
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000578.TP
Dmitry V. Levina1978322014-06-03 12:03:41 +0000579\fB\-e\ verbose\fR=\,\fIset\fR
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000580Dereference structures for the specified set of system calls. The
Wichert Akkerman8829a551999-06-11 13:18:40 +0000581default is
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000582.BR verbose = all .
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000583.TP
Dmitry V. Levina1978322014-06-03 12:03:41 +0000584\fB\-e\ raw\fR=\,\fIset\fR
Roland McGrath0411b402003-10-22 06:16:32 +0000585Print raw, undecoded arguments for the specified set of system calls.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000586This option has the effect of causing all arguments to be printed
587in hexadecimal. This is mostly useful if you don't trust the
588decoding or you need to know the actual numeric value of an
589argument.
Elliott Hughes03a418e2018-06-15 13:11:40 -0700590See also
591.B \-X raw
592option.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000593.TP
Dmitry V. Levina1978322014-06-03 12:03:41 +0000594\fB\-e\ signal\fR=\,\fIset\fR
Wichert Akkerman8829a551999-06-11 13:18:40 +0000595Trace only the specified subset of signals. The default is
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000596.BR signal = all .
Wichert Akkerman8829a551999-06-11 13:18:40 +0000597For example,
Elliott Hughesb7556142018-02-20 17:03:16 -0800598.BR signal "=!" SIGIO
Wichert Akkerman8829a551999-06-11 13:18:40 +0000599(or
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000600.BR signal "=!" io )
Elliott Hughesb7556142018-02-20 17:03:16 -0800601causes
602.B SIGIO
603signals not to be traced.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000604.TP
Dmitry V. Levina1978322014-06-03 12:03:41 +0000605\fB\-e\ read\fR=\,\fIset\fR
Wichert Akkerman8829a551999-06-11 13:18:40 +0000606Perform a full hexadecimal and ASCII dump of all the data read from
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000607file descriptors listed in the specified set. For example, to see
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000608all input activity on file descriptors
609.I 3
610and
611.I 5
612use
Dmitry V. Levina1978322014-06-03 12:03:41 +0000613\fB\-e\ read\fR=\,\fI3\fR,\fI5\fR.
Wichert Akkerman8829a551999-06-11 13:18:40 +0000614Note that this is independent from the normal tracing of the
615.BR read (2)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000616system call which is controlled by the option
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000617.BR -e "\ " trace = read .
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000618.TP
Dmitry V. Levina1978322014-06-03 12:03:41 +0000619\fB\-e\ write\fR=\,\fIset\fR
Wichert Akkerman8829a551999-06-11 13:18:40 +0000620Perform a full hexadecimal and ASCII dump of all the data written to
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000621file descriptors listed in the specified set. For example, to see
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000622all output activity on file descriptors
623.I 3
624and
625.I 5
626use
Dmitry V. Levina1978322014-06-03 12:03:41 +0000627\fB\-e\ write\fR=\,\fI3\fR,\,\fI5\fR.
Wichert Akkerman8829a551999-06-11 13:18:40 +0000628Note that this is independent from the normal tracing of the
629.BR write (2)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000630system call which is controlled by the option
Dmitry V. Levina7835e62010-03-31 17:26:49 +0000631.BR -e "\ " trace = write .
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000632.TP
Elliott Hughes03a418e2018-06-15 13:11:40 -0700633\fB\-e\ inject\fR=\,\fIset\/\fR[:\fBerror\fR=\,\fIerrno\/\fR|:\fBretval\fR=\,\fIvalue\/\fR][:\fBsignal\fR=\,\fIsig\/\fR][:\fBsyscall\fR=\fIsyscall\fR][:\fBdelay_enter\fR=\,\fIusecs\/\fR][:\fBdelay_exit\fR=\,\fIusecs\/\fR][:\fBwhen\fR=\,\fIexpr\/\fR]
Elliott Hughesd35df492017-02-15 15:19:05 -0800634Perform syscall tampering for the specified set of syscalls.
635
636At least one of
637.BR error ,
638.BR retval ,
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700639.BR signal ,
640.BR delay_enter ,
Elliott Hughesd35df492017-02-15 15:19:05 -0800641or
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700642.B delay_exit
Elliott Hughesd35df492017-02-15 15:19:05 -0800643options has to be specified.
644.B error
645and
646.B retval
647are mutually exclusive.
648
649If :\fBerror\fR=\,\fIerrno\/\fR option is specified,
650a fault is injected into a syscall invocation:
Elliott Hughes03a418e2018-06-15 13:11:40 -0700651the syscall number is replaced by -1 which corresponds to an invalid syscall
652(unless a syscall is specified with :\fBsyscall=\fR option),
Elliott Hughesd35df492017-02-15 15:19:05 -0800653and the error code is specified using a symbolic
654.I errno
655value like
656.B ENOSYS
657or a numeric value within 1..4095 range.
658
659If :\fBretval\fR=\,\fIvalue\/\fR option is specified,
660success injection is performed: the syscall number is replaced by -1,
661but a bogus success value is returned to the callee.
662
663If :\fBsignal\fR=\,\fIsig\/\fR option is specified with either a symbolic value
664like
665.B SIGSEGV
666or a numeric value within 1..\fBSIGRTMAX\fR range,
667that signal is delivered on entering every syscall specified by the
668.IR set .
669
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700670If :\fBdelay_enter\fR=\,\fIusecs\/\fR or :\fBdelay_exit\fR=\,\fIusecs\/\fR
671options are specified, delay injection is performed: the tracee is delayed
672by at least
673.IR usecs
674microseconds on entering or exiting the syscall.
675
Elliott Hughesd35df492017-02-15 15:19:05 -0800676If :\fBsignal\fR=\,\fIsig\/\fR option is specified without
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700677:\fBerror\fR=\,\fIerrno\/\fR, :\fBretval\fR=\,\fIvalue\/\fR or
678:\fBdelay_{enter,exit}\fR=\,\fIusecs\/\fR options,
Elliott Hughesd35df492017-02-15 15:19:05 -0800679then only a signal
680.I sig
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700681is delivered without a syscall fault or delay injection.
Elliott Hughesd35df492017-02-15 15:19:05 -0800682Conversely, :\fBerror\fR=\,\fIerrno\/\fR or
683:\fBretval\fR=\,\fIvalue\/\fR option without
Elliott Hughes28e98bc2018-06-14 16:59:04 -0700684:\fBdelay_enter\fR=\,\fIusecs\/\fR,
685:\fBdelay_exit\fR=\,\fIusecs\/\fR or
686:\fBsignal\fR=\,\fIsig\/\fR options injects a fault without delivering a signal
687or injecting a delay, etc.
Elliott Hughesd35df492017-02-15 15:19:05 -0800688
689If both :\fBerror\fR=\,\fIerrno\/\fR or :\fBretval\fR=\,\fIvalue\/\fR
690and :\fBsignal\fR=\,\fIsig\/\fR options are specified, then both
691a fault or success is injected and a signal is delivered.
692
Elliott Hughes03a418e2018-06-15 13:11:40 -0700693if :\fBsyscall\fR=\fIsyscall\fR option is specified, the corresponding syscall
694with no side effects is injected instead of -1.
695Currently, only "pure" (see
696.BR "-e trace" = "%pure"
697description) syscalls can be specified there.
698
Elliott Hughesd35df492017-02-15 15:19:05 -0800699Unless a :\fBwhen\fR=\,\fIexpr\fR subexpression is specified,
700an injection is being made into every invocation of each syscall from the
701.IR set .
702
703The format of the subexpression is one of the following:
704.RS
705.IP "" 2
706.I first
707.RS 4
708For every syscall from the
709.IR set ,
710perform an injection for the syscall invocation number
711.I first
712only.
713.RE
714.IP "" 2
715\fIfirst\/\fB+\fR
716.RS 4
717For every syscall from the
718.IR set ,
719perform injections for the syscall invocation number
720.I first
721and all subsequent invocations.
722.RE
723.IP "" 2
724\fIfirst\/\fB+\fIstep\fR
725.RS 4
726For every syscall from the
727.IR set ,
728perform injections for syscall invocations number
729.IR first ,
730.IR first + step ,
731.IR first + step + step ,
732and so on.
733.RE
734.RE
735.IP
736For example, to fail each third and subsequent chdir syscalls with
737.BR ENOENT ,
738use
739\fB\-e\ inject\fR=\,\fIchdir\/\fR:\fBerror\fR=\,\fIENOENT\/\fR:\fBwhen\fR=\,\fI3\/\fB+\fR.
740
741The valid range for numbers
742.I first
743and
744.I step
745is 1..65535.
746
747An injection expression can contain only one
748.BR error =
749or
750.BR retval =
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700751specification, and only one
752.BR signal =
753specification. If an injection expression contains multiple
Elliott Hughesd35df492017-02-15 15:19:05 -0800754.BR when =
755specifications, the last one takes precedence.
756
757Accounting of syscalls that are subject to injection
758is done per syscall and per tracee.
759
760Specification of syscall injection can be combined
761with other syscall filtering options, for example,
762\fB\-P \fI/dev/urandom \fB\-e inject\fR=\,\fIfile\/\fR:\fBerror\fR=\,\fIENOENT\fR.
763
764.TP
765\fB\-e\ fault\fR=\,\fIset\/\fR[:\fBerror\fR=\,\fIerrno\/\fR][:\fBwhen\fR=\,\fIexpr\/\fR]
766Perform syscall fault injection for the specified set of syscalls.
767
768This is equivalent to more generic
769\fB\-e\ inject\fR= expression with default value of
770.I errno
771option set to
772.IR ENOSYS .
773
774.TP
Elliott Hughesc1873762018-12-19 15:13:36 -0800775.BR "\-e\ kvm" = vcpu
776Print the exit reason of kvm vcpu. Requires Linux kernel version 4.16.0
777or higher.
778
779.TP
Elliott Hughesd35df492017-02-15 15:19:05 -0800780.BI "\-P " path
781Trace only system calls accessing
782.IR path .
783Multiple
784.B \-P
785options can be used to specify several paths.
786.TP
787.B \-v
788Print unabbreviated versions of environment, stat, termios, etc.
789calls. These structures are very common in calls and so the default
790behavior displays a reasonable subset of structure members. Use
791this option to get all of the gory details.
792.SS Tracing
793.TP 12
794.BI "\-b " syscall
795If specified syscall is reached, detach from traced process.
796Currently, only
797.I execve
798syscall is supported. This option is useful if you want to trace
799multi-threaded process and therefore require -f, but don't want
800to trace its (potentially very complex) children.
801.TP
802.B \-D
803Run tracer process as a detached grandchild, not as parent of the
804tracee. This reduces the visible effect of
805.B strace
806by keeping the tracee a direct child of the calling process.
807.TP
808.B \-f
809Trace child processes as they are created by currently traced
810processes as a result of the
811.BR fork (2),
812.BR vfork (2)
813and
814.BR clone (2)
815system calls. Note that
816.B \-p
817.I PID
818.B \-f
819will attach all threads of process PID if it is multi-threaded,
820not only thread with thread_id = PID.
821.TP
822.B \-ff
823If the
824.B \-o
825.I filename
826option is in effect, each processes trace is written to
827.I filename.pid
828where pid is the numeric process id of each process.
829This is incompatible with
830.BR \-c ,
831since no per-process counts are kept.
Elliott Hughesb7556142018-02-20 17:03:16 -0800832
833One might want to consider using
834.BR strace-log-merge (1)
835to obtain a combined strace log view.
Elliott Hughesd35df492017-02-15 15:19:05 -0800836.TP
Denys Vlasenkoc5ccfa42012-03-26 13:10:50 +0200837.BI "\-I " interruptible
838When strace can be interrupted by signals (such as pressing ^C).
8391: no signals are blocked; 2: fatal signals are blocked while decoding syscall
840(default); 3: fatal signals are always blocked (default if '-o FILE PROG');
8414: fatal signals and SIGTSTP (^Z) are always blocked (useful to make
842strace -o FILE PROG not stop on ^Z).
Elliott Hughesd35df492017-02-15 15:19:05 -0800843.SS Startup
844.TP 12
845\fB\-E\ \fIvar\fR=\,\fIval\fR
846Run command with
847.IR var = val
848in its list of environment variables.
Denys Vlasenkoc5ccfa42012-03-26 13:10:50 +0200849.TP
Elliott Hughesd35df492017-02-15 15:19:05 -0800850.BI "\-E " var
851Remove
852.IR var
853from the inherited list of environment variables before passing it on to
854the command.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000855.TP
856.BI "\-p " pid
857Attach to the process with the process
858.SM ID
859.I pid
860and begin tracing.
861The trace may be terminated
862at any time by a keyboard interrupt signal (\c
863.SM CTRL\s0-C).
864.B strace
865will respond by detaching itself from the traced process(es)
866leaving it (them) to continue running.
867Multiple
868.B \-p
Dmitry V. Levinfa8c2862016-01-22 14:37:14 +0000869options can be used to attach to many processes in addition to
870.I command
871(which is optional if at least one
872.B \-p
873option is given).
874.B \-p
875"`pidof PROG`" syntax is supported.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000876.TP
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000877.BI "\-u " username
Wichert Akkerman8829a551999-06-11 13:18:40 +0000878Run command with the user \s-1ID\s0, group \s-2ID\s0, and
879supplementary groups of
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000880.IR username .
881This option is only useful when running as root and enables the
882correct execution of setuid and/or setgid binaries.
883Unless this option is used setuid and setgid programs are executed
884without effective privileges.
Elliott Hughesd35df492017-02-15 15:19:05 -0800885.SS Miscellaneous
886.TP 12
887.B \-d
888Show some debugging output of
889.B strace
890itself on the standard error.
Roland McGrath4417fda2003-01-24 04:31:20 +0000891.TP
Elliott Hughesd35df492017-02-15 15:19:05 -0800892.B \-F
Elliott Hughesb7556142018-02-20 17:03:16 -0800893This option is deprecated. It is retained for backward compatibility only
894and may be removed in future releases.
895Usage of multiple instances of
896.B \-F
897option is still equivalent to a single
898.BR \-f ,
899and it is ignored at all if used along with one or more instances of
900.B \-f
901option.
Roland McGrath4417fda2003-01-24 04:31:20 +0000902.TP
Elliott Hughesd35df492017-02-15 15:19:05 -0800903.B \-h
904Print the help summary.
905.TP
906.B \-V
907Print the version number of
908.BR strace .
Roland McGratha09353a2008-12-10 06:09:29 +0000909.SH DIAGNOSTICS
910When
911.I command
912exits,
913.B strace
914exits with the same exit status.
915If
916.I command
917is terminated by a signal,
918.B strace
919terminates itself with the same signal, so that
920.B strace
921can be used as a wrapper process transparent to the invoking parent process.
Denys Vlasenkob5370532013-06-26 15:35:16 +0200922Note that parent-child relationship (signal stop notifications,
923getppid() value, etc) between traced process and its parent are not preserved
924unless
925.B \-D
926is used.
Roland McGratha09353a2008-12-10 06:09:29 +0000927.LP
928When using
Dmitry V. Levinb9bc2162016-07-29 17:51:54 +0000929.B \-p
930without a
931.IR command ,
Roland McGratha09353a2008-12-10 06:09:29 +0000932the exit status of
933.B strace
Dmitry V. Levinb9bc2162016-07-29 17:51:54 +0000934is zero unless no processes has been attached or there was an unexpected error
935in doing the tracing.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000936.SH "SETUID INSTALLATION"
937If
938.B strace
939is installed setuid to root then the invoking user will be able to
940attach to and trace processes owned by any user.
941In addition setuid and setgid programs will be executed and traced
942with the correct effective privileges.
943Since only users trusted with full root privileges should be allowed
944to do these things,
945it only makes sense to install
946.B strace
947as setuid to root when the users who can execute it are restricted
948to those users who have this trust.
949For example, it makes sense to install a special version of
Wichert Akkerman8829a551999-06-11 13:18:40 +0000950.B strace
Denys Vlasenkob5370532013-06-26 15:35:16 +0200951with mode 'rwsr-xr--', user
Wichert Akkerman8829a551999-06-11 13:18:40 +0000952.B root
953and group
954.BR trace ,
955where members of the
956.B trace
957group are trusted users.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000958If you do use this feature, please remember to install
Elliott Hughesb7556142018-02-20 17:03:16 -0800959a regular non-setuid version of
Wichert Akkerman8829a551999-06-11 13:18:40 +0000960.B strace
Elliott Hughesb7556142018-02-20 17:03:16 -0800961for ordinary users to use.
962.SH "MULTIPLE PERSONALITY SUPPORT"
963On some architectures,
964.B strace
965supports decoding of syscalls for processes that use different ABI rather than
966the one
967.B strace
968uses.
969Specifically, in addition to decoding native ABI,
970.B strace
971can decode the following ABIs on the following architectures:
972.TS H
973allbox;
974lb lb
975l l.
976Architecture ABIs supported
977x86_64 i386, x32 (when built as an x86_64 application); i386 (when built as an x32 application)
978AArch64 ARM 32-bit EABI
979PowerPC 64-bit PowerPC 32-bit
980RISC-V 64-bit RISC-V 32-bit
981s390x s390
982SPARC 64-bit SPARC 32-bit
983TILE 64-bit TILE 32-bit
984.TE
985.PP
986This support is optional and relies on ability to generate and parse structure
987definitions during the build time.
988Please refer to the output of the
989.B strace \-V
990command in order to figure out what support is available in your strace build
991("non-native" refers to an ABI that differs from the ABI strace has):
992.TP 15
993.B m32-mpers
994.B strace
995can trace and properly decode non-native 32-bit binaries.
996.TP
997.B no-m32-mpers
998.B strace
999can trace, but cannot properly decode non-native 32-bit binaries.
1000.TP
1001.B mx32-mpers
1002.B strace
1003can trace and properly decode non-native 32-on-64-bit binaries.
1004.TP
1005.B no-mx32-mpers
1006.B strace
1007can trace, but cannot properly decode non-native 32-on-64-bit binaries.
1008.PP
1009If the output contains neither
1010.B m32-mpers
1011nor
1012.BR no-m32-mpers ,
1013then decoding of non-native 32-bit binaries is not implemented at all
1014or not applicable.
1015.PP
1016Likewise, if the output contains neither
1017.B mx32-mpers
1018nor
1019.BR no-mx32-mpers ,
1020then decoding of non-native 32-on-64-bit binaries is not implemented at all
1021or not applicable.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001022.SH NOTES
1023It is a pity that so much tracing clutter is produced by systems
1024employing shared libraries.
1025.LP
1026It is instructive to think about system call inputs and outputs
1027as data-flow across the user/kernel boundary. Because user-space
1028and kernel-space are separate and address-protected, it is
1029sometimes possible to make deductive inferences about process
1030behavior using inputs and outputs as propositions.
1031.LP
1032In some cases, a system call will differ from the documented behavior
Elliott Hughes77c3ff82017-09-08 17:11:00 -07001033or have a different name. For example, the
1034.BR faccessat (2)
1035system call does not have
1036.I flags
1037argument, and the
1038.BR setrlimit (2)
1039library function uses
Elliott Hughesb7556142018-02-20 17:03:16 -08001040.BR prlimit64 (2)
Elliott Hughes77c3ff82017-09-08 17:11:00 -07001041system call on modern (2.6.38+) kernels. These
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001042discrepancies are normal but idiosyncratic characteristics of the
1043system call interface and are accounted for by C library wrapper
1044functions.
1045.LP
Dmitry V. Levina5c16b82015-12-09 15:55:33 +00001046Some system calls have different names in different architectures and
1047personalities. In these cases, system call filtering and printing
1048uses the names that match corresponding
1049.BR __NR_ *
1050kernel macros of the tracee's architecture and personality.
1051There are two exceptions from this general rule:
1052.BR arm_fadvise64_64 (2)
1053ARM syscall and
1054.BR xtensa_fadvise64_64 (2)
1055Xtensa syscall are filtered and printed as
1056.BR fadvise64_64 (2).
1057.LP
Elliott Hughes03a418e2018-06-15 13:11:40 -07001058On x32, syscalls that are intended to be used by 64-bit processes and not x32
1059ones (for example,
1060.BR readv ,
1061that has syscall number 19 on x86_64, with its x32 counterpart has syscall
1062number 515), but called with
1063.B __X32_SYSCALL_BIT
1064flag being set, are designated with "#64" suffix.
1065.LP
Denys Vlasenkob5370532013-06-26 15:35:16 +02001066On some platforms a process that is attached to with the
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001067.B \-p
Denys Vlasenkob5370532013-06-26 15:35:16 +02001068option may observe a spurious EINTR return from the current
Dmitry V. Levina1978322014-06-03 12:03:41 +00001069system call that is not restartable. (Ideally, all system calls
Denys Vlasenkob5370532013-06-26 15:35:16 +02001070should be restarted on strace attach, making the attach invisible
1071to the traced process, but a few system calls aren't.
1072Arguably, every instance of such behavior is a kernel bug.)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001073This may have an unpredictable effect on the process
1074if the process takes no action to restart the system call.
Elliott Hughes28e98bc2018-06-14 16:59:04 -07001075.LP
1076As
1077.B strace
1078executes the specified
1079.I command
1080directly and does not employ a shell for that, scripts without shebang
1081that usually run just fine when invoked by shell fail to execute with
1082.B ENOEXEC
1083error.
1084It is advisable to manually supply a shell as a
1085.I command
1086with the script as its argument.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001087.SH BUGS
1088Programs that use the
1089.I setuid
1090bit do not have
1091effective user
1092.SM ID
1093privileges while being traced.
1094.LP
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001095A traced process runs slowly.
1096.LP
1097Traced processes which are descended from
1098.I command
1099may be left running after an interrupt signal (\c
1100.SM CTRL\s0-C).
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001101.SH HISTORY
Wichert Akkerman8829a551999-06-11 13:18:40 +00001102The original
1103.B strace
1104was written by Paul Kranenburg
Elliott Hughesb7556142018-02-20 17:03:16 -08001105for SunOS and was inspired by its
1106.B trace
1107utility.
Wichert Akkerman8829a551999-06-11 13:18:40 +00001108The SunOS version of
1109.B strace
1110was ported to Linux and enhanced
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001111by Branko Lankester, who also wrote the Linux kernel support.
Wichert Akkerman8829a551999-06-11 13:18:40 +00001112Even though Paul released
1113.B strace
11142.5 in 1992,
1115Branko's work was based on Paul's
1116.B strace
11171.5 release from 1991.
1118In 1993, Rick Sladkey merged
1119.B strace
11202.5 for SunOS and the second release of
1121.B strace
1122for Linux, added many of the features of
1123.BR truss (1)
1124from SVR4, and produced an
1125.B strace
1126that worked on both platforms. In 1994 Rick ported
1127.B strace
1128to SVR4 and Solaris and wrote the
1129automatic configuration support. In 1995 he ported
1130.B strace
1131to Irix
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001132and tired of writing about himself in the third person.
Elliott Hughesb7556142018-02-20 17:03:16 -08001133.PP
1134Beginning with 1996,
1135.B strace
1136was maintained by Wichert Akkerman.
1137During his tenure,
1138.B strace
1139development migrated to CVS; ports to FreeBSD and many architectures on Linux
1140(including ARM, IA-64, MIPS, PA-RISC, PowerPC, s390, SPARC) were introduced.
1141In 2002, the burden of
1142.B strace
Elliott Hughes03a418e2018-06-15 13:11:40 -07001143maintainership was transferred to Roland McGrath.
Elliott Hughesb7556142018-02-20 17:03:16 -08001144Since then,
1145.B strace
1146gained support for several new Linux architectures (AMD64, s390x, SuperH),
1147bi-architecture support for some of them, and received numerous additions and
1148improvements in syscalls decoders on Linux;
1149.B strace
1150development migrated to
1151.B git
1152during that period.
1153Since 2009,
1154.B strace
1155is actively maintained by Dmitry Levin.
1156.B strace
1157gained support for AArch64, ARC, AVR32, Blackfin, Meta, Nios II, OpenSISC 1000,
1158RISC-V, Tile/TileGx, Xtensa architectures since that time.
1159In 2012, unmaintained and apparently broken support for non-Linux operating
1160systems was removed.
1161Also, in 2012
1162.B strace
1163gained support for path tracing and file descriptor path decoding.
1164In 2014, support for stack traces printing was added.
1165In 2016, syscall fault injection was implemented.
1166.PP
1167For the additional information, please refer to the
1168.B NEWS
1169file and
1170.B strace
1171repository commit log.
Elliott Hughesd35df492017-02-15 15:19:05 -08001172.SH REPORTING BUGS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001173Problems with
1174.B strace
Dmitry V. Levindd762c32012-02-25 15:29:21 +01001175should be reported to the
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001176.B strace
Elliott Hughes28e98bc2018-06-14 16:59:04 -07001177mailing list at <strace\-devel@lists.strace.io>.
Elliott Hughesd35df492017-02-15 15:19:05 -08001178.SH "SEE ALSO"
Elliott Hughesb7556142018-02-20 17:03:16 -08001179.BR strace-log-merge (1),
Elliott Hughesd35df492017-02-15 15:19:05 -08001180.BR ltrace (1),
Elliott Hughesb7556142018-02-20 17:03:16 -08001181.BR perf-trace (1),
1182.BR trace-cmd (1),
Elliott Hughesd35df492017-02-15 15:19:05 -08001183.BR time (1),
1184.BR ptrace (2),
1185.BR proc (5)