1 //! Create custom target-specific debugging commands accessible via GDB's 2 //! `monitor` command! 3 4 use crate::target::Target; 5 6 pub use crate::protocol::ConsoleOutput; 7 pub use crate::{output, outputln}; 8 9 /// Target Extension - Handle custom GDB `monitor` commands. 10 pub trait MonitorCmd: Target { 11 /// Handle custom commands sent using the `monitor` command. 12 /// 13 /// The GDB remote serial protocol includes a built-in mechanism to send 14 /// arbitrary commands to the remote stub: the `monitor` command. For 15 /// example, running `monitor dbg` from the GDB client will invoke 16 /// `handle_monitor_cmd` with `cmd = b"dbg"`. 17 /// 18 /// Commands are _not_ guaranteed to be valid UTF-8, hence the use of 19 /// `&[u8]` as opposed to `&str`. 20 /// 21 /// Intermediate console output can be written back to the GDB client using 22 /// the provided `ConsoleOutput` object + the 23 /// [`gdbstub::output!`](macro.output.html) macro. 24 /// 25 /// _Note:_ The maximum length of incoming commands is limited by the size 26 /// of the packet buffer provided to the [`GdbStub`](struct.GdbStub.html). 27 /// Specifically, commands can only be up to `(buf.len() - 10) / 2` bytes. handle_monitor_cmd(&mut self, cmd: &[u8], out: ConsoleOutput<'_>) -> Result<(), Self::Error>28 fn handle_monitor_cmd(&mut self, cmd: &[u8], out: ConsoleOutput<'_>) 29 -> Result<(), Self::Error>; 30 } 31 32 define_ext!(MonitorCmdOps, MonitorCmd); 33