1 Star2 Stars3 Stars4 Stars5 Stars (还没有评分)
Loading...

DTrace tricks and tips (11) –如何运行带参数的命令

使用DTrace运行不带参数的命令很简单。假设程序名字叫“a”,执行这个命令即可:“dtrace -n 'pid$target::sigaction:entry' -c ./a”。如果程序需要参数(假设为“-x”),如何运行呢?

试着执行如下命令:

bash-3.2# dtrace -n 'pid$target::sigaction:entry' -c ./a -x
dtrace: option requires an argument -- x

可以看到DTrace会报错。改正方法是用引号把命令和参数引用起来,如下所示:

bash-3.2# dtrace -n 'pid$target::sigaction:entry' -c './a -x'
dtrace: description 'pid$target::sigaction:entry' matched 1 probe
The address is 0x8060ea0, sizeof(struct sigaction) is 32
dtrace: pid 1019 has exited
CPU ID FUNCTION:NAME
  0 58581 sigaction:entry 

这样就可以了。

参考资料:
http://www.listbox.com/member/archive/184261/2014/10/sort/time_rev/page/1/entry/9:14/20141021062337:50291224-590C-11E4-8E44-A280B3C58233/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.