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

DTraceToolkit脚本解析(10)-modcalls.d

modcalls.d位于DTraceToolkitKernel文件夹下,其功能是统计不同模块调用kernel函数的次数。脚本代码就一行(略去版权信息):

fbt:::entry { @calls[probemod] = count(); }

脚本代码分析如下:
监听fbt Provider的 entry probefbt Provider几乎提供了对所有kernel函数的entryexittrace)。定义calls这个aggregation,用probemodkeyprobemod记录了当前probe的模块名)。当probe触发后,把calls里相应模块的统计次数加1

执行脚本,输出如下:

Nans-MacBook-Pro:Kernel root# ./modcalls.d 
dtrace: script './modcalls.d' matched 47940 probes
^C

  com.apple.driver.AppleAPI                                 5
  com.apple.driver.AppleOSXWatchdog                         7
  com.apple.driver.AppleUSBComposite                        9
  com.apple.driver.AppleUSBTCButtons                        17
......

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.