-
-
Notifications
You must be signed in to change notification settings - Fork 64
Add support for "expedited registers" in T-stop packets. #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
637b676
d492a7a
aacb48f
c5c5f2d
b7bdac8
5dfc89d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ | |
| use crate::stub::error::GdbStubError; | ||
| use crate::stub::error::InternalError; | ||
| use crate::stub::stop_reason::IntoStopReason; | ||
| use crate::stub::BaseStopReason; | ||
| use crate::target::Target; | ||
| use managed::ManagedSlice; | ||
|
|
||
|
|
@@ -251,12 +252,60 @@ | |
| impl<'a, T: Target, C: Connection> GdbStubStateMachineInner<'a, state::Running, T, C> { | ||
| /// Report a target stop reason back to GDB. | ||
| pub fn report_stop( | ||
| self, | ||
| target: &mut T, | ||
| reason: impl IntoStopReason<T>, | ||
| ) -> Result<GdbStubStateMachine<'a, T, C>, GdbStubError<T::Error, C::Error>> { | ||
| self.report_stop_impl(target, reason, None) | ||
| } | ||
|
|
||
| /// Report a target stop reason back to GDB, including expedited | ||
| /// register values in the stop reply T-packet. | ||
| /// | ||
| /// The iterator yields `(register_number, value_bytes)` pairs that | ||
| /// are written as expedition registers in the T-packet. Values | ||
cfallin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// should be in target byte order (typically little-endian). | ||
cfallin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// | ||
| /// This may be useful to use, rather than [`report_stop`], when | ||
| /// we want to provide register values immediately to, for | ||
| /// example, avoid a round-trip, or work around a quirk/bug in a | ||
| /// debugger that does not otherwise request new register values. | ||
| pub fn report_stop_with_regs( | ||
| self, | ||
| target: &mut T, | ||
| reason: impl IntoStopReason<T>, | ||
| regs: &mut dyn Iterator<Item = (u32, &[u8])>, | ||
|
||
| ) -> Result<GdbStubStateMachine<'a, T, C>, GdbStubError<T::Error, C::Error>> { | ||
| self.report_stop_impl(target, reason, Some(regs)) | ||
| } | ||
|
|
||
| /// Shared implementation for the | ||
| /// `report_stop`/`report_stop_with_regs` API. Takes an `Option` | ||
| /// around the `&mut dyn Iterator` to avoid making a dynamic | ||
| /// vtable dispatch in the common `report_stop` case. | ||
| fn report_stop_impl( | ||
| mut self, | ||
| target: &mut T, | ||
| reason: impl IntoStopReason<T>, | ||
| regs: Option<&mut dyn Iterator<Item = (u32, &[u8])>>, | ||
| ) -> Result<GdbStubStateMachine<'a, T, C>, GdbStubError<T::Error, C::Error>> { | ||
| let reason: BaseStopReason<_, _> = reason.into(); | ||
| let is_t_packet = reason.is_t_packet(); | ||
cfallin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| let mut res = ResponseWriter::new(&mut self.i.conn, target.use_rle()); | ||
| let event = self.i.inner.finish_exec(&mut res, target, reason.into())?; | ||
| let event = self.i.inner.finish_exec(&mut res, target, reason)?; | ||
|
|
||
| if let Some(regs) = regs { | ||
cfallin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if is_t_packet { | ||
| for (reg_id, value) in regs { | ||
| res.write_num(reg_id).map_err(InternalError::from)?; | ||
| res.write_str(":").map_err(InternalError::from)?; | ||
| res.write_hex_buf(value).map_err(InternalError::from)?; | ||
| res.write_str(";").map_err(InternalError::from)?; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| res.flush().map_err(InternalError::from)?; | ||
|
|
||
| Ok(match event { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.