7 Module implementing the debug server. |
7 Module implementing the debug server. |
8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 import shlex |
11 import shlex |
|
12 import contextlib |
12 |
13 |
13 from PyQt5.QtCore import pyqtSignal, pyqtSlot, QModelIndex |
14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, QModelIndex |
14 from PyQt5.QtNetwork import ( |
15 from PyQt5.QtNetwork import ( |
15 QTcpServer, QHostAddress, QHostInfo, QNetworkInterface |
16 QTcpServer, QHostAddress, QHostInfo, QNetworkInterface |
16 ) |
17 ) |
184 @param project reference to the project object (defaults to None) |
185 @param project reference to the project object (defaults to None) |
185 @type Project (optional) |
186 @type Project (optional) |
186 @param parent reference to the parent object |
187 @param parent reference to the parent object |
187 @type QObject |
188 @type QObject |
188 """ |
189 """ |
189 super(DebugServer, self).__init__(parent) |
190 super().__init__(parent) |
190 |
191 |
191 self.__originalPathString = originalPathString |
192 self.__originalPathString = originalPathString |
192 |
193 |
193 self.__debuggerInterfaces = {} |
194 self.__debuggerInterfaces = {} |
194 # the interface name is the key, a function to get the |
195 # the interface name is the key, a function to get the |
423 @type bool |
424 @type bool |
424 @return list of supported languages |
425 @return list of supported languages |
425 @rtype list of str |
426 @rtype list of str |
426 """ |
427 """ |
427 languages = list(self.__debuggerInterfaceRegistry.keys()) |
428 languages = list(self.__debuggerInterfaceRegistry.keys()) |
428 try: |
429 with contextlib.suppress(ValueError): |
429 languages.remove("None") |
430 languages.remove("None") |
430 except ValueError: |
|
431 pass # it is not in the list |
|
432 |
431 |
433 if shellOnly: |
432 if shellOnly: |
434 languages = [lang for lang in languages |
433 languages = [lang for lang in languages |
435 if self.__debuggerInterfaceRegistry[lang][0] & |
434 if self.__debuggerInterfaceRegistry[lang][0] & |
436 DebugClientCapabilities.HasShell] |
435 DebugClientCapabilities.HasShell] |
506 data |
505 data |
507 @type dict |
506 @type dict |
508 """ |
507 """ |
509 self.running = False |
508 self.running = False |
510 |
509 |
511 if not self.passive or not self.passiveClientExited: |
510 if ( |
512 if self.debuggerInterface and self.debuggerInterface.isConnected(): |
511 (not self.passive or not self.passiveClientExited) and |
513 self.shutdownServer() |
512 self.debuggerInterface and |
514 self.debugging = False |
513 self.debuggerInterface.isConnected() |
515 self.clientGone.emit(unplanned and self.debugging) |
514 ): |
|
515 self.shutdownServer() |
|
516 self.debugging = False |
|
517 self.clientGone.emit(unplanned and self.debugging) |
516 |
518 |
517 if clType: |
519 if clType: |
518 if clType not in self.getSupportedLanguages(): |
520 if clType not in self.getSupportedLanguages(): |
519 # a not supported client language was requested |
521 # a not supported client language was requested |
520 return |
522 return |
1483 Public method to ask the client for the latest traceback disassembly. |
1485 Public method to ask the client for the latest traceback disassembly. |
1484 |
1486 |
1485 @param debuggerId ID of the debugger backend |
1487 @param debuggerId ID of the debugger backend |
1486 @type str |
1488 @type str |
1487 """ |
1489 """ |
1488 try: |
1490 with contextlib.suppress(AttributeError): |
1489 self.debuggerInterface.remoteClientDisassembly(debuggerId) |
1491 self.debuggerInterface.remoteClientDisassembly(debuggerId) |
1490 except AttributeError: |
|
1491 # remote client doesn't support that |
|
1492 pass |
|
1493 |
1492 |
1494 def remoteClientSetFilter(self, debuggerId, scope, filterStr): |
1493 def remoteClientSetFilter(self, debuggerId, scope, filterStr): |
1495 """ |
1494 """ |
1496 Public method to set a variables filter list. |
1495 Public method to set a variables filter list. |
1497 |
1496 |
1992 @param clientType type of the debug client |
1991 @param clientType type of the debug client |
1993 @type str |
1992 @type str |
1994 @param venvName name of the virtual environment |
1993 @param venvName name of the virtual environment |
1995 @type str |
1994 @type str |
1996 """ |
1995 """ |
1997 try: |
1996 with contextlib.suppress(KeyError): |
1998 self.__debuggerInterfaceRegistry[clientType][0] = capabilities |
1997 self.__debuggerInterfaceRegistry[clientType][0] = capabilities |
1999 self.clientCapabilities.emit(capabilities, clientType, venvName) |
1998 self.clientCapabilities.emit(capabilities, clientType, venvName) |
2000 except KeyError: |
|
2001 # ignore silently |
|
2002 pass |
|
2003 |
1999 |
2004 def signalClientCompletionList(self, completionList, text, debuggerId): |
2000 def signalClientCompletionList(self, completionList, text, debuggerId): |
2005 """ |
2001 """ |
2006 Public method to process the client auto completion info. |
2002 Public method to process the client auto completion info. |
2007 |
2003 |