Python signal.SIGTRAP Examples
The following are 10
code examples of signal.SIGTRAP().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
signal
, or try the search function
.
Example #1
Source File: process.py From darkc0de-old-stuff with GNU General Public License v3.0 | 6 votes |
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()
Example #2
Source File: linux.py From nightmare with GNU General Public License v2.0 | 5 votes |
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)
Example #3
Source File: posix.py From nightmare with GNU General Public License v2.0 | 5 votes |
def platformSendBreak(self): self.sendSignal(signal.SIGTRAP) # FIXME maybe change to SIGSTOP
Example #4
Source File: posix.py From nightmare with GNU General Public License v2.0 | 5 votes |
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)
Example #5
Source File: _defs_linux.py From ptracer with Apache License 2.0 | 5 votes |
def WPTRACEEVENT(status): if os.WIFSTOPPED(status): stopsig = os.WSTOPSIG(status) if stopsig == signal.SIGTRAP: return status >> 16 return 0
Example #6
Source File: process.py From peach with Mozilla Public License 2.0 | 5 votes |
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
Example #7
Source File: debugger.py From darkc0de-old-stuff with GNU General Public License v3.0 | 5 votes |
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
Example #8
Source File: darwin.py From nightmare with GNU General Public License v2.0 | 4 votes |
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
Example #9
Source File: ptrace.py From ptracer with Apache License 2.0 | 4 votes |
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)))
Example #10
Source File: process.py From peach with Mozilla Public License 2.0 | 4 votes |
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()