decompiler  1.0.0
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
ValueSet Class Reference

A range of values attached to a Varnode within a data-flow subsystem. More...

#include <rangeutil.hh>

Classes

class  Equation
 An external that can be applied to a ValueSet. More...
 

Public Member Functions

int4 getCount (void) const
 Get the current iteration count.
 
const CircleRangegetLandMark (void) const
 Get any landmark range. More...
 
int4 getTypeCode (void) const
 Return '0' for normal constant, '1' for spacebase relative.
 
VarnodegetVarnode (void) const
 Get the Varnode attached to this ValueSet.
 
const CircleRangegetRange (void) const
 Get the actual range of values.
 
bool isLeftStable (void) const
 Return true if the left boundary hasn't been changing.
 
bool isRightStable (void) const
 Return true if the right boundary hasn't been changing.
 
void printRaw (ostream &s) const
 Write a text description of to the given stream. More...
 

Static Public Attributes

static const int4 MAX_STEP = 32
 

Private Member Functions

bool doesEquationApply (int4 num, int4 slot) const
 Does the indicated equation apply for the given input slot. More...
 
void setFull (void)
 Mark value set as possibly containing any value.
 
void setVarnode (Varnode *v, int4 tCode)
 Attach this to given Varnode and set initial values. More...
 
void addEquation (int4 slot, int4 type, const CircleRange &constraint)
 Insert an equation restricting this value set. More...
 
void addLandmark (int4 type, const CircleRange &constraint)
 Add a widening landmark.
 
bool computeTypeCode (void)
 Figure out if this value set is absolute or relative. More...
 
bool iterate (Widener &widener)
 Regenerate this value set from operator inputs. More...
 

Private Attributes

int4 typeCode
 0=pure constant 1=stack relative
 
int4 numParams
 Number of input parameters to defining operation.
 
int4 count
 Depth first numbering / widening count.
 
OpCode opCode
 Op-code defining Varnode.
 
bool leftIsStable
 Set to true if left boundary of range didn't change (last iteration)
 
bool rightIsStable
 Set to true if right boundary of range didn't change (last iteration)
 
Varnodevn
 Varnode whose set this represents.
 
CircleRange range
 Range of values or offsets in this set.
 
vector< Equationequations
 Any equations associated with this value set.
 
PartitionpartHead
 If Varnode is a component head, pointer to corresponding Partition.
 
ValueSetnext
 Next ValueSet to iterate.
 

Friends

class ValueSetSolver
 

Detailed Description

A range of values attached to a Varnode within a data-flow subsystem.

This class acts as both the set of values for the Varnode and as a node in a sub-graph overlaying the full data-flow of the function containing the Varnode. The values are stored in the CircleRange field and can be interpreted either as absolute values (if typeCode is 0) or as values relative to a stack pointer or some other register (if typeCode is non-zero).

Member Function Documentation

void ValueSet::addEquation ( int4  slot,
int4  type,
const CircleRange constraint 
)
private

Insert an equation restricting this value set.

Equations are stored as an array of (slot,range) pairs, ordered on slot.

Parameters
slotis the given slot
typeis the constraint characteristic
constraintis the given range

Referenced by ValueSetSolver::generateFalseEquation(), and ValueSetSolver::generateTrueEquation().

bool ValueSet::computeTypeCode ( void  )
private

Figure out if this value set is absolute or relative.

Examine the input value sets that determine this set and decide if it is relative. In general, this will be relative if any of its inputs are. Certain combinations are indeterminate, which this method flags by returning true. The Varnode attached to this must have a defining op.

Returns
true if there is an indeterminate combination

References CPUI_CAST, CPUI_COPY, CPUI_INDIRECT, CPUI_INT_ADD, CPUI_INT_SUB, CPUI_MULTIEQUAL, CPUI_PTRADD, CPUI_PTRSUB, PcodeOp::getIn(), Varnode::getValueSet(), and typeCode.

bool ValueSet::doesEquationApply ( int4  num,
int4  slot 
) const
inlineprivate

Does the indicated equation apply for the given input slot.

Perform basic checks that the selected Equation exists and applies to the indicated input slot.

Parameters
numis the index selecting an Equation
slotis the indicated slot
Returns
true if the Equation exists and applies
const CircleRange * ValueSet::getLandMark ( void  ) const

Get any landmark range.

If a landmark was associated with this value set, return its range, otherwise return null.

Returns
the landmark range or null

Referenced by WidenerFull::doWidening().

bool ValueSet::iterate ( Widener widener)
private

Regenerate this value set from operator inputs.

Recalculate this value set by grabbing the value sets of the inputs to the operator defining the Varnode attached to this value set and pushing them forward through the operator.

Returns
true if there was a change to this value set

References Widener::checkFreeze(), CircleRange::circleUnion(), CPUI_MULTIEQUAL, Widener::doWidening(), CircleRange::getEnd(), PcodeOp::getIn(), CircleRange::getMin(), Varnode::getSize(), Varnode::getValueSet(), CircleRange::intersect(), CircleRange::isEmpty(), leftIsStable, CircleRange::minimalContainer(), CircleRange::pushForwardBinary(), CircleRange::pushForwardTrinary(), CircleRange::pushForwardUnary(), range, rightIsStable, CircleRange::setFull(), and vn.

Referenced by ValueSetSolver::solve().

void ValueSet::printRaw ( ostream &  s) const

Write a text description of to the given stream.

Parameters
sis the stream to print to

References CPUI_MAX, and get_opname().

Referenced by ValueSetSolver::solve().

void ValueSet::setVarnode ( Varnode v,
int4  tCode 
)
private

Attach this to given Varnode and set initial values.

The initial values in this are set based on the type of Varnode:

  • Constant gets the single value
  • Input gets all possible values
  • Other Varnodes that are written start with an empty set
Parameters
vis the given Varnode to attach to
tCodeindicates whether to treat values as constants are relative offsets

References PcodeOp::code(), CPUI_COPY, CPUI_INDIRECT, CPUI_MAX, PcodeOp::numInput(), and Varnode::setValueSet().

Member Data Documentation

const int4 ValueSet::MAX_STEP = 32
static

Maximum step inferred for a value set

Referenced by CircleRange::printRaw().


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