eric6/DebugClients/Python/DebugBase.py

branch
multi_processing
changeset 7421
4a9900aef04e
parent 7405
bf6be3cff6cf
child 7563
b0d6b63f2843
equal deleted inserted replaced
7420:0d596bb4a60d 7421:4a9900aef04e
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
979 exitcode = 1 984 exitcode = 1
980 message = code.decode() 985 message = code.decode()
981 elif isinstance(code, int): 986 elif isinstance(code, int):
982 exitcode = code 987 exitcode = code
983 message = "" 988 message = ""
989 elif code is None:
990 exitcode = 0
991 message = ""
984 else: 992 else:
985 exitcode = 1 993 exitcode = 1
986 message = str(code) 994 message = str(code)
987 else: 995 else:
988 exitcode = 1 996 exitcode = 1

eric ide

mercurial