diff --git a/fuzzer/Fuzzer.java b/fuzzer/Fuzzer.java index a91f0bbdf1915c27c292bdde45aabca90e23f46d..abb7b0338d41f48c87feee7b4a27856ee6c581cb 100644 --- a/fuzzer/Fuzzer.java +++ b/fuzzer/Fuzzer.java @@ -52,7 +52,7 @@ public class Fuzzer { // Current stack of instructions private static ArrayList<Instruction> instructionStack = new ArrayList<Instruction>(); // Max stack of instructions before resetting stack - private static final int MAX_STACK = 3; + private static final int MAX_STACK = 2; public static void main(String[] args) throws IOException { System.out.println(Instruction.getBNF()); diff --git a/fuzzer/Instruction.java b/fuzzer/Instruction.java index fffc4f009bbbed11bb8541c26e14ea9ea203b6e8..b7a722928f9214d31ac2de7a4c3abb17da25295e 100644 --- a/fuzzer/Instruction.java +++ b/fuzzer/Instruction.java @@ -142,14 +142,30 @@ public enum Instruction { cumProb = 0; for (Instruction instruction : MAX_ZERO_INSTRUCTIONS) { - cumProb += instruction.probability; + // Temporary stack where we add this loop's instruction + List<Instruction> tempStack = new ArrayList<Instruction>(instructionStack); + tempStack.add(instruction); + // If the probability has increased, find it and add to base prob, otherwise 0 + int probToAdd = 0; + if (pathwayProb.containsKey(tempStack)) { + probToAdd = pathwayProb.get(tempStack); + } + cumProb += instruction.probability + probToAdd; ZERO_CUML_PROB.add(cumProb); } ZERO_MAX_CUML_PROB = cumProb; cumProb = 0; for (Instruction instruction : MAX_ONE_INSTRUCTIONS) { - cumProb += instruction.probability; + // Temporary stack where we add this loop's instruction + List<Instruction> tempStack = new ArrayList<Instruction>(instructionStack); + tempStack.add(instruction); + // If the probability has increased, find it and add to base prob, otherwise 0 + int probToAdd = 0; + if (pathwayProb.containsKey(tempStack)) { + probToAdd = pathwayProb.get(tempStack); + } + cumProb += instruction.probability + probToAdd; ONE_CUML_PROB.add(cumProb); } ONE_MAX_CUML_PROB = cumProb;