--- a/DebugClients/Python/DebugBase.py Thu Mar 23 18:58:56 2017 +0100 +++ b/DebugClients/Python/DebugBase.py Fri Apr 07 18:33:59 2017 +0200 @@ -65,6 +65,9 @@ # cache for fixed file names _fnCache = {} + + # Stop all timers, when greenlets are used + pollTimerEnabled = True def __init__(self, dbgClient): """ @@ -112,9 +115,11 @@ """ Private method to set a flag every 0.5 s to check for new messages. """ - while True: + while DebugBase.pollTimerEnabled: time.sleep(0.5) self.eventPollFlag = True + + self.eventPollFlag = False def getCurrentFrame(self): """ @@ -357,7 +362,7 @@ if event == 'c_return': return - print('DebugBase.trace_dispatch:' # __IGNORE_WARNING__ + print('DebugBase.trace_dispatch:' # __IGNORE_WARNING_M801__ ' unknown debugging event: ', repr(event)) return self.trace_dispatch @@ -421,25 +426,25 @@ sys.settrace(None) sys.setprofile(None) - def run(self, cmd, globals=None, locals=None, debug=True): + def run(self, cmd, globalsDict=None, localsDict=None, debug=True): """ 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 + @keyparam globalsDict dictionary of global variables for cmd @type dict - @keyparam locals dictionary of local variables for cmd + @keyparam localsDict dictionary of local variables for cmd @type dict @keyparam debug flag if command should run under debugger control @type bool """ - if globals is None: + if globalsDict is None: import __main__ - globals = __main__.__dict__ + globalsDict = __main__.__dict__ - if locals is None: - locals = globals + if localsDict is None: + localsDict = globalsDict if not isinstance(cmd, types.CodeType): cmd = compile(cmd, "<string>", "exec") @@ -452,7 +457,7 @@ sys.settrace(self.trace_dispatch) try: - exec(cmd, globals, locals) + exec(cmd, globalsDict, localsDict) atexit._run_exitfuncs() self._dbgClient.progTerminated(0) except SystemExit: @@ -524,6 +529,20 @@ @type frame object """ self._set_stopinfo(None, frame.f_back) + + def move_instruction_pointer(self, lineno): + """ + Public methode to move the instruction pointer to another line. + + @param lineno new line number + @type int + """ + try: + self.currentFrame.f_lineno = lineno + stack = self.getStack(self.currentFrame) + self._dbgClient.sendResponseLine(stack) + except Exception as e: + printerr(e) def set_quit(self): """ @@ -562,16 +581,13 @@ try: return self._fnCache[fn] except KeyError: - if fn and fn != frame.f_code.co_filename: - absFilename = os.path.abspath(fn) - if absFilename.endswith(('.pyc', '.pyo')): - fixedName = absFilename[:-1] - if not os.path.exists(fixedName): - fixedName = absFilename - else: + absFilename = os.path.abspath(fn) + if absFilename.endswith(('.pyc', '.pyo')): + fixedName = absFilename[:-1] + if not os.path.exists(fixedName): fixedName = absFilename else: - fixedName = frame.f_code.co_filename + fixedName = absFilename # update cache self._fnCache[fn] = fixedName return fixedName @@ -792,12 +808,16 @@ filename = excval.filename lineno = excval.lineno charno = excval.offset - - if charno is None: - charno = 0 - filename = os.path.abspath(filename) - realSyntaxError = os.path.exists(filename) + if filename is None: + realSyntaxError = False + else: + if charno is None: + charno = 0 + + filename = os.path.abspath(filename) + realSyntaxError = os.path.exists(filename) + except (AttributeError, ValueError): message = "" filename = ""