decompiler  1.0.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Emulate Class Referenceabstract

A pcode-based emulator interface. More...

#include <emulate.hh>

Inheritance diagram for Emulate:
EmulateMemory EmulatePcodeOp EmulateSnippet EmulatePcodeCache EmulateFunction

Public Member Functions

 Emulate (void)
 generic emulator constructor
 
void setHalt (bool val)
 Set the halt state of the emulator. More...
 
bool getHalt (void) const
 Get the halt state of the emulator. More...
 
virtual void setExecuteAddress (const Address &addr)=0
 Set the address of the next instruction to emulate.
 
virtual Address getExecuteAddress (void) const =0
 Get the address of the current instruction being executed.
 
void executeCurrentOp (void)
 Do a single pcode op step. More...
 

Protected Member Functions

virtual void executeUnary (void)=0
 Execute a unary arithmetic/logical operation.
 
virtual void executeBinary (void)=0
 Execute a binary arithmetic/logical operation.
 
virtual void executeLoad (void)=0
 Standard behavior for a p-code LOAD.
 
virtual void executeStore (void)=0
 Standard behavior for a p-code STORE.
 
virtual void executeBranch (void)=0
 Standard behavior for a BRANCH. More...
 
virtual bool executeCbranch (void)=0
 Check if the conditional of a CBRANCH is true. More...
 
virtual void executeBranchind (void)=0
 Standard behavior for a BRANCHIND.
 
virtual void executeCall (void)=0
 Standard behavior for a p-code CALL.
 
virtual void executeCallind (void)=0
 Standard behavior for a CALLIND.
 
virtual void executeCallother (void)=0
 Standard behavior for a user-defined p-code op.
 
virtual void executeMultiequal (void)=0
 Standard behavior for a MULTIEQUAL (phi-node)
 
virtual void executeIndirect (void)=0
 Standard behavior for an INDIRECT op.
 
virtual void executeSegmentOp (void)=0
 Behavior for a SEGMENTOP.
 
virtual void executeCpoolRef (void)=0
 Standard behavior for a CPOOLREF (constant pool reference) op.
 
virtual void executeNew (void)=0
 Standard behavior for (low-level) NEW op.
 
virtual void fallthruOp (void)=0
 Standard p-code fall-thru semantics.
 

Protected Attributes

bool emu_halted
 Set to true if the emulator is halted.
 
OpBehaviorcurrentBehave
 Behavior of the next op to execute.
 

Detailed Description

A pcode-based emulator interface.

The interface expects that the underlying emulation engine operates on individual pcode operations as its atomic operation. The interface allows execution stepping through individual pcode operations. The interface allows querying of the current pcode op, the current machine address, and the rest of the machine state.

Member Function Documentation

virtual void Emulate::executeBranch ( void  )
protectedpure virtual

Standard behavior for a BRANCH.

This routine performs a standard p-code BRANCH operation on the memory state. This same routine is used for CBRANCH operations if the condition has evaluated to true.

Implemented in EmulatePcodeCache, EmulateMemory, EmulateSnippet, and EmulateFunction.

virtual bool Emulate::executeCbranch ( void  )
protectedpure virtual

Check if the conditional of a CBRANCH is true.

This routine only checks if the condition for a p-code CBRANCH is true. It does not perform the actual branch.

Returns
the boolean state indicated by the condition

Implemented in EmulateMemory, EmulateSnippet, and EmulatePcodeOp.

void Emulate::executeCurrentOp ( void  )

Do a single pcode op step.

This method executes a single pcode operation, the current one (returned by getCurrentOp()). The MemoryState of the emulator is queried and changed as needed to accomplish this.

References CPUI_BRANCH, CPUI_BRANCHIND, CPUI_CALL, CPUI_CALLIND, CPUI_CALLOTHER, CPUI_CBRANCH, CPUI_CPOOLREF, CPUI_INDIRECT, CPUI_LOAD, CPUI_MULTIEQUAL, CPUI_NEW, CPUI_RETURN, CPUI_SEGMENTOP, and CPUI_STORE.

Referenced by EmulateFunction::emulatePath(), ExecutablePcode::evaluate(), and EmulatePcodeCache::executeInstruction().

bool Emulate::getHalt ( void  ) const
inline

Get the halt state of the emulator.

Applications and breakpoints can use this method and its companion setHalt() to terminate and restart the main emulator loop as needed. The emulator itself makes no use of this routine or the associated state variable emu_halted.

Returns
true if the emulator is in a "halted" state.

Referenced by ExecutablePcode::evaluate().

void Emulate::setHalt ( bool  val)
inline

Set the halt state of the emulator.

Applications and breakpoints can use this method and its companion getHalt() to terminate and restart the main emulator loop as needed. The emulator itself makes no use of this routine or the associated state variable emu_halted.

Parameters
valis what the halt state of the emulator should be set to

The documentation for this class was generated from the following files: