A VS Code extension that generates and displays function call graphs for Rust code, with special support for Verus-verified functions. This extension uses the same tools and analysis as the GitHub workflow to provide accurate call graph visualization.
- Context Menu Integration: Right-click on any function in a Rust file to generate its call graph
- Real Call Graph Analysis: Uses
rust-analyzer-test
and SCIP (Symbol Code Intelligence Protocol) data for accurate analysis - Interactive Visualization: View graphs in an integrated webview with zoom and pan controls
- Verus Function Support: Specifically designed to work with Verus-verified functions and show dependency paths to libsignal functions
- Fast Performance: Uses pre-built binaries and pre-generated SCIP indices for instant graph generation
The extension requires the following tools to be installed on your system:
-
Rust and Cargo - Required for Rust projects
# Install via rustup curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
curl - For downloading pre-built binaries
# Most systems have this pre-installed curl --version
-
Graphviz - For rendering DOT files to SVG/PNG
# Ubuntu/Debian sudo apt-get install graphviz # macOS (with Homebrew) brew install graphviz # Windows (with Chocolatey) choco install graphviz
You can verify all dependencies are correctly installed by running:
cargo --version
curl --version
dot -V
Important: This extension requires a pre-generated SCIP index file named index_scip.json
in your project root.
To generate this file, run one of these commands in your project root:
# Using rust-analyzer:
rust-analyzer scip . && scip print --json index.scip > index_scip.json
# Using verus-analyzer:
verus-analyzer scip . && scip print --json index.scip > index_scip.json
The SCIP index generation can take several minutes for large projects, which is why we require it to be pre-generated rather than generating it on-demand. Here are some tools to install rust-analyzer/verus-analyzer/scip and also to generate the json file.
The extension follows the same process as the GitHub workflow:
- Tool Setup: Downloads pre-built
rust-analyzer-test
binaries (cached after first download) - SCIP Data: Uses the pre-generated
index_scip.json
file from your project root - Symbol Mapping: Maps function names to their SCIP symbols using the same algorithm as the Python scripts
- Graph Generation: Uses the
generate_function_subgraph_dot
tool to create DOT format graphs - Visualization: Converts to SVG and displays in an interactive webview
- Open a Rust file in VS Code
- Place your cursor on a function name
- Right-click to open the context menu
- Select "Display Call Graph"
- Wait for the graph to be generated and displayed
The generated graphs show:
- Function Dependencies: How functions call each other
- Depth Analysis: Up to 5 levels of function calls (configurable)
- Source Filtering: Filters to show paths to libsignal functions
- Interactive Controls: Zoom, pan, and fit-to-window functionality
The extension uses the following default settings:
- Depth: 5 levels of function calls
- Filter:
none
(no filtering by default) - Format: SVG for best quality visualization
- Include Callers:
false
(don't show functions that call the target by default) - Include Callees:
true
(show functions called by the target by default)
These settings can be customized in VS Code settings under "Call Graph Visualizer".
You can customize the graph generation behavior by modifying these VS Code settings:
- Open Settings:
Ctrl/Cmd + ,
orFile > Preferences > Settings
- Search for: "Call Graph Visualizer"
- Configure:
- Depth: Maximum levels of function calls to analyze (1-10)
- Filter Sources: Choose
none
orfilter-non-libsignal-sources
- Output Format: Choose between
svg
,png
, ordot
- Include Callers: Show functions that call the target function
- Include Callees: Show functions called by the target function
Alternatively, add these to your settings.json
:
{
"callGraphVisualizer.depth": 5,
"callGraphVisualizer.filterSources": "none",
"callGraphVisualizer.outputFormat": "svg",
"callGraphVisualizer.includeCallers": false,
"callGraphVisualizer.includeCallees": true
}
- "Tool not found" errors: Ensure all required dependencies are installed and available in your PATH
- "No symbol found" errors: The function might not be in the SCIP analysis data
- Build failures: Make sure you have a working Rust toolchain and internet access
The extension logs detailed information to the VS Code console. To view:
- Open VS Code Developer Tools (
Help > Toggle Developer Tools
) - Check the Console tab for debug output
- Look for messages from the Call Graph Visualizer extension
The extension consists of several components:
- Extension Host (
extension.ts
): Main VS Code integration and command handling - Graph Generator (
graphGenerator.ts
): Core logic for setting up tools and generating graphs - Rust Analyzer Client (
rustAnalyzer.ts
): Helper for Rust code analysis (legacy, kept for compatibility)
The extension automatically downloads and builds:
- rust-analyzer-test - Contains the graph generation tool
- SCIP analysis data for libsignal dependencies
Function Name → SCIP Symbol Mapping → Graph Tool → DOT File → SVG → Webview
To develop or modify this extension:
- Clone the repository
- Install dependencies:
npm install
- Open in VS Code and press F5 to launch in debug mode
- Make changes and test with the development instance
npm run compile # Compile TypeScript
npm run package # Create production build
This extension is part of the curve25519-dalek project. Please follow the project's contribution guidelines when submitting changes.
This extension is licensed under the same terms as the curve25519-dalek project.