add tool for graph visualization

This commit is contained in:
Alwin Berger 2023-02-10 14:01:34 +01:00
parent 92bdab266d
commit 9dc3f3c065
4 changed files with 1476 additions and 0 deletions

4
graph2viz/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.csv
*.png
*.pdf
target

1435
graph2viz/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

14
graph2viz/Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[package]
name = "graph2viz"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
fret = { path = "../LibAFL/fuzzers/FRET" }
serde = { version = "1.0", default-features = false, features = ["alloc"] } # serialization lib
hashbrown = { version = "0.12", features = ["serde", "ahash-compile-time-rng"] } # A faster hashmap, nostd compatible
petgraph = { version="0.6.0", features = ["serde-1"] }
ron = "0.7" # write serialized data - including hashmaps
rand = "0.5"

23
graph2viz/src/main.rs Normal file
View File

@ -0,0 +1,23 @@
use std::path::PathBuf;
use std::{env,fs};
use fret::systemstate::graph::SysGraphFeedbackState;
use petgraph::dot::{Dot, Config};
fn main() {
let args : Vec<String> = env::args().collect();
let path_a = PathBuf::from(args[1].clone());
let raw_a = fs::read(path_a).expect("Can not read dumped traces b");
// let path_b = PathBuf::from(args[2].clone());
let feedbackstate : SysGraphFeedbackState = ron::from_str(&String::from_utf8_lossy(&raw_a)).expect("Can not parse HashMap");
let newgraph = feedbackstate.graph.map(
|_, n| n.get_taskname(),
// |_, n| format!("{} {:?}",n.get_taskname(),n.get_input_counts().iter().min().unwrap_or(&0)),
|_, e| e,
);
// let tempg = format!("{:?}",Dot::with_config(&newgraph, &[Config::EdgeNoLabel]));
println!("{:?}",Dot::with_config(&newgraph, &[Config::EdgeNoLabel]));
}