本文整理汇总了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()
示例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)
示例3: platformSendBreak
# 需要导入模块: import signal [as 别名]
# 或者: from signal import SIGTRAP [as 别名]
def platformSendBreak(self):
self.sendSignal(signal.SIGTRAP) # FIXME maybe change to SIGSTOP
示例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)
示例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
示例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
示例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
示例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
示例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)))
示例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()