decompiler  1.0.0
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
ghidra::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

◆ addEquation()

void ghidra::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 ghidra::ValueSetSolver::generateFalseEquation(), and ghidra::ValueSetSolver::generateTrueEquation().

◆ computeTypeCode()

bool ghidra::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 ghidra::CPUI_CAST, ghidra::CPUI_COPY, ghidra::CPUI_INDIRECT, ghidra::CPUI_INT_ADD, ghidra::CPUI_INT_SUB, ghidra::CPUI_MULTIEQUAL, ghidra::CPUI_PTRADD, ghidra::CPUI_PTRSUB, ghidra::PcodeOp::getIn(), ghidra::Varnode::getValueSet(), and typeCode.

◆ doesEquationApply()

bool ghidra::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

◆ getLandMark()

const CircleRange * ghidra::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 ghidra::WidenerFull::doWidening().

◆ iterate()

bool ghidra::ValueSet::iterate ( Widener widener)
private

◆ printRaw()

void ghidra::ValueSet::printRaw ( ostream &  s) const

Write a text description of to the given stream.

Parameters
sis the stream to print to

References ghidra::CPUI_MAX.

Referenced by ghidra::ValueSetSolver::solve().

◆ setVarnode()

void ghidra::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 ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_INDIRECT, ghidra::CPUI_MAX, ghidra::PcodeOp::numInput(), and ghidra::Varnode::setValueSet().

Member Data Documentation

◆ MAX_STEP

const int4 ghidra::ValueSet::MAX_STEP = 32
static

Maximum step inferred for a value set

Referenced by ghidra::CircleRange::printRaw().


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