[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22681 - in monkey/branches/MonkeyBacktracking/monkey/Monke
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22681 - in monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator: . src/org/monkey/comparator src/org/monkey/comparator/testing src/org/monkey/comparator/testing/refs |
Date: |
Sun, 15 Jul 2012 12:41:42 +0200 |
Author: safey
Date: 2012-07-15 12:41:42 +0200 (Sun, 15 Jul 2012)
New Revision: 22681
Added:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/.fatjar
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/ValueClassifier.java
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/refs/monkey_different_and_longer_history.xml
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/refs/monkey_different_history.xml
Modified:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/comparator.properties
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/mcomparator.jar
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/Constants.java
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/StackTraceFeature.java
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/ComparatorTest.java
Log:
updates
Added: monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/.fatjar
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/.fatjar
(rev 0)
+++ monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/.fatjar
2012-07-15 10:41:42 UTC (rev 22681)
@@ -0,0 +1,14 @@
+#Fat Jar Configuration File
+#Sun Jul 15 12:40:42 CEST 2012
+onejar.license.required=true
+manifest.classpath=
+manifest.removesigners=true
+onejar.checkbox=false
+jarname=mcomparator.jar
+manifest.mergeall=true
+manifest.mainclass=org.monkey.comparator.MonkeyComparator
+manifest.file=<createnew>
+jarname.isextern=false
+onejar.expand=
+excludes=
+includes=
Modified:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/comparator.properties
===================================================================
---
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/comparator.properties
2012-07-15 10:34:37 UTC (rev 22680)
+++
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/comparator.properties
2012-07-15 10:41:42 UTC (rev 22681)
@@ -1,4 +1,8 @@
+MAX_INT=2147483647
+MIN_INT=-2147483647
+ENABLE_VALUE_CLASSES=false
LINE_NUMBER_DIFFERENCE_THRESHOLD=10
+
# Features' scores
GENERAL_PROPERTIES_FEATURE_SCORE=100
STACK_TRACE_FEATURE_SCORE=50
Modified:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/mcomparator.jar
===================================================================
(Binary files differ)
Modified:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/Constants.java
===================================================================
---
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/Constants.java
2012-07-15 10:34:37 UTC (rev 22680)
+++
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/Constants.java
2012-07-15 10:41:42 UTC (rev 22681)
@@ -6,6 +6,9 @@
import java.util.Properties;
public abstract class Constants {
+ public static int MAX_INT;
+ public static int MIN_INT;
+ public static boolean ENABLE_VALUE_CLASSES;
public static int LINE_NUMBER_DIFFERENCE_THRESHOLD;
/* Features' scores */
@@ -33,6 +36,9 @@
Properties properties = new Properties();
try {
properties.load(new
FileInputStream(propertiesFilePath));
+ MAX_INT =
Integer.parseInt(properties.getProperty("MAX_INT"));
+ MIN_INT =
Integer.parseInt(properties.getProperty("MIN_INT"));
+ ENABLE_VALUE_CLASSES =
Boolean.parseBoolean(properties.getProperty("ENABLE_VALUE_CLASSES"));
LINE_NUMBER_DIFFERENCE_THRESHOLD =
Integer.parseInt(properties.getProperty("LINE_NUMBER_DIFFERENCE_THRESHOLD"));
GENERAL_PROPERTIES_FEATURE_SCORE =
Double.parseDouble(properties.getProperty("GENERAL_PROPERTIES_FEATURE_SCORE"));
STACK_TRACE_FEATURE_SCORE =
Double.parseDouble(properties.getProperty("STACK_TRACE_FEATURE_SCORE"));
Modified:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/StackTraceFeature.java
===================================================================
---
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/StackTraceFeature.java
2012-07-15 10:34:37 UTC (rev 22680)
+++
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/StackTraceFeature.java
2012-07-15 10:41:42 UTC (rev 22681)
@@ -14,19 +14,20 @@
private double expressionValueScore;
private int functionNum;
private int expressionNum;
+ private int epochNum;
public StackTraceFeature(Bug bugA, Bug bugB, double featureTotalScore) {
super(bugA, bugB, featureTotalScore);
featureName = "Feature: Stack-Trace";
}
- private double compareFunctions() {
- int numFunctionA = bugA.getEpoch(0).getFunctionNum();
- int numFunctionB = bugB.getEpoch(0).getFunctionNum();
+ private double compareFunctions(int epochIndex) {
+ int numFunctionA = bugA.getEpoch(epochIndex).getFunctionNum();
+ int numFunctionB = bugB.getEpoch(epochIndex).getFunctionNum();
if (numFunctionA >= numFunctionB)
- return doCompareFunctions(bugB.getEpoch(0),
bugA.getEpoch(0));
- return doCompareFunctions(bugA.getEpoch(0), bugB.getEpoch(0));
+ return doCompareFunctions(bugB.getEpoch(epochIndex),
bugA.getEpoch(epochIndex));
+ return doCompareFunctions(bugA.getEpoch(epochIndex),
bugB.getEpoch(epochIndex));
}
private double doCompareFunctions(Epoch shorterEpoch, Epoch
longerEpoch) {
@@ -88,7 +89,7 @@
expressionLongerFunction =
longerFunction.getExpression(j);
if
(expressionShorterFunction.getName().equals(expressionLongerFunction.getName()))
{
expressionsScore +=
expressionSyntaxScore;
- if
(expressionShorterFunction.getValue().equals(expressionLongerFunction.getValue()))
+ if
(ValueClassifier.classify(expressionShorterFunction.getValue(),
expressionLongerFunction.getValue()))
expressionsScore +=
expressionValueScore;
break; // break inner loop
}
@@ -101,31 +102,40 @@
@Override
public double score() {
assignScorePoints();
- return compareFunctions();
+ double finalScore = 0.0;
+ for (int i = 0; i < epochNum; i++)
+ finalScore += compareFunctions(i);
+ return finalScore;
}
@Override
protected void assignScorePoints() {
+ int epochNumA = bugA.getEpochNum();
+ int epochNumB = bugB.getEpochNum();
+ epochNum = epochNumA <= epochNumB ? epochNumA : epochNumB; //
compare the smallest number of epoch steps
- int functionNumA = bugA.getEpoch(0).getFunctionNum();
- int functionNumB = bugB.getEpoch(0).getFunctionNum();
- functionNum = functionNumA >= functionNumB ? functionNumA :
functionNumB; // taking the larger number of functions of the two stack traces
-
+ int expressionNumA, expressionNumB, functionNumA, functionNumB;
Function function;
- int expressionNumA = 0;
- for (int i = 0; i < functionNumA; i++) {
- function = bugA.getEpoch(0).getFunction(i);
- expressionNumA += function.getExpressionNum();
+ for (int i = 0; i < epochNum; i++) {
+ functionNumA = bugA.getEpoch(i).getFunctionNum();
+ functionNumB = bugB.getEpoch(i).getFunctionNum();
+ functionNum += functionNumA >= functionNumB ?
functionNumA : functionNumB; // taking the larger number of functions of the
two stack traces
+
+ expressionNumA = 0;
+ for (int j = 0; j < functionNumA; j++) {
+ function = bugA.getEpoch(i).getFunction(j);
+ expressionNumA += function.getExpressionNum();
+ }
+
+ expressionNumB = 0;
+ for (int j = 0; j < functionNumB; j++) {
+ function = bugB.getEpoch(i).getFunction(j);
+ expressionNumB += function.getExpressionNum();
+ }
+
+ expressionNum += expressionNumA >= expressionNumB ?
expressionNumA : expressionNumB; // taking the larger number of expressions of
the two stack traces
}
- int expressionNumB = 0;
- for (int i = 0; i < functionNumB; i++) {
- function = bugB.getEpoch(0).getFunction(i);
- expressionNumB += function.getExpressionNum();
- }
-
- expressionNum = expressionNumA >= expressionNumB ?
expressionNumA : expressionNumB; // taking the larger number of expressions of
the two stack traces
-
double allFunctionSemanticsScore =
Constants.FUNCTION_SEMANTICS_WEIGHT * featureTotalScore;
double singleFunctionSemanticsScore =
(double)allFunctionSemanticsScore / (double)functionNum;
Added:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/ValueClassifier.java
===================================================================
---
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/ValueClassifier.java
(rev 0)
+++
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/ValueClassifier.java
2012-07-15 10:41:42 UTC (rev 22681)
@@ -0,0 +1,75 @@
+package org.monkey.comparator;
+
+public class ValueClassifier {
+ public static boolean classify(String expressionValueA, String
expressionValueB) {
+ /* If value classes disabled compare values normally and return
*/
+ if (Constants.ENABLE_VALUE_CLASSES == false) {
+ if (expressionValueA.equals(expressionValueB))
+ return true;
+ return false;
+ }
+
+ /* Value classes enabled */
+ if (((expressionValueA.startsWith("0x") ||
expressionValueA.equals("NULL"))
+ && (expressionValueB.startsWith("0x") ||
expressionValueB.equals("NULL")))) {
+ return classifyPointer(expressionValueA,
expressionValueB);
+ }
+ try {
+ int iA = Integer.parseInt(expressionValueA);
+ int iB = Integer.parseInt(expressionValueB);
+ return classifyInteger(iA, iB);
+ }
+ catch (NumberFormatException e) {
+ try {
+ float fA = Float.parseFloat(expressionValueA);
+ float fB = Float.parseFloat(expressionValueB);
+ return classifyFloat(fA, fB);
+ }
+ catch (NumberFormatException ee) {
+ return classifyString(expressionValueA,
expressionValueB);
+ }
+ }
+ }
+
+ private static boolean classifyInteger(int expressionAValue, int
expressionBValue) {
+ if (expressionAValue == 0 || expressionBValue == 0 ||
+ expressionAValue == 1 || expressionBValue == 1
+ || expressionAValue == -1 || expressionBValue
== -1 ||
+ expressionAValue == Constants.MAX_INT ||
expressionBValue == Constants.MAX_INT ||
+ expressionAValue == Constants.MIN_INT ||
expressionBValue == Constants.MIN_INT) {
+ if (expressionAValue == expressionBValue)
+ return true;
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean classifyFloat(float bugAValue, float bugBValue) {
+ if (bugAValue == 0.0 || bugBValue == 0.0) {
+ if (bugAValue == bugBValue)
+ return true;
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean classifyPointer(String bugAValue, String
bugBValue) {
+ if (bugAValue.equals("NULL") || bugBValue.equals("NULL")) {
+ if (bugAValue.equals(bugBValue))
+ return true;
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean classifyString(String bugAValue, String
bugBValue) {
+ if (bugAValue.equals("NULL") || bugAValue.equals("")
+ || bugBValue.equals("NULL") ||
bugBValue.equals("")) {
+ if (bugAValue.equals(bugBValue)) {
+ return true;
+ }
+ return false;
+ }
+ return true;
+ }
+}
Property changes on:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/ValueClassifier.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/ComparatorTest.java
===================================================================
---
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/ComparatorTest.java
2012-07-15 10:34:37 UTC (rev 22680)
+++
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/ComparatorTest.java
2012-07-15 10:41:42 UTC (rev 22681)
@@ -78,4 +78,34 @@
System.out.println("score = " + similarityPercentage);
assertEquals(32.958333333333336, similarityPercentage, 0);
}
+
+ @Test
+ public void testIdenticalHistory() {
+ Bug bugA =
XMLParser.parse("src/org/monkey/comparator/testing/refs/monkey_different_trace.xml");
+ Bug bugB =
XMLParser.parse("src/org/monkey/comparator/testing/refs/monkey_different_trace.xml");
+
+ double similarityPercentage =
MonkeyComparator.compareBugs(bugA, bugB, "comparator.properties");
+ System.out.println("score = " + similarityPercentage);
+ assertEquals(100.0, similarityPercentage, 0);
+ }
+
+ @Test
+ public void testDifferentHistory() {
+ Bug bugA =
XMLParser.parse("src/org/monkey/comparator/testing/refs/monkey_different_trace.xml");
+ Bug bugB =
XMLParser.parse("src/org/monkey/comparator/testing/refs/monkey_different_history.xml");
+
+ double similarityPercentage =
MonkeyComparator.compareBugs(bugA, bugB, "comparator.properties");
+ System.out.println("score = " + similarityPercentage);
+ assertEquals(94.44444444444446, similarityPercentage, 0);
+ }
+
+ @Test
+ public void testDifferentAndLongerHistory() {
+ Bug bugA =
XMLParser.parse("src/org/monkey/comparator/testing/refs/monkey_different_trace.xml");
+ Bug bugB =
XMLParser.parse("src/org/monkey/comparator/testing/refs/monkey_different_and_longer_history.xml");
+
+ double similarityPercentage =
MonkeyComparator.compareBugs(bugA, bugB, "comparator.properties");
+ System.out.println("score = " + similarityPercentage);
+ assertEquals(94.44444444444446, similarityPercentage, 0);
+ }
}
Added:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/refs/monkey_different_and_longer_history.xml
===================================================================
---
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/refs/monkey_different_and_longer_history.xml
(rev 0)
+++
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/refs/monkey_different_and_longer_history.xml
2012-07-15 10:41:42 UTC (rev 22681)
@@ -0,0 +1,114 @@
+<?xml version="1.0"?>
+<crash category="npe" function="crashFunction" line="14"
file="bug_null_pointer_exception.c" >
+<history>
+<epoch step="0" >
+<trace>
+<function name="crashFunction" line="14" file="bug_null_pointer_exception.c"
depth="0" >
+<expressions>
+<expression name="crashStruct" >NULL</expression>
+<expression name="x" >5</expression>
+<expression name="y" >6</expression>
+<expression name="s" >Hello</expression>
+</expressions>
+</function>
+<function name="intermediateFunction" line="20"
file="bug_null_pointer_exception.c" depth="0" >
+<expressions>
+<expression name="alpha" >1</expression>
+<expression name="beta" >2</expression>
+<expression name="gamma" >7</expression>
+<expression name="delta" >hurray</expression>
+</expressions>
+</function>
+<function name="anotherCrashFunction" line="3"
file="bug_null_pointer_exception.c" depth="1" >
+<expressions>
+<expression name="a" >3</expression>
+<expression name="b" >7</expression>
+<expression name="c" >9</expression>
+<expression name="d" >112</expression>
+</expressions>
+</function>
+</trace>
+</epoch>
+<epoch step="1" >
+<trace>
+<function name="crashFunction" line="14" file="bug_null_pointer_exception.c"
depth="0" >
+<expressions>
+<expression name="crashStruct" >NULL</expression>
+<expression name="x" >5</expression>
+<expression name="y" >6</expression>
+<expression name="s" >Hello</expression>
+</expressions>
+</function>
+<function name="intermediateFunction" line="20"
file="bug_null_pointer_exception.c" depth="0" >
+<expressions>
+<expression name="alpha" >1</expression>
+<expression name="beta" >2</expression>
+<expression name="gamma" >7</expression>
+<expression name="delta" >hurray</expression>
+</expressions>
+</function>
+<function name="anotherCrashFunction" line="3"
file="bug_null_pointer_exception.c" depth="1" >
+<expressions>
+<expression name="i" >3</expression>
+<expression name="j" >7</expression>
+<expression name="k" >9</expression>
+</expressions>
+</function>
+</trace>
+</epoch>
+<epoch step="2" >
+<trace>
+<function name="crashFunction" line="14" file="bug_null_pointer_exception.c"
depth="0" >
+<expressions>
+<expression name="crashStruct" >NULL</expression>
+<expression name="x" >5</expression>
+<expression name="y" >6</expression>
+<expression name="s" >Hello</expression>
+</expressions>
+</function>
+<function name="intermediateFunction" line="20"
file="bug_null_pointer_exception.c" depth="0" >
+<expressions>
+<expression name="alpha" >1</expression>
+<expression name="beta" >2</expression>
+<expression name="gamma" >7</expression>
+<expression name="delta" >hurray</expression>
+</expressions>
+</function>
+<function name="anotherCrashFunction" line="3"
file="bug_null_pointer_exception.c" depth="1" >
+<expressions>
+<expression name="i" >3</expression>
+<expression name="j" >7</expression>
+<expression name="k" >9</expression>
+</expressions>
+</function>
+</trace>
+</epoch>
+<epoch step="3" >
+<trace>
+<function name="crashFunction" line="14" file="bug_null_pointer_exception.c"
depth="0" >
+<expressions>
+<expression name="crashStruct" >NULL</expression>
+<expression name="x" >5</expression>
+<expression name="y" >6</expression>
+<expression name="s" >Hello</expression>
+</expressions>
+</function>
+<function name="intermediateFunction" line="20"
file="bug_null_pointer_exception.c" depth="0" >
+<expressions>
+<expression name="alpha" >1</expression>
+<expression name="beta" >2</expression>
+<expression name="gamma" >7</expression>
+<expression name="delta" >hurray</expression>
+</expressions>
+</function>
+<function name="anotherCrashFunction" line="3"
file="bug_null_pointer_exception.c" depth="1" >
+<expressions>
+<expression name="i" >3</expression>
+<expression name="j" >7</expression>
+<expression name="k" >9</expression>
+</expressions>
+</function>
+</trace>
+</epoch>
+</history>
+</crash>
Property changes on:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/refs/monkey_different_and_longer_history.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/refs/monkey_different_history.xml
===================================================================
---
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/refs/monkey_different_history.xml
(rev 0)
+++
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/refs/monkey_different_history.xml
2012-07-15 10:41:42 UTC (rev 22681)
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<crash category="npe" function="crashFunction" line="14"
file="bug_null_pointer_exception.c" >
+<history>
+<epoch step="0" >
+<trace>
+<function name="crashFunction" line="14" file="bug_null_pointer_exception.c"
depth="0" >
+<expressions>
+<expression name="crashStruct" >NULL</expression>
+<expression name="x" >5</expression>
+<expression name="y" >6</expression>
+<expression name="s" >Hello</expression>
+</expressions>
+</function>
+<function name="intermediateFunction" line="20"
file="bug_null_pointer_exception.c" depth="0" >
+<expressions>
+<expression name="alpha" >1</expression>
+<expression name="beta" >2</expression>
+<expression name="gamma" >7</expression>
+<expression name="delta" >hurray</expression>
+</expressions>
+</function>
+<function name="anotherCrashFunction" line="3"
file="bug_null_pointer_exception.c" depth="1" >
+<expressions>
+<expression name="a" >3</expression>
+<expression name="b" >7</expression>
+<expression name="c" >9</expression>
+<expression name="d" >112</expression>
+</expressions>
+</function>
+</trace>
+</epoch>
+<epoch step="1" >
+<trace>
+<function name="crashFunction" line="14" file="bug_null_pointer_exception.c"
depth="0" >
+<expressions>
+<expression name="crashStruct" >NULL</expression>
+<expression name="x" >5</expression>
+<expression name="y" >6</expression>
+<expression name="s" >Hello</expression>
+</expressions>
+</function>
+<function name="intermediateFunction" line="20"
file="bug_null_pointer_exception.c" depth="0" >
+<expressions>
+<expression name="alpha" >1</expression>
+<expression name="beta" >2</expression>
+<expression name="gamma" >7</expression>
+<expression name="delta" >hurray</expression>
+</expressions>
+</function>
+<function name="anotherCrashFunction" line="3"
file="bug_null_pointer_exception.c" depth="1" >
+<expressions>
+<expression name="i" >3</expression>
+<expression name="j" >7</expression>
+<expression name="k" >9</expression>
+</expressions>
+</function>
+</trace>
+</epoch>
+</history>
+</crash>
Property changes on:
monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator/src/org/monkey/comparator/testing/refs/monkey_different_history.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22681 - in monkey/branches/MonkeyBacktracking/monkey/MonkeyBugComparator: . src/org/monkey/comparator src/org/monkey/comparator/testing src/org/monkey/comparator/testing/refs,
gnunet <=