Package ghidra.app.emulator
Class EmulatorHelper
java.lang.Object
ghidra.app.emulator.EmulatorHelper
- All Implemented Interfaces:
EmulatorConfiguration,MemoryFaultHandler
@Deprecated(since="12.1",
forRemoval=true)
public class EmulatorHelper
extends Object
implements MemoryFaultHandler, EmulatorConfiguration
Deprecated, for removal: This API element is subject to removal in a future version.
This is the primary "entry point" for using an
Emulator.
This is part of the older p-code emulation system. For information about the newer p-code
emulation system, see PcodeEmulator. There are several example scripts in the
SystemEmulation module.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEmulatorHelper(Program program) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionvoidclearBreakpoint(Address addr) Deprecated, for removal: This API element is subject to removal in a future version.Clear breakpointcreateMemoryBlockFromMemoryState(String name, Address start, int length, boolean overlay, TaskMonitor monitor) Deprecated, for removal: This API element is subject to removal in a future version.Create a new initialized memory block using the current emulator memory statevoiddispose()Deprecated, for removal: This API element is subject to removal in a future version.voidenableMemoryWriteTracking(boolean enable) Deprecated, for removal: This API element is subject to removal in a future version.Enable/Disable tracking of memory writes in the form of an address set.Deprecated, for removal: This API element is subject to removal in a future version.Get the current context register valueDeprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Get current execution addressDeprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Get Program Counter (PC) register defined by applicable processor specificationDeprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Get Stack Pointer register defined by applicable compiler specificationDeprecated, for removal: This API element is subject to removal in a future version.protected EmulatorDeprecated, for removal: This API element is subject to removal in a future version.byte[]readMemory(Address addr, int length) Deprecated, for removal: This API element is subject to removal in a future version.bytereadMemoryByte(Address addr) Deprecated, for removal: This API element is subject to removal in a future version.readNullTerminatedString(Address addr, int maxLength) Deprecated, for removal: This API element is subject to removal in a future version.Read string from memory state.readRegister(Register reg) Deprecated, for removal: This API element is subject to removal in a future version.readRegister(String regName) Deprecated, for removal: This API element is subject to removal in a future version.readStackValue(int relativeOffset, int size, boolean signed) Deprecated, for removal: This API element is subject to removal in a future version.Read a stack value from the memory state.voidregisterCallOtherCallback(String pcodeOpName, BreakCallBack callback) Deprecated, for removal: This API element is subject to removal in a future version.Register callback for language defined pcodeop (call other).voidDeprecated, for removal: This API element is subject to removal in a future version.Register default callback for language defined pcodeops (call other).booleanrun(Address addr, ProcessorContext context, TaskMonitor monitor) Deprecated, for removal: This API element is subject to removal in a future version.Start execution at the specified address using the initial context specified.booleanrun(TaskMonitor monitor) Deprecated, for removal: This API element is subject to removal in a future version.Continue execution from the current execution address.voidsetBreakpoint(Address addr) Deprecated, for removal: This API element is subject to removal in a future version.Establish breakpointvoidsetContextRegister(Register ctxReg, BigInteger value) Deprecated, for removal: This API element is subject to removal in a future version.Set current context register value.voidsetContextRegister(RegisterValue ctxRegValue) Deprecated, for removal: This API element is subject to removal in a future version.Set current context register value.voidsetMemoryFaultHandler(MemoryFaultHandler handler) Deprecated, for removal: This API element is subject to removal in a future version.Provides ability to install a low-level memory fault handler.booleanstep(TaskMonitor monitor) Deprecated, for removal: This API element is subject to removal in a future version.Step execution one instruction which may consist of multiple pcode operations.booleanuninitializedRead(Address address, int size, byte[] buf, int bufOffset) Deprecated, for removal: This API element is subject to removal in a future version.An attempt has been made to read uninitialized memory at the specified address.booleanunknownAddress(Address address, boolean write) Deprecated, for removal: This API element is subject to removal in a future version.Unable to translate the specified addressvoidunregisterCallOtherCallback(String pcodeOpName) Deprecated, for removal: This API element is subject to removal in a future version.Unregister callback for language defined pcodeop (call other).voidDeprecated, for removal: This API element is subject to removal in a future version.Unregister default callback for language defined pcodeops (call other).voidwriteMemory(Address addr, byte[] bytes) Deprecated, for removal: This API element is subject to removal in a future version.voidwriteMemoryValue(Address addr, int size, long value) Deprecated, for removal: This API element is subject to removal in a future version.voidwriteRegister(Register reg, long value) Deprecated, for removal: This API element is subject to removal in a future version.voidwriteRegister(Register reg, BigInteger value) Deprecated, for removal: This API element is subject to removal in a future version.voidwriteRegister(String regName, long value) Deprecated, for removal: This API element is subject to removal in a future version.voidwriteRegister(String regName, BigInteger value) Deprecated, for removal: This API element is subject to removal in a future version.voidwriteStackValue(int relativeOffset, int size, long value) Deprecated, for removal: This API element is subject to removal in a future version.Write a value onto the stackvoidwriteStackValue(int relativeOffset, int size, BigInteger value) Deprecated, for removal: This API element is subject to removal in a future version.Write a value onto the stackMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.app.emulator.EmulatorConfiguration
getPreferredMemoryPageSize, getProgramCounterName, isWriteBackEnabled
-
Constructor Details
-
EmulatorHelper
Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Details
-
newEmulator
Deprecated, for removal: This API element is subject to removal in a future version. -
dispose
public void dispose()Deprecated, for removal: This API element is subject to removal in a future version. -
getMemoryFaultHandler
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
getMemoryFaultHandlerin interfaceEmulatorConfiguration
-
getLoadData
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
getLoadDatain interfaceEmulatorConfiguration
-
getLanguage
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
getLanguagein interfaceEmulatorConfiguration
-
getProgram
Deprecated, for removal: This API element is subject to removal in a future version. -
getPCRegister
Deprecated, for removal: This API element is subject to removal in a future version.Get Program Counter (PC) register defined by applicable processor specification- Returns:
- Program Counter register
-
getStackPointerRegister
Deprecated, for removal: This API element is subject to removal in a future version.Get Stack Pointer register defined by applicable compiler specification- Returns:
- Stack Pointer register
-
setMemoryFaultHandler
Deprecated, for removal: This API element is subject to removal in a future version.Provides ability to install a low-level memory fault handler. The handler methods should generally return 'false' to allow the default handler to generate the appropriate target error. Within the fault handler, the EmulateExecutionState can be used to distinguish the pcode-emit state and the actual execution state since an attempt to execute an instruction at an uninitialized memory location will cause an uninitializedRead during the PCODE_EMIT state.- Parameters:
handler- memory fault handler.
-
getEmulateExecutionState
Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- the low-level emulator execution state
-
readRegister
Deprecated, for removal: This API element is subject to removal in a future version. -
readRegister
Deprecated, for removal: This API element is subject to removal in a future version. -
writeRegister
Deprecated, for removal: This API element is subject to removal in a future version. -
writeRegister
Deprecated, for removal: This API element is subject to removal in a future version. -
writeRegister
Deprecated, for removal: This API element is subject to removal in a future version. -
writeRegister
Deprecated, for removal: This API element is subject to removal in a future version. -
readNullTerminatedString
Deprecated, for removal: This API element is subject to removal in a future version.Read string from memory state.- Parameters:
addr- memory addressmaxLength- limit string read to this length. If return string is truncated, "..." will be appended.- Returns:
- string read from memory state
-
readMemoryByte
Deprecated, for removal: This API element is subject to removal in a future version. -
readMemory
Deprecated, for removal: This API element is subject to removal in a future version. -
writeMemory
Deprecated, for removal: This API element is subject to removal in a future version. -
writeMemoryValue
Deprecated, for removal: This API element is subject to removal in a future version. -
readStackValue
Deprecated, for removal: This API element is subject to removal in a future version.Read a stack value from the memory state.- Parameters:
relativeOffset- offset relative to current stack pointersize- data size in bytessigned- true if value read is signed, false if unsigned- Returns:
- value
- Throws:
Exception- error occurs reading stack pointer
-
writeStackValue
Deprecated, for removal: This API element is subject to removal in a future version.Write a value onto the stack- Parameters:
relativeOffset- offset relative to current stack pointersize- data size in bytesvalue-- Throws:
Exception- error occurs reading stack pointer
-
writeStackValue
Deprecated, for removal: This API element is subject to removal in a future version.Write a value onto the stack- Parameters:
relativeOffset- offset relative to current stack pointersize- data size in bytesvalue-- Throws:
Exception- error occurs reading stack pointer
-
setBreakpoint
Deprecated, for removal: This API element is subject to removal in a future version.Establish breakpoint- Parameters:
addr- memory address for new breakpoint
-
clearBreakpoint
Deprecated, for removal: This API element is subject to removal in a future version.Clear breakpoint- Parameters:
addr- memory address for breakpoint to be cleared
-
setContextRegister
Deprecated, for removal: This API element is subject to removal in a future version.Set current context register value. Keep in mind that any non-flowing context values will be stripped.- Parameters:
ctxRegValue-
-
setContextRegister
Deprecated, for removal: This API element is subject to removal in a future version.Set current context register value. Keep in mind that any non-flowing context values will be stripped.- Parameters:
ctxReg- context registervalue- context value
-
getContextRegister
Deprecated, for removal: This API element is subject to removal in a future version.Get the current context register value- Returns:
- context register value or null if not set or unknown
-
registerCallOtherCallback
Deprecated, for removal: This API element is subject to removal in a future version.Register callback for language defined pcodeop (call other). WARNING! Using this method may circumvent the default CALLOTHER emulation support when supplied by the Processor module.- Parameters:
pcodeOpName- the name of the pcode opcallback- the callback to register
-
registerDefaultCallOtherCallback
Deprecated, for removal: This API element is subject to removal in a future version.Register default callback for language defined pcodeops (call other). WARNING! Using this method may circumvent the default CALLOTHER emulation support when supplied by the Processor module.- Parameters:
callback- the default callback to register
-
unregisterCallOtherCallback
Deprecated, for removal: This API element is subject to removal in a future version.Unregister callback for language defined pcodeop (call other).- Parameters:
pcodeOpName- the name of the pcode op
-
unregisterDefaultCallOtherCallback
public void unregisterDefaultCallOtherCallback()Deprecated, for removal: This API element is subject to removal in a future version.Unregister default callback for language defined pcodeops (call other). WARNING! Using this method may circumvent the default CALLOTHER emulation support when supplied by the Processor module. -
getExecutionAddress
Deprecated, for removal: This API element is subject to removal in a future version.Get current execution address- Returns:
- current execution address
-
run
public boolean run(Address addr, ProcessorContext context, TaskMonitor monitor) throws CancelledException Deprecated, for removal: This API element is subject to removal in a future version.Start execution at the specified address using the initial context specified. Method will block until execution stops. This method will initialize context register based upon the program stored context if not already done. In addition, both general register value and the context register may be further modified via the context parameter if specified.- Parameters:
addr- initial program addresscontext- optional context settings which override current program contextmonitor-- Returns:
- true if execution completes without error (i.e., is at breakpoint)
- Throws:
CancelledException- if execution cancelled via monitor
-
run
Deprecated, for removal: This API element is subject to removal in a future version.Continue execution from the current execution address. No adjustment will be made to the context beyond the normal context flow behavior defined by the language. Method will block until execution stops.- Parameters:
monitor-- Returns:
- true if execution completes without error (i.e., is at breakpoint)
- Throws:
CancelledException- if execution cancelled via monitor
-
getLastError
Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- last error message associated with execution failure
-
step
Deprecated, for removal: This API element is subject to removal in a future version.Step execution one instruction which may consist of multiple pcode operations. No adjustment will be made to the context beyond the normal context flow behavior defined by the language. Method will block until execution stops.- Returns:
- true if execution completes without error
- Throws:
CancelledException- if execution cancelled via monitor
-
createMemoryBlockFromMemoryState
public MemoryBlock createMemoryBlockFromMemoryState(String name, Address start, int length, boolean overlay, TaskMonitor monitor) throws MemoryConflictException, AddressOverflowException, CancelledException, LockException, DuplicateNameException Deprecated, for removal: This API element is subject to removal in a future version.Create a new initialized memory block using the current emulator memory state- Parameters:
name- block namestart- start address of the blocklength- the size of the blockoverlay- if true, the block will be created as an OVERLAY which means that a new overlay address space will be created and the block will have a starting address at the same offset as the given start address parameter, but in the new address space.monitor-- Returns:
- new memory block
- Throws:
LockException- if exclusive lock not in place (see haveLock())MemoryConflictException- if the new block overlaps with a previous blockAddressOverflowException- if the start is beyond the address spaceCancelledException- user cancelled operationDuplicateNameException
-
enableMemoryWriteTracking
public void enableMemoryWriteTracking(boolean enable) Deprecated, for removal: This API element is subject to removal in a future version.Enable/Disable tracking of memory writes in the form of an address set.- Parameters:
enable-
-
getTrackedMemoryWriteSet
Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- address set of memory locations written by the emulator if memory write tracking is enabled, otherwise null is returned. The address set returned will continue to be updated unless memory write tracking becomes disabled.
-
unknownAddress
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:MemoryFaultHandlerUnable to translate the specified address- Specified by:
unknownAddressin interfaceMemoryFaultHandler- Parameters:
address- address which failed to be translatedwrite- true if memory operation was a write vs. read- Returns:
- true if fault was handled
-
uninitializedRead
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:MemoryFaultHandlerAn attempt has been made to read uninitialized memory at the specified address.- Specified by:
uninitializedReadin interfaceMemoryFaultHandler- Parameters:
address- uninitialized storage address (memory, register or unique)size- number of uninitialized bytesbuf- storage bufferbufOffset- read offset within buffer- Returns:
- true if data should be treated as initialized
-
getEmulator
Deprecated, for removal: This API element is subject to removal in a future version.
-
PcodeEmulatorinstead.