eric6/Debugger/DebugUI.py

branch
multi_processing
changeset 7379
72a72fd56494
parent 7377
cc920e534ac0
child 7389
770ffcb88be5
equal deleted inserted replaced
7377:cc920e534ac0 7379:72a72fd56494
8 """ 8 """
9 9
10 10
11 import os 11 import os
12 12
13 from PyQt5.QtCore import pyqtSignal, QObject, Qt 13 from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, Qt
14 from PyQt5.QtGui import QKeySequence 14 from PyQt5.QtGui import QKeySequence
15 from PyQt5.QtWidgets import QMenu, QToolBar, QApplication, QDialog 15 from PyQt5.QtWidgets import QMenu, QToolBar, QApplication, QDialog
16 16
17 from UI.Info import Program 17 from UI.Info import Program
18 18
1012 if self.ui.getViewProfile() != "debug": 1012 if self.ui.getViewProfile() != "debug":
1013 self.ui.setDebugProfile() 1013 self.ui.setDebugProfile()
1014 self.viewmanager.setFileLine(fn, line) 1014 self.viewmanager.setFileLine(fn, line)
1015 if not forStack: 1015 if not forStack:
1016 self.__getThreadList() 1016 self.__getThreadList()
1017 self.__getClientVariables() 1017 self.__getClientVariables(debuggerId)
1018 1018
1019 self.debugActGrp.setEnabled(True) 1019 self.debugActGrp.setEnabled(True)
1020 1020
1021 @pyqtSlot(int, str, bool)
1021 def __clientExit(self, status, message, quiet): 1022 def __clientExit(self, status, message, quiet):
1022 """ 1023 """
1023 Private method to handle the debugged program terminating. 1024 Private method to handle the debugged program terminating.
1024 1025
1025 @param status exit code of the debugged program 1026 @param status exit code of the debugged program
1128 ' <b>{1}</b> at line <b>{2}</b>, character <b>{3}</b>.' 1129 ' <b>{1}</b> at line <b>{2}</b>, character <b>{3}</b>.'
1129 '</p>') 1130 '</p>')
1130 .format(filename, message, lineNo, characterNo)) 1131 .format(filename, message, lineNo, characterNo))
1131 1132
1132 def __clientException(self, exceptionType, exceptionMessage, stackTrace, 1133 def __clientException(self, exceptionType, exceptionMessage, stackTrace,
1133 debuggerId=""): 1134 debuggerId):
1134 """ 1135 """
1135 Private method to handle an exception of the debugged program. 1136 Private method to handle an exception of the debugged program.
1136 1137
1137 @param exceptionType type of exception raised 1138 @param exceptionType type of exception raised
1138 @type str 1139 @type str
1224 self.exceptionInterrupt.emit() 1225 self.exceptionInterrupt.emit()
1225 stack = [] 1226 stack = []
1226 for fn, ln, func, args in stackTrace: 1227 for fn, ln, func, args in stackTrace:
1227 stack.append((fn, ln, func, args)) 1228 stack.append((fn, ln, func, args))
1228 self.clientStack.emit(stack, debuggerId) 1229 self.clientStack.emit(stack, debuggerId)
1229 self.__getClientVariables() 1230 self.__getClientVariables(debuggerId)
1230 self.ui.setDebugProfile() 1231 self.ui.setDebugProfile()
1231 self.debugActGrp.setEnabled(True) 1232 self.debugActGrp.setEnabled(True)
1232 return 1233 return
1233 elif res == E5MessageBox.Ignore: 1234 elif res == E5MessageBox.Ignore:
1234 if exceptionType not in self.excIgnoreList: 1235 if exceptionType not in self.excIgnoreList:
1240 else: 1241 else:
1241 self.debugActions[self.lastAction]() 1242 self.debugActions[self.lastAction]()
1242 else: 1243 else:
1243 self.__continue() 1244 self.__continue()
1244 1245
1245 def __clientSignal(self, message, filename, lineNo, funcName, funcArgs): 1246 def __clientSignal(self, message, filename, lineNo, funcName, funcArgs,
1247 debuggerId):
1246 """ 1248 """
1247 Private method to handle a signal generated on the client side. 1249 Private method to handle a signal generated on the client side.
1248 1250
1249 @param message message of the syntax error 1251 @param message message of the syntax error
1250 @type str 1252 @type str
1254 @type int 1256 @type int
1255 @param funcName name of the function causing the signal 1257 @param funcName name of the function causing the signal
1256 @type str 1258 @type str
1257 @param funcArgs function arguments 1259 @param funcArgs function arguments
1258 @type str 1260 @type str
1261 @param debuggerId ID of the debugger backend
1262 @type str
1259 """ 1263 """
1260 self.ui.raise_() 1264 self.ui.raise_()
1261 self.ui.activateWindow() 1265 self.ui.activateWindow()
1262 QApplication.processEvents() 1266 QApplication.processEvents()
1263 self.viewmanager.setFileLine(filename, lineNo, True) 1267 self.viewmanager.setFileLine(filename, lineNo, True)
1285 Private method to get the list of threads from the client. 1289 Private method to get the list of threads from the client.
1286 1290
1287 @param debuggerId ID of the debugger backend 1291 @param debuggerId ID of the debugger backend
1288 @type str 1292 @type str
1289 """ 1293 """
1290 self.debugServer.remoteThreadList(debuggerId=debuggerId) 1294 self.debugServer.remoteThreadList(debuggerId)
1291 1295
1292 def __clientThreadSet(self): 1296 def __clientThreadSet(self, debuggerId):
1293 """ 1297 """
1294 Private method to handle a change of the client's current thread. 1298 Private method to handle a change of the client's current thread.
1295 """ 1299
1296 self.debugServer.remoteClientVariables(0, self.localsVarFilter) 1300 @param debuggerId ID of the debugger backend
1297 1301 @type str
1298 def __getClientVariables(self, debuggerId=""): 1302 """
1303 self.debugServer.remoteClientVariables(
1304 debuggerId, 0, self.localsVarFilter)
1305
1306 def __getClientVariables(self, debuggerId):
1299 """ 1307 """
1300 Private method to request the global and local variables. 1308 Private method to request the global and local variables.
1301 1309
1302 In the first step, the global variables are requested from the client. 1310 In the first step, the global variables are requested from the client.
1303 Once these have been received, the local variables are requested. 1311 Once these have been received, the local variables are requested.
1305 1313
1306 @param debuggerId ID of the debugger backend 1314 @param debuggerId ID of the debugger backend
1307 @type str 1315 @type str
1308 """ 1316 """
1309 # get globals first 1317 # get globals first
1310 self.debugServer.remoteClientVariables(1, self.globalsVarFilter, 1318 self.debugServer.remoteClientVariables(
1311 debuggerId=debuggerId) 1319 debuggerId, 1, self.globalsVarFilter)
1312 # the local variables are requested once we have received the globals 1320 # the local variables are requested once we have received the globals
1313 1321
1314 def __clientVariables(self, scope, variables): 1322 def __clientVariables(self, scope, variables, debuggerId):
1315 """ 1323 """
1316 Private method to write the clients variables to the user interface. 1324 Private method to write the clients variables to the user interface.
1317 1325
1318 @param scope scope of the variables (-1 = empty locals, 1 = global, 1326 @param scope scope of the variables (-1 = empty locals, 1 = global,
1319 0 = local) 1327 0 = local)
1328 @type int
1320 @param variables the list of variables from the client 1329 @param variables the list of variables from the client
1321 """ 1330 @type list
1322 self.ui.activateDebugViewer() 1331 @param debuggerId ID of the debugger backend
1323 if scope > 0: 1332 @type str
1324 self.debugViewer.showVariables(variables, True) 1333 """
1325 if scope == 1: 1334 if debuggerId == self.getSelectedDebuggerId():
1326 # now get the local variables 1335 self.ui.activateDebugViewer()
1327 self.debugServer.remoteClientVariables(0, self.localsVarFilter) 1336 if scope > 0:
1328 elif scope == 0: 1337 self.debugViewer.showVariables(variables, True)
1329 self.debugViewer.showVariables(variables, False) 1338 if scope == 1:
1330 elif scope == -1: 1339 # now get the local variables
1331 vlist = [(self.tr('No locals available.'), '', '')] 1340 self.debugServer.remoteClientVariables(
1332 self.debugViewer.showVariables(vlist, False) 1341 self.getSelectedDebuggerId(),
1333 1342 0, self.localsVarFilter)
1334 def __clientVariable(self, scope, variables): 1343 elif scope == 0:
1344 self.debugViewer.showVariables(variables, False)
1345 elif scope == -1:
1346 vlist = [(self.tr('No locals available.'), '', '')]
1347 self.debugViewer.showVariables(vlist, False)
1348
1349 def __clientVariable(self, scope, variables, debuggerId):
1335 """ 1350 """
1336 Private method to write the contents of a clients classvariable to 1351 Private method to write the contents of a clients classvariable to
1337 the user interface. 1352 the user interface.
1338 1353
1339 @param scope scope of the variables (-1 = empty global, 1 = global, 1354 @param scope scope of the variables (-1 = empty locals, 1 = global,
1340 0 = local) 1355 0 = local)
1341 @param variables the list of members of a classvariable from the client 1356 @type int
1342 """ 1357 @param variables the list of variables from the client
1343 self.ui.activateDebugViewer() 1358 @type list
1344 if scope == 1: 1359 @param debuggerId ID of the debugger backend
1345 self.debugViewer.showVariable(variables, True) 1360 @type str
1346 elif scope == 0: 1361 """
1347 self.debugViewer.showVariable(variables, False) 1362 if debuggerId == self.getSelectedDebuggerId():
1363 self.ui.activateDebugViewer()
1364 if scope == 1:
1365 self.debugViewer.showVariable(variables, True)
1366 elif scope == 0:
1367 self.debugViewer.showVariable(variables, False)
1348 1368
1349 def __clientBreakConditionError(self, filename, lineno): 1369 def __clientBreakConditionError(self, filename, lineno):
1350 """ 1370 """
1351 Private method to handle a condition error of a breakpoint. 1371 Private method to handle a condition error of a breakpoint.
1352 1372
2257 """ 2277 """
2258 Private method to handle the Continue action. 2278 Private method to handle the Continue action.
2259 """ 2279 """
2260 self.lastAction = 0 2280 self.lastAction = 0
2261 self.__enterRemote() 2281 self.__enterRemote()
2262 self.debugServer.remoteContinue() 2282 self.debugServer.remoteContinue(self.getSelectedDebuggerId())
2263 self.__getThreadList() 2283 self.__getThreadList()
2264 2284
2265 def __specialContinue(self): 2285 def __specialContinue(self):
2266 """ 2286 """
2267 Private method to handle the Special Continue action. 2287 Private method to handle the Special Continue action.
2268 """ 2288 """
2269 self.lastAction = 2 2289 self.lastAction = 2
2270 self.__enterRemote() 2290 self.__enterRemote()
2271 self.debugServer.remoteContinue(1) 2291 self.debugServer.remoteContinue(self.getSelectedDebuggerId(), 1)
2272 self.__getThreadList() 2292 self.__getThreadList()
2273 2293
2274 def __step(self): 2294 def __step(self):
2275 """ 2295 """
2276 Private method to handle the Step action. 2296 Private method to handle the Step action.
2277 """ 2297 """
2278 self.lastAction = 1 2298 self.lastAction = 1
2279 self.__enterRemote() 2299 self.__enterRemote()
2280 self.debugServer.remoteStep() 2300 self.debugServer.remoteStep(self.getSelectedDebuggerId())
2281 2301
2282 def __stepOver(self): 2302 def __stepOver(self):
2283 """ 2303 """
2284 Private method to handle the Step Over action. 2304 Private method to handle the Step Over action.
2285 """ 2305 """
2286 self.lastAction = 2 2306 self.lastAction = 2
2287 self.__enterRemote() 2307 self.__enterRemote()
2288 self.debugServer.remoteStepOver() 2308 self.debugServer.remoteStepOver(self.getSelectedDebuggerId())
2289 self.__getThreadList() 2309 self.__getThreadList()
2290 2310
2291 def __stepOut(self): 2311 def __stepOut(self):
2292 """ 2312 """
2293 Private method to handle the Step Out action. 2313 Private method to handle the Step Out action.
2294 """ 2314 """
2295 self.lastAction = 3 2315 self.lastAction = 3
2296 self.__enterRemote() 2316 self.__enterRemote()
2297 self.debugServer.remoteStepOut() 2317 self.debugServer.remoteStepOut(self.getSelectedDebuggerId())
2298 self.__getThreadList() 2318 self.__getThreadList()
2299 2319
2300 def __stepQuit(self): 2320 def __stepQuit(self):
2301 """ 2321 """
2302 Private method to handle the Step Quit action. 2322 Private method to handle the Step Quit action.
2303 """ 2323 """
2304 self.lastAction = 4 2324 self.lastAction = 4
2305 self.__enterRemote() 2325 self.__enterRemote()
2306 self.debugServer.remoteStepQuit() 2326 self.debugServer.remoteStepQuit(self.getSelectedDebuggerId())
2307 self.__resetUI() 2327 self.__resetUI()
2308 2328
2309 def __runToCursor(self): 2329 def __runToCursor(self):
2310 """ 2330 """
2311 Private method to handle the Run to Cursor action. 2331 Private method to handle the Run to Cursor action.
2313 self.lastAction = 0 2333 self.lastAction = 0
2314 aw = self.viewmanager.activeWindow() 2334 aw = self.viewmanager.activeWindow()
2315 line = aw.getCursorPosition()[0] + 1 2335 line = aw.getCursorPosition()[0] + 1
2316 self.__enterRemote() 2336 self.__enterRemote()
2317 self.debugServer.remoteBreakpoint( 2337 self.debugServer.remoteBreakpoint(
2338 self.getSelectedDebuggerId(),
2318 aw.getFileName(), line, 1, None, 1) 2339 aw.getFileName(), line, 1, None, 1)
2319 self.debugServer.remoteContinue() 2340 self.debugServer.remoteContinue(self.getSelectedDebuggerId())
2320 self.__getThreadList() 2341 self.__getThreadList()
2321 2342
2322 def __moveInstructionPointer(self): 2343 def __moveInstructionPointer(self):
2323 """ 2344 """
2324 Private method to move the instruction pointer to a different line. 2345 Private method to move the instruction pointer to a different line.
2325 """ 2346 """
2326 self.lastAction = 0 2347 self.lastAction = 0
2327 aw = self.viewmanager.activeWindow() 2348 aw = self.viewmanager.activeWindow()
2328 line = aw.getCursorPosition()[0] + 1 2349 line = aw.getCursorPosition()[0] + 1
2329 self.debugServer.remoteMoveIP(line) 2350 self.debugServer.remoteMoveIP(self.getSelectedDebuggerId(), line)
2330 2351
2331 def __enterRemote(self): 2352 def __enterRemote(self):
2332 """ 2353 """
2333 Private method to update the user interface. 2354 Private method to update the user interface.
2334 2355
2357 @type str 2378 @type str
2358 """ 2379 """
2359 self.debugServer.remoteClientStack(debuggerId) 2380 self.debugServer.remoteClientStack(debuggerId)
2360 self.__getThreadList(debuggerId) 2381 self.__getThreadList(debuggerId)
2361 self.__getClientVariables(debuggerId) 2382 self.__getClientVariables(debuggerId)
2383
2384 def getSelectedDebuggerId(self):
2385 """
2386 Public method to get the currently selected debugger ID.
2387
2388 @return selected debugger ID
2389 @rtype str
2390 """
2391 return self.debugViewer.getSelectedDebuggerId()

eric ide

mercurial