当前位置: 首页>>代码示例>>Java>>正文


Java IFDSSolver类代码示例

本文整理汇总了Java中heros.solver.IFDSSolver的典型用法代码示例。如果您正苦于以下问题:Java IFDSSolver类的具体用法?Java IFDSSolver怎么用?Java IFDSSolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IFDSSolver类属于heros.solver包,在下文中一共展示了IFDSSolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initIFDS

import heros.solver.IFDSSolver; //导入依赖的package包/类
private void initIFDS() {
	Scene.v().setCallGraph(new CallGraph());
	this.jumpFunctions = new JumpFunctions<Unit, FlowAbstraction, IFDSSolver.BinaryDomain>(IFDSSolver.getAllTop());
	this.endSum = HashBasedTable.create();
	this.inc = HashBasedTable.create();
	this.icfg = new JitIcfg(new ArrayList<SootMethod>()) {
		@Override
		public Set<SootMethod> getCalleesOfCallAt(Unit u) {
			if (currentTask != null)
				return currentTask.calleesOfCallAt(u);
			else // Empty by default (same behaviour as L1)
				return new HashSet<SootMethod>();
		}
	};
	this.reporter.setIFDS(icfg, jumpFunctions);
}
 
开发者ID:secure-software-engineering,项目名称:cheetah,代码行数:17,代码来源:LayeredAnalysis.java

示例2: runOneDirectionSolver

import heros.solver.IFDSSolver; //导入依赖的package包/类
public static void runOneDirectionSolver(AnalysisConfigurationBuilder configBuilder) {

		Pair<IfdsReporter, AnalysisConfigurationBuilder> pair = configBuilder.decorateReporter(new PropagationReporterDecorator() {
			@Override
			public IfdsReporter decorate(IfdsReporter reporter) {
				return new DelayingReporter(reporter);
			}
		});
		
		TabulationProblem problem = createTabulationProblem(pair.second);
		IFDSSolver<Unit, Trackable, SootMethod, BiDiInterproceduralCFG<Unit, SootMethod>> solver = createSolver(problem);

		AnalysisReporting.analysisStarted();
		
		_runOneDirectionSolver(problem, solver);
		pair.first.analysisFinished();
		AnalysisReporting.analysisFinished();
	}
 
开发者ID:johanneslerch,项目名称:FlowTwist,代码行数:19,代码来源:SolverFactory.java

示例3: runInnerToOuterSolver

import heros.solver.IFDSSolver; //导入依赖的package包/类
public static void runInnerToOuterSolver(AnalysisConfigurationBuilder configBuilder) {

		Pair<IfdsReporter, AnalysisConfigurationBuilder> pair = configBuilder.decorateReporter(new PropagationReporterDecorator() {
			@Override
			public IfdsReporter decorate(IfdsReporter reporter) {
				return new DelayingReporter(reporter);
			}
		});
		configBuilder = pair.second;
		
		TabulationProblem forwardTabulationProblem = createTabulationProblem(configBuilder.direction(FORWARDS));
		IFDSSolver<Unit, Trackable, SootMethod, BiDiInterproceduralCFG<Unit, SootMethod>> forwardSolver = createSolver(forwardTabulationProblem);
		TabulationProblem backwardTabulationProblem = createTabulationProblem(configBuilder.direction(BACKWARDS));
		IFDSSolver<Unit, Trackable, SootMethod, BiDiInterproceduralCFG<Unit, SootMethod>> backwardSolver = createSolver(backwardTabulationProblem);

		AnalysisReporting.analysisStarted();
		
		_runOneDirectionSolver(forwardTabulationProblem, forwardSolver);
		_runOneDirectionSolver(backwardTabulationProblem, backwardSolver);
		pair.first.analysisFinished();
		AnalysisReporting.analysisFinished();
	}
 
开发者ID:johanneslerch,项目名称:FlowTwist,代码行数:23,代码来源:SolverFactory.java

示例4: runSolver

import heros.solver.IFDSSolver; //导入依赖的package包/类
public void runSolver(final boolean followReturnsPastSeeds, final String...initialSeeds) {
	IFDSSolver<Statement, JoinableFact, TestMethod, InterproceduralCFG<Statement, TestMethod>> solver =
			new IFDSSolver<Statement, JoinableFact, TestMethod, InterproceduralCFG<Statement, TestMethod>>(
			createTabulationProblem(followReturnsPastSeeds, initialSeeds));

	solver.solve();
	assertAllFlowFunctionsUsed();
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:9,代码来源:TestHelper.java

示例5: processEdge

import heros.solver.IFDSSolver; //导入依赖的package包/类
public boolean processEdge(PathEdge<Unit, Abstraction> edge){
	// We are generating a fact out of thin air here. If we have an
	// edge <d1,n,d2>, there need not necessarily be a jump function
	// to <n,d2>.
	if (!jumpFn.forwardLookup(edge.factAtSource(), edge.getTarget()).containsKey(edge.factAtTarget())) {
		propagate(edge.factAtSource(), edge.getTarget(), edge.factAtTarget(),
				EdgeIdentity.<IFDSSolver.BinaryDomain>v(), null, false);
		return true;
	}
	return false;
}
 
开发者ID:0-14N,项目名称:soot-inflow,代码行数:12,代码来源:InfoflowSolver.java

示例6: createSolver

import heros.solver.IFDSSolver; //导入依赖的package包/类
private static IFDSSolver<Unit, Trackable, SootMethod, BiDiInterproceduralCFG<Unit, SootMethod>> createSolver(
		final TabulationProblem tabulationProblem) {
	IFDSSolver<Unit, Trackable, SootMethod, BiDiInterproceduralCFG<Unit, SootMethod>> solver = new PathTrackingIFDSSolver<Unit, Trackable, SootMethod, BiDiInterproceduralCFG<Unit, SootMethod>>(
			tabulationProblem) {
		@Override
		protected String getDebugName() {
			if (tabulationProblem.getContext().direction == FORWARDS)
				return "FW";
			else
				return "BW";
		}
	};
	return solver;
}
 
开发者ID:johanneslerch,项目名称:FlowTwist,代码行数:15,代码来源:SolverFactory.java

示例7: setIFDS

import heros.solver.IFDSSolver; //导入依赖的package包/类
public void setIFDS(JitIcfg icfg, JumpFunctions<Unit, FlowAbstraction, IFDSSolver.BinaryDomain> jumpFunctions) {
	this.icfg = icfg;
	this.pathFinder = new PathFinder(icfg, jumpFunctions);
}
 
开发者ID:secure-software-engineering,项目名称:cheetah,代码行数:5,代码来源:Reporter.java

示例8: analyze

import heros.solver.IFDSSolver; //导入依赖的package包/类
public void analyze() {
	icfg.initForMethod(task.getStartMethod());
	InterproceduralAnalysisProblem problem = new InterproceduralAnalysisProblem(icfg);
	IFDSSolver<Unit, FlowAbstraction, SootMethod, JitIcfg> solver = new IFDSSolver<Unit, FlowAbstraction, SootMethod, JitIcfg>(
			problem, jumpFunctions, endSum, inc) {

		// FlowTwist -> PropagateAndMerge
		@Override
		protected void propagate(FlowAbstraction sourceVal, Unit target, FlowAbstraction targetVal,
				EdgeFunction<IFDSSolver.BinaryDomain> f, Unit relatedCallSite, boolean isUnbalancedReturn,
				boolean force) {

			// Report leaks from summaries
			Map<FlowAbstraction, Set<List<FlowAbstraction>>> summaryLeaks = jumpFn.summaryPathsLookup(sourceVal,
					target);
			if (!summaryLeaks.isEmpty()) {
				if (DEBUG_REPORT)
					LOGGER.debug("Report (sum) " + sourceVal + " --- " + target.getJavaSourceStartLineNumber() + ":"
							+ target + " --- " + summaryLeaks);
				reporter.report(sourceVal, summaryLeaks);
			}

			// Set neighbours
			FlowAbstraction neighbour = null;
			Set<FlowAbstraction> similarTargets = jumpFn.forwardLookup(sourceVal, target).keySet();
			for (FlowAbstraction fa : similarTargets) {
				// If the values are similar, but not exact
				if (!targetVal.equals(FlowAbstraction.zeroAbstraction()) && targetVal.getUnit() != target
						&& !fa.exactEquals(targetVal) && fa.getShortName().equals(targetVal.getShortName())) {
					fa.addNeighbour(targetVal);
					neighbour = fa;
					if (DEBUG_NEIGHBOURS)
						LOGGER.debug("Initiate Neighbour " + targetVal + ":" + targetVal.getUnit() + " TO " + fa
								+ ":" + fa.getUnit() + " AT " + target + " METHOD " + icfg.getMethodOf(target));
					break;
				}
			}
			if (neighbour == null)
				propagateAfterMerge(sourceVal, target, targetVal, f, relatedCallSite, isUnbalancedReturn, force);
			else
				propagateAfterMerge(sourceVal, target, neighbour, f, relatedCallSite, isUnbalancedReturn, force);

		}
	};
	solver.solve();
}
 
开发者ID:secure-software-engineering,项目名称:cheetah,代码行数:47,代码来源:AnalysisTask.java

示例9: _runOneDirectionSolver

import heros.solver.IFDSSolver; //导入依赖的package包/类
protected static void _runOneDirectionSolver(final TabulationProblem tabulationProblem, IFDSSolver<Unit, Trackable, SootMethod, BiDiInterproceduralCFG<Unit, SootMethod>> solver) {
	AnalysisReporting.ifdsStarting(tabulationProblem.getContext(), solver);
	solver.solve();
	AnalysisReporting.ifdsFinished(tabulationProblem.getContext(), solver, FlowFunctionFactory.propCounter.get());
	FlowFunctionFactory.propCounter.set(0);
}
 
开发者ID:johanneslerch,项目名称:FlowTwist,代码行数:7,代码来源:SolverFactory.java

示例10: computeResults

import heros.solver.IFDSSolver; //导入依赖的package包/类
private Set<UpdatableWrapper<Local>> computeResults(final String codeDir) {
//		extractVersion(codeDir);
		
		soot.G.reset();
 		final Set<UpdatableWrapper<Local>> results = new HashSet<UpdatableWrapper<Local>>();
 
		PackManager.v().getPack("wjtp").add(new Transform("wjtp.ifds", new SceneTransformer() {
			protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) {
//				Scene.v().getSootClass(className).setApplicationClass();
				System.out.println("Running IFDS on initial CFG...");
				
				long nanoBeforeCFG = System.nanoTime();
				UpdatableInterproceduralCFG<Unit, SootMethod> icfg =
						new UpdatableJimpleBasedInterproceduralCFG();
				System.out.println("ICFG created in " + (System.nanoTime() - nanoBeforeCFG) / 1E9 + " seconds.");

				IFDSTabulationProblem<UpdatableWrapper<Unit>, UpdatableWrapper<Local>, UpdatableWrapper<SootMethod>,
							UpdatableInterproceduralCFG<Unit, SootMethod>> problem =
					new IFDSUninitializedVariables(icfg);
				IFDSSolver<UpdatableWrapper<Unit>,UpdatableWrapper<Local>,UpdatableWrapper<SootMethod>,
							UpdatableInterproceduralCFG<Unit,SootMethod>> solver =
					new IFDSSolver<UpdatableWrapper<Unit>,UpdatableWrapper<Local>,UpdatableWrapper<SootMethod>,
							UpdatableInterproceduralCFG<Unit,SootMethod>>(problem);	

				long beforeSolver = System.nanoTime();
				System.out.println("Running solver...");
				solver.solve();
				System.out.println("Solver done in " + ((System.nanoTime() - beforeSolver) / 1E9) + " seconds.");
				
				SootMethod meth = Scene.v().getMainClass().getMethodByName("runMainAndExit"); 
				UpdatableWrapper<Unit> ret = icfg.wrap(meth.getActiveBody().getUnits().getPredOf
						(meth.getActiveBody().getUnits().getLast()));
				results.addAll(solver.ifdsResultsAt(ret));
			}
		}));

		final String sootcp = codeDir + File.separator + "bin" + File.pathSeparator
				+ JUNIT_DIR + "/lib/hamcrest-core-1.3.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/rt.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/jce.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\rt.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\jce.jar";
		System.out.println("Soot classpath: " + sootcp);
		
		soot.Main.v().run(new String[] {
				"-W",
				"-main-class", CLASS_NAME,
				"-process-path", codeDir + File.separator + "bin",
				"-src-prec", "java",
//				"-pp",
				"-cp", sootcp,
//				"-no-bodies-for-excluded",
//				"-exclude", "java",
//				"-exclude", "javax",
				"-output-format", "none",
				"-p", "jb", "use-original-names:true",
				"-p", "cg.spark", "on",
//				"-p", "cg.spark", "verbose:true",
				CLASS_NAME } );
		return results;
	}
 
开发者ID:StevenArzt,项目名称:reviser,代码行数:62,代码来源:IFDSUninitializedVariablesJUnitCommits.java

示例11: computeResults

import heros.solver.IFDSSolver; //导入依赖的package包/类
private Set<UpdatableWrapper<Local>> computeResults(final String codeDir) {
//		extractVersion(codeDir);
		
		soot.G.reset();
 		final Set<UpdatableWrapper<Local>> results = new HashSet<UpdatableWrapper<Local>>();
 
		PackManager.v().getPack("wjtp").add(new Transform("wjtp.ifds", new SceneTransformer() {
			protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) {
//				Scene.v().getSootClass(className).setApplicationClass();
				System.out.println("Running IFDS on initial CFG...");
				
				long nanoBeforeCFG = System.nanoTime();
				UpdatableInterproceduralCFG<Unit, SootMethod> icfg =
						new UpdatableJimpleBasedInterproceduralCFG();
				System.out.println("ICFG created in " + (System.nanoTime() - nanoBeforeCFG) / 1E9 + " seconds.");

				IFDSTabulationProblem<UpdatableWrapper<Unit>, UpdatableWrapper<Local>, UpdatableWrapper<SootMethod>,
							UpdatableInterproceduralCFG<Unit, SootMethod>> problem =
					new IFDSUninitializedVariables(icfg);
				IFDSSolver<UpdatableWrapper<Unit>,UpdatableWrapper<Local>,UpdatableWrapper<SootMethod>,
							UpdatableInterproceduralCFG<Unit,SootMethod>> solver =
					new IFDSSolver<UpdatableWrapper<Unit>,UpdatableWrapper<Local>,UpdatableWrapper<SootMethod>,
							UpdatableInterproceduralCFG<Unit,SootMethod>>(problem);	

				long beforeSolver = System.nanoTime();
				System.out.println("Running solver...");
				solver.solve();
				System.out.println("Solver done in " + ((System.nanoTime() - beforeSolver) / 1E9) + " seconds.");
				
				SootMethod meth = Scene.v().getMainClass().getMethodByName("main"); 
				UpdatableWrapper<Unit> ret = icfg.wrap(meth.getActiveBody().getUnits().getPredOf
						(meth.getActiveBody().getUnits().getLast()));
				results.addAll(solver.ifdsResultsAt(ret));
			}
		}));

		final String sootcp = codeDir + File.separator + "bin" + File.pathSeparator
				+ JUNIT_DIR + "/lib/hamcrest-core-1.3.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/rt.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/jce.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\rt.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\jce.jar";
		System.out.println("Soot classpath: " + sootcp);
		
		soot.Main.v().run(new String[] {
				"-W",
				"-main-class", CLASS_NAME,
				"-process-path", codeDir + File.separator + "bin",
				"-src-prec", "java",
				"-allow-phantom-refs",
//				"-pp",
				"-cp", sootcp,
//				"-no-bodies-for-excluded",
//				"-exclude", "java",
//				"-exclude", "javax",
				"-output-format", "none",
				"-p", "jb", "use-original-names:true",
				"-p", "cg.spark", "on",
//				"-p", "cg.spark", "verbose:true",
				CLASS_NAME } );
		return results;
	}
 
开发者ID:StevenArzt,项目名称:reviser,代码行数:63,代码来源:IFDSUninitializedVariablesJUnitCommits.java

示例12: computeResults

import heros.solver.IFDSSolver; //导入依赖的package包/类
private Set<Pair<Value, Set<DefinitionStmt>>> computeResults(final String codeDir) {
//		extractVersion(codeDir);
		
		soot.G.reset();
 		final Set<Pair<Value, Set<DefinitionStmt>>> results = new HashSet<Pair<Value, Set<DefinitionStmt>>>();
 
		PackManager.v().getPack("wjtp").add(new Transform("wjtp.ifds", new SceneTransformer() {
			protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) {
//				Scene.v().getSootClass(className).setApplicationClass();
				System.out.println("Running IFDS on initial CFG...");
				
				long nanoBeforeCFG = System.nanoTime();
				InterproceduralCFG<Unit, SootMethod> icfg = new JimpleBasedInterproceduralCFG();
				System.out.println("ICFG created in " + (System.nanoTime() - nanoBeforeCFG) / 1E9 + " seconds.");

				IFDSTabulationProblem<Unit, Pair<Value, Set<DefinitionStmt>>, SootMethod,
							InterproceduralCFG<Unit, SootMethod>> problem =
					new IFDSReachingDefinitions(icfg);
				IFDSSolver<Unit,Pair<Value, Set<DefinitionStmt>>,SootMethod,
							InterproceduralCFG<Unit,SootMethod>> solver =
					new IFDSSolver<Unit,Pair<Value, Set<DefinitionStmt>>,SootMethod,
							InterproceduralCFG<Unit,SootMethod>>(problem);	

				long beforeSolver = System.nanoTime();
				System.out.println("Running solver...");
				solver.solve();
				System.out.println("Solver done in " + ((System.nanoTime() - beforeSolver) / 1E9) + " seconds.");
				
				SootMethod meth = Scene.v().getMainClass().getMethodByName("runMainAndExit"); 
				Unit ret = meth.getActiveBody().getUnits().getPredOf(meth.getActiveBody().getUnits().getLast());
				results.addAll(solver.ifdsResultsAt(ret));
			}
		}));

		final String sootcp = codeDir + File.separator + "bin" + File.pathSeparator
				+ JUNIT_DIR + "/lib/hamcrest-core-1.3.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/rt.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/jce.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\rt.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\jce.jar";
		System.out.println("Soot classpath: " + sootcp);
		
		soot.Main.v().run(new String[] {
				"-W",
				"-main-class", CLASS_NAME,
				"-process-path", codeDir + File.separator + "bin",
				"-src-prec", "java",
//				"-pp",
				"-cp", sootcp,
//				"-no-bodies-for-excluded",
//				"-exclude", "java",
//				"-exclude", "javax",
				"-output-format", "none",
				"-p", "jb", "use-original-names:true",
				"-p", "cg.spark", "on",
//				"-p", "cg.spark", "verbose:true",
				CLASS_NAME } );
		return results;
	}
 
开发者ID:StevenArzt,项目名称:reviser,代码行数:60,代码来源:IFDSReachingDefinitionsJUnitCommits.java

示例13: computeResults

import heros.solver.IFDSSolver; //导入依赖的package包/类
private Set<Pair<Value, Set<DefinitionStmt>>> computeResults(final String codeDir) {
//		extractVersion(codeDir);
		
		soot.G.reset();
 		final Set<Pair<Value, Set<DefinitionStmt>>> results = new HashSet<Pair<Value, Set<DefinitionStmt>>>();
 
		PackManager.v().getPack("wjtp").add(new Transform("wjtp.ifds", new SceneTransformer() {
			protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) {
//				Scene.v().getSootClass(className).setApplicationClass();
				System.out.println("Running IFDS on initial CFG...");
				
				long nanoBeforeCFG = System.nanoTime();
				InterproceduralCFG<Unit, SootMethod> icfg = new JimpleBasedInterproceduralCFG();
				System.out.println("ICFG created in " + (System.nanoTime() - nanoBeforeCFG) / 1E9 + " seconds.");

				IFDSTabulationProblem<Unit, Pair<Value, Set<DefinitionStmt>>, SootMethod,
							InterproceduralCFG<Unit, SootMethod>> problem =
					new IFDSReachingDefinitions(icfg);
				IFDSSolver<Unit,Pair<Value, Set<DefinitionStmt>>,SootMethod,
							InterproceduralCFG<Unit,SootMethod>> solver =
					new IFDSSolver<Unit,Pair<Value, Set<DefinitionStmt>>,SootMethod,
							InterproceduralCFG<Unit,SootMethod>>(problem);	

				long beforeSolver = System.nanoTime();
				System.out.println("Running solver...");
				solver.solve();
				System.out.println("Solver done in " + ((System.nanoTime() - beforeSolver) / 1E9) + " seconds.");
				
				SootMethod meth = Scene.v().getMainClass().getMethodByName("main"); 
				Unit ret = meth.getActiveBody().getUnits().getPredOf(meth.getActiveBody().getUnits().getLast());
				results.addAll(solver.ifdsResultsAt(ret));
			}
		}));

		final String sootcp = codeDir + File.separator + "bin" + File.pathSeparator
				+ JUNIT_DIR + "/lib/hamcrest-core-1.3.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/rt.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/jce.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\rt.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\jce.jar";
		System.out.println("Soot classpath: " + sootcp);
		
		soot.Main.v().run(new String[] {
				"-W",
				"-main-class", CLASS_NAME,
				"-process-path", codeDir + File.separator + "classes",
				"-src-prec", "java",
//				"-pp",
				"-cp", sootcp,
				"-no-bodies-for-excluded",
				"-exclude", "java",
				"-exclude", "javax",
				"-output-format", "none",
				"-p", "jb", "use-original-names:true",
				"-p", "cg.spark", "on",
//				"-p", "cg.spark", "verbose:true",
				CLASS_NAME } );
		return results;
	}
 
开发者ID:StevenArzt,项目名称:reviser,代码行数:60,代码来源:IFDSReachingDefinitionsAbcCommits.java

示例14: computeResults

import heros.solver.IFDSSolver; //导入依赖的package包/类
private Set<Local> computeResults(final String codeDir) {
//		extractVersion(codeDir);
		
		soot.G.reset();
 		final Set<Local> results = new HashSet<Local>();
 
		PackManager.v().getPack("wjtp").add(new Transform("wjtp.ifds", new SceneTransformer() {
			protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) {
//				Scene.v().getSootClass(className).setApplicationClass();
				System.out.println("Running IFDS on initial CFG...");
				
				long nanoBeforeCFG = System.nanoTime();
				InterproceduralCFG<Unit, SootMethod> icfg = new JimpleBasedInterproceduralCFG();
				System.out.println("ICFG created in " + (System.nanoTime() - nanoBeforeCFG) / 1E9 + " seconds.");

				IFDSTabulationProblem<Unit, Local, SootMethod, InterproceduralCFG<Unit, SootMethod>> problem =
					new IFDSUninitializedVariables(icfg);
				IFDSSolver<Unit,Local,SootMethod,InterproceduralCFG<Unit,SootMethod>> solver =
					new IFDSSolver<Unit,Local,SootMethod,InterproceduralCFG<Unit,SootMethod>>(problem);	

				long beforeSolver = System.nanoTime();
				System.out.println("Running solver...");
				solver.solve();
				System.out.println("Solver done in " + ((System.nanoTime() - beforeSolver) / 1E9) + " seconds.");
				
				SootMethod meth = Scene.v().getMainClass().getMethodByName("runMainAndExit"); 
				Unit ret = meth.getActiveBody().getUnits().getPredOf(meth.getActiveBody().getUnits().getLast());
				results.addAll(solver.ifdsResultsAt(ret));
			}
		}));

		final String sootcp = codeDir + File.pathSeparator
				+ JUNIT_DIR + "/hamcrest-core-1.3.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/rt.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/jce.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\rt.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\jce.jar";
		System.out.println("Soot classpath: " + sootcp);
		
		soot.Main.v().run(new String[] {
				"-W",
				"-main-class", CLASS_NAME,
				"-process-path", codeDir,
				"-src-prec", "java",
//				"-pp",
				"-cp", sootcp,
//				"-no-bodies-for-excluded",
//				"-exclude", "java",
//				"-exclude", "javax",
				"-output-format", "none",
				"-p", "jb", "use-original-names:true",
				"-p", "cg.spark", "on",
//				"-p", "cg.spark", "verbose:true",
				CLASS_NAME } );
		return results;
	}
 
开发者ID:StevenArzt,项目名称:reviser,代码行数:57,代码来源:IFDSUninitializedVariablesJUnit.java

示例15: computeResults

import heros.solver.IFDSSolver; //导入依赖的package包/类
private Set<UpdatableWrapper<Local>> computeResults(final String codeDir) {
//		extractVersion(codeDir);
		
		soot.G.reset();
 		final Set<UpdatableWrapper<Local>> results = new HashSet<UpdatableWrapper<Local>>();
 
		PackManager.v().getPack("wjtp").add(new Transform("wjtp.ifds", new SceneTransformer() {
			protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) {
//				Scene.v().getSootClass(className).setApplicationClass();
				System.out.println("Running IFDS on initial CFG...");
				
				long nanoBeforeCFG = System.nanoTime();
				UpdatableInterproceduralCFG<Unit, SootMethod> icfg =
						new UpdatableJimpleBasedInterproceduralCFG();
				System.out.println("ICFG created in " + (System.nanoTime() - nanoBeforeCFG) / 1E9 + " seconds.");

				IFDSTabulationProblem<UpdatableWrapper<Unit>, UpdatableWrapper<Local>, UpdatableWrapper<SootMethod>,
							UpdatableInterproceduralCFG<Unit, SootMethod>> problem =
					new IFDSUninitializedVariables(icfg);
				IFDSSolver<UpdatableWrapper<Unit>,UpdatableWrapper<Local>,UpdatableWrapper<SootMethod>,
							UpdatableInterproceduralCFG<Unit,SootMethod>> solver =
					new IFDSSolver<UpdatableWrapper<Unit>,UpdatableWrapper<Local>,UpdatableWrapper<SootMethod>,
							UpdatableInterproceduralCFG<Unit,SootMethod>>(problem);	

				long beforeSolver = System.nanoTime();
				System.out.println("Running solver...");
				solver.solve();
				System.out.println("Solver done in " + ((System.nanoTime() - beforeSolver) / 1E9) + " seconds.");
				
				SootMethod meth = Scene.v().getMainClass().getMethodByName("main"); 
				UpdatableWrapper<Unit> ret = icfg.wrap(meth.getActiveBody().getUnits().getPredOf
						(meth.getActiveBody().getUnits().getLast()));
				results.addAll(solver.ifdsResultsAt(ret));
			}
		}));

		final String sootcp = codeDir + File.separator + "classes" + File.pathSeparator
				+ JUNIT_DIR + "/lib/hamcrest-core-1.3.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/rt.jar" + File.pathSeparator
				+ "/usr/lib/jvm/java-6-sun/jre/lib/jce.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\rt.jar" + File.pathSeparator
				+ "C:\\Program Files\\Java\\jre7\\lib\\jce.jar";
		System.out.println("Soot classpath: " + sootcp);
		
		soot.Main.v().run(new String[] {
				"-W",
				"-main-class", CLASS_NAME,
				"-process-path", codeDir + File.separator + "classes",
				"-src-prec", "java",
				"-allow-phantom-refs",
//				"-pp",
				"-cp", sootcp,
				"-no-bodies-for-excluded",
				"-exclude", "java",
				"-exclude", "javax",
				"-output-format", "none",
				"-p", "jb", "use-original-names:true",
				"-p", "cg.spark", "on",
//				"-p", "cg.spark", "verbose:true",
				CLASS_NAME } );
		return results;
	}
 
开发者ID:StevenArzt,项目名称:reviser,代码行数:63,代码来源:IFDSUninitializedVariablesAbcCommits.java


注:本文中的heros.solver.IFDSSolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。