- Fixed bug when bp is set on same addr
[pygdb.git] / DbgTerminal.py
index c8b079fe18491567865c0d86c4c2ca9e39902e6b..8beec4652f97750b6a553710185b6c92b5295e37 100644 (file)
@@ -5,6 +5,8 @@ __author__ = "shuber"
 
 
 import gtk
+import os
+import pango
 import pty
 import string
 import time
@@ -17,27 +19,43 @@ import ClientIOTerminal
 
 class DbgTerminal (vte.Terminal):
 
-       isactive = True
-       lastrow = 0
-       history = []
-
-
        def __init__(self, clientCmd):
 
                vte.Terminal.__init__(self)
 
+               #Set members
+               self.childpid = None
+               self.history = []
+               self.lastrow = 0
+               self.isactive = True
+
                #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):
+               self.childpid = self.fork_command( self.getCommand(), self.getArgv())
+               self.setPty(self.client_ptyslave)
+               self.waitForActivation()
+
+       def stopDbg(self):
+
+               if self.childpid != None:
+                       #9=KILL, 15=TERM
+                       os.kill(self.childpid, 15);
+                       self.childpid = None
+
+
 
        def contents_changed(self, term):
                c,r = term.get_cursor_position()
@@ -111,7 +129,10 @@ class DbgTerminal (vte.Terminal):
        def setQuit(self):
                raise NotImplementedError()
 
-       def setBreakpoint(self, file, lineno):
+       def setBreakpoint(self, file, lineno, condition=False):
+               raise NotImplementedError()
+
+       def delBreakpoint(self, breakpoint):
                raise NotImplementedError()
 
        def getExpression(self, expr):
@@ -126,15 +147,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)
-
        
        
 
@@ -176,17 +188,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()
-
-
-