Log unimplemented instructions (issue 163) (#599)

* Remove double printing of exception.

* Pretty print the unimplemented instruction raised by unicorn (UcError).

* Raise exception after unimplemented instruction error logging.

* Ensure the raised exception is actually a unicorn invalid instruction error.

* Resolve conflict
This commit is contained in:
awr|arr 2017-11-28 19:18:12 -05:00 committed by Mark Mossberg
parent 481e41991d
commit e50cc6b9b2
2 changed files with 7 additions and 1 deletions

View File

@ -9,6 +9,7 @@ from functools import wraps
from itertools import islice, imap
import capstone as cs
import unicorn
from .disasm import init_disassembler
from ..smtlib import Expression, Bool, BitVec, Array, Operators, Constant
@ -844,6 +845,12 @@ class Cpu(Eventful):
emu = UnicornEmulator(self)
try:
emu.emulate(insn)
except unicorn.UcError as e:
if e.errno == unicorn.UC_ERR_INSN_INVALID:
text_bytes = ' '.join('%02x'%x for x in insn.bytes)
logger.error("Unimplemented instruction: 0x%016x:\t%s\t%s\t%s",
insn.address, text_bytes, insn.mnemonic, insn.op_str)
raise InstructionEmulationError(str(e))
except Exception as e:
raise InstructionEmulationError(str(e))
finally:

View File

@ -499,7 +499,6 @@ class Executor(Eventful):
import traceback
trace = traceback.format_exc()
logger.error("Exception: %s\n%s", str(e), trace)
print "Exception: %s\n%s"%( str(e), trace)
#Notify this worker is done
self._publish('will_terminate_state', current_state, current_state_id, e)
current_state = None