Suppose I have a julia script, in which many functions are called. There might be even be nested calling. Namely, the main function calls function A, which calls function B, which in turn calls function C.
How can get a summary of these call relationships?
profiling is the easiest way here. I would recommend ProfileView.jl which will give you nice flamegraphs
Out of curiosity, is there any function or macro that when called in a certain place returns the call stack as a vector or similar?
Might not be exactly what you are after, but my package TraceFuns.jl allows you to see which functions get called from a specific top-level call.
2 Likes
You might be looking for stacktrace()
:
julia> stacktrace()
14-element Vector{Base.StackTraces.StackFrame}:
top-level scope at REPL[10]:1
eval at boot.jl:383 [inlined]
eval_user_input(ast::Any, backend::REPL.REPLBackend, mod::Module) at REPL.jl:150
repl_backend_loop(backend::REPL.REPLBackend, get_module::Function) at REPL.jl:246
start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function) at REPL.jl:231
kwcall(::NamedTuple, ::typeof(REPL.start_repl_backend), backend::REPL.REPLBackend, consumer::Any) at REPL.jl:228
run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any) at REPL.jl:389
run_repl(repl::REPL.AbstractREPL, consumer::Any) at REPL.jl:375
(::Base.var"#1013#1015"{Bool, Bool, Bool})(REPL::Module) at client.jl:432
#invokelatest#2 at essentials.jl:887 [inlined]
invokelatest at essentials.jl:884 [inlined]
run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool) at client.jl:416
exec_options(opts::Base.JLOptions) at client.jl:333
_start() at client.jl:552