pub struct EntriesCursor<'abbrev, R>where
R: Reader,{ /* private fields */ }Expand description
A cursor into the Debugging Information Entries tree for a compilation unit.
The EntriesCursor can traverse the DIE tree in DFS order using Self::next_dfs,
or skip to the next sibling of the entry the cursor is currently pointing to
using Self::next_sibling.
Self::next_dfs will skip over the null DIEs that delimit lists of children. Use
Self::next_entry if you wish to stop at null DIEs. This may be useful if you want
to read entries at a specific depth, such as moving to the first child prior to using
Self::next_sibling.
Implementations§
Source§impl<'abbrev, R: Reader> EntriesCursor<'abbrev, R>
impl<'abbrev, R: Reader> EntriesCursor<'abbrev, R>
Sourcepub fn current(&self) -> Option<&DebuggingInformationEntry<R>>
pub fn current(&self) -> Option<&DebuggingInformationEntry<R>>
Get a reference to the entry that the cursor is currently pointing to.
If the cursor is not pointing at an entry, or if the current entry is a
null entry, then None is returned.
Sourcepub fn offset(&self) -> UnitOffset<R::Offset>
pub fn offset(&self) -> UnitOffset<R::Offset>
The unit offset of the current DIE.
This works even if the cursor is positioned at a null DIE.
Sourcepub fn depth(&self) -> isize
pub fn depth(&self) -> isize
The tree depth of the current DIE.
This works even if the cursor is positioned at a null DIE.
Sourcepub fn next_offset(&self) -> UnitOffset<R::Offset>
pub fn next_offset(&self) -> UnitOffset<R::Offset>
The unit offset of the next DIE that Self::next_entry will read.
Sourcepub fn next_depth(&self) -> isize
pub fn next_depth(&self) -> isize
The tree depth of the next DIE that Self::next_entry will read.
Sourcepub fn next_entry(&mut self) -> Result<bool>
pub fn next_entry(&mut self) -> Result<bool>
Move the cursor to the next DIE in the tree.
Returns true if there is a next entry, even if this entry is null.
If there is no next entry, then false is returned.
Sourcepub fn next_dfs(&mut self) -> Result<Option<&DebuggingInformationEntry<R>>>
pub fn next_dfs(&mut self) -> Result<Option<&DebuggingInformationEntry<R>>>
Move the cursor to the next DIE in the tree in DFS order.
Upon successful movement of the cursor, returns the entry, which may be:
-
The first child of the previous current entry, if any.
-
The sibling of the previous current entry, if any.
-
The sibling of the previous entry’s parent, if any, and so on.
If there is no next entry, then None is returned.
Here is an example that prints the offset and depth of all entries in a compilation unit.
let unit = get_some_unit();
let abbrevs = get_abbrevs_for_unit(&unit);
let mut cursor = unit.entries(&abbrevs);
// Traverse the DIE tree in depth-first search order.
while let Some(current) = cursor.next_dfs().expect("Should parse next dfs") {
println!(
"Offset: {:x} Depth: {} Tag: {}",
current.offset().0,
current.depth(),
current.tag()
);
}Sourcepub fn next_sibling(&mut self) -> Result<Option<&DebuggingInformationEntry<R>>>
pub fn next_sibling(&mut self) -> Result<Option<&DebuggingInformationEntry<R>>>
Move the cursor to the next sibling DIE of the current one.
Returns Ok(Some(entry)) when the cursor has been moved to the next sibling,
Ok(None) when there is no next sibling.
The depth of the cursor is never changed if this method returns Ok. Once
Ok(None) is returned, this method will continue to return Ok(None) until
either Self::next_entry or Self::next_dfs is called.
This method is useful for reading only the children of a DIE. However, you
must first move the cursor to the first child. Self::next_entry is usually
the easiest way to do this. You should also use either Self::next_depth or
DebuggingInformationEntry::has_children to determine if the DIE can have
children.
Here is an example that iterates over all of the direct children of the root entry:
let unit = get_some_unit();
let abbrevs = get_abbrevs_for_unit(&unit);
let mut cursor = unit.entries(&abbrevs);
// Move the cursor to the root.
assert!(cursor.next_entry().unwrap());
// Move the cursor to the root's first child, if any.
assert!(cursor.current().unwrap().has_children());
assert!(cursor.next_entry().unwrap());
// Iterate the root's children.
while let Some(current) = cursor.current() {
println!("{:?} is a child of the root", current);
cursor.next_sibling().expect("Should parse next sibling");
}Trait Implementations§
Source§impl<'abbrev, R> Clone for EntriesCursor<'abbrev, R>
impl<'abbrev, R> Clone for EntriesCursor<'abbrev, R>
Source§fn clone(&self) -> EntriesCursor<'abbrev, R>
fn clone(&self) -> EntriesCursor<'abbrev, R>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more