當前位置: 首頁>>代碼示例>>Python>>正文


Python signal.SIGTRAP屬性代碼示例

本文整理匯總了Python中signal.SIGTRAP屬性的典型用法代碼示例。如果您正苦於以下問題:Python signal.SIGTRAP屬性的具體用法?Python signal.SIGTRAP怎麽用?Python signal.SIGTRAP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在signal的用法示例。


在下文中一共展示了signal.SIGTRAP屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: waitExit

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTRAP [as 別名]
def waitExit(self):
        debug("Wait %s exit" % self)
        while True:
            # Wait for any process signal
            event = self.waitEvent()
            event_cls = event.__class__

            # Process exited: we are done
            if event_cls == ProcessExit:
                debug(str(event))
                return

            # Event different than a signal? Raise an exception
            if event_cls != ProcessSignal:
                raise event

            # Send the signal to the process
            signum = event.signum
            if signum not in (SIGTRAP, SIGSTOP):
                self.cont(signum)
            else:
                self.cont() 
開發者ID:tuwid,項目名稱:darkc0de-old-stuff,代碼行數:24,代碼來源:process.py

示例2: platformWait

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTRAP [as 別名]
def platformWait(self):        
        # Blocking wait once...
        pid, status = os.waitpid(-1, 0x40000002)
        self.setMeta("ThreadId", pid)
        # Stop the rest of the threads... 
        # why is linux debugging so Ghetto?!?!
        if not self.stepping: # If we're stepping, only do the one
            for tid in self.pthreads:
                if tid == pid:
                    continue
                try:
                    os.kill(tid, signal.SIGTRAP)
                    os.waitpid(tid, 0x40000002)
                except Exception, e:
                    print "WARNING TID is invalid %d %s" % (tid,e) 
開發者ID:joxeankoret,項目名稱:nightmare,代碼行數:17,代碼來源:linux.py

示例3: platformSendBreak

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTRAP [as 別名]
def platformSendBreak(self):
        self.sendSignal(signal.SIGTRAP) # FIXME maybe change to SIGSTOP 
開發者ID:joxeankoret,項目名稱:nightmare,代碼行數:4,代碼來源:posix.py

示例4: handlePosixSignal

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTRAP [as 別名]
def handlePosixSignal(self, sig):
        """
        Handle a basic posix signal for this trace.  This was seperated from
        platformProcessEvent so extenders could skim events and still use this logic.
        """
        if sig == signal.SIGTRAP:

            # Traps on posix systems are a little complicated
            if self.stepping:
                #FIXME try out was single step thing for intel
                self.stepping = False
                self.fireNotifiers(vtrace.NOTIFY_STEP)

            elif self.checkWatchpoints():
                return

            elif self.checkBreakpoints():
                # It was either a known BP or a sendBreak()
                return

            elif self.execing:
                self.execing = False
                self.handleAttach()

            else:
                self._fireSignal(sig)

        elif sig == signal.SIGSTOP:
            #FIXME only on attaching..
            self.handleAttach()

        else:
            self._fireSignal(sig) 
開發者ID:joxeankoret,項目名稱:nightmare,代碼行數:35,代碼來源:posix.py

示例5: WPTRACEEVENT

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTRAP [as 別名]
def WPTRACEEVENT(status):
    if os.WIFSTOPPED(status):
        stopsig = os.WSTOPSIG(status)
        if stopsig == signal.SIGTRAP:
            return status >> 16

    return 0 
開發者ID:pinterest,項目名稱:ptracer,代碼行數:9,代碼來源:_defs_linux.py

示例6: GetMonitorData

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTRAP [as 別名]
def GetMonitorData(self):
        time.sleep(self.lookout_time)
        sytem_crash_report = self.get_crash_report(self.system_report_path)
        bucket = {}

        if not len(self.crash_trace):
            if self.process.returncode < 0:
                crashSignals = [
                    # POSIX.1-1990 signals
                    signal.SIGILL,
                    signal.SIGABRT,
                    signal.SIGFPE,
                    signal.SIGSEGV,
                    # SUSv2 / POSIX.1-2001 signals
                    signal.SIGBUS,
                    signal.SIGSYS,
                    signal.SIGTRAP,
            ]
            for crashSignal in crashSignals:
                if process.returncode == -crashSignal:
                    bucket["auxdat.txt"] = "Process exited with signal: %d" % -process.returncode
        else:
            bucket["auxdat.txt"] = "".join(self.crash_trace)

        if sytem_crash_report:
            bucket["system_crash_report.txt"] = sytem_crash_report

        if self.console_log:
            bucket["stdout.txt"] = "".join(self.console_log[-1000:])

        if self.failure:
            meta = {
                "environ": os.environ.data,
                "command": self.arguments
            }
            bucket["meta.txt"] = json.dumps(dict(meta))
            bucket["Bucket"] = os.path.basename(self.command)
            return bucket 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:40,代碼來源:process.py

示例7: addProcess

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTRAP [as 別名]
def addProcess(self, pid, is_attached, parent=None):
        if pid in self.dict:
            raise KeyError("Process % is already registered!" % pid)
        process = PtraceProcess(self, pid, is_attached, parent=parent)
        info("Attach %s to debugger" % process)
        self.dict[pid] = process
        self.list.append(process)
        process.waitSignals(SIGTRAP, SIGSTOP)
        if HAS_PTRACE_EVENTS and self.options:
            process.setoptions(self.options)
        return process 
開發者ID:tuwid,項目名稱:darkc0de-old-stuff,代碼行數:13,代碼來源:debugger.py

示例8: platformProcessEvent

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTRAP [as 別名]
def platformProcessEvent(self, exc):
        """
        Handle a mach exception message
        """
        # Set the thread that signaled.
        self.setMeta('ThreadId', exc.thread.name)
        self.setMeta('MachException', exc)

        excode = exc.exception
        if excode == EXC_SOFTWARE:
            if exc.codeCnt != 2:
                raise Exception('EXC_SOFTWARE with codeCnt != 2: %d' % exc.codeCnt)
            if exc.codes[0] != EXC_SOFT_SIGNAL:
                raise Exception('codes[0] != EXC_SOFT_SIGNAL: %.8x' % exc.codes[0])

            sig = exc.codes[1]
            if sig == signal.SIGTRAP:
                # FIXME I think we can catch these!
                # Traps on posix systems are a little complicated
                if self.stepping:
                    self.stepping = False
                    self.fireNotifiers(vtrace.NOTIFY_STEP)

                # FIXME and these too...
                elif self.checkBreakpoints():
                    # It was either a known BP or a sendBreak()
                    return

                elif self.execing:
                    self.execing = False
                    self.handleAttach()

                else:
                    self._fireSignal(sig)

            elif sig == signal.SIGSTOP:
                self.handleAttach()

            else:
                self._fireSignal(sig)

        elif excode == EXC_BAD_ACCESS:
            print 'Bad Access:',repr([hex(x) for x in [exc.codes[i] for i in range(exc.codeCnt)]])
            self.fireNotifiers(vtrace.NOTIFY_SIGNAL)

        elif excode == EXC_CRASH:
            print 'Crash:',repr([hex(x) for x in [exc.codes[i] for i in range(exc.codeCnt)]])
            self.setMeta('ExitCode', -1)
            self.fireNotifiers(vtrace.NOTIFY_EXIT)

        else:
            print 'Unprocessed Exception Type: %d' % excode
            self.fireNotifiers(vrtrace.NOTIFY_SIGNAL)

        return 
開發者ID:joxeankoret,項目名稱:nightmare,代碼行數:57,代碼來源:darwin.py

示例9: _wait_for_trace_stop

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTRAP [as 別名]
def _wait_for_trace_stop(pid):
    try:
        # First, check if the tracee is already stopped.
        siginfo = getsiginfo(pid)
    except OSError as e:
        if e.errno == errno.ESRCH:
            # The tracee is still running, so we'll wait
            pass
        else:
            raise
    else:
        # Normally, PTRACE_ATTACH will send a SIGSTOP to the tracee,
        # which we will see here.  However, on some kernels the actual
        # signal may sometimes be SIGTRAP, and that seems to happen
        # when the previous tracer had died without calling PTRACE_DETACH
        # on this process first.  In this case, we need to restart the process
        # and wait for the real SIGSTOP.
        if siginfo.si_signo == signal.SIGTRAP:
            cont(pid, siginfo.si_signo)
        elif is_stop_signal(siginfo.si_signo):
            return
        else:
            raise OSError('traced process has stopped with an unexpected '
                          'signal {}'.format(siginfo.si_signo))

    pid, status = wait(pid)

    if os.WIFEXITED(status):
        raise OSError('traced process {} has exited with exit code {}'.format(
            pid, os.WEXITSTATUS(status)))

    elif os.WIFSIGNALED(status):
        raise OSError('traced process {} has been killed by '
                      'the {} signal {}'.format(pid, os.WTERMSIG(status)))

    if not os.WIFSTOPPED(status):
        raise OSError('waitpid({}) returned an unexpected status {}'.format(
            pid, hex(status)))

    stopsig = os.WSTOPSIG(status)
    if stopsig != signal.SIGSTOP:
        raise OSError('waitpid({}) returned an unexpected status {}'.format(
            pid, hex(status))) 
開發者ID:pinterest,項目名稱:ptracer,代碼行數:45,代碼來源:ptrace.py

示例10: _StartProcess

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTRAP [as 別名]
def _StartProcess(self):
        MonitorDebug(self._name, "_StartProcess")
        self.failure = False
        self.sanlog = []
        self.stderr = []
        self.stdout = []

        print("Command: {}".format(self.arguments))
        self.process = Popen(self.arguments, stderr=PIPE, stdout=PIPE,
                             env=os.environ, bufsize=1, close_fds=isPosix())

        # Todo: Add timeout= for GUI applications.
        stdout, stderr = self.process.communicate()

        if stderr.find("ERROR: AddressSanitizer: ") != -1:
            if stderr.find("AddressSanitizer failed to allocate") == -1:
                self.failure = True
                self.sanlog = re.findall(self.asan_regex, stderr, re.DOTALL)[0]
                self.stdout = stdout
                self.stderr = stderr
        else:
            if self.process.returncode < 0:
                crashSignals = [
                    # POSIX.1-1990 signals
                    signal.SIGILL,
                    signal.SIGABRT,
                    signal.SIGFPE,
                    signal.SIGSEGV,
                    # SUSv2 / POSIX.1-2001 signals
                    signal.SIGBUS,
                    signal.SIGSYS,
                    signal.SIGTRAP,
            ]
            for crashSignal in crashSignals:
                if process.returncode == -crashSignal:
                    self.failure = True
                    self.sanlog = "Process exited with signal: %d" % -process.returncode
                    self.stdout = stdout
                    self.stderr = stderr

        if self.failure:
            self._StopProcess() 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:44,代碼來源:process.py


注:本文中的signal.SIGTRAP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。