rust-callgraph
rust-callgraph copied to clipboard
Which functions call each other in your rust crate? Static call graph analysis.
- rust-callgraph
Computes the callgraph of rust programs.
Based on [[https://github.com/nrc/callgraph.rs]], updated to be compilable with the current rustc API.
- Usage #+BEGIN_SRC sh cargo +nightly r -- example_code/fun_method.rs --sysroot /usr/local/ #+END_SRC
Adapt the path of the sysroot, e. g. ~/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/~.
The arguments are passed to a call to rustc.
- How it works
Using the rustc interface, run the compiler until after analysis stage, walk the expanded syntax tree and remember function and method definitions and resolved calls.
- Features Extracts all kinds of calls:
- function defs
- struct associated impl methods
- trait method declarations
- trait method default impl
- trait method implementations
- statically dispatched calls
- dynamically dispatched calls
Missing features:
- requires a nightly toolchain (this will not change since the rustc interface will not be stabilized)
- runs a single rustc commandline, no support to build a whole cargo project
- rudimentary debugging output, no real output