Debugger/DebuggerInterfacePython.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2525
8b507a9a2d40
parent 2991
226481ff40d1
child 3058
0a02c433f52d
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
74 self.qsock = None 74 self.qsock = None
75 self.queue = [] 75 self.queue = []
76 # set default values for capabilities of clients 76 # set default values for capabilities of clients
77 self.clientCapabilities = ClientDefaultCapabilities 77 self.clientCapabilities = ClientDefaultCapabilities
78 78
79 self.codec = QTextCodec.codecForName(Preferences.getSystem("StringEncoding")) 79 self.codec = QTextCodec.codecForName(
80 Preferences.getSystem("StringEncoding"))
80 81
81 self.__unicodeRe = re.compile(r"""\bu(["'])""") 82 self.__unicodeRe = re.compile(r"""\bu(["'])""")
82 83
83 if passive: 84 if passive:
84 # set translation function 85 # set translation function
123 """ 124 """
124 Private method to start the debugger client process. 125 Private method to start the debugger client process.
125 126
126 @param program name of the executable to start (string) 127 @param program name of the executable to start (string)
127 @param arguments arguments to be passed to the program (list of string) 128 @param arguments arguments to be passed to the program (list of string)
128 @param environment dictionary of environment settings to pass (dict of string) 129 @param environment dictionary of environment settings to pass
130 (dict of string)
129 @return the process object (QProcess) or None 131 @return the process object (QProcess) or None
130 """ 132 """
131 proc = QProcess() 133 proc = QProcess()
132 if environment is not None: 134 if environment is not None:
133 env = [] 135 env = []
162 return None, False 164 return None, False
163 165
164 debugClientType = Preferences.getDebugger("DebugClientType") 166 debugClientType = Preferences.getDebugger("DebugClientType")
165 if debugClientType == "standard": 167 if debugClientType == "standard":
166 debugClient = os.path.join(getConfig('ericDir'), 168 debugClient = os.path.join(getConfig('ericDir'),
167 "DebugClients", "Python", "DebugClient.py") 169 "DebugClients", "Python",
170 "DebugClient.py")
168 elif debugClientType == "threaded": 171 elif debugClientType == "threaded":
169 debugClient = os.path.join(getConfig('ericDir'), 172 debugClient = os.path.join(getConfig('ericDir'),
170 "DebugClients", "Python", "DebugClientThreads.py") 173 "DebugClients", "Python",
174 "DebugClientThreads.py")
171 else: 175 else:
172 debugClient = Preferences.getDebugger("DebugClient") 176 debugClient = Preferences.getDebugger("DebugClient")
173 if debugClient == "": 177 if debugClient == "":
174 debugClient = os.path.join(sys.path[0], 178 debugClient = os.path.join(sys.path[0],
175 "DebugClients", "Python", "DebugClient.py") 179 "DebugClients", "Python",
180 "DebugClient.py")
176 181
177 redirect = str(Preferences.getDebugger("PythonRedirect")) 182 redirect = str(Preferences.getDebugger("PythonRedirect"))
178 noencoding = \ 183 noencoding = Preferences.getDebugger("PythonNoEncoding") and \
179 Preferences.getDebugger("PythonNoEncoding") and '--no-encoding' or '' 184 '--no-encoding' or ''
180 185
181 if Preferences.getDebugger("RemoteDbgEnabled"): 186 if Preferences.getDebugger("RemoteDbgEnabled"):
182 ipaddr = self.debugServer.getHostAddress(False) 187 ipaddr = self.debugServer.getHostAddress(False)
183 rexec = Preferences.getDebugger("RemoteExecution") 188 rexec = Preferences.getDebugger("RemoteExecution")
184 rhost = Preferences.getDebugger("RemoteHost") 189 rhost = Preferences.getDebugger("RemoteHost")
192 process = self.__startProcess(args[0], args[1:]) 197 process = self.__startProcess(args[0], args[1:])
193 if process is None: 198 if process is None:
194 E5MessageBox.critical(None, 199 E5MessageBox.critical(None,
195 self.trUtf8("Start Debugger"), 200 self.trUtf8("Start Debugger"),
196 self.trUtf8( 201 self.trUtf8(
197 """<p>The debugger backend could not be started.</p>""")) 202 """<p>The debugger backend could not be"""
203 """ started.</p>"""))
198 204
199 # set translation function 205 # set translation function
200 if Preferences.getDebugger("PathTranslation"): 206 if Preferences.getDebugger("PathTranslation"):
201 self.translateRemote = \ 207 self.translateRemote = \
202 Preferences.getDebugger("PathTranslationRemote") 208 Preferences.getDebugger("PathTranslationRemote")
237 process = self.__startProcess(args[0], args[1:], clientEnv) 243 process = self.__startProcess(args[0], args[1:], clientEnv)
238 if process is None: 244 if process is None:
239 E5MessageBox.critical(None, 245 E5MessageBox.critical(None,
240 self.trUtf8("Start Debugger"), 246 self.trUtf8("Start Debugger"),
241 self.trUtf8( 247 self.trUtf8(
242 """<p>The debugger backend could not be started.</p>""")) 248 """<p>The debugger backend could not be"""
249 """ started.</p>"""))
243 return process, self.__isNetworked 250 return process, self.__isNetworked
244 251
245 process = self.__startProcess(interpreter, 252 process = self.__startProcess(interpreter,
246 [debugClient, noencoding, str(port), redirect, ipaddr], 253 [debugClient, noencoding, str(port), redirect, ipaddr],
247 clientEnv) 254 clientEnv)
248 if process is None: 255 if process is None:
249 E5MessageBox.critical(None, 256 E5MessageBox.critical(None,
250 self.trUtf8("Start Debugger"), 257 self.trUtf8("Start Debugger"),
251 self.trUtf8("""<p>The debugger backend could not be started.</p>""")) 258 self.trUtf8(
259 """<p>The debugger backend could not be started.</p>"""))
252 return process, self.__isNetworked 260 return process, self.__isNetworked
253 261
254 def startRemoteForProject(self, port, runInConsole): 262 def startRemoteForProject(self, port, runInConsole):
255 """ 263 """
256 Public method to start a remote Python interpreter for a project. 264 Public method to start a remote Python interpreter for a project.
287 process = self.__startProcess(args[0], args[1:]) 295 process = self.__startProcess(args[0], args[1:])
288 if process is None: 296 if process is None:
289 E5MessageBox.critical(None, 297 E5MessageBox.critical(None,
290 self.trUtf8("Start Debugger"), 298 self.trUtf8("Start Debugger"),
291 self.trUtf8( 299 self.trUtf8(
292 """<p>The debugger backend could not be started.</p>""")) 300 """<p>The debugger backend could not be"""
301 """ started.</p>"""))
293 # set translation function 302 # set translation function
294 if project.getDebugProperty("PATHTRANSLATION"): 303 if project.getDebugProperty("PATHTRANSLATION"):
295 self.translateRemote = project.getDebugProperty("REMOTEPATH") 304 self.translateRemote = \
296 self.translateLocal = project.getDebugProperty("LOCALPATH") 305 project.getDebugProperty("REMOTEPATH")
306 self.translateLocal = \
307 project.getDebugProperty("LOCALPATH")
297 self.translate = self.__remoteTranslation 308 self.translate = self.__remoteTranslation
298 else: 309 else:
299 self.translate = self.__identityTranslation 310 self.translate = self.__identityTranslation
300 return process, self.__isNetworked 311 return process, self.__isNetworked
301 312
330 process = self.__startProcess(args[0], args[1:], clientEnv) 341 process = self.__startProcess(args[0], args[1:], clientEnv)
331 if process is None: 342 if process is None:
332 E5MessageBox.critical(None, 343 E5MessageBox.critical(None,
333 self.trUtf8("Start Debugger"), 344 self.trUtf8("Start Debugger"),
334 self.trUtf8( 345 self.trUtf8(
335 """<p>The debugger backend could not be started.</p>""")) 346 """<p>The debugger backend could not be"""
347 """ started.</p>"""))
336 return process, self.__isNetworked 348 return process, self.__isNetworked
337 349
338 process = self.__startProcess(interpreter, 350 process = self.__startProcess(interpreter,
339 [debugClient, noencoding, str(port), redirect, ipaddr], 351 [debugClient, noencoding, str(port), redirect, ipaddr],
340 clientEnv) 352 clientEnv)
341 if process is None: 353 if process is None:
342 E5MessageBox.critical(None, 354 E5MessageBox.critical(None,
343 self.trUtf8("Start Debugger"), 355 self.trUtf8("Start Debugger"),
344 self.trUtf8("""<p>The debugger backend could not be started.</p>""")) 356 self.trUtf8(
357 """<p>The debugger backend could not be started.</p>"""))
345 return process, self.__isNetworked 358 return process, self.__isNetworked
346 359
347 def getClientCapabilities(self): 360 def getClientCapabilities(self):
348 """ 361 """
349 Public method to retrieve the debug clients capabilities. 362 Public method to retrieve the debug clients capabilities.
419 """ 432 """
420 Public method to set the environment for a program to debug, run, ... 433 Public method to set the environment for a program to debug, run, ...
421 434
422 @param env environment settings (dictionary) 435 @param env environment settings (dictionary)
423 """ 436 """
424 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEnv, str(env))) 437 self.__sendCommand('{0}{1}\n'.format(
425 438 DebugProtocol.RequestEnv, str(env)))
426 def remoteLoad(self, fn, argv, wd, traceInterpreter=False, autoContinue=True, 439
427 autoFork=False, forkChild=False): 440 def remoteLoad(self, fn, argv, wd, traceInterpreter=False,
441 autoContinue=True, autoFork=False, forkChild=False):
428 """ 442 """
429 Public method to load a new program to debug. 443 Public method to load a new program to debug.
430 444
431 @param fn the filename to debug (string) 445 @param fn the filename to debug (string)
432 @param argv the commandline arguments to pass to the program (string) 446 @param argv the commandline arguments to pass to the program (string)
433 @param wd the working directory for the program (string) 447 @param wd the working directory for the program (string)
434 @keyparam traceInterpreter flag indicating if the interpreter library should be 448 @keyparam traceInterpreter flag indicating if the interpreter library
435 traced as well (boolean) 449 should be traced as well (boolean)
436 @keyparam autoContinue flag indicating, that the debugger should not stop 450 @keyparam autoContinue flag indicating, that the debugger should not
437 at the first executable line (boolean) 451 stop at the first executable line (boolean)
438 @keyparam autoFork flag indicating the automatic fork mode (boolean) 452 @keyparam autoFork flag indicating the automatic fork mode (boolean)
439 @keyparam forkChild flag indicating to debug the child after forking (boolean) 453 @keyparam forkChild flag indicating to debug the child after forking
454 (boolean)
440 """ 455 """
441 self.__autoContinue = autoContinue 456 self.__autoContinue = autoContinue
442 self.__scriptName = os.path.abspath(fn) 457 self.__scriptName = os.path.abspath(fn)
443 458
444 wd = self.translate(wd, False) 459 wd = self.translate(wd, False)
445 fn = self.translate(os.path.abspath(fn), False) 460 fn = self.translate(os.path.abspath(fn), False)
446 self.__sendCommand('{0}{1}\n'.format( 461 self.__sendCommand('{0}{1}\n'.format(
447 DebugProtocol.RequestForkMode, repr((autoFork, forkChild)))) 462 DebugProtocol.RequestForkMode, repr((autoFork, forkChild))))
448 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format( 463 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
449 DebugProtocol.RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)), 464 DebugProtocol.RequestLoad, wd, fn,
450 traceInterpreter)) 465 str(Utilities.parseOptionString(argv)),
466 traceInterpreter))
451 467
452 def remoteRun(self, fn, argv, wd, autoFork=False, forkChild=False): 468 def remoteRun(self, fn, argv, wd, autoFork=False, forkChild=False):
453 """ 469 """
454 Public method to load a new program to run. 470 Public method to load a new program to run.
455 471
456 @param fn the filename to run (string) 472 @param fn the filename to run (string)
457 @param argv the commandline arguments to pass to the program (string) 473 @param argv the commandline arguments to pass to the program (string)
458 @param wd the working directory for the program (string) 474 @param wd the working directory for the program (string)
459 @keyparam autoFork flag indicating the automatic fork mode (boolean) 475 @keyparam autoFork flag indicating the automatic fork mode (boolean)
460 @keyparam forkChild flag indicating to debug the child after forking (boolean) 476 @keyparam forkChild flag indicating to debug the child after forking
477 (boolean)
461 """ 478 """
462 self.__scriptName = os.path.abspath(fn) 479 self.__scriptName = os.path.abspath(fn)
463 480
464 wd = self.translate(wd, False) 481 wd = self.translate(wd, False)
465 fn = self.translate(os.path.abspath(fn), False) 482 fn = self.translate(os.path.abspath(fn), False)
466 self.__sendCommand('{0}{1}\n'.format( 483 self.__sendCommand('{0}{1}\n'.format(
467 DebugProtocol.RequestForkMode, repr((autoFork, forkChild)))) 484 DebugProtocol.RequestForkMode, repr((autoFork, forkChild))))
468 self.__sendCommand('{0}{1}|{2}|{3}\n'.format( 485 self.__sendCommand('{0}{1}|{2}|{3}\n'.format(
469 DebugProtocol.RequestRun, wd, fn, str(Utilities.parseOptionString(argv)))) 486 DebugProtocol.RequestRun, wd, fn,
487 str(Utilities.parseOptionString(argv))))
470 488
471 def remoteCoverage(self, fn, argv, wd, erase=False): 489 def remoteCoverage(self, fn, argv, wd, erase=False):
472 """ 490 """
473 Public method to load a new program to collect coverage data. 491 Public method to load a new program to collect coverage data.
474 492
481 self.__scriptName = os.path.abspath(fn) 499 self.__scriptName = os.path.abspath(fn)
482 500
483 wd = self.translate(wd, False) 501 wd = self.translate(wd, False)
484 fn = self.translate(os.path.abspath(fn), False) 502 fn = self.translate(os.path.abspath(fn), False)
485 self.__sendCommand('{0}{1}@@{2}@@{3}@@{4:d}\n'.format( 503 self.__sendCommand('{0}{1}@@{2}@@{3}@@{4:d}\n'.format(
486 DebugProtocol.RequestCoverage, wd, fn, str(Utilities.parseOptionString(argv)), 504 DebugProtocol.RequestCoverage, wd, fn,
487 erase)) 505 str(Utilities.parseOptionString(argv)), erase))
488 506
489 def remoteProfile(self, fn, argv, wd, erase=False): 507 def remoteProfile(self, fn, argv, wd, erase=False):
490 """ 508 """
491 Public method to load a new program to collect profiling data. 509 Public method to load a new program to collect profiling data.
492 510
493 @param fn the filename to run (string) 511 @param fn the filename to run (string)
494 @param argv the commandline arguments to pass to the program (string) 512 @param argv the commandline arguments to pass to the program (string)
495 @param wd the working directory for the program (string) 513 @param wd the working directory for the program (string)
496 @keyparam erase flag indicating that timing info should be cleared first (boolean) 514 @keyparam erase flag indicating that timing info should be cleared
515 first (boolean)
497 """ 516 """
498 self.__scriptName = os.path.abspath(fn) 517 self.__scriptName = os.path.abspath(fn)
499 518
500 wd = self.translate(wd, False) 519 wd = self.translate(wd, False)
501 fn = self.translate(os.path.abspath(fn), False) 520 fn = self.translate(os.path.abspath(fn), False)
541 """ 560 """
542 Public method to continue the debugged program. 561 Public method to continue the debugged program.
543 562
544 @param special flag indicating a special continue operation (boolean) 563 @param special flag indicating a special continue operation (boolean)
545 """ 564 """
546 self.__sendCommand('{0}{1:d}\n'.format(DebugProtocol.RequestContinue, special)) 565 self.__sendCommand('{0}{1:d}\n'.format(
566 DebugProtocol.RequestContinue, special))
547 567
548 def remoteBreakpoint(self, fn, line, set, cond=None, temp=False): 568 def remoteBreakpoint(self, fn, line, set, cond=None, temp=False):
549 """ 569 """
550 Public method to set or clear a breakpoint. 570 Public method to set or clear a breakpoint.
551 571
555 @param cond condition of the breakpoint (string) 575 @param cond condition of the breakpoint (string)
556 @param temp flag indicating a temporary breakpoint (boolean) 576 @param temp flag indicating a temporary breakpoint (boolean)
557 """ 577 """
558 fn = self.translate(fn, False) 578 fn = self.translate(fn, False)
559 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format( 579 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format(
560 DebugProtocol.RequestBreak, fn, line, temp, set, cond)) 580 DebugProtocol.RequestBreak, fn, line, temp, set,
581 cond))
561 582
562 def remoteBreakpointEnable(self, fn, line, enable): 583 def remoteBreakpointEnable(self, fn, line, enable):
563 """ 584 """
564 Public method to enable or disable a breakpoint. 585 Public method to enable or disable a breakpoint.
565 586
566 @param fn filename the breakpoint belongs to (string) 587 @param fn filename the breakpoint belongs to (string)
567 @param line linenumber of the breakpoint (int) 588 @param line linenumber of the breakpoint (int)
568 @param enable flag indicating enabling or disabling a breakpoint (boolean) 589 @param enable flag indicating enabling or disabling a breakpoint
590 (boolean)
569 """ 591 """
570 fn = self.translate(fn, False) 592 fn = self.translate(fn, False)
571 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format( 593 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format(
572 DebugProtocol.RequestBreakEnable, fn, line, enable)) 594 DebugProtocol.RequestBreakEnable, fn, line, enable))
573 595
586 def remoteWatchpoint(self, cond, set, temp=False): 608 def remoteWatchpoint(self, cond, set, temp=False):
587 """ 609 """
588 Public method to set or clear a watch expression. 610 Public method to set or clear a watch expression.
589 611
590 @param cond expression of the watch expression (string) 612 @param cond expression of the watch expression (string)
591 @param set flag indicating setting or resetting a watch expression (boolean) 613 @param set flag indicating setting or resetting a watch expression
614 (boolean)
592 @param temp flag indicating a temporary watch expression (boolean) 615 @param temp flag indicating a temporary watch expression (boolean)
593 """ 616 """
594 # cond is combination of cond and special (s. watch expression viewer) 617 # cond is combination of cond and special (s. watch expression viewer)
595 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}\n'.format( 618 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}\n'.format(
596 DebugProtocol.RequestWatch, cond, temp, set)) 619 DebugProtocol.RequestWatch, cond, temp, set))
598 def remoteWatchpointEnable(self, cond, enable): 621 def remoteWatchpointEnable(self, cond, enable):
599 """ 622 """
600 Public method to enable or disable a watch expression. 623 Public method to enable or disable a watch expression.
601 624
602 @param cond expression of the watch expression (string) 625 @param cond expression of the watch expression (string)
603 @param enable flag indicating enabling or disabling a watch expression (boolean) 626 @param enable flag indicating enabling or disabling a watch expression
627 (boolean)
604 """ 628 """
605 # cond is combination of cond and special (s. watch expression viewer) 629 # cond is combination of cond and special (s. watch expression viewer)
606 self.__sendCommand('{0}{1},{2:d}\n'.format( 630 self.__sendCommand('{0}{1},{2:d}\n'.format(
607 DebugProtocol.RequestWatchEnable, cond, enable)) 631 DebugProtocol.RequestWatchEnable, cond, enable))
608 632
609 def remoteWatchpointIgnore(self, cond, count): 633 def remoteWatchpointIgnore(self, cond, count):
610 """ 634 """
611 Public method to ignore a watch expression the next couple of occurrences. 635 Public method to ignore a watch expression the next couple of
636 occurrences.
612 637
613 @param cond expression of the watch expression (string) 638 @param cond expression of the watch expression (string)
614 @param count number of occurrences to ignore (int) 639 @param count number of occurrences to ignore (int)
615 """ 640 """
616 # cond is combination of cond and special (s. watch expression viewer) 641 # cond is combination of cond and special (s. watch expression viewer)
635 """ 660 """
636 Public method to request to set the given thread as current thread. 661 Public method to request to set the given thread as current thread.
637 662
638 @param tid id of the thread (integer) 663 @param tid id of the thread (integer)
639 """ 664 """
640 self.__sendCommand('{0}{1:d}\n'.format(DebugProtocol.RequestThreadSet, tid)) 665 self.__sendCommand('{0}{1:d}\n'.format(
666 DebugProtocol.RequestThreadSet, tid))
641 667
642 def remoteClientVariables(self, scope, filter, framenr=0): 668 def remoteClientVariables(self, scope, filter, framenr=0):
643 """ 669 """
644 Public method to request the variables of the debugged program. 670 Public method to request the variables of the debugged program.
645 671
658 @param filter list of variable types to filter out (list of int) 684 @param filter list of variable types to filter out (list of int)
659 @param var list encoded name of variable to retrieve (string) 685 @param var list encoded name of variable to retrieve (string)
660 @param framenr framenumber of the variables to retrieve (int) 686 @param framenr framenumber of the variables to retrieve (int)
661 """ 687 """
662 self.__sendCommand('{0}{1}, {2:d}, {3:d}, {4}\n'.format( 688 self.__sendCommand('{0}{1}, {2:d}, {3:d}, {4}\n'.format(
663 DebugProtocol.RequestVariable, str(var), framenr, scope, str(filter))) 689 DebugProtocol.RequestVariable, str(var), framenr, scope,
690 str(filter)))
664 691
665 def remoteClientSetFilter(self, scope, filter): 692 def remoteClientSetFilter(self, scope, filter):
666 """ 693 """
667 Public method to set a variables filter list. 694 Public method to set a variables filter list.
668 695
680 """ 707 """
681 if on: 708 if on:
682 cmd = "on" 709 cmd = "on"
683 else: 710 else:
684 cmd = "off" 711 cmd = "off"
685 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestCallTrace, cmd)) 712 self.__sendCommand('{0}{1}\n'.format(
713 DebugProtocol.RequestCallTrace, cmd))
686 714
687 def remoteEval(self, arg): 715 def remoteEval(self, arg):
688 """ 716 """
689 Public method to evaluate arg in the current context of the debugged program. 717 Public method to evaluate arg in the current context of the debugged
718 program.
690 719
691 @param arg the arguments to evaluate (string) 720 @param arg the arguments to evaluate (string)
692 """ 721 """
693 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEval, arg)) 722 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEval, arg))
694 723
695 def remoteExec(self, stmt): 724 def remoteExec(self, stmt):
696 """ 725 """
697 Public method to execute stmt in the current context of the debugged program. 726 Public method to execute stmt in the current context of the debugged
727 program.
698 728
699 @param stmt statement to execute (string) 729 @param stmt statement to execute (string)
700 """ 730 """
701 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestExec, stmt)) 731 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestExec, stmt))
702 732
717 Public slot to get the a list of possible commandline completions 747 Public slot to get the a list of possible commandline completions
718 from the remote client. 748 from the remote client.
719 749
720 @param text the text to be completed (string) 750 @param text the text to be completed (string)
721 """ 751 """
722 self.__sendCommand("{0}{1}\n".format(DebugProtocol.RequestCompletion, text)) 752 self.__sendCommand("{0}{1}\n".format(
753 DebugProtocol.RequestCompletion, text))
723 754
724 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase): 755 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase):
725 """ 756 """
726 Public method to prepare a new unittest run. 757 Public method to prepare a new unittest run.
727 758
728 @param fn the filename to load (string) 759 @param fn the filename to load (string)
729 @param tn the testname to load (string) 760 @param tn the testname to load (string)
730 @param tfn the test function name to load tests from (string) 761 @param tfn the test function name to load tests from (string)
731 @param failed list of failed test, if only failed test should be run 762 @param failed list of failed test, if only failed test should be run
732 (list of strings) 763 (list of strings)
733 @param cov flag indicating collection of coverage data is requested (boolean) 764 @param cov flag indicating collection of coverage data is requested
765 (boolean)
734 @param covname filename to be used to assemble the coverage caches 766 @param covname filename to be used to assemble the coverage caches
735 filename (string) 767 filename (string)
736 @param coverase flag indicating erasure of coverage data is requested (boolean) 768 @param coverase flag indicating erasure of coverage data is requested
769 (boolean)
737 """ 770 """
738 self.__scriptName = os.path.abspath(fn) 771 self.__scriptName = os.path.abspath(fn)
739 772
740 fn = self.translate(os.path.abspath(fn), False) 773 fn = self.translate(os.path.abspath(fn), False)
741 self.__sendCommand('{0}{1}|{2}|{3}|{4}|{5:d}|{6}|{7:d}\n'.format( 774 self.__sendCommand('{0}{1}|{2}|{3}|{4}|{5:d}|{6}|{7:d}\n'.format(
756 789
757 def __askForkTo(self): 790 def __askForkTo(self):
758 """ 791 """
759 Private method to ask the user which branch of a fork to follow. 792 Private method to ask the user which branch of a fork to follow.
760 """ 793 """
761 selections = [self.trUtf8("Parent Process"), self.trUtf8("Child process")] 794 selections = [self.trUtf8("Parent Process"),
795 self.trUtf8("Child process")]
762 res, ok = QInputDialog.getItem( 796 res, ok = QInputDialog.getItem(
763 None, 797 None,
764 self.trUtf8("Client forking"), 798 self.trUtf8("Client forking"),
765 self.trUtf8("Select the fork branch to follow."), 799 self.trUtf8("Select the fork branch to follow."),
766 selections, 800 selections,
812 cf = stack[0] 846 cf = stack[0]
813 if self.__autoContinue: 847 if self.__autoContinue:
814 self.__autoContinue = False 848 self.__autoContinue = False
815 QTimer.singleShot(0, self.remoteContinue) 849 QTimer.singleShot(0, self.remoteContinue)
816 else: 850 else:
817 self.debugServer.signalClientLine(cf[0], int(cf[1]), 851 self.debugServer.signalClientLine(
818 resp == DebugProtocol.ResponseStack) 852 cf[0], int(cf[1]),
853 resp == DebugProtocol.ResponseStack)
819 self.debugServer.signalClientStack(stack) 854 self.debugServer.signalClientStack(stack)
820 continue 855 continue
821 856
822 if resp == DebugProtocol.CallTrace: 857 if resp == DebugProtocol.CallTrace:
823 event, fromStr, toStr = line[eoc:-1].split("@@") 858 event, fromStr, toStr = line[eoc:-1].split("@@")
829 toFile, toLineno, toFunc) 864 toFile, toLineno, toFunc)
830 continue 865 continue
831 866
832 if resp == DebugProtocol.ResponseThreadList: 867 if resp == DebugProtocol.ResponseThreadList:
833 currentId, threadList = eval(evalArg) 868 currentId, threadList = eval(evalArg)
834 self.debugServer.signalClientThreadList(currentId, threadList) 869 self.debugServer.signalClientThreadList(
870 currentId, threadList)
835 continue 871 continue
836 872
837 if resp == DebugProtocol.ResponseThreadSet: 873 if resp == DebugProtocol.ResponseThreadSet:
838 self.debugServer.signalClientThreadSet() 874 self.debugServer.signalClientThreadSet()
839 continue 875 continue
881 break 917 break
882 except (IndexError, ValueError, SyntaxError): 918 except (IndexError, ValueError, SyntaxError):
883 exctype = None 919 exctype = None
884 excmessage = '' 920 excmessage = ''
885 stack = [] 921 stack = []
886 self.debugServer.signalClientException(exctype, excmessage, stack) 922 self.debugServer.signalClientException(
923 exctype, excmessage, stack)
887 continue 924 continue
888 925
889 if resp == DebugProtocol.ResponseSyntax: 926 if resp == DebugProtocol.ResponseSyntax:
890 exc = self.translate(evalArg, True) 927 exc = self.translate(evalArg, True)
891 try: 928 try:
897 fn = '' 934 fn = ''
898 ln = 0 935 ln = 0
899 cn = 0 936 cn = 0
900 if cn is None: 937 if cn is None:
901 cn = 0 938 cn = 0
902 self.debugServer.signalClientSyntaxError(message, fn, ln, cn) 939 self.debugServer.signalClientSyntaxError(
940 message, fn, ln, cn)
903 continue 941 continue
904 942
905 if resp == DebugProtocol.ResponseExit: 943 if resp == DebugProtocol.ResponseExit:
906 self.__scriptName = "" 944 self.__scriptName = ""
907 self.debugServer.signalClientExit(evalArg) 945 self.debugServer.signalClientExit(evalArg)
916 954
917 if resp == DebugProtocol.ResponseBPConditionError: 955 if resp == DebugProtocol.ResponseBPConditionError:
918 fn, lineno = evalArg.split(',') 956 fn, lineno = evalArg.split(',')
919 lineno = int(lineno) 957 lineno = int(lineno)
920 fn = self.translate(fn, True) 958 fn = self.translate(fn, True)
921 self.debugServer.signalClientBreakConditionError(fn, lineno) 959 self.debugServer.signalClientBreakConditionError(
960 fn, lineno)
922 continue 961 continue
923 962
924 if resp == DebugProtocol.ResponseClearWatch: 963 if resp == DebugProtocol.ResponseClearWatch:
925 self.debugServer.signalClientClearWatch(evalArg) 964 self.debugServer.signalClientClearWatch(evalArg)
926 continue 965 continue
934 self.debugServer.signalClientRawInput(prompt, echo) 973 self.debugServer.signalClientRawInput(prompt, echo)
935 continue 974 continue
936 975
937 if resp == DebugProtocol.ResponseBanner: 976 if resp == DebugProtocol.ResponseBanner:
938 version, platform, dbgclient = eval(evalArg) 977 version, platform, dbgclient = eval(evalArg)
939 self.debugServer.signalClientBanner(version, platform, dbgclient) 978 self.debugServer.signalClientBanner(
979 version, platform, dbgclient)
940 continue 980 continue
941 981
942 if resp == DebugProtocol.ResponseCapabilities: 982 if resp == DebugProtocol.ResponseCapabilities:
943 cap, clType = eval(evalArg) 983 cap, clType = eval(evalArg)
944 self.clientCapabilities = cap 984 self.clientCapabilities = cap
972 self.debugServer.clientUtStopTest() 1012 self.debugServer.clientUtStopTest()
973 continue 1013 continue
974 1014
975 if resp == DebugProtocol.ResponseUTTestFailed: 1015 if resp == DebugProtocol.ResponseUTTestFailed:
976 testname, traceback, id = eval(evalArg) 1016 testname, traceback, id = eval(evalArg)
977 self.debugServer.clientUtTestFailed(testname, traceback, id) 1017 self.debugServer.clientUtTestFailed(
1018 testname, traceback, id)
978 continue 1019 continue
979 1020
980 if resp == DebugProtocol.ResponseUTTestErrored: 1021 if resp == DebugProtocol.ResponseUTTestErrored:
981 testname, traceback, id = eval(evalArg) 1022 testname, traceback, id = eval(evalArg)
982 self.debugServer.clientUtTestErrored(testname, traceback, id) 1023 self.debugServer.clientUtTestErrored(
1024 testname, traceback, id)
983 continue 1025 continue
984 1026
985 if resp == DebugProtocol.ResponseUTTestSkipped: 1027 if resp == DebugProtocol.ResponseUTTestSkipped:
986 testname, reason, id = eval(line[eoc:-1]) 1028 testname, reason, id = eval(line[eoc:-1])
987 self.debugServer.clientUtTestSkipped(testname, reason, id) 1029 self.debugServer.clientUtTestSkipped(testname, reason, id)
988 continue 1030 continue
989 1031
990 if resp == DebugProtocol.ResponseUTTestFailedExpected: 1032 if resp == DebugProtocol.ResponseUTTestFailedExpected:
991 testname, traceback, id = eval(line[eoc:-1]) 1033 testname, traceback, id = eval(line[eoc:-1])
992 self.debugServer.clientUtTestFailedExpected(testname, traceback, id) 1034 self.debugServer.clientUtTestFailedExpected(
1035 testname, traceback, id)
993 continue 1036 continue
994 1037
995 if resp == DebugProtocol.ResponseUTTestSucceededUnexpected: 1038 if resp == DebugProtocol.ResponseUTTestSucceededUnexpected:
996 testname, id = eval(line[eoc:-1]) 1039 testname, id = eval(line[eoc:-1])
997 self.debugServer.clientUtTestSucceededUnexpected(testname, id) 1040 self.debugServer.clientUtTestSucceededUnexpected(
1041 testname, id)
998 continue 1042 continue
999 1043
1000 if resp == DebugProtocol.ResponseUTFinished: 1044 if resp == DebugProtocol.ResponseUTFinished:
1001 self.debugServer.clientUtFinished() 1045 self.debugServer.clientUtFinished()
1002 continue 1046 continue

eric ide

mercurial