Class ExceptionalBlockGraph
- java.lang.Object
-
- soot.toolkits.graph.BlockGraph
-
- soot.toolkits.graph.ExceptionalBlockGraph
-
- All Implemented Interfaces:
Iterable<Block>,DirectedBodyGraph<Block>,DirectedGraph<Block>,ExceptionalGraph<Block>
- Direct Known Subclasses:
CompleteBlockGraph
public class ExceptionalBlockGraph extends BlockGraph implements ExceptionalGraph<Block>
Represents a CFG where the nodes are
Blocks and the edges are derived from control flow. Control flow associated with exceptions is taken into account: when aUnitmay throw an exception that is caught by aTrapwithin theBody, the exceptingUnitstarts a new basic block (Units do not start a new block when all the exceptions they might throw would escape the method without being caught).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExceptionalBlockGraph.ExceptionDest
-
Field Summary
Fields Modifier and Type Field Description protected Map<Block,List<Block>>blockToExceptionalPredsprotected Map<Block,List<Block>>blockToExceptionalSuccsprotected Map<Block,Collection<ExceptionalBlockGraph.ExceptionDest>>blockToExceptionDestsprotected Map<Block,List<Block>>blockToUnexceptionalPredsprotected Map<Block,List<Block>>blockToUnexceptionalSuccsprotected ThrowAnalysisthrowAnalysis
-
Constructor Summary
Constructors Constructor Description ExceptionalBlockGraph(Body body)Constructs anExceptionalBlockGraphfor the blocks found by partitioning the the units of the providedBodyinstance into basic blocks.ExceptionalBlockGraph(ExceptionalUnitGraph unitGraph)Constructs a graph for the blocks found by partitioning the theUnits in anExceptionalUnitGraph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<Unit,Block>buildBlocks(Set<Unit> leaders, UnitGraph uncastUnitGraph)A utility method that does most of the work of constructing basic blocks, once the set of block leaders has been determined, and which designates the heads and tails of the graph.List<Block>getExceptionalPredsOf(Block b)Returns a list of nodes which are predecessors of a given node when only exceptional control flow is considered.List<Block>getExceptionalSuccsOf(Block b)Returns a list of nodes which are successors of a given node when only exceptional control flow is considered.Collection<ExceptionalBlockGraph.ExceptionDest>getExceptionDests(Block b)Returns a collection ofExceptionDestobjects which represent how exceptions thrown by a specified node will be handled.List<Block>getUnexceptionalPredsOf(Block b)Returns a list of nodes which are predecessors of a given node when only unexceptional control flow is considered.List<Block>getUnexceptionalSuccsOf(Block b)Returns a list of nodes which are successors of a given node when only unexceptional control flow is considered.-
Methods inherited from class soot.toolkits.graph.BlockGraph
computeLeaders, getBlocks, getBody, getHeads, getPredsOf, getSuccsOf, getTails, iterator, size, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface soot.toolkits.graph.DirectedGraph
getHeads, getPredsOf, getSuccsOf, getTails, iterator, size
-
Methods inherited from interface soot.toolkits.graph.ExceptionalGraph
getBody
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
blockToExceptionDests
protected Map<Block,Collection<ExceptionalBlockGraph.ExceptionDest>> blockToExceptionDests
-
throwAnalysis
protected ThrowAnalysis throwAnalysis
-
-
Constructor Detail
-
ExceptionalBlockGraph
public ExceptionalBlockGraph(Body body)
Constructs an
ExceptionalBlockGraphfor the blocks found by partitioning the the units of the providedBodyinstance into basic blocks.Note that this constructor builds an
ExceptionalUnitGraphinternally when splittingbody'sUnits intoBlocks. Callers who already have anExceptionalUnitGraphto hand can use the constructor taking anExceptionalUnitGraphas a parameter, as a minor optimization.- Parameters:
body- The underlying body we want to make a graph for.
-
ExceptionalBlockGraph
public ExceptionalBlockGraph(ExceptionalUnitGraph unitGraph)
Constructs a graph for the blocks found by partitioning the theUnits in anExceptionalUnitGraph.- Parameters:
unitGraph- TheExceptionalUnitGraphwhoseUnits are to be split into blocks.
-
-
Method Detail
-
buildBlocks
protected Map<Unit,Block> buildBlocks(Set<Unit> leaders, UnitGraph uncastUnitGraph)
A utility method that does most of the work of constructing basic blocks, once the set of block leaders has been determined, and which designates the heads and tails of the graph.
BlockGraphprovides an implementation ofbuildBlocks()which splits theUnits inunitGraphso that eachUnitin the passed set of block leaders is the first unit in a block. It defines as heads the blocks which begin withUnits which are heads inunitGraph, and defines as tails the blocks which end withUnits which are tails inunitGraph. Subclasses might override this behavior. This implementation calls the inherited implementation to split units into blocks, before adding the distinctions between exceptional and unexceptional control flow.- Overrides:
buildBlocksin classBlockGraph- Parameters:
leaders- ContainsUnits which are to be block leaders.uncastUnitGraph- Provides information about the predecessors and successors of eachUnitin theBody, for determining the predecessors and successors of each createdBlock.- Returns:
- a
MapfromUnits which begin or end a block to the block which contains them.
-
getUnexceptionalPredsOf
public List<Block> getUnexceptionalPredsOf(Block b)
Description copied from interface:ExceptionalGraphReturns a list of nodes which are predecessors of a given node when only unexceptional control flow is considered.- Specified by:
getUnexceptionalPredsOfin interfaceExceptionalGraph<Block>- Parameters:
b- The node whose predecessors are to be returned.- Returns:
- a
Listof the nodes in this graph from which there is an unexceptional edge ton.
-
getUnexceptionalSuccsOf
public List<Block> getUnexceptionalSuccsOf(Block b)
Description copied from interface:ExceptionalGraphReturns a list of nodes which are successors of a given node when only unexceptional control flow is considered.- Specified by:
getUnexceptionalSuccsOfin interfaceExceptionalGraph<Block>- Parameters:
b- The node whose successors are to be returned.- Returns:
- a
Listof nodes in this graph to which there is an unexceptional edge fromn.
-
getExceptionalPredsOf
public List<Block> getExceptionalPredsOf(Block b)
Description copied from interface:ExceptionalGraphReturns a list of nodes which are predecessors of a given node when only exceptional control flow is considered.- Specified by:
getExceptionalPredsOfin interfaceExceptionalGraph<Block>- Parameters:
b- The node whose predecessors are to be returned.- Returns:
- a
Listof nodes in this graph from which there is an exceptional edge ton.
-
getExceptionalSuccsOf
public List<Block> getExceptionalSuccsOf(Block b)
Description copied from interface:ExceptionalGraphReturns a list of nodes which are successors of a given node when only exceptional control flow is considered.- Specified by:
getExceptionalSuccsOfin interfaceExceptionalGraph<Block>- Parameters:
b- The node whose successors are to be returned.- Returns:
- a
Listof nodes in this graph to which there is an exceptional edge fromn.
-
getExceptionDests
public Collection<ExceptionalBlockGraph.ExceptionDest> getExceptionDests(Block b)
Description copied from interface:ExceptionalGraphReturns a collection ofExceptionDestobjects which represent how exceptions thrown by a specified node will be handled.- Specified by:
getExceptionDestsin interfaceExceptionalGraph<Block>- Parameters:
b- The node for which to provide exception information.- Returns:
- a collection of
ExceptionDestobjects describing the traps and handlers, if any, which catch the exceptions which may be thrown byn.
-
-