X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=DbgTerminal.py;h=21aa1c42d790f4b1bc230be0e51c54715b627466;hb=054679cd2c3372717bf7982407e2453428193581;hp=69fa8339c61dc905e744390520dfb5fa5e5bdc77;hpb=0024f43ac5834f611179587a6fc25385ee5bf4a5;p=pygdb.git diff --git a/DbgTerminal.py b/DbgTerminal.py index 69fa833..21aa1c4 100644 --- a/DbgTerminal.py +++ b/DbgTerminal.py @@ -5,6 +5,8 @@ __author__ = "shuber" import gtk +import os +import pango import pty import string import time @@ -17,25 +19,46 @@ import ClientIOTerminal class DbgTerminal (vte.Terminal): + isactive = True lastrow = 0 history = [] + childpid = None - def __init__(self, clientCmd): + def __init__(self, clientCmd, exitcb=None): vte.Terminal.__init__(self) + def onChildExited(): + self.childpid = None + if exitcb != None: + exitcb() + #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()) + self.connect("child-exited", lambda *w: onChildExited()) + + #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: + os.kill(self.childpid, 15); + self.childpid = None + def contents_changed(self, term): @@ -110,23 +133,26 @@ class DbgTerminal (vte.Terminal): def setQuit(self): raise NotImplementedError() - def setBreakpoint(self, file, lineno): + def setBreakpoint(self, file, lineno, condition=False): raise NotImplementedError() - def getExpression(self, expr): + def delBreakpoint(self, breakpoint): raise NotImplementedError() - def getLastLine(self): - if len(self.history) == 0: - return None + def getExpression(self, expr): + raise NotImplementedError() - return self.history[-1] + def waitForActivation(self, his): + raise NotImplementedError() - def feed_dbg(self, text): - self.feed_child(text) + def setActive(self, isactive): + self.isactive = isactive + def isActive(self): + return self.isactive + @@ -166,17 +192,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() - - -