added stability tests to ValueSet

This commit is contained in:
caheckman 2019-06-06 14:03:43 -04:00
parent 32793712fe
commit 4ae42d0bd4
2 changed files with 17 additions and 3 deletions

View file

@ -1442,6 +1442,8 @@ void ValueSet::setVarnode(Varnode *v,int4 tCode)
opCode = CPUI_MAX; opCode = CPUI_MAX;
numParams = 0; numParams = 0;
range.setRange(0,vn->getSize()); // Treat as offset of 0 relative to special value range.setRange(0,vn->getSize()); // Treat as offset of 0 relative to special value
leftIsStable = true;
rightIsStable = true;
} }
else if (vn->isWritten()) { else if (vn->isWritten()) {
PcodeOp *op = vn->getDef(); PcodeOp *op = vn->getDef();
@ -1452,17 +1454,23 @@ void ValueSet::setVarnode(Varnode *v,int4 tCode)
} }
else else
numParams = op->numInput(); numParams = op->numInput();
leftIsStable = false;
rightIsStable = false;
} }
else if (vn->isConstant()) { else if (vn->isConstant()) {
opCode = CPUI_MAX; opCode = CPUI_MAX;
numParams = 0; numParams = 0;
range.setRange(vn->getOffset(),vn->getSize()); range.setRange(vn->getOffset(),vn->getSize());
leftIsStable = true;
rightIsStable = true;
} }
else { // Some other form of input else { // Some other form of input
opCode = CPUI_MAX; opCode = CPUI_MAX;
numParams = 0; numParams = 0;
typeCode = 0; typeCode = 0;
range.setFull(vn->getSize()); range.setFull(vn->getSize());
leftIsStable = false;
rightIsStable = false;
} }
} }
@ -1633,6 +1641,8 @@ bool ValueSet::iterate(Widener &widener)
if (res == range) if (res == range)
return false; return false;
leftIsStable = range.getMin() == res.getMin();
rightIsStable = range.getEnd() == res.getEnd();
if (partHead != (Partition *)0) { if (partHead != (Partition *)0) {
if (!widener.doWidening(*this, range, res)) if (!widener.doWidening(*this, range, res))
setFull(); setFull();

View file

@ -127,11 +127,13 @@ public:
private: private:
friend class ValueSetSolver; friend class ValueSetSolver;
int4 typeCode; ///< 0=pure constant 1=stack relative int4 typeCode; ///< 0=pure constant 1=stack relative
Varnode *vn; ///< Varnode whose set this represents
OpCode opCode; ///< Op-code defining Varnode
int4 numParams; ///< Number of input parameters to defining operation int4 numParams; ///< Number of input parameters to defining operation
CircleRange range; ///< Range of values or offsets in this set
int4 count; ///< Depth first numbering / widening count int4 count; ///< Depth first numbering / widening count
OpCode opCode; ///< Op-code defining Varnode
bool leftIsStable; ///< Set to \b true if left boundary of range didn't change (last iteration)
bool rightIsStable; ///< Set to \b true if right boundary of range didn't change (last iteration)
Varnode *vn; ///< Varnode whose set this represents
CircleRange range; ///< Range of values or offsets in this set
vector<Equation> equations; ///< Any equations associated with this value set vector<Equation> equations; ///< Any equations associated with this value set
Partition *partHead; ///< If Varnode is a component head, pointer to corresponding Partition Partition *partHead; ///< If Varnode is a component head, pointer to corresponding Partition
ValueSet *next; ///< Next ValueSet to iterate ValueSet *next; ///< Next ValueSet to iterate
@ -148,6 +150,8 @@ public:
int4 getTypeCode(void) const { return typeCode; } ///< Return '0' for normal constant, '1' for spacebase relative int4 getTypeCode(void) const { return typeCode; } ///< Return '0' for normal constant, '1' for spacebase relative
Varnode *getVarnode(void) const { return vn; } ///< Get the Varnode attached to \b this ValueSet Varnode *getVarnode(void) const { return vn; } ///< Get the Varnode attached to \b this ValueSet
const CircleRange &getRange(void) const { return range; } ///< Get the actual range of values const CircleRange &getRange(void) const { return range; } ///< Get the actual range of values
bool isLeftStable(void) const { return leftIsStable; }
bool isRightStable(void) const { return rightIsStable; }
void printRaw(ostream &s) const; ///< Write a text description of \b to the given stream void printRaw(ostream &s) const; ///< Write a text description of \b to the given stream
}; };