From 3c94180482e4ccd256f087ff182278f083a94276 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Wed, 11 Jun 2008 18:22:18 +0200 Subject: [PATCH] Adding a source view --- DbgTerminal.py | 3 +++ GdbTerminal.py | 9 +++++++++ PositionFrame.py | 16 ++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/DbgTerminal.py b/DbgTerminal.py index c854bba..afeca3d 100644 --- a/DbgTerminal.py +++ b/DbgTerminal.py @@ -193,6 +193,9 @@ class DbgTerminal (vte.Terminal): def getExpression(self, expr): raise NotImplementedError() + def listCodeSnippet(self): + raise NotImplementedError() + def waitForPrompt(self, his): raise NotImplementedError() diff --git a/GdbTerminal.py b/GdbTerminal.py index 579849d..5e6ba6d 100755 --- a/GdbTerminal.py +++ b/GdbTerminal.py @@ -137,6 +137,15 @@ class GdbTerminal (DbgTerminal.DbgTerminal): split = string.split(answer, "=") return string.join(split[1:], "=").strip() + + def listCodeSnippet(self): + starthis = self.getHistoryLen() + self.feed_child("list\n") + endhis, response = self.waitForPrompt(starthis) + + text = string.join(self.history[starthis:endhis], "\n") + return text + def waitForPrompt(self, his): rx = "^\(gdb\)" diff --git a/PositionFrame.py b/PositionFrame.py index ce82619..4403932 100644 --- a/PositionFrame.py +++ b/PositionFrame.py @@ -69,12 +69,22 @@ class PositionFrame (StatusFrame.StatusFrame): def updateValues(self, status, param): + + #Create new text buffer for source view + buf = gtk.TextBuffer() if status == "break": self.file, self.lineno = param self.positionLabel.set_label("%s:%d" % (self.file, self.lineno)) + + #Get some code + code = self.debugger.listCodeSnippet() + buf.set_text(code) + + else: self.file, self.lineno = None, None + code = "" if status == "exited": self.positionLabel.set_label("Exited with code %d." % param) @@ -85,6 +95,12 @@ class PositionFrame (StatusFrame.StatusFrame): else: self.positionLabel.set_label(status) + + #Set the buffer + self.srcview.set_buffer(buf) + + + def applyConfiguration(self, conf): pass -- 2.39.5