Class ComposedPcodeEmulationCallbacks<T>
- Type Parameters:
T- the emulator's value domain
- All Implemented Interfaces:
PcodeEmulationCallbacks<T>
The two (currently) methods that do not implement a pure broadcast pattern are
handleMissingUserop(PcodeThread, PcodeOp, PcodeFrame, String, PcodeUseropLibrary) and
readUninitialized(PcodeThread, PcodeExecutorStatePiece, AddressSetView). For a missing
userop, it will terminate after the first delegate returns true, in which case it also
returns true. If all delegates return false, then it returns false. For
an uninitialized read, each delegate's returned "still-uninitialized" set is passed to the
subsequent delegate. The first delegate gets the set as passed into the composition. The set
returned by the composition is that returned by the last delegate. This terminates early when any
delegate returns the empty set.
One (currently) other method has a non-void return type:
readUninitialized(PcodeThread, PcodeExecutorStatePiece, AddressSpace, Object, int). The
callback is broadcast as expected, and the return value is the max returned by the delegates.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ghidra.pcode.emu.PcodeEmulationCallbacks
PcodeEmulationCallbacks.NoPcodeEmulationCallbacks, PcodeEmulationCallbacks.Wrapper<T> -
Constructor Summary
ConstructorsConstructorDescriptionComposedPcodeEmulationCallbacks(PcodeEmulationCallbacks<T>... delegates) Construct a composition of delegate callbacks -
Method Summary
Modifier and TypeMethodDescriptionvoidafterBranch(PcodeThread<T> thread, PcodeOp op, Address target) The emulator has just branched to an address.voidafterExecuteInject(PcodeThread<T> thread, Address address) The emulator has just finished executing an injected p-code program.voidafterExecuteInstruction(PcodeThread<T> thread, Instruction instruction) The emulator has finished executing an instruction.voidafterLoad(PcodeThread<T> thread, PcodeOp op, AddressSpace space, T offset, int size, T value) The emulator has just loaded a value from its execution state.voidafterStepOp(PcodeThread<T> thread, PcodeOp op, PcodeFrame frame) The emulator has just executed a p-code op.voidafterStore(PcodeThread<T> thread, PcodeOp op, AddressSpace space, T offset, int size, T value) The emulator has just stored a value into its execution state.voidbeforeDecodeInstruction(PcodeThread<T> thread, Address counter, RegisterValue context) The emulator, having found no injects, is preparing to decode an instruction.voidbeforeExecuteInject(PcodeThread<T> thread, Address address, PcodeProgram program) The emulator is preparing to execute an injected program.voidbeforeExecuteInstruction(PcodeThread<T> thread, Instruction instruction, PcodeProgram program) The emulator is preparing to execute a decoded instruction.voidbeforeLoad(PcodeThread<T> thread, PcodeOp op, AddressSpace space, T offset, int size) The emulator is preparing to load a value from its execution state.voidbeforeStepOp(PcodeThread<T> thread, PcodeOp op, PcodeFrame frame) The emulator is preparing to execute a p-code op.voidbeforeStore(PcodeThread<T> thread, PcodeOp op, AddressSpace space, T offset, int size, T value) The emulator is preparing to store a value into its execution state.<A,U> void dataWritten(PcodeThread<T> thread, PcodeExecutorStatePiece<A, U> piece, Address address, int length, U value) Data was written into the given state piece (concrete addressing).<A,U> void dataWritten(PcodeThread<T> thread, PcodeExecutorStatePiece<A, U> piece, AddressSpace space, A offset, int length, U value) Data was written into the given state piece (abstract addressing).voidemulatorCreated(PcodeMachine<T> machine) The emulator has been created, but not yet finished construction.getInject(PcodeThread<T> thread, Address address) The emulator is preparing to decode an instruction, but is checking for injected overrides first.booleanhandleMissingUserop(PcodeThread<T> thread, PcodeOp op, PcodeFrame frame, String opName, PcodeUseropLibrary<T> library) The emulator has encountered a userop for which it has no definition.<A,U> AddressSetView readUninitialized(PcodeThread<T> thread, PcodeExecutorStatePiece<A, U> piece, AddressSetView set) The emulator is preparing to read from uninitialized portions of the given state piece (concrete addressing).<A,U> int readUninitialized(PcodeThread<T> thread, PcodeExecutorStatePiece<A, U> piece, AddressSpace space, A offset, int length) The emulator is preparing to read from uninitialized portions of the given state piece (abstract addressing).voidsharedStateCreated(PcodeMachine<T> machine) The emulator's shared state has been created.voidthreadCreated(PcodeThread<T> thread) A new thread has just been created.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.pcode.emu.PcodeEmulationCallbacks
delegateDataWritten, delegateDataWritten, delegateReadUninitialized, delegateReadUninitialized, wrapFor
-
Constructor Details
-
ComposedPcodeEmulationCallbacks
Construct a composition of delegate callbacks- Parameters:
delegates- the delegates
-
-
Method Details
-
emulatorCreated
Description copied from interface:PcodeEmulationCallbacksThe emulator has been created, but not yet finished construction.WARNING: At this point, the emulator has not been fully constructed. The most the callback ought to do is save a pointer to the machine. Attempting to access the machine or invoke any of its methods will likely result in a
NullPointerException. Use thePcodeEmulationCallbacks.sharedStateCreated(PcodeMachine)callback to access the machine after it has been constructed- Specified by:
emulatorCreatedin interfacePcodeEmulationCallbacks<T>- Parameters:
machine- the emulator or abstract machine.
-
threadCreated
Description copied from interface:PcodeEmulationCallbacksA new thread has just been created.The thread is fully constructed. This callback may access it.
- Specified by:
threadCreatedin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the new thread
-
getInject
Description copied from interface:PcodeEmulationCallbacksThe emulator is preparing to decode an instruction, but is checking for injected overrides first.- Specified by:
getInjectin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadaddress- the thread's program counter- Returns:
- null, or a p-code program to override the instruction
- See Also:
-
beforeExecuteInject
Description copied from interface:PcodeEmulationCallbacksThe emulator is preparing to execute an injected program.- Specified by:
beforeExecuteInjectin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadaddress- the thread's program counterprogram- the injected p-code program- See Also:
-
afterExecuteInject
Description copied from interface:PcodeEmulationCallbacksThe emulator has just finished executing an injected p-code program.If the program executed a branch, then
addresswill be the target address. Note that any sane inject ought to execute a branch, even to effect fall-through, otherwise the program counter cannot advance.- Specified by:
afterExecuteInjectin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadaddress- the thread's program counter
-
beforeDecodeInstruction
Description copied from interface:PcodeEmulationCallbacksThe emulator, having found no injects, is preparing to decode an instruction.- Specified by:
beforeDecodeInstructionin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadcounter- the thread's program countercontext- the decode contextreg value
-
beforeExecuteInstruction
public void beforeExecuteInstruction(PcodeThread<T> thread, Instruction instruction, PcodeProgram program) Description copied from interface:PcodeEmulationCallbacksThe emulator is preparing to execute a decoded instruction.- Specified by:
beforeExecuteInstructionin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadinstruction- the decoded instructionprogram- the instruction's p-code program
-
afterExecuteInstruction
Description copied from interface:PcodeEmulationCallbacksThe emulator has finished executing an instruction.- Specified by:
afterExecuteInstructionin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadinstruction- the just-executed instruction
-
beforeStepOp
Description copied from interface:PcodeEmulationCallbacksThe emulator is preparing to execute a p-code op.- Specified by:
beforeStepOpin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadop- the opframe- the frame for the current p-code program
-
afterStepOp
Description copied from interface:PcodeEmulationCallbacksThe emulator has just executed a p-code op.- Specified by:
afterStepOpin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadop- the opframe- the frame for the current p-code program
-
beforeLoad
Description copied from interface:PcodeEmulationCallbacksThe emulator is preparing to load a value from its execution state.- Specified by:
beforeLoadin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadop- thePcodeOp.LOADopspace- the address space of the operandoffset- the offset of the operandsize- the size of the operand
-
afterLoad
public void afterLoad(PcodeThread<T> thread, PcodeOp op, AddressSpace space, T offset, int size, T value) Description copied from interface:PcodeEmulationCallbacksThe emulator has just loaded a value from its execution state.- Specified by:
afterLoadin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadop- thePcodeOp.LOADopspace- the address space of the operandoffset- the offset of the operandsize- the size of the operandvalue- the value loaded
-
beforeStore
public void beforeStore(PcodeThread<T> thread, PcodeOp op, AddressSpace space, T offset, int size, T value) Description copied from interface:PcodeEmulationCallbacksThe emulator is preparing to store a value into its execution state.- Specified by:
beforeStorein interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadop- thePcodeOp.STOREopspace- the address space of the operandoffset- the offset of the operandsize- the size of the operandvalue- the value to store
-
afterStore
public void afterStore(PcodeThread<T> thread, PcodeOp op, AddressSpace space, T offset, int size, T value) Description copied from interface:PcodeEmulationCallbacksThe emulator has just stored a value into its execution state.- Specified by:
afterStorein interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadop- thePcodeOp.STOREopspace- the address space of the operandoffset- the offset of the operandsize- the size of the operandvalue- the value stored
-
afterBranch
Description copied from interface:PcodeEmulationCallbacksThe emulator has just branched to an address.- Specified by:
afterBranchin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadop- the branching optarget- the new program counter
-
handleMissingUserop
public boolean handleMissingUserop(PcodeThread<T> thread, PcodeOp op, PcodeFrame frame, String opName, PcodeUseropLibrary<T> library) Description copied from interface:PcodeEmulationCallbacksThe emulator has encountered a userop for which it has no definition.Emulation has not yet been interrupted at this point. If a callback returns true, indicating the fault has been handled, then the emulator will proceed. If not, then emulation for this thread will be interrupted
- Specified by:
handleMissingUseropin interfacePcodeEmulationCallbacks<T>- Parameters:
thread- the threadop- thePcodeOp.CALLOTHERopframe- the frame for the current p-code programopName- the name of the userop being calledlibrary- the thread's userop library- Returns:
- true if handled, false if not
-
dataWritten
public <A,U> void dataWritten(PcodeThread<T> thread, PcodeExecutorStatePiece<A, U> piece, AddressSpace space, A offset, int length, U value) Description copied from interface:PcodeEmulationCallbacksData was written into the given state piece (abstract addressing).NOTE: In contrast to the operation-driven callbacks, e.g.,
PcodeEmulationCallbacks.beforeStore(PcodeThread, PcodeOp, AddressSpace, Object, int, Object), thethreadparameter here may be null. It is not necessarily the thread executing the op, but the thread associated to the state being accessed. In particular, when this is the shared state,threadwill be null. When this is the local state,threadwill be the thread of execution. If this behavior poses a serious limitation, then we may consider changing this to always be the thread of execution.- Specified by:
dataWrittenin interfacePcodeEmulationCallbacks<T>- Type Parameters:
A- the piece's address domainU- the piece's value domain- Parameters:
thread- the thread associated to the piecepiece- the state piecespace- the address space of the operandoffset- the offset of the operandlength- the size of the operandvalue- the value written
-
dataWritten
public <A,U> void dataWritten(PcodeThread<T> thread, PcodeExecutorStatePiece<A, U> piece, Address address, int length, U value) Description copied from interface:PcodeEmulationCallbacksData was written into the given state piece (concrete addressing).- Specified by:
dataWrittenin interfacePcodeEmulationCallbacks<T>- Type Parameters:
A- the piece's address domainU- the piece's value domain- Parameters:
thread- the thread associated to the piece. SeePcodeEmulationCallbacks.dataWritten(PcodeThread, PcodeExecutorStatePiece, AddressSpace, Object, int, Object)piece- the state pieceaddress- the address of the operandlength- the size of the operandvalue- the value written
-
readUninitialized
public <A,U> int readUninitialized(PcodeThread<T> thread, PcodeExecutorStatePiece<A, U> piece, AddressSpace space, A offset, int length) Description copied from interface:PcodeEmulationCallbacksThe emulator is preparing to read from uninitialized portions of the given state piece (abstract addressing).This callback provides an opportunity for something to initialize the required portion lazily. In most cases, this should either return 0 indicating the requested portion remains uninitialized, or the full
lengthindicating the full requested portion is now initialized. If, for some reason, the requested portion could only be partially initialized, this can return a smaller length. Partial initializations are only recognized from the starting offset. Other parts could be initialized; however, there is no mechanism for communicating that result to the emulator.- Specified by:
readUninitializedin interfacePcodeEmulationCallbacks<T>- Type Parameters:
A- the piece's address domainU- the piece's value domain- Parameters:
thread- the thread associated to the piece. SeePcodeEmulationCallbacks.dataWritten(PcodeThread, PcodeExecutorStatePiece, AddressSpace, Object, int, Object)piece- the state piecespace- the address space of the operandoffset- the offset of the operandlength- the size of the operand- Returns:
- the length of the operand just initialized, typically 0 or
length
-
readUninitialized
public <A,U> AddressSetView readUninitialized(PcodeThread<T> thread, PcodeExecutorStatePiece<A, U> piece, AddressSetView set) Description copied from interface:PcodeEmulationCallbacksThe emulator is preparing to read from uninitialized portions of the given state piece (concrete addressing).This callback provides an opportunity for something to initialize the required portion lazily. This method must return the address set that remains uninitialized. If no part of the required portion was initialized, this should return
setidentically, so that the caller can quickly recognize that nothing has changed. Otherwise, this should copyset, remove those parts it was able to initialize, and return the copy. DO NOT modify the givenset.- Specified by:
readUninitializedin interfacePcodeEmulationCallbacks<T>- Type Parameters:
A- the piece's address domainU- the piece's value domain- Parameters:
thread- the thread associated to the piece. SeePcodeEmulationCallbacks.dataWritten(PcodeThread, PcodeExecutorStatePiece, AddressSpace, Object, int, Object)piece- the state pieceset- the uninitialized portion required- Returns:
- the addresses in
setthat remain uninitialized
-