Class CFGFormatter<InsnType extends IInstruction>

java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.cfg.CFGFormatter<InsnType>
Direct Known Subclasses:
ECFGFormatter

public class CFGFormatter<InsnType extends IInstruction> extends Object
Customizable CFG formatter.

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

  • Field Details

    • cfgfwccnt

      public static final AtomicInteger cfgfwccnt
      Performance counter reserved for internal use.
  • Constructor Details

    • CFGFormatter

      public CFGFormatter(CFG<InsnType> cfg)
      Legacy CFG formatter. Variables/registers/bits in data chains are represented by their ids.
      Parameters:
      cfg - a CFG
    • CFGFormatter

      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)
  • Method Details

    • getCfg

      public final CFG<InsnType> getCfg()
    • formatSimple

      public final String 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 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
    • formatChains

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

      protected final void padLine(StringBuilder sb, int alignLen)
    • genHeader

      protected void genHeader(StringBuilder sb)
      The default implementation does nothing.
    • genBOL

      protected void genBOL(StringBuilder sb, long address, InsnType insn)
      The default implementation does nothing.
    • genPreAddress

      protected void genPreAddress(StringBuilder sb, long address, InsnType insn)
      The default implementation does nothing.
    • genAddress

      protected void genAddress(StringBuilder sb, long address, InsnType insn)
      The default implementation generates ADDRESS/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

      protected void genPostAddress(StringBuilder sb, long address, InsnType insn)
      The default implementation appends 2 spaces.
    • genPreInstruction

      protected void genPreInstruction(StringBuilder sb, long address, InsnType insn)
      The default implementation does nothing.
    • genPostInstruction

      protected void genPostInstruction(StringBuilder sb, long address, InsnType insn)
      The default implementation appends spaces to pad the current line to 120 characters (or more).
    • genPreChains

      protected void genPreChains(StringBuilder sb, long address, InsnType insn)
      The default implementation does nothing.
    • genPostChains

      protected void genPostChains(StringBuilder sb, long address, InsnType insn)
      The default implementation appends spaces to pad the current line to 2000 characters (or more).
    • genEOL

      protected void genEOL(StringBuilder sb, long address, InsnType insn)
      The default implementation appends a New Line (\n) character.
    • genTrailer

      protected void genTrailer(StringBuilder sb)
      The default implementation does nothing.