[erlang-questions] : Examining bindings on the stack
Raimo Niskanen
raimo+erlang-questions@REDACTED
Wed Sep 10 11:12:36 CEST 2008
On Wed, Sep 10, 2008 at 09:28:25AM +0100, Brian Candler wrote:
> On Wed, Sep 10, 2008 at 07:33:46AM +0200, Nicolas Charpentier wrote:
> > As dbg is complex, I can't give you exactly the instructions to type but
> > basically to activate trace on a specific function it will be something
> > like that:
> >
> > > dbg:tracer().
> > > dbg:p(all,[c]).
> > > dbg:tpl(Module,Function,Match_spec).
> >
> > The Match_spec allow you to filter the function call you want to trace
> > according to the value of the parameter. By default I always use
> > Match_spec = [{'_',[],[{return_trace}]}].
Then you would love:
Match_spec = [{'_',[],[{exception_trace}]}].
We should have dbg shortcuts for those.
>
> This does the job perfectly, thank you. It's rather cool to watch recursive
> functions expanding themselves:
>
> (<0.36.0>) call adder:addup([1,2,3])
>
> (<0.36.0>) call adder:addup([1,2,3],0)
> (<0.36.0>) call adder:addup([2,3],1)
> (<0.36.0>) call adder:addup([3],3)
> (<0.36.0>) call adder:addup([],6)
>
> so I think could usefully be introduced to new erlangers very early on. I
> also see it can trace messages in and out of a process.
>
> A question: is it possible to call dbg:p in such a way as to clear
> individual flags? The reason is that I found
>
> dbg:p(Regname,[all]).
>
> disables display of the function arguments. After some digging, I found it's
> because 'all' sets the 'arity' flag too (documented under erlang:trace/3)
There is acually an error in the dbg documentation here. The 'all's are
not the same. erlang:trace/3's 'all' is as documented, but dbg's 'all' is
[m,c,p,garbage_collection,running,sos,sofs,sol,sofl,timestamp,arity,return_to],
it's in the source.
>
> I finally managed to clear just the arity flag by talking to the lower layer:
>
> erlang:trace(whereis(Regname), false, [arity]).
>
> but I can't see a way in dbg to do this. dbg:p(Regname,[clear]) clears them
> all.
Unfortunately today dbg has no way to clear individual flags.
dbg:p(Regname, [m,c,p,garbage_collection,running,sos,sofs,sol,sofl,timestamp,return_to]
but if you use the match spec for return_trace you might skip the
process trace flag return_to, and you will have to consider if you
really need the sos,sofs,sol,sofl flags - gives:
dbg:p(Regname, [m,c,p,garbage_collection,running,timestamp]
And do you really need to see how your process is garbage collected
and scheduled in or out?
dbg:p(Regname, [m,c,p,timestamp]
With propagation to childs:
dbg:p(Regname, [m,c,p,sos,timestamp]
Is that one worthy of a shorcut name?
>
> Regards,
>
> Brian.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list