diff -r 4affedf129c5 -r 25115adf9758 DebugClients/Python3/DebugBase.py --- a/DebugClients/Python3/DebugBase.py Mon Aug 08 22:02:45 2016 +0200 +++ b/DebugClients/Python3/DebugBase.py Mon Aug 08 22:30:48 2016 +0200 @@ -277,7 +277,7 @@ @type depends on the previous event parameter @return local trace function @rtype trace function or None - @exception bdb.BdbQuit + @exception SystemExit """ # give the client a chance to push through new break points. if self.eventPollFlag: @@ -285,7 +285,7 @@ self.eventPollFlag = False if self.quitting: - raise bdb.BdbQuit + raise SystemExit if event == 'line': if self.stop_here(frame) or self.break_here(frame): @@ -321,7 +321,7 @@ self.user_line(frame) if self.quitting and not self._dbgClient.passive: - raise bdb.BdbQuit + raise SystemExit return if event == 'exception': @@ -377,6 +377,36 @@ sys.settrace(self.trace_dispatch) sys.setprofile(self._dbgClient.callTraceEnabled) + def run(self, cmd, globals=None, locals=None): + """ + Public method to start a given command under debugger control. + + @param cmd command / code to execute under debugger control + @type str or CodeType + @keyparam globals dictionary of global variables for cmd + @type dict + @keyparam locals dictionary of local variables for cmd + @type dict + """ + if globals is None: + import __main__ + globals = __main__.__dict__ + + if locals is None: + locals = globals + + sys.settrace(self.trace_dispatch) + if isinstance(cmd, str): + cmd = compile(cmd, "<string>", "exec") + + try: + exec(cmd, globals, locals) + except SystemExit: + pass + finally: + self.quitting = 1 + sys.settrace(None) + def set_continue(self, special): """ Public method reimplemented from bdb.py to always get informed of @@ -649,8 +679,11 @@ Public method reimplemented to report an exception to the debug server. @param frame the frame object - @param excinfo information about the exception - @param unhandled flag indicating an uncaught exception + @type frame object + @param excinfo details about the exception + @type tuple(Exception, excval object, traceback frame object) + @keyparam unhandled flag indicating an uncaught exception + @type bool """ exctype, excval, exctb = excinfo @@ -658,7 +691,7 @@ # ignore these return - if exctype in [SystemExit, bdb.BdbQuit]: + if exctype == SystemExit: atexit._run_exitfuncs() if excval is None: excval = 0