diff options
| author | serpilliere <serpilliere@users.noreply.github.com> | 2017-05-10 00:34:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-10 00:34:45 +0200 |
| commit | caa17aa1f2c49647fd1f3215319c416649e8d9d5 (patch) | |
| tree | 77495b355b4c111852d6abb89aac73290fb640dd | |
| parent | f76c4aadc06141caf1bbd775a258928d73794a35 (diff) | |
| parent | 2eafe654c0bdedd6999f738c7b3266768f13e74a (diff) | |
| download | miasm-caa17aa1f2c49647fd1f3215319c416649e8d9d5.tar.gz miasm-caa17aa1f2c49647fd1f3215319c416649e8d9d5.zip | |
Merge pull request #553 from commial/feature/symbexec-assignblk
SymbolicExecutionEngine .state -> AssignBlock
| -rw-r--r-- | example/symbol_exec/single_instr.py | 5 | ||||
| -rw-r--r-- | miasm2/ir/symbexec.py | 7 | ||||
| -rwxr-xr-x | test/ir/symbexec.py | 4 |
3 files changed, 14 insertions, 2 deletions
diff --git a/example/symbol_exec/single_instr.py b/example/symbol_exec/single_instr.py index 3e418e5a..c31de738 100644 --- a/example/symbol_exec/single_instr.py +++ b/example/symbol_exec/single_instr.py @@ -37,5 +37,6 @@ symb.dump_mem() # Check final status eax, ebx = ira.arch.regs.EAX, ira.arch.regs.EBX -assert symb.symbols[eax] == symbols_init[ebx] -assert eax in symb.modified() +final_state = symb.as_assignblock() +assert final_state[eax] == symbols_init[ebx] +assert eax in final_state diff --git a/miasm2/ir/symbexec.py b/miasm2/ir/symbexec.py index 33d0f8bd..f9444424 100644 --- a/miasm2/ir/symbexec.py +++ b/miasm2/ir/symbexec.py @@ -504,6 +504,13 @@ class SymbolicExecutionEngine(object): return ret + def as_assignblock(self): + """Return the current state as an AssignBlock""" + return AssignBlock({ + dst: self.symbols[dst] for dst in self.modified() + }) + + class symbexec(SymbolicExecutionEngine): """ DEPRECATED object diff --git a/test/ir/symbexec.py b/test/ir/symbexec.py index e2bd411f..f8d8c7bf 100755 --- a/test/ir/symbexec.py +++ b/test/ir/symbexec.py @@ -75,6 +75,10 @@ class TestSymbExec(unittest.TestCase): self.assertEqual(e.apply_expr(assignblk.dst2ExprAff(id_x)), addr0) self.assertEqual(e.apply_expr(id_x), addr0) + # state + self.assertEqual(e.as_assignblock().get_r(), set([id_x, id_y])) + + if __name__ == '__main__': testsuite = unittest.TestLoader().loadTestsFromTestCase(TestSymbExec) report = unittest.TextTestRunner(verbosity=2).run(testsuite) |