visualstudio_py_debugger.py 文件源码

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

项目:AutoDiff 作者: icewall 项目源码 文件源码
def handle_line(self, frame, arg):
        if not DETACHED:
            stepping = self.stepping

            # http://pytools.codeplex.com/workitem/815
            # if we block for a step into/over we don't want to block again for a breakpoint
            blocked_for_stepping = False

            if stepping is not STEPPING_NONE:   # check for the common case of no stepping first...
                if (((stepping == STEPPING_OVER or stepping == STEPPING_INTO) and frame.f_lineno != self.stopped_on_line) 
                    or stepping == STEPPING_LAUNCH_BREAK 
                    or stepping == STEPPING_ATTACH_BREAK):
                    if ((stepping == STEPPING_LAUNCH_BREAK and not MODULES) or                        
                        not should_debug_code(frame.f_code)):  # don't break into our own debugger / non-user code
                        # don't break into inital Python code needed to set things up
                        return self.trace_func

                    blocked_for_stepping = stepping != STEPPING_LAUNCH_BREAK and stepping != STEPPING_ATTACH_BREAK
                    self.block_maybe_attach()

            if BREAKPOINTS and blocked_for_stepping is False:
                bp = BREAKPOINTS.get(frame.f_lineno)
                if bp is not None:
                    for (filename, bp_id), (condition, bound) in bp.items():
                        if filename == frame.f_code.co_filename or (not bound and filename_is_same(filename, frame.f_code.co_filename)):   
                            if condition:                            
                                try:
                                    res = eval(condition.condition, frame.f_globals, frame.f_locals)
                                    if condition.break_when_changed:
                                        block = condition.last_value != res
                                        condition.last_value = res
                                    else:
                                        block = res
                                except:
                                    block = True
                            else:
                                block = True

                            if block:
                                probe_stack()
                                update_all_thread_stacks(self)
                                self.block(lambda: (report_breakpoint_hit(bp_id, self.id), mark_all_threads_for_break()))
                                break

        # forward call to previous trace function, if any, updating trace function appropriately
        old_trace_func = self.prev_trace_func
        if old_trace_func is not None:
            self.prev_trace_func = None  # clear first incase old_trace_func stack overflows
            self.prev_trace_func = old_trace_func(frame, 'line', arg)

        return self.trace_func
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号