Class CFGFormatter<InsnType extends IInstruction>
java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.cfg.CFGFormatter<InsnType>
- Direct Known Subclasses:
ECFGFormatter
Customizable CFG formatter.
Sub-classes are permitted. Protected methods genXxx()
may be overridden to customize
rendering.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AtomicInteger
Performance counter reserved for internal use. -
Constructor Summary
ConstructorsConstructorDescriptionCFGFormatter
(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. -
Method Summary
Modifier and TypeMethodDescriptionformat
(boolean formatAddresses, boolean formatChains, boolean formatInOut, IDFA<InsnType> dfa, IFormattingContextFactory<InsnType> fcf) Format the CFG into a printable string, with optional data chains.formatChains
(Map<Integer, Collection<T>> chains, IVariableProvider varprv) final String
Convenience method.protected void
genAddress
(StringBuilder sb, long address, InsnType insn) The default implementation generatesADDRESS/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
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
The default implementation does nothing.getCfg()
protected final void
padLine
(StringBuilder sb, int alignLen)
-
Field Details
-
cfgfwccnt
Performance counter reserved for internal use.
-
-
Constructor Details
-
CFGFormatter
Legacy CFG formatter. Variables/registers/bits in data chains are represented by their ids.- Parameters:
cfg
- a CFG
-
CFGFormatter
Build a CFG formatter with an optional variable provider to aid in the representation of data chains.- Parameters:
cfg
- a CFGvarprv
- optional variable providerformatFineGrained
- 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)
-
-
Method Details
-
getCfg
-
formatSimple
Convenience method. Format a CFG without any chain.- Returns:
-
format
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 addressformatChains
- true to format data chainsformatInOut
- true to format the input and output chainsdfa
- DFA objectfcf
- optional context generator for instructions- Returns:
- the formatted CFG
-
formatChains
public static <T extends Number> String formatChains(Map<Integer, Collection<T>> chains, IVariableProvider varprv) -
padLine
-
genHeader
The default implementation does nothing. -
genBOL
The default implementation does nothing. -
genPreAddress
The default implementation does nothing. -
genAddress
The default implementation generatesADDRESS/SIZE
. -
genAddressCharacter
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)
-
genPostAddress
The default implementation appends 2 spaces. -
genPreInstruction
The default implementation does nothing. -
genPostInstruction
The default implementation appends spaces to pad the current line to 120 characters (or more). -
genPreChains
The default implementation does nothing. -
genPostChains
The default implementation appends spaces to pad the current line to 2000 characters (or more). -
genEOL
The default implementation appends a New Line (\n
) character. -
genTrailer
The default implementation does nothing.
-