问题
It seems as if I have a caused a deadlock somewhere either in my code or in code that I'm using, but I am not sure how to debug it. Since I have no clue where the problem is and I can make the system almost completely idle, I think that it would be useful to see a trace of all functions and messages leading up to the hang. It looks like dbg
provides some help in tracing, but I don't see how to configure it for such a broad trace. Is such a trace possible with dbg
or are there other ways of debugging hangs in Erlang that are better?
回答1:
I recommend using dbg
. While there is a conventional debugger as mentioned in another answer its usefulness is very limited for concurrent programs since it cause plenty of timeouts usually.
To overcome the hurdle of using dbg
I recommend the following resources:
All answers are interesting here but especially the user_default in the linked one helps also
Example what can be done by handling the trace messages yourself which can be useful in hard to debug cases.
Continuously updated links and nodes about Erlangs dbg
If you need to use dbg
in production I recommend using redbug which helps you not crash your node. Blogpost about using redbug
回答2:
Did you try the Erlang Debugger?
来源:https://stackoverflow.com/questions/21368129/debugging-a-function-call-that-hangs-in-erlang