]> git.sthu.org Git - pygdb.git/commitdiff
step out button
authorStefan Huber <shuber2@gmail.com>
Fri, 13 Jun 2008 15:01:06 +0000 (17:01 +0200)
committerStefan Huber <shuber2@gmail.com>
Fri, 13 Jun 2008 15:01:06 +0000 (17:01 +0200)
DbgTerminal.py
GdbTerminal.py
MainControlWindow.py
PositionFrame.py
featurerequest.txt

index 5c5cbd2968e0c7ae1de392087f857e5f2a7aa5b2..ab365deb4245bde09116810e2ecdea9c84cbe779 100644 (file)
@@ -199,6 +199,9 @@ class DbgTerminal (vte.Terminal):
        def setStepin(self):
                raise NotImplementedError()
 
+       def setStepout(self):
+               raise NotImplementedError()
+
        def setQuit(self):
                raise NotImplementedError()
 
index 5be9c05fd165108449fd97150b6712762ee67350..6218d64780e18e7b2e0f515e3ecf7d90bd34ac3a 100644 (file)
@@ -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
 
index 0b5c3f11413e36067c55c373fbb625a63d20d8ca..f5f47cd5472cf18345a52124ad453c1887c66848 100644 (file)
@@ -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)
 
index 985dccf914ceab57107520b17eca20515c2d0aaf..0eb49f34bd3e15c71c49ae774cf7db6a4cad4a24 100644 (file)
@@ -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)
 
 
index f511ca7981466d4f4286a144331b3083ea70ed26..bd8e9413b67b3b15a531a322f2b6436a5cab7402 100644 (file)
@@ -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: