From: Stefan Huber Date: Fri, 4 Jul 2008 08:54:38 +0000 (+0200) Subject: - Changed backtrace view to a treeview X-Git-Tag: v0.99.4~1 X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=5b9048fcd21428e36a95bb21d0e2caf8eae61d10;p=pygdb.git - Changed backtrace view to a treeview - By double-clicking on a bt-entry vim jumps to position --- diff --git a/DbgTerminal.py b/DbgTerminal.py index a899a63..9d08866 100644 --- a/DbgTerminal.py +++ b/DbgTerminal.py @@ -100,6 +100,8 @@ class DbgTerminal (vte.Terminal): for cb in self.gotInactiveCallback: cb(status, param) except Exception, e: + import traceback + traceback.print_exc() print e return True diff --git a/GdbTerminal.py b/GdbTerminal.py index f8a8614..842f768 100644 --- a/GdbTerminal.py +++ b/GdbTerminal.py @@ -154,7 +154,53 @@ class GdbTerminal (DbgTerminal.DbgTerminal): 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 to the environment variable PATH such that you can call pygdb from console directly. - If you like, you can add the following line. It leads to a configuration file - loading when opening a source file - autocmd BufRead *.c* :GDBLoadConfig - + diff --git a/PositionFrame.py b/PositionFrame.py index 0eb49f3..035f32d 100644 --- a/PositionFrame.py +++ b/PositionFrame.py @@ -18,15 +18,17 @@ import StatusFrame 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) @@ -44,12 +46,54 @@ class PositionFrame (StatusFrame.StatusFrame): 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(): @@ -68,22 +112,49 @@ class PositionFrame (StatusFrame.StatusFrame): 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": @@ -96,10 +167,6 @@ class PositionFrame (StatusFrame.StatusFrame): self.positionLabel.set_label(status) - #Set the buffer - self.srcview.set_buffer(buf) - - def applyConfiguration(self, conf): diff --git a/StatusWindow.py b/StatusWindow.py index f03c11c..ae99036 100644 --- a/StatusWindow.py +++ b/StatusWindow.py @@ -40,7 +40,7 @@ class StatusWindow (gtk.Window): #Adding the frames self.frames = [] - self.frames += [PositionFrame.PositionFrame(debugger), \ + self.frames += [PositionFrame.PositionFrame(debugger,self), \ WatchesFrame.WatchesFrame(debugger), \ BreakpointsFrame.BreakpointsFrame(debugger) ] @@ -106,8 +106,12 @@ class StatusWindow (gtk.Window): def updateVim(self): - os.system('gvim --servername %s --remote-send " :GDBLoadConfig"' % \ self.vimservername) + def gotoVim(self, file, lineno): + file = self.debugger.toAbsPath(file) + os.system('gvim --servername %s --remote-send ":e %s:%s"' % \ + (self.vimservername, file, lineno)) + diff --git a/featurerequest.txt b/featurerequest.txt index 68f92bf..0922e51 100644 --- a/featurerequest.txt +++ b/featurerequest.txt @@ -1,7 +1,8 @@ Smaller requests Medium requestes: - - double-click on backtrace entries + - local variables frame + - double-click on backtrace entries --> open source file - keyboard shortcuts for run/continue/etc - Deactivate breakpoints