// converts a DIE that represents a function into the self pointer that represents it
converts a DIE that represents a function into the self pointer that represents it
converts a DIE that represents a function into the self pointer that represents it
pub fn subfunction_to_self(
        &self,
        offset: gimli::DebugInfoOffset,
    ) -> Option<gimli::DebugInfoOffset> {
        // find the local unit this subfunction was defined in
        if let Some((unit, offset)) = self.di_to_unit(offset) {
            let mut tree = unit.entries_tree(Some(offset)).ok()?;
            let mut parameters = tree.root().ok()?.children();
            while let Some(node) = parameters.next().ok()? {
                let entry = node.entry();
                if entry.tag() == constants::DW_TAG_formal_parameter {
                    if let Some(name) = self
                        .di_parser
                        .get_str_val(entry, constants::DW_AT_name)
                        .ok()?
                    {
                        if name == "self" {
                            // we have found the type of self, so return it
                            let ptr = get_type(unit, entry).ok()?;
                            // deref this pointer to get to the underlying type
                            return self.deref_ptr(ptr).ok();
                        } else {
                            return None;
                        }
                    } else {
                        return None;
                    }
                }
            }
        }
        // if we got here, we failed
        None
    }
pub fn subfunction_to_self ( & self , offset : gimli :: DebugInfoOffset , ) -> Option < gimli :: DebugInfoOffset > { // find the local unit this subfunction was defined in if let Some ( ( unit , offset ) ) = self . di_to_unit ( offset ) { let mut tree = unit . entries_tree ( Some ( offset ) ) . ok ( ) ? ; let mut parameters = tree . root ( ) . ok ( ) ? . children ( ) ; while let Some ( node ) = parameters . next ( ) . ok ( ) ? { let entry = node . entry ( ) ; if entry . tag ( ) == constants :: DW_TAG_formal_parameter { if let Some ( name ) = self . di_parser . get_str_val ( entry , constants :: DW_AT_name ) . ok ( ) ? { if name == " " { // we have found the type of self, so return it let ptr = get_type ( unit , entry ) . ok ( ) ? ; // deref this pointer to get to the underlying type return self . deref_ptr ( ptr ) . ok ( ) ; } else { return None ; } } else { return None ; } } } } // if we got here, we failed None }
converts a DIE that represents a function into the self pointer that represents it
converts a DIE that represents a function into the self pointer that represents it
&self
offset
gimli::DebugInfoOffset