eric6/Debugger/DebugUI.py

branch
multi_processing
changeset 7411
6d8dcb3551b3
parent 7410
401791e6f50f
child 7415
e953b2a449a9
equal deleted inserted replaced
7410:401791e6f50f 7411:6d8dcb3551b3
109 self.forkIntoChild = Preferences.toBool( 109 self.forkIntoChild = Preferences.toBool(
110 Preferences.Prefs.settings.value('DebugInfo/ForkIntoChild', False)) 110 Preferences.Prefs.settings.value('DebugInfo/ForkIntoChild', False))
111 self.enableMultiprocess = Preferences.toBool( 111 self.enableMultiprocess = Preferences.toBool(
112 Preferences.Prefs.settings.value( 112 Preferences.Prefs.settings.value(
113 'DebugInfo/EnableMultiprocess', False)) 113 'DebugInfo/EnableMultiprocess', False))
114 self.multiprocessNoDebugHistory = Preferences.toList(
115 Preferences.Prefs.settings.value(
116 'DebugInfo/MultiprocessNoDebugHistory'))
114 117
115 self.lastDebuggedFile = None 118 self.lastDebuggedFile = None
116 self.lastStartAction = 0 # 0=None, 1=Script, 2=Project 119 self.lastStartAction = 0 # 0=None, 1=Script, 2=Project
117 self.clientType = "" 120 self.clientType = ""
118 self.lastAction = -1 121 self.lastAction = -1
916 Public method to clear the various debug histories. 919 Public method to clear the various debug histories.
917 """ 920 """
918 self.argvHistory = [] 921 self.argvHistory = []
919 self.wdHistory = [] 922 self.wdHistory = []
920 self.envHistory = [] 923 self.envHistory = []
924 self.multiprocessNoDebugHistory = []
921 925
922 Preferences.Prefs.settings.setValue( 926 Preferences.Prefs.settings.setValue(
923 'DebugInfo/ArgumentsHistory', self.argvHistory) 927 'DebugInfo/ArgumentsHistory', self.argvHistory)
924 Preferences.Prefs.settings.setValue( 928 Preferences.Prefs.settings.setValue(
925 'DebugInfo/WorkingDirectoryHistory', self.wdHistory) 929 'DebugInfo/WorkingDirectoryHistory', self.wdHistory)
926 Preferences.Prefs.settings.setValue( 930 Preferences.Prefs.settings.setValue(
927 'DebugInfo/EnvironmentHistory', self.envHistory) 931 'DebugInfo/EnvironmentHistory', self.envHistory)
932 Preferences.Prefs.settings.setValue(
933 'DebugInfo/MultiprocessNoDebugHistory',
934 self.multiprocessNoDebugHistory)
928 935
929 def shutdown(self): 936 def shutdown(self):
930 """ 937 """
931 Public method to perform shutdown actions. 938 Public method to perform shutdown actions.
932 """ 939 """
959 'DebugInfo/ForkAutomatically', self.forkAutomatically) 966 'DebugInfo/ForkAutomatically', self.forkAutomatically)
960 Preferences.Prefs.settings.setValue( 967 Preferences.Prefs.settings.setValue(
961 'DebugInfo/ForkIntoChild', self.forkIntoChild) 968 'DebugInfo/ForkIntoChild', self.forkIntoChild)
962 Preferences.Prefs.settings.setValue( 969 Preferences.Prefs.settings.setValue(
963 'DebugInfo/EnableMultiprocess', self.enableMultiprocess) 970 'DebugInfo/EnableMultiprocess', self.enableMultiprocess)
971 Preferences.Prefs.settings.setValue(
972 'DebugInfo/MultiprocessNoDebugHistory',
973 self.multiprocessNoDebugHistory)
964 974
965 def shutdownServer(self): 975 def shutdownServer(self):
966 """ 976 """
967 Public method to shut down the debug server. 977 Public method to shut down the debug server.
968 978
1244 if exceptionType not in self.excIgnoreList: 1254 if exceptionType not in self.excIgnoreList:
1245 self.excIgnoreList.append(exceptionType) 1255 self.excIgnoreList.append(exceptionType)
1246 1256
1247 if self.lastAction != -1: 1257 if self.lastAction != -1:
1248 if self.lastAction == 2: 1258 if self.lastAction == 2:
1249 self.__specialContinue() 1259 self.__specialContinue(debuggerId)
1250 else: 1260 else:
1251 self.debugActions[self.lastAction]() 1261 self.debugActions[self.lastAction](debuggerId)
1252 else: 1262 else:
1253 self.__continue() 1263 self.__continue(debuggerId)
1254 1264
1255 def __clientSignal(self, message, filename, lineNo, funcName, funcArgs, 1265 def __clientSignal(self, message, filename, lineNo, funcName, funcArgs,
1256 debuggerId): 1266 debuggerId):
1257 """ 1267 """
1258 Private method to handle a signal generated on the client side. 1268 Private method to handle a signal generated on the client side.
1715 1725
1716 if dlg.clearHistories(): 1726 if dlg.clearHistories():
1717 self.setArgvHistory("", clearHistories=True) 1727 self.setArgvHistory("", clearHistories=True)
1718 self.setWdHistory("", clearHistories=True) 1728 self.setWdHistory("", clearHistories=True)
1719 self.setEnvHistory("", clearHistories=True) 1729 self.setEnvHistory("", clearHistories=True)
1730 self.setMultiprocessNoDebugHistory("", clearHistories=True)
1720 elif dlg.historiesModified(): 1731 elif dlg.historiesModified():
1721 argvHistory, wdHistory, envHistory = dlg.getHistories() 1732 argvHistory, wdHistory, envHistory, _ = dlg.getHistories()
1722 self.setArgvHistory("", history=argvHistory) 1733 self.setArgvHistory("", history=argvHistory)
1723 self.setWdHistory("", history=wdHistory) 1734 self.setWdHistory("", history=wdHistory)
1724 self.setEnvHistory("", history=envHistory) 1735 self.setEnvHistory("", history=envHistory)
1725 1736
1726 def __profileScript(self): 1737 def __profileScript(self):
1850 1861
1851 if dlg.clearHistories(): 1862 if dlg.clearHistories():
1852 self.setArgvHistory("", clearHistories=True) 1863 self.setArgvHistory("", clearHistories=True)
1853 self.setWdHistory("", clearHistories=True) 1864 self.setWdHistory("", clearHistories=True)
1854 self.setEnvHistory("", clearHistories=True) 1865 self.setEnvHistory("", clearHistories=True)
1866 self.setMultiprocessNoDebugHistory("", clearHistories=True)
1855 elif dlg.historiesModified(): 1867 elif dlg.historiesModified():
1856 argvHistory, wdHistory, envHistory = dlg.getHistories() 1868 argvHistory, wdHistory, envHistory, _ = dlg.getHistories()
1857 self.setArgvHistory("", history=argvHistory) 1869 self.setArgvHistory("", history=argvHistory)
1858 self.setWdHistory("", history=wdHistory) 1870 self.setWdHistory("", history=wdHistory)
1859 self.setEnvHistory("", history=envHistory) 1871 self.setEnvHistory("", history=envHistory)
1860 1872
1861 def __runScript(self): 1873 def __runScript(self):
1989 2001
1990 if dlg.clearHistories(): 2002 if dlg.clearHistories():
1991 self.setArgvHistory("", clearHistories=True) 2003 self.setArgvHistory("", clearHistories=True)
1992 self.setWdHistory("", clearHistories=True) 2004 self.setWdHistory("", clearHistories=True)
1993 self.setEnvHistory("", clearHistories=True) 2005 self.setEnvHistory("", clearHistories=True)
2006 self.setMultiprocessNoDebugHistory("", clearHistories=True)
1994 elif dlg.historiesModified(): 2007 elif dlg.historiesModified():
1995 argvHistory, wdHistory, envHistory = dlg.getHistories() 2008 argvHistory, wdHistory, envHistory, _ = dlg.getHistories()
1996 self.setArgvHistory("", history=argvHistory) 2009 self.setArgvHistory("", history=argvHistory)
1997 self.setWdHistory("", history=wdHistory) 2010 self.setWdHistory("", history=wdHistory)
1998 self.setEnvHistory("", history=envHistory) 2011 self.setEnvHistory("", history=envHistory)
1999 2012
2000 def __debugScript(self): 2013 def __debugScript(self):
2032 cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory, 2045 cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
2033 self.envHistory, self.exceptions, self.ui, 0, 2046 self.envHistory, self.exceptions, self.ui, 0,
2034 tracePython=self.tracePython, autoClearShell=self.autoClearShell, 2047 tracePython=self.tracePython, autoClearShell=self.autoClearShell,
2035 autoContinue=self.autoContinue, autoFork=self.forkAutomatically, 2048 autoContinue=self.autoContinue, autoFork=self.forkAutomatically,
2036 forkChild=self.forkIntoChild, 2049 forkChild=self.forkIntoChild,
2037 enableMultiprocess=self.enableMultiprocess) 2050 enableMultiprocess=self.enableMultiprocess,
2051 multiprocessNoDebugHistory=self.multiprocessNoDebugHistory)
2038 if dlg.exec_() == QDialog.Accepted: 2052 if dlg.exec_() == QDialog.Accepted:
2039 (lastUsedVenvName, argv, wd, env, exceptions, clearShell, 2053 (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
2040 console) = dlg.getData() 2054 console) = dlg.getData()
2041 (tracePython, autoContinue, forkAutomatically, forkIntoChild, 2055 (tracePython, autoContinue, forkAutomatically, forkIntoChild,
2042 enableMultiprocess) = dlg.getDebugData() 2056 enableMultiprocess, multiprocessNoDebug,
2057 ) = dlg.getDebugData()
2043 2058
2044 if debugProject: 2059 if debugProject:
2045 fn = self.project.getMainScript(True) 2060 fn = self.project.getMainScript(True)
2046 if fn is None: 2061 if fn is None:
2047 E5MessageBox.critical( 2062 E5MessageBox.critical(
2112 2127
2113 # Save the forking flags 2128 # Save the forking flags
2114 self.forkAutomatically = forkAutomatically 2129 self.forkAutomatically = forkAutomatically
2115 self.forkIntoChild = forkIntoChild 2130 self.forkIntoChild = forkIntoChild
2116 2131
2117 # Save the multiprocess debugging flag 2132 # Save the multiprocess debugging data
2118 self.enableMultiprocess = enableMultiprocess 2133 self.enableMultiprocess = enableMultiprocess
2134 self.setMultiprocessNoDebugHistory(multiprocessNoDebug)
2119 2135
2120 # Hide all error highlights 2136 # Hide all error highlights
2121 self.viewmanager.unhighlight() 2137 self.viewmanager.unhighlight()
2122 2138
2123 if not doNotStart: 2139 if not doNotStart:
2141 tracePython=tracePython, 2157 tracePython=tracePython,
2142 autoContinue=autoContinue, forProject=debugProject, 2158 autoContinue=autoContinue, forProject=debugProject,
2143 runInConsole=console, autoFork=forkAutomatically, 2159 runInConsole=console, autoFork=forkAutomatically,
2144 forkChild=forkIntoChild, clientType=self.clientType, 2160 forkChild=forkIntoChild, clientType=self.clientType,
2145 enableCallTrace=enableCallTrace, 2161 enableCallTrace=enableCallTrace,
2146 enableMultiprocess=enableMultiprocess) 2162 enableMultiprocess=enableMultiprocess,
2163 multiprocessNoDebug=multiprocessNoDebug)
2147 2164
2148 if ( 2165 if (
2149 self.debugServer.isClientProcessUp() and 2166 self.debugServer.isClientProcessUp() and
2150 self.debugServer.getClientType() == self.clientType 2167 self.debugServer.getClientType() == self.clientType
2151 ): 2168 ):
2156 2173
2157 if dlg.clearHistories(): 2174 if dlg.clearHistories():
2158 self.setArgvHistory("", clearHistories=True) 2175 self.setArgvHistory("", clearHistories=True)
2159 self.setWdHistory("", clearHistories=True) 2176 self.setWdHistory("", clearHistories=True)
2160 self.setEnvHistory("", clearHistories=True) 2177 self.setEnvHistory("", clearHistories=True)
2178 self.setMultiprocessNoDebugHistory("", clearHistories=True)
2161 elif dlg.historiesModified(): 2179 elif dlg.historiesModified():
2162 argvHistory, wdHistory, envHistory = dlg.getHistories() 2180 (argvHistory, wdHistory, envHistory,
2181 noDebugHistory) = dlg.getHistories()
2163 self.setArgvHistory("", history=argvHistory) 2182 self.setArgvHistory("", history=argvHistory)
2164 self.setWdHistory("", history=wdHistory) 2183 self.setWdHistory("", history=wdHistory)
2165 self.setEnvHistory("", history=envHistory) 2184 self.setEnvHistory("", history=envHistory)
2185 self.setMultiprocessNoDebugHistory("", history=noDebugHistory)
2166 2186
2167 def __doRestart(self): 2187 def __doRestart(self):
2168 """ 2188 """
2169 Private slot to handle the restart action to restart the last 2189 Private slot to handle the restart action to restart the last
2170 debugged file. 2190 debugged file.
2214 if self.lastStartAction in [1, 2]: 2234 if self.lastStartAction in [1, 2]:
2215 # Ask the client to send call trace info 2235 # Ask the client to send call trace info
2216 enableCallTrace = self.debugViewer.isCallTraceEnabled() 2236 enableCallTrace = self.debugViewer.isCallTraceEnabled()
2217 self.debugViewer.clearCallTrace() 2237 self.debugViewer.clearCallTrace()
2218 self.debugViewer.setCallTraceToProjectMode(forProject) 2238 self.debugViewer.setCallTraceToProjectMode(forProject)
2239 multiprocessNoDebug = self.multiprocessNoDebugHistory[0]
2219 2240
2220 # Ask the client to debug the new program. 2241 # Ask the client to debug the new program.
2221 self.debugServer.remoteLoad( 2242 self.debugServer.remoteLoad(
2222 venvName, fn, argv, wd, env, 2243 venvName, fn, argv, wd, env,
2223 autoClearShell=self.autoClearShell, 2244 autoClearShell=self.autoClearShell,
2227 runInConsole=self.runInConsole, 2248 runInConsole=self.runInConsole,
2228 autoFork=self.forkAutomatically, 2249 autoFork=self.forkAutomatically,
2229 forkChild=self.forkIntoChild, 2250 forkChild=self.forkIntoChild,
2230 clientType=self.clientType, 2251 clientType=self.clientType,
2231 enableCallTrace=enableCallTrace, 2252 enableCallTrace=enableCallTrace,
2232 enableMultiprocess=self.enableMultiprocess) 2253 enableMultiprocess=self.enableMultiprocess,
2254 multiprocessNoDebug=multiprocessNoDebug)
2233 2255
2234 # Signal that we have started a debugging session 2256 # Signal that we have started a debugging session
2235 self.debuggingStarted.emit(fn) 2257 self.debuggingStarted.emit(fn)
2236 2258
2237 elif self.lastStartAction in [3, 4]: 2259 elif self.lastStartAction in [3, 4]:
2293 self.debuggingStarted.emit(fn) 2315 self.debuggingStarted.emit(fn)
2294 2316
2295 # Initialize the call stack viewer 2317 # Initialize the call stack viewer
2296 self.debugViewer.initCallStackViewer(False) 2318 self.debugViewer.initCallStackViewer(False)
2297 2319
2298 def __continue(self): 2320 def __continue(self, debuggerId=""):
2299 """ 2321 """
2300 Private method to handle the Continue action. 2322 Private method to handle the Continue action.
2301 """ 2323
2324 @param debuggerId ID of the debugger backend
2325 @type str
2326 """
2327 if not debuggerId:
2328 debuggerId = self.getSelectedDebuggerId()
2329
2302 self.lastAction = 0 2330 self.lastAction = 0
2303 self.__enterRemote() 2331 self.__enterRemote()
2304 self.debugServer.remoteContinue(self.getSelectedDebuggerId()) 2332 self.debugServer.remoteContinue(debuggerId)
2305 2333
2306 def __specialContinue(self): 2334 def __specialContinue(self, debuggerId=""):
2307 """ 2335 """
2308 Private method to handle the Special Continue action. 2336 Private method to handle the Special Continue action.
2309 """ 2337
2338 @param debuggerId ID of the debugger backend
2339 @type str
2340 """
2341 if not debuggerId:
2342 debuggerId = self.getSelectedDebuggerId()
2343
2310 self.lastAction = 2 2344 self.lastAction = 2
2311 self.__enterRemote() 2345 self.__enterRemote()
2312 self.debugServer.remoteContinue(self.getSelectedDebuggerId(), 1) 2346 self.debugServer.remoteContinue(debuggerId, 1)
2313 2347
2314 def __step(self): 2348 def __step(self, debuggerId=""):
2315 """ 2349 """
2316 Private method to handle the Step action. 2350 Private method to handle the Step action.
2317 """ 2351
2352 @param debuggerId ID of the debugger backend
2353 @type str
2354 """
2355 if not debuggerId:
2356 debuggerId = self.getSelectedDebuggerId()
2357
2318 self.lastAction = 1 2358 self.lastAction = 1
2319 self.__enterRemote() 2359 self.__enterRemote()
2320 self.debugServer.remoteStep(self.getSelectedDebuggerId()) 2360 self.debugServer.remoteStep(debuggerId)
2321 2361
2322 def __stepOver(self): 2362 def __stepOver(self, debuggerId=""):
2323 """ 2363 """
2324 Private method to handle the Step Over action. 2364 Private method to handle the Step Over action.
2325 """ 2365
2366 @param debuggerId ID of the debugger backend
2367 @type str
2368 """
2369 if not debuggerId:
2370 debuggerId = self.getSelectedDebuggerId()
2371
2326 self.lastAction = 2 2372 self.lastAction = 2
2327 self.__enterRemote() 2373 self.__enterRemote()
2328 self.debugServer.remoteStepOver(self.getSelectedDebuggerId()) 2374 self.debugServer.remoteStepOver(debuggerId)
2329 2375
2330 def __stepOut(self): 2376 def __stepOut(self, debuggerId=""):
2331 """ 2377 """
2332 Private method to handle the Step Out action. 2378 Private method to handle the Step Out action.
2333 """ 2379
2380 @param debuggerId ID of the debugger backend
2381 @type str
2382 """
2383 if not debuggerId:
2384 debuggerId = self.getSelectedDebuggerId()
2385
2334 self.lastAction = 3 2386 self.lastAction = 3
2335 self.__enterRemote() 2387 self.__enterRemote()
2336 self.debugServer.remoteStepOut(self.getSelectedDebuggerId()) 2388 self.debugServer.remoteStepOut(debuggerId)
2337 2389
2338 def __stepQuit(self): 2390 def __stepQuit(self, debuggerId=""):
2339 """ 2391 """
2340 Private method to handle the Step Quit action. 2392 Private method to handle the Step Quit action.
2341 """ 2393
2394 @param debuggerId ID of the debugger backend
2395 @type str
2396 """
2397 if not debuggerId:
2398 debuggerId = self.getSelectedDebuggerId()
2399
2342 self.lastAction = 4 2400 self.lastAction = 4
2343 self.__enterRemote() 2401 self.__enterRemote()
2344 self.debugServer.remoteStepQuit(self.getSelectedDebuggerId()) 2402 self.debugServer.remoteStepQuit(debuggerId)
2345 self.__resetUI() 2403 self.__resetUI()
2346 2404
2347 def __runToCursor(self): 2405 def __runToCursor(self, debuggerId=""):
2348 """ 2406 """
2349 Private method to handle the Run to Cursor action. 2407 Private method to handle the Run to Cursor action.
2350 """ 2408
2409 @param debuggerId ID of the debugger backend
2410 @type str
2411 """
2412 if not debuggerId:
2413 debuggerId = self.getSelectedDebuggerId()
2414
2351 self.lastAction = 0 2415 self.lastAction = 0
2352 aw = self.viewmanager.activeWindow() 2416 aw = self.viewmanager.activeWindow()
2353 line = aw.getCursorPosition()[0] + 1 2417 line = aw.getCursorPosition()[0] + 1
2354 self.__enterRemote() 2418 self.__enterRemote()
2355 self.debugServer.remoteBreakpoint( 2419 self.debugServer.remoteBreakpoint(
2356 self.getSelectedDebuggerId(), 2420 self.getSelectedDebuggerId(),
2357 aw.getFileName(), line, 1, None, 1) 2421 aw.getFileName(), line, 1, None, 1)
2358 self.debugServer.remoteContinue(self.getSelectedDebuggerId()) 2422 self.debugServer.remoteContinue(debuggerId)
2359 2423
2360 def __moveInstructionPointer(self): 2424 def __moveInstructionPointer(self, debuggerId=""):
2361 """ 2425 """
2362 Private method to move the instruction pointer to a different line. 2426 Private method to move the instruction pointer to a different line.
2363 """ 2427
2428 @param debuggerId ID of the debugger backend
2429 @type str
2430 """
2431 if not debuggerId:
2432 debuggerId = self.getSelectedDebuggerId()
2433
2364 self.lastAction = 0 2434 self.lastAction = 0
2365 aw = self.viewmanager.activeWindow() 2435 aw = self.viewmanager.activeWindow()
2366 line = aw.getCursorPosition()[0] + 1 2436 line = aw.getCursorPosition()[0] + 1
2367 self.debugServer.remoteMoveIP(self.getSelectedDebuggerId(), line) 2437 self.debugServer.remoteMoveIP(debuggerId, line)
2368 2438
2369 def __enterRemote(self): 2439 def __enterRemote(self):
2370 """ 2440 """
2371 Private method to update the user interface. 2441 Private method to update the user interface.
2372 2442
2413 2483
2414 @param enable enable state to be set 2484 @param enable enable state to be set
2415 @type bool 2485 @type bool
2416 """ 2486 """
2417 self.debugActGrp.setEnabled(enable) 2487 self.debugActGrp.setEnabled(enable)
2488
2489 def setMultiprocessNoDebugHistory(self, noDebugList, clearHistories=False,
2490 history=None):
2491 """
2492 Public slot to initialize the no debug list history.
2493
2494 @param noDebugList whitespace separated list of progframs not to be
2495 debugged
2496 @type str
2497 @param clearHistories flag indicating, that the list should be cleared
2498 @type bool
2499 @param history list of history entries to be set
2500 @type list of str
2501 """
2502 if clearHistories:
2503 del self.multiprocessNoDebugHistory[1:]
2504 elif history is not None:
2505 self.multiprocessNoDebugHistory = history[:]
2506 else:
2507 if noDebugList in self.multiprocessNoDebugHistory:
2508 self.multiprocessNoDebugHistory.remove(noDebugList)
2509 self.multiprocessNoDebugHistory.insert(0, noDebugList)

eric ide

mercurial