# Class: com.pnfsoftware.jeb.core.units.code.CFGUtil

Utility code for [IControlFlowGraph](IControlFlowGraph).

## Static Method: canReach
- parameter: `from`, type: `com.pnfsoftware.jeb.core.units.code.IBasicBlock<? extends com.pnfsoftware.jeb.core.units.code.IInstruction>`
- parameter: `to`, type: `com.pnfsoftware.jeb.core.units.code.IBasicBlock<? extends com.pnfsoftware.jeb.core.units.code.IInstruction>`
- return type: `boolean`

Description: Determine whether a regular path exists between a source block and a destination block. If both source and destination blocks are the same block B, the method returns true if B is part of a regular loop \(i.e., a path exists from B to B\). Exceptional flow \(irregular edges\) are disregarded.
parameter: from: source block
parameter: to: destination block
return: true if a path exists between the source and the destination

## Static Method: canReach
- parameter: `from`, type: `com.pnfsoftware.jeb.core.units.code.IBasicBlock<? extends com.pnfsoftware.jeb.core.units.code.IInstruction>`
- parameter: `to`, type: `com.pnfsoftware.jeb.core.units.code.IBasicBlock<? extends com.pnfsoftware.jeb.core.units.code.IInstruction>`
- parameter: `alsoFollowIrregularFlow`, type: `boolean`
- return type: `boolean`

Description: Determine whether a path exists between a source block and a destination block. If both source and destination blocks are the same block B, the method returns true if B is part of a loop \(i.e., a path exists from B to B\).
parameter: from: source block
parameter: to: destination block
parameter: alsoFollowIrregularFlow: if true, irregular control flow will also be followed
return: true if a path exists between the source and the destination

## Static Method: canReach
- parameter: `from`, type: `com.pnfsoftware.jeb.core.units.code.IBasicBlock<? extends com.pnfsoftware.jeb.core.units.code.IInstruction>`
- parameter: `to`, type: `com.pnfsoftware.jeb.core.units.code.IBasicBlock<? extends com.pnfsoftware.jeb.core.units.code.IInstruction>`
- parameter: `alsoFollowIrregularFlow`, type: `boolean`
- parameter: `stopperBlocks`, type: `java.util.Collection<com.pnfsoftware.jeb.core.units.code.IBasicBlock<? extends com.pnfsoftware.jeb.core.units.code.IInstruction>>`
- return type: `boolean`

Description: Determine whether a path exists between a source block and a destination block. If both source and destination blocks are the same block B, the method returns true if B is part of a loop \(i.e., a path exists from B to B\).
parameter: from: source block
parameter: to: destination block
parameter: alsoFollowIrregularFlow: if true, irregular control flow will also be followed
parameter: stopperBlocks: blocks where exploration should stop
return: true if a path exists between the source and the destination

## Static Method: countDeepInputs
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.IBasicBlock<? extends com.pnfsoftware.jeb.core.units.code.IInstruction>`
- parameter: `maxdepth`, type: `int`
- return type: `int`

Description: Count regular the number of top\-level input blocks leading to the provided block.
parameter: b: the basic block to be examined
parameter: maxdepth: if less or equal than 1, this method is equivalent to            [IBasicBlock#insize()](IBasicBlock#insize())
return: the number of inputs

## Static Method: toDot
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.IControlFlowGraph<?,?>`
- parameter: `file`, type: `java.io.File`

Description: Build the CFG text representation using the dot language. To generate a PNG: `dot
 out.dot -Tpng -o out.png`
parameter: cfg: control flow graph
parameter: file: output file
throws: if the file cannot be written

## Static Method: toDot
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.IControlFlowGraph<?,?>`
- parameter: `file`, type: `java.io.File`
- parameter: `title`, type: `java.lang.String`

Description: Build the CFG text representation using the dot language. To generate a PNG: `dot
 out.dot -Tpng -o out.png`
parameter: cfg: control flow graph
parameter: file: output file
parameter: title: optional graph title
throws: if the file cannot be written

## Static Method: toDot
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.IControlFlowGraph<?,?>`
- parameter: `file`, type: `java.io.File`
- parameter: `title`, type: `java.lang.String`
- parameter: `blockHeaders`, type: `java.util.Map<java.lang.Long,java.lang.String>`

Description: Build the CFG text representation using the dot language. To generate a PNG: `dot
 out.dot -Tpng -o out.png`
parameter: cfg: control flow graph
parameter: file: output file
parameter: title: optional graph title
parameter: blockHeaders: optional map of block headers \(block\_address \-\>            block\_description\_string\); if null, a standard header "\(block\_index\)" is used
throws: if the file cannot be written

## Static Method: toDot
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.IControlFlowGraph<?,?>`
- parameter: `file`, type: `java.io.File`
- parameter: `title`, type: `java.lang.String`
- parameter: `blockHeaders`, type: `java.util.Map<java.lang.Long,java.lang.String>`
- parameter: `lineLimit`, type: `int`

Description: Build the CFG text representation using the dot language. To generate a PNG: `dot
 out.dot -Tpng -o out.png`
parameter: cfg: control flow graph
parameter: file: output file
parameter: title: optional graph title
parameter: blockHeaders: optional block headers
parameter: lineLimit: line limit
throws: if the file cannot be written

## Static Method: toTempDot
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.IControlFlowGraph<?,?>`
- parameter: `name`, type: `java.lang.String`

Description: Write a CFG dot file to a temporary file.
parameter: cfg: control flow graph
parameter: name: temporary file name

## Static Method: toTempDot
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.IControlFlowGraph<?,?>`
- parameter: `name`, type: `java.lang.String`
- parameter: `title`, type: `java.lang.String`
- parameter: `blockHeaders`, type: `java.util.Map<java.lang.Long,java.lang.String>`
- parameter: `lineLimit`, type: `int`

Description: Write a CFG dot file to a temporary file.
parameter: cfg: control flow graph
parameter: name: temporary file name
parameter: title: optional graph title
parameter: blockHeaders: optional block headers
parameter: lineLimit: line limit

## Static Method: verify
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.IControlFlowGraph<?,?>`

Description: Verification of a CFG. Throws [RuntimeException](RuntimeException) \(or derived\) on error. 

 Calls [#verify(IControlFlowGraph, boolean, boolean, boolean, boolean, boolean)](#verify(IControlFlowGraph, boolean, boolean, boolean, boolean, boolean)) with all optional checks enabled.
parameter: cfg: the CFG to be verified
throws: if the verification failed

## Static Method: verify
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.IControlFlowGraph<?,?>`
- parameter: `checkConnected`, type: `boolean`
- parameter: `checkGapless`, type: `boolean`
- parameter: `checkFlowinfo`, type: `boolean`
- parameter: `checkNoDupEdges`, type: `boolean`
- parameter: `checkNoDupIrregularEdges`, type: `boolean`

Description: Verification of a CFG. Throws [RuntimeException](RuntimeException) \(or derived\) on error. 

 This method checks the following:
 \- the graph is not empty
 \- no block is empty
 \- all blocks are reachable, either regularly or irregularly, from the entry node \#0
 

 Additional optional checks can be performed, see the parameters.
parameter: cfg: the CFG to be verified
parameter: checkConnected: if true, the graph is verified to be connected, i.e. all blocks must be            reachable from the entry block
parameter: checkGapless: if true, the graph cannot have gaps between basic blocks
parameter: checkFlowinfo: if true, consistency checks between            [IInstruction#getBreakingFlow(long)](IInstruction#getBreakingFlow(long)) and            [IBasicBlock#getOutputBlocks()](IBasicBlock#getOutputBlocks()) are performed
parameter: checkNoDupEdges: if true, verify that CFG input/output regular edges of basic blocks do            not contain duplicates
parameter: checkNoDupIrregularEdges: if true, verify that CFG input/output irregular edges of            basic blocks do not contain duplicates
throws: if the verification failed

