[erlang-questions] Tracing ejabberd

Francesco Cesarini <>
Wed May 14 09:08:03 CEST 2008

You are probably running Erlang in embedded mode, which loads all the 
modules at startup. I assume that the runtime tools application is not 
part of the build. That is where dbg is.

Also, because of the strange setup with ejabberd, you probably need to 
play around before you are able to get any trace messages.
to run dbg on an ejabbed node and bypass the group leader io problem, 
you have to

* Start a distributed Erlang Node
* Connect to the Ejabberd Cluster
* Start the tracer
* Connect the ejabberd nodes to the tracer
* Pick which processes and functions to trace

In pseudo code, you would do something like this:

erl -sname dbg -setcookie COOKIE   (Where COOKIE is the same cookie as 
the ejabberd node)

1> net_adm:ping(EJABBERDNODENAME). (Where EJABBERDNODENAME is the 
distributed Erlang node name running on EjabberD).
2> dbg:tracer().
3> lists:foreach(fun(Node) -> dbg:n(Node) end, nodes()).

You can now use all of the trace commands and get the ourput redirected 
to your shell. They include dbg:p/2 to pick which processes to trace and 
dbg:tp for global calls and dbg:tpl for local ones.

hope this helps,

Tuncer Ayaz wrote:
> On Tue, May 13, 2008 at 9:28 PM, Vlad12 <> wrote:
>>  Hello,
>>  Can anyone tell me why every time i run ejabberd on "live" mode (opens an
>>  erlang shell at the node  ) it does not allow me to run
>>  dbg or fprof functions?
>>  shell$ ./ejabberdct live
>>  This is what i get if i try to run dbg:tracer(). :
>>  ()4> dbg:tracer().
>>  ** exited: {undef,[{dbg,tracer,[]},
>>                    {erl_eval,do_apply,5},
>>                    {shell,exprs,6},
>>                    {shell,eval_loop,3}]} **
> If I may trust my slowly building Erlang skills this
> error means that the system is unable to locate either
> the module 'dbg' or the method 'dbg:tracer'.
> A wild guess is that ejabberd's runtime config does not
> include too many additional libs/modules.
> The solution to your problem is something which I hope
> to know soon after having digged deeper into ejabberd.
> I know this doesn't solve your issue but may help
> clear the situation.
>>  =ERROR REPORT==== 13-May-2008::13:21:29 ===
>>  Error in process <0.334.0> on node '' with exit value:
>>  {undef,[{dbg,tracer,[]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
>>  The error message is similar if i run fprof:trace(start). :
>>  ()9> fprof:trace(start).
>>  {'EXIT',<0.354.0>,
>>         {undef,[{dbg,trace_port,[file,"fprof.trace"]},
>>                 {fprof,open_dbg_trace_port,2},
>>                 {fprof,handle_req,3},
>>                 {fprof,server_loop,1}]}}
>>  =ERROR REPORT==== 13-May-2008::13:25:53 ===
>>  Error in process <0.354.0> on node '' with exit value:
>>  {undef,[{dbg,trace_port,[file,"fprof.trace"]},{fprof,open_dbg_trace_port,2},{fprof,handle_req,3},{fprof,server_loop,1}]}
>>   Help is greatly appreciated
> _______________________________________________
> erlang-questions mailing list
> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list