I want to write a dtrace probe that would match a function with std::string
argument and print the string's content:
void func(std::string some) {
/* some code here */
}
I tried to implement the probe like this:
pid$target::func(std??string):entry
{
this->str = *(uintptr_t*)copyin(arg1, sizeof(char*));
printf("arg1 %s", copyinstr(this->str));
}
Unfortunately, this doesn't work for me, dtrace reports it detected invalid address.. Also, there is another problem here - string in libstdc++ uses copy on write, so just coping a pointer is not enough here. Does anybody know how to do it? I'm using dtrace on mac os x.