- stopping gdb in any case...
import pango
import pty
import string
import pango
import pty
import string
isactive = True
lastrow = 0
history = []
isactive = True
lastrow = 0
history = []
- def __init__(self, clientCmd):
+ def __init__(self, clientCmd, exitcb=None):
vte.Terminal.__init__(self)
vte.Terminal.__init__(self)
+ def onChildExited():
+ self.childpid = None
+ if exitcb != None:
+ exitcb()
+
#Start debugger
self.clientCmd = clientCmd
#Open pseudo-terminal where to-be-debugged process reads/writes to
#Start debugger
self.clientCmd = clientCmd
#Open pseudo-terminal where to-be-debugged process reads/writes to
#Set up terminal window and initialize debugger
self.connect("cursor-moved", self.contents_changed)
#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")
#font description
fontdesc = pango.FontDescription("monospace 9")
- self.fork_command( self.getCommand(), self.getArgv())
+ self.childpid = self.fork_command( self.getCommand(), self.getArgv())
self.setPty(self.client_ptyslave)
self.waitForActivation()
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):
c,r = term.get_cursor_position()
def contents_changed(self, term):
c,r = term.get_cursor_position()
class GdbTerminal (DbgTerminal.DbgTerminal):
class GdbTerminal (DbgTerminal.DbgTerminal):
- def __init__(self, clientCmd):
- DbgTerminal.DbgTerminal.__init__(self, clientCmd)
+ def __init__(self, clientCmd, exitcb=None):
+ DbgTerminal.DbgTerminal.__init__(self, clientCmd, exitcb)
def getArgv(self):
return ["gdb", "--fullname", string.split(self.clientCmd)[0]]
def getArgv(self):
return ["gdb", "--fullname", string.split(self.clientCmd)[0]]
#Callbacks for new positions
newPosCbs = []
#Callbacks for new positions
newPosCbs = []
- def __init__(self, dbgterm, quitonclose=True):
+ def __init__(self, dbgterm, closecb=None):
#Set up GTK stuff
gtk.Window.__init__(self)
#Set up GTK stuff
gtk.Window.__init__(self)
- if quitonclose:
- self.connect("destroy", lambda *w: gtk.main_quit() )
+
+ if closecb!=None:
+ self.connect("destroy", lambda *w: closecb() )
#Set terminals
self.dbgterm = dbgterm
#Set terminals
self.dbgterm = dbgterm
class StatusWindow (gtk.Window):
class StatusWindow (gtk.Window):
- def __init__(self, mainctrlwnd, debugger, quitonclose=True):
+ def __init__(self, mainctrlwnd, debugger, closecb=None):
gtk.Window.__init__(self)
self.set_screen(mainctrlwnd.get_screen())
gtk.Window.__init__(self)
self.set_screen(mainctrlwnd.get_screen())
self.set_title("Status")
self.set_default_size(400,600)
self.set_title("Status")
self.set_default_size(400,600)
- if quitonclose:
- self.connect("destroy", lambda *w: gtk.main_quit())
+ if closecb!=None:
+ self.connect("destroy", lambda *w: closecb())
#Register callback function for new positions
#Register callback function for new positions
__author__ = "shuber"
import gtk
__author__ = "shuber"
import gtk
-def launchDebugger(clientCmd):
+def launchDebugger(clientCmd, quitonclose=True):
+
+
+
+ def hideWindows():
+ #Kill the debugger
+ dbgterm.stopDbg()
+
+ mainCtrlWnd.destroy()
+ statusWnd.destroy()
+ gtk.main_quit()
+
+
+
+ #Determine the closing callback func
+ if quitonclose:
+ destroycb = gtk.main_quit
+ else:
+ destroycb = hideWindows
+
- dbgterm = GdbTerminal.GdbTerminal(clientCmd)
+ dbgterm = GdbTerminal.GdbTerminal(clientCmd, destroycb)
- mainCtrlWnd = MainControlWindow.MainControlWindow(dbgterm)
- statusWnd = StatusWindow.StatusWindow(mainCtrlWnd, dbgterm)
+ mainCtrlWnd = MainControlWindow.MainControlWindow(dbgterm, destroycb)
+ statusWnd = StatusWindow.StatusWindow(mainCtrlWnd, dbgterm, destroycb)
+ return dbgterm, mainCtrlWnd, statusWnd
#Create the terminals
clientCmd = string.join(sys.argv[1:])
launchDebugger(clientCmd)
#Create the terminals
clientCmd = string.join(sys.argv[1:])
launchDebugger(clientCmd)
#Do not use a ~ for home directory
sys.path.append("/home/shuber/projekte/pygdb/")
#Do not use a ~ for home directory
sys.path.append("/home/shuber/projekte/pygdb/")
import GdbTerminal
import MainControlWindow
import StatusWindow
import GdbTerminal
import MainControlWindow
import StatusWindow
if gdbterm == None:
clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd)
if gdbterm == None:
clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd)
- gdbterm = GdbTerminal.GdbTerminal(clientcmd)
- mainctrlwnd = MainControlWindow.MainControlWindow(gdbterm, quitonclose=False)
- statuswnd = StatusWindow.StatusWindow(mainctrlwnd, gdbterm, quitonclose=False)
- gdbterm.initialize()
+ gdbterm, mainctrlwnd, statuswnd = pygdb.launchDebugger(clientcmd, False)
for bp in gdbBps:
statuswnd.breakpointsFrame.addBreakpoint(bp["file"], bp["lineno"], bp["cond"])
gtk.main()
for bp in gdbBps:
statuswnd.breakpointsFrame.addBreakpoint(bp["file"], bp["lineno"], bp["cond"])
gtk.main()
- gtk.main()
- print "hello"
- #mainctrlwnd.hide()
- #statuswnd.hide()
def gdbToggleBreakpoint(lineno=None, file=None):
def gdbToggleBreakpoint(lineno=None, file=None):