Usage: strace [-ACdffhikkqqrtttTvVwxxyyzZ] [-I N] [-b execve] [-e EXPR]...
[-a COLUMN] [-o FILE] [-s STRSIZE] [-X FORMAT] [-O OVERHEAD]
[-S SORTBY] [-P PATH]... [-p PID]... [-U COLUMNS] [--seccomp-bpf]
[--secontext[=FORMAT]]
{ -p PID | [-DDD] [-E VAR=VAL]... [-u USERNAME] PROG [ARGS] }
or: strace -c[dfwzZ] [-I N] [-b execve] [-e EXPR]... [-O OVERHEAD]
[-S SORTBY] [-P PATH]... [-p PID]... [-U COLUMNS] [--seccomp-bpf]
{ -p PID | [-DDD] [-E VAR=VAL]... [-u USERNAME] PROG [ARGS] }
General:
-e EXPR a qualifying expression: OPTION=[!]all or OPTION=[!]VAL1[,VAL2]...
options: trace, abbrev, verbose, raw, signal, read, write, fault,
inject, status, quiet, kvm, decode-fds, secontext
Startup:
-E VAR=VAL, --env=VAR=VAL
put VAR=VAL in the environment for command
-E VAR, --env=VAR
remove VAR from the environment for command
-p PID, --attach=PID
trace process with process id PID, may be repeated
-u USERNAME, --user=USERNAME
run command as USERNAME handling setuid and/or setgid
USERNAME may be a user name or a UID:GID pair, where UID
and GID are numbers. In the latter case, strace does not
perform name lookups.
--argv0=NAME set PROG argv[0] to NAME
Tracing:
-b execve, --detach-on=execve
detach on execve syscall
-D, --daemonize[=grandchild]
run tracer process as a grandchild, not as a parent
-DD, --daemonize=pgroup
run tracer process in a separate process group
-DDD, --daemonize=session
run tracer process in a separate session
-f, --follow-forks
follow forks
-ff, --follow-forks --output-separately
follow forks with output into separate files
-I INTERRUPTIBLE, --interruptible=INTERRUPTIBLE
1, anywhere: no signals are blocked
2, waiting: fatal signals are blocked while decoding syscall (default)
3, never: fatal signals are always blocked (default if '-o FILE PROG')
4, never_tstp: fatal signals and SIGTSTP (^Z) are always blocked
(useful to make 'strace -o FILE PROG' not stop on ^Z)
--kill-on-exit kill all tracees if strace is killed
Filtering:
-e trace=[!][?]{{SYSCALL|GROUP|all|/REGEX}[@64|@32|@x32]|none},
--trace=[!][?]{{SYSCALL|GROUP|all|/REGEX}[@64|@32|@x32]|none}
trace only specified syscalls.
groups: %clock, %creds, %desc, %file, %fstat, %fstatfs %ipc, %lstat,
%memory, %net, %process, %pure, %signal, %stat, %%stat,
%statfs, %%statfs
-e signal=SET, --signal=SET
trace only the specified set of signals
print only the signals from SET
-e status=SET, --status=SET
print only system calls with the return statuses in SET
statuses: successful, failed, unfinished, unavailable, detached
-e trace-fds=SET, --trace-fds=SET
trace operations on file descriptors from SET
-P PATH, --trace-path=PATH
trace accesses to PATH
-z, --successful-only
print only syscalls that returned without an error code
-Z, --failed-only
print only syscalls that returned with an error code
Output format:
-a COLUMN, --columns=COLUMN
alignment COLUMN for printing syscall results (default 40)
--color[=WHEN]
colorize output; WHEN is auto, always, or never (default auto)
-e abbrev=SET, --abbrev=SET
abbreviate output for the syscalls in SET
-e verbose=SET, --verbose=SET
dereference structures for the syscall in SET
-e raw=SET, --raw=SET
print undecoded arguments for the syscalls in SET
-e read=SET, --read=SET
dump the data read from the file descriptors in SET
-e write=SET, --write=SET
dump the data written to the file descriptors in SET
-e quiet=SET, --quiet=SET
suppress various informational messages
messages: attach, exit, path-resolution, personality, thread-execve
-e kvm=vcpu[+], --kvm=vcpu[+]
print exit reason of kvm vcpu ('+' for printing kvm_run struct)
-e namespace=new, --namespace=new
print namespace IDs that the tracee enters
-e decode-fds=SET, --decode-fds=SET
what kinds of file descriptor information details to decode
details: dev (device major/minor for block/char device files),
eventfd (associated eventfd object details for eventfds),
path (file path),
pidfd (associated PID for pidfds),
socket (protocol-specific information for socket descriptors),
signalfd (signal masks for signalfds)
-e secontext=FORMAT, --secontext[=FORMAT]
print SELinux contexts in square brackets
formats: comma-separated list of all, full, mismatch, none
all: equivalent to full,mismatch
full: print the full context instead of the type only
mismatch: print expected context when actual is not matching
none: equivalent to not specifying the option at all
-i, --instruction-pointer
print instruction pointer at time of syscall
-k, --stack-trace[=symbol]
obtain stack trace between each syscall
-kk, --stack-trace=source
obtain stack trace and source info between each syscall
--stack-trace-frame-limit=limit
obtain no more than this amount of frames
when backtracing a syscall (default 256)
-n, --syscall-number
print syscall number
-N, --arg-names
print syscall argument names
-o FILE, --output=FILE
send trace output to FILE instead of stderr
-A, --output-append-mode
open the file provided in the -o option in append mode
--output-separately
output into separate files (by appending pid to file names)
-q, --quiet=attach,personality
suppress messages about attaching, detaching, etc.
-qq, --quiet=attach,personality,exit
suppress messages about process exit status as well.
-qqq, --quiet=all
suppress all suppressible messages.
-r, --relative-timestamps[=PRECISION]
print relative timestamp
precision: one of s, ms, us, ns; default is microseconds
-s STRSIZE, --string-limit=STRSIZE
limit length of print strings to STRSIZE chars (default 32)
--absolute-timestamps=[[format:]FORMAT[,[precision:]PRECISION]]
set the format of absolute timestamps
format: none, time, or unix; default is time
precision: one of s, ms, us, ns; default is seconds
-t, --absolute-timestamps[=time]
print absolute timestamp
-tt, --absolute-timestamps=[time,]us
print absolute timestamp with usecs
-ttt, --absolute-timestamps=unix,us
print absolute UNIX time with usecs
-T, --syscall-times[=PRECISION]
print time spent in each syscall
precision: one of s, ms, us, ns; default is microseconds
-v, --no-abbrev
verbose mode: print entities unabbreviated
--strings-in-hex=non-ascii-chars
use hex instead of octal in escape sequences
-x, --strings-in-hex=non-ascii
print non-ASCII strings in hex
-xx, --strings-in-hex[=all]
print all strings in hex
-X FORMAT, --const-print-style=FORMAT
set the FORMAT for printing of named constants and flags
formats: raw, abbrev, verbose
-y, --decode-fds[=path]
print paths associated with file descriptor arguments
-yy, --decode-fds=all
print all available information associated with file
descriptors in addition to paths
--decode-pids=pidns
print PIDs in strace's namespace, too
-Y, --decode-pids=comm
print command names associated with PIDs
--always-show-pid
show PID prefix also for the process started by strace
Statistics:
-c, --summary-only
count time, calls, and errors for each syscall and report
summary
-C, --summary like -c, but also print the regular output
-O OVERHEAD[UNIT], --summary-syscall-overhead=OVERHEAD[UNIT]
set overhead for tracing syscalls to OVERHEAD UNITs
units: one of s, ms, us, ns; default is microseconds
-S SORTBY, --summary-sort-by=SORTBY
sort syscall counts by: time, min-time, max-time, avg-time,
calls, errors, name, nothing (default time)
-U COLUMNS, --summary-columns=COLUMNS
show specific columns in the summary report: comma-separated
list of time-percent, total-time, min-time, max-time,
avg-time, calls, errors, name
(default time-percent,total-time,avg-time,calls,errors,name)
-w, --summary-wall-clock
summarise syscall latency (default is system time)
Stop condition:
--syscall-limit=LIMIT
Detach all tracees after tracing LIMIT syscalls
Tampering:
-e inject=SET[:error=ERRNO|:retval=VALUE][:signal=SIG][:syscall=SYSCALL]
[:delay_enter=DELAY][:delay_exit=DELAY]
[:poke_enter=@argN=DATAN,@argM=DATAM...]
[:poke_exit=@argN=DATAN,@argM=DATAM...]
[:when=WHEN],
--inject=SET[:error=ERRNO|:retval=VALUE][:signal=SIG][:syscall=SYSCALL]
[:delay_enter=DELAY][:delay_exit=DELAY]
[:poke_enter=@argN=DATAN,@argM=DATAM...]
[:poke_exit=@argN=DATAN,@argM=DATAM...]
[:when=WHEN],
perform syscall tampering for the syscalls in SET
delay: microseconds or NUMBER{s|ms|us|ns}
when: FIRST[..LAST][+[STEP]]
-e fault=SET[:error=ERRNO][:when=WHEN], --fault=SET[:error=ERRNO][:when=WHEN]
synonym for -e inject with default ERRNO set to ENOSYS.
Miscellaneous:
-d, --debug enable debug output to stderr
-h, --help print help message
--seccomp-bpf enable seccomp-bpf filtering
--tips[=[[id:]ID][,[format:]FORMAT]]
show strace tips, tricks, and tweaks on exit
id: non-negative integer or random; default is random
format: none, compact, full; default is compact
-V, --version print version
Options (75)
| Option | Description | Source |
|---|
-e EXPR | Modifies which events to trace or how to trace them by specifying a qualifying expression. | help + man |
-E, --env VAR=VAL | Runs the command with the environment variable var=val set for execution. | help + man + man |
-p, --attach PID | Attaches to the process with the process ID pid and begin tracing. | help + man + man |
-u, --user USERNAME | run command as USERNAME handling setuid and/or setgid USERNAME may be a user name or a UID:GID pair, where UID and GID are numbers. | help + man + man |
--argv0 NAME | Sets the executed command's argv[0] to name. | help + man |
-b, --detach-on execve | Detaches from the traced process if the specified system call is reached. | help + man + man |
-D, --daemonize grandchild | run tracer process as a grandchild, not as a parent | help + man + man |
-f, --follow-forks | Traces child processes as they are created by currently traced processes as a result of the fork(2), vfork(2) and clone(2) system calls. | help + man + man |
-I, --interruptible INTERRUPTIBLE | 1, anywhere: no signals are blocked 2, waiting: fatal signals are blocked while decoding syscall (default) 3, never: fatal signals are always blocked (default if '-o FILE PROG') 4, never_tstp: fatal… | help + man + man |
--trace syscall_set | Traces only the specified set of system calls. | help + man |
-P, --trace-path PATH | Traces only system calls accessing path. | help + man + man |
-z, --successful-only | Prints only system calls that returned without an error code. | help + man + man |
-Z, --failed-only | Prints only system calls that returned with an error code. | help + man + man |
-a, --columns COLUMN | Aligns return values in a specific column (default column 40). | help + man + man |
--color WHEN | Colorize the trace output. | help + man |
-i, --instruction-pointer | Prints the instruction pointer at the time of the system call. | help + man + man |
-k, --stack-trace symbol | Prints the execution stack trace and source code information of the traced processes after each system call. | help + man + man |
--stack-trace-frame-limit limit | Prints no more than this amount of stack trace frames when backtracing a system call (the default is 256). | help + man |
-n, --syscall-number | Prints the system call number. | help + man + man |
-N, --arg-names | Prints the system call argument names. | help + man + man |
-o, --output FILE | Writes the trace output to the file filename rather than to stderr. | help + man + man |
-A, --output-append-mode | Opens the file provided in the -o option in append mode. | help + man + man |
--output-separately | If the --output=filename option is in effect, the trace for each process is written to a separate filename.pid file, where pid is the process ID. | help + man |
-q, --quiet attach | suppress messages about attaching, detaching, etc. | help + man + man |
-r, --relative-timestamps PRECISION | print relative timestamp precision: one of s, ms, us, ns; | help + man |
-s, --string-limit STRSIZE | Specifies the maximum string size to print (the default is 32). | help + man + man |
--absolute-timestamps format:]FORMAT | set the format of absolute timestamps format: none, time, or unix; | help + man |
-T, --syscall-times PRECISION | print time spent in each syscall precision: one of s, ms, us, ns; | help + man + man |
-v, --no-abbrev | Prints unabbreviated versions of environment, stat, termios, etc. | help + man + man |
--strings-in-hex non-ascii-chars | Prints all non-ASCII strings in hexadecimal string format. | help + man |
-X, --const-print-style FORMAT | set the FORMAT for printing of named constants and flags formats: raw, abbrev, verbose | help + man + man |
-y, --decode-fds path | Decodes various information associated with file descriptors. | help + man + man |
--decode-pids pidns | Decodes various information associated with process IDs (and also thread IDs, process group IDs, and session IDs). | help + man |
--always-show-pid | Shows PID prefix also for the process started by strace. | help + man |
-c, --summary-only | Counts time, calls, and errors for each system call and report a summary on program exit, suppressing the regular output. | help + man + man |
-C, --summary | Like -c, but also prints the regular output while processes are running. | help + man + man |
-O, --summary-syscall-overhead OVERHEAD[UNIT | set overhead for tracing syscalls to OVERHEAD UNITs units: one of s, ms, us, ns; | help + man + man |
-S, --summary-sort-by SORTBY | sort syscall counts by: time, min-time, max-time, avg-time, calls, errors, name, nothing (default time) | help + man + man |
-U, --summary-columns COLUMNS | show specific columns in the summary report: comma-separated list of time-percent, total-time, min-time, max-time, avg-time, calls, errors, name (default… | help + man + man |
-w, --summary-wall-clock | Summarizes the wall clock time for each system call, measured from its beginning to its end. | help + man + man |
--syscall-limit LIMIT | Detaches all tracees after limit system calls have been captured. | help + man |
--inject | [:delay_enter=DELAY][:delay_exit=DELAY] [:poke_enter=@argN=DATAN,@argM=DATAM...] [:poke_exit=@argN=DATAN,@argM=DATAM...] [:when=WHEN], perform syscall tampering for the syscalls in SET delay:… | help |
-d, --debug | Shows some debugging output of strace itself on the standard error. | help + man + man |
-h, --help | Prints the help summary. | help + man + man |
--seccomp-bpf | Attempts to use seccomp-bpf (see seccomp(2)) to cause the kernel to stop the tracee only for the system calls that are being traced. | help + man |
--tips id:]ID | show strace tips, tricks, and tweaks on exit id: non-negative integer or random; | help |
-V, --version | Prints the version number of strace and the list of enabled optional features. | help + man + man |
-DD | (in the manual page but not in --help) | man |
-DDD | (in the manual page but not in --help) | man |
-ff | (in the manual page but not in --help) | man |
--kill-on-exit | Applies the PTRACE_O_EXITKILL ptrace option to all tracees, which sends a SIGKILL signal to a tracee if the tracer exits. (in the manual page but not in --help) | man |
--trace-fds set | Traces only the system calls that operate on the specified subset of (non-negative) file descriptors. (in the manual page but not in --help) | man |
--signal set | Traces only the specified subset of signals. (in the manual page but not in --help) | man |
--status set | Prints only system calls with the specified return status. (in the manual page but not in --help) | man |
--abbrev syscall_set | Abbreviates the output from printing each member of large structures. (in the manual page but not in --help) | man |
--verbose syscall_set | Dereferences structures for the specified set of system calls. (in the manual page but not in --help) | man |
--raw syscall_set | Prints raw, undecoded arguments for the specified set of system calls. (in the manual page but not in --help) | man |
--read set | Performs a full hexadecimal and ASCII dump of all the data read from file descriptors listed in the specified set. (in the manual page but not in --help) | man |
--write set | Performs a full hexadecimal and ASCII dump of all the data written to file descriptors listed in the specified set. (in the manual page but not in --help) | man |
--silent set | (in the manual page but not in --help) | man |
--silence set | Suppresses various information messages. (in the manual page but not in --help) | man |
--kvm vcpu|vcpu+ | Prints the exit reason of kvm vcpu (=vcpu), or prints the whole kvm_run struct including the reason (=vcpu+). (in the manual page but not in --help) | man |
--namespace new | Prints the new namespaces entered by the tracee. (in the manual page but not in --help) | man |
-kk | (in the manual page but not in --help) | man |
-qq | (in the manual page but not in --help) | man |
-qqq | (in the manual page but not in --help) | man |
-t | (in the manual page but not in --help) | man |
-tt | (in the manual page but not in --help) | man |
-ttt | (in the manual page but not in --help) | man |
-x | (in the manual page but not in --help) | man |
-xx | [--strings-in-hex[=all]](#strings~3) (in the manual page but not in --help) | man |
-yy | (in the manual page but not in --help) | man |
--pidns-translation | (in the manual page but not in --help) | man |
-Y | (in the manual page but not in --help) | man |
-F | This option is deprecated. (in the manual page but not in --help) | man |
Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.