Interface PcodeExecutorStatePiece<A,T>
- Type Parameters:
A- the type of address offsetsT- the type of values
- All Known Subinterfaces:
JitBytesPcodeExecutorState,PcodeExecutorState<T>
- All Known Implementing Classes:
AbstractBytesPcodeExecutorStatePiece,AbstractLongOffsetPcodeExecutorStatePiece,AbstractPcodeExecutorState,AddressesReadTracePcodeExecutorStatePiece,BytesPcodeExecutorState,BytesPcodeExecutorStatePiece,DebuggerPcodeUtils.WatchValuePcodeExecutorState,DebuggerPcodeUtils.WatchValuePcodeExecutorStatePiece,DefaultPcodeExecutorState,IndependentPairedPcodeExecutorState,JitBytesPcodeExecutorStatePiece,JitDataFlowState,JitDefaultBytesPcodeExecutorState,JitThreadBytesPcodeExecutorState,LocationPcodeExecutorStatePiece,PairedPcodeExecutorState,PairedPcodeExecutorStatePiece,TaintPcodeExecutorState,TaintPcodeExecutorStatePiece,ThreadPcodeExecutorState,TraceMemoryStatePcodeExecutorStatePiece
T, addressed by offsets of type
A
The typical pattern for implementing a state is to compose it from one or more state pieces. Each
piece must use the same address type and arithmetic. If more than one piece is needed, they are
composed using PairedPcodeExecutorStatePiece. Once all the pieces are composed, the root
piece can be wrapped to make a state using DefaultPcodeExecutorState or
PairedPcodeExecutorState. The latter corrects the address type to be a pair so it matches
the type of values.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumReasons for reading state -
Method Summary
Modifier and TypeMethodDescriptiondefault voidcheckRange(AddressSpace space, long offset, int size) Construct a range, if only to verify the range is validvoidclear()Erase the entire state or piecedefault PcodeExecutorStatePiece<A, T> Create a deep copy of this stateGet the arithmetic used to manipulate addresses of the type used by this stateGet the arithmetic used to manipulate values of the type stored by this stategetConcreteBuffer(Address address, PcodeArithmetic.Purpose purpose) Bind a buffer of concrete bytes at the given start addressGet the language defining the address spaces of this state piecegetNextEntryInternal(AddressSpace space, long offset) Get the entry at a given offset (without issuing callbacks)getNextEntryInternal(AddressSpace space, A offset) Get the entry at or after a given offset (without issuing callbacks)Get all register values known to this statedefault TgetVar(Address address, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason) Get the value of a variabledefault TgetVar(AddressSpace space, long offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason) Get the value of a variablegetVar(AddressSpace space, A offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason) Get the value of a variabledefault TgetVar(Register reg, PcodeExecutorStatePiece.Reason reason) Get the value of a register variabledefault TgetVar(Varnode var, PcodeExecutorStatePiece.Reason reason) Get the value of a variabledefault TgetVarInternal(AddressSpace space, long offset, int size, PcodeExecutorStatePiece.Reason reason) Get the value of a variable without issuing callbacksgetVarInternal(AddressSpace space, A offset, int size, PcodeExecutorStatePiece.Reason reason) Get the value of a variable without issuing callbacksdefault BigIntegerinspectBigInteger(Address address, int size) Convenience to inspect the concrete value of a variable as aBigIntegerdefault byteinspectByte(Address address) Convenience to inspect the concrete value of a variable as abytedefault byte[]inspectConcrete(Address address, int size) Convenience to inspect the concrete value of a variabledefault intinspectInt(Address address) Convenience to inspect the concrete value of a variable as anintdefault longinspectLong(Address address) Convenience to inspect the concrete value of a variable as alongdefault RegisterValueinspectRegisterValue(Register register) Convenience to inspect the concrete value of a register variable as aRegisterValuedefault shortinspectShort(Address address) Convenience to inspect the concrete value of a variable as ashortdefault longquantizeOffset(AddressSpace space, long offset) Quantize the given offset to the language's "addressable unit"default voidsetBigInteger(Address address, int size, BigInteger value) Convenience to set a variable to a concrete value as aBigIntegerdefault voidConvenience to set a variable to a concrete value as abytedefault voidsetConcrete(Address address, byte[] value) Convenience to set a variable to a concrete valuedefault voidConvenience to set a variable to a concrete value as anintdefault voidConvenience to set a variable to a concrete value as alongdefault voidsetRegisterValue(Register register, RegisterValue value) Convenience to set a register variable to a concrete value as aRegisterValuedefault voidsetRegisterValue(RegisterValue value) Convenience to set a register variable to a concrete value as aRegisterValuedefault voidConvenience to set a variable to a concrete value as ashortdefault voidSet the value of a variabledefault voidsetVar(AddressSpace space, long offset, int size, boolean quantize, T val) Set the value of a variablevoidsetVar(AddressSpace space, A offset, int size, boolean quantize, T val) Set the value of a variabledefault voidSet the value of a register variabledefault voidSet the value of a variabledefault voidsetVarInternal(AddressSpace space, long offset, int size, T val) Set the value of a variable without issuing callbacksvoidsetVarInternal(AddressSpace space, A offset, int size, T val) Set the value of a variable without issuing callbacksStream over the pieces within.
-
Method Details
-
checkRange
Construct a range, if only to verify the range is valid- Parameters:
space- the address spaceoffset- the starting offsetsize- the length (in bytes) of the range
-
getLanguage
Language getLanguage()Get the language defining the address spaces of this state piece- Returns:
- the language
-
getAddressArithmetic
PcodeArithmetic<A> getAddressArithmetic()Get the arithmetic used to manipulate addresses of the type used by this state- Returns:
- the address (or offset) arithmetic
-
getArithmetic
PcodeArithmetic<T> getArithmetic()Get the arithmetic used to manipulate values of the type stored by this state- Returns:
- the arithmetic
-
streamPieces
Stream<PcodeExecutorStatePiece<?,?>> streamPieces()Stream over the pieces within.If this piece is not a composition of others, then simply stream this piece in a singleton. Otherwise, stream the component pieces. (Do not include the composition itself, just the component pieces.)
- Returns:
- the stream
-
fork
Create a deep copy of this state- Parameters:
cb- callbacks to receive emulation events- Returns:
- the copy
-
setVar
Set the value of a register variable- Parameters:
reg- the registerval- the value
-
setVar
Set the value of a variable- Parameters:
var- the variableval- the value
-
setVar
Set the value of a variable- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variablequantize- true to quantize to the language's "addressable unit"val- the value
-
setVarInternal
Set the value of a variable without issuing callbacks- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variableval- the value
-
setVar
Set the value of a variable- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variablequantize- true to quantize to the language's "addressable unit"val- the value
-
setVarInternal
Set the value of a variable without issuing callbacks- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variableval- the value
-
setVar
Set the value of a variable- Parameters:
address- the address in memorysize- the size of the variablequantize- true to quantize to the language's "addressable unit"val- the value
-
getVar
Get the value of a register variable- Parameters:
reg- the registerreason- the reason for reading the register- Returns:
- the value
-
getVar
Get the value of a variable- Parameters:
var- the variablereason- the reason for reading the variable- Returns:
- the value
-
getVar
T getVar(AddressSpace space, A offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason) Get the value of a variable- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variablequantize- true to quantize to the language's "addressable unit"reason- the reason for reading the variable- Returns:
- the value
-
getVarInternal
Get the value of a variable without issuing callbacks- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variablereason- the reason for reading the variable- Returns:
- the value
-
getNextEntryInternal
Get the entry at or after a given offset (without issuing callbacks)(Optional operation) For pieces where each value is effective over a range, it is common to use an internal map (vice a byte array). When serializing the state, or otherwise seeking a complete examination, it is useful to retrieve those internal entries.
- Parameters:
space- the address spaceoffset- the offset within the space- Returns:
- the entry
-
getVar
default T getVar(AddressSpace space, long offset, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason) Get the value of a variableThis method is typically used for reading memory variables.
- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variablequantize- true to quantize to the language's "addressable unit"reason- the reason for reading the variable- Returns:
- the value
-
getVarInternal
default T getVarInternal(AddressSpace space, long offset, int size, PcodeExecutorStatePiece.Reason reason) Get the value of a variable without issuing callbacks- Parameters:
space- the address spaceoffset- the offset within the spacesize- the size of the variablereason- the reason for reading the variable- Returns:
- the value
-
getNextEntryInternal
Get the entry at a given offset (without issuing callbacks)(Optional operation) For pieces where each value is effective over a range, it is common to use an internal map (vice a byte array). When serializing the state, or otherwise seeking a complete examination, it is useful to retrieve those internal entries. This returns the next entry at or after the given offset within the given space. NOTE the returned entry must be for the given space. If no such entry exists, return
null.- Parameters:
space- the address spaceoffset- the offset within the space- Returns:
- the entry or null
-
getVar
default T getVar(Address address, int size, boolean quantize, PcodeExecutorStatePiece.Reason reason) Get the value of a variableThis method is typically used for reading memory variables.
- Parameters:
address- the address of the variablesize- the size of the variablequantize- true to quantize to the language's "addressable unit"reason- the reason for reading the variable- Returns:
- the value
-
getRegisterValues
Get all register values known to this stateWhen the state acts as a cache, it should only return those cached.
- Returns:
- a map of registers and their values
-
getConcreteBuffer
Bind 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
-
quantizeOffset
Quantize the given offset to the language's "addressable unit"- Parameters:
space- the space where the offset appliesoffset- the offset- Returns:
- the quantized offset
-
clear
void clear()Erase 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.
-
setConcrete
Convenience to set a variable to a concrete value- Parameters:
address- the address in memoryvalue- the value
-
inspectConcrete
Convenience to inspect the concrete value of a variable- Parameters:
address- the address in memorysize- the number of bytes to inspect- Returns:
- the value
- Throws:
ConcretionError- if the value cannot be made concrete
-
setBigInteger
Convenience to set a variable to a concrete value as aBigInteger- Parameters:
address- the address is memorysize- the size of the variable (in bytes)value- the value
-
inspectBigInteger
Convenience to inspect the concrete value of a variable as aBigInteger- Parameters:
address- the address in memorysize- the number of bytes to inspect- Returns:
- the value
- Throws:
ConcretionError- if the value cannot be made concrete
-
setLong
Convenience to set a variable to a concrete value as along- Parameters:
address- the address is memoryvalue- the value
-
inspectLong
Convenience to inspect the concrete value of a variable as along- Parameters:
address- the address in memory- Returns:
- the value
- Throws:
ConcretionError- if the value cannot be made concrete
-
setInt
Convenience to set a variable to a concrete value as anint- Parameters:
address- the address is memoryvalue- the value
-
inspectInt
Convenience to inspect the concrete value of a variable as anint- Parameters:
address- the address in memory- Returns:
- the value
- Throws:
ConcretionError- if the value cannot be made concrete
-
setShort
Convenience to set a variable to a concrete value as ashort- Parameters:
address- the address is memoryvalue- the value
-
inspectShort
Convenience to inspect the concrete value of a variable as ashort- Parameters:
address- the address in memory- Returns:
- the value
- Throws:
ConcretionError- if the value cannot be made concrete
-
setByte
Convenience to set a variable to a concrete value as abyte- Parameters:
address- the address is memoryvalue- the value
-
inspectByte
Convenience to inspect the concrete value of a variable as abyte- Parameters:
address- the address in memory- Returns:
- the value
- Throws:
ConcretionError- if the value cannot be made concrete
-
setRegisterValue
Convenience to set a register variable to a concrete value as aRegisterValueNOTE: The register from the given value does not have to match the given register, but their sizes should at least match. This permits simpler moving of values from one register to another. If the sizes do not match, the behavior is undefined.
- Parameters:
register- the registervalue- the value
-
setRegisterValue
Convenience to set a register variable to a concrete value as aRegisterValue- Parameters:
value- the value
-
inspectRegisterValue
Convenience to inspect the concrete value of a register variable as aRegisterValue- Parameters:
register- the register- Returns:
- the value
- Throws:
ConcretionError- if the value cannot be made concrete
-