strace \- trace system calls and signals
.SH SYNOPSIS
.SY strace
-.OP \-CdffhikqrtttTvVxxy
+.if '@ENABLE_STACKTRACE_TRUE@'#' .ig end_unwind_opt
+.OP \-ACdffhikqrtttTvVxxy
+.end_unwind_opt
+.if '@ENABLE_STACKTRACE_FALSE@'#' .ig end_no_unwind_opt
+.OP \-ACdffhiqrtttTvVxxy
+.end_no_unwind_opt
.OP \-I n
.OP \-b execve
.OM \-e expr
.OP \-a column
.OP \-o file
.OP \-s strsize
+.OP \-X format
.OM \-P path
.OM \-p pid
.BR "" {
rt_sigreturn(0xe) = 0
read(0, "", 1) = 0
.CE
-Arguments are printed in symbolic form with a passion.
+Arguments are printed in symbolic form with passion.
This example shows the shell performing ">>xyzzy" output redirection:
.CW
open("xyzzy", O_WRONLY|O_APPEND|O_CREAT, 0666) = 3
.CE
-Here the third argument of open is decoded by breaking down the
+Here, the third argument of
+.B open
+is decoded by breaking down the
flag argument into its three bitwise-OR constituents and printing the
-mode value in octal by tradition. Where traditional or native
+mode value in octal by tradition. Where the traditional or native
usage differs from ANSI or POSIX, the latter forms are preferred.
In some cases,
.B strace
-output has proven to be more readable than the source.
+output is proven to be more readable than the source.
.LP
Structure pointers are dereferenced and the members are displayed
-as appropriate. In all cases arguments are formatted in the most C-like
+as appropriate. In most cases, arguments are formatted in the most C-like
fashion possible.
For example, the essence of the command "ls \-l /dev/null" is captured as:
.CW
lstat("/dev/null", {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0
.CE
Notice how the 'struct stat' argument is dereferenced and how each member is
-displayed symbolically. In particular, observe how the st_mode member
-is carefully decoded into a bitwise-OR of symbolic and numeric values.
-Also notice in this example that the first argument to lstat is an input
-to the system call and the second argument is an output. Since output
-arguments are not modified if the system call fails, arguments may not
-always be dereferenced. For example, retrying the "ls \-l" example
+displayed symbolically. In particular, observe how the
+.B st_mode
+member is carefully decoded into a bitwise-OR of symbolic and numeric values.
+Also notice in this example that the first argument to
+.B lstat
+is an input to the system call and the second argument is an output.
+Since output arguments are not modified if the system call fails, arguments may
+not always be dereferenced. For example, retrying the "ls \-l" example
with a non-existent file produces the following line:
.CW
lstat("/foo/bar", 0xb004) = \-1 ENOENT (No such file or directory)
.CE
In this case the porch light is on but nobody is home.
.LP
+Syscalls unknown to
+.B strace
+are printed raw, with the unknown system call number printed in hexadecimal form
+and prefixed with "syscall_":
+.CW
+syscall_0xbad(0x1, 0x2, 0x3, 0x4, 0x5, 0x6) = -1 ENOSYS (Function not implemented)
+.CE
+.LP
Character pointers are dereferenced and printed as C strings.
Non-printing characters in strings are normally represented by
ordinary C escape codes.
getgroups(32, [100, 0]) = 2
.CE
On the other hand, bit-sets are also shown using square brackets
-but set elements are separated only by a space. Here is the shell
+but set elements are separated only by a space. Here is the shell,
preparing to execute an external command:
.CW
sigprocmask(SIG_BLOCK, [CHLD TTOU], []) = 0
.CE
-Here the second argument is a bit-set of two signals, SIGCHLD and SIGTTOU.
-In some cases the bit-set is so full that printing out the unset
+Here, the second argument is a bit-set of two signals,
+.BR SIGCHLD " and " SIGTTOU .
+In some cases, the bit-set is so full that printing out the unset
elements is more valuable. In that case, the bit-set is prefixed by
a tilde like this:
.CW
sigprocmask(SIG_UNBLOCK, ~[], NULL) = 0
.CE
-Here the second argument represents the full set of all signals.
+Here, the second argument represents the full set of all signals.
.SH OPTIONS
.SS Output format
.TP 12
.TP
.B \-i
Print the instruction pointer at the time of the system call.
+.if '@ENABLE_STACKTRACE_TRUE@'#' .ig end_unwind
.TP
.B \-k
-Print the execution stack trace of the traced processes after each system call (experimental).
-This option is available only if
-.B strace
-is built with libunwind.
+Print the execution stack trace of the traced processes after each system call.
+.end_unwind
.TP
.BI "\-o " filename
Write the trace output to the file
.I filename
rather than to stderr.
-Use
-.I filename.pid
-if
+.IR filename . pid
+form is used if
.B \-ff
-is used.
-If the argument begins with '|' or with '!' then the rest of the
+option is supplied.
+If the argument begins with '|' or '!', the rest of the
argument is treated as a command and all output is piped to it.
This is convenient for piping the debugging output to a program
without affecting the redirections of executed programs.
+The latter is not compatible with
+.B \-ff
+option currently.
+.TP
+.B \-A
+Open the file provided in the
+.B \-o
+option in append mode.
.TP
.B \-q
Suppress messages about attaching, detaching etc. This happens
Print a relative timestamp upon entry to each system call. This
records the time difference between the beginning of successive
system calls.
+Note that since
+.B \-r
+option uses the monotonic clock time for measuring time difference and not the
+wall clock time, its measurements can differ from the difference in time
+reported by the
+.B \-t
+option.
.TP
.BI "\-s " strsize
Specify the maximum string size to print (the default is 32). Note
full.
.TP
.B \-t
-Prefix each line of the trace with the time of day.
+Prefix each line of the trace with the wall clock time.
.TP
.B \-tt
If given twice, the time printed will include the microseconds.
.B \-xx
Print all strings in hexadecimal string format.
.TP
+.BI "\-X " format
+Set the format for printing of named constants and flags.
+Supported
+.I format
+values are:
+.RS
+.TP 10
+.B raw
+Raw number output, without decoding.
+.TP
+.B abbrev
+Output a named constant or a set of flags instead of the raw number if they are
+found.
+This is the default
+.B strace
+behaviour.
+.TP
+.B verbose
+Output both the raw value and the decoded string (as a comment).
+.RE
+.TP
.B \-y
Print paths associated with file descriptor arguments.
.TP
.B \-yy
-Print protocol specific information associated with socket file descriptors.
+Print protocol specific information associated with socket file descriptors,
+and block/character device number associated with device file descriptors.
.SS Statistics
.TP 12
.B \-c
Count time, calls, and errors for each system call and report a summary on
-program exit. On Linux, this attempts to show system time (CPU time spent
-running in the kernel) independent of wall clock time. If
+program exit, suppressing the regular output.
+This attempts to show system time (CPU time spent running
+in the kernel) independent of wall clock time. If
.B \-c
is used with
-.B \-f
-or
-.B \-F
-, only aggregate totals for all traced processes are kept.
+.BR \-f ,
+only aggregate totals for all traced processes are kept.
.TP
.B \-C
Like
.BR read ,
.BR write ,
.BR fault ,
+.BR inject ,
or
-.B inject
+.B kvm
and
.I value
is a qualifier-dependent symbol or number. The default
.BR open .
Question mark before the syscall qualification allows suppression of error
in case no syscalls matched the qualification provided.
+Appending one of "@64", "@32", or "@x32" suffixes to the syscall qualification
+allows specifying syscalls only for the 64-bit, 32-bit, or 32-on-64-bit
+personality, respectively.
In addition, the special values
.B all
and
.B POSIX
Extended Regular Expression syntax (see
.BR regex (7)).
-.PP
+.TP
.BR "\-e\ trace" = %file
.TQ
.BR "\-e\ trace" = file " (deprecated)"
accidentally forget to include a call like
.B lstat
in the list. Betchya woulda forgot that one.
-.PP
+.TP
.BR "\-e\ trace" = %process
.TQ
.BR "\-e\ trace" = process " (deprecated)"
Trace all system calls which involve process management. This
is useful for watching the fork, wait, and exec steps of a process.
-.PP
+.TP
.BR "\-e\ trace" = %network
.TQ
.BR "\-e\ trace" = network " (deprecated)"
Trace all the network related system calls.
-.PP
+.TP
.BR "\-e\ trace" = %signal
.TQ
.BR "\-e\ trace" = signal " (deprecated)"
Trace all signal related system calls.
-.PP
+.TP
.BR "\-e\ trace" = %ipc
.TQ
.BR "\-e\ trace" = ipc " (deprecated)"
Trace all IPC related system calls.
-.PP
+.TP
.BR "\-e\ trace" = %desc
.TQ
.BR "\-e\ trace" = desc " (deprecated)"
Trace all file descriptor related system calls.
-.PP
+.TP
.BR "\-e\ trace" = %memory
.TQ
.BR "\-e\ trace" = memory " (deprecated)"
.BR "\-e\ trace" = /statv?fs|fsstat|ustat
regular expression.
.TP
+.BR "\-e\ trace" = %pure
+Trace syscalls that always succeed and have no arguments.
+Currently, this list includes
+.BR arc_gettls "(2), " getdtablesize "(2), " getegid "(2), " getegid32 "(2),"
+.BR geteuid "(2), " geteuid32 "(2), " getgid "(2), " getgid32 "(2),"
+.BR getpagesize "(2), " getpgrp "(2), " getpid "(2), " getppid "(2),"
+.BR get_thread_area (2)
+(on architectures other than x86),
+.BR gettid "(2), " get_tls "(2), " getuid "(2), " getuid32 "(2),"
+.BR getxgid "(2), " getxpid "(2), " getxuid "(2), " kern_features "(2), and"
+.BR metag_get_tls "(2)"
+syscalls.
+.TP
\fB\-e\ abbrev\fR=\,\fIset\fR
Abbreviate the output from printing each member of large structures.
The default is
in hexadecimal. This is mostly useful if you don't trust the
decoding or you need to know the actual numeric value of an
argument.
+See also
+.B \-X raw
+option.
.TP
\fB\-e\ signal\fR=\,\fIset\fR
Trace only the specified subset of signals. The default is
.BR signal = all .
For example,
-.B signal "=!" SIGIO
+.BR signal "=!" SIGIO
(or
.BR signal "=!" io )
-causes SIGIO signals not to be traced.
+causes
+.B SIGIO
+signals not to be traced.
.TP
\fB\-e\ read\fR=\,\fIset\fR
Perform a full hexadecimal and ASCII dump of all the data read from
system call which is controlled by the option
.BR -e "\ " trace = write .
.TP
-\fB\-e\ inject\fR=\,\fIset\/\fR[:\fBerror\fR=\,\fIerrno\/\fR|:\fBretval\fR=\,\fIvalue\/\fR][:\fBsignal\fR=\,\fIsig\/\fR][:\fBwhen\fR=\,\fIexpr\/\fR]
+\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]
Perform syscall tampering for the specified set of syscalls.
At least one of
.BR error ,
.BR retval ,
+.BR signal ,
+.BR delay_enter ,
or
-.B signal
+.B delay_exit
options has to be specified.
.B error
and
If :\fBerror\fR=\,\fIerrno\/\fR option is specified,
a fault is injected into a syscall invocation:
-the syscall number is replaced by -1 which corresponds to an invalid syscall,
+the syscall number is replaced by -1 which corresponds to an invalid syscall
+(unless a syscall is specified with :\fBsyscall=\fR option),
and the error code is specified using a symbolic
.I errno
value like
that signal is delivered on entering every syscall specified by the
.IR set .
+If :\fBdelay_enter\fR=\,\fIusecs\/\fR or :\fBdelay_exit\fR=\,\fIusecs\/\fR
+options are specified, delay injection is performed: the tracee is delayed
+by at least
+.IR usecs
+microseconds on entering or exiting the syscall.
+
If :\fBsignal\fR=\,\fIsig\/\fR option is specified without
-:\fBerror\fR=\,\fIerrno\/\fR or :\fBretval\fR=\,\fIvalue\/\fR options,
+:\fBerror\fR=\,\fIerrno\/\fR, :\fBretval\fR=\,\fIvalue\/\fR or
+:\fBdelay_{enter,exit}\fR=\,\fIusecs\/\fR options,
then only a signal
.I sig
-is delivered without a syscall fault injection.
+is delivered without a syscall fault or delay injection.
Conversely, :\fBerror\fR=\,\fIerrno\/\fR or
:\fBretval\fR=\,\fIvalue\/\fR option without
-:\fBsignal\fR=\,\fIsig\/\fR option injects a fault without delivering a signal.
+:\fBdelay_enter\fR=\,\fIusecs\/\fR,
+:\fBdelay_exit\fR=\,\fIusecs\/\fR or
+:\fBsignal\fR=\,\fIsig\/\fR options injects a fault without delivering a signal
+or injecting a delay, etc.
If both :\fBerror\fR=\,\fIerrno\/\fR or :\fBretval\fR=\,\fIvalue\/\fR
and :\fBsignal\fR=\,\fIsig\/\fR options are specified, then both
a fault or success is injected and a signal is delivered.
+if :\fBsyscall\fR=\fIsyscall\fR option is specified, the corresponding syscall
+with no side effects is injected instead of -1.
+Currently, only "pure" (see
+.BR "-e trace" = "%pure"
+description) syscalls can be specified there.
+
Unless a :\fBwhen\fR=\,\fIexpr\fR subexpression is specified,
an injection is being made into every invocation of each syscall from the
.IR set .
option set to
.IR ENOSYS .
+.TP
+.BR "\-e\ kvm" = vcpu
+Print the exit reason of kvm vcpu. Requires Linux kernel version 4.16.0
+or higher.
+
.TP
.BI "\-P " path
Trace only system calls accessing
This is incompatible with
.BR \-c ,
since no per-process counts are kept.
+
+One might want to consider using
+.BR strace-log-merge (1)
+to obtain a combined strace log view.
.TP
.BI "\-I " interruptible
When strace can be interrupted by signals (such as pressing ^C).
.B trace
group are trusted users.
If you do use this feature, please remember to install
-a non-setuid version of
+a regular non-setuid version of
+.B strace
+for ordinary users to use.
+.SH "MULTIPLE PERSONALITY SUPPORT"
+On some architectures,
+.B strace
+supports decoding of syscalls for processes that use different ABI rather than
+the one
+.B strace
+uses.
+Specifically, in addition to decoding native ABI,
+.B strace
+can decode the following ABIs on the following architectures:
+.TS H
+allbox;
+lb lb
+l l.
+Architecture ABIs supported
+x86_64 i386, x32 (when built as an x86_64 application); i386 (when built as an x32 application)
+AArch64 ARM 32-bit EABI
+PowerPC 64-bit PowerPC 32-bit
+RISC-V 64-bit RISC-V 32-bit
+s390x s390
+SPARC 64-bit SPARC 32-bit
+TILE 64-bit TILE 32-bit
+.TE
+.PP
+This support is optional and relies on ability to generate and parse structure
+definitions during the build time.
+Please refer to the output of the
+.B strace \-V
+command in order to figure out what support is available in your strace build
+("non-native" refers to an ABI that differs from the ABI strace has):
+.TP 15
+.B m32-mpers
+.B strace
+can trace and properly decode non-native 32-bit binaries.
+.TP
+.B no-m32-mpers
+.B strace
+can trace, but cannot properly decode non-native 32-bit binaries.
+.TP
+.B mx32-mpers
+.B strace
+can trace and properly decode non-native 32-on-64-bit binaries.
+.TP
+.B no-mx32-mpers
.B strace
-for ordinary lusers to use.
+can trace, but cannot properly decode non-native 32-on-64-bit binaries.
+.PP
+If the output contains neither
+.B m32-mpers
+nor
+.BR no-m32-mpers ,
+then decoding of non-native 32-bit binaries is not implemented at all
+or not applicable.
+.PP
+Likewise, if the output contains neither
+.B mx32-mpers
+nor
+.BR no-mx32-mpers ,
+then decoding of non-native 32-on-64-bit binaries is not implemented at all
+or not applicable.
.SH NOTES
It is a pity that so much tracing clutter is produced by systems
employing shared libraries.
argument, and the
.BR setrlimit (2)
library function uses
-.BR prlimit (2)
+.BR prlimit64 (2)
system call on modern (2.6.38+) kernels. These
discrepancies are normal but idiosyncratic characteristics of the
system call interface and are accounted for by C library wrapper
Xtensa syscall are filtered and printed as
.BR fadvise64_64 (2).
.LP
+On x32, syscalls that are intended to be used by 64-bit processes and not x32
+ones (for example,
+.BR readv ,
+that has syscall number 19 on x86_64, with its x32 counterpart has syscall
+number 515), but called with
+.B __X32_SYSCALL_BIT
+flag being set, are designated with "#64" suffix.
+.LP
On some platforms a process that is attached to with the
.B \-p
option may observe a spurious EINTR return from the current
Arguably, every instance of such behavior is a kernel bug.)
This may have an unpredictable effect on the process
if the process takes no action to restart the system call.
+.LP
+As
+.B strace
+executes the specified
+.I command
+directly and does not employ a shell for that, scripts without shebang
+that usually run just fine when invoked by shell fail to execute with
+.B ENOEXEC
+error.
+It is advisable to manually supply a shell as a
+.I command
+with the script as its argument.
.SH BUGS
Programs that use the
.I setuid
The original
.B strace
was written by Paul Kranenburg
-for SunOS and was inspired by its trace utility.
+for SunOS and was inspired by its
+.B trace
+utility.
The SunOS version of
.B strace
was ported to Linux and enhanced
.B strace
to Irix
and tired of writing about himself in the third person.
+.PP
+Beginning with 1996,
+.B strace
+was maintained by Wichert Akkerman.
+During his tenure,
+.B strace
+development migrated to CVS; ports to FreeBSD and many architectures on Linux
+(including ARM, IA-64, MIPS, PA-RISC, PowerPC, s390, SPARC) were introduced.
+In 2002, the burden of
+.B strace
+maintainership was transferred to Roland McGrath.
+Since then,
+.B strace
+gained support for several new Linux architectures (AMD64, s390x, SuperH),
+bi-architecture support for some of them, and received numerous additions and
+improvements in syscalls decoders on Linux;
+.B strace
+development migrated to
+.B git
+during that period.
+Since 2009,
+.B strace
+is actively maintained by Dmitry Levin.
+.B strace
+gained support for AArch64, ARC, AVR32, Blackfin, Meta, Nios II, OpenSISC 1000,
+RISC-V, Tile/TileGx, Xtensa architectures since that time.
+In 2012, unmaintained and apparently broken support for non-Linux operating
+systems was removed.
+Also, in 2012
+.B strace
+gained support for path tracing and file descriptor path decoding.
+In 2014, support for stack traces printing was added.
+In 2016, syscall fault injection was implemented.
+.PP
+For the additional information, please refer to the
+.B NEWS
+file and
+.B strace
+repository commit log.
.SH REPORTING BUGS
Problems with
.B strace
should be reported to the
.B strace
-mailing list at <strace\-devel@lists.sourceforge.net>.
+mailing list at <strace\-devel@lists.strace.io>.
.SH "SEE ALSO"
+.BR strace-log-merge (1),
.BR ltrace (1),
+.BR perf-trace (1),
+.BR trace-cmd (1),
.BR time (1),
.BR ptrace (2),
.BR proc (5)