-
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
Fix SBValue crash and add some features #24
Open
tetenpapier
wants to merge
7
commits into
endoli:main
Choose a base branch
from
tetenpapier:master
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+318
−31
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8b5e852
add basic creation for breakpoints
tetenpapier a6a68b9
handle nullptr for SBValue
tetenpapier d6d8b52
add basic childs methods for SBValue
tetenpapier 5c1b6b2
add basic change value for SBValue
tetenpapier b464f24
add steps over and out
tetenpapier 5687498
add Memory region info item and list
tetenpapier c2cb753
Merge branch 'endoli:master' into master
tetenpapier 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
use crate::sys; | ||
use lldb_addr_t; | ||
use std::ffi::CStr; | ||
|
||
#[allow(missing_docs)] | ||
#[derive(Debug)] | ||
pub struct SBMemoryRegionInfo { | ||
pub raw: sys::SBMemoryRegionInfoRef, | ||
} | ||
|
||
impl SBMemoryRegionInfo { | ||
#[allow(missing_docs)] | ||
pub fn new() -> Self { | ||
SBMemoryRegionInfo::from(unsafe { sys::CreateSBMemoryRegionInfo() }) | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn clear(&self) { | ||
unsafe { sys::SBMemoryRegionInfoClear(self.raw) }; | ||
} | ||
|
||
/* | ||
pub fn get_description(&self, description: SBStream) -> SBStream { | ||
} | ||
*/ | ||
|
||
#[allow(missing_docs)] | ||
pub fn is_executable(&self) -> bool { | ||
unsafe { sys::SBMemoryRegionInfoIsExecutable(self.raw) } | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn is_mapped(&self) -> bool { | ||
unsafe { sys::SBMemoryRegionInfoIsMapped(self.raw) } | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn is_readable(&self) -> bool { | ||
unsafe { sys::SBMemoryRegionInfoIsReadable(self.raw) } | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn is_writable(&self) -> bool { | ||
unsafe { sys::SBMemoryRegionInfoIsWritable(self.raw) } | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn get_name(&self) -> Option<String> { | ||
unsafe { | ||
let ptr = sys::SBMemoryRegionInfoGetName(self.raw); | ||
|
||
if !ptr.is_null() { | ||
match CStr::from_ptr(ptr).to_str() { | ||
Ok(s) => Some(s.to_owned()), | ||
_ => panic!("No MemoryRegionInfo name string?"), | ||
} | ||
} else { | ||
None | ||
} | ||
} | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn get_region_base(&self) -> lldb_addr_t { | ||
unsafe { sys::SBMemoryRegionInfoGetRegionBase(self.raw) } | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn get_region_end(&self) -> lldb_addr_t { | ||
unsafe { sys::SBMemoryRegionInfoGetRegionEnd(self.raw) } | ||
} | ||
} | ||
|
||
impl Clone for SBMemoryRegionInfo { | ||
fn clone(&self) -> Self { | ||
Self { | ||
raw: unsafe { sys::CloneSBMemoryRegionInfo(self.raw) }, | ||
} | ||
} | ||
} | ||
|
||
impl Default for SBMemoryRegionInfo { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl Drop for SBMemoryRegionInfo { | ||
fn drop(&mut self) { | ||
unsafe { sys::DisposeSBMemoryRegionInfo(self.raw) }; | ||
} | ||
} | ||
|
||
impl From<sys::SBMemoryRegionInfoRef> for SBMemoryRegionInfo { | ||
fn from(raw: sys::SBMemoryRegionInfoRef) -> Self { | ||
Self { raw } | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
use crate::sys; | ||
use crate::SBMemoryRegionInfo; | ||
|
||
#[allow(missing_docs)] | ||
#[derive(Debug)] | ||
pub struct SBMemoryRegionInfoList { | ||
pub raw: sys::SBMemoryRegionInfoListRef, | ||
} | ||
|
||
impl SBMemoryRegionInfoList { | ||
#[allow(missing_docs)] | ||
pub fn new() -> Self { | ||
SBMemoryRegionInfoList::from(unsafe { sys::CreateSBMemoryRegionInfoList() }) | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn append(&self, region: SBMemoryRegionInfo) { | ||
unsafe { sys::SBMemoryRegionInfoListAppend(self.raw, region.raw) }; | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn append_list(&self, region_list: SBMemoryRegionInfoList) { | ||
unsafe { sys::SBMemoryRegionInfoListAppendList(self.raw, region_list.raw) }; | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn clear(&self) { | ||
unsafe { sys::SBMemoryRegionInfoListClear(self.raw) }; | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn get_memory_region(&self, index: u32) -> Option<SBMemoryRegionInfo> { | ||
let tmp = SBMemoryRegionInfo::default(); | ||
if unsafe { sys::SBMemoryRegionInfoListGetMemoryRegionAtIndex(self.raw, index, tmp.raw) } { | ||
Some(tmp) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn get_size(&self) -> u32 { | ||
unsafe { sys::SBMemoryRegionInfoListGetSize(self.raw) } | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub fn iter(&self) -> SBMemoryRegionInfoListIter { | ||
SBMemoryRegionInfoListIter { | ||
memory_list: self, | ||
idx: 0, | ||
} | ||
} | ||
} | ||
|
||
impl Clone for SBMemoryRegionInfoList { | ||
fn clone(&self) -> Self { | ||
Self { | ||
raw: unsafe { sys::CloneSBMemoryRegionInfoList(self.raw) }, | ||
} | ||
} | ||
} | ||
|
||
impl Default for SBMemoryRegionInfoList { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl Drop for SBMemoryRegionInfoList { | ||
fn drop(&mut self) { | ||
unsafe { sys::DisposeSBMemoryRegionInfoList(self.raw) }; | ||
} | ||
} | ||
|
||
impl From<sys::SBMemoryRegionInfoListRef> for SBMemoryRegionInfoList { | ||
fn from(raw: sys::SBMemoryRegionInfoListRef) -> Self { | ||
Self { raw } | ||
} | ||
} | ||
|
||
#[allow(missing_docs)] | ||
pub struct SBMemoryRegionInfoListIter<'d> { | ||
memory_list: &'d SBMemoryRegionInfoList, | ||
idx: u32, | ||
} | ||
|
||
impl<'d> Iterator for SBMemoryRegionInfoListIter<'d> { | ||
type Item = SBMemoryRegionInfo; | ||
|
||
#[allow(missing_docs)] | ||
fn next(&mut self) -> Option<SBMemoryRegionInfo> { | ||
if self.idx < self.memory_list.get_size() { | ||
let r = self.memory_list.get_memory_region(self.idx); | ||
self.idx += 1; | ||
r | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
#[allow(missing_docs)] | ||
fn size_hint(&self) -> (usize, Option<usize>) { | ||
let sz = self.memory_list.get_size() as usize; | ||
(sz - self.idx as usize, Some(sz)) | ||
} | ||
} |
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
Oops, something went wrong.
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.
I'm not sure about the implementation here. Do we create a new SBFrame and return it as an option if
sys::SBMemoryRegionInfoGetDescription
returns true ? in the source code of lldb, it always returns true. Or Do we take an SBFrame in parameter and pass it in the sys function ?