Ghidra 11.3.2
Ghidra internal decompiler documentation.
Loading...
Searching...
No Matches
ghidra::Emulate Class Referenceabstract

A pcode-based emulator interface. More...

#include <emulate.hh>

Inheritance diagram for ghidra::Emulate:
[legend]
Collaboration diagram for ghidra::Emulate:
[legend]

Public Member Functions

 Emulate (void)
 generic emulator constructor
 
void setHalt (bool val)
 Set the halt state of the emulator.
 
bool getHalt (void) const
 Get the halt state of the emulator.
 
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.
 

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.
 
virtual bool executeCbranch (void)=0
 Check if the conditional of a CBRANCH is true.
 
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

◆ executeBinary()

virtual void ghidra::Emulate::executeBinary ( void  )
protectedpure virtual

Execute a binary arithmetic/logical operation.

Implemented in ghidra::EmulateMemory, ghidra::EmulatePcodeOp, and ghidra::EmulateSnippet.

Referenced by executeCurrentOp().

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

Referenced by executeCurrentOp().

◆ executeBranchind()

virtual void ghidra::Emulate::executeBranchind ( void  )
protectedpure virtual

Standard behavior for a BRANCHIND.

Implemented in ghidra::EmulateMemory, ghidra::EmulateSnippet, and ghidra::EmulateFunction.

Referenced by executeCurrentOp().

◆ executeCall()

virtual void ghidra::Emulate::executeCall ( void  )
protectedpure virtual

Standard behavior for a p-code CALL.

Implemented in ghidra::EmulateMemory, ghidra::EmulateSnippet, and ghidra::EmulateFunction.

Referenced by executeCurrentOp().

◆ executeCallind()

virtual void ghidra::Emulate::executeCallind ( void  )
protectedpure virtual

Standard behavior for a CALLIND.

Implemented in ghidra::EmulateMemory, ghidra::EmulateSnippet, and ghidra::EmulateFunction.

Referenced by executeCurrentOp().

◆ executeCallother()

virtual void ghidra::Emulate::executeCallother ( void  )
protectedpure virtual

Standard behavior for a user-defined p-code op.

Implemented in ghidra::EmulateMemory, ghidra::EmulatePcodeCache, ghidra::EmulateSnippet, and ghidra::EmulateFunction.

Referenced by executeCurrentOp().

◆ 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::EmulatePcodeOp, and ghidra::EmulateSnippet.

Referenced by executeCurrentOp().

◆ executeCpoolRef()

virtual void ghidra::Emulate::executeCpoolRef ( void  )
protectedpure virtual

Standard behavior for a CPOOLREF (constant pool reference) op.

Implemented in ghidra::EmulateMemory, ghidra::EmulatePcodeOp, and ghidra::EmulateSnippet.

Referenced by executeCurrentOp().

◆ executeCurrentOp()

◆ executeIndirect()

virtual void ghidra::Emulate::executeIndirect ( void  )
protectedpure virtual

Standard behavior for an INDIRECT op.

Implemented in ghidra::EmulateMemory, ghidra::EmulatePcodeOp, and ghidra::EmulateSnippet.

Referenced by executeCurrentOp().

◆ executeLoad()

virtual void ghidra::Emulate::executeLoad ( void  )
protectedpure virtual

Standard behavior for a p-code LOAD.

Implemented in ghidra::EmulateMemory, ghidra::EmulatePcodeOp, ghidra::EmulateSnippet, and ghidra::EmulateFunction.

Referenced by executeCurrentOp().

◆ executeMultiequal()

virtual void ghidra::Emulate::executeMultiequal ( void  )
protectedpure virtual

Standard behavior for a MULTIEQUAL (phi-node)

Implemented in ghidra::EmulateMemory, ghidra::EmulatePcodeOp, and ghidra::EmulateSnippet.

Referenced by executeCurrentOp().

◆ executeNew()

virtual void ghidra::Emulate::executeNew ( void  )
protectedpure virtual

Standard behavior for (low-level) NEW op.

Implemented in ghidra::EmulateMemory, ghidra::EmulatePcodeOp, and ghidra::EmulateSnippet.

Referenced by executeCurrentOp().

◆ executeSegmentOp()

virtual void ghidra::Emulate::executeSegmentOp ( void  )
protectedpure virtual

Behavior for a SEGMENTOP.

Implemented in ghidra::EmulateMemory, ghidra::EmulatePcodeOp, and ghidra::EmulateSnippet.

Referenced by executeCurrentOp().

◆ executeStore()

virtual void ghidra::Emulate::executeStore ( void  )
protectedpure virtual

Standard behavior for a p-code STORE.

Implemented in ghidra::EmulateMemory, ghidra::EmulatePcodeOp, and ghidra::EmulateSnippet.

Referenced by executeCurrentOp().

◆ executeUnary()

virtual void ghidra::Emulate::executeUnary ( void  )
protectedpure virtual

Execute a unary arithmetic/logical operation.

Implemented in ghidra::EmulateMemory, ghidra::EmulatePcodeOp, and ghidra::EmulateSnippet.

Referenced by executeCurrentOp().

◆ fallthruOp()

virtual void ghidra::Emulate::fallthruOp ( void  )
protectedpure virtual

Standard p-code fall-thru semantics.

Implemented in ghidra::EmulatePcodeCache, ghidra::EmulateSnippet, and ghidra::EmulateFunction.

Referenced by executeCurrentOp().

◆ getExecuteAddress()

virtual Address ghidra::Emulate::getExecuteAddress ( void  ) const
pure virtual

Get the address of the current instruction being executed.

Implemented in ghidra::EmulatePcodeCache, ghidra::EmulatePcodeOp, and ghidra::EmulateSnippet.

◆ 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.

References emu_halted.

Referenced by ghidra::ExecutablePcode::evaluate().

◆ setExecuteAddress()

◆ 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

References emu_halted.

Referenced by ghidra::TerminateCallBack::addressCallback().


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