public class

GenericCodeFormatter

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.asm.render.GenericCodeFormatter<InsnType extends com.pnfsoftware.jeb.core.units.code.IInstruction>

Class Overview

Formatter used by the INativeCodeUnit. Client plugins may override some public and protected methods to customize their disassembly.

Summary

Constants
int MNEMONIC_RIGHT_PADDING_LENGTH_DEFAULT
Public Constructors
GenericCodeFormatter()
GenericCodeFormatter(IVirtualMemory mem)
FOR TESTING ONLY
Public Methods
final long createItemIdForAddress(long address)
final long createItemIdForImmediate(long insnAddress, int opndIndexGlobal)
final long createItemIdForRegister(long regCode)
final void formatAddress(long address, CodeDocumentPart out)
void formatAddress(long address, IInstructionOperandGeneric opnd, CodeDocumentPart out)
Format an address regarding getDefaultAddressFormatter()
void formatDataDeclarator(int size, CodeDocumentPart out)
void formatInstruction(long address, IInstruction insn, CodeDocumentPart out)
Displays only pure assembly code: Mnemonic and Operands.
void formatOperand(long address, IInstruction insn, IInstructionOperand opnd, int opndIndexGlobal, int opndDepth, CodeDocumentPart out)
Generic operand formatter.
final void formatRelativeAddress(IInstructionOperandGeneric opnd, long address, CodeDocumentPart out)
String generateExtraMethodComment(long address)
Generate an optional string that will be prepended to a function header comment.
int getArrayElementPerLine()
The default implementation returns 10.
ItemClassIdentifiers getBestClassIdForAddress(long address)
INativeCodeUnit<InsnType> getCodeUnit()
String getDataSeparator()
The default implementation returns the comma string.
AddressFormatter getDefaultAddressFormatter()
NumberFormatter getDefaultNumberFormatter()
Endianness getEndianness()
String getInlineCommentString()
The default implementation returns a semi-column string.
String getLabelPrefix()
Get the assembly label prefix.
String getLabelSuffix()
Can be overridden.
IVirtualMemory getMemory()
String getMemoryAccessPrefix()
The default implementation returns the opening square bracket.
String getMemoryAccessSegmentInfo(IInstruction insn, IInstructionOperand opnd)
The default implementation returns the empty string.
String getMemoryAccessSizeInfo(IInstruction insn, IInstructionOperandSized opnd)
Can be overridden.
String getMemoryAccessSuffix()
The default implementation returns the closing square bracket.
final int getMnemonicRightPaddingLength()
String getMultiLineCommentBegin()
The default implementation returns "slash-*".
String getMultiLineCommentEnd()
The default implementation returns "*-slash".
NumberFormatter getNumberFormatter(IInstructionOperand opnd, boolean createIfNone)
NumberFormatter getNumberFormatter(INativeDataItem item)
String getOperandSeparator()
Can be overridden.
String getProcedureDefinitionEnd()
String getProcedureDefinitionStart()
String getRawDataDeclarator(int bitsize)
The default implementation returns "dX".
String getRegisterName(long registerIdentifier)
The default implementation returns "rX".
boolean isDoNotAttemptImmediateToAddressResolution()
void setCodeUnit(INativeCodeUnit<InsnType> pbcu)
void setDoNotAttemptImmediateToAddressResolution(boolean doNotResolveImmAsAddr)
final void setMnemonicRightPaddingLength(int length)
Protected Methods
final void addPrefix(IInstruction insn, IInstructionOperandGeneric opnd, CodeDocumentPart out)
final void addSuffix(IInstruction insn, IInstructionOperandGeneric opnd, CodeDocumentPart out)
void formatMnemonic(long address, IInstruction insn, boolean prependPrefix, CodeDocumentPart out)
void formatOperands(long address, IInstruction insn, CodeDocumentPart out)
int formatPrefix(long address, IInstruction insn, CodeDocumentPart out)
void formatRegister(long regValue, CodeDocumentPart out)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int MNEMONIC_RIGHT_PADDING_LENGTH_DEFAULT

Constant Value: 10 (0x0000000a)

Public Constructors

public GenericCodeFormatter ()

public GenericCodeFormatter (IVirtualMemory mem)

FOR TESTING ONLY

Public Methods

public final long createItemIdForAddress (long address)

public final long createItemIdForImmediate (long insnAddress, int opndIndexGlobal)

public final long createItemIdForRegister (long regCode)

public final void formatAddress (long address, CodeDocumentPart out)

public void formatAddress (long address, IInstructionOperandGeneric opnd, CodeDocumentPart out)

Format an address regarding getDefaultAddressFormatter()

Parameters
address address to represent
opnd optional; IFF address is a relative address

public void formatDataDeclarator (int size, CodeDocumentPart out)

public void formatInstruction (long address, IInstruction insn, CodeDocumentPart out)

Displays only pure assembly code: Mnemonic and Operands. If you need to display the address and bytecode, refer to #formatInstruction(ProcessorBasedCodeUnit, long, IInstruction, CodeDocumentPart)

public void formatOperand (long address, IInstruction insn, IInstructionOperand opnd, int opndIndexGlobal, int opndDepth, CodeDocumentPart out)

Generic operand formatter. Can be overridden, although not recommended. If the processor uses custom instructions, that is, instructions that are neither IInstructionOperandGeneric or IInstructionOperandCMA, the processor should override this method.

public final void formatRelativeAddress (IInstructionOperandGeneric opnd, long address, CodeDocumentPart out)

public String generateExtraMethodComment (long address)

Generate an optional string that will be prepended to a function header comment. The default implementation returns null.

Parameters
address function address

public int getArrayElementPerLine ()

The default implementation returns 10. Can be overridden.

Returns
  • a number >= 1

public ItemClassIdentifiers getBestClassIdForAddress (long address)

public INativeCodeUnit<InsnType> getCodeUnit ()

public String getDataSeparator ()

The default implementation returns the comma string. Can be overridden.

public AddressFormatter getDefaultAddressFormatter ()

public NumberFormatter getDefaultNumberFormatter ()

public Endianness getEndianness ()

public String getInlineCommentString ()

The default implementation returns a semi-column string. Can be overridden.

public String getLabelPrefix ()

Get the assembly label prefix. Can be overridden.

public String getLabelSuffix ()

Can be overridden.

public IVirtualMemory getMemory ()

public String getMemoryAccessPrefix ()

The default implementation returns the opening square bracket. Can be overridden.

public String getMemoryAccessSegmentInfo (IInstruction insn, IInstructionOperand opnd)

The default implementation returns the empty string. Can be overridden.

public String getMemoryAccessSizeInfo (IInstruction insn, IInstructionOperandSized opnd)

Can be overridden.

public String getMemoryAccessSuffix ()

The default implementation returns the closing square bracket. Can be overridden.

public final int getMnemonicRightPaddingLength ()

public String getMultiLineCommentBegin ()

The default implementation returns "slash-*". Can be overridden.

public String getMultiLineCommentEnd ()

The default implementation returns "*-slash". Can be overridden.

public NumberFormatter getNumberFormatter (IInstructionOperand opnd, boolean createIfNone)

public NumberFormatter getNumberFormatter (INativeDataItem item)

public String getOperandSeparator ()

Can be overridden.

public String getProcedureDefinitionEnd ()

public String getProcedureDefinitionStart ()

public String getRawDataDeclarator (int bitsize)

The default implementation returns "dX". Can be overridden.

public String getRegisterName (long registerIdentifier)

The default implementation returns "rX". Should be overridden.

Returns
  • a register name, never null (on error, the implementation should return a default safe string)

public boolean isDoNotAttemptImmediateToAddressResolution ()

public void setCodeUnit (INativeCodeUnit<InsnType> pbcu)

public void setDoNotAttemptImmediateToAddressResolution (boolean doNotResolveImmAsAddr)

public final void setMnemonicRightPaddingLength (int length)

Protected Methods

protected final void addPrefix (IInstruction insn, IInstructionOperandGeneric opnd, CodeDocumentPart out)

protected final void addSuffix (IInstruction insn, IInstructionOperandGeneric opnd, CodeDocumentPart out)

protected void formatMnemonic (long address, IInstruction insn, boolean prependPrefix, CodeDocumentPart out)

protected void formatOperands (long address, IInstruction insn, CodeDocumentPart out)

protected int formatPrefix (long address, IInstruction insn, CodeDocumentPart out)

protected void formatRegister (long regValue, CodeDocumentPart out)