Debugger/DebuggerInterfacePython.py

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

eric ide

mercurial