根据您的说法,您实际上并不需要运行调试器。 Erlang VM 的并发模型不太适合 stop-everything-and-inspect-style 调试的概念。
另一方面,VM 具有强大的内置跟踪功能。 dbg 模块是它们全部暴露的地方,但是该模块的界面很难使用,尤其是如果您是初学者。
我建议使用recon_trace 来了解您的流程发生了什么:http://ferd.github.io/recon/recon_trace.html。
如果您不想安装 recon,请从 Erlang shell 启动程序,然后在该 shell 中键入:
%enable tracing capabilities
1> dbg:tracer().
% Trace Pattern Local-scope
% (tell the tracer to trace every call in YourModule, even unexported functions).
2> dbg:tpl(YourModule, x).
% Tell dbg to print calls from all processes calling your module.
3> dbg:p(all,call).
% Run your traced module
4> YourModule:SomeFun().
% You should see nice(?) traces of inputs, outputs, and
% exceptions in your shell
查看以下会话,我在其中摸索不知道如何使用 queue 模块:
Eshell V6.3 (abort with ^G)
1> dbg:tracer(), dbg:tpl(queue, x), dbg:p(all, call).
{ok,[{matched,nonode@nohost,26}]}
2> X = queue:new().
(<0.33.0>) call queue:new()
(<0.33.0>) returned from queue:new/0 -> {[],[]}
{[],[]}
3> X = queue:cons(1).
** exception error: undefined function queue:cons/1
4> X = queue:cons(X,1).
(<0.39.0>) call queue:cons({[],[]},1)
(<0.39.0>) call queue:in_r({[],[]},1)
(<0.39.0>) exception_from {queue,in_r,2} {error,badarg}
(<0.39.0>) exception_from {queue,cons,2} {error,badarg}
** exception error: bad argument
in function queue:in_r/2
called as queue:in_r({[],[]},1)
5> X = queue:cons(1,X).
(<0.41.0>) call queue:cons(1,{[],[]})
(<0.41.0>) call queue:in_r(1,{[],[]})
(<0.41.0>) returned from queue:in_r/2 -> {[],[1]}
(<0.41.0>) returned from queue:cons/2 -> {[],[1]}
** exception error: no match of right hand side value {[],[1]}
6> X1 = queue:cons(1,X).
(<0.43.0>) call queue:cons(1,{[],[]})
(<0.43.0>) call queue:in_r(1,{[],[]})
(<0.43.0>) returned from queue:in_r/2 -> {[],[1]}
(<0.43.0>) returned from queue:cons/2 -> {[],[1]}
{[],[1]}
希望这有助于您入门。
如果您想了解 Erlang 向导是如何做到的,请观看 Mats Cronqvist's talk "Taking the printf out of printf debugging"。