[dtrace-discuss] sub-function

James C. McPherson James.McPherson at Sun.COM
Tue Jul 8 06:05:42 PDT 2008


Nigel S wrote:
> I'm a newbie as dtrace, but couldn't find an answer to this by searching
> :
> 
> For example, I have function "lsearch" which is called in many different
> places. It's also called by "composemessage".
> 
> I have been able to successfully create a script which show the return
> values of "lsearch". Now what I would like to do, is for it to only show
> the return value of "lsearch" when it's called by "composemessage".

Hi Nigel,
perhaps something like this might work for you:



===========================================================
#!/usr/sbin/dtrace

pid$target::*composemessage*:entry
{
	self->composed = 1;
}

pid$target::*lsearch*:entry
/self->composed/
{
	ustack(10);
}

pid$target::*lsearch*:return
/self->composed/
{
	printf("returning %d", arg1);
	self->composed = 0;
}
===========================================================


You should have a look in the DTrace manual for info about
predicates.


hth,
James C. McPherson
--
Senior Kernel Software Engineer, Solaris
Sun Microsystems
http://blogs.sun.com/jmcp	http://www.jmcp.homeunix.com/blog


More information about the dtrace-discuss mailing list