Stacktrace in erlang tracer
Asked Answered
H

0

6

Is it possible to return a stacktrace in a trace? I'm using :dbg.tp/3 and :dbg.tracer/2 to get a trace along with the calling module. I tried caller function (see in docs: https://erlang.org/doc/apps/erts/match_spec.html) but it gives me the very next call from the stack (which is {:erl_eval, :do_apply, 6}), what I need is the first function that is defined in my project.

For context, handler function passed to tracer/2:

    handler_fun = fn {:trace, _pid, :call, {_m, _f, _a}, dump}, _ignored ->
      IO.puts(dump)
    end

and the tp call (for now I just use process dump that gives me the stack in binary, but I would like to get it in a form that I can interpret in code and not parse it):

:dbg.tp(module, :_, [{:_, [], [{:message, {:process_dump}}]}])

I'm open to using a different tool than tracing/dbg.

Headship answered 24/8, 2021 at 19:41 Comment(1)
Hey, have you found an answer to this by any chance?Headship

© 2022 - 2024 — McMap. All rights reserved.