pub fn new(target: &str, args: &Vec<String>, breakpoints: & mut HashMap<usize, Breakpoint>) -> Option<Inferior> {
        let mut cmd = Command::new(target);
        cmd.args(args);
        
        unsafe {
            cmd.pre_exec(child_traceme);
        }
        
        let child = cmd.spawn().ok()?;
        let mut inferior = Inferior { child };

        match waitpid(nix::unistd::Pid::from_raw(inferior.child.id() as i32), None).ok()? {
            WaitStatus::Stopped(_pid, _sig) => {
                // The target is actually loaded, add breakpoints
                for (baddr, breakpoint) in breakpoints {
                    match inferior.write_byte(*baddr, 0xcc) {
                        Err(_) => {
                            println!("Unable to set breakpoint at {}", baddr);
                            return None;
                        },
                        Ok(orig_byte) => { breakpoint.orig_byte = orig_byte; }
                    }
                }
                Some(inferior)
            }
            _ => {
                return None
            }
        }
    }
/// Attempts to start a new inferior process. Returns Some(Inferior) if successful, or None if
/// an error is encountered.
Attempts to start a new inferior process. Returns Some(Inferior) if successful, or None if
an error is encountered.
Attempts to start a new inferior process . Returns Some ( Inferior ) if successful or None if an error is encountered .
pub fn new(target: &str, args: &Vec<String>, breakpoints: & mut HashMap<usize, Breakpoint>) -> Option<Inferior> {
        let mut cmd = Command::new(target);
        cmd.args(args);
        unsafe {
            cmd.pre_exec(child_traceme);
        }
        let child = cmd.spawn().ok()?;
        let mut inferior = Inferior { child };
        match waitpid(nix::unistd::Pid::from_raw(inferior.child.id() as i32), None).ok()? {
            WaitStatus::Stopped(_pid, _sig) => {
                // The target is actually loaded, add breakpoints
                for (baddr, breakpoint) in breakpoints {
                    match inferior.write_byte(*baddr, 0xcc) {
                        Err(_) => {
                            println!("Unable to set breakpoint at {}", baddr);
                            return None;
                        },
                        Ok(orig_byte) => { breakpoint.orig_byte = orig_byte; }
                    }
                }
                Some(inferior)
            }
            _ => {
                return None
            }
        }
    }
pub fn new ( target : & str , args : & Vec < String > , breakpoints : & mut HashMap < usize , Breakpoint > ) -> Option < Inferior > { let mut cmd = Command :: new ( target ) ; cmd . args ( args ) ; unsafe { cmd . pre_exec ( child_traceme ) ; } let child = cmd . spawn ( ) . ok ( ) ? ; let mut inferior = Inferior { child } ; match waitpid ( nix :: unistd :: Pid :: from_raw ( inferior . child . id ( ) as i32 ) , None ) . ok ( ) ? { WaitStatus :: Stopped ( _pid , _sig ) => { // The target is actually loaded, add breakpoints for ( baddr , breakpoint ) in breakpoints { match inferior . write_byte ( * baddr , 0xcc ) { Err ( _ ) => { println ! ( " " baddr ) ; return None ; } , Ok ( orig_byte ) => { breakpoint . orig_byte = orig_byte ; } } } Some ( inferior ) } _ => { return None } } }
Attempts to start a new inferior process.
Attempts to start a new inferior process .
target
&str
args
&Vec<String>
breakpoints
& mut HashMap<usize, Breakpoint>
target
&str
args
&Vec<String>
breakpoints
& mut HashMap<usize, Breakpoint>