Class DefaultEmulator
- All Implemented Interfaces:
- Emulator
Emulator.
 
 This class used to be named Emulator, until it was replaced by an interface extracted
 from this class. There is now a second implementation named AdaptedEmulator, which wraps
 the newer PcodeEmulator system. If you are developing a new use case based on p-code
 emulation, please consider using PcodeEmulator directly. There are several example
 scripts in the SystemEmulation module. If you are maintaining an existing use case
 currently based on Emulator, you will at least need to change new Emulator(...)
 to new DefaultEmulator(...). It is highly recommended to port to the newer
 PcodeEmulator. You may find the AdaptedEmulator useful during the transition, but
 that class is only transitional.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdd a filter on memory accessvoidaddProvider(MemoryLoadImage provider, AddressSetView view) Add memory load image providerdisassemble(Integer count) Disassemble from the current execute addressvoiddispose()Clean up resources used by the emulatorvoidexecuteInstruction(boolean stopAtBreakpoint, TaskMonitor monitor) Execute instruction at current addressgenAddress(String addr) Get 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.FilteredMemoryStateGet the memory state, modified by all installed access filtersbooleangetHalt()Check if the emulator has been haltedGet the address of the last instruction executed (or the instructed currently being executed)getMemoryBank(AddressSpace space, int ps) Get the memory statelonggetPC()Get the value of the program counterGet the name of the program counter registerintbooleanbooleanvoidsetContextRegisterValue(RegisterValue regValue) Sets the context register value at the current execute address.voidsetExecuteAddress(long addressableWordOffset) Set the value of the program countervoidsetHalt(boolean halt) Halt or un-halt the emulator
- 
Constructor Details- 
DefaultEmulator
 
- 
- 
Method Details- 
cloneMemory
- 
getMemoryBank
- 
disposepublic void dispose()Description copied from interface:EmulatorClean up resources used by the emulator
- 
genAddress
- 
getPCpublic long getPC()Description copied from interface:EmulatorGet the value of the program counter
- 
getPCRegisterNameDescription copied from interface:EmulatorGet the name of the program counter register- Specified by:
- getPCRegisterNamein interface- Emulator
- Returns:
- the name
 
- 
getMemStateDescription copied from interface:EmulatorGet the memory state- Specified by:
- getMemStatein interface- Emulator
- Returns:
- the state
 
- 
getFilteredMemStatepublic ghidra.app.emulator.FilteredMemoryState getFilteredMemState()Description copied from interface:EmulatorGet the memory state, modified by all installed access filters- Specified by:
- getFilteredMemStatein interface- Emulator
- Returns:
- the state
 
- 
addMemoryAccessFilterDescription copied from interface:EmulatorAdd a filter on memory access- Specified by:
- addMemoryAccessFilterin interface- Emulator
- Parameters:
- filter- the filter
 
- 
getBreakTableDescription copied from interface:EmulatorGet the breakpoint table- Specified by:
- getBreakTablein interface- Emulator
- Returns:
- the breakpoint table
 
- 
setExecuteAddresspublic void setExecuteAddress(long addressableWordOffset) Description copied from interface:EmulatorSet the value of the program counter- Specified by:
- setExecuteAddressin interface- Emulator
- Parameters:
- addressableWordOffset- the word offset of the instruction to execute next.
 
- 
getExecuteAddressDescription copied from interface:EmulatorGet current execution address (or the address of the next instruction to be executed)- Specified by:
- getExecuteAddressin interface- Emulator
- Returns:
- current execution address
 
- 
getLastExecuteAddressDescription copied from interface:EmulatorGet the address of the last instruction executed (or the instructed currently being executed)- Specified by:
- getLastExecuteAddressin interface- Emulator
- Returns:
- the address
 
- 
getDefaultContext
- 
setHaltpublic void setHalt(boolean halt) Description copied from interface:EmulatorHalt or un-halt the emulator
- 
getHaltpublic boolean getHalt()Description copied from interface:EmulatorCheck if the emulator has been halted
- 
executeInstructionpublic void executeInstruction(boolean stopAtBreakpoint, TaskMonitor monitor) throws CancelledException, LowlevelError, InstructionDecodeException Description copied from interface:EmulatorExecute instruction at current address- Specified by:
- executeInstructionin interface- Emulator
- Parameters:
- stopAtBreakpoint- if true and breakpoint hits at current execution address execution will halt without executing instruction.
- Throws:
- CancelledException- if execution was cancelled
- LowlevelError
- InstructionDecodeException
 
- 
isAtBreakpointpublic boolean isAtBreakpoint()- Specified by:
- isAtBreakpointin interface- Emulator
- Returns:
- true if halted at a breakpoint
 
- 
getEmulateExecutionStateDescription copied from interface:EmulatorGet 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:
- getEmulateExecutionStatein interface- Emulator
- Returns:
- emulator execution state. This can be useful within a memory fault handler to determine if a memory read was associated with instruction parsing (i.e., PCODE_EMIT) or normal an actual emulated read (i.e., EXECUTE).
 
- 
isExecutingpublic boolean isExecuting()- Specified by:
- isExecutingin interface- Emulator
- Returns:
- true if emulator is busy executing an instruction
 
- 
getLanguage
- 
disassembleDisassemble from the current execute address- Parameters:
- count- number of contiguous instructions to disassemble
- Returns:
- list of instructions
 
- 
getTickCountpublic int getTickCount()
- 
getContextRegisterValueDescription copied from interface:EmulatorReturns 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:
- getContextRegisterValuein interface- Emulator
- Returns:
- context as a RegisterValue object
 
- 
setContextRegisterValueDescription copied from interface:EmulatorSets 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:
- setContextRegisterValuein interface- Emulator
- Parameters:
- regValue- is the value to set context to
 
- 
addProviderAdd memory load image provider- Parameters:
- provider- memory load image provider
- view- memory region which corresponds to provider
 
 
-