-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: add many safe wrapper functions #39
Conversation
0828838
to
a22851e
Compare
a22851e
to
d93ca79
Compare
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.
Thanks!
This looks good with just some minor details.
If you don't want to deal with that, I can merge it and fix it up myself as well. Just let me know!
src/address.rs
Outdated
/// Returns offset of the address in the section | ||
/// | ||
/// See also: | ||
/// - [`get_section`] for get the section corresponding to this address |
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.
"for getting the"
src/filespec.rs
Outdated
@@ -33,6 +33,12 @@ impl SBFileSpec { | |||
} | |||
} | |||
|
|||
/// Create SBFileSpec from path | |||
pub fn from_path(path: &str, resolve: bool) -> Self { |
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.
Would it make sense for this to be generic on something like:
pub fn from_path<P: AsRef<Path>>(path: P, resolve: bool) -> Self
?
src/module.rs
Outdated
@@ -133,6 +139,63 @@ impl<'d> Iterator for SBModuleSectionIter<'d> { | |||
|
|||
impl<'d> ExactSizeIterator for SBModuleSectionIter<'d> {} | |||
|
|||
/// The list of symbols in the module | |||
pub struct ModuleSymbols<'d> { |
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.
Shouldn't this just be a SBModuleSymbolsIter
like the other iterators?
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 think it should have direct indexed accessor and length access so I made it have intermediate struct.
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.
Curious to know why... but not going to block on it.
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.
When I want to get first library (excluding exexutable), I think it should be possible to access 1th element without accessing 0th element, but I came up with implementing nth
of iterator is enough so I'll do this instead of intermediate struct.
src/process.rs
Outdated
|
||
/// Reads the memory at specified address in the process to the `buffer` | ||
pub fn read_memory(&self, addr: lldb_addr_t, buffer: &mut [u8]) -> Result<(), SBError> { | ||
// SBProcessReadMemory will return error the memory region is not allowed to read |
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.
"will return an error if the" (2 missing words)
src/process.rs
Outdated
} | ||
|
||
/// Loads the specified image to the process | ||
pub fn load_image(&self, file: &SBFileSpec) -> Result<u32, SBError> { |
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'd probably make a quick pub struct ImageToken(u32)
to hide the image_token rather than just allowing any u32
to be used.
src/process.rs
Outdated
unsafe { sys::SBProcessGetByteOrder(self.raw) } | ||
} | ||
|
||
/// Loads the specified image to the process |
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.
"into the" and a missing period at the end.
src/process.rs
Outdated
} | ||
} | ||
|
||
/// Unloads the image loaded with [`load_image`] |
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.
Missing period at the end.
src/process.rs
Outdated
/// | ||
/// [`load_image`]: Self::load_image | ||
pub fn unload_image(&self, image_token: u32) -> Result<(), SBError> { | ||
// the method returns error if image_token is not valid, instead of cause undefined behavior |
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.
"instead of causing"
src/process.rs
Outdated
} | ||
} | ||
|
||
/// Returns the [`SBTarget`] corresponds to this SBProcess. |
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.
"corresponding" and missing backticks on SBProcess
and None
(below)
src/process.rs
Outdated
@@ -700,6 +700,9 @@ impl<'d> Iterator for SBProcessQueueIter<'d> { | |||
} | |||
} | |||
|
|||
/// The token to unload image | |||
struct ImageToken(u32); |
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.
Won't this need to be pub
? And exported from lib.rs
?
src/module.rs
Outdated
@@ -133,6 +139,63 @@ impl<'d> Iterator for SBModuleSectionIter<'d> { | |||
|
|||
impl<'d> ExactSizeIterator for SBModuleSectionIter<'d> {} | |||
|
|||
/// The list of symbols in the module | |||
pub struct ModuleSymbols<'d> { |
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.
Curious to know why... but not going to block on it.
Thank you! |
This PR adds many safe wrapper functions that I need in my project.
Those functions are firstly implemented with
SBXxxExt
trait in my project and it looks work well so I create this PR to upstream functionalities.