有时,我们需要使用DTrace
追踪程序的链接库的函数,这时module
名字就应该是链接库的名字。什么样的名字是有效的呢?让我做个实验验证一下。
我的程序链接了MySQL
的client
库,执行下面这些命令:
bash-3.2# dtrace -n 'pid$target::mysql_real_connect:entry' -p 10848
dtrace: description 'pid$target::mysql_real_connect:entry' matched 1 probe
^C
bash-3.2# dtrace -n 'pid$target:mysqlclient_r:mysql_real_connect:entry' -p 10848
dtrace: invalid probe specifier pid$target:mysqlclient_r:mysql_real_connect:entry: probe description pid10848:mysqlclient_r:mysql_real_connect:entry does not match any probes
bash-3.2# dtrace -n 'pid$target:libmysqlclient_r:mysql_real_connect:entry' -p 10848
dtrace: description 'pid$target:libmysqlclient_r:mysql_real_connect:entry' matched 1 probe
^C
bash-3.2# dtrace -n 'pid$target:libmysqlclient_r.so:mysql_real_connect:entry' -p 10848
dtrace: description 'pid$target:libmysqlclient_r.so:mysql_real_connect:entry' matched 1 probe
^C
bash-3.2# dtrace -n 'pid$target:libmysqlclient_r.so.15:mysql_real_connect:entry' -p 10848
dtrace: description 'pid$target:libmysqlclient_r.so.15:mysql_real_connect:entry' matched 1 probe
^C
bash-3.2# dtrace -n 'pid$target:libmysqlclient_r.so.15.0:mysql_real_connect:entry' -p 10848
dtrace: description 'pid$target:libmysqlclient_r.so.15.0:mysql_real_connect:entry' matched 1 probe
^C
bash-3.2# dtrace -n 'pid$target:libmysqlclient_r.so.15.0.0:mysql_real_connect:entry' -p 10848
dtrace: description 'pid$target:libmysqlclient_r.so.15.0.0:mysql_real_connect:entry' matched 1 probe
^C
可以看到,libmysqlclient_r
,libmysqlclient_r.so
,libmysqlclient_r.so.15
,libmysqlclient_r.so.15.0
和libmysqlclient_r.so.15.0.0
都是有效的module
名称,但是mysqlclient_r
不行。此外省略module
名也可以。