1
打印我想寫一個DTrace探測器,將匹配函數std::string
參數並打印字符串的內容:怎樣的libstdC++字符串內容使用DTrace
void func(std::string some) {
/* some code here */
}
我試圖執行探頭like this:
pid$target::func(std??string):entry
{
this->str = *(uintptr_t*)copyin(arg1, sizeof(char*));
printf("arg1 %s", copyinstr(this->str));
}
不幸的是,這並不適用於我,dtrace報告它檢測到無效地址。另外,這裏還有另一個問題 - libstdC++中的字符串在寫入時使用拷貝,所以僅僅在這裏處理指針是不夠的。有人知道該怎麼做嗎?我在mac os x上使用dtrace。