Remove ctrlc dependency
Former-commit-id: b78552cbbdbdce140861406659678af2da4719b0
This commit is contained in:
parent
ab37609fcb
commit
db04bdf341
|
@ -19,7 +19,6 @@ time = "0.2.6"
|
||||||
bitfield = "0.13.1"
|
bitfield = "0.13.1"
|
||||||
bitflags = "1.2.1"
|
bitflags = "1.2.1"
|
||||||
zip = {version = "0.5.4", default-features = false, features = ["deflate", "time"]}
|
zip = {version = "0.5.4", default-features = false, features = ["deflate", "time"]}
|
||||||
ctrlc = "3.1.3"
|
|
||||||
bit-set = "0.5.1"
|
bit-set = "0.5.1"
|
||||||
debug_stub_derive = "0.3.0"
|
debug_stub_derive = "0.3.0"
|
||||||
bytesize = "1.0.0"
|
bytesize = "1.0.0"
|
||||||
|
|
|
@ -76,11 +76,7 @@ impl Debugger {
|
||||||
}
|
}
|
||||||
GpuInfo => println!("GPU: {:#?}", self.gba.sysbus.io.gpu),
|
GpuInfo => println!("GPU: {:#?}", self.gba.sysbus.io.gpu),
|
||||||
Step(count) => {
|
Step(count) => {
|
||||||
self.ctrlc_flag.store(true, Ordering::SeqCst);
|
|
||||||
for _ in 0..count {
|
for _ in 0..count {
|
||||||
if !self.ctrlc_flag.load(Ordering::SeqCst) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
self.gba.cpu.step(&mut self.gba.sysbus);
|
self.gba.cpu.step(&mut self.gba.sysbus);
|
||||||
while self.gba.cpu.last_executed.is_none() {
|
while self.gba.cpu.last_executed.is_none() {
|
||||||
self.gba.cpu.step(&mut self.gba.sysbus);
|
self.gba.cpu.step(&mut self.gba.sysbus);
|
||||||
|
@ -107,8 +103,7 @@ impl Debugger {
|
||||||
println!("{}\n", self.gba.cpu);
|
println!("{}\n", self.gba.cpu);
|
||||||
}
|
}
|
||||||
Continue => {
|
Continue => {
|
||||||
self.ctrlc_flag.store(true, Ordering::SeqCst);
|
loop {
|
||||||
while self.ctrlc_flag.load(Ordering::SeqCst) {
|
|
||||||
self.gba.key_poll();
|
self.gba.key_poll();
|
||||||
match self.gba.check_breakpoint() {
|
match self.gba.check_breakpoint() {
|
||||||
Some(addr) => {
|
Some(addr) => {
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{prelude::*, BufReader};
|
use std::io::{prelude::*, BufReader};
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use ctrlc;
|
|
||||||
use rustyline::error::ReadlineError;
|
use rustyline::error::ReadlineError;
|
||||||
use rustyline::Editor;
|
use rustyline::Editor;
|
||||||
|
|
||||||
|
@ -41,23 +38,14 @@ type DebuggerResult<T> = Result<T, DebuggerError>;
|
||||||
pub struct Debugger {
|
pub struct Debugger {
|
||||||
pub gba: GameBoyAdvance,
|
pub gba: GameBoyAdvance,
|
||||||
running: bool,
|
running: bool,
|
||||||
pub ctrlc_flag: Arc<AtomicBool>,
|
|
||||||
pub previous_command: Option<Command>,
|
pub previous_command: Option<Command>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debugger {
|
impl Debugger {
|
||||||
pub fn new(gba: GameBoyAdvance) -> 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 {
|
Debugger {
|
||||||
gba: gba,
|
gba: gba,
|
||||||
running: false,
|
running: false,
|
||||||
ctrlc_flag: ctrlc_flag,
|
|
||||||
previous_command: None,
|
previous_command: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue