From 2acf3ef301aea1c033859fdb733d29145b8b6c01 Mon Sep 17 00:00:00 2001 From: Alwin Berger Date: Tue, 21 Feb 2023 19:22:50 +0100 Subject: [PATCH] add plotting to snakefile --- fuzzers/FRET/benchmark/Snakefile | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/fuzzers/FRET/benchmark/Snakefile b/fuzzers/FRET/benchmark/Snakefile index 13bc820289..ec38482aaa 100644 --- a/fuzzers/FRET/benchmark/Snakefile +++ b/fuzzers/FRET/benchmark/Snakefile @@ -1,6 +1,12 @@ import csv def_flags="--no-default-features --features std,snapshot_restore,singlecore" +rule build_showmap: + output: + directory("bins/target_showmap") + shell: + "cargo build --target-dir {output} {def_flags},systemstate" + rule build_random: output: directory("bins/target_random") @@ -74,6 +80,58 @@ rule run_bench: script="export FUZZ_RANDOM=1\n"+script shell(script) +rule run_showmap: + input: + "build/{target}.elf", + "bins/target_showmap", + "timedump/{fuzzer}/{target}.{num}.case" + output: + "timedump/{fuzzer}/{target}.{num}.trace.ron" + run: + with open('target_symbols.csv') as csvfile: + reader = csv.DictReader(csvfile) + line = next((x for x in reader if x['kernel']==wildcards.target), None) + if line == None: + return False + kernel=line['kernel'] + fuzz_main=line['main_function'] + fuzz_input=line['input_symbol'] + fuzz_len=line['input_size'] + bkp=line['return_function'] + script=""" + mkdir -p $(dirname {output}) + export KERNEL=$(pwd)/{input[0]} + export FUZZ_MAIN={fuzz_main} + export FUZZ_INPUT={fuzz_input} + export FUZZ_INPUT_LEN={fuzz_len} + export BREAKPOINT={bkp} + export TRACE_DUMP=$(pwd)/{output} + export FUZZER=$(pwd)/{input[1]}/debug/fret + export DO_SHOWMAP=$(pwd)/{input[2]} + set +e + ../fuzzer.sh + exit 0 + """ + if wildcards.fuzzer == 'random': + script="export FUZZ_RANDOM=1\n"+script + shell(script) + +rule tarnsform_trace: + input: + "timedump/{fuzzer}/{target}.{num}.trace.ron" + output: + "timedump/{fuzzer}/{target}.{num}.trace.csv" + shell: + "$(pwd)/../../../../state2gantt/target/debug/state2gantt {input} > {output[0]}" + +rule trace2gantt: + input: + "timedump/{fuzzer}/{target}.{num}.trace.csv" + output: + "timedump/{fuzzer}/{target}.{num}.trace.csv.png" + shell: + "Rscript --vanilla $(pwd)/../../../../state2gantt/gantt.R {input}" + rule all_bins: input: "bins/target_random",