]> granicus.if.org Git - strace/blob - strace.1.in
strace.1.in: history update
[strace] / strace.1.in
1 .\" 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 .\" Copyright (c) 1996-2017 The strace developers.
5 .\" 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.
28 .de CW
29 .sp
30 .in +4n
31 .nf
32 .ft CW
33 ..
34 .de CE
35 .ft R
36 .fi
37 .in
38 .sp
39 ..
40 .\" 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" "]...\&"
48 ..
49 .\" Required option.
50 .de OR
51 .  ie \\n(.$-1 \
52 .    RI "\fB\\$1\fP" "\ \\$2"
53 .  el \
54 .    BR "\\$1"
55 ..
56 .TH STRACE 1 "@MANPAGE_DATE@" "strace @VERSION@"
57 .SH NAME
58 strace \- trace system calls and signals
59 .SH SYNOPSIS
60 .SY strace
61 .OP \-CdffhikqrtttTvVxxy
62 .OP \-I n
63 .OP \-b execve
64 .OM \-e expr
65 .OP \-a column
66 .OP \-o file
67 .OP \-s strsize
68 .OM \-P path
69 .OM \-p pid
70 .BR "" {
71 .OR \-p pid
72 .BR "" |
73 .OP \-D
74 .OM \-E var\fR[=\fIval\fR]
75 .OP \-u username
76 .IR command " [" args ]
77 .BR "" }
78 .YS
79 .SY strace
80 .B \-c
81 .OP \-df
82 .OP \-I n
83 .OP \-b execve
84 .OM \-e expr
85 .OP \-O overhead
86 .OP \-S sortby
87 .OM \-P path
88 .OM \-p pid
89 .BR "" {
90 .OR \-p pid
91 .BR "" |
92 .OP \-D
93 .OM \-E var\fR[=\fIval\fR]
94 .OP -u username
95 .IR command " [" args ]
96 .BR "" }
97 .YS
98
99 .SH DESCRIPTION
100 .IX "strace command" "" "\fLstrace\fR command"
101 .LP
102 In the simplest case
103 .B strace
104 runs the specified
105 .I command
106 until it exits.
107 It intercepts and records the system calls which are called
108 by a process and the signals which are received by a process.
109 The name of each system call, its arguments and its return value
110 are printed on standard error or to the file specified with the
111 .B \-o
112 option.
113 .LP
114 .B strace
115 is a useful diagnostic, instructional, and debugging tool.
116 System administrators, diagnosticians and trouble-shooters will find
117 it invaluable for solving problems with
118 programs for which the source is not readily available since
119 they do not need to be recompiled in order to trace them.
120 Students, hackers and the overly-curious will find that
121 a great deal can be learned about a system and its system calls by
122 tracing even ordinary programs.  And programmers will find that
123 since system calls and signals are events that happen at the user/kernel
124 interface, a close examination of this boundary is very
125 useful for bug isolation, sanity checking and
126 attempting to capture race conditions.
127 .LP
128 Each line in the trace contains the system call name, followed
129 by its arguments in parentheses and its return value.
130 An example from stracing the command "cat /dev/null" is:
131 .CW
132 open("/dev/null", O_RDONLY) = 3
133 .CE
134 Errors (typically a return value of \-1) have the errno symbol
135 and error string appended.
136 .CW
137 open("/foo/bar", O_RDONLY) = \-1 ENOENT (No such file or directory)
138 .CE
139 Signals are printed as signal symbol and decoded siginfo structure.
140 An excerpt from stracing and interrupting the command "sleep 666" is:
141 .CW
142 sigsuspend([] <unfinished ...>
143 --- SIGINT {si_signo=SIGINT, si_code=SI_USER, si_pid=...} ---
144 +++ killed by SIGINT +++
145 .CE
146 If a system call is being executed and meanwhile another one is being called
147 from a different thread/process then
148 .B strace
149 will try to preserve the order of those events and mark the ongoing call as
150 being
151 .IR unfinished .
152 When the call returns it will be marked as
153 .IR resumed .
154 .CW
155 [pid 28772] select(4, [3], NULL, NULL, NULL <unfinished ...>
156 [pid 28779] clock_gettime(CLOCK_REALTIME, {1130322148, 939977000}) = 0
157 [pid 28772] <... select resumed> )      = 1 (in [3])
158 .CE
159 Interruption of a (restartable) system call by a signal delivery is processed
160 differently as kernel terminates the system call and also arranges its
161 immediate reexecution after the signal handler completes.
162 .CW
163 read(0, 0x7ffff72cf5cf, 1)              = ? ERESTARTSYS (To be restarted)
164 --- SIGALRM ... ---
165 rt_sigreturn(0xe)                       = 0
166 read(0, "", 1)                          = 0
167 .CE
168 Arguments are printed in symbolic form with passion.
169 This example shows the shell performing ">>xyzzy" output redirection:
170 .CW
171 open("xyzzy", O_WRONLY|O_APPEND|O_CREAT, 0666) = 3
172 .CE
173 Here, the third argument of open is decoded by breaking down the
174 flag argument into its three bitwise-OR constituents and printing the
175 mode value in octal by tradition.  Where the traditional or native
176 usage differs from ANSI or POSIX, the latter forms are preferred.
177 In some cases,
178 .B strace
179 output is proven to be more readable than the source.
180 .LP
181 Structure pointers are dereferenced and the members are displayed
182 as appropriate.  In most cases, arguments are formatted in the most C-like
183 fashion possible.
184 For example, the essence of the command "ls \-l /dev/null" is captured as:
185 .CW
186 lstat("/dev/null", {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0
187 .CE
188 Notice how the 'struct stat' argument is dereferenced and how each member is
189 displayed symbolically.  In particular, observe how the
190 .B st_mode
191 member is carefully decoded into a bitwise-OR of symbolic and numeric values.
192 Also notice in this example that the first argument to
193 .B lstat
194 is an input to the system call and the second argument is an output.
195 Since output arguments are not modified if the system call fails, arguments may
196 not always be dereferenced.  For example, retrying the "ls \-l" example
197 with a non-existent file produces the following line:
198 .CW
199 lstat("/foo/bar", 0xb004) = \-1 ENOENT (No such file or directory)
200 .CE
201 In this case the porch light is on but nobody is home.
202 .LP
203 Character pointers are dereferenced and printed as C strings.
204 Non-printing characters in strings are normally represented by
205 ordinary C escape codes.
206 Only the first
207 .I strsize
208 (32 by default) bytes of strings are printed;
209 longer strings have an ellipsis appended following the closing quote.
210 Here is a line from "ls \-l" where the
211 .B getpwuid
212 library routine is reading the password file:
213 .CW
214 read(3, "root::0:0:System Administrator:/"..., 1024) = 422
215 .CE
216 While structures are annotated using curly braces, simple pointers
217 and arrays are printed using square brackets with commas separating
218 elements.  Here is an example from the command "id" on a system with
219 supplementary group ids:
220 .CW
221 getgroups(32, [100, 0]) = 2
222 .CE
223 On the other hand, bit-sets are also shown using square brackets
224 but set elements are separated only by a space.  Here is the shell,
225 preparing to execute an external command:
226 .CW
227 sigprocmask(SIG_BLOCK, [CHLD TTOU], []) = 0
228 .CE
229 Here, the second argument is a bit-set of two signals,
230 .BR SIGCHLD " and " SIGTTOU .
231 In some cases, the bit-set is so full that printing out the unset
232 elements is more valuable.  In that case, the bit-set is prefixed by
233 a tilde like this:
234 .CW
235 sigprocmask(SIG_UNBLOCK, ~[], NULL) = 0
236 .CE
237 Here, the second argument represents the full set of all signals.
238 .SH OPTIONS
239 .SS Output format
240 .TP 12
241 .BI "\-a " column
242 Align return values in a specific column (default column 40).
243 .TP
244 .B \-i
245 Print the instruction pointer at the time of the system call.
246 .TP
247 .B \-k
248 Print the execution stack trace of the traced processes after each system call (experimental).
249 This option is available only if
250 .B strace
251 is built with libunwind.
252 .TP
253 .BI "\-o " filename
254 Write the trace output to the file
255 .I filename
256 rather than to stderr.
257 .IR filename . pid
258 form is used if
259 .B \-ff
260 option is supplied.
261 If the argument begins with '|' or '!', the rest of the
262 argument is treated as a command and all output is piped to it.
263 This is convenient for piping the debugging output to a program
264 without affecting the redirections of executed programs.
265 The latter is not compatible with
266 .B \-ff
267 option currently.
268 .TP
269 .B \-q
270 Suppress messages about attaching, detaching etc.  This happens
271 automatically when output is redirected to a file and the command
272 is run directly instead of attaching.
273 .TP
274 .B \-qq
275 If given twice, suppress messages about process exit status.
276 .TP
277 .B \-r
278 Print a relative timestamp upon entry to each system call.  This
279 records the time difference between the beginning of successive
280 system calls.
281 .TP
282 .BI "\-s " strsize
283 Specify the maximum string size to print (the default is 32).  Note
284 that filenames are not considered strings and are always printed in
285 full.
286 .TP
287 .B \-t
288 Prefix each line of the trace with the wall clock time.
289 .TP
290 .B \-tt
291 If given twice, the time printed will include the microseconds.
292 .TP
293 .B \-ttt
294 If given thrice, the time printed will include the microseconds
295 and the leading portion will be printed as the number
296 of seconds since the epoch.
297 .TP
298 .B \-T
299 Show the time spent in system calls.  This records the time
300 difference between the beginning and the end of each system call.
301 .TP
302 .B \-x
303 Print all non-ASCII strings in hexadecimal string format.
304 .TP
305 .B \-xx
306 Print all strings in hexadecimal string format.
307 .TP
308 .B \-y
309 Print paths associated with file descriptor arguments.
310 .TP
311 .B \-yy
312 Print protocol specific information associated with socket file descriptors.
313 .SS Statistics
314 .TP 12
315 .B \-c
316 Count time, calls, and errors for each system call and report a summary on
317 program exit.  This attempts to show system time (CPU time spent running
318 in the kernel) independent of wall clock time.  If
319 .B \-c
320 is used with
321 .BR \-f ,
322 only aggregate totals for all traced processes are kept.
323 .TP
324 .B \-C
325 Like
326 .B \-c
327 but also print regular output while processes are running.
328 .TP
329 .BI "\-O " overhead
330 Set the overhead for tracing system calls to
331 .I overhead
332 microseconds.
333 This is useful for overriding the default heuristic for guessing
334 how much time is spent in mere measuring when timing system calls using
335 the
336 .B \-c
337 option.  The accuracy of the heuristic can be gauged by timing a given
338 program run without tracing (using
339 .BR time (1))
340 and comparing the accumulated
341 system call time to the total produced using
342 .BR \-c .
343 .TP
344 .BI "\-S " sortby
345 Sort the output of the histogram printed by the
346 .B \-c
347 option by the specified criterion.  Legal values are
348 .BR time ,
349 .BR calls ,
350 .BR name ,
351 and
352 .B nothing
353 (default is
354 .BR time ).
355 .TP
356 .B \-w
357 Summarise the time difference between the beginning and end of
358 each system call.  The default is to summarise the system time.
359 .SS Filtering
360 .TP 12
361 .BI "\-e " expr
362 A qualifying expression which modifies which events to trace
363 or how to trace them.  The format of the expression is:
364 .RS 15
365 .IP
366 [\,\fIqualifier\/\fB=\fR][\fB!\fR][\fB?\fR]\,\fIvalue1\/\fR[\fB,\fR[\fB?\fR]\,\fIvalue2\/\fR]...
367 .RE
368 .IP
369 where
370 .I qualifier
371 is one of
372 .BR trace ,
373 .BR abbrev ,
374 .BR verbose ,
375 .BR raw ,
376 .BR signal ,
377 .BR read ,
378 .BR write ,
379 .BR fault ,
380 or
381 .B inject
382 and
383 .I value
384 is a qualifier-dependent symbol or number.  The default
385 qualifier is
386 .BR trace .
387 Using an exclamation mark negates the set of values.  For example,
388 .BR \-e "\ " open
389 means literally
390 .BR \-e "\ " trace = open
391 which in turn means trace only the
392 .B open
393 system call.  By contrast,
394 .BR \-e "\ " trace "=!" open
395 means to trace every system call except
396 .BR open .
397 Question mark before the syscall qualification allows suppression of error
398 in case no syscalls matched the qualification provided.
399 In addition, the special values
400 .B all
401 and
402 .B none
403 have the obvious meanings.
404 .IP
405 Note that some shells use the exclamation point for history
406 expansion even inside quoted arguments.  If so, you must escape
407 the exclamation point with a backslash.
408 .TP
409 \fB\-e\ trace\fR=\,\fIset\fR
410 Trace only the specified set of system calls.  The
411 .B \-c
412 option is useful for determining which system calls might be useful
413 to trace.  For example,
414 .BR trace = open,close,read,write
415 means to only
416 trace those four system calls.  Be careful when making inferences
417 about the user/kernel boundary if only a subset of system calls
418 are being monitored.  The default is
419 .BR trace = all .
420 .TP
421 \fB\-e\ trace\fR=/\,\fIregex\fR
422 Trace only those system calls that match the
423 .IR regex .
424 You can use
425 .B POSIX
426 Extended Regular Expression syntax (see
427 .BR regex (7)).
428 .PP
429 .BR "\-e\ trace" = %file
430 .TQ
431 .BR "\-e\ trace" = file " (deprecated)"
432 Trace all system calls which take a file name as an argument.  You
433 can think of this as an abbreviation for
434 .BR "\-e\ trace" = open , stat , chmod , unlink ,...
435 which is useful to seeing what files the process is referencing.
436 Furthermore, using the abbreviation will ensure that you don't
437 accidentally forget to include a call like
438 .B lstat
439 in the list.  Betchya woulda forgot that one.
440 .PP
441 .BR "\-e\ trace" = %process
442 .TQ
443 .BR "\-e\ trace" = process " (deprecated)"
444 Trace all system calls which involve process management.  This
445 is useful for watching the fork, wait, and exec steps of a process.
446 .PP
447 .BR "\-e\ trace" = %network
448 .TQ
449 .BR "\-e\ trace" = network " (deprecated)"
450 Trace all the network related system calls.
451 .PP
452 .BR "\-e\ trace" = %signal
453 .TQ
454 .BR "\-e\ trace" = signal " (deprecated)"
455 Trace all signal related system calls.
456 .PP
457 .BR "\-e\ trace" = %ipc
458 .TQ
459 .BR "\-e\ trace" = ipc " (deprecated)"
460 Trace all IPC related system calls.
461 .PP
462 .BR "\-e\ trace" = %desc
463 .TQ
464 .BR "\-e\ trace" = desc " (deprecated)"
465 Trace all file descriptor related system calls.
466 .PP
467 .BR "\-e\ trace" = %memory
468 .TQ
469 .BR "\-e\ trace" = memory " (deprecated)"
470 Trace all memory mapping related system calls.
471 .TP
472 .BR "\-e\ trace" = %stat
473 Trace stat syscall variants.
474 .TP
475 .BR "\-e\ trace" = %lstat
476 Trace lstat syscall variants.
477 .TP
478 .BR "\-e\ trace" = %fstat
479 Trace fstat and fstatat syscall variants.
480 .TP
481 .BR "\-e\ trace" = %%stat
482 Trace syscalls used for requesting file status (stat, lstat, fstat, fstatat,
483 statx, and their variants).
484 .TP
485 .BR "\-e\ trace" = %statfs
486 Trace statfs, statfs64, statvfs, osf_statfs, and osf_statfs64 system calls.
487 The same effect can be achieved with
488 .BR "\-e\ trace" = /^(.*_)?statv?fs
489 regular expression.
490 .TP
491 .BR "\-e\ trace" = %fstatfs
492 Trace fstatfs, fstatfs64, fstatvfs, osf_fstatfs, and osf_fstatfs64 system calls.
493 The same effect can be achieved with
494 .BR "\-e\ trace" = /fstatv?fs
495 regular expression.
496 .TP
497 .BR "\-e\ trace" = %%statfs
498 Trace syscalls related to file system statistics (statfs-like, fstatfs-like,
499 and ustat).  The same effect can be achieved with
500 .BR "\-e\ trace" = /statv?fs|fsstat|ustat
501 regular expression.
502 .TP
503 \fB\-e\ abbrev\fR=\,\fIset\fR
504 Abbreviate the output from printing each member of large structures.
505 The default is
506 .BR abbrev = all .
507 The
508 .B \-v
509 option has the effect of
510 .BR abbrev = none .
511 .TP
512 \fB\-e\ verbose\fR=\,\fIset\fR
513 Dereference structures for the specified set of system calls.  The
514 default is
515 .BR verbose = all .
516 .TP
517 \fB\-e\ raw\fR=\,\fIset\fR
518 Print raw, undecoded arguments for the specified set of system calls.
519 This option has the effect of causing all arguments to be printed
520 in hexadecimal.  This is mostly useful if you don't trust the
521 decoding or you need to know the actual numeric value of an
522 argument.
523 .TP
524 \fB\-e\ signal\fR=\,\fIset\fR
525 Trace only the specified subset of signals.  The default is
526 .BR signal = all .
527 For example,
528 .B signal "=!" SIGIO
529 (or
530 .BR signal "=!" io )
531 causes SIGIO signals not to be traced.
532 .TP
533 \fB\-e\ read\fR=\,\fIset\fR
534 Perform a full hexadecimal and ASCII dump of all the data read from
535 file descriptors listed in the specified set.  For example, to see
536 all input activity on file descriptors
537 .I 3
538 and
539 .I 5
540 use
541 \fB\-e\ read\fR=\,\fI3\fR,\fI5\fR.
542 Note that this is independent from the normal tracing of the
543 .BR read (2)
544 system call which is controlled by the option
545 .BR -e "\ " trace = read .
546 .TP
547 \fB\-e\ write\fR=\,\fIset\fR
548 Perform a full hexadecimal and ASCII dump of all the data written to
549 file descriptors listed in the specified set.  For example, to see
550 all output activity on file descriptors
551 .I 3
552 and
553 .I 5
554 use
555 \fB\-e\ write\fR=\,\fI3\fR,\,\fI5\fR.
556 Note that this is independent from the normal tracing of the
557 .BR write (2)
558 system call which is controlled by the option
559 .BR -e "\ " trace = write .
560 .TP
561 \fB\-e\ inject\fR=\,\fIset\/\fR[:\fBerror\fR=\,\fIerrno\/\fR|:\fBretval\fR=\,\fIvalue\/\fR][:\fBsignal\fR=\,\fIsig\/\fR][:\fBwhen\fR=\,\fIexpr\/\fR]
562 Perform syscall tampering for the specified set of syscalls.
563
564 At least one of
565 .BR error ,
566 .BR retval ,
567 or
568 .B signal
569 options has to be specified.
570 .B error
571 and
572 .B retval
573 are mutually exclusive.
574
575 If :\fBerror\fR=\,\fIerrno\/\fR option is specified,
576 a fault is injected into a syscall invocation:
577 the syscall number is replaced by -1 which corresponds to an invalid syscall,
578 and the error code is specified using a symbolic
579 .I errno
580 value like
581 .B ENOSYS
582 or a numeric value within 1..4095 range.
583
584 If :\fBretval\fR=\,\fIvalue\/\fR option is specified,
585 success injection is performed: the syscall number is replaced by -1,
586 but a bogus success value is returned to the callee.
587
588 If :\fBsignal\fR=\,\fIsig\/\fR option is specified with either a symbolic value
589 like
590 .B SIGSEGV
591 or a numeric value within 1..\fBSIGRTMAX\fR range,
592 that signal is delivered on entering every syscall specified by the
593 .IR set .
594
595 If :\fBsignal\fR=\,\fIsig\/\fR option is specified without
596 :\fBerror\fR=\,\fIerrno\/\fR or :\fBretval\fR=\,\fIvalue\/\fR options,
597 then only a signal
598 .I sig
599 is delivered without a syscall fault injection.
600 Conversely, :\fBerror\fR=\,\fIerrno\/\fR or
601 :\fBretval\fR=\,\fIvalue\/\fR option without
602 :\fBsignal\fR=\,\fIsig\/\fR option injects a fault without delivering a signal.
603
604 If both :\fBerror\fR=\,\fIerrno\/\fR or :\fBretval\fR=\,\fIvalue\/\fR
605 and :\fBsignal\fR=\,\fIsig\/\fR options are specified, then both
606 a fault or success is injected and a signal is delivered.
607
608 Unless a :\fBwhen\fR=\,\fIexpr\fR subexpression is specified,
609 an injection is being made into every invocation of each syscall from the
610 .IR set .
611
612 The format of the subexpression is one of the following:
613 .RS
614 .IP "" 2
615 .I first
616 .RS 4
617 For every syscall from the
618 .IR set ,
619 perform an injection for the syscall invocation number
620 .I first
621 only.
622 .RE
623 .IP "" 2
624 \fIfirst\/\fB+\fR
625 .RS 4
626 For every syscall from the
627 .IR set ,
628 perform injections for the syscall invocation number
629 .I first
630 and all subsequent invocations.
631 .RE
632 .IP "" 2
633 \fIfirst\/\fB+\fIstep\fR
634 .RS 4
635 For every syscall from the
636 .IR set ,
637 perform injections for syscall invocations number
638 .IR first ,
639 .IR first + step ,
640 .IR first + step + step ,
641 and so on.
642 .RE
643 .RE
644 .IP
645 For example, to fail each third and subsequent chdir syscalls with
646 .BR ENOENT ,
647 use
648 \fB\-e\ inject\fR=\,\fIchdir\/\fR:\fBerror\fR=\,\fIENOENT\/\fR:\fBwhen\fR=\,\fI3\/\fB+\fR.
649
650 The valid range for numbers
651 .I first
652 and
653 .I step
654 is 1..65535.
655
656 An injection expression can contain only one
657 .BR error =
658 or
659 .BR retval =
660 specification, and only one
661 .BR signal =
662 specification.  If an injection expression contains multiple
663 .BR when =
664 specifications, the last one takes precedence.
665
666 Accounting of syscalls that are subject to injection
667 is done per syscall and per tracee.
668
669 Specification of syscall injection can be combined
670 with other syscall filtering options, for example,
671 \fB\-P \fI/dev/urandom \fB\-e inject\fR=\,\fIfile\/\fR:\fBerror\fR=\,\fIENOENT\fR.
672
673 .TP
674 \fB\-e\ fault\fR=\,\fIset\/\fR[:\fBerror\fR=\,\fIerrno\/\fR][:\fBwhen\fR=\,\fIexpr\/\fR]
675 Perform syscall fault injection for the specified set of syscalls.
676
677 This is equivalent to more generic
678 \fB\-e\ inject\fR= expression with default value of
679 .I errno
680 option set to
681 .IR ENOSYS .
682
683 .TP
684 .BI "\-P " path
685 Trace only system calls accessing
686 .IR path .
687 Multiple
688 .B \-P
689 options can be used to specify several paths.
690 .TP
691 .B \-v
692 Print unabbreviated versions of environment, stat, termios, etc.
693 calls.  These structures are very common in calls and so the default
694 behavior displays a reasonable subset of structure members.  Use
695 this option to get all of the gory details.
696 .SS Tracing
697 .TP 12
698 .BI "\-b " syscall
699 If specified syscall is reached, detach from traced process.
700 Currently, only
701 .I execve
702 syscall is supported.  This option is useful if you want to trace
703 multi-threaded process and therefore require -f, but don't want
704 to trace its (potentially very complex) children.
705 .TP
706 .B \-D
707 Run tracer process as a detached grandchild, not as parent of the
708 tracee.  This reduces the visible effect of
709 .B strace
710 by keeping the tracee a direct child of the calling process.
711 .TP
712 .B \-f
713 Trace child processes as they are created by currently traced
714 processes as a result of the
715 .BR fork (2),
716 .BR vfork (2)
717 and
718 .BR clone (2)
719 system calls.  Note that
720 .B \-p
721 .I PID
722 .B \-f
723 will attach all threads of process PID if it is multi-threaded,
724 not only thread with thread_id = PID.
725 .TP
726 .B \-ff
727 If the
728 .B \-o
729 .I filename
730 option is in effect, each processes trace is written to
731 .I filename.pid
732 where pid is the numeric process id of each process.
733 This is incompatible with
734 .BR \-c ,
735 since no per-process counts are kept.
736
737 One might want to consider using
738 .BR strace-log-merge (1)
739 to obtain a combined strace log view.
740 .TP
741 .BI "\-I " interruptible
742 When strace can be interrupted by signals (such as pressing ^C).
743 1: no signals are blocked; 2: fatal signals are blocked while decoding syscall
744 (default); 3: fatal signals are always blocked (default if '-o FILE PROG');
745 4: fatal signals and SIGTSTP (^Z) are always blocked (useful to make
746 strace -o FILE PROG not stop on ^Z).
747 .SS Startup
748 .TP 12
749 \fB\-E\ \fIvar\fR=\,\fIval\fR
750 Run command with
751 .IR var = val
752 in its list of environment variables.
753 .TP
754 .BI "\-E " var
755 Remove
756 .IR var
757 from the inherited list of environment variables before passing it on to
758 the command.
759 .TP
760 .BI "\-p " pid
761 Attach to the process with the process
762 .SM ID
763 .I pid
764 and begin tracing.
765 The trace may be terminated
766 at any time by a keyboard interrupt signal (\c
767 .SM CTRL\s0-C).
768 .B strace
769 will respond by detaching itself from the traced process(es)
770 leaving it (them) to continue running.
771 Multiple
772 .B \-p
773 options can be used to attach to many processes in addition to
774 .I command
775 (which is optional if at least one
776 .B \-p
777 option is given).
778 .B \-p
779 "`pidof PROG`" syntax is supported.
780 .TP
781 .BI "\-u " username
782 Run command with the user \s-1ID\s0, group \s-2ID\s0, and
783 supplementary groups of
784 .IR username .
785 This option is only useful when running as root and enables the
786 correct execution of setuid and/or setgid binaries.
787 Unless this option is used setuid and setgid programs are executed
788 without effective privileges.
789 .SS Miscellaneous
790 .TP 12
791 .B \-d
792 Show some debugging output of
793 .B strace
794 itself on the standard error.
795 .TP
796 .B \-F
797 This option is deprecated.  It is retained for backward compatibility only
798 and may be removed in future releases.
799 Usage of multiple instances of
800 .B \-F
801 option is still equivalent to a single
802 .BR \-f ,
803 and it is ignored at all if used along with one or more instances of
804 .B \-f
805 option.
806 .TP
807 .B \-h
808 Print the help summary.
809 .TP
810 .B \-V
811 Print the version number of
812 .BR strace .
813 .SH DIAGNOSTICS
814 When
815 .I command
816 exits,
817 .B strace
818 exits with the same exit status.
819 If
820 .I command
821 is terminated by a signal,
822 .B strace
823 terminates itself with the same signal, so that
824 .B strace
825 can be used as a wrapper process transparent to the invoking parent process.
826 Note that parent-child relationship (signal stop notifications,
827 getppid() value, etc) between traced process and its parent are not preserved
828 unless
829 .B \-D
830 is used.
831 .LP
832 When using
833 .B \-p
834 without a
835 .IR command ,
836 the exit status of
837 .B strace
838 is zero unless no processes has been attached or there was an unexpected error
839 in doing the tracing.
840 .SH "SETUID INSTALLATION"
841 If
842 .B strace
843 is installed setuid to root then the invoking user will be able to
844 attach to and trace processes owned by any user.
845 In addition setuid and setgid programs will be executed and traced
846 with the correct effective privileges.
847 Since only users trusted with full root privileges should be allowed
848 to do these things,
849 it only makes sense to install
850 .B strace
851 as setuid to root when the users who can execute it are restricted
852 to those users who have this trust.
853 For example, it makes sense to install a special version of
854 .B strace
855 with mode 'rwsr-xr--', user
856 .B root
857 and group
858 .BR trace ,
859 where members of the
860 .B trace
861 group are trusted users.
862 If you do use this feature, please remember to install
863 a regular non-setuid version of
864 .B strace
865 for ordinary users to use.
866 .SH "MULTIPLE PERSONALITY SUPPORT"
867 On some architectures,
868 .B strace
869 supports decoding of syscalls for processes that use different ABI rather than
870 the one
871 .B strace
872 uses.
873 Specifically, in addition to decoding native ABI,
874 .B strace
875 can decode the following ABIs on the following architectures:
876 .TS H
877 allbox;
878 lb lb
879 l l.
880 Architecture    ABIs supported
881 x86_64  i386, x32 (when built as an x86_64 application); i386 (when built as an x32 application)
882 AArch64 ARM 32-bit EABI
883 PowerPC 64-bit  PowerPC 32-bit
884 RISC-V 64-bit   RISC-V 32-bit
885 s390x   s390
886 SPARC 64-bit    SPARC 32-bit
887 TILE 64-bit     TILE 32-bit
888 .TE
889 .PP
890 This support is optional and relies on ability to generate and parse structure
891 definitions during the build time.
892 Please refer to the output of the
893 .B strace \-V
894 command in order to figure out what support is available in your strace build
895 ("non-native" refers to an ABI that differs from the ABI strace has):
896 .TP 15
897 .B m32-mpers
898 .B strace
899 can trace and properly decode non-native 32-bit binaries.
900 .TP
901 .B no-m32-mpers
902 .B strace
903 can trace, but cannot properly decode non-native 32-bit binaries.
904 .TP
905 .B mx32-mpers
906 .B strace
907 can trace and properly decode non-native 32-on-64-bit binaries.
908 .TP
909 .B no-mx32-mpers
910 .B strace
911 can trace, but cannot properly decode non-native 32-on-64-bit binaries.
912 .PP
913 If the output contains neither
914 .B m32-mpers
915 nor
916 .BR no-m32-mpers ,
917 then decoding of non-native 32-bit binaries is not implemented at all
918 or not applicable.
919 .PP
920 Likewise, if the output contains neither
921 .B mx32-mpers
922 nor
923 .BR no-mx32-mpers ,
924 then decoding of non-native 32-on-64-bit binaries is not implemented at all
925 or not applicable.
926 .SH NOTES
927 It is a pity that so much tracing clutter is produced by systems
928 employing shared libraries.
929 .LP
930 It is instructive to think about system call inputs and outputs
931 as data-flow across the user/kernel boundary.  Because user-space
932 and kernel-space are separate and address-protected, it is
933 sometimes possible to make deductive inferences about process
934 behavior using inputs and outputs as propositions.
935 .LP
936 In some cases, a system call will differ from the documented behavior
937 or have a different name.  For example, the
938 .BR faccessat (2)
939 system call does not have
940 .I flags
941 argument, and the
942 .BR setrlimit (2)
943 library function uses
944 .BR prlimit64 (2)
945 system call on modern (2.6.38+) kernels.  These
946 discrepancies are normal but idiosyncratic characteristics of the
947 system call interface and are accounted for by C library wrapper
948 functions.
949 .LP
950 Some system calls have different names in different architectures and
951 personalities.  In these cases, system call filtering and printing
952 uses the names that match corresponding
953 .BR __NR_ *
954 kernel macros of the tracee's architecture and personality.
955 There are two exceptions from this general rule:
956 .BR arm_fadvise64_64 (2)
957 ARM syscall and
958 .BR xtensa_fadvise64_64 (2)
959 Xtensa syscall are filtered and printed as
960 .BR fadvise64_64 (2).
961 .LP
962 On some platforms a process that is attached to with the
963 .B \-p
964 option may observe a spurious EINTR return from the current
965 system call that is not restartable.  (Ideally, all system calls
966 should be restarted on strace attach, making the attach invisible
967 to the traced process, but a few system calls aren't.
968 Arguably, every instance of such behavior is a kernel bug.)
969 This may have an unpredictable effect on the process
970 if the process takes no action to restart the system call.
971 .SH BUGS
972 Programs that use the
973 .I setuid
974 bit do not have
975 effective user
976 .SM ID
977 privileges while being traced.
978 .LP
979 A traced process runs slowly.
980 .LP
981 Traced processes which are descended from
982 .I command
983 may be left running after an interrupt signal (\c
984 .SM CTRL\s0-C).
985 .SH HISTORY
986 The original
987 .B strace
988 was written by Paul Kranenburg
989 for SunOS and was inspired by its
990 .B trace
991 utility.
992 The SunOS version of
993 .B strace
994 was ported to Linux and enhanced
995 by Branko Lankester, who also wrote the Linux kernel support.
996 Even though Paul released
997 .B strace
998 2.5 in 1992,
999 Branko's work was based on Paul's
1000 .B strace
1001 1.5 release from 1991.
1002 In 1993, Rick Sladkey merged
1003 .B strace
1004 2.5 for SunOS and the second release of
1005 .B strace
1006 for Linux, added many of the features of
1007 .BR truss (1)
1008 from SVR4, and produced an
1009 .B strace
1010 that worked on both platforms.  In 1994 Rick ported
1011 .B strace
1012 to SVR4 and Solaris and wrote the
1013 automatic configuration support.  In 1995 he ported
1014 .B strace
1015 to Irix
1016 and tired of writing about himself in the third person.
1017 .PP
1018 Beginning with 1996,
1019 .B strace
1020 was maintained by Wichert Akkerman.
1021 During his tenure,
1022 .B strace
1023 development migrated to CVS; ports to FreeBSD and many architectures on Linux
1024 (including ARM, IA-64, MIPS, PA-RISC, PowerPC, s390, SPARC) were introduced.
1025 In 2002, the burden of
1026 .B strace
1027 maintainership was transferred to Ronald McGrath.
1028 Since then,
1029 .B strace
1030 gained support for several new Linux architectures (AMD64, s390x, SuperH),
1031 bi-architecture support for some of them, and received numerous additions and
1032 improvements in syscalls decoders on Linux;
1033 .B strace
1034 development migrated to
1035 .B git
1036 during that period.
1037 Since 2009,
1038 .B strace
1039 is actively maintained by Dmitry Levin.
1040 .B strace
1041 gained support for AArch64, ARC, AVR32, Blackfin, Meta, Nios II, OpenSISC 1000,
1042 RISC-V, Tile/TileGx, Xtensa architectures since that time.
1043 In 2012, unmaintained and apparently broken support for non-Linux operating
1044 systems was removed.
1045 Also, in 2012
1046 .B strace
1047 gained support for path tracing and file descriptor path decoding.
1048 In 2014, support for stack traces printing was added.
1049 In 2016, syscall fault injection was implemented.
1050 .PP
1051 For the additional information, please refer to the
1052 .B NEWS
1053 file and
1054 .B strace
1055 repository commit log.
1056 .SH REPORTING BUGS
1057 Problems with
1058 .B strace
1059 should be reported to the
1060 .B strace
1061 mailing list at <strace\-devel@lists.sourceforge.net>.
1062 .SH "SEE ALSO"
1063 .BR strace-log-merge (1),
1064 .BR ltrace (1),
1065 .BR perf-trace (1),
1066 .BR trace-cmd (1),
1067 .BR time (1),
1068 .BR ptrace (2),
1069 .BR proc (5)