Debugger/DebugServer.py

changeset 945
8cd4d08fa9f6
parent 893
5907b8d05b46
child 984
f4bddd7cf51e
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
27 "DebuggerInterfacePython", 27 "DebuggerInterfacePython",
28 "DebuggerInterfacePython3", 28 "DebuggerInterfacePython3",
29 "DebuggerInterfaceRuby", 29 "DebuggerInterfaceRuby",
30 "DebuggerInterfaceNone", 30 "DebuggerInterfaceNone",
31 ] 31 ]
32
32 33
33 class DebugServer(QTcpServer): 34 class DebugServer(QTcpServer):
34 """ 35 """
35 Class implementing the debug server embedded within the IDE. 36 Class implementing the debug server embedded within the IDE.
36 37
38 via stdout 39 via stdout
39 @signal clientProcessStderr(str) emitted after the client has sent some output 40 @signal clientProcessStderr(str) emitted after the client has sent some output
40 via stderr 41 via stderr
41 @signal clientOutput(str) emitted after the client has sent some output 42 @signal clientOutput(str) emitted after the client has sent some output
42 @signal clientRawInputSent() emitted after the data was sent to the debug client 43 @signal clientRawInputSent() emitted after the data was sent to the debug client
43 @signal clientLine(filename, lineno, forStack) emitted after the debug client 44 @signal clientLine(filename, lineno, forStack) emitted after the debug client
44 has executed a line of code 45 has executed a line of code
45 @signal clientStack(stack) emitted after the debug client has executed a 46 @signal clientStack(stack) emitted after the debug client has executed a
46 line of code 47 line of code
47 @signal clientThreadList(currentId, threadList) emitted after a thread list 48 @signal clientThreadList(currentId, threadList) emitted after a thread list
48 has been received 49 has been received
49 @signal clientThreadSet() emitted after the client has acknowledged the change 50 @signal clientThreadSet() emitted after the client has acknowledged the change
50 of the current thread 51 of the current thread
51 @signal clientVariables(scope, variables) emitted after a variables dump has 52 @signal clientVariables(scope, variables) emitted after a variables dump has
52 been received 53 been received
53 @signal clientVariable(scope, variables) emitted after a dump for one class 54 @signal clientVariable(scope, variables) emitted after a dump for one class
54 variable has been received 55 variable has been received
55 @signal clientStatement(bool) emitted after an interactive command has 56 @signal clientStatement(bool) emitted after an interactive command has
56 been executed. The parameter is 0 to indicate that the command is 57 been executed. The parameter is 0 to indicate that the command is
57 complete and 1 if it needs more input. 58 complete and 1 if it needs more input.
58 @signal clientException(exception) emitted after an exception occured on the 59 @signal clientException(exception) emitted after an exception occured on the
59 client side 60 client side
60 @signal clientSyntaxError(exception) emitted after a syntax error has been detected 61 @signal clientSyntaxError(exception) emitted after a syntax error has been detected
61 on the client side 62 on the client side
62 @signal clientExit(int) emitted with the exit status after the client has exited 63 @signal clientExit(int) emitted with the exit status after the client has exited
63 @signal clientClearBreak(filename, lineno) emitted after the debug client 64 @signal clientClearBreak(filename, lineno) emitted after the debug client
79 passive debug mode 80 passive debug mode
80 @signal clientGone(bool) emitted if the client went away (planned or unplanned) 81 @signal clientGone(bool) emitted if the client went away (planned or unplanned)
81 @signal utPrepared(nrTests, exc_type, exc_value) emitted after the client has 82 @signal utPrepared(nrTests, exc_type, exc_value) emitted after the client has
82 loaded a unittest suite 83 loaded a unittest suite
83 @signal utFinished() emitted after the client signalled the end of the unittest 84 @signal utFinished() emitted after the client signalled the end of the unittest
84 @signal utStartTest(testname, testdocu) emitted after the client has started 85 @signal utStartTest(testname, testdocu) emitted after the client has started
85 a test 86 a test
86 @signal utStopTest() emitted after the client has finished a test 87 @signal utStopTest() emitted after the client has finished a test
87 @signal utTestFailed(testname, exc_info) emitted after the client reported 88 @signal utTestFailed(testname, exc_info) emitted after the client reported
88 a failed test 89 a failed test
89 @signal utTestErrored(testname, exc_info) emitted after the client reported 90 @signal utTestErrored(testname, exc_info) emitted after the client reported
90 an errored test 91 an errored test
91 """ 92 """
92 clientClearBreak = pyqtSignal(str, int) 93 clientClearBreak = pyqtSignal(str, int)
93 clientClearWatch = pyqtSignal(str) 94 clientClearWatch = pyqtSignal(str)
94 clientGone = pyqtSignal(bool) 95 clientGone = pyqtSignal(bool)
128 129
129 # create our models 130 # create our models
130 self.breakpointModel = BreakPointModel(self) 131 self.breakpointModel = BreakPointModel(self)
131 self.watchpointModel = WatchPointModel(self) 132 self.watchpointModel = WatchPointModel(self)
132 self.watchSpecialCreated = \ 133 self.watchSpecialCreated = \
133 self.trUtf8("created", "must be same as in EditWatchpointDialog") 134 self.trUtf8("created", "must be same as in EditWatchpointDialog")
134 self.watchSpecialChanged = \ 135 self.watchSpecialChanged = \
135 self.trUtf8("changed", "must be same as in EditWatchpointDialog") 136 self.trUtf8("changed", "must be same as in EditWatchpointDialog")
136 137
137 self.networkInterface = Preferences.getDebugger("NetworkInterface") 138 self.networkInterface = Preferences.getDebugger("NetworkInterface")
138 if self.networkInterface == "all": 139 if self.networkInterface == "all":
139 hostAddress = QHostAddress("0.0.0.0")#QHostAddress.Any) 140 hostAddress = QHostAddress("0.0.0.0") # QHostAddress.Any)
140 elif self.networkInterface == "allv6": 141 elif self.networkInterface == "allv6":
141 hostAddress = QHostAddress("::")#QHostAddress.AnyIPv6) 142 hostAddress = QHostAddress("::") # QHostAddress.AnyIPv6)
142 else: 143 else:
143 hostAddress = QHostAddress(Preferences.getDebugger("NetworkInterface")) 144 hostAddress = QHostAddress(Preferences.getDebugger("NetworkInterface"))
144 if Preferences.getDebugger("PassiveDbgEnabled"): 145 if Preferences.getDebugger("PassiveDbgEnabled"):
145 socket = Preferences.getDebugger("PassiveDbgPort") # default: 42424 146 socket = Preferences.getDebugger("PassiveDbgPort") # default: 42424
146 self.listen(hostAddress, socket) 147 self.listen(hostAddress, socket)
147 self.passive = True 148 self.passive = True
148 self.passiveClientExited = False 149 self.passiveClientExited = False
149 else: 150 else:
150 self.listen(hostAddress) 151 self.listen(hostAddress)
223 self.__clientCapabilities[clientLanguage] = clientCapabilities 224 self.__clientCapabilities[clientLanguage] = clientCapabilities
224 for extension in clientExtensions: 225 for extension in clientExtensions:
225 if extension not in self.__clientAssociations: 226 if extension not in self.__clientAssociations:
226 self.__clientAssociations[extension] = clientLanguage 227 self.__clientAssociations[extension] = clientLanguage
227 228
228 def getSupportedLanguages(self, shellOnly = False): 229 def getSupportedLanguages(self, shellOnly=False):
229 """ 230 """
230 Public slot to return the supported programming languages. 231 Public slot to return the supported programming languages.
231 232
232 @param shellOnly flag indicating only languages supporting an 233 @param shellOnly flag indicating only languages supporting an
233 interactive shell should be returned 234 interactive shell should be returned
258 if lang == language: 259 if lang == language:
259 extensions.append(ext) 260 extensions.append(ext)
260 261
261 return tuple(extensions) 262 return tuple(extensions)
262 263
263 def __createDebuggerInterface(self, clientType = None): 264 def __createDebuggerInterface(self, clientType=None):
264 """ 265 """
265 Private slot to create the debugger interface object. 266 Private slot to create the debugger interface object.
266 267
267 @param clientType type of the client interface to be created (string) 268 @param clientType type of the client interface to be created (string)
268 """ 269 """
292 293
293 @param clType type of client to be started (string) 294 @param clType type of client to be started (string)
294 """ 295 """
295 if clType is not None and clType in self.getSupportedLanguages(): 296 if clType is not None and clType in self.getSupportedLanguages():
296 self.clientType = clType 297 self.clientType = clType
297 Preferences.Prefs.settings.setValue('DebugClient/Type', 298 Preferences.Prefs.settings.setValue('DebugClient/Type',
298 self.clientType) 299 self.clientType)
299 300
300 def startClient(self, unplanned = True, clType = None, forProject = False, 301 def startClient(self, unplanned=True, clType=None, forProject=False,
301 runInConsole = False): 302 runInConsole=False):
302 """ 303 """
303 Public method to start a debug client. 304 Public method to start a debug client.
304 305
305 @keyparam unplanned flag indicating that the client has died (boolean) 306 @keyparam unplanned flag indicating that the client has died (boolean)
306 @keyparam clType type of client to be started (string) 307 @keyparam clType type of client to be started (string)
307 @keyparam forProject flag indicating a project related action (boolean) 308 @keyparam forProject flag indicating a project related action (boolean)
308 @keyparam runInConsole flag indicating to start the debugger in a 309 @keyparam runInConsole flag indicating to start the debugger in a
309 console window (boolean) 310 console window (boolean)
310 """ 311 """
311 self.running = False 312 self.running = False
312 313
313 if not self.passive or not self.passiveClientExited: 314 if not self.passive or not self.passiveClientExited:
314 if self.debuggerInterface and self.debuggerInterface.isConnected(): 315 if self.debuggerInterface and self.debuggerInterface.isConnected():
315 self.shutdownServer() 316 self.shutdownServer()
316 self.clientGone.emit(unplanned and self.debugging) 317 self.clientGone.emit(unplanned and self.debugging)
317 318
318 if clType: 319 if clType:
333 self.__createDebuggerInterface() 334 self.__createDebuggerInterface()
334 if forProject: 335 if forProject:
335 project = e5App().getObject("Project") 336 project = e5App().getObject("Project")
336 if not project.isDebugPropertiesLoaded(): 337 if not project.isDebugPropertiesLoaded():
337 self.clientProcess, isNetworked = \ 338 self.clientProcess, isNetworked = \
338 self.debuggerInterface.startRemote(self.serverPort(), 339 self.debuggerInterface.startRemote(self.serverPort(),
339 runInConsole) 340 runInConsole)
340 else: 341 else:
341 self.clientProcess, isNetworked = \ 342 self.clientProcess, isNetworked = \
342 self.debuggerInterface.startRemoteForProject(self.serverPort(), 343 self.debuggerInterface.startRemoteForProject(self.serverPort(),
343 runInConsole) 344 runInConsole)
344 else: 345 else:
345 self.clientProcess, isNetworked = \ 346 self.clientProcess, isNetworked = \
346 self.debuggerInterface.startRemote(self.serverPort(), runInConsole) 347 self.debuggerInterface.startRemote(self.serverPort(), runInConsole)
347 348
367 368
368 def __clientProcessOutput(self): 369 def __clientProcessOutput(self):
369 """ 370 """
370 Private slot to process client output received via stdout. 371 Private slot to process client output received via stdout.
371 """ 372 """
372 output = str(self.clientProcess.readAllStandardOutput(), 373 output = str(self.clientProcess.readAllStandardOutput(),
373 Preferences.getSystem("IOEncoding"), 374 Preferences.getSystem("IOEncoding"),
374 'replace') 375 'replace')
375 self.clientProcessStdout.emit(output) 376 self.clientProcessStdout.emit(output)
376 377
377 def __clientProcessError(self): 378 def __clientProcessError(self):
378 """ 379 """
379 Private slot to process client output received via stderr. 380 Private slot to process client output received via stderr.
380 """ 381 """
381 error = str(self.clientProcess.readAllStandardError(), 382 error = str(self.clientProcess.readAllStandardError(),
382 Preferences.getSystem("IOEncoding"), 383 Preferences.getSystem("IOEncoding"),
383 'replace') 384 'replace')
384 self.clientProcessStderr.emit(error) 385 self.clientProcessStderr.emit(error)
385 386
386 def __clientClearBreakPoint(self, fn, lineno): 387 def __clientClearBreakPoint(self, fn, lineno):
387 """ 388 """
401 @param parentIndex index of parent item (QModelIndex) 402 @param parentIndex index of parent item (QModelIndex)
402 @param start start row (integer) 403 @param start start row (integer)
403 @param end end row (integer) 404 @param end end row (integer)
404 """ 405 """
405 if self.debugging: 406 if self.debugging:
406 for row in range(start, end+1): 407 for row in range(start, end + 1):
407 index = self.breakpointModel.index(row, 0, parentIndex) 408 index = self.breakpointModel.index(row, 0, parentIndex)
408 fn, lineno = self.breakpointModel.getBreakPointByIndex(index)[0:2] 409 fn, lineno = self.breakpointModel.getBreakPointByIndex(index)[0:2]
409 self.remoteBreakpoint(fn, lineno, False) 410 self.remoteBreakpoint(fn, lineno, False)
410 411
411 def __changeBreakPoints(self, startIndex, endIndex): 412 def __changeBreakPoints(self, startIndex, endIndex):
434 @param parentIndex index of parent item (QModelIndex) 435 @param parentIndex index of parent item (QModelIndex)
435 @param start start row (integer) 436 @param start start row (integer)
436 @param end end row (integer) 437 @param end end row (integer)
437 """ 438 """
438 if self.debugging: 439 if self.debugging:
439 for row in range(start, end+1): 440 for row in range(start, end + 1):
440 index = self.breakpointModel.index(row, 0, parentIndex) 441 index = self.breakpointModel.index(row, 0, parentIndex)
441 fn, line, cond, temp, enabled, ignorecount = \ 442 fn, line, cond, temp, enabled, ignorecount = \
442 self.breakpointModel.getBreakPointByIndex(index)[:6] 443 self.breakpointModel.getBreakPointByIndex(index)[:6]
443 self.remoteBreakpoint(fn, line, True, cond, temp) 444 self.remoteBreakpoint(fn, line, True, cond, temp)
444 if not enabled: 445 if not enabled:
500 @param parentIndex index of parent item (QModelIndex) 501 @param parentIndex index of parent item (QModelIndex)
501 @param start start row (integer) 502 @param start start row (integer)
502 @param end end row (integer) 503 @param end end row (integer)
503 """ 504 """
504 if self.debugging: 505 if self.debugging:
505 for row in range(start, end+1): 506 for row in range(start, end + 1):
506 index = self.watchpointModel.index(row, 0, parentIndex) 507 index = self.watchpointModel.index(row, 0, parentIndex)
507 cond, special = self.watchpointModel.getWatchPointByIndex(index)[0:2] 508 cond, special = self.watchpointModel.getWatchPointByIndex(index)[0:2]
508 cond = self.__makeWatchCondition(cond, special) 509 cond = self.__makeWatchCondition(cond, special)
509 self.__remoteWatchpoint(cond, False) 510 self.__remoteWatchpoint(cond, False)
510 511
511 def __watchPointDataAboutToBeChanged(self, startIndex, endIndex): 512 def __watchPointDataAboutToBeChanged(self, startIndex, endIndex):
512 """ 513 """
513 Private slot to handle the dataAboutToBeChanged signal of the 514 Private slot to handle the dataAboutToBeChanged signal of the
514 watch expression model. 515 watch expression model.
515 516
516 @param startIndex start index of the rows to be changed (QModelIndex) 517 @param startIndex start index of the rows to be changed (QModelIndex)
517 @param endIndex end index of the rows to be changed (QModelIndex) 518 @param endIndex end index of the rows to be changed (QModelIndex)
518 """ 519 """
572 res = E5MessageBox.yesNo(None, 573 res = E5MessageBox.yesNo(None,
573 self.trUtf8("Connection from illegal host"), 574 self.trUtf8("Connection from illegal host"),
574 self.trUtf8("""<p>A connection was attempted by the""" 575 self.trUtf8("""<p>A connection was attempted by the"""
575 """ illegal host <b>{0}</b>. Accept this connection?</p>""")\ 576 """ illegal host <b>{0}</b>. Accept this connection?</p>""")\
576 .format(peerAddress), 577 .format(peerAddress),
577 icon = E5MessageBox.Warning) 578 icon=E5MessageBox.Warning)
578 if not res: 579 if not res:
579 sock.abort() 580 sock.abort()
580 return 581 return
581 else: 582 else:
582 allowedHosts = Preferences.getDebugger("AllowedHosts") 583 allowedHosts = Preferences.getDebugger("AllowedHosts")
626 envdict[key] = value 627 envdict[key] = value
627 except UnpackError: 628 except UnpackError:
628 pass 629 pass
629 self.debuggerInterface.remoteEnvironment(envdict) 630 self.debuggerInterface.remoteEnvironment(envdict)
630 631
631 def remoteLoad(self, fn, argv, wd, env, autoClearShell = True, 632 def remoteLoad(self, fn, argv, wd, env, autoClearShell=True,
632 tracePython = False, autoContinue = True, forProject = False, 633 tracePython=False, autoContinue=True, forProject=False,
633 runInConsole = False, autoFork = False, forkChild = False, 634 runInConsole=False, autoFork=False, forkChild=False,
634 clientType = ""): 635 clientType=""):
635 """ 636 """
636 Public method to load a new program to debug. 637 Public method to load a new program to debug.
637 638
638 @param fn the filename to debug (string) 639 @param fn the filename to debug (string)
639 @param argv the commandline arguments to pass to the program (string) 640 @param argv the commandline arguments to pass to the program (string)
644 @keyparam tracePython flag indicating if the Python library should be traced 645 @keyparam tracePython flag indicating if the Python library should be traced
645 as well (boolean) 646 as well (boolean)
646 @keyparam autoContinue flag indicating, that the debugger should not stop 647 @keyparam autoContinue flag indicating, that the debugger should not stop
647 at the first executable line (boolean) 648 at the first executable line (boolean)
648 @keyparam forProject flag indicating a project related action (boolean) 649 @keyparam forProject flag indicating a project related action (boolean)
649 @keyparam runInConsole flag indicating to start the debugger in a 650 @keyparam runInConsole flag indicating to start the debugger in a
650 console window (boolean) 651 console window (boolean)
651 @keyparam autoFork flag indicating the automatic fork mode (boolean) 652 @keyparam autoFork flag indicating the automatic fork mode (boolean)
652 @keyparam forkChild flag indicating to debug the child after forking (boolean) 653 @keyparam forkChild flag indicating to debug the child after forking (boolean)
653 @keyparam clientType client type to be used (string) 654 @keyparam clientType client type to be used (string)
654 """ 655 """
661 self.__setClientType(clientType) 662 self.__setClientType(clientType)
662 else: 663 else:
663 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 664 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]])
664 except KeyError: 665 except KeyError:
665 self.__setClientType('Python3') # assume it is a Python3 file 666 self.__setClientType('Python3') # assume it is a Python3 file
666 self.startClient(False, forProject = forProject, runInConsole = runInConsole) 667 self.startClient(False, forProject=forProject, runInConsole=runInConsole)
667 668
668 self.remoteEnvironment(env) 669 self.remoteEnvironment(env)
669 670
670 self.debuggerInterface.remoteLoad(fn, argv, wd, tracePython, autoContinue, 671 self.debuggerInterface.remoteLoad(fn, argv, wd, tracePython, autoContinue,
671 autoFork, forkChild) 672 autoFork, forkChild)
672 self.debugging = True 673 self.debugging = True
673 self.running = True 674 self.running = True
674 self.__restoreBreakpoints() 675 self.__restoreBreakpoints()
675 self.__restoreWatchpoints() 676 self.__restoreWatchpoints()
676 677
677 def remoteRun(self, fn, argv, wd, env, autoClearShell = True, 678 def remoteRun(self, fn, argv, wd, env, autoClearShell=True,
678 forProject = False, runInConsole = False, 679 forProject=False, runInConsole=False,
679 autoFork = False, forkChild = False, 680 autoFork=False, forkChild=False,
680 clientType = ""): 681 clientType=""):
681 """ 682 """
682 Public method to load a new program to run. 683 Public method to load a new program to run.
683 684
684 @param fn the filename to run (string) 685 @param fn the filename to run (string)
685 @param argv the commandline arguments to pass to the program (string) 686 @param argv the commandline arguments to pass to the program (string)
686 @param wd the working directory for the program (string) 687 @param wd the working directory for the program (string)
687 @param env environment settings (string) 688 @param env environment settings (string)
688 @keyparam autoClearShell flag indicating, that the interpreter window should 689 @keyparam autoClearShell flag indicating, that the interpreter window should
689 be cleared (boolean) 690 be cleared (boolean)
690 @keyparam forProject flag indicating a project related action (boolean) 691 @keyparam forProject flag indicating a project related action (boolean)
691 @keyparam runInConsole flag indicating to start the debugger in a 692 @keyparam runInConsole flag indicating to start the debugger in a
692 console window (boolean) 693 console window (boolean)
693 @keyparam autoFork flag indicating the automatic fork mode (boolean) 694 @keyparam autoFork flag indicating the automatic fork mode (boolean)
694 @keyparam forkChild flag indicating to debug the child after forking (boolean) 695 @keyparam forkChild flag indicating to debug the child after forking (boolean)
695 @keyparam clientType client type to be used (string) 696 @keyparam clientType client type to be used (string)
696 """ 697 """
702 self.__setClientType(clientType) 703 self.__setClientType(clientType)
703 else: 704 else:
704 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 705 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]])
705 except KeyError: 706 except KeyError:
706 self.__setClientType('Python3') # assume it is a Python3 file 707 self.__setClientType('Python3') # assume it is a Python3 file
707 self.startClient(False, forProject = forProject, runInConsole = runInConsole) 708 self.startClient(False, forProject=forProject, runInConsole=runInConsole)
708 709
709 self.remoteEnvironment(env) 710 self.remoteEnvironment(env)
710 711
711 self.debuggerInterface.remoteRun(fn, argv, wd, autoFork, forkChild) 712 self.debuggerInterface.remoteRun(fn, argv, wd, autoFork, forkChild)
712 self.debugging = False 713 self.debugging = False
713 self.running = True 714 self.running = True
714 715
715 def remoteCoverage(self, fn, argv, wd, env, autoClearShell = True, 716 def remoteCoverage(self, fn, argv, wd, env, autoClearShell=True,
716 erase = False, forProject = False, runInConsole = False, 717 erase=False, forProject=False, runInConsole=False,
717 clientType = ""): 718 clientType=""):
718 """ 719 """
719 Public method to load a new program to collect coverage data. 720 Public method to load a new program to collect coverage data.
720 721
721 @param fn the filename to run (string) 722 @param fn the filename to run (string)
722 @param argv the commandline arguments to pass to the program (string) 723 @param argv the commandline arguments to pass to the program (string)
723 @param wd the working directory for the program (string) 724 @param wd the working directory for the program (string)
724 @param env environment settings (string) 725 @param env environment settings (string)
725 @keyparam autoClearShell flag indicating, that the interpreter window should 726 @keyparam autoClearShell flag indicating, that the interpreter window should
726 be cleared (boolean) 727 be cleared (boolean)
727 @keyparam erase flag indicating that coverage info should be 728 @keyparam erase flag indicating that coverage info should be
728 cleared first (boolean) 729 cleared first (boolean)
729 @keyparam forProject flag indicating a project related action (boolean) 730 @keyparam forProject flag indicating a project related action (boolean)
730 @keyparam runInConsole flag indicating to start the debugger in a 731 @keyparam runInConsole flag indicating to start the debugger in a
731 console window (boolean) 732 console window (boolean)
732 @keyparam clientType client type to be used (string) 733 @keyparam clientType client type to be used (string)
733 """ 734 """
734 self.__autoClearShell = autoClearShell 735 self.__autoClearShell = autoClearShell
735 736
739 self.__setClientType(clientType) 740 self.__setClientType(clientType)
740 else: 741 else:
741 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 742 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]])
742 except KeyError: 743 except KeyError:
743 self.__setClientType('Python3') # assume it is a Python3 file 744 self.__setClientType('Python3') # assume it is a Python3 file
744 self.startClient(False, forProject = forProject, runInConsole = runInConsole) 745 self.startClient(False, forProject=forProject, runInConsole=runInConsole)
745 746
746 self.remoteEnvironment(env) 747 self.remoteEnvironment(env)
747 748
748 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase) 749 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase)
749 self.debugging = False 750 self.debugging = False
750 self.running = True 751 self.running = True
751 752
752 def remoteProfile(self, fn, argv, wd, env, autoClearShell = True, 753 def remoteProfile(self, fn, argv, wd, env, autoClearShell=True,
753 erase = False, forProject = False, 754 erase=False, forProject=False,
754 runInConsole = False, 755 runInConsole=False,
755 clientType = ""): 756 clientType=""):
756 """ 757 """
757 Public method to load a new program to collect profiling data. 758 Public method to load a new program to collect profiling data.
758 759
759 @param fn the filename to run (string) 760 @param fn the filename to run (string)
760 @param argv the commandline arguments to pass to the program (string) 761 @param argv the commandline arguments to pass to the program (string)
762 @param env environment settings (string) 763 @param env environment settings (string)
763 @keyparam autoClearShell flag indicating, that the interpreter window should 764 @keyparam autoClearShell flag indicating, that the interpreter window should
764 be cleared (boolean) 765 be cleared (boolean)
765 @keyparam erase flag indicating that timing info should be cleared first (boolean) 766 @keyparam erase flag indicating that timing info should be cleared first (boolean)
766 @keyparam forProject flag indicating a project related action (boolean) 767 @keyparam forProject flag indicating a project related action (boolean)
767 @keyparam runInConsole flag indicating to start the debugger in a 768 @keyparam runInConsole flag indicating to start the debugger in a
768 console window (boolean) 769 console window (boolean)
769 @keyparam clientType client type to be used (string) 770 @keyparam clientType client type to be used (string)
770 """ 771 """
771 self.__autoClearShell = autoClearShell 772 self.__autoClearShell = autoClearShell
772 773
776 self.__setClientType(clientType) 777 self.__setClientType(clientType)
777 else: 778 else:
778 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]]) 779 self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]])
779 except KeyError: 780 except KeyError:
780 self.__setClientType('Python3') # assume it is a Python3 file 781 self.__setClientType('Python3') # assume it is a Python3 file
781 self.startClient(False, forProject = forProject, runInConsole = runInConsole) 782 self.startClient(False, forProject=forProject, runInConsole=runInConsole)
782 783
783 self.remoteEnvironment(env) 784 self.remoteEnvironment(env)
784 785
785 self.debuggerInterface.remoteProfile(fn, argv, wd, erase) 786 self.debuggerInterface.remoteProfile(fn, argv, wd, erase)
786 self.debugging = False 787 self.debugging = False
787 self.running = True 788 self.running = True
788 789
789 def remoteStatement(self, stmt): 790 def remoteStatement(self, stmt):
790 """ 791 """
791 Public method to execute a Python statement. 792 Public method to execute a Python statement.
792 793
793 @param stmt the Python statement to execute (string). It 794 @param stmt the Python statement to execute (string). It
794 should not have a trailing newline. 795 should not have a trailing newline.
795 """ 796 """
796 self.debuggerInterface.remoteStatement(stmt) 797 self.debuggerInterface.remoteStatement(stmt)
817 """ 818 """
818 Public method to stop the debugged program. 819 Public method to stop the debugged program.
819 """ 820 """
820 self.debuggerInterface.remoteStepQuit() 821 self.debuggerInterface.remoteStepQuit()
821 822
822 def remoteContinue(self, special = False): 823 def remoteContinue(self, special=False):
823 """ 824 """
824 Public method to continue the debugged program. 825 Public method to continue the debugged program.
825 826
826 @param special flag indicating a special continue operation 827 @param special flag indicating a special continue operation
827 """ 828 """
857 @param line linenumber of the breakpoint (int) 858 @param line linenumber of the breakpoint (int)
858 @param count number of occurrences to ignore (int) 859 @param count number of occurrences to ignore (int)
859 """ 860 """
860 self.debuggerInterface.remoteBreakpointIgnore(fn, line, count) 861 self.debuggerInterface.remoteBreakpointIgnore(fn, line, count)
861 862
862 def __remoteWatchpoint(self, cond, set, temp = False): 863 def __remoteWatchpoint(self, cond, set, temp=False):
863 """ 864 """
864 Private method to set or clear a watch expression. 865 Private method to set or clear a watch expression.
865 866
866 @param cond expression of the watch expression (string) 867 @param cond expression of the watch expression (string)
867 @param set flag indicating setting or resetting a watch expression (boolean) 868 @param set flag indicating setting or resetting a watch expression (boolean)
888 @param count number of occurrences to ignore (int) 889 @param count number of occurrences to ignore (int)
889 """ 890 """
890 # cond is combination of cond and special (s. watch expression viewer) 891 # cond is combination of cond and special (s. watch expression viewer)
891 self.debuggerInterface.remoteWatchpointIgnore(cond, count) 892 self.debuggerInterface.remoteWatchpointIgnore(cond, count)
892 893
893 def remoteRawInput(self,s): 894 def remoteRawInput(self, s):
894 """ 895 """
895 Public method to send the raw input to the debugged program. 896 Public method to send the raw input to the debugged program.
896 897
897 @param s the raw input (string) 898 @param s the raw input (string)
898 """ 899 """
911 912
912 @param tid id of the thread (integer) 913 @param tid id of the thread (integer)
913 """ 914 """
914 self.debuggerInterface.remoteSetThread(tid) 915 self.debuggerInterface.remoteSetThread(tid)
915 916
916 def remoteClientVariables(self, scope, filter, framenr = 0): 917 def remoteClientVariables(self, scope, filter, framenr=0):
917 """ 918 """
918 Public method to request the variables of the debugged program. 919 Public method to request the variables of the debugged program.
919 920
920 @param scope the scope of the variables (0 = local, 1 = global) 921 @param scope the scope of the variables (0 = local, 1 = global)
921 @param filter list of variable types to filter out (list of int) 922 @param filter list of variable types to filter out (list of int)
922 @param framenr framenumber of the variables to retrieve (int) 923 @param framenr framenumber of the variables to retrieve (int)
923 """ 924 """
924 self.debuggerInterface.remoteClientVariables(scope, filter, framenr) 925 self.debuggerInterface.remoteClientVariables(scope, filter, framenr)
925 926
926 def remoteClientVariable(self, scope, filter, var, framenr = 0): 927 def remoteClientVariable(self, scope, filter, var, framenr=0):
927 """ 928 """
928 Public method to request the variables of the debugged program. 929 Public method to request the variables of the debugged program.
929 930
930 @param scope the scope of the variables (0 = local, 1 = global) 931 @param scope the scope of the variables (0 = local, 1 = global)
931 @param filter list of variable types to filter out (list of int) 932 @param filter list of variable types to filter out (list of int)
1021 1022
1022 @param line client output (string) 1023 @param line client output (string)
1023 """ 1024 """
1024 self.clientOutput.emit(line) 1025 self.clientOutput.emit(line)
1025 1026
1026 def signalClientLine(self, filename, lineno, forStack = False): 1027 def signalClientLine(self, filename, lineno, forStack=False):
1027 """ 1028 """
1028 Public method to process client position feedback. 1029 Public method to process client position feedback.
1029 1030
1030 @param filename name of the file currently being executed (string) 1031 @param filename name of the file currently being executed (string)
1031 @param lineno line of code currently being executed (integer) 1032 @param lineno line of code currently being executed (integer)
1272 def __restoreBreakpoints(self): 1273 def __restoreBreakpoints(self):
1273 """ 1274 """
1274 Private method to restore the breakpoints after a restart. 1275 Private method to restore the breakpoints after a restart.
1275 """ 1276 """
1276 if self.debugging: 1277 if self.debugging:
1277 self.__addBreakPoints(QModelIndex(), 0, self.breakpointModel.rowCount()-1) 1278 self.__addBreakPoints(QModelIndex(), 0, self.breakpointModel.rowCount() - 1)
1278 1279
1279 def __restoreWatchpoints(self): 1280 def __restoreWatchpoints(self):
1280 """ 1281 """
1281 Private method to restore the watch expressions after a restart. 1282 Private method to restore the watch expressions after a restart.
1282 """ 1283 """
1283 if self.debugging: 1284 if self.debugging:
1284 self.__addWatchPoints(QModelIndex(), 0, self.watchpointModel.rowCount()-1) 1285 self.__addWatchPoints(QModelIndex(), 0, self.watchpointModel.rowCount() - 1)
1285 1286
1286 def getBreakPointModel(self): 1287 def getBreakPointModel(self):
1287 """ 1288 """
1288 Public slot to get a reference to the breakpoint model object. 1289 Public slot to get a reference to the breakpoint model object.
1289 1290

eric ide

mercurial