]> git.sthu.org Git - pygdb.git/commitdiff
added watches and status line
authorStefan Huber <shuber2@gmail.com>
Sun, 8 Jun 2008 13:20:25 +0000 (15:20 +0200)
committerStefan Huber <shuber2@gmail.com>
Sun, 8 Jun 2008 13:30:54 +0000 (15:30 +0200)
DbgTerminal.py
GdbTerminal.py
MainControlWindow.py
StatusWindow.py [new file with mode: 0644]
WatchesFrame.py [new file with mode: 0644]

index 69fa8339c61dc905e744390520dfb5fa5e5bdc77..c8b079fe18491567865c0d86c4c2ca9e39902e6b 100644 (file)
@@ -17,6 +17,7 @@ import ClientIOTerminal
 
 class DbgTerminal (vte.Terminal):
 
+       isactive = True
        lastrow = 0
        history = []
 
@@ -116,6 +117,15 @@ class DbgTerminal (vte.Terminal):
        def getExpression(self, expr):
                raise NotImplementedError()
 
+       def waitForActivation(self, his):               
+               raise NotImplementedError()
+
+       def setActive(self, isactive):
+               self.isactive = isactive
+
+       def isActive(self):
+               return self.isactive
+
        def getLastLine(self):
                if len(self.history) == 0:
                        return None
@@ -125,7 +135,7 @@ class DbgTerminal (vte.Terminal):
        def feed_dbg(self, text):
                self.feed_child(text)
 
-
+       
        
 
 
index 12256c1d0066e73b4d1f80dc69afbceae38f1cc8..bcd857ac5ef5428fdc0fc435a57a0cba5d8b7047 100755 (executable)
@@ -32,23 +32,23 @@ class GdbTerminal (DbgTerminal.DbgTerminal):
                his = self.getHistoryLen()
                argv = string.join(string.split(self.clientCmd)[1:])
                self.feed_dbg("run " + argv + "\n")
-               return self.waitForPosition(his)
+               return self.waitForActivation(his)
 
 
        def setContinue(self):
                his = self.getHistoryLen()
                self.feed_dbg("cont\n");
-               return self.waitForPosition(his)
+               return self.waitForActivation(his)
 
        def setStepover(self):
                his = self.getHistoryLen()
                self.feed_dbg("next\n");
-               return self.waitForPosition(his)
+               return self.waitForActivation(his)
 
        def setStepin(self):
                his = self.getHistoryLen()
                self.feed_dbg("step\n");
-               return self.waitForPosition(his)
+               return self.waitForActivation(his)
 
        def setQuit(self):
                self.feed_dbg("quit\n")
@@ -63,16 +63,24 @@ class GdbTerminal (DbgTerminal.DbgTerminal):
                his = self.getHistoryLen()
                self.feed_dbg("print " + expr + "\n")
 
-               rx = re.compile("^\$[1-9][0-9]* = .*$")
+               rx = re.compile("^\(gdb\) $")
                his, response = self.waitForRx(rx, his)
 
-               split = string.split(response, "=")
+               answer = self.history[his-1]
+
+               if len(string.split(answer, "=")) == 1:
+                       return answer.strip()
+
+               split = string.split(answer, "=")
                return string.join(split[1:], "=").strip()
 
 
-       def waitForPosition(self, his):
+       def waitForActivation(self, his):
+
+               self.setActive(False)
                rx = re.compile("^\(gdb\) $")
                his, reponse = self.waitForRx(rx,his)
+               self.setActive(True)
 
                if self.history[his-1][0:2]=="\x1a\x1a":
                        tuples = string.split(self.history[his-1][2:], ":")
index d82baaf760ebe069695b14c5b5833fb5cd7c2dd0..55bff28ce698ae6eb83329dccd63da2dd3f36690 100755 (executable)
@@ -132,15 +132,16 @@ class MainControlWindow (gtk.Window):
 
 if __name__ == "__main__":
 
-       def newpos(pos):
-               print "new pos: ", pos
+
+       import StatusWindow
 
 
        clientCmd = string.join(sys.argv[1:])
        dbgterm = GdbTerminal.GdbTerminal(clientCmd)
        mainCtrlWnd = MainControlWindow(dbgterm)
 
-       mainCtrlWnd.newPosCbs += [newpos]
+       statusWnd = StatusWindow.StatusWindow(mainCtrlWnd, dbgterm)
+       mainCtrlWnd.newPosCbs += [statusWnd.updateValues]
 
        gtk.main()
 
diff --git a/StatusWindow.py b/StatusWindow.py
new file mode 100644 (file)
index 0000000..a97e625
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+#shuber, 2008-06-04
+
+__author__ = "shuber"
+
+
+import gtk
+import vte
+
+import WatchesFrame
+
+
+class StatusWindow (gtk.Window):
+
+       def __init__(self, parent, debugger):
+
+               gtk.Window.__init__(self)
+               self.set_screen(parent.get_screen())
+
+               self.set_border_width(5)
+               self.set_title("Status")
+               self.set_default_size(400,400)
+
+
+               vbox = gtk.VBox(False, 5)
+               self.add(vbox)
+
+               self.status = gtk.Label("Not Running")
+               vbox.pack_start(self.status, False, False)
+               vpaned = gtk.VPaned()
+               vbox.add(vpaned)
+
+               self.watchesFrame = WatchesFrame.WatchesFrame(debugger)
+               vpaned.add1(self.watchesFrame)
+
+               self.show_all()
+
+
+       def updateValues(self, pos):
+
+               if pos == None:
+                       self.status.set_text("Exited")
+               else:
+                       file, lineno = pos
+                       self.status.set_text("%s:%s" % (file, lineno))
+
+               self.watchesFrame.updateValues()
+
+
diff --git a/WatchesFrame.py b/WatchesFrame.py
new file mode 100644 (file)
index 0000000..823f79f
--- /dev/null
@@ -0,0 +1,118 @@
+#!/usr/bin/python
+#shuber, 2008-06-04
+
+__author__ = "shuber"
+
+
+import gobject
+import gtk
+import vte
+
+import DbgTerminal
+
+
+class WatchesFrame (gtk.Frame):
+
+
+       def __init__(self, debugger):
+
+               gtk.Frame.__init__(self, "Watches")
+               self.debugger = debugger
+
+               vbox = gtk.VBox(False, 5)
+               self.add(vbox)
+
+               hbox = gtk.HButtonBox()
+               vbox.pack_start(hbox, False, False)
+               
+               self.addBtn = gtk.Button(stock=gtk.STOCK_ADD)
+               self.delBtn = gtk.Button(stock=gtk.STOCK_REMOVE)
+               hbox.add(self.addBtn)
+               hbox.add(self.delBtn)
+               hbox.set_layout(gtk.BUTTONBOX_SPREAD)
+
+               sw = gtk.ScrolledWindow()
+               sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
+               sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+               vbox.add(sw)
+
+               self.model = self.__createModel()
+               self.tv = gtk.TreeView(self.model)
+               self.tv.set_rules_hint(True)
+               self.tv.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
+
+               self.__addColumns(self.tv)      
+               sw.add(self.tv)
+
+               self.addBtn.connect("clicked", self.addBtnClicked)
+               self.delBtn.connect("clicked", self.delBtnClicked)
+
+
+
+       def __createModel(self):
+       
+               model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, \
+                               gobject.TYPE_BOOLEAN)
+
+               return model
+
+
+       def __addColumns(self, tv):
+
+               model = tv.get_model()
+
+               renderer = gtk.CellRendererText()
+               renderer.connect("edited", self.onExprEdited, model)
+               renderer.set_data("column", 0)
+               col = gtk.TreeViewColumn("Expr", renderer, text=0, editable=2)
+               col.set_resizable(True)
+               tv.append_column(col)
+
+
+               renderer = gtk.CellRendererText()
+               renderer.set_data("column", 1)
+               col = gtk.TreeViewColumn("Result", renderer, text=1)
+               col.set_resizable(True)
+               tv.append_column(col)
+
+
+       def onExprEdited(self, cell, pathStr, expr, model):
+               iter = model.get_iter_from_string(pathStr)
+               path = model.get_path(iter)[0]
+               col = cell.get_data("column")
+
+               model.set(iter, 0, expr)
+
+               if self.debugger.isActive():
+                       res = self.debugger.getExpression(expr)
+                       model.set(iter, 1, res)
+
+
+
+
+       def addBtnClicked(self, btn):
+               iter = self.model.append()
+               self.model.set(iter, 0, "0", 1, "0", 2, True)
+
+
+       def delBtnClicked(self, btn):
+               selection = self.tv.get_selection()
+               model, paths = selection.get_selected_rows()
+
+               for path in paths:
+                       iter = model.get_iter(path)
+                       model.remove(iter)
+
+
+       def updateValues(self):
+
+               iter = self.model.get_iter_first()
+
+               while iter != None:
+
+                       expr, = self.model.get(iter, 0)
+                        res = self.debugger.getExpression(expr)
+                        self.model.set(iter, 1, res)
+
+                       iter = self.model.iter_next(iter)
+