mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Iterate statement form
This commit is contained in:
parent
b2bc1eb019
commit
3644c120c0
1 changed files with 25 additions and 13 deletions
|
@ -3058,23 +3058,35 @@ PcodeOp *BlockWhileDo::testTerminal(Funcdata &data,int4 slot) const
|
||||||
return resOp;
|
return resOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is a final sanity check on the \e iterate statement. If statement is just a
|
/// Make sure the loop variable is involved as input in the iterator statement.
|
||||||
/// CAST or COPY, we revert to displaying the whole loop using \e while
|
/// \return \b true if the loop variable is an input to the iterator statement
|
||||||
/// \return \b true is the statement looks like a suitable for-loop iterator.
|
|
||||||
bool BlockWhileDo::testIterateForm(void) const
|
bool BlockWhileDo::testIterateForm(void) const
|
||||||
|
|
||||||
{
|
{
|
||||||
PcodeOp *curOp = iterateOp;
|
Varnode *targetVn = loopDef->getOut();
|
||||||
OpCode opc = curOp->code();
|
HighVariable *high = targetVn->getHigh();
|
||||||
while(opc == CPUI_COPY || opc == CPUI_CAST) {
|
|
||||||
Varnode *vn = curOp->getIn(0);
|
vector<PcodeOpNode> path;
|
||||||
if (!curOp->notPrinted())
|
PcodeOp *op = iterateOp;
|
||||||
if (vn->isExplicit()) return false; // End of statement, no substantive op seen
|
path.push_back(PcodeOpNode(op,0));
|
||||||
if (!vn->isWritten()) return false;
|
while(!path.empty()) {
|
||||||
curOp = vn->getDef();
|
PcodeOpNode &node(path.back());
|
||||||
opc = curOp->code();
|
if (node.op->numInput() <= node.slot) {
|
||||||
|
path.pop_back();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Varnode *vn = node.op->getIn(node.slot);
|
||||||
|
node.slot += 1;
|
||||||
|
if (vn->isAnnotation()) continue;
|
||||||
|
if (vn->getHigh() == high) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (vn->isExplicit()) continue; // Truncate at explicit
|
||||||
|
if (!vn->isWritten()) continue;
|
||||||
|
op = vn->getDef();
|
||||||
|
path.push_back(PcodeOpNode(vn->getDef(),0));
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockWhileDo::markLabelBumpUp(bool bump)
|
void BlockWhileDo::markLabelBumpUp(bool bump)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue