daniel5151 / gdbstub

An ergonomic, featureful, and easy-to-integrate implementation of the GDB Remote Serial Protocol in Rust (with no-compromises #![no_std] support)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Misleading comment in `state_machine`?

xobs opened this issue · comments

In the documentation for incoming_data() in the state::Running state, the comment is annotated as such:

/// Pass a byte to the GDB stub.
///
/// NOTE: unlike the `incoming_data` method in the `state::Idle` state,
/// this method does not perform any state transitions, and will
/// return a `GdbStubStateMachineInner` in the `state::Running` state.
pub fn incoming_data(
mut self,
target: &mut T,
byte: u8,
) -> Result<GdbStubStateMachine<'a, T, C>, Error<T::Error, C::Error>> {
let packet_buffer = match self.i.recv_packet.pump(&mut self.i.packet_buffer, byte)? {
Some(buf) => buf,
None => return Ok(self.into()),
};
let packet = Packet::from_buf(target, packet_buffer).map_err(Error::PacketParse)?;
let state = self
.i
.inner
.handle_packet(target, &mut self.i.conn, packet)?;
Ok(match state {
State::Pump => self.transition(state::Running {}).into(),
State::Disconnect(reason) => self.transition(state::Disconnected { reason }).into(),
State::DeferredStopReason => self.transition(state::Running {}).into(),
State::CtrlCInterrupt => self
.transition(state::CtrlCInterrupt { from_idle: false })
.into(),
})
}

However, contrary to the comment, it seems as though this performs state transitions as normal, and it doesn't always return a state that's state::Running.

Is this comment incorrect? Does it need to be updated?

Yep, that's definitely wrong!
I believe I left that in from an earlier iteration of the code, and forgot to remove it.

Thanks for brining it to my attention. No need to send a PR or anything - I'll push up a commit fixing this shortly.

closed via d69da3a