diff -r 7c6bd2366602 -r af9a6dac2611 src/eric7/Debugger/DebugUI.py --- a/src/eric7/Debugger/DebugUI.py Sat Dec 16 15:21:11 2023 +0100 +++ b/src/eric7/Debugger/DebugUI.py Sat Dec 16 16:30:55 2023 +0100 @@ -10,6 +10,7 @@ import contextlib import copy import os +import shlex from PyQt6.QtCore import QKeyCombination, QObject, Qt, pyqtSignal, pyqtSlot from PyQt6.QtGui import QKeySequence @@ -40,6 +41,7 @@ exception @signal debuggingStarted(filename) emitted when a debugging session was started + @signal debuggingFinished emitted to signal the end of a debugging session @signal resetUI(full) emitted to reset the UI partially or fully @signal exceptionInterrupt() emitted after the execution was interrupted by an exception and acknowledged by the user @@ -53,6 +55,7 @@ resetUI = pyqtSignal(bool) exceptionInterrupt = pyqtSignal() debuggingStarted = pyqtSignal(str) + debuggingFinished = pyqtSignal() appendStdout = pyqtSignal(str) processChangedProjectFiles = pyqtSignal() @@ -156,7 +159,7 @@ debugServer.clientLine.connect(self.__clientLine) debugServer.clientDisconnected.connect(self.__clientDisconnected) debugServer.clientExit.connect(self.__clientExit) - debugServer.lastClientExited.connect(self.__lastClientExited) + debugServer.mainClientExit.connect(self.__mainClientExit) debugServer.clientSyntaxError.connect(self.__clientSyntaxError) debugServer.clientException.connect(self.__clientException) debugServer.clientSignal.connect(self.__clientSignal) @@ -1343,13 +1346,15 @@ timeout=timeout, ) - def __lastClientExited(self): + def __mainClientExit(self): """ Private slot handling the exit of the last client. """ self.viewmanager.exit() self.__resetUI() + self.debuggingFinished.emit() + def __clientSyntaxError(self, message, filename, lineNo, characterNo): """ Private method to handle a syntax error in the debugged program. @@ -2705,6 +2710,61 @@ self.setEnvHistory("", history=envHistory) self.setMultiprocessNoDebugHistory("", history=noDebugHistory) + def debugInternalScript( + self, venvName, scriptName, argv, workDir, environment, clientType, forProject + ): + """ + Public method to run an internal script with debugger support. + + @param venvName name of the environment for the debug tests run + @type str + @param scriptName name of the internal script to be run + @type str + @param argv string or list containing the parameters for the script + @type str or list of str + @param workDir working directory for the script + @type str + @param environment string defining the additional or changed environment + variables + @type str + @param clientType type (language) of the debug client to be used + @type str + @param forProject flag indicating a project related debug session + @type bool + """ + self.__resetUI() + + # Hide all error highlights + self.viewmanager.unhighlight() + + self.debugViewer.initCallStackViewer(forProject) + + # Ask the client to send call trace info + enableCallTrace = self.debugViewer.isCallTraceEnabled() + self.debugViewer.clearCallTrace() + self.debugViewer.setCallTraceToProjectMode(forProject) + + args = shlex.join(argv) if isinstance(argv, list) else argv + # Ask the client to open the new program. + self.debugServer.remoteLoad( + venvName, + scriptName, + args, + workDir, + environment, + clientType=clientType, + enableCallTrace=enableCallTrace, + ) + + if ( + self.debugServer.isClientProcessUp() + and self.debugServer.getClientType() == clientType + ): + # Signal that we have started a debugging session + self.debuggingStarted.emit(scriptName) + + self.stopAct.setEnabled(True) + def __doRestart(self): """ Private slot to handle the restart action to restart the last @@ -3070,3 +3130,12 @@ @type dict """ self.overrideGlobalConfig = copy.deepcopy(overrideData) + + def getProjectEnvironmentString(self): + """ + Public method to get the string for the project environment. + + @return string for the project environment + @rtype str + """ + return self.debugServer.getProjectEnvironmentString()