Package sootup.callgraph
Class GraphBasedCallGraph
java.lang.Object
sootup.callgraph.GraphBasedCallGraph
- All Implemented Interfaces:
CallGraph,MutableCallGraph
This class implements a mutable call graph as a graph.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classThis internal class is used to describe a vertex in the graph.Nested classes/interfaces inherited from interface sootup.callgraph.CallGraph
CallGraph.Call -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGraphBasedCallGraph(@NonNull org.jgrapht.graph.DirectedPseudograph<GraphBasedCallGraph.Vertex, CallGraph.Call> graph, @NonNull Map<MethodSignature, GraphBasedCallGraph.Vertex> signatureToVertex, @NonNull List<MethodSignature> entryMethods) GraphBasedCallGraph(List<MethodSignature> entryMethods) The constructor of the graph based call graph. it initializes the call graph object. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCall(@NonNull CallGraph.Call call) This method enables to add calls that are edges in the call graph.voidaddCall(@NonNull MethodSignature sourceMethod, @NonNull MethodSignature targetMethod, @NonNull InvokableStmt invokableStmt) This method enables to add calls that are edges in the call graph.voidaddMethod(@NonNull MethodSignature calledMethod) This method enables to add method that are nodes in the call graph.protected voidaddMethod(@NonNull MethodSignature calledMethod, GraphBasedCallGraph.Vertex vertex) intThis method counts every edge in the call graph.@NonNull Set<CallGraph.Call>callsFrom(@NonNull MethodSignature sourceMethod) This method returns all method signatures that are called by a given method signature.@NonNull Set<MethodSignature>callSourcesTo(@NonNull MethodSignature targetMethod) This method returns all method signatures that call a given method signature.@NonNull Set<CallGraph.Call>callsTo(@NonNull MethodSignature targetMethod) This method returns all method signatures that call a given method signature.@NonNull Set<MethodSignature>callTargetsFrom(@NonNull MethodSignature sourceMethod) This method returns all method signatures that are called by a given method signature.booleancontainsCall(@NonNull CallGraph.Call call) This method checks if an edge is contained in the call graph.booleancontainsCall(@NonNull MethodSignature sourceMethod, @NonNull MethodSignature targetMethod, @NonNull InvokableStmt invokableStmt) This method checks if an edge is contained in the call graph.booleancontainsMethod(@NonNull MethodSignature method) This method checks if a given method signature is a node in the call graph.@NonNull MutableCallGraphcopy()This method copies a call graph.@NonNull CallGraphDifferenceThis method compares the difference between the current call graph and call graph passed into the argument.protected @NonNull CallGraph.CalledgeOf(@NonNull MethodSignature source, @NonNull MethodSignature target, @NonNull InvokableStmt invokableStmt) it returns the edge of the graph that is described by the given source, target, stmt in the call graph.@NonNull Set<CallGraph.Call>getCalls()This method returns all calls in the call graph.@NonNull List<MethodSignature>This method returns all entry methods of the call graph@NonNull Set<MethodSignature>This method returns method signatures in the call graph.protected StringThis returns the string that is used in the toString Method to define the called methodsprotected StringThis returns the string that is used in the toString Method to define the methods that call a specific methodtoString()This method exports the call graph in a human-readable string.protected @NonNull GraphBasedCallGraph.VertexvertexOf(@NonNull MethodSignature method) it returns the vertex of the graph that describes the given method signature in the call graph.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface sootup.callgraph.CallGraph
exportAsDot, exportAsDot, toDotEdge
-
Constructor Details
-
GraphBasedCallGraph
The constructor of the graph based call graph. it initializes the call graph object. -
GraphBasedCallGraph
protected GraphBasedCallGraph(@NonNull org.jgrapht.graph.DirectedPseudograph<GraphBasedCallGraph.Vertex, CallGraph.Call> graph, @NonNull Map<MethodSignature, GraphBasedCallGraph.Vertex> signatureToVertex, @NonNull List<MethodSignature> entryMethods)
-
-
Method Details
-
addMethod
Description copied from interface:MutableCallGraphThis method enables to add method that are nodes in the call graph.- Specified by:
addMethodin interfaceMutableCallGraph- Parameters:
calledMethod- the method that will be added to the call graph.
-
addMethod
-
addCall
public void addCall(@NonNull MethodSignature sourceMethod, @NonNull MethodSignature targetMethod, @NonNull InvokableStmt invokableStmt) Description copied from interface:MutableCallGraphThis method enables to add calls that are edges in the call graph.- Specified by:
addCallin 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.invokableStmt- this paramter defines the invoke statement of the edge in the call graph.
-
addCall
Description copied from interface:MutableCallGraphThis method enables to add calls that are edges in the call graph.- Specified by:
addCallin interfaceMutableCallGraph- Parameters:
call- this parameter defines the call that is transformed to the edge in the call graph.
-
getMethodSignatures
Description copied from interface:CallGraphThis method returns method signatures in the call graph. A method signature is a node in the call graph.- Specified by:
getMethodSignaturesin interfaceCallGraph- Returns:
- a set containing all method signatures in the call graph.
-
getCalls
Description copied from interface:CallGraphThis method returns all calls in the call graph. Calls are a edges in the call graph. They contain the source, target and calling stmt. -
callTargetsFrom
Description copied from interface:CallGraphThis 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:
callTargetsFromin 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:CallGraphThis 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:
callSourcesToin 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
-
callsFrom
Description copied from interface:CallGraphThis 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:CallGraphThis 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 -
containsMethod
Description copied from interface:CallGraphThis method checks if a given method signature is a node in the call graph.- Specified by:
containsMethodin 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, @NonNull InvokableStmt invokableStmt) Description copied from interface:CallGraphThis 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:
containsCallin interfaceCallGraph- Parameters:
sourceMethod- it defines the source node in the call graphtargetMethod- it defines the target node in the call graphinvokableStmt- 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:CallGraphThis 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:
containsCallin 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:CallGraphThis method counts every edge in the call graph. -
copy
Description copied from interface:CallGraphThis method copies a call graph. -
diff
Description copied from interface:CallGraphThis method compares the difference between the current call graph and call graph passed into the argument. -
vertexOf
it returns the vertex of the graph that describes the given method signature in the call graph. It will throw an exception if the vertex is not found- Parameters:
method- the method signature searched in the call graph- Returns:
- the vertex of the requested method signature in optional otherwise an empty optional.
- Throws:
IllegalArgumentException- if there is no vertex for the requested method signature
-
edgeOf
protected @NonNull CallGraph.Call edgeOf(@NonNull MethodSignature source, @NonNull MethodSignature target, @NonNull InvokableStmt invokableStmt) it returns the edge of the graph that is described by the given source, target, stmt in the call graph. It will throw an exception if the source or target is not contained in the call graph or if the edge could not be found.- Parameters:
source- the signature of the source methodtarget- the signature of the target methodinvokableStmt- the stmt causing the call- Returns:
- the found edge in an optional or otherwise an empty optional
-
toString
This method exports the call graph in a human-readable string. The String lists all nodes in the call graph. For each node it also lists the outgoing and incoming edges. An outgoing edge is marked by a "To" and an incoming edge by a "From" The nodes, incoming edges, and outgoing edges are sorted in order by the classname, method name, parameter list -
printCallingMethods
This returns the string that is used in the toString Method to define the methods that call a specific method- Parameters:
call- The data of the call- Returns:
- The returned String will be used in the toString method to define the methods that call a specific method
-
printCalledMethods
This returns the string that is used in the toString Method to define the called methods- Parameters:
call- The data of the call- Returns:
- The returned String will be used in the toString method to define the called methods
-
getEntryMethods
Description copied from interface:CallGraphThis method returns all entry methods of the call graph- Specified by:
getEntryMethodsin interfaceCallGraph- Returns:
- a list of method signatures of entry points of the call graph
-