Skip to content

Commit 3f3c910

Browse files
committed
ci clean
1 parent 034f7bc commit 3f3c910

5 files changed

Lines changed: 47 additions & 54 deletions

File tree

src/arch.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ pub trait RegId: Sized + Debug {
4646
///
4747
/// Returns `None` if this mapping direction is not implemented.
4848
///
49-
/// This method currently only needs to return `Some` for a register if that
50-
/// register is sent with
51-
/// [`GdbStubStateMachineInner::report_stop_with_regs`].
49+
/// This method currently only needs to return `Some` for registers sent
50+
/// with [`StopReasonReporter::add_reg`].
5251
///
53-
/// [`GdbStubStateMachineInner::report_stop_with_regs`]:
54-
/// crate::stub::state_machine::GdbStubStateMachineInner::report_stop_with_regs
52+
/// [`StopReasonReporter::add_reg`]: crate::stub::state_machine::StopReasonReporter::add_reg
5553
fn to_raw_id(&self) -> Option<usize> {
5654
None
5755
}

src/lib.rs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,12 @@
167167
//! #
168168
//! # enum MyTargetEvent {
169169
//! # IncomingData,
170-
//! # StopReason(SingleThreadStopReason<u32>),
170+
//! # Stopped,
171171
//! # }
172172
//! #
173173
//! use gdbstub::common::Signal;
174174
//! use gdbstub::conn::{Connection, ConnectionExt}; // note the use of `ConnectionExt`
175175
//! use gdbstub::stub::{run_blocking, DisconnectReason, GdbStub};
176-
//! use gdbstub::stub::SingleThreadStopReason;
177176
//! use gdbstub::target::Target;
178177
//!
179178
//! enum MyGdbBlockingEventLoop {}
@@ -183,57 +182,55 @@
183182
//! impl run_blocking::BlockingEventLoop for MyGdbBlockingEventLoop {
184183
//! type Target = MyTarget;
185184
//! type Connection = Box<dyn ConnectionExt<Error = std::io::Error>>;
186-
//!
187-
//! // or MultiThreadStopReason on multi threaded targets
188-
//! type StopReason = SingleThreadStopReason<u32>;
185+
//! type Tid = (); // Single threaded example
189186
//!
190187
//! // Invoked immediately after the target's `resume` method has been
191188
//! // called. The implementation should block until either the target
192189
//! // reports a stop reason, or if new data was sent over the connection.
193-
//! fn wait_for_stop_reason(
190+
//! fn wait_for_stop_reason<'a>(
194191
//! target: &mut MyTarget,
195-
//! conn: &mut Self::Connection,
192+
//! mut simple_stub: run_blocking::SimpleStub<'a, Self::Target, Self::Connection, Self::Tid>,
196193
//! ) -> Result<
197-
//! run_blocking::Event<SingleThreadStopReason<u32>>,
194+
//! run_blocking::Event<'a, Self::Target, Self::Connection, Self::Tid>,
198195
//! run_blocking::WaitForStopReasonError<
199196
//! <Self::Target as Target>::Error,
200197
//! <Self::Connection as Connection>::Error,
201198
//! >,
202199
//! > {
203-
//! // the specific mechanism to "select" between incoming data and target
200+
//! // The specific mechanism to "select" between incoming data and target
204201
//! // events will depend on your project's architecture.
205202
//! //
206-
//! // some examples of how you might implement this method include: `epoll`,
203+
//! // Some examples of how you might implement this method include: `epoll`,
207204
//! // `select!` across multiple event channels, periodic polling, etc...
208205
//! //
209-
//! // in this example, lets assume the target has a magic method that handles
206+
//! // In this example, lets assume the target has a magic method that handles
210207
//! // this for us.
211-
//! let event = match target.run_and_check_for_incoming_data(conn) {
208+
//! let event = match target.run_and_check_for_incoming_data(simple_stub.borrow_conn()) {
212209
//! MyTargetEvent::IncomingData => {
213-
//! let byte = conn
214-
//! .read() // method provided by the `ConnectionExt` trait
210+
//! let byte = simple_stub
211+
//! .borrow_conn()
212+
//! .read()
215213
//! .map_err(run_blocking::WaitForStopReasonError::Connection)?;
216214
//!
217-
//! run_blocking::Event::IncomingData(byte)
215+
//! simple_stub.incoming_data(target, byte)
218216
//! }
219-
//! MyTargetEvent::StopReason(reason) => {
220-
//! run_blocking::Event::TargetStopped(reason)
217+
//! MyTargetEvent::Stopped => {
218+
//! // Report a target stop reason back to GDB. In this example,
219+
//! // we choose to report a SIGINT stop reason, but your target
220+
//! // can use any stop reason appropriate for the event.
221+
//! simple_stub.report_stop(target, |report_stop| {
222+
//! report_stop.signal(Signal::SIGINT)
223+
//! })
221224
//! }
222225
//! };
223226
//!
224227
//! Ok(event)
225228
//! }
226229
//!
227230
//! // Invoked when the GDB client sends a Ctrl-C interrupt.
228-
//! fn on_interrupt(
229-
//! target: &mut MyTarget,
230-
//! ) -> Result<Option<SingleThreadStopReason<u32>>, <MyTarget as Target>::Error> {
231-
//! // notify the target that a ctrl-c interrupt has occurred.
231+
//! fn on_interrupt(target: &mut MyTarget) -> Result<(), <MyTarget as Target>::Error> {
232232
//! target.stop_in_response_to_ctrl_c_interrupt()?;
233-
//!
234-
//! // a pretty typical stop reason in response to a Ctrl-C interrupt is to
235-
//! // report a "Signal::SIGINT".
236-
//! Ok(Some(SingleThreadStopReason::Signal(Signal::SIGINT).into()))
233+
//! Ok(())
237234
//! }
238235
//! }
239236
//!

src/stub/mod.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,25 @@ pub mod run_blocking {
3737
///
3838
/// [`GdbStubStateMachine`]: state_machine::GdbStubStateMachine
3939
pub struct SimpleStub<'a, T: Target, C: Connection, Tid: IsValidTid> {
40-
pub(crate) inner:
40+
pub(crate) gdb:
4141
state_machine::GdbStubStateMachineInner<'a, state_machine::state::Running, T, C, Tid>,
4242
}
4343

4444
/// Opaque type representing an event that was occurred in
4545
/// [`BlockingEventLoop::wait_for_stop_reason`].
4646
///
4747
/// Created via [`SimpleStub`].
48-
pub struct Event<'a, T: Target, C: Connection, Tid: IsValidTid>(
49-
pub(crate) Result<
48+
pub struct Event<'a, T: Target, C: Connection, Tid: IsValidTid> {
49+
pub(crate) gdb: Result<
5050
state_machine::GdbStubStateMachine<'a, T, C, Tid>,
5151
GdbStubError<<T as Target>::Error, <C as Connection>::Error>,
5252
>,
53-
);
53+
}
5454

5555
impl<'a, T: Target, C: Connection, Tid: IsValidTid> SimpleStub<'a, T, C, Tid> {
5656
/// Return a mutable reference to the underlying connection.
5757
pub fn borrow_conn(&mut self) -> &mut C {
58-
self.inner.borrow_conn()
58+
self.gdb.borrow_conn()
5959
}
6060

6161
/// Report a target stop reason back to GDB.
@@ -69,12 +69,16 @@ pub mod run_blocking {
6969
GdbStubError<<T as Target>::Error, <C as Connection>::Error>,
7070
>,
7171
) -> Event<'a, T, C, Tid> {
72-
Event(report(self.inner.report_stop(target)))
72+
Event {
73+
gdb: report(self.gdb.report_stop(target)),
74+
}
7375
}
7476

7577
/// Pass a byte to the GDB stub.
7678
pub fn incoming_data(self, target: &mut T, byte: u8) -> Event<'a, T, C, Tid> {
77-
Event(self.inner.incoming_data(target, byte))
79+
Event {
80+
gdb: self.gdb.incoming_data(target, byte),
81+
}
7882
}
7983
}
8084

@@ -83,9 +87,7 @@ pub mod run_blocking {
8387
///
8488
/// Reminder: to use `gdbstub` in a non-blocking manner (e.g: via
8589
/// async/await, unix polling, from an interrupt handler, etc...) you will
86-
/// need to interface with the
87-
/// [`GdbStubStateMachine`](state_machine::GdbStubStateMachine) API
88-
/// directly.
90+
/// need to interface with the [`GdbStubStateMachine`] API directly.
8991
pub trait BlockingEventLoop {
9092
/// The Target being driven.
9193
type Target: Target;
@@ -145,12 +147,10 @@ pub mod run_blocking {
145147
/// `Event::StopReason` in `wait_for_stop_reason()` as usual.
146148
///
147149
/// _Suggestion_: If you're unsure which stop reason to report in
148-
/// response to a ctrl-c interrupt,
149-
/// [`BaseStopReason::Signal(Signal::SIGINT)`] may be a sensible
150+
/// response to a ctrl-c interrupt, [`Signal::SIGINT`] may be a sensible
150151
/// default.
151152
///
152-
/// [`BaseStopReason::Signal(Signal::SIGINT)`]:
153-
/// crate::stub::BaseStopReason::Signal
153+
/// [`Signal::SIGINT`]: crate::common::Signal::SIGINT
154154
fn on_interrupt(target: &mut Self::Target) -> Result<(), <Self::Target as Target>::Error> {
155155
let _ = target;
156156
Ok(())
@@ -248,10 +248,9 @@ impl<'a, T: Target, C: Connection> GdbStub<'a, T, C> {
248248
use run_blocking::WaitForStopReasonError;
249249

250250
// block waiting for the target to return a stop reason
251-
let res =
252-
E::wait_for_stop_reason(target, run_blocking::SimpleStub { inner: gdb });
251+
let res = E::wait_for_stop_reason(target, run_blocking::SimpleStub { gdb });
253252
match res {
254-
Ok(run_blocking::Event(gdb)) => gdb?,
253+
Ok(run_blocking::Event { gdb }) => gdb?,
255254
Err(WaitForStopReasonError::Target(e)) => {
256255
break Err(InternalError::TargetError(e).into());
257256
}

src/stub/state_machine.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -947,11 +947,7 @@ where
947947
/// resuming the target (and of course - retuning an appropriate stop
948948
/// reason).
949949
/// - If you're unsure which stop reason to report in response to a ctrl-c
950-
/// interrupt, [`BaseStopReason::Signal(Signal::SIGINT)`] may be a
951-
/// sensible default.
952-
///
953-
/// [`BaseStopReason::Signal(Signal::SIGINT)`]:
954-
/// crate::stub::BaseStopReason::Signal
950+
/// interrupt, reporting a [`Signal::SIGINT`] may be a sensible default.
955951
pub fn interrupt_handled(self) -> GdbStubStateMachine<'a, T, C, Tid> {
956952
if self.state.from_idle {
957953
self.transition(state::Idle {}).into()

src/target/ext/base/reverse_exec.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ where
4040
pub type ReverseStepOps<'a, Tid, T> =
4141
&'a mut dyn ReverseStep<Tid, Arch = <T as Target>::Arch, Error = <T as Target>::Error>;
4242

43-
/// Describes the point reached in a replay log (used alongside
44-
/// [`BaseStopReason::ReplayLog`](crate::stub::BaseStopReason::ReplayLog))
43+
/// Describes the point reached in a replay log (used in
44+
/// [`StopReasonReporter::replay_log`])
45+
///
46+
/// [`StopReasonReporter::replay_log`]:
47+
/// crate::stub::state_machine::StopReasonReporter::replay_log
4548
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
4649
pub enum ReplayLogPosition {
4750
/// Reached the beginning of the replay log.

0 commit comments

Comments
 (0)