1 use super::prelude::*; 2 3 #[derive(Debug)] 4 pub struct M<'a> { 5 pub addr: &'a [u8], 6 pub val: &'a [u8], 7 } 8 9 impl<'a> ParseCommand<'a> for M<'a> { 10 #[inline(always)] from_packet(buf: PacketBuf<'a>) -> Option<Self>11 fn from_packet(buf: PacketBuf<'a>) -> Option<Self> { 12 let body = buf.into_body(); 13 14 let mut body = body.split_mut(|&b| b == b',' || b == b':'); 15 let addr = decode_hex_buf(body.next()?).ok()?; 16 // The length part of the packet doesn't appear to actually be useful, 17 // given that it can be trivially derived from the amount of data read 18 // in via `val`. 19 // 20 // As such - we'll still parse it to ensure the packet is 21 // spec-compliant, but we won't stash the parsed length anywhere. 22 // 23 // TODO?: dig into whether any GDB clients actually attempt to send over 24 // a mismatched `len` and `val` (e.g: sending a longer `val`, with `len` 25 // used to truncate the data). My gut feeling is that this would never 26 // actually occur in practice (and the fact that `gdbstub` has gotten 27 // away with not handling this for many years at this point reinforces 28 // that gut feeling). 29 let _len: usize = decode_hex(body.next()?).ok()?; 30 let val = decode_hex_buf(body.next()?).ok()?; 31 32 Some(M { addr, val }) 33 } 34 } 35