src/eric7/Debugger/DebugServer.py

branch
eric7-maintenance
changeset 10814
ba20efe10336
parent 10733
d96c69a235fc
parent 10766
d35d6f96c24b
child 11019
27cd57e98461
equal deleted inserted replaced
10734:2b015db9761a 10814:ba20efe10336
16 from PyQt6.QtNetwork import QHostAddress, QHostInfo, QNetworkInterface, QTcpServer 16 from PyQt6.QtNetwork import QHostAddress, QHostInfo, QNetworkInterface, QTcpServer
17 17
18 from eric7 import Preferences 18 from eric7 import Preferences
19 from eric7.EricWidgets import EricMessageBox 19 from eric7.EricWidgets import EricMessageBox
20 from eric7.EricWidgets.EricApplication import ericApp 20 from eric7.EricWidgets.EricApplication import ericApp
21 from eric7.SystemUtilities import FileSystemUtilities
21 22
22 from . import DebugClientCapabilities 23 from . import DebugClientCapabilities
23 from .BreakPointModel import BreakPointModel 24 from .BreakPointModel import BreakPointModel
24 from .WatchPointModel import WatchPointModel 25 from .WatchPointModel import WatchPointModel
25 26
239 240
240 self.lastClientType = "" 241 self.lastClientType = ""
241 self.__autoClearShell = False 242 self.__autoClearShell = False
242 self.__forProject = False 243 self.__forProject = False
243 244
245 self.__ericServerDebugging = False
246
244 self.clientClearBreak.connect(self.__clientClearBreakPoint) 247 self.clientClearBreak.connect(self.__clientClearBreakPoint)
245 self.clientClearWatch.connect(self.__clientClearWatchPoint) 248 self.clientClearWatch.connect(self.__clientClearWatchPoint)
246 self.newConnection.connect(self.__newConnection) 249 self.newConnection.connect(self.__newConnection)
247 250
248 self.breakpointModel.rowsAboutToBeRemoved.connect(self.__deleteBreakPoints) 251 self.breakpointModel.rowsAboutToBeRemoved.connect(self.__deleteBreakPoints)
490 unplanned=True, 493 unplanned=True,
491 clType=None, 494 clType=None,
492 forProject=False, 495 forProject=False,
493 runInConsole=False, 496 runInConsole=False,
494 venvName="", 497 venvName="",
495 workingDir=None, 498 workingDir="",
496 configOverride=None, 499 configOverride=None,
500 startRemote=None,
497 ): 501 ):
498 """ 502 """
499 Public method to start a debug client. 503 Public method to start a debug client.
500 504
501 @param unplanned flag indicating that the client has died 505 @param unplanned flag indicating that the client has died (defaults to True)
502 @type bool 506 @type bool (optional)
503 @param clType type of client to be started 507 @param clType type of client to be started (defaults to None)
504 @type str 508 @type str (optional)
505 @param forProject flag indicating a project related action 509 @param forProject flag indicating a project related action (defaults to False)
506 @type bool 510 @type bool (optional)
507 @param runInConsole flag indicating to start the debugger in a 511 @param runInConsole flag indicating to start the debugger in a
508 console window 512 console window (defaults to False)
509 @type bool 513 @type bool (optional)
510 @param venvName name of the virtual environment to be used 514 @param venvName name of the virtual environment to be used (defaults to "")
511 @type str 515 @type str (optional)
512 @param workingDir directory to start the debugger client in 516 @param workingDir directory to start the debugger client in (defaults to "")
513 @type str 517 @type str (optional)
514 @param configOverride dictionary containing the global config override 518 @param configOverride dictionary containing the global config override data
515 data 519 (defaults to None)
516 @type dict 520 @type dict (optional)
521 @param startRemote flag indicating to start the client via an eric-ide server
522 (defaults to None)
523 @type bool (optional)
517 """ 524 """
518 self.running = False 525 self.running = False
519 526
520 if ( 527 if (
521 (not self.passive or not self.passiveClientExited) 528 (not self.passive or not self.passiveClientExited)
558 runInConsole, 565 runInConsole,
559 venvName, 566 venvName,
560 self.__originalPathString, 567 self.__originalPathString,
561 workingDir=workingDir, 568 workingDir=workingDir,
562 configOverride=configOverride, 569 configOverride=configOverride,
570 startRemote=startRemote,
563 ) 571 )
564 else: 572 else:
565 if not venvName and project.getProjectData(dataKey="EMBEDDED_VENV"): 573 if not venvName and project.getProjectData(dataKey="EMBEDDED_VENV"):
566 venvName = self.getProjectEnvironmentString() 574 venvName = self.getProjectEnvironmentString()
567 575
574 runInConsole, 582 runInConsole,
575 venvName, 583 venvName,
576 self.__originalPathString, 584 self.__originalPathString,
577 workingDir=workingDir, 585 workingDir=workingDir,
578 configOverride=configOverride, 586 configOverride=configOverride,
587 startRemote=startRemote,
579 ) 588 )
580 else: 589 else:
581 ( 590 (
582 self.clientProcess, 591 self.clientProcess,
583 _isNetworked, 592 _isNetworked,
587 runInConsole, 596 runInConsole,
588 venvName, 597 venvName,
589 self.__originalPathString, 598 self.__originalPathString,
590 workingDir=workingDir, 599 workingDir=workingDir,
591 configOverride=configOverride, 600 configOverride=configOverride,
601 startRemote=startRemote,
592 ) 602 )
593 603
594 if self.clientProcess: 604 if self.clientProcess:
595 self.clientProcess.readyReadStandardError.connect( 605 self.clientProcess.readyReadStandardError.connect(
596 self.__clientProcessError 606 self.__clientProcessError
598 self.clientProcess.readyReadStandardOutput.connect( 608 self.clientProcess.readyReadStandardOutput.connect(
599 self.__clientProcessOutput 609 self.__clientProcessOutput
600 ) 610 )
601 611
602 # Perform actions necessary, if client type has changed 612 # Perform actions necessary, if client type has changed
613 if self.lastClientType != self.clientType:
614 self.lastClientType = self.clientType
615 self.remoteBanner()
616 elif self.__autoClearShell:
617 self.__autoClearShell = False
618 self.remoteBanner()
619 elif startRemote:
620 self.__ericServerDebugging = True
603 if self.lastClientType != self.clientType: 621 if self.lastClientType != self.clientType:
604 self.lastClientType = self.clientType 622 self.lastClientType = self.clientType
605 self.remoteBanner() 623 self.remoteBanner()
606 elif self.__autoClearShell: 624 elif self.__autoClearShell:
607 self.__autoClearShell = False 625 self.__autoClearShell = False
727 ) = self.breakpointModel.getBreakPointByIndex(index)[:6] 745 ) = self.breakpointModel.getBreakPointByIndex(index)[:6]
728 746
729 if (fn, lineno) in self.__reportedBreakpointIssues: 747 if (fn, lineno) in self.__reportedBreakpointIssues:
730 self.__reportedBreakpointIssues.remove((fn, lineno)) 748 self.__reportedBreakpointIssues.remove((fn, lineno))
731 749
732 self.remoteBreakpoint(debuggerId, fn, lineno, True, cond, temp) 750 if (
733 if not enabled: 751 self.__ericServerDebugging
734 self.__remoteBreakpointEnable(debuggerId, fn, lineno, False) 752 and FileSystemUtilities.isRemoteFileName(fn)
735 if ignorecount: 753 ) or (
736 self.__remoteBreakpointIgnore(debuggerId, fn, lineno, ignorecount) 754 not self.__ericServerDebugging
755 and FileSystemUtilities.isPlainFileName(fn)
756 ):
757 self.remoteBreakpoint(debuggerId, fn, lineno, True, cond, temp)
758 if not enabled:
759 self.__remoteBreakpointEnable(debuggerId, fn, lineno, False)
760 if ignorecount:
761 self.__remoteBreakpointIgnore(
762 debuggerId, fn, lineno, ignorecount
763 )
737 764
738 def __makeWatchCondition(self, cond, special): 765 def __makeWatchCondition(self, cond, special):
739 """ 766 """
740 Private method to construct the condition string. 767 Private method to construct the condition string.
741 768
902 """ 929 """
903 return self.clientType 930 return self.clientType
904 931
905 def isClientProcessUp(self): 932 def isClientProcessUp(self):
906 """ 933 """
907 Public method to check, if the debug client process is up. 934 Public method to check, if the debug client process is up or we are
935 doing debugging via the eric-ide server.
908 936
909 @return flag indicating a running debug client process 937 @return flag indicating a running debug client process
910 @rtype bool 938 @rtype bool
911 """ 939 """
912 return self.clientProcess is not None 940 return self.clientProcess is not None or self.__ericServerDebugging
913 941
914 def __newConnection(self): 942 def __newConnection(self):
915 """ 943 """
916 Private slot to handle a new connection. 944 Private slot to handle a new connection.
917 """ 945 """
1089 False, 1117 False,
1090 forProject=forProject, 1118 forProject=forProject,
1091 runInConsole=runInConsole, 1119 runInConsole=runInConsole,
1092 venvName=venvName, 1120 venvName=venvName,
1093 configOverride=configOverride, 1121 configOverride=configOverride,
1122 startRemote=FileSystemUtilities.isRemoteFileName(fn),
1094 ) 1123 )
1095 1124
1096 self.setCallTraceEnabled("", enableCallTrace) 1125 self.setCallTraceEnabled("", enableCallTrace)
1097 self.remoteEnvironment(env) 1126 self.remoteEnvironment(env)
1098 1127
1179 False, 1208 False,
1180 forProject=forProject, 1209 forProject=forProject,
1181 runInConsole=runInConsole, 1210 runInConsole=runInConsole,
1182 venvName=venvName, 1211 venvName=venvName,
1183 configOverride=configOverride, 1212 configOverride=configOverride,
1213 startRemote=FileSystemUtilities.isRemoteFileName(fn),
1184 ) 1214 )
1185 1215
1186 self.remoteEnvironment(env) 1216 self.remoteEnvironment(env)
1187 1217
1188 self.debuggerInterface.remoteRun(fn, argv, wd) 1218 self.debuggerInterface.remoteRun(fn, argv, wd)
1261 False, 1291 False,
1262 forProject=forProject, 1292 forProject=forProject,
1263 runInConsole=runInConsole, 1293 runInConsole=runInConsole,
1264 venvName=venvName, 1294 venvName=venvName,
1265 configOverride=configOverride, 1295 configOverride=configOverride,
1296 startRemote=FileSystemUtilities.isRemoteFileName(fn),
1266 ) 1297 )
1267 1298
1268 self.remoteEnvironment(env) 1299 self.remoteEnvironment(env)
1269 1300
1270 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase) 1301 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase)
1343 False, 1374 False,
1344 forProject=forProject, 1375 forProject=forProject,
1345 runInConsole=runInConsole, 1376 runInConsole=runInConsole,
1346 venvName=venvName, 1377 venvName=venvName,
1347 configOverride=configOverride, 1378 configOverride=configOverride,
1379 startRemote=FileSystemUtilities.isRemoteFileName(fn),
1348 ) 1380 )
1349 1381
1350 self.remoteEnvironment(env) 1382 self.remoteEnvironment(env)
1351 1383
1352 self.debuggerInterface.remoteProfile(fn, argv, wd, erase) 1384 self.debuggerInterface.remoteProfile(fn, argv, wd, erase)
1911 if self.passive: 1943 if self.passive:
1912 self.__createDebuggerInterface("None") 1944 self.__createDebuggerInterface("None")
1913 self.signalClientOutput(self.tr("\nNot connected\n")) 1945 self.signalClientOutput(self.tr("\nNot connected\n"))
1914 self.signalClientStatement(False, "") 1946 self.signalClientStatement(False, "")
1915 self.running = False 1947 self.running = False
1948 self.__ericServerDebugging = False
1916 1949
1917 def signalClientClearBreak(self, filename, lineno, debuggerId): 1950 def signalClientClearBreak(self, filename, lineno, debuggerId):
1918 """ 1951 """
1919 Public method to process the client clear breakpoint command. 1952 Public method to process the client clear breakpoint command.
1920 1953
2222 else: 2255 else:
2223 return "" 2256 return ""
2224 except KeyError: 2257 except KeyError:
2225 # The project object is not present 2258 # The project object is not present
2226 return "" 2259 return ""
2260
2261 def getEricServerEnvironmentString(self):
2262 """
2263 Public method to get the string for an eric-ide server environment.
2264
2265 @return string for the eric-ide server environment
2266 @rtype str
2267 """
2268 return "eric-ide Server"

eric ide

mercurial