Package soot.jimple.toolkits.callgraph
Class CallGraph
- java.lang.Object
-
- soot.jimple.toolkits.callgraph.CallGraph
-
- Direct Known Subclasses:
SlowCallGraph
public class CallGraph extends Object implements Iterable<Edge>
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
-
-
Field Summary
Fields Modifier and Type Field Description protected Edge
dummy
protected Set<Edge>
edges
protected QueueReader<Edge>
reader
protected Map<MethodOrMethodContext,Edge>
srcMethodToEdge
protected Map<Unit,Edge>
srcUnitToEdge
protected ChunkedQueue<Edge>
stream
protected Map<MethodOrMethodContext,Edge>
tgtToEdge
-
Constructor Summary
Constructors Constructor Description CallGraph()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addEdge(Edge e)
Used to add an edge to the call graph.Iterator<Edge>
edgesInto(MethodOrMethodContext m)
Returns an iterator over all edges that have m as their target method.Iterator<Edge>
edgesOutOf(MethodOrMethodContext m)
Returns an iterator over all edges that have m as their source method.Iterator<Edge>
edgesOutOf(Unit u)
Returns an iterator over all edges that have u as their source unit.Edge
findEdge(Unit u, SootMethod callee)
Find the specific call edge that is going out from the callsite u and the call target is callee.boolean
isEntryMethod(SootMethod method)
Does this method have no incoming edge?Iterator<Edge>
iterator()
QueueReader<Edge>
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.QueueReader<Edge>
newListener()
Returns a QueueReader object which will contain ONLY NEW edges which will be added to the graph.boolean
removeAllEdgesOutOf(Unit u)
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.Iterator<MethodOrMethodContext>
sourceMethods()
Returns an iterator over all methods that are the sources of at least one edge.boolean
swapEdgesOutOf(Stmt out, Stmt in)
Swaps an invocation statement.String
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 Detail
-
stream
protected ChunkedQueue<Edge> stream
-
reader
protected QueueReader<Edge> reader
-
srcMethodToEdge
protected Map<MethodOrMethodContext,Edge> srcMethodToEdge
-
tgtToEdge
protected Map<MethodOrMethodContext,Edge> tgtToEdge
-
dummy
protected Edge dummy
-
-
Method Detail
-
addEdge
public boolean addEdge(Edge e)
Used to add an edge to the call graph. Returns true iff the edge was not already present.
-
removeAllEdgesOutOf
public boolean removeAllEdgesOutOf(Unit u)
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
public boolean swapEdgesOutOf(Stmt out, Stmt in)
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
public boolean removeEdge(Edge e)
Removes the edge e from the call graph. Returns true iff the edge was originally present in the call graph.
-
removeEdge
public boolean removeEdge(Edge e, boolean removeInEdgeList)
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
public boolean removeEdges(Collection<Edge> edges)
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
public boolean isEntryMethod(SootMethod method)
Does this method have no incoming edge?- Parameters:
method
-- Returns:
-
findEdge
public Edge findEdge(Unit u, SootMethod callee)
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
public Iterator<MethodOrMethodContext> sourceMethods()
Returns an iterator over all methods that are the sources of at least one edge.
-
edgesOutOf
public Iterator<Edge> edgesOutOf(Unit u)
Returns an iterator over all edges that have u as their source unit.
-
edgesOutOf
public Iterator<Edge> edgesOutOf(MethodOrMethodContext m)
Returns an iterator over all edges that have m as their source method.
-
edgesInto
public Iterator<Edge> edgesInto(MethodOrMethodContext m)
Returns an iterator over all edges that have m as their target method.
-
listener
public QueueReader<Edge> 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
public QueueReader<Edge> newListener()
Returns a QueueReader object which will contain ONLY NEW edges which will be added to the graph.
-
size
public int size()
Returns the number of edges in the call graph.
-
-