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". Any ideas , suggestions ? TIA -- This message posted from opensolaris.org
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". > > Any ideas , suggestions ?in this case, you need to use a predicate, like in this example: pid$target::composemessage:entry { self->watch = 1; } pid$target::lsearch:return /self->watch == 1/ /* that''s the predicate */ { /* print return value */ } pid$target::composemessage:return /self->watch == 1/ { self->watch = 0; /* turn it off again! */ } HTH Michael -- Michael Schuster http://blogs.sun.com/recursion Recursion, n.: see ''Recursion''
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