decompiler
1.0.0
|
A pcode-based emulator interface. More...
#include <emulate.hh>
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. | |
OpBehavior * | currentBehave |
Behavior of the next op to execute. | |
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.
|
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.
|
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.
Implemented in ghidra::EmulateMemory, ghidra::EmulateSnippet, and ghidra::EmulatePcodeOp.
void ghidra::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 ghidra::CPUI_BRANCH, ghidra::CPUI_BRANCHIND, ghidra::CPUI_CALL, ghidra::CPUI_CALLIND, ghidra::CPUI_CALLOTHER, ghidra::CPUI_CBRANCH, ghidra::CPUI_CPOOLREF, ghidra::CPUI_INDIRECT, ghidra::CPUI_LOAD, ghidra::CPUI_MULTIEQUAL, ghidra::CPUI_NEW, ghidra::CPUI_RETURN, ghidra::CPUI_SEGMENTOP, and ghidra::CPUI_STORE.
Referenced by ghidra::EmulateFunction::emulatePath(), ghidra::ExecutablePcode::evaluate(), and ghidra::EmulatePcodeCache::executeInstruction().
|
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.
Referenced by ghidra::ExecutablePcode::evaluate().
|
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.
val | is what the halt state of the emulator should be set to |