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 |
| 328 | Print ip:port pairs associated with socket file descriptors. |
| 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 |
Denys Vlasenko | 94f00e6 | 2012-03-26 13:31:11 +0200 | [diff] [blame] | 533 | options can be used to attach to many processes. |
Denys Vlasenko | 6bc050c | 2012-03-13 11:48:22 +0100 | [diff] [blame] | 534 | -p "`pidof PROG`" syntax is supported. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 535 | .TP |
Grant Edwards | 8a08277 | 2011-04-07 20:25:40 +0000 | [diff] [blame] | 536 | .BI "\-P " path |
| 537 | Trace only system calls accessing |
| 538 | .I path. |
| 539 | Multiple |
| 540 | .B \-P |
Denys Vlasenko | 7239dbc | 2013-03-05 15:46:34 +0100 | [diff] [blame] | 541 | options can be used to specify several paths. |
Grant Edwards | 8a08277 | 2011-04-07 20:25:40 +0000 | [diff] [blame] | 542 | .TP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 543 | .BI "\-s " strsize |
| 544 | Specify the maximum string size to print (the default is 32). Note |
| 545 | that filenames are not considered strings and are always printed in |
| 546 | full. |
| 547 | .TP |
| 548 | .BI "\-S " sortby |
| 549 | Sort the output of the histogram printed by the |
| 550 | .B \-c |
Roland McGrath | 0411b40 | 2003-10-22 06:16:32 +0000 | [diff] [blame] | 551 | option by the specified criterion. Legal values are |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 552 | .BR time , |
| 553 | .BR calls , |
| 554 | .BR name , |
| 555 | and |
| 556 | .B nothing |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 557 | (default is |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 558 | .BR time ). |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 559 | .TP |
| 560 | .BI "\-u " username |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 561 | Run command with the user \s-1ID\s0, group \s-2ID\s0, and |
| 562 | supplementary groups of |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 563 | .IR username . |
| 564 | This option is only useful when running as root and enables the |
| 565 | correct execution of setuid and/or setgid binaries. |
| 566 | Unless this option is used setuid and setgid programs are executed |
| 567 | without effective privileges. |
Roland McGrath | 4417fda | 2003-01-24 04:31:20 +0000 | [diff] [blame] | 568 | .TP |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 569 | \fB\-E\ \fIvar\fR=\,\fIval\fR |
Roland McGrath | 4417fda | 2003-01-24 04:31:20 +0000 | [diff] [blame] | 570 | Run command with |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 571 | .IR var = val |
Roland McGrath | 4417fda | 2003-01-24 04:31:20 +0000 | [diff] [blame] | 572 | in its list of environment variables. |
| 573 | .TP |
| 574 | .BI "\-E " var |
| 575 | Remove |
| 576 | .IR var |
| 577 | from the inherited list of environment variables before passing it on to |
| 578 | the command. |
Roland McGrath | a09353a | 2008-12-10 06:09:29 +0000 | [diff] [blame] | 579 | .SH DIAGNOSTICS |
| 580 | When |
| 581 | .I command |
| 582 | exits, |
| 583 | .B strace |
| 584 | exits with the same exit status. |
| 585 | If |
| 586 | .I command |
| 587 | is terminated by a signal, |
| 588 | .B strace |
| 589 | terminates itself with the same signal, so that |
| 590 | .B strace |
| 591 | 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] | 592 | Note that parent-child relationship (signal stop notifications, |
| 593 | getppid() value, etc) between traced process and its parent are not preserved |
| 594 | unless |
| 595 | .B \-D |
| 596 | is used. |
Roland McGrath | a09353a | 2008-12-10 06:09:29 +0000 | [diff] [blame] | 597 | .LP |
| 598 | When using |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 599 | .BR \-p , |
Roland McGrath | a09353a | 2008-12-10 06:09:29 +0000 | [diff] [blame] | 600 | the exit status of |
| 601 | .B strace |
| 602 | is zero unless there was an unexpected error in doing the tracing. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 603 | .SH "SETUID INSTALLATION" |
| 604 | If |
| 605 | .B strace |
| 606 | is installed setuid to root then the invoking user will be able to |
| 607 | attach to and trace processes owned by any user. |
| 608 | In addition setuid and setgid programs will be executed and traced |
| 609 | with the correct effective privileges. |
| 610 | Since only users trusted with full root privileges should be allowed |
| 611 | to do these things, |
| 612 | it only makes sense to install |
| 613 | .B strace |
| 614 | as setuid to root when the users who can execute it are restricted |
| 615 | to those users who have this trust. |
| 616 | For example, it makes sense to install a special version of |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 617 | .B strace |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 618 | with mode 'rwsr-xr--', user |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 619 | .B root |
| 620 | and group |
| 621 | .BR trace , |
| 622 | where members of the |
| 623 | .B trace |
| 624 | group are trusted users. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 625 | If you do use this feature, please remember to install |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 626 | a non-setuid version of |
| 627 | .B strace |
| 628 | for ordinary lusers to use. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 629 | .SH "SEE ALSO" |
Roland McGrath | 7f7f436 | 2005-12-02 03:59:35 +0000 | [diff] [blame] | 630 | .BR ltrace (1), |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 631 | .BR time (1), |
Roland McGrath | 7f7f436 | 2005-12-02 03:59:35 +0000 | [diff] [blame] | 632 | .BR ptrace (2), |
| 633 | .BR proc (5) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 634 | .SH NOTES |
| 635 | It is a pity that so much tracing clutter is produced by systems |
| 636 | employing shared libraries. |
| 637 | .LP |
| 638 | It is instructive to think about system call inputs and outputs |
| 639 | as data-flow across the user/kernel boundary. Because user-space |
| 640 | and kernel-space are separate and address-protected, it is |
| 641 | sometimes possible to make deductive inferences about process |
| 642 | behavior using inputs and outputs as propositions. |
| 643 | .LP |
| 644 | In some cases, a system call will differ from the documented behavior |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 645 | or have a different name. For example, on System V-derived systems |
| 646 | the true |
| 647 | .BR time (2) |
| 648 | system call does not take an argument and the |
| 649 | .B stat |
| 650 | function is called |
| 651 | .B xstat |
| 652 | and takes an extra leading argument. These |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 653 | discrepancies are normal but idiosyncratic characteristics of the |
| 654 | system call interface and are accounted for by C library wrapper |
| 655 | functions. |
| 656 | .LP |
Dmitry V. Levin | a5c16b8 | 2015-12-09 15:55:33 +0000 | [diff] [blame^] | 657 | Some system calls have different names in different architectures and |
| 658 | personalities. In these cases, system call filtering and printing |
| 659 | uses the names that match corresponding |
| 660 | .BR __NR_ * |
| 661 | kernel macros of the tracee's architecture and personality. |
| 662 | There are two exceptions from this general rule: |
| 663 | .BR arm_fadvise64_64 (2) |
| 664 | ARM syscall and |
| 665 | .BR xtensa_fadvise64_64 (2) |
| 666 | Xtensa syscall are filtered and printed as |
| 667 | .BR fadvise64_64 (2). |
| 668 | .LP |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 669 | On some platforms a process that is attached to with the |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 670 | .B \-p |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 671 | option may observe a spurious EINTR return from the current |
Dmitry V. Levin | a197832 | 2014-06-03 12:03:41 +0000 | [diff] [blame] | 672 | system call that is not restartable. (Ideally, all system calls |
Denys Vlasenko | b537053 | 2013-06-26 15:35:16 +0200 | [diff] [blame] | 673 | should be restarted on strace attach, making the attach invisible |
| 674 | to the traced process, but a few system calls aren't. |
| 675 | Arguably, every instance of such behavior is a kernel bug.) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 676 | This may have an unpredictable effect on the process |
| 677 | if the process takes no action to restart the system call. |
| 678 | .SH BUGS |
| 679 | Programs that use the |
| 680 | .I setuid |
| 681 | bit do not have |
| 682 | effective user |
| 683 | .SM ID |
| 684 | privileges while being traced. |
| 685 | .LP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 686 | A traced process runs slowly. |
| 687 | .LP |
| 688 | Traced processes which are descended from |
| 689 | .I command |
| 690 | may be left running after an interrupt signal (\c |
| 691 | .SM CTRL\s0-C). |
| 692 | .LP |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 693 | The |
| 694 | .B \-i |
| 695 | option is weakly supported. |
| 696 | .SH HISTORY |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 697 | The original |
| 698 | .B strace |
| 699 | was written by Paul Kranenburg |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 700 | for SunOS and was inspired by its trace utility. |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 701 | The SunOS version of |
| 702 | .B strace |
| 703 | was ported to Linux and enhanced |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 704 | by Branko Lankester, who also wrote the Linux kernel support. |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 705 | Even though Paul released |
| 706 | .B strace |
| 707 | 2.5 in 1992, |
| 708 | Branko's work was based on Paul's |
| 709 | .B strace |
| 710 | 1.5 release from 1991. |
| 711 | In 1993, Rick Sladkey merged |
| 712 | .B strace |
| 713 | 2.5 for SunOS and the second release of |
| 714 | .B strace |
| 715 | for Linux, added many of the features of |
| 716 | .BR truss (1) |
| 717 | from SVR4, and produced an |
| 718 | .B strace |
| 719 | that worked on both platforms. In 1994 Rick ported |
| 720 | .B strace |
| 721 | to SVR4 and Solaris and wrote the |
| 722 | automatic configuration support. In 1995 he ported |
| 723 | .B strace |
| 724 | to Irix |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 725 | and tired of writing about himself in the third person. |
| 726 | .SH PROBLEMS |
| 727 | Problems with |
| 728 | .B strace |
Dmitry V. Levin | dd762c3 | 2012-02-25 15:29:21 +0100 | [diff] [blame] | 729 | should be reported to the |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 730 | .B strace |
Dmitry V. Levin | a7835e6 | 2010-03-31 17:26:49 +0000 | [diff] [blame] | 731 | mailing list at <strace\-devel@lists.sourceforge.net>. |