71 Constructor |
71 Constructor |
72 |
72 |
73 @param dbgClient the owning client |
73 @param dbgClient the owning client |
74 """ |
74 """ |
75 self._dbgClient = dbgClient |
75 self._dbgClient = dbgClient |
76 if sys.version_info[0] == 2: |
|
77 self.stopOnHandleLine = self._dbgClient.handleLine.func_code |
|
78 else: |
|
79 self.stopOnHandleLine = self._dbgClient.handleLine.__code__ |
|
80 |
76 |
81 self._mainThread = True |
77 self._mainThread = True |
82 self.quitting = 0 |
78 self.quitting = False |
83 |
79 |
84 self.tracePythonLibs(0) |
80 self.tracePythonLibs(0) |
85 |
81 |
86 # Special handling of a recursion error |
82 # Special handling of a recursion error |
87 self.skipFrames = 0 |
83 self.skipFrames = 0 |
88 |
84 |
89 self.__isBroken = False |
85 self.isBroken = False |
90 self.cFrame = None |
86 self.cFrame = None |
91 |
87 |
92 # current frame we are at |
88 # current frame we are at |
93 self.currentFrame = None |
89 self.currentFrame = None |
94 |
90 |
95 # frame that we are stepping in, can be different than currentFrame |
91 # frames, where we want to stop or release debugger |
96 self.stepFrame = None |
|
97 |
|
98 self.botframe = None |
92 self.botframe = None |
99 self.stopframe = None |
93 self.stopframe = None |
100 self.returnframe = None |
94 self.returnframe = None |
101 self.stop_everywhere = False |
95 self.stop_everywhere = False |
102 |
96 |
173 Public method to perform a step operation in this thread. |
167 Public method to perform a step operation in this thread. |
174 |
168 |
175 @param traceMode If it is True, then the step is a step into, |
169 @param traceMode If it is True, then the step is a step into, |
176 otherwise it is a step over. |
170 otherwise it is a step over. |
177 """ |
171 """ |
178 self.stepFrame = self.currentFrame |
|
179 |
|
180 if traceMode: |
172 if traceMode: |
181 self.currentFrame = None |
|
182 self.set_step() |
173 self.set_step() |
183 else: |
174 else: |
184 self.set_next(self.currentFrame) |
175 self.set_next(self.currentFrame) |
185 |
176 |
186 def stepOut(self): |
177 def stepOut(self): |
187 """ |
178 """ |
188 Public method to perform a step out of the current call. |
179 Public method to perform a step out of the current call. |
189 """ |
180 """ |
190 self.stepFrame = self.currentFrame |
|
191 self.set_return(self.currentFrame) |
181 self.set_return(self.currentFrame) |
192 |
182 |
193 def go(self, special): |
183 def go(self, special): |
194 """ |
184 """ |
195 Public method to resume the thread. |
185 Public method to resume the thread. |
196 |
186 |
197 It resumes the thread stopping only at breakpoints or exceptions. |
187 It resumes the thread stopping only at breakpoints or exceptions. |
198 |
188 |
199 @param special flag indicating a special continue operation |
189 @param special flag indicating a special continue operation |
200 """ |
190 """ |
201 self.currentFrame = None |
|
202 self.set_continue(special) |
191 self.set_continue(special) |
203 |
192 |
204 def setRecursionDepth(self, frame): |
193 def setRecursionDepth(self, frame): |
205 """ |
194 """ |
206 Public method to determine the current recursion depth. |
195 Public method to determine the current recursion depth. |
387 @type frame object |
376 @type frame object |
388 """ |
377 """ |
389 if frame is None: |
378 if frame is None: |
390 frame = sys._getframe().f_back # Skip set_trace method |
379 frame = sys._getframe().f_back # Skip set_trace method |
391 |
380 |
|
381 if sys.version_info[0] == 2: |
|
382 stopOnHandleLine = self._dbgClient.handleLine.func_code |
|
383 bootstrap = '__bootstrap' |
|
384 else: |
|
385 stopOnHandleLine = self._dbgClient.handleLine.__code__ |
|
386 bootstrap = 'bootstrap' |
|
387 |
392 frame.f_trace = self.trace_dispatch |
388 frame.f_trace = self.trace_dispatch |
393 while frame is not None: |
389 while frame is not None: |
394 # stop at erics debugger frame |
390 # stop at erics debugger frame |
395 if frame.f_back.f_code == self.stopOnHandleLine: |
391 if frame.f_back.f_code == stopOnHandleLine: |
396 frame.f_trace = self.trace_dispatch |
392 frame.f_trace = self.trace_dispatch |
397 self.botframe = frame |
393 self.botframe = frame |
398 break |
394 break |
399 |
395 |
400 frame = frame.f_back |
396 frame = frame.f_back |
493 """ |
489 """ |
494 Public method to quit. |
490 Public method to quit. |
495 |
491 |
496 Disables the trace functions and resets all frame pointer. |
492 Disables the trace functions and resets all frame pointer. |
497 """ |
493 """ |
498 self.currentFrame = None |
|
499 sys.setprofile(None) |
494 sys.setprofile(None) |
500 sys.settrace(None) |
495 sys.settrace(None) |
501 self.stopframe = None |
496 self.stopframe = None |
502 self.returnframe = None |
497 self.returnframe = None |
503 self.quitting = 1 |
498 self.quitting = True |
504 |
499 |
505 def fix_frame_filename(self, frame): |
500 def fix_frame_filename(self, frame): |
506 """ |
501 """ |
507 Public method used to fixup the filename for a given frame. |
502 Public method used to fixup the filename for a given frame. |
508 |
503 |
718 return |
713 return |
719 |
714 |
720 self.currentFrame = frame |
715 self.currentFrame = frame |
721 stack = self.getStack(frame, applyTrace=True) |
716 stack = self.getStack(frame, applyTrace=True) |
722 |
717 |
723 self.__isBroken = True |
718 self.isBroken = True |
724 |
719 |
725 self._dbgClient.sendResponseLine(stack) |
720 self._dbgClient.sendResponseLine(stack) |
726 self._dbgClient.eventLoop() |
721 self._dbgClient.eventLoop() |
727 |
722 |
728 self.__isBroken = False |
723 self.isBroken = False |
729 |
724 |
730 def user_exception(self, frame, excinfo, unhandled=False): |
725 def user_exception(self, frame, excinfo, unhandled=False): |
731 """ |
726 """ |
732 Public method reimplemented to report an exception to the debug server. |
727 Public method reimplemented to report an exception to the debug server. |
733 |
728 |
734 @param frame the frame object |
729 @param frame the frame object |
806 return |
801 return |
807 |
802 |
808 self.skipFrames = 0 |
803 self.skipFrames = 0 |
809 if (exctype == RuntimeError and |
804 if (exctype == RuntimeError and |
810 str(excval).startswith('maximum recursion depth exceeded') or |
805 str(excval).startswith('maximum recursion depth exceeded') or |
811 sys.version_info >= (3, 5) and exctype == RecursionError): |
806 sys.version_info >= (3, 5) and |
|
807 exctype == RecursionError): # __IGNORE_WARNING__ |
812 excval = 'maximum recursion depth exceeded' |
808 excval = 'maximum recursion depth exceeded' |
813 depth = 0 |
809 depth = 0 |
814 tb = exctb |
810 tb = exctb |
815 while tb: |
811 while tb: |
816 tb = tb.tb_next |
812 tb = tb.tb_next |