72 |
72 |
73 self._dbgClient = dbgClient |
73 self._dbgClient = dbgClient |
74 self._mainThread = True |
74 self._mainThread = True |
75 |
75 |
76 self.tracePythonLibs(0) |
76 self.tracePythonLibs(0) |
|
77 |
|
78 # Special handling of a recursion error |
|
79 self.skipFrames = 0 |
77 |
80 |
78 self.__isBroken = False |
81 self.__isBroken = False |
79 self.cFrame = None |
82 self.cFrame = None |
80 |
83 |
81 # current frame we are at |
84 # current frame we are at |
678 self._dbgClient.write("{0}{1}\n".format( |
681 self._dbgClient.write("{0}{1}\n".format( |
679 ResponseSyntax, str(exclist))) |
682 ResponseSyntax, str(exclist))) |
680 self._dbgClient.eventLoop() |
683 self._dbgClient.eventLoop() |
681 return |
684 return |
682 |
685 |
|
686 self.skipFrames = 0 |
|
687 if (exctype == RuntimeError and |
|
688 str(excval).startswith('maximum recursion depth exceeded') or |
|
689 sys.version_info >= (3, 5) and exctype == RecursionError): |
|
690 excval = 'maximum recursion depth exceeded' |
|
691 depth = 0 |
|
692 tb = exctb |
|
693 while tb: |
|
694 tb = tb.tb_next |
|
695 |
|
696 if (tb and tb.tb_frame.f_code.co_name == 'trace_dispatch' and |
|
697 __file__.startswith(tb.tb_frame.f_code.co_filename)): |
|
698 depth = 1 |
|
699 self.skipFrames += depth |
|
700 |
|
701 # always 1 if running without debugger |
|
702 self.skipFrames = max(1, self.skipFrames) |
|
703 |
683 exctype = self.__extractExceptionName(exctype) |
704 exctype = self.__extractExceptionName(exctype) |
684 |
705 |
685 if excval is None: |
706 if excval is None: |
686 excval = '' |
707 excval = '' |
687 |
708 |
698 frlist = self.__extract_stack(exctb) |
719 frlist = self.__extract_stack(exctb) |
699 frlist.reverse() |
720 frlist.reverse() |
700 |
721 |
701 self.currentFrame = frlist[0] |
722 self.currentFrame = frlist[0] |
702 |
723 |
703 for fr in frlist: |
724 for fr in frlist[self.skipFrames:]: |
704 filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) |
725 filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) |
705 |
726 |
706 if os.path.basename(filename).startswith("DebugClient") or \ |
727 if os.path.basename(filename).startswith("DebugClient") or \ |
707 os.path.basename(filename) == "bdb.py": |
728 os.path.basename(filename) == "bdb.py": |
708 break |
729 break |