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.
This commit is contained in:
Disconnect3d 2018-03-02 01:40:51 +07:00 committed by Yan Ivnitskiy
parent 48f88be759
commit 20cb97f7ae

View File

@ -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