This repository contains the Rust implementation of the PCG Analysis.
For more information about the PCG model, please checkout our OOPSLA 2025 paper.
The PCG analysis can be easily included in Rust projects as a Cargo dependency.
The analysis is not available on crates.io (yet); the easiest way to include it
in your project is to include it as a git repository dependency in your
Cargo.toml as described
here.
Note that our library interfaces with the Rust compiler APIs and therefore
requires that the project it is included in uses a nightly version of the Rust
compiler (this is typically specified via a rust-toolchain file in the parent
project). Although the compiler APIs in nightly Rust versions are unstable, our
implementation supports multiple versions by using conditional compilation based
on the compiler version. If you find that the library fails to compile for a
particular nightly release, please file an
issue.
We provide a UI for generating debug visualizations for the PCG. You can see the visualizations for some simple example programs here: https://prusti.github.io/pcg/
We also provide a simple webservice where you can upload a Rust file and view the resulting PCGs: https://pcg.fly.dev.
If you want to generate and visualize PCGs on your own machine, follow the instructions below...
The pcg-bin folder contains a binary can be used to run the PCG analysis on
all functions within a Rust source file and (optionally) produce visualizations
of the analysis outputs that can be viewed via a web interface.
To run the binary on all functions in a Rust source file:
cargo run [FILENAME].rs
To generate visualization output, set the PCG_VISUALIZATION environment
variable to true when running the pcg-bin, e.g.:
PCG_VISUALIZATION=true cargo run [FILENAME.rs]
To view the output, you need to run the visualization server, by running:
cd visualization && ./serve
Then, you can view the output graphs via the web interface at
http://localhost:8080.
Once the server is running, you can keep it running and analyze other files
(e.g. PCG_VISUALIZATION=true cargo run [FILENAME2].rs). Just
refresh the page to see updated results.