xref: /freebsd/usr.bin/truss/truss.1 (revision a90b9d0159070121c221b966469c3e36d912bf82)
1.\"
2.Dd July 24, 2017
3.Dt TRUSS 1
4.Os
5.Sh NAME
6.Nm truss
7.Nd trace system calls
8.Sh SYNOPSIS
9.Nm
10.Op Fl facedDHS
11.Op Fl o Ar file
12.Op Fl s Ar strsize
13.Fl p Ar pid
14.Nm
15.Op Fl facedDHS
16.Op Fl o Ar file
17.Op Fl s Ar strsize
18.Ar command Op Ar args
19.Sh DESCRIPTION
20The
21.Nm
22utility traces the system calls called by the specified process or program.
23Output is to the specified output file, or standard error by default.
24It does this by stopping and restarting the process being monitored via
25.Xr ptrace 2 .
26.Pp
27The options are as follows:
28.Bl -tag -width indent
29.It Fl f
30Trace descendants of the original traced process created by
31.Xr fork 2 ,
32.Xr vfork 2 ,
33etc.
34To distinguish events between processes,
35the process ID
36.Pq PID
37of the process is included in the output of each event.
38.It Fl a
39Show the argument strings that are passed in each
40.Xr execve 2
41system call.
42.It Fl c
43Do not display individual system calls or signals.
44Instead, before exiting, print a summary containing for each system call:
45the total system time used,
46the number of times the call was invoked,
47and the number of times the call returned with an error.
48.It Fl e
49Show the environment strings that are passed in each
50.Xr execve 2
51system call.
52.It Fl d
53Include timestamps in the output showing the time elapsed
54since the trace was started.
55.It Fl D
56Include timestamps in the output showing the time elapsed
57since the last recorded event.
58.It Fl H
59Include the thread ID of in the output of each event.
60.It Fl S
61Do not display information about signals received by the process.
62(Normally,
63.Nm
64displays signal as well as system call events.)
65.It Fl o Ar file
66Print the output to the specified
67.Ar file
68instead of standard error.
69.It Fl s Ar strsize
70Display strings using at most
71.Ar strsize
72characters.
73If the buffer is larger,
74.Dq Li ...
75will be displayed at the end of the string.
76The default
77.Ar strsize
78is 32.
79.It Fl p Ar pid
80Follow the process specified by
81.Ar pid
82instead of a new command.
83.It Ar command Op Ar args
84Execute
85.Ar command
86and trace the system calls of it.
87(The
88.Fl p
89and
90.Ar command
91options are mutually exclusive.)
92.El
93.Sh EXAMPLES
94Follow the system calls used in echoing "hello":
95.Dl $ truss /bin/echo hello
96.Pp
97Do the same, but put the output into a file:
98.Dl $ truss -o /tmp/truss.out /bin/echo hello
99.Pp
100Follow an already-running process:
101.Dl $ truss -p 34
102.Sh SEE ALSO
103.Xr dtrace 1 ,
104.Xr kdump 1 ,
105.Xr ktrace 1 ,
106.Xr ptrace 2 ,
107.Xr utrace 2
108.Sh HISTORY
109The
110.Nm
111command was written by
112.An Sean Eric Fagan
113for
114.Fx .
115It was modeled after
116similar commands available for System V Release 4 and SunOS.
117