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
4条答案
按热度按时间rjzwgtxy1#
这里有一个简单的技巧:
cwdobuhd2#
This might work:
Except that it doesn't work for tail calls. For example, given these two functions:
I get these results:
That is, I can only see
bar
, sincefoo
's call frame has been left already whenwhere_am_i
is called.4bbkushb3#
self()可以被任何其他pid代替(rpc:pinfo甚至可以和远程procs一起工作)。2如果你甚至不能修改源或光束,这会很有帮助。
g52tjvyc4#
下面是我的代码:
列表是系统中的自定义模块。请使用您的foo模块。