public class

CFGFormatter

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.asm.cfg.CFGFormatter<InsnType extends com.pnfsoftware.jeb.core.units.code.IInstruction>
Known Direct Subclasses

Class Overview

Customizable CFG formatter.

Sub-classes are permitted. Protected methods genXxx() may be overridden to customize rendering.

Summary

Fields
public static final AtomicInteger cfgfwccnt Performance counter reserved for internal use.
Public Constructors
CFGFormatter(CFG<InsnType> cfg)
Legacy CFG formatter.
CFGFormatter(CFG<InsnType> cfg, IVariableProvider varprv, boolean formatFineGrained)
Build a CFG formatter with an optional variable provider to aid in the representation of data chains.
Public Methods
String format(boolean formatAddresses, boolean formatChains, boolean formatInOut, IDFA<InsnType> dfa, IFormattingContextFactory<InsnType> fcf)
Format the CFG into a printable string, with optional data chains.
static <T extends Number> String formatChains(Map<Integer, Collection<T>> chains, IVariableProvider varprv)
final String formatSimple()
Convenience method.
final CFG<InsnType> getCfg()
Protected Methods
void genAddress(StringBuilder sb, long address, InsnType insn)
The default implementation generates ADDRESS/SIZE.
void genAddressCharacter(StringBuilder sb, long address, InsnType insn, BasicBlock<InsnType> b, int i)
The default implementation generates one of:
: (default) > (entry) + (block) * (handler) v (branching down) ^ (branching up)
void genBOL(StringBuilder sb, long address, InsnType insn)
The default implementation does nothing.
void genEOL(StringBuilder sb, long address, InsnType insn)
The default implementation appends a New Line (\n) character.
void genHeader(StringBuilder sb)
The default implementation does nothing.
void genPostAddress(StringBuilder sb, long address, InsnType insn)
The default implementation appends 2 spaces.
void genPostChains(StringBuilder sb, long address, InsnType insn)
The default implementation appends spaces to pad the current line to 2000 characters (or more).
void genPostInstruction(StringBuilder sb, long address, InsnType insn)
The default implementation appends spaces to pad the current line to 120 characters (or more).
void genPreAddress(StringBuilder sb, long address, InsnType insn)
The default implementation does nothing.
void genPreChains(StringBuilder sb, long address, InsnType insn)
The default implementation does nothing.
void genPreInstruction(StringBuilder sb, long address, InsnType insn)
The default implementation does nothing.
void genTrailer(StringBuilder sb)
The default implementation does nothing.
final void padLine(StringBuilder sb, int alignLen)
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final AtomicInteger cfgfwccnt

Performance counter reserved for internal use.

Public Constructors

public CFGFormatter (CFG<InsnType> cfg)

Legacy CFG formatter. Variables/registers/bits in data chains are represented by their ids.

Parameters
cfg a CFG

public CFGFormatter (CFG<InsnType> cfg, IVariableProvider varprv, boolean formatFineGrained)

Build a CFG formatter with an optional variable provider to aid in the representation of data chains.

Parameters
cfg a CFG
varprv optional variable provider
formatFineGrained N/A if varprv is null; else, determine if the chains should be represented fine grained (partial variable use is explicitly shown), or coarse grained (any bit of a variable being used will be represented as a full variable use)

Public Methods

public String format (boolean formatAddresses, boolean formatChains, boolean formatInOut, IDFA<InsnType> dfa, IFormattingContextFactory<InsnType> fcf)

Format the CFG into a printable string, with optional data chains.

Parameters
formatAddresses true to prepend instructions by their address
formatChains true to format data chains
formatInOut true to format the input and output chains
dfa DFA object
fcf optional context generator for instructions
Returns
  • the formatted CFG

public static String formatChains (Map<Integer, Collection<T>> chains, IVariableProvider varprv)

public final String formatSimple ()

Convenience method. Format a CFG without any chain.

public final CFG<InsnType> getCfg ()

Protected Methods

protected void genAddress (StringBuilder sb, long address, InsnType insn)

The default implementation generates ADDRESS/SIZE.

protected void genAddressCharacter (StringBuilder sb, long address, InsnType insn, BasicBlock<InsnType> b, int i)

The default implementation generates one of:
: (default) > (entry) + (block) * (handler) v (branching down) ^ (branching up)

protected void genBOL (StringBuilder sb, long address, InsnType insn)

The default implementation does nothing.

protected void genEOL (StringBuilder sb, long address, InsnType insn)

The default implementation appends a New Line (\n) character.

protected void genHeader (StringBuilder sb)

The default implementation does nothing.

protected void genPostAddress (StringBuilder sb, long address, InsnType insn)

The default implementation appends 2 spaces.

protected void genPostChains (StringBuilder sb, long address, InsnType insn)

The default implementation appends spaces to pad the current line to 2000 characters (or more).

protected void genPostInstruction (StringBuilder sb, long address, InsnType insn)

The default implementation appends spaces to pad the current line to 120 characters (or more).

protected void genPreAddress (StringBuilder sb, long address, InsnType insn)

The default implementation does nothing.

protected void genPreChains (StringBuilder sb, long address, InsnType insn)

The default implementation does nothing.

protected void genPreInstruction (StringBuilder sb, long address, InsnType insn)

The default implementation does nothing.

protected void genTrailer (StringBuilder sb)

The default implementation does nothing.

protected final void padLine (StringBuilder sb, int alignLen)