Ejemplo n.º 1
0
 def cont(self, signum=0):
     if signum:
         info("Continue process %s (send signal %s)" % (
             self.pid, signalName(signum)))
     else:
         info("Continue process %s" % self.pid)
     ptrace_cont(self.pid, signum)
     self.is_stopped = False
Ejemplo n.º 2
0
 def cont(self, signum=0):
     if signum:
         info("Continue process %s (send signal %s)" %
              (self.pid, signalName(signum)))
     else:
         info("Continue process %s" % self.pid)
     ptrace_cont(self.pid, signum)
     self.is_stopped = False
Ejemplo n.º 3
0
    def __spawn(self):
        self.pid = os.fork()
        if self.pid == 0:
            # Make GCOV dump into the session_dir
            os.environ['GCOV_PREFIX'] = self.service.gcov_dir
            os.environ['GCOV_PREFIX_STRIP'] = str(service.gcovstrip)
            os.close(sys.stdin.fileno())
            os.close(sys.stderr.fileno())
            os.close(sys.stdout.fileno())

            os.dup2(self.conn.fileno(), sys.stdin.fileno())
            os.dup2(self.conn.fileno(), sys.stderr.fileno())
            os.dup2(self.conn.fileno(), sys.stdout.fileno())

            ptrace_traceme() #force process to stop after exec
            os.execvp(self.service.cmd[0], self.service.cmd)
            raise Exception("Failed to Exec")
        (pid, ret) = os.waitpid(self.pid, 0) #Wait for first trap
        self.tracer = PtraceProcess(None, self.pid, True)
        #set a breakpoint when it exits gracefully
        self.exitbp = self.tracer.createBreakpoint(self.finiaddr)
        ptrace_cont(self.pid) #Start the process again
        self.service.instances[self.pid] = self
Ejemplo n.º 4
0
    def __handle_event(self, pid, status):
        if os.WCOREDUMP(status):
            logger.warning("Core dump created for %s" % (self.pid))

        if os.WIFEXITED(status):
            self.service.instances.pop(self.pid, None)
            self.log_event(0)
            self.__spawn()

        elif os.WIFSIGNALED(status):
            self.service.instances.pop(self.pid, None)
            sig = os.WTERMSIG(status)
            self.log_event(sig)
            self.__spawn()

        elif os.WIFSTOPPED(status):
            self.coverage.capture(self.pid)
            sig = os.WSTOPSIG(status)

            #Don't log breakpoints
            if sig == signal.SIGTRAP:
                self.exitbp.desinstall(set_ip = True)
                ptrace_cont(self.pid, 0)
                return

            self.log_event(sig)
            if sig == signal.SIGPIPE:
                ptrace_detach(self.pid)
                os.waitpid(self.pid, 0) #Clean up Zombie
                self.running = False

            elif sig == signal.SIGSEGV:
                self.__capturecore()
                self.__spawn()
            else:
                ptrace_cont(self.pid, sig)
Ejemplo n.º 5
0
 def cont(self, signum=0):
     signum = self.filterSignal(signum)
     ptrace_cont(self.pid, signum)
     self.is_stopped = False
Ejemplo n.º 6
0
 def cont(self, signum=0):
     signum = self.filterSignal(signum)
     ptrace_cont(self.pid, signum)
     self.is_stopped = False
Ejemplo n.º 7
0
 def cont(self, signum=0):
     return ptrace_cont(self.pid, signum)