Skip to content

Commit

Permalink
Selftest: Forward unicorn error message when emulation fails
Browse files Browse the repository at this point in the history
When the selftest fails with an emulation failure in unicorn, we would
previously not print any information hinting at the underlying problem.

This commit improves debuggability by printing the UcError exception
thrown by Unicorn.

Signed-off-by: Hanno Becker <[email protected]>
  • Loading branch information
hanno-becker committed Dec 17, 2024
1 parent 7fc797b commit 9bc198e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions slothy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1334,11 +1334,11 @@ def run_code(code, txt=None):
mu.emu_start(CODE_BASE + offset, CODE_BASE + len(objcode))
else:
mu.emu_start(CODE_BASE + offset, CODE_END)
except:
except UcError as e:
log.error("Failed to emulate code using unicorn engine")
log.error("Code")
log.error(SourceLine.write_multiline(code))
raise SelfTestException("Selftest failed: Unicorn failed to emulate code")
raise SelfTestException(f"Selftest failed: Unicorn failed to emulate code: {str(e)}") from e

final_register_contents = {}
for r in regs:
Expand Down

0 comments on commit 9bc198e

Please sign in to comment.