public class CallGraph
extends java.lang.Object
Call
s in a program, optimized for retrieval
of incoming and outgoing edges for any method in constant time.Modifier and Type | Field and Description |
---|---|
java.util.Map<MethodSignature,java.util.Set<Call>> |
incoming |
java.util.Map<MethodSignature,java.util.Set<Call>> |
outgoing |
Constructor and Description |
---|
CallGraph() |
Modifier and Type | Method and Description |
---|---|
void |
addCall(Call call)
Add a
Call to this call graph. |
void |
clear()
Clear the call graph references.
|
Node |
reconstructCallGraph(ClassPool programClassPool,
MethodSignature start)
|
Node |
reconstructCallGraph(ClassPool programClassPool,
MethodSignature start,
int maxDepth,
int maxWidth)
Calculate the incoming call graph for a method of interest, showing how it can be reached.
|
Node |
reconstructCallGraph(ClassPool programClassPool,
MethodSignature start,
java.util.Set<EntryPoint> entryPoints)
Extension of
reconstructCallGraph(ClassPool, MethodSignature) that also collects
all EntryPoint s found along the way. |
public final java.util.Map<MethodSignature,java.util.Set<Call>> incoming
public final java.util.Map<MethodSignature,java.util.Set<Call>> outgoing
public void addCall(Call call)
Call
to this call graph.call
- The call to be added.public void clear()
public Node reconstructCallGraph(ClassPool programClassPool, MethodSignature start)
programClassPool
- The current ClassPool
of the program that can be used for mapping.
class names to the actual Clazz
.start
- The MethodSignature
of the method whose incoming call graph
should be calculated.Node
that represents the single call graph root, i.e. the start method.public Node reconstructCallGraph(ClassPool programClassPool, MethodSignature start, int maxDepth, int maxWidth)
We have an inverted tree structure like the following example:
onCreate() <-- predecessor -- proxy() <-- predecessor -- root()
onResume() <-- predecessor ----| |
unusedMethod() <-- predecessor -------|
Here, root()
is the method whose call graph is to be calculated, and the graph now shows
that it can be reached from onCreate()
via proxy()
, and also directly from
onResume()
or unusedMethod()
.
Generally, we still can't be sure whether the top most methods (leaves in the tree) can be
reached themselves, if we don't find any incoming edges. But if these methods are EntryPoint
s
of an Android app, they will most likely be called at some point in the app lifecycle.
programClassPool
- The current ClassPool
of the program that can be used for mapping.
class names to the actual Clazz
.start
- The MethodSignature
of the method whose incoming call graph
should be calculated.maxDepth
- maximal depth of reconstructed CallGraph
similar to CallGraphWalker.MAX_DEPTH_DEFAULT
.maxWidth
- maximal width of reconstructed CallGraph
similar to CallGraphWalker.MAX_WIDTH_DEFAULT
.Node
that represents the single call graph root, i.e. the start method.public Node reconstructCallGraph(ClassPool programClassPool, MethodSignature start, java.util.Set<EntryPoint> entryPoints)
reconstructCallGraph(ClassPool, MethodSignature)
that also collects
all EntryPoint
s found along the way.programClassPool
- The current ClassPool
of the program that can be used for mapping.start
- The MethodSignature
of the method whose incoming call graph
should be calculated.entryPoints
- A set that will be filled with all EntryPoint
s that are part
of the incoming call graph.Node
that represents the single call graph root, i.e. the start method.