1 use gdbstub::target; 2 use gdbstub::target::ext::monitor_cmd::{outputln, ConsoleOutput}; 3 4 use crate::gdb::Emu; 5 6 impl target::ext::monitor_cmd::MonitorCmd for Emu { handle_monitor_cmd( &mut self, cmd: &[u8], mut out: ConsoleOutput<'_>, ) -> Result<(), Self::Error>7 fn handle_monitor_cmd( 8 &mut self, 9 cmd: &[u8], 10 mut out: ConsoleOutput<'_>, 11 ) -> Result<(), Self::Error> { 12 let cmd = match core::str::from_utf8(cmd) { 13 Ok(cmd) => cmd, 14 Err(_) => { 15 outputln!(out, "command must be valid UTF-8"); 16 return Ok(()); 17 } 18 }; 19 20 match cmd { 21 "" => outputln!(out, "Sorry, didn't catch that. Try `monitor ping`!"), 22 "ping" => outputln!(out, "pong!"), 23 _ => outputln!(out, "I don't know how to handle '{}'", cmd), 24 }; 25 26 Ok(()) 27 } 28 } 29