fn add_probe(&mut self, definition: ProbeDefinition) -> Fallible<()> {
        let c_name = CString::new(definition.name)?;

        // Unfortunately, the `providerAddProbe` C function is variadic, taking the types of the probe arguments
        // as variadic arguments.  This isn't a very ergonomic API design for either C or Rust wrappers.
        // In this case there is a max number of supported arguments, exposed in the `MAX_ARGUMENTS` constant.  At
        // the time of this writing this is '6', so we must handle from 0 to 6 possible arg counts.
        assert_eq!(6, MAX_ARGUMENTS);

        let arg_types: Vec<ArgType_t> = definition
            .arg_types
            .iter()
            .map(|x| Self::get_arg_type(x.clone()))
            .collect();

        let probe_ptr = unsafe {
            match arg_types.len() {
                0 => providerAddProbe(self.provider, c_name.as_ptr(), 0),
                1 => providerAddProbe(self.provider, c_name.as_ptr(), 1, arg_types[0]),
                2 => providerAddProbe(
                    self.provider,
                    c_name.as_ptr(),
                    2,
                    arg_types[0],
                    arg_types[1],
                ),
                3 => providerAddProbe(
                    self.provider,
                    c_name.as_ptr(),
                    3,
                    arg_types[0],
                    arg_types[1],
                    arg_types[2],
                ),
                4 => providerAddProbe(
                    self.provider,
                    c_name.as_ptr(),
                    4,
                    arg_types[0],
                    arg_types[1],
                    arg_types[2],
                    arg_types[3],
                ),
                5 => providerAddProbe(
                    self.provider,
                    c_name.as_ptr(),
                    5,
                    arg_types[0],
                    arg_types[1],
                    arg_types[2],
                    arg_types[3],
                    arg_types[4],
                ),
                _ => providerAddProbe(
                    self.provider,
                    c_name.as_ptr(),
                    6,
                    arg_types[0],
                    arg_types[1],
                    arg_types[2],
                    arg_types[3],
                    arg_types[4],
                    arg_types[5],
                ),
            }
        };

        if probe_ptr.is_null() {
            return Err(StapError::NativeCallFailed {
                func: "providerAddProbe",
            }
            .into());
        }

        let probe = StapProbe { probe: probe_ptr };

        self.probes.insert(definition, probe);
        Ok(())
    }
/// Actually creates a systemtap probe object and associates it with the provider.  This also
/// keeps a record of the `ProbeDefinition` which will be used at runtime to ensure the
/// probe'sarg count and types are the same as when the probe was defined.
Actually creates a systemtap probe object and associates it with the provider.  This also
keeps a record of the `ProbeDefinition` which will be used at runtime to ensure the
probe'sarg count and types are the same as when the probe was defined.
Actually creates a systemtap probe object and associates it with the provider . This also keeps a record of the ` ProbeDefinition ` which will be used at runtime to ensure the probe ' sarg count and types are the same as when the probe was defined .
fn add_probe(&mut self, definition: ProbeDefinition) -> Fallible<()> {
        let c_name = CString::new(definition.name)?;
        // Unfortunately, the `providerAddProbe` C function is variadic, taking the types of the probe arguments
        // as variadic arguments.  This isn't a very ergonomic API design for either C or Rust wrappers.
        // In this case there is a max number of supported arguments, exposed in the `MAX_ARGUMENTS` constant.  At
        // the time of this writing this is '6', so we must handle from 0 to 6 possible arg counts.
        assert_eq!(6, MAX_ARGUMENTS);
        let arg_types: Vec<ArgType_t> = definition
            .arg_types
            .iter()
            .map(|x| Self::get_arg_type(x.clone()))
            .collect();
        let probe_ptr = unsafe {
            match arg_types.len() {
                0 => providerAddProbe(self.provider, c_name.as_ptr(), 0),
                1 => providerAddProbe(self.provider, c_name.as_ptr(), 1, arg_types[0]),
                2 => providerAddProbe(
                    self.provider,
                    c_name.as_ptr(),
                    2,
                    arg_types[0],
                    arg_types[1],
                ),
                3 => providerAddProbe(
                    self.provider,
                    c_name.as_ptr(),
                    3,
                    arg_types[0],
                    arg_types[1],
                    arg_types[2],
                ),
                4 => providerAddProbe(
                    self.provider,
                    c_name.as_ptr(),
                    4,
                    arg_types[0],
                    arg_types[1],
                    arg_types[2],
                    arg_types[3],
                ),
                5 => providerAddProbe(
                    self.provider,
                    c_name.as_ptr(),
                    5,
                    arg_types[0],
                    arg_types[1],
                    arg_types[2],
                    arg_types[3],
                    arg_types[4],
                ),
                _ => providerAddProbe(
                    self.provider,
                    c_name.as_ptr(),
                    6,
                    arg_types[0],
                    arg_types[1],
                    arg_types[2],
                    arg_types[3],
                    arg_types[4],
                    arg_types[5],
                ),
            }
        };
        if probe_ptr.is_null() {
            return Err(StapError::NativeCallFailed {
                func: "providerAddProbe",
            }
            .into());
        }
        let probe = StapProbe { probe: probe_ptr };
        self.probes.insert(definition, probe);
        Ok(())
    }
fn add_probe ( & mut self , definition : ProbeDefinition ) -> Fallible < ( ) > { let c_name = CString :: new ( definition . name ) ? ; // Unfortunately, the `providerAddProbe` C function is variadic, taking the types of the probe arguments // as variadic arguments.  This isn't a very ergonomic API design for either C or Rust wrappers. // In this case there is a max number of supported arguments, exposed in the `MAX_ARGUMENTS` constant.  At // the time of this writing this is '6', so we must handle from 0 to 6 possible arg counts. assert_eq ! ( 6 MAX_ARGUMENTS ) ; let arg_types : Vec < ArgType_t > = definition . arg_types . iter ( ) . map ( | x | Self :: get_arg_type ( x . clone ( ) ) ) . collect ( ) ; let probe_ptr = unsafe { match arg_types . len ( ) { 0 => providerAddProbe ( self . provider , c_name . as_ptr ( ) , 0 ) , 1 => providerAddProbe ( self . provider , c_name . as_ptr ( ) , 1 , arg_types [ 0 ] ) , 2 => providerAddProbe ( self . provider , c_name . as_ptr ( ) , 2 , arg_types [ 0 ] , arg_types [ 1 ] , ) , 3 => providerAddProbe ( self . provider , c_name . as_ptr ( ) , 3 , arg_types [ 0 ] , arg_types [ 1 ] , arg_types [ 2 ] , ) , 4 => providerAddProbe ( self . provider , c_name . as_ptr ( ) , 4 , arg_types [ 0 ] , arg_types [ 1 ] , arg_types [ 2 ] , arg_types [ 3 ] , ) , 5 => providerAddProbe ( self . provider , c_name . as_ptr ( ) , 5 , arg_types [ 0 ] , arg_types [ 1 ] , arg_types [ 2 ] , arg_types [ 3 ] , arg_types [ 4 ] , ) , _ => providerAddProbe ( self . provider , c_name . as_ptr ( ) , 6 , arg_types [ 0 ] , arg_types [ 1 ] , arg_types [ 2 ] , arg_types [ 3 ] , arg_types [ 4 ] , arg_types [ 5 ] , ) , } } ; if probe_ptr . is_null ( ) { return Err ( StapError :: NativeCallFailed { func : " " , } . into ( ) ) ; } let probe = StapProbe { probe : probe_ptr } ; self . probes . insert ( definition , probe ) ; Ok ( ( ) ) }
Actually creates a systemtap probe object and associates it with the provider.
Actually creates a systemtap probe object and associates it with the provider .
&mut self
definition
ProbeDefinition
&mut self
definition
ProbeDefinition