这个问题几乎概括了它。“dtrace 'print an associative array'” 只在谷歌上出现了一次,类似的搜索同样没用。
编辑:
如果我要使用聚合,我不知道我仍然能够删除条目。我的应用程序要求我能够执行以下操作:
file_descriptors[0] = "stdin"
file_descriptors[3] = "service.log"
...
...
file_descriptors[3] = 0
...
...
# should print only those entries that have not been cleared.
print_array(file_descriptors)
我知道您可以清除整个聚合,但是单个条目呢?
更新:
由于我在 OS X 中执行此操作,并且我的应用程序是跟踪已由特定进程打开的所有文件描述符,因此我能够拥有一个包含 256 个路径名的数组,因此:
syscall::open*:entry
/execname == $1/
{
self->path = copyinstr(arg0);
}
syscall::open*:return
/execname == $1/
{
opened[arg0] = self->path;
}
syscall::close*:entry
/execname == $1/
{
opened[arg0] = 0;
}
tick-10sec
{
printf(" 0: %s\n", opened[0]);
}
The above probe repeated 255 more times...
糟透了。我真的很想拥有更好的东西。