From 20cb97f7aec84707436cc61115ef33107dbd32e4 Mon Sep 17 00:00:00 2001 From: Disconnect3d Date: Fri, 2 Mar 2018 01:40:51 +0700 Subject: [PATCH] Fix Cpu.execute's improper reporting of `Unimplemented instruction` (#777) When particular instruction's implementation raised an `AttributeError` it was catched by `Cpu.execute` and we just saw "oh this instruction is not implemented" while it was, but its implementation was broken. --- manticore/core/cpu/abstractcpu.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/manticore/core/cpu/abstractcpu.py b/manticore/core/cpu/abstractcpu.py index 1f8f846..9282151 100644 --- a/manticore/core/cpu/abstractcpu.py +++ b/manticore/core/cpu/abstractcpu.py @@ -816,19 +816,23 @@ class Cpu(Eventful): name = self.canonicalize_instruction_name(insn) - if logger.level == logging.DEBUG : + if logger.level == logging.DEBUG: logger.debug(self.render_instruction(insn)) for l in self.render_registers(): register_logger.debug(l) try: - try: - getattr(self, name)(*insn.operands) - except AttributeError: - text_bytes = ' '.join('%02x'%x for x in insn.bytes) + implementation = getattr(self, name, None) + + if implementation is not None: + implementation(*insn.operands) + + else: + text_bytes = ' '.join('%02x' % x for x in insn.bytes) logger.info("Unimplemented instruction: 0x%016x:\t%s\t%s\t%s", insn.address, text_bytes, insn.mnemonic, insn.op_str) self.emulate(insn) + except (Interruption, Syscall) as e: e.on_handled = lambda: self._publish_instruction_as_executed(insn) raise e