diff -r 866adc8c315b -r 0acf98cd089a eric6/Debugger/StartDialog.py --- a/eric6/Debugger/StartDialog.py Sun Jan 17 13:53:08 2021 +0100 +++ b/eric6/Debugger/StartDialog.py Mon Feb 01 10:38:16 2021 +0100 @@ -7,6 +7,8 @@ Module implementing the Start Program dialog. """ +import os + from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QComboBox, QInputDialog from E5Gui.E5PathPicker import E5PathPickerModes @@ -28,7 +30,7 @@ exceptions, parent=None, dialogType=0, modfuncList=None, tracePython=False, autoClearShell=True, autoContinue=True, - autoFork=False, forkChild=False): + enableMultiprocess=False, multiprocessNoDebugHistory=None): """ Constructor @@ -55,21 +57,23 @@ <li>3 = start profile dialog</li> </ul> @type int (0 to 3) - @keyparam modfuncList history list of module functions + @param modfuncList history list of module functions @type list of str - @keyparam tracePython flag indicating if the Python library should + @param tracePython flag indicating if the Python library should be traced as well @type bool - @keyparam autoClearShell flag indicating, that the interpreter window + @param autoClearShell flag indicating, that the interpreter window should be cleared automatically @type bool - @keyparam autoContinue flag indicating, that the debugger should not + @param autoContinue flag indicating, that the debugger should not stop at the first executable line @type bool - @keyparam autoFork flag indicating the automatic fork mode + @param enableMultiprocess flag indicating the support for multi process + debugging @type bool - @keyparam forkChild flag indicating to debug the child after forking - @type bool + @param multiprocessNoDebugHistory list of lists with programs not to be + debugged + @type list of str """ super(StartDialog, self).__init__(parent) self.setModal(True) @@ -126,15 +130,23 @@ self.ui.venvComboBox.setCurrentIndex(venvIndex) if dialogType == 0: # start debug dialog + enableMultiprocessGlobal = Preferences.getDebugger( + "MultiProcessEnabled") self.ui.tracePythonCheckBox.setChecked(tracePython) self.ui.tracePythonCheckBox.show() self.ui.autoContinueCheckBox.setChecked(autoContinue) - self.ui.forkModeCheckBox.setChecked(autoFork) - self.ui.forkChildCheckBox.setChecked(forkChild) - - if dialogType == 1: # start run dialog - self.ui.forkModeCheckBox.setChecked(autoFork) - self.ui.forkChildCheckBox.setChecked(forkChild) + self.ui.multiprocessGroup.setEnabled(enableMultiprocessGlobal) + self.ui.multiprocessGroup.setChecked( + enableMultiprocess & enableMultiprocessGlobal) + self.ui.multiprocessNoDebugCombo.clear() + self.ui.multiprocessNoDebugCombo.setToolTip(self.tr( + "Enter the list of programs or program patterns not to be" + " debugged separated by '{0}'.").format(os.pathsep) + ) + if multiprocessNoDebugHistory: + self.ui.multiprocessNoDebugCombo.addItems( + multiprocessNoDebugHistory) + self.ui.multiprocessNoDebugCombo.setCurrentIndex(0) if dialogType == 3: # start coverage or profile dialog self.ui.eraseCheckBox.setChecked(True) @@ -156,9 +168,9 @@ """ Public method to retrieve the data entered into this dialog. - @return a tuple of interpreter (string), argv (string), workdir - (string), environment (string), exceptions flag (boolean), - clear interpreter flag (boolean) and run in console flag (boolean) + @return a tuple of interpreter, argv, workdir, environment, + exceptions flag, clear interpreter flag and run in console flag + @rtype tuple of (str, str, str, str, bool, bool, bool) """ cmdLine = self.ui.cmdlineCombo.currentText() workdir = self.ui.workdirPicker.currentText(toNative=False) @@ -181,41 +193,26 @@ @return a tuple of a flag indicating, if the Python library should be traced as well, a flag indicating, that the debugger should not - stop at the first executable line (boolean), a flag indicating, - that the debugger should fork automatically (boolean) and a flag - indicating, that the debugger should debug the child process after - forking automatically (boolean) + stop at the first executable line, a flag indicating to support + multi process debugging and a space separated list of programs not + to be debugged + @rtype tuple of (bool, bool, bool, str) """ if self.dialogType == 0: return (self.ui.tracePythonCheckBox.isChecked(), self.ui.autoContinueCheckBox.isChecked(), - self.ui.forkModeCheckBox.isChecked(), - self.ui.forkChildCheckBox.isChecked()) + self.ui.multiprocessGroup.isChecked(), + self.ui.multiprocessNoDebugCombo.currentText()) else: - return (False, False, False, False) - - def getRunData(self): - """ - Public method to retrieve the debug related data entered into this - dialog. - - @return a tuple of a flag indicating, that the debugger should fork - automatically (boolean) and a flag indicating, that the debugger - should debug the child process after forking automatically - (boolean) - """ - if self.dialogType == 1: - return (self.ui.forkModeCheckBox.isChecked(), - self.ui.forkChildCheckBox.isChecked()) - else: - return (False, False) - + return (False, False, False, "") + def getCoverageData(self): """ Public method to retrieve the coverage related data entered into this dialog. - @return flag indicating erasure of coverage info (boolean) + @return flag indicating erasure of coverage info + @rtype bool """ if self.dialogType == 2: return self.ui.eraseCheckBox.isChecked() @@ -227,7 +224,8 @@ Public method to retrieve the profiling related data entered into this dialog. - @return flag indicating erasure of profiling info (boolean) + @return flag indicating erasure of profiling info + @rtype bool """ if self.dialogType == 3: return self.ui.eraseCheckBox.isChecked() @@ -253,6 +251,11 @@ self.ui.cmdlineCombo.addItem(cmdLine) self.ui.workdirPicker.addItem(workdir) self.ui.environmentCombo.addItem(environment) + + if self.dialogType == 0: + noDebugList = self.ui.multiprocessNoDebugCombo.currentText() + self.ui.multiprocessNoDebugCombo.clear() + self.ui.multiprocessNoDebugCombo.addItem(noDebugList) def __editHistory(self): """ @@ -264,6 +267,15 @@ self.tr("Working Directory"), self.tr("Environment"), ] + combos = [ + None, + self.ui.cmdlineCombo, + self.ui.workdirPicker, + self.ui.environmentCombo, + ] + if self.dialogType == 0: + histories.append(self.tr("No Debug Programs")) + combos.append(self.ui.multiprocessNoDebugCombo) historyKind, ok = QInputDialog.getItem( self, self.tr("Edit History"), @@ -271,32 +283,27 @@ histories, 0, False) if ok and historyKind: + history = [] historiesIndex = histories.index(historyKind) if historiesIndex == 2: history = self.ui.workdirPicker.getPathItems() else: - history = [] - if historiesIndex == 1: - combo = self.ui.cmdlineCombo - else: - combo = self.ui.environmentCombo - for index in range(combo.count()): - history.append(combo.itemText(index)) + combo = combos[historiesIndex] + if combo: + for index in range(combo.count()): + history.append(combo.itemText(index)) - from .StartHistoryEditDialog import StartHistoryEditDialog - dlg = StartHistoryEditDialog(history, self) + if history: + from .StartHistoryEditDialog import StartHistoryEditDialog + dlg = StartHistoryEditDialog(history, self) if dlg.exec() == QDialog.Accepted: history = dlg.getHistory() - if historiesIndex == 1: - combo = self.ui.cmdlineCombo - elif historiesIndex == 2: - combo = self.ui.workdirPicker - else: - combo = self.ui.environmentCombo - combo.clear() - combo.addItems(history) - - self.__historiesModified = True + combo = combos[historiesIndex] + if combo: + combo.clear() + combo.addItems(history) + + self.__historiesModified = True def historiesModified(self): """ @@ -321,22 +328,32 @@ Public method to get the lists of histories. @return tuple containing the histories of command line arguments, - working directories, environment settings and interpreters + working directories, environment settings and no debug programs + lists @rtype tuple of four list of str """ + if self.dialogType == 0: + noDebugHistory = [ + self.ui.multiprocessNoDebugCombo.itemText(index) + for index in range(self.ui.multiprocessNoDebugCombo.count()) + ] + else: + noDebugHistory = None return ( [self.ui.cmdlineCombo.itemText(index) for index in range( self.ui.cmdlineCombo.count())], self.ui.workdirPicker.getPathItems(), [self.ui.environmentCombo.itemText(index) for index in range( self.ui.environmentCombo.count())], + noDebugHistory, ) def on_buttonBox_clicked(self, button): """ Private slot called by a button of the button box clicked. - @param button button that was clicked (QAbstractButton) + @param button button that was clicked + @type QAbstractButton """ if button == self.clearButton: self.__clearHistories()