📄 strace.1
字号:
is one of.BR trace ,.BR abbrev ,.BR verbose ,.BR raw ,.BR signal ,.BR read ,or.B writeand.I valueis a qualifier-dependent symbol or number. The defaultqualifier is.BR trace .Using an exclamation mark negates the set of values. For example,.B \-eopenmeans literally.B "\-e trace=open"which in turn means trace only the.B opensystem call. By contrast,.B "\-etrace=!open"means to trace every system call except.BR open .In addition, the special values.B alland.B nonehave the obvious meanings..IPNote that some shells use the exclamation point for historyexpansion even inside quoted arguments. If so, you must escapethe exclamation point with a backslash..TP.BI "\-e trace=" setTrace only the specified set of system calls. The.B \-coption is useful for determining which system calls might be usefulto trace. For example,.B trace=open,close,read,writemeans to onlytrace those four system calls. Be careful when making inferencesabout the user/kernel boundary if only a subset of system callsare being monitored. The default is.BR trace=all ..TP.B "\-e trace=file"Trace all system calls which take a file name as an argument. Youcan think of this as an abbreviation for.BR "\-e\ trace=open,stat,chmod,unlink," ...which is useful to seeing what files the process is referencing.Furthermore, using the abbreviation will ensure that you don'taccidentally forget to include a call like.B lstatin the list. Betchya woulda forgot that one..TP.B "\-e trace=process"Trace all system calls which involve process management. Thisis useful for watching the fork, wait, and exec steps of a process..TP.B "\-e trace=network"Trace all the network related system calls..TP.B "\-e trace=signal"Trace all signal related system calls..TP.B "\-e trace=ipc"Trace all IPC related system calls..TP.BI "\-e abbrev=" setAbbreviate the output from printing each member of large structures.The default is.BR abbrev=all .The.B \-voption has the effect of.BR abbrev=none ..TP.BI "\-e verbose=" setDereference structures for the specified set of system calls. Thedefault is.BR verbose=all ..TP.BI "\-e raw=" setPrint raw, undecoded arguments for the specifed set of system calls.This option has the effect of causing all arguments to be printedin hexadecimal. This is mostly useful if you don't trust thedecoding or you need to know the actual numeric value of anargument..TP.BI "\-e signal=" setTrace only the specified subset of signals. The default is.BR signal=all .For example,.B signal=!SIGIO(or.BR signal=!io )causes SIGIO signals not to be traced..TP.BI "\-e read=" setPerform a full hexadecimal and ASCII dump of all the data read fromfile descriptors listed in the specified set. For example, to seeall input activity on file descriptors 3 and 5 use.BR "\-e read=3,5" .Note that this is independent from the normal tracing of the.BR read (2)system call which is controlled by the option.BR "\-e trace=read" ..TP.BI "\-e write=" setPerform a full hexadecimal and ASCII dump of all the data written tofile descriptors listed in the specified set. For example, to seeall output activity on file descriptors 3 and 5 use.BR "\-e write=3,5" .Note that this is independent from the normal tracing of the.BR write (2)system call which is controlled by the option.BR "\-e trace=write" ..TP.BI "\-o " filenameWrite the trace output to the file.I filenamerather than to stderr.Use.I filename.pidif.B \-ffis used.If the argument begins with `|' or with `!' then the rest of theargument is treated as a command and all output is piped to it.This is convenient for piping the debugging output to a programwithout affecting the redirections of executed programs..TP.BI "\-O " overheadSet the overhead for tracing system calls to.I overheadmicroseconds.This is useful for overriding the default heuristic for guessinghow much time is spent in mere measuring when timing system calls usingthe.B \-coption. The acuracy of the heuristic can be gauged by timing a givenprogram run without tracing (using.BR time (1))and comparing the accumulatedsystem call time to the total produced using.BR \-c ..TP.BI "\-p " pidAttach to the process with the process.SM ID.I pidand begin tracing.The trace may be terminatedat any time by a keyboard interrupt signal (\c.SM CTRL\s0-C)..B stracewill respond by detaching itself from the traced process(es)leaving it (them) to continue running.Multiple.B \-poptions can be used to attach to up to 32 processes in addition to.I command(which is optional if at least one.B \-poption is given)..TP.BI "\-s " strsizeSpecify the maximum string size to print (the default is 32). Notethat filenames are not considered strings and are always printed infull..TP.BI "\-S " sortbySort the output of the histogram printed by the.B \-coption by the specified critereon. Legal values are.BR time ,.BR calls ,.BR name ,and.B nothing(default.BR time )..TP.BI "\-u " usernameRun command with the user \s-1ID\s0, group \s-2ID\s0, andsupplementary groups of.IR username .This option is only useful when running as root and enables thecorrect execution of setuid and/or setgid binaries.Unless this option is used setuid and setgid programs are executedwithout effective privileges..SH "SETUID INSTALLATION"If.B straceis installed setuid to root then the invoking user will be able toattach to and trace processes owned by any user.In addition setuid and setgid programs will be executed and tracedwith the correct effective privileges.Since only users trusted with full root privileges should be allowedto do these things,it only makes sense to install.B straceas setuid to root when the users who can execute it are restrictedto those users who have this trust.For example, it makes sense to install a special version of.B stracewith mode `rwsr-xr--', user.B rootand group.BR trace ,where members of the.B tracegroup are trusted users.If you do use this feature, please remember to installa non-setuid version of.B stracefor ordinary lusers to use..SH "SEE ALSO".BR ptrace (2),.BR proc (4),.BR time (1),.BR trace (1),.BR truss (1).SH NOTESIt is a pity that so much tracing clutter is produced by systemsemploying shared libraries..LPIt is instructive to think about system call inputs and outputsas data-flow across the user/kernel boundary. Because user-spaceand kernel-space are separate and address-protected, it issometimes possible to make deductive inferences about processbehavior using inputs and outputs as propositions..LPIn some cases, a system call will differ from the documented behavioror have a different name. For example, on System V-derived systemsthe true.BR time (2)system call does not take an argument and the.B statfunction is called.B xstatand takes an extra leading argument. Thesediscrepancies are normal but idiosyncratic characteristics of thesystem call interface and are accounted for by C library wrapperfunctions..LPOn some platforms a process that has a system call trace appliedto it with the.B \-poption will receive a.BR \s-1SIGSTOP\s0 .This signal may interrupt a system call that is not restartable.This may have an unpredictable effect on the processif the process takes no action to restart the system call..SH BUGSPrograms that use the.I setuidbit do not haveeffective user.SM IDprivileges while being traced..LPA traced process ignores.SM SIGSTOPexcept on SVR4 platforms..LPA traced process which tries to block SIGTRAP will be sent a SIGSTOPin an attempt to force continuation of tracing..LPA traced process runs slowly..LPTraced processes which are descended from.I commandmay be left running after an interrupt signal (\c.SM CTRL\s0-C)..LPOn Linux, exciting as it would be, tracing the init process is forbidden..LPThe.B \-ioption is weakly supported..SH HISTORY.B straceThe original.B stracewas written by Paul Kranenburgfor SunOS and was inspired by its trace utility.The SunOS version of.B stracewas ported to Linux and enhancedby Branko Lankester, who also wrote the Linux kernel support.Even though Paul released.B strace2.5 in 1992,Branko's work was based on Paul's.B strace1.5 release from 1991.In 1993, Rick Sladkey merged.B strace2.5 for SunOS and the second release of.B stracefor Linux, added many of the features of.BR truss (1)from SVR4, and produced an.B stracethat worked on both platforms. In 1994 Rick ported.B straceto SVR4 and Solaris and wrote theautomatic configuration support. In 1995 he ported.B straceto Irixand tired of writing about himself in the third person..SH PROBLEMSProblems with.B straceshould be reported to the current.B stracemaintainer, Wichert Akkerman, at <wakkerma@debian.org>.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -