Class AdaptedEmulator
- All Implemented Interfaces:
Emulator
Emulator
that wraps the newer PcodeEmulator
This is a transitional utility only. It is currently used only by the pcode tests until that is
ported to use the new PcodeEmulator
directly. New use cases based on p-code emulation
should use the PcodeEmulator
directly. Older use cases still being actively maintained
should begin work porting to PcodeEmulator
. Old use cases without active maintenance may
try this wrapper, but may have to remain using DefaultEmulator
. At a minimum, to update
such old use cases, `new Emulator(...)` must be replaced by `new DefaultEmulator(...)`.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a filter on memory accessvoid
dispose()
Clean up resources used by the emulatorvoid
executeInstruction
(boolean stopAtBreakpoint, TaskMonitor monitor) Execute instruction at current addressGet the breakpoint tableReturns the current context register value.Get the low-level execution stateGet current execution address (or the address of the next instruction to be executed)ghidra.app.emulator.FilteredMemoryState
Get the memory state, modified by all installed access filtersboolean
getHalt()
Check if the emulator has been haltedGet the address of the last instruction executed (or the instructed currently being executed)Get the memory statelong
getPC()
Get the value of the program counterGet the name of the program counter registerprotected void
boolean
boolean
protected ghidra.app.emulator.AdaptedEmulator.AdaptedPcodeEmulator
void
setContextRegisterValue
(RegisterValue regValue) Sets the context register value at the current execute address.void
setExecuteAddress
(long addressableWordOffset) Set the value of the program countervoid
setHalt
(boolean halt) Halt or un-halt the emulator
-
Constructor Details
-
AdaptedEmulator
-
-
Method Details
-
newPcodeEmulator
protected ghidra.app.emulator.AdaptedEmulator.AdaptedPcodeEmulator newPcodeEmulator(EmulatorConfiguration config) -
initializeRegisters
-
getPCRegisterName
Description copied from interface:Emulator
Get the name of the program counter register- Specified by:
getPCRegisterName
in interfaceEmulator
- Returns:
- the name
-
setExecuteAddress
public void setExecuteAddress(long addressableWordOffset) Description copied from interface:Emulator
Set the value of the program counter- Specified by:
setExecuteAddress
in interfaceEmulator
- Parameters:
addressableWordOffset
- the word offset of the instruction to execute next.
-
getExecuteAddress
Description copied from interface:Emulator
Get current execution address (or the address of the next instruction to be executed)- Specified by:
getExecuteAddress
in interfaceEmulator
- Returns:
- current execution address
-
getLastExecuteAddress
Description copied from interface:Emulator
Get the address of the last instruction executed (or the instructed currently being executed)- Specified by:
getLastExecuteAddress
in interfaceEmulator
- Returns:
- the address
-
getPC
public long getPC()Description copied from interface:Emulator
Get the value of the program counter -
executeInstruction
public void executeInstruction(boolean stopAtBreakpoint, TaskMonitor monitor) throws CancelledException, LowlevelError, InstructionDecodeException Description copied from interface:Emulator
Execute instruction at current address- Specified by:
executeInstruction
in interfaceEmulator
- Parameters:
stopAtBreakpoint
- if true and breakpoint hits at current execution address execution will halt without executing instruction.- Throws:
CancelledException
- if execution was cancelledLowlevelError
InstructionDecodeException
-
isExecuting
public boolean isExecuting()- Specified by:
isExecuting
in interfaceEmulator
- Returns:
- true if emulator is busy executing an instruction
-
getEmulateExecutionState
Description copied from interface:Emulator
Get the low-level execution stateThis can be useful within a memory fault handler to determine if a memory read was associated with instruction parsing (i.e.,
EmulateExecutionState.INSTRUCTION_DECODE
) or an actual emulated read (i.e.,EmulateExecutionState.EXECUTE
).- Specified by:
getEmulateExecutionState
in interfaceEmulator
- Returns:
- emulator execution state.
-
getMemState
Description copied from interface:Emulator
Get the memory state- Specified by:
getMemState
in interfaceEmulator
- Returns:
- the state
-
addMemoryAccessFilter
Description copied from interface:Emulator
Add a filter on memory access- Specified by:
addMemoryAccessFilter
in interfaceEmulator
- Parameters:
filter
- the filter
-
getFilteredMemState
public ghidra.app.emulator.FilteredMemoryState getFilteredMemState()Description copied from interface:Emulator
Get the memory state, modified by all installed access filters- Specified by:
getFilteredMemState
in interfaceEmulator
- Returns:
- the state
-
setContextRegisterValue
Description copied from interface:Emulator
Sets the context register value at the current execute address.The Emulator should not be running when this method is invoked. Only flowing context bits should be set, as non-flowing bits will be cleared prior to parsing on instruction. In addition, any future context state set by the pcode emitter will take precedence over context set using this method. This method is primarily intended to be used to establish the initial context state.
- Specified by:
setContextRegisterValue
in interfaceEmulator
- Parameters:
regValue
- is the value to set context to
-
getContextRegisterValue
Description copied from interface:Emulator
Returns the current context register value.The context value returned reflects its state when the previously executed instruction was parsed/executed. The context value returned will feed into the next instruction to be parsed with its non-flowing bits cleared and any future context state merged in.
- Specified by:
getContextRegisterValue
in interfaceEmulator
- Returns:
- context as a RegisterValue object
-
getBreakTable
Description copied from interface:Emulator
Get the breakpoint table- Specified by:
getBreakTable
in interfaceEmulator
- Returns:
- the breakpoint table
-
isAtBreakpoint
public boolean isAtBreakpoint()- Specified by:
isAtBreakpoint
in interfaceEmulator
- Returns:
- true if halted at a breakpoint
-
setHalt
public void setHalt(boolean halt) Description copied from interface:Emulator
Halt or un-halt the emulator -
getHalt
public boolean getHalt()Description copied from interface:Emulator
Check if the emulator has been halted -
dispose
public void dispose()Description copied from interface:Emulator
Clean up resources used by the emulator
-