Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tregression/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<classpathentry exported="true" kind="lib" path="lib/poi-ooxml-3.11-20141221.jar"/>
<classpathentry exported="true" kind="lib" path="lib/poi-ooxml-schemas-3.11-20141221.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xmlbeans-2.6.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="module" value="true"/>
</attributes>
Expand Down
6 changes: 3 additions & 3 deletions tregression/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.8
49 changes: 49 additions & 0 deletions tregression/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@
id="traceagent.command.runSingleDefects4jBugs"
name="Run Single Defect4j Bug">
</command>
<command
defaultHandler="tregression.handler.SeparateVersionConcHandler"
id="tregression.command.runSeparateVersionsConc"
name="Run for separate versions concurrent">
</command>
<command
defaultHandler="tregression.handler.AllDefects4jConcHandler"
id="tregression.command.runAllDefects4jConcurrent"
name="Run all defects 4j concurrent">
</command>
<command
defaultHandler="traceagent.handler.PlayRegressionLocalizationHandlerConc"
id="tregression.command.regressionLocalConc"
name="Play the process of regession localisation (Concurrent)">
</command>
<command
defaultHandler="tregression.handler.RunRecordingExperiment"
id="tregression.command.recordingexp"
name="Run recording experiment">
</command>
</extension>
<extension
point="org.eclipse.ui.views">
Expand Down Expand Up @@ -84,6 +104,30 @@
name="Step Properties"
restorable="true">
</view>
<view
category="tregression.category"
class="tregression.views.ConcurrentBuggyTraceView"
icon="icons/cross_mark.png"
id="tregression.evalView.buggyConcTraceView"
name="Concurrent Buggy Trace"
restorable="true">
</view>
<view
category="tregression.category"
class="tregression.views.ConcurrentCorrectTraceView"
icon="icons/check_mark.png"
id="tregression.evalView.concurrentCorrectTraceView"
name="Concurrent Correct Trace"
restorable="true">
</view>
<view
category="tregression.categories"
class="tregression.views.ConcurrentStepPropertyView"
icon="icons/property.png"
id="tregression.view.concStepProperties"
name="Step Properties view concurrent"
restorable="true">
</view>
</extension>
<extension
point="org.eclipse.ui.perspectives">
Expand Down Expand Up @@ -139,6 +183,11 @@
label="Retrieve All Defect4j Regressions"
style="push">
</command>
<command
commandId="tregression.command.runSeparateVersionsConc"
label="Run separate versions conc"
style="push">
</command>
</menu>
<menu
label="Trace Agent">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package traceagent.handler;

import java.util.Comparator;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;

import microbat.model.trace.Trace;
import microbat.model.trace.TraceNode;
import tregression.empiricalstudy.RootCauseFinder;
import tregression.empiricalstudy.RootCauseNode;
import tregression.views.BuggyTraceView;
import tregression.views.ConcurrentBuggyTraceView;
import tregression.views.ConcurrentCorrectTraceView;
import tregression.views.CorrectTraceView;
import tregression.views.TregressionViews;

public class PlayRegressionLocalizationHandlerConc extends AbstractHandler {

public static RootCauseFinder finder = null;

ConcurrentBuggyTraceView buggyView;
ConcurrentCorrectTraceView correctView;

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

Job job = new Job("Recovering Regression ...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
buggyView = TregressionViews.getConcBuggyTraceView();
correctView = TregressionViews.getConcCorrectTraceView();
}
});

Thread.sleep(2000);

finder.getRegressionNodeList().sort(new Comparator<TraceNode>() {
@Override
public int compare(TraceNode o1, TraceNode o2) {
return o2.getOrder() - o1.getOrder();
}
});;

for(final TraceNode node: finder.getRegressionNodeList()) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
Trace buggyTrace = node.getTrace();
// Trace correctTrace = correctView.getTrace();
buggyView.jumpToNode(buggyTrace, node.getOrder(), true);

try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});

boolean stop = false;
for(RootCauseNode rNode: finder.getRealRootCaseList()) {
if(rNode.getRoot().equals(node)) {
stop = true;
break;
}
}

if(stop)break;

}

} catch (Exception e) {
e.printStackTrace();
}

return Status.OK_STATUS;
}
};
job.schedule();

return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package traceagent.handler;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -17,6 +19,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.osgi.service.debug.DebugTrace;

import experiment.utils.report.ExperimentReportComparisonReporter;
import experiment.utils.report.rules.TextComparisonRule;
Expand All @@ -33,6 +36,7 @@
import traceagent.report.BugCaseTrial.TraceTrial;
import tregression.empiricalstudy.TestCase;
import tregression.empiricalstudy.config.Defects4jProjectConfig;
import tregression.empiricalstudy.config.ProjectConfig;
import tregression.handler.PathConfiguration;
import tregression.separatesnapshots.AppClassPathInitializer;

Expand All @@ -41,13 +45,62 @@
*
*/
public class RunAllDefects4jHandler extends AbstractHandler {
FileOutputStream fos = null;
boolean handlerStopped = false;

/**
* Used to check if the job is canceled
* @author Gabau
*
*/
private class CancelThread extends Thread {
public boolean stopped = false;
IProgressMonitor monitor;
InstrumentationExecutor executor;
public CancelThread(IProgressMonitor monitor,
InstrumentationExecutor executor) {
this.setName("Cancel thread");
this.monitor = monitor;
this.executor = executor;
this.setDaemon(true);
}

@Override
public void run() {
while (!stopped) {
if (monitor.isCanceled()) {
executor.interrupt();
stopped = true;
break;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

public void stopMonitoring() {
this.stopped = true;
handlerStopped = true;
}

}

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
fos = new FileOutputStream(new File("K:\\output6.txt"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Job job = new Job("Run Trace Agent On Defects4j") {
@Override
protected IStatus run(IProgressMonitor monitor) {
String reportFile = "Agent_Defect4j.xlsx";
String reportFile = "K:\\Agent_Defect4j.xlsx";
try {
runAll(reportFile, monitor);
System.out.println("Complete!");
Expand All @@ -72,11 +125,15 @@ && new File(oldDefects4jFile).exists()) {
}

protected void runAll(String reportFile, IProgressMonitor monitor) throws Exception {
String[] projects = {"Chart", "Closure", "Lang", "Math", "Mockito", "Time"};
int[] bugNum = {26, 133, 65, 106, 38, 27};
//String[] projects = {"Chart", "Closure", "Lang", "Math", "Mockito", "Time"};
//int[] bugNum = {26, 133, 65, 106, 38, 27};
String[] projects = {"Csv"};
int[] bugNum = {16};

AgentDefects4jReport report = new AgentDefects4jReport(new File(reportFile));
TestcaseFilter filter = new TestcaseFilter(false);
for (int i = 0; i < projects.length; i++) {
if (handlerStopped) return;
String project = projects[i];
if (monitor.isCanceled()) {
return;
Expand All @@ -86,7 +143,7 @@ protected void runAll(String reportFile, IProgressMonitor monitor) throws Except
return;
}
System.out.println("working on the " + j + "th bug of " + project + " project.");
Defects4jProjectConfig d4jConfig = Defects4jProjectConfig.getConfig(project, String.valueOf(j));
ProjectConfig d4jConfig = Defects4jProjectConfig.getConfig(project, String.valueOf(j));
try {
runSingleBug(d4jConfig, report, null, filter, monitor);
} catch (Exception e) {
Expand All @@ -96,7 +153,7 @@ protected void runAll(String reportFile, IProgressMonitor monitor) throws Except
}
}

void runSingleBug(Defects4jProjectConfig config, AgentDefects4jReport report, List<TestCase> tcs,
void runSingleBug(ProjectConfig config, AgentDefects4jReport report, List<TestCase> tcs,
TestcaseFilter filter, IProgressMonitor monitor)
throws IOException {
String projectName = config.projectName;
Expand All @@ -116,19 +173,21 @@ void runSingleBug(Defects4jProjectConfig config, AgentDefects4jReport report, Li
SingleTimer timer = SingleTimer.start("run buggy test");
if (!filter.filter(projectName, bugID, tc.getName(), true)) {
TraceTrial bugTrace = run(buggyPath, tc, config, includeLibs, excludeLibs, true);
if (bugTrace == null) continue;
trial.setBugTrace(bugTrace);
}
timer.startNewTask("run correct test");
if (!filter.filter(projectName, bugID, tc.getName(), false)) {
TraceTrial correctTrace = run(fixPath, tc, config, includeLibs, excludeLibs, false);
if (correctTrace == null) continue;
trial.setFixedTrace(correctTrace);
}

report.record(trial);
}
}

public TraceTrial run(String workingDir, TestCase tc, Defects4jProjectConfig config, List<String> includeLibs,
public TraceTrial run(String workingDir, TestCase tc, ProjectConfig config, List<String> includeLibs,
List<String> excludeLibs, boolean isBuggy) {
SingleTimer timer = SingleTimer.start(String.format("run %s test", isBuggy ? "buggy" : "correct"));
AppJavaClassPath appClassPath = AppClassPathInitializer.initialize(workingDir, tc, config);
Expand All @@ -140,10 +199,19 @@ public TraceTrial run(String workingDir, TestCase tc, Defects4jProjectConfig con

RunningInfo info = null;
try {
info = executor.run();
info = executor.runCounter();
PreCheckInformation pci = executor.getPrecheckInfo();
if (pci.getThreadNum() > 1) {
String toWrite = config.projectName + config.regressionID + "\n";
fos.write(toWrite.getBytes());
}
} catch (StepLimitException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (info == null) return null;
PreCheckInformation precheckInfo = executor.getPrecheckInfo();
return new TraceTrial(workingDir, precheckInfo, info, timer.getExecutionTime(), isBuggy);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import traceagent.report.AgentDefects4jReport;
import tregression.empiricalstudy.TestCase;
import tregression.empiricalstudy.config.Defects4jProjectConfig;
import tregression.empiricalstudy.config.ProjectConfig;
import tregression.preference.TregressionPreference;

/**
Expand All @@ -43,7 +44,7 @@ protected IStatus run(IProgressMonitor monitor) {
tcs = Arrays.asList(new TestCase(testcase));
}
System.out.println("working on the " + id + "th bug of " + projectName + " project.");
Defects4jProjectConfig config = Defects4jProjectConfig.getConfig(projectName,
ProjectConfig config = Defects4jProjectConfig.getConfig(projectName,
id);
AgentDefects4jReport report = new AgentDefects4jReport(new File("Agent_Defect4j_tc.xlsx"));
runSingleBug(config, report, tcs, new TestcaseFilter(false), monitor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public enum AgentDefects4jHeaders implements ExcelHeader {
LOADED_CLASSES,
PRECHECK_STEP_NUM,
RUN_STEP_NUM,
IS_DEADLOCK,
IS_TIMEOUT,
PROGRAM_MSG,
SUMMARY;

Expand Down
Loading