pub fn threads(
        &self,
    ) -> Result<Vec<Box<dyn Thread<ThreadId = mach_port_t>>>, Box<dyn std::error::Error>> {
        let mut threads: mach_types::thread_act_array_t = std::ptr::null_mut();
        let mut tcount: mach_msg_type_number_t = 0;

        let result = unsafe { mach::task::task_threads(self.port, &mut threads, &mut tcount) };

        if result == kern_return::KERN_SUCCESS {
            let tcount = tcount as usize;
            let mut osx_threads = Vec::with_capacity(tcount);

            for i in 0..tcount {
                let port = unsafe { *threads.add(i) };
                let pthread_id = match unsafe { pthread_from_mach_thread_np(port) } {
                    0 => None,
                    id => Some(id),
                };
                let task_port = self.port;
                let thread = Box::new(OSXThread {
                    port,
                    pthread_id,
                    task_port,
                }) as Box<dyn Thread<ThreadId = mach_port_t>>;

                osx_threads.push(thread);
            }
            Ok(osx_threads)
        } else {
            Err(format!(
                "Failure to read task {} threads. Error: {}",
                self.port, result
            )
            .into())
        }
    }
/// Returns the current snapshot view of this debuggee process threads.
Returns the current snapshot view of this debuggee process threads.
Returns the current snapshot view of this debuggee process threads .
pub fn threads(
        &self,
    ) -> Result<Vec<Box<dyn Thread<ThreadId = mach_port_t>>>, Box<dyn std::error::Error>> {
        let mut threads: mach_types::thread_act_array_t = std::ptr::null_mut();
        let mut tcount: mach_msg_type_number_t = 0;
        let result = unsafe { mach::task::task_threads(self.port, &mut threads, &mut tcount) };
        if result == kern_return::KERN_SUCCESS {
            let tcount = tcount as usize;
            let mut osx_threads = Vec::with_capacity(tcount);
            for i in 0..tcount {
                let port = unsafe { *threads.add(i) };
                let pthread_id = match unsafe { pthread_from_mach_thread_np(port) } {
                    0 => None,
                    id => Some(id),
                };
                let task_port = self.port;
                let thread = Box::new(OSXThread {
                    port,
                    pthread_id,
                    task_port,
                }) as Box<dyn Thread<ThreadId = mach_port_t>>;
                osx_threads.push(thread);
            }
            Ok(osx_threads)
        } else {
            Err(format!(
                "Failure to read task {} threads. Error: {}",
                self.port, result
            )
            .into())
        }
    }
pub fn threads ( & self , ) -> Result < Vec < Box < dyn Thread < ThreadId = mach_port_t > > > , Box < dyn std :: error :: Error > > { let mut threads : mach_types :: thread_act_array_t = std :: ptr :: null_mut ( ) ; let mut tcount : mach_msg_type_number_t = 0 ; let result = unsafe { mach :: task :: task_threads ( self . port , & mut threads , & mut tcount ) } ; if result == kern_return :: KERN_SUCCESS { let tcount = tcount as usize ; let mut osx_threads = Vec :: with_capacity ( tcount ) ; for i in 0 .. tcount { let port = unsafe { * threads . add ( i ) } ; let pthread_id = match unsafe { pthread_from_mach_thread_np ( port ) } { 0 => None , id => Some ( id ) , } ; let task_port = self . port ; let thread = Box :: new ( OSXThread { port , pthread_id , task_port , } ) as Box < dyn Thread < ThreadId = mach_port_t > > ; osx_threads . push ( thread ) ; } Ok ( osx_threads ) } else { Err ( format ! ( " " self port result ) . into ( ) ) } }
Returns the current snapshot view of this debuggee process threads.
Returns the current snapshot view of this debuggee process threads .
&self