Ghidra Decompiler Analysis Engine
Classes | Public Member Functions | List of all members
ValueSetSolver Class Reference

Class that determines a ValueSet for each Varnode in a data-flow system. More...

#include <rangeutil.hh>

Public Member Functions

void establishValueSets (const vector< Varnode * > &sinks, const vector< PcodeOp * > &reads, Varnode *stackReg, bool indirectAsCopy)
 Build value sets for a data-flow system. More...
 
void solve (int4 max, Widener &widener)
 Iterate the ValueSet system until it stabilizes. More...
 

Detailed Description

Class that determines a ValueSet for each Varnode in a data-flow system.

This class uses value set analysis to calculate (an overestimation of) the range of values that can reach each Varnode. The system is formed by providing a set of Varnodes for which the range is desired (the sinks) via establishValueSets(). This creates a system of Varnodes (within the single function) that can flow to the sinks. Running the method solve() does the analysis, and the caller can examine the results by examining the ValueSet attached to any of the Varnodes in the system (via Varnode::getValueSet()). The ValueSetSolver::solve() starts with minimal value sets and does iteration steps by pushing them through the PcodeOps until stability is reached. A Widener object is passed to solve() which selects the specific strategy for accelerating convergence.

Member Function Documentation

◆ establishValueSets()

void ValueSetSolver::establishValueSets ( const vector< Varnode * > &  sinks,
const vector< PcodeOp * > &  reads,
Varnode stackReg,
bool  indirectAsCopy 
)

Build value sets for a data-flow system.

Given a set of sinks, find all the Varnodes that flow directly into them and set up their initial ValueSet objects.

Parameters
sinksis the list terminating Varnodes
readsare add-on PcodeOps where we would like to know input ValueSets at the point of read
stackReg(if non-NULL) gives the stack pointer (for keeping track of relative offsets)
indirectAsCopyis true if solver should treat CPUI_INDIRECT as CPUI_COPY operations

◆ solve()

void ValueSetSolver::solve ( int4  max,
Widener widener 
)

Iterate the ValueSet system until it stabilizes.

The ValueSets are recalculated in the established topological ordering, with looping at various levels until a fixed point is reached.

Parameters
maxis the maximum number of iterations to allow before forcing termination
wideneris the Widening strategy to use to accelerate stabilization

The documentation for this class was generated from the following files: