Class TraceMemoryStatePcodeExecutorStatePiece
- All Implemented Interfaces:
PcodeExecutorStatePiece<byte[],TraceMemoryState>
TraceMemoryState
This state piece is meant to be used as an auxiliary to a concrete trace-bound state. It should
be used with TraceMemoryStatePcodeArithmetic as a means of computing the "state" of a
Sleigh expression's value. It essentially works like a rudimentary taint analyzer: If any part of
any input to the expression in tainted, i.e., not TraceMemoryState.KNOWN, then the result
is TraceMemoryState.UNKNOWN. This is best exemplified in
getUnique(long, int, Reason, PcodeStateCallbacks), though it's also exemplified in
getFromSpace(AddressSpace, long, int, Reason, PcodeStateCallbacks).
NOTE: This is backed directly by the trace rather than using PcodeStateCallbacks.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ghidra.pcode.exec.PcodeExecutorStatePiece
PcodeExecutorStatePiece.Reason -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PcodeTraceDataAccessprotected final ULongSpan.MutableULongSpanMap<TraceMemoryState> Fields inherited from class ghidra.pcode.exec.AbstractLongOffsetPcodeExecutorStatePiece
addressArithmetic, arithmetic, cb, language, uniqueSpace -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstruct a pieceprotectedTraceMemoryStatePcodeExecutorStatePiece(PcodeTraceDataAccess data, ULongSpan.MutableULongSpanMap<TraceMemoryState> unique) -
Method Summary
Modifier and TypeMethodDescriptionprotected TraceMemoryStatecheckSize(int size, TraceMemoryState val) Check that the size of the value matches that givenvoidclear()Erase the entire state or pieceCreate a deep copy of this stategetConcreteBuffer(Address address, PcodeArithmetic.Purpose purpose) Bind a buffer of concrete bytes at the given start addressprotected AddressSpacegetForSpace(AddressSpace space, boolean toWrite) Get the internal space for the given address spaceprotected TraceMemoryStategetFromNullSpace(int size, PcodeExecutorStatePiece.Reason reason, PcodeStateCallbacks cb) In case spaces are generated lazily, and we're reading from a space that doesn't yet exist, "read" a default value.protected TraceMemoryStategetFromSpace(AddressSpace space, long offset, int size, PcodeExecutorStatePiece.Reason reason, PcodeStateCallbacks cb) Get a value from the given spaceGet all register values known to this stateprotected Map<Register, TraceMemoryState> getRegisterValuesFromSpace(AddressSpace s, List<Register> registers) Can the given space for register values, as inAbstractLongOffsetPcodeExecutorStatePiece.getRegisterValues()protected TraceMemoryStategetUnique(long offset, int size, PcodeExecutorStatePiece.Reason reason, PcodeStateCallbacks cb) Get a value from the unique space Some state pieces treat unique values in a way that merits a separate implementation.protected AddressRangerange(AddressSpace space, long offset, int size) protected voidsetInSpace(AddressSpace space, long offset, int size, TraceMemoryState val, PcodeStateCallbacks cb) Set a value in the given spaceprotected voidsetUnique(long offset, int size, TraceMemoryState val, PcodeStateCallbacks cb) Set a value in the unique spaceMethods inherited from class ghidra.pcode.exec.AbstractLongOffsetPcodeExecutorStatePiece
forkMap, getAddressArithmetic, getArithmetic, getLanguage, getVar, getVar, getVarInternal, getVarInternal, getVarInternal, setVar, setVar, setVarInternal, setVarInternal, setVarInternal, streamPiecesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.pcode.exec.PcodeExecutorStatePiece
checkRange, getNextEntryInternal, getNextEntryInternal, getVar, getVar, getVar, inspectBigInteger, inspectByte, inspectConcrete, inspectInt, inspectLong, inspectRegisterValue, inspectShort, quantizeOffset, setBigInteger, setByte, setConcrete, setInt, setLong, setRegisterValue, setRegisterValue, setShort, setVar, setVar, setVar
-
Field Details
-
unique
-
data
-
-
Constructor Details
-
TraceMemoryStatePcodeExecutorStatePiece
protected TraceMemoryStatePcodeExecutorStatePiece(PcodeTraceDataAccess data, ULongSpan.MutableULongSpanMap<TraceMemoryState> unique) -
TraceMemoryStatePcodeExecutorStatePiece
Construct a piece- Parameters:
data- the trace-data access shim
-
-
Method Details
-
checkSize
Description copied from class:AbstractLongOffsetPcodeExecutorStatePieceCheck that the size of the value matches that givenExtensions may override this and do nothing when the abstract type has no defined size
- Overrides:
checkSizein classAbstractLongOffsetPcodeExecutorStatePiece<byte[],TraceMemoryState, AddressSpace> - Parameters:
size- the size in bytesval- the value- Returns:
- the value, possibly adjusted
-
fork
Description copied from interface:PcodeExecutorStatePieceCreate a deep copy of this state- Parameters:
cb- callbacks to receive emulation events- Returns:
- the copy
-
range
-
setUnique
Description copied from class:AbstractLongOffsetPcodeExecutorStatePieceSet a value in the unique spaceSome state pieces treat unique values in a way that merits a separate implementation. This permits the standard path to be overridden.
- Overrides:
setUniquein classAbstractLongOffsetPcodeExecutorStatePiece<byte[],TraceMemoryState, AddressSpace> - Parameters:
offset- the offset in unique space to store the valuesize- the number of bytes to write (the size of the value)val- the value to storecb- callbacks to receive emulation events
-
getUnique
protected TraceMemoryState getUnique(long offset, int size, PcodeExecutorStatePiece.Reason reason, PcodeStateCallbacks cb) Description copied from class:AbstractLongOffsetPcodeExecutorStatePieceGet a value from the unique space Some state pieces treat unique values in a way that merits a separate implementation. This permits the standard path to be overridden.- Overrides:
getUniquein classAbstractLongOffsetPcodeExecutorStatePiece<byte[],TraceMemoryState, AddressSpace> - Parameters:
offset- the offset in unique space to get the valuesize- the number of bytes to read (the size of the value)reason- the reason for reading statecb- callbacks to receive emulation events- Returns:
- the read value
-
getForSpace
Description copied from class:AbstractLongOffsetPcodeExecutorStatePieceGet the internal space for the given address space- Specified by:
getForSpacein classAbstractLongOffsetPcodeExecutorStatePiece<byte[],TraceMemoryState, AddressSpace> - Parameters:
space- the address spacetoWrite- in case internal spaces are generated lazily, this indicates the space must be present, because it is going to be written to.- Returns:
- the space, or
null
-
setInSpace
protected void setInSpace(AddressSpace space, long offset, int size, TraceMemoryState val, PcodeStateCallbacks cb) Description copied from class:AbstractLongOffsetPcodeExecutorStatePieceSet a value in the given space- Specified by:
setInSpacein classAbstractLongOffsetPcodeExecutorStatePiece<byte[],TraceMemoryState, AddressSpace> - Parameters:
space- the address spaceoffset- the offset within the spacesize- the number of bytes to write (the size of the value)val- the value to storecb- callbacks to receive emulation events
-
getFromSpace
protected TraceMemoryState getFromSpace(AddressSpace space, long offset, int size, PcodeExecutorStatePiece.Reason reason, PcodeStateCallbacks cb) Description copied from class:AbstractLongOffsetPcodeExecutorStatePieceGet a value from the given space- Specified by:
getFromSpacein classAbstractLongOffsetPcodeExecutorStatePiece<byte[],TraceMemoryState, AddressSpace> - Parameters:
space- the address spaceoffset- the offset within the spacesize- the number of bytes to read (the size of the value)reason- the reason for reading statecb- callbacks to receive emulation events- Returns:
- the read value
-
getFromNullSpace
protected TraceMemoryState getFromNullSpace(int size, PcodeExecutorStatePiece.Reason reason, PcodeStateCallbacks cb) Description copied from class:AbstractLongOffsetPcodeExecutorStatePieceIn case spaces are generated lazily, and we're reading from a space that doesn't yet exist, "read" a default value.By default, the returned value is 0, which should be reasonable for all implementations.
- Overrides:
getFromNullSpacein classAbstractLongOffsetPcodeExecutorStatePiece<byte[],TraceMemoryState, AddressSpace> - Parameters:
size- the number of bytes to read (the size of the value)reason- the reason for reading statecb- callbacks to receive emulation events- Returns:
- the default value
-
getRegisterValuesFromSpace
protected Map<Register,TraceMemoryState> getRegisterValuesFromSpace(AddressSpace s, List<Register> registers) Description copied from class:AbstractLongOffsetPcodeExecutorStatePieceCan the given space for register values, as inAbstractLongOffsetPcodeExecutorStatePiece.getRegisterValues()- Specified by:
getRegisterValuesFromSpacein classAbstractLongOffsetPcodeExecutorStatePiece<byte[],TraceMemoryState, AddressSpace> - Parameters:
s- the space to scanregisters- the registers known to be in the corresponding address space- Returns:
- the map of registers to values
-
getRegisterValues
Description copied from interface:PcodeExecutorStatePieceGet all register values known to this stateWhen the state acts as a cache, it should only return those cached.
- Specified by:
getRegisterValuesin interfacePcodeExecutorStatePiece<byte[],TraceMemoryState> - Overrides:
getRegisterValuesin classAbstractLongOffsetPcodeExecutorStatePiece<byte[],TraceMemoryState, AddressSpace> - Returns:
- a map of registers and their values
-
getConcreteBuffer
Description copied from interface:PcodeExecutorStatePieceBind a buffer of concrete bytes at the given start address- Parameters:
address- the start addresspurpose- the reason why the emulator needs a concrete value- Returns:
- a buffer
-
clear
public void clear()Description copied from interface:PcodeExecutorStatePieceErase the entire state or pieceThis is generally only useful when the state is itself a cache to another object. This will ensure the state is reading from that object rather than a stale cache. If this is not a cache, this could in fact clear the whole state, and the machine using it will be left in the dark.
-