-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Dynamic RegId
Support
#58
Closed
Closed
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a4ff570
Allow variable register sizes for `SingleRegisterAccess`
DrChat 272090e
Clean-up use of `Some(NonZeroUsize::new(N).unwrap())`
DrChat 37c82ec
Wrap raw `read_register` callback, and introduce a weird compiler error
DrChat 6b19ed0
Handle overflow when writing out registers
DrChat 59e45c4
Update documentation
DrChat 834bd68
Documentation update
DrChat 1fcbb0d
Substitue unwrap calls for passing up None
DrChat 0d82197
Move `n` variable usage to allow for DCE
DrChat 04e264f
Missing period
DrChat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -35,7 +35,7 @@ pub trait SingleRegisterAccess<Id>: Target { | |||||
&mut self, | ||||||
DrChat marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
tid: Id, | ||||||
reg_id: <Self::Arch as Arch>::RegId, | ||||||
dst: &mut [u8], | ||||||
output: SendRegisterOutput<'_>, | ||||||
) -> TargetResult<(), Self>; | ||||||
|
||||||
/// Write from a single register on the target. | ||||||
|
@@ -65,3 +65,19 @@ pub trait SingleRegisterAccess<Id>: Target { | |||||
/// See [`SingleRegisterAccess`] | ||||||
pub type SingleRegisterAccessOps<'a, Id, T> = | ||||||
&'a mut dyn SingleRegisterAccess<Id, Arch = <T as Target>::Arch, Error = <T as Target>::Error>; | ||||||
|
||||||
/// An interface to send register data to the GDB remote debugger. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
pub struct SendRegisterOutput<'a> { | ||||||
inner: &'a mut dyn FnMut(&[u8]), | ||||||
} | ||||||
|
||||||
impl<'a> SendRegisterOutput<'a> { | ||||||
pub(crate) fn new(inner: &'a mut dyn FnMut(&[u8])) -> Self { | ||||||
Self { inner } | ||||||
} | ||||||
|
||||||
/// Write out raw register bytes to the GDB debugger. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
GDB stands for GNU DeBugger, so "GDB debugger" is redundant (like ATM Machine) |
||||||
pub fn write(&mut self, data: &[u8]) { | ||||||
(self.inner)(data) | ||||||
} | ||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any recommendations for these
unwrap()
calls? I know they're not allowed ingdbstub
code, but this will just get optimized out by the compiler.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, since you're already in a function that returns
Option<_>
, you can just useNonZeroUsize::new(x)?
.At the end of the day, any reasonably optimizing compiler should generate equivalent code when using
?
orunwrap
in these trivial cases (i.e: it'll elide the None branch entirely)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 using the
?
operator is a nicer shorthand :)I wish there was a
new()
compile-time constructor that threw a compiler error if the constant evaluated to 0 - that'd be a bit nicer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sigh, preaching to the choir...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂 time to submit some RFCs to Rust I guess