eric6/Debugger/CallTraceViewer.py

branch
multi_processing
changeset 7379
72a72fd56494
parent 7360
9190402e4505
child 7421
4a9900aef04e
--- a/eric6/Debugger/CallTraceViewer.py	Thu Jan 30 19:37:03 2020 +0100
+++ b/eric6/Debugger/CallTraceViewer.py	Sat Feb 01 19:48:21 2020 +0100
@@ -30,17 +30,22 @@
     """
     sourceFile = pyqtSignal(str, int)
     
-    def __init__(self, debugServer, parent=None):
+    def __init__(self, debugServer, debugViewer, parent=None):
         """
         Constructor
         
-        @param debugServer reference to the debug server object (DebugServer)
-        @param parent reference to the parent widget (QWidget)
+        @param debugServer reference to the debug server object
+        @type DebugServer
+        @param debugViewer reference to the debug viewer object
+        @type DebugViewer
+        @param parent reference to the parent widget
+        @type QWidget
         """
         super(CallTraceViewer, self).__init__(parent)
         self.setupUi(self)
         
         self.__dbs = debugServer
+        self.__debugViewer = debugViewer
         
         self.startTraceButton.setIcon(
             UI.PixmapCache.getIcon("callTraceStart.png"))
@@ -62,6 +67,7 @@
         
         self.__projectMode = False
         self.__project = None
+        self.__tracedDebuggerId = ""
         
         stopOnExit = Preferences.toBool(
             Preferences.Prefs.settings.value("CallTrace/StopOnExit", True))
@@ -83,9 +89,14 @@
         """
         Private slot to set the call trace enabled status.
         
-        @param enabled flag indicating the new state (boolean)
+        @param enabled flag indicating the new state
+        @type bool
         """
-        self.__dbs.setCallTraceEnabled(enabled)
+        if enabled:
+            self.__tracedDebuggerId = (
+                self.__debugViewer.getSelectedDebuggerId()
+            )
+        self.__dbs.setCallTraceEnabled(self.__tracedDebuggerId, enabled)
         self.stopTraceButton.setEnabled(enabled)
         self.startTraceButton.setEnabled(not enabled)
         self.__callTraceEnabled = enabled
@@ -192,8 +203,10 @@
         """
         Private slot to open the double clicked file in an editor.
         
-        @param item reference to the double clicked item (QTreeWidgetItem)
-        @param column column that was double clicked (integer)
+        @param item reference to the double clicked item
+        @type QTreeWidgetItem
+        @param column column that was double clicked
+        @type int
         """
         if item is not None and column > 0:
             columnStr = item.text(column)
@@ -222,63 +235,86 @@
         In project mode the call trace info is shown with project relative
         path names.
         
-        @param enabled flag indicating to enable the project mode (boolean)
+        @param enabled flag indicating to enable the project mode
+        @type bool
         """
         self.__projectMode = enabled
         if enabled and self.__project is None:
             self.__project = e5App().getObject("Project")
     
     def __addCallTraceInfo(self, isCall, fromFile, fromLine, fromFunction,
-                           toFile, toLine, toFunction):
+                           toFile, toLine, toFunction, debuggerId):
         """
         Private method to add an entry to the call trace viewer.
         
-        @param isCall flag indicating a 'call' (boolean)
-        @param fromFile name of the originating file (string)
-        @param fromLine line number in the originating file (string)
-        @param fromFunction name of the originating function (string)
-        @param toFile name of the target file (string)
-        @param toLine line number in the target file (string)
-        @param toFunction name of the target function (string)
+        @param isCall flag indicating a 'call'
+        @type bool
+        @param fromFile name of the originating file
+        @type str
+        @param fromLine line number in the originating file
+        @type str
+        @param fromFunction name of the originating function
+        @type str
+        @param toFile name of the target file
+        @type str
+        @param toLine line number in the target file
+        @type str
+        @param toFunction name of the target function
+        @type str
+        @param debuggerId ID of the debugger backend
+        @type str
         """
-        if isCall:
-            icon = UI.PixmapCache.getIcon("forward.png")
-        else:
-            icon = UI.PixmapCache.getIcon("back.png")
-        parentItem = (
-            self.__callStack[-1] if self.__callStack else self.callTrace)
-        
-        if self.__projectMode:
-            fromFile = self.__project.getRelativePath(fromFile)
-            toFile = self.__project.getRelativePath(toFile)
-        
-        itm = QTreeWidgetItem(
-            parentItem,
-            ["",
-             self.__entryFormat.format(fromFile, fromLine, fromFunction),
-             self.__entryFormat.format(toFile, toLine, toFunction)])
-        itm.setIcon(0, icon)
-        itm.setData(0, Qt.UserRole, isCall)
-        itm.setExpanded(True)
-        
-        if isCall:
-            self.__callStack.append(itm)
-        else:
-            if self.__callStack:
-                self.__callStack.pop(-1)
+        if debuggerId == self.__tracedDebuggerId:
+            if isCall:
+                icon = UI.PixmapCache.getIcon("forward.png")
+            else:
+                icon = UI.PixmapCache.getIcon("back.png")
+            parentItem = (
+                self.__callStack[-1] if self.__callStack else self.callTrace)
+            
+            if self.__projectMode:
+                fromFile = self.__project.getRelativePath(fromFile)
+                toFile = self.__project.getRelativePath(toFile)
+            
+            itm = QTreeWidgetItem(
+                parentItem,
+                ["",
+                 self.__entryFormat.format(fromFile, fromLine, fromFunction),
+                 self.__entryFormat.format(toFile, toLine, toFunction)])
+            itm.setIcon(0, icon)
+            itm.setData(0, Qt.UserRole, isCall)
+            itm.setExpanded(True)
+            
+            if isCall:
+                self.__callStack.append(itm)
+            else:
+                if self.__callStack:
+                    self.__callStack.pop(-1)
     
     def isCallTraceEnabled(self):
         """
         Public method to get the state of the call trace function.
         
-        @return flag indicating the state of the call trace function (boolean)
+        @return flag indicating the state of the call trace function
+        @rtype bool
         """
         return self.__callTraceEnabled
     
-    @pyqtSlot()
-    def __clientExit(self):
+    @pyqtSlot(int, str, bool, str)
+    def __clientExit(self, status, message, quiet, debuggerId):
         """
-        Private slot handling a client exiting.
+        Private slot to handle a debug client terminating.
+        
+        @param status exit code of the debugged program
+        @type int
+        @param message exit message of the debugged program
+        @type str
+        @param quiet flag indicating to suppress exit info display
+        @type bool
+        @param debuggerId ID of the debugger backend
+        @type str
         """
-        if self.stopCheckBox.isChecked():
-            self.__setCallTraceEnabled(False)
+        if debuggerId == self.__tracedDebuggerId:
+            if self.stopCheckBox.isChecked():
+                self.__setCallTraceEnabled(False)
+            self.__tracedDebuggerId = ""

eric ide

mercurial