Is there a library that I can use to chart function calls?

I’m working in a program that has deeply nested functions. It is becoming difficult to trace what is actually going on in the code. I’m wondering if there is a library that could print out something that shows which function a function calls and its functions.

For example if I have modules A, B, and C each with functions a, b, and c respectively and A.a/0 calls B.b/0 which calls C.c/0 I would like to have some output like the following

A.a
-> B.b
-> C.c

I’ve found a few libraries that do tracing at runtime but I’d like to be able to just do something like SomeLibrary.trace_function(mod, fun, arity).

1 Like

Not currently, but you could perhaps build something on top of mix xref callers.

3 Likes

Take a look at the gabiz/tracer call graph example.

Is that what you need?

4 Likes

This actually does look like it might work for my needs. I’ll dig into it in a bit and see. Ideally I was looking for something that would do static analysis of the mods/funs sort of like dialyzer can tell what a function can/should return and what calls those functions. After I get some time to check this out I’ll respond with if it works. Thank you

1 Like

@bryanhuntesl this seems to do what I need. The output is a bit more verbose than I expected but that is better than not enough. I ended up with over 1k lines of output from the function. I may fork the library and add some filtering over the weekend if I get time. Most of my output was from ecto and logger. Thanks again for the recommendation.

2 Likes