Struct gimli::EntriesCursor
[−]
[src]
pub struct EntriesCursor<'input, 'abbrev, 'unit, Endian> where 'input: 'unit, Endian: Endianity + 'unit {
// some fields omitted
}A cursor into the Debugging Information Entries tree for a compilation unit.
The EntriesCursor can traverse the DIE tree in either DFS order, or skip
to the next sibling of the entry the cursor is currently pointing to.
Methods
impl<'input, 'abbrev, 'unit, Endian> EntriesCursor<'input, 'abbrev, 'unit, Endian> where Endian: Endianity[src]
fn current<'me>(&'me mut self) -> Option<ParseResult<DebuggingInformationEntry<'input, 'abbrev, 'unit, Endian>>>
Get the entry that the cursor is currently pointing to.
fn next_dfs(&mut self) -> Option<isize>
Move the cursor to the next DIE in the tree in DFS order.
Upon successful movement of the cursor, return the delta traversal depth:
If we moved down into the previous current entry's children, we get
Some(1).If we moved to the previous current entry's sibling, we get
Some(0).If the previous entry does not have any siblings and we move up to its parent's next sibling, then we get
Some(-1). Note that if the parent doesn't have a next sibling, then it could go up to the parent's parent's next sibling and returnSome(-2), etc.
If there is no next entry, then None is returned.
Here is an example that finds the first entry in a compilation unit that does not have any children.
let unit = get_some_unit(); let abbrevs = get_abbrevs_for_unit(&unit); let mut first_entry_with_no_children = None; let mut cursor = unit.entries(&abbrevs); // Keep looping while the cursor is moving deeper into the DIE tree. while let Some(delta_depth) = cursor.next_dfs() { // 0 means we moved to a sibling, a negative number means we went back // up to a parent's sibling. In either case, bail out of the loop because // we aren't going deeper into the tree anymore. if delta_depth <= 0 { break; } let current = cursor.current() .expect("Should be at an entry") .expect("And we should parse the entry ok"); first_entry_with_no_children = Some(current); } println!("The first entry with no children is {:?}", first_entry_with_no_children.unwrap());
fn next_sibling(&mut self) -> Option<()>
Move the cursor to the next sibling DIE of the current one.
Returns Some when the cursor the cursor has been moved to the next
sibling, None when there is no next sibling.
After returning None, the cursor is exhausted.
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's first child. assert_eq!(cursor.next_dfs().unwrap(), 1); // Iterate the root's children. loop { let current = cursor.current() .expect("Should be at an entry") .expect("And we should parse the entry ok"); println!("{:?} is a child of the root", current); if cursor.next_sibling().is_none() { break; } }
Trait Implementations
impl<'input, 'abbrev, 'unit, Endian: Debug> Debug for EntriesCursor<'input, 'abbrev, 'unit, Endian> where 'input: 'unit, Endian: Endianity + 'unit[src]
impl<'input, 'abbrev, 'unit, Endian: Clone> Clone for EntriesCursor<'input, 'abbrev, 'unit, Endian> where 'input: 'unit, Endian: Endianity + 'unit[src]
fn clone(&self) -> EntriesCursor<'input, 'abbrev, 'unit, Endian>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more