Hey Hamish,
AKA, what's wrong with the following? Isn't a string literal always
a constant?
$ cat > cfretain_calayer.d
pid$target::CFRetain:entry
{
isaptr = *(uint32_t*)copyin(arg0, 4);
classnameptr = *(uint32_t*)copyin(isaptr+8, 4);
classname = copyinstr(classnameptr);
p = (classname == "CALayer" ? "CFRetain(CALayer)\n" : "");
printf(p);
}
$ sudo dtrace -p 31303 -s cfretain_calayer.d
dtrace: failed to compile script cfretain_calayer.d: line 8:
printf( ) argument #1 is incompatible with prototype:
prototype: string constant
argument: string
Also, please let me know if there's a better way to be doing this
(I'm a dtrace newbie).
DTrace requires that you provide a constant string so that it can
perform
type checking on additional arguments (i.e. to ensure that if you
specify
the %d format option that you have an int to print). You have two pretty
easy ways to fix this:
printf("%s\n", classname == "CALayer" ? "CFRetain(CALayer)" : "");
or
trace(classname == "CALayer" ? "CFRetain(CALayer)" : "");
Note also, that all of your variables should probably be probe-local
(prefixed with this->).
Further, if you only want trace when classname == "CALayer", rather than
printing out an empty string, you could do something like this:
pid$target::CFRetain:entry
{
this->isaptr = *(uint32_t*)copyin(arg0, 4);
this->classnameptr = *(uint32_t*)copyin(isaptr+8, 4);
this->classname = copyinstr(classnameptr);
}
pid$target::CFRetain:entry
/this->classname == "CALayer"/
{
trace("CFRetain(CALayer)");
}
Hope that helps.
Adam
--
Adam Leventhal, Fishworks http://blogs.sun.com/ahl
_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org