what is
strace ?
Linux 解释
从字面意思上就可道 strace
跟踪程序执行时候的系统调用和信号.
how use?
man 一下strace 发现它的参数一大坨,是不是很郁闷,不用担心,其实我们只要记住几个常用的参数就可以搞定绝对大多数问题啦
注意 test指可执行文件
strace -i 查看可执行文件的系统调用
-i 查看可执行文件在那个地址进行了系统调用,可配合gdb
-p " pid of test" 附加到运行的进程 Ctrl +c 结束
-o trace.log 输出重定向到日志里面
-f fork 之后,跟踪fork 之后的进程
-t 输出每一行加上调用时间,秒为单位
-tt 输出每一行加上调用时间,毫秒为单位
-T 显示每一系统调用时间
other:
-e expr 指定跟踪格式,格式如下
[qualifier=][!]value1[,value2]...
手册如下面说明
where qualifier is one of trace, abbrev, verbose, raw, signal, read, or
write and
value is a qualifier-dependent symbol or number. The
default qualifier is trace.
Using an exclamation mark negates the set of
values. For example, -e open means
literally -e trace=open which in turn
means trace only the open system call. By
contrast, -e trace=!open means
to trace every system call except open. In addi‐
tion, the special values
all and none have the obvious meanings.
Note that some shells use the exclamation point for history expansion even
inside
quoted arguments. If so, you must escape the exclamation point with
a backslash.
这句话很好懂,这里就不解释啦
strace 就到这里啦,其他的参数man一下就知道了...................
linux 工具系列之 - strace,码迷,mamicode.com