Skip to content

Which functions call each other in your rust crate? Static call graph analysis.

License

Notifications You must be signed in to change notification settings

heinzelotto/rust-callgraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-callgraph

Computes the callgraph of rust programs.

Works with Rustc nightly 1.82.0 (`nightly-2024-08-07`). Works with full Cargo projects.

Installation

export RUSTFLAGS="-L $RUSTUP_HOME/toolchains/nightly-2024-08-07-x86_64-unknown-linux-gnu/lib"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$RUSTUP_HOME/toolchains/nightly-2024-08-07-x86_64-unknown-linux-gnu/lib"
cargo install --debug --locked --path . --force

Usage

cd ./example_code
cargo callgraph # To run on a full Cargo project
callgraph src/main.rs # To run on a single file

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)
  • rudimentary debugging output, no real output

About

Which functions call each other in your rust crate? Static call graph analysis.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages