From 9bc198e167da8877fb2cde549010f6b48519b093 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 17 Dec 2024 05:12:10 +0000 Subject: [PATCH] Selftest: Forward unicorn error message when emulation fails 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 --- slothy/helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slothy/helper.py b/slothy/helper.py index fc2b76f7..b8a1bb22 100644 --- a/slothy/helper.py +++ b/slothy/helper.py @@ -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: