Debugger/DebugServer.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2573
71837b5366d5
parent 2988
f53c03574697
child 3058
0a02c433f52d
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
14 pass 14 pass
15 15
16 import os 16 import os
17 17
18 from PyQt4.QtCore import pyqtSignal, QModelIndex 18 from PyQt4.QtCore import pyqtSignal, QModelIndex
19 from PyQt4.QtNetwork import QTcpServer, QHostAddress, QHostInfo, QNetworkInterface 19 from PyQt4.QtNetwork import QTcpServer, QHostAddress, QHostInfo, \
20 QNetworkInterface
20 21
21 from E5Gui.E5Application import e5App 22 from E5Gui.E5Application import e5App
22 from E5Gui import E5MessageBox 23 from E5Gui import E5MessageBox
23 24
24 from .BreakPointModel import BreakPointModel 25 from .BreakPointModel import BreakPointModel
39 40
40 class DebugServer(QTcpServer): 41 class DebugServer(QTcpServer):
41 """ 42 """
42 Class implementing the debug server embedded within the IDE. 43 Class implementing the debug server embedded within the IDE.
43 44
44 @signal clientProcessStdout(str) emitted after the client has sent some output 45 @signal clientProcessStdout(str) emitted after the client has sent some
45 via stdout 46 output via stdout
46 @signal clientProcessStderr(str) emitted after the client has sent some output 47 @signal clientProcessStderr(str) emitted after the client has sent some
47 via stderr 48 output via stderr
48 @signal clientOutput(str) emitted after the client has sent some output 49 @signal clientOutput(str) emitted after the client has sent some output
49 @signal clientRawInputSent() emitted after the data was sent to the debug client 50 @signal clientRawInputSent() emitted after the data was sent to the
50 @signal clientLine(filename, lineno, forStack) emitted after the debug client 51 debug client
51 has executed a line of code 52 @signal clientLine(filename, lineno, forStack) emitted after the
53 debug client has executed a line of code
52 @signal clientStack(stack) emitted after the debug client has executed a 54 @signal clientStack(stack) emitted after the debug client has executed a
53 line of code 55 line of code
54 @signal clientThreadList(currentId, threadList) emitted after a thread list 56 @signal clientThreadList(currentId, threadList) emitted after a thread list
55 has been received 57 has been received
56 @signal clientThreadSet() emitted after the client has acknowledged the change 58 @signal clientThreadSet() emitted after the client has acknowledged the
57 of the current thread 59 change of the current thread
58 @signal clientVariables(scope, variables) emitted after a variables dump has 60 @signal clientVariables(scope, variables) emitted after a variables dump
59 been received 61 has been received
60 @signal clientVariable(scope, variables) emitted after a dump for one class 62 @signal clientVariable(scope, variables) emitted after a dump for one class
61 variable has been received 63 variable has been received
62 @signal clientStatement(bool) emitted after an interactive command has 64 @signal clientStatement(bool) emitted after an interactive command has
63 been executed. The parameter is 0 to indicate that the command is 65 been executed. The parameter is 0 to indicate that the command is
64 complete and 1 if it needs more input. 66 complete and 1 if it needs more input.
65 @signal clientException(exception) emitted after an exception occured on the 67 @signal clientException(exception) emitted after an exception occured on
66 client side 68 the client side
67 @signal clientSyntaxError(exception) emitted after a syntax error has been detected 69 @signal clientSyntaxError(exception) emitted after a syntax error has been
68 on the client side 70 detected on the client side
69 @signal clientExit(int) emitted with the exit status after the client has exited 71 @signal clientExit(int) emitted with the exit status after the client has
72 exited
70 @signal clientClearBreak(filename, lineno) emitted after the debug client 73 @signal clientClearBreak(filename, lineno) emitted after the debug client
71 has decided to clear a temporary breakpoint 74 has decided to clear a temporary breakpoint
72 @signal clientBreakConditionError(fn, lineno) emitted after the client has signaled 75 @signal clientBreakConditionError(fn, lineno) emitted after the client has
73 a syntax error in a breakpoint condition 76 signaled a syntax error in a breakpoint condition
74 @signal clientClearWatch(condition) emitted after the debug client 77 @signal clientClearWatch(condition) emitted after the debug client
75 has decided to clear a temporary watch expression 78 has decided to clear a temporary watch expression
76 @signal clientWatchConditionError(condition) emitted after the client has signaled 79 @signal clientWatchConditionError(condition) emitted after the client has
77 a syntax error in a watch expression 80 signaled a syntax error in a watch expression
78 @signal clientRawInput(prompt, echo) emitted after a raw input request was received 81 @signal clientRawInput(prompt, echo) emitted after a raw input request was
82 received
79 @signal clientBanner(banner) emitted after the client banner was received 83 @signal clientBanner(banner) emitted after the client banner was received
80 @signal clientCapabilities(int capabilities, string cltype) emitted after the clients 84 @signal clientCapabilities(int capabilities, string cltype) emitted after
81 capabilities were received 85 the clients capabilities were received
82 @signal clientCompletionList(completionList, text) emitted after the client 86 @signal clientCompletionList(completionList, text) emitted after the client
83 the commandline completion list and the reworked searchstring was 87 the commandline completion list and the reworked searchstring was
84 received from the client 88 received from the client
85 @signal passiveDebugStarted(str, bool) emitted after the debug client has connected in 89 @signal passiveDebugStarted(str, bool) emitted after the debug client has
86 passive debug mode 90 connected in passive debug mode
87 @signal clientGone(bool) emitted if the client went away (planned or unplanned) 91 @signal clientGone(bool) emitted if the client went away (planned or
88 @signal utPrepared(nrTests, exc_type, exc_value) emitted after the client has 92 unplanned)
89 loaded a unittest suite 93 @signal utPrepared(nrTests, exc_type, exc_value) emitted after the client
90 @signal utFinished() emitted after the client signalled the end of the unittest 94 has loaded a unittest suite
91 @signal utStartTest(testname, testdocu) emitted after the client has started 95 @signal utFinished() emitted after the client signalled the end of the
92 a test 96 unittest
97 @signal utStartTest(testname, testdocu) emitted after the client has
98 started a test
93 @signal utStopTest() emitted after the client has finished a test 99 @signal utStopTest() emitted after the client has finished a test
94 @signal utTestFailed(testname, exc_info, id) emitted after the client reported 100 @signal utTestFailed(testname, exc_info, id) emitted after the client
95 a failed test 101 reported a failed test
96 @signal utTestErrored(testname, exc_info, id) emitted after the client reported 102 @signal utTestErrored(testname, exc_info, id) emitted after the client
97 an errored test 103 reported an errored test
98 @signal utTestSkipped(testname, reason, id) emitted after the client reported 104 @signal utTestSkipped(testname, reason, id) emitted after the client
99 a skipped test 105 reported a skipped test
100 @signal utTestFailedExpected(testname, exc_info, id) emitted after the client reported 106 @signal utTestFailedExpected(testname, exc_info, id) emitted after the
101 an expected test failure 107 client reported an expected test failure
102 @signal utTestSucceededUnexpected(testname, id) emitted after the client reported 108 @signal utTestSucceededUnexpected(testname, id) emitted after the client
103 an unexpected test success 109 reported an unexpected test success
104 @signal callTraceInfo(isCall, fromFile, fromLine, fromFunction, toFile, toLine, toFunction) 110 @signal callTraceInfo(isCall, fromFile, fromLine, fromFunction, toFile,
105 emitted after the client reported the call trace data 111 toLine, toFunction) emitted after the client reported the call trace
112 data
106 """ 113 """
107 clientClearBreak = pyqtSignal(str, int) 114 clientClearBreak = pyqtSignal(str, int)
108 clientClearWatch = pyqtSignal(str) 115 clientClearWatch = pyqtSignal(str)
109 clientGone = pyqtSignal(bool) 116 clientGone = pyqtSignal(bool)
110 clientProcessStdout = pyqtSignal(str) 117 clientProcessStdout = pyqtSignal(str)
198 205
199 self.clientClearBreak.connect(self.__clientClearBreakPoint) 206 self.clientClearBreak.connect(self.__clientClearBreakPoint)
200 self.clientClearWatch.connect(self.__clientClearWatchPoint) 207 self.clientClearWatch.connect(self.__clientClearWatchPoint)
201 self.newConnection[()].connect(self.__newConnection) 208 self.newConnection[()].connect(self.__newConnection)
202 209
203 self.breakpointModel.rowsAboutToBeRemoved.connect(self.__deleteBreakPoints) 210 self.breakpointModel.rowsAboutToBeRemoved.connect(
211 self.__deleteBreakPoints)
204 self.breakpointModel.dataAboutToBeChanged.connect( 212 self.breakpointModel.dataAboutToBeChanged.connect(
205 self.__breakPointDataAboutToBeChanged) 213 self.__breakPointDataAboutToBeChanged)
206 self.breakpointModel.dataChanged.connect(self.__changeBreakPoints) 214 self.breakpointModel.dataChanged.connect(self.__changeBreakPoints)
207 self.breakpointModel.rowsInserted.connect(self.__addBreakPoints) 215 self.breakpointModel.rowsInserted.connect(self.__addBreakPoints)
208 216
209 self.watchpointModel.rowsAboutToBeRemoved.connect(self.__deleteWatchPoints) 217 self.watchpointModel.rowsAboutToBeRemoved.connect(
218 self.__deleteWatchPoints)
210 self.watchpointModel.dataAboutToBeChanged.connect( 219 self.watchpointModel.dataAboutToBeChanged.connect(
211 self.__watchPointDataAboutToBeChanged) 220 self.__watchPointDataAboutToBeChanged)
212 self.watchpointModel.dataChanged.connect(self.__changeWatchPoints) 221 self.watchpointModel.dataChanged.connect(self.__changeWatchPoints)
213 self.watchpointModel.rowsInserted.connect(self.__addWatchPoints) 222 self.watchpointModel.rowsInserted.connect(self.__addWatchPoints)
214 223
215 self.__registerDebuggerInterfaces() 224 self.__registerDebuggerInterfaces()
216 225
217 def getHostAddress(self, localhost): 226 def getHostAddress(self, localhost):
218 """ 227 """
219 Public method to get the IP address or hostname the debug server is listening. 228 Public method to get the IP address or hostname the debug server is
220 229 listening.
221 @param localhost flag indicating to return the address for localhost (boolean) 230
231 @param localhost flag indicating to return the address for localhost
232 (boolean)
222 @return IP address or hostname (string) 233 @return IP address or hostname (string)
223 """ 234 """
224 if self.networkInterface == "all": 235 if self.networkInterface == "all":
225 if localhost: 236 if localhost:
226 return "127.0.0.1" 237 return "127.0.0.1"
235 return "{0}@@i{1}".format(self.networkInterface, 246 return "{0}@@i{1}".format(self.networkInterface,
236 self.networkInterfaceIndex) 247 self.networkInterfaceIndex)
237 248
238 def __getNetworkInterfaceAndIndex(self, address): 249 def __getNetworkInterfaceAndIndex(self, address):
239 """ 250 """
240 Private method to determine the network interface and the interface index. 251 Private method to determine the network interface and the interface
252 index.
241 253
242 @param address address to determine the info for (string) 254 @param address address to determine the info for (string)
243 @return tuple of network interface name (string) and index (integer) 255 @return tuple of network interface name (string) and index (integer)
244 """ 256 """
245 if address not in ["all", "allv6"]: 257 if address not in ["all", "allv6"]:
246 for networkInterface in QNetworkInterface.allInterfaces(): 258 for networkInterface in QNetworkInterface.allInterfaces():
247 addressEntries = networkInterface.addressEntries() 259 addressEntries = networkInterface.addressEntries()
248 if len(addressEntries) > 0: 260 if len(addressEntries) > 0:
249 for addressEntry in addressEntries: 261 for addressEntry in addressEntries:
250 if addressEntry.ip().toString().lower() == address.lower(): 262 if addressEntry.ip().toString().lower() == \
263 address.lower():
251 return networkInterface.humanReadableName(), \ 264 return networkInterface.humanReadableName(), \
252 networkInterface.index() 265 networkInterface.index()
253 266
254 return "", 0 267 return "", 0
255 268
296 pass # it is not in the list 309 pass # it is not in the list
297 310
298 if shellOnly: 311 if shellOnly:
299 languages = \ 312 languages = \
300 [lang for lang in languages \ 313 [lang for lang in languages \
301 if self.__clientCapabilities[lang] & DebugClientCapabilities.HasShell] 314 if self.__clientCapabilities[lang] &
315 DebugClientCapabilities.HasShell]
302 316
303 return languages[:] 317 return languages[:]
304 318
305 def getExtensions(self, language): 319 def getExtensions(self, language):
306 """ 320 """
307 Public slot to get the extensions associated with the given language. 321 Public slot to get the extensions associated with the given language.
308 322
309 @param language language to get extensions for (string) 323 @param language language to get extensions for (string)
310 @return tuple of extensions associated with the language (tuple of strings) 324 @return tuple of extensions associated with the language
325 (tuple of strings)
311 """ 326 """
312 extensions = [] 327 extensions = []
313 for ext, lang in list(self.__clientAssociations.items()): 328 for ext, lang in list(self.__clientAssociations.items()):
314 if lang == language: 329 if lang == language:
315 extensions.append(ext) 330 extensions.append(ext)
325 if self.lastClientType != self.clientType or clientType is not None: 340 if self.lastClientType != self.clientType or clientType is not None:
326 if clientType is None: 341 if clientType is None:
327 clientType = self.clientType 342 clientType = self.clientType
328 if clientType == "Python2": 343 if clientType == "Python2":
329 from .DebuggerInterfacePython import DebuggerInterfacePython 344 from .DebuggerInterfacePython import DebuggerInterfacePython
330 self.debuggerInterface = DebuggerInterfacePython(self, self.passive) 345 self.debuggerInterface = DebuggerInterfacePython(
346 self, self.passive)
331 elif clientType == "Python3": 347 elif clientType == "Python3":
332 from .DebuggerInterfacePython3 import DebuggerInterfacePython3 348 from .DebuggerInterfacePython3 import DebuggerInterfacePython3
333 self.debuggerInterface = DebuggerInterfacePython3(self, self.passive) 349 self.debuggerInterface = DebuggerInterfacePython3(
350 self, self.passive)
334 elif clientType == "Ruby": 351 elif clientType == "Ruby":
335 from .DebuggerInterfaceRuby import DebuggerInterfaceRuby 352 from .DebuggerInterfaceRuby import DebuggerInterfaceRuby
336 self.debuggerInterface = DebuggerInterfaceRuby(self, self.passive) 353 self.debuggerInterface = DebuggerInterfaceRuby(
354 self, self.passive)
337 elif clientType == "None": 355 elif clientType == "None":
338 from .DebuggerInterfaceNone import DebuggerInterfaceNone 356 from .DebuggerInterfaceNone import DebuggerInterfaceNone
339 self.debuggerInterface = DebuggerInterfaceNone(self, self.passive) 357 self.debuggerInterface = DebuggerInterfaceNone(
358 self, self.passive)
340 else: 359 else:
341 from .DebuggerInterfaceNone import DebuggerInterfaceNone 360 from .DebuggerInterfaceNone import DebuggerInterfaceNone
342 self.debuggerInterface = DebuggerInterfaceNone(self, self.passive) 361 self.debuggerInterface = DebuggerInterfaceNone(
362 self, self.passive)
343 self.clientType = "None" 363 self.clientType = "None"
344 364
345 def __setClientType(self, clType): 365 def __setClientType(self, clType):
346 """ 366 """
347 Private method to set the client type. 367 Private method to set the client type.
389 self.clientProcess, isNetworked = \ 409 self.clientProcess, isNetworked = \
390 self.debuggerInterface.startRemote(self.serverPort(), 410 self.debuggerInterface.startRemote(self.serverPort(),
391 runInConsole) 411 runInConsole)
392 else: 412 else:
393 self.clientProcess, isNetworked = \ 413 self.clientProcess, isNetworked = \
394 self.debuggerInterface.startRemoteForProject(self.serverPort(), 414 self.debuggerInterface.startRemoteForProject(
395 runInConsole) 415 self.serverPort(), runInConsole)
396 else: 416 else:
397 self.clientProcess, isNetworked = \ 417 self.clientProcess, isNetworked = \
398 self.debuggerInterface.startRemote(self.serverPort(), runInConsole) 418 self.debuggerInterface.startRemote(
419 self.serverPort(), runInConsole)
399 420
400 if self.clientProcess: 421 if self.clientProcess:
401 self.clientProcess.readyReadStandardError.connect( 422 self.clientProcess.readyReadStandardError.connect(
402 self.__clientProcessError) 423 self.__clientProcessError)
403 self.clientProcess.readyReadStandardOutput.connect( 424 self.clientProcess.readyReadStandardOutput.connect(
455 @param end end row (integer) 476 @param end end row (integer)
456 """ 477 """
457 if self.debugging: 478 if self.debugging:
458 for row in range(start, end + 1): 479 for row in range(start, end + 1):
459 index = self.breakpointModel.index(row, 0, parentIndex) 480 index = self.breakpointModel.index(row, 0, parentIndex)
460 fn, lineno = self.breakpointModel.getBreakPointByIndex(index)[0:2] 481 fn, lineno = \
482 self.breakpointModel.getBreakPointByIndex(index)[0:2]
461 self.remoteBreakpoint(fn, lineno, False) 483 self.remoteBreakpoint(fn, lineno, False)
462 484
463 def __changeBreakPoints(self, startIndex, endIndex): 485 def __changeBreakPoints(self, startIndex, endIndex):
464 """ 486 """
465 Private slot to set changed breakpoints. 487 Private slot to set changed breakpoints.
466 488
467 @param indexes indexes of changed breakpoints. 489 @param startIndex starting index of the change breakpoins (QModelIndex)
490 @param endIndex ending index of the change breakpoins (QModelIndex)
468 """ 491 """
469 if self.debugging: 492 if self.debugging:
470 self.__addBreakPoints(QModelIndex(), startIndex.row(), endIndex.row()) 493 self.__addBreakPoints(
494 QModelIndex(), startIndex.row(), endIndex.row())
471 495
472 def __breakPointDataAboutToBeChanged(self, startIndex, endIndex): 496 def __breakPointDataAboutToBeChanged(self, startIndex, endIndex):
473 """ 497 """
474 Private slot to handle the dataAboutToBeChanged signal of the breakpoint model. 498 Private slot to handle the dataAboutToBeChanged signal of the
499 breakpoint model.
475 500
476 @param startIndex start index of the rows to be changed (QModelIndex) 501 @param startIndex start index of the rows to be changed (QModelIndex)
477 @param endIndex end index of the rows to be changed (QModelIndex) 502 @param endIndex end index of the rows to be changed (QModelIndex)
478 """ 503 """
479 if self.debugging: 504 if self.debugging:
480 self.__deleteBreakPoints(QModelIndex(), startIndex.row(), endIndex.row()) 505 self.__deleteBreakPoints(
506 QModelIndex(), startIndex.row(), endIndex.row())
481 507
482 def __addBreakPoints(self, parentIndex, start, end): 508 def __addBreakPoints(self, parentIndex, start, end):
483 """ 509 """
484 Private slot to add breakpoints. 510 Private slot to add breakpoints.
485 511
518 def __splitWatchCondition(self, cond): 544 def __splitWatchCondition(self, cond):
519 """ 545 """
520 Private method to split a remote watch expression. 546 Private method to split a remote watch expression.
521 547
522 @param cond remote expression (string) 548 @param cond remote expression (string)
523 @return tuple of local expression (string) and special condition (string) 549 @return tuple of local expression (string) and special condition
550 (string)
524 """ 551 """
525 if cond.endswith(" ??created??"): 552 if cond.endswith(" ??created??"):
526 cond, special = cond.split() 553 cond, special = cond.split()
527 special = self.watchSpecialCreated 554 special = self.watchSpecialCreated
528 elif cond.endswith(" ??changed??"): 555 elif cond.endswith(" ??changed??"):
554 @param end end row (integer) 581 @param end end row (integer)
555 """ 582 """
556 if self.debugging: 583 if self.debugging:
557 for row in range(start, end + 1): 584 for row in range(start, end + 1):
558 index = self.watchpointModel.index(row, 0, parentIndex) 585 index = self.watchpointModel.index(row, 0, parentIndex)
559 cond, special = self.watchpointModel.getWatchPointByIndex(index)[0:2] 586 cond, special = \
587 self.watchpointModel.getWatchPointByIndex(index)[0:2]
560 cond = self.__makeWatchCondition(cond, special) 588 cond = self.__makeWatchCondition(cond, special)
561 self.__remoteWatchpoint(cond, False) 589 self.__remoteWatchpoint(cond, False)
562 590
563 def __watchPointDataAboutToBeChanged(self, startIndex, endIndex): 591 def __watchPointDataAboutToBeChanged(self, startIndex, endIndex):
564 """ 592 """
567 595
568 @param startIndex start index of the rows to be changed (QModelIndex) 596 @param startIndex start index of the rows to be changed (QModelIndex)
569 @param endIndex end index of the rows to be changed (QModelIndex) 597 @param endIndex end index of the rows to be changed (QModelIndex)
570 """ 598 """
571 if self.debugging: 599 if self.debugging:
572 self.__deleteWatchPoints(QModelIndex(), startIndex.row(), endIndex.row()) 600 self.__deleteWatchPoints(
601 QModelIndex(), startIndex.row(), endIndex.row())
573 602
574 def __addWatchPoints(self, parentIndex, start, end): 603 def __addWatchPoints(self, parentIndex, start, end):
575 """ 604 """
576 Private slot to set a watch expression. 605 Private slot to set a watch expression.
577 606
597 626
598 @param startIndex start index of the rows to be changed (QModelIndex) 627 @param startIndex start index of the rows to be changed (QModelIndex)
599 @param endIndex end index of the rows to be changed (QModelIndex) 628 @param endIndex end index of the rows to be changed (QModelIndex)
600 """ 629 """
601 if self.debugging: 630 if self.debugging:
602 self.__addWatchPoints(QModelIndex(), startIndex.row(), endIndex.row()) 631 self.__addWatchPoints(
632 QModelIndex(), startIndex.row(), endIndex.row())
603 633
604 def getClientCapabilities(self, type): 634 def getClientCapabilities(self, type):
605 """ 635 """
606 Public method to retrieve the debug clients capabilities. 636 Public method to retrieve the debug clients capabilities.
607 637
621 peerAddress = sock.peerAddress().toString() 651 peerAddress = sock.peerAddress().toString()
622 if peerAddress not in Preferences.getDebugger("AllowedHosts"): 652 if peerAddress not in Preferences.getDebugger("AllowedHosts"):
623 # the peer is not allowed to connect 653 # the peer is not allowed to connect
624 res = E5MessageBox.yesNo(None, 654 res = E5MessageBox.yesNo(None,
625 self.trUtf8("Connection from illegal host"), 655 self.trUtf8("Connection from illegal host"),
626 self.trUtf8("""<p>A connection was attempted by the""" 656 self.trUtf8(
627 """ illegal host <b>{0}</b>. Accept this connection?</p>""")\ 657 """<p>A connection was attempted by the illegal host"""
658 """ <b>{0}</b>. Accept this connection?</p>""")\
628 .format(peerAddress), 659 .format(peerAddress),
629 icon=E5MessageBox.Warning) 660 icon=E5MessageBox.Warning)
630 if not res: 661 if not res:
631 sock.abort() 662 sock.abort()
632 return 663 return
634 allowedHosts = Preferences.getDebugger("AllowedHosts") 665 allowedHosts = Preferences.getDebugger("AllowedHosts")
635 allowedHosts.append(peerAddress) 666 allowedHosts.append(peerAddress)
636 Preferences.setDebugger("AllowedHosts", allowedHosts) 667 Preferences.setDebugger("AllowedHosts", allowedHosts)
637 668
638 if self.passive: 669 if self.passive:
639 self.__createDebuggerInterface(Preferences.getDebugger("PassiveDbgType")) 670 self.__createDebuggerInterface(
671 Preferences.getDebugger("PassiveDbgType"))
640 672
641 accepted = self.debuggerInterface.newConnection(sock) 673 accepted = self.debuggerInterface.newConnection(sock)
642 if accepted: 674 if accepted:
643 # Perform actions necessary, if client type has changed 675 # Perform actions necessary, if client type has changed
644 if self.lastClientType != self.clientType: 676 if self.lastClientType != self.clientType:
689 721
690 @param fn the filename to debug (string) 722 @param fn the filename to debug (string)
691 @param argv the commandline arguments to pass to the program (string) 723 @param argv the commandline arguments to pass to the program (string)
692 @param wd the working directory for the program (string) 724 @param wd the working directory for the program (string)
693 @param env environment settings (string) 725 @param env environment settings (string)
694 @keyparam autoClearShell flag indicating, that the interpreter window should 726 @keyparam autoClearShell flag indicating, that the interpreter window
695 be cleared (boolean) 727 should be cleared (boolean)
696 @keyparam tracePython flag indicating if the Python library should be traced 728 @keyparam tracePython flag indicating if the Python library should be
697 as well (boolean) 729 traced as well (boolean)
698 @keyparam autoContinue flag indicating, that the debugger should not stop 730 @keyparam autoContinue flag indicating, that the debugger should not
699 at the first executable line (boolean) 731 stop at the first executable line (boolean)
700 @keyparam forProject flag indicating a project related action (boolean) 732 @keyparam forProject flag indicating a project related action (boolean)
701 @keyparam runInConsole flag indicating to start the debugger in a 733 @keyparam runInConsole flag indicating to start the debugger in a
702 console window (boolean) 734 console window (boolean)
703 @keyparam autoFork flag indicating the automatic fork mode (boolean) 735 @keyparam autoFork flag indicating the automatic fork mode (boolean)
704 @keyparam forkChild flag indicating to debug the child after forking (boolean) 736 @keyparam forkChild flag indicating to debug the child after forking
737 (boolean)
705 @keyparam clientType client type to be used (string) 738 @keyparam clientType client type to be used (string)
706 @keyparam enableCallTrace flag indicating to enable the call trace 739 @keyparam enableCallTrace flag indicating to enable the call trace
707 function (boolean) 740 function (boolean)
708 """ 741 """
709 self.__autoClearShell = autoClearShell 742 self.__autoClearShell = autoClearShell
712 # Restart the client 745 # Restart the client
713 try: 746 try:
714 if clientType: 747 if clientType:
715 self.__setClientType(clientType) 748 self.__setClientType(clientType)
716 else: 749 else:
717 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 750 self.__setClientType(
751 self.__clientAssociations[os.path.splitext(fn)[1]])
718 except KeyError: 752 except KeyError:
719 self.__setClientType('Python3') # assume it is a Python3 file 753 self.__setClientType('Python3') # assume it is a Python3 file
720 self.startClient(False, forProject=forProject, runInConsole=runInConsole) 754 self.startClient(False, forProject=forProject,
755 runInConsole=runInConsole)
721 756
722 self.setCallTraceEnabled(enableCallTrace) 757 self.setCallTraceEnabled(enableCallTrace)
723 self.remoteEnvironment(env) 758 self.remoteEnvironment(env)
724 759
725 self.debuggerInterface.remoteLoad(fn, argv, wd, tracePython, autoContinue, 760 self.debuggerInterface.remoteLoad(fn, argv, wd, tracePython,
726 autoFork, forkChild) 761 autoContinue, autoFork, forkChild)
727 self.debugging = True 762 self.debugging = True
728 self.running = True 763 self.running = True
729 self.__restoreBreakpoints() 764 self.__restoreBreakpoints()
730 self.__restoreWatchpoints() 765 self.__restoreWatchpoints()
731 766
738 773
739 @param fn the filename to run (string) 774 @param fn the filename to run (string)
740 @param argv the commandline arguments to pass to the program (string) 775 @param argv the commandline arguments to pass to the program (string)
741 @param wd the working directory for the program (string) 776 @param wd the working directory for the program (string)
742 @param env environment settings (string) 777 @param env environment settings (string)
743 @keyparam autoClearShell flag indicating, that the interpreter window should 778 @keyparam autoClearShell flag indicating, that the interpreter window
744 be cleared (boolean) 779 should be cleared (boolean)
745 @keyparam forProject flag indicating a project related action (boolean) 780 @keyparam forProject flag indicating a project related action (boolean)
746 @keyparam runInConsole flag indicating to start the debugger in a 781 @keyparam runInConsole flag indicating to start the debugger in a
747 console window (boolean) 782 console window (boolean)
748 @keyparam autoFork flag indicating the automatic fork mode (boolean) 783 @keyparam autoFork flag indicating the automatic fork mode (boolean)
749 @keyparam forkChild flag indicating to debug the child after forking (boolean) 784 @keyparam forkChild flag indicating to debug the child after forking
785 (boolean)
750 @keyparam clientType client type to be used (string) 786 @keyparam clientType client type to be used (string)
751 """ 787 """
752 self.__autoClearShell = autoClearShell 788 self.__autoClearShell = autoClearShell
753 789
754 # Restart the client 790 # Restart the client
755 try: 791 try:
756 if clientType: 792 if clientType:
757 self.__setClientType(clientType) 793 self.__setClientType(clientType)
758 else: 794 else:
759 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 795 self.__setClientType(
796 self.__clientAssociations[os.path.splitext(fn)[1]])
760 except KeyError: 797 except KeyError:
761 self.__setClientType('Python3') # assume it is a Python3 file 798 self.__setClientType('Python3') # assume it is a Python3 file
762 self.startClient(False, forProject=forProject, runInConsole=runInConsole) 799 self.startClient(False, forProject=forProject,
800 runInConsole=runInConsole)
763 801
764 self.remoteEnvironment(env) 802 self.remoteEnvironment(env)
765 803
766 self.debuggerInterface.remoteRun(fn, argv, wd, autoFork, forkChild) 804 self.debuggerInterface.remoteRun(fn, argv, wd, autoFork, forkChild)
767 self.debugging = False 805 self.debugging = False
775 813
776 @param fn the filename to run (string) 814 @param fn the filename to run (string)
777 @param argv the commandline arguments to pass to the program (string) 815 @param argv the commandline arguments to pass to the program (string)
778 @param wd the working directory for the program (string) 816 @param wd the working directory for the program (string)
779 @param env environment settings (string) 817 @param env environment settings (string)
780 @keyparam autoClearShell flag indicating, that the interpreter window should 818 @keyparam autoClearShell flag indicating, that the interpreter window
781 be cleared (boolean) 819 should be cleared (boolean)
782 @keyparam erase flag indicating that coverage info should be 820 @keyparam erase flag indicating that coverage info should be
783 cleared first (boolean) 821 cleared first (boolean)
784 @keyparam forProject flag indicating a project related action (boolean) 822 @keyparam forProject flag indicating a project related action (boolean)
785 @keyparam runInConsole flag indicating to start the debugger in a 823 @keyparam runInConsole flag indicating to start the debugger in a
786 console window (boolean) 824 console window (boolean)
791 # Restart the client 829 # Restart the client
792 try: 830 try:
793 if clientType: 831 if clientType:
794 self.__setClientType(clientType) 832 self.__setClientType(clientType)
795 else: 833 else:
796 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 834 self.__setClientType(
835 self.__clientAssociations[os.path.splitext(fn)[1]])
797 except KeyError: 836 except KeyError:
798 self.__setClientType('Python3') # assume it is a Python3 file 837 self.__setClientType('Python3') # assume it is a Python3 file
799 self.startClient(False, forProject=forProject, runInConsole=runInConsole) 838 self.startClient(False, forProject=forProject,
839 runInConsole=runInConsole)
800 840
801 self.remoteEnvironment(env) 841 self.remoteEnvironment(env)
802 842
803 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase) 843 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase)
804 self.debugging = False 844 self.debugging = False
813 853
814 @param fn the filename to run (string) 854 @param fn the filename to run (string)
815 @param argv the commandline arguments to pass to the program (string) 855 @param argv the commandline arguments to pass to the program (string)
816 @param wd the working directory for the program (string) 856 @param wd the working directory for the program (string)
817 @param env environment settings (string) 857 @param env environment settings (string)
818 @keyparam autoClearShell flag indicating, that the interpreter window should 858 @keyparam autoClearShell flag indicating, that the interpreter window
819 be cleared (boolean) 859 should be cleared (boolean)
820 @keyparam erase flag indicating that timing info should be cleared first (boolean) 860 @keyparam erase flag indicating that timing info should be cleared
861 first (boolean)
821 @keyparam forProject flag indicating a project related action (boolean) 862 @keyparam forProject flag indicating a project related action (boolean)
822 @keyparam runInConsole flag indicating to start the debugger in a 863 @keyparam runInConsole flag indicating to start the debugger in a
823 console window (boolean) 864 console window (boolean)
824 @keyparam clientType client type to be used (string) 865 @keyparam clientType client type to be used (string)
825 """ 866 """
828 # Restart the client 869 # Restart the client
829 try: 870 try:
830 if clientType: 871 if clientType:
831 self.__setClientType(clientType) 872 self.__setClientType(clientType)
832 else: 873 else:
833 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 874 self.__setClientType(
875 self.__clientAssociations[os.path.splitext(fn)[1]])
834 except KeyError: 876 except KeyError:
835 self.__setClientType('Python3') # assume it is a Python3 file 877 self.__setClientType('Python3') # assume it is a Python3 file
836 self.startClient(False, forProject=forProject, runInConsole=runInConsole) 878 self.startClient(False, forProject=forProject,
879 runInConsole=runInConsole)
837 880
838 self.remoteEnvironment(env) 881 self.remoteEnvironment(env)
839 882
840 self.debuggerInterface.remoteProfile(fn, argv, wd, erase) 883 self.debuggerInterface.remoteProfile(fn, argv, wd, erase)
841 self.debugging = False 884 self.debugging = False
898 """ 941 """
899 Private method to enable or disable a breakpoint. 942 Private method to enable or disable a breakpoint.
900 943
901 @param fn filename the breakpoint belongs to (string) 944 @param fn filename the breakpoint belongs to (string)
902 @param line linenumber of the breakpoint (int) 945 @param line linenumber of the breakpoint (int)
903 @param enable flag indicating enabling or disabling a breakpoint (boolean) 946 @param enable flag indicating enabling or disabling a breakpoint
947 (boolean)
904 """ 948 """
905 self.debuggerInterface.remoteBreakpointEnable(fn, line, enable) 949 self.debuggerInterface.remoteBreakpointEnable(fn, line, enable)
906 950
907 def __remoteBreakpointIgnore(self, fn, line, count): 951 def __remoteBreakpointIgnore(self, fn, line, count):
908 """ 952 """
917 def __remoteWatchpoint(self, cond, set, temp=False): 961 def __remoteWatchpoint(self, cond, set, temp=False):
918 """ 962 """
919 Private method to set or clear a watch expression. 963 Private method to set or clear a watch expression.
920 964
921 @param cond expression of the watch expression (string) 965 @param cond expression of the watch expression (string)
922 @param set flag indicating setting or resetting a watch expression (boolean) 966 @param set flag indicating setting or resetting a watch expression
967 (boolean)
923 @param temp flag indicating a temporary watch expression (boolean) 968 @param temp flag indicating a temporary watch expression (boolean)
924 """ 969 """
925 # cond is combination of cond and special (s. watch expression viewer) 970 # cond is combination of cond and special (s. watch expression viewer)
926 self.debuggerInterface.remoteWatchpoint(cond, set, temp) 971 self.debuggerInterface.remoteWatchpoint(cond, set, temp)
927 972
928 def __remoteWatchpointEnable(self, cond, enable): 973 def __remoteWatchpointEnable(self, cond, enable):
929 """ 974 """
930 Private method to enable or disable a watch expression. 975 Private method to enable or disable a watch expression.
931 976
932 @param cond expression of the watch expression (string) 977 @param cond expression of the watch expression (string)
933 @param enable flag indicating enabling or disabling a watch expression (boolean) 978 @param enable flag indicating enabling or disabling a watch expression
979 (boolean)
934 """ 980 """
935 # cond is combination of cond and special (s. watch expression viewer) 981 # cond is combination of cond and special (s. watch expression viewer)
936 self.debuggerInterface.remoteWatchpointEnable(cond, enable) 982 self.debuggerInterface.remoteWatchpointEnable(cond, enable)
937 983
938 def __remoteWatchpointIgnore(self, cond, count): 984 def __remoteWatchpointIgnore(self, cond, count):
939 """ 985 """
940 Private method to ignore a watch expression the next couple of occurrences. 986 Private method to ignore a watch expression the next couple of
987 occurrences.
941 988
942 @param cond expression of the watch expression (string) 989 @param cond expression of the watch expression (string)
943 @param count number of occurrences to ignore (int) 990 @param count number of occurrences to ignore (int)
944 """ 991 """
945 # cond is combination of cond and special (s. watch expression viewer) 992 # cond is combination of cond and special (s. watch expression viewer)
985 @param scope the scope of the variables (0 = local, 1 = global) 1032 @param scope the scope of the variables (0 = local, 1 = global)
986 @param filter list of variable types to filter out (list of int) 1033 @param filter list of variable types to filter out (list of int)
987 @param var list encoded name of variable to retrieve (string) 1034 @param var list encoded name of variable to retrieve (string)
988 @param framenr framenumber of the variables to retrieve (int) 1035 @param framenr framenumber of the variables to retrieve (int)
989 """ 1036 """
990 self.debuggerInterface.remoteClientVariable(scope, filter, var, framenr) 1037 self.debuggerInterface.remoteClientVariable(
1038 scope, filter, var, framenr)
991 1039
992 def remoteClientSetFilter(self, scope, filter): 1040 def remoteClientSetFilter(self, scope, filter):
993 """ 1041 """
994 Public method to set a variables filter list. 1042 Public method to set a variables filter list.
995 1043
1006 """ 1054 """
1007 self.debuggerInterface.setCallTraceEnabled(on) 1055 self.debuggerInterface.setCallTraceEnabled(on)
1008 1056
1009 def remoteEval(self, arg): 1057 def remoteEval(self, arg):
1010 """ 1058 """
1011 Public method to evaluate arg in the current context of the debugged program. 1059 Public method to evaluate arg in the current context of the debugged
1060 program.
1012 1061
1013 @param arg the arguments to evaluate (string) 1062 @param arg the arguments to evaluate (string)
1014 """ 1063 """
1015 self.debuggerInterface.remoteEval(arg) 1064 self.debuggerInterface.remoteEval(arg)
1016 1065
1017 def remoteExec(self, stmt): 1066 def remoteExec(self, stmt):
1018 """ 1067 """
1019 Public method to execute stmt in the current context of the debugged program. 1068 Public method to execute stmt in the current context of the debugged
1069 program.
1020 1070
1021 @param stmt statement to execute (string) 1071 @param stmt statement to execute (string)
1022 """ 1072 """
1023 self.debuggerInterface.remoteExec(stmt) 1073 self.debuggerInterface.remoteExec(stmt)
1024 1074
1041 1091
1042 @param text the text to be completed (string) 1092 @param text the text to be completed (string)
1043 """ 1093 """
1044 self.debuggerInterface.remoteCompletion(text) 1094 self.debuggerInterface.remoteCompletion(text)
1045 1095
1046 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase, clientType=""): 1096 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase,
1097 clientType=""):
1047 """ 1098 """
1048 Public method to prepare a new unittest run. 1099 Public method to prepare a new unittest run.
1049 1100
1050 @param fn the filename to load (string) 1101 @param fn the filename to load (string)
1051 @param tn the testname to load (string) 1102 @param tn the testname to load (string)
1052 @param tfn the test function name to load tests from (string) 1103 @param tfn the test function name to load tests from (string)
1053 @param failed list of failed test, if only failed test should be run 1104 @param failed list of failed test, if only failed test should be run
1054 (list of strings) 1105 (list of strings)
1055 @param cov flag indicating collection of coverage data is requested (boolean) 1106 @param cov flag indicating collection of coverage data is requested
1107 (boolean)
1056 @param covname filename to be used to assemble the coverage caches 1108 @param covname filename to be used to assemble the coverage caches
1057 filename (string) 1109 filename (string)
1058 @param coverase flag indicating erasure of coverage data is requested (boolean) 1110 @param coverase flag indicating erasure of coverage data is requested
1111 (boolean)
1059 @keyparam clientType client type to be used (string) 1112 @keyparam clientType client type to be used (string)
1060 """ 1113 """
1061 # Restart the client if there is already a program loaded. 1114 # Restart the client if there is already a program loaded.
1062 try: 1115 try:
1063 if clientType: 1116 if clientType:
1064 self.__setClientType(clientType) 1117 self.__setClientType(clientType)
1065 else: 1118 else:
1066 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 1119 self.__setClientType(
1120 self.__clientAssociations[os.path.splitext(fn)[1]])
1067 except KeyError: 1121 except KeyError:
1068 self.__setClientType('Python3') # assume it is a Python3 file 1122 self.__setClientType('Python3') # assume it is a Python3 file
1069 self.startClient(False) 1123 self.startClient(False)
1070 1124
1071 self.debuggerInterface.remoteUTPrepare( 1125 self.debuggerInterface.remoteUTPrepare(
1115 1169
1116 def signalClientThreadList(self, currentId, threadList): 1170 def signalClientThreadList(self, currentId, threadList):
1117 """ 1171 """
1118 Public method to process the client thread list info. 1172 Public method to process the client thread list info.
1119 1173
1120 @param currentID id of the current thread (integer) 1174 @param currentId id of the current thread (integer)
1121 @param threadList list of dictionaries containing the thread data 1175 @param threadList list of dictionaries containing the thread data
1122 """ 1176 """
1123 self.clientThreadList.emit(currentId, threadList) 1177 self.clientThreadList.emit(currentId, threadList)
1124 1178
1125 def signalClientThreadSet(self): 1179 def signalClientThreadSet(self):
1130 1184
1131 def signalClientVariables(self, scope, variables): 1185 def signalClientVariables(self, scope, variables):
1132 """ 1186 """
1133 Public method to process the client variables info. 1187 Public method to process the client variables info.
1134 1188
1135 @param scope scope of the variables (-1 = empty global, 1 = global, 0 = local) 1189 @param scope scope of the variables (-1 = empty global, 1 = global,
1190 0 = local)
1136 @param variables the list of variables from the client 1191 @param variables the list of variables from the client
1137 """ 1192 """
1138 self.clientVariables.emit(scope, variables) 1193 self.clientVariables.emit(scope, variables)
1139 1194
1140 def signalClientVariable(self, scope, variables): 1195 def signalClientVariable(self, scope, variables):
1141 """ 1196 """
1142 Public method to process the client variable info. 1197 Public method to process the client variable info.
1143 1198
1144 @param scope scope of the variables (-1 = empty global, 1 = global, 0 = local) 1199 @param scope scope of the variables (-1 = empty global, 1 = global,
1200 0 = local)
1145 @param variables the list of members of a classvariable from the client 1201 @param variables the list of members of a classvariable from the client
1146 """ 1202 """
1147 self.clientVariable.emit(scope, variables) 1203 self.clientVariable.emit(scope, variables)
1148 1204
1149 def signalClientStatement(self, more): 1205 def signalClientStatement(self, more):
1152 1208
1153 @param more flag indicating that more user input is required 1209 @param more flag indicating that more user input is required
1154 """ 1210 """
1155 self.clientStatement.emit(more) 1211 self.clientStatement.emit(more)
1156 1212
1157 def signalClientException(self, exceptionType, exceptionMessage, stackTrace): 1213 def signalClientException(self, exceptionType, exceptionMessage,
1214 stackTrace):
1158 """ 1215 """
1159 Public method to process the exception info from the client. 1216 Public method to process the exception info from the client.
1160 1217
1161 @param exceptionType type of exception raised (string) 1218 @param exceptionType type of exception raised (string)
1162 @param exceptionMessage message given by the exception (string) 1219 @param exceptionMessage message given by the exception (string)
1163 @param stackTrace list of stack entries with the exception position 1220 @param stackTrace list of stack entries with the exception position
1164 first. Each stack entry is a list giving the filename and the linenumber. 1221 first. Each stack entry is a list giving the filename and the
1222 linenumber.
1165 """ 1223 """
1166 if self.running: 1224 if self.running:
1167 self.clientException.emit(exceptionType, exceptionMessage, stackTrace) 1225 self.clientException.emit(exceptionType, exceptionMessage,
1226 stackTrace)
1168 1227
1169 def signalClientSyntaxError(self, message, filename, lineNo, characterNo): 1228 def signalClientSyntaxError(self, message, filename, lineNo, characterNo):
1170 """ 1229 """
1171 Public method to process the syntax error info from the client. 1230 Public method to process the syntax error info from the client.
1172 1231
1173 @param message message of the syntax error (string) 1232 @param message message of the syntax error (string)
1174 @param filename translated filename of the syntax error position (string) 1233 @param filename translated filename of the syntax error position
1234 (string)
1175 @param lineNo line number of the syntax error position (integer) 1235 @param lineNo line number of the syntax error position (integer)
1176 @param characterNo character number of the syntax error position (integer) 1236 @param characterNo character number of the syntax error position
1237 (integer)
1177 """ 1238 """
1178 if self.running: 1239 if self.running:
1179 self.clientSyntaxError.emit(message, filename, lineNo, characterNo) 1240 self.clientSyntaxError.emit(message, filename, lineNo, characterNo)
1180 1241
1181 def signalClientExit(self, status): 1242 def signalClientExit(self, status):
1389 def __restoreBreakpoints(self): 1450 def __restoreBreakpoints(self):
1390 """ 1451 """
1391 Private method to restore the breakpoints after a restart. 1452 Private method to restore the breakpoints after a restart.
1392 """ 1453 """
1393 if self.debugging: 1454 if self.debugging:
1394 self.__addBreakPoints(QModelIndex(), 0, self.breakpointModel.rowCount() - 1) 1455 self.__addBreakPoints(
1456 QModelIndex(), 0, self.breakpointModel.rowCount() - 1)
1395 1457
1396 def __restoreWatchpoints(self): 1458 def __restoreWatchpoints(self):
1397 """ 1459 """
1398 Private method to restore the watch expressions after a restart. 1460 Private method to restore the watch expressions after a restart.
1399 """ 1461 """
1400 if self.debugging: 1462 if self.debugging:
1401 self.__addWatchPoints(QModelIndex(), 0, self.watchpointModel.rowCount() - 1) 1463 self.__addWatchPoints(
1464 QModelIndex(), 0, self.watchpointModel.rowCount() - 1)
1402 1465
1403 def getBreakPointModel(self): 1466 def getBreakPointModel(self):
1404 """ 1467 """
1405 Public slot to get a reference to the breakpoint model object. 1468 Public slot to get a reference to the breakpoint model object.
1406 1469
1410 1473
1411 def getWatchPointModel(self): 1474 def getWatchPointModel(self):
1412 """ 1475 """
1413 Public slot to get a reference to the watch expression model object. 1476 Public slot to get a reference to the watch expression model object.
1414 1477
1415 @return reference to the watch expression model object (WatchPointModel) 1478 @return reference to the watch expression model object
1479 (WatchPointModel)
1416 """ 1480 """
1417 return self.watchpointModel 1481 return self.watchpointModel
1418 1482
1419 def isConnected(self): 1483 def isConnected(self):
1420 """ 1484 """

eric ide

mercurial