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):
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, \
"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):
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)
#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()
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)
-
-
-def launchDebugger(wnd, term):
-
- wnd.toggleClientIOWindow()
-
- term.setBreakpoint("main.cpp", 15)
- term.setRun()
- res = term.getExpression("a")
- print "Result = ", res
-
- term.setQuit()
-
-
-
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
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)
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)
dbgterm = GdbTerminal(string.join(sys.argv[1:]))
dbgwnd = DbgTerminal.DbgWindow(dbgterm)
- DbgTerminal.launchDebugger(dbgwnd, dbgterm)
gtk.main()
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")
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)
#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()