149364d3cSMike Pritchard.\" 2*8fb164a6SEdward Tomasz Napierala.Dd July 24, 2017 3bbeaf6c0SSean Eric Fagan.Dt TRUSS 1 462500372SRuslan Ermilov.Os 5bbeaf6c0SSean Eric Fagan.Sh NAME 63cf51049SPhilippe Charnier.Nm truss 7bbeaf6c0SSean Eric Fagan.Nd trace system calls 83cf51049SPhilippe Charnier.Sh SYNOPSIS 98fe908efSRuslan Ermilov.Nm 10d70876fdSJohn Baldwin.Op Fl facedDHS 113cf51049SPhilippe Charnier.Op Fl o Ar file 120cf21b4fSBrian Somers.Op Fl s Ar strsize 133cf51049SPhilippe Charnier.Fl p Ar pid 148fe908efSRuslan Ermilov.Nm 15d70876fdSJohn Baldwin.Op Fl facedDHS 16bbeaf6c0SSean Eric Fagan.Op Fl o Ar file 170cf21b4fSBrian Somers.Op Fl s Ar strsize 18353067fcSRuslan Ermilov.Ar command Op Ar args 19bbeaf6c0SSean Eric Fagan.Sh DESCRIPTION 20e8937ba0SPhilippe CharnierThe 21e8937ba0SPhilippe Charnier.Nm 22e8937ba0SPhilippe Charnierutility traces the system calls called by the specified process or program. 23bbeaf6c0SSean Eric FaganOutput is to the specified output file, or standard error by default. 24bbeaf6c0SSean Eric FaganIt does this by stopping and restarting the process being monitored via 255d2d083cSXin LI.Xr ptrace 2 . 26bbeaf6c0SSean Eric Fagan.Pp 27bbeaf6c0SSean Eric FaganThe options are as follows: 283cf51049SPhilippe Charnier.Bl -tag -width indent 29c03bfcc8SMatthew N. Dodd.It Fl f 306fb9b618SGiorgos KeramidasTrace descendants of the original traced process created by 3106e482e6SRuslan Ermilov.Xr fork 2 , 3206e482e6SRuslan Ermilov.Xr vfork 2 , 3306e482e6SRuslan Ermilovetc. 34d70876fdSJohn BaldwinTo distinguish events between processes, 35d70876fdSJohn Baldwinthe process ID 36d70876fdSJohn Baldwin.Pq PID 37d70876fdSJohn Baldwinof the process is included in the output of each event. 389897b203SMatthew N. Dodd.It Fl a 3906e482e6SRuslan ErmilovShow the argument strings that are passed in each 4006e482e6SRuslan Ermilov.Xr execve 2 4106e482e6SRuslan Ermilovsystem call. 42ee3b0f6eSDiomidis Spinellis.It Fl c 437096af2eSBryan DreweryDo not display individual system calls or signals. 44ee3b0f6eSDiomidis SpinellisInstead, before exiting, print a summary containing for each system call: 45ee3b0f6eSDiomidis Spinellisthe total system time used, 46ee3b0f6eSDiomidis Spinellisthe number of times the call was invoked, 47ee3b0f6eSDiomidis Spinellisand the number of times the call returned with an error. 489897b203SMatthew N. Dodd.It Fl e 4906e482e6SRuslan ErmilovShow the environment strings that are passed in each 5006e482e6SRuslan Ermilov.Xr execve 2 5106e482e6SRuslan Ermilovsystem call. 520d0bd00eSMatthew N. Dodd.It Fl d 530d0bd00eSMatthew N. DoddInclude timestamps in the output showing the time elapsed 540d0bd00eSMatthew N. Doddsince the trace was started. 550d0bd00eSMatthew N. Dodd.It Fl D 560d0bd00eSMatthew N. DoddInclude timestamps in the output showing the time elapsed 570d0bd00eSMatthew N. Doddsince the last recorded event. 58d70876fdSJohn Baldwin.It Fl H 59d70876fdSJohn BaldwinInclude the thread ID of in the output of each event. 60bbeaf6c0SSean Eric Fagan.It Fl S 61bbeaf6c0SSean Eric FaganDo not display information about signals received by the process. 62bbeaf6c0SSean Eric Fagan(Normally, 633cf51049SPhilippe Charnier.Nm 64bbeaf6c0SSean Eric Fagandisplays signal as well as system call events.) 653cf51049SPhilippe Charnier.It Fl o Ar file 663cf51049SPhilippe CharnierPrint the output to the specified 673cf51049SPhilippe Charnier.Ar file 683cf51049SPhilippe Charnierinstead of standard error. 690cf21b4fSBrian Somers.It Fl s Ar strsize 700cf21b4fSBrian SomersDisplay strings using at most 710cf21b4fSBrian Somers.Ar strsize 720cf21b4fSBrian Somerscharacters. 730cf21b4fSBrian SomersIf the buffer is larger, 74cb29445aSRuslan Ermilov.Dq Li ... 750cf21b4fSBrian Somerswill be displayed at the end of the string. 760cf21b4fSBrian SomersThe default 770cf21b4fSBrian Somers.Ar strsize 780cf21b4fSBrian Somersis 32. 793cf51049SPhilippe Charnier.It Fl p Ar pid 80bbeaf6c0SSean Eric FaganFollow the process specified by 81bbeaf6c0SSean Eric Fagan.Ar pid 82bbeaf6c0SSean Eric Faganinstead of a new command. 83353067fcSRuslan Ermilov.It Ar command Op Ar args 84bbeaf6c0SSean Eric FaganExecute 85bbeaf6c0SSean Eric Fagan.Ar command 86bbeaf6c0SSean Eric Faganand trace the system calls of it. 87bbeaf6c0SSean Eric Fagan(The 88bbeaf6c0SSean Eric Fagan.Fl p 89bbeaf6c0SSean Eric Faganand 90bbeaf6c0SSean Eric Fagan.Ar command 91bbeaf6c0SSean Eric Faganoptions are mutually exclusive.) 929b88faecSRuslan Ermilov.El 93bbeaf6c0SSean Eric Fagan.Sh EXAMPLES 94279e48d5SEdward Tomasz NapieralaFollow the system calls used in echoing "hello": 95bbeaf6c0SSean Eric Fagan.Dl $ truss /bin/echo hello 96279e48d5SEdward Tomasz Napierala.Pp 97279e48d5SEdward Tomasz NapieralaDo the same, but put the output into a file: 98bbeaf6c0SSean Eric Fagan.Dl $ truss -o /tmp/truss.out /bin/echo hello 99279e48d5SEdward Tomasz Napierala.Pp 100279e48d5SEdward Tomasz NapieralaFollow an already-running process: 101a88e970cSTom Rhodes.Dl $ truss -p 34 102bbeaf6c0SSean Eric Fagan.Sh SEE ALSO 103*8fb164a6SEdward Tomasz Napierala.Xr dtrace 1 , 1043cf51049SPhilippe Charnier.Xr kdump 1 , 105bbeaf6c0SSean Eric Fagan.Xr ktrace 1 , 106195aef99SBryan Drewery.Xr ptrace 2 , 107195aef99SBryan Drewery.Xr utrace 2 108bbeaf6c0SSean Eric Fagan.Sh HISTORY 109bbeaf6c0SSean Eric FaganThe 1103cf51049SPhilippe Charnier.Nm 1113cf51049SPhilippe Charniercommand was written by 1123cf51049SPhilippe Charnier.An Sean Eric Fagan 1133cf51049SPhilippe Charnierfor 114f3c2973dSMike Pritchard.Fx . 115f3c2973dSMike PritchardIt was modeled after 116bbeaf6c0SSean Eric Fagansimilar commands available for System V Release 4 and SunOS. 117