| java.lang.Object | |
| ↳ | com.pnfsoftware.jeb.core.units.code.asm.processor.AbstractProcessor<InsnType extends com.pnfsoftware.jeb.core.units.code.IInstruction> |
An abstract implementation of a processor. It is recommended to inherit from
this class. The implementor simply needs to implement a
IProcessor#parseAtInternal(byte[], int, int) parseAt() method. Instruction alignment is
enforced.
This skeleton provides support for concurrent operations on IProcessor, via an
IModelLock. Implementations must carefully lock and unlock, as needed.
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.pnfsoftware.jeb.core.units.code.asm.processor.IProcessor
| |||||||||||
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| protected int | defaultMode | ||||||||||
| protected int | mode | ||||||||||
| protected Collection<Integer> | supportedModes | ||||||||||
| protected Collection<ProcessorVariant> | supportedVariants | ||||||||||
| protected ProcessorVariant | variant | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
AbstractProcessor(int parseCacheLength, int defaultMode, Endianness endianness, int instructionAlign)
Create a processor.
| |||||||||||
| AbstractProcessor(int parseCacheLength, int defaultMode, IUnitCreator parent, int instructionAlign) | |||||||||||
|
AbstractProcessor(int parseCacheLength, int defaultMode, IUnitCreator parent, int instructionAlign, int parseBufferBefore)
Create a processor, retrieving Endianness from parent
IUnitCreator. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| EntryPointDescription |
createEntryPoint(long address)
The default implementation creates an entry-point using the exact provided address, with a
default processor mode.
| ||||||||||
| final int |
getDefaultMode()
Get the default processor mode.
| ||||||||||
| final Endianness |
getEndianness()
Get the endianness this processor operates in.
| ||||||||||
| final int |
getInstructionAlignment()
Retrieve the instruction alignment, in bytes.
| ||||||||||
| final Object | getInternalLock() | ||||||||||
| final int |
getMode()
Get the processor mode.
| ||||||||||
| String |
getRegisterName(long registerCode)
The default implementation returns null.
| ||||||||||
| ICodeResolver<InsnType> |
getResolver()
The default implementation returns null.
| ||||||||||
| Collection<Integer> |
getSupportedModes()
Get the list of valid modes that this processor supports.
| ||||||||||
| Collection<ProcessorVariant> |
getSupportedVariants()
Retrieve a list of supported processor variants.
| ||||||||||
| ProcessorType |
getType()
Retrieve the processor type.
| ||||||||||
| ProcessorVariant |
getVariant()
Get the processor variant used by this object.
| ||||||||||
| boolean |
isRISC()
Provide a hint about the instruction set architecture.
| ||||||||||
| final void | lockRead() | ||||||||||
| final void | lockWrite() | ||||||||||
| final InsnType |
parseAt(byte[] bytes, int index, int end)
Parse a single instruction.
| ||||||||||
| final InsnType |
parseAt(IVirtualMemory vm, long address)
Parse a single instruction at the specified address in memory.
| ||||||||||
| InsnType |
parseWithContext(IMachineContext context)
Parse a single instruction given a machine context.
| ||||||||||
| final void |
setEndianness(Endianness endianness)
Set the endianness of this processor.
| ||||||||||
| final void |
setInstructionAlignment(int align)
Set the instruction alignment, in bytes.
| ||||||||||
| int |
setMode(int newMode)
Set the processor mode.
| ||||||||||
| void |
setVariant(ProcessorVariant variant)
Set the new variant used by this processor.
| ||||||||||
| final void | unlockRead() | ||||||||||
| final void | unlockWrite() | ||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| abstract InsnType |
parseAtInternal(byte[] bytes, int index, int end)
Decode bytes as instructions.
| ||||||||||
| InsnType |
parseWithContextInternal(IMachineContext context)
The default implementation throws UnsupportedOperationException.@return
| ||||||||||
| final void |
setDefaultMode(int defaultMode)
Set the default mode.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.pnfsoftware.jeb.core.units.code.asm.analyzer.IModelLock
| |||||||||||
From interface
com.pnfsoftware.jeb.core.units.code.asm.processor.IProcessor
| |||||||||||
Create a processor.
Create a processor, retrieving Endianness from parent IUnitCreator. If the endianness
cannot be retrieved, default little-endian will be used.
| parseCacheLength | Total byte length to retrieve when
parseAt(IVirtualMemory, long) method is called. |
|---|---|
| defaultMode | Default Processor Mode |
| parent | Creator of the processor |
| instructionAlign | Minimum instruction alignment allowed. |
| parseBufferBefore | number of bytes to parse before current address when
parseAt(IVirtualMemory, long) method is called. Note than the byte range
will be [address-parseBufferBefore, address+parseCacheLength]
|
The default implementation creates an entry-point using the exact provided address, with a default processor mode.
| address | address of the instruction |
|---|
Get the default processor mode. The mode indicates the current operating size of the processor. Typically, this represents the size in bits of general purpose (GP) registers, as well as the size of the program counter (PC).
MODE_DEFAULT (0)
Retrieve the instruction alignment, in bytes.
Get the processor mode. Typically, the processor mode is a size in bits that indicates how
instructions are parsed and/or how addresses are calculated and addressed. Typical processor
modes are 16, 32, or 64 (bits). Note: A 'processor mode' could have a different semantic, but
anything non-standard is unlikely to be understood by client code. This function will never
return 0 See MODE_Xxx for common constants.
MODE_DEFAULT (0)
The default implementation returns null.
The default implementation returns null. Careful, access to this object is subject to locking.
Get the list of valid modes that this processor supports.
Retrieve a list of supported processor variants.
Retrieve the processor type. The type depends on the current execution
mode. A processor class may implement several modes, mapping to various processor types.
Provide a hint about the instruction set architecture.
Parse a single instruction.
| bytes | input code buffer |
|---|---|
| index | where to parse in the input buffer |
| end | exclusive end offset in the buffer: if parsing at the given index offset requires bytes past the end offset, an exception is raised |
| ProcessorException |
|---|
Parse a single instruction at the specified address in memory.
| vm | the input virtual memory |
|---|---|
| address | the address to read at, with permission of read+write |
| ProcessorException |
|---|
Parse a single instruction given a machine context. The context provides access to at least:
| ProcessorException |
|---|
Set the instruction alignment, in bytes. The implementation may decide to enforce alignment,
or ignore it. If alignment is enforced, attempting to parse an unaligned instruction should
raise a ProcessorException.
| align | the alignment, must be a strictly positive power of 2 |
|---|
Set the processor mode. Implementors may override this class, if they have other/better/proper ways to determine the processor operating mode. In that case, the mode provided by thi method may be regarded as a hint - or disregarded entirely.
| newMode | the mode, the value MODE_DEFAULT (0) can be provided to revert to the
default processor mode |
|---|
| ProcessorException |
|---|
Set the new variant used by this processor.
| ProcessorException |
|---|
Decode bytes as instructions. The one and only method all processors must implement. This
method is not synchronized; implementations should keep its protection level to `protected`,
unless they want client code to be able to do fast(er), albeit unsafe, parsing. Most
implementations should keep this method protected, and client code should call
parseAt(byte[], int, int) or other similar, safe methods.@return
| ProcessorException |
|---|
The default implementation throws UnsupportedOperationException.@return
| ProcessorException |
|---|
Set the default mode. Only for implementors. This method is and should be called just once (at construction time).
| defaultMode | the default processor mode, cannot be 0 |
|---|