Ghidra Decompiler Analysis Engine
|
A SLEIGH based implementation of the Emulate interface. More...
#include <emulate.hh>
Public Member Functions | |
EmulatePcodeCache (Translate *t, MemoryState *s, BreakTable *b) | |
Pcode cache emulator constructor. More... | |
bool | isInstructionStart (void) const |
Return true if we are at an instruction start. More... | |
int4 | numCurrentOps (void) const |
Return number of pcode ops in translation of current instruction. More... | |
int4 | getCurrentOpIndex (void) const |
Get the index of current pcode op within current instruction. More... | |
PcodeOpRaw * | getOpByIndex (int4 i) const |
Get pcode op in current instruction translation by index. More... | |
virtual void | setExecuteAddress (const Address &addr) |
Set current execution address. More... | |
virtual Address | getExecuteAddress (void) const |
Get current execution address. More... | |
void | executeInstruction (void) |
Execute (the rest of) a single machine instruction. More... | |
Public Member Functions inherited from EmulateMemory | |
EmulateMemory (MemoryState *mem) | |
Construct given a memory state. | |
MemoryState * | getMemoryState (void) const |
Get the emulator's memory state. More... | |
Public Member Functions inherited from Emulate | |
void | setHalt (bool val) |
Set the halt state of the emulator. More... | |
bool | getHalt (void) const |
Get the halt state of the emulator. More... | |
void | executeCurrentOp (void) |
Do a single pcode op step. More... | |
Protected Member Functions | |
virtual void | fallthruOp (void) |
Execute fallthru semantics for the pcode cache. More... | |
virtual void | executeBranch (void) |
Execute branch (including relative branches) More... | |
virtual void | executeCallother (void) |
Execute breakpoint for this user-defined op. More... | |
Protected Member Functions inherited from EmulateMemory | |
virtual void | executeUnary (void) |
Execute a unary arithmetic/logical operation. | |
virtual void | executeBinary (void) |
Execute a binary arithmetic/logical operation. | |
virtual void | executeLoad (void) |
Standard behavior for a p-code LOAD. | |
virtual void | executeStore (void) |
Standard behavior for a p-code STORE. | |
virtual bool | executeCbranch (void) |
Check if the conditional of a CBRANCH is true. More... | |
virtual void | executeBranchind (void) |
Standard behavior for a BRANCHIND. | |
virtual void | executeCall (void) |
Standard behavior for a p-code CALL. | |
virtual void | executeCallind (void) |
Standard behavior for a CALLIND. | |
virtual void | executeMultiequal (void) |
Standard behavior for a MULTIEQUAL (phi-node) | |
virtual void | executeIndirect (void) |
Standard behavior for an INDIRECT op. | |
virtual void | executeSegmentOp (void) |
Behavior for a SEGMENTOP. | |
virtual void | executeCpoolRef (void) |
Standard behavior for a CPOOLREF (constant pool reference) op. | |
virtual void | executeNew (void) |
Standard behavior for (low-level) NEW op. | |
Additional Inherited Members | |
Protected Attributes inherited from EmulateMemory | |
MemoryState * | memstate |
The memory state of the emulator. | |
PcodeOpRaw * | currentOp |
Current op to execute. | |
Protected Attributes inherited from Emulate | |
bool | emu_halted |
Set to true if the emulator is halted. | |
OpBehavior * | currentBehave |
Behavior of the next op to execute. | |
A SLEIGH based implementation of the Emulate interface.
This implementation uses a Translate object to translate machine instructions into pcode and caches pcode ops for later use by the emulator. The pcode is cached as soon as the execution address is set, either explicitly, or via branches and fallthrus. There are additional methods for inspecting the pcode ops in the current instruction as a sequence.
EmulatePcodeCache::EmulatePcodeCache | ( | Translate * | t, |
MemoryState * | s, | ||
BreakTable * | b | ||
) |
Pcode cache emulator constructor.
t | is the SLEIGH translator |
s | is the MemoryState the emulator should manipulate |
b | is the table of breakpoints the emulator should invoke |
|
protectedvirtual |
Execute branch (including relative branches)
Since the full instruction is cached, we can do relative branches properly.
Reimplemented from EmulateMemory.
|
protectedvirtual |
Execute breakpoint for this user-defined op.
Look for a breakpoint for the given user-defined op and invoke it. If it doesn't exist, or doesn't replace the action, throw an exception
Reimplemented from EmulateMemory.
void EmulatePcodeCache::executeInstruction | ( | void | ) |
Execute (the rest of) a single machine instruction.
This routine executes an entire machine instruction at once, as a conventional debugger step function would do. If execution is at the start of an instruction, the breakpoints are checked and invoked as needed for the current address. If this routine is invoked while execution is in the middle of a machine instruction, execution is continued until the current instruction completes.
|
protectedvirtual |
Execute fallthru semantics for the pcode cache.
Update the iterator into the current pcode cache, and if necessary, generate the pcode for the fallthru instruction and reset the iterator.
Implements Emulate.
|
inline |
Get the index of current pcode op within current instruction.
This routine can be used to determine where, within the sequence of ops in the translation of the entire machine instruction, the currently executing op is.
|
inlinevirtual |
|
inline |
Get pcode op in current instruction translation by index.
This routine can be used to examine ops other than the currently executing op in the machine instruction's translation sequence.
i | is the desired op index |
|
inline |
Return true if we are at an instruction start.
Since the emulator can single step through individual pcode operations, the machine state may be halted in the middle of a single machine instruction, unlike conventional debuggers. This routine can be used to determine if execution is actually at the beginning of a machine instruction.
|
inline |
Return number of pcode ops in translation of current instruction.
A typical machine instruction translates into a sequence of pcode ops.
|
virtual |
Set current execution address.
Set the current execution address and cache the pcode translation of the machine instruction at that address
addr | is the address where execution should continue |
Implements Emulate.