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