[erlang-questions] Examining bindings on the stack

Nicolas Charpentier <>
Wed Sep 10 07:33:46 CEST 2008


Brian Candler wrote:
> I'd like to know the easiest way to examine bindings on the stack in an
> error backtrace. In particular I'd to be able to see the arguments to all
> the functions called up to this point.
> 
> I've had limited success with the erlang debugger. I was trying to debug a
> backtrace from a call into an existing complex library (in this case
> yaws_soap_lib)

Hi,

If you know the name of the function in which the 'bug' occurs you can 
easily see the value of parameters using *dbg* 
(http://www.erlang.org/doc/apps/runtime_tools/index.html).

dbg is a trace/debug tool which can be used on a runtime system (almost 
the time safely) without any specific compilation (like debug_info for 
example).
With dbg, you can *at run-time*  add a trace on any function of your 
system and see the value of parameters and the result of the function call.
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}]}].


Hope that it will help
Regards,

---
Nicolas
http://charpi.net



More information about the erlang-questions mailing list