Debugger/DebugServer.py

changeset 2988
f53c03574697
parent 2953
703452a2876f
child 3018
70924c0bdaf1
child 3057
10516539f238
equal deleted inserted replaced
2987:c99695c0f13a 2988:f53c03574697
8 """ 8 """
9 9
10 import os 10 import os
11 11
12 from PyQt4.QtCore import pyqtSignal, QModelIndex 12 from PyQt4.QtCore import pyqtSignal, QModelIndex
13 from PyQt4.QtNetwork import QTcpServer, QHostAddress, QHostInfo, QNetworkInterface 13 from PyQt4.QtNetwork import QTcpServer, QHostAddress, QHostInfo, \
14 QNetworkInterface
14 15
15 from E5Gui.E5Application import e5App 16 from E5Gui.E5Application import e5App
16 from E5Gui import E5MessageBox 17 from E5Gui import E5MessageBox
17 18
18 from .BreakPointModel import BreakPointModel 19 from .BreakPointModel import BreakPointModel
33 34
34 class DebugServer(QTcpServer): 35 class DebugServer(QTcpServer):
35 """ 36 """
36 Class implementing the debug server embedded within the IDE. 37 Class implementing the debug server embedded within the IDE.
37 38
38 @signal clientProcessStdout(str) emitted after the client has sent some output 39 @signal clientProcessStdout(str) emitted after the client has sent some
39 via stdout 40 output via stdout
40 @signal clientProcessStderr(str) emitted after the client has sent some output 41 @signal clientProcessStderr(str) emitted after the client has sent some
41 via stderr 42 output via stderr
42 @signal clientOutput(str) emitted after the client has sent some output 43 @signal clientOutput(str) emitted after the client has sent some output
43 @signal clientRawInputSent() emitted after the data was sent to the debug client 44 @signal clientRawInputSent() emitted after the data was sent to the
44 @signal clientLine(filename, lineno, forStack) emitted after the debug client 45 debug client
45 has executed a line of code 46 @signal clientLine(filename, lineno, forStack) emitted after the
47 debug client has executed a line of code
46 @signal clientStack(stack) emitted after the debug client has executed a 48 @signal clientStack(stack) emitted after the debug client has executed a
47 line of code 49 line of code
48 @signal clientThreadList(currentId, threadList) emitted after a thread list 50 @signal clientThreadList(currentId, threadList) emitted after a thread list
49 has been received 51 has been received
50 @signal clientThreadSet() emitted after the client has acknowledged the change 52 @signal clientThreadSet() emitted after the client has acknowledged the
51 of the current thread 53 change of the current thread
52 @signal clientVariables(scope, variables) emitted after a variables dump has 54 @signal clientVariables(scope, variables) emitted after a variables dump
53 been received 55 has been received
54 @signal clientVariable(scope, variables) emitted after a dump for one class 56 @signal clientVariable(scope, variables) emitted after a dump for one class
55 variable has been received 57 variable has been received
56 @signal clientStatement(bool) emitted after an interactive command has 58 @signal clientStatement(bool) emitted after an interactive command has
57 been executed. The parameter is 0 to indicate that the command is 59 been executed. The parameter is 0 to indicate that the command is
58 complete and 1 if it needs more input. 60 complete and 1 if it needs more input.
59 @signal clientException(exception) emitted after an exception occured on the 61 @signal clientException(exception) emitted after an exception occured on
60 client side 62 the client side
61 @signal clientSyntaxError(exception) emitted after a syntax error has been detected 63 @signal clientSyntaxError(exception) emitted after a syntax error has been
62 on the client side 64 detected on the client side
63 @signal clientExit(int) emitted with the exit status after the client has exited 65 @signal clientExit(int) emitted with the exit status after the client has
66 exited
64 @signal clientClearBreak(filename, lineno) emitted after the debug client 67 @signal clientClearBreak(filename, lineno) emitted after the debug client
65 has decided to clear a temporary breakpoint 68 has decided to clear a temporary breakpoint
66 @signal clientBreakConditionError(fn, lineno) emitted after the client has signaled 69 @signal clientBreakConditionError(fn, lineno) emitted after the client has
67 a syntax error in a breakpoint condition 70 signaled a syntax error in a breakpoint condition
68 @signal clientClearWatch(condition) emitted after the debug client 71 @signal clientClearWatch(condition) emitted after the debug client
69 has decided to clear a temporary watch expression 72 has decided to clear a temporary watch expression
70 @signal clientWatchConditionError(condition) emitted after the client has signaled 73 @signal clientWatchConditionError(condition) emitted after the client has
71 a syntax error in a watch expression 74 signaled a syntax error in a watch expression
72 @signal clientRawInput(prompt, echo) emitted after a raw input request was received 75 @signal clientRawInput(prompt, echo) emitted after a raw input request was
76 received
73 @signal clientBanner(banner) emitted after the client banner was received 77 @signal clientBanner(banner) emitted after the client banner was received
74 @signal clientCapabilities(int capabilities, string cltype) emitted after the clients 78 @signal clientCapabilities(int capabilities, string cltype) emitted after
75 capabilities were received 79 the clients capabilities were received
76 @signal clientCompletionList(completionList, text) emitted after the client 80 @signal clientCompletionList(completionList, text) emitted after the client
77 the commandline completion list and the reworked searchstring was 81 the commandline completion list and the reworked searchstring was
78 received from the client 82 received from the client
79 @signal passiveDebugStarted(str, bool) emitted after the debug client has connected in 83 @signal passiveDebugStarted(str, bool) emitted after the debug client has
80 passive debug mode 84 connected in passive debug mode
81 @signal clientGone(bool) emitted if the client went away (planned or unplanned) 85 @signal clientGone(bool) emitted if the client went away (planned or
82 @signal utPrepared(nrTests, exc_type, exc_value) emitted after the client has 86 unplanned)
83 loaded a unittest suite 87 @signal utPrepared(nrTests, exc_type, exc_value) emitted after the client
84 @signal utFinished() emitted after the client signalled the end of the unittest 88 has loaded a unittest suite
85 @signal utStartTest(testname, testdocu) emitted after the client has started 89 @signal utFinished() emitted after the client signalled the end of the
86 a test 90 unittest
91 @signal utStartTest(testname, testdocu) emitted after the client has
92 started a test
87 @signal utStopTest() emitted after the client has finished a test 93 @signal utStopTest() emitted after the client has finished a test
88 @signal utTestFailed(testname, exc_info, id) emitted after the client reported 94 @signal utTestFailed(testname, exc_info, id) emitted after the client
89 a failed test 95 reported a failed test
90 @signal utTestErrored(testname, exc_info, id) emitted after the client reported 96 @signal utTestErrored(testname, exc_info, id) emitted after the client
91 an errored test 97 reported an errored test
92 @signal utTestSkipped(testname, reason, id) emitted after the client reported 98 @signal utTestSkipped(testname, reason, id) emitted after the client
93 a skipped test 99 reported a skipped test
94 @signal utTestFailedExpected(testname, exc_info, id) emitted after the client reported 100 @signal utTestFailedExpected(testname, exc_info, id) emitted after the
95 an expected test failure 101 client reported an expected test failure
96 @signal utTestSucceededUnexpected(testname, id) emitted after the client reported 102 @signal utTestSucceededUnexpected(testname, id) emitted after the client
97 an unexpected test success 103 reported an unexpected test success
98 @signal callTraceInfo(isCall, fromFile, fromLine, fromFunction, toFile, toLine, toFunction) 104 @signal callTraceInfo(isCall, fromFile, fromLine, fromFunction, toFile,
99 emitted after the client reported the call trace data 105 toLine, toFunction) emitted after the client reported the call trace
106 data
100 """ 107 """
101 clientClearBreak = pyqtSignal(str, int) 108 clientClearBreak = pyqtSignal(str, int)
102 clientClearWatch = pyqtSignal(str) 109 clientClearWatch = pyqtSignal(str)
103 clientGone = pyqtSignal(bool) 110 clientGone = pyqtSignal(bool)
104 clientProcessStdout = pyqtSignal(str) 111 clientProcessStdout = pyqtSignal(str)
179 186
180 self.clientClearBreak.connect(self.__clientClearBreakPoint) 187 self.clientClearBreak.connect(self.__clientClearBreakPoint)
181 self.clientClearWatch.connect(self.__clientClearWatchPoint) 188 self.clientClearWatch.connect(self.__clientClearWatchPoint)
182 self.newConnection[()].connect(self.__newConnection) 189 self.newConnection[()].connect(self.__newConnection)
183 190
184 self.breakpointModel.rowsAboutToBeRemoved.connect(self.__deleteBreakPoints) 191 self.breakpointModel.rowsAboutToBeRemoved.connect(
192 self.__deleteBreakPoints)
185 self.breakpointModel.dataAboutToBeChanged.connect( 193 self.breakpointModel.dataAboutToBeChanged.connect(
186 self.__breakPointDataAboutToBeChanged) 194 self.__breakPointDataAboutToBeChanged)
187 self.breakpointModel.dataChanged.connect(self.__changeBreakPoints) 195 self.breakpointModel.dataChanged.connect(self.__changeBreakPoints)
188 self.breakpointModel.rowsInserted.connect(self.__addBreakPoints) 196 self.breakpointModel.rowsInserted.connect(self.__addBreakPoints)
189 197
190 self.watchpointModel.rowsAboutToBeRemoved.connect(self.__deleteWatchPoints) 198 self.watchpointModel.rowsAboutToBeRemoved.connect(
199 self.__deleteWatchPoints)
191 self.watchpointModel.dataAboutToBeChanged.connect( 200 self.watchpointModel.dataAboutToBeChanged.connect(
192 self.__watchPointDataAboutToBeChanged) 201 self.__watchPointDataAboutToBeChanged)
193 self.watchpointModel.dataChanged.connect(self.__changeWatchPoints) 202 self.watchpointModel.dataChanged.connect(self.__changeWatchPoints)
194 self.watchpointModel.rowsInserted.connect(self.__addWatchPoints) 203 self.watchpointModel.rowsInserted.connect(self.__addWatchPoints)
195 204
196 self.__registerDebuggerInterfaces() 205 self.__registerDebuggerInterfaces()
197 206
198 def getHostAddress(self, localhost): 207 def getHostAddress(self, localhost):
199 """ 208 """
200 Public method to get the IP address or hostname the debug server is listening. 209 Public method to get the IP address or hostname the debug server is
201 210 listening.
202 @param localhost flag indicating to return the address for localhost (boolean) 211
212 @param localhost flag indicating to return the address for localhost
213 (boolean)
203 @return IP address or hostname (string) 214 @return IP address or hostname (string)
204 """ 215 """
205 if self.networkInterface == "all": 216 if self.networkInterface == "all":
206 if localhost: 217 if localhost:
207 return "127.0.0.1" 218 return "127.0.0.1"
216 return "{0}@@i{1}".format(self.networkInterface, 227 return "{0}@@i{1}".format(self.networkInterface,
217 self.networkInterfaceIndex) 228 self.networkInterfaceIndex)
218 229
219 def __getNetworkInterfaceAndIndex(self, address): 230 def __getNetworkInterfaceAndIndex(self, address):
220 """ 231 """
221 Private method to determine the network interface and the interface index. 232 Private method to determine the network interface and the interface
233 index.
222 234
223 @param address address to determine the info for (string) 235 @param address address to determine the info for (string)
224 @return tuple of network interface name (string) and index (integer) 236 @return tuple of network interface name (string) and index (integer)
225 """ 237 """
226 if address not in ["all", "allv6"]: 238 if address not in ["all", "allv6"]:
227 for networkInterface in QNetworkInterface.allInterfaces(): 239 for networkInterface in QNetworkInterface.allInterfaces():
228 addressEntries = networkInterface.addressEntries() 240 addressEntries = networkInterface.addressEntries()
229 if len(addressEntries) > 0: 241 if len(addressEntries) > 0:
230 for addressEntry in addressEntries: 242 for addressEntry in addressEntries:
231 if addressEntry.ip().toString().lower() == address.lower(): 243 if addressEntry.ip().toString().lower() == \
244 address.lower():
232 return networkInterface.humanReadableName(), \ 245 return networkInterface.humanReadableName(), \
233 networkInterface.index() 246 networkInterface.index()
234 247
235 return "", 0 248 return "", 0
236 249
277 pass # it is not in the list 290 pass # it is not in the list
278 291
279 if shellOnly: 292 if shellOnly:
280 languages = \ 293 languages = \
281 [lang for lang in languages \ 294 [lang for lang in languages \
282 if self.__clientCapabilities[lang] & DebugClientCapabilities.HasShell] 295 if self.__clientCapabilities[lang] &
296 DebugClientCapabilities.HasShell]
283 297
284 return languages[:] 298 return languages[:]
285 299
286 def getExtensions(self, language): 300 def getExtensions(self, language):
287 """ 301 """
288 Public slot to get the extensions associated with the given language. 302 Public slot to get the extensions associated with the given language.
289 303
290 @param language language to get extensions for (string) 304 @param language language to get extensions for (string)
291 @return tuple of extensions associated with the language (tuple of strings) 305 @return tuple of extensions associated with the language
306 (tuple of strings)
292 """ 307 """
293 extensions = [] 308 extensions = []
294 for ext, lang in list(self.__clientAssociations.items()): 309 for ext, lang in list(self.__clientAssociations.items()):
295 if lang == language: 310 if lang == language:
296 extensions.append(ext) 311 extensions.append(ext)
306 if self.lastClientType != self.clientType or clientType is not None: 321 if self.lastClientType != self.clientType or clientType is not None:
307 if clientType is None: 322 if clientType is None:
308 clientType = self.clientType 323 clientType = self.clientType
309 if clientType == "Python2": 324 if clientType == "Python2":
310 from .DebuggerInterfacePython import DebuggerInterfacePython 325 from .DebuggerInterfacePython import DebuggerInterfacePython
311 self.debuggerInterface = DebuggerInterfacePython(self, self.passive) 326 self.debuggerInterface = DebuggerInterfacePython(
327 self, self.passive)
312 elif clientType == "Python3": 328 elif clientType == "Python3":
313 from .DebuggerInterfacePython3 import DebuggerInterfacePython3 329 from .DebuggerInterfacePython3 import DebuggerInterfacePython3
314 self.debuggerInterface = DebuggerInterfacePython3(self, self.passive) 330 self.debuggerInterface = DebuggerInterfacePython3(
331 self, self.passive)
315 elif clientType == "Ruby": 332 elif clientType == "Ruby":
316 from .DebuggerInterfaceRuby import DebuggerInterfaceRuby 333 from .DebuggerInterfaceRuby import DebuggerInterfaceRuby
317 self.debuggerInterface = DebuggerInterfaceRuby(self, self.passive) 334 self.debuggerInterface = DebuggerInterfaceRuby(
335 self, self.passive)
318 elif clientType == "None": 336 elif clientType == "None":
319 from .DebuggerInterfaceNone import DebuggerInterfaceNone 337 from .DebuggerInterfaceNone import DebuggerInterfaceNone
320 self.debuggerInterface = DebuggerInterfaceNone(self, self.passive) 338 self.debuggerInterface = DebuggerInterfaceNone(
339 self, self.passive)
321 else: 340 else:
322 from .DebuggerInterfaceNone import DebuggerInterfaceNone 341 from .DebuggerInterfaceNone import DebuggerInterfaceNone
323 self.debuggerInterface = DebuggerInterfaceNone(self, self.passive) 342 self.debuggerInterface = DebuggerInterfaceNone(
343 self, self.passive)
324 self.clientType = "None" 344 self.clientType = "None"
325 345
326 def __setClientType(self, clType): 346 def __setClientType(self, clType):
327 """ 347 """
328 Private method to set the client type. 348 Private method to set the client type.
370 self.clientProcess, isNetworked = \ 390 self.clientProcess, isNetworked = \
371 self.debuggerInterface.startRemote(self.serverPort(), 391 self.debuggerInterface.startRemote(self.serverPort(),
372 runInConsole) 392 runInConsole)
373 else: 393 else:
374 self.clientProcess, isNetworked = \ 394 self.clientProcess, isNetworked = \
375 self.debuggerInterface.startRemoteForProject(self.serverPort(), 395 self.debuggerInterface.startRemoteForProject(
376 runInConsole) 396 self.serverPort(), runInConsole)
377 else: 397 else:
378 self.clientProcess, isNetworked = \ 398 self.clientProcess, isNetworked = \
379 self.debuggerInterface.startRemote(self.serverPort(), runInConsole) 399 self.debuggerInterface.startRemote(
400 self.serverPort(), runInConsole)
380 401
381 if self.clientProcess: 402 if self.clientProcess:
382 self.clientProcess.readyReadStandardError.connect( 403 self.clientProcess.readyReadStandardError.connect(
383 self.__clientProcessError) 404 self.__clientProcessError)
384 self.clientProcess.readyReadStandardOutput.connect( 405 self.clientProcess.readyReadStandardOutput.connect(
436 @param end end row (integer) 457 @param end end row (integer)
437 """ 458 """
438 if self.debugging: 459 if self.debugging:
439 for row in range(start, end + 1): 460 for row in range(start, end + 1):
440 index = self.breakpointModel.index(row, 0, parentIndex) 461 index = self.breakpointModel.index(row, 0, parentIndex)
441 fn, lineno = self.breakpointModel.getBreakPointByIndex(index)[0:2] 462 fn, lineno = \
463 self.breakpointModel.getBreakPointByIndex(index)[0:2]
442 self.remoteBreakpoint(fn, lineno, False) 464 self.remoteBreakpoint(fn, lineno, False)
443 465
444 def __changeBreakPoints(self, startIndex, endIndex): 466 def __changeBreakPoints(self, startIndex, endIndex):
445 """ 467 """
446 Private slot to set changed breakpoints. 468 Private slot to set changed breakpoints.
447 469
448 @param startIndex starting index of the change breakpoins (QModelIndex) 470 @param startIndex starting index of the change breakpoins (QModelIndex)
449 @param endIndex ending index of the change breakpoins (QModelIndex) 471 @param endIndex ending index of the change breakpoins (QModelIndex)
450 """ 472 """
451 if self.debugging: 473 if self.debugging:
452 self.__addBreakPoints(QModelIndex(), startIndex.row(), endIndex.row()) 474 self.__addBreakPoints(
475 QModelIndex(), startIndex.row(), endIndex.row())
453 476
454 def __breakPointDataAboutToBeChanged(self, startIndex, endIndex): 477 def __breakPointDataAboutToBeChanged(self, startIndex, endIndex):
455 """ 478 """
456 Private slot to handle the dataAboutToBeChanged signal of the breakpoint model. 479 Private slot to handle the dataAboutToBeChanged signal of the
480 breakpoint model.
457 481
458 @param startIndex start index of the rows to be changed (QModelIndex) 482 @param startIndex start index of the rows to be changed (QModelIndex)
459 @param endIndex end index of the rows to be changed (QModelIndex) 483 @param endIndex end index of the rows to be changed (QModelIndex)
460 """ 484 """
461 if self.debugging: 485 if self.debugging:
462 self.__deleteBreakPoints(QModelIndex(), startIndex.row(), endIndex.row()) 486 self.__deleteBreakPoints(
487 QModelIndex(), startIndex.row(), endIndex.row())
463 488
464 def __addBreakPoints(self, parentIndex, start, end): 489 def __addBreakPoints(self, parentIndex, start, end):
465 """ 490 """
466 Private slot to add breakpoints. 491 Private slot to add breakpoints.
467 492
500 def __splitWatchCondition(self, cond): 525 def __splitWatchCondition(self, cond):
501 """ 526 """
502 Private method to split a remote watch expression. 527 Private method to split a remote watch expression.
503 528
504 @param cond remote expression (string) 529 @param cond remote expression (string)
505 @return tuple of local expression (string) and special condition (string) 530 @return tuple of local expression (string) and special condition
531 (string)
506 """ 532 """
507 if cond.endswith(" ??created??"): 533 if cond.endswith(" ??created??"):
508 cond, special = cond.split() 534 cond, special = cond.split()
509 special = self.watchSpecialCreated 535 special = self.watchSpecialCreated
510 elif cond.endswith(" ??changed??"): 536 elif cond.endswith(" ??changed??"):
536 @param end end row (integer) 562 @param end end row (integer)
537 """ 563 """
538 if self.debugging: 564 if self.debugging:
539 for row in range(start, end + 1): 565 for row in range(start, end + 1):
540 index = self.watchpointModel.index(row, 0, parentIndex) 566 index = self.watchpointModel.index(row, 0, parentIndex)
541 cond, special = self.watchpointModel.getWatchPointByIndex(index)[0:2] 567 cond, special = \
568 self.watchpointModel.getWatchPointByIndex(index)[0:2]
542 cond = self.__makeWatchCondition(cond, special) 569 cond = self.__makeWatchCondition(cond, special)
543 self.__remoteWatchpoint(cond, False) 570 self.__remoteWatchpoint(cond, False)
544 571
545 def __watchPointDataAboutToBeChanged(self, startIndex, endIndex): 572 def __watchPointDataAboutToBeChanged(self, startIndex, endIndex):
546 """ 573 """
549 576
550 @param startIndex start index of the rows to be changed (QModelIndex) 577 @param startIndex start index of the rows to be changed (QModelIndex)
551 @param endIndex end index of the rows to be changed (QModelIndex) 578 @param endIndex end index of the rows to be changed (QModelIndex)
552 """ 579 """
553 if self.debugging: 580 if self.debugging:
554 self.__deleteWatchPoints(QModelIndex(), startIndex.row(), endIndex.row()) 581 self.__deleteWatchPoints(
582 QModelIndex(), startIndex.row(), endIndex.row())
555 583
556 def __addWatchPoints(self, parentIndex, start, end): 584 def __addWatchPoints(self, parentIndex, start, end):
557 """ 585 """
558 Private slot to set a watch expression. 586 Private slot to set a watch expression.
559 587
579 607
580 @param startIndex start index of the rows to be changed (QModelIndex) 608 @param startIndex start index of the rows to be changed (QModelIndex)
581 @param endIndex end index of the rows to be changed (QModelIndex) 609 @param endIndex end index of the rows to be changed (QModelIndex)
582 """ 610 """
583 if self.debugging: 611 if self.debugging:
584 self.__addWatchPoints(QModelIndex(), startIndex.row(), endIndex.row()) 612 self.__addWatchPoints(
613 QModelIndex(), startIndex.row(), endIndex.row())
585 614
586 def getClientCapabilities(self, type): 615 def getClientCapabilities(self, type):
587 """ 616 """
588 Public method to retrieve the debug clients capabilities. 617 Public method to retrieve the debug clients capabilities.
589 618
603 peerAddress = sock.peerAddress().toString() 632 peerAddress = sock.peerAddress().toString()
604 if peerAddress not in Preferences.getDebugger("AllowedHosts"): 633 if peerAddress not in Preferences.getDebugger("AllowedHosts"):
605 # the peer is not allowed to connect 634 # the peer is not allowed to connect
606 res = E5MessageBox.yesNo(None, 635 res = E5MessageBox.yesNo(None,
607 self.trUtf8("Connection from illegal host"), 636 self.trUtf8("Connection from illegal host"),
608 self.trUtf8("""<p>A connection was attempted by the""" 637 self.trUtf8(
609 """ illegal host <b>{0}</b>. Accept this connection?</p>""")\ 638 """<p>A connection was attempted by the illegal host"""
639 """ <b>{0}</b>. Accept this connection?</p>""")\
610 .format(peerAddress), 640 .format(peerAddress),
611 icon=E5MessageBox.Warning) 641 icon=E5MessageBox.Warning)
612 if not res: 642 if not res:
613 sock.abort() 643 sock.abort()
614 return 644 return
616 allowedHosts = Preferences.getDebugger("AllowedHosts") 646 allowedHosts = Preferences.getDebugger("AllowedHosts")
617 allowedHosts.append(peerAddress) 647 allowedHosts.append(peerAddress)
618 Preferences.setDebugger("AllowedHosts", allowedHosts) 648 Preferences.setDebugger("AllowedHosts", allowedHosts)
619 649
620 if self.passive: 650 if self.passive:
621 self.__createDebuggerInterface(Preferences.getDebugger("PassiveDbgType")) 651 self.__createDebuggerInterface(
652 Preferences.getDebugger("PassiveDbgType"))
622 653
623 accepted = self.debuggerInterface.newConnection(sock) 654 accepted = self.debuggerInterface.newConnection(sock)
624 if accepted: 655 if accepted:
625 # Perform actions necessary, if client type has changed 656 # Perform actions necessary, if client type has changed
626 if self.lastClientType != self.clientType: 657 if self.lastClientType != self.clientType:
671 702
672 @param fn the filename to debug (string) 703 @param fn the filename to debug (string)
673 @param argv the commandline arguments to pass to the program (string) 704 @param argv the commandline arguments to pass to the program (string)
674 @param wd the working directory for the program (string) 705 @param wd the working directory for the program (string)
675 @param env environment settings (string) 706 @param env environment settings (string)
676 @keyparam autoClearShell flag indicating, that the interpreter window should 707 @keyparam autoClearShell flag indicating, that the interpreter window
677 be cleared (boolean) 708 should be cleared (boolean)
678 @keyparam tracePython flag indicating if the Python library should be traced 709 @keyparam tracePython flag indicating if the Python library should be
679 as well (boolean) 710 traced as well (boolean)
680 @keyparam autoContinue flag indicating, that the debugger should not stop 711 @keyparam autoContinue flag indicating, that the debugger should not
681 at the first executable line (boolean) 712 stop at the first executable line (boolean)
682 @keyparam forProject flag indicating a project related action (boolean) 713 @keyparam forProject flag indicating a project related action (boolean)
683 @keyparam runInConsole flag indicating to start the debugger in a 714 @keyparam runInConsole flag indicating to start the debugger in a
684 console window (boolean) 715 console window (boolean)
685 @keyparam autoFork flag indicating the automatic fork mode (boolean) 716 @keyparam autoFork flag indicating the automatic fork mode (boolean)
686 @keyparam forkChild flag indicating to debug the child after forking (boolean) 717 @keyparam forkChild flag indicating to debug the child after forking
718 (boolean)
687 @keyparam clientType client type to be used (string) 719 @keyparam clientType client type to be used (string)
688 @keyparam enableCallTrace flag indicating to enable the call trace 720 @keyparam enableCallTrace flag indicating to enable the call trace
689 function (boolean) 721 function (boolean)
690 """ 722 """
691 self.__autoClearShell = autoClearShell 723 self.__autoClearShell = autoClearShell
694 # Restart the client 726 # Restart the client
695 try: 727 try:
696 if clientType: 728 if clientType:
697 self.__setClientType(clientType) 729 self.__setClientType(clientType)
698 else: 730 else:
699 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 731 self.__setClientType(
732 self.__clientAssociations[os.path.splitext(fn)[1]])
700 except KeyError: 733 except KeyError:
701 self.__setClientType('Python3') # assume it is a Python3 file 734 self.__setClientType('Python3') # assume it is a Python3 file
702 self.startClient(False, forProject=forProject, runInConsole=runInConsole) 735 self.startClient(False, forProject=forProject,
736 runInConsole=runInConsole)
703 737
704 self.setCallTraceEnabled(enableCallTrace) 738 self.setCallTraceEnabled(enableCallTrace)
705 self.remoteEnvironment(env) 739 self.remoteEnvironment(env)
706 740
707 self.debuggerInterface.remoteLoad(fn, argv, wd, tracePython, autoContinue, 741 self.debuggerInterface.remoteLoad(fn, argv, wd, tracePython,
708 autoFork, forkChild) 742 autoContinue, autoFork, forkChild)
709 self.debugging = True 743 self.debugging = True
710 self.running = True 744 self.running = True
711 self.__restoreBreakpoints() 745 self.__restoreBreakpoints()
712 self.__restoreWatchpoints() 746 self.__restoreWatchpoints()
713 747
720 754
721 @param fn the filename to run (string) 755 @param fn the filename to run (string)
722 @param argv the commandline arguments to pass to the program (string) 756 @param argv the commandline arguments to pass to the program (string)
723 @param wd the working directory for the program (string) 757 @param wd the working directory for the program (string)
724 @param env environment settings (string) 758 @param env environment settings (string)
725 @keyparam autoClearShell flag indicating, that the interpreter window should 759 @keyparam autoClearShell flag indicating, that the interpreter window
726 be cleared (boolean) 760 should be cleared (boolean)
727 @keyparam forProject flag indicating a project related action (boolean) 761 @keyparam forProject flag indicating a project related action (boolean)
728 @keyparam runInConsole flag indicating to start the debugger in a 762 @keyparam runInConsole flag indicating to start the debugger in a
729 console window (boolean) 763 console window (boolean)
730 @keyparam autoFork flag indicating the automatic fork mode (boolean) 764 @keyparam autoFork flag indicating the automatic fork mode (boolean)
731 @keyparam forkChild flag indicating to debug the child after forking (boolean) 765 @keyparam forkChild flag indicating to debug the child after forking
766 (boolean)
732 @keyparam clientType client type to be used (string) 767 @keyparam clientType client type to be used (string)
733 """ 768 """
734 self.__autoClearShell = autoClearShell 769 self.__autoClearShell = autoClearShell
735 770
736 # Restart the client 771 # Restart the client
737 try: 772 try:
738 if clientType: 773 if clientType:
739 self.__setClientType(clientType) 774 self.__setClientType(clientType)
740 else: 775 else:
741 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 776 self.__setClientType(
777 self.__clientAssociations[os.path.splitext(fn)[1]])
742 except KeyError: 778 except KeyError:
743 self.__setClientType('Python3') # assume it is a Python3 file 779 self.__setClientType('Python3') # assume it is a Python3 file
744 self.startClient(False, forProject=forProject, runInConsole=runInConsole) 780 self.startClient(False, forProject=forProject,
781 runInConsole=runInConsole)
745 782
746 self.remoteEnvironment(env) 783 self.remoteEnvironment(env)
747 784
748 self.debuggerInterface.remoteRun(fn, argv, wd, autoFork, forkChild) 785 self.debuggerInterface.remoteRun(fn, argv, wd, autoFork, forkChild)
749 self.debugging = False 786 self.debugging = False
757 794
758 @param fn the filename to run (string) 795 @param fn the filename to run (string)
759 @param argv the commandline arguments to pass to the program (string) 796 @param argv the commandline arguments to pass to the program (string)
760 @param wd the working directory for the program (string) 797 @param wd the working directory for the program (string)
761 @param env environment settings (string) 798 @param env environment settings (string)
762 @keyparam autoClearShell flag indicating, that the interpreter window should 799 @keyparam autoClearShell flag indicating, that the interpreter window
763 be cleared (boolean) 800 should be cleared (boolean)
764 @keyparam erase flag indicating that coverage info should be 801 @keyparam erase flag indicating that coverage info should be
765 cleared first (boolean) 802 cleared first (boolean)
766 @keyparam forProject flag indicating a project related action (boolean) 803 @keyparam forProject flag indicating a project related action (boolean)
767 @keyparam runInConsole flag indicating to start the debugger in a 804 @keyparam runInConsole flag indicating to start the debugger in a
768 console window (boolean) 805 console window (boolean)
773 # Restart the client 810 # Restart the client
774 try: 811 try:
775 if clientType: 812 if clientType:
776 self.__setClientType(clientType) 813 self.__setClientType(clientType)
777 else: 814 else:
778 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 815 self.__setClientType(
816 self.__clientAssociations[os.path.splitext(fn)[1]])
779 except KeyError: 817 except KeyError:
780 self.__setClientType('Python3') # assume it is a Python3 file 818 self.__setClientType('Python3') # assume it is a Python3 file
781 self.startClient(False, forProject=forProject, runInConsole=runInConsole) 819 self.startClient(False, forProject=forProject,
820 runInConsole=runInConsole)
782 821
783 self.remoteEnvironment(env) 822 self.remoteEnvironment(env)
784 823
785 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase) 824 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase)
786 self.debugging = False 825 self.debugging = False
795 834
796 @param fn the filename to run (string) 835 @param fn the filename to run (string)
797 @param argv the commandline arguments to pass to the program (string) 836 @param argv the commandline arguments to pass to the program (string)
798 @param wd the working directory for the program (string) 837 @param wd the working directory for the program (string)
799 @param env environment settings (string) 838 @param env environment settings (string)
800 @keyparam autoClearShell flag indicating, that the interpreter window should 839 @keyparam autoClearShell flag indicating, that the interpreter window
801 be cleared (boolean) 840 should be cleared (boolean)
802 @keyparam erase flag indicating that timing info should be cleared first (boolean) 841 @keyparam erase flag indicating that timing info should be cleared
842 first (boolean)
803 @keyparam forProject flag indicating a project related action (boolean) 843 @keyparam forProject flag indicating a project related action (boolean)
804 @keyparam runInConsole flag indicating to start the debugger in a 844 @keyparam runInConsole flag indicating to start the debugger in a
805 console window (boolean) 845 console window (boolean)
806 @keyparam clientType client type to be used (string) 846 @keyparam clientType client type to be used (string)
807 """ 847 """
810 # Restart the client 850 # Restart the client
811 try: 851 try:
812 if clientType: 852 if clientType:
813 self.__setClientType(clientType) 853 self.__setClientType(clientType)
814 else: 854 else:
815 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 855 self.__setClientType(
856 self.__clientAssociations[os.path.splitext(fn)[1]])
816 except KeyError: 857 except KeyError:
817 self.__setClientType('Python3') # assume it is a Python3 file 858 self.__setClientType('Python3') # assume it is a Python3 file
818 self.startClient(False, forProject=forProject, runInConsole=runInConsole) 859 self.startClient(False, forProject=forProject,
860 runInConsole=runInConsole)
819 861
820 self.remoteEnvironment(env) 862 self.remoteEnvironment(env)
821 863
822 self.debuggerInterface.remoteProfile(fn, argv, wd, erase) 864 self.debuggerInterface.remoteProfile(fn, argv, wd, erase)
823 self.debugging = False 865 self.debugging = False
880 """ 922 """
881 Private method to enable or disable a breakpoint. 923 Private method to enable or disable a breakpoint.
882 924
883 @param fn filename the breakpoint belongs to (string) 925 @param fn filename the breakpoint belongs to (string)
884 @param line linenumber of the breakpoint (int) 926 @param line linenumber of the breakpoint (int)
885 @param enable flag indicating enabling or disabling a breakpoint (boolean) 927 @param enable flag indicating enabling or disabling a breakpoint
928 (boolean)
886 """ 929 """
887 self.debuggerInterface.remoteBreakpointEnable(fn, line, enable) 930 self.debuggerInterface.remoteBreakpointEnable(fn, line, enable)
888 931
889 def __remoteBreakpointIgnore(self, fn, line, count): 932 def __remoteBreakpointIgnore(self, fn, line, count):
890 """ 933 """
899 def __remoteWatchpoint(self, cond, set, temp=False): 942 def __remoteWatchpoint(self, cond, set, temp=False):
900 """ 943 """
901 Private method to set or clear a watch expression. 944 Private method to set or clear a watch expression.
902 945
903 @param cond expression of the watch expression (string) 946 @param cond expression of the watch expression (string)
904 @param set flag indicating setting or resetting a watch expression (boolean) 947 @param set flag indicating setting or resetting a watch expression
948 (boolean)
905 @param temp flag indicating a temporary watch expression (boolean) 949 @param temp flag indicating a temporary watch expression (boolean)
906 """ 950 """
907 # cond is combination of cond and special (s. watch expression viewer) 951 # cond is combination of cond and special (s. watch expression viewer)
908 self.debuggerInterface.remoteWatchpoint(cond, set, temp) 952 self.debuggerInterface.remoteWatchpoint(cond, set, temp)
909 953
910 def __remoteWatchpointEnable(self, cond, enable): 954 def __remoteWatchpointEnable(self, cond, enable):
911 """ 955 """
912 Private method to enable or disable a watch expression. 956 Private method to enable or disable a watch expression.
913 957
914 @param cond expression of the watch expression (string) 958 @param cond expression of the watch expression (string)
915 @param enable flag indicating enabling or disabling a watch expression (boolean) 959 @param enable flag indicating enabling or disabling a watch expression
960 (boolean)
916 """ 961 """
917 # cond is combination of cond and special (s. watch expression viewer) 962 # cond is combination of cond and special (s. watch expression viewer)
918 self.debuggerInterface.remoteWatchpointEnable(cond, enable) 963 self.debuggerInterface.remoteWatchpointEnable(cond, enable)
919 964
920 def __remoteWatchpointIgnore(self, cond, count): 965 def __remoteWatchpointIgnore(self, cond, count):
921 """ 966 """
922 Private method to ignore a watch expression the next couple of occurrences. 967 Private method to ignore a watch expression the next couple of
968 occurrences.
923 969
924 @param cond expression of the watch expression (string) 970 @param cond expression of the watch expression (string)
925 @param count number of occurrences to ignore (int) 971 @param count number of occurrences to ignore (int)
926 """ 972 """
927 # cond is combination of cond and special (s. watch expression viewer) 973 # cond is combination of cond and special (s. watch expression viewer)
967 @param scope the scope of the variables (0 = local, 1 = global) 1013 @param scope the scope of the variables (0 = local, 1 = global)
968 @param filter list of variable types to filter out (list of int) 1014 @param filter list of variable types to filter out (list of int)
969 @param var list encoded name of variable to retrieve (string) 1015 @param var list encoded name of variable to retrieve (string)
970 @param framenr framenumber of the variables to retrieve (int) 1016 @param framenr framenumber of the variables to retrieve (int)
971 """ 1017 """
972 self.debuggerInterface.remoteClientVariable(scope, filter, var, framenr) 1018 self.debuggerInterface.remoteClientVariable(
1019 scope, filter, var, framenr)
973 1020
974 def remoteClientSetFilter(self, scope, filter): 1021 def remoteClientSetFilter(self, scope, filter):
975 """ 1022 """
976 Public method to set a variables filter list. 1023 Public method to set a variables filter list.
977 1024
988 """ 1035 """
989 self.debuggerInterface.setCallTraceEnabled(on) 1036 self.debuggerInterface.setCallTraceEnabled(on)
990 1037
991 def remoteEval(self, arg): 1038 def remoteEval(self, arg):
992 """ 1039 """
993 Public method to evaluate arg in the current context of the debugged program. 1040 Public method to evaluate arg in the current context of the debugged
1041 program.
994 1042
995 @param arg the arguments to evaluate (string) 1043 @param arg the arguments to evaluate (string)
996 """ 1044 """
997 self.debuggerInterface.remoteEval(arg) 1045 self.debuggerInterface.remoteEval(arg)
998 1046
999 def remoteExec(self, stmt): 1047 def remoteExec(self, stmt):
1000 """ 1048 """
1001 Public method to execute stmt in the current context of the debugged program. 1049 Public method to execute stmt in the current context of the debugged
1050 program.
1002 1051
1003 @param stmt statement to execute (string) 1052 @param stmt statement to execute (string)
1004 """ 1053 """
1005 self.debuggerInterface.remoteExec(stmt) 1054 self.debuggerInterface.remoteExec(stmt)
1006 1055
1023 1072
1024 @param text the text to be completed (string) 1073 @param text the text to be completed (string)
1025 """ 1074 """
1026 self.debuggerInterface.remoteCompletion(text) 1075 self.debuggerInterface.remoteCompletion(text)
1027 1076
1028 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase, clientType=""): 1077 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase,
1078 clientType=""):
1029 """ 1079 """
1030 Public method to prepare a new unittest run. 1080 Public method to prepare a new unittest run.
1031 1081
1032 @param fn the filename to load (string) 1082 @param fn the filename to load (string)
1033 @param tn the testname to load (string) 1083 @param tn the testname to load (string)
1034 @param tfn the test function name to load tests from (string) 1084 @param tfn the test function name to load tests from (string)
1035 @param failed list of failed test, if only failed test should be run 1085 @param failed list of failed test, if only failed test should be run
1036 (list of strings) 1086 (list of strings)
1037 @param cov flag indicating collection of coverage data is requested (boolean) 1087 @param cov flag indicating collection of coverage data is requested
1088 (boolean)
1038 @param covname filename to be used to assemble the coverage caches 1089 @param covname filename to be used to assemble the coverage caches
1039 filename (string) 1090 filename (string)
1040 @param coverase flag indicating erasure of coverage data is requested (boolean) 1091 @param coverase flag indicating erasure of coverage data is requested
1092 (boolean)
1041 @keyparam clientType client type to be used (string) 1093 @keyparam clientType client type to be used (string)
1042 """ 1094 """
1043 # Restart the client if there is already a program loaded. 1095 # Restart the client if there is already a program loaded.
1044 try: 1096 try:
1045 if clientType: 1097 if clientType:
1046 self.__setClientType(clientType) 1098 self.__setClientType(clientType)
1047 else: 1099 else:
1048 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 1100 self.__setClientType(
1101 self.__clientAssociations[os.path.splitext(fn)[1]])
1049 except KeyError: 1102 except KeyError:
1050 self.__setClientType('Python3') # assume it is a Python3 file 1103 self.__setClientType('Python3') # assume it is a Python3 file
1051 self.startClient(False) 1104 self.startClient(False)
1052 1105
1053 self.debuggerInterface.remoteUTPrepare( 1106 self.debuggerInterface.remoteUTPrepare(
1112 1165
1113 def signalClientVariables(self, scope, variables): 1166 def signalClientVariables(self, scope, variables):
1114 """ 1167 """
1115 Public method to process the client variables info. 1168 Public method to process the client variables info.
1116 1169
1117 @param scope scope of the variables (-1 = empty global, 1 = global, 0 = local) 1170 @param scope scope of the variables (-1 = empty global, 1 = global,
1171 0 = local)
1118 @param variables the list of variables from the client 1172 @param variables the list of variables from the client
1119 """ 1173 """
1120 self.clientVariables.emit(scope, variables) 1174 self.clientVariables.emit(scope, variables)
1121 1175
1122 def signalClientVariable(self, scope, variables): 1176 def signalClientVariable(self, scope, variables):
1123 """ 1177 """
1124 Public method to process the client variable info. 1178 Public method to process the client variable info.
1125 1179
1126 @param scope scope of the variables (-1 = empty global, 1 = global, 0 = local) 1180 @param scope scope of the variables (-1 = empty global, 1 = global,
1181 0 = local)
1127 @param variables the list of members of a classvariable from the client 1182 @param variables the list of members of a classvariable from the client
1128 """ 1183 """
1129 self.clientVariable.emit(scope, variables) 1184 self.clientVariable.emit(scope, variables)
1130 1185
1131 def signalClientStatement(self, more): 1186 def signalClientStatement(self, more):
1134 1189
1135 @param more flag indicating that more user input is required 1190 @param more flag indicating that more user input is required
1136 """ 1191 """
1137 self.clientStatement.emit(more) 1192 self.clientStatement.emit(more)
1138 1193
1139 def signalClientException(self, exceptionType, exceptionMessage, stackTrace): 1194 def signalClientException(self, exceptionType, exceptionMessage,
1195 stackTrace):
1140 """ 1196 """
1141 Public method to process the exception info from the client. 1197 Public method to process the exception info from the client.
1142 1198
1143 @param exceptionType type of exception raised (string) 1199 @param exceptionType type of exception raised (string)
1144 @param exceptionMessage message given by the exception (string) 1200 @param exceptionMessage message given by the exception (string)
1145 @param stackTrace list of stack entries with the exception position 1201 @param stackTrace list of stack entries with the exception position
1146 first. Each stack entry is a list giving the filename and the linenumber. 1202 first. Each stack entry is a list giving the filename and the
1203 linenumber.
1147 """ 1204 """
1148 if self.running: 1205 if self.running:
1149 self.clientException.emit(exceptionType, exceptionMessage, stackTrace) 1206 self.clientException.emit(exceptionType, exceptionMessage,
1207 stackTrace)
1150 1208
1151 def signalClientSyntaxError(self, message, filename, lineNo, characterNo): 1209 def signalClientSyntaxError(self, message, filename, lineNo, characterNo):
1152 """ 1210 """
1153 Public method to process the syntax error info from the client. 1211 Public method to process the syntax error info from the client.
1154 1212
1155 @param message message of the syntax error (string) 1213 @param message message of the syntax error (string)
1156 @param filename translated filename of the syntax error position (string) 1214 @param filename translated filename of the syntax error position
1215 (string)
1157 @param lineNo line number of the syntax error position (integer) 1216 @param lineNo line number of the syntax error position (integer)
1158 @param characterNo character number of the syntax error position (integer) 1217 @param characterNo character number of the syntax error position
1218 (integer)
1159 """ 1219 """
1160 if self.running: 1220 if self.running:
1161 self.clientSyntaxError.emit(message, filename, lineNo, characterNo) 1221 self.clientSyntaxError.emit(message, filename, lineNo, characterNo)
1162 1222
1163 def signalClientExit(self, status): 1223 def signalClientExit(self, status):
1371 def __restoreBreakpoints(self): 1431 def __restoreBreakpoints(self):
1372 """ 1432 """
1373 Private method to restore the breakpoints after a restart. 1433 Private method to restore the breakpoints after a restart.
1374 """ 1434 """
1375 if self.debugging: 1435 if self.debugging:
1376 self.__addBreakPoints(QModelIndex(), 0, self.breakpointModel.rowCount() - 1) 1436 self.__addBreakPoints(
1437 QModelIndex(), 0, self.breakpointModel.rowCount() - 1)
1377 1438
1378 def __restoreWatchpoints(self): 1439 def __restoreWatchpoints(self):
1379 """ 1440 """
1380 Private method to restore the watch expressions after a restart. 1441 Private method to restore the watch expressions after a restart.
1381 """ 1442 """
1382 if self.debugging: 1443 if self.debugging:
1383 self.__addWatchPoints(QModelIndex(), 0, self.watchpointModel.rowCount() - 1) 1444 self.__addWatchPoints(
1445 QModelIndex(), 0, self.watchpointModel.rowCount() - 1)
1384 1446
1385 def getBreakPointModel(self): 1447 def getBreakPointModel(self):
1386 """ 1448 """
1387 Public slot to get a reference to the breakpoint model object. 1449 Public slot to get a reference to the breakpoint model object.
1388 1450
1392 1454
1393 def getWatchPointModel(self): 1455 def getWatchPointModel(self):
1394 """ 1456 """
1395 Public slot to get a reference to the watch expression model object. 1457 Public slot to get a reference to the watch expression model object.
1396 1458
1397 @return reference to the watch expression model object (WatchPointModel) 1459 @return reference to the watch expression model object
1460 (WatchPointModel)
1398 """ 1461 """
1399 return self.watchpointModel 1462 return self.watchpointModel
1400 1463
1401 def isConnected(self): 1464 def isConnected(self):
1402 """ 1465 """

eric ide

mercurial