diff --git a/src/core.rs b/src/core.rs index dde8fd7..bb37520 100644 --- a/src/core.rs +++ b/src/core.rs @@ -11,7 +11,7 @@ use crate::{ core::commands::CoreCmd, decode::Instruction, exceptions::ExceptionType, - gdb::{self, DebugCommand, StopReason}, + gdb::{self, DebugCommand, DebugStream, StopReason}, instructions::find_and_exec, mem::MemConfig, }; @@ -39,7 +39,7 @@ impl Core { loop { if let Ok(cmd) = self.command_stream.try_recv() { match cmd { - CoreCmd::EnterDbgMode(dbg_stream) => { + CoreCmd::EnterDbgMode(DebugStream(dbg_stream)) => { let _ = self.debug_loop(dbg_stream); } }; @@ -57,7 +57,7 @@ impl Core { if let Ok(cmd) = self.command_stream.recv() { eprintln!("Recieved a command"); match cmd { - CoreCmd::EnterDbgMode(dbg_stream) => { + CoreCmd::EnterDbgMode(DebugStream(dbg_stream)) => { let _ = self.debug_loop(dbg_stream); } }; diff --git a/src/core/commands.rs b/src/core/commands.rs index 93bdd1e..3fe913b 100644 --- a/src/core/commands.rs +++ b/src/core/commands.rs @@ -1,7 +1,5 @@ -use std::sync::mpsc; - use crate::gdb; pub enum CoreCmd { - EnterDbgMode(mpsc::Receiver), + EnterDbgMode(gdb::DebugStream), } diff --git a/src/gdb.rs b/src/gdb.rs index 17e2f71..ae2ef9b 100644 --- a/src/gdb.rs +++ b/src/gdb.rs @@ -24,6 +24,8 @@ pub(crate) enum DebugCommand { ExitDebugMode, } +pub struct DebugStream(pub(crate) mpsc::Receiver); + #[derive(Clone, Copy, Debug)] pub(crate) enum StopReason { Exception(ExceptionType), @@ -74,7 +76,7 @@ pub fn run_stub(cmd_sender: mpsc::Sender) { .expect("Couldnt set TCP stream to nonblocking"); cmd_sender - .send(CoreCmd::EnterDbgMode(dbg_rx)) + .send(CoreCmd::EnterDbgMode(DebugStream(dbg_rx))) .expect("couldnt ask core to enter debug mode"); handle_gdb_connection(stream, dbg_tx).expect("failure during connection"); diff --git a/src/main.rs b/src/main.rs index 274ef02..f4f8a56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ // This file is part of TRVE (https://gitea.taitep.se/taitep/trve) // See LICENSE file in the project root for full license text. -use std::{env, path::PathBuf, sync::Arc, time::Duration}; +use std::{path::PathBuf, sync::Arc, time::Duration}; use clap::Parser;