public class

CFG

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.asm.decompiler.ast.emulator.CFG

Class Overview

Control-Flow Graph (CFG) representing the control-flow of an ICMethod.

This class is a minimal implementation to be used by SimpleCEmulator. The computed graph only provides the reachable statements from each statement (through getFallThroughTarget(ICStatement) and getConditionalTarget(ICStatement, int)).

Known limitations/simplifications:

  • statements are assumed to be unique within the method, and serves to identify graph nodes (i.e. no basic blocks)
  • for compound statements (see ICCompound), the embedded ICBlock are kept in the CFG and transfer control to their first statement
  • do-while loops are not specifically handled; they are ordered as while-loops
  • switch-case are not handled
  • predicates are not stored on their corresponding edges; it's the client responsibility to retrieve them
  • graph exit(s) are represented by 'null' nodes

Summary

Public Constructors
CFG()
Public Methods
static CFG buildCFG(ICMethod method)
Process method's AST and build the corresponding CFG.
ICStatement getConditionalTarget(ICStatement from)
Get the statement reachable from the given statement, when its predicate is true.
ICStatement getConditionalTarget(ICStatement from, int n)
Get the statement reachable from the given statement, when its n-th predicate is true.
ICStatement getEntryPoint()
Get CFG entry point.
ICStatement getFallThroughTarget(ICStatement from)
Get the fallthrough statement reachable from the given statement.
void setEntryPoint(ICStatement entryPoint)
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public CFG ()

Public Methods

public static CFG buildCFG (ICMethod method)

Process method's AST and build the corresponding CFG.

Returns
  • cfg of the method

public ICStatement getConditionalTarget (ICStatement from)

Get the statement reachable from the given statement, when its predicate is true. For multi-predicates statement, see getConditionalTarget(ICStatement, int).

Returns
  • statement conditionally reachable, null if none

public ICStatement getConditionalTarget (ICStatement from, int n)

Get the statement reachable from the given statement, when its n-th predicate is true. This method is the preferred one for multi-predicate statements (if-elseif-..), and the reachable statements are ordered as they are in their container statement.

Returns
  • the n-th conditionally reachable statement, null if none

public ICStatement getEntryPoint ()

Get CFG entry point.

Returns
  • cfg entry point, might be null

public ICStatement getFallThroughTarget (ICStatement from)

Get the fallthrough statement reachable from the given statement.

The fallthrough statement is either the unique reachable statement for an unconditional statement, or the statement reachable when the predicate(s) are false for conditional statements.

Returns
  • fallthrough statement, might be null

public void setEntryPoint (ICStatement entryPoint)

public String toString ()