Sni*_*gus 7 printing arrays associative dtrace
这个问题几乎总结了一下."dtrace'打印一个关联数组'"只有一个谷歌命中,类似的搜索同样没用.
编辑:
如果我要使用聚合,我不知道我仍然可以删除条目.我的申请要求我能够做以下事情:
file_descriptors[0] = "stdin"
file_descriptors[3] = "service.log"
...
...
file_descriptors[3] = 0
...
...
print_array(file_descriptors) # should print only those entries that have not been cleared.
Run Code Online (Sandbox Code Playgroud)
我知道您可以清除整个聚合,但是单个条目呢?
更新:
由于我在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...
Run Code Online (Sandbox Code Playgroud)
太糟糕了.我真的想要有更好的东西.
这是Google 找到的链接吗?因为这个建议看起来很合理:
我认为您正在寻找的效果应该通过使用聚合而不是数组来实现。所以你实际上会做类似的事情:
@requests[remote_ip,request] = count();
Run Code Online (Sandbox Code Playgroud)
... 进而:
profile:::tick-10sec
{
/* print all of the requests */
printa(@requests);
/* Nuke the requests aggregation */
trunc(@requests);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2115 次 |
| 最近记录: |