Dump instruction trace for all error exceptions, not just illegal opcode

Wrap opcode execution with try-except to catch all ZCpuError subclasses except
ZCpuQuit and ZCpuRestart, which are normal control flow. This ensures we get
trace dumps for divide by zero, not implemented, and other errors.
This commit is contained in:
Jared Miller 2026-02-09 21:47:13 -05:00
parent 0f5fada29e
commit 8ba1701c9f
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -216,7 +216,15 @@ class ZCpu:
# The returned function is unbound, so we must pass
# self to it ourselves.
func(self, *operands)
try:
func(self, *operands)
except (ZCpuQuit, ZCpuRestart):
# Normal control flow - don't dump trace
raise
except ZCpuError:
# All other ZCpu errors - dump trace for debugging
self._dump_trace()
raise
return True
def run(self):