i need to debug some module in foreign system, 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.
PS: I cannot stop system, all work I can do by reload this module (but with som 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
Here's a simple trick:
Here is my code for doing this:
Lists is a custom module in the system. Use your foo module instead.
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.self() can be replaced by any other pid (rpc:pinfo should even work with remote procs). This helps if you cannot even modify the source or beam.