Class AbstractInterproceduralAnalysis<S>
- java.lang.Object
-
- soot.jimple.toolkits.annotation.purity.AbstractInterproceduralAnalysis<S>
-
- Type Parameters:
S-
- Direct Known Subclasses:
PurityInterproceduralAnalysis
public abstract class AbstractInterproceduralAnalysis<S> extends Object
Inter-procedural iterator skeleton for summary-based analysis A "summary" is an abstract element associated to each method that fully models the effect of calling the method. In a summary-based analysis, the summary of a method can be computed using solely the summary of all methods it calls: the summary does not depend upon the context in which a method is called. The inter-procedural analysis interacts with a intra-procedural analysis that is able to compute the summary of one method, given the summary of all the method it calls. The inter-procedural analysis calls the intra-procedural analysis in a reverse topological order of method dependencies to resolve unknown summaries. It iterates over recursively dependant methods. Generally, the intra-procedural works by maintaining an abstract value that represent the effect of the method from its entry point and up to the current point. At the entry point, this value is empty. The summary of the method is then the merge of the abstract values at all its return points. You can provide off-the-shelf summaries for methods you do not which to analyse. Any method using these "filtered-out" methods will use the off-the-shelf summary instead of performing an intra-procedural analysis. This is useful for native methods, incremental analysis, or when you hand-made summary. Methods that are called solely by filtered-out ones will never be analysed, effectively trimming the call-graph dependencies. This class tries to use the same abstract methods and data management policy as regular FlowAnalysis classes.
-
-
Field Summary
Fields Modifier and Type Field Description protected CallGraphcgprotected Map<SootMethod,S>dataprotected DirectedGraph<SootMethod>dgstatic booleandoCheckprotected Map<SootMethod,Integer>orderprotected Map<SootMethod,S>unanalysed
-
Constructor Summary
Constructors Constructor Description AbstractInterproceduralAnalysis(CallGraph cg, SootMethodFilter filter, Iterator<SootMethod> heads, boolean verbose)The constructor performs some preprocessing, but you have to call doAnalysis to preform the real stuff.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidanalyseCall(S src, Stmt callStmt, S dst)Analyse the callcallStmtin the contextsrc, and put the result intodst.protected abstract voidanalyseMethod(SootMethod method, S dst)Compute the summary for a method by analysing its body.protected abstract voidapplySummary(S src, Stmt callStmt, S summary, S dst)Interprocedural analysis will call applySummary repeatedly as a consequence toanalyseCall(Object, Stmt, Object), once for each possible target method of thecallStmt, provided with its summary.protected abstract voidcopy(S sr, S dst)Copy src into dst.protected voiddoAnalysis(boolean verbose)Carry out the analysis.voiddrawAsManyDot(String prefix, boolean drawUnanalysed)Dump the each summary computed by the interprocedural analysis as a separate graph.voiddrawAsOneDot(String name)Dump the interprocedural analysis result as a graph.protected voidfillDotGraph(String prefix, S o, DotGraph out)Called by drawAsOneDot to fill dot subgraph out with the contents of summary o.Iterator<SootMethod>getAnalysedMethods()Get an iterator over the list of SootMethod with an associated summary.SgetSummaryFor(SootMethod m)Query the analysis result.protected abstract voidmerge(S in1, S in2, S out)Merge in1 and in2 into out.protected abstract SnewInitialSummary()Initial summary value for analysed functions.protected abstract SsummaryOfUnanalysedMethod(SootMethod method)Whenever the analyse requires the summary of a method you filtered-out, this function is called instead of analyseMethod.
-
-
-
Field Detail
-
doCheck
public static final boolean doCheck
- See Also:
- Constant Field Values
-
cg
protected final CallGraph cg
-
dg
protected final DirectedGraph<SootMethod> dg
-
data
protected final Map<SootMethod,S> data
-
order
protected final Map<SootMethod,Integer> order
-
unanalysed
protected final Map<SootMethod,S> unanalysed
-
-
Constructor Detail
-
AbstractInterproceduralAnalysis
public AbstractInterproceduralAnalysis(CallGraph cg, SootMethodFilter filter, Iterator<SootMethod> heads, boolean verbose)
The constructor performs some preprocessing, but you have to call doAnalysis to preform the real stuff.- Parameters:
cg-filter-verbose-heads-
-
-
Method Detail
-
newInitialSummary
protected abstract S newInitialSummary()
Initial summary value for analysed functions.- Returns:
-
summaryOfUnanalysedMethod
protected abstract S summaryOfUnanalysedMethod(SootMethod method)
Whenever the analyse requires the summary of a method you filtered-out, this function is called instead of analyseMethod.Note: This function is called at most once per filtered-out method. It is the equivalent of entryInitialFlow!
- Parameters:
method-- Returns:
-
analyseMethod
protected abstract void analyseMethod(SootMethod method, S dst)
Compute the summary for a method by analysing its body. Will be called only on methods not filtered-out.- Parameters:
method- is the method to be analyseddst- is where to put the computed method summary
-
applySummary
protected abstract void applySummary(S src, Stmt callStmt, S summary, S dst)
Interprocedural analysis will call applySummary repeatedly as a consequence toanalyseCall(Object, Stmt, Object), once for each possible target method of thecallStmt, provided with its summary.- Parameters:
src- summary valid before the call statementcallStmt- a statement containing a InvokeStmt or InvokeExprsummary- summary of the possible target of callStmt considered heredst- where to put the result- See Also:
analyseCall(S,soot.jimple.Stmt,S)
-
merge
protected abstract void merge(S in1, S in2, S out)
Merge in1 and in2 into out. Note: in1 or in2 can be aliased to out (e.g., analyseCall).- Parameters:
in1-in2-out-
-
fillDotGraph
protected void fillDotGraph(String prefix, S o, DotGraph out)
Called by drawAsOneDot to fill dot subgraph out with the contents of summary o.- Parameters:
prefix- gives you a unique string to prefix your node names and avoid name-clasho-out-
-
analyseCall
public void analyseCall(S src, Stmt callStmt, S dst)
Analyse the callcallStmtin the contextsrc, and put the result intodst. For each possible target of the call, this will get the summary for the target method (possiblysummaryOfUnanalysedMethod(SootMethod)) andapplySummary(Object, Stmt, Object, Object), then merge the results intodstusingmerge(Object, Object, Object).- Parameters:
src-dst-callStmt-- See Also:
summaryOfUnanalysedMethod(SootMethod),applySummary(Object, Stmt, Object, Object)
-
drawAsOneDot
public void drawAsOneDot(String name)
Dump the interprocedural analysis result as a graph. One node / subgraph for each analysed method that contains the method summary, and call-to edges. Note: this graph does not show filtered-out methods for which a conservative summary was asked via summaryOfUnanalysedMethod.- Parameters:
name- output filename- See Also:
fillDotGraph(java.lang.String,S,soot.util.dot.DotGraph)
-
drawAsManyDot
public void drawAsManyDot(String prefix, boolean drawUnanalysed)
Dump the each summary computed by the interprocedural analysis as a separate graph.- Parameters:
prefix- is prepended before method name in output filenamedrawUnanalysed- do you also want info for the unanalysed methods required by the analysis via summaryOfUnanalysedMethod ?- See Also:
fillDotGraph(java.lang.String,S,soot.util.dot.DotGraph)
-
getSummaryFor
public S getSummaryFor(SootMethod m)
Query the analysis result.- Parameters:
m-- Returns:
-
getAnalysedMethods
public Iterator<SootMethod> getAnalysedMethods()
Get an iterator over the list of SootMethod with an associated summary. (Does not contain filtered-out or native methods.)- Returns:
-
doAnalysis
protected void doAnalysis(boolean verbose)
Carry out the analysis. Call this from your InterproceduralAnalysis constructor, just after super(cg). Then , you will be able to call drawAsDot, for instance.- Parameters:
verbose-
-
-