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 "" {
.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 the traditional or native
usage differs from ANSI or POSIX, the latter forms are preferred.
are printed raw, with the unknown system call number printed in hexadecimal form
and prefixed with "syscall_":
.CW
-syscall_0xbad(0xfedcba9876543210, 0xfedcba9876543211, 0xfedcba9876543212,
-0xfedcba9876543213, 0xfedcba9876543214, 0xfedcba9876543215) = -1 (errno 38)
+syscall_0xbad(0x1, 0x2, 0x3, 0x4, 0x5, 0x6) = -1 ENOSYS (Function not implemented)
.CE
.LP
Character pointers are dereferenced and printed as C strings.
.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
.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
automatically when output is redirected to a file and the command
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
.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. This attempts to show system time (CPU time spent running
+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
.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)"
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
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
(including ARM, IA-64, MIPS, PA-RISC, PowerPC, s390, SPARC) were introduced.
In 2002, the burden of
.B strace
-maintainership was transferred to Ronald McGrath.
+maintainership was transferred to Roland McGrath.
Since then,
.B strace
gained support for several new Linux architectures (AMD64, s390x, SuperH),
.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),