5128:b6cbdba69967 | 5129:e4ab234cf071 |
---|---|
17 from PyQt5.QtWidgets import QInputDialog | 17 from PyQt5.QtWidgets import QInputDialog |
18 | 18 |
19 from E5Gui.E5Application import e5App | 19 from E5Gui.E5Application import e5App |
20 from E5Gui import E5MessageBox | 20 from E5Gui import E5MessageBox |
21 | 21 |
22 ##from . import DebugProtocol | |
23 from . import DebugClientCapabilities | 22 from . import DebugClientCapabilities |
24 | 23 |
25 import Preferences | 24 import Preferences |
26 import Utilities | 25 import Utilities |
27 | 26 |
28 from eric6config import getConfig | 27 from eric6config import getConfig |
29 | 28 |
30 | 29 |
31 ClientDefaultCapabilities = DebugClientCapabilities.HasAll | 30 ClientDefaultCapabilities = DebugClientCapabilities.HasAll |
32 ##EOT = '>EOT<\n' | |
33 | 31 |
34 | 32 |
35 class DebuggerInterfacePython3(QObject): | 33 class DebuggerInterfacePython3(QObject): |
36 """ | 34 """ |
37 Class implementing the Python debugger interface for the debug server. | 35 Class implementing the Python debugger interface for the debug server. |
403 # do not want any slots called during shutdown | 401 # do not want any slots called during shutdown |
404 self.qsock.disconnected.disconnect(self.debugServer.startClient) | 402 self.qsock.disconnected.disconnect(self.debugServer.startClient) |
405 self.qsock.readyRead.disconnect(self.__parseClientLine) | 403 self.qsock.readyRead.disconnect(self.__parseClientLine) |
406 | 404 |
407 # close down socket, and shut down client as well. | 405 # close down socket, and shut down client as well. |
408 ## self.__sendCommand('{0}\n'.format(DebugProtocol.RequestShutdown)) | |
409 self.__sendJsonCommand("RequestShutdown", {}) | 406 self.__sendJsonCommand("RequestShutdown", {}) |
410 self.qsock.flush() | 407 self.qsock.flush() |
411 | 408 |
412 self.qsock.close() | 409 self.qsock.close() |
413 | 410 |
427 """ | 424 """ |
428 Public method to set the environment for a program to debug, run, ... | 425 Public method to set the environment for a program to debug, run, ... |
429 | 426 |
430 @param env environment settings (dictionary) | 427 @param env environment settings (dictionary) |
431 """ | 428 """ |
432 ## self.__sendCommand('{0}{1}\n'.format( | |
433 ## DebugProtocol.RequestEnv, str(env))) | |
434 self.__sendJsonCommand("RequestEnvironment", {"environment": env}) | 429 self.__sendJsonCommand("RequestEnvironment", {"environment": env}) |
435 | 430 |
436 def remoteLoad(self, fn, argv, wd, traceInterpreter=False, | 431 def remoteLoad(self, fn, argv, wd, traceInterpreter=False, |
437 autoContinue=True, autoFork=False, forkChild=False): | 432 autoContinue=True, autoFork=False, forkChild=False): |
438 """ | 433 """ |
452 self.__autoContinue = autoContinue | 447 self.__autoContinue = autoContinue |
453 self.__scriptName = os.path.abspath(fn) | 448 self.__scriptName = os.path.abspath(fn) |
454 | 449 |
455 wd = self.translate(wd, False) | 450 wd = self.translate(wd, False) |
456 fn = self.translate(os.path.abspath(fn), False) | 451 fn = self.translate(os.path.abspath(fn), False) |
457 ## self.__sendCommand('{0}{1}\n'.format( | |
458 ## DebugProtocol.RequestForkMode, repr((autoFork, forkChild)))) | |
459 ## self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format( | |
460 ## DebugProtocol.RequestLoad, wd, fn, | |
461 ## str(Utilities.parseOptionString(argv)), | |
462 ## traceInterpreter)) | |
463 self.__sendJsonCommand("RequestLoad", { | 452 self.__sendJsonCommand("RequestLoad", { |
464 "workdir": wd, | 453 "workdir": wd, |
465 "filename": fn, | 454 "filename": fn, |
466 "argv": Utilities.parseOptionString(argv), | 455 "argv": Utilities.parseOptionString(argv), |
467 "traceInterpreter": traceInterpreter, | 456 "traceInterpreter": traceInterpreter, |
482 """ | 471 """ |
483 self.__scriptName = os.path.abspath(fn) | 472 self.__scriptName = os.path.abspath(fn) |
484 | 473 |
485 wd = self.translate(wd, False) | 474 wd = self.translate(wd, False) |
486 fn = self.translate(os.path.abspath(fn), False) | 475 fn = self.translate(os.path.abspath(fn), False) |
487 ## self.__sendCommand('{0}{1}\n'.format( | |
488 ## DebugProtocol.RequestForkMode, repr((autoFork, forkChild)))) | |
489 ## self.__sendCommand('{0}{1}|{2}|{3}\n'.format( | |
490 ## DebugProtocol.RequestRun, wd, fn, | |
491 ## str(Utilities.parseOptionString(argv)))) | |
492 self.__sendJsonCommand("RequestRun", { | 476 self.__sendJsonCommand("RequestRun", { |
493 "workdir": wd, | 477 "workdir": wd, |
494 "filename": fn, | 478 "filename": fn, |
495 "argv": Utilities.parseOptionString(argv), | 479 "argv": Utilities.parseOptionString(argv), |
496 "autofork": autoFork, | 480 "autofork": autoFork, |
509 """ | 493 """ |
510 self.__scriptName = os.path.abspath(fn) | 494 self.__scriptName = os.path.abspath(fn) |
511 | 495 |
512 wd = self.translate(wd, False) | 496 wd = self.translate(wd, False) |
513 fn = self.translate(os.path.abspath(fn), False) | 497 fn = self.translate(os.path.abspath(fn), False) |
514 ## self.__sendCommand('{0}{1}@@{2}@@{3}@@{4:d}\n'.format( | |
515 ## DebugProtocol.RequestCoverage, wd, fn, | |
516 ## str(Utilities.parseOptionString(argv)), | |
517 ## erase)) | |
518 self.__sendJsonCommand("RequestCoverage", { | 498 self.__sendJsonCommand("RequestCoverage", { |
519 "workdir": wd, | 499 "workdir": wd, |
520 "filename": fn, | 500 "filename": fn, |
521 "argv": Utilities.parseOptionString(argv), | 501 "argv": Utilities.parseOptionString(argv), |
522 "erase": erase, | 502 "erase": erase, |
534 """ | 514 """ |
535 self.__scriptName = os.path.abspath(fn) | 515 self.__scriptName = os.path.abspath(fn) |
536 | 516 |
537 wd = self.translate(wd, False) | 517 wd = self.translate(wd, False) |
538 fn = self.translate(os.path.abspath(fn), False) | 518 fn = self.translate(os.path.abspath(fn), False) |
539 ## self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format( | |
540 ## DebugProtocol.RequestProfile, wd, fn, | |
541 ## str(Utilities.parseOptionString(argv)), erase)) | |
542 self.__sendJsonCommand("RequestProfile", { | 519 self.__sendJsonCommand("RequestProfile", { |
543 "workdir": wd, | 520 "workdir": wd, |
544 "filename": fn, | 521 "filename": fn, |
545 "argv": Utilities.parseOptionString(argv), | 522 "argv": Utilities.parseOptionString(argv), |
546 "erase": erase, | 523 "erase": erase, |
551 Public method to execute a Python statement. | 528 Public method to execute a Python statement. |
552 | 529 |
553 @param stmt the Python statement to execute (string). It | 530 @param stmt the Python statement to execute (string). It |
554 should not have a trailing newline. | 531 should not have a trailing newline. |
555 """ | 532 """ |
556 ## self.__sendCommand('{0}\n'.format(stmt)) | |
557 ## self.__sendCommand(DebugProtocol.RequestOK + '\n') | |
558 self.__sendJsonCommand("ExecuteStatement", { | 533 self.__sendJsonCommand("ExecuteStatement", { |
559 "statement": stmt, | 534 "statement": stmt, |
560 }) | 535 }) |
561 | 536 |
562 def remoteStep(self): | 537 def remoteStep(self): |
563 """ | 538 """ |
564 Public method to single step the debugged program. | 539 Public method to single step the debugged program. |
565 """ | 540 """ |
566 ## self.__sendCommand(DebugProtocol.RequestStep + '\n') | |
567 self.__sendJsonCommand("RequestStep", {}) | 541 self.__sendJsonCommand("RequestStep", {}) |
568 | 542 |
569 def remoteStepOver(self): | 543 def remoteStepOver(self): |
570 """ | 544 """ |
571 Public method to step over the debugged program. | 545 Public method to step over the debugged program. |
572 """ | 546 """ |
573 ## self.__sendCommand(DebugProtocol.RequestStepOver + '\n') | |
574 self.__sendJsonCommand("RequestStepOver", {}) | 547 self.__sendJsonCommand("RequestStepOver", {}) |
575 | 548 |
576 def remoteStepOut(self): | 549 def remoteStepOut(self): |
577 """ | 550 """ |
578 Public method to step out the debugged program. | 551 Public method to step out the debugged program. |
579 """ | 552 """ |
580 ## self.__sendCommand(DebugProtocol.RequestStepOut + '\n') | |
581 self.__sendJsonCommand("RequestStepOut", {}) | 553 self.__sendJsonCommand("RequestStepOut", {}) |
582 | 554 |
583 def remoteStepQuit(self): | 555 def remoteStepQuit(self): |
584 """ | 556 """ |
585 Public method to stop the debugged program. | 557 Public method to stop the debugged program. |
586 """ | 558 """ |
587 ## self.__sendCommand(DebugProtocol.RequestStepQuit + '\n') | |
588 self.__sendJsonCommand("RequestStepQuit", {}) | 559 self.__sendJsonCommand("RequestStepQuit", {}) |
589 | 560 |
590 def remoteContinue(self, special=False): | 561 def remoteContinue(self, special=False): |
591 """ | 562 """ |
592 Public method to continue the debugged program. | 563 Public method to continue the debugged program. |
593 | 564 |
594 @param special flag indicating a special continue operation | 565 @param special flag indicating a special continue operation |
595 """ | 566 """ |
596 ## self.__sendCommand('{0}{1:d}\n'.format( | |
597 ## DebugProtocol.RequestContinue, special)) | |
598 self.__sendJsonCommand("RequestContinue", { | 567 self.__sendJsonCommand("RequestContinue", { |
599 "special": special, | 568 "special": special, |
600 }) | 569 }) |
601 | 570 |
602 def remoteBreakpoint(self, fn, line, setBreakpoint, cond=None, temp=False): | 571 def remoteBreakpoint(self, fn, line, setBreakpoint, cond=None, temp=False): |
608 @param setBreakpoint flag indicating setting or resetting a | 577 @param setBreakpoint flag indicating setting or resetting a |
609 breakpoint (boolean) | 578 breakpoint (boolean) |
610 @param cond condition of the breakpoint (string) | 579 @param cond condition of the breakpoint (string) |
611 @param temp flag indicating a temporary breakpoint (boolean) | 580 @param temp flag indicating a temporary breakpoint (boolean) |
612 """ | 581 """ |
613 ## fn = self.translate(fn, False) | |
614 ## self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format( | |
615 ## DebugProtocol.RequestBreak, fn, line, temp, set, cond)) | |
616 self.__sendJsonCommand("RequestBreakpoint", { | 582 self.__sendJsonCommand("RequestBreakpoint", { |
617 "filename": self.translate(fn, False), | 583 "filename": self.translate(fn, False), |
618 "line": line, | 584 "line": line, |
619 "temporary": temp, | 585 "temporary": temp, |
620 "setBreakpoint": setBreakpoint, | 586 "setBreakpoint": setBreakpoint, |
628 @param fn filename the breakpoint belongs to (string) | 594 @param fn filename the breakpoint belongs to (string) |
629 @param line linenumber of the breakpoint (int) | 595 @param line linenumber of the breakpoint (int) |
630 @param enable flag indicating enabling or disabling a breakpoint | 596 @param enable flag indicating enabling or disabling a breakpoint |
631 (boolean) | 597 (boolean) |
632 """ | 598 """ |
633 ## fn = self.translate(fn, False) | |
634 ## self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format( | |
635 ## DebugProtocol.RequestBreakEnable, fn, line, enable)) | |
636 self.__sendJsonCommand("RequestBreakpointEnable", { | 599 self.__sendJsonCommand("RequestBreakpointEnable", { |
637 "filename": self.translate(fn, False), | 600 "filename": self.translate(fn, False), |
638 "line": line, | 601 "line": line, |
639 "enable": enable, | 602 "enable": enable, |
640 }) | 603 }) |
645 | 608 |
646 @param fn filename the breakpoint belongs to (string) | 609 @param fn filename the breakpoint belongs to (string) |
647 @param line linenumber of the breakpoint (int) | 610 @param line linenumber of the breakpoint (int) |
648 @param count number of occurrences to ignore (int) | 611 @param count number of occurrences to ignore (int) |
649 """ | 612 """ |
650 ## fn = self.translate(fn, False) | |
651 ## self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format( | |
652 ## DebugProtocol.RequestBreakIgnore, fn, line, count)) | |
653 self.__sendJsonCommand("RequestBreakpointIgnore", { | 613 self.__sendJsonCommand("RequestBreakpointIgnore", { |
654 "filename": self.translate(fn, False), | 614 "filename": self.translate(fn, False), |
655 "line": line, | 615 "line": line, |
656 "count": count, | 616 "count": count, |
657 }) | 617 }) |
664 @param setWatch flag indicating setting or resetting a watch expression | 624 @param setWatch flag indicating setting or resetting a watch expression |
665 (boolean) | 625 (boolean) |
666 @param temp flag indicating a temporary watch expression (boolean) | 626 @param temp flag indicating a temporary watch expression (boolean) |
667 """ | 627 """ |
668 # cond is combination of cond and special (s. watch expression viewer) | 628 # cond is combination of cond and special (s. watch expression viewer) |
669 ## self.__sendCommand('{0}{1}@@{2:d}@@{3:d}\n'.format( | |
670 ## DebugProtocol.RequestWatch, cond, temp, set)) | |
671 self.__sendJsonCommand("RequestWatch", { | 629 self.__sendJsonCommand("RequestWatch", { |
672 "temporary": temp, | 630 "temporary": temp, |
673 "setWatch": setWatch, | 631 "setWatch": setWatch, |
674 "condition": cond, | 632 "condition": cond, |
675 }) | 633 }) |
681 @param cond expression of the watch expression (string) | 639 @param cond expression of the watch expression (string) |
682 @param enable flag indicating enabling or disabling a watch expression | 640 @param enable flag indicating enabling or disabling a watch expression |
683 (boolean) | 641 (boolean) |
684 """ | 642 """ |
685 # cond is combination of cond and special (s. watch expression viewer) | 643 # cond is combination of cond and special (s. watch expression viewer) |
686 ## self.__sendCommand('{0}{1},{2:d}\n'.format( | |
687 ## DebugProtocol.RequestWatchEnable, cond, enable)) | |
688 self.__sendJsonCommand("RequestWatchEnable", { | 644 self.__sendJsonCommand("RequestWatchEnable", { |
689 "condition": cond, | 645 "condition": cond, |
690 "enable": enable, | 646 "enable": enable, |
691 }) | 647 }) |
692 | 648 |
697 | 653 |
698 @param cond expression of the watch expression (string) | 654 @param cond expression of the watch expression (string) |
699 @param count number of occurrences to ignore (int) | 655 @param count number of occurrences to ignore (int) |
700 """ | 656 """ |
701 # cond is combination of cond and special (s. watch expression viewer) | 657 # cond is combination of cond and special (s. watch expression viewer) |
702 ## self.__sendCommand('{0}{1},{2:d}\n'.format( | |
703 ## DebugProtocol.RequestWatchIgnore, cond, count)) | |
704 self.__sendJsonCommand("RequestWatchIgnore", { | 658 self.__sendJsonCommand("RequestWatchIgnore", { |
705 "condition": cond, | 659 "condition": cond, |
706 "count": count, | 660 "count": count, |
707 }) | 661 }) |
708 | 662 |
710 """ | 664 """ |
711 Public method to send the raw input to the debugged program. | 665 Public method to send the raw input to the debugged program. |
712 | 666 |
713 @param s the raw input (string) | 667 @param s the raw input (string) |
714 """ | 668 """ |
715 ## self.__sendCommand(s + '\n') | |
716 self.__sendJsonCommand("RawInput", { | 669 self.__sendJsonCommand("RawInput", { |
717 "input": s, | 670 "input": s, |
718 }) | 671 }) |
719 | 672 |
720 def remoteThreadList(self): | 673 def remoteThreadList(self): |
721 """ | 674 """ |
722 Public method to request the list of threads from the client. | 675 Public method to request the list of threads from the client. |
723 """ | 676 """ |
724 ## self.__sendCommand('{0}\n'.format(DebugProtocol.RequestThreadList)) | |
725 self.__sendJsonCommand("RequestThreadList", {}) | 677 self.__sendJsonCommand("RequestThreadList", {}) |
726 | 678 |
727 def remoteSetThread(self, tid): | 679 def remoteSetThread(self, tid): |
728 """ | 680 """ |
729 Public method to request to set the given thread as current thread. | 681 Public method to request to set the given thread as current thread. |
730 | 682 |
731 @param tid id of the thread (integer) | 683 @param tid id of the thread (integer) |
732 """ | 684 """ |
733 ## self.__sendCommand('{0}{1:d}\n'.format( | |
734 ## DebugProtocol.RequestThreadSet, tid)) | |
735 self.__sendJsonCommand("RequestThreadSet", { | 685 self.__sendJsonCommand("RequestThreadSet", { |
736 "threadID": tid, | 686 "threadID": tid, |
737 }) | 687 }) |
738 | 688 |
739 def remoteClientVariables(self, scope, filter, framenr=0): | 689 def remoteClientVariables(self, scope, filter, framenr=0): |
742 | 692 |
743 @param scope the scope of the variables (0 = local, 1 = global) | 693 @param scope the scope of the variables (0 = local, 1 = global) |
744 @param filter list of variable types to filter out (list of int) | 694 @param filter list of variable types to filter out (list of int) |
745 @param framenr framenumber of the variables to retrieve (int) | 695 @param framenr framenumber of the variables to retrieve (int) |
746 """ | 696 """ |
747 ## self.__sendCommand('{0}{1:d}, {2:d}, {3}\n'.format( | |
748 ## DebugProtocol.RequestVariables, framenr, scope, str(filter))) | |
749 self.__sendJsonCommand("RequestVariables", { | 697 self.__sendJsonCommand("RequestVariables", { |
750 "frameNumber": framenr, | 698 "frameNumber": framenr, |
751 "scope": scope, | 699 "scope": scope, |
752 "filters": filter, | 700 "filters": filter, |
753 }) | 701 }) |
759 @param scope the scope of the variables (0 = local, 1 = global) | 707 @param scope the scope of the variables (0 = local, 1 = global) |
760 @param filter list of variable types to filter out (list of int) | 708 @param filter list of variable types to filter out (list of int) |
761 @param var list encoded name of variable to retrieve (string) | 709 @param var list encoded name of variable to retrieve (string) |
762 @param framenr framenumber of the variables to retrieve (int) | 710 @param framenr framenumber of the variables to retrieve (int) |
763 """ | 711 """ |
764 ## self.__sendCommand('{0}{1}, {2:d}, {3:d}, {4}\n'.format( | |
765 ## DebugProtocol.RequestVariable, str(var), framenr, scope, | |
766 ## str(filter))) | |
767 self.__sendJsonCommand("RequestVariable", { | 712 self.__sendJsonCommand("RequestVariable", { |
768 "variable": var, | 713 "variable": var, |
769 "frameNumber": framenr, | 714 "frameNumber": framenr, |
770 "scope": scope, | 715 "scope": scope, |
771 "filters": filter, | 716 "filters": filter, |
776 Public method to set a variables filter list. | 721 Public method to set a variables filter list. |
777 | 722 |
778 @param scope the scope of the variables (0 = local, 1 = global) | 723 @param scope the scope of the variables (0 = local, 1 = global) |
779 @param filter regexp string for variable names to filter out (string) | 724 @param filter regexp string for variable names to filter out (string) |
780 """ | 725 """ |
781 ## self.__sendCommand('{0}{1:d}, "{2}"\n'.format( | |
782 ## DebugProtocol.RequestSetFilter, scope, filter)) | |
783 self.__sendJsonCommand("RequestSetFilter", { | 726 self.__sendJsonCommand("RequestSetFilter", { |
784 "scope": scope, | 727 "scope": scope, |
785 "filter": filter, | 728 "filter": filter, |
786 }) | 729 }) |
787 | 730 |
789 """ | 732 """ |
790 Public method to set the call trace state. | 733 Public method to set the call trace state. |
791 | 734 |
792 @param on flag indicating to enable the call trace function (boolean) | 735 @param on flag indicating to enable the call trace function (boolean) |
793 """ | 736 """ |
794 ## if on: | |
795 ## cmd = "on" | |
796 ## else: | |
797 ## cmd = "off" | |
798 ## self.__sendCommand('{0}{1}\n'.format( | |
799 ## DebugProtocol.RequestCallTrace, cmd)) | |
800 self.__sendJsonCommand("RequestCallTrace", { | 737 self.__sendJsonCommand("RequestCallTrace", { |
801 "enable": on, | 738 "enable": on, |
802 }) | 739 }) |
803 | 740 |
804 ## def remoteEval(self, arg): | |
805 ## """ | |
806 ## Public method to evaluate arg in the current context of the debugged | |
807 ## program. | |
808 ## | |
809 ## @param arg the arguments to evaluate (string) | |
810 ## """ | |
811 #### self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEval, arg)) | |
812 ## self.__sendJsonCommand("RequestEval", { | |
813 ## "argument": arg, | |
814 ## }) | |
815 ## | |
816 ## def remoteExec(self, stmt): | |
817 ## """ | |
818 ## Public method to execute stmt in the current context of the debugged | |
819 ## program. | |
820 ## | |
821 ## @param stmt statement to execute (string) | |
822 ## """ | |
823 ## self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestExec, stmt)) | |
824 ## | |
825 def remoteBanner(self): | 741 def remoteBanner(self): |
826 """ | 742 """ |
827 Public slot to get the banner info of the remote client. | 743 Public slot to get the banner info of the remote client. |
828 """ | 744 """ |
829 ## self.__sendCommand(DebugProtocol.RequestBanner + '\n') | |
830 self.__sendJsonCommand("RequestBanner", {}) | 745 self.__sendJsonCommand("RequestBanner", {}) |
831 | 746 |
832 def remoteCapabilities(self): | 747 def remoteCapabilities(self): |
833 """ | 748 """ |
834 Public slot to get the debug clients capabilities. | 749 Public slot to get the debug clients capabilities. |
835 """ | 750 """ |
836 ## self.__sendCommand(DebugProtocol.RequestCapabilities + '\n') | |
837 self.__sendJsonCommand("RequestCapabilities", {}) | 751 self.__sendJsonCommand("RequestCapabilities", {}) |
838 | 752 |
839 def remoteCompletion(self, text): | 753 def remoteCompletion(self, text): |
840 """ | 754 """ |
841 Public slot to get the a list of possible commandline completions | 755 Public slot to get the a list of possible commandline completions |
842 from the remote client. | 756 from the remote client. |
843 | 757 |
844 @param text the text to be completed (string) | 758 @param text the text to be completed (string) |
845 """ | 759 """ |
846 ## self.__sendCommand("{0}{1}\n".format( | |
847 ## DebugProtocol.RequestCompletion, text)) | |
848 self.__sendJsonCommand("RequestCompletion", { | 760 self.__sendJsonCommand("RequestCompletion", { |
849 "text": text, | 761 "text": text, |
850 }) | 762 }) |
851 | 763 |
852 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase): | 764 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase): |
866 (boolean) | 778 (boolean) |
867 """ | 779 """ |
868 self.__scriptName = os.path.abspath(fn) | 780 self.__scriptName = os.path.abspath(fn) |
869 | 781 |
870 fn = self.translate(os.path.abspath(fn), False) | 782 fn = self.translate(os.path.abspath(fn), False) |
871 ## self.__sendCommand('{0}{1}|{2}|{3}|{4}|{5:d}|{6}|{7:d}\n'.format( | |
872 ## DebugProtocol.RequestUTPrepare, fn, tn, tfn, str(failed), | |
873 ## cov, covname, coverase)) | |
874 self.__sendJsonCommand("RequestUTPrepare", { | 783 self.__sendJsonCommand("RequestUTPrepare", { |
875 "filename": fn, | 784 "filename": fn, |
876 "testname": tn, | 785 "testname": tn, |
877 "testfunctionname": tfn, | 786 "testfunctionname": tfn, |
878 "failed": failed, | 787 "failed": failed, |
883 | 792 |
884 def remoteUTRun(self): | 793 def remoteUTRun(self): |
885 """ | 794 """ |
886 Public method to start a unittest run. | 795 Public method to start a unittest run. |
887 """ | 796 """ |
888 ## self.__sendCommand('{0}\n'.format(DebugProtocol.RequestUTRun)) | |
889 self.__sendJsonCommand("RequestUTRun", {}) | 797 self.__sendJsonCommand("RequestUTRun", {}) |
890 | 798 |
891 def remoteUTStop(self): | 799 def remoteUTStop(self): |
892 """ | 800 """ |
893 Public method to stop a unittest run. | 801 Public method to stop a unittest run. |
894 """ | 802 """ |
895 ## self.__sendCommand('{0}\n'.format(DebugProtocol.RequestUTStop)) | |
896 self.__sendJsonCommand("RequestUTStop", {}) | 803 self.__sendJsonCommand("RequestUTStop", {}) |
897 | 804 |
898 def __askForkTo(self): | 805 def __askForkTo(self): |
899 """ | 806 """ |
900 Private method to ask the user which branch of a fork to follow. | 807 Private method to ask the user which branch of a fork to follow. |
906 self.tr("Client forking"), | 813 self.tr("Client forking"), |
907 self.tr("Select the fork branch to follow."), | 814 self.tr("Select the fork branch to follow."), |
908 selections, | 815 selections, |
909 0, False) | 816 0, False) |
910 if not ok or res == selections[0]: | 817 if not ok or res == selections[0]: |
911 ## self.__sendCommand(DebugProtocol.ResponseForkTo + 'parent\n') | |
912 self.__sendJsonCommand("ResponseForkTo", { | 818 self.__sendJsonCommand("ResponseForkTo", { |
913 "target": "parent", | 819 "target": "parent", |
914 }) | 820 }) |
915 else: | 821 else: |
916 ## self.__sendCommand(DebugProtocol.ResponseForkTo + 'child\n') | |
917 self.__sendJsonCommand("ResponseForkTo", { | 822 self.__sendJsonCommand("ResponseForkTo", { |
918 "target": "child", | 823 "target": "child", |
919 }) | 824 }) |
920 | 825 |
921 def __parseClientLine(self): | 826 def __parseClientLine(self): |
926 qs = self.qsock.readLine() | 831 qs = self.qsock.readLine() |
927 if self.codec is not None: | 832 if self.codec is not None: |
928 line = self.codec.toUnicode(qs) | 833 line = self.codec.toUnicode(qs) |
929 else: | 834 else: |
930 line = bytes(qs).decode() | 835 line = bytes(qs).decode() |
931 ## if line.endswith(EOT): | |
932 ## line = line[:-len(EOT)] | |
933 ## if not line: | |
934 ## continue | |
935 | 836 |
936 ## print("Server: ", line) ##debug | 837 ## print("Server: ", line) ##debug |
937 | 838 |
938 ## if line.startswith("{") and "jsonrpc" in line: | |
939 self.__handleJsonCommand(line) | 839 self.__handleJsonCommand(line) |
940 continue | 840 continue |
941 ## | |
942 ## eoc = line.find('<') + 1 | |
943 ## | |
944 ## # Deal with case where user has written directly to stdout | |
945 ## # or stderr, but not line terminated and we stepped over the | |
946 ## # write call, in that case the >line< will not be the first | |
947 ## # string read from the socket... | |
948 ## boc = line.find('>') | |
949 ## if boc > 0 and eoc > boc: | |
950 ## self.debugServer.signalClientOutput(line[:boc]) | |
951 ## line = line[boc:] | |
952 ## eoc = line.find('<') + 1 | |
953 ## boc = line.find('>') | |
954 ## | |
955 ## self.debugServer.signalClientOutput(line) | |
956 ## if boc >= 0 and eoc > boc: | |
957 ## resp = line[boc:eoc] | |
958 ## | |
959 ## if resp == DebugProtocol.ResponseLine or \ | |
960 ## resp == DebugProtocol.ResponseStack: | |
961 ## stack = eval(line[eoc:-1]) | |
962 ## for s in stack: | |
963 ## s[0] = self.translate(s[0], True) | |
964 ## cf = stack[0] | |
965 ## if self.__autoContinue: | |
966 ## self.__autoContinue = False | |
967 ## QTimer.singleShot(0, self.remoteContinue) | |
968 ## else: | |
969 ## self.debugServer.signalClientLine( | |
970 ## cf[0], int(cf[1]), | |
971 ## resp == DebugProtocol.ResponseStack) | |
972 ## self.debugServer.signalClientStack(stack) | |
973 ## continue | |
974 ## | |
975 ## if resp == DebugProtocol.CallTrace: | |
976 ## event, fromStr, toStr = line[eoc:-1].split("@@") | |
977 ## isCall = event.lower() == "c" | |
978 ## fromFile, fromLineno, fromFunc = fromStr.rsplit(":", 2) | |
979 ## toFile, toLineno, toFunc = toStr.rsplit(":", 2) | |
980 ## self.debugServer.signalClientCallTrace( | |
981 ## isCall, | |
982 ## fromFile, fromLineno, fromFunc, | |
983 ## toFile, toLineno, toFunc) | |
984 ## continue | |
985 ## | |
986 ## if resp == DebugProtocol.ResponseThreadList: | |
987 ## currentId, threadList = eval(line[eoc:-1]) | |
988 ## self.debugServer.signalClientThreadList( | |
989 ## currentId, threadList) | |
990 ## continue | |
991 ## | |
992 ## if resp == DebugProtocol.ResponseThreadSet: | |
993 ## self.debugServer.signalClientThreadSet() | |
994 ## continue | |
995 ## | |
996 ## if resp == DebugProtocol.ResponseVariables: | |
997 ## vlist = eval(line[eoc:-1]) | |
998 ## scope = vlist[0] | |
999 ## try: | |
1000 ## variables = vlist[1:] | |
1001 ## except IndexError: | |
1002 ## variables = [] | |
1003 ## self.debugServer.signalClientVariables(scope, variables) | |
1004 ## continue | |
1005 ## | |
1006 ## if resp == DebugProtocol.ResponseVariable: | |
1007 ## vlist = eval(line[eoc:-1]) | |
1008 ## scope = vlist[0] | |
1009 ## try: | |
1010 ## variables = vlist[1:] | |
1011 ## except IndexError: | |
1012 ## variables = [] | |
1013 ## self.debugServer.signalClientVariable(scope, variables) | |
1014 ## continue | |
1015 ## | |
1016 ## if resp == DebugProtocol.ResponseOK: | |
1017 ## self.debugServer.signalClientStatement(False) | |
1018 ## continue | |
1019 ## | |
1020 ## if resp == DebugProtocol.ResponseContinue: | |
1021 ## self.debugServer.signalClientStatement(True) | |
1022 ## continue | |
1023 ## | |
1024 ## if resp == DebugProtocol.ResponseException: | |
1025 ## exc = line[eoc:-1] | |
1026 ## exc = self.translate(exc, True) | |
1027 ## try: | |
1028 ## exclist = eval(exc) | |
1029 ## exctype = exclist[0] | |
1030 ## excmessage = exclist[1] | |
1031 ## stack = exclist[2:] | |
1032 ## if stack and stack[0] and stack[0][0] == "<string>": | |
1033 ## for stackEntry in stack: | |
1034 ## if stackEntry[0] == "<string>": | |
1035 ## stackEntry[0] = self.__scriptName | |
1036 ## else: | |
1037 ## break | |
1038 ## except (IndexError, ValueError, SyntaxError): | |
1039 ## exctype = None | |
1040 ## excmessage = '' | |
1041 ## stack = [] | |
1042 ## self.debugServer.signalClientException( | |
1043 ## exctype, excmessage, stack) | |
1044 ## continue | |
1045 ## | |
1046 ## if resp == DebugProtocol.ResponseSyntax: | |
1047 ## exc = line[eoc:-1] | |
1048 ## exc = self.translate(exc, True) | |
1049 ## try: | |
1050 ## message, (fn, ln, cn) = eval(exc) | |
1051 ## if fn is None: | |
1052 ## fn = '' | |
1053 ## except (IndexError, ValueError): | |
1054 ## message = None | |
1055 ## fn = '' | |
1056 ## ln = 0 | |
1057 ## cn = 0 | |
1058 ## if cn is None: | |
1059 ## cn = 0 | |
1060 ## self.debugServer.signalClientSyntaxError( | |
1061 ## message, fn, ln, cn) | |
1062 ## continue | |
1063 ## | |
1064 ## if resp == DebugProtocol.ResponseSignal: | |
1065 ## sig = line[eoc:-1] | |
1066 ## sig = self.translate(sig, True) | |
1067 ## message, (fn, ln, func, args) = eval(sig) | |
1068 ## self.debugServer.signalClientSignal( | |
1069 ## message, fn, ln, func, args) | |
1070 ## continue | |
1071 ## | |
1072 ## if resp == DebugProtocol.ResponseExit: | |
1073 ## self.__scriptName = "" | |
1074 ## self.debugServer.signalClientExit(line[eoc:-1]) | |
1075 ## continue | |
1076 ## | |
1077 ## if resp == DebugProtocol.ResponseClearBreak: | |
1078 ## fn, lineno = line[eoc:-1].split(',') | |
1079 ## lineno = int(lineno) | |
1080 ## fn = self.translate(fn, True) | |
1081 ## self.debugServer.signalClientClearBreak(fn, lineno) | |
1082 ## continue | |
1083 ## | |
1084 ## if resp == DebugProtocol.ResponseBPConditionError: | |
1085 ## fn, lineno = line[eoc:-1].split(',') | |
1086 ## lineno = int(lineno) | |
1087 ## fn = self.translate(fn, True) | |
1088 ## self.debugServer.signalClientBreakConditionError( | |
1089 ## fn, lineno) | |
1090 ## continue | |
1091 ## | |
1092 ## if resp == DebugProtocol.ResponseClearWatch: | |
1093 ## cond = line[eoc:-1] | |
1094 ## self.debugServer.signalClientClearWatch(cond) | |
1095 ## continue | |
1096 ## | |
1097 ## if resp == DebugProtocol.ResponseWPConditionError: | |
1098 ## cond = line[eoc:-1] | |
1099 ## self.debugServer.signalClientWatchConditionError(cond) | |
1100 ## continue | |
1101 ## | |
1102 ## if resp == DebugProtocol.ResponseRaw: | |
1103 ## prompt, echo = eval(line[eoc:-1]) | |
1104 ## self.debugServer.signalClientRawInput(prompt, echo) | |
1105 ## continue | |
1106 ## | |
1107 ## if resp == DebugProtocol.ResponseBanner: | |
1108 ## version, platform, dbgclient = eval(line[eoc:-1]) | |
1109 ## self.debugServer.signalClientBanner( | |
1110 ## version, platform, dbgclient) | |
1111 ## continue | |
1112 ## | |
1113 ## if resp == DebugProtocol.ResponseCapabilities: | |
1114 ## cap, clType = eval(line[eoc:-1]) | |
1115 ## self.clientCapabilities = cap | |
1116 ## self.debugServer.signalClientCapabilities(cap, clType) | |
1117 ## continue | |
1118 ## | |
1119 ## if resp == DebugProtocol.ResponseCompletion: | |
1120 ## clstring, text = line[eoc:-1].split('||') | |
1121 ## cl = eval(clstring) | |
1122 ## self.debugServer.signalClientCompletionList(cl, text) | |
1123 ## continue | |
1124 ## | |
1125 ## if resp == DebugProtocol.PassiveStartup: | |
1126 ## fn, exc = line[eoc:-1].split('|') | |
1127 ## exc = bool(exc) | |
1128 ## fn = self.translate(fn, True) | |
1129 ## self.debugServer.passiveStartUp(fn, exc) | |
1130 ## continue | |
1131 ## | |
1132 ## if resp == DebugProtocol.ResponseUTPrepared: | |
1133 ## res, exc_type, exc_value = eval(line[eoc:-1]) | |
1134 ## self.debugServer.clientUtPrepared(res, exc_type, exc_value) | |
1135 ## continue | |
1136 ## | |
1137 ## if resp == DebugProtocol.ResponseUTStartTest: | |
1138 ## testname, doc = eval(line[eoc:-1]) | |
1139 ## self.debugServer.clientUtStartTest(testname, doc) | |
1140 ## continue | |
1141 ## | |
1142 ## if resp == DebugProtocol.ResponseUTStopTest: | |
1143 ## self.debugServer.clientUtStopTest() | |
1144 ## continue | |
1145 ## | |
1146 ## if resp == DebugProtocol.ResponseUTTestFailed: | |
1147 ## testname, traceback, id = eval(line[eoc:-1]) | |
1148 ## self.debugServer.clientUtTestFailed( | |
1149 ## testname, traceback, id) | |
1150 ## continue | |
1151 ## | |
1152 ## if resp == DebugProtocol.ResponseUTTestErrored: | |
1153 ## testname, traceback, id = eval(line[eoc:-1]) | |
1154 ## self.debugServer.clientUtTestErrored( | |
1155 ## testname, traceback, id) | |
1156 ## continue | |
1157 ## | |
1158 ## if resp == DebugProtocol.ResponseUTTestSkipped: | |
1159 ## testname, reason, id = eval(line[eoc:-1]) | |
1160 ## self.debugServer.clientUtTestSkipped(testname, reason, id) | |
1161 ## continue | |
1162 ## | |
1163 ## if resp == DebugProtocol.ResponseUTTestFailedExpected: | |
1164 ## testname, traceback, id = eval(line[eoc:-1]) | |
1165 ## self.debugServer.clientUtTestFailedExpected( | |
1166 ## testname, traceback, id) | |
1167 ## continue | |
1168 ## | |
1169 ## if resp == DebugProtocol.ResponseUTTestSucceededUnexpected: | |
1170 ## testname, id = eval(line[eoc:-1]) | |
1171 ## self.debugServer.clientUtTestSucceededUnexpected( | |
1172 ## testname, id) | |
1173 ## continue | |
1174 ## | |
1175 ## if resp == DebugProtocol.ResponseUTFinished: | |
1176 ## self.debugServer.clientUtFinished() | |
1177 ## continue | |
1178 ## | |
1179 ## if resp == DebugProtocol.RequestForkTo: | |
1180 ## self.__askForkTo() | |
1181 ## continue | |
1182 ## | |
1183 ## self.debugServer.signalClientOutput(line) | |
1184 | 841 |
1185 def __handleJsonCommand(self, jsonStr): | 842 def __handleJsonCommand(self, jsonStr): |
1186 """ | 843 """ |
1187 Private method to handle a command serialized as a JSON string. | 844 Private method to handle a command or response serialized as a |
845 JSON string. | |
846 | |
847 @param jsonStr string containing the command or response received | |
848 from the debug backend | |
849 @type str | |
1188 """ | 850 """ |
1189 import json | 851 import json |
1190 | 852 |
1191 try: | 853 try: |
1192 commandDict = json.loads(jsonStr.strip()) | 854 commandDict = json.loads(jsonStr.strip()) |
1193 except json.JSONDecodeError as err: | 855 except json.JSONDecodeError as err: |
1194 # TODO: implement real error handling | 856 # TODO: implement real error handling |
1195 ## print(str(err)) | 857 ##print(str(err)) |
1196 return | 858 return |
1197 | 859 |
1198 method = commandDict["method"] | 860 method = commandDict["method"] |
1199 params = commandDict["params"] | 861 params = commandDict["params"] |
1200 | 862 |