You can use Process.info(self(), :current_stacktrace)
to get the current stacktrace (and the calling function should be there), but this is generally considered a debugging utility, not something to be used in production.
Additionally, be aware that tail calls don’t produce stack entries, so in a code like this:
def foo(), do: bar()
def bar(), do: Process.info(self(), :current_stacktrace)
The stacktrace information won’t include foo()
.