Class ValueFlowQuery
- java.lang.Object
-
- com.tonic.analysis.simulation.query.ValueFlowQuery
-
public class ValueFlowQuery extends Object
Def-use query over the values observed by a simulation run.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanflowsTo(SimValue source, SimValue target)Searches the dependent chain for a path from one value to another.static ValueFlowQueryfrom(SimulationResult result)Builds the def-use flow graph over a completed simulation.List<SimValue>getConstants()Scans every simulated state for constant stack and local values.IRInstructiongetDefiningInstruction(SimValue value)Resolves the instruction that produced a value, falling back to the value's own recorded source instruction.Set<SimValue>getDependencies(SimValue value)Looks up the inputs a value was computed from.Set<SimValue>getDependents(SimValue value)Scans the dependency map for values computed from the given one.List<SimValue>getFlowPath(SimValue source, SimValue target)Finds the shortest chain of dependent values leading from one value to another.List<IRInstruction>getUses(SimValue value)Looks up the instructions that consume a value as an operand.intgetValueCount()List<SimValue>getValuesAtStackPosition(int position)Collects everything a stack slot held over the whole simulation.List<SimValue>getValuesInLocal(int localIndex)Collects everything a local slot held over the whole simulation.StringtoString()
-
-
-
Method Detail
-
from
public static ValueFlowQuery from(SimulationResult result)
Builds the def-use flow graph over a completed simulation.- Parameters:
result- the simulation whose recorded states are indexed- Returns:
- a query over that result
-
getDefiningInstruction
public IRInstruction getDefiningInstruction(SimValue value)
Resolves the instruction that produced a value, falling back to the value's own recorded source instruction.- Parameters:
value- the value to query- Returns:
- the producing instruction, or null if the value is null or has no source
-
getUses
public List<IRInstruction> getUses(SimValue value)
Looks up the instructions that consume a value as an operand.- Parameters:
value- the value to query- Returns:
- its consumers, or an empty list if it has none recorded
-
getDependencies
public Set<SimValue> getDependencies(SimValue value)
Looks up the inputs a value was computed from.- Parameters:
value- the value to query- Returns:
- its input values, or an empty set if it has none recorded
-
flowsTo
public boolean flowsTo(SimValue source, SimValue target)
Searches the dependent chain for a path from one value to another.- Parameters:
source- the value to start fromtarget- the value to reach- Returns:
- true if target is reachable from source, false if either is null
-
getDependents
public Set<SimValue> getDependents(SimValue value)
Scans the dependency map for values computed from the given one.- Parameters:
value- the input value- Returns:
- the values that directly consume it
-
getFlowPath
public List<SimValue> getFlowPath(SimValue source, SimValue target)
Finds the shortest chain of dependent values leading from one value to another.- Parameters:
source- the value to start fromtarget- the value to reach- Returns:
- the path including both endpoints, or an empty list if either is null or unreachable
-
getValuesAtStackPosition
public List<SimValue> getValuesAtStackPosition(int position)
Collects everything a stack slot held over the whole simulation.- Parameters:
position- the stack position to sample- Returns:
- the distinct values seen at that position, in encounter order
-
getValuesInLocal
public List<SimValue> getValuesInLocal(int localIndex)
Collects everything a local slot held over the whole simulation.- Parameters:
localIndex- the local variable slot to sample- Returns:
- the distinct values seen in that slot, in encounter order
-
getConstants
public List<SimValue> getConstants()
Scans every simulated state for constant stack and local values.- Returns:
- the distinct constants observed, in encounter order
-
getValueCount
public int getValueCount()
- Returns:
- the number of values with a recorded defining instruction
-
-