DebugClients/Python3/DebugBase.py

branch
debugger speed
changeset 5084
25115adf9758
parent 5083
4affedf129c5
child 5085
85dfb7886fb9
equal deleted inserted replaced
5083:4affedf129c5 5084:25115adf9758
275 @type str 275 @type str
276 @param arg The arguments 276 @param arg The arguments
277 @type depends on the previous event parameter 277 @type depends on the previous event parameter
278 @return local trace function 278 @return local trace function
279 @rtype trace function or None 279 @rtype trace function or None
280 @exception bdb.BdbQuit 280 @exception SystemExit
281 """ 281 """
282 # give the client a chance to push through new break points. 282 # give the client a chance to push through new break points.
283 if self.eventPollFlag: 283 if self.eventPollFlag:
284 self._dbgClient.eventPoll() 284 self._dbgClient.eventPoll()
285 self.eventPollFlag = False 285 self.eventPollFlag = False
286 286
287 if self.quitting: 287 if self.quitting:
288 raise bdb.BdbQuit 288 raise SystemExit
289 289
290 if event == 'line': 290 if event == 'line':
291 if self.stop_here(frame) or self.break_here(frame): 291 if self.stop_here(frame) or self.break_here(frame):
292 self.user_line(frame) 292 self.user_line(frame)
293 return 293 return
319 elif frame is not self.stepFrame: 319 elif frame is not self.stepFrame:
320 self.stepFrame = None 320 self.stepFrame = None
321 self.user_line(frame) 321 self.user_line(frame)
322 322
323 if self.quitting and not self._dbgClient.passive: 323 if self.quitting and not self._dbgClient.passive:
324 raise bdb.BdbQuit 324 raise SystemExit
325 return 325 return
326 326
327 if event == 'exception': 327 if event == 'exception':
328 if not self.__skipFrame(frame): 328 if not self.__skipFrame(frame):
329 # When stepping with next/until/return in a generator frame, 329 # When stepping with next/until/return in a generator frame,
375 375
376 self.set_step() 376 self.set_step()
377 sys.settrace(self.trace_dispatch) 377 sys.settrace(self.trace_dispatch)
378 sys.setprofile(self._dbgClient.callTraceEnabled) 378 sys.setprofile(self._dbgClient.callTraceEnabled)
379 379
380 def run(self, cmd, globals=None, locals=None):
381 """
382 Public method to start a given command under debugger control.
383
384 @param cmd command / code to execute under debugger control
385 @type str or CodeType
386 @keyparam globals dictionary of global variables for cmd
387 @type dict
388 @keyparam locals dictionary of local variables for cmd
389 @type dict
390 """
391 if globals is None:
392 import __main__
393 globals = __main__.__dict__
394
395 if locals is None:
396 locals = globals
397
398 sys.settrace(self.trace_dispatch)
399 if isinstance(cmd, str):
400 cmd = compile(cmd, "<string>", "exec")
401
402 try:
403 exec(cmd, globals, locals)
404 except SystemExit:
405 pass
406 finally:
407 self.quitting = 1
408 sys.settrace(None)
409
380 def set_continue(self, special): 410 def set_continue(self, special):
381 """ 411 """
382 Public method reimplemented from bdb.py to always get informed of 412 Public method reimplemented from bdb.py to always get informed of
383 exceptions. 413 exceptions.
384 414
647 def user_exception(self, frame, excinfo, unhandled=False): 677 def user_exception(self, frame, excinfo, unhandled=False):
648 """ 678 """
649 Public method reimplemented to report an exception to the debug server. 679 Public method reimplemented to report an exception to the debug server.
650 680
651 @param frame the frame object 681 @param frame the frame object
652 @param excinfo information about the exception 682 @type frame object
653 @param unhandled flag indicating an uncaught exception 683 @param excinfo details about the exception
684 @type tuple(Exception, excval object, traceback frame object)
685 @keyparam unhandled flag indicating an uncaught exception
686 @type bool
654 """ 687 """
655 exctype, excval, exctb = excinfo 688 exctype, excval, exctb = excinfo
656 689
657 if exctype in [GeneratorExit, StopIteration]: 690 if exctype in [GeneratorExit, StopIteration]:
658 # ignore these 691 # ignore these
659 return 692 return
660 693
661 if exctype in [SystemExit, bdb.BdbQuit]: 694 if exctype == SystemExit:
662 atexit._run_exitfuncs() 695 atexit._run_exitfuncs()
663 if excval is None: 696 if excval is None:
664 excval = 0 697 excval = 0
665 elif isinstance(excval, str): 698 elif isinstance(excval, str):
666 self._dbgClient.write(excval) 699 self._dbgClient.write(excval)

eric ide

mercurial