src/eric7/Debugger/DebuggerInterfacePython.py

branch
eric7-maintenance
changeset 10460
3b34efa2857c
parent 10349
df7edc29cbfb
parent 10439
21c28b0f9e41
child 10534
783d835d7fe4
equal deleted inserted replaced
10366:411df92e881f 10460:3b34efa2857c
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 2
3 # Copyright (c) 2009 - 2023 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2009 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing the Python3 debugger interface for the debug server. 7 Module implementing the Python3 debugger interface for the debug server.
8 """ 8 """
132 @rtype QProcess or None 132 @rtype QProcess or None
133 """ 133 """
134 proc = QProcess(self) 134 proc = QProcess(self)
135 if environment is not None: 135 if environment is not None:
136 env = QProcessEnvironment() 136 env = QProcessEnvironment()
137 for key, value in list(environment.items()): 137 for key, value in environment.items():
138 env.insert(key, value) 138 env.insert(key, value)
139 proc.setProcessEnvironment(env) 139 proc.setProcessEnvironment(env)
140 args = arguments[:] 140 args = arguments[:]
141 if workingDir: 141 if workingDir:
142 proc.setWorkingDirectory(workingDir) 142 proc.setWorkingDirectory(workingDir)
695 Public method to return the IDs of the connected debugger backends. 695 Public method to return the IDs of the connected debugger backends.
696 696
697 @return list of connected debugger backend IDs 697 @return list of connected debugger backend IDs
698 @rtype list of str 698 @rtype list of str
699 """ 699 """
700 return sorted(self.__connections.keys()) 700 return sorted(self.__connections)
701 701
702 def __flush(self): 702 def __flush(self):
703 """ 703 """
704 Private slot to flush the queue. 704 Private slot to flush the queue.
705 """ 705 """
788 reportAllExceptions=False, 788 reportAllExceptions=False,
789 ): 789 ):
790 """ 790 """
791 Public method to load a new program to debug. 791 Public method to load a new program to debug.
792 792
793 @param fn the filename to debug 793 @param fn filename to debug
794 @type str 794 @type str
795 @param argv the commandline arguments to pass to the program 795 @param argv list of command line arguments to pass to the program
796 @type str 796 @type list of str
797 @param wd the working directory for the program 797 @param wd working directory for the program
798 @type str 798 @type str
799 @param traceInterpreter flag indicating if the interpreter library 799 @param traceInterpreter flag indicating if the interpreter library
800 should be traced as well 800 should be traced as well
801 @type bool 801 @type bool
802 @param autoContinue flag indicating, that the debugger should not 802 @param autoContinue flag indicating, that the debugger should not
818 self.__sendJsonCommand( 818 self.__sendJsonCommand(
819 "RequestLoad", 819 "RequestLoad",
820 { 820 {
821 "workdir": wd, 821 "workdir": wd,
822 "filename": fn, 822 "filename": fn,
823 "argv": Utilities.parseOptionString(argv), 823 "argv": argv,
824 "traceInterpreter": traceInterpreter, 824 "traceInterpreter": traceInterpreter,
825 "multiprocess": enableMultiprocess, 825 "multiprocess": enableMultiprocess,
826 "reportAllExceptions": reportAllExceptions, 826 "reportAllExceptions": reportAllExceptions,
827 }, 827 },
828 self.__mainDebugger, 828 self.__mainDebugger,
830 830
831 def remoteRun(self, fn, argv, wd): 831 def remoteRun(self, fn, argv, wd):
832 """ 832 """
833 Public method to load a new program to run. 833 Public method to load a new program to run.
834 834
835 @param fn the filename to run 835 @param fn filename to run
836 @type str 836 @type str
837 @param argv the commandline arguments to pass to the program 837 @param argv list of command line arguments to pass to the program
838 @type str 838 @type list of str
839 @param wd the working directory for the program 839 @param wd working directory for the program
840 @type str 840 @type str
841 """ 841 """
842 self.__scriptName = os.path.abspath(fn) 842 self.__scriptName = os.path.abspath(fn)
843 843
844 wd = self.translate(wd, False) 844 wd = self.translate(wd, False)
846 self.__sendJsonCommand( 846 self.__sendJsonCommand(
847 "RequestRun", 847 "RequestRun",
848 { 848 {
849 "workdir": wd, 849 "workdir": wd,
850 "filename": fn, 850 "filename": fn,
851 "argv": Utilities.parseOptionString(argv), 851 "argv": argv,
852 }, 852 },
853 self.__mainDebugger, 853 self.__mainDebugger,
854 ) 854 )
855 855
856 def remoteCoverage(self, fn, argv, wd, erase=False): 856 def remoteCoverage(self, fn, argv, wd, erase=False):
857 """ 857 """
858 Public method to load a new program to collect coverage data. 858 Public method to load a new program to collect coverage data.
859 859
860 @param fn the filename to run 860 @param fn filename to run
861 @type str 861 @type str
862 @param argv the commandline arguments to pass to the program 862 @param argv list of command line arguments to pass to the program
863 @type str 863 @type list of str
864 @param wd the working directory for the program 864 @param wd working directory for the program
865 @type str 865 @type str
866 @param erase flag indicating that coverage info should be 866 @param erase flag indicating that coverage info should be
867 cleared first 867 cleared first
868 @type bool 868 @type bool
869 """ 869 """
874 self.__sendJsonCommand( 874 self.__sendJsonCommand(
875 "RequestCoverage", 875 "RequestCoverage",
876 { 876 {
877 "workdir": wd, 877 "workdir": wd,
878 "filename": fn, 878 "filename": fn,
879 "argv": Utilities.parseOptionString(argv), 879 "argv": argv,
880 "erase": erase, 880 "erase": erase,
881 }, 881 },
882 self.__mainDebugger, 882 self.__mainDebugger,
883 ) 883 )
884 884
885 def remoteProfile(self, fn, argv, wd, erase=False): 885 def remoteProfile(self, fn, argv, wd, erase=False):
886 """ 886 """
887 Public method to load a new program to collect profiling data. 887 Public method to load a new program to collect profiling data.
888 888
889 @param fn the filename to run 889 @param fn filename to run
890 @type str 890 @type str
891 @param argv the commandline arguments to pass to the program 891 @param argv list of command line arguments to pass to the program
892 @type str 892 @type list of str
893 @param wd the working directory for the program 893 @param wd working directory for the program
894 @type str 894 @type str
895 @param erase flag indicating that timing info should be cleared 895 @param erase flag indicating that timing info should be cleared
896 first 896 first
897 @type bool 897 @type bool
898 """ 898 """
903 self.__sendJsonCommand( 903 self.__sendJsonCommand(
904 "RequestProfile", 904 "RequestProfile",
905 { 905 {
906 "workdir": wd, 906 "workdir": wd,
907 "filename": fn, 907 "filename": fn,
908 "argv": Utilities.parseOptionString(argv), 908 "argv": argv,
909 "erase": erase, 909 "erase": erase,
910 }, 910 },
911 self.__mainDebugger, 911 self.__mainDebugger,
912 ) 912 )
913 913
915 """ 915 """
916 Public method to execute a Python statement. 916 Public method to execute a Python statement.
917 917
918 @param debuggerId ID of the debugger backend 918 @param debuggerId ID of the debugger backend
919 @type str 919 @type str
920 @param stmt the Python statement to execute. 920 @param stmt Python statement to execute.
921 @type str 921 @type str
922 """ 922 """
923 self.__sendJsonCommand( 923 self.__sendJsonCommand(
924 "ExecuteStatement", 924 "ExecuteStatement",
925 { 925 {
991 Public method to continue the debugged program to the given line 991 Public method to continue the debugged program to the given line
992 or until returning from the current frame. 992 or until returning from the current frame.
993 993
994 @param debuggerId ID of the debugger backend 994 @param debuggerId ID of the debugger backend
995 @type str 995 @type str
996 @param line the new line, where execution should be continued to 996 @param line new line, where execution should be continued to
997 @type int 997 @type int
998 """ 998 """
999 self.__isStepCommand = False 999 self.__isStepCommand = False
1000 self.__sendJsonCommand( 1000 self.__sendJsonCommand(
1001 "RequestContinueUntil", 1001 "RequestContinueUntil",
1009 """ 1009 """
1010 Public method to move the instruction pointer to a different line. 1010 Public method to move the instruction pointer to a different line.
1011 1011
1012 @param debuggerId ID of the debugger backend 1012 @param debuggerId ID of the debugger backend
1013 @type str 1013 @type str
1014 @param line the new line, where execution should be continued 1014 @param line new line, where execution should be continued
1015 @type int 1015 @type int
1016 """ 1016 """
1017 self.__sendJsonCommand( 1017 self.__sendJsonCommand(
1018 "RequestMoveIP", 1018 "RequestMoveIP",
1019 { 1019 {
1030 1030
1031 @param debuggerId ID of the debugger backend 1031 @param debuggerId ID of the debugger backend
1032 @type str 1032 @type str
1033 @param fn filename the breakpoint belongs to 1033 @param fn filename the breakpoint belongs to
1034 @type str 1034 @type str
1035 @param line linenumber of the breakpoint 1035 @param line line number of the breakpoint
1036 @type int 1036 @type int
1037 @param setBreakpoint flag indicating setting or resetting a breakpoint 1037 @param setBreakpoint flag indicating setting or resetting a breakpoint
1038 @type bool 1038 @type bool
1039 @param cond condition of the breakpoint 1039 @param cond condition of the breakpoint
1040 @type str 1040 @type str
1041 @param temp flag indicating a temporary breakpoint 1041 @param temp flag indicating a temporary breakpoint
1042 @type bool 1042 @type bool
1043 """ 1043 """
1044 debuggerList = [debuggerId] if debuggerId else list(self.__connections.keys()) 1044 debuggerList = [debuggerId] if debuggerId else list(self.__connections)
1045 for debuggerId in debuggerList: 1045 for debuggerId in debuggerList:
1046 self.__sendJsonCommand( 1046 self.__sendJsonCommand(
1047 "RequestBreakpoint", 1047 "RequestBreakpoint",
1048 { 1048 {
1049 "filename": self.translate(fn, False), 1049 "filename": self.translate(fn, False),
1061 1061
1062 @param debuggerId ID of the debugger backend 1062 @param debuggerId ID of the debugger backend
1063 @type str 1063 @type str
1064 @param fn filename the breakpoint belongs to 1064 @param fn filename the breakpoint belongs to
1065 @type str 1065 @type str
1066 @param line linenumber of the breakpoint 1066 @param line line number of the breakpoint
1067 @type int 1067 @type int
1068 @param enable flag indicating enabling or disabling a breakpoint 1068 @param enable flag indicating enabling or disabling a breakpoint
1069 @type bool 1069 @type bool
1070 """ 1070 """
1071 debuggerList = [debuggerId] if debuggerId else list(self.__connections.keys()) 1071 debuggerList = [debuggerId] if debuggerId else list(self.__connections)
1072 for debuggerId in debuggerList: 1072 for debuggerId in debuggerList:
1073 self.__sendJsonCommand( 1073 self.__sendJsonCommand(
1074 "RequestBreakpointEnable", 1074 "RequestBreakpointEnable",
1075 { 1075 {
1076 "filename": self.translate(fn, False), 1076 "filename": self.translate(fn, False),
1086 1086
1087 @param debuggerId ID of the debugger backend 1087 @param debuggerId ID of the debugger backend
1088 @type str 1088 @type str
1089 @param fn filename the breakpoint belongs to 1089 @param fn filename the breakpoint belongs to
1090 @type str 1090 @type str
1091 @param line linenumber of the breakpoint 1091 @param line line number of the breakpoint
1092 @type int 1092 @type int
1093 @param count number of occurrences to ignore 1093 @param count number of occurrences to ignore
1094 @type int 1094 @type int
1095 """ 1095 """
1096 debuggerList = [debuggerId] if debuggerId else list(self.__connections.keys()) 1096 debuggerList = [debuggerId] if debuggerId else list(self.__connections)
1097 for debuggerId in debuggerList: 1097 for debuggerId in debuggerList:
1098 self.__sendJsonCommand( 1098 self.__sendJsonCommand(
1099 "RequestBreakpointIgnore", 1099 "RequestBreakpointIgnore",
1100 { 1100 {
1101 "filename": self.translate(fn, False), 1101 "filename": self.translate(fn, False),
1116 @param setWatch flag indicating setting or resetting a watch expression 1116 @param setWatch flag indicating setting or resetting a watch expression
1117 @type bool 1117 @type bool
1118 @param temp flag indicating a temporary watch expression 1118 @param temp flag indicating a temporary watch expression
1119 @type bool 1119 @type bool
1120 """ 1120 """
1121 debuggerList = [debuggerId] if debuggerId else list(self.__connections.keys()) 1121 debuggerList = [debuggerId] if debuggerId else list(self.__connections)
1122 for debuggerId in debuggerList: 1122 for debuggerId in debuggerList:
1123 # cond is combination of cond and special (s. watch expression 1123 # cond is combination of cond and special (s. watch expression
1124 # viewer) 1124 # viewer)
1125 self.__sendJsonCommand( 1125 self.__sendJsonCommand(
1126 "RequestWatch", 1126 "RequestWatch",
1141 @param cond expression of the watch expression 1141 @param cond expression of the watch expression
1142 @type str 1142 @type str
1143 @param enable flag indicating enabling or disabling a watch expression 1143 @param enable flag indicating enabling or disabling a watch expression
1144 @type bool 1144 @type bool
1145 """ 1145 """
1146 debuggerList = [debuggerId] if debuggerId else list(self.__connections.keys()) 1146 debuggerList = [debuggerId] if debuggerId else list(self.__connections)
1147 for debuggerId in debuggerList: 1147 for debuggerId in debuggerList:
1148 # cond is combination of cond and special (s. watch expression 1148 # cond is combination of cond and special (s. watch expression
1149 # viewer) 1149 # viewer)
1150 self.__sendJsonCommand( 1150 self.__sendJsonCommand(
1151 "RequestWatchEnable", 1151 "RequestWatchEnable",
1166 @param cond expression of the watch expression 1166 @param cond expression of the watch expression
1167 @type str 1167 @type str
1168 @param count number of occurrences to ignore 1168 @param count number of occurrences to ignore
1169 @type int 1169 @type int
1170 """ 1170 """
1171 debuggerList = [debuggerId] if debuggerId else list(self.__connections.keys()) 1171 debuggerList = [debuggerId] if debuggerId else list(self.__connections)
1172 for debuggerId in debuggerList: 1172 for debuggerId in debuggerList:
1173 # cond is combination of cond and special (s. watch expression 1173 # cond is combination of cond and special (s. watch expression
1174 # viewer) 1174 # viewer)
1175 self.__sendJsonCommand( 1175 self.__sendJsonCommand(
1176 "RequestWatchIgnore", 1176 "RequestWatchIgnore",
1185 """ 1185 """
1186 Public method to send the raw input to the debugged program. 1186 Public method to send the raw input to the debugged program.
1187 1187
1188 @param debuggerId ID of the debugger backend 1188 @param debuggerId ID of the debugger backend
1189 @type str 1189 @type str
1190 @param inputString the raw input 1190 @param inputString raw input
1191 @type str 1191 @type str
1192 """ 1192 """
1193 self.__sendJsonCommand( 1193 self.__sendJsonCommand(
1194 "RawInput", 1194 "RawInput",
1195 { 1195 {
1239 """ 1239 """
1240 Public method to request the variables of the debugged program. 1240 Public method to request the variables of the debugged program.
1241 1241
1242 @param debuggerId ID of the debugger backend 1242 @param debuggerId ID of the debugger backend
1243 @type str 1243 @type str
1244 @param scope the scope of the variables (0 = local, 1 = global) 1244 @param scope scope of the variables (0 = local, 1 = global)
1245 @type int 1245 @type int
1246 @param filterList list of variable types to filter out 1246 @param filterList list of variable types to filter out
1247 @type list of str 1247 @type list of str
1248 @param framenr framenumber of the variables to retrieve 1248 @param framenr framenumber of the variables to retrieve
1249 @type int 1249 @type int
1269 """ 1269 """
1270 Public method to request the variables of the debugged program. 1270 Public method to request the variables of the debugged program.
1271 1271
1272 @param debuggerId ID of the debugger backend 1272 @param debuggerId ID of the debugger backend
1273 @type str 1273 @type str
1274 @param scope the scope of the variables (0 = local, 1 = global) 1274 @param scope scope of the variables (0 = local, 1 = global)
1275 @type int 1275 @type int
1276 @param filterList list of variable types to filter out 1276 @param filterList list of variable types to filter out
1277 @type list of str 1277 @type list of str
1278 @param var list encoded name of variable to retrieve 1278 @param var list encoded name of variable to retrieve
1279 @type list of str 1279 @type list of str
1309 """ 1309 """
1310 Public method to set a variables filter list. 1310 Public method to set a variables filter list.
1311 1311
1312 @param debuggerId ID of the debugger backend 1312 @param debuggerId ID of the debugger backend
1313 @type str 1313 @type str
1314 @param scope the scope of the variables (0 = local, 1 = global) 1314 @param scope scope of the variables (0 = local, 1 = global)
1315 @type int 1315 @type int
1316 @param filterStr regexp string for variable names to filter out 1316 @param filterStr regexp string for variable names to filter out
1317 @type str 1317 @type str
1318 """ 1318 """
1319 self.__sendJsonCommand( 1319 self.__sendJsonCommand(
1382 Public slot to get the a list of possible commandline completions 1382 Public slot to get the a list of possible commandline completions
1383 from the remote client. 1383 from the remote client.
1384 1384
1385 @param debuggerId ID of the debugger backend 1385 @param debuggerId ID of the debugger backend
1386 @type str 1386 @type str
1387 @param text the text to be completed 1387 @param text text to be completed
1388 @type str 1388 @type str
1389 """ 1389 """
1390 self.__sendJsonCommand( 1390 self.__sendJsonCommand(
1391 "RequestCompletion", 1391 "RequestCompletion",
1392 { 1392 {

eric ide

mercurial