Ghidra is a software reverse engineering (SRE) framework
added stability tests to ValueSet
caheckman4ae42d0bd43e
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.ccindex 47780baa36..18db824ac8 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.cc@@ -1442,6 +1442,8 @@ void ValueSet::setVarnode(Varnode *v,int4 tCode)opCode = CPUI_MAX;numParams = 0;range.setRange(0,vn->getSize()); // Treat as offset of 0 relative to special value+ leftIsStable = true;+ rightIsStable = true;}else if (vn->isWritten()) {PcodeOp *op = vn->getDef();@@ -1452,17 +1454,23 @@ void ValueSet::setVarnode(Varnode *v,int4 tCode)}elsenumParams = op->numInput();+ leftIsStable = false;+ rightIsStable = false;}else if (vn->isConstant()) {opCode = CPUI_MAX;numParams = 0;range.setRange(vn->getOffset(),vn->getSize());+ leftIsStable = true;+ rightIsStable = true;}else { // Some other form of inputopCode = CPUI_MAX;numParams = 0;typeCode = 0;range.setFull(vn->getSize());+ leftIsStable = false;+ rightIsStable = false;}}@@ -1633,6 +1641,8 @@ bool ValueSet::iterate(Widener &widener)if (res == range)return false;+ leftIsStable = range.getMin() == res.getMin();+ rightIsStable = range.getEnd() == res.getEnd();if (partHead != (Partition *)0) {if (!widener.doWidening(*this, range, res))setFull();diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.hhindex 0142412b0e..c8528cf388 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/rangeutil.hh@@ -127,11 +127,13 @@ public:private:friend class ValueSetSolver;int4 typeCode; ///< 0=pure constant 1=stack relative- Varnode *vn; ///< Varnode whose set this represents- OpCode opCode; ///< Op-code defining Varnodeint4 numParams; ///< Number of input parameters to defining operation- CircleRange range; ///< Range of values or offsets in this setint4 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 setvector<Equation> equations; ///< Any equations associated with this value setPartition *partHead; ///< If Varnode is a component head, pointer to corresponding PartitionValueSet *next; ///< Next ValueSet to iterate@@ -148,6 +150,8 @@ public:int4 getTypeCode(void) const { return typeCode; } ///< Return '0' for normal constant, '1' for spacebase relativeVarnode *getVarnode(void) const { return vn; } ///< Get the Varnode attached to \b this ValueSetconst 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};