aboutsummaryrefslogtreecommitdiff
path: root/src/stub/state_machine.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/stub/state_machine.rs')
-rw-r--r--src/stub/state_machine.rs36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/stub/state_machine.rs b/src/stub/state_machine.rs
index 766d343..7b623dd 100644
--- a/src/stub/state_machine.rs
+++ b/src/stub/state_machine.rs
@@ -33,18 +33,21 @@
//! [`BlockingEventLoop`]: super::run_blocking::BlockingEventLoop
//! [`GdbStub::run_blocking`]: super::GdbStub::run_blocking
-use managed::ManagedSlice;
-
+use super::core_impl::FinishExecStatus;
+use super::core_impl::GdbStubImpl;
+use super::core_impl::State;
+use super::DisconnectReason;
+use super::GdbStub;
use crate::arch::Arch;
use crate::conn::Connection;
use crate::protocol::recv_packet::RecvPacketStateMachine;
-use crate::protocol::{Packet, ResponseWriter};
-use crate::stub::error::GdbStubError as Error;
+use crate::protocol::Packet;
+use crate::protocol::ResponseWriter;
+use crate::stub::error::GdbStubError;
+use crate::stub::error::InternalError;
use crate::stub::stop_reason::IntoStopReason;
use crate::target::Target;
-
-use super::core_impl::{FinishExecStatus, GdbStubImpl, State};
-use super::{DisconnectReason, GdbStub};
+use managed::ManagedSlice;
/// State-machine interface to `GdbStub`.
///
@@ -78,7 +81,6 @@ where
// payloads, which are used when transitioning between states.
pub mod state {
use super::*;
-
use crate::stub::stop_reason::MultiThreadStopReason;
// used internally when logging state transitions
@@ -212,13 +214,13 @@ impl<'a, T: Target, C: Connection> GdbStubStateMachineInner<'a, state::Idle<T>,
mut self,
target: &mut T,
byte: u8,
- ) -> Result<GdbStubStateMachine<'a, T, C>, Error<T::Error, C::Error>> {
+ ) -> Result<GdbStubStateMachine<'a, T, C>, GdbStubError<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 packet = Packet::from_buf(target, packet_buffer).map_err(InternalError::PacketParse)?;
let state = self
.i
.inner
@@ -254,10 +256,10 @@ impl<'a, T: Target, C: Connection> GdbStubStateMachineInner<'a, state::Running,
mut self,
target: &mut T,
reason: impl IntoStopReason<T>,
- ) -> Result<GdbStubStateMachine<'a, T, C>, Error<T::Error, C::Error>> {
+ ) -> Result<GdbStubStateMachine<'a, T, C>, GdbStubError<T::Error, C::Error>> {
let mut res = ResponseWriter::new(&mut self.i.conn, target.use_rle());
let event = self.i.inner.finish_exec(&mut res, target, reason.into())?;
- res.flush()?;
+ res.flush().map_err(InternalError::from)?;
Ok(match event {
FinishExecStatus::Handled => self
@@ -272,21 +274,17 @@ impl<'a, T: Target, C: Connection> GdbStubStateMachineInner<'a, state::Running,
}
/// 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>> {
+ ) -> Result<GdbStubStateMachine<'a, T, C>, GdbStubError<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 packet = Packet::from_buf(target, packet_buffer).map_err(InternalError::PacketParse)?;
let state = self
.i
.inner
@@ -333,7 +331,7 @@ impl<'a, T: Target, C: Connection> GdbStubStateMachineInner<'a, state::CtrlCInte
self,
target: &mut T,
stop_reason: Option<impl IntoStopReason<T>>,
- ) -> Result<GdbStubStateMachine<'a, T, C>, Error<T::Error, C::Error>> {
+ ) -> Result<GdbStubStateMachine<'a, T, C>, GdbStubError<T::Error, C::Error>> {
if self.state.from_idle {
// target is stopped - we cannot report the stop reason yet
Ok(self