public class DOTCFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>> extends java.lang.Object implements CFGVisualizer<A,S,T>
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
checkerName |
protected java.util.Map<java.lang.String,java.lang.String> |
generated
Mapping from class/method representation to generated dot file.
|
protected java.lang.String |
outdir |
protected java.lang.StringBuilder |
sbBlock |
protected java.lang.StringBuilder |
sbDigraph |
protected java.lang.StringBuilder |
sbStore |
protected boolean |
verbose |
Constructor and Description |
---|
DOTCFGVisualizer() |
Modifier and Type | Method and Description |
---|---|
protected void |
addDotEdge(long sId,
long eId,
java.lang.String labelContent) |
protected java.lang.String |
dotOutputFileName(UnderlyingAST ast) |
protected java.lang.String |
escapeDoubleQuotes(java.lang.String str) |
protected java.lang.String |
generateDotGraph(ControlFlowGraph cfg,
Block entry,
@Nullable Analysis<A,S,T> analysis)
Generate the dot representation as String.
|
protected void |
generateDotNodes(java.util.Set<Block> visited,
ControlFlowGraph cfg,
@Nullable Analysis<A,S,T> analysis) |
protected java.util.IdentityHashMap<Block,java.util.List<java.lang.Integer>> |
getProcessOrder(ControlFlowGraph cfg) |
void |
init(java.util.Map<java.lang.String,java.lang.Object> args)
Initialization method guaranteed to be called once before the first invocation of
visualize . |
protected java.lang.String |
prepareNodeType(Node t) |
protected java.lang.String |
prepareString(java.lang.String s) |
void |
shutdown()
Write a file
methods.txt that contains a mapping from source code location to
generated dot file. |
protected java.lang.String |
toStringEscapeDoubleQuotes(java.lang.Object obj) |
@Nullable java.util.Map<java.lang.String,java.lang.Object> |
visualize(ControlFlowGraph cfg,
Block entry,
@Nullable Analysis<A,S,T> analysis)
Output a visualization representing the control flow graph starting at
entry . |
void |
visualizeBlock(Block bb,
@Nullable Analysis<A,S,T> analysis)
Produce a representation of the contests of a basic block.
|
void |
visualizeBlockNode(Node t,
@Nullable Analysis<A,S,T> analysis)
Visualize a Node based on the analysis.
|
void |
visualizeBlockTransferInput(Block bb,
Analysis<A,S,T> analysis)
Visualize the transferInput of a Block based on the analysis.
|
void |
visualizeSpecialBlock(SpecialBlock sbb)
Visualize a SpecialBlock.
|
void |
visualizeStore(S store)
Delegate the visualization responsibility to the passed
Store instance, which will
call back to this visualizer instance for sub-components. |
void |
visualizeStoreArrayVal(FlowExpressions.ArrayAccess arrayValue,
A value)
Called by
CFAbstractStore#internalVisualize() to visualize the value of arrays
collected by this Store. |
void |
visualizeStoreClassVals(FlowExpressions.ClassName className,
A value)
Called by
CFAbstractStore#internalVisualize() to visualize the value of class names
collected by this Store. |
void |
visualizeStoreFieldVals(FlowExpressions.FieldAccess fieldAccess,
A value)
Called by
CFAbstractStore#internalVisualize() to visualize the value of fields
collected by this Store. |
void |
visualizeStoreFooter()
Called by
CFAbstractStore to visualize any information after the invocation of CFAbstractStore#internalVisualize() . |
void |
visualizeStoreHeader(java.lang.String classCanonicalName)
Called by a
CFAbstractStore to visualize the class name before calling the CFAbstractStore#internalVisualize() method. |
void |
visualizeStoreKeyVal(java.lang.String keyName,
java.lang.Object value)
Called by
CFAbstractStore#internalVisualize() to visualize the specific information
collected according to the specific kind of Store. |
void |
visualizeStoreLocalVar(FlowExpressions.LocalVariable localVar,
A value)
Called by
CFAbstractStore#internalVisualize() to visualize a local variable. |
void |
visualizeStoreMethodVals(FlowExpressions.MethodCall methodCall,
A value)
Called by
CFAbstractStore#internalVisualize() to visualize the value of pure method
calls collected by this Store. |
void |
visualizeStoreThisVal(A value)
Called by
CFAbstractStore#internalVisualize() to visualize the value of the current
object this in this Store. |
protected java.lang.String outdir
protected boolean verbose
protected java.lang.String checkerName
protected java.lang.StringBuilder sbDigraph
protected java.lang.StringBuilder sbStore
protected java.lang.StringBuilder sbBlock
protected java.util.Map<java.lang.String,java.lang.String> generated
public void init(java.util.Map<java.lang.String,java.lang.Object> args)
CFGVisualizer
visualize
.init
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
args
- implementation-dependent optionspublic @Nullable java.util.Map<java.lang.String,java.lang.Object> visualize(ControlFlowGraph cfg, Block entry, @Nullable Analysis<A,S,T> analysis)
entry
. The
concrete actions are implementation dependent.
An invocation visualize(cfg, entry, null);
does not output stores at the beginning
of basic blocks.
visualize
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
cfg
- the CFG to visualizeentry
- the entry node of the control flow graph to be representedanalysis
- an analysis containing information about the program represented by the CFG.
The information includes Store
s that are valid at the beginning of basic blocks
reachable from entry
and per-node information for value producing Node
s.
Can also be null
to indicate that this information should not be output.protected java.lang.String generateDotGraph(ControlFlowGraph cfg, Block entry, @Nullable Analysis<A,S,T> analysis)
protected void generateDotNodes(java.util.Set<Block> visited, ControlFlowGraph cfg, @Nullable Analysis<A,S,T> analysis)
protected java.lang.String dotOutputFileName(UnderlyingAST ast)
protected java.util.IdentityHashMap<Block,java.util.List<java.lang.Integer>> getProcessOrder(ControlFlowGraph cfg)
public void visualizeBlock(Block bb, @Nullable Analysis<A,S,T> analysis)
visualizeBlock
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
bb
- basic block to visualizeanalysis
- the current analysispublic void visualizeSpecialBlock(SpecialBlock sbb)
CFGVisualizer
visualizeSpecialBlock
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
sbb
- the special blockpublic void visualizeBlockTransferInput(Block bb, Analysis<A,S,T> analysis)
CFGVisualizer
visualizeBlockTransferInput
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
bb
- the blockanalysis
- the current analysispublic void visualizeBlockNode(Node t, @Nullable Analysis<A,S,T> analysis)
CFGVisualizer
visualizeBlockNode
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
t
- the nodeanalysis
- the current analysisprotected java.lang.String prepareNodeType(Node t)
protected java.lang.String prepareString(java.lang.String s)
protected void addDotEdge(long sId, long eId, java.lang.String labelContent)
public void visualizeStore(S store)
CFGVisualizer
Store
instance, which will
call back to this visualizer instance for sub-components.visualizeStore
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
store
- the store to visualizepublic void visualizeStoreThisVal(A value)
CFGVisualizer
CFAbstractStore#internalVisualize()
to visualize the value of the current
object this
in this Store.visualizeStoreThisVal
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
value
- the value of the current object thispublic void visualizeStoreLocalVar(FlowExpressions.LocalVariable localVar, A value)
CFGVisualizer
CFAbstractStore#internalVisualize()
to visualize a local variable.visualizeStoreLocalVar
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
localVar
- the local variablevalue
- the value of the local variablepublic void visualizeStoreFieldVals(FlowExpressions.FieldAccess fieldAccess, A value)
CFGVisualizer
CFAbstractStore#internalVisualize()
to visualize the value of fields
collected by this Store.visualizeStoreFieldVals
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
fieldAccess
- the fieldvalue
- the value of the fieldpublic void visualizeStoreArrayVal(FlowExpressions.ArrayAccess arrayValue, A value)
CFGVisualizer
CFAbstractStore#internalVisualize()
to visualize the value of arrays
collected by this Store.visualizeStoreArrayVal
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
arrayValue
- the arrayvalue
- the value of the arraypublic void visualizeStoreMethodVals(FlowExpressions.MethodCall methodCall, A value)
CFGVisualizer
CFAbstractStore#internalVisualize()
to visualize the value of pure method
calls collected by this Store.visualizeStoreMethodVals
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
methodCall
- the pure method callvalue
- the value of the pure method callpublic void visualizeStoreClassVals(FlowExpressions.ClassName className, A value)
CFGVisualizer
CFAbstractStore#internalVisualize()
to visualize the value of class names
collected by this Store.visualizeStoreClassVals
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
className
- the class namevalue
- the value of the class namepublic void visualizeStoreKeyVal(java.lang.String keyName, java.lang.Object value)
CFGVisualizer
CFAbstractStore#internalVisualize()
to visualize the specific information
collected according to the specific kind of Store. Currently, these Stores call this method:
LockStore
, NullnessStore
, and InitializationStore
to visualize
additional information.visualizeStoreKeyVal
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
keyName
- the name of the specific information to be visualizedvalue
- the value of the specific information to be visualizedprotected java.lang.String escapeDoubleQuotes(java.lang.String str)
protected java.lang.String toStringEscapeDoubleQuotes(java.lang.Object obj)
public void visualizeStoreHeader(java.lang.String classCanonicalName)
CFGVisualizer
CFAbstractStore
to visualize the class name before calling the CFAbstractStore#internalVisualize()
method.visualizeStoreHeader
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
classCanonicalName
- the canonical name of the classpublic void visualizeStoreFooter()
CFGVisualizer
CFAbstractStore
to visualize any information after the invocation of CFAbstractStore#internalVisualize()
.visualizeStoreFooter
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
public void shutdown()
methods.txt
that contains a mapping from source code location to
generated dot file.shutdown
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>