Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show Erlang call stack?

Tags:

stack

erlang

call

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
like image 505
vinnitu Avatar asked Feb 12 '10 13:02

vinnitu


People also ask

What is current call stack?

In computer science, a call stack is a stack data structure that stores information about the active subroutines of a computer program. This kind of stack is also known as an execution stack, program stack, control stack, run-time stack, or machine stack, and is often shortened to just "the stack".

What is the difference between call stack and stack trace?

A call stack is typically "the current stack of operations" - i.e. while it's running. A stack trace is typically a copy of the call stack which is logged at some sort of failure, e.g. an exception.

What is call stack in C#?

A call stack, in C#, is the list of names of methods called at run time from the beginning of a program until the execution of the current statement. A call stack is mainly intended to keep track of the point to which each active subroutine should return control when it finishes executing.


1 Answers

Here's a simple trick:

Trace = try throw(42) catch 42 -> erlang:get_stacktrace() end,
erlang:display(Trace)
like image 158
RichardC Avatar answered Nov 03 '22 01:11

RichardC