From daed3a0205e540922c944e13145dd37686ebeb9d Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Wed, 21 Apr 2021 20:36:10 +0200 Subject: [PATCH] added proper cpu exit handling --- riscemu/CPU.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/riscemu/CPU.py b/riscemu/CPU.py index ee47ad9..e3e957b 100644 --- a/riscemu/CPU.py +++ b/riscemu/CPU.py @@ -1,3 +1,4 @@ +import sys import traceback from typing import Tuple, List, Dict, Callable, Type @@ -115,8 +116,14 @@ class CPU: launch_debug_session(self, self.mmu, self.regs, "Exception encountered, launching debug:") - print() - print(FMT_CPU + "Program exited with code {}".format(self.exit_code) + FMT_NONE) + if self.exit: + print() + print(FMT_CPU + "Program exited with code {}".format(self.exit_code) + FMT_NONE) + sys.exit(self.exit_code) + else: + print() + print(FMT_CPU + "Program stopped without exiting!" + FMT_NONE) + def __run_instruction(self, ins: 'LoadedInstruction'): if ins.name in self.instructions: