diff --git a/src/main/java/br/unb/cic/analysis/Main.java b/src/main/java/br/unb/cic/analysis/Main.java index f1115a41..ca6f598c 100644 --- a/src/main/java/br/unb/cic/analysis/Main.java +++ b/src/main/java/br/unb/cic/analysis/Main.java @@ -1,30 +1,28 @@ package br.unb.cic.analysis; -import java.io.File; -import java.io.FileWriter; -import java.util.*; -import java.util.stream.Collectors; -import java.util.ArrayList; -import java.util.Map.Entry; - import br.unb.cic.analysis.df.*; +import br.unb.cic.analysis.io.DefaultReader; +import br.unb.cic.analysis.io.MergeConflictReader; +import br.unb.cic.analysis.ioa.InterproceduralOverrideAssignment; +import br.unb.cic.analysis.model.Statement; +import br.unb.cic.analysis.reachability.ReachabilityAnalysis; import br.unb.cic.analysis.svfa.SVFAAnalysis; import br.unb.cic.analysis.svfa.SVFAInterProcedural; import br.unb.cic.analysis.svfa.SVFAIntraProcedural; import br.unb.cic.analysis.svfa.confluence.SVFAConfluenceAnalysis; +import br.unb.cic.diffclass.DiffClass; import org.apache.commons.cli.*; - import scala.collection.JavaConverters; import soot.Body; import soot.BodyTransformer; import soot.PackManager; import soot.Transform; -import br.unb.cic.analysis.io.DefaultReader; -import br.unb.cic.analysis.io.MergeConflictReader; -import br.unb.cic.analysis.model.Statement; -import br.unb.cic.analysis.reachability.ReachabilityAnalysis; -import br.unb.cic.diffclass.DiffClass; +import java.io.File; +import java.io.FileWriter; +import java.util.*; +import java.util.Map.Entry; +import java.util.stream.Collectors; public class Main { @@ -149,13 +147,27 @@ private void createOptions() { private void runAnalysis(String mode, String classpath) { switch(mode) { - case "svfa-interprocedural" : runSparseValueFlowAnalysis(classpath, true); break; - case "svfa-intraprocedural" : runSparseValueFlowAnalysis(classpath, false); break; - case "svfa-confluence-interprocedural": runSparseValueFlowConfluenceAnalysis(classpath, true); break; - case "svfa-confluence-intraprocedural": runSparseValueFlowConfluenceAnalysis(classpath, false); break; - case "reachability" : runReachabilityAnalysis(classpath); break; - default : runDataFlowAnalysis(classpath, mode); - } + case "svfa-interprocedural": + runSparseValueFlowAnalysis(classpath, true); + break; + case "svfa-intraprocedural": + runSparseValueFlowAnalysis(classpath, false); + break; + case "svfa-confluence-interprocedural": + runSparseValueFlowConfluenceAnalysis(classpath, true); + break; + case "svfa-confluence-intraprocedural": + runSparseValueFlowConfluenceAnalysis(classpath, false); + break; + case "reachability": + runReachabilityAnalysis(classpath); + break; + case "overriding-interprocedural": + runInterproceduralOverrideAssignmentAnalysis(classpath); + break; + default: + runDataFlowAnalysis(classpath, mode); + } } private void runDataFlowAnalysis(String classpath, String mode) { @@ -167,8 +179,12 @@ protected void internalTransform(Body body, String phaseName, Map c.toString()).collect(Collectors.toList())); } } + private void runInterproceduralOverrideAssignmentAnalysis(String classpath) { + InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition); + + PackManager.v().getPack("wjtp").add(new Transform("wjtp.analysis", analysis)); + soot.options.Options.v().setPhaseOption("cg.spark", "on"); + soot.options.Options.v().setPhaseOption("cg.spark", "verbose:true"); + + SootWrapper.builder() + .withClassPath(classpath) + .addClass(targetClasses.stream().collect(Collectors.joining(" "))) + .build() + .execute(); + + conflicts.addAll(analysis.getConflicts().stream().map(c -> c.toString()).collect(Collectors.toList())); + } + /* * After discussing this algorithm with the researchers at * UFPE, we decided that we should not support this analysis @@ -193,9 +225,9 @@ protected void internalTransform(Body body, String phaseName, Map c.toString()).collect(Collectors.toList())); } diff --git a/src/main/java/br/unb/cic/analysis/svfa/SVFAAnalysis.java b/src/main/java/br/unb/cic/analysis/svfa/SVFAAnalysis.java index 23647b0c..954ae970 100644 --- a/src/main/java/br/unb/cic/analysis/svfa/SVFAAnalysis.java +++ b/src/main/java/br/unb/cic/analysis/svfa/SVFAAnalysis.java @@ -2,18 +2,13 @@ import br.unb.cic.analysis.AbstractMergeConflictDefinition; import br.unb.cic.analysis.model.Statement; - import br.unb.cic.soot.graph.*; import br.unb.cic.soot.svfa.jimple.JSVFA; import scala.collection.JavaConverters; import soot.SootMethod; import soot.Unit; -import java.util.List; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -74,7 +69,7 @@ public final scala.collection.immutable.List getEntryPoints() { definition.loadSinkStatements(); return JavaConverters.asScalaBuffer(getSourceStatements() .stream() - .map(stmt -> stmt.getSootMethod()) + .map(Statement::getSootMethod) .collect(Collectors.toList())).toList(); }