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 self) -> Option<&'me DebuggingInformationEntry<'input, 'abbrev, 'unit, Endian>>

Get a reference to the entry that the cursor is currently pointing to.

fn next_entry(&mut self) -> ParseResult<Option<()>>

Move the cursor to the next DIE in the tree.

Returns Some if there is a next entry, even if this entry is null. If there is no next entry, then None is returned.

fn next_dfs<'me>(&'me mut self) -> ParseResult<Option<(isize, &'me DebuggingInformationEntry<'input, 'abbrev, 'unit, Endian>)>>

Move the cursor to the next DIE in the tree in DFS order.

Upon successful movement of the cursor, return the delta traversal depth and the entry:

  • If we moved down into the previous current entry's children, we get Some((1, entry)).

  • If we moved to the previous current entry's sibling, we get Some((0, entry)).

  • If the previous entry does not have any siblings and we move up to its parent's next sibling, then we get Some((-1, entry)). 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 return Some((-2, entry)), 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);

// Move the cursor to the root.
assert!(cursor.next_dfs().unwrap().is_some());

// Keep looping while the cursor is moving deeper into the DIE tree.
while let Some((delta_depth, current)) = cursor.next_dfs().expect("Should parse 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;
    }

    first_entry_with_no_children = Some(current.clone());
}

println!("The first entry with no children is {:?}",
         first_entry_with_no_children.unwrap());

fn next_sibling<'me>(&'me mut self) -> ParseResult<Option<&'me DebuggingInformationEntry<'input, 'abbrev, 'unit, Endian>>>

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 next_entry or next_dfs is called.

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_dfs().unwrap().is_some());

// Move the cursor to the root's first child.
assert!(cursor.next_dfs().unwrap().is_some());

// Iterate the root's children.
loop {
    {
        let current = cursor.current().expect("Should be at an entry");
        println!("{:?} is a child of the root", current);
    }

    if cursor.next_sibling().expect("Should parse 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]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

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