DebugClients/Python/DebugBase.py

changeset 5587
ea526b78ee6c
parent 5582
d829281d439f
child 5616
adcffadf4962
equal deleted inserted replaced
5586:0e5421d679e7 5587:ea526b78ee6c
419 self.user_exception(excinfo, True) 419 self.user_exception(excinfo, True)
420 finally: 420 finally:
421 sys.settrace(None) 421 sys.settrace(None)
422 sys.setprofile(None) 422 sys.setprofile(None)
423 423
424 def run(self, cmd, globals=None, locals=None, debug=True): 424 def run(self, cmd, globalsDict=None, localsDict=None, debug=True):
425 """ 425 """
426 Public method to start a given command under debugger control. 426 Public method to start a given command under debugger control.
427 427
428 @param cmd command / code to execute under debugger control 428 @param cmd command / code to execute under debugger control
429 @type str or CodeType 429 @type str or CodeType
430 @keyparam globals dictionary of global variables for cmd 430 @keyparam globalsDict dictionary of global variables for cmd
431 @type dict 431 @type dict
432 @keyparam locals dictionary of local variables for cmd 432 @keyparam localsDict dictionary of local variables for cmd
433 @type dict 433 @type dict
434 @keyparam debug flag if command should run under debugger control 434 @keyparam debug flag if command should run under debugger control
435 @type bool 435 @type bool
436 """ 436 """
437 if globals is None: 437 if globalsDict is None:
438 import __main__ 438 import __main__
439 globals = __main__.__dict__ 439 globalsDict = __main__.__dict__
440 440
441 if locals is None: 441 if localsDict is None:
442 locals = globals 442 localsDict = globalsDict
443 443
444 if not isinstance(cmd, types.CodeType): 444 if not isinstance(cmd, types.CodeType):
445 cmd = compile(cmd, "<string>", "exec") 445 cmd = compile(cmd, "<string>", "exec")
446 446
447 if debug: 447 if debug:
450 # function call. This is ensured by setting stop_everywhere. 450 # function call. This is ensured by setting stop_everywhere.
451 self.stop_everywhere = True 451 self.stop_everywhere = True
452 sys.settrace(self.trace_dispatch) 452 sys.settrace(self.trace_dispatch)
453 453
454 try: 454 try:
455 exec(cmd, globals, locals) 455 exec(cmd, globalsDict, localsDict)
456 atexit._run_exitfuncs() 456 atexit._run_exitfuncs()
457 self._dbgClient.progTerminated(0) 457 self._dbgClient.progTerminated(0)
458 except SystemExit: 458 except SystemExit:
459 atexit._run_exitfuncs() 459 atexit._run_exitfuncs()
460 excinfo = sys.exc_info() 460 excinfo = sys.exc_info()

eric ide

mercurial