1999-08-28 23:23:38 +00:00
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2017-07-21 13:58:51 +00:00
|
|
|
.Dd July 24, 2017
|
1997-12-06 05:23:12 +00:00
|
|
|
.Dt TRUSS 1
|
2001-07-10 14:16:33 +00:00
|
|
|
.Os
|
1997-12-06 05:23:12 +00:00
|
|
|
.Sh NAME
|
1998-01-05 07:30:26 +00:00
|
|
|
.Nm truss
|
1997-12-06 05:23:12 +00:00
|
|
|
.Nd trace system calls
|
1998-01-05 07:30:26 +00:00
|
|
|
.Sh SYNOPSIS
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm
|
2016-02-23 19:56:29 +00:00
|
|
|
.Op Fl facedDHS
|
1998-01-05 07:30:26 +00:00
|
|
|
.Op Fl o Ar file
|
2006-01-02 08:36:25 +00:00
|
|
|
.Op Fl s Ar strsize
|
1998-01-05 07:30:26 +00:00
|
|
|
.Fl p Ar pid
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm
|
2016-02-23 19:56:29 +00:00
|
|
|
.Op Fl facedDHS
|
1997-12-06 05:23:12 +00:00
|
|
|
.Op Fl o Ar file
|
2006-01-02 08:36:25 +00:00
|
|
|
.Op Fl s Ar strsize
|
2006-12-11 11:34:44 +00:00
|
|
|
.Ar command Op Ar args
|
1997-12-06 05:23:12 +00:00
|
|
|
.Sh DESCRIPTION
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility traces the system calls called by the specified process or program.
|
1997-12-06 05:23:12 +00:00
|
|
|
Output is to the specified output file, or standard error by default.
|
|
|
|
It does this by stopping and restarting the process being monitored via
|
2007-04-10 04:03:34 +00:00
|
|
|
.Xr ptrace 2 .
|
1997-12-06 05:23:12 +00:00
|
|
|
.Pp
|
|
|
|
The options are as follows:
|
1998-01-05 07:30:26 +00:00
|
|
|
.Bl -tag -width indent
|
2002-08-04 01:02:52 +00:00
|
|
|
.It Fl f
|
2005-07-31 03:30:48 +00:00
|
|
|
Trace descendants of the original traced process created by
|
2002-11-26 17:33:37 +00:00
|
|
|
.Xr fork 2 ,
|
|
|
|
.Xr vfork 2 ,
|
|
|
|
etc.
|
2016-02-23 19:56:29 +00:00
|
|
|
To distinguish events between processes,
|
|
|
|
the process ID
|
|
|
|
.Pq PID
|
|
|
|
of the process is included in the output of each event.
|
2002-08-04 02:24:21 +00:00
|
|
|
.It Fl a
|
2002-11-26 17:33:37 +00:00
|
|
|
Show the argument strings that are passed in each
|
|
|
|
.Xr execve 2
|
|
|
|
system call.
|
2009-05-12 20:42:12 +00:00
|
|
|
.It Fl c
|
2015-10-09 20:47:29 +00:00
|
|
|
Do not display individual system calls or signals.
|
2009-05-12 20:42:12 +00:00
|
|
|
Instead, before exiting, print a summary containing for each system call:
|
|
|
|
the total system time used,
|
|
|
|
the number of times the call was invoked,
|
|
|
|
and the number of times the call returned with an error.
|
2002-08-04 02:24:21 +00:00
|
|
|
.It Fl e
|
2002-11-26 17:33:37 +00:00
|
|
|
Show the environment strings that are passed in each
|
|
|
|
.Xr execve 2
|
|
|
|
system call.
|
2002-08-04 01:27:31 +00:00
|
|
|
.It Fl d
|
|
|
|
Include timestamps in the output showing the time elapsed
|
|
|
|
since the trace was started.
|
|
|
|
.It Fl D
|
|
|
|
Include timestamps in the output showing the time elapsed
|
|
|
|
since the last recorded event.
|
2016-02-23 19:56:29 +00:00
|
|
|
.It Fl H
|
|
|
|
Include the thread ID of in the output of each event.
|
1997-12-06 05:23:12 +00:00
|
|
|
.It Fl S
|
|
|
|
Do not display information about signals received by the process.
|
|
|
|
(Normally,
|
1998-01-05 07:30:26 +00:00
|
|
|
.Nm
|
1997-12-06 05:23:12 +00:00
|
|
|
displays signal as well as system call events.)
|
1998-01-05 07:30:26 +00:00
|
|
|
.It Fl o Ar file
|
|
|
|
Print the output to the specified
|
|
|
|
.Ar file
|
|
|
|
instead of standard error.
|
2006-01-02 08:36:25 +00:00
|
|
|
.It Fl s Ar strsize
|
|
|
|
Display strings using at most
|
|
|
|
.Ar strsize
|
|
|
|
characters.
|
|
|
|
If the buffer is larger,
|
2006-09-29 15:20:48 +00:00
|
|
|
.Dq Li ...
|
2006-01-02 08:36:25 +00:00
|
|
|
will be displayed at the end of the string.
|
|
|
|
The default
|
|
|
|
.Ar strsize
|
|
|
|
is 32.
|
1998-01-05 07:30:26 +00:00
|
|
|
.It Fl p Ar pid
|
2001-07-15 08:06:20 +00:00
|
|
|
Follow the process specified by
|
1997-12-06 05:23:12 +00:00
|
|
|
.Ar pid
|
|
|
|
instead of a new command.
|
2006-12-11 11:34:44 +00:00
|
|
|
.It Ar command Op Ar args
|
1997-12-06 05:23:12 +00:00
|
|
|
Execute
|
|
|
|
.Ar command
|
|
|
|
and trace the system calls of it.
|
|
|
|
(The
|
|
|
|
.Fl p
|
|
|
|
and
|
|
|
|
.Ar command
|
|
|
|
options are mutually exclusive.)
|
2000-12-19 16:00:12 +00:00
|
|
|
.El
|
1997-12-06 05:23:12 +00:00
|
|
|
.Sh EXAMPLES
|
2017-07-21 13:50:59 +00:00
|
|
|
Follow the system calls used in echoing "hello":
|
1997-12-06 05:23:12 +00:00
|
|
|
.Dl $ truss /bin/echo hello
|
2017-07-21 13:50:59 +00:00
|
|
|
.Pp
|
|
|
|
Do the same, but put the output into a file:
|
1997-12-06 05:23:12 +00:00
|
|
|
.Dl $ truss -o /tmp/truss.out /bin/echo hello
|
2017-07-21 13:50:59 +00:00
|
|
|
.Pp
|
|
|
|
Follow an already-running process:
|
2009-01-23 00:58:14 +00:00
|
|
|
.Dl $ truss -p 34
|
1997-12-06 05:23:12 +00:00
|
|
|
.Sh SEE ALSO
|
2017-07-21 13:58:51 +00:00
|
|
|
.Xr dtrace 1 ,
|
1998-01-05 07:30:26 +00:00
|
|
|
.Xr kdump 1 ,
|
1997-12-06 05:23:12 +00:00
|
|
|
.Xr ktrace 1 ,
|
2015-10-06 21:58:38 +00:00
|
|
|
.Xr ptrace 2 ,
|
|
|
|
.Xr utrace 2
|
1997-12-06 05:23:12 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
1998-01-05 07:30:26 +00:00
|
|
|
.Nm
|
|
|
|
command was written by
|
|
|
|
.An Sean Eric Fagan
|
|
|
|
for
|
2000-01-23 01:48:16 +00:00
|
|
|
.Fx .
|
|
|
|
It was modeled after
|
1997-12-06 05:23:12 +00:00
|
|
|
similar commands available for System V Release 4 and SunOS.
|