Class CallGraph
java.lang.Object
proguard.analysis.datastructure.callgraph.CallGraph
Collection of all
Calls in a program, optimized for retrieval of incoming and outgoing
edges for any method in constant time.-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Map<MethodSignature,Set<Call>> final Map<MethodSignature,Set<Call>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreate an empty call graph.protectedCallGraph(Map<MethodSignature, Set<Call>> incoming, Map<MethodSignature, Set<Call>> outgoing, boolean concurrent) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd aCallto this call graph.voidclear()Clear the call graph references.static CallGraphreconstructCallGraph(ClassPool programClassPool, MethodSignature start, int maxDepth, int maxWidth, Set<MethodSignature> stopMethods) Calculate the incoming call graph for a method of interest, showing how it can be reached from a given Set of stop methods, which typically are Android lifecycle methods such as an Activity's onCreate() method:reconstructCallGraph(ClassPool programClassPool, MethodSignature start, Set<MethodSignature> stopMethods) reconstructCallGraph(ClassPool programClassPool, MethodSignature start, Set<MethodSignature> stopMethods, Set<MethodSignature> reachedMethods) Extension ofreconstructCallGraph(ClassPool, MethodSignature, Set)that also collects all reached stop methods.toDot()Produces a DOT graph representation of the given call graph.voidWrites a DOT graph representation of the given call graph.
-
Field Details
-
incoming
-
outgoing
-
-
Constructor Details
-
CallGraph
public CallGraph()Create an empty call graph. -
CallGraph
protected CallGraph(Map<MethodSignature, Set<Call>> incoming, Map<MethodSignature, Set<Call>> outgoing, boolean concurrent)
-
-
Method Details
-
concurrentCallGraph
Provides concurrency readyCallGraph, backed byConcurrentHashMaps and byConcurrentSkipListSets. Not needed without multithreading. -
addCall
Add aCallto this call graph.- Parameters:
call- The call to be added.
-
clear
public void clear()Clear the call graph references. -
reconstructCallGraph
public Node reconstructCallGraph(ClassPool programClassPool, MethodSignature start, Set<MethodSignature> stopMethods) - Parameters:
programClassPool- The currentClassPoolof the program that can be used for mapping. class names to the actualClazz.start- TheMethodSignatureof the method whose incoming call graph should be calculated.stopMethods- Set ofMethodSignatureto stop exploration at, if desired.- Returns:
- A
Nodethat represents the single call graph root, i.e. the start method.
-
reconstructCallGraph
public Node reconstructCallGraph(ClassPool programClassPool, MethodSignature start, int maxDepth, int maxWidth, Set<MethodSignature> stopMethods) Calculate the incoming call graph for a method of interest, showing how it can be reached from a given Set of stop methods, which typically are Android lifecycle methods such as an Activity's onCreate() method:We have an inverted tree structure like the following example:
Here,onCreate() <-- predecessor -- proxy() <-- predecessor -- root() onResume() <-- predecessor ----| | unusedMethod() <-- predecessor -------|root()is the method whose call graph is to be calculated, and the graph now shows that it can be reached fromonCreate()viaproxy(), and also directly fromonResume()orunusedMethod().- Parameters:
programClassPool- The currentClassPoolof the program that can be used for mapping. class names to the actualClazz.start- TheMethodSignatureof the method whose incoming call graph should be calculated.maxDepth- maximal depth of reconstructedCallGraphsimilar toCallGraphWalker.MAX_DEPTH_DEFAULT.maxWidth- maximal width of reconstructedCallGraphsimilar toCallGraphWalker.MAX_WIDTH_DEFAULT.stopMethods- Set of method signatures to stop exploration, for example for entry points- Returns:
- A
Nodethat represents the single call graph root, i.e. the start method.
-
reconstructCallGraph
public Node reconstructCallGraph(ClassPool programClassPool, MethodSignature start, Set<MethodSignature> stopMethods, Set<MethodSignature> reachedMethods) Extension ofreconstructCallGraph(ClassPool, MethodSignature, Set)that also collects all reached stop methods.- Parameters:
programClassPool- The currentClassPoolof the program that can be used for mapping.start- TheMethodSignatureof the method whose incoming call graph should be calculated.stopMethods- A set ofMethodSignatureto stop exploration, e.g. app entry pointsreachedMethods- A set that will be filled with all reached stop methods- Returns:
- A
Nodethat represents the single call graph root, i.e. the start method.
-
writeDot
Writes a DOT graph representation of the given call graph.- Throws:
IOException
-
toDot
Produces a DOT graph representation of the given call graph.
-