Debugger/DebugServer.py

changeset 6352
4bdc6503df81
parent 6348
d6c0b8ab1fc6
child 6367
7bc6fc02d981
equal deleted inserted replaced
6351:27ce01e44a5f 6352:4bdc6503df81
447 self.clientType = clType 447 self.clientType = clType
448 Preferences.Prefs.settings.setValue( 448 Preferences.Prefs.settings.setValue(
449 'DebugClient/Type', self.clientType) 449 'DebugClient/Type', self.clientType)
450 450
451 def startClient(self, unplanned=True, clType=None, forProject=False, 451 def startClient(self, unplanned=True, clType=None, forProject=False,
452 runInConsole=False, interpreter=""): 452 runInConsole=False, venvName=""):
453 """ 453 """
454 Public method to start a debug client. 454 Public method to start a debug client.
455 455
456 @keyparam unplanned flag indicating that the client has died (boolean) 456 @keyparam unplanned flag indicating that the client has died
457 @keyparam clType type of client to be started (string) 457 @type bool
458 @keyparam forProject flag indicating a project related action (boolean) 458 @keyparam clType type of client to be started
459 @type str
460 @keyparam forProject flag indicating a project related action
461 @type bool
459 @keyparam runInConsole flag indicating to start the debugger in a 462 @keyparam runInConsole flag indicating to start the debugger in a
460 console window (boolean) 463 console window
461 @keyparam interpreter interpreter to be used to execute the remote 464 @type bool
462 side (string) 465 @keyparam venvName name of the virtual environment to be used
466 @type str
463 """ 467 """
464 self.running = False 468 self.running = False
465 469
466 if not self.passive or not self.passiveClientExited: 470 if not self.passive or not self.passiveClientExited:
467 if self.debuggerInterface and self.debuggerInterface.isConnected(): 471 if self.debuggerInterface and self.debuggerInterface.isConnected():
483 if forProject: 487 if forProject:
484 project = e5App().getObject("Project") 488 project = e5App().getObject("Project")
485 if not project.isDebugPropertiesLoaded(): 489 if not project.isDebugPropertiesLoaded():
486 self.clientProcess, isNetworked, clientInterpreter = \ 490 self.clientProcess, isNetworked, clientInterpreter = \
487 self.debuggerInterface.startRemote( 491 self.debuggerInterface.startRemote(
488 self.serverPort(), runInConsole, interpreter) 492 self.serverPort(), runInConsole, venvName)
489 else: 493 else:
490 self.clientProcess, isNetworked, clientInterpreter = \ 494 self.clientProcess, isNetworked, clientInterpreter = \
491 self.debuggerInterface.startRemoteForProject( 495 self.debuggerInterface.startRemoteForProject(
492 self.serverPort(), runInConsole, interpreter) 496 self.serverPort(), runInConsole, venvName)
493 else: 497 else:
494 self.clientProcess, isNetworked, clientInterpreter = \ 498 self.clientProcess, isNetworked, clientInterpreter = \
495 self.debuggerInterface.startRemote( 499 self.debuggerInterface.startRemote(
496 self.serverPort(), runInConsole, interpreter) 500 self.serverPort(), runInConsole, venvName)
497 501
498 if self.clientProcess: 502 if self.clientProcess:
499 self.clientProcess.readyReadStandardError.connect( 503 self.clientProcess.readyReadStandardError.connect(
500 self.__clientProcessError) 504 self.__clientProcessError)
501 self.clientProcess.readyReadStandardOutput.connect( 505 self.clientProcess.readyReadStandardOutput.connect(
802 envdict[key] = value 806 envdict[key] = value
803 except ValueError: 807 except ValueError:
804 pass 808 pass
805 self.debuggerInterface.remoteEnvironment(envdict) 809 self.debuggerInterface.remoteEnvironment(envdict)
806 810
807 def remoteLoad(self, interpreter, fn, argv, wd, env, autoClearShell=True, 811 def remoteLoad(self, venvName, fn, argv, wd, env, autoClearShell=True,
808 tracePython=False, autoContinue=True, forProject=False, 812 tracePython=False, autoContinue=True, forProject=False,
809 runInConsole=False, autoFork=False, forkChild=False, 813 runInConsole=False, autoFork=False, forkChild=False,
810 clientType="", enableCallTrace=False): 814 clientType="", enableCallTrace=False):
811 """ 815 """
812 Public method to load a new program to debug. 816 Public method to load a new program to debug.
813 817
814 @param interpreter interpreter to be used to execute the remote 818 @param venvName name of the virtual environment to be used
815 side (string) 819 @type str
816 @param fn the filename to debug (string) 820 @param fn the filename to debug
817 @param argv the commandline arguments to pass to the program (string) 821 @type str
818 @param wd the working directory for the program (string) 822 @param argv the command line arguments to pass to the program
819 @param env environment settings (string) 823 @type str
824 @param wd the working directory for the program
825 @type str
826 @param env environment parameter settings
827 @type str
820 @keyparam autoClearShell flag indicating, that the interpreter window 828 @keyparam autoClearShell flag indicating, that the interpreter window
821 should be cleared (boolean) 829 should be cleared
830 @type bool
822 @keyparam tracePython flag indicating if the Python library should be 831 @keyparam tracePython flag indicating if the Python library should be
823 traced as well (boolean) 832 traced as well
833 @type bool
824 @keyparam autoContinue flag indicating, that the debugger should not 834 @keyparam autoContinue flag indicating, that the debugger should not
825 stop at the first executable line (boolean) 835 stop at the first executable line
826 @keyparam forProject flag indicating a project related action (boolean) 836 @type bool
837 @keyparam forProject flag indicating a project related action
838 @type bool
827 @keyparam runInConsole flag indicating to start the debugger in a 839 @keyparam runInConsole flag indicating to start the debugger in a
828 console window (boolean) 840 console window
829 @keyparam autoFork flag indicating the automatic fork mode (boolean) 841 @type bool
842 @keyparam autoFork flag indicating the automatic fork mode
843 @type bool
830 @keyparam forkChild flag indicating to debug the child after forking 844 @keyparam forkChild flag indicating to debug the child after forking
831 (boolean) 845 @type bool
832 @keyparam clientType client type to be used (string) 846 @keyparam clientType client type to be used
847 @type str
833 @keyparam enableCallTrace flag indicating to enable the call trace 848 @keyparam enableCallTrace flag indicating to enable the call trace
834 function (boolean) 849 function
850 @type bool
835 """ 851 """
836 self.__autoClearShell = autoClearShell 852 self.__autoClearShell = autoClearShell
837 self.__autoContinue = autoContinue 853 self.__autoContinue = autoContinue
838 854
839 # Restart the client 855 # Restart the client
844 self.__setClientType( 860 self.__setClientType(
845 self.__findLanguageForExtension(os.path.splitext(fn)[1])) 861 self.__findLanguageForExtension(os.path.splitext(fn)[1]))
846 except KeyError: 862 except KeyError:
847 self.__setClientType('Python3') # assume it is a Python3 file 863 self.__setClientType('Python3') # assume it is a Python3 file
848 self.startClient(False, forProject=forProject, 864 self.startClient(False, forProject=forProject,
849 runInConsole=runInConsole, interpreter=interpreter) 865 runInConsole=runInConsole, venvName=venvName)
850 866
851 self.setCallTraceEnabled(enableCallTrace) 867 self.setCallTraceEnabled(enableCallTrace)
852 self.remoteEnvironment(env) 868 self.remoteEnvironment(env)
853 869
854 self.debuggerInterface.remoteLoad(fn, argv, wd, tracePython, 870 self.debuggerInterface.remoteLoad(fn, argv, wd, tracePython,
856 self.debugging = True 872 self.debugging = True
857 self.running = True 873 self.running = True
858 self.__restoreBreakpoints() 874 self.__restoreBreakpoints()
859 self.__restoreWatchpoints() 875 self.__restoreWatchpoints()
860 876
861 def remoteRun(self, interpreter, fn, argv, wd, env, autoClearShell=True, 877 def remoteRun(self, venvName, fn, argv, wd, env, autoClearShell=True,
862 forProject=False, runInConsole=False, autoFork=False, 878 forProject=False, runInConsole=False, autoFork=False,
863 forkChild=False, clientType=""): 879 forkChild=False, clientType=""):
864 """ 880 """
865 Public method to load a new program to run. 881 Public method to load a new program to run.
866 882
867 @param interpreter interpreter to be used to execute the remote 883 @param venvName name of the virtual environment to be used
868 side (string) 884 @type str
869 @param fn the filename to run (string) 885 @param fn the filename to debug
870 @param argv the commandline arguments to pass to the program (string) 886 @type str
871 @param wd the working directory for the program (string) 887 @param argv the command line arguments to pass to the program
872 @param env environment settings (string) 888 @type str
889 @param wd the working directory for the program
890 @type str
891 @param env environment parameter settings
892 @type str
873 @keyparam autoClearShell flag indicating, that the interpreter window 893 @keyparam autoClearShell flag indicating, that the interpreter window
874 should be cleared (boolean) 894 should be cleared
875 @keyparam forProject flag indicating a project related action (boolean) 895 @type bool
896 @keyparam forProject flag indicating a project related action
897 @type bool
876 @keyparam runInConsole flag indicating to start the debugger in a 898 @keyparam runInConsole flag indicating to start the debugger in a
877 console window (boolean) 899 console window
878 @keyparam autoFork flag indicating the automatic fork mode (boolean) 900 @type bool
901 @keyparam autoFork flag indicating the automatic fork mode
902 @type bool
879 @keyparam forkChild flag indicating to debug the child after forking 903 @keyparam forkChild flag indicating to debug the child after forking
880 (boolean) 904 @type bool
881 @keyparam clientType client type to be used (string) 905 @keyparam clientType client type to be used
906 @type str
882 """ 907 """
883 self.__autoClearShell = autoClearShell 908 self.__autoClearShell = autoClearShell
884 909
885 # Restart the client 910 # Restart the client
886 try: 911 try:
890 self.__setClientType( 915 self.__setClientType(
891 self.__findLanguageForExtension(os.path.splitext(fn)[1])) 916 self.__findLanguageForExtension(os.path.splitext(fn)[1]))
892 except KeyError: 917 except KeyError:
893 self.__setClientType('Python3') # assume it is a Python3 file 918 self.__setClientType('Python3') # assume it is a Python3 file
894 self.startClient(False, forProject=forProject, 919 self.startClient(False, forProject=forProject,
895 runInConsole=runInConsole, interpreter=interpreter) 920 runInConsole=runInConsole, venvName=venvName)
896 921
897 self.remoteEnvironment(env) 922 self.remoteEnvironment(env)
898 923
899 self.debuggerInterface.remoteRun(fn, argv, wd, autoFork, forkChild) 924 self.debuggerInterface.remoteRun(fn, argv, wd, autoFork, forkChild)
900 self.debugging = False 925 self.debugging = False
901 self.running = True 926 self.running = True
902 927
903 def remoteCoverage(self, interpreter, fn, argv, wd, env, 928 def remoteCoverage(self, venvName, fn, argv, wd, env,
904 autoClearShell=True, erase=False, forProject=False, 929 autoClearShell=True, erase=False, forProject=False,
905 runInConsole=False, clientType=""): 930 runInConsole=False, clientType=""):
906 """ 931 """
907 Public method to load a new program to collect coverage data. 932 Public method to load a new program to collect coverage data.
908 933
909 @param interpreter interpreter to be used to execute the remote 934 @param venvName name of the virtual environment to be used
910 side (string) 935 @type str
911 @param fn the filename to run (string) 936 @param fn the filename to debug
912 @param argv the commandline arguments to pass to the program (string) 937 @type str
913 @param wd the working directory for the program (string) 938 @param argv the command line arguments to pass to the program
914 @param env environment settings (string) 939 @type str
940 @param wd the working directory for the program
941 @type str
942 @param env environment parameter settings
943 @type str
915 @keyparam autoClearShell flag indicating, that the interpreter window 944 @keyparam autoClearShell flag indicating, that the interpreter window
916 should be cleared (boolean) 945 should be cleared
946 @type bool
917 @keyparam erase flag indicating that coverage info should be 947 @keyparam erase flag indicating that coverage info should be
918 cleared first (boolean) 948 cleared first
919 @keyparam forProject flag indicating a project related action (boolean) 949 @type bool
950 @keyparam forProject flag indicating a project related action
951 @type bool
920 @keyparam runInConsole flag indicating to start the debugger in a 952 @keyparam runInConsole flag indicating to start the debugger in a
921 console window (boolean) 953 console window
922 @keyparam clientType client type to be used (string) 954 @type bool
955 @keyparam clientType client type to be used
956 @type str
923 """ 957 """
924 self.__autoClearShell = autoClearShell 958 self.__autoClearShell = autoClearShell
925 959
926 # Restart the client 960 # Restart the client
927 try: 961 try:
931 self.__setClientType( 965 self.__setClientType(
932 self.__findLanguageForExtension(os.path.splitext(fn)[1])) 966 self.__findLanguageForExtension(os.path.splitext(fn)[1]))
933 except KeyError: 967 except KeyError:
934 self.__setClientType('Python3') # assume it is a Python3 file 968 self.__setClientType('Python3') # assume it is a Python3 file
935 self.startClient(False, forProject=forProject, 969 self.startClient(False, forProject=forProject,
936 runInConsole=runInConsole, interpreter=interpreter) 970 runInConsole=runInConsole, venvName=venvName)
937 971
938 self.remoteEnvironment(env) 972 self.remoteEnvironment(env)
939 973
940 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase) 974 self.debuggerInterface.remoteCoverage(fn, argv, wd, erase)
941 self.debugging = False 975 self.debugging = False
942 self.running = True 976 self.running = True
943 977
944 def remoteProfile(self, interpreter, fn, argv, wd, env, 978 def remoteProfile(self, venvName, fn, argv, wd, env,
945 autoClearShell=True, erase=False, forProject=False, 979 autoClearShell=True, erase=False, forProject=False,
946 runInConsole=False, clientType=""): 980 runInConsole=False, clientType=""):
947 """ 981 """
948 Public method to load a new program to collect profiling data. 982 Public method to load a new program to collect profiling data.
949 983
950 @param interpreter interpreter to be used to execute the remote 984 @param venvName name of the virtual environment to be used
951 side (string) 985 @type str
952 @param fn the filename to run (string) 986 @param fn the filename to debug
953 @param argv the commandline arguments to pass to the program (string) 987 @type str
954 @param wd the working directory for the program (string) 988 @param argv the command line arguments to pass to the program
955 @param env environment settings (string) 989 @type str
990 @param wd the working directory for the program
991 @type str
992 @param env environment parameter settings
993 @type str
956 @keyparam autoClearShell flag indicating, that the interpreter window 994 @keyparam autoClearShell flag indicating, that the interpreter window
957 should be cleared (boolean) 995 should be cleared
958 @keyparam erase flag indicating that timing info should be cleared 996 @type bool
959 first (boolean) 997 @keyparam erase flag indicating that coverage info should be
960 @keyparam forProject flag indicating a project related action (boolean) 998 cleared first
999 @type bool
1000 @keyparam forProject flag indicating a project related action
1001 @type bool
961 @keyparam runInConsole flag indicating to start the debugger in a 1002 @keyparam runInConsole flag indicating to start the debugger in a
962 console window (boolean) 1003 console window
963 @keyparam clientType client type to be used (string) 1004 @type bool
1005 @keyparam clientType client type to be used
1006 @type str
964 """ 1007 """
965 self.__autoClearShell = autoClearShell 1008 self.__autoClearShell = autoClearShell
966 1009
967 # Restart the client 1010 # Restart the client
968 try: 1011 try:
972 self.__setClientType( 1015 self.__setClientType(
973 self.__findLanguageForExtension(os.path.splitext(fn)[1])) 1016 self.__findLanguageForExtension(os.path.splitext(fn)[1]))
974 except KeyError: 1017 except KeyError:
975 self.__setClientType('Python3') # assume it is a Python3 file 1018 self.__setClientType('Python3') # assume it is a Python3 file
976 self.startClient(False, forProject=forProject, 1019 self.startClient(False, forProject=forProject,
977 runInConsole=runInConsole, interpreter=interpreter) 1020 runInConsole=runInConsole, venvName=venvName)
978 1021
979 self.remoteEnvironment(env) 1022 self.remoteEnvironment(env)
980 1023
981 self.debuggerInterface.remoteProfile(fn, argv, wd, erase) 1024 self.debuggerInterface.remoteProfile(fn, argv, wd, erase)
982 self.debugging = False 1025 self.debugging = False

eric ide

mercurial