Package qilin.core.builder.callgraph
Class OnFlyCallGraph
java.lang.Object
qilin.core.builder.callgraph.OnFlyCallGraph
- All Implemented Interfaces:
Iterable<Edge>
,CallGraph
,MutableCallGraph
Represents the edges in a call graph. This class is meant to act as only a container of edges;
code for various call graph builders should be kept out of it, as well as most code for accessing
the edges.
- Author:
- Ondrej Lhotak
-
Nested Class Summary
Nested classes/interfaces inherited from interface sootup.callgraph.CallGraph
CallGraph.Call
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected Map<MethodSignature,
Set<CallGraph.Call>> protected Edge
protected Set<MethodSignature>
protected QueueReader<Edge>
protected Map<ContextMethod,
Edge> protected ChunkedQueue<Edge>
protected Map<ContextMethod,
Edge> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCall
(CallGraph.Call call) This method enables to add calls that are edges in the call graph.void
addCall
(MethodSignature sourceMethod, MethodSignature targetMethod, InvokableStmt stmt) This method enables to add calls that are edges in the call graph.boolean
Used to add an edge to the call graph.void
addMethod
(MethodSignature calledMethod) This method enables to add method that are nodes in the call graph.int
This method counts every edge in the call graph.callsFrom
(MethodSignature sourceMethod) This method returns all method signatures that are called by a given method signature.callSourcesTo
(MethodSignature targetMethod) This method returns all method signatures that call a given method signature.callsTo
(MethodSignature targetMethod) This method returns all method signatures that call a given method signature.callTargetsFrom
(MethodSignature sourceMethod) This method returns all method signatures that are called by a given method signature.boolean
containsCall
(CallGraph.Call call) This method checks if an edge is contained in the call graph.boolean
containsCall
(MethodSignature sourceMethod, MethodSignature targetMethod, InvokableStmt stmt) This method checks if an edge is contained in the call graph.boolean
containsMethod
(MethodSignature method) This method checks if a given method signature is a node in the call graph.copy()
This method copies a call graph.This method compares the difference between the current call graph and call graph passed into the argument.Returns an iterator over all edges that have m as their target method.Returns an iterator over all edges that have m as their source method.edgesOutOf
(Stmt u) Returns an iterator over all edges that have u as their source unit.This method converts the call graph object into dot format and write it to a string file.findEdge
(Stmt u, SootMethod callee) Find the specific call edge that is going out from the callsite u and the call target is callee.This method returns all entry methods of the call graphThis method returns method signatures in the call graph.boolean
isEntryMethod
(SootMethod method) Does this method have no incoming edge?iterator()
listener()
Returns a QueueReader object containing all edges added so far, and which will be informed of any new edges that are later added to the graph.Returns a QueueReader object which will contain ONLY NEW edges which will be added to the graph.boolean
Removes all outgoing edges that start at the given unitboolean
removeEdge
(Edge e) Removes the edge e from the call graph.boolean
removeEdge
(Edge e, boolean removeInEdgeList) Removes the edge e from the call graph.boolean
removeEdges
(Collection<Edge> edges) Removes the edges from the call graph.int
size()
Returns the number of edges in the call graph.Returns an iterator over all methods that are the sources of at least one edge.boolean
swapEdgesOutOf
(InvokableStmt out, InvokableStmt in) Swaps an invocation statement.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
methods
-
calls
-
callCnt
protected int callCnt -
edges
-
stream
-
reader
-
srcMethodToEdge
-
srcUnitToEdge
-
tgtToEdge
-
dummy
-
-
Constructor Details
-
OnFlyCallGraph
public OnFlyCallGraph()
-
-
Method Details
-
addEdge
Used to add an edge to the call graph. Returns true iff the edge was not already present. -
removeAllEdgesOutOf
Removes all outgoing edges that start at the given unit- Parameters:
u
- The unit from which to remove all outgoing edges- Returns:
- True if at least one edge has been removed, otherwise false
-
swapEdgesOutOf
Swaps an invocation statement. All edges that previously went from the given statement to some callee now go from the new statement to the same callee. This method is intended to be used when a Jimple statement is replaced, but the replacement does not semantically affect the edges.- Parameters:
out
- The old statementin
- The new statement- Returns:
- True if at least one edge was affected by this operation
-
removeEdge
Removes the edge e from the call graph. Returns true iff the edge was originally present in the call graph. -
removeEdge
Removes the edge e from the call graph. Returns true iff the edge was originally present in the call graph.- Parameters:
e
- the edgeremoveInEdgeList
- when true (recommended), it is ensured that the edge reader is informed about the removal- Returns:
- whether the removal was successful.
-
removeEdges
Removes the edges from the call graph. Returns true iff one edge was originally present in the call graph.- Parameters:
edges
- the edges- Returns:
- whether the removal was successful.
-
isEntryMethod
Does this method have no incoming edge?- Parameters:
method
-- Returns:
-
findEdge
Find the specific call edge that is going out from the callsite u and the call target is callee. Without advanced data structure, we can only sequentially search for the match. Fortunately, the number of outgoing edges for a unit is not too large.- Parameters:
u
-callee
-- Returns:
-
sourceMethods
Returns an iterator over all methods that are the sources of at least one edge. -
edgesOutOf
Returns an iterator over all edges that have u as their source unit. -
edgesOutOf
Returns an iterator over all edges that have m as their source method. -
edgesInto
Returns an iterator over all edges that have m as their target method. -
listener
Returns a QueueReader object containing all edges added so far, and which will be informed of any new edges that are later added to the graph. -
newListener
Returns a QueueReader object which will contain ONLY NEW edges which will be added to the graph. -
toString
-
size
public int size()Returns the number of edges in the call graph. -
iterator
-
addMethod
Description copied from interface:MutableCallGraph
This method enables to add method that are nodes in the call graph.- Specified by:
addMethod
in interfaceMutableCallGraph
- Parameters:
calledMethod
- the method that will be added to the call graph.
-
addCall
public void addCall(@Nonnull MethodSignature sourceMethod, @Nonnull MethodSignature targetMethod, @Nonnull InvokableStmt stmt) Description copied from interface:MutableCallGraph
This method enables to add calls that are edges in the call graph.- Specified by:
addCall
in interfaceMutableCallGraph
- Parameters:
sourceMethod
- this parameter defines the source node of the edge in the call graph.targetMethod
- this paramter defines the target node of the edge in the call graph.stmt
- this paramter defines the invoke statement of the edge in the call graph.
-
addCall
Description copied from interface:MutableCallGraph
This method enables to add calls that are edges in the call graph.- Specified by:
addCall
in interfaceMutableCallGraph
- Parameters:
call
- this parameter defines the call that is transformed to the edge in the call graph.
-
getMethodSignatures
Description copied from interface:CallGraph
This method returns method signatures in the call graph. A method signature is a node in the call graph.- Specified by:
getMethodSignatures
in interfaceCallGraph
- Returns:
- a set containing all method signatures in the call graph.
-
copy
Description copied from interface:CallGraph
This method copies a call graph. -
diff
Description copied from interface:CallGraph
This method compares the difference between the current call graph and call graph passed into the argument. -
containsMethod
Description copied from interface:CallGraph
This method checks if a given method signature is a node in the call graph.- Specified by:
containsMethod
in interfaceCallGraph
- Parameters:
method
- the method signature of the requested node- Returns:
- it returns true if the node described by the method signature is included in the call graph, otherwise it will return false.
-
containsCall
public boolean containsCall(@Nonnull MethodSignature sourceMethod, @Nonnull MethodSignature targetMethod, InvokableStmt stmt) Description copied from interface:CallGraph
This method checks if an edge is contained in the call graph. The edge is defined by a source and target method signature which can be nodes in the call graph- Specified by:
containsCall
in interfaceCallGraph
- Parameters:
sourceMethod
- it defines the source node in the call graphtargetMethod
- it defines the target node in the call graphstmt
- it defines the invoke stmt of the call- Returns:
- true if the edge is contained in the call graph, otherwise it will be false.
-
containsCall
Description copied from interface:CallGraph
This method checks if an edge is contained in the call graph. The edge is defined by a source and target method signature which can be nodes in the call graph- Specified by:
containsCall
in interfaceCallGraph
- Parameters:
call
- it defines the requested call in the call graph- Returns:
- true if the edge is contained in the call graph, otherwise it will be false.
-
callCount
public int callCount()Description copied from interface:CallGraph
This method counts every edge in the call graph. -
exportAsDot
Description copied from interface:CallGraph
This method converts the call graph object into dot format and write it to a string file.- Specified by:
exportAsDot
in interfaceCallGraph
-
callsFrom
Description copied from interface:CallGraph
This method returns all method signatures that are called by a given method signature. It returns the targets of outgoing edges of the given node (method signature) in the call graph -
callsTo
Description copied from interface:CallGraph
This method returns all method signatures that call a given method signature. It returns the sources of incoming edges of the given node (method signature) in the call graph -
callTargetsFrom
Description copied from interface:CallGraph
This method returns all method signatures that are called by a given method signature. It returns the targets of outgoing edges of the given node (method signature) in the call graph- Specified by:
callTargetsFrom
in interfaceCallGraph
- Parameters:
sourceMethod
- the method signature of the requested node in the call graph- Returns:
- a set of method signatures that are reached by a direct outgoing edge in the call graph
-
callSourcesTo
Description copied from interface:CallGraph
This method returns all method signatures that call a given method signature. It returns the sources of incoming edges of the given node (method signature) in the call graph- Specified by:
callSourcesTo
in interfaceCallGraph
- Parameters:
targetMethod
- the method signature of the requested node in the call graph- Returns:
- a set of method signatures that reach the targetMethod by a direct edge in the call graph
-
getEntryMethods
Description copied from interface:CallGraph
This method returns all entry methods of the call graph- Specified by:
getEntryMethods
in interfaceCallGraph
- Returns:
- a list of method signatures of entry points of the call graph
-