Debugger/DebuggerInterfacePython3.py

changeset 406
eacf81fad150
parent 112
16893e193e9d
child 465
c20e25deb33a
equal deleted inserted replaced
405:374066392929 406:eacf81fad150
36 exts = [] 36 exts = []
37 for ext in Preferences.getDebugger("Python3Extensions").split(): 37 for ext in Preferences.getDebugger("Python3Extensions").split():
38 if ext.startswith("."): 38 if ext.startswith("."):
39 exts.append(ext) 39 exts.append(ext)
40 else: 40 else:
41 exts.append(".%s" % ext) 41 exts.append(".{0}".format(ext))
42 42
43 if exts: 43 if exts:
44 return ["Python3", ClientDefaultCapabilities, exts] 44 return ["Python3", ClientDefaultCapabilities, exts]
45 else: 45 else:
46 return ["", 0, []] 46 return ["", 0, []]
119 """ 119 """
120 proc = QProcess() 120 proc = QProcess()
121 if environment is not None: 121 if environment is not None:
122 env = [] 122 env = []
123 for key, value in list(environment.items()): 123 for key, value in list(environment.items()):
124 env.append("%s=%s" % (key, value)) 124 env.append("{0}={1}".format(key, value))
125 proc.setEnvironment(env) 125 proc.setEnvironment(env)
126 args = [] 126 args = []
127 for arg in arguments: 127 for arg in arguments:
128 args.append(arg) 128 args.append(arg)
129 proc.start(program, args) 129 proc.start(program, args)
385 self.disconnect(self.qsock, SIGNAL('disconnected()'), 385 self.disconnect(self.qsock, SIGNAL('disconnected()'),
386 self.debugServer.startClient) 386 self.debugServer.startClient)
387 self.disconnect(self.qsock, SIGNAL('readyRead()'), self.__parseClientLine) 387 self.disconnect(self.qsock, SIGNAL('readyRead()'), self.__parseClientLine)
388 388
389 # close down socket, and shut down client as well. 389 # close down socket, and shut down client as well.
390 self.__sendCommand('%s\n' % RequestShutdown) 390 self.__sendCommand('{0}\n'.format(RequestShutdown))
391 self.qsock.flush() 391 self.qsock.flush()
392 392
393 self.qsock.close() 393 self.qsock.close()
394 394
395 # reinitialize 395 # reinitialize
408 """ 408 """
409 Public method to set the environment for a program to debug, run, ... 409 Public method to set the environment for a program to debug, run, ...
410 410
411 @param env environment settings (dictionary) 411 @param env environment settings (dictionary)
412 """ 412 """
413 self.__sendCommand('%s%s\n' % (RequestEnv, str(env))) 413 self.__sendCommand('{0}{1}\n'.format(RequestEnv, str(env)))
414 414
415 def remoteLoad(self, fn, argv, wd, traceInterpreter = False, autoContinue = True, 415 def remoteLoad(self, fn, argv, wd, traceInterpreter = False, autoContinue = True,
416 autoFork = False, forkChild = False): 416 autoFork = False, forkChild = False):
417 """ 417 """
418 Public method to load a new program to debug. 418 Public method to load a new program to debug.
429 """ 429 """
430 self.__autoContinue = autoContinue 430 self.__autoContinue = autoContinue
431 431
432 wd = self.translate(wd, False) 432 wd = self.translate(wd, False)
433 fn = self.translate(os.path.abspath(fn), False) 433 fn = self.translate(os.path.abspath(fn), False)
434 self.__sendCommand('%s%s\n' % (RequestForkMode, repr((autoFork, forkChild)))) 434 self.__sendCommand('{0}{1}\n'.format(RequestForkMode, repr((autoFork, forkChild))))
435 self.__sendCommand('%s%s|%s|%s|%d\n' % \ 435 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
436 (RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)), 436 RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)),
437 traceInterpreter)) 437 traceInterpreter))
438 438
439 def remoteRun(self, fn, argv, wd, autoFork = False, forkChild = False): 439 def remoteRun(self, fn, argv, wd, autoFork = False, forkChild = False):
440 """ 440 """
441 Public method to load a new program to run. 441 Public method to load a new program to run.
446 @keyparam autoFork flag indicating the automatic fork mode (boolean) 446 @keyparam autoFork flag indicating the automatic fork mode (boolean)
447 @keyparam forkChild flag indicating to debug the child after forking (boolean) 447 @keyparam forkChild flag indicating to debug the child after forking (boolean)
448 """ 448 """
449 wd = self.translate(wd, False) 449 wd = self.translate(wd, False)
450 fn = self.translate(os.path.abspath(fn), False) 450 fn = self.translate(os.path.abspath(fn), False)
451 self.__sendCommand('%s%s\n' % (RequestForkMode, repr((autoFork, forkChild)))) 451 self.__sendCommand('{0}{1}\n'.format(RequestForkMode, repr((autoFork, forkChild))))
452 self.__sendCommand('%s%s|%s|%s\n' % \ 452 self.__sendCommand('{0}{1}|{2}|{3}\n'.format(
453 (RequestRun, wd, fn, str(Utilities.parseOptionString(argv)))) 453 RequestRun, wd, fn, str(Utilities.parseOptionString(argv))))
454 454
455 def remoteCoverage(self, fn, argv, wd, erase = False): 455 def remoteCoverage(self, fn, argv, wd, erase = False):
456 """ 456 """
457 Public method to load a new program to collect coverage data. 457 Public method to load a new program to collect coverage data.
458 458
462 @keyparam erase flag indicating that coverage info should be 462 @keyparam erase flag indicating that coverage info should be
463 cleared first (boolean) 463 cleared first (boolean)
464 """ 464 """
465 wd = self.translate(wd, False) 465 wd = self.translate(wd, False)
466 fn = self.translate(os.path.abspath(fn), False) 466 fn = self.translate(os.path.abspath(fn), False)
467 self.__sendCommand('%s%s@@%s@@%s@@%d\n' % \ 467 self.__sendCommand('{0}{1}@@{2}@@{3}@@{4:d}\n'.format(
468 (RequestCoverage, wd, fn, str(Utilities.parseOptionString(argv)), 468 RequestCoverage, wd, fn, str(Utilities.parseOptionString(argv)),
469 erase)) 469 erase))
470 470
471 def remoteProfile(self, fn, argv, wd, erase = False): 471 def remoteProfile(self, fn, argv, wd, erase = False):
472 """ 472 """
473 Public method to load a new program to collect profiling data. 473 Public method to load a new program to collect profiling data.
477 @param wd the working directory for the program (string) 477 @param wd the working directory for the program (string)
478 @keyparam erase flag indicating that timing info should be cleared first (boolean) 478 @keyparam erase flag indicating that timing info should be cleared first (boolean)
479 """ 479 """
480 wd = self.translate(wd, False) 480 wd = self.translate(wd, False)
481 fn = self.translate(os.path.abspath(fn), False) 481 fn = self.translate(os.path.abspath(fn), False)
482 self.__sendCommand('%s%s|%s|%s|%d\n' % \ 482 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
483 (RequestProfile, wd, fn, str(Utilities.parseOptionString(argv)), erase)) 483 RequestProfile, wd, fn, str(Utilities.parseOptionString(argv)), erase))
484 484
485 def remoteStatement(self, stmt): 485 def remoteStatement(self, stmt):
486 """ 486 """
487 Public method to execute a Python statement. 487 Public method to execute a Python statement.
488 488
489 @param stmt the Python statement to execute (string). It 489 @param stmt the Python statement to execute (string). It
490 should not have a trailing newline. 490 should not have a trailing newline.
491 """ 491 """
492 self.__sendCommand('%s\n' % stmt) 492 self.__sendCommand('{0}\n'.format(stmt))
493 self.__sendCommand(RequestOK + '\n') 493 self.__sendCommand(RequestOK + '\n')
494 494
495 def remoteStep(self): 495 def remoteStep(self):
496 """ 496 """
497 Public method to single step the debugged program. 497 Public method to single step the debugged program.
520 """ 520 """
521 Public method to continue the debugged program. 521 Public method to continue the debugged program.
522 522
523 @param special flag indicating a special continue operation 523 @param special flag indicating a special continue operation
524 """ 524 """
525 self.__sendCommand('%s%d\n' % (RequestContinue, special)) 525 self.__sendCommand('{0}{1:d}\n'.format(RequestContinue, special))
526 526
527 def remoteBreakpoint(self, fn, line, set, cond = None, temp = False): 527 def remoteBreakpoint(self, fn, line, set, cond = None, temp = False):
528 """ 528 """
529 Public method to set or clear a breakpoint. 529 Public method to set or clear a breakpoint.
530 530
533 @param set flag indicating setting or resetting a breakpoint (boolean) 533 @param set flag indicating setting or resetting a breakpoint (boolean)
534 @param cond condition of the breakpoint (string) 534 @param cond condition of the breakpoint (string)
535 @param temp flag indicating a temporary breakpoint (boolean) 535 @param temp flag indicating a temporary breakpoint (boolean)
536 """ 536 """
537 fn = self.translate(fn, False) 537 fn = self.translate(fn, False)
538 self.__sendCommand('%s%s@@%d@@%d@@%d@@%s\n' % \ 538 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format(
539 (RequestBreak, fn, line, temp, set, cond)) 539 RequestBreak, fn, line, temp, set, cond))
540 540
541 def remoteBreakpointEnable(self, fn, line, enable): 541 def remoteBreakpointEnable(self, fn, line, enable):
542 """ 542 """
543 Public method to enable or disable a breakpoint. 543 Public method to enable or disable a breakpoint.
544 544
545 @param fn filename the breakpoint belongs to (string) 545 @param fn filename the breakpoint belongs to (string)
546 @param line linenumber of the breakpoint (int) 546 @param line linenumber of the breakpoint (int)
547 @param enable flag indicating enabling or disabling a breakpoint (boolean) 547 @param enable flag indicating enabling or disabling a breakpoint (boolean)
548 """ 548 """
549 fn = self.translate(fn, False) 549 fn = self.translate(fn, False)
550 self.__sendCommand('%s%s,%d,%d\n' % (RequestBreakEnable, fn, line, enable)) 550 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format(
551 RequestBreakEnable, fn, line, enable))
551 552
552 def remoteBreakpointIgnore(self, fn, line, count): 553 def remoteBreakpointIgnore(self, fn, line, count):
553 """ 554 """
554 Public method to ignore a breakpoint the next couple of occurrences. 555 Public method to ignore a breakpoint the next couple of occurrences.
555 556
556 @param fn filename the breakpoint belongs to (string) 557 @param fn filename the breakpoint belongs to (string)
557 @param line linenumber of the breakpoint (int) 558 @param line linenumber of the breakpoint (int)
558 @param count number of occurrences to ignore (int) 559 @param count number of occurrences to ignore (int)
559 """ 560 """
560 fn = self.translate(fn, False) 561 fn = self.translate(fn, False)
561 self.__sendCommand('%s%s,%d,%d\n' % (RequestBreakIgnore, fn, line, count)) 562 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format(
563 RequestBreakIgnore, fn, line, count))
562 564
563 def remoteWatchpoint(self, cond, set, temp = False): 565 def remoteWatchpoint(self, cond, set, temp = False):
564 """ 566 """
565 Public method to set or clear a watch expression. 567 Public method to set or clear a watch expression.
566 568
567 @param cond expression of the watch expression (string) 569 @param cond expression of the watch expression (string)
568 @param set flag indicating setting or resetting a watch expression (boolean) 570 @param set flag indicating setting or resetting a watch expression (boolean)
569 @param temp flag indicating a temporary watch expression (boolean) 571 @param temp flag indicating a temporary watch expression (boolean)
570 """ 572 """
571 # cond is combination of cond and special (s. watch expression viewer) 573 # cond is combination of cond and special (s. watch expression viewer)
572 self.__sendCommand('%s%s@@%d@@%d\n' % (RequestWatch, cond, temp, set)) 574 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}\n'.format(RequestWatch, cond, temp, set))
573 575
574 def remoteWatchpointEnable(self, cond, enable): 576 def remoteWatchpointEnable(self, cond, enable):
575 """ 577 """
576 Public method to enable or disable a watch expression. 578 Public method to enable or disable a watch expression.
577 579
578 @param cond expression of the watch expression (string) 580 @param cond expression of the watch expression (string)
579 @param enable flag indicating enabling or disabling a watch expression (boolean) 581 @param enable flag indicating enabling or disabling a watch expression (boolean)
580 """ 582 """
581 # cond is combination of cond and special (s. watch expression viewer) 583 # cond is combination of cond and special (s. watch expression viewer)
582 self.__sendCommand('%s%s,%d\n' % (RequestWatchEnable, cond, enable)) 584 self.__sendCommand('{0}{1},{2:d}\n'.format(RequestWatchEnable, cond, enable))
583 585
584 def remoteWatchpointIgnore(self, cond, count): 586 def remoteWatchpointIgnore(self, cond, count):
585 """ 587 """
586 Public method to ignore a watch expression the next couple of occurrences. 588 Public method to ignore a watch expression the next couple of occurrences.
587 589
588 @param cond expression of the watch expression (string) 590 @param cond expression of the watch expression (string)
589 @param count number of occurrences to ignore (int) 591 @param count number of occurrences to ignore (int)
590 """ 592 """
591 # cond is combination of cond and special (s. watch expression viewer) 593 # cond is combination of cond and special (s. watch expression viewer)
592 self.__sendCommand('%s%s,%d\n' % (RequestWatchIgnore, cond, count)) 594 self.__sendCommand('{0}{1},{2:d}\n'.format(RequestWatchIgnore, cond, count))
593 595
594 def remoteRawInput(self,s): 596 def remoteRawInput(self,s):
595 """ 597 """
596 Public method to send the raw input to the debugged program. 598 Public method to send the raw input to the debugged program.
597 599
601 603
602 def remoteThreadList(self): 604 def remoteThreadList(self):
603 """ 605 """
604 Public method to request the list of threads from the client. 606 Public method to request the list of threads from the client.
605 """ 607 """
606 self.__sendCommand('%s\n' % RequestThreadList) 608 self.__sendCommand('{0}\n'.format(RequestThreadList))
607 609
608 def remoteSetThread(self, tid): 610 def remoteSetThread(self, tid):
609 """ 611 """
610 Public method to request to set the given thread as current thread. 612 Public method to request to set the given thread as current thread.
611 613
612 @param tid id of the thread (integer) 614 @param tid id of the thread (integer)
613 """ 615 """
614 self.__sendCommand('%s%d\n' % (RequestThreadSet, tid)) 616 self.__sendCommand('{0}{1:d}\n'.format(RequestThreadSet, tid))
615 617
616 def remoteClientVariables(self, scope, filter, framenr = 0): 618 def remoteClientVariables(self, scope, filter, framenr = 0):
617 """ 619 """
618 Public method to request the variables of the debugged program. 620 Public method to request the variables of the debugged program.
619 621
620 @param scope the scope of the variables (0 = local, 1 = global) 622 @param scope the scope of the variables (0 = local, 1 = global)
621 @param filter list of variable types to filter out (list of int) 623 @param filter list of variable types to filter out (list of int)
622 @param framenr framenumber of the variables to retrieve (int) 624 @param framenr framenumber of the variables to retrieve (int)
623 """ 625 """
624 self.__sendCommand('%s%d, %d, %s\n' % \ 626 self.__sendCommand('{0}{1:d}, {2:d}, {3}\n'.format(
625 (RequestVariables, framenr, scope, str(filter))) 627 RequestVariables, framenr, scope, str(filter)))
626 628
627 def remoteClientVariable(self, scope, filter, var, framenr = 0): 629 def remoteClientVariable(self, scope, filter, var, framenr = 0):
628 """ 630 """
629 Public method to request the variables of the debugged program. 631 Public method to request the variables of the debugged program.
630 632
631 @param scope the scope of the variables (0 = local, 1 = global) 633 @param scope the scope of the variables (0 = local, 1 = global)
632 @param filter list of variable types to filter out (list of int) 634 @param filter list of variable types to filter out (list of int)
633 @param var list encoded name of variable to retrieve (string) 635 @param var list encoded name of variable to retrieve (string)
634 @param framenr framenumber of the variables to retrieve (int) 636 @param framenr framenumber of the variables to retrieve (int)
635 """ 637 """
636 self.__sendCommand('%s%s, %d, %d, %s\n' % \ 638 self.__sendCommand('{0}{1}, {2:d}, {3:d}, {4}\n'.format(
637 (RequestVariable, str(var), framenr, scope, str(filter))) 639 RequestVariable, str(var), framenr, scope, str(filter)))
638 640
639 def remoteClientSetFilter(self, scope, filter): 641 def remoteClientSetFilter(self, scope, filter):
640 """ 642 """
641 Public method to set a variables filter list. 643 Public method to set a variables filter list.
642 644
643 @param scope the scope of the variables (0 = local, 1 = global) 645 @param scope the scope of the variables (0 = local, 1 = global)
644 @param filter regexp string for variable names to filter out (string) 646 @param filter regexp string for variable names to filter out (string)
645 """ 647 """
646 self.__sendCommand('%s%d, "%s"\n' % (RequestSetFilter, scope, filter)) 648 self.__sendCommand('{0}{1:d}, "{2}"\n'.format(RequestSetFilter, scope, filter))
647 649
648 def remoteEval(self, arg): 650 def remoteEval(self, arg):
649 """ 651 """
650 Public method to evaluate arg in the current context of the debugged program. 652 Public method to evaluate arg in the current context of the debugged program.
651 653
652 @param arg the arguments to evaluate (string) 654 @param arg the arguments to evaluate (string)
653 """ 655 """
654 self.__sendCommand('%s%s\n' % (RequestEval, arg)) 656 self.__sendCommand('{0}{1}\n'.format(RequestEval, arg))
655 657
656 def remoteExec(self, stmt): 658 def remoteExec(self, stmt):
657 """ 659 """
658 Public method to execute stmt in the current context of the debugged program. 660 Public method to execute stmt in the current context of the debugged program.
659 661
660 @param stmt statement to execute (string) 662 @param stmt statement to execute (string)
661 """ 663 """
662 self.__sendCommand('%s%s\n' % (RequestExec, stmt)) 664 self.__sendCommand('{0}{1}\n'.format(RequestExec, stmt))
663 665
664 def remoteBanner(self): 666 def remoteBanner(self):
665 """ 667 """
666 Public slot to get the banner info of the remote client. 668 Public slot to get the banner info of the remote client.
667 """ 669 """
678 Public slot to get the a list of possible commandline completions 680 Public slot to get the a list of possible commandline completions
679 from the remote client. 681 from the remote client.
680 682
681 @param text the text to be completed (string) 683 @param text the text to be completed (string)
682 """ 684 """
683 self.__sendCommand("%s%s\n" % (RequestCompletion, text)) 685 self.__sendCommand("{0}{1}\n".format(RequestCompletion, text))
684 686
685 def remoteUTPrepare(self, fn, tn, tfn, cov, covname, coverase): 687 def remoteUTPrepare(self, fn, tn, tfn, cov, covname, coverase):
686 """ 688 """
687 Public method to prepare a new unittest run. 689 Public method to prepare a new unittest run.
688 690
693 @param covname filename to be used to assemble the coverage caches 695 @param covname filename to be used to assemble the coverage caches
694 filename 696 filename
695 @param coverase flag indicating erasure of coverage data is requested 697 @param coverase flag indicating erasure of coverage data is requested
696 """ 698 """
697 fn = self.translate(os.path.abspath(fn), False) 699 fn = self.translate(os.path.abspath(fn), False)
698 self.__sendCommand('%s%s|%s|%s|%d|%s|%d\n' % \ 700 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}|{5}|{6:d}\n'.format(
699 (RequestUTPrepare, fn, tn, tfn, cov, covname, coverase)) 701 RequestUTPrepare, fn, tn, tfn, cov, covname, coverase))
700 702
701 def remoteUTRun(self): 703 def remoteUTRun(self):
702 """ 704 """
703 Public method to start a unittest run. 705 Public method to start a unittest run.
704 """ 706 """
705 self.__sendCommand('%s\n' % RequestUTRun) 707 self.__sendCommand('{0}\n'.format(RequestUTRun))
706 708
707 def remoteUTStop(self): 709 def remoteUTStop(self):
708 """ 710 """
709 Public method to stop a unittest run. 711 Public method to stop a unittest run.
710 """ 712 """
711 self.__sendCommand('%s\n' % RequestUTStop) 713 self.__sendCommand('{0}\n'.format(RequestUTStop))
712 714
713 def __askForkTo(self): 715 def __askForkTo(self):
714 """ 716 """
715 Private method to ask the user which branch of a fork to follow. 717 Private method to ask the user which branch of a fork to follow.
716 """ 718 """

eric ide

mercurial