eric6/Debugger/DebugUI.py

changeset 8163
29fb6d420a25
parent 8162
8358c3c95841
child 8176
31965986ecd1
child 8218
7c09585bd960
equal deleted inserted replaced
8162:8358c3c95841 8163:29fb6d420a25
6 """ 6 """
7 Module implementing the debugger UI. 7 Module implementing the debugger UI.
8 """ 8 """
9 9
10 import os 10 import os
11 import copy
11 12
12 from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, Qt 13 from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, Qt
13 from PyQt5.QtGui import QKeySequence 14 from PyQt5.QtGui import QKeySequence
14 from PyQt5.QtWidgets import QMenu, QToolBar, QApplication, QDialog 15 from PyQt5.QtWidgets import QMenu, QToolBar, QApplication, QDialog
15 16
108 Preferences.Prefs.settings.value( 109 Preferences.Prefs.settings.value(
109 'DebugInfo/EnableMultiprocess', False)) 110 'DebugInfo/EnableMultiprocess', False))
110 self.multiprocessNoDebugHistory = Preferences.toList( 111 self.multiprocessNoDebugHistory = Preferences.toList(
111 Preferences.Prefs.settings.value( 112 Preferences.Prefs.settings.value(
112 'DebugInfo/MultiprocessNoDebugHistory')) 113 'DebugInfo/MultiprocessNoDebugHistory'))
113 self.overrideGlobalConfig = Preferences.toBool( 114 self.overrideGlobalConfig = {
114 Preferences.Prefs.settings.value( 115 "enable": Preferences.toBool(Preferences.Prefs.settings.value(
115 'DebugInfo/OverrideGlobal', False)) 116 'DebugInfo/OverrideGlobal', False)),
116 self.redirectStdinAndStdout = Preferences.toBool( 117 "redirect": Preferences.toBool(Preferences.Prefs.settings.value(
117 Preferences.Prefs.settings.value( 118 'DebugInfo/RedirectStdinStdout', True)),
118 'DebugInfo/RedirectStdinStdout', True)) 119 }
119 120
120 self.lastDebuggedFile = None 121 self.lastDebuggedFile = None
121 self.lastStartAction = 0 # 0=None, 1=Script, 2=Project 122 self.lastStartAction = 0 # 0=None, 1=Script, 2=Project
122 self.clientType = "" 123 self.clientType = ""
123 self.lastAction = -1 124 self.lastAction = -1
1010 Preferences.Prefs.settings.setValue( 1011 Preferences.Prefs.settings.setValue(
1011 'DebugInfo/MultiprocessNoDebugHistory', 1012 'DebugInfo/MultiprocessNoDebugHistory',
1012 self.multiprocessNoDebugHistory) 1013 self.multiprocessNoDebugHistory)
1013 Preferences.Prefs.settings.setValue( 1014 Preferences.Prefs.settings.setValue(
1014 'DebugInfo/OverrideGlobal', 1015 'DebugInfo/OverrideGlobal',
1015 self.overrideGlobalConfig) 1016 self.overrideGlobalConfig["enable"])
1016 Preferences.Prefs.settings.setValue( 1017 Preferences.Prefs.settings.setValue(
1017 'DebugInfo/RedirectStdinStdout', 1018 'DebugInfo/RedirectStdinStdout',
1018 self.redirectStdinAndStdout) 1019 self.overrideGlobalConfig["redirect"])
1019 1020
1020 def shutdownServer(self): 1021 def shutdownServer(self):
1021 """ 1022 """
1022 Public method to shut down the debug server. 1023 Public method to shut down the debug server.
1023 1024
1701 else: 1702 else:
1702 cap = self.tr("Coverage of Script") 1703 cap = self.tr("Coverage of Script")
1703 dlg = StartDialog( 1704 dlg = StartDialog(
1704 cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory, 1705 cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
1705 self.envHistory, self.exceptions, self.ui, 2, 1706 self.envHistory, self.exceptions, self.ui, 2,
1706 autoClearShell=self.autoClearShell) 1707 autoClearShell=self.autoClearShell,
1708 configOverride=self.overrideGlobalConfig)
1707 if dlg.exec() == QDialog.DialogCode.Accepted: 1709 if dlg.exec() == QDialog.DialogCode.Accepted:
1708 (lastUsedVenvName, argv, wd, env, exceptions, clearShell, 1710 (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
1709 console) = dlg.getData() 1711 console) = dlg.getData()
1712 configOverride = dlg.getGlobalOverrideData()
1710 eraseCoverage = dlg.getCoverageData() 1713 eraseCoverage = dlg.getCoverageData()
1711 1714
1712 if runProject: 1715 if runProject:
1713 fn = self.project.getMainScript(True) 1716 fn = self.project.getMainScript(True)
1714 if fn is None: 1717 if fn is None:
1727 doNotStart = True 1730 doNotStart = True
1728 1731
1729 # save the info for later use 1732 # save the info for later use
1730 self.project.setDbgInfo( 1733 self.project.setDbgInfo(
1731 lastUsedVenvName, argv, wd, env, exceptions, self.excList, 1734 lastUsedVenvName, argv, wd, env, exceptions, self.excList,
1732 self.excIgnoreList, clearShell 1735 self.excIgnoreList, clearShell,
1736 configOverride=configOverride
1733 ) 1737 )
1734 1738
1735 self.lastStartAction = 6 1739 self.lastStartAction = 6
1736 self.clientType = self.project.getProjectLanguage() 1740 self.clientType = self.project.getProjectLanguage()
1737 else: 1741 else:
1773 self.autoClearShell = clearShell 1777 self.autoClearShell = clearShell
1774 1778
1775 # Save the run in console flag 1779 # Save the run in console flag
1776 self.runInConsole = console 1780 self.runInConsole = console
1777 1781
1782 # Save the global config override data
1783 self.overrideGlobalConfig = copy.deepcopy(configOverride)
1784
1778 # Hide all error highlights 1785 # Hide all error highlights
1779 self.viewmanager.unhighlight() 1786 self.viewmanager.unhighlight()
1780 1787
1781 if not doNotStart: 1788 if not doNotStart:
1782 if runProject and self.project.getProjectType() in [ 1789 if runProject and self.project.getProjectType() in [
1789 # Ask the client to open the new program. 1796 # Ask the client to open the new program.
1790 self.debugServer.remoteCoverage( 1797 self.debugServer.remoteCoverage(
1791 lastUsedVenvName, fn, argv, wd, env, 1798 lastUsedVenvName, fn, argv, wd, env,
1792 autoClearShell=self.autoClearShell, erase=eraseCoverage, 1799 autoClearShell=self.autoClearShell, erase=eraseCoverage,
1793 forProject=runProject, runInConsole=console, 1800 forProject=runProject, runInConsole=console,
1794 clientType=self.clientType) 1801 clientType=self.clientType,
1802 configOverride=self.overrideGlobalConfig)
1795 1803
1796 self.stopAct.setEnabled(True) 1804 self.stopAct.setEnabled(True)
1797 1805
1798 if dlg.clearHistories(): 1806 if dlg.clearHistories():
1799 self.setArgvHistory("", clearHistories=True) 1807 self.setArgvHistory("", clearHistories=True)
1838 else: 1846 else:
1839 cap = self.tr("Profile of Script") 1847 cap = self.tr("Profile of Script")
1840 dlg = StartDialog( 1848 dlg = StartDialog(
1841 cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory, 1849 cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
1842 self.envHistory, self.exceptions, self.ui, 3, 1850 self.envHistory, self.exceptions, self.ui, 3,
1843 autoClearShell=self.autoClearShell) 1851 autoClearShell=self.autoClearShell,
1852 configOverride=self.overrideGlobalConfig)
1844 if dlg.exec() == QDialog.DialogCode.Accepted: 1853 if dlg.exec() == QDialog.DialogCode.Accepted:
1845 (lastUsedVenvName, argv, wd, env, exceptions, clearShell, 1854 (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
1846 console) = dlg.getData() 1855 console) = dlg.getData()
1856 configOverride = dlg.getGlobalOverrideData()
1847 eraseTimings = dlg.getProfilingData() 1857 eraseTimings = dlg.getProfilingData()
1848 1858
1849 if runProject: 1859 if runProject:
1850 fn = self.project.getMainScript(True) 1860 fn = self.project.getMainScript(True)
1851 if fn is None: 1861 if fn is None:
1864 doNotStart = True 1874 doNotStart = True
1865 1875
1866 # save the info for later use 1876 # save the info for later use
1867 self.project.setDbgInfo( 1877 self.project.setDbgInfo(
1868 lastUsedVenvName, argv, wd, env, exceptions, self.excList, 1878 lastUsedVenvName, argv, wd, env, exceptions, self.excList,
1869 self.excIgnoreList, clearShell 1879 self.excIgnoreList, clearShell,
1880 configOverride=configOverride
1870 ) 1881 )
1871 1882
1872 self.lastStartAction = 8 1883 self.lastStartAction = 8
1873 self.clientType = self.project.getProjectLanguage() 1884 self.clientType = self.project.getProjectLanguage()
1874 else: 1885 else:
1910 self.autoClearShell = clearShell 1921 self.autoClearShell = clearShell
1911 1922
1912 # Save the run in console flag 1923 # Save the run in console flag
1913 self.runInConsole = console 1924 self.runInConsole = console
1914 1925
1926 # Save the global config override data
1927 self.overrideGlobalConfig = copy.deepcopy(configOverride)
1928
1915 # Hide all error highlights 1929 # Hide all error highlights
1916 self.viewmanager.unhighlight() 1930 self.viewmanager.unhighlight()
1917 1931
1918 if not doNotStart: 1932 if not doNotStart:
1919 if runProject and self.project.getProjectType() in [ 1933 if runProject and self.project.getProjectType() in [
1926 # Ask the client to open the new program. 1940 # Ask the client to open the new program.
1927 self.debugServer.remoteProfile( 1941 self.debugServer.remoteProfile(
1928 lastUsedVenvName, fn, argv, wd, env, 1942 lastUsedVenvName, fn, argv, wd, env,
1929 autoClearShell=self.autoClearShell, erase=eraseTimings, 1943 autoClearShell=self.autoClearShell, erase=eraseTimings,
1930 forProject=runProject, runInConsole=console, 1944 forProject=runProject, runInConsole=console,
1931 clientType=self.clientType) 1945 clientType=self.clientType,
1946 configOverride=self.overrideGlobalConfig)
1932 1947
1933 self.stopAct.setEnabled(True) 1948 self.stopAct.setEnabled(True)
1934 1949
1935 if dlg.clearHistories(): 1950 if dlg.clearHistories():
1936 self.setArgvHistory("", clearHistories=True) 1951 self.setArgvHistory("", clearHistories=True)
1976 cap = self.tr("Run Script") 1991 cap = self.tr("Run Script")
1977 dlg = StartDialog( 1992 dlg = StartDialog(
1978 cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory, 1993 cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
1979 self.envHistory, self.exceptions, self.ui, 1, 1994 self.envHistory, self.exceptions, self.ui, 1,
1980 autoClearShell=self.autoClearShell, 1995 autoClearShell=self.autoClearShell,
1981 enableConfigOverride=self.overrideGlobalConfig, 1996 configOverride=self.overrideGlobalConfig)
1982 enableRedirect=self.redirectStdinAndStdout)
1983 if dlg.exec() == QDialog.DialogCode.Accepted: 1997 if dlg.exec() == QDialog.DialogCode.Accepted:
1984 (lastUsedVenvName, argv, wd, env, exceptions, clearShell, 1998 (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
1985 console) = dlg.getData() 1999 console) = dlg.getData()
1986 enableConfigOverride, enableRedirect = dlg.getGlobalOverrideData() 2000 configOverride = dlg.getGlobalOverrideData()
1987 2001
1988 if runProject: 2002 if runProject:
1989 fn = self.project.getMainScript(True) 2003 fn = self.project.getMainScript(True)
1990 if fn is None: 2004 if fn is None:
1991 E5MessageBox.critical( 2005 E5MessageBox.critical(
2001 not self.project.saveAllScripts(reportSyntaxErrors=True) 2015 not self.project.saveAllScripts(reportSyntaxErrors=True)
2002 ): 2016 ):
2003 doNotStart = True 2017 doNotStart = True
2004 2018
2005 # save the info for later use 2019 # save the info for later use
2006 # TODO: add global config override data
2007 self.project.setDbgInfo( 2020 self.project.setDbgInfo(
2008 lastUsedVenvName, argv, wd, env, exceptions, self.excList, 2021 lastUsedVenvName, argv, wd, env, exceptions, self.excList,
2009 self.excIgnoreList, clearShell 2022 self.excIgnoreList, clearShell,
2023 configOverride=configOverride
2010 ) 2024 )
2011 2025
2012 self.lastStartAction = 4 2026 self.lastStartAction = 4
2013 self.clientType = self.project.getProjectLanguage() 2027 self.clientType = self.project.getProjectLanguage()
2014 else: 2028 else:
2049 2063
2050 # Save the run in console flag 2064 # Save the run in console flag
2051 self.runInConsole = console 2065 self.runInConsole = console
2052 2066
2053 # Save the global config override data 2067 # Save the global config override data
2054 self.overrideGlobalConfig = enableConfigOverride 2068 self.overrideGlobalConfig = copy.deepcopy(configOverride)
2055 self.redirectStdinAndStdout = enableRedirect
2056 2069
2057 # Hide all error highlights 2070 # Hide all error highlights
2058 self.viewmanager.unhighlight() 2071 self.viewmanager.unhighlight()
2059 2072
2060 if not doNotStart: 2073 if not doNotStart:
2064 fn = os.path.join(getConfig('ericDir'), "eric6.py") 2077 fn = os.path.join(getConfig('ericDir'), "eric6.py")
2065 2078
2066 self.debugViewer.initCallStackViewer(runProject) 2079 self.debugViewer.initCallStackViewer(runProject)
2067 2080
2068 # Ask the client to open the new program. 2081 # Ask the client to open the new program.
2069 # TODO: add global config override data
2070 self.debugServer.remoteRun( 2082 self.debugServer.remoteRun(
2071 lastUsedVenvName, fn, argv, wd, env, 2083 lastUsedVenvName, fn, argv, wd, env,
2072 autoClearShell=self.autoClearShell, forProject=runProject, 2084 autoClearShell=self.autoClearShell, forProject=runProject,
2073 runInConsole=console, clientType=self.clientType) 2085 runInConsole=console, clientType=self.clientType,
2086 configOverride=self.overrideGlobalConfig)
2074 2087
2075 self.stopAct.setEnabled(True) 2088 self.stopAct.setEnabled(True)
2076 2089
2077 if dlg.clearHistories(): 2090 if dlg.clearHistories():
2078 self.setArgvHistory("", clearHistories=True) 2091 self.setArgvHistory("", clearHistories=True)
2120 cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory, 2133 cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
2121 self.envHistory, self.exceptions, self.ui, 0, 2134 self.envHistory, self.exceptions, self.ui, 0,
2122 tracePython=self.tracePython, autoClearShell=self.autoClearShell, 2135 tracePython=self.tracePython, autoClearShell=self.autoClearShell,
2123 autoContinue=self.autoContinue, 2136 autoContinue=self.autoContinue,
2124 enableMultiprocess=self.enableMultiprocess, 2137 enableMultiprocess=self.enableMultiprocess,
2125 multiprocessNoDebugHistory=self.multiprocessNoDebugHistory) 2138 multiprocessNoDebugHistory=self.multiprocessNoDebugHistory,
2139 configOverride=self.overrideGlobalConfig)
2126 if dlg.exec() == QDialog.DialogCode.Accepted: 2140 if dlg.exec() == QDialog.DialogCode.Accepted:
2127 (lastUsedVenvName, argv, wd, env, exceptions, clearShell, 2141 (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
2128 console) = dlg.getData() 2142 console) = dlg.getData()
2143 configOverride = dlg.getGlobalOverrideData()
2129 (tracePython, autoContinue, enableMultiprocess, 2144 (tracePython, autoContinue, enableMultiprocess,
2130 multiprocessNoDebug) = dlg.getDebugData() 2145 multiprocessNoDebug) = dlg.getDebugData()
2131 2146
2132 if debugProject: 2147 if debugProject:
2133 fn = self.project.getMainScript(True) 2148 fn = self.project.getMainScript(True)
2150 self.project.setDbgInfo( 2165 self.project.setDbgInfo(
2151 lastUsedVenvName, argv, wd, env, exceptions, self.excList, 2166 lastUsedVenvName, argv, wd, env, exceptions, self.excList,
2152 self.excIgnoreList, clearShell, tracePython=tracePython, 2167 self.excIgnoreList, clearShell, tracePython=tracePython,
2153 autoContinue=autoContinue, 2168 autoContinue=autoContinue,
2154 enableMultiprocess=enableMultiprocess, 2169 enableMultiprocess=enableMultiprocess,
2155 multiprocessNoDebug=multiprocessNoDebug 2170 multiprocessNoDebug=multiprocessNoDebug,
2171 configOverride=configOverride
2156 ) 2172 )
2157 2173
2158 self.lastStartAction = 2 2174 self.lastStartAction = 2
2159 self.clientType = self.project.getProjectLanguage() 2175 self.clientType = self.project.getProjectLanguage()
2160 else: 2176 else:
2203 2219
2204 # Save the multiprocess debugging data 2220 # Save the multiprocess debugging data
2205 self.enableMultiprocess = enableMultiprocess 2221 self.enableMultiprocess = enableMultiprocess
2206 self.setMultiprocessNoDebugHistory(multiprocessNoDebug) 2222 self.setMultiprocessNoDebugHistory(multiprocessNoDebug)
2207 2223
2224 # Save the global config override data
2225 self.overrideGlobalConfig = copy.deepcopy(configOverride)
2226
2208 # Hide all error highlights 2227 # Hide all error highlights
2209 self.viewmanager.unhighlight() 2228 self.viewmanager.unhighlight()
2210 2229
2211 if not doNotStart: 2230 if not doNotStart:
2212 if debugProject and self.project.getProjectType() in [ 2231 if debugProject and self.project.getProjectType() in [
2229 tracePython=tracePython, 2248 tracePython=tracePython,
2230 autoContinue=autoContinue, forProject=debugProject, 2249 autoContinue=autoContinue, forProject=debugProject,
2231 runInConsole=console, clientType=self.clientType, 2250 runInConsole=console, clientType=self.clientType,
2232 enableCallTrace=enableCallTrace, 2251 enableCallTrace=enableCallTrace,
2233 enableMultiprocess=enableMultiprocess, 2252 enableMultiprocess=enableMultiprocess,
2234 multiprocessNoDebug=multiprocessNoDebug) 2253 multiprocessNoDebug=multiprocessNoDebug,
2254 configOverride=self.overrideGlobalConfig)
2235 2255
2236 if ( 2256 if (
2237 self.debugServer.isClientProcessUp() and 2257 self.debugServer.isClientProcessUp() and
2238 self.debugServer.getClientType() == self.clientType 2258 self.debugServer.getClientType() == self.clientType
2239 ): 2259 ):
2318 forProject=forProject, 2338 forProject=forProject,
2319 runInConsole=self.runInConsole, 2339 runInConsole=self.runInConsole,
2320 clientType=self.clientType, 2340 clientType=self.clientType,
2321 enableCallTrace=enableCallTrace, 2341 enableCallTrace=enableCallTrace,
2322 enableMultiprocess=self.enableMultiprocess, 2342 enableMultiprocess=self.enableMultiprocess,
2323 multiprocessNoDebug=multiprocessNoDebug) 2343 multiprocessNoDebug=multiprocessNoDebug,
2344 configOverride=self.overrideGlobalConfig)
2324 2345
2325 # Signal that we have started a debugging session 2346 # Signal that we have started a debugging session
2326 self.debuggingStarted.emit(fn) 2347 self.debuggingStarted.emit(fn)
2327 2348
2328 elif self.lastStartAction in [3, 4]: 2349 elif self.lastStartAction in [3, 4]:
2330 self.debugServer.remoteRun( 2351 self.debugServer.remoteRun(
2331 venvName, fn, argv, wd, env, 2352 venvName, fn, argv, wd, env,
2332 autoClearShell=self.autoClearShell, 2353 autoClearShell=self.autoClearShell,
2333 forProject=forProject, 2354 forProject=forProject,
2334 runInConsole=self.runInConsole, 2355 runInConsole=self.runInConsole,
2335 clientType=self.clientType) 2356 clientType=self.clientType,
2357 configOverride=self.overrideGlobalConfig)
2336 2358
2337 elif self.lastStartAction in [5, 6]: 2359 elif self.lastStartAction in [5, 6]:
2338 # Ask the client to coverage run the new program. 2360 # Ask the client to coverage run the new program.
2339 self.debugServer.remoteCoverage( 2361 self.debugServer.remoteCoverage(
2340 venvName, fn, argv, wd, env, 2362 venvName, fn, argv, wd, env,
2341 autoClearShell=self.autoClearShell, 2363 autoClearShell=self.autoClearShell,
2342 erase=self.eraseCoverage, 2364 erase=self.eraseCoverage,
2343 forProject=forProject, 2365 forProject=forProject,
2344 runInConsole=self.runInConsole, 2366 runInConsole=self.runInConsole,
2345 clientType=self.clientType) 2367 clientType=self.clientType,
2368 configOverride=self.overrideGlobalConfig)
2346 2369
2347 elif self.lastStartAction in [7, 8]: 2370 elif self.lastStartAction in [7, 8]:
2348 # Ask the client to profile run the new program. 2371 # Ask the client to profile run the new program.
2349 self.debugServer.remoteProfile( 2372 self.debugServer.remoteProfile(
2350 venvName, fn, argv, wd, env, 2373 venvName, fn, argv, wd, env,
2351 autoClearShell=self.autoClearShell, 2374 autoClearShell=self.autoClearShell,
2352 erase=self.eraseTimings, 2375 erase=self.eraseTimings,
2353 forProject=forProject, 2376 forProject=forProject,
2354 runInConsole=self.runInConsole, 2377 runInConsole=self.runInConsole,
2355 clientType=self.clientType) 2378 clientType=self.clientType,
2379 configOverride=self.overrideGlobalConfig)
2356 2380
2357 self.stopAct.setEnabled(True) 2381 self.stopAct.setEnabled(True)
2358 2382
2359 def __stopScript(self): 2383 def __stopScript(self):
2360 """ 2384 """
2587 run in multi process mode 2611 run in multi process mode
2588 @type bool 2612 @type bool
2589 """ 2613 """
2590 self.enableMultiprocess = enableMultiprocess 2614 self.enableMultiprocess = enableMultiprocess
2591 2615
2592 def setEnableGlobalConfigOverride(self, override, redirect): 2616 def setEnableGlobalConfigOverride(self, overrideData):
2593 """ 2617 """
2594 Public method to initialize the global config override data. 2618 Public method to initialize the global config override data.
2595 2619
2596 @param override flag indicating to enable global config override 2620 @param overrideData dictionary containing a flag indicating to enable
2597 @type bool 2621 global config override and a flag indicating to redirect
2598 @param redirect flag indicating to redirect stdin/stdout/stderr 2622 stdin/stdout/stderr
2599 @type bool 2623 @type dict
2600 """ 2624 """
2601 self.overrideGlobalConfig = override 2625 self.overrideGlobalConfig = copy.deepcopy(overrideData)
2602 self.redirectStdinAndStdout = redirect

eric ide

mercurial