Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
19 #ifndef __CPUI_EMULATE__
20 #define __CPUI_EMULATE__
140 map<Address,BreakCallBack *> addresscallback;
141 map<uintb,BreakCallBack *> pcodecallback;
279 vector<PcodeOpRaw *> &opcache;
280 vector<VarnodeData *> &varcache;
281 const vector<OpBehavior *> &inst;
285 PcodeEmitCache(vector<PcodeOpRaw *> &ocache,vector<VarnodeData *> &vcache,
286 const vector<OpBehavior *> &in,uintb uniqReserve);
298 vector<PcodeOpRaw *> opcache;
299 vector<VarnodeData *> varcache;
300 vector<OpBehavior *> inst;
303 bool instruction_start;
305 int4 instruction_length;
306 void clearCache(
void);
307 void createInstruction(
const Address &addr);
308 void establishOp(
void);
333 return instruction_start;
341 return opcache.size();
367 return current_address;
virtual void executeBinary(void)=0
Execute a binary arithmetic/logical operation.
virtual void executeMultiequal(void)
Standard behavior for a MULTIEQUAL (phi-node)
Definition: emulate.cc:296
EmulatePcodeCache(Translate *t, MemoryState *s, BreakTable *b)
Pcode cache emulator constructor.
Definition: emulate.cc:329
virtual void setEmulate(Emulate *emu)
Associate an emulator with all breakpoints in the table.
Definition: emulate.cc:52
Abstract class for emitting pcode to an application.
Definition: translate.hh:76
virtual void setExecuteAddress(const Address &addr)
Set current execution address.
Definition: emulate.cc:432
virtual void executeMultiequal(void)=0
Standard behavior for a MULTIEQUAL (phi-node)
bool emu_halted
Set to true if the emulator is halted.
Definition: emulate.hh:170
virtual void executeCallother(void)=0
Standard behavior for a user-defined p-code op.
int4 numCurrentOps(void) const
Return number of pcode ops in translation of current instruction.
Definition: emulate.hh:338
virtual void executeCallother(void)
Execute breakpoint for this user-defined op.
Definition: emulate.cc:421
Classes for disassembly and pcode generation.
virtual bool doAddressBreak(const Address &addr)
Invoke any breakpoints for the given address.
Definition: emulate.cc:87
virtual bool addressCallback(const Address &addr)
Call back method for address based breakpoints.
Definition: emulate.hh:115
virtual void executeCallother(void)
Standard behavior for a user-defined p-code op.
Definition: emulate.cc:290
void registerPcodeCallback(const string &nm, BreakCallBack *func)
Register a pcode based breakpoint.
Definition: emulate.cc:23
virtual bool doAddressBreak(const Address &addr)=0
Invoke any breakpoints associated with this machine address.
virtual void executeBinary(void)
Execute a binary arithmetic/logical operation.
Definition: emulate.cc:225
virtual void dump(const Address &addr, OpCode opc, VarnodeData *outvar, VarnodeData *vars, int4 isize)
The main pcode emit method.
Definition: emulate.cc:121
virtual void executeLoad(void)=0
Standard behavior for a p-code LOAD.
int4 getCurrentOpIndex(void) const
Get the index of current pcode op within current instruction.
Definition: emulate.hh:347
virtual void executeIndirect(void)
Standard behavior for an INDIRECT op.
Definition: emulate.cc:302
PcodeOpRaw * getOpByIndex(int4 i) const
Get pcode op in current instruction translation by index.
Definition: emulate.hh:357
An abstract Emulate class using a MemoryState object as the backing machine state.
Definition: emulate.hh:243
virtual void executeStore(void)
Standard behavior for a p-code STORE.
Definition: emulate.cc:246
virtual void executeBranchind(void)=0
Standard behavior for a BRANCHIND.
Classes for keeping track of memory state during emulation.
Class encapsulating the action/behavior of specific pcode opcodes.
Definition: opbehavior.hh:42
virtual void setEmulate(Emulate *emu)=0
Associate a particular emulator with breakpoints in this table.
virtual void fallthruOp(void)
Execute fallthru semantics for the pcode cache.
Definition: emulate.cc:389
virtual bool doPcodeOpBreak(PcodeOpRaw *curop)
Invoke any breakpoints for the given pcode op.
Definition: emulate.cc:72
BreakTableCallBack(Translate *t)
Basic breaktable constructor.
Definition: emulate.hh:154
A SLEIGH based implementation of the Emulate interface.
Definition: emulate.hh:296
PcodeOpRaw * currentOp
Current op to execute.
Definition: emulate.hh:246
virtual void executeUnary(void)=0
Execute a unary arithmetic/logical operation.
void setEmulate(Emulate *emu)
Associate a particular emulator with this breakpoint.
Definition: emulate.hh:123
bool getHalt(void) const
Get the halt state of the emulator.
Definition: emulate.hh:224
void setHalt(bool val)
Set the halt state of the emulator.
Definition: emulate.hh:214
A pcode-based emulator interface.
Definition: emulate.hh:168
P-code emitter that dumps its raw Varnodes and PcodeOps to an in memory cache.
Definition: emulate.hh:278
void registerAddressCallback(const Address &addr, BreakCallBack *func)
Register an address based breakpoint.
Definition: emulate.cc:43
All storage/state for a pcode machine.
Definition: memstate.hh:148
virtual void executeCallind(void)=0
Standard behavior for a CALLIND.
virtual void executeNew(void)=0
Standard behavior for (low-level) NEW op.
virtual bool pcodeCallback(PcodeOpRaw *op)
Call back method for pcode based breakpoints.
Definition: emulate.hh:102
void executeInstruction(void)
Execute (the rest of) a single machine instruction.
Definition: emulate.cc:446
virtual bool doPcodeOpBreak(PcodeOpRaw *curop)=0
Invoke any breakpoints associated with this particular pcodeop.
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
virtual void executeBranchind(void)
Standard behavior for a BRANCHIND.
Definition: emulate.cc:270
virtual void executeBranch(void)
Execute branch (including relative branches)
Definition: emulate.cc:402
The interface to a translation engine for a processor.
Definition: translate.hh:294
virtual void executeSegmentOp(void)
Behavior for a SEGMENTOP.
Definition: emulate.cc:308
virtual void fallthruOp(void)=0
Standard p-code fall-thru semantics.
Emulate * emulate
The emulator currently associated with this breakpoint.
Definition: emulate.hh:79
BreakCallBack(void)
Generic breakpoint constructor.
Definition: emulate.hh:90
virtual void executeNew(void)
Standard behavior for (low-level) NEW op.
Definition: emulate.cc:320
virtual void executeUnary(void)
Execute a unary arithmetic/logical operation.
Definition: emulate.cc:216
OpCode
The op-code defining a specific p-code operation (PcodeOp)
Definition: opcodes.hh:35
virtual void executeBranch(void)=0
Standard behavior for a BRANCH.
A breakpoint object.
Definition: emulate.hh:77
OpBehavior * currentBehave
Behavior of the next op to execute.
Definition: emulate.hh:171
virtual bool executeCbranch(void)=0
Check if the conditional of a CBRANCH is true.
virtual Address getExecuteAddress(void) const
Get current execution address.
Definition: emulate.hh:364
MemoryState * memstate
The memory state of the emulator.
Definition: emulate.hh:245
A low-level representation of a single pcode operation.
Definition: pcoderaw.hh:94
PcodeEmitCache(vector< PcodeOpRaw * > &ocache, vector< VarnodeData * > &vcache, const vector< OpBehavior * > &in, uintb uniqReserve)
Constructor.
Definition: emulate.cc:102
virtual Address getExecuteAddress(void) const =0
Get the address of the current instruction being executed.
Data defining a specific memory location.
Definition: pcoderaw.hh:33
virtual void setExecuteAddress(const Address &addr)=0
Set the address of the next instruction to emulate.
virtual void executeCpoolRef(void)=0
Standard behavior for a CPOOLREF (constant pool reference) op.
virtual void executeCall(void)
Standard behavior for a p-code CALL.
Definition: emulate.cc:277
void executeCurrentOp(void)
Do a single pcode op step.
Definition: emulate.cc:141
virtual bool executeCbranch(void)
Check if the conditional of a CBRANCH is true.
Definition: emulate.cc:263
virtual void executeBranch(void)
Standard behavior for a BRANCH.
Definition: emulate.cc:257
A basic instantiation of a breakpoint table.
Definition: emulate.hh:137
virtual void executeIndirect(void)=0
Standard behavior for an INDIRECT op.
virtual void executeStore(void)=0
Standard behavior for a p-code STORE.
virtual void executeLoad(void)
Standard behavior for a p-code LOAD.
Definition: emulate.cc:235
bool isInstructionStart(void) const
Return true if we are at an instruction start.
Definition: emulate.hh:330
virtual void executeCallind(void)
Standard behavior for a CALLIND.
Definition: emulate.cc:283
virtual void executeCall(void)=0
Standard behavior for a p-code CALL.
MemoryState * getMemoryState(void) const
Get the emulator's memory state.
Definition: emulate.hh:269
virtual void executeCpoolRef(void)
Standard behavior for a CPOOLREF (constant pool reference) op.
Definition: emulate.cc:314
virtual void executeSegmentOp(void)=0
Behavior for a SEGMENTOP.
EmulateMemory(MemoryState *mem)
Construct given a memory state.
Definition: emulate.hh:264
A collection of breakpoints for the emulator.
Definition: emulate.hh:37