dwarf stack: save expression and add is_exp_equal() to compare

expressions
This commit is contained in:
2020-01-25 17:24:36 +04:00
parent e48cfddeb0
commit 4f94a9e1c2
2 changed files with 45 additions and 3 deletions
+22
View File
@@ -1078,6 +1078,25 @@ const dwarf_op_map* find_op_map(int op)
return NULL;
}
bool __dwarf_stack::is_expr_equal(__dwarf_stack* rhs)
{
if(rhs->expr.Size() != expr.Size()) {
return false;
}
pst_dwarf_op* rop = (pst_dwarf_op*)rhs->expr.First();
pst_dwarf_op* lop = (pst_dwarf_op*)expr.First();
while(lop != NULL && rop != NULL) {
if(lop->operation != rop->operation || lop->arg1 != rop->arg1 || lop->arg2 != rop->arg2) {
return false;
}
lop = (pst_dwarf_op*)expr.Next(lop);
rop = (pst_dwarf_op*)rhs->expr.Next(rop);
}
return true;
}
bool __dwarf_stack::get_value(uint64_t& value)
{
if(!Size()) {
@@ -1114,6 +1133,9 @@ bool __dwarf_stack::calc_expression(Dwarf_Op *exprs, int expr_len, Dwarf_Attribu
return false;
}
pst_dwarf_op* op = new pst_dwarf_op(exprs[i].atom, exprs[i].number, exprs[i].number2);
expr.InsertLast(op);
dwarf_value* v = get();
// dereference register location there if it is not last in stack
if(v && (v->type & DWARF_TYPE_REGISTER_LOC)) {