return self.__getAnswerFromCmd("list\n")
def getBacktrace(self):
- return self.__getAnswerFromCmd("bt\n")
+
+ stack = []
+ answ = self.__getAnswerFromCmd("bt\n")
+
+ rxstartfull = re.compile("^\#\d+\s+0x[0-9a-f]+\s+in\s+\S+\s+\(")
+ rxstartshort = re.compile("^\#\d+\s+\S+\s+\(")
+ rxpos = re.compile("at \S+:\d+$")
+
+ try:
+
+ i=0
+ while i<len(answ):
+ line = answ[i]
+
+ while not rxstartfull.search(line) and not rxstartshort.search(line):
+ print "Warning: '", line, "' does not match bt entry."
+ i+=1
+ line = answ[i]
+
+ parts = line.split()
+
+ if rxstartfull.search(line):
+ func = parts[3]
+ addr = parts[1]
+ else:
+ func = parts[1]
+ addr = None
+
+
+ #Search for file position
+ while not rxpos.search(line):
+ print "Warning: '", line, "' does not match file pos marker."
+ i+=1
+ line = answ[i]
+
+ parts = line.split()
+ pos = parts[-1]
+ [file,lineno] = pos.split(":")
+
+ stack += [[addr,func,file,lineno]]
+
+ i+=1
+
+ except IndexError:
+ pass
+
+ return stack
def waitForPrompt(self, his):
rx = "^\(gdb\)"
class PositionFrame (StatusFrame.StatusFrame):
- def __init__(self, debugger):
+ def __init__(self, debugger, statuswnd):
StatusFrame.StatusFrame.__init__(self, debugger)
self.set_label("Position")
+ self.statuswnd = statuswnd
debugger.gotActiveCallback += [self.updateValues]
debugger.gotInactiveCallback += [self.updateValues]
self.file = None
+ self.bt = None
self.lineno = 0
vbox = gtk.VBox(False, 5)
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
vbox.add(sw)
- self.srcview = gtk.TextView()
- sw.add(self.srcview)
+ self.model = self.__createModel()
+ self.tv = gtk.TreeView(self.model)
+ self.tv.set_rules_hint(True)
+ self.tv.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
+ self.tv.connect("row-activated", self.rowactivated)
+
+ self.__addColumns(self.tv)
+ sw.add(self.tv)
self.openBtn.connect("clicked", self.openBtnClicked)
+ def __createModel(self):
+ model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, \
+ gobject.TYPE_STRING, gobject.TYPE_STRING)
+
+ return model
+
+
+ def __addColumns(self, tv):
+
+ model = tv.get_model()
+
+ renderer = gtk.CellRendererText()
+ renderer.set_data("column", 0)
+ col = gtk.TreeViewColumn("Addr", renderer, text=0)
+ col.set_resizable(True)
+ tv.append_column(col)
+
+ renderer = gtk.CellRendererText()
+ renderer.set_data("column", 1)
+ col = gtk.TreeViewColumn("Func", renderer, text=1)
+ col.set_resizable(True)
+ tv.append_column(col)
+
+ renderer = gtk.CellRendererText()
+ renderer.set_data("column", 2)
+ col = gtk.TreeViewColumn("File", renderer, text=2)
+ col.set_resizable(True)
+ tv.append_column(col)
+
+ renderer = gtk.CellRendererText()
+ renderer.set_data("column", 3)
+ col = gtk.TreeViewColumn("Lin", renderer, text=3)
+ col.set_resizable(True)
+ tv.append_column(col)
+
+
def openBtnClicked(self, btn):
if not self.debugger.isActive():
dialog.destroy()
+ def rowactivated(self, tv, path, col, *w):
+ no, = path
+ no = int(no)
+ entry = self.bt[no]
+ self.statuswnd.gotoVim(entry[2], entry[3])
+
+
+
def updateValues(self, status, param):
- #Create new text buffer for source view
- buf = gtk.TextBuffer()
- if status == "break":
+ #Remove them all
+ iter = self.model.get_iter_first()
+ while iter != None:
+ newiter = self.model.iter_next(iter)
+ self.model.remove(iter)
+ iter = newiter
+
+
+ if status == "break":
+
+
+ #Set current file position
self.file, self.lineno = param
self.positionLabel.set_label("%s:%d" % (self.file, self.lineno))
- #Get some code
- code = string.join(self.debugger.getBacktrace(), "\n")
- buf.set_text(code)
+ #Add the entries
+ self.bt = self.debugger.getBacktrace()
+ for [addr, func, file, lineno] in self.bt:
+ iter = self.model.append()
+
+ if addr!=None:
+ self.model.set(iter, 0, addr)
+
+ self.model.set(iter, 1, func)
+ self.model.set(iter, 2, file)
+ self.model.set(iter, 3, lineno)
+
else:
self.file, self.lineno = None, None
+ self.bt = None
code = ""
if status == "exited":
self.positionLabel.set_label(status)
- #Set the buffer
- self.srcview.set_buffer(buf)
-
-
def applyConfiguration(self, conf):