eric7/Debugger/CallTraceViewer.py

Fri, 17 Jun 2022 16:36:14 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 17 Jun 2022 16:36:14 +0200
branch
eric7
changeset 9153
506e35e424d5
parent 9152
8a68afaf1ba2
permissions
-rw-r--r--

Finished replacing the use of "QFileInfo()" with Python equivalents.

2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8637
diff changeset
3 # Copyright (c) 2012 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the Call Trace viewer widget.
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
10 import pathlib
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
11 import re
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
12
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
13 from PyQt6.QtCore import pyqtSlot, pyqtSignal, Qt
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
14 from PyQt6.QtWidgets import QWidget, QTreeWidgetItem
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
8358
144a6b854f70 Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8356
diff changeset
16 from EricWidgets.EricApplication import ericApp
144a6b854f70 Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8356
diff changeset
17 from EricWidgets import EricFileDialog, EricMessageBox
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
18
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from .Ui_CallTraceViewer import Ui_CallTraceViewer
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import UI.PixmapCache
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Preferences
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class CallTraceViewer(QWidget, Ui_CallTraceViewer):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class implementing the Call Trace viewer widget.
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
2988
f53c03574697 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2622
diff changeset
29 @signal sourceFile(str, int) emitted to show the source of a call/return
f53c03574697 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2622
diff changeset
30 point
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 sourceFile = pyqtSignal(str, int)
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
34 def __init__(self, debugServer, debugViewer, parent=None):
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 Constructor
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
38 @param debugServer reference to the debug server object
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
39 @type DebugServer
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
40 @param debugViewer reference to the debug viewer object
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
41 @type DebugViewer
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
42 @param parent reference to the parent widget
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
43 @type QWidget
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
45 super().__init__(parent)
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.setupUi(self)
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.__dbs = debugServer
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
49 self.__debugViewer = debugViewer
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
2988
f53c03574697 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2622
diff changeset
51 self.startTraceButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
52 UI.PixmapCache.getIcon("callTraceStart"))
2988
f53c03574697 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2622
diff changeset
53 self.stopTraceButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
54 UI.PixmapCache.getIcon("callTraceStop"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
55 self.resizeButton.setIcon(UI.PixmapCache.getIcon("resizeColumns"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
56 self.clearButton.setIcon(UI.PixmapCache.getIcon("editDelete"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
57 self.saveButton.setIcon(UI.PixmapCache.getIcon("fileSave"))
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
2988
f53c03574697 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2622
diff changeset
59 self.__headerItem = QTreeWidgetItem(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
60 ["", self.tr("From"), self.tr("To")])
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
61 self.__headerItem.setIcon(0, UI.PixmapCache.getIcon("callReturn"))
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.callTrace.setHeaderItem(self.__headerItem)
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.__callStack = []
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.__entryFormat = "{0}:{1} ({2})"
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
67 self.__entryRe = re.compile(r"""(.+):(\d+)\s\((.*)\)""")
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
68
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
69 self.__projectMode = False
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
70 self.__project = None
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
71 self.__tracedDebuggerId = ""
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
5150
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
73 stopOnExit = Preferences.toBool(
8637
394377638256 Replaced the direct access to 'Preferences.Prefs.settings' with 'Preferences.getSettings()'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
74 Preferences.getSettings().value("CallTrace/StopOnExit", True))
5150
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
75 self.stopCheckBox.setChecked(stopOnExit)
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
76
5151
0a5906c38bfd Some finetuning with respect to start-up of the call trace viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5150
diff changeset
77 self.__callTraceEnabled = (Preferences.toBool(
8637
394377638256 Replaced the direct access to 'Preferences.Prefs.settings' with 'Preferences.getSettings()'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
78 Preferences.getSettings().value("CallTrace/Enabled", False)) and
5151
0a5906c38bfd Some finetuning with respect to start-up of the call trace viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5150
diff changeset
79 not stopOnExit)
0a5906c38bfd Some finetuning with respect to start-up of the call trace viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5150
diff changeset
80
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 if self.__callTraceEnabled:
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
82 self.startTraceButton.setEnabled(False)
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
83 else:
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.stopTraceButton.setEnabled(False)
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.__dbs.callTraceInfo.connect(self.__addCallTraceInfo)
5150
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
87 self.__dbs.clientExit.connect(self.__clientExit)
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
89 def __setCallTraceEnabled(self, enabled):
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
90 """
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
91 Private slot to set the call trace enabled status.
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
92
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
93 @param enabled flag indicating the new state
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
94 @type bool
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
95 """
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
96 if enabled:
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
97 self.__tracedDebuggerId = (
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
98 self.__debugViewer.getSelectedDebuggerId()
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
99 )
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
100 self.__dbs.setCallTraceEnabled(self.__tracedDebuggerId, enabled)
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
101 self.stopTraceButton.setEnabled(enabled)
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
102 self.startTraceButton.setEnabled(not enabled)
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
103 self.__callTraceEnabled = enabled
8637
394377638256 Replaced the direct access to 'Preferences.Prefs.settings' with 'Preferences.getSettings()'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
104 Preferences.getSettings().setValue("CallTrace/Enabled", enabled)
5150
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
105
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
106 if not enabled:
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
107 for column in range(self.callTrace.columnCount()):
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
108 self.callTrace.resizeColumnToContents(column)
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
109
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
110 @pyqtSlot(bool)
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
111 def on_stopCheckBox_clicked(self, checked):
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
112 """
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
113 Private slot to handle a click on the stop check box.
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
114
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
115 @param checked state of the check box
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
116 @type bool
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
117 """
8637
394377638256 Replaced the direct access to 'Preferences.Prefs.settings' with 'Preferences.getSettings()'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
118 Preferences.getSettings().setValue("CallTrace/StopOnExit", checked)
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
119
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 @pyqtSlot()
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 def on_startTraceButton_clicked(self):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 Private slot to start call tracing.
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 """
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
125 self.__setCallTraceEnabled(True)
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 @pyqtSlot()
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 def on_stopTraceButton_clicked(self):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 Private slot to start call tracing.
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 """
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
132 self.__setCallTraceEnabled(False)
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 @pyqtSlot()
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 def on_resizeButton_clicked(self):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 Private slot to resize the columns of the call trace to their contents.
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 for column in range(self.callTrace.columnCount()):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 self.callTrace.resizeColumnToContents(column)
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 @pyqtSlot()
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 def on_clearButton_clicked(self):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 Private slot to clear the call trace.
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 self.clear()
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 @pyqtSlot()
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 def on_saveButton_clicked(self):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
152 Private slot to save the call trace info to a file.
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 """
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
154 if self.callTrace.topLevelItemCount() > 0:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
155 fname, selectedFilter = EricFileDialog.getSaveFileNameAndFilter(
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
156 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
157 self.tr("Save Call Trace Info"),
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
158 "",
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
159 self.tr("Text Files (*.txt);;All Files (*)"),
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
160 None,
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
161 EricFileDialog.DontConfirmOverwrite)
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
162 if fname:
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
163 fpath = pathlib.Path(fname)
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
164 if not fpath.suffix:
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
165 ex = selectedFilter.split("(*")[1].split(")")[0]
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
166 if ex:
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
167 fpath = fpath.with_suffix(ex)
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
168 if fpath.exists():
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
169 res = EricMessageBox.yesNo(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2988
diff changeset
170 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
171 self.tr("Save Call Trace Info"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
172 self.tr("<p>The file <b>{0}</b> already exists."
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9152
diff changeset
173 " Overwrite it?</p>").format(fpath),
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
174 icon=EricMessageBox.Warning)
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
175 if not res:
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
176 return
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
177
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
178 try:
7927
866ddf957461 Call Trace Viewer, Call Stack Viewer: some refinements and further adaptions to the multi-process debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
179 title = self.tr("Call Trace Info of '{0}'").format(
866ddf957461 Call Trace Viewer, Call Stack Viewer: some refinements and further adaptions to the multi-process debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
180 self.__tracedDebuggerId)
9152
8a68afaf1ba2 Started replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
181 with fpath.open("w", encoding="utf-8") as f:
7927
866ddf957461 Call Trace Viewer, Call Stack Viewer: some refinements and further adaptions to the multi-process debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
182 f.write("{0}\n".format(title))
866ddf957461 Call Trace Viewer, Call Stack Viewer: some refinements and further adaptions to the multi-process debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
183 f.write("{0}\n\n".format(len(title) * "="))
7785
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
184 itm = self.callTrace.topLevelItem(0)
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
185 while itm is not None:
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7927
diff changeset
186 isCall = itm.data(0, Qt.ItemDataRole.UserRole)
8230
8b5c6896655b Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
187 call = "->" if isCall else "<-"
7785
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
188 f.write("{0} {1} || {2}\n".format(
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
189 call,
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
190 itm.text(1), itm.text(2)))
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
191 itm = self.callTrace.itemBelow(itm)
7836
2f0d208b8137 Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
192 except OSError as err:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
193 EricMessageBox.critical(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2988
diff changeset
194 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
195 self.tr("Error saving Call Trace Info"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
196 self.tr("""<p>The call trace info could not"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
197 """ be written to <b>{0}</b></p>"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
198 """<p>Reason: {1}</p>""")
9153
506e35e424d5 Finished replacing the use of "QFileInfo()" with Python equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9152
diff changeset
199 .format(fpath, str(err)))
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 @pyqtSlot(QTreeWidgetItem, int)
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 def on_callTrace_itemDoubleClicked(self, item, column):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 """
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
204 Private slot to open the double clicked file in an editor.
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
205
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
206 @param item reference to the double clicked item
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
207 @type QTreeWidgetItem
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
208 @param column column that was double clicked
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
209 @type int
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 """
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
211 if item is not None and column > 0:
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
212 columnStr = item.text(column)
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
213 match = self.__entryRe.fullmatch(columnStr.strip())
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
214 if match:
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
215 filename, lineno, func = match.groups()
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
216 try:
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
217 lineno = int(lineno)
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
218 except ValueError:
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
219 # do nothing, if the line info is not an integer
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
220 return
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
221 if self.__projectMode:
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
222 filename = self.__project.getAbsolutePath(filename)
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
223 self.sourceFile.emit(filename, lineno)
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 def clear(self):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 Public slot to clear the call trace info.
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 self.callTrace.clear()
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 self.__callStack = []
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
232 def setProjectMode(self, enabled):
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
233 """
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
234 Public slot to set the call trace viewer to project mode.
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
235
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
236 In project mode the call trace info is shown with project relative
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
237 path names.
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
238
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
239 @param enabled flag indicating to enable the project mode
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
240 @type bool
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
241 """
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
242 self.__projectMode = enabled
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
243 if enabled and self.__project is None:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
244 self.__project = ericApp().getObject("Project")
2171
c7dd548d67d8 Finished the coding part of the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2170
diff changeset
245
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 def __addCallTraceInfo(self, isCall, fromFile, fromLine, fromFunction,
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
247 toFile, toLine, toFunction, debuggerId):
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 Private method to add an entry to the call trace viewer.
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
251 @param isCall flag indicating a 'call'
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
252 @type bool
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
253 @param fromFile name of the originating file
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
254 @type str
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
255 @param fromLine line number in the originating file
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
256 @type str
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
257 @param fromFunction name of the originating function
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
258 @type str
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
259 @param toFile name of the target file
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
260 @type str
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
261 @param toLine line number in the target file
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
262 @type str
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
263 @param toFunction name of the target function
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
264 @type str
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
265 @param debuggerId ID of the debugger backend
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
266 @type str
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 """
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
268 if debuggerId == self.__tracedDebuggerId:
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
269 if isCall:
7564
787684e6f2f3 Merged with default branch.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7421 7533
diff changeset
270 icon = UI.PixmapCache.getIcon("forward")
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
271 else:
7564
787684e6f2f3 Merged with default branch.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7421 7533
diff changeset
272 icon = UI.PixmapCache.getIcon("back")
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
273 parentItem = (
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
274 self.__callStack[-1] if self.__callStack else self.callTrace)
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
275
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
276 if self.__projectMode:
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
277 fromFile = self.__project.getRelativePath(fromFile)
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
278 toFile = self.__project.getRelativePath(toFile)
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
279
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
280 itm = QTreeWidgetItem(
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
281 parentItem,
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
282 ["",
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
283 self.__entryFormat.format(fromFile, fromLine, fromFunction),
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
284 self.__entryFormat.format(toFile, toLine, toFunction)])
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
285 itm.setIcon(0, icon)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7927
diff changeset
286 itm.setData(0, Qt.ItemDataRole.UserRole, isCall)
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
287 itm.setExpanded(True)
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
288
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
289 if isCall:
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
290 self.__callStack.append(itm)
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
291 else:
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
292 if self.__callStack:
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
293 self.__callStack.pop(-1)
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 def isCallTraceEnabled(self):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 Public method to get the state of the call trace function.
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
299 @return flag indicating the state of the call trace function
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
300 @rtype bool
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 return self.__callTraceEnabled
5150
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
303
7421
4a9900aef04e Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7379
diff changeset
304 @pyqtSlot(str, int, str, bool, str)
4a9900aef04e Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7379
diff changeset
305 def __clientExit(self, program, status, message, quiet, debuggerId):
5150
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
306 """
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
307 Private slot to handle a debug client terminating.
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
308
7421
4a9900aef04e Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7379
diff changeset
309 @param program name of the exited program
4a9900aef04e Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7379
diff changeset
310 @type str
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
311 @param status exit code of the debugged program
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
312 @type int
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
313 @param message exit message of the debugged program
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
314 @type str
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
315 @param quiet flag indicating to suppress exit info display
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
316 @type bool
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
317 @param debuggerId ID of the debugger backend
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
318 @type str
5150
72a053e1c440 Added capability to stop recording upon exit of the client script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
319 """
7379
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
320 if debuggerId == self.__tracedDebuggerId:
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
321 if self.stopCheckBox.isChecked():
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
322 self.__setCallTraceEnabled(False)
72a72fd56494 Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
323 self.__tracedDebuggerId = ""

eric ide

mercurial