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