frysk.proc.live
Class Instruction

java.lang.Object
  extended by frysk.proc.live.Instruction
Direct Known Subclasses:
IA32InstructionParser.Jump

public class Instruction
extends Object

An architecture independent way of representing an assembly level instruction which is used for stepping and breakpoint insertion. Possibly knows about displaced instruction execution and/or emultation. Constructed by archtecture Isas given a memory buffer and address of the instruction. Instruction objects are immutable.

See Also:
Isa.getInstruction(Buffer, long)

Field Summary
private  boolean executeOutOfLine
           
private  byte[] instr
           
private  String name
           
private  boolean simulate
           
 
Constructor Summary
Instruction(byte[] instr)
           
Instruction(byte[] instr, boolean executeOutOfLine)
           
Instruction(byte[] instr, boolean executeOutOfLine, boolean simulate)
           
Instruction(String name, byte[] instr)
           
Instruction(String name, byte[] instr, boolean executeOutOfLine)
           
Instruction(String name, byte[] instr, boolean executeOutOfLine, boolean simulate)
          Package private constructor called by the Isa ito create an inmutable Instruction.
 
Method Summary
 boolean canExecuteOutOfLine()
          Whether or not this instruction can be executed out of line.
 boolean canSimulate()
          Whether or not this instruction can be emulated.
 void fixupExecuteOutOfLine(Task task, long pc, long address)
          After the instruction has been executed out of line fixes up the given Task as if the instruction was actually executed at the given pc instead of the given address.
 byte[] getBytes()
          Returns the raw instruction bytes.
 String getName()
          Returns a human readable string representation of the instruction.
 void setupExecuteOutOfLine(Task task, long pc, long address)
          Prepares the given Task for executing this instruction at the given address.
 void simulate(Task task)
          The default implementation just does a sanity check and throws an exception if simulation was requested on a instruction that cannot be emulated.
 String toString()
          A human readable representation of the Instruction including the class name, the opcode name and the instruction bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

private final String name

instr

private final byte[] instr

executeOutOfLine

private final boolean executeOutOfLine

simulate

private final boolean simulate
Constructor Detail

Instruction

Instruction(String name,
            byte[] instr,
            boolean executeOutOfLine,
            boolean simulate)
Package private constructor called by the Isa ito create an inmutable Instruction.


Instruction

Instruction(byte[] instr)

Instruction

Instruction(String name,
            byte[] instr)

Instruction

Instruction(byte[] instr,
            boolean executeOutOfLine)

Instruction

Instruction(byte[] instr,
            boolean executeOutOfLine,
            boolean simulate)

Instruction

Instruction(String name,
            byte[] instr,
            boolean executeOutOfLine)
Method Detail

getName

public String getName()
Returns a human readable string representation of the instruction. Often just the opcode name, but can include any instruction arguments.


getBytes

public byte[] getBytes()
Returns the raw instruction bytes.


canExecuteOutOfLine

public boolean canExecuteOutOfLine()
Whether or not this instruction can be executed out of line.


setupExecuteOutOfLine

public void setupExecuteOutOfLine(Task task,
                                  long pc,
                                  long address)
Prepares the given Task for executing this instruction at the given address. Pair with fixupExecuteOutOfLine after a Task step over the out of line instruction to setup the Task as if the Task did a step over the instruction at the given pc.

The default implementation puts the bytes of the instruction at address and sets the pc of the Task to that address. Override when the instruction needs anything more.


fixupExecuteOutOfLine

public void fixupExecuteOutOfLine(Task task,
                                  long pc,
                                  long address)
After the instruction has been executed out of line fixes up the given Task as if the instruction was actually executed at the given pc instead of the given address.

The default implementation just sets the pc at the given pc plus the length of this instruction. Override when the instruction needs to do anything else.


canSimulate

public boolean canSimulate()
Whether or not this instruction can be emulated.


simulate

public void simulate(Task task)
The default implementation just does a sanity check and throws an exception if simulation was requested on a instruction that cannot be emulated.


toString

public String toString()
A human readable representation of the Instruction including the class name, the opcode name and the instruction bytes.

Overrides:
toString in class Object