diff --git a/fuzzer/Fuzzer.java b/fuzzer/Fuzzer.java index 7212839891875204a923a8b879e6448d5eb89f9d..dca1a02bebdc7485247e22114831fe20769990ab 100644 --- a/fuzzer/Fuzzer.java +++ b/fuzzer/Fuzzer.java @@ -122,22 +122,22 @@ public class Fuzzer { switch (runCount){ case 0: // Test with stack full - return generateInput(true, INSTRUCTION_MAX, MAX_STACK_SIZE, false, false); + return generateInput(true, INSTRUCTION_MAX, MAX_STACK_SIZE, true, false); case 1: // Test with stack full - return generateInput(true, INSTRUCTION_MAX, MAX_STACK_SIZE - 1, false, false); + return generateInput(true, INSTRUCTION_MAX, MAX_STACK_SIZE - 1, true, false); case 3: // Run static tests and empty stack - return getStaticTests() + generateInput(true, INSTRUCTION_MAX, 0, false, false); + return getStaticTests() + generateInput(true, INSTRUCTION_MAX, 0, true, false); case 4: // Test with dynamic probability return generateInput(true, INSTRUCTION_MAX, 0, true, false); case 5: // Test with long var names - return generateInput(true, INSTRUCTION_MAX, 0, false, true); + return generateInput(true, INSTRUCTION_MAX, 0, true, true); } // Run from random stack - return generateInput(true, INSTRUCTION_MAX, 0, false, false); + return generateInput(true, INSTRUCTION_MAX, 0, true, false); } /* @@ -209,6 +209,7 @@ public class Fuzzer { // System.out.println("map: " + key + " " + value); //} + } /*** diff --git a/fuzzer/Instruction.java b/fuzzer/Instruction.java index fffc4f009bbbed11bb8541c26e14ea9ea203b6e8..ea2185779502f54df5a0f039d8e565115a47ff3b 100644 --- a/fuzzer/Instruction.java +++ b/fuzzer/Instruction.java @@ -10,8 +10,8 @@ public enum Instruction { SUB("-",new OperandType[]{}, 2, -1, 2), MULT("*",new OperandType[]{}, 2, -1, 2), DIV("/",new OperandType[]{}, 2, -1, 2), - PUSH("push",new OperandType[]{OperandType.STRING}, 0, 1, 3), - POP("pop",new OperandType[]{}, 1, -1, 4), + PUSH("push",new OperandType[]{OperandType.STRING}, 0, 1, 4), + POP("pop",new OperandType[]{}, 1, -1, 3), LOAD("load",new OperandType[]{OperandType.STRING}, 0, 1, 1), //Note. Check variable existence REM("remove",new OperandType[]{OperandType.STRING}, 0, 0, 1), //Note. Check variable existence STORE("store",new OperandType[]{OperandType.STRING}, 1, -1, 1), @@ -86,6 +86,7 @@ public enum Instruction { Map<List<Instruction>, Integer> pathwayProb) { // Check if cumlative probabilities have been calculated checkProbability(instructionStack, pathwayProb); + System.out.println(max); ArrayList<Instruction> instructions; ArrayList<Integer> instCumlProbs; @@ -142,14 +143,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;