support partial call graph/ pointerAnalysis when computation canceled
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2580 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
2b4ea4a088
commit
07399bc2c8
|
@ -12,7 +12,6 @@ package com.ibm.wala.ipa.callgraph;
|
|||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import com.ibm.wala.eclipse.util.CancelException;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerFlowGraphFactory;
|
||||
|
||||
|
@ -29,10 +28,8 @@ public interface CallGraphBuilder {
|
|||
* @param options an object representing controlling options that the call
|
||||
* graph building algorithm needs to know.
|
||||
* @return the built call graph
|
||||
* @throws CancelException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public CallGraph makeCallGraph(AnalysisOptions options, IProgressMonitor monitor) throws IllegalArgumentException, CancelException;
|
||||
public CallGraph makeCallGraph(AnalysisOptions options, IProgressMonitor monitor) throws IllegalArgumentException, CallGraphBuilderCancelException;
|
||||
|
||||
/**
|
||||
* @return the Pointer Analysis information computed as a side-effect of
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 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.ipa.callgraph;
|
||||
|
||||
import com.ibm.wala.eclipse.util.CancelException;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
|
||||
/**
|
||||
* An exception to throw when call graph construction is cancelled. This exception allows clients
|
||||
* to retrieve the partially-built call graph and pointer analysis
|
||||
*
|
||||
* @author sjfink
|
||||
*
|
||||
*/
|
||||
public class CallGraphBuilderCancelException extends CancelException {
|
||||
|
||||
private final CallGraph cg;
|
||||
private final PointerAnalysis pointerAnalysis;
|
||||
|
||||
public static CallGraphBuilderCancelException createCallGraphBuilderCancelException(Exception cause, CallGraph cg,
|
||||
PointerAnalysis pointerAnalysis) {
|
||||
return new CallGraphBuilderCancelException(cause, cg, pointerAnalysis);
|
||||
}
|
||||
|
||||
|
||||
public static CallGraphBuilderCancelException createCallGraphBuilderCancelException(String msg, CallGraph cg,
|
||||
PointerAnalysis pointerAnalysis) {
|
||||
return new CallGraphBuilderCancelException(msg, cg, pointerAnalysis);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link CallGraph} in whatever state it was left when computation was canceled
|
||||
*/
|
||||
public CallGraph getPartialCallGraph() {
|
||||
return cg;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the {@link PointerAnalysis} in whatever state it was left when computation was canceled
|
||||
*/
|
||||
public PointerAnalysis getPartialPointerAnalysis() {
|
||||
return pointerAnalysis;
|
||||
}
|
||||
|
||||
private CallGraphBuilderCancelException(String msg, CallGraph cg, PointerAnalysis pointerAnalysis) {
|
||||
super(msg);
|
||||
this.cg = cg;
|
||||
this.pointerAnalysis = pointerAnalysis;
|
||||
}
|
||||
|
||||
private CallGraphBuilderCancelException(Exception cause, CallGraph cg, PointerAnalysis pointerAnalysis) {
|
||||
super(cause);
|
||||
this.cg = cg;
|
||||
this.pointerAnalysis = pointerAnalysis;
|
||||
}
|
||||
|
||||
}
|
|
@ -31,6 +31,7 @@ import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
|||
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.Context;
|
||||
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
|
@ -233,7 +234,7 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder {
|
|||
/*
|
||||
* @see com.ibm.wala.ipa.callgraph.CallGraphBuilder#makeCallGraph(com.ibm.wala.ipa.callgraph.AnalysisOptions)
|
||||
*/
|
||||
public CallGraph makeCallGraph(AnalysisOptions options, IProgressMonitor monitor) throws IllegalArgumentException, CancelException {
|
||||
public CallGraph makeCallGraph(AnalysisOptions options, IProgressMonitor monitor) throws IllegalArgumentException, CallGraphBuilderCancelException {
|
||||
if (options == null) {
|
||||
throw new IllegalArgumentException("options is null");
|
||||
}
|
||||
|
@ -272,7 +273,12 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder {
|
|||
customInit();
|
||||
|
||||
solver = makeSolver();
|
||||
solver.solve(monitor);
|
||||
try {
|
||||
solver.solve(monitor);
|
||||
} catch (CancelException e) {
|
||||
CallGraphBuilderCancelException c = CallGraphBuilderCancelException.createCallGraphBuilderCancelException(e, callGraph, system.extractPointerAnalysis(this));
|
||||
throw c;
|
||||
}
|
||||
|
||||
return callGraph;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue