add IFDSExplorerExample
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3836 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
133bd80a7e
commit
248db587a9
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/IFDSExplorerExample.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.IFDSExplorerExample"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-dotExe /opt/local/bin/dot -viewerExe /Users/manu/scripts/open_pdf.scpt"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.ide.tests"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Xmx800M"/>
|
||||
</launchConfiguration>
|
|
@ -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 <path_to_dot_exe> -viewerExe <path_to_viewer_exe>
|
||||
* @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<Entrypoint> 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<BasicBlockInContext<IExplodedBasicBlock>, CGNode, Pair<CGNode, Integer>> result = reachingDefs.analyze();
|
||||
IFDSExplorer.setDotExe(p.getProperty("dotExe"));
|
||||
IFDSExplorer.setGvExe(p.getProperty("viewerExe"));
|
||||
IFDSExplorer.viewIFDS(result);
|
||||
}
|
||||
|
||||
}
|
|
@ -83,6 +83,7 @@ public class IFDSExplorer {
|
|||
irFileName = "ir.pdf";
|
||||
break;
|
||||
case PS:
|
||||
case EPS:
|
||||
irFileName = "ir.ps";
|
||||
break;
|
||||
case SVG:
|
||||
|
|
Loading…
Reference in New Issue