0
votes

I am using MAC OS 10.14 with MongooseIM. I want to use debugger in MongooseIM. When I execute im(). in MongooseIm shell, I get the following error:

Call to i:im/0 in application debugger failed. ok

I can verify that I can run im(). in the erlang shell $ erl. It seems I have to enable the debugger in the MongooseIM but I don't know how to do that. I failed to find it in Erlang/Ejabberd/MongooseIM docs. I have also read the following related to this :

Call to i:im() in application debugger failed in mongooseim https://github.com/esl/MongooseIM/issues/1788

As per the second URL, I need to add debugger app in the rebar.config in MongooseIM but I don't know how, please help.

1
I am using $ sudo /Users/MAC/Documents/Workspace/MongooseIm/MongooseIM/_build/prod/rel/mongooseim/bin/mongooseimctl live to start the MongooseIm server and then I try im(). inside the live shellShubham1164
Since the live shell is working fine. But when I use $sudo /Users/MAC/Documents/Workspace/MongooseIm/MongooseIM/_build/prod/rel/mongooseim/bin/mongooseimctl debug, I get some the following error *** ERROR: Shell process terminated! (^G to start new job) ***Shubham1164
You can follow this suggestion - github.com/esl/MongooseIM/issues/1788#issuecomment-378195556 - and add the debugger application to rebar.config, but please see my answer below for the suggested alternative.erszcz

1 Answers

1
votes

i:im() is a stepwise debugger (like gdb, lldb, or pdb which allow for setting breakpoints, running a program, pausing execution, etc) based on wxWidgets graphical user interface library. MongooseIM is a server - it does not bundle wxWidgets, because it does not have a graphical interface at all.

Due to the nature of the Erlang VM, where a lot of concurrent activities happen side by side, a stepwise debugger is not the best tool for the job. For example, setting a breakpoint in a process which is called via gen_server:call() would make the call time out, leading to a cascade of errors possibly irrelevant to the problem being debugged.

However, the Erlang VM has a builtin debugging facility more suitable to its concurrent nature - a tracing debugger. Tracing does not allow for breakpoints or pausing execution. Instead, it records (a subset of all) the exact events happening in the system and prints/saves them for a posteriori inspection.

This video and transcript provide a brief introduction to tracing on the Erlang VM (in Elixir syntax), while Mats Cronqvist, one of the Erlang veterans, elaborates on the subject in his Erlang User Conference 2014 talk Taking the printf out of printf debugging.

That being said, MongooseIM ships with two interfaces to the tracing mechanism:

  • dbg - the standard OTP interface - this SO post shows its basics - be careful if tracing in production, since dbg does not provide any safety mechanisms, so it's possible to overload a production system,

  • recon - a way more user friendly and safe for production tracing library, with outstanding documentation. This is probably your best choice when the ease of applicability and the set of features are considered.