add tool to generate simple gantt charts

This commit is contained in:
Alwin Berger 2023-02-07 14:55:28 +01:00
parent 87220ca9a0
commit 92bdab266d
9 changed files with 1522 additions and 0 deletions

4
state2gantt/.gitignore vendored Normal file
View File

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

1433
state2gantt/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

14
state2gantt/Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[package]
name = "state2gantt"
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"

4
state2gantt/Makefile Normal file
View File

@ -0,0 +1,4 @@
all(%):
target/debug/state2gantt $%_afl.ron > $%_afl.csv
target/debug/state2gantt $%_state.ron > $%_state.csv
target/debug/state2gantt $%_random.ron > $%_random.csv

44
state2gantt/gantt.R Normal file
View File

@ -0,0 +1,44 @@
args = commandArgs(trailingOnly=TRUE)
if (length(args)==0) {
filename="~/code/FRET/state2gantt/trace.csv"
} else {
filename=args[1]
}
trace <- read.csv(filename)
task_ids = unique(trace[[3]]) # assume this has descending prio order
prio_from_name <- function(t) {
1 + length(task_ids) - Position(function(y) y==t, task_ids)
}
trace[[3]]=sapply(trace[[3]], prio_from_name )
width = 710
height = (9/16) * width
if (length(args)>0) { png(file=sprintf("%s.png",filename), width=width, height=height) }
# prepare an empty plot
plot(c(trace[[2]][1],trace[[2]][length(trace[[2]])]),
c(0,length(task_ids)),
col = "white", xlab = "", ylab = "")
# draw all segments
segments(x0 = trace$start,
y0 = trace$name,
x1 = trace$end,
y1 = trace$name,
lwd = 3)
highlight_prio <- function(p,col) {
interest = trace[which(trace[[3]] == p),]
segments(x0 = interest$start,
y0 = interest$name,
x1 = interest$end,
y1 = interest$name,
lwd = 3,
col = col)
}
highlight_prio(1,"red")
#highlight_prio(2,"green")
if (length(args)>0) { dev.off() }

20
state2gantt/src/main.rs Normal file
View File

@ -0,0 +1,20 @@
use std::collections::HashMap;
use std::path::PathBuf;
use std::{env,fs};
use fret::systemstate::RefinedFreeRTOSSystemState;
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 trace : Vec<RefinedFreeRTOSSystemState> = ron::from_str(&String::from_utf8_lossy(&raw_a)).expect("Can not parse HashMap");
println!("start,end,name");
for s in trace {
if s.current_task.task_name == "Tmr Svc" {continue;}
println!("{},{},{}",s.start_tick,s.end_tick,s.current_task.task_name);
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long