如何显示Erlang调用堆栈? [英] How to show Erlang call stack?
本文介绍了如何显示Erlang调用堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要调试外部系统中的某些模块。该模块具有公共功能 foo()
-我怎么知道从哪个foo()调用给定模块的位置(模块和函数名称)
?我的意思是调用堆栈。
I need to debug some module in foreign system. The module has public function foo()
- how can I know place (module and function name)
from which foo() given module was called? I mean stack of calls.
我无法停止系统,只要重新加载此模块即可完成所有工作(但带有一些调试信息)。
I cannot stop system, all work I can do by reload this module (but with some debug info).
-module(given).
-export(foo/0).
foo() ->
%% here is my debug - and
%% i need here(!) known about unknown_module:unknown_foo!
ok.
---
-module(unknown_module).
..
unknown_foo() ->
given:foo(). %% see above
推荐答案
这是一个简单的技巧:
Trace = try throw(42) catch 42 -> erlang:get_stacktrace() end,
erlang:display(Trace)
这篇关于如何显示Erlang调用堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文