plotting + minia fix

This commit is contained in:
Alwin Berger 2025-02-13 16:38:29 +01:00
parent 4d29735354
commit 7d1e4fd171
3 changed files with 28 additions and 11 deletions

View File

@ -8,16 +8,18 @@ args = commandArgs(trailingOnly=TRUE)
if (length(args) > 0) {
sqlite_file <- args[1]
con <- dbConnect(RSQLite::SQLite(), sqlite_file)
} else {
stop("No sqlite file provided")
print("No sqlite file provided, assume defaults")
args = c("bench.sqlite", "remote")
sqlite_file <- args[1]
con <- dbConnect(RSQLite::SQLite(), sqlite_file)
}
combos <- dbGetQuery(con, "SELECT * FROM combos")
casenames <- dbGetQuery(con, "SELECT casename FROM combos GROUP BY casename")
toolnames <- dbGetQuery(con, "SELECT toolname FROM combos GROUP BY toolname")
ml2lines <- function(ml) {
ml2lines <- function(ml, casename) {
lines = NULL
last = 0
for (i in seq_len(dim(ml)[1])) {
@ -28,10 +30,22 @@ ml2lines <- function(ml) {
return(lines)
}
draw_plot <- function(data) {
draw_plot <- function(data, casename) {
MY_COLORS <- c("green", "blue", "red", "magenta", "orange", "cyan", "pink", "gray", "orange", "black", "yellow","brown")
LEGEND_POS="bottomright"
ISNS_PER_US = (10**3)/(2**5)
# Convert timestamp from microseconds to hours
for (n in seq_len(length(data))) {
data[[n]]$timestamp <- data[[n]]$timestamp / 3600000
data[[n]]$min <- data[[n]]$min / ISNS_PER_US
data[[n]]$max <- data[[n]]$max / ISNS_PER_US
data[[n]]$median <- data[[n]]$median / ISNS_PER_US
data[[n]]$mean <- data[[n]]$mean / ISNS_PER_US
data[[n]]$sdiv <- data[[n]]$sdiv / ISNS_PER_US
}
# draw limits
max_x <- max(sapply(data, function(tbl) max(tbl$timestamp, na.rm = TRUE)))
max_y <- max(sapply(data, function(tbl) max(tbl$max, na.rm = TRUE)))
@ -40,10 +54,10 @@ draw_plot <- function(data) {
# plot setup
h_ = 380
w_ = h_*4/3
png(file=sprintf("test.png"), width=w_, height=h_)
png(file=sprintf("%s/sql_%s.png", args[2],casename), width=w_, height=h_)
par(mar=c(4,4,1,1))
par(oma=c(0,0,0,0))
plot(c(0,max_x),c(min_y,max_y), col='white', xlab="Time [h]", ylab="WCRT estimate [insn]", pch='.')
plot(c(0,max_x),c(min_y,max_y), col='white', xlab="Time [h]", ylab="WCRT estimate [us]", pch='.')
# plot data
for (n in seq_len(length(data))) {
@ -64,8 +78,9 @@ draw_plot <- function(data) {
dev.off()
}
for (c in casenames) {
tables <- dbGetQuery(con, sprintf("SELECT * FROM combos WHERE casename == '%s'", c))
print(casenames[['casename']])
for (cn in casenames[['casename']]) {
tables <- dbGetQuery(con, sprintf("SELECT * FROM combos WHERE casename == '%s'", cn[[1]]))
table_list <- list()
for (row in 1:nrow(tables)) {
table_name <- tables[row, 'fullname']
@ -73,7 +88,7 @@ for (c in casenames) {
table_data <- dbGetQuery(con, sprintf("SELECT * FROM '%s'", table_name))
table_list[[tool_name]] <- table_data
}
draw_plot(table_list)
draw_plot(table_list, cn[[1]])
}
dbDisconnect(con)

View File

@ -281,10 +281,11 @@ let run_client = |state: Option<_>, mut mgr, _core_id| {
unsafe {
#[cfg(feature = "fuzz_int")]
{
libafl_interrupt_offsets=[[0;MAX_NUM_INTERRUPT];NUM_INTERRUPT_SOURCES];
for &c in &interrupt_config {
let (i,_) = c;
let name = format!("isr_{}_times",i);
let input_bytes = input.parts_by_name(&name).next().map(|x| x.1.bytes()).unwrap_or(&[0u8; MAX_NUM_INTERRUPT*4]);
let input_bytes = input.parts_by_name(&name).next().map(|x| x.1.bytes()).unwrap_or(&[]);
let t = input_bytes_to_interrupt_times(input_bytes, c);
for j in 0..t.len() {libafl_interrupt_offsets[i][j]=t[j];}
libafl_num_interrupts[i]=t.len();

View File

@ -118,11 +118,12 @@ pub fn input_bytes_to_interrupt_times(buf: &[u8], config: (usize,u32)) -> Vec<u3
// obey the minimum inter arrival time while maintaining the sort
for i in 0..ret.len() {
if ret[i]==0 {continue;}
for j in i+1..ret.len()-1 {
for j in i+1..ret.len() {
if ret[j]-ret[i] < config.1 * QEMU_ISNS_PER_USEC {
// ret[j] = u32::saturating_add(ret[i],config.1 * QEMU_ISNS_PER_USEC);
ret[j] = 0; // remove the interrupt
ret.sort_unstable();
break;
} else {break;}
}
}