274 @type str |
274 @type str |
275 @param arg The arguments |
275 @param arg The arguments |
276 @type depends on the previous event parameter |
276 @type depends on the previous event parameter |
277 @return local trace function |
277 @return local trace function |
278 @rtype trace function or None |
278 @rtype trace function or None |
279 @exception bdb.BdbQuit |
279 @exception SystemExit |
280 """ |
280 """ |
281 # give the client a chance to push through new break points. |
281 # give the client a chance to push through new break points. |
282 if self.eventPollFlag: |
282 if self.eventPollFlag: |
283 self._dbgClient.eventPoll() |
283 self._dbgClient.eventPoll() |
284 self.eventPollFlag = False |
284 self.eventPollFlag = False |
285 |
285 |
286 if self.quitting: |
286 if self.quitting: |
287 raise bdb.BdbQuit |
287 raise SystemExit |
288 |
288 |
289 if event == 'line': |
289 if event == 'line': |
290 if self.stop_here(frame) or self.break_here(frame): |
290 if self.stop_here(frame) or self.break_here(frame): |
291 self.user_line(frame) |
291 self.user_line(frame) |
292 return |
292 return |
315 elif frame is not self.stepFrame: |
315 elif frame is not self.stepFrame: |
316 self.stepFrame = None |
316 self.stepFrame = None |
317 self.user_line(frame) |
317 self.user_line(frame) |
318 |
318 |
319 if self.quitting and not self._dbgClient.passive: |
319 if self.quitting and not self._dbgClient.passive: |
320 raise bdb.BdbQuit |
320 raise SystemExit |
321 return |
321 return |
322 |
322 |
323 if event == 'exception': |
323 if event == 'exception': |
324 if not self.__skipFrame(frame): |
324 if not self.__skipFrame(frame): |
325 self.user_exception(frame, arg) |
325 self.user_exception(frame, arg) |
357 |
357 |
358 self.set_step() |
358 self.set_step() |
359 sys.settrace(self.trace_dispatch) |
359 sys.settrace(self.trace_dispatch) |
360 sys.setprofile(self._dbgClient.callTraceEnabled) |
360 sys.setprofile(self._dbgClient.callTraceEnabled) |
361 |
361 |
|
362 def run(self, cmd, globals=None, locals=None): |
|
363 """ |
|
364 Public method to start a given command under debugger control. |
|
365 |
|
366 @param cmd command / code to execute under debugger control |
|
367 @type str or CodeType |
|
368 @keyparam globals dictionary of global variables for cmd |
|
369 @type dict |
|
370 @keyparam locals dictionary of local variables for cmd |
|
371 @type dict |
|
372 """ |
|
373 if globals is None: |
|
374 import __main__ |
|
375 globals = __main__.__dict__ |
|
376 |
|
377 if locals is None: |
|
378 locals = globals |
|
379 |
|
380 sys.settrace(self.trace_dispatch) |
|
381 if not isinstance(cmd, types.CodeType): |
|
382 cmd += '\n' |
|
383 |
|
384 try: |
|
385 exec cmd in globals, locals |
|
386 except SystemExit: |
|
387 pass |
|
388 finally: |
|
389 self.quitting = 1 |
|
390 sys.settrace(None) |
|
391 |
362 def set_continue(self, special): |
392 def set_continue(self, special): |
363 """ |
393 """ |
364 Public method reimplemented from bdb.py to always get informed of |
394 Public method reimplemented from bdb.py to always get informed of |
365 exceptions. |
395 exceptions. |
366 |
396 |
627 def user_exception(self, frame, (exctype, excval, exctb), unhandled=0): |
657 def user_exception(self, frame, (exctype, excval, exctb), unhandled=0): |
628 """ |
658 """ |
629 Public method reimplemented to report an exception to the debug server. |
659 Public method reimplemented to report an exception to the debug server. |
630 |
660 |
631 @param frame the frame object |
661 @param frame the frame object |
|
662 @type frame object |
632 @param exctype the type of the exception |
663 @param exctype the type of the exception |
|
664 @type Exception |
633 @param excval data about the exception |
665 @param excval data about the exception |
|
666 @type excval object |
634 @param exctb traceback for the exception |
667 @param exctb traceback for the exception |
|
668 @type traceback frame object |
635 @param unhandled flag indicating an uncaught exception |
669 @param unhandled flag indicating an uncaught exception |
|
670 @type int |
636 """ |
671 """ |
637 if exctype in [GeneratorExit, StopIteration]: |
672 if exctype in [GeneratorExit, StopIteration]: |
638 # ignore these |
673 # ignore these |
639 return |
674 return |
640 |
675 |
641 if exctype in [SystemExit, bdb.BdbQuit]: |
676 if exctype == SystemExit: |
642 atexit._run_exitfuncs() |
677 atexit._run_exitfuncs() |
643 if excval is None: |
678 if excval is None: |
644 excval = 0 |
679 excval = 0 |
645 elif isinstance(excval, (unicode, str)): |
680 elif isinstance(excval, (unicode, str)): |
646 self._dbgClient.write(excval) |
681 self._dbgClient.write(excval) |