diff --git a/com.ibm.wala.core.tests/META-INF/MANIFEST.MF b/com.ibm.wala.core.tests/META-INF/MANIFEST.MF index f37b56b76..0e21e7bab 100644 --- a/com.ibm.wala.core.tests/META-INF/MANIFEST.MF +++ b/com.ibm.wala.core.tests/META-INF/MANIFEST.MF @@ -18,6 +18,7 @@ Export-Package: com.ibm.wala.core.tests.basic, com.ibm.wala.core.tests.slicer, com.ibm.wala.core.tests.util, com.ibm.wala.demandpa.driver, + com.ibm.wala.examples.analysis.dataflow, com.ibm.wala.examples.drivers, com.ibm.wala.examples.properties Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/com.ibm.wala.ide.tests/META-INF/MANIFEST.MF b/com.ibm.wala.ide.tests/META-INF/MANIFEST.MF index 2b88f2ab5..e8b289242 100644 --- a/com.ibm.wala.ide.tests/META-INF/MANIFEST.MF +++ b/com.ibm.wala.ide.tests/META-INF/MANIFEST.MF @@ -13,7 +13,8 @@ Require-Bundle: com.ibm.wala.shrike, org.eclipse.jdt.core, org.eclipse.ui, org.eclipse.ui.ide, - org.junit4;bundle-version="4.3.1" + org.junit4;bundle-version="4.3.1", + com.ibm.wala.core.testdata;bundle-version="1.0.0" Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy diff --git a/com.ibm.wala.ide.tests/launchers/IFDSExplorerExample.launch b/com.ibm.wala.ide.tests/launchers/IFDSExplorerExample.launch new file mode 100644 index 000000000..0497a53de --- /dev/null +++ b/com.ibm.wala.ide.tests/launchers/IFDSExplorerExample.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/IFDSExplorerExample.java b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/IFDSExplorerExample.java new file mode 100644 index 000000000..93f7d21a8 --- /dev/null +++ b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/IFDSExplorerExample.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package com.ibm.wala.examples.drivers; + +import java.io.IOException; +import java.util.Properties; + +import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; +import com.ibm.wala.core.tests.util.TestConstants; +import com.ibm.wala.dataflow.IFDS.TabulationResult; +import com.ibm.wala.examples.analysis.dataflow.ContextSensitiveReachingDefs; +import com.ibm.wala.ide.ui.IFDSExplorer; +import com.ibm.wala.ipa.callgraph.AnalysisCache; +import com.ibm.wala.ipa.callgraph.AnalysisOptions; +import com.ibm.wala.ipa.callgraph.AnalysisScope; +import com.ibm.wala.ipa.callgraph.CGNode; +import com.ibm.wala.ipa.callgraph.CallGraph; +import com.ibm.wala.ipa.callgraph.CallGraphBuilder; +import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException; +import com.ibm.wala.ipa.callgraph.Entrypoint; +import com.ibm.wala.ipa.callgraph.impl.Util; +import com.ibm.wala.ipa.cfg.BasicBlockInContext; +import com.ibm.wala.ipa.cha.ClassHierarchy; +import com.ibm.wala.ipa.cha.IClassHierarchy; +import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; +import com.ibm.wala.util.collections.Pair; +import com.ibm.wala.util.config.AnalysisScopeReader; +import com.ibm.wala.util.io.CommandLine; +import com.ibm.wala.util.io.FileProvider; +import com.ibm.wala.util.warnings.WalaException; + +/** + * An example of using {@link IFDSExplorer}. We visualize the result of running {@link ContextSensitiveReachingDefs} on a simple test example. + */ +public class IFDSExplorerExample { + + /** + * Usage: IFDSExplorerExample -dotExe -viewerExe + * @param args + * @throws IOException + * @throws CallGraphBuilderCancelException + * @throws IllegalArgumentException + * @throws WalaException + */ + public static void main(String[] args) throws IOException, IllegalArgumentException, CallGraphBuilderCancelException, WalaException { + Properties p = CommandLine.parse(args); + AnalysisScope scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, + FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), IFDSExplorer.class.getClassLoader()); + IClassHierarchy cha = ClassHierarchy.make(scope); + Iterable entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, + "Ldataflow/StaticDataflow"); + AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); + + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCache(), cha, scope); + CallGraph cg = builder.makeCallGraph(options, null); + AnalysisCache cache = new AnalysisCache(); + ContextSensitiveReachingDefs reachingDefs = new ContextSensitiveReachingDefs(cg, cache); + TabulationResult, CGNode, Pair> result = reachingDefs.analyze(); + IFDSExplorer.setDotExe(p.getProperty("dotExe")); + IFDSExplorer.setGvExe(p.getProperty("viewerExe")); + IFDSExplorer.viewIFDS(result); + } + +} diff --git a/com.ibm.wala.ide/src/com/ibm/wala/ide/ui/IFDSExplorer.java b/com.ibm.wala.ide/src/com/ibm/wala/ide/ui/IFDSExplorer.java index 6dd366fac..dfccfdeb0 100644 --- a/com.ibm.wala.ide/src/com/ibm/wala/ide/ui/IFDSExplorer.java +++ b/com.ibm.wala.ide/src/com/ibm/wala/ide/ui/IFDSExplorer.java @@ -83,6 +83,7 @@ public class IFDSExplorer { irFileName = "ir.pdf"; break; case PS: + case EPS: irFileName = "ir.ps"; break; case SVG: