|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sofya.graphs.Graph sofya.graphs.cfg.CFG
public class CFG
Class which represents the basic block control flow graph for a given method.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface sofya.base.SConstants |
---|
SConstants.BlockLabel, SConstants.BlockObjectType, SConstants.BlockSubType, SConstants.BlockType, SConstants.BranchObjectType, SConstants.BranchType, SConstants.EDObjectType, SConstants.TraceObjectType |
Field Summary | |
---|---|
protected gnu.trove.TIntObjectHashMap |
blockOffsetMap
Lookup table which maps bytecode offsets to blocks, used to optimize retrieval of successor blocks when constructing edges. |
protected java.lang.String |
displayString
Human-friendly string for the method for which this CFG was built. |
protected MethodSignature |
methodSignature
Signature of the method for which the control flow graph is built. |
Fields inherited from class sofya.graphs.Graph |
---|
edges, MATCH_INCOMING, MATCH_OUTGOING, nodes |
Fields inherited from interface sofya.base.SConstants |
---|
DEFAULT_PORT, INST_COMPATIBLE, INST_OLD_UNSUPPORTED, INST_OPT_NORMAL, INST_OPT_SEQUENCE, SIG_CHKALIVE, SIG_ECHO |
Constructor Summary | |
---|---|
protected |
CFG(MethodSignature signature,
java.lang.String displayString)
Creates a control flow graph. |
protected |
CFG(java.lang.String displayString)
Creates a control flow graph. |
Method Summary | |
---|---|
protected void |
addBlock(Block b)
Adds a block to the CFG. |
protected void |
addEdge(Edge e)
Adds an edge to the list of edges. |
protected Block |
addExceptionalExit(Block realExit)
Creates and adds to the CFG an exceptional exit block associated with a given 'real' block. |
protected void |
addNode(Node n)
Adds a node to the CFG, creating an entry in the offset map so the block can be retrieved by its start offset later. |
Block[] |
getBasicBlocks()
Gets the basic blocks in this control flow graph. |
Block[] |
getBasicBlocks(int typeMask)
Gets the basic blocks in this control flow graph corresponding to selected types. |
Block |
getBlock(int id)
Gets a block from the node list. |
int |
getHighestNodeId()
Returns the highest node ID in the control flow graph. |
java.lang.String |
getMethodName()
Returns the name of the method with which this control flow graph is associated. |
int |
getNumberOfBranches()
Returns the number of branches in the control flow graph. |
int |
getNumberOfEdges()
Returns the number of edges in the control flow graph. |
int |
getNumberOfNodes()
Returns the number of nodes in the control flow graph. |
int |
getRootNodeID()
Returns the ID of the root node of the control flow graph. |
MethodSignature |
getSignature()
Gets the signature of the method that this CFG models. |
int |
getSummaryBranchID()
Returns the ID of summary branch, which captures all exceptional exits from the method that cannot be precisely identified. |
protected void |
setNumberOfBranches(int count)
Sets the number of branches in the control flow graph, for use by CFHandler . |
protected void |
setSignature(MethodSignature ms)
Sets the signature of the method that this CFG models. |
protected void |
setSummaryBranchID(int id)
Sets the ID of summary branch. |
java.lang.String |
toString()
Returns string representation of the control flow graph, which is a list of the edges that constitute the CFG. |
Methods inherited from class sofya.graphs.Graph |
---|
clear, getEdge, getEdgeCount, getEdges, getEdges, getEdges, getNode, getNodeCount, getRootNode, removeEdge, removeNode |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected MethodSignature methodSignature
protected java.lang.String displayString
protected gnu.trove.TIntObjectHashMap blockOffsetMap
Constructor Detail |
---|
protected CFG(MethodSignature signature, java.lang.String displayString)
signature
- Signature of the method for which the control flow
graph will be built.displayString
- Human-friendly string to represent the method
for which the control flow graph will be built.protected CFG(java.lang.String displayString)
Used by the MapHandler
primarily to provide legacy
support.
displayString
- Human-friendly string to represent the method
for which the control flow graph is/was built.Method Detail |
---|
public MethodSignature getSignature()
protected void setSignature(MethodSignature ms)
ms
- The signature of the method for which this CFG has
been constructed.public Block[] getBasicBlocks()
public Block[] getBasicBlocks(int typeMask)
typeMask
- Bitmask indicating the types of basic blocks to
be retrieved.
public Block getBlock(int id)
id
- ID of the block to be retrieved.
protected void addEdge(Edge e)
addEdge
in class Graph
e
- Edge to be added to the CFG.Edge
protected void addNode(Node n)
If the given node is not a Block
, this
method behaves identically to the implementation in
Graph
. 'Virtual' blocks (entry, exit, and return)
are not added to the offset map. This is because the offset map is an
optimization to speed up the creation of the most common types of edges
representing flow of control through actual code. Creation of edges
pointing to virtual nodes is handled explicitly as necessary.
addNode
in class Graph
n
- Node to be added to the graph, typically expected to be a
Block
.protected void addBlock(Block b)
b
- Block to be added to the CFG.Block
protected Block addExceptionalExit(Block realExit)
Note: The new block created by this method will not be connected to any other blocks through any predecessor or successor references. An edge connecting the blocks must also be added to establish those relationships. However, the (virtual) exit block's start and end offsets will be equivalent to those of the 'real' node with which it is associated.
realExit
- Block which represents the actual code at which the
exit occurs.
Block
public int getNumberOfNodes()
public int getNumberOfEdges()
public int getNumberOfBranches()
protected void setNumberOfBranches(int count)
CFHandler
.
count
- The number of branches (branch IDs) in the control
flow graph.public int getHighestNodeId()
public java.lang.String getMethodName()
public int getRootNodeID()
public int getSummaryBranchID()
protected void setSummaryBranchID(int id)
id
- The ID of summary branch.public java.lang.String toString()
toString
in class Graph
Block.toString()
,
Edge.toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |