83 # current frame we are at |
84 # current frame we are at |
84 self.currentFrame = None |
85 self.currentFrame = None |
85 |
86 |
86 # frame that we are stepping in, can be different than currentFrame |
87 # frame that we are stepping in, can be different than currentFrame |
87 self.stepFrame = None |
88 self.stepFrame = None |
|
89 |
|
90 self.botframe = None |
|
91 self.stopframe = None |
|
92 self.returnframe = None |
|
93 self.stop_everywhere = False |
88 |
94 |
89 # provide a hook to perform a hard breakpoint |
95 # provide a hook to perform a hard breakpoint |
90 # Use it like this: |
96 # Use it like this: |
91 # if hasattr(sys, 'breakpoint): sys.breakpoint() |
97 # if hasattr(sys, 'breakpoint): sys.breakpoint() |
92 sys.breakpoint = self.set_trace |
98 sys.breakpoint = self.set_trace |
290 if self.stop_here(frame) or self.break_here(frame): |
296 if self.stop_here(frame) or self.break_here(frame): |
291 self.user_line(frame) |
297 self.user_line(frame) |
292 return |
298 return |
293 |
299 |
294 if event == 'call': |
300 if event == 'call': |
295 if self.botframe is None: |
301 if self.botframe is None and frame.f_lineno > 1: |
296 # First call of dispatch since reset() |
|
297 # (CT) Note that this may also be None! |
|
298 self.botframe = frame.f_back |
302 self.botframe = frame.f_back |
|
303 frame.f_trace = self.trace_dispatch |
|
304 self._dbgClient.mainFrame = frame |
|
305 |
|
306 self.user_line(frame) |
299 return self.trace_dispatch |
307 return self.trace_dispatch |
300 |
308 |
301 if not (self.stop_here(frame) or |
309 if not (self.stop_here(frame) or |
302 self.__checkBreakInFrame(frame) or |
310 self.__checkBreakInFrame(frame) or |
303 Watch.watches != []): |
311 Watch.watches != []): |
304 # No need to trace this function |
312 # No need to trace this function |
305 return |
313 return |
306 return self.trace_dispatch |
314 return self.trace_dispatch |
307 |
315 |
308 if event == 'return': |
316 if event == 'return': |
309 if self.stop_here(frame) or frame == self.returnframe: |
317 # The program has finished if we have just left the first frame |
310 # The program has finished if we have just left the first frame |
318 if (self.stop_here(frame) and |
311 if frame == self._dbgClient.mainFrame and \ |
319 frame == self._dbgClient.mainFrame and |
312 self._mainThread: |
320 self._mainThread): |
313 atexit._run_exitfuncs() |
321 atexit._run_exitfuncs() |
314 self._dbgClient.progTerminated(arg) |
322 self._dbgClient.progTerminated(arg) |
315 elif frame is not self.stepFrame: |
323 |
316 self.stepFrame = None |
324 if self.quitting and not self._dbgClient.passive: |
317 self.user_line(frame) |
325 raise SystemExit |
318 |
|
319 if self.quitting and not self._dbgClient.passive: |
|
320 raise SystemExit |
|
321 return |
326 return |
322 |
327 |
323 if event == 'exception': |
328 if event == 'exception': |
324 if not self.__skipFrame(frame): |
329 if not self.__skipFrame(frame): |
325 self.user_exception(frame, arg) |
330 self.user_exception(frame, arg) |
387 pass |
392 pass |
388 finally: |
393 finally: |
389 self.quitting = 1 |
394 self.quitting = 1 |
390 sys.settrace(None) |
395 sys.settrace(None) |
391 |
396 |
|
397 def _set_stopinfo(self, stopframe, returnframe): |
|
398 """ |
|
399 Protected method to update the frame pointers. |
|
400 |
|
401 @param stopframe the frame object where to stop |
|
402 @type frame object |
|
403 @param returnframe the frame object where to stop on a function return |
|
404 @type frame object |
|
405 """ |
|
406 self.stopframe = stopframe |
|
407 self.returnframe = returnframe |
|
408 self.stop_everywhere = False |
|
409 |
392 def set_continue(self, special): |
410 def set_continue(self, special): |
393 """ |
411 """ |
394 Public method reimplemented from bdb.py to always get informed of |
412 Public method to stop only on next breakpoint. |
395 exceptions. |
|
396 |
413 |
397 @param special flag indicating a special continue operation |
414 @param special flag indicating a special continue operation |
398 """ |
415 @type bool |
399 # Modified version of the one found in bdb.py |
416 """ |
400 # Here we only set a new stop frame if it is a normal continue. |
417 # Here we only set a new stop frame if it is a normal continue. |
401 if not special: |
418 if not special: |
402 self._set_stopinfo(self.botframe, None) |
419 self._set_stopinfo(self.botframe, None) |
403 # Disable tracing if not started in debug mode |
420 # Disable tracing if not started in debug mode |
404 if not self._dbgClient.debugging: |
421 if not self._dbgClient.debugging: |
405 sys.settrace(None) |
422 sys.settrace(None) |
406 sys.setprofile(None) |
423 sys.setprofile(None) |
|
424 |
|
425 def set_step(self): |
|
426 """ |
|
427 Public method to stop after one line of code. |
|
428 """ |
|
429 self._set_stopinfo(None, None) |
|
430 self.stop_everywhere = True |
407 |
431 |
408 def set_quit(self): |
432 def set_quit(self): |
409 """ |
433 """ |
410 Public method to quit. |
434 Public method to quit. |
411 |
435 |
794 |
818 |
795 Tracing is turned off for files that are part of the |
819 Tracing is turned off for files that are part of the |
796 debugger that are called from the application being debugged. |
820 debugger that are called from the application being debugged. |
797 |
821 |
798 @param frame the frame object |
822 @param frame the frame object |
|
823 @type frame object |
799 @return flag indicating whether the debugger should stop here |
824 @return flag indicating whether the debugger should stop here |
|
825 @rtype bool |
800 """ |
826 """ |
801 if self.__skipFrame(frame): |
827 if self.__skipFrame(frame): |
802 return 0 |
828 return False |
803 return bdb.Bdb.stop_here(self, frame) |
829 |
|
830 return (self.stop_everywhere or |
|
831 frame is self.stopframe or |
|
832 frame is self.returnframe or |
|
833 frame is self.botframe) |
804 |
834 |
805 def tracePythonLibs(self, enable): |
835 def tracePythonLibs(self, enable): |
806 """ |
836 """ |
807 Public method to update the settings to trace into Python libraries. |
837 Public method to update the settings to trace into Python libraries. |
808 |
838 |