- fixing ssh problem
authorStefan Huber <shuber2@gmail.com>
Mon, 9 Jun 2008 10:01:24 +0000 (12:01 +0200)
committerStefan Huber <shuber2@gmail.com>
Mon, 9 Jun 2008 10:01:24 +0000 (12:01 +0200)
- some minor changes
- added addBreakpoint function for external usage

BreakpointsFrame.py
DbgTerminal.py
GdbTerminal.py
StatusWindow.py
pygdb.py

index 3216de661c4ed21ae8b55730a2a7003e7bf8bb31..9b709b403ea610f9721b841f1a1fb427ef75a079 100644 (file)
@@ -92,7 +92,8 @@ class BreakpointsFrame (gtk.Frame):
 
 
                bpspec = self.bpEntry.get_text()
-               rx = re.compile("^[\w\._\-]+:\d+\s*(\sif\s+\S+.*)?$")
+               bpspec = bpspec.strip()
+               rx = re.compile("^[\w\._\-]+:\d+(\s+if\s+\S+.*)?$")
 
                #Check if format is correct
                if not rx.search(bpspec):
@@ -115,12 +116,16 @@ class BreakpointsFrame (gtk.Frame):
                pos = ifsplit[0].strip()        
                [file,lineno] = string.split(pos, ":")
 
-               pos = self.debugger.setBreakpoint(file, lineno, cond)
+               self.addBreakpoint(file, lineno, cond)
+       
+
+
+       def addBreakpoint(self, file, lineno, cond=None):
 
-               if pos!=None:
-                       iter = self.model.append()
-                       self.model.set(iter, 0, pos)
-                       self.model.set(iter, 1, bpspec)
+               no = self.debugger.setBreakpoint(file, lineno, cond)
+
+               if no!=None:
+                       self.addBreakpointToList(no, file, lineno, cond)
                else:
                        dialog = gtk.MessageDialog(None, \
                                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \
@@ -128,10 +133,19 @@ class BreakpointsFrame (gtk.Frame):
                                "Invalid specification!") 
                        dialog.run()
                        dialog.destroy()
-                       return
 
 
 
+       def addBreakpointToList(self, no, file, lineno, cond=None):
+               iter = self.model.append()
+               self.model.set(iter, 0, no)
+
+               if cond==None:
+                       self.model.set(iter, 1, "%s:%s" % (str(file), str(lineno)))
+               else:
+                       self.model.set(iter, 1, "%s:%s if %s" % (str(file), str(lineno), str(cond)))
+
+
 
        def delBtnClicked(self, btn):
 
@@ -169,13 +183,7 @@ class BreakpointsFrame (gtk.Frame):
 
                for bp in bpnts:
                        [no, file, lineno, cond] = bp
-                       iter = self.model.append()
-                       self.model.set(iter, 0, no)
-
-                       if cond==None:
-                               self.model.set(iter, 1, "%s:%s" % (file, lineno))
-                       else:
-                               self.model.set(iter, 1, "%s:%s if %s" % (file, lineno, cond))
+                       self.addBreakpointToList(no, file, lineno, cond)
 
 
        
index 605c2b79612823a92f4955f935517737b142f856..8cdc932abfbeda71402a10a1d0ddd985582e9e75 100644 (file)
@@ -29,20 +29,23 @@ class DbgTerminal (vte.Terminal):
 
                #Start debugger
                self.clientCmd = clientCmd
-               self.fork_command( self.getCommand(), self.getArgv())
-
                #Open pseudo-terminal where to-be-debugged process reads/writes to
                self.client_ptymaster, self.client_ptyslave = pty.openpty()
-               self.setPty(self.client_ptyslave)
 
                #Set up terminal window and initialize debugger
                self.connect("cursor-moved", self.contents_changed)
                self.connect("child-exited", lambda *w: gtk.main_quit())
 
+               #font description
                fontdesc = pango.FontDescription("monospace 9")
                self.set_font(fontdesc)
 
 
+       def initialize(self):
+               #Launch debugger
+               self.fork_command( self.getCommand(), self.getArgv())
+               self.setPty(self.client_ptyslave)
+
 
        def contents_changed(self, term):
                c,r = term.get_cursor_position()
@@ -134,15 +137,6 @@ class DbgTerminal (vte.Terminal):
        def isActive(self):
                return self.isactive
 
-       def getLastLine(self):
-               if len(self.history) == 0:
-                       return None
-
-               return self.history[-1]
-
-       def feed_dbg(self, text):
-               self.feed_child(text)
-
        
        
 
@@ -184,17 +178,3 @@ class DbgWindow (gtk.Window):
 
 
 
-
-def launchDebugger(wnd, term):
-
-       wnd.toggleClientIOWindow()
-
-       term.setBreakpoint("main.cpp", 15)
-       term.setRun()
-       res = term.getExpression("a")
-       print "Result = ", res
-
-       term.setQuit()
-
-
-
index 77d21e2f6e3fbffab0c3143214bca2ff1dd8db31..496e7c39ed2302c14ef9b83efd90fb7cb6400c89 100755 (executable)
@@ -25,54 +25,55 @@ class GdbTerminal (DbgTerminal.DbgTerminal):
 
        def setPty(self, pty):
                ttyname = os.ttyname(pty)
-               self.feed_dbg("set inferior-tty %s\n" % (ttyname,))
+               self.feed_child("set inferior-tty %s\n" % (ttyname,))
 
        def setRun(self):
 
                his = self.getHistoryLen()
                argv = string.join(string.split(self.clientCmd)[1:])
-               self.feed_dbg("run " + argv + "\n")
+               self.feed_child("run " + argv + "\n")
                return self.waitForActivation(his)
 
 
        def setContinue(self):
                his = self.getHistoryLen()
-               self.feed_dbg("cont\n");
+               self.feed_child("cont\n");
                return self.waitForActivation(his)
 
        def setStepover(self):
                his = self.getHistoryLen()
-               self.feed_dbg("next\n");
+               self.feed_child("next\n");
                return self.waitForActivation(his)
 
        def setStepin(self):
                his = self.getHistoryLen()
-               self.feed_dbg("step\n");
+               self.feed_child("step\n");
                return self.waitForActivation(his)
 
        def setQuit(self):
-               self.feed_dbg("quit\n")
+               self.feed_child("quit\n")
                self.waitForNewline()
-               self.feed_dbg("y\n");
+               self.feed_child("y\n");
 
        def setBreakpoint(self, file, lineno, condition=None):
                his = self.getHistoryLen()
                if condition==None:
-                       self.feed_dbg("break %s:%s\n" % (file, str(lineno)))
+                       self.feed_child("break %s:%s\n" % (file, str(lineno)))
                else:
-                       self.feed_dbg("break %s:%s if %s\n" % \
+                       self.feed_child("break %s:%s if %s\n" % \
                                        (file, str(lineno), condition))
 
                rx = re.compile("^Breakpoint |^No|^\(gdb\) ")
                his, response = self.waitForRx(rx, his)
 
+               print his, response
 
                if response[0:10] == "Breakpoint":
                        return string.split(response)[1].strip()
                if response[0:5] == "(gdb)":
                        return None
                if response[0:14] == "No source file":
-                       self.feed_dbg("n\n");
+                       self.feed_child("n\n");
                        return None
                if response[0:3] == "No ":
                        return None
@@ -80,11 +81,11 @@ class GdbTerminal (DbgTerminal.DbgTerminal):
                return NotImplementedError()
 
        def delBreakpoint(self, breakpoint):
-               self.feed_dbg("del breakpoint %s\n" % (breakpoint,))
+               self.feed_child("del breakpoint %s\n" % (breakpoint,))
 
        def getBreakpoints(self):
                starthis = self.getHistoryLen()
-               self.feed_dbg("info breakpoints\n")
+               self.feed_child("info breakpoints\n")
 
                rx = re.compile("^\(gdb\) ")
                endhis, response = self.waitForRx(rx, starthis)
@@ -128,7 +129,7 @@ class GdbTerminal (DbgTerminal.DbgTerminal):
        def getExpression(self, expr):
 
                his = self.getHistoryLen()
-               self.feed_dbg("print " + expr + "\n")
+               self.feed_child("print " + expr + "\n")
 
                rx = re.compile("^\(gdb\) $")
                his, response = self.waitForRx(rx, his)
@@ -163,7 +164,6 @@ if __name__ == "__main__":
        dbgterm = GdbTerminal(string.join(sys.argv[1:]))
        dbgwnd = DbgTerminal.DbgWindow(dbgterm)
 
-       DbgTerminal.launchDebugger(dbgwnd, dbgterm)
        gtk.main()
 
 
index 1eb486251471aa9d540a27b5108b67607f5d02fd..8614788666d65b5adb2d71b02cb77720aed0d24d 100644 (file)
@@ -13,10 +13,10 @@ import BreakpointsFrame
 
 class StatusWindow (gtk.Window):
 
-       def __init__(self, parent, debugger):
+       def __init__(self, mainctrlwnd, debugger):
 
                gtk.Window.__init__(self)
-               self.set_screen(parent.get_screen())
+               self.set_screen(mainctrlwnd.get_screen())
 
                self.set_border_width(5)
                self.set_title("Status")
@@ -24,6 +24,11 @@ class StatusWindow (gtk.Window):
                self.connect("destroy", lambda *w: gtk.main_quit())
 
 
+               #Register callback function for new positions
+               self.mainctrlwnd = mainctrlwnd
+               mainctrlwnd.newPosCbs += [self.updateValues]
+
+
                vbox = gtk.VBox(False, 5)
                self.add(vbox)
 
index 64c48df01fc383ffef040277475070f40b1c3949..be9ecb05444d1036c3fa9feaa35df6945f3e8daf 100755 (executable)
--- a/pygdb.py
+++ b/pygdb.py
@@ -19,10 +19,9 @@ def launchDebugger(clientCmd):
        #Create windows
        mainCtrlWnd = MainControlWindow.MainControlWindow(dbgterm)
        statusWnd = StatusWindow.StatusWindow(mainCtrlWnd, dbgterm)
+       dbgterm.initialize()
 
-       #Register callback function for new positions
-       mainCtrlWnd.newPosCbs += [statusWnd.updateValues]
-
+       print "run"
        gtk.main()