Class CallGraph
- java.lang.Object
-
- it.unive.lisa.util.datastructures.graph.BaseGraph<CallGraph,CallGraphNode,CallGraphEdge>
-
- it.unive.lisa.interprocedural.callgraph.CallGraph
-
- All Implemented Interfaces:
Graph<CallGraph,CallGraphNode,CallGraphEdge>
- Direct Known Subclasses:
BaseCallGraph
public abstract class CallGraph extends BaseGraph<CallGraph,CallGraphNode,CallGraphEdge>
A callgraph of the program to analyze, that knows how to resolve dynamic targets ofUnresolvedCalls.
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.util.datastructures.graph.BaseGraph
adjacencyMatrix, entrypoints
-
-
Constructor Summary
Constructors Constructor Description CallGraph()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.Collection<CodeMember>getCallees(CodeMember cm)Yields all theCodeMembers that are called by the given one.java.util.Collection<CodeMember>getCallees(java.util.Collection<? extends CodeMember> cms)Yields all theCodeMembers that are called by the given ones.java.util.Collection<CodeMember>getCalleesTransitively(CodeMember cm)Yields the transitive closure ofgetCallees(CodeMember).java.util.Collection<CodeMember>getCalleesTransitively(java.util.Collection<? extends CodeMember> cms)Yields the transitive closure ofgetCallees(CodeMember)of each given code member.java.util.Collection<CodeMember>getCallers(CodeMember cm)Yields all theCodeMembers that call the given one.java.util.Collection<CodeMember>getCallers(java.util.Collection<? extends CodeMember> cms)Yields all theCodeMembers that call the given ones.java.util.Collection<CodeMember>getCallersTransitively(CodeMember cm)Yields the transitive closure ofgetCallers(CodeMember).java.util.Collection<CodeMember>getCallersTransitively(java.util.Collection<? extends CodeMember> cms)Yields the transitive closure ofgetCallers(CodeMember)over each given code member.abstract java.util.Collection<Call>getCallSites(CodeMember cm)Yields all theCalls that target the givenCodeMember.java.util.Collection<Call>getCallSites(java.util.Collection<? extends CodeMember> cms)Yields all theCalls that target at least one of the givenCodeMembers.java.util.Collection<java.util.Collection<CodeMember>>getRecursions()Yields all the recursions that happens in the program, in the form of collections of theCodeMembers composing them.java.util.Collection<java.util.Collection<CodeMember>>getRecursionsContaining(CodeMember cm)Yields all the recursions happening in the program, in the form of collections of theCodeMembers composing them, containing the given code member.voidinit(Application app)Initializes the call graph of the given program.abstract voidregisterCall(CFGCall call)abstract Callresolve(UnresolvedCall call, java.util.Set<Type>[] types, SymbolAliasing aliasing)Yields aCallimplementation that corresponds to the resolution of the givenUnresolvedCall.-
Methods inherited from class it.unive.lisa.util.datastructures.graph.BaseGraph
addEdge, addNode, addNode, containsEdge, containsNode, followersOf, getAdjacencyMatrix, getEdgeConnecting, getEdges, getEdgesConnecting, getEdgesCount, getEntrypoints, getIngoingEdges, getNodes, getNodesCount, getOutgoingEdges, isEqualTo, predecessorsOf, toSerializableGraph, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.util.datastructures.graph.Graph
accept, getCycleEntries, toSerializableGraph
-
-
-
-
Method Detail
-
init
public void init(Application app) throws CallGraphConstructionException
Initializes the call graph of the given program. A call to this method should effectively re-initialize the call graph as if it is yet to be used. This is useful when the same instance is used in multiple analyses.- Parameters:
app- the application to analyze- Throws:
CallGraphConstructionException- if an exception happens while building the call graph
-
resolve
public abstract Call resolve(UnresolvedCall call, java.util.Set<Type>[] types, SymbolAliasing aliasing) throws CallResolutionException
Yields aCallimplementation that corresponds to the resolution of the givenUnresolvedCall.- Parameters:
call- the call to resolvetypes- the runtime types of the parameters of the callaliasing- the symbol aliasing information, might benull- Returns:
- a collection of all the possible runtime targets
- Throws:
CallResolutionException- if this call graph is unable to resolve the given call
-
registerCall
public abstract void registerCall(CFGCall call)
- Parameters:
call- the call to register
-
getCallSites
public abstract java.util.Collection<Call> getCallSites(CodeMember cm)
Yields all theCalls that target the givenCodeMember. The returned collection might contain partial results if this call graph is not fully built.- Parameters:
cm- the target code member- Returns:
- the collection of calls that target the code member
-
getCallSites
public java.util.Collection<Call> getCallSites(java.util.Collection<? extends CodeMember> cms)
Yields all theCalls that target at least one of the givenCodeMembers. The returned collection might contain partial results if this call graph is not fully built.- Parameters:
cms- the target code members- Returns:
- the collection of calls that target the code members
-
getCallers
public java.util.Collection<CodeMember> getCallers(java.util.Collection<? extends CodeMember> cms)
Yields all theCodeMembers that call the given ones. The returned collection might contain partial results if this call graph is not fully built.- Parameters:
cms- the target code members- Returns:
- the collection of callers code members
-
getCallersTransitively
public java.util.Collection<CodeMember> getCallersTransitively(CodeMember cm)
Yields the transitive closure ofgetCallers(CodeMember). The returned collection might contain partial results if this call graph is not fully built.- Parameters:
cm- the target code member- Returns:
- the collection of callers code members computed transitively
-
getCallersTransitively
public java.util.Collection<CodeMember> getCallersTransitively(java.util.Collection<? extends CodeMember> cms)
Yields the transitive closure ofgetCallers(CodeMember)over each given code member. The returned collection might contain partial results if this call graph is not fully built.- Parameters:
cms- the target code members- Returns:
- the collection of callers code members computed transitively
-
getCallees
public java.util.Collection<CodeMember> getCallees(java.util.Collection<? extends CodeMember> cms)
Yields all theCodeMembers that are called by the given ones. The returned collection might contain partial results if this call graph is not fully built.- Parameters:
cms- the target code members- Returns:
- the collection of callees code members
-
getCalleesTransitively
public java.util.Collection<CodeMember> getCalleesTransitively(CodeMember cm)
Yields the transitive closure ofgetCallees(CodeMember). The returned collection might contain partial results if this call graph is not fully built.- Parameters:
cm- the target code member- Returns:
- the collection of callees code members computed transitively
-
getCalleesTransitively
public java.util.Collection<CodeMember> getCalleesTransitively(java.util.Collection<? extends CodeMember> cms)
Yields the transitive closure ofgetCallees(CodeMember)of each given code member. The returned collection might contain partial results if this call graph is not fully built.- Parameters:
cms- the target code members- Returns:
- the collection of callees code members computed transitively
-
getCallees
public java.util.Collection<CodeMember> getCallees(CodeMember cm)
Yields all theCodeMembers that are called by the given one. The returned collection might contain partial results if this call graph is not fully built.- Parameters:
cm- the target code member- Returns:
- the collection of called code members
-
getCallers
public java.util.Collection<CodeMember> getCallers(CodeMember cm)
Yields all theCodeMembers that call the given one. The returned collection might contain partial results if this call graph is not fully built.- Parameters:
cm- the target code member- Returns:
- the collection of callers code members
-
getRecursions
public java.util.Collection<java.util.Collection<CodeMember>> getRecursions()
Yields all the recursions that happens in the program, in the form of collections of theCodeMembers composing them.- Returns:
- the recursions
-
getRecursionsContaining
public java.util.Collection<java.util.Collection<CodeMember>> getRecursionsContaining(CodeMember cm)
Yields all the recursions happening in the program, in the form of collections of theCodeMembers composing them, containing the given code member.- Parameters:
cm- the target code member- Returns:
- the recursions
-
-