Sat, 25 Mar 2017 17:18:12 +0100
Merged with debugger changes done by Tobias.
--- a/DebugClients/Python/DebugBase.py Thu Mar 23 19:06:13 2017 +0100 +++ b/DebugClients/Python/DebugBase.py Sat Mar 25 17:18:12 2017 +0100 @@ -524,6 +524,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): """ @@ -789,12 +803,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 = ""
--- a/DebugClients/Python/DebugClientBase.py Thu Mar 23 19:06:13 2017 +0100 +++ b/DebugClients/Python/DebugClientBase.py Sat Mar 25 17:18:12 2017 +0100 @@ -223,9 +223,6 @@ self.variant = 'You should not see this' - # commandline completion stuff - self.complete = Completer(self.debugMod.__dict__).complete - self.compile_command = codeop.CommandCompiler() self.coding_re = re.compile(r"coding[:=]\s*([-\w_.]+)") @@ -726,6 +723,10 @@ self.set_quit() self.eventExit = True + elif method == "RequestMoveIP": + newLine = params["newLine"] + self.currentThreadExec.move_instruction_pointer(newLine) + elif method == "RequestContinue": self.currentThreadExec.go(params["special"]) self.eventExit = True @@ -1778,7 +1779,20 @@ self.__getCompletionList(text, localCompleter, completions) except AttributeError: pass - self.__getCompletionList(text, self.complete, completions) + + cf = self.currentThread.getCurrentFrame() + frmnr = self.framenr + while cf is not None and frmnr > 0: + cf = cf.f_back + frmnr -= 1 + + if cf is None: + globaldict = self.debugMod.__dict__ + else: + globaldict = cf.f_globals + + globalCompleter = Completer(globaldict).complete + self.__getCompletionList(text, globalCompleter, completions) self.sendJsonCommand("ResponseCompletion", { "completions": list(completions),
--- a/Debugger/DebugServer.py Thu Mar 23 19:06:13 2017 +0100 +++ b/Debugger/DebugServer.py Sat Mar 25 17:18:12 2017 +0100 @@ -996,6 +996,14 @@ """ self.debuggerInterface.remoteContinue(special) + def remoteMoveIP(self, line): + """ + Public method to move the instruction pointer to a different line. + + @param line the new line, where execution should be continued + """ + self.debuggerInterface.remoteMoveIP(line) + def remoteBreakpoint(self, fn, line, setBreakpoint, cond=None, temp=False): """ Public method to set or clear a breakpoint.
--- a/Debugger/DebugUI.py Thu Mar 23 19:06:13 2017 +0100 +++ b/Debugger/DebugUI.py Sat Mar 25 17:18:12 2017 +0100 @@ -109,7 +109,7 @@ self.lastAction = -1 self.debugActions = [ self.__continue, self.__step, self.__stepOver, self.__stepOut, - self.__stepQuit, self.__runToCursor + self.__stepQuit, self.__runToCursor, self.__moveInstructionPointer ] self.localsVarFilter, self.globalsVarFilter = \ Preferences.getVarFilters() @@ -357,6 +357,26 @@ )) act.triggered.connect(self.__runToCursor) self.actions.append(act) + + act = E5Action( + self.tr('Move Instruction Pointer to Cursor'), + UI.PixmapCache.getIcon("moveInstructionPointer.png"), + self.tr('&Jump To Cursor'), Qt.Key_F12, 0, + self.debugActGrp, 'dbg_jump_to_cursor') + act.setStatusTip(self.tr( + """Skip the code from the""" + """ current line to the current cursor position""")) + act.setWhatsThis(self.tr( + """<b>Move Instruction Pointer to Cursor</b>""" + """<p>Move the Python internal instruction pointer to the""" + """ current cursor position without executing the code in""" + """ between.</p>""" + """<p>It's not possible to jump out of a function or jump""" + """ in a code block, e.g. a loop. In these cases, a error""" + """ message is printed to the log window.<p>""" + )) + act.triggered.connect(self.__moveInstructionPointer) + self.actions.append(act) act = E5Action( self.tr('Single Step'), @@ -2215,7 +2235,16 @@ self.debugServer.remoteBreakpoint( aw.getFileName(), line, 1, None, 1) self.debugServer.remoteContinue() - + + def __moveInstructionPointer(self): + """ + Private method to move the instruction pointer to a different line. + """ + self.lastAction = 0 + aw = self.viewmanager.activeWindow() + line = aw.getCursorPosition()[0] + 1 + self.debugServer.remoteMoveIP(line) + def __enterRemote(self): """ Private method to update the user interface.
--- a/Debugger/DebuggerInterfaceNone.py Thu Mar 23 19:06:13 2017 +0100 +++ b/Debugger/DebuggerInterfaceNone.py Sat Mar 25 17:18:12 2017 +0100 @@ -210,6 +210,14 @@ """ return + def remoteMoveIP(self, line): + """ + Public method to move the instruction pointer to a different line. + + @param line the new line, where execution should be continued + """ + return + def remoteBreakpoint(self, fn, line, setBreakpoint, cond=None, temp=False): """ Public method to set or clear a breakpoint.
--- a/Debugger/DebuggerInterfacePython2.py Thu Mar 23 19:06:13 2017 +0100 +++ b/Debugger/DebuggerInterfacePython2.py Sat Mar 25 17:18:12 2017 +0100 @@ -563,6 +563,16 @@ "special": special, }) + def remoteMoveIP(self, line): + """ + Public method to move the instruction pointer to a different line. + + @param line the new line, where execution should be continued + """ + self.__sendJsonCommand("RequestMoveIP", { + "newLine": line, + }) + def remoteBreakpoint(self, fn, line, setBreakpoint, cond=None, temp=False): """ Public method to set or clear a breakpoint.
--- a/Debugger/DebuggerInterfacePython3.py Thu Mar 23 19:06:13 2017 +0100 +++ b/Debugger/DebuggerInterfacePython3.py Sat Mar 25 17:18:12 2017 +0100 @@ -563,6 +563,16 @@ "special": special, }) + def remoteMoveIP(self, line): + """ + Public method to move the instruction pointer to a different line. + + @param line the new line, where execution should be continued + """ + self.__sendJsonCommand("RequestMoveIP", { + "newLine": line, + }) + def remoteBreakpoint(self, fn, line, setBreakpoint, cond=None, temp=False): """ Public method to set or clear a breakpoint.
--- a/changelog Thu Mar 23 19:06:13 2017 +0100 +++ b/changelog Sat Mar 25 17:18:12 2017 +0100 @@ -7,6 +7,11 @@ and generators to the code style checker -- added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored +- Debugger + -- shell autocompleter takes the right global variables into account now + -- move the instruction pointer within the current function (Hotkey: F12) + -- report syntax and indentation errors raised by an application or module + in the correct manner - Mercurial Interface -- extended the user configuration dialog