debugger.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:python-ptrace 作者: vstinner 项目源码 文件源码
def addProcess(self, pid, is_attached, parent=None, is_thread=False):
        """
        Add a new process using its identifier. Use is_attached=False to
        attach an existing (running) process, and is_attached=True to trace
        a new (stopped) process.
        """
        if pid in self.dict:
            raise KeyError("The process %s is already registered!" % pid)
        process = PtraceProcess(self, pid, is_attached,
                                parent=parent, is_thread=is_thread)
        info("Attach %s to debugger" % process)
        self.dict[pid] = process
        self.list.append(process)
        try:
            process.waitSignals(SIGTRAP, SIGSTOP)
        except KeyboardInterrupt:
            error(
                "User interrupt! Force the process %s attach "
                "(don't wait for signals)."
                % pid)
        except ProcessSignal as event:
            event.display()
        except:   # noqa: E722
            process.is_attached = False
            process.detach()
            raise
        if HAS_PTRACE_EVENTS and self.options:
            process.setoptions(self.options)
        return process
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号