If I use a simple dtrace script such as this: fbt::somefunc:entry{self->trace=1;} fbt::somefunc:return{self->trace=0;} fbt:::entry{} fbt:::return{printf("%lx", arg1);} then it will descend to whatever depth is necessary If I want to limit it to say 3 functions deep, how can I do that? The quick answer I want to use is to do "self->depth++" on each entry and then use /self->depth < 4/... but the problem is then handling return and decrementing depth properly. Is there something that I''m missing? Darren
Hey Darren, There is a stackdepth builtin variable that holds the depth of the stack. You can use that to find how deep you are instead of using your own depth variable. Also I''m not sure your script does what you think it does. You need predicates that use the self->trace variable. Here is my rewrite with stackdepth. fbt::somefunc:entry { self->trace=1; self->funcdepth = stackdepth; } fbt::somefunc:return { self->trace=0; } fbt:::return /self->trace && (stackdepth - self->funcdepth) < 4/ { printf("%lx",arg1); } I just typed this script in email and have not tested it. So please use with care :-) BTW the stackdepth equivalent in the userland is ustackdepth. -Angelo On Apr 6, 2011, at 9:48 AM, Darren Reed wrote:> If I use a simple dtrace script such as this: > > fbt::somefunc:entry{self->trace=1;} > fbt::somefunc:return{self->trace=0;} > fbt:::entry{} > fbt:::return{printf("%lx", arg1);} > > then it will descend to whatever depth is necessary > > If I want to limit it to say 3 functions deep, how can I do that? > > The quick answer I want to use is to do "self->depth++" on each entry and then use /self->depth < 4/... > but the problem is then handling return and decrementing depth properly. > > Is there something that I''m missing? > > Darren > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Hi Angelo, I think that this is exactly what I was looking for. Put the lack of predicates using self->trace down to something that I just didn''t transcribe when I was writing the email. Darren Angelo Rajadurai wrote:> Hey Darren, > > There is a stackdepth builtin variable that holds the depth of the stack. You can use that to find how deep you are instead of using your own depth variable. > > Also I''m not sure your script does what you think it does. You need predicates that use the self->trace variable. Here is my rewrite with stackdepth. > > fbt::somefunc:entry > { > self->trace=1; > self->funcdepth = stackdepth; > } > > fbt::somefunc:return > { > self->trace=0; > } > > fbt:::return > /self->trace && (stackdepth - self->funcdepth) < 4/ > { > printf("%lx",arg1); > } > > I just typed this script in email and have not tested it. So please use with care :-) > > BTW the stackdepth equivalent in the userland is ustackdepth. > > > -Angelo > > > On Apr 6, 2011, at 9:48 AM, Darren Reed wrote: > > >> If I use a simple dtrace script such as this: >> >> fbt::somefunc:entry{self->trace=1;} >> fbt::somefunc:return{self->trace=0;} >> fbt:::entry{} >> fbt:::return{printf("%lx", arg1);} >> >> then it will descend to whatever depth is necessary >> >> If I want to limit it to say 3 functions deep, how can I do that? >> >> The quick answer I want to use is to do "self->depth++" on each entry and then use /self->depth < 4/... >> but the problem is then handling return and decrementing depth properly. >> >> Is there something that I''m missing? >> >> Darren >> >> _______________________________________________ >> dtrace-discuss mailing list >> dtrace-discuss at opensolaris.org >> > >