[erlang-questions] Examining bindings on the stack

Brian Candler <>
Wed Sep 10 10:28:25 CEST 2008

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}]}].

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


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)

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



More information about the erlang-questions mailing list