state2gantt + LIBAFL_EDGES_MAP_SIZE_IN_USE

This commit is contained in:
Alwin Berger 2024-09-02 15:49:53 +02:00
parent 861d380a96
commit cc61262037
7 changed files with 1527 additions and 419 deletions

View File

@ -67,6 +67,7 @@
export LIBAFL_QEMU_DIR=$(pwd)/qemu-libafl-bridge export LIBAFL_QEMU_DIR=$(pwd)/qemu-libafl-bridge
export CUSTOM_QEMU_NO_BUILD=1 export CUSTOM_QEMU_NO_BUILD=1
export CUSTOM_QEMU_NO_CONFIGURE=1 export CUSTOM_QEMU_NO_CONFIGURE=1
export LIBAFL_EDGES_MAP_SIZE_IN_USE=1048576
# export EMULATION_MODE=systemmode # export EMULATION_MODE=systemmode
# export CPU_TARGET=arm # export CPU_TARGET=arm
# export CROSS_CC=arm-none-eabi-gcc # export CROSS_CC=arm-none-eabi-gcc

905
graph2viz/Cargo.lock generated

File diff suppressed because it is too large Load Diff

905
state2gantt/Cargo.lock generated

File diff suppressed because it is too large Load Diff

7
state2gantt/driver.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
if [ -z "$1" ]; then exit 1; fi
OFILE_A="$(dirname "$1")/$(basename -s .trace.ron "$1")_a.csv"
OFILE_B="$(dirname "$1")/$(basename -s .trace.ron "$1")_b.csv"
~/code/FRET/state2gantt/target/debug/state2gantt $1 "$OFILE_A" "$OFILE_B"
# ~/code/FRET/state2gantt/plot.r "$OFILE_A" html
~/code/FRET/state2gantt/plot_response.r "$OFILE_A" "$OFILE_B" html

10
state2gantt/plot.r Normal file → Executable file
View File

@ -1,9 +1,13 @@
#!/usr/bin/env Rscript
# Load necessary libraries # Load necessary libraries
library(ggplot2) library(ggplot2)
library(readr) library(readr)
library(dplyr) library(dplyr)
library(plotly) library(plotly)
QEMU_SHIFT<-5
TIMESCALE<-1000000
# Function to create a Gantt chart with dots on short segments # Function to create a Gantt chart with dots on short segments
create_gantt_chart <- function(csv_file, MIN_WIDTH, output_format = NULL) { create_gantt_chart <- function(csv_file, MIN_WIDTH, output_format = NULL) {
# Read the CSV file # Read the CSV file
@ -11,8 +15,8 @@ create_gantt_chart <- function(csv_file, MIN_WIDTH, output_format = NULL) {
# Ensure start and end columns are treated as integers # Ensure start and end columns are treated as integers
df <- df %>% df <- df %>%
mutate(start = as.integer(start), mutate(start = (as.integer(start) * 2**QEMU_SHIFT)/TIMESCALE,
end = as.integer(end)) end = (as.integer(end) * 2**QEMU_SHIFT)/TIMESCALE)
# Calculate the segment width # Calculate the segment width
df <- df %>% df <- df %>%
@ -65,5 +69,5 @@ if (length(args) < 1 || length(args) > 2) {
} }
} }
MIN_WIDTH <- 100 # You can set your desired minimum width here MIN_WIDTH <- 500 # You can set your desired minimum width here
create_gantt_chart(csv_file, MIN_WIDTH, output_format) create_gantt_chart(csv_file, MIN_WIDTH, output_format)

29
state2gantt/plot_gantt.py Normal file
View File

@ -0,0 +1,29 @@
import plotly.figure_factory as ff
import plotly.express as px
import pandas as pd
import sys
def create_gantt_chart(csv_file):
# Read the CSV file
df = pd.read_csv(csv_file)
df.sort_values(by='prio', inplace=True, ascending=False)
# Prepare the data for the Gantt chart
gantt_data = [
dict(Task=row['name'], Start=row['start'], Finish=row['end'], Priority=row['prio'])
for _, row in df.iterrows()
]
# Create the Gantt chart
fig = ff.create_gantt(gantt_data, group_tasks=True)
# Show the Gantt chart
fig.write_html("plot.html")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python script.py <csv_file>")
sys.exit(1)
csv_file = sys.argv[1]
create_gantt_chart(csv_file)

89
state2gantt/plot_response.r Executable file
View File

@ -0,0 +1,89 @@
#!/usr/bin/env Rscript
# Load necessary libraries
library(ggplot2)
library(readr)
library(dplyr)
library(plotly)
QEMU_SHIFT<-5
TIMESCALE<-1000000
# Function to create a Gantt chart with dots on short segments
create_gantt_chart <- function(csv_file_a, csv_file_b, MIN_WIDTH, output_format = NULL) {
# Read the CSV file
df <- read_csv(csv_file_a)
# df_b <- read_csv(csv_file_b)
df_b <- read_csv(csv_file_b, col_types = cols(.default = "d", name = col_character()))
# df <- df %>% bind_rows(df_b)
# Ensure start and end columns are treated as integers
df <- df %>%
mutate(start = (as.integer(start) * 2**QEMU_SHIFT)/TIMESCALE,
end = (as.integer(end) * 2**QEMU_SHIFT)/TIMESCALE)
df_b <- df_b %>%
mutate(start = (as.integer(start) * 2**QEMU_SHIFT)/TIMESCALE,
end = (as.integer(end) * 2**QEMU_SHIFT)/TIMESCALE)
# Calculate the segment width
df <- df %>%
mutate(width = end - start)
# Sort the DataFrame by 'prio' column in descending order
df <- df %>%
arrange(prio)
# Create the Gantt chart with ggplot2
p <- ggplot(df, aes(x = start, xend = end, y = reorder(name, prio), yend = name)) +
geom_segment(aes(color = factor(prio)), size = 6) +
labs(title = "Gantt Chart", x = "Time Step", y = "Task", color = "Priority") +
theme_minimal()
# Plot Ranges
p <- p + geom_segment(data = df_b, aes(color = factor(prio)), size = 1)
p <- p + geom_point(data = df_b,
aes(x = end, y = name),
color = "blue", size = 2)
# Add dots on segments shorter than MIN_WIDTH
p <- p + geom_point(data = df %>% filter(width < MIN_WIDTH),
aes(x = start, y = name),
color = "red", size = 1)
# Convert the ggplot object to a plotly object for interactivity
p_interactive <- ggplotly(p)
# Handle output format
if (!is.null(output_format)) {
output_file <- sub("\\.csv$", paste0(".", output_format), csv_file_a)
if (output_format == "html") {
htmlwidgets::saveWidget(p_interactive, output_file)
} else if (output_format == "png") {
ggsave(output_file, plot = p, device = "png")
} else {
stop("Invalid output format. Use 'html' or 'png'.")
}
} else {
# Print the interactive Gantt chart
print(p_interactive)
}
}
# Main execution
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2 || length(args) > 3) {
stop("Usage: Rscript script.R <csv_file> <csv_file> [output_format]")
} else {
csv_file_a <- args[1]
csv_file_b <- args[2]
if (length(args) == 3) {
output_format <- args[3]
} else {
output_format <- NULL
}
}
MIN_WIDTH <- 500 # You can set your desired minimum width here
create_gantt_chart(csv_file_a, csv_file_b, MIN_WIDTH, output_format)