From db04bdf341477b732b92631314a9a2975b44bfac Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Mon, 13 Apr 2020 18:27:16 +0300 Subject: [PATCH] Remove ctrlc dependency Former-commit-id: b78552cbbdbdce140861406659678af2da4719b0 --- rustboyadvance-core/Cargo.toml | 1 - rustboyadvance-core/src/debugger/command.rs | 7 +------ rustboyadvance-core/src/debugger/mod.rs | 12 ------------ 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/rustboyadvance-core/Cargo.toml b/rustboyadvance-core/Cargo.toml index 945c4d2..e0cfbdf 100644 --- a/rustboyadvance-core/Cargo.toml +++ b/rustboyadvance-core/Cargo.toml @@ -19,7 +19,6 @@ time = "0.2.6" bitfield = "0.13.1" bitflags = "1.2.1" zip = {version = "0.5.4", default-features = false, features = ["deflate", "time"]} -ctrlc = "3.1.3" bit-set = "0.5.1" debug_stub_derive = "0.3.0" bytesize = "1.0.0" diff --git a/rustboyadvance-core/src/debugger/command.rs b/rustboyadvance-core/src/debugger/command.rs index 02a39fb..cb6e9b4 100644 --- a/rustboyadvance-core/src/debugger/command.rs +++ b/rustboyadvance-core/src/debugger/command.rs @@ -76,11 +76,7 @@ impl Debugger { } GpuInfo => println!("GPU: {:#?}", self.gba.sysbus.io.gpu), Step(count) => { - self.ctrlc_flag.store(true, Ordering::SeqCst); for _ in 0..count { - if !self.ctrlc_flag.load(Ordering::SeqCst) { - break; - } self.gba.cpu.step(&mut self.gba.sysbus); while self.gba.cpu.last_executed.is_none() { self.gba.cpu.step(&mut self.gba.sysbus); @@ -107,8 +103,7 @@ impl Debugger { println!("{}\n", self.gba.cpu); } Continue => { - self.ctrlc_flag.store(true, Ordering::SeqCst); - while self.ctrlc_flag.load(Ordering::SeqCst) { + loop { self.gba.key_poll(); match self.gba.check_breakpoint() { Some(addr) => { diff --git a/rustboyadvance-core/src/debugger/mod.rs b/rustboyadvance-core/src/debugger/mod.rs index 1b6cb3a..32d1e6d 100644 --- a/rustboyadvance-core/src/debugger/mod.rs +++ b/rustboyadvance-core/src/debugger/mod.rs @@ -1,9 +1,6 @@ use std::fs::File; use std::io::{prelude::*, BufReader}; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; -use ctrlc; use rustyline::error::ReadlineError; use rustyline::Editor; @@ -41,23 +38,14 @@ type DebuggerResult = Result; pub struct Debugger { pub gba: GameBoyAdvance, running: bool, - pub ctrlc_flag: Arc, pub previous_command: Option, } impl Debugger { pub fn new(gba: GameBoyAdvance) -> Debugger { - let ctrlc_flag = Arc::new(AtomicBool::new(true)); - let r = ctrlc_flag.clone(); - ctrlc::set_handler(move || { - println!("Stopping, Ctrl-C detected!"); - r.store(false, Ordering::SeqCst); - }) - .expect("Error setting Ctrl-C handler"); Debugger { gba: gba, running: false, - ctrlc_flag: ctrlc_flag, previous_command: None, } }