On Wed, Dec 16, 2009 at 2:17 PM, Hillel (Sabba) Markowitz <sabbahil...@gmail.com> wrote: > On Wed, Dec 16, 2009 at 2:13 PM, Chad Mynhier <cmynh...@gmail.com> wrote: >> >> 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 >> > > Thanks, this looks good. I will try it and see how it works.
Actually, there's a bug in the above. For this case: -> A -> B -> C <- C <- B <- A The time for B will include the time spent in C, and the time for A will include the entire time. So what you'll need to do is something more like this: #define STACKDEPTHBASE 2 pid$target:::entry / ustackdepth == STACKDEPTHBASE / { self->ts[ustackdepth] = timestamp; self->func[ustackdepth] = probefunc; } pid$target:::entry / ustackdepth > STACKDEPTHBASE && self->ts[ustackdepth - 1]/ { /* * Increment the time we just spent in the function that * called us. Zero its time so we stop counting against it. */ @profile[self->func[ustackdepth - 1]] = sum(timestamp - self->ts[ustackdepth - 1]); self->ts[ustackdepth - 1] = 0; /* * Accounting for function we're entering. */ self->func[ustackdepth] = probefunc; self->ts[ustackdepth] = timestamp; } pid$target:::return / ustackdepth + 1 > STACKDEPTHBASE && self->ts[ustackdepth]/ { /* * Accounting for function we're leaving. */ @profile[self->func[ustackdepth + 1]] = sum(timestamp - self->ts[ustackdepth + 1]); self->ts[ustackdepth + 1] = 0; self->func[ustackdepth + 1] = 0; /* * We're about to re-enter the function that called us, so * set the timestamp for him. */ self->ts[ustackdepth] = timestamp; } pid$target:::return / ustackdepth + 1 == STACKDEPTHBASE && self->ts[ustackdepth + 1] / { @profile[self->func[ustackdepth + 1]] = sum(timestamp - self->ts[ustackdepth + 1]); self->ts[ustackdepth + 1] = 0; self->func[ustackdepth + 1] = 0; } Chad _______________________________________________ dtrace-discuss mailing list dtrace-discuss@opensolaris.org