From 32cf025183d25d3ab1f8e398ef391f6b3616d980 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Fri, 13 Jun 2008 17:01:06 +0200 Subject: [PATCH] step out button --- DbgTerminal.py | 3 +++ GdbTerminal.py | 26 +++++++++++++++++++++----- MainControlWindow.py | 8 ++++++++ PositionFrame.py | 2 +- featurerequest.txt | 1 - 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/DbgTerminal.py b/DbgTerminal.py index 5c5cbd2..ab365de 100644 --- a/DbgTerminal.py +++ b/DbgTerminal.py @@ -199,6 +199,9 @@ class DbgTerminal (vte.Terminal): def setStepin(self): raise NotImplementedError() + def setStepout(self): + raise NotImplementedError() + def setQuit(self): raise NotImplementedError() diff --git a/GdbTerminal.py b/GdbTerminal.py index 5be9c05..6218d64 100644 --- a/GdbTerminal.py +++ b/GdbTerminal.py @@ -36,6 +36,22 @@ class GdbTerminal (DbgTerminal.DbgTerminal): def setStepin(self): self.feed_child("step\n"); + def setStepout(self): + bt = self.getBacktrace() + + if len(bt) < 2: + self.setContinue() + + else: + #Get the second line + sec = bt[1] + + #Check if it is a backtrace line + if re.compile("^#1\s+.*\s\S+:\d+$").search(sec): + pos = string.split(sec)[-1] + self.feed_child("advance %s\n" % pos) + + def setQuit(self): self.feed_child("quit\n") self.waitForNewline() @@ -129,12 +145,10 @@ class GdbTerminal (DbgTerminal.DbgTerminal): def listCodeSnippet(self): - answ = self.__getAnswerFromCmd("list\n") - return string.join(answ, "\n") + return self.__getAnswerFromCmd("list\n") def getBacktrace(self): - answ = self.__getAnswerFromCmd("bt\n") - return string.join(answ, "\n") + return self.__getAnswerFromCmd("bt\n") def waitForPrompt(self, his): rx = "^\(gdb\)" @@ -186,10 +200,12 @@ class GdbTerminal (DbgTerminal.DbgTerminal): return "continued", None if string.find(line, "\x1a\x1a") == 0: - rxcont = re.compile("^\(gdb\)\s+(cont|step|next|stepi|nexti)") + rxcont = re.compile("^\(gdb\)\s+(cont|step|next|stepi|nexti|advance)") if rxcont.search(self.history[his-1]): return "stepped", None + if rxcont.search(self.history[his-2]): + return "stepped", None return None diff --git a/MainControlWindow.py b/MainControlWindow.py index 0b5c3f1..f5f47cd 100644 --- a/MainControlWindow.py +++ b/MainControlWindow.py @@ -51,6 +51,8 @@ class MainControlWindow (gtk.Window): hbtnbox.add(self.stepoverBtn) self.stepinBtn = gtk.Button("Step In") hbtnbox.add(self.stepinBtn) + self.stepoutBtn = gtk.Button("Step Out") + hbtnbox.add(self.stepoutBtn) self.quitBtn = gtk.Button("Quit") hbtnbox.add(self.quitBtn) @@ -68,6 +70,7 @@ class MainControlWindow (gtk.Window): self.stepoverBtnHandler = self.stepoverBtn.connect('clicked', \ self.stepoverBtnClicked) self.stepinBtnHandler = self.stepinBtn.connect('clicked', self.stepinBtnClicked) + self.stepoutBtnHandler = self.stepoutBtn.connect('clicked', self.stepoutBtnClicked) self.quitBtnHandler = self.quitBtn.connect('clicked', self.quitBtnClicked) #Show the window @@ -87,6 +90,9 @@ class MainControlWindow (gtk.Window): def stepinBtnClicked(self, btn): pos = self.dbgterm.setStepin() + def stepoutBtnClicked(self, btn): + pos = self.dbgterm.setStepout() + def quitBtnClicked(self, btn): self.dbgterm.setQuit() @@ -95,6 +101,7 @@ class MainControlWindow (gtk.Window): self.continueBtn.handler_block(self.continueBtnHandler) self.stepoverBtn.handler_block(self.stepoverBtnHandler) self.stepinBtn.handler_block(self.stepinBtnHandler) + self.stepoutBtn.handler_block(self.stepoutBtnHandler) self.quitBtn.handler_block(self.quitBtnHandler) def enableButtons(self, *w): @@ -102,5 +109,6 @@ class MainControlWindow (gtk.Window): self.continueBtn.handler_unblock(self.continueBtnHandler) self.stepoverBtn.handler_unblock(self.stepoverBtnHandler) self.stepinBtn.handler_unblock(self.stepinBtnHandler) + self.stepoutBtn.handler_unblock(self.stepoutBtnHandler) self.quitBtn.handler_unblock(self.quitBtnHandler) diff --git a/PositionFrame.py b/PositionFrame.py index 985dccf..0eb49f3 100644 --- a/PositionFrame.py +++ b/PositionFrame.py @@ -78,7 +78,7 @@ class PositionFrame (StatusFrame.StatusFrame): self.positionLabel.set_label("%s:%d" % (self.file, self.lineno)) #Get some code - code = self.debugger.getBacktrace() + code = string.join(self.debugger.getBacktrace(), "\n") buf.set_text(code) diff --git a/featurerequest.txt b/featurerequest.txt index f511ca7..bd8e941 100644 --- a/featurerequest.txt +++ b/featurerequest.txt @@ -13,7 +13,6 @@ Smaller requests Medium requestes: - Deactivate breakpoints - Hightlight current line in little source field - - Button for step out of function ('bt', followed by 'advance') Bigger requests: - bidirectional, immediate communication with vim: -- 2.39.5