Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 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 | .\" All rights reserved. |
| 5 | .\" |
| 6 | .\" Redistribution and use in source and binary forms, with or without |
| 7 | .\" modification, are permitted provided that the following conditions |
| 8 | .\" are met: |
| 9 | .\" 1. Redistributions of source code must retain the above copyright |
| 10 | .\" notice, this list of conditions and the following disclaimer. |
| 11 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| 12 | .\" notice, this list of conditions and the following disclaimer in the |
| 13 | .\" documentation and/or other materials provided with the distribution. |
| 14 | .\" 3. The name of the author may not be used to endorse or promote products |
| 15 | .\" derived from this software without specific prior written permission. |
| 16 | .\" |
| 17 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 18 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 19 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 20 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 22 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 27 | .de CW |
| 28 | .sp |
| 29 | .nf |
| 30 | .ft CW |
| 31 | .. |
| 32 | .de CE |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 33 | .ft R |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 34 | .fi |
| 35 | .sp |
| 36 | .. |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 37 | .\" Macro IX is not defined in the groff macros |
| 38 | .if \n(.g \{\ |
| 39 | . de IX |
| 40 | .. |
| 41 | .\} |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 42 | .TH STRACE 1 "2010-03-30" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 43 | .SH NAME |
| 44 | strace \- trace system calls and signals |
| 45 | .SH SYNOPSIS |
| 46 | .B strace |
Luca Clementi | 327064b | 2013-07-23 00:11:35 -0700 | [diff] [blame] | 47 | [\fB-CdffhikqrtttTvVxxy\fR] |
Denys Vlasenko | c5ccfa4 | 2012-03-26 13:10:50 +0200 | [diff] [blame] | 48 | [\fB-I\fIn\fR] |
Denys Vlasenko | 22efaf0 | 2013-02-27 12:15:19 +0100 | [diff] [blame] | 49 | [\fB-b\fIexecve\fR] |
| 50 | [\fB-e\fIexpr\fR]... |
| 51 | [\fB-a\fIcolumn\fR] |
Denys Vlasenko | c5ccfa4 | 2012-03-26 13:10:50 +0200 | [diff] [blame] | 52 | [\fB-o\fIfile\fR] |
| 53 | [\fB-s\fIstrsize\fR] |
| 54 | [\fB-P\fIpath\fR]... \fB-p\fIpid\fR... / |
| 55 | [\fB-D\fR] |
| 56 | [\fB-E\fIvar\fR[=\fIval\fR]]... [\fB-u\fIusername\fR] |
| 57 | \fIcommand\fR [\fIargs\fR] |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 58 | .sp |
| 59 | .B strace |
Denys Vlasenko | c5ccfa4 | 2012-03-26 13:10:50 +0200 | [diff] [blame] | 60 | \fB-c\fR[\fBdf\fR] |
| 61 | [\fB-I\fIn\fR] |
Denys Vlasenko | 22efaf0 | 2013-02-27 12:15:19 +0100 | [diff] [blame] | 62 | [\fB-b\fIexecve\fR] |
| 63 | [\fB-e\fIexpr\fR]... |
| 64 | [\fB-O\fIoverhead\fR] |
Denys Vlasenko | c5ccfa4 | 2012-03-26 13:10:50 +0200 | [diff] [blame] | 65 | [\fB-S\fIsortby\fR] \fB-p\fIpid\fR... / |
| 66 | [\fB-D\fR] |
| 67 | [\fB-E\fIvar\fR[=\fIval\fR]]... [\fB-u\fIusername\fR] |
| 68 | \fIcommand\fR [\fIargs\fR] |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 69 | .SH DESCRIPTION |
| 70 | .IX "strace command" "" "\fLstrace\fR command" |
| 71 | .LP |
| 72 | In the simplest case |
| 73 | .B strace |
| 74 | runs the specified |
| 75 | .I command |
| 76 | until it exits. |
| 77 | It intercepts and records the system calls which are called |
| 78 | by a process and the signals which are received by a process. |
| 79 | The name of each system call, its arguments and its return value |
| 80 | are printed on standard error or to the file specified with the |
| 81 | .B \-o |
Roland McGrath | a09353a | 2008-12-10 06:09:29 +0000 | [diff] [blame] | 82 | option. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 83 | .LP |
| 84 | .B strace |
Nate Sammons | b4aa113 | 1999-03-31 05:59:04 +0000 | [diff] [blame] | 85 | is a useful diagnostic, instructional, and debugging tool. |
Roland McGrath | 0411b40 | 2003-10-22 06:16:32 +0000 | [diff] [blame] | 86 | System administrators, diagnosticians and trouble-shooters will find |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 87 | it invaluable for solving problems with |
| 88 | programs for which the source is not readily available since |
| 89 | they do not need to be recompiled in order to trace them. |
| 90 | Students, hackers and the overly-curious will find that |
| 91 | a great deal can be learned about a system and its system calls by |
| 92 | tracing even ordinary programs. And programmers will find that |
| 93 | since system calls and signals are events that happen at the user/kernel |
| 94 | interface, a close examination of this boundary is very |
| 95 | useful for bug isolation, sanity checking and |
| 96 | attempting to capture race conditions. |
| 97 | .LP |
| 98 | Each line in the trace contains the system call name, followed |
| 99 | by its arguments in parentheses and its return value. |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 100 | An example from stracing the command "cat /dev/null" is: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 101 | .CW |
| 102 | open("/dev/null", O_RDONLY) = 3 |
| 103 | .CE |
| 104 | Errors (typically a return value of \-1) have the errno symbol |
| 105 | and error string appended. |
| 106 | .CW |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 107 | open("/foo/bar", O_RDONLY) = \-1 ENOENT (No such file or directory) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 108 | .CE |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 109 | Signals are printed as signal symbol and decoded siginfo structure. |
| 110 | An excerpt from stracing and interrupting the command "sleep 666" is: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 111 | .CW |
| 112 | sigsuspend([] <unfinished ...> |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 113 | --- SIGINT {si_signo=SIGINT, si_code=SI_USER, si_pid=...} --- |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 114 | +++ killed by SIGINT +++ |
| 115 | .CE |
Jan Kratochvil | 14256a7 | 2008-09-12 08:44:30 +0000 | [diff] [blame] | 116 | If a system call is being executed and meanwhile another one is being called |
| 117 | from a different thread/process then |
| 118 | .B strace |
| 119 | will try to preserve the order of those events and mark the ongoing call as |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 120 | being |
| 121 | .IR unfinished . |
| 122 | When the call returns it will be marked as |
| 123 | .IR resumed . |
Jan Kratochvil | 14256a7 | 2008-09-12 08:44:30 +0000 | [diff] [blame] | 124 | .CW |
| 125 | [pid 28772] select(4, [3], NULL, NULL, NULL <unfinished ...> |
| 126 | [pid 28779] clock_gettime(CLOCK_REALTIME, {1130322148, 939977000}) = 0 |
| 127 | [pid 28772] <... select resumed> ) = 1 (in [3]) |
| 128 | .CE |
| 129 | Interruption of a (restartable) system call by a signal delivery is processed |
| 130 | differently as kernel terminates the system call and also arranges its |
| 131 | immediate reexecution after the signal handler completes. |
| 132 | .CW |
| 133 | read(0, 0x7ffff72cf5cf, 1) = ? ERESTARTSYS (To be restarted) |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 134 | --- SIGALRM ... --- |
Jan Kratochvil | 14256a7 | 2008-09-12 08:44:30 +0000 | [diff] [blame] | 135 | rt_sigreturn(0xe) = 0 |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 136 | read(0, "", 1) = 0 |
Jan Kratochvil | 14256a7 | 2008-09-12 08:44:30 +0000 | [diff] [blame] | 137 | .CE |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 138 | Arguments are printed in symbolic form with a passion. |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 139 | This example shows the shell performing ">>xyzzy" output redirection: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 140 | .CW |
| 141 | open("xyzzy", O_WRONLY|O_APPEND|O_CREAT, 0666) = 3 |
| 142 | .CE |
Dmitry V. Levin | 9b3eb84 | 2012-02-22 00:29:44 +0000 | [diff] [blame] | 143 | Here the third argument of open is decoded by breaking down the |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 144 | flag argument into its three bitwise-OR constituents and printing the |
| 145 | mode value in octal by tradition. Where traditional or native |
| 146 | usage differs from ANSI or POSIX, the latter forms are preferred. |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 147 | In some cases, |
| 148 | .B strace |
| 149 | output has proven to be more readable than the source. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 150 | .LP |
| 151 | Structure pointers are dereferenced and the members are displayed |
| 152 | as appropriate. In all cases arguments are formatted in the most C-like |
| 153 | fashion possible. |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 154 | For example, the essence of the command "ls \-l /dev/null" is captured as: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 155 | .CW |
| 156 | lstat("/dev/null", {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0 |
| 157 | .CE |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 158 | Notice how the 'struct stat' argument is dereferenced and how each member is |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 159 | displayed symbolically. In particular, observe how the st_mode member |
| 160 | is carefully decoded into a bitwise-OR of symbolic and numeric values. |
| 161 | Also notice in this example that the first argument to lstat is an input |
| 162 | to the system call and the second argument is an output. Since output |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 163 | arguments are not modified if the system call fails, arguments may not |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 164 | always be dereferenced. For example, retrying the "ls \-l" example |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 165 | with a non-existent file produces the following line: |
| 166 | .CW |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 167 | lstat("/foo/bar", 0xb004) = \-1 ENOENT (No such file or directory) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 168 | .CE |
| 169 | In this case the porch light is on but nobody is home. |
| 170 | .LP |
| 171 | Character pointers are dereferenced and printed as C strings. |
| 172 | Non-printing characters in strings are normally represented by |
| 173 | ordinary C escape codes. |
| 174 | Only the first |
| 175 | .I strsize |
| 176 | (32 by default) bytes of strings are printed; |
| 177 | longer strings have an ellipsis appended following the closing quote. |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 178 | Here is a line from "ls \-l" where the |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 179 | .B getpwuid |
| 180 | library routine is reading the password file: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 181 | .CW |
| 182 | read(3, "root::0:0:System Administrator:/"..., 1024) = 422 |
| 183 | .CE |
| 184 | While structures are annotated using curly braces, simple pointers |
| 185 | and arrays are printed using square brackets with commas separating |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 186 | elements. Here is an example from the command "id" on a system with |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 187 | supplementary group ids: |
| 188 | .CW |
| 189 | getgroups(32, [100, 0]) = 2 |
| 190 | .CE |
| 191 | On the other hand, bit-sets are also shown using square brackets |
| 192 | but set elements are separated only by a space. Here is the shell |
| 193 | preparing to execute an external command: |
| 194 | .CW |
| 195 | sigprocmask(SIG_BLOCK, [CHLD TTOU], []) = 0 |
| 196 | .CE |
| 197 | Here the second argument is a bit-set of two signals, SIGCHLD and SIGTTOU. |
| 198 | In some cases the bit-set is so full that printing out the unset |
| 199 | elements is more valuable. In that case, the bit-set is prefixed by |
| 200 | a tilde like this: |
| 201 | .CW |
| 202 | sigprocmask(SIG_UNBLOCK, ~[], NULL) = 0 |
| 203 | .CE |
| 204 | Here the second argument represents the full set of all signals. |
| 205 | .SH OPTIONS |
| 206 | .TP 12 |
| 207 | .TP |
| 208 | .B \-c |
Roland McGrath | 4de04aa | 2004-08-31 07:47:47 +0000 | [diff] [blame] | 209 | Count time, calls, and errors for each system call and report a summary on |
| 210 | program exit. On Linux, this attempts to show system time (CPU time spent |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 211 | running in the kernel) independent of wall clock time. If |
| 212 | .B \-c |
| 213 | is used with |
| 214 | .B \-f |
| 215 | or |
| 216 | .B \-F |
| 217 | (below), only aggregate totals for all traced processes are kept. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 218 | .TP |
Dmitry V. Levin | e3a7ef5 | 2010-03-28 19:24:54 +0000 | [diff] [blame] | 219 | .B \-C |
| 220 | Like |
| 221 | .B \-c |
| 222 | but also print regular output while processes are running. |
| 223 | .TP |
Andreas Schwab | b87d30c | 2010-06-11 15:49:36 +0200 | [diff] [blame] | 224 | .B \-D |
Andreas Schwab | b87d30c | 2010-06-11 15:49:36 +0200 | [diff] [blame] | 225 | Run tracer process as a detached grandchild, not as parent of the |
| 226 | tracee. This reduces the visible effect of |
| 227 | .B strace |
| 228 | by keeping the tracee a direct child of the calling process. |
| 229 | .TP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 230 | .B \-d |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 231 | Show some debugging output of |
| 232 | .B strace |
| 233 | itself on the standard error. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 234 | .TP |
| 235 | .B \-f |
| 236 | Trace child processes as they are created by currently traced |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 237 | processes as a result of the |
Denys Vlasenko | 22efaf0 | 2013-02-27 12:15:19 +0100 | [diff] [blame] | 238 | .BR fork (2), |
| 239 | .BR vfork (2) |
| 240 | and |
| 241 | .BR clone (2) |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 242 | system calls. Note that |
Denys Vlasenko | 22efaf0 | 2013-02-27 12:15:19 +0100 | [diff] [blame] | 243 | .B \-p |
| 244 | .I PID |
| 245 | .B \-f |
| 246 | will attach all threads of process PID if it is multi-threaded, |
| 247 | not only thread with thread_id = PID. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 248 | .TP |
| 249 | .B \-ff |
| 250 | If the |
| 251 | .B \-o |
| 252 | .I filename |
| 253 | option is in effect, each processes trace is written to |
| 254 | .I filename.pid |
| 255 | where pid is the numeric process id of each process. |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 256 | This is incompatible with |
| 257 | .BR \-c , |
| 258 | since no per-process counts are kept. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 259 | .TP |
| 260 | .B \-F |
Roland McGrath | 41c4822 | 2008-07-18 00:25:10 +0000 | [diff] [blame] | 261 | This option is now obsolete and it has the same functionality as |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 262 | .BR \-f . |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 263 | .TP |
| 264 | .B \-h |
| 265 | Print the help summary. |
| 266 | .TP |
| 267 | .B \-i |
| 268 | Print the instruction pointer at the time of the system call. |
| 269 | .TP |
Luca Clementi | 327064b | 2013-07-23 00:11:35 -0700 | [diff] [blame] | 270 | .B \-k |
Dmitry V. Levin | 2734a70 | 2014-06-18 15:34:27 +0000 | [diff] [blame] | 271 | Print the execution stack trace of the traced processes after each system call (experimental). |
Giedrius Statkevičius | 6a63bfa | 2015-03-03 21:24:34 +0200 | [diff] [blame] | 272 | This option is available only if |
| 273 | .B strace |
| 274 | is built with libunwind. |
Luca Clementi | 327064b | 2013-07-23 00:11:35 -0700 | [diff] [blame] | 275 | .TP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 276 | .B \-q |
| 277 | Suppress messages about attaching, detaching etc. This happens |
| 278 | automatically when output is redirected to a file and the command |
| 279 | is run directly instead of attaching. |
| 280 | .TP |
Daniel P. Berrange | 01997cf | 2013-05-13 11:30:55 +0100 | [diff] [blame] | 281 | .B \-qq |
Dmitry V. Levin | e8ff4c6 | 2013-05-28 20:27:10 +0000 | [diff] [blame] | 282 | If given twice, suppress messages about process exit status. |
Daniel P. Berrange | 01997cf | 2013-05-13 11:30:55 +0100 | [diff] [blame] | 283 | .TP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 284 | .B \-r |
| 285 | Print a relative timestamp upon entry to each system call. This |
| 286 | records the time difference between the beginning of successive |
| 287 | system calls. |
| 288 | .TP |
| 289 | .B \-t |
| 290 | Prefix each line of the trace with the time of day. |
| 291 | .TP |
| 292 | .B \-tt |
| 293 | If given twice, the time printed will include the microseconds. |
| 294 | .TP |
| 295 | .B \-ttt |
| 296 | If given thrice, the time printed will include the microseconds |
| 297 | and the leading portion will be printed as the number |
| 298 | of seconds since the epoch. |
| 299 | .TP |
| 300 | .B \-T |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 301 | Show the time spent in system calls. This records the time |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 302 | difference between the beginning and the end of each system call. |
| 303 | .TP |
Mark Hills | e53bf23 | 2014-05-28 17:52:40 +0100 | [diff] [blame] | 304 | .B \-w |
| 305 | Summarise the time difference between the beginning and end of |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 306 | each system call. The default is to summarise the system time. |
Mark Hills | e53bf23 | 2014-05-28 17:52:40 +0100 | [diff] [blame] | 307 | .TP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 308 | .B \-v |
| 309 | Print unabbreviated versions of environment, stat, termios, etc. |
| 310 | calls. These structures are very common in calls and so the default |
| 311 | behavior displays a reasonable subset of structure members. Use |
| 312 | this option to get all of the gory details. |
| 313 | .TP |
| 314 | .B \-V |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 315 | Print the version number of |
| 316 | .BR strace . |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 317 | .TP |
| 318 | .B \-x |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 319 | Print all non-ASCII strings in hexadecimal string format. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 320 | .TP |
| 321 | .B \-xx |
| 322 | Print all strings in hexadecimal string format. |
| 323 | .TP |
Grant Edwards | 8a08277 | 2011-04-07 20:25:40 +0000 | [diff] [blame] | 324 | .B \-y |
| 325 | Print paths associated with file descriptor arguments. |
| 326 | .TP |
Dmitry V. Levin | 2f6510c | 2014-08-21 03:17:48 +0000 | [diff] [blame] | 327 | .B \-yy |
Fabien Siron | e6d2b56 | 2016-05-26 15:29:41 +0000 | [diff] [blame] | 328 | Print protocol specific information associated with socket file descriptors. |
Dmitry V. Levin | 2f6510c | 2014-08-21 03:17:48 +0000 | [diff] [blame] | 329 | .TP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 330 | .BI "\-a " column |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 331 | Align return values in a specific column (default column 40). |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 332 | .TP |
Denys Vlasenko | 22efaf0 | 2013-02-27 12:15:19 +0100 | [diff] [blame] | 333 | .BI "\-b " syscall |
| 334 | If specified syscall is reached, detach from traced process. |
| 335 | Currently, only |
| 336 | .I execve |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 337 | syscall is supported. This option is useful if you want to trace |
Denys Vlasenko | 22efaf0 | 2013-02-27 12:15:19 +0100 | [diff] [blame] | 338 | multi-threaded process and therefore require -f, but don't want |
| 339 | to trace its (potentially very complex) children. |
| 340 | .TP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 341 | .BI "\-e " expr |
| 342 | A qualifying expression which modifies which events to trace |
| 343 | or how to trace them. The format of the expression is: |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 344 | .RS 15 |
| 345 | .IP |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 346 | [\,\fIqualifier\/\fB=\fR][\fB!\fR]\,\fIvalue1\/\fR[\fB,\,\fIvalue2\/\fR]... |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 347 | .RE |
| 348 | .IP |
| 349 | where |
| 350 | .I qualifier |
| 351 | is one of |
| 352 | .BR trace , |
| 353 | .BR abbrev , |
| 354 | .BR verbose , |
| 355 | .BR raw , |
| 356 | .BR signal , |
| 357 | .BR read , |
| 358 | or |
| 359 | .B write |
| 360 | and |
| 361 | .I value |
| 362 | is a qualifier-dependent symbol or number. The default |
| 363 | qualifier is |
| 364 | .BR trace . |
| 365 | Using an exclamation mark negates the set of values. For example, |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 366 | .BR \-e "\ " open |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 367 | means literally |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 368 | .BR \-e "\ " trace = open |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 369 | which in turn means trace only the |
| 370 | .B open |
| 371 | system call. By contrast, |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 372 | .BR \-e "\ " trace "=!" open |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 373 | means to trace every system call except |
| 374 | .BR open . |
| 375 | In addition, the special values |
| 376 | .B all |
| 377 | and |
| 378 | .B none |
| 379 | have the obvious meanings. |
| 380 | .IP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 381 | Note that some shells use the exclamation point for history |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 382 | expansion even inside quoted arguments. If so, you must escape |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 383 | the exclamation point with a backslash. |
| 384 | .TP |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 385 | \fB\-e\ trace\fR=\,\fIset\fR |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 386 | Trace only the specified set of system calls. The |
| 387 | .B \-c |
| 388 | option is useful for determining which system calls might be useful |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 389 | to trace. For example, |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 390 | .BR trace = open,close,read,write |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 391 | means to only |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 392 | trace those four system calls. Be careful when making inferences |
| 393 | about the user/kernel boundary if only a subset of system calls |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 394 | are being monitored. The default is |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 395 | .BR trace = all . |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 396 | .TP |
Dmitry V. Levin | 1c3031b | 2011-01-14 17:17:20 +0000 | [diff] [blame] | 397 | .BR "\-e\ trace" = file |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 398 | Trace all system calls which take a file name as an argument. You |
| 399 | can think of this as an abbreviation for |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 400 | .BR "\-e\ trace" = open , stat , chmod , unlink ,... |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 401 | which is useful to seeing what files the process is referencing. |
| 402 | Furthermore, using the abbreviation will ensure that you don't |
| 403 | accidentally forget to include a call like |
| 404 | .B lstat |
| 405 | in the list. Betchya woulda forgot that one. |
| 406 | .TP |
Dmitry V. Levin | 1c3031b | 2011-01-14 17:17:20 +0000 | [diff] [blame] | 407 | .BR "\-e\ trace" = process |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 408 | Trace all system calls which involve process management. This |
| 409 | is useful for watching the fork, wait, and exec steps of a process. |
| 410 | .TP |
Dmitry V. Levin | 1c3031b | 2011-01-14 17:17:20 +0000 | [diff] [blame] | 411 | .BR "\-e\ trace" = network |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 412 | Trace all the network related system calls. |
| 413 | .TP |
Dmitry V. Levin | 1c3031b | 2011-01-14 17:17:20 +0000 | [diff] [blame] | 414 | .BR "\-e\ trace" = signal |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 415 | Trace all signal related system calls. |
| 416 | .TP |
Dmitry V. Levin | 1c3031b | 2011-01-14 17:17:20 +0000 | [diff] [blame] | 417 | .BR "\-e\ trace" = ipc |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 418 | Trace all IPC related system calls. |
| 419 | .TP |
Dmitry V. Levin | 1c3031b | 2011-01-14 17:17:20 +0000 | [diff] [blame] | 420 | .BR "\-e\ trace" = desc |
Roland McGrath | 2fe7b13 | 2005-07-05 03:25:35 +0000 | [diff] [blame] | 421 | Trace all file descriptor related system calls. |
| 422 | .TP |
Namhyung Kim | 9679296 | 2012-10-24 11:41:57 +0900 | [diff] [blame] | 423 | .BR "\-e\ trace" = memory |
| 424 | Trace all memory mapping related system calls. |
| 425 | .TP |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 426 | \fB\-e\ abbrev\fR=\,\fIset\fR |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 427 | Abbreviate the output from printing each member of large structures. |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 428 | The default is |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 429 | .BR abbrev = all . |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 430 | The |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 431 | .B \-v |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 432 | option has the effect of |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 433 | .BR abbrev = none . |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 434 | .TP |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 435 | \fB\-e\ verbose\fR=\,\fIset\fR |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 436 | Dereference structures for the specified set of system calls. The |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 437 | default is |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 438 | .BR verbose = all . |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 439 | .TP |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 440 | \fB\-e\ raw\fR=\,\fIset\fR |
Roland McGrath | 0411b40 | 2003-10-22 06:16:32 +0000 | [diff] [blame] | 441 | Print raw, undecoded arguments for the specified set of system calls. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 442 | This option has the effect of causing all arguments to be printed |
| 443 | in hexadecimal. This is mostly useful if you don't trust the |
| 444 | decoding or you need to know the actual numeric value of an |
| 445 | argument. |
| 446 | .TP |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 447 | \fB\-e\ signal\fR=\,\fIset\fR |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 448 | Trace only the specified subset of signals. The default is |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 449 | .BR signal = all . |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 450 | For example, |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 451 | .B signal "=!" SIGIO |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 452 | (or |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 453 | .BR signal "=!" io ) |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 454 | causes SIGIO signals not to be traced. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 455 | .TP |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 456 | \fB\-e\ read\fR=\,\fIset\fR |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 457 | Perform a full hexadecimal and ASCII dump of all the data read from |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 458 | file descriptors listed in the specified set. For example, to see |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 459 | all input activity on file descriptors |
| 460 | .I 3 |
| 461 | and |
| 462 | .I 5 |
| 463 | use |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 464 | \fB\-e\ read\fR=\,\fI3\fR,\fI5\fR. |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 465 | Note that this is independent from the normal tracing of the |
| 466 | .BR read (2) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 467 | system call which is controlled by the option |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 468 | .BR -e "\ " trace = read . |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 469 | .TP |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 470 | \fB\-e\ write\fR=\,\fIset\fR |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 471 | Perform a full hexadecimal and ASCII dump of all the data written to |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 472 | file descriptors listed in the specified set. For example, to see |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 473 | all output activity on file descriptors |
| 474 | .I 3 |
| 475 | and |
| 476 | .I 5 |
| 477 | use |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 478 | \fB\-e\ write\fR=\,\fI3\fR,\,\fI5\fR. |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 479 | Note that this is independent from the normal tracing of the |
| 480 | .BR write (2) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 481 | system call which is controlled by the option |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 482 | .BR -e "\ " trace = write . |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 483 | .TP |
Denys Vlasenko | c5ccfa4 | 2012-03-26 13:10:50 +0200 | [diff] [blame] | 484 | .BI "\-I " interruptible |
| 485 | When strace can be interrupted by signals (such as pressing ^C). |
| 486 | 1: no signals are blocked; 2: fatal signals are blocked while decoding syscall |
| 487 | (default); 3: fatal signals are always blocked (default if '-o FILE PROG'); |
| 488 | 4: fatal signals and SIGTSTP (^Z) are always blocked (useful to make |
| 489 | strace -o FILE PROG not stop on ^Z). |
| 490 | .TP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 491 | .BI "\-o " filename |
| 492 | Write the trace output to the file |
| 493 | .I filename |
| 494 | rather than to stderr. |
| 495 | Use |
| 496 | .I filename.pid |
| 497 | if |
| 498 | .B \-ff |
| 499 | is used. |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 500 | If the argument begins with '|' or with '!' then the rest of the |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 501 | argument is treated as a command and all output is piped to it. |
| 502 | This is convenient for piping the debugging output to a program |
| 503 | without affecting the redirections of executed programs. |
| 504 | .TP |
| 505 | .BI "\-O " overhead |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 506 | Set the overhead for tracing system calls to |
| 507 | .I overhead |
| 508 | microseconds. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 509 | This is useful for overriding the default heuristic for guessing |
| 510 | how much time is spent in mere measuring when timing system calls using |
| 511 | the |
| 512 | .B \-c |
Roland McGrath | 0411b40 | 2003-10-22 06:16:32 +0000 | [diff] [blame] | 513 | option. The accuracy of the heuristic can be gauged by timing a given |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 514 | program run without tracing (using |
| 515 | .BR time (1)) |
| 516 | and comparing the accumulated |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 517 | system call time to the total produced using |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 518 | .BR \-c . |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 519 | .TP |
| 520 | .BI "\-p " pid |
| 521 | Attach to the process with the process |
| 522 | .SM ID |
| 523 | .I pid |
| 524 | and begin tracing. |
| 525 | The trace may be terminated |
| 526 | at any time by a keyboard interrupt signal (\c |
| 527 | .SM CTRL\s0-C). |
| 528 | .B strace |
| 529 | will respond by detaching itself from the traced process(es) |
| 530 | leaving it (them) to continue running. |
| 531 | Multiple |
| 532 | .B \-p |
Dmitry V. Levin | fa8c286 | 2016-01-22 14:37:14 +0000 | [diff] [blame] | 533 | options can be used to attach to many processes in addition to |
| 534 | .I command |
| 535 | (which is optional if at least one |
| 536 | .B \-p |
| 537 | option is given). |
| 538 | .B \-p |
| 539 | "`pidof PROG`" syntax is supported. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 540 | .TP |
Grant Edwards | 8a08277 | 2011-04-07 20:25:40 +0000 | [diff] [blame] | 541 | .BI "\-P " path |
| 542 | Trace only system calls accessing |
Dmitry V. Levin | 3872143 | 2016-01-22 14:53:40 +0000 | [diff] [blame] | 543 | .IR path . |
Grant Edwards | 8a08277 | 2011-04-07 20:25:40 +0000 | [diff] [blame] | 544 | Multiple |
| 545 | .B \-P |
Denys Vlasenko | 7239dbc | 2013-03-05 15:46:34 +0100 | [diff] [blame] | 546 | options can be used to specify several paths. |
Grant Edwards | 8a08277 | 2011-04-07 20:25:40 +0000 | [diff] [blame] | 547 | .TP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 548 | .BI "\-s " strsize |
| 549 | Specify the maximum string size to print (the default is 32). Note |
| 550 | that filenames are not considered strings and are always printed in |
| 551 | full. |
| 552 | .TP |
| 553 | .BI "\-S " sortby |
| 554 | Sort the output of the histogram printed by the |
| 555 | .B \-c |
Roland McGrath | 0411b40 | 2003-10-22 06:16:32 +0000 | [diff] [blame] | 556 | option by the specified criterion. Legal values are |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 557 | .BR time , |
| 558 | .BR calls , |
| 559 | .BR name , |
| 560 | and |
| 561 | .B nothing |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 562 | (default is |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 563 | .BR time ). |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 564 | .TP |
| 565 | .BI "\-u " username |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 566 | Run command with the user \s-1ID\s0, group \s-2ID\s0, and |
| 567 | supplementary groups of |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 568 | .IR username . |
| 569 | This option is only useful when running as root and enables the |
| 570 | correct execution of setuid and/or setgid binaries. |
| 571 | Unless this option is used setuid and setgid programs are executed |
| 572 | without effective privileges. |
Roland McGrath | 4417fda | 2003-01-24 04:31:20 +0000 | [diff] [blame] | 573 | .TP |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 574 | \fB\-E\ \fIvar\fR=\,\fIval\fR |
Roland McGrath | 4417fda | 2003-01-24 04:31:20 +0000 | [diff] [blame] | 575 | Run command with |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 576 | .IR var = val |
Roland McGrath | 4417fda | 2003-01-24 04:31:20 +0000 | [diff] [blame] | 577 | in its list of environment variables. |
| 578 | .TP |
| 579 | .BI "\-E " var |
| 580 | Remove |
| 581 | .IR var |
| 582 | from the inherited list of environment variables before passing it on to |
| 583 | the command. |
Roland McGrath | a09353a | 2008-12-10 06:09:29 +0000 | [diff] [blame] | 584 | .SH DIAGNOSTICS |
| 585 | When |
| 586 | .I command |
| 587 | exits, |
| 588 | .B strace |
| 589 | exits with the same exit status. |
| 590 | If |
| 591 | .I command |
| 592 | is terminated by a signal, |
| 593 | .B strace |
| 594 | terminates itself with the same signal, so that |
| 595 | .B strace |
| 596 | can be used as a wrapper process transparent to the invoking parent process. |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 597 | Note that parent-child relationship (signal stop notifications, |
| 598 | getppid() value, etc) between traced process and its parent are not preserved |
| 599 | unless |
| 600 | .B \-D |
| 601 | is used. |
Roland McGrath | a09353a | 2008-12-10 06:09:29 +0000 | [diff] [blame] | 602 | .LP |
| 603 | When using |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 604 | .BR \-p , |
Roland McGrath | a09353a | 2008-12-10 06:09:29 +0000 | [diff] [blame] | 605 | the exit status of |
| 606 | .B strace |
| 607 | is zero unless there was an unexpected error in doing the tracing. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 608 | .SH "SETUID INSTALLATION" |
| 609 | If |
| 610 | .B strace |
| 611 | is installed setuid to root then the invoking user will be able to |
| 612 | attach to and trace processes owned by any user. |
| 613 | In addition setuid and setgid programs will be executed and traced |
| 614 | with the correct effective privileges. |
| 615 | Since only users trusted with full root privileges should be allowed |
| 616 | to do these things, |
| 617 | it only makes sense to install |
| 618 | .B strace |
| 619 | as setuid to root when the users who can execute it are restricted |
| 620 | to those users who have this trust. |
| 621 | For example, it makes sense to install a special version of |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 622 | .B strace |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 623 | with mode 'rwsr-xr--', user |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 624 | .B root |
| 625 | and group |
| 626 | .BR trace , |
| 627 | where members of the |
| 628 | .B trace |
| 629 | group are trusted users. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 630 | If you do use this feature, please remember to install |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 631 | a non-setuid version of |
| 632 | .B strace |
| 633 | for ordinary lusers to use. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 634 | .SH "SEE ALSO" |
Roland McGrath | 7f7f436 | 2005-12-02 03:59:35 +0000 | [diff] [blame] | 635 | .BR ltrace (1), |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 636 | .BR time (1), |
Roland McGrath | 7f7f436 | 2005-12-02 03:59:35 +0000 | [diff] [blame] | 637 | .BR ptrace (2), |
| 638 | .BR proc (5) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 639 | .SH NOTES |
| 640 | It is a pity that so much tracing clutter is produced by systems |
| 641 | employing shared libraries. |
| 642 | .LP |
| 643 | It is instructive to think about system call inputs and outputs |
| 644 | as data-flow across the user/kernel boundary. Because user-space |
| 645 | and kernel-space are separate and address-protected, it is |
| 646 | sometimes possible to make deductive inferences about process |
| 647 | behavior using inputs and outputs as propositions. |
| 648 | .LP |
| 649 | In some cases, a system call will differ from the documented behavior |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 650 | or have a different name. For example, on System V-derived systems |
| 651 | the true |
| 652 | .BR time (2) |
| 653 | system call does not take an argument and the |
| 654 | .B stat |
| 655 | function is called |
| 656 | .B xstat |
| 657 | and takes an extra leading argument. These |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 658 | discrepancies are normal but idiosyncratic characteristics of the |
| 659 | system call interface and are accounted for by C library wrapper |
| 660 | functions. |
| 661 | .LP |
Dmitry V. Levin | a5c16b8 | 2015-12-09 15:55:33 +0000 | [diff] [blame] | 662 | Some system calls have different names in different architectures and |
| 663 | personalities. In these cases, system call filtering and printing |
| 664 | uses the names that match corresponding |
| 665 | .BR __NR_ * |
| 666 | kernel macros of the tracee's architecture and personality. |
| 667 | There are two exceptions from this general rule: |
| 668 | .BR arm_fadvise64_64 (2) |
| 669 | ARM syscall and |
| 670 | .BR xtensa_fadvise64_64 (2) |
| 671 | Xtensa syscall are filtered and printed as |
| 672 | .BR fadvise64_64 (2). |
| 673 | .LP |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 674 | On some platforms a process that is attached to with the |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 675 | .B \-p |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 676 | option may observe a spurious EINTR return from the current |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 677 | system call that is not restartable. (Ideally, all system calls |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 678 | should be restarted on strace attach, making the attach invisible |
| 679 | to the traced process, but a few system calls aren't. |
| 680 | Arguably, every instance of such behavior is a kernel bug.) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 681 | This may have an unpredictable effect on the process |
| 682 | if the process takes no action to restart the system call. |
| 683 | .SH BUGS |
| 684 | Programs that use the |
| 685 | .I setuid |
| 686 | bit do not have |
| 687 | effective user |
| 688 | .SM ID |
| 689 | privileges while being traced. |
| 690 | .LP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 691 | A traced process runs slowly. |
| 692 | .LP |
| 693 | Traced processes which are descended from |
| 694 | .I command |
| 695 | may be left running after an interrupt signal (\c |
| 696 | .SM CTRL\s0-C). |
| 697 | .LP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 698 | The |
| 699 | .B \-i |
| 700 | option is weakly supported. |
| 701 | .SH HISTORY |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 702 | The original |
| 703 | .B strace |
| 704 | was written by Paul Kranenburg |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 705 | for SunOS and was inspired by its trace utility. |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 706 | The SunOS version of |
| 707 | .B strace |
| 708 | was ported to Linux and enhanced |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 709 | by Branko Lankester, who also wrote the Linux kernel support. |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 710 | Even though Paul released |
| 711 | .B strace |
| 712 | 2.5 in 1992, |
| 713 | Branko's work was based on Paul's |
| 714 | .B strace |
| 715 | 1.5 release from 1991. |
| 716 | In 1993, Rick Sladkey merged |
| 717 | .B strace |
| 718 | 2.5 for SunOS and the second release of |
| 719 | .B strace |
| 720 | for Linux, added many of the features of |
| 721 | .BR truss (1) |
| 722 | from SVR4, and produced an |
| 723 | .B strace |
| 724 | that worked on both platforms. In 1994 Rick ported |
| 725 | .B strace |
| 726 | to SVR4 and Solaris and wrote the |
| 727 | automatic configuration support. In 1995 he ported |
| 728 | .B strace |
| 729 | to Irix |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 730 | and tired of writing about himself in the third person. |
| 731 | .SH PROBLEMS |
| 732 | Problems with |
| 733 | .B strace |
Dmitry V. Levin | dd762c3 | 2012-02-25 15:29:21 +0100 | [diff] [blame] | 734 | should be reported to the |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 735 | .B strace |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 736 | mailing list at <strace\-devel@lists.sourceforge.net>. |