调试挂在Erlang中的函数调用 [英] Debugging a function call that hangs in Erlang

查看:90
本文介绍了调试挂在Erlang中的函数调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎我的代码或正在使用的代码中的某个地方都造成了死锁,但是我不确定如何调试它。因为我不知道问题出在哪里,而且我可以使系统几乎完全空闲,所以我认为查看导致挂起的所有功能和消息的跟踪将很有用。看来 dbg 在跟踪方面提供了一些帮助,但我看不到如何针对如此广泛的跟踪进行配置。 dbg 是否可以进行这种跟踪,或者在Erlang中还有其他更好的调试挂起方式?

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?

推荐答案

我建议使用 dbg 。虽然有另一个答案中提到的常规调试器,但是它对并发程序的用处非常有限,因为它通常会导致大量超时。

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.

克服使用<$的障碍c $ c> dbg 我推荐以下资源:

To overcome the hurdle of using dbg I recommend the following resources:

所有答案在这里都很有趣,但是特别是链接的user_default也有帮助

示例可以自己处理跟踪消息怎么做在难以调试的情况下很有用。

Example what can be done by handling the trace messages yourself which can be useful in hard to debug cases.

有关Erlangs dbg的链接和节点不断更新

如果需要使用 dbg 在生产中,我建议使用 redbug ,可帮助您避免节点崩溃。 关于使用redbug的博文

If you need to use dbg in production I recommend using redbug which helps you not crash your node. Blogpost about using redbug

这篇关于调试挂在Erlang中的函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆