src/eric7/Debugger/DebugServer.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9264
18a7312cfdb3
child 9278
36448ca469c2
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
10 import os 10 import os
11 import shlex 11 import shlex
12 import contextlib 12 import contextlib
13 13
14 from PyQt6.QtCore import pyqtSignal, pyqtSlot, QModelIndex 14 from PyQt6.QtCore import pyqtSignal, pyqtSlot, QModelIndex
15 from PyQt6.QtNetwork import ( 15 from PyQt6.QtNetwork import QTcpServer, QHostAddress, QHostInfo, QNetworkInterface
16 QTcpServer, QHostAddress, QHostInfo, QNetworkInterface
17 )
18 16
19 from EricWidgets.EricApplication import ericApp 17 from EricWidgets.EricApplication import ericApp
20 from EricWidgets import EricMessageBox 18 from EricWidgets import EricMessageBox
21 19
22 from .BreakPointModel import BreakPointModel 20 from .BreakPointModel import BreakPointModel
33 31
34 32
35 class DebugServer(QTcpServer): 33 class DebugServer(QTcpServer):
36 """ 34 """
37 Class implementing the debug server embedded within the IDE. 35 Class implementing the debug server embedded within the IDE.
38 36
39 @signal clientProcessStdout(str) emitted after the client has sent some 37 @signal clientProcessStdout(str) emitted after the client has sent some
40 output via stdout 38 output via stdout
41 @signal clientProcessStderr(str) emitted after the client has sent some 39 @signal clientProcessStderr(str) emitted after the client has sent some
42 output via stderr 40 output via stderr
43 @signal clientOutput(str) emitted after the client has sent some output 41 @signal clientOutput(str) emitted after the client has sent some output
107 @signal appendStdout(msg) emitted when a passive debug connection is 105 @signal appendStdout(msg) emitted when a passive debug connection is
108 established or lost 106 established or lost
109 @signal clientDebuggerId(debuggerId) emitted to indicate a newly connected 107 @signal clientDebuggerId(debuggerId) emitted to indicate a newly connected
110 debugger backend 108 debugger backend
111 """ 109 """
110
112 clientClearBreak = pyqtSignal(str, int, str) 111 clientClearBreak = pyqtSignal(str, int, str)
113 clientClearWatch = pyqtSignal(str, str) 112 clientClearWatch = pyqtSignal(str, str)
114 clientGone = pyqtSignal(bool) 113 clientGone = pyqtSignal(bool)
115 clientProcessStdout = pyqtSignal(str) 114 clientProcessStdout = pyqtSignal(str)
116 clientProcessStderr = pyqtSignal(str) 115 clientProcessStderr = pyqtSignal(str)
117 clientRawInputSent = pyqtSignal(str) 116 clientRawInputSent = pyqtSignal(str)
118 clientOutput = pyqtSignal(str) 117 clientOutput = pyqtSignal(str)
119 clientLine = pyqtSignal(str, int, str, str, bool) 118 clientLine = pyqtSignal(str, int, str, str, bool)
120 clientStack = pyqtSignal(list, str, str) 119 clientStack = pyqtSignal(list, str, str)
121 clientThreadList = pyqtSignal('PyQt_PyObject', list, str) 120 clientThreadList = pyqtSignal("PyQt_PyObject", list, str)
122 clientThreadSet = pyqtSignal(str) 121 clientThreadSet = pyqtSignal(str)
123 clientVariables = pyqtSignal(int, list, str) 122 clientVariables = pyqtSignal(int, list, str)
124 clientVariable = pyqtSignal(int, list, str) 123 clientVariable = pyqtSignal(int, list, str)
125 clientStatement = pyqtSignal(bool, str) 124 clientStatement = pyqtSignal(bool, str)
126 clientDisassembly = pyqtSignal(dict, str) 125 clientDisassembly = pyqtSignal(dict, str)
140 clientInterpreterChanged = pyqtSignal(str) 139 clientInterpreterChanged = pyqtSignal(str)
141 clientDebuggerId = pyqtSignal(str) 140 clientDebuggerId = pyqtSignal(str)
142 passiveDebugStarted = pyqtSignal(str, bool) 141 passiveDebugStarted = pyqtSignal(str, bool)
143 callTraceInfo = pyqtSignal(bool, str, str, str, str, str, str, str) 142 callTraceInfo = pyqtSignal(bool, str, str, str, str, str, str, str)
144 appendStdout = pyqtSignal(str) 143 appendStdout = pyqtSignal(str)
145 144
146 def __init__(self, originalPathString, preventPassiveDebugging=False, 145 def __init__(
147 project=None, parent=None): 146 self,
147 originalPathString,
148 preventPassiveDebugging=False,
149 project=None,
150 parent=None,
151 ):
148 """ 152 """
149 Constructor 153 Constructor
150 154
151 @param originalPathString original PATH environment variable 155 @param originalPathString original PATH environment variable
152 @type str 156 @type str
153 @param preventPassiveDebugging flag overriding the PassiveDbgEnabled 157 @param preventPassiveDebugging flag overriding the PassiveDbgEnabled
154 setting (defaults to False) 158 setting (defaults to False)
155 @type bool (optional) 159 @type bool (optional)
157 @type Project (optional) 161 @type Project (optional)
158 @param parent reference to the parent object 162 @param parent reference to the parent object
159 @type QObject 163 @type QObject
160 """ 164 """
161 super().__init__(parent) 165 super().__init__(parent)
162 166
163 self.__originalPathString = originalPathString 167 self.__originalPathString = originalPathString
164 168
165 self.__debuggerInterfaces = {} 169 self.__debuggerInterfaces = {}
166 # the interface name is the key, a function to get the 170 # the interface name is the key, a function to get the
167 # registration data is the value 171 # registration data is the value
168 self.__debuggerInterfaceRegistry = {} 172 self.__debuggerInterfaceRegistry = {}
169 # the client language is the key, a list containing the client 173 # the client language is the key, a list containing the client
170 # capabilities, a list of associated file extensions, a 174 # capabilities, a list of associated file extensions, a
171 # function reference to create the debugger interface (see 175 # function reference to create the debugger interface (see
172 # __createDebuggerInterface() below) and the interface name is 176 # __createDebuggerInterface() below) and the interface name is
173 # the value 177 # the value
174 178
175 # create our models 179 # create our models
176 self.breakpointModel = BreakPointModel(project, self) 180 self.breakpointModel = BreakPointModel(project, self)
177 self.watchpointModel = WatchPointModel(self) 181 self.watchpointModel = WatchPointModel(self)
178 self.watchSpecialCreated = self.tr( 182 self.watchSpecialCreated = self.tr(
179 "created", "must be same as in EditWatchpointDialog") 183 "created", "must be same as in EditWatchpointDialog"
184 )
180 self.watchSpecialChanged = self.tr( 185 self.watchSpecialChanged = self.tr(
181 "changed", "must be same as in EditWatchpointDialog") 186 "changed", "must be same as in EditWatchpointDialog"
182 187 )
188
183 # arrays to track already reported issues 189 # arrays to track already reported issues
184 self.__reportedBreakpointIssues = [] 190 self.__reportedBreakpointIssues = []
185 self.__reportedWatchpointIssues = [] 191 self.__reportedWatchpointIssues = []
186 192
187 self.networkInterface = Preferences.getDebugger("NetworkInterface") 193 self.networkInterface = Preferences.getDebugger("NetworkInterface")
188 if self.networkInterface == "all": 194 if self.networkInterface == "all":
189 hostAddress = QHostAddress("0.0.0.0") 195 hostAddress = QHostAddress("0.0.0.0")
190 # QHostAddress.SpecialAddress.Any) # secok 196 # QHostAddress.SpecialAddress.Any) # secok
191 elif self.networkInterface == "allv6": 197 elif self.networkInterface == "allv6":
192 hostAddress = QHostAddress("::") 198 hostAddress = QHostAddress("::")
193 # QHostAddress.SpecialAddress.AnyIPv6) 199 # QHostAddress.SpecialAddress.AnyIPv6)
194 else: 200 else:
195 hostAddress = QHostAddress(self.networkInterface) 201 hostAddress = QHostAddress(self.networkInterface)
196 self.networkInterfaceName, self.networkInterfaceIndex = ( 202 (
197 self.__getNetworkInterfaceAndIndex(self.networkInterface)) 203 self.networkInterfaceName,
198 204 self.networkInterfaceIndex,
199 if (not preventPassiveDebugging and 205 ) = self.__getNetworkInterfaceAndIndex(self.networkInterface)
200 Preferences.getDebugger("PassiveDbgEnabled")): 206
207 if not preventPassiveDebugging and Preferences.getDebugger("PassiveDbgEnabled"):
201 sock = Preferences.getDebugger("PassiveDbgPort") # default: 42424 208 sock = Preferences.getDebugger("PassiveDbgPort") # default: 42424
202 self.listen(hostAddress, sock) 209 self.listen(hostAddress, sock)
203 self.passive = True 210 self.passive = True
204 self.passiveClientExited = False 211 self.passiveClientExited = False
205 else: 212 else:
206 if hostAddress.toString().lower().startswith("fe80"): 213 if hostAddress.toString().lower().startswith("fe80"):
207 hostAddress.setScopeId(self.networkInterfaceName) 214 hostAddress.setScopeId(self.networkInterfaceName)
208 self.listen(hostAddress) 215 self.listen(hostAddress)
209 self.passive = False 216 self.passive = False
210 217
211 self.debuggerInterface = None 218 self.debuggerInterface = None
212 self.debugging = False 219 self.debugging = False
213 self.running = False 220 self.running = False
214 self.clientProcess = None 221 self.clientProcess = None
215 self.clientInterpreter = "" 222 self.clientInterpreter = ""
216 self.clientType = Preferences.getSettings().value('DebugClient/Type') 223 self.clientType = Preferences.getSettings().value("DebugClient/Type")
217 if self.clientType is None: 224 if self.clientType is None:
218 self.clientType = 'Python3' 225 self.clientType = "Python3"
219 226
220 self.lastClientType = '' 227 self.lastClientType = ""
221 self.__autoClearShell = False 228 self.__autoClearShell = False
222 self.__forProject = False 229 self.__forProject = False
223 230
224 self.clientClearBreak.connect(self.__clientClearBreakPoint) 231 self.clientClearBreak.connect(self.__clientClearBreakPoint)
225 self.clientClearWatch.connect(self.__clientClearWatchPoint) 232 self.clientClearWatch.connect(self.__clientClearWatchPoint)
226 self.newConnection.connect(self.__newConnection) 233 self.newConnection.connect(self.__newConnection)
227 234
228 self.breakpointModel.rowsAboutToBeRemoved.connect( 235 self.breakpointModel.rowsAboutToBeRemoved.connect(self.__deleteBreakPoints)
229 self.__deleteBreakPoints)
230 self.breakpointModel.dataAboutToBeChanged.connect( 236 self.breakpointModel.dataAboutToBeChanged.connect(
231 self.__breakPointDataAboutToBeChanged) 237 self.__breakPointDataAboutToBeChanged
238 )
232 self.breakpointModel.dataChanged.connect(self.__changeBreakPoints) 239 self.breakpointModel.dataChanged.connect(self.__changeBreakPoints)
233 self.breakpointModel.rowsInserted.connect(self.__addBreakPoints) 240 self.breakpointModel.rowsInserted.connect(self.__addBreakPoints)
234 241
235 self.watchpointModel.rowsAboutToBeRemoved.connect( 242 self.watchpointModel.rowsAboutToBeRemoved.connect(self.__deleteWatchPoints)
236 self.__deleteWatchPoints)
237 self.watchpointModel.dataAboutToBeChanged.connect( 243 self.watchpointModel.dataAboutToBeChanged.connect(
238 self.__watchPointDataAboutToBeChanged) 244 self.__watchPointDataAboutToBeChanged
245 )
239 self.watchpointModel.dataChanged.connect(self.__changeWatchPoints) 246 self.watchpointModel.dataChanged.connect(self.__changeWatchPoints)
240 self.watchpointModel.rowsInserted.connect(self.__addWatchPoints) 247 self.watchpointModel.rowsInserted.connect(self.__addWatchPoints)
241 248
242 self.__maxVariableSize = Preferences.getDebugger("MaxVariableSize") 249 self.__maxVariableSize = Preferences.getDebugger("MaxVariableSize")
243 250
244 self.__multiprocessNoDebugList = [] 251 self.__multiprocessNoDebugList = []
245 252
246 self.__registerDebuggerInterfaces() 253 self.__registerDebuggerInterfaces()
247 254
248 def getHostAddress(self, localhost): 255 def getHostAddress(self, localhost):
249 """ 256 """
250 Public method to get the IP address or hostname the debug server is 257 Public method to get the IP address or hostname the debug server is
251 listening. 258 listening.
252 259
253 @param localhost flag indicating to return the address for localhost 260 @param localhost flag indicating to return the address for localhost
254 @type bool 261 @type bool
255 @return IP address or hostname 262 @return IP address or hostname
256 @rtype str 263 @rtype str
257 """ 264 """
264 if localhost: 271 if localhost:
265 return "::1" 272 return "::1"
266 else: 273 else:
267 return "{0}@@v6".format(QHostInfo.localHostName()) 274 return "{0}@@v6".format(QHostInfo.localHostName())
268 else: 275 else:
269 return "{0}@@i{1}".format(self.networkInterface, 276 return "{0}@@i{1}".format(self.networkInterface, self.networkInterfaceIndex)
270 self.networkInterfaceIndex) 277
271
272 def __getNetworkInterfaceAndIndex(self, address): 278 def __getNetworkInterfaceAndIndex(self, address):
273 """ 279 """
274 Private method to determine the network interface and the interface 280 Private method to determine the network interface and the interface
275 index. 281 index.
276 282
277 @param address address to determine the info for 283 @param address address to determine the info for
278 @type str 284 @type str
279 @return tuple of network interface name and index 285 @return tuple of network interface name and index
280 @rtype tuple of (str, int) 286 @rtype tuple of (str, int)
281 """ 287 """
282 if address not in ["all", "allv6"]: 288 if address not in ["all", "allv6"]:
283 for networkInterface in QNetworkInterface.allInterfaces(): 289 for networkInterface in QNetworkInterface.allInterfaces():
284 addressEntries = networkInterface.addressEntries() 290 addressEntries = networkInterface.addressEntries()
285 if len(addressEntries) > 0: 291 if len(addressEntries) > 0:
286 for addressEntry in addressEntries: 292 for addressEntry in addressEntries:
287 if (addressEntry.ip().toString().lower() == 293 if addressEntry.ip().toString().lower() == address.lower():
288 address.lower()): 294 return (
289 return (networkInterface.humanReadableName(), 295 networkInterface.humanReadableName(),
290 networkInterface.index()) 296 networkInterface.index(),
291 297 )
298
292 return "", 0 299 return "", 0
293 300
294 def preferencesChanged(self): 301 def preferencesChanged(self):
295 """ 302 """
296 Public slot to handle the preferencesChanged signal. 303 Public slot to handle the preferencesChanged signal.
297 """ 304 """
298 registeredInterfaces = {} 305 registeredInterfaces = {}
299 for interfaceName in self.__debuggerInterfaces: 306 for interfaceName in self.__debuggerInterfaces:
300 registeredInterfaces[interfaceName] = ( 307 registeredInterfaces[interfaceName] = self.__debuggerInterfaces[
301 self.__debuggerInterfaces[interfaceName]) 308 interfaceName
302 309 ]
310
303 self.__debuggerInterfaceRegistry = {} 311 self.__debuggerInterfaceRegistry = {}
304 for interfaceName, getRegistryData in registeredInterfaces.items(): 312 for interfaceName, getRegistryData in registeredInterfaces.items():
305 self.registerDebuggerInterface(interfaceName, getRegistryData, 313 self.registerDebuggerInterface(
306 reregister=True) 314 interfaceName, getRegistryData, reregister=True
307 315 )
316
308 self.__maxVariableSize = Preferences.getDebugger("MaxVariableSize") 317 self.__maxVariableSize = Preferences.getDebugger("MaxVariableSize")
309 318
310 def registerDebuggerInterface(self, interfaceName, getRegistryData, 319 def registerDebuggerInterface(
311 reregister=False): 320 self, interfaceName, getRegistryData, reregister=False
321 ):
312 """ 322 """
313 Public method to register a debugger interface. 323 Public method to register a debugger interface.
314 324
315 @param interfaceName name of the debugger interface 325 @param interfaceName name of the debugger interface
316 @type str 326 @type str
317 @param getRegistryData reference to a function to be called 327 @param getRegistryData reference to a function to be called
318 to get the debugger interface details. This method shall 328 to get the debugger interface details. This method shall
319 return the client language, the client capabilities, the 329 return the client language, the client capabilities, the
325 """ 335 """
326 if interfaceName in self.__debuggerInterfaces and not reregister: 336 if interfaceName in self.__debuggerInterfaces and not reregister:
327 EricMessageBox.warning( 337 EricMessageBox.warning(
328 None, 338 None,
329 self.tr("Register Debugger Interface"), 339 self.tr("Register Debugger Interface"),
330 self.tr("""<p>The debugger interface <b>{0}</b> has already""" 340 self.tr(
331 """ been registered. Ignoring this request.</p>""")) 341 """<p>The debugger interface <b>{0}</b> has already"""
342 """ been registered. Ignoring this request.</p>"""
343 ),
344 )
332 return 345 return
333 346
334 if not reregister: 347 if not reregister:
335 self.__debuggerInterfaces[interfaceName] = getRegistryData 348 self.__debuggerInterfaces[interfaceName] = getRegistryData
336 registryDataList = getRegistryData() 349 registryDataList = getRegistryData()
337 if registryDataList: 350 if registryDataList:
338 for (clientLanguage, clientCapabilities, clientExtensions, 351 for (
339 interfaceCreator) in registryDataList: 352 clientLanguage,
353 clientCapabilities,
354 clientExtensions,
355 interfaceCreator,
356 ) in registryDataList:
340 self.__debuggerInterfaceRegistry[clientLanguage] = [ 357 self.__debuggerInterfaceRegistry[clientLanguage] = [
341 clientCapabilities, clientExtensions, interfaceCreator, 358 clientCapabilities,
342 interfaceName] 359 clientExtensions,
343 360 interfaceCreator,
361 interfaceName,
362 ]
363
344 def unregisterDebuggerInterface(self, interfaceName): 364 def unregisterDebuggerInterface(self, interfaceName):
345 """ 365 """
346 Public method to unregister a debugger interface. 366 Public method to unregister a debugger interface.
347 367
348 @param interfaceName interfaceName of the debugger interface 368 @param interfaceName interfaceName of the debugger interface
349 @type str 369 @type str
350 """ 370 """
351 if interfaceName in self.__debuggerInterfaces: 371 if interfaceName in self.__debuggerInterfaces:
352 clientLanguages = [] 372 clientLanguages = []
353 for clientLanguage, registryData in ( 373 for (
354 self.__debuggerInterfaceRegistry.items()): 374 clientLanguage,
375 registryData,
376 ) in self.__debuggerInterfaceRegistry.items():
355 if interfaceName == registryData[-1]: 377 if interfaceName == registryData[-1]:
356 clientLanguages.append(clientLanguage) 378 clientLanguages.append(clientLanguage)
357 for clientLanguage in clientLanguages: 379 for clientLanguage in clientLanguages:
358 del self.__debuggerInterfaceRegistry[clientLanguage] 380 del self.__debuggerInterfaceRegistry[clientLanguage]
359 del self.__debuggerInterfaces[interfaceName] 381 del self.__debuggerInterfaces[interfaceName]
360 382
361 def __findLanguageForExtension(self, ext): 383 def __findLanguageForExtension(self, ext):
362 """ 384 """
363 Private method to get the language associated with a file extension. 385 Private method to get the language associated with a file extension.
364 386
365 @param ext file extension 387 @param ext file extension
366 @type str 388 @type str
367 @return associated language 389 @return associated language
368 @rtype str 390 @rtype str
369 """ 391 """
370 for language in self.__debuggerInterfaceRegistry: 392 for language in self.__debuggerInterfaceRegistry:
371 if ext in self.__debuggerInterfaceRegistry[language][1]: 393 if ext in self.__debuggerInterfaceRegistry[language][1]:
372 return language 394 return language
373 395
374 return "" 396 return ""
375 397
376 def __registerDebuggerInterfaces(self): 398 def __registerDebuggerInterfaces(self):
377 """ 399 """
378 Private method to register the available internal debugger interfaces. 400 Private method to register the available internal debugger interfaces.
379 """ 401 """
380 for name, interface in DebuggerInterfaces.items(): 402 for name, interface in DebuggerInterfaces.items():
381 modName = "Debugger.{0}".format(interface) 403 modName = "Debugger.{0}".format(interface)
382 mod = __import__(modName) 404 mod = __import__(modName)
383 components = modName.split('.') 405 components = modName.split(".")
384 for comp in components[1:]: 406 for comp in components[1:]:
385 mod = getattr(mod, comp) 407 mod = getattr(mod, comp)
386 408
387 self.registerDebuggerInterface(name, mod.getRegistryData) 409 self.registerDebuggerInterface(name, mod.getRegistryData)
388 410
389 def getSupportedLanguages(self, shellOnly=False): 411 def getSupportedLanguages(self, shellOnly=False):
390 """ 412 """
391 Public slot to return the supported programming languages. 413 Public slot to return the supported programming languages.
392 414
393 @param shellOnly flag indicating only languages supporting an 415 @param shellOnly flag indicating only languages supporting an
394 interactive shell should be returned 416 interactive shell should be returned
395 @type bool 417 @type bool
396 @return list of supported languages 418 @return list of supported languages
397 @rtype list of str 419 @rtype list of str
398 """ 420 """
399 languages = list(self.__debuggerInterfaceRegistry.keys()) 421 languages = list(self.__debuggerInterfaceRegistry.keys())
400 with contextlib.suppress(ValueError): 422 with contextlib.suppress(ValueError):
401 languages.remove("None") 423 languages.remove("None")
402 424
403 if shellOnly: 425 if shellOnly:
404 languages = [lang for lang in languages 426 languages = [
405 if self.__debuggerInterfaceRegistry[lang][0] & 427 lang
406 DebugClientCapabilities.HasShell] 428 for lang in languages
407 429 if self.__debuggerInterfaceRegistry[lang][0]
430 & DebugClientCapabilities.HasShell
431 ]
432
408 return languages[:] 433 return languages[:]
409 434
410 def getExtensions(self, language): 435 def getExtensions(self, language):
411 """ 436 """
412 Public slot to get the extensions associated with the given language. 437 Public slot to get the extensions associated with the given language.
413 438
414 @param language language to get extensions for 439 @param language language to get extensions for
415 @type str 440 @type str
416 @return tuple of extensions associated with the language 441 @return tuple of extensions associated with the language
417 @rtype tuple of str 442 @rtype tuple of str
418 """ 443 """
419 if language in self.__debuggerInterfaceRegistry: 444 if language in self.__debuggerInterfaceRegistry:
420 return tuple(self.__debuggerInterfaceRegistry[language][1]) 445 return tuple(self.__debuggerInterfaceRegistry[language][1])
421 else: 446 else:
422 return () 447 return ()
423 448
424 def __createDebuggerInterface(self, clientType=None): 449 def __createDebuggerInterface(self, clientType=None):
425 """ 450 """
426 Private slot to create the debugger interface object. 451 Private slot to create the debugger interface object.
427 452
428 @param clientType type of the client interface to be created 453 @param clientType type of the client interface to be created
429 @type str 454 @type str
430 """ 455 """
431 if self.lastClientType != self.clientType or clientType is not None: 456 if self.lastClientType != self.clientType or clientType is not None:
432 if clientType is None: 457 if clientType is None:
433 clientType = self.clientType 458 clientType = self.clientType
434 if clientType in self.__debuggerInterfaceRegistry: 459 if clientType in self.__debuggerInterfaceRegistry:
435 self.debuggerInterface = ( 460 self.debuggerInterface = self.__debuggerInterfaceRegistry[clientType][
436 self.__debuggerInterfaceRegistry[clientType][2]( 461 2
437 self, self.passive)) 462 ](self, self.passive)
438 else: 463 else:
439 self.debuggerInterface = ( 464 self.debuggerInterface = self.__debuggerInterfaceRegistry["None"][2](
440 self.__debuggerInterfaceRegistry["None"][2]( 465 self, self.passive
441 self, self.passive)) 466 )
442 self.clientType = "None" 467 self.clientType = "None"
443 468
444 def __setClientType(self, clType): 469 def __setClientType(self, clType):
445 """ 470 """
446 Private method to set the client type. 471 Private method to set the client type.
447 472
448 @param clType type of client to be started 473 @param clType type of client to be started
449 @type str 474 @type str
450 """ 475 """
451 if clType is not None and clType in self.getSupportedLanguages(): 476 if clType is not None and clType in self.getSupportedLanguages():
452 self.clientType = clType 477 self.clientType = clType
453 Preferences.getSettings().setValue( 478 Preferences.getSettings().setValue("DebugClient/Type", self.clientType)
454 'DebugClient/Type', self.clientType) 479
455 480 def startClient(
456 def startClient(self, unplanned=True, clType=None, forProject=False, 481 self,
457 runInConsole=False, venvName="", workingDir=None, 482 unplanned=True,
458 configOverride=None): 483 clType=None,
484 forProject=False,
485 runInConsole=False,
486 venvName="",
487 workingDir=None,
488 configOverride=None,
489 ):
459 """ 490 """
460 Public method to start a debug client. 491 Public method to start a debug client.
461 492
462 @param unplanned flag indicating that the client has died 493 @param unplanned flag indicating that the client has died
463 @type bool 494 @type bool
464 @param clType type of client to be started 495 @param clType type of client to be started
465 @type str 496 @type str
466 @param forProject flag indicating a project related action 497 @param forProject flag indicating a project related action
475 @param configOverride dictionary containing the global config override 506 @param configOverride dictionary containing the global config override
476 data 507 data
477 @type dict 508 @type dict
478 """ 509 """
479 self.running = False 510 self.running = False
480 511
481 if ( 512 if (
482 (not self.passive or not self.passiveClientExited) and 513 (not self.passive or not self.passiveClientExited)
483 self.debuggerInterface and 514 and self.debuggerInterface
484 self.debuggerInterface.isConnected() 515 and self.debuggerInterface.isConnected()
485 ): 516 ):
486 self.shutdownServer() 517 self.shutdownServer()
487 self.debugging = False 518 self.debugging = False
488 self.clientGone.emit(unplanned and self.debugging) 519 self.clientGone.emit(unplanned and self.debugging)
489 520
490 if clType: 521 if clType:
491 if clType not in self.getSupportedLanguages(): 522 if clType not in self.getSupportedLanguages():
492 # a not supported client language was requested 523 # a not supported client language was requested
493 return 524 return
494 525
495 self.__setClientType(clType) 526 self.__setClientType(clType)
496 527
497 # only start the client, if we are not in passive mode 528 # only start the client, if we are not in passive mode
498 if not self.passive: 529 if not self.passive:
499 if self.clientProcess: 530 if self.clientProcess:
500 with contextlib.suppress(RuntimeError): 531 with contextlib.suppress(RuntimeError):
501 # Workaround: The wrapped C/C++ object of type QProcess 532 # Workaround: The wrapped C/C++ object of type QProcess
502 # gets deleted prematurely sometimes. 533 # gets deleted prematurely sometimes.
503 self.clientProcess.kill() 534 self.clientProcess.kill()
504 self.clientProcess.waitForFinished(1000) 535 self.clientProcess.waitForFinished(1000)
505 self.clientProcess.deleteLater() 536 self.clientProcess.deleteLater()
506 self.clientProcess = None 537 self.clientProcess = None
507 538
508 self.__forProject = forProject 539 self.__forProject = forProject
509 self.__createDebuggerInterface() 540 self.__createDebuggerInterface()
510 if forProject: 541 if forProject:
511 project = ericApp().getObject("Project") 542 project = ericApp().getObject("Project")
512 if not project.isDebugPropertiesLoaded(): 543 if not project.isDebugPropertiesLoaded():
513 self.clientProcess, isNetworked, clientInterpreter = ( 544 (
514 self.debuggerInterface.startRemote( 545 self.clientProcess,
515 self.serverPort(), runInConsole, venvName, 546 isNetworked,
516 self.__originalPathString, workingDir=workingDir, 547 clientInterpreter,
517 configOverride=configOverride)) 548 ) = self.debuggerInterface.startRemote(
549 self.serverPort(),
550 runInConsole,
551 venvName,
552 self.__originalPathString,
553 workingDir=workingDir,
554 configOverride=configOverride,
555 )
518 else: 556 else:
519 self.clientProcess, isNetworked, clientInterpreter = ( 557 (
520 self.debuggerInterface.startRemoteForProject( 558 self.clientProcess,
521 self.serverPort(), runInConsole, venvName, 559 isNetworked,
522 self.__originalPathString, workingDir=workingDir, 560 clientInterpreter,
523 configOverride=configOverride)) 561 ) = self.debuggerInterface.startRemoteForProject(
562 self.serverPort(),
563 runInConsole,
564 venvName,
565 self.__originalPathString,
566 workingDir=workingDir,
567 configOverride=configOverride,
568 )
524 else: 569 else:
525 self.clientProcess, isNetworked, clientInterpreter = ( 570 (
526 self.debuggerInterface.startRemote( 571 self.clientProcess,
527 self.serverPort(), runInConsole, venvName, 572 isNetworked,
528 self.__originalPathString, workingDir=workingDir, 573 clientInterpreter,
529 configOverride=configOverride)) 574 ) = self.debuggerInterface.startRemote(
530 575 self.serverPort(),
576 runInConsole,
577 venvName,
578 self.__originalPathString,
579 workingDir=workingDir,
580 configOverride=configOverride,
581 )
582
531 if self.clientProcess: 583 if self.clientProcess:
532 self.clientProcess.readyReadStandardError.connect( 584 self.clientProcess.readyReadStandardError.connect(
533 self.__clientProcessError) 585 self.__clientProcessError
586 )
534 self.clientProcess.readyReadStandardOutput.connect( 587 self.clientProcess.readyReadStandardOutput.connect(
535 self.__clientProcessOutput) 588 self.__clientProcessOutput
536 589 )
590
537 # Perform actions necessary, if client type has changed 591 # Perform actions necessary, if client type has changed
538 if self.lastClientType != self.clientType: 592 if self.lastClientType != self.clientType:
539 self.lastClientType = self.clientType 593 self.lastClientType = self.clientType
540 self.remoteBanner() 594 self.remoteBanner()
541 elif self.__autoClearShell: 595 elif self.__autoClearShell:
545 if clType and self.lastClientType: 599 if clType and self.lastClientType:
546 self.__setClientType(self.lastClientType) 600 self.__setClientType(self.lastClientType)
547 else: 601 else:
548 self.__createDebuggerInterface("None") 602 self.__createDebuggerInterface("None")
549 clientInterpreter = "" 603 clientInterpreter = ""
550 604
551 if clientInterpreter != self.clientInterpreter: 605 if clientInterpreter != self.clientInterpreter:
552 self.clientInterpreter = clientInterpreter 606 self.clientInterpreter = clientInterpreter
553 self.clientInterpreterChanged.emit(clientInterpreter) 607 self.clientInterpreterChanged.emit(clientInterpreter)
554 608
555 def __clientProcessOutput(self): 609 def __clientProcessOutput(self):
556 """ 610 """
557 Private slot to process client output received via stdout. 611 Private slot to process client output received via stdout.
558 """ 612 """
559 output = str(self.clientProcess.readAllStandardOutput(), 613 output = str(
560 Preferences.getSystem("IOEncoding"), 614 self.clientProcess.readAllStandardOutput(),
561 'replace') 615 Preferences.getSystem("IOEncoding"),
616 "replace",
617 )
562 self.clientProcessStdout.emit(output) 618 self.clientProcessStdout.emit(output)
563 619
564 def __clientProcessError(self): 620 def __clientProcessError(self):
565 """ 621 """
566 Private slot to process client output received via stderr. 622 Private slot to process client output received via stderr.
567 """ 623 """
568 error = str(self.clientProcess.readAllStandardError(), 624 error = str(
569 Preferences.getSystem("IOEncoding"), 625 self.clientProcess.readAllStandardError(),
570 'replace') 626 Preferences.getSystem("IOEncoding"),
627 "replace",
628 )
571 self.clientProcessStderr.emit(error) 629 self.clientProcessStderr.emit(error)
572 630
573 @pyqtSlot(str, int) 631 @pyqtSlot(str, int)
574 def __clientClearBreakPoint(self, fn, lineno): 632 def __clientClearBreakPoint(self, fn, lineno):
575 """ 633 """
576 Private slot to handle the clientClearBreak signal. 634 Private slot to handle the clientClearBreak signal.
577 635
578 @param fn filename of breakpoint to clear 636 @param fn filename of breakpoint to clear
579 @type str 637 @type str
580 @param lineno line number of breakpoint to clear 638 @param lineno line number of breakpoint to clear
581 @type int 639 @type int
582 """ 640 """
583 if self.debugging: 641 if self.debugging:
584 index = self.breakpointModel.getBreakPointIndex(fn, lineno) 642 index = self.breakpointModel.getBreakPointIndex(fn, lineno)
585 self.breakpointModel.deleteBreakPointByIndex(index) 643 self.breakpointModel.deleteBreakPointByIndex(index)
586 if (fn, lineno) in self.__reportedBreakpointIssues: 644 if (fn, lineno) in self.__reportedBreakpointIssues:
587 self.__reportedBreakpointIssues.remove((fn, lineno)) 645 self.__reportedBreakpointIssues.remove((fn, lineno))
588 646
589 def __deleteBreakPoints(self, parentIndex, start, end): 647 def __deleteBreakPoints(self, parentIndex, start, end):
590 """ 648 """
591 Private slot to delete breakpoints. 649 Private slot to delete breakpoints.
592 650
593 @param parentIndex index of parent item 651 @param parentIndex index of parent item
594 @type QModelIndex 652 @type QModelIndex
595 @param start start row 653 @param start start row
596 @type int 654 @type int
597 @param end end row 655 @param end end row
598 @type int 656 @type int
599 """ 657 """
600 if self.debugging: 658 if self.debugging:
601 for row in range(start, end + 1): 659 for row in range(start, end + 1):
602 index = self.breakpointModel.index(row, 0, parentIndex) 660 index = self.breakpointModel.index(row, 0, parentIndex)
603 fn, lineno = ( 661 fn, lineno = self.breakpointModel.getBreakPointByIndex(index)[0:2]
604 self.breakpointModel.getBreakPointByIndex(index)[0:2])
605 # delete the breakpoints of all connected backends 662 # delete the breakpoints of all connected backends
606 self.remoteBreakpoint("", fn, lineno, False) 663 self.remoteBreakpoint("", fn, lineno, False)
607 if (fn, lineno) in self.__reportedBreakpointIssues: 664 if (fn, lineno) in self.__reportedBreakpointIssues:
608 self.__reportedBreakpointIssues.remove((fn, lineno)) 665 self.__reportedBreakpointIssues.remove((fn, lineno))
609 666
610 def __changeBreakPoints(self, startIndex, endIndex): 667 def __changeBreakPoints(self, startIndex, endIndex):
611 """ 668 """
612 Private slot to set changed breakpoints. 669 Private slot to set changed breakpoints.
613 670
614 @param startIndex starting index of the change breakpoins 671 @param startIndex starting index of the change breakpoins
615 @type QModelIndex 672 @type QModelIndex
616 @param endIndex ending index of the change breakpoins 673 @param endIndex ending index of the change breakpoins
617 @type QModelIndex 674 @type QModelIndex
618 """ 675 """
619 if self.debugging: 676 if self.debugging:
620 self.__addBreakPoints( 677 self.__addBreakPoints(QModelIndex(), startIndex.row(), endIndex.row())
621 QModelIndex(), startIndex.row(), endIndex.row()) 678
622
623 def __breakPointDataAboutToBeChanged(self, startIndex, endIndex): 679 def __breakPointDataAboutToBeChanged(self, startIndex, endIndex):
624 """ 680 """
625 Private slot to handle the dataAboutToBeChanged signal of the 681 Private slot to handle the dataAboutToBeChanged signal of the
626 breakpoint model. 682 breakpoint model.
627 683
628 @param startIndex start index of the rows to be changed 684 @param startIndex start index of the rows to be changed
629 @type QModelIndex 685 @type QModelIndex
630 @param endIndex end index of the rows to be changed 686 @param endIndex end index of the rows to be changed
631 @type QModelIndex 687 @type QModelIndex
632 """ 688 """
633 if self.debugging: 689 if self.debugging:
634 self.__deleteBreakPoints( 690 self.__deleteBreakPoints(QModelIndex(), startIndex.row(), endIndex.row())
635 QModelIndex(), startIndex.row(), endIndex.row()) 691
636
637 def __addBreakPoints(self, parentIndex, start, end, debuggerId=""): 692 def __addBreakPoints(self, parentIndex, start, end, debuggerId=""):
638 """ 693 """
639 Private slot to add breakpoints. 694 Private slot to add breakpoints.
640 695
641 @param parentIndex index of parent item 696 @param parentIndex index of parent item
642 @type QModelIndex 697 @type QModelIndex
643 @param start start row 698 @param start start row
644 @type int 699 @type int
645 @param end end row 700 @param end end row
649 @type str 704 @type str
650 """ 705 """
651 if self.debugging: 706 if self.debugging:
652 for row in range(start, end + 1): 707 for row in range(start, end + 1):
653 index = self.breakpointModel.index(row, 0, parentIndex) 708 index = self.breakpointModel.index(row, 0, parentIndex)
654 fn, lineno, cond, temp, enabled, ignorecount = ( 709 (
655 self.breakpointModel.getBreakPointByIndex(index)[:6]) 710 fn,
656 711 lineno,
712 cond,
713 temp,
714 enabled,
715 ignorecount,
716 ) = self.breakpointModel.getBreakPointByIndex(index)[:6]
717
657 if (fn, lineno) in self.__reportedBreakpointIssues: 718 if (fn, lineno) in self.__reportedBreakpointIssues:
658 self.__reportedBreakpointIssues.remove((fn, lineno)) 719 self.__reportedBreakpointIssues.remove((fn, lineno))
659 720
660 self.remoteBreakpoint(debuggerId, fn, lineno, True, cond, temp) 721 self.remoteBreakpoint(debuggerId, fn, lineno, True, cond, temp)
661 if not enabled: 722 if not enabled:
662 self.__remoteBreakpointEnable( 723 self.__remoteBreakpointEnable(debuggerId, fn, lineno, False)
663 debuggerId, fn, lineno, False)
664 if ignorecount: 724 if ignorecount:
665 self.__remoteBreakpointIgnore( 725 self.__remoteBreakpointIgnore(debuggerId, fn, lineno, ignorecount)
666 debuggerId, fn, lineno, ignorecount) 726
667
668 def __makeWatchCondition(self, cond, special): 727 def __makeWatchCondition(self, cond, special):
669 """ 728 """
670 Private method to construct the condition string. 729 Private method to construct the condition string.
671 730
672 @param cond condition 731 @param cond condition
673 @type str 732 @type str
674 @param special special condition 733 @param special special condition
675 @type str 734 @type str
676 @return condition string 735 @return condition string
682 if special == self.watchSpecialCreated: 741 if special == self.watchSpecialCreated:
683 _cond = "{0} ??created??".format(cond) 742 _cond = "{0} ??created??".format(cond)
684 elif special == self.watchSpecialChanged: 743 elif special == self.watchSpecialChanged:
685 _cond = "{0} ??changed??".format(cond) 744 _cond = "{0} ??changed??".format(cond)
686 return _cond 745 return _cond
687 746
688 def __splitWatchCondition(self, cond): 747 def __splitWatchCondition(self, cond):
689 """ 748 """
690 Private method to split a remote watch expression. 749 Private method to split a remote watch expression.
691 750
692 @param cond remote expression 751 @param cond remote expression
693 @type str 752 @type str
694 @return tuple of local expression (string) and special condition 753 @return tuple of local expression (string) and special condition
695 @rtype str 754 @rtype str
696 """ 755 """
701 cond, special = cond.split() 760 cond, special = cond.split()
702 special = self.watchSpecialChanged 761 special = self.watchSpecialChanged
703 else: 762 else:
704 cond = cond 763 cond = cond
705 special = "" 764 special = ""
706 765
707 return cond, special 766 return cond, special
708 767
709 @pyqtSlot(str) 768 @pyqtSlot(str)
710 def __clientClearWatchPoint(self, condition): 769 def __clientClearWatchPoint(self, condition):
711 """ 770 """
712 Private slot to handle the clientClearWatch signal. 771 Private slot to handle the clientClearWatch signal.
713 772
714 @param condition expression of watch expression to clear 773 @param condition expression of watch expression to clear
715 @type str 774 @type str
716 """ 775 """
717 if self.debugging: 776 if self.debugging:
718 cond, special = self.__splitWatchCondition(condition) 777 cond, special = self.__splitWatchCondition(condition)
719 index = self.watchpointModel.getWatchPointIndex(cond, special) 778 index = self.watchpointModel.getWatchPointIndex(cond, special)
720 self.watchpointModel.deleteWatchPointByIndex(index) 779 self.watchpointModel.deleteWatchPointByIndex(index)
721 if condition in self.__reportedWatchpointIssues: 780 if condition in self.__reportedWatchpointIssues:
722 self.__reportedWatchpointIssues.remove(condition) 781 self.__reportedWatchpointIssues.remove(condition)
723 782
724 def __deleteWatchPoints(self, parentIndex, start, end): 783 def __deleteWatchPoints(self, parentIndex, start, end):
725 """ 784 """
726 Private slot to delete watch expressions. 785 Private slot to delete watch expressions.
727 786
728 @param parentIndex index of parent item 787 @param parentIndex index of parent item
729 @type QModelIndex 788 @type QModelIndex
730 @param start start row 789 @param start start row
731 @type int 790 @type int
732 @param end end row 791 @param end end row
733 @type int 792 @type int
734 """ 793 """
735 if self.debugging: 794 if self.debugging:
736 for row in range(start, end + 1): 795 for row in range(start, end + 1):
737 index = self.watchpointModel.index(row, 0, parentIndex) 796 index = self.watchpointModel.index(row, 0, parentIndex)
738 cond, special = ( 797 cond, special = self.watchpointModel.getWatchPointByIndex(index)[0:2]
739 self.watchpointModel.getWatchPointByIndex(index)[0:2])
740 cond = self.__makeWatchCondition(cond, special) 798 cond = self.__makeWatchCondition(cond, special)
741 self.__remoteWatchpoint("", cond, False) 799 self.__remoteWatchpoint("", cond, False)
742 if cond in self.__reportedWatchpointIssues: 800 if cond in self.__reportedWatchpointIssues:
743 self.__reportedWatchpointIssues.remove(cond) 801 self.__reportedWatchpointIssues.remove(cond)
744 802
745 def __watchPointDataAboutToBeChanged(self, startIndex, endIndex): 803 def __watchPointDataAboutToBeChanged(self, startIndex, endIndex):
746 """ 804 """
747 Private slot to handle the dataAboutToBeChanged signal of the 805 Private slot to handle the dataAboutToBeChanged signal of the
748 watch expression model. 806 watch expression model.
749 807
750 @param startIndex start index of the rows to be changed 808 @param startIndex start index of the rows to be changed
751 @type QModelIndex 809 @type QModelIndex
752 @param endIndex end index of the rows to be changed 810 @param endIndex end index of the rows to be changed
753 @type QModelIndex 811 @type QModelIndex
754 """ 812 """
755 if self.debugging: 813 if self.debugging:
756 self.__deleteWatchPoints( 814 self.__deleteWatchPoints(QModelIndex(), startIndex.row(), endIndex.row())
757 QModelIndex(), startIndex.row(), endIndex.row()) 815
758
759 def __addWatchPoints(self, parentIndex, start, end, debuggerId=""): 816 def __addWatchPoints(self, parentIndex, start, end, debuggerId=""):
760 """ 817 """
761 Private slot to set a watch expression. 818 Private slot to set a watch expression.
762 819
763 @param parentIndex index of parent item 820 @param parentIndex index of parent item
764 @type QModelIndex 821 @type QModelIndex
765 @param start start row 822 @param start start row
766 @type int 823 @type int
767 @param end end row 824 @param end end row
771 @type str 828 @type str
772 """ 829 """
773 if self.debugging: 830 if self.debugging:
774 for row in range(start, end + 1): 831 for row in range(start, end + 1):
775 index = self.watchpointModel.index(row, 0, parentIndex) 832 index = self.watchpointModel.index(row, 0, parentIndex)
776 cond, special, temp, enabled, ignorecount = ( 833 (
777 self.watchpointModel.getWatchPointByIndex(index)[:5]) 834 cond,
835 special,
836 temp,
837 enabled,
838 ignorecount,
839 ) = self.watchpointModel.getWatchPointByIndex(index)[:5]
778 cond = self.__makeWatchCondition(cond, special) 840 cond = self.__makeWatchCondition(cond, special)
779 841
780 if cond in self.__reportedWatchpointIssues: 842 if cond in self.__reportedWatchpointIssues:
781 self.__reportedWatchpointIssues.remove(cond) 843 self.__reportedWatchpointIssues.remove(cond)
782 844
783 self.__remoteWatchpoint(debuggerId, cond, True, temp) 845 self.__remoteWatchpoint(debuggerId, cond, True, temp)
784 if not enabled: 846 if not enabled:
785 self.__remoteWatchpointEnable(debuggerId, cond, False) 847 self.__remoteWatchpointEnable(debuggerId, cond, False)
786 if ignorecount: 848 if ignorecount:
787 self.__remoteWatchpointIgnore(debuggerId, cond, 849 self.__remoteWatchpointIgnore(debuggerId, cond, ignorecount)
788 ignorecount) 850
789
790 def __changeWatchPoints(self, startIndex, endIndex): 851 def __changeWatchPoints(self, startIndex, endIndex):
791 """ 852 """
792 Private slot to set changed watch expressions. 853 Private slot to set changed watch expressions.
793 854
794 @param startIndex start index of the rows to be changed 855 @param startIndex start index of the rows to be changed
795 @type QModelIndex 856 @type QModelIndex
796 @param endIndex end index of the rows to be changed 857 @param endIndex end index of the rows to be changed
797 @type QModelIndex 858 @type QModelIndex
798 """ 859 """
799 if self.debugging: 860 if self.debugging:
800 self.__addWatchPoints( 861 self.__addWatchPoints(QModelIndex(), startIndex.row(), endIndex.row())
801 QModelIndex(), startIndex.row(), endIndex.row()) 862
802
803 def getClientCapabilities(self, clientType): 863 def getClientCapabilities(self, clientType):
804 """ 864 """
805 Public method to retrieve the debug clients capabilities. 865 Public method to retrieve the debug clients capabilities.
806 866
807 @param clientType debug client type 867 @param clientType debug client type
808 @type str 868 @type str
809 @return debug client capabilities 869 @return debug client capabilities
810 @rtype int 870 @rtype int
811 """ 871 """
812 try: 872 try:
813 return self.__debuggerInterfaceRegistry[clientType][0] 873 return self.__debuggerInterfaceRegistry[clientType][0]
814 except KeyError: 874 except KeyError:
815 return 0 # no capabilities 875 return 0 # no capabilities
816 876
817 def getClientInterpreter(self): 877 def getClientInterpreter(self):
818 """ 878 """
819 Public method to get the interpreter of the debug client. 879 Public method to get the interpreter of the debug client.
820 880
821 @return interpreter of the debug client 881 @return interpreter of the debug client
822 @rtype str 882 @rtype str
823 """ 883 """
824 return self.clientInterpreter 884 return self.clientInterpreter
825 885
826 def getClientType(self): 886 def getClientType(self):
827 """ 887 """
828 Public method to get the currently running debug client type. 888 Public method to get the currently running debug client type.
829 889
830 @return debug client type 890 @return debug client type
831 @rtype str 891 @rtype str
832 """ 892 """
833 return self.clientType 893 return self.clientType
834 894
835 def isClientProcessUp(self): 895 def isClientProcessUp(self):
836 """ 896 """
837 Public method to check, if the debug client process is up. 897 Public method to check, if the debug client process is up.
838 898
839 @return flag indicating a running debug client process 899 @return flag indicating a running debug client process
840 @rtype bool 900 @rtype bool
841 """ 901 """
842 return self.clientProcess is not None 902 return self.clientProcess is not None
843 903
844 def __newConnection(self): 904 def __newConnection(self):
845 """ 905 """
846 Private slot to handle a new connection. 906 Private slot to handle a new connection.
847 """ 907 """
848 sock = self.nextPendingConnection() 908 sock = self.nextPendingConnection()
852 res = EricMessageBox.yesNo( 912 res = EricMessageBox.yesNo(
853 None, 913 None,
854 self.tr("Connection from illegal host"), 914 self.tr("Connection from illegal host"),
855 self.tr( 915 self.tr(
856 """<p>A connection was attempted by the illegal host""" 916 """<p>A connection was attempted by the illegal host"""
857 """ <b>{0}</b>. Accept this connection?</p>""") 917 """ <b>{0}</b>. Accept this connection?</p>"""
858 .format(peerAddress), 918 ).format(peerAddress),
859 icon=EricMessageBox.Warning) 919 icon=EricMessageBox.Warning,
920 )
860 if not res: 921 if not res:
861 sock.abort() 922 sock.abort()
862 return 923 return
863 else: 924 else:
864 allowedHosts = Preferences.getDebugger("AllowedHosts") 925 allowedHosts = Preferences.getDebugger("AllowedHosts")
865 allowedHosts.append(peerAddress) 926 allowedHosts.append(peerAddress)
866 Preferences.setDebugger("AllowedHosts", allowedHosts) 927 Preferences.setDebugger("AllowedHosts", allowedHosts)
867 928
868 if self.passive: 929 if self.passive:
869 self.__createDebuggerInterface( 930 self.__createDebuggerInterface(Preferences.getDebugger("PassiveDbgType"))
870 Preferences.getDebugger("PassiveDbgType")) 931
871
872 self.debuggerInterface.newConnection(sock) 932 self.debuggerInterface.newConnection(sock)
873 933
874 def masterClientConnected(self): 934 def masterClientConnected(self):
875 """ 935 """
876 Public method to perform actions after the master client has finally 936 Public method to perform actions after the master client has finally
877 established the connection. 937 established the connection.
878 """ 938 """
883 elif self.__autoClearShell: 943 elif self.__autoClearShell:
884 self.__autoClearShell = False 944 self.__autoClearShell = False
885 self.remoteBanner() 945 self.remoteBanner()
886 elif self.passive: 946 elif self.passive:
887 self.remoteBanner() 947 self.remoteBanner()
888 948
889 def shutdownServer(self): 949 def shutdownServer(self):
890 """ 950 """
891 Public method to cleanly shut down. 951 Public method to cleanly shut down.
892 952
893 It closes our socket and shuts down 953 It closes our socket and shuts down
894 the debug client. (Needed on Win OS) 954 the debug client. (Needed on Win OS)
895 """ 955 """
896 if self.debuggerInterface is not None: 956 if self.debuggerInterface is not None:
897 self.debuggerInterface.shutdown() 957 self.debuggerInterface.shutdown()
898 958
899 def remoteEnvironment(self, env): 959 def remoteEnvironment(self, env):
900 """ 960 """
901 Public method to set the environment for a program to debug, run, ... 961 Public method to set the environment for a program to debug, run, ...
902 962
903 @param env environment settings 963 @param env environment settings
904 @type str 964 @type str
905 """ 965 """
906 envlist = shlex.split(env) 966 envlist = shlex.split(env)
907 envdict = {} 967 envdict = {}
908 for el in envlist: 968 for el in envlist:
909 if '=' in el: 969 if "=" in el:
910 key, value = el.split('=', 1) 970 key, value = el.split("=", 1)
911 envdict[key] = value 971 envdict[key] = value
912 else: 972 else:
913 envdict[el] = "" 973 envdict[el] = ""
914 self.debuggerInterface.remoteEnvironment(envdict) 974 self.debuggerInterface.remoteEnvironment(envdict)
915 975
916 def remoteLoad(self, venvName, fn, argv, wd, env, autoClearShell=True, 976 def remoteLoad(
917 tracePython=False, autoContinue=True, forProject=False, 977 self,
918 runInConsole=False, clientType="", enableCallTrace=False, 978 venvName,
919 enableMultiprocess=False, multiprocessNoDebug="", 979 fn,
920 configOverride=None): 980 argv,
981 wd,
982 env,
983 autoClearShell=True,
984 tracePython=False,
985 autoContinue=True,
986 forProject=False,
987 runInConsole=False,
988 clientType="",
989 enableCallTrace=False,
990 enableMultiprocess=False,
991 multiprocessNoDebug="",
992 configOverride=None,
993 ):
921 """ 994 """
922 Public method to load a new program to debug. 995 Public method to load a new program to debug.
923 996
924 @param venvName name of the virtual environment to be used 997 @param venvName name of the virtual environment to be used
925 @type str 998 @type str
926 @param fn the filename to debug 999 @param fn the filename to debug
927 @type str 1000 @type str
928 @param argv the command line arguments to pass to the program 1001 @param argv the command line arguments to pass to the program
962 """ 1035 """
963 self.__autoClearShell = autoClearShell 1036 self.__autoClearShell = autoClearShell
964 self.__multiprocessNoDebugList = [ 1037 self.__multiprocessNoDebugList = [
965 s.strip() for s in multiprocessNoDebug.split(os.pathsep) 1038 s.strip() for s in multiprocessNoDebug.split(os.pathsep)
966 ] 1039 ]
967 1040
968 if clientType not in self.getSupportedLanguages(): 1041 if clientType not in self.getSupportedLanguages():
969 # a not supported client language was requested 1042 # a not supported client language was requested
970 EricMessageBox.critical( 1043 EricMessageBox.critical(
971 None, 1044 None,
972 self.tr("Start Debugger"), 1045 self.tr("Start Debugger"),
973 self.tr( 1046 self.tr(
974 """<p>The debugger type <b>{0}</b> is not supported""" 1047 """<p>The debugger type <b>{0}</b> is not supported"""
975 """ or not configured.</p>""").format(clientType) 1048 """ or not configured.</p>"""
1049 ).format(clientType),
976 ) 1050 )
977 return 1051 return
978 1052
979 # Restart the client 1053 # Restart the client
980 try: 1054 try:
981 if clientType: 1055 if clientType:
982 self.__setClientType(clientType) 1056 self.__setClientType(clientType)
983 else: 1057 else:
984 self.__setClientType( 1058 self.__setClientType(
985 self.__findLanguageForExtension(os.path.splitext(fn)[1])) 1059 self.__findLanguageForExtension(os.path.splitext(fn)[1])
1060 )
986 except KeyError: 1061 except KeyError:
987 self.__setClientType('Python3') # assume it is a Python3 file 1062 self.__setClientType("Python3") # assume it is a Python3 file
988 self.startClient(False, forProject=forProject, 1063 self.startClient(
989 runInConsole=runInConsole, venvName=venvName, 1064 False,
990 configOverride=configOverride) 1065 forProject=forProject,
991 1066 runInConsole=runInConsole,
1067 venvName=venvName,
1068 configOverride=configOverride,
1069 )
1070
992 self.setCallTraceEnabled("", enableCallTrace) 1071 self.setCallTraceEnabled("", enableCallTrace)
993 self.remoteEnvironment(env) 1072 self.remoteEnvironment(env)
994 1073
995 self.debuggerInterface.remoteLoad( 1074 self.debuggerInterface.remoteLoad(
996 fn, argv, wd, tracePython, autoContinue, 1075 fn,
997 enableMultiprocess=enableMultiprocess 1076 argv,
1077 wd,
1078 tracePython,
1079 autoContinue,
1080 enableMultiprocess=enableMultiprocess,
998 ) 1081 )
999 self.debugging = True 1082 self.debugging = True
1000 self.running = True 1083 self.running = True
1001 self.__restoreBreakpoints() 1084 self.__restoreBreakpoints()
1002 self.__restoreWatchpoints() 1085 self.__restoreWatchpoints()
1003 self.__restoreNoDebugList() 1086 self.__restoreNoDebugList()
1004 1087
1005 def remoteRun(self, venvName, fn, argv, wd, env, autoClearShell=True, 1088 def remoteRun(
1006 forProject=False, runInConsole=False, clientType="", 1089 self,
1007 configOverride=None): 1090 venvName,
1091 fn,
1092 argv,
1093 wd,
1094 env,
1095 autoClearShell=True,
1096 forProject=False,
1097 runInConsole=False,
1098 clientType="",
1099 configOverride=None,
1100 ):
1008 """ 1101 """
1009 Public method to load a new program to run. 1102 Public method to load a new program to run.
1010 1103
1011 @param venvName name of the virtual environment to be used 1104 @param venvName name of the virtual environment to be used
1012 @type str 1105 @type str
1013 @param fn the filename to debug 1106 @param fn the filename to debug
1014 @type str 1107 @type str
1015 @param argv the command line arguments to pass to the program 1108 @param argv the command line arguments to pass to the program
1031 @param configOverride dictionary containing the global config override 1124 @param configOverride dictionary containing the global config override
1032 data 1125 data
1033 @type dict 1126 @type dict
1034 """ 1127 """
1035 self.__autoClearShell = autoClearShell 1128 self.__autoClearShell = autoClearShell
1036 1129
1037 if clientType not in self.getSupportedLanguages(): 1130 if clientType not in self.getSupportedLanguages():
1038 EricMessageBox.critical( 1131 EricMessageBox.critical(
1039 None, 1132 None,
1040 self.tr("Start Debugger"), 1133 self.tr("Start Debugger"),
1041 self.tr( 1134 self.tr(
1042 """<p>The debugger type <b>{0}</b> is not supported""" 1135 """<p>The debugger type <b>{0}</b> is not supported"""
1043 """ or not configured.</p>""").format(clientType) 1136 """ or not configured.</p>"""
1137 ).format(clientType),
1044 ) 1138 )
1045 # a not supported client language was requested 1139 # a not supported client language was requested
1046 return 1140 return
1047 1141
1048 # Restart the client 1142 # Restart the client
1049 try: 1143 try:
1050 if clientType: 1144 if clientType:
1051 self.__setClientType(clientType) 1145 self.__setClientType(clientType)
1052 else: 1146 else:
1053 self.__setClientType( 1147 self.__setClientType(
1054 self.__findLanguageForExtension(os.path.splitext(fn)[1])) 1148 self.__findLanguageForExtension(os.path.splitext(fn)[1])
1149 )
1055 except KeyError: 1150 except KeyError:
1056 self.__setClientType('Python3') # assume it is a Python3 file 1151 self.__setClientType("Python3") # assume it is a Python3 file
1057 self.startClient(False, forProject=forProject, 1152 self.startClient(
1058 runInConsole=runInConsole, venvName=venvName, 1153 False,
1059 configOverride=configOverride) 1154 forProject=forProject,
1060 1155 runInConsole=runInConsole,
1156 venvName=venvName,
1157 configOverride=configOverride,
1158 )
1159
1061 self.remoteEnvironment(env) 1160 self.remoteEnvironment(env)
1062 1161
1063 self.debuggerInterface.remoteRun(fn, argv, wd) 1162 self.debuggerInterface.remoteRun(fn, argv, wd)
1064 self.debugging = False 1163 self.debugging = False
1065 self.running = True 1164 self.running = True
1066 1165
1067 def remoteCoverage(self, venvName, fn, argv, wd, env, 1166 def remoteCoverage(
1068 autoClearShell=True, erase=False, forProject=False, 1167 self,
1069 runInConsole=False, clientType="", configOverride=None): 1168 venvName,
1169 fn,
1170 argv,
1171 wd,
1172 env,
1173 autoClearShell=True,
1174 erase=False,
1175 forProject=False,
1176 runInConsole=False,
1177 clientType="",
1178 configOverride=None,
1179 ):
1070 """ 1180 """
1071 Public method to load a new program to collect coverage data. 1181 Public method to load a new program to collect coverage data.
1072 1182
1073 @param venvName name of the virtual environment to be used 1183 @param venvName name of the virtual environment to be used
1074 @type str 1184 @type str
1075 @param fn the filename to debug 1185 @param fn the filename to debug
1076 @type str 1186 @type str
1077 @param argv the command line arguments to pass to the program 1187 @param argv the command line arguments to pass to the program
1096 @param configOverride dictionary containing the global config override 1206 @param configOverride dictionary containing the global config override
1097 data 1207 data
1098 @type dict 1208 @type dict
1099 """ 1209 """
1100 self.__autoClearShell = autoClearShell 1210 self.__autoClearShell = autoClearShell
1101 1211
1102 if clientType not in self.getSupportedLanguages(): 1212 if clientType not in self.getSupportedLanguages():
1103 # a not supported client language was requested 1213 # a not supported client language was requested
1104 EricMessageBox.critical( 1214 EricMessageBox.critical(
1105 None, 1215 None,
1106 self.tr("Start Debugger"), 1216 self.tr("Start Debugger"),
1107 self.tr( 1217 self.tr(
1108 """<p>The debugger type <b>{0}</b> is not supported""" 1218 """<p>The debugger type <b>{0}</b> is not supported"""
1109 """ or not configured.</p>""").format(clientType) 1219 """ or not configured.</p>"""
1220 ).format(clientType),
1110 ) 1221 )
1111 return 1222 return
1112 1223
1113 # Restart the client 1224 # Restart the client
1114 try: 1225 try:
1115 if clientType: 1226 if clientType:
1116 self.__setClientType(clientType) 1227 self.__setClientType(clientType)
1117 else: 1228 else:
1118 self.__setClientType( 1229 self.__setClientType(
1119 self.__findLanguageForExtension(os.path.splitext(fn)[1])) 1230 self.__findLanguageForExtension(os.path.splitext(fn)[1])
1231 )
1120 except KeyError: 1232 except KeyError:
1121 self.__setClientType('Python3') # assume it is a Python3 file 1233 self.__setClientType("Python3") # assume it is a Python3 file
1122 self.startClient(False, forProject=forProject, 1234 self.startClient(
1123 runInConsole=runInConsole, venvName=venvName, 1235 False,
1124 configOverride=configOverride) 1236 forProject=forProject,
1125 1237 runInConsole=runInConsole,
1238 venvName=venvName,
1239 configOverride=configOverride,
1240 )
1241
1126 self.remoteEnvironment(env) 1242 self.remoteEnvironment(env)
1127 1243
1128 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase) 1244 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase)
1129 self.debugging = False 1245 self.debugging = False
1130 self.running = True 1246 self.running = True
1131 1247
1132 def remoteProfile(self, venvName, fn, argv, wd, env, 1248 def remoteProfile(
1133 autoClearShell=True, erase=False, forProject=False, 1249 self,
1134 runInConsole=False, clientType="", configOverride=None): 1250 venvName,
1251 fn,
1252 argv,
1253 wd,
1254 env,
1255 autoClearShell=True,
1256 erase=False,
1257 forProject=False,
1258 runInConsole=False,
1259 clientType="",
1260 configOverride=None,
1261 ):
1135 """ 1262 """
1136 Public method to load a new program to collect profiling data. 1263 Public method to load a new program to collect profiling data.
1137 1264
1138 @param venvName name of the virtual environment to be used 1265 @param venvName name of the virtual environment to be used
1139 @type str 1266 @type str
1140 @param fn the filename to debug 1267 @param fn the filename to debug
1141 @type str 1268 @type str
1142 @param argv the command line arguments to pass to the program 1269 @param argv the command line arguments to pass to the program
1161 @param configOverride dictionary containing the global config override 1288 @param configOverride dictionary containing the global config override
1162 data 1289 data
1163 @type dict 1290 @type dict
1164 """ 1291 """
1165 self.__autoClearShell = autoClearShell 1292 self.__autoClearShell = autoClearShell
1166 1293
1167 if clientType not in self.getSupportedLanguages(): 1294 if clientType not in self.getSupportedLanguages():
1168 # a not supported client language was requested 1295 # a not supported client language was requested
1169 EricMessageBox.critical( 1296 EricMessageBox.critical(
1170 None, 1297 None,
1171 self.tr("Start Debugger"), 1298 self.tr("Start Debugger"),
1172 self.tr( 1299 self.tr(
1173 """<p>The debugger type <b>{0}</b> is not supported""" 1300 """<p>The debugger type <b>{0}</b> is not supported"""
1174 """ or not configured.</p>""").format(clientType) 1301 """ or not configured.</p>"""
1302 ).format(clientType),
1175 ) 1303 )
1176 return 1304 return
1177 1305
1178 # Restart the client 1306 # Restart the client
1179 try: 1307 try:
1180 if clientType: 1308 if clientType:
1181 self.__setClientType(clientType) 1309 self.__setClientType(clientType)
1182 else: 1310 else:
1183 self.__setClientType( 1311 self.__setClientType(
1184 self.__findLanguageForExtension(os.path.splitext(fn)[1])) 1312 self.__findLanguageForExtension(os.path.splitext(fn)[1])
1313 )
1185 except KeyError: 1314 except KeyError:
1186 self.__setClientType('Python3') # assume it is a Python3 file 1315 self.__setClientType("Python3") # assume it is a Python3 file
1187 self.startClient(False, forProject=forProject, 1316 self.startClient(
1188 runInConsole=runInConsole, venvName=venvName, 1317 False,
1189 configOverride=configOverride) 1318 forProject=forProject,
1190 1319 runInConsole=runInConsole,
1320 venvName=venvName,
1321 configOverride=configOverride,
1322 )
1323
1191 self.remoteEnvironment(env) 1324 self.remoteEnvironment(env)
1192 1325
1193 self.debuggerInterface.remoteProfile(fn, argv, wd, erase) 1326 self.debuggerInterface.remoteProfile(fn, argv, wd, erase)
1194 self.debugging = False 1327 self.debugging = False
1195 self.running = True 1328 self.running = True
1196 1329
1197 def remoteStatement(self, debuggerId, stmt): 1330 def remoteStatement(self, debuggerId, stmt):
1198 """ 1331 """
1199 Public method to execute a Python statement. 1332 Public method to execute a Python statement.
1200 1333
1201 @param debuggerId ID of the debugger backend 1334 @param debuggerId ID of the debugger backend
1202 @type str 1335 @type str
1203 @param stmt the Python statement to execute. 1336 @param stmt the Python statement to execute.
1204 @type str 1337 @type str
1205 """ 1338 """
1206 self.debuggerInterface.remoteStatement(debuggerId, stmt.rstrip()) 1339 self.debuggerInterface.remoteStatement(debuggerId, stmt.rstrip())
1207 1340
1208 def remoteStep(self, debuggerId): 1341 def remoteStep(self, debuggerId):
1209 """ 1342 """
1210 Public method to single step the debugged program. 1343 Public method to single step the debugged program.
1211 1344
1212 @param debuggerId ID of the debugger backend 1345 @param debuggerId ID of the debugger backend
1213 @type str 1346 @type str
1214 """ 1347 """
1215 self.debuggerInterface.remoteStep(debuggerId) 1348 self.debuggerInterface.remoteStep(debuggerId)
1216 1349
1217 def remoteStepOver(self, debuggerId): 1350 def remoteStepOver(self, debuggerId):
1218 """ 1351 """
1219 Public method to step over the debugged program. 1352 Public method to step over the debugged program.
1220 1353
1221 @param debuggerId ID of the debugger backend 1354 @param debuggerId ID of the debugger backend
1222 @type str 1355 @type str
1223 """ 1356 """
1224 self.debuggerInterface.remoteStepOver(debuggerId) 1357 self.debuggerInterface.remoteStepOver(debuggerId)
1225 1358
1226 def remoteStepOut(self, debuggerId): 1359 def remoteStepOut(self, debuggerId):
1227 """ 1360 """
1228 Public method to step out the debugged program. 1361 Public method to step out the debugged program.
1229 1362
1230 @param debuggerId ID of the debugger backend 1363 @param debuggerId ID of the debugger backend
1231 @type str 1364 @type str
1232 """ 1365 """
1233 self.debuggerInterface.remoteStepOut(debuggerId) 1366 self.debuggerInterface.remoteStepOut(debuggerId)
1234 1367
1235 def remoteStepQuit(self, debuggerId): 1368 def remoteStepQuit(self, debuggerId):
1236 """ 1369 """
1237 Public method to stop the debugged program. 1370 Public method to stop the debugged program.
1238 1371
1239 @param debuggerId ID of the debugger backend 1372 @param debuggerId ID of the debugger backend
1240 @type str 1373 @type str
1241 """ 1374 """
1242 self.debuggerInterface.remoteStepQuit(debuggerId) 1375 self.debuggerInterface.remoteStepQuit(debuggerId)
1243 1376
1244 def remoteContinue(self, debuggerId, special=False): 1377 def remoteContinue(self, debuggerId, special=False):
1245 """ 1378 """
1246 Public method to continue the debugged program. 1379 Public method to continue the debugged program.
1247 1380
1248 @param debuggerId ID of the debugger backend 1381 @param debuggerId ID of the debugger backend
1249 @type str 1382 @type str
1250 @param special flag indicating a special continue operation 1383 @param special flag indicating a special continue operation
1251 """ 1384 """
1252 self.debuggerInterface.remoteContinue(debuggerId, special) 1385 self.debuggerInterface.remoteContinue(debuggerId, special)
1253 1386
1254 def remoteContinueUntil(self, debuggerId, line): 1387 def remoteContinueUntil(self, debuggerId, line):
1255 """ 1388 """
1256 Public method to continue the debugged program to the given line 1389 Public method to continue the debugged program to the given line
1257 or until returning from the current frame. 1390 or until returning from the current frame.
1258 1391
1259 @param debuggerId ID of the debugger backend 1392 @param debuggerId ID of the debugger backend
1260 @type str 1393 @type str
1261 @param line the new line, where execution should be continued to 1394 @param line the new line, where execution should be continued to
1262 @type int 1395 @type int
1263 """ 1396 """
1264 self.debuggerInterface.remoteContinueUntil(debuggerId, line) 1397 self.debuggerInterface.remoteContinueUntil(debuggerId, line)
1265 1398
1266 def remoteMoveIP(self, debuggerId, line): 1399 def remoteMoveIP(self, debuggerId, line):
1267 """ 1400 """
1268 Public method to move the instruction pointer to a different line. 1401 Public method to move the instruction pointer to a different line.
1269 1402
1270 @param debuggerId ID of the debugger backend 1403 @param debuggerId ID of the debugger backend
1271 @type str 1404 @type str
1272 @param line the new line, where execution should be continued 1405 @param line the new line, where execution should be continued
1273 @type int 1406 @type int
1274 """ 1407 """
1275 self.debuggerInterface.remoteMoveIP(debuggerId, line) 1408 self.debuggerInterface.remoteMoveIP(debuggerId, line)
1276 1409
1277 def remoteBreakpoint(self, debuggerId, fn, line, setBreakpoint, cond=None, 1410 def remoteBreakpoint(
1278 temp=False): 1411 self, debuggerId, fn, line, setBreakpoint, cond=None, temp=False
1412 ):
1279 """ 1413 """
1280 Public method to set or clear a breakpoint. 1414 Public method to set or clear a breakpoint.
1281 1415
1282 @param debuggerId ID of the debugger backend 1416 @param debuggerId ID of the debugger backend
1283 @type str 1417 @type str
1284 @param fn filename the breakpoint belongs to 1418 @param fn filename the breakpoint belongs to
1285 @type str 1419 @type str
1286 @param line linenumber of the breakpoint 1420 @param line linenumber of the breakpoint
1291 @type str 1425 @type str
1292 @param temp flag indicating a temporary breakpoint 1426 @param temp flag indicating a temporary breakpoint
1293 @type bool 1427 @type bool
1294 """ 1428 """
1295 self.debuggerInterface.remoteBreakpoint( 1429 self.debuggerInterface.remoteBreakpoint(
1296 debuggerId, fn, line, setBreakpoint, cond, temp) 1430 debuggerId, fn, line, setBreakpoint, cond, temp
1297 1431 )
1432
1298 def __remoteBreakpointEnable(self, debuggerId, fn, line, enable): 1433 def __remoteBreakpointEnable(self, debuggerId, fn, line, enable):
1299 """ 1434 """
1300 Private method to enable or disable a breakpoint. 1435 Private method to enable or disable a breakpoint.
1301 1436
1302 @param debuggerId ID of the debugger backend 1437 @param debuggerId ID of the debugger backend
1303 @type str 1438 @type str
1304 @param fn filename the breakpoint belongs to 1439 @param fn filename the breakpoint belongs to
1305 @type str 1440 @type str
1306 @param line linenumber of the breakpoint 1441 @param line linenumber of the breakpoint
1307 @type int 1442 @type int
1308 @param enable flag indicating enabling or disabling a breakpoint 1443 @param enable flag indicating enabling or disabling a breakpoint
1309 @type bool 1444 @type bool
1310 """ 1445 """
1311 self.debuggerInterface.remoteBreakpointEnable( 1446 self.debuggerInterface.remoteBreakpointEnable(debuggerId, fn, line, enable)
1312 debuggerId, fn, line, enable) 1447
1313
1314 def __remoteBreakpointIgnore(self, debuggerId, fn, line, count): 1448 def __remoteBreakpointIgnore(self, debuggerId, fn, line, count):
1315 """ 1449 """
1316 Private method to ignore a breakpoint the next couple of occurrences. 1450 Private method to ignore a breakpoint the next couple of occurrences.
1317 1451
1318 @param debuggerId ID of the debugger backend 1452 @param debuggerId ID of the debugger backend
1319 @type str 1453 @type str
1320 @param fn filename the breakpoint belongs to 1454 @param fn filename the breakpoint belongs to
1321 @type str 1455 @type str
1322 @param line linenumber of the breakpoint 1456 @param line linenumber of the breakpoint
1323 @type int 1457 @type int
1324 @param count number of occurrences to ignore 1458 @param count number of occurrences to ignore
1325 @type int 1459 @type int
1326 """ 1460 """
1327 self.debuggerInterface.remoteBreakpointIgnore( 1461 self.debuggerInterface.remoteBreakpointIgnore(debuggerId, fn, line, count)
1328 debuggerId, fn, line, count) 1462
1329
1330 def __remoteWatchpoint(self, debuggerId, cond, setWatch, temp=False): 1463 def __remoteWatchpoint(self, debuggerId, cond, setWatch, temp=False):
1331 """ 1464 """
1332 Private method to set or clear a watch expression. 1465 Private method to set or clear a watch expression.
1333 1466
1334 @param debuggerId ID of the debugger backend 1467 @param debuggerId ID of the debugger backend
1335 @type str 1468 @type str
1336 @param cond expression of the watch expression 1469 @param cond expression of the watch expression
1337 @type str 1470 @type str
1338 @param setWatch flag indicating setting or resetting a watch expression 1471 @param setWatch flag indicating setting or resetting a watch expression
1339 @type bool 1472 @type bool
1340 @param temp flag indicating a temporary watch expression 1473 @param temp flag indicating a temporary watch expression
1341 @type bool 1474 @type bool
1342 """ 1475 """
1343 # cond is combination of cond and special (s. watch expression viewer) 1476 # cond is combination of cond and special (s. watch expression viewer)
1344 self.debuggerInterface.remoteWatchpoint(debuggerId, cond, setWatch, 1477 self.debuggerInterface.remoteWatchpoint(debuggerId, cond, setWatch, temp)
1345 temp) 1478
1346
1347 def __remoteWatchpointEnable(self, debuggerId, cond, enable): 1479 def __remoteWatchpointEnable(self, debuggerId, cond, enable):
1348 """ 1480 """
1349 Private method to enable or disable a watch expression. 1481 Private method to enable or disable a watch expression.
1350 1482
1351 @param debuggerId ID of the debugger backend 1483 @param debuggerId ID of the debugger backend
1352 @type str 1484 @type str
1353 @param cond expression of the watch expression 1485 @param cond expression of the watch expression
1354 @type str 1486 @type str
1355 @param enable flag indicating enabling or disabling a watch expression 1487 @param enable flag indicating enabling or disabling a watch expression
1356 @type bool 1488 @type bool
1357 """ 1489 """
1358 # cond is combination of cond and special (s. watch expression viewer) 1490 # cond is combination of cond and special (s. watch expression viewer)
1359 self.debuggerInterface.remoteWatchpointEnable(debuggerId, cond, enable) 1491 self.debuggerInterface.remoteWatchpointEnable(debuggerId, cond, enable)
1360 1492
1361 def __remoteWatchpointIgnore(self, debuggerId, cond, count): 1493 def __remoteWatchpointIgnore(self, debuggerId, cond, count):
1362 """ 1494 """
1363 Private method to ignore a watch expression the next couple of 1495 Private method to ignore a watch expression the next couple of
1364 occurrences. 1496 occurrences.
1365 1497
1366 @param debuggerId ID of the debugger backend 1498 @param debuggerId ID of the debugger backend
1367 @type str 1499 @type str
1368 @param cond expression of the watch expression 1500 @param cond expression of the watch expression
1369 @type str 1501 @type str
1370 @param count number of occurrences to ignore 1502 @param count number of occurrences to ignore
1371 @type int 1503 @type int
1372 """ 1504 """
1373 # cond is combination of cond and special (s. watch expression viewer) 1505 # cond is combination of cond and special (s. watch expression viewer)
1374 self.debuggerInterface.remoteWatchpointIgnore(debuggerId, cond, count) 1506 self.debuggerInterface.remoteWatchpointIgnore(debuggerId, cond, count)
1375 1507
1376 def remoteRawInput(self, debuggerId, inputString): 1508 def remoteRawInput(self, debuggerId, inputString):
1377 """ 1509 """
1378 Public method to send the raw input to the debugged program. 1510 Public method to send the raw input to the debugged program.
1379 1511
1380 @param debuggerId ID of the debugger backend 1512 @param debuggerId ID of the debugger backend
1381 @type str 1513 @type str
1382 @param inputString the raw input 1514 @param inputString the raw input
1383 @type str 1515 @type str
1384 """ 1516 """
1385 self.debuggerInterface.remoteRawInput(debuggerId, inputString) 1517 self.debuggerInterface.remoteRawInput(debuggerId, inputString)
1386 self.clientRawInputSent.emit(debuggerId) 1518 self.clientRawInputSent.emit(debuggerId)
1387 1519
1388 def remoteThreadList(self, debuggerId): 1520 def remoteThreadList(self, debuggerId):
1389 """ 1521 """
1390 Public method to request the list of threads from the client. 1522 Public method to request the list of threads from the client.
1391 1523
1392 @param debuggerId ID of the debugger backend 1524 @param debuggerId ID of the debugger backend
1393 @type str 1525 @type str
1394 """ 1526 """
1395 self.debuggerInterface.remoteThreadList(debuggerId) 1527 self.debuggerInterface.remoteThreadList(debuggerId)
1396 1528
1397 def remoteSetThread(self, debuggerId, tid): 1529 def remoteSetThread(self, debuggerId, tid):
1398 """ 1530 """
1399 Public method to request to set the given thread as current thread. 1531 Public method to request to set the given thread as current thread.
1400 1532
1401 @param debuggerId ID of the debugger backend 1533 @param debuggerId ID of the debugger backend
1402 @type str 1534 @type str
1403 @param tid id of the thread 1535 @param tid id of the thread
1404 @type int 1536 @type int
1405 """ 1537 """
1406 self.debuggerInterface.remoteSetThread(debuggerId, tid) 1538 self.debuggerInterface.remoteSetThread(debuggerId, tid)
1407 1539
1408 def remoteClientStack(self, debuggerId): 1540 def remoteClientStack(self, debuggerId):
1409 """ 1541 """
1410 Public method to request the stack of the main thread. 1542 Public method to request the stack of the main thread.
1411 1543
1412 @param debuggerId ID of the debugger backend 1544 @param debuggerId ID of the debugger backend
1413 @type str 1545 @type str
1414 """ 1546 """
1415 self.debuggerInterface.remoteClientStack(debuggerId) 1547 self.debuggerInterface.remoteClientStack(debuggerId)
1416 1548
1417 def remoteClientVariables(self, debuggerId, scope, filterList, framenr=0): 1549 def remoteClientVariables(self, debuggerId, scope, filterList, framenr=0):
1418 """ 1550 """
1419 Public method to request the variables of the debugged program. 1551 Public method to request the variables of the debugged program.
1420 1552
1421 @param debuggerId ID of the debugger backend 1553 @param debuggerId ID of the debugger backend
1422 @type str 1554 @type str
1423 @param scope the scope of the variables (0 = local, 1 = global) 1555 @param scope the scope of the variables (0 = local, 1 = global)
1424 @type int 1556 @type int
1425 @param filterList list of variable types to filter out 1557 @param filterList list of variable types to filter out
1426 @type list of str 1558 @type list of str
1427 @param framenr framenumber of the variables to retrieve 1559 @param framenr framenumber of the variables to retrieve
1428 @type int 1560 @type int
1429 """ 1561 """
1430 self.debuggerInterface.remoteClientVariables( 1562 self.debuggerInterface.remoteClientVariables(
1431 debuggerId, scope, filterList, framenr, self.__maxVariableSize) 1563 debuggerId, scope, filterList, framenr, self.__maxVariableSize
1432 1564 )
1433 def remoteClientVariable(self, debuggerId, scope, filterList, var, 1565
1434 framenr=0, maxSize=0): 1566 def remoteClientVariable(
1567 self, debuggerId, scope, filterList, var, framenr=0, maxSize=0
1568 ):
1435 """ 1569 """
1436 Public method to request the variables of the debugged program. 1570 Public method to request the variables of the debugged program.
1437 1571
1438 @param debuggerId ID of the debugger backend 1572 @param debuggerId ID of the debugger backend
1439 @type str 1573 @type str
1440 @param scope the scope of the variables (0 = local, 1 = global) 1574 @param scope the scope of the variables (0 = local, 1 = global)
1441 @type int 1575 @type int
1442 @param filterList list of variable types to filter out 1576 @param filterList list of variable types to filter out
1449 be shown. If it is bigger than that, a 'too big' indication will 1583 be shown. If it is bigger than that, a 'too big' indication will
1450 be given (@@TOO_BIG_TO_SHOW@@). 1584 be given (@@TOO_BIG_TO_SHOW@@).
1451 @type int 1585 @type int
1452 """ 1586 """
1453 self.debuggerInterface.remoteClientVariable( 1587 self.debuggerInterface.remoteClientVariable(
1454 debuggerId, scope, filterList, var, framenr, 1588 debuggerId, scope, filterList, var, framenr, self.__maxVariableSize
1455 self.__maxVariableSize) 1589 )
1456 1590
1457 def remoteClientDisassembly(self, debuggerId): 1591 def remoteClientDisassembly(self, debuggerId):
1458 """ 1592 """
1459 Public method to ask the client for the latest traceback disassembly. 1593 Public method to ask the client for the latest traceback disassembly.
1460 1594
1461 @param debuggerId ID of the debugger backend 1595 @param debuggerId ID of the debugger backend
1462 @type str 1596 @type str
1463 """ 1597 """
1464 with contextlib.suppress(AttributeError): 1598 with contextlib.suppress(AttributeError):
1465 self.debuggerInterface.remoteClientDisassembly(debuggerId) 1599 self.debuggerInterface.remoteClientDisassembly(debuggerId)
1466 1600
1467 def remoteClientSetFilter(self, debuggerId, scope, filterStr): 1601 def remoteClientSetFilter(self, debuggerId, scope, filterStr):
1468 """ 1602 """
1469 Public method to set a variables filter list. 1603 Public method to set a variables filter list.
1470 1604
1471 @param debuggerId ID of the debugger backend 1605 @param debuggerId ID of the debugger backend
1472 @type str 1606 @type str
1473 @param scope the scope of the variables (0 = local, 1 = global) 1607 @param scope the scope of the variables (0 = local, 1 = global)
1474 @type int 1608 @type int
1475 @param filterStr regexp string for variable names to filter out 1609 @param filterStr regexp string for variable names to filter out
1476 @type str 1610 @type str
1477 """ 1611 """
1478 self.debuggerInterface.remoteClientSetFilter( 1612 self.debuggerInterface.remoteClientSetFilter(debuggerId, scope, filterStr)
1479 debuggerId, scope, filterStr) 1613
1480
1481 def setCallTraceEnabled(self, debuggerId, on): 1614 def setCallTraceEnabled(self, debuggerId, on):
1482 """ 1615 """
1483 Public method to set the call trace state. 1616 Public method to set the call trace state.
1484 1617
1485 @param debuggerId ID of the debugger backend 1618 @param debuggerId ID of the debugger backend
1486 @type str 1619 @type str
1487 @param on flag indicating to enable the call trace function 1620 @param on flag indicating to enable the call trace function
1488 @type bool 1621 @type bool
1489 """ 1622 """
1490 self.debuggerInterface.setCallTraceEnabled(debuggerId, on) 1623 self.debuggerInterface.setCallTraceEnabled(debuggerId, on)
1491 1624
1492 def remoteBanner(self): 1625 def remoteBanner(self):
1493 """ 1626 """
1494 Public slot to get the banner info of the remote client. 1627 Public slot to get the banner info of the remote client.
1495 """ 1628 """
1496 self.debuggerInterface.remoteBanner() 1629 self.debuggerInterface.remoteBanner()
1497 1630
1498 def remoteCapabilities(self): 1631 def remoteCapabilities(self):
1499 """ 1632 """
1500 Public slot to get the debug clients capabilities. 1633 Public slot to get the debug clients capabilities.
1501 """ 1634 """
1502 self.debuggerInterface.remoteCapabilities() 1635 self.debuggerInterface.remoteCapabilities()
1503 1636
1504 def remoteCompletion(self, debuggerId, text): 1637 def remoteCompletion(self, debuggerId, text):
1505 """ 1638 """
1506 Public slot to get the a list of possible commandline completions 1639 Public slot to get the a list of possible commandline completions
1507 from the remote client. 1640 from the remote client.
1508 1641
1509 @param debuggerId ID of the debugger backend 1642 @param debuggerId ID of the debugger backend
1510 @type str 1643 @type str
1511 @param text the text to be completed 1644 @param text the text to be completed
1512 @type str 1645 @type str
1513 """ 1646 """
1514 self.debuggerInterface.remoteCompletion(debuggerId, text) 1647 self.debuggerInterface.remoteCompletion(debuggerId, text)
1515 1648
1516 def signalClientOutput(self, line, debuggerId): 1649 def signalClientOutput(self, line, debuggerId):
1517 """ 1650 """
1518 Public method to process a line of client output. 1651 Public method to process a line of client output.
1519 1652
1520 @param line client output 1653 @param line client output
1521 @type str 1654 @type str
1522 @param debuggerId ID of the debugger backend 1655 @param debuggerId ID of the debugger backend
1523 @type str 1656 @type str
1524 """ 1657 """
1525 if debuggerId: 1658 if debuggerId:
1526 self.clientOutput.emit("{0}: {1}".format(debuggerId, line)) 1659 self.clientOutput.emit("{0}: {1}".format(debuggerId, line))
1527 else: 1660 else:
1528 self.clientOutput.emit(line) 1661 self.clientOutput.emit(line)
1529 1662
1530 def signalClientLine(self, filename, lineno, debuggerId, forStack=False, 1663 def signalClientLine(
1531 threadName=""): 1664 self, filename, lineno, debuggerId, forStack=False, threadName=""
1665 ):
1532 """ 1666 """
1533 Public method to process client position feedback. 1667 Public method to process client position feedback.
1534 1668
1535 @param filename name of the file currently being executed 1669 @param filename name of the file currently being executed
1536 @type str 1670 @type str
1537 @param lineno line of code currently being executed 1671 @param lineno line of code currently being executed
1538 @type int 1672 @type int
1539 @param debuggerId ID of the debugger backend 1673 @param debuggerId ID of the debugger backend
1541 @param forStack flag indicating this is for a stack dump 1675 @param forStack flag indicating this is for a stack dump
1542 @type bool 1676 @type bool
1543 @param threadName name of the thread signaling the event 1677 @param threadName name of the thread signaling the event
1544 @type str 1678 @type str
1545 """ 1679 """
1546 self.clientLine.emit(filename, lineno, debuggerId, threadName, 1680 self.clientLine.emit(filename, lineno, debuggerId, threadName, forStack)
1547 forStack) 1681
1548
1549 def signalClientStack(self, stack, debuggerId, threadName=""): 1682 def signalClientStack(self, stack, debuggerId, threadName=""):
1550 """ 1683 """
1551 Public method to process a client's stack information. 1684 Public method to process a client's stack information.
1552 1685
1553 @param stack list of stack entries. Each entry is a tuple of three 1686 @param stack list of stack entries. Each entry is a tuple of three
1554 values giving the filename, linenumber and method 1687 values giving the filename, linenumber and method
1555 @type list of lists of (string, integer, string) 1688 @type list of lists of (string, integer, string)
1556 @param debuggerId ID of the debugger backend 1689 @param debuggerId ID of the debugger backend
1557 @type str 1690 @type str
1558 @param threadName name of the thread signaling the event 1691 @param threadName name of the thread signaling the event
1559 @type str 1692 @type str
1560 """ 1693 """
1561 self.clientStack.emit(stack, debuggerId, threadName) 1694 self.clientStack.emit(stack, debuggerId, threadName)
1562 1695
1563 def signalClientThreadList(self, currentId, threadList, debuggerId): 1696 def signalClientThreadList(self, currentId, threadList, debuggerId):
1564 """ 1697 """
1565 Public method to process the client thread list info. 1698 Public method to process the client thread list info.
1566 1699
1567 @param currentId id of the current thread 1700 @param currentId id of the current thread
1568 @type int 1701 @type int
1569 @param threadList list of dictionaries containing the thread data 1702 @param threadList list of dictionaries containing the thread data
1570 @type list of dict 1703 @type list of dict
1571 @param debuggerId ID of the debugger backend 1704 @param debuggerId ID of the debugger backend
1572 @type str 1705 @type str
1573 """ 1706 """
1574 self.clientThreadList.emit(currentId, threadList, debuggerId) 1707 self.clientThreadList.emit(currentId, threadList, debuggerId)
1575 1708
1576 def signalClientThreadSet(self, debuggerId): 1709 def signalClientThreadSet(self, debuggerId):
1577 """ 1710 """
1578 Public method to handle the change of the client thread. 1711 Public method to handle the change of the client thread.
1579 1712
1580 @param debuggerId ID of the debugger backend 1713 @param debuggerId ID of the debugger backend
1581 @type str 1714 @type str
1582 """ 1715 """
1583 self.clientThreadSet.emit(debuggerId) 1716 self.clientThreadSet.emit(debuggerId)
1584 1717
1585 def signalClientVariables(self, scope, variables, debuggerId): 1718 def signalClientVariables(self, scope, variables, debuggerId):
1586 """ 1719 """
1587 Public method to process the client variables info. 1720 Public method to process the client variables info.
1588 1721
1589 @param scope scope of the variables 1722 @param scope scope of the variables
1590 (-2 = no frame found, -1 = empty locals, 1 = global, 0 = local) 1723 (-2 = no frame found, -1 = empty locals, 1 = global, 0 = local)
1591 @type int 1724 @type int
1592 @param variables the list of variables from the client 1725 @param variables the list of variables from the client
1593 @type list 1726 @type list
1594 @param debuggerId ID of the debugger backend 1727 @param debuggerId ID of the debugger backend
1595 @type str 1728 @type str
1596 """ 1729 """
1597 self.clientVariables.emit(scope, variables, debuggerId) 1730 self.clientVariables.emit(scope, variables, debuggerId)
1598 1731
1599 def signalClientVariable(self, scope, variables, debuggerId): 1732 def signalClientVariable(self, scope, variables, debuggerId):
1600 """ 1733 """
1601 Public method to process the client variable info. 1734 Public method to process the client variable info.
1602 1735
1603 @param scope scope of the variables (-1 = empty global, 1 = global, 1736 @param scope scope of the variables (-1 = empty global, 1 = global,
1604 0 = local) 1737 0 = local)
1605 @type int 1738 @type int
1606 @param variables the list of members of a classvariable from the client 1739 @param variables the list of members of a classvariable from the client
1607 @type list 1740 @type list
1608 @param debuggerId ID of the debugger backend 1741 @param debuggerId ID of the debugger backend
1609 @type str 1742 @type str
1610 """ 1743 """
1611 self.clientVariable.emit(scope, variables, debuggerId) 1744 self.clientVariable.emit(scope, variables, debuggerId)
1612 1745
1613 def signalClientStatement(self, more, debuggerId): 1746 def signalClientStatement(self, more, debuggerId):
1614 """ 1747 """
1615 Public method to process the input response from the client. 1748 Public method to process the input response from the client.
1616 1749
1617 @param more flag indicating that more user input is required 1750 @param more flag indicating that more user input is required
1618 @type bool 1751 @type bool
1619 @param debuggerId ID of the debugger backend 1752 @param debuggerId ID of the debugger backend
1620 @type str 1753 @type str
1621 """ 1754 """
1622 self.clientStatement.emit(more, debuggerId) 1755 self.clientStatement.emit(more, debuggerId)
1623 1756
1624 def signalClientDisassembly(self, disassembly, debuggerId): 1757 def signalClientDisassembly(self, disassembly, debuggerId):
1625 """ 1758 """
1626 Public method to process the disassembly info from the client. 1759 Public method to process the disassembly info from the client.
1627 1760
1628 @param disassembly dictionary containing the disassembly information 1761 @param disassembly dictionary containing the disassembly information
1629 @type dict 1762 @type dict
1630 @param debuggerId ID of the debugger backend 1763 @param debuggerId ID of the debugger backend
1631 @type str 1764 @type str
1632 """ 1765 """
1633 if self.running: 1766 if self.running:
1634 self.clientDisassembly.emit(disassembly, debuggerId) 1767 self.clientDisassembly.emit(disassembly, debuggerId)
1635 1768
1636 def signalClientException(self, exceptionType, exceptionMessage, 1769 def signalClientException(
1637 stackTrace, debuggerId, threadName=""): 1770 self, exceptionType, exceptionMessage, stackTrace, debuggerId, threadName=""
1771 ):
1638 """ 1772 """
1639 Public method to process the exception info from the client. 1773 Public method to process the exception info from the client.
1640 1774
1641 @param exceptionType type of exception raised 1775 @param exceptionType type of exception raised
1642 @type str 1776 @type str
1643 @param exceptionMessage message given by the exception 1777 @param exceptionMessage message given by the exception
1644 @type str 1778 @type str
1645 @param stackTrace list of stack entries with the exception position 1779 @param stackTrace list of stack entries with the exception position
1650 @type str 1784 @type str
1651 @param threadName name of the thread signaling the event 1785 @param threadName name of the thread signaling the event
1652 @type str 1786 @type str
1653 """ 1787 """
1654 if self.running: 1788 if self.running:
1655 self.clientException.emit(exceptionType, exceptionMessage, 1789 self.clientException.emit(
1656 stackTrace, debuggerId, threadName) 1790 exceptionType, exceptionMessage, stackTrace, debuggerId, threadName
1657 1791 )
1658 def signalClientSyntaxError(self, message, filename, lineNo, characterNo, 1792
1659 debuggerId, threadName=""): 1793 def signalClientSyntaxError(
1794 self, message, filename, lineNo, characterNo, debuggerId, threadName=""
1795 ):
1660 """ 1796 """
1661 Public method to process a syntax error info from the client. 1797 Public method to process a syntax error info from the client.
1662 1798
1663 @param message message of the syntax error 1799 @param message message of the syntax error
1664 @type str 1800 @type str
1665 @param filename translated filename of the syntax error position 1801 @param filename translated filename of the syntax error position
1666 @type str 1802 @type str
1667 @param lineNo line number of the syntax error position 1803 @param lineNo line number of the syntax error position
1672 @type str 1808 @type str
1673 @param threadName name of the thread signaling the event 1809 @param threadName name of the thread signaling the event
1674 @type str 1810 @type str
1675 """ 1811 """
1676 if self.running: 1812 if self.running:
1677 self.clientSyntaxError.emit(message, filename, lineNo, characterNo, 1813 self.clientSyntaxError.emit(
1678 debuggerId, threadName) 1814 message, filename, lineNo, characterNo, debuggerId, threadName
1679 1815 )
1680 def signalClientSignal(self, message, filename, lineNo, 1816
1681 funcName, funcArgs, debuggerId): 1817 def signalClientSignal(
1818 self, message, filename, lineNo, funcName, funcArgs, debuggerId
1819 ):
1682 """ 1820 """
1683 Public method to process a signal generated on the client side. 1821 Public method to process a signal generated on the client side.
1684 1822
1685 @param message message of the syntax error 1823 @param message message of the syntax error
1686 @type str 1824 @type str
1687 @param filename translated filename of the syntax error position 1825 @param filename translated filename of the syntax error position
1688 @type str 1826 @type str
1689 @param lineNo line number of the syntax error position 1827 @param lineNo line number of the syntax error position
1694 @type str 1832 @type str
1695 @param debuggerId ID of the debugger backend 1833 @param debuggerId ID of the debugger backend
1696 @type str 1834 @type str
1697 """ 1835 """
1698 if self.running: 1836 if self.running:
1699 self.clientSignal.emit(message, filename, lineNo, 1837 self.clientSignal.emit(
1700 funcName, funcArgs, debuggerId) 1838 message, filename, lineNo, funcName, funcArgs, debuggerId
1701 1839 )
1840
1702 def signalClientDisconnected(self, debuggerId): 1841 def signalClientDisconnected(self, debuggerId):
1703 """ 1842 """
1704 Public method to send a signal when a debug client has closed its 1843 Public method to send a signal when a debug client has closed its
1705 connection. 1844 connection.
1706 1845
1707 @param debuggerId ID of the debugger backend 1846 @param debuggerId ID of the debugger backend
1708 @type str 1847 @type str
1709 """ 1848 """
1710 self.clientDisconnected.emit(debuggerId) 1849 self.clientDisconnected.emit(debuggerId)
1711 1850
1712 def signalClientExit(self, program, status, message, debuggerId): 1851 def signalClientExit(self, program, status, message, debuggerId):
1713 """ 1852 """
1714 Public method to process the client exit status. 1853 Public method to process the client exit status.
1715 1854
1716 @param program name of the exited program 1855 @param program name of the exited program
1717 @type str 1856 @type str
1718 @param status exit code 1857 @param status exit code
1719 @type int 1858 @type int
1720 @param message message sent with the exit 1859 @param message message sent with the exit
1721 @type str 1860 @type str
1722 @param debuggerId ID of the debugger backend 1861 @param debuggerId ID of the debugger backend
1723 @type str 1862 @type str
1724 """ 1863 """
1725 self.clientExit.emit(program, int(status), message, False, debuggerId) 1864 self.clientExit.emit(program, int(status), message, False, debuggerId)
1726 1865
1727 def signalMainClientExit(self): 1866 def signalMainClientExit(self):
1728 """ 1867 """
1729 Public method to process the main client exiting. 1868 Public method to process the main client exiting.
1730 """ 1869 """
1731 self.mainClientExit.emit() 1870 self.mainClientExit.emit()
1732 1871
1733 def signalLastClientExited(self): 1872 def signalLastClientExited(self):
1734 """ 1873 """
1735 Public method to process the last client exit event. 1874 Public method to process the last client exit event.
1736 """ 1875 """
1737 if self.passive: 1876 if self.passive:
1738 self.__passiveShutDown() 1877 self.__passiveShutDown()
1739 self.lastClientExited.emit() 1878 self.lastClientExited.emit()
1740 if Preferences.getDebugger("AutomaticReset") or (self.running and 1879 if Preferences.getDebugger("AutomaticReset") or (
1741 not self.debugging): 1880 self.running and not self.debugging
1881 ):
1742 self.debugging = False 1882 self.debugging = False
1743 self.startClient(False, forProject=self.__forProject) 1883 self.startClient(False, forProject=self.__forProject)
1744 if self.passive: 1884 if self.passive:
1745 self.__createDebuggerInterface("None") 1885 self.__createDebuggerInterface("None")
1746 self.signalClientOutput(self.tr('\nNot connected\n')) 1886 self.signalClientOutput(self.tr("\nNot connected\n"))
1747 self.signalClientStatement(False, "") 1887 self.signalClientStatement(False, "")
1748 self.running = False 1888 self.running = False
1749 1889
1750 def signalClientClearBreak(self, filename, lineno, debuggerId): 1890 def signalClientClearBreak(self, filename, lineno, debuggerId):
1751 """ 1891 """
1752 Public method to process the client clear breakpoint command. 1892 Public method to process the client clear breakpoint command.
1753 1893
1754 @param filename filename of the breakpoint 1894 @param filename filename of the breakpoint
1755 @type str 1895 @type str
1756 @param lineno line umber of the breakpoint 1896 @param lineno line umber of the breakpoint
1757 @type int 1897 @type int
1758 @param debuggerId ID of the debugger backend 1898 @param debuggerId ID of the debugger backend
1759 @type str 1899 @type str
1760 """ 1900 """
1761 self.clientClearBreak.emit(filename, lineno, debuggerId) 1901 self.clientClearBreak.emit(filename, lineno, debuggerId)
1762 1902
1763 def signalClientBreakConditionError(self, filename, lineno, debuggerId): 1903 def signalClientBreakConditionError(self, filename, lineno, debuggerId):
1764 """ 1904 """
1765 Public method to process the client breakpoint condition error info. 1905 Public method to process the client breakpoint condition error info.
1766 1906
1767 @param filename filename of the breakpoint 1907 @param filename filename of the breakpoint
1768 @type str 1908 @type str
1769 @param lineno line umber of the breakpoint 1909 @param lineno line umber of the breakpoint
1770 @type int 1910 @type int
1771 @param debuggerId ID of the debugger backend 1911 @param debuggerId ID of the debugger backend
1772 @type str 1912 @type str
1773 """ 1913 """
1774 if (filename, lineno) not in self.__reportedBreakpointIssues: 1914 if (filename, lineno) not in self.__reportedBreakpointIssues:
1775 self.__reportedBreakpointIssues.append((filename, lineno)) 1915 self.__reportedBreakpointIssues.append((filename, lineno))
1776 self.clientBreakConditionError.emit(filename, lineno, debuggerId) 1916 self.clientBreakConditionError.emit(filename, lineno, debuggerId)
1777 1917
1778 def signalClientClearWatch(self, condition, debuggerId): 1918 def signalClientClearWatch(self, condition, debuggerId):
1779 """ 1919 """
1780 Public slot to handle the clientClearWatch signal. 1920 Public slot to handle the clientClearWatch signal.
1781 1921
1782 @param condition expression of watch expression to clear 1922 @param condition expression of watch expression to clear
1783 @type str 1923 @type str
1784 @param debuggerId ID of the debugger backend 1924 @param debuggerId ID of the debugger backend
1785 @type str 1925 @type str
1786 """ 1926 """
1787 self.clientClearWatch.emit(condition, debuggerId) 1927 self.clientClearWatch.emit(condition, debuggerId)
1788 1928
1789 def signalClientWatchConditionError(self, condition, debuggerId): 1929 def signalClientWatchConditionError(self, condition, debuggerId):
1790 """ 1930 """
1791 Public method to process the client watch expression error info. 1931 Public method to process the client watch expression error info.
1792 1932
1793 @param condition expression of watch expression to clear 1933 @param condition expression of watch expression to clear
1794 @type str 1934 @type str
1795 @param debuggerId ID of the debugger backend 1935 @param debuggerId ID of the debugger backend
1796 @type str 1936 @type str
1797 """ 1937 """
1798 if condition not in self.__reportedWatchpointIssues: 1938 if condition not in self.__reportedWatchpointIssues:
1799 self.__reportedWatchpointIssues.append(condition) 1939 self.__reportedWatchpointIssues.append(condition)
1800 self.clientWatchConditionError.emit(condition, debuggerId) 1940 self.clientWatchConditionError.emit(condition, debuggerId)
1801 1941
1802 def signalClientRawInput(self, prompt, echo, debuggerId): 1942 def signalClientRawInput(self, prompt, echo, debuggerId):
1803 """ 1943 """
1804 Public method to process the client raw input command. 1944 Public method to process the client raw input command.
1805 1945
1806 @param prompt the input prompt 1946 @param prompt the input prompt
1807 @type str 1947 @type str
1808 @param echo flag indicating an echoing of the input 1948 @param echo flag indicating an echoing of the input
1809 @type bool 1949 @type bool
1810 @param debuggerId ID of the debugger backend 1950 @param debuggerId ID of the debugger backend
1811 @type str 1951 @type str
1812 """ 1952 """
1813 self.clientRawInput.emit(prompt, echo, debuggerId) 1953 self.clientRawInput.emit(prompt, echo, debuggerId)
1814 1954
1815 def signalClientBanner(self, version, platform, venvName): 1955 def signalClientBanner(self, version, platform, venvName):
1816 """ 1956 """
1817 Public method to process the client banner info. 1957 Public method to process the client banner info.
1818 1958
1819 @param version interpreter version info 1959 @param version interpreter version info
1820 @type str 1960 @type str
1821 @param platform hostname of the client 1961 @param platform hostname of the client
1822 @type str 1962 @type str
1823 @param venvName name of the virtual environment 1963 @param venvName name of the virtual environment
1824 @type str 1964 @type str
1825 """ 1965 """
1826 self.clientBanner.emit(version, platform, venvName) 1966 self.clientBanner.emit(version, platform, venvName)
1827 1967
1828 def signalClientCapabilities(self, capabilities, clientType, venvName): 1968 def signalClientCapabilities(self, capabilities, clientType, venvName):
1829 """ 1969 """
1830 Public method to process the client capabilities info. 1970 Public method to process the client capabilities info.
1831 1971
1832 @param capabilities bitmaks with the client capabilities 1972 @param capabilities bitmaks with the client capabilities
1833 @type int 1973 @type int
1834 @param clientType type of the debug client 1974 @param clientType type of the debug client
1835 @type str 1975 @type str
1836 @param venvName name of the virtual environment 1976 @param venvName name of the virtual environment
1837 @type str 1977 @type str
1838 """ 1978 """
1839 with contextlib.suppress(KeyError): 1979 with contextlib.suppress(KeyError):
1840 self.__debuggerInterfaceRegistry[clientType][0] = capabilities 1980 self.__debuggerInterfaceRegistry[clientType][0] = capabilities
1841 self.clientCapabilities.emit(capabilities, clientType, venvName) 1981 self.clientCapabilities.emit(capabilities, clientType, venvName)
1842 1982
1843 def signalClientCompletionList(self, completionList, text, debuggerId): 1983 def signalClientCompletionList(self, completionList, text, debuggerId):
1844 """ 1984 """
1845 Public method to process the client auto completion info. 1985 Public method to process the client auto completion info.
1846 1986
1847 @param completionList list of possible completions 1987 @param completionList list of possible completions
1848 @type list of str 1988 @type list of str
1849 @param text the text to be completed 1989 @param text the text to be completed
1850 @type str 1990 @type str
1851 @param debuggerId ID of the debugger backend 1991 @param debuggerId ID of the debugger backend
1852 @type str 1992 @type str
1853 """ 1993 """
1854 self.clientCompletionList.emit(completionList, text) 1994 self.clientCompletionList.emit(completionList, text)
1855 1995
1856 def signalClientCallTrace(self, isCall, fromFile, fromLine, fromFunction, 1996 def signalClientCallTrace(
1857 toFile, toLine, toFunction, debuggerId): 1997 self,
1998 isCall,
1999 fromFile,
2000 fromLine,
2001 fromFunction,
2002 toFile,
2003 toLine,
2004 toFunction,
2005 debuggerId,
2006 ):
1858 """ 2007 """
1859 Public method to process the client call trace data. 2008 Public method to process the client call trace data.
1860 2009
1861 @param isCall flag indicating a 'call' 2010 @param isCall flag indicating a 'call'
1862 @type bool 2011 @type bool
1863 @param fromFile name of the originating file 2012 @param fromFile name of the originating file
1864 @type str 2013 @type str
1865 @param fromLine line number in the originating file 2014 @param fromLine line number in the originating file
1874 @type str 2023 @type str
1875 @param debuggerId ID of the debugger backend 2024 @param debuggerId ID of the debugger backend
1876 @type str 2025 @type str
1877 """ 2026 """
1878 self.callTraceInfo.emit( 2027 self.callTraceInfo.emit(
1879 isCall, fromFile, fromLine, fromFunction, 2028 isCall,
1880 toFile, toLine, toFunction, debuggerId) 2029 fromFile,
1881 2030 fromLine,
2031 fromFunction,
2032 toFile,
2033 toLine,
2034 toFunction,
2035 debuggerId,
2036 )
2037
1882 def passiveStartUp(self, fn, exc, debuggerId): 2038 def passiveStartUp(self, fn, exc, debuggerId):
1883 """ 2039 """
1884 Public method to handle a passive debug connection. 2040 Public method to handle a passive debug connection.
1885 2041
1886 @param fn filename of the debugged script 2042 @param fn filename of the debugged script
1887 @type str 2043 @type str
1888 @param exc flag to enable exception reporting of the IDE 2044 @param exc flag to enable exception reporting of the IDE
1889 @type bool 2045 @type bool
1890 @param debuggerId ID of the debugger backend 2046 @param debuggerId ID of the debugger backend
1895 self.debugging = True 2051 self.debugging = True
1896 self.running = True 2052 self.running = True
1897 self.__restoreBreakpoints(debuggerId) 2053 self.__restoreBreakpoints(debuggerId)
1898 self.__restoreWatchpoints(debuggerId) 2054 self.__restoreWatchpoints(debuggerId)
1899 self.passiveDebugStarted.emit(fn, exc) 2055 self.passiveDebugStarted.emit(fn, exc)
1900 2056
1901 def __passiveShutDown(self): 2057 def __passiveShutDown(self):
1902 """ 2058 """
1903 Private method to shut down a passive debug connection. 2059 Private method to shut down a passive debug connection.
1904 """ 2060 """
1905 self.passiveClientExited = True 2061 self.passiveClientExited = True
1906 self.shutdownServer() 2062 self.shutdownServer()
1907 self.appendStdout.emit(self.tr("Passive debug connection closed\n")) 2063 self.appendStdout.emit(self.tr("Passive debug connection closed\n"))
1908 2064
1909 def __restoreBreakpoints(self, debuggerId=""): 2065 def __restoreBreakpoints(self, debuggerId=""):
1910 """ 2066 """
1911 Private method to restore the breakpoints after a restart. 2067 Private method to restore the breakpoints after a restart.
1912 2068
1913 @param debuggerId ID of the debugger backend to send to. If this is 2069 @param debuggerId ID of the debugger backend to send to. If this is
1914 empty, they will be broadcast to all connected backends. 2070 empty, they will be broadcast to all connected backends.
1915 @type str 2071 @type str
1916 """ 2072 """
1917 if self.debugging: 2073 if self.debugging:
1918 self.__addBreakPoints( 2074 self.__addBreakPoints(
1919 QModelIndex(), 0, self.breakpointModel.rowCount() - 1, 2075 QModelIndex(), 0, self.breakpointModel.rowCount() - 1, debuggerId
1920 debuggerId) 2076 )
1921 2077
1922 def __restoreWatchpoints(self, debuggerId=""): 2078 def __restoreWatchpoints(self, debuggerId=""):
1923 """ 2079 """
1924 Private method to restore the watch expressions after a restart. 2080 Private method to restore the watch expressions after a restart.
1925 2081
1926 @param debuggerId ID of the debugger backend to send to. If this is 2082 @param debuggerId ID of the debugger backend to send to. If this is
1927 empty, they will be broadcast to all connected backends. 2083 empty, they will be broadcast to all connected backends.
1928 @type str 2084 @type str
1929 """ 2085 """
1930 if self.debugging: 2086 if self.debugging:
1931 self.__addWatchPoints( 2087 self.__addWatchPoints(
1932 QModelIndex(), 0, self.watchpointModel.rowCount() - 1, 2088 QModelIndex(), 0, self.watchpointModel.rowCount() - 1, debuggerId
1933 debuggerId) 2089 )
1934 2090
1935 def getBreakPointModel(self): 2091 def getBreakPointModel(self):
1936 """ 2092 """
1937 Public slot to get a reference to the breakpoint model object. 2093 Public slot to get a reference to the breakpoint model object.
1938 2094
1939 @return reference to the breakpoint model object 2095 @return reference to the breakpoint model object
1940 @rtype BreakPointModel 2096 @rtype BreakPointModel
1941 """ 2097 """
1942 return self.breakpointModel 2098 return self.breakpointModel
1943 2099
1944 def getWatchPointModel(self): 2100 def getWatchPointModel(self):
1945 """ 2101 """
1946 Public slot to get a reference to the watch expression model object. 2102 Public slot to get a reference to the watch expression model object.
1947 2103
1948 @return reference to the watch expression model object 2104 @return reference to the watch expression model object
1949 @rtype WatchPointModel 2105 @rtype WatchPointModel
1950 """ 2106 """
1951 return self.watchpointModel 2107 return self.watchpointModel
1952 2108
1953 def isConnected(self): 2109 def isConnected(self):
1954 """ 2110 """
1955 Public method to test, if the debug server is connected to a backend. 2111 Public method to test, if the debug server is connected to a backend.
1956 2112
1957 @return flag indicating a connection 2113 @return flag indicating a connection
1958 @rtype bool 2114 @rtype bool
1959 """ 2115 """
1960 return self.debuggerInterface and self.debuggerInterface.isConnected() 2116 return self.debuggerInterface and self.debuggerInterface.isConnected()
1961 2117
1962 def isDebugging(self): 2118 def isDebugging(self):
1963 """ 2119 """
1964 Public method to test, if the debug server is debugging. 2120 Public method to test, if the debug server is debugging.
1965 2121
1966 @return flag indicating the debugging state 2122 @return flag indicating the debugging state
1967 @rtype bool 2123 @rtype bool
1968 """ 2124 """
1969 return self.debugging 2125 return self.debugging
1970 2126
1971 def setDebugging(self, on): 2127 def setDebugging(self, on):
1972 """ 2128 """
1973 Public method to set the debugging state. 2129 Public method to set the debugging state.
1974 2130
1975 @param on flag indicating the new debugging state 2131 @param on flag indicating the new debugging state
1976 @type bool 2132 @type bool
1977 """ 2133 """
1978 self.debugging = on 2134 self.debugging = on
1979 2135
1980 def signalClientDebuggerId(self, debuggerId): 2136 def signalClientDebuggerId(self, debuggerId):
1981 """ 2137 """
1982 Public method to signal the receipt of a new debugger ID. 2138 Public method to signal the receipt of a new debugger ID.
1983 2139
1984 This signal indicates, that a new debugger backend has connected. 2140 This signal indicates, that a new debugger backend has connected.
1985 2141
1986 @param debuggerId ID of the newly connected debugger backend 2142 @param debuggerId ID of the newly connected debugger backend
1987 @type str 2143 @type str
1988 """ 2144 """
1989 self.clientDebuggerId.emit(debuggerId) 2145 self.clientDebuggerId.emit(debuggerId)
1990 2146
1991 def getDebuggerIds(self): 2147 def getDebuggerIds(self):
1992 """ 2148 """
1993 Public method to return the IDs of the connected debugger backends. 2149 Public method to return the IDs of the connected debugger backends.
1994 2150
1995 @return list of connected debugger backend IDs 2151 @return list of connected debugger backend IDs
1996 @rtype list of str 2152 @rtype list of str
1997 """ 2153 """
1998 if self.debuggerInterface: 2154 if self.debuggerInterface:
1999 return self.debuggerInterface.getDebuggerIds() 2155 return self.debuggerInterface.getDebuggerIds()
2000 else: 2156 else:
2001 return [] 2157 return []
2002 2158
2003 def initializeClient(self, debuggerId): 2159 def initializeClient(self, debuggerId):
2004 """ 2160 """
2005 Public method to initialize a freshly connected debug client. 2161 Public method to initialize a freshly connected debug client.
2006 2162
2007 @param debuggerId ID of the connected debugger 2163 @param debuggerId ID of the connected debugger
2008 @type str 2164 @type str
2009 """ 2165 """
2010 self.__restoreBreakpoints(debuggerId) 2166 self.__restoreBreakpoints(debuggerId)
2011 self.__restoreWatchpoints(debuggerId) 2167 self.__restoreWatchpoints(debuggerId)
2012 self.__restoreNoDebugList(debuggerId) 2168 self.__restoreNoDebugList(debuggerId)
2013 2169
2014 def __restoreNoDebugList(self, debuggerId=""): 2170 def __restoreNoDebugList(self, debuggerId=""):
2015 """ 2171 """
2016 Private method to restore the list of scripts not to be debugged after 2172 Private method to restore the list of scripts not to be debugged after
2017 a restart. 2173 a restart.
2018 2174
2019 @param debuggerId ID of the debugger backend to send to. If this is 2175 @param debuggerId ID of the debugger backend to send to. If this is
2020 empty, they will be broadcast to all connected backends. 2176 empty, they will be broadcast to all connected backends.
2021 @type str 2177 @type str
2022 """ 2178 """
2023 if self.debugging: 2179 if self.debugging:
2024 self.debuggerInterface.remoteNoDebugList( 2180 self.debuggerInterface.remoteNoDebugList(
2025 debuggerId, self.__multiprocessNoDebugList) 2181 debuggerId, self.__multiprocessNoDebugList
2182 )

eric ide

mercurial