From f4c1f9a11cd7de5411c1a8d060194a789bb96e04 Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Thu, 6 Mar 2025 15:43:06 -0500 Subject: [PATCH 1/2] added exit command to debugger --- src/debugger.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/debugger.rs b/src/debugger.rs index 12de8bac..44446698 100644 --- a/src/debugger.rs +++ b/src/debugger.rs @@ -199,6 +199,26 @@ impl DebuggerCommand for ContinueCommand { } } +struct ExitCommand; +#[derive(Parser, Debug)] +enum ExitSubcommand { + /// Exits the debugger and shutsdown the simulation + Exit, +} +impl DebuggerCommand for ExitCommand { + fn handle( + &self, + context: &mut Context, + _matches: &ArgMatches, + ) -> Result<(bool, Option), String> { + context.shutdown(); + Ok((true, None)) + } + fn extend(&self, command: Command) -> Command { + ExitSubcommand::augment_subcommands(command) + } +} + // Build the debugger context. fn init(context: &mut Context) { let debugger = context.get_data_container_mut(DebuggerPlugin); @@ -209,6 +229,7 @@ fn init(context: &mut Context) { commands.insert("population", Box::new(PopulationCommand)); commands.insert("next", Box::new(NextCommand)); commands.insert("continue", Box::new(ContinueCommand)); + commands.insert("exit", Box::new(ExitCommand)); commands.insert("global", Box::new(GlobalPropertyCommand)); let mut cli = Command::new("repl") From a3a257cc5c464f9097f5d92be0862b7de40891fa Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Fri, 7 Mar 2025 12:26:12 -0500 Subject: [PATCH 2/2] updated ctrl-d debugger msg --- src/debugger.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debugger.rs b/src/debugger.rs index 44446698..b34c9fb0 100644 --- a/src/debugger.rs +++ b/src/debugger.rs @@ -253,7 +253,7 @@ fn init(context: &mut Context) { } fn exit_debugger() -> ! { - println!("Got Ctrl-D, Exiting..."); + println!("Got Ctrl-D, Terminating execution."); std::process::exit(0); }