On Wed, Dec 16, 2009 at 2:13 PM, Chad Mynhier <[email protected]> wrote:
> On Wed, Dec 16, 2009 at 1:52 PM, Hillel (Sabba) Markowitz
> <[email protected]> wrote:
>>
>> As can be seen, if recursive code is used, the self->ts gets reset to
>> timestamp with every entry, and the innermost exit causes a time to be
>> calculated and the ts to be reset. The rest of the returns within the
>> recursion will be ignored because of the conditional.
>>
>> I would like to know if someone has already done this before I try to
>> reinvent the wheel or if there is a tool in the dtrace toolkit to do
>> this already.
>
> You'll need to keep an array of timestamps indexed on ustackdepth.
> Something like this (it appears that ustackdepth on entry doesn't
> actually match ustackdepth on return):
>
> pid$target:*.so::entry
> {
>    self->ts[probemod, probefunc, ustackdepth] = timestamp;
> }
>
> pid$target:*.so::return
> / self->ts[probemod, probefunc, ustackdepth + 1] /
> {
>   �...@func_time[probemod, probefunc] = sum(timestamp -
> self->ts[probemod, probefunc, ustackdepth + 1]);
>    self->ts[probemod, probefunc, ustackdepth + 1] = 0;
> }
>
> Chad
>

When running this test, it appears to have ustackdepth  set as the
actual depth in the stack rather than recursion. Thus if there is code
of the form

A(vars)
{
   B(vars);
   c(vars);
}

B(vars)
{
   c(vars);
}

C will appear as two different values of ustack depth.  In this
particular case, C is not recursive but is called at different points
in the code. What I am trying to look for is

A(vars)
{
     code
     if (end test)
         {
             finished = true;
         }
      else
         {
             finished = false;
         }
     if (!finished)
     {
        finished = A(vars);
     }
     code
     return finished
}

-- 
       Sabba     -          סבא הלל        -     Hillel
Hillel (Sabba) Markowitz | Said the fox to the fish, "Join me ashore"
 [email protected] | The fish are the Jews, Torah is our water
http://photos1.blogger.com/blogger/7637/544/640/SabbaHillel.jpg
_______________________________________________
dtrace-discuss mailing list
[email protected]

Reply via email to