class Tracepoint(ExtendedBreakpoint): """This class is used as a tracepoint in tracepointmodel. Basically Tracpoints are Breakpoint but they are extended with tracedVariables (list of Variable-Value-Pairs). Every Tracepoint contains some variables that are traced. Tracepoints are breakpoints and stop program then get information of asked variables and then continue program """ def __init__(self, distObjects, sensitiveVariable, nr): """Init Tracepoint @param sensitiveVariable: is the sensitive variable. Use extendedBreakpoints for this. If extBP occures then the variables and their values will be stored. @param nr: needed to initialize ExtendedBreakpoint class """ ExtendedBreakpoint.__init__(self, sensitiveVariable, nr, distObjects.gdb_connector) """here are the traced variables stored with their values""" self.gdb_connector = distObjects.gdb_connector self.distObjects = distObjects self.vwFactory = TraceVWFactory() self.variableList = VariableList(self.vwFactory, distObjects) self.counter = 0 self.hitted = False self.stop = False self.connect(self.distObjects.signalProxy, SIGNAL('dataForTracepointsReady()'), self.readDataFromVarModel) self.wave = [] def addVar(self, variableToTrace): """ add a var to trace its value @param variableToTrace: variable name of the variable that shoudl be traced""" vw = self.variableList.addVarByName(variableToTrace) QObject.connect(vw, SIGNAL('replace(PyQt_PyObject, PyQt_PyObject)'), self.replaceVariable) newValueList = ValueList(variableToTrace, vw.getType()) self.wave.append(newValueList) def replaceVariable(self, pendingVar, newVar): """ replace existing variable in list with new one @param pendingVar: var to replace @param newVar: new var""" vwOld = self.variableList.getVariableWrapper(pendingVar) vwNew = self.variableList.replaceVar(pendingVar, newVar) QObject.connect(vwNew, SIGNAL('replace(PyQt_PyObject, PyQt_PyObject)'), self.replaceVariable) def tracePointOccurred(self, stop): """ set if stop is needed or not @param stop: (bool), gdb stops after tracing if True, gdb continues after tracing if False """ self.stop = stop self.hitted = True def readDataFromVarModel(self): """tracepoint occurred: get values of all traced variables then continue debugging """ if self.hitted: self.hitted = False self.counter = self.counter + 1 #print "\n\n------------------------ tracePoint " + self.name + " line: " + self.line + " occured " + str(self.counter) + " times:" for varList in self.wave: for v in self.variableList.list: if v.variable.uniquename == varList.name: varList.addValue(v.variable.type, v.variable.value) if not(self.stop): self.stop = True self.gdb_connector.cont()
class WatchController(QObject): """ the Controller for the WatchView """ def __init__(self, distributedObjects): """ Constructor <br> Create a WatchView, a WatchVWFactory and a VariableList <br> Listens to the following Signals: SignalProxy::AddWatch(QString), SignalProxy::insertDockWidgets() and SignalProxy::cleanupModels() @param distributedObjects distributedobjects.DistributedObjects, the DistributedObjects-Instance """ QObject.__init__(self) self.distributedObjects = distributedObjects #self.root = RootVarWrapper() self.vwFactory = WatchVWFactory() self.variableModel = VariableModel(self, self.distributedObjects) self.watchView = WatchView(self) self.watchView.treeView.setModel(self.variableModel) self.watchVariableList = VariableList(self.vwFactory, self.distributedObjects) QObject.connect(self.distributedObjects.signal_proxy, SIGNAL('AddWatch(QString)'), self.addWatch) QObject.connect(self.distributedObjects.signal_proxy, SIGNAL('insertDockWidgets()'), self.insertDockWidgets) QObject.connect(self.distributedObjects.signal_proxy, SIGNAL('cleanupModels()'), self.clearVars) def clearVars(self): """ clears the WatchView and the VariableList <br> this function is connected to the signal SignalProxy::cleanupModels() """ # clear lists del self.watchVariableList.list[:] self.variableModel.clear() def insertDockWidgets(self): """ adds the Watch-DockWidget to the GUI <br> this function is connected to the signal SignalProxy::insertDockWidgets() """ self.watchDock = QDockWidget("Watch") self.watchDock.setObjectName("WatchView") self.watchDock.setWidget(self.watchView) self.distributedObjects.signal_proxy.addDockWidget(Qt.BottomDockWidgetArea, self.watchDock, True) def removeSelected(self, row, parent): """ remove selected variable from WatchView @param row int, selected row @param parent TreeItem, parent item from selectected item """ self.variableModel.removeRow(row, parent) def addWatch(self, watch): """ adds the Variable watch to the VariableList and its wrapper to the WatchView this function is connected to the signal SignalProxy::AddWatch(QString) @param watch Variable, the Variable to add to watch """ vw = self.watchVariableList.addVarByName(watch) # connect changed and replace signal from wrapper QObject.connect(vw, SIGNAL('changed()'), vw.hasChanged) QObject.connect(vw, SIGNAL('replace(PyQt_PyObject, PyQt_PyObject)'), self.replaceVariable) # set parent for root variable vw.setParent(self.variableModel.root) # add variable to root children self.variableModel.root.addChild(vw) self.variableModel.addVar(vw) def replaceVariable(self, pendingVar, newVar): """ replaces a variable in the variablelist @param pendingVar variables.variablewrapper.VariableWrapper, VariableWrapper to replace in the list @param newVar variables.Variable, new Variable which replaces existing VariableWrapper in List """ vwOld = self.watchVariableList.getVariableWrapper(pendingVar) vwNew = self.watchVariableList.replaceVar(pendingVar, newVar) QObject.connect(vwNew, SIGNAL('changed()'), vwNew.hasChanged) QObject.connect(vwNew, SIGNAL('replace(PyQt_PyObject, PyQt_PyObject)'), self.replaceVariable) # set parent for root variable vwNew.setParent(self.variableModel.root) # add variable to root children self.variableModel.root.replaceChild(vwOld, vwNew) vwNew.setChanged(True) self.variableModel.update() def saveSession(self, xmlHandler): """ Insert session info to xml file @param xmlHandler sessionmanager.XmlHandler, handler to write to the session-xml-file """ watchParent = xmlHandler.createNode("Watches") for var in self.variableModel.getVariables(): xmlHandler.createNode("Watch", watchParent, { 'exp': var.getExp()}) def loadSession(self, xmlHandler): """ load session info to xml file @param xmlHandler sessionmanager.XmlHandler, handler to read from the session-xml-file """ watchParent = xmlHandler.getNode("Watches") if watchParent != None: childnodes = watchParent.childNodes() for i in range(childnodes.size()): attr = xmlHandler.getAttributes(childnodes.at(i)) self.addWatch(attr["exp"])