pub fn code_reverse_lookup(&self, ip: CodePtr) -> Option<MFArity> {
    if !ip.belongs_to(&self.code) {
      return None
    }

    // Find a function with closest code offset less than ip

    // some sane starting value: Code size in Words
    let mut min_dist = self.code.len() + 1;
    let mut fa = FunArity::new(gen_atoms::UNDEFINED, 0);

    let code_begin = &self.code[0] as *const Word;
    assert!(ip.get() > code_begin);
    let ip_offset = (ip.get() as usize - code_begin as usize) / WORD_BYTES;

    for (key, export_offset) in &self.funs {
      //let &CodeOffset(fn_offset) = fn_offset0;
      if ip_offset >= *export_offset {
        let dist = ip_offset - *export_offset;
        if dist < min_dist {
          min_dist = dist;
          fa = key.clone();
        }
      }
    }

    let mfa = MFArity::new_from_funarity(self.mod_id.module(), &fa);
    Some(mfa)
  }
/// Check whether IP belongs to this module's code range, and if so, try and
/// find the MFA for the code location.
// TODO: Use some smart range tree or binary search or something
Check whether IP belongs to this module's code range, and if so, try and
find the MFA for the code location.
TODO: Use some smart range tree or binary search or something
Check whether IP belongs to this module ' s code range and if so try and find the MFA for the code location . TODO : Use some smart range tree or binary search or something
pub fn code_reverse_lookup(&self, ip: CodePtr) -> Option<MFArity> {
    if !ip.belongs_to(&self.code) {
      return None
    }
    // Find a function with closest code offset less than ip
    // some sane starting value: Code size in Words
    let mut min_dist = self.code.len() + 1;
    let mut fa = FunArity::new(gen_atoms::UNDEFINED, 0);
    let code_begin = &self.code[0] as *const Word;
    assert!(ip.get() > code_begin);
    let ip_offset = (ip.get() as usize - code_begin as usize) / WORD_BYTES;
    for (key, export_offset) in &self.funs {
      //let &CodeOffset(fn_offset) = fn_offset0;
      if ip_offset >= *export_offset {
        let dist = ip_offset - *export_offset;
        if dist < min_dist {
          min_dist = dist;
          fa = key.clone();
        }
      }
    }
    let mfa = MFArity::new_from_funarity(self.mod_id.module(), &fa);
    Some(mfa)
  }
pub fn code_reverse_lookup ( & self , ip : CodePtr ) -> Option < MFArity > { if ! ip . belongs_to ( & self . code ) { return None } // Find a function with closest code offset less than ip // some sane starting value: Code size in Words let mut min_dist = self . code . len ( ) + 1 ; let mut fa = FunArity :: new ( gen_atoms :: UNDEFINED , 0 ) ; let code_begin = & self . code [ 0 ] as * const Word ; assert ! ( ip get ( ) code_begin ) ; let ip_offset = ( ip . get ( ) as usize - code_begin as usize ) / WORD_BYTES ; for ( key , export_offset ) in & self . funs { //let &CodeOffset(fn_offset) = fn_offset0; if ip_offset >= * export_offset { let dist = ip_offset - * export_offset ; if dist < min_dist { min_dist = dist ; fa = key . clone ( ) ; } } } let mfa = MFArity :: new_from_funarity ( self . mod_id . module ( ) , & fa ) ; Some ( mfa ) }
Check whether IP belongs to this module's code range, and if so, try and
find the MFA for the code location.
Check whether IP belongs to this module ' s code range and if so try and find the MFA for the code location .
&self
ip
CodePtr