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

A pcode-based emulator interface. More...

#include <emulate.hh>

Inheritance diagram for ghidra::Emulate:
ghidra::EmulateMemory ghidra::EmulatePcodeOp ghidra::EmulateSnippet ghidra::EmulatePcodeCache ghidra::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

◆ executeBranch()

virtual void ghidra::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 ghidra::EmulatePcodeCache, ghidra::EmulateMemory, ghidra::EmulateSnippet, and ghidra::EmulateFunction.

◆ executeCbranch()

virtual bool ghidra::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 ghidra::EmulateMemory, ghidra::EmulateSnippet, and ghidra::EmulatePcodeOp.

◆ executeCurrentOp()

void ghidra::Emulate::executeCurrentOp ( void  )

◆ getHalt()

bool ghidra::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 ghidra::ExecutablePcode::evaluate().

◆ setHalt()

void ghidra::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: