我正在尝试读取在我的return探测器中传递给函数的初始参数。与entry探测器不同,参数变量(arg0,arg1,...)返回探测中没有包含初始参数,我不确定如何才能检索这些值。
此外,由于并发问题,我希望避免将值存储在全局变量中。
发布于 2012-08-06 23:04:09
您可以将参数保存在线程本地存储中,例如
pid$target:foo:bar:entry
{
self->arg0 = arg0;
self->arg1 = arg1;
/*
* Avoid the race in which dtrace(1) attaches to the victim during
* the window between the two probes.
*/
self->trace = 1;
}
pid$target:foo:bar:return
/self->trace/
{
printf("arg0 = 0x%x, arg1 = 0x%x\n", self->arg0, self->arg1);
/* Deallocate the thread-local storage. */
self->arg0 = 0;
self->arg1 = 0;
}发布于 2013-06-28 05:47:37
正如rmh回答的那样-使用局部变量是一种方法。否则,dtrace将不得不在输入时为您保存这些值-并且它不知道有关传入参数或您的期望的任何信息,并且将不得不进行垃圾收集。(从技术上讲,它确实知道最终会发生什么,但与映射到一组简单的虚拟D指令的局部变量方法相比,这会增加复杂的开销)。
https://stackoverflow.com/questions/11583072
复制相似问题