432 """ |
432 """ |
433 Public method to start a given command under debugger control. |
433 Public method to start a given command under debugger control. |
434 |
434 |
435 @param cmd command / code to execute under debugger control |
435 @param cmd command / code to execute under debugger control |
436 @type str or CodeType |
436 @type str or CodeType |
437 @keyparam globalsDict dictionary of global variables for cmd |
437 @param globalsDict dictionary of global variables for cmd |
438 @type dict |
438 @type dict |
439 @keyparam localsDict dictionary of local variables for cmd |
439 @param localsDict dictionary of local variables for cmd |
440 @type dict |
440 @type dict |
441 @keyparam debug flag if command should run under debugger control |
441 @param debug flag if command should run under debugger control |
442 @type bool |
442 @type bool |
|
443 @return exit code of the program |
|
444 @rtype int |
443 """ |
445 """ |
444 if globalsDict is None: |
446 if globalsDict is None: |
445 import __main__ |
447 import __main__ |
446 globalsDict = __main__.__dict__ |
448 globalsDict = __main__.__dict__ |
447 |
449 |
460 |
462 |
461 try: |
463 try: |
462 exec(cmd, globalsDict, localsDict) |
464 exec(cmd, globalsDict, localsDict) |
463 atexit._run_exitfuncs() |
465 atexit._run_exitfuncs() |
464 self._dbgClient.progTerminated(0) |
466 self._dbgClient.progTerminated(0) |
|
467 exitcode = 0 |
465 except SystemExit: |
468 except SystemExit: |
466 atexit._run_exitfuncs() |
469 atexit._run_exitfuncs() |
467 excinfo = sys.exc_info() |
470 excinfo = sys.exc_info() |
468 exitcode, message = self.__extractSystemExitMessage(excinfo) |
471 exitcode, message = self.__extractSystemExitMessage(excinfo) |
469 self._dbgClient.progTerminated(exitcode, message) |
472 self._dbgClient.progTerminated(exitcode, message) |
470 except Exception: |
473 except Exception: |
471 excinfo = sys.exc_info() |
474 excinfo = sys.exc_info() |
472 self.user_exception(excinfo, True) |
475 self.user_exception(excinfo, True) |
|
476 exitcode = 242 |
473 finally: |
477 finally: |
474 self.quitting = True |
478 self.quitting = True |
475 sys.settrace(None) |
479 sys.settrace(None) |
|
480 return exitcode |
476 |
481 |
477 def _set_stopinfo(self, stopframe, returnframe): |
482 def _set_stopinfo(self, stopframe, returnframe): |
478 """ |
483 """ |
479 Protected method to update the frame pointers. |
484 Protected method to update the frame pointers. |
480 |
485 |