Package ghidra.util.state
Class ContextState
- java.lang.Object
-
- ghidra.util.state.ContextState
-
public class ContextState extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ContextState(Address entryPt, Program program)
Constructs an empty state.ContextState(Address entryPt, ProgramContext programCtx, Program program)
Constructs an empty state.ContextState(SequenceNumber pcodeEntry, ContextState previousState)
Derive a new context state from an initial state
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContextState
branchState(SequenceNumber pcodeEntry)
Branch the current state.java.util.HashMap<java.lang.Long,Varnode>
clearUniqueState()
When done processing a particular instruction, this method should be invoked to clear any unique Varnode state.Varnode
get(int spaceID, Varnode offsetValue, int size)
Retrieve the value/operation stored within the specified space using an offset identified by a value/operation.Varnode
get(int spaceID, Varnode offsetValue, int size, TaskMonitor monitor)
Retrieve the value/operation stored within the specified space using an offset identified by a value/operation.Varnode
get(Varnode varnode)
Retrieve the value/operation stored in the specified addressable location (address or register varnode).Varnode
get(Varnode varnode, TaskMonitor monitor)
Retrieve the value/operation stored in the specified addressable location (address or register varnode).java.util.List<Register>
getDifferingRegisters(ContextState other)
SequenceNumber
getEntryPoint()
Returns the point at which the state was instantiated.SequenceNumber
getExitPoint()
java.util.Set<SequenceNumber>
getFlowFroms()
ContextState
getPreviousContextState()
Returns previous ContextState which flowed into this one.Program
getProgram()
Returns program associated with this context stateSequenceRange
getSequenceRange()
boolean
hasDifferingRegisters(ContextState other)
boolean
isFlowFrom(SequenceNumber seq)
void
lock()
When no longer updating this state, this method should be invoked to cleanup resources no longer needed (e.g., uniqueState no longer maintained).void
setDebugVarnod(Varnode varnode)
Set a varnode to be debugged.boolean
store(int spaceID, Varnode offsetValue, Varnode storedValue, int size)
void
store(Varnode addressVarnode, Varnode storedValue)
Store a value.
-
-
-
Constructor Detail
-
ContextState
public ContextState(Address entryPt, Program program)
Constructs an empty state.- Parameters:
pcodeEntry
- instruction identifies the instruction entry point for this context state. A pcodeIndex of 0 is assumed. Initial state utilizes the program's stored context.program
-
-
ContextState
public ContextState(Address entryPt, ProgramContext programCtx, Program program)
Constructs an empty state.- Parameters:
pcodeEntry
- instruction identifies the instruction entry point for this context state. A pcodeIndex of 0 is assumed.programCtx
- initial program context or nullprogram
-
-
ContextState
public ContextState(SequenceNumber pcodeEntry, ContextState previousState)
Derive a new context state from an initial state- Parameters:
instructionAddr
- instruction identifies the instruction entry point for this context state.pcodeIndex
- pcode identifies the pcode entry point for this context state.previousState
- previous context state flowing into the specified pcode location
-
-
Method Detail
-
getProgram
public Program getProgram()
Returns program associated with this context state
-
getPreviousContextState
public ContextState getPreviousContextState()
Returns previous ContextState which flowed into this one.
-
isFlowFrom
public boolean isFlowFrom(SequenceNumber seq)
-
getFlowFroms
public java.util.Set<SequenceNumber> getFlowFroms()
-
getExitPoint
public SequenceNumber getExitPoint()
-
getSequenceRange
public SequenceRange getSequenceRange()
-
setDebugVarnod
public void setDebugVarnod(Varnode varnode)
Set a varnode to be debugged. This will be passed to any states derived from this state.- Parameters:
varnode
- varnode to be debugged
-
branchState
public ContextState branchState(SequenceNumber pcodeEntry)
Branch the current state. The current state should be associated with branch target, the returned state should be used for the fall-through flow.- Returns:
-
getEntryPoint
public SequenceNumber getEntryPoint()
Returns the point at which the state was instantiated.
-
clearUniqueState
public java.util.HashMap<java.lang.Long,Varnode> clearUniqueState()
When done processing a particular instruction, this method should be invoked to clear any unique Varnode state.- Returns:
- previous unique state
-
lock
public void lock()
When no longer updating this state, this method should be invoked to cleanup resources no longer needed (e.g., uniqueState no longer maintained).
-
store
public void store(Varnode addressVarnode, Varnode storedValue)
Store a value. Unique varnodes not permitted once locked.- Parameters:
addressVarnode
- identifies storage (address, register or unique)storedValue
- constant or OperationVarnode
-
get
public Varnode get(int spaceID, Varnode offsetValue, int size)
Retrieve the value/operation stored within the specified space using an offset identified by a value/operation.- Parameters:
spaceID
-offsetValue
-size
-- Returns:
- stored value/operation or null or DUMMY_BYTE_VARNODE
-
get
public Varnode get(int spaceID, Varnode offsetValue, int size, TaskMonitor monitor) throws CancelledException
Retrieve the value/operation stored within the specified space using an offset identified by a value/operation.- Parameters:
spaceID
-offsetValue
-size
-- Returns:
- stored value/operation or null or DUMMY_BYTE_VARNODE
- Throws:
CancelledException
-
get
public Varnode get(Varnode varnode)
Retrieve the value/operation stored in the specified addressable location (address or register varnode). If varnode is a constant, the input argument will be returned. Unique varnodes not permitted once locked.- Parameters:
varnode
- identifies constant or storage (constant, address, register or unique), if VarnodeOperation specified null will always be returned.- Returns:
- stored value/operation
-
get
public Varnode get(Varnode varnode, TaskMonitor monitor) throws CancelledException
Retrieve the value/operation stored in the specified addressable location (address or register varnode). If varnode is a constant, the input argument will be returned. Unique varnodes not permitted once locked.- Parameters:
varnode
- identifies constant or storage (constant, address, register or unique), if VarnodeOperation specified null will always be returned.- Returns:
- stored value/operation
- Throws:
CancelledException
-
getDifferingRegisters
public java.util.List<Register> getDifferingRegisters(ContextState other)
-
hasDifferingRegisters
public boolean hasDifferingRegisters(ContextState other)
-
-