Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/controllers/debugcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from helpers.gdboutput import GdbOutput
import logging
from helpers.configstore import ConfigSet, ConfigItem
from helpers.gdbinit import GDBInit


class DebugConfig(ConfigSet):
Expand All @@ -47,13 +48,22 @@ def __init__(self, distributedObjects):
self.distributedObjects = distributedObjects

self.connector = self.distributedObjects.gdb_connector
self.gdbinit = self.distributedObjects.gdb_init
self.signalProxy = self.distributedObjects.signalProxy

self.executableName = None
self.lastCmdWasStep = False

self.ptyhandler.start()

GDBInit.writeFile(self.gdbinit.getPath(),self.gdbinit.getFileName())

self.connector.start()

self.connector.initPrettyPrinter(self.gdbinit.getPath() + self.gdbinit.getFileName())
self.connector.startPrettyPrinting()

self.toggleBeautify = True

self.connector.reader.asyncRecordReceived.connect(self.handleAsyncRecord, Qt.QueuedConnection)

Expand Down Expand Up @@ -131,7 +141,18 @@ def finish(self):
def until(self, file_, line):
self.connector.until(file_, line)
self.lastCmdWasStep = False


def beautify(self):
if self.toggleBeautify:
self.connector.disablePrettyPrinter()
else:
self.connector.enablePrettyPrinter()

self.toggleBeautify = not self.toggleBeautify
self.distributedObjects.localsController.reloadLocals()
self.distributedObjects.watchController.clearModel()
self.distributedObjects.datagraphController.clearDataGraph()

def evaluateExpression(self, exp):
if exp == "":
return None
Expand Down
7 changes: 7 additions & 0 deletions src/controllers/localscontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@ def getLocals(self):

for vw in self.variableList.list:
self.add(vw)

def reloadLocals(self):
self.clear()
self.variableList.reloadLocals()

for vw in self.variableList.list:
self.add(vw)
1 change: 1 addition & 0 deletions src/controllers/tooltipcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ def showToolTip(self, exp, pos, parent):

def hideToolTip(self):
self.view.hideLater()

6 changes: 4 additions & 2 deletions src/controllers/treeitemcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ def getChildren(self, factory):
Get Children from VariableList for StructVariable
@param factory derived from VarWrapperFactory, factory to look in VariableList for children
"""
if len(self.childItems) == 0:
if (len(self.childItems) == 0) or (self._v.numChild != len(self.childItems)):
self.removeChildren()
for child in self._v.childs:
vwChild = child.makeWrapper(factory)
vwChild.parent = self
vwChild.dataChanged.connect(vwChild.hasChanged)
vwChild.dataChanged.connect(vwChild.hasChanged)
self.addChild(vwChild)
self._v.numChild = len(self.childItems)

return self.childItems

Expand Down
6 changes: 5 additions & 1 deletion src/controllers/watchcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ def loadSession(self, xmlHandler):
childnodes = watchParent.childNodes()
for i in range(childnodes.size()):
attr = xmlHandler.getAttributes(childnodes.at(i))
self.addWatch(attr["exp"])
self.addWatch(attr["exp"])

def clearModel(self):
self.model.clear()

21 changes: 13 additions & 8 deletions src/datagraph/datagraphcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __init__(self, distributedObjects):
## @var vwFactory
# datagraph.datagraphvwfactory.DataGraphVWFactory, private, self-created DataGraphVWFactory
self.vwFactory = DataGraphVWFactory(self.distributedObjects)

## @var variableList
# variables.variablelist.VariableList, private, self-created VariableList
self.variableList = VariableList(self.vwFactory, self.distributedObjects)
Expand Down Expand Up @@ -101,23 +102,27 @@ def addVar(self, varWrapper, xPos=0, yPos=0, addVarToList=True):
@param yPos Integer, the Y-Coordinate of the Position where to add the VariableWrapper
@param addVarToList Boolean, tells if varWrapper should be added to the VariableList too
"""
varWrapper.createView()
self.addGraph(varWrapper, xPos, yPos)
if addVarToList:
self.variableList.addVar(varWrapper)

def addGraph(self, wrapper, xPos=0, yPos=0):
wrapper.createView()
try:
varWrapper.getView().render()
wrapper.getView().render()
except:
from mako import exceptions
logging.error("Caught exception while rendering template: %s", exceptions.text_error_template().render())
varWrapper.setXPos(xPos)
varWrapper.setYPos(yPos)
self.data_graph_view.addItem(varWrapper.getView())
if addVarToList:
self.variableList.addVar(varWrapper)
wrapper.setXPos(xPos)
wrapper.setYPos(yPos)
self.data_graph_view.addItem(wrapper.getView())

def removeVar(self, varWrapper):
""" removes the given varWrapper from the DataGraphView and the PointerList
@param varWrapper variables.variablewrapper.VariableWrapper, the VariableWrapper to remove
"""
self.variableList.removeVar(varWrapper)
if varWrapper in self.variableList:
self.variableList.removeVar(varWrapper)
self.data_graph_view.removeItem(varWrapper.getView())

def addPointer(self, fromView, toView):
Expand Down
18 changes: 9 additions & 9 deletions src/datagraph/datagraphvw.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def prepareContextMenu(self, menu):
action.setChecked(self.vertical)

def render(self, role, **kwargs):
self.varWrapper.getChildren()
return HtmlTemplateHandler.render(self, role, vertical=self.vertical, **kwargs)


Expand Down Expand Up @@ -204,7 +205,7 @@ def render(self, role, **kwargs):
def setFilter(self, f):
VariableWrapper.setFilter(self, f)
self.setDirty(True)


class ComplexDataGraphVW(DataGraphVW):
def __init__(self, variable, distributedObjects, vwFactory, templateHandler):
Expand All @@ -221,14 +222,13 @@ def __init__(self, variable, distributedObjects, vwFactory, templateHandler):
def setOpen(self, open_):
self.isOpen = open_
self.setDirty(True)

def getChildren(self):
""" returns list of children as DataGraphVWs; creates the wrappers if they haven't yet been
@return list of datagraph.datagraphvw.DataGraphVW """
if not self.childrenWrapper:
self.childrenWrapper = []
for childVar in self.childs:
wrapper = childVar.makeWrapper(self.vwFactory)
wrapper.setExistingView(self.getView(), self)
self.childrenWrapper.append(wrapper)
return self.childrenWrapper
self.childrenWrapper = []
for childVar in self.childs:
wrapper = childVar.makeWrapper(self.vwFactory)
wrapper.setExistingView(self.getView(), self)
self.childrenWrapper.append(wrapper)
return self.childrenWrapper
46 changes: 46 additions & 0 deletions src/datagraph/svgimage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# ricodebug - A GDB frontend which focuses on visually supported
# debugging using data structure graphs and SystemC features.
#
# Copyright (C) 2011 The ricodebug project team at the
# Upper Austrian University Of Applied Sciences Hagenberg,
# Department Embedded Systems Design
#
# This file is part of ricodebug.
#
# ricodebug is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# For further information see <http://syscdbg.hagenberg.servus.at/>.

from PyQt4.QtCore import QObject, pyqtSignal


class SVGImage(QObject):
changed = pyqtSignal(str)

def __init__(self, name, fileObject):
QObject.__init__(self)
self.name = name
self.fileObject = fileObject
self.imageContent = fileObject.read()
self.inScope = True

def refresh(self):
self.fileObject.seek(0)
self.imageContent = self.fileObject.read()

def die(self):
pass

def __str__(self):
return self.name
55 changes: 55 additions & 0 deletions src/datagraph/svgvw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# ricodebug - A GDB frontend which focuses on visually supported
# debugging using data structure graphs and SystemC features.
#
# Copyright (C) 2011 The ricodebug project team at the
# Upper Austrian University Of Applied Sciences Hagenberg,
# Department Embedded Systems Design
#
# This file is part of ricodebug.
#
# ricodebug is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# For further information see <http://syscdbg.hagenberg.servus.at/>.

from .datagraphvw import HtmlTemplateHandler, DataGraphVW
from .htmlvariableview import HtmlVariableView


class SVGDataGraphVW(DataGraphVW):
""" Wrapper for SVG Images """

def __init__(self, image, distributedObjects):
""" Constructor
@param image SVG image to wrap with the new DataGraphVW
@param distributedObjects the DistributedObjects-Instance
"""
DataGraphVW.__init__(self, image, distributedObjects)
self.image = image
self.templateHandler = HtmlTemplateHandler(self,
self.distributedObjects,
"svgview.mako")

def showContent(self):
self.image.refresh()
return self.image.imageContent

def showName(self):
return str(self.image)

def render(self, role, **kwargs):
return self.templateHandler.render(role)

def createView(self):
self._view = HtmlVariableView(self, self.distributedObjects)
self.parentWrapper = self._view
2 changes: 2 additions & 0 deletions src/datagraph/templates/svgview.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<tr><th>${varWrapper.showName()}</th></tr>
<tr><td>${varWrapper.showContent()}<td></tr>
15 changes: 15 additions & 0 deletions src/helpers/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ def __init__(self):
"Del var from Watch", "+",
"Remove selected variable from watchview-window")

###############################################
## miscellaneous
###############################################
self.Beautify = self.__createAction(":/icons/images/beautify.png",
"Beautify", None, "Pretty Print of Objects")

def getAddToWatchAction(self, name, slot):
a = self.createEx(name)
a.setText("Add '%s' to watch window" % name)
Expand All @@ -155,6 +161,15 @@ def getAddToTracepointAction(self, varname, tpname, slot):
a.triggeredEx.connect(slot)
return a

def getAddSVGToDatagraphAction(self, name, slot):
a = self.createEx(name)
a.setText(str(name))
a.setIcon(QtGui.QIcon(":/icons/images/insert.png"))
a.setIconVisibleInMenu(True)
a.triggeredEx.connect(slot)
return a


def createEx(self, parameter):
return self.ActionEx(parameter, self)

Expand Down
6 changes: 2 additions & 4 deletions src/helpers/distributedobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,25 @@
from views.threadview import ThreadView
from models.threadmodel import ThreadModel
from views.mitraceview import MiTraceView

from helpers.gdbinit import GDBInit

class DistributedObjects:
def __init__(self, mainwindow):
self.mainwindow = mainwindow
self.settings = QSettings("fh-hagenberg", "ricodebug")
self.configStore = ConfigStore(self.settings)
self.gdb_connector = GdbConnector()
self.gdb_init = GDBInit()
self.actions = Actions()
self.signalProxy = SignalProxy(self)
self.sessionManager = SessionManager(self)

self.breakpointModel, _ = self.buildModelAndView(BreakpointModel, BreakpointView, "Breakpoints")

self.debugController = DebugController(self)
self.variablePool = VariablePool(self)
self.editorController = EditorController(self)
self.toolTipController = ToolTipController(self, ToolTipView(self, self.editorController.editor_view))
self.filelistController = FileListController(self)
self.stackController = StackController(self)

self.threadModel, _ = self.buildModelAndView(ThreadModel, ThreadView, "Threads")

self.watchView = WatchView()
Expand Down
21 changes: 18 additions & 3 deletions src/helpers/gdbconnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import subprocess
import signal
import logging
import os
from .gdbreader import GdbReader
from .gdboutput import GdbOutput
from PyQt4.QtCore import QObject, pyqtSignal
Expand All @@ -41,7 +42,7 @@ def __init__(self):

def start(self):
try:
self.gdb = subprocess.Popen(['gdb', '-i', 'mi', '-q'],
self.gdb = subprocess.Popen(['gdb', '-i', 'mi', '-q', '-nx'], \
shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
except OSError as e:
logging.critical("Could not start gdb. Error message: %s", e)
Expand Down Expand Up @@ -79,6 +80,10 @@ def openFile(self, filename):
self.executeAndRaiseIfFailed("-file-exec-and-symbols " + filename,
"Could not open file!")

def startPrettyPrinting(self):
self.execute("-enable-pretty-printing", \
"Enable MI PrettyPrint")

def getSources(self):
res = self.executeAndRaiseIfFailed("-file-list-exec-source-files",
"Could not get files.")
Expand Down Expand Up @@ -268,8 +273,8 @@ def var_assign(self, exp, value):
return self.execute("-var-assign \"" + exp + "\" " + value)

def var_list_children(self, exp):
return self.execute("-var-list-children --all-values \"" +
str(exp) + "\"")
return self.execute("-var-list-children --all-values \"" + \
str(exp) + "\" 0 100")

def var_update(self, exp):
return self.execute("-var-update --all-values \"" + exp + "\"")
Expand All @@ -289,3 +294,13 @@ def threadInfo(self):

def selectThread(self, id_):
return self.executeAndRaiseIfFailed("-thread-select %s" % id_)

def initPrettyPrinter(self,path):
command = "source" + path
self.executeAndRaiseIfFailed(command,"Can not load pretty printer module!")

def enablePrettyPrinter(self):
return self.executeAndRaiseIfFailed("enable pretty-printer", "Enables Initialized Printers")

def disablePrettyPrinter(self):
return self.executeAndRaiseIfFailed("disable pretty-printer", "Disables Initialized Printers")
Loading