Debugger/DebugServer.py

changeset 481
ad71812ba395
parent 470
99d8c50ba42f
child 482
4650a72c307a
equal deleted inserted replaced
480:793552e39173 481:ad71812ba395
68 has decided to clear a temporary watch expression 68 has decided to clear a temporary watch expression
69 @signal clientWatchConditionError(condition) emitted after the client has signaled 69 @signal clientWatchConditionError(condition) emitted after the client has signaled
70 a syntax error in a watch expression 70 a syntax error in a watch expression
71 @signal clientRawInput(prompt, echo) emitted after a raw input request was received 71 @signal clientRawInput(prompt, echo) emitted after a raw input request was received
72 @signal clientBanner(banner) emitted after the client banner was received 72 @signal clientBanner(banner) emitted after the client banner was received
73 @signal clientCapabilities(int capabilities, QString cltype) emitted after the clients 73 @signal clientCapabilities(int capabilities, string cltype) emitted after the clients
74 capabilities were received 74 capabilities were received
75 @signal clientCompletionList(completionList, text) emitted after the client 75 @signal clientCompletionList(completionList, text) emitted after the client
76 the commandline completion list and the reworked searchstring was 76 the commandline completion list and the reworked searchstring was
77 received from the client 77 received from the client
78 @signal passiveDebugStarted emitted after the debug client has connected in 78 @signal passiveDebugStarted emitted after the debug client has connected in
87 @signal utTestFailed(testname, exc_info) emitted after the client reported 87 @signal utTestFailed(testname, exc_info) emitted after the client reported
88 a failed test 88 a failed test
89 @signal utTestErrored(testname, exc_info) emitted after the client reported 89 @signal utTestErrored(testname, exc_info) emitted after the client reported
90 an errored test 90 an errored test
91 """ 91 """
92 clientClearBreak = pyqtSignal(str, int)
93 clientClearWatch = pyqtSignal(str)
94 clientGone = pyqtSignal(bool)
95 clientProcessStdout = pyqtSignal(str)
96 clientProcessStderr = pyqtSignal(str)
97 clientRawInputSent = pyqtSignal()
98 clientOutput = pyqtSignal(str)
99 clientLine = pyqtSignal(str, int, bool)
100 clientStack = pyqtSignal(list)
101 clientThreadList = pyqtSignal(int, list)
102 clientThreadSet = pyqtSignal()
103 clientVariables = pyqtSignal(int, list)
104 clientVariable = pyqtSignal(int, list)
105 clientStatement = pyqtSignal(bool)
106 clientException = pyqtSignal(str, str, list)
107 clientSyntaxError = pyqtSignal(str, str, int, int)
108 clientExit = pyqtSignal(int)
109 clientBreakConditionError = pyqtSignal(str, int)
110 clientWatchConditionError = pyqtSignal(str)
111 clientRawInput = pyqtSignal(str, bool)
112 clientBanner = pyqtSignal(str, str, str)
113 clientCapabilities = pyqtSignal(int, str)
114 clientCompletionList = pyqtSignal(list, str)
115 utPrepared = pyqtSignal(int, str, str)
116 utStartTest = pyqtSignal(str, str)
117 utStopTest = pyqtSignal()
118 utTestFailed = pyqtSignal(str, str)
119 utTestFailed = pyqtSignal(str, str)
120 utFinished = pyqtSignal()
121 passiveDebugStarted = pyqtSignal(str, bool)
122
92 def __init__(self): 123 def __init__(self):
93 """ 124 """
94 Constructor 125 Constructor
95 """ 126 """
96 QTcpServer.__init__(self) 127 QTcpServer.__init__(self)
125 self.clientType = \ 156 self.clientType = \
126 Preferences.Prefs.settings.value('DebugClient/Type', 'Python') 157 Preferences.Prefs.settings.value('DebugClient/Type', 'Python')
127 self.lastClientType = '' 158 self.lastClientType = ''
128 self.__autoClearShell = False 159 self.__autoClearShell = False
129 160
130 self.connect(self, SIGNAL("clientClearBreak"), self.__clientClearBreakPoint) 161 self.clientClearBreak.connect(self.__clientClearBreakPoint)
131 self.connect(self, SIGNAL("clientClearWatch"), self.__clientClearWatchPoint) 162 self.clientClearWatch.connect(self.__clientClearWatchPoint)
132 self.newConnection[()].connect(self.__newConnection) 163 self.newConnection[()].connect(self.__newConnection)
133 164
134 self.breakpointModel.rowsAboutToBeRemoved.connect(self.__deleteBreakPoints) 165 self.breakpointModel.rowsAboutToBeRemoved.connect(self.__deleteBreakPoints)
135 self.breakpointModel.dataAboutToBeChanged.connect( 166 self.breakpointModel.dataAboutToBeChanged.connect(
136 self.__breakPointDataAboutToBeChanged) 167 self.__breakPointDataAboutToBeChanged)
277 console window (boolean) 308 console window (boolean)
278 """ 309 """
279 if not self.passive or not self.passiveClientExited: 310 if not self.passive or not self.passiveClientExited:
280 if self.debuggerInterface and self.debuggerInterface.isConnected(): 311 if self.debuggerInterface and self.debuggerInterface.isConnected():
281 self.shutdownServer() 312 self.shutdownServer()
282 self.emit(SIGNAL('clientGone'), unplanned & self.debugging) 313 self.clientGone.emit(unplanned and self.debugging)
283 314
284 if clType: 315 if clType:
285 self.__setClientType(clType) 316 self.__setClientType(clType)
286 317
287 # only start the client, if we are not in passive mode 318 # only start the client, if we are not in passive mode
336 Private slot to process client output received via stdout. 367 Private slot to process client output received via stdout.
337 """ 368 """
338 output = str(self.clientProcess.readAllStandardOutput(), 369 output = str(self.clientProcess.readAllStandardOutput(),
339 Preferences.getSystem("IOEncoding"), 370 Preferences.getSystem("IOEncoding"),
340 'replace') 371 'replace')
341 self.emit(SIGNAL("clientProcessStdout"), output) 372 self.clientProcessStdout.emit(output)
342 373
343 def __clientProcessError(self): 374 def __clientProcessError(self):
344 """ 375 """
345 Private slot to process client output received via stderr. 376 Private slot to process client output received via stderr.
346 """ 377 """
347 error = str(self.clientProcess.readAllStandardError(), 378 error = str(self.clientProcess.readAllStandardError(),
348 Preferences.getSystem("IOEncoding"), 379 Preferences.getSystem("IOEncoding"),
349 'replace') 380 'replace')
350 self.emit(SIGNAL("clientProcessStderr"), error) 381 self.clientProcessStderr.emit(error)
351 382
352 def __clientClearBreakPoint(self, fn, lineno): 383 def __clientClearBreakPoint(self, fn, lineno):
353 """ 384 """
354 Private slot to handle the clientClearBreak signal. 385 Private slot to handle the clientClearBreak signal.
355 386
840 Public method to send the raw input to the debugged program. 871 Public method to send the raw input to the debugged program.
841 872
842 @param s the raw input (string) 873 @param s the raw input (string)
843 """ 874 """
844 self.debuggerInterface.remoteRawInput(s) 875 self.debuggerInterface.remoteRawInput(s)
845 self.emit(SIGNAL('clientRawInputSent')) 876 self.clientRawInputSent.emit()
846 877
847 def remoteThreadList(self): 878 def remoteThreadList(self):
848 """ 879 """
849 Public method to request the list of threads from the client. 880 Public method to request the list of threads from the client.
850 """ 881 """
957 """ 988 """
958 public method to stop a unittest run. 989 public method to stop a unittest run.
959 """ 990 """
960 self.debuggerInterface.remoteUTStop() 991 self.debuggerInterface.remoteUTStop()
961 992
962 def clientOutput(self, line): 993 def signalClientOutput(self, line):
963 """ 994 """
964 Public method to process a line of client output. 995 Public method to process a line of client output.
965 996
966 @param line client output (string) 997 @param line client output (string)
967 """ 998 """
968 self.emit(SIGNAL('clientOutput'), line) 999 self.clientOutput.emit(line)
969 1000
970 def clientLine(self, filename, lineno, forStack = False): 1001 def signalClientLine(self, filename, lineno, forStack = False):
971 """ 1002 """
972 Public method to process client position feedback. 1003 Public method to process client position feedback.
973 1004
974 @param filename name of the file currently being executed (string) 1005 @param filename name of the file currently being executed (string)
975 @param lineno line of code currently being executed (integer) 1006 @param lineno line of code currently being executed (integer)
976 @param forStack flag indicating this is for a stack dump (boolean) 1007 @param forStack flag indicating this is for a stack dump (boolean)
977 """ 1008 """
978 self.emit(SIGNAL('clientLine'), filename, lineno, forStack) 1009 self.clientLine.emit(filename, lineno, forStack)
979 1010
980 def clientStack(self, stack): 1011 def signalClientStack(self, stack):
981 """ 1012 """
982 Public method to process a client's stack information. 1013 Public method to process a client's stack information.
983 1014
984 @param stack list of stack entries. Each entry is a tuple of three 1015 @param stack list of stack entries. Each entry is a tuple of three
985 values giving the filename, linenumber and method 1016 values giving the filename, linenumber and method
986 (list of lists of (string, integer, string)) 1017 (list of lists of (string, integer, string))
987 """ 1018 """
988 self.emit(SIGNAL('clientStack'), stack) 1019 self.clientStack.emit(stack)
989 1020
990 def clientThreadList(self, currentId, threadList): 1021 def signalClientThreadList(self, currentId, threadList):
991 """ 1022 """
992 Public method to process the client thread list info. 1023 Public method to process the client thread list info.
993 1024
994 @param currentID id of the current thread (integer) 1025 @param currentID id of the current thread (integer)
995 @param threadList list of dictionaries containing the thread data 1026 @param threadList list of dictionaries containing the thread data
996 """ 1027 """
997 self.emit(SIGNAL('clientThreadList'), currentId, threadList) 1028 self.clientThreadList.emit(currentId, threadList)
998 1029
999 def clientThreadSet(self): 1030 def signalClientThreadSet(self):
1000 """ 1031 """
1001 Public method to handle the change of the client thread. 1032 Public method to handle the change of the client thread.
1002 """ 1033 """
1003 self.emit(SIGNAL('clientThreadSet')) 1034 self.clientThreadSet.emit()
1004 1035
1005 def clientVariables(self, scope, variables): 1036 def signalClientVariables(self, scope, variables):
1006 """ 1037 """
1007 Public method to process the client variables info. 1038 Public method to process the client variables info.
1008 1039
1009 @param scope scope of the variables (-1 = empty global, 1 = global, 0 = local) 1040 @param scope scope of the variables (-1 = empty global, 1 = global, 0 = local)
1010 @param variables the list of variables from the client 1041 @param variables the list of variables from the client
1011 """ 1042 """
1012 self.emit(SIGNAL('clientVariables'), scope, variables) 1043 self.clientVariables.emit(scope, variables)
1013 1044
1014 def clientVariable(self, scope, variables): 1045 def signalClientVariable(self, scope, variables):
1015 """ 1046 """
1016 Public method to process the client variable info. 1047 Public method to process the client variable info.
1017 1048
1018 @param scope scope of the variables (-1 = empty global, 1 = global, 0 = local) 1049 @param scope scope of the variables (-1 = empty global, 1 = global, 0 = local)
1019 @param variables the list of members of a classvariable from the client 1050 @param variables the list of members of a classvariable from the client
1020 """ 1051 """
1021 self.emit(SIGNAL('clientVariable'), scope, variables) 1052 self.clientVariable.emit(scope, variables)
1022 1053
1023 def clientStatement(self, more): 1054 def signalClientStatement(self, more):
1024 """ 1055 """
1025 Public method to process the input response from the client. 1056 Public method to process the input response from the client.
1026 1057
1027 @param more flag indicating that more user input is required 1058 @param more flag indicating that more user input is required
1028 """ 1059 """
1029 self.emit(SIGNAL('clientStatement'), more) 1060 self.clientStatement.emit(more)
1030 1061
1031 def clientException(self, exceptionType, exceptionMessage, stackTrace): 1062 def signalClientException(self, exceptionType, exceptionMessage, stackTrace):
1032 """ 1063 """
1033 Public method to process the exception info from the client. 1064 Public method to process the exception info from the client.
1034 1065
1035 @param exceptionType type of exception raised (string) 1066 @param exceptionType type of exception raised (string)
1036 @param exceptionMessage message given by the exception (string) 1067 @param exceptionMessage message given by the exception (string)
1037 @param stackTrace list of stack entries with the exception position 1068 @param stackTrace list of stack entries with the exception position
1038 first. Each stack entry is a list giving the filename and the linenumber. 1069 first. Each stack entry is a list giving the filename and the linenumber.
1039 """ 1070 """
1040 self.emit(SIGNAL('clientException'), exceptionType, exceptionMessage, stackTrace) 1071 self.clientException.emit(exceptionType, exceptionMessage, stackTrace)
1041 1072
1042 def clientSyntaxError(self, message, filename, lineNo, characterNo): 1073 def signalClientSyntaxError(self, message, filename, lineNo, characterNo):
1043 """ 1074 """
1044 Public method to process the syntax error info from the client. 1075 Public method to process the syntax error info from the client.
1045 1076
1046 @param message message of the syntax error (string) 1077 @param message message of the syntax error (string)
1047 @param filename translated filename of the syntax error position (string) 1078 @param filename translated filename of the syntax error position (string)
1048 @param lineNo line number of the syntax error position (integer) 1079 @param lineNo line number of the syntax error position (integer)
1049 @param characterNo character number of the syntax error position (integer) 1080 @param characterNo character number of the syntax error position (integer)
1050 """ 1081 """
1051 self.emit(SIGNAL('clientSyntaxError'), message, filename, lineNo, characterNo) 1082 self.clientSyntaxError.emit(message, filename, lineNo, characterNo)
1052 1083
1053 def clientExit(self, status): 1084 def signalClientExit(self, status):
1054 """ 1085 """
1055 Public method to process the client exit status. 1086 Public method to process the client exit status.
1056 1087
1057 @param status exit code as a string (string) 1088 @param status exit code as a string (string)
1058 """ 1089 """
1059 if self.passive: 1090 if self.passive:
1060 self.__passiveShutDown() 1091 self.__passiveShutDown()
1061 self.emit(SIGNAL('clientExit(int)'), int(status)) 1092 self.clientExit.emit(int(status))
1062 if Preferences.getDebugger("AutomaticReset"): 1093 if Preferences.getDebugger("AutomaticReset"):
1063 self.startClient(False) 1094 self.startClient(False)
1064 if self.passive: 1095 if self.passive:
1065 self.__createDebuggerInterface("None") 1096 self.__createDebuggerInterface("None")
1066 self.clientOutput(self.trUtf8('\nNot connected\n')) 1097 self.signalClientOutput(self.trUtf8('\nNot connected\n'))
1067 self.clientStatement(False) 1098 self.signalClientStatement(False)
1068 1099
1069 def clientClearBreak(self, filename, lineno): 1100 def signalClientClearBreak(self, filename, lineno):
1070 """ 1101 """
1071 Public method to process the client clear breakpoint command. 1102 Public method to process the client clear breakpoint command.
1072 1103
1073 @param filename filename of the breakpoint (string) 1104 @param filename filename of the breakpoint (string)
1074 @param lineno line umber of the breakpoint (integer) 1105 @param lineno line umber of the breakpoint (integer)
1075 """ 1106 """
1076 self.emit(SIGNAL('clientClearBreak'), filename, lineno) 1107 self.clientClearBreak.emit(filename, lineno)
1077 1108
1078 def clientBreakConditionError(self, filename, lineno): 1109 def signalClientBreakConditionError(self, filename, lineno):
1079 """ 1110 """
1080 Public method to process the client breakpoint condition error info. 1111 Public method to process the client breakpoint condition error info.
1081 1112
1082 @param filename filename of the breakpoint (string) 1113 @param filename filename of the breakpoint (string)
1083 @param lineno line umber of the breakpoint (integer) 1114 @param lineno line umber of the breakpoint (integer)
1084 """ 1115 """
1085 self.emit(SIGNAL('clientBreakConditionError'), filename, lineno) 1116 self.clientBreakConditionError.emit(filename, lineno)
1086 1117
1087 def clientClearWatch(self, condition): 1118 def signalClientClearWatch(self, condition):
1088 """ 1119 """
1089 Public slot to handle the clientClearWatch signal. 1120 Public slot to handle the clientClearWatch signal.
1090 1121
1091 @param condition expression of watch expression to clear (string) 1122 @param condition expression of watch expression to clear (string)
1092 """ 1123 """
1093 self.emit(SIGNAL('clientClearWatch'), condition) 1124 self.clientClearWatch.emit(condition)
1094 1125
1095 def clientWatchConditionError(self, condition): 1126 def signalClientWatchConditionError(self, condition):
1096 """ 1127 """
1097 Public method to process the client watch expression error info. 1128 Public method to process the client watch expression error info.
1098 1129
1099 @param condition expression of watch expression to clear (string) 1130 @param condition expression of watch expression to clear (string)
1100 """ 1131 """
1101 self.emit(SIGNAL('clientWatchConditionError'), condition) 1132 self.clientWatchConditionError.emit(condition)
1102 1133
1103 def clientRawInput(self, prompt, echo): 1134 def signalClientRawInput(self, prompt, echo):
1104 """ 1135 """
1105 Public method to process the client raw input command. 1136 Public method to process the client raw input command.
1106 1137
1107 @param prompt the input prompt (string) 1138 @param prompt the input prompt (string)
1108 @param echo flag indicating an echoing of the input (boolean) 1139 @param echo flag indicating an echoing of the input (boolean)
1109 """ 1140 """
1110 self.emit(SIGNAL('clientRawInput'), prompt, echo) 1141 self.clientRawInput.emit(prompt, echo)
1111 1142
1112 def clientBanner(self, version, platform, debugClient): 1143 def signalClientBanner(self, version, platform, debugClient):
1113 """ 1144 """
1114 Public method to process the client banner info. 1145 Public method to process the client banner info.
1115 1146
1116 @param version interpreter version info (string) 1147 @param version interpreter version info (string)
1117 @param platform hostname of the client (string) 1148 @param platform hostname of the client (string)
1118 @param debugClient additional debugger type info (string) 1149 @param debugClient additional debugger type info (string)
1119 """ 1150 """
1120 self.emit(SIGNAL('clientBanner'), version, platform, debugClient) 1151 self.clientBanner.emit(version, platform, debugClient)
1121 1152
1122 def clientCapabilities(self, capabilities, clientType): 1153 def signalClientCapabilities(self, capabilities, clientType):
1123 """ 1154 """
1124 Public method to process the client capabilities info. 1155 Public method to process the client capabilities info.
1125 1156
1126 @param capabilities bitmaks with the client capabilities (integer) 1157 @param capabilities bitmaks with the client capabilities (integer)
1127 @param clientType type of the debug client (string) 1158 @param clientType type of the debug client (string)
1128 """ 1159 """
1129 self.__clientCapabilities[clientType] = capabilities 1160 self.__clientCapabilities[clientType] = capabilities
1130 self.emit(SIGNAL('clientCapabilities'), capabilities, clientType) 1161 self.clientCapabilities.emit(capabilities, clientType)
1131 1162
1132 def clientCompletionList(self, completionList, text): 1163 def signalClientCompletionList(self, completionList, text):
1133 """ 1164 """
1134 Public method to process the client auto completion info. 1165 Public method to process the client auto completion info.
1135 1166
1136 @param completionList list of possible completions (list of strings) 1167 @param completionList list of possible completions (list of strings)
1137 @param text the text to be completed (string) 1168 @param text the text to be completed (string)
1138 """ 1169 """
1139 self.emit(SIGNAL('clientCompletionList'), completionList, text) 1170 self.clientCompletionList.emit(completionList, text)
1140 1171
1141 def clientUtPrepared(self, result, exceptionType, exceptionValue): 1172 def clientUtPrepared(self, result, exceptionType, exceptionValue):
1142 """ 1173 """
1143 Public method to process the client unittest prepared info. 1174 Public method to process the client unittest prepared info.
1144 1175
1145 @param result number of test cases (0 = error) (integer) 1176 @param result number of test cases (0 = error) (integer)
1146 @param exceptionType exception type (string) 1177 @param exceptionType exception type (string)
1147 @param exceptionValue exception message (string) 1178 @param exceptionValue exception message (string)
1148 """ 1179 """
1149 self.emit(SIGNAL('utPrepared'), result, exceptionType, exceptionValue) 1180 self.utPrepared.emit(result, exceptionType, exceptionValue)
1150 1181
1151 def clientUtStartTest(self, testname, doc): 1182 def clientUtStartTest(self, testname, doc):
1152 """ 1183 """
1153 Public method to process the client start test info. 1184 Public method to process the client start test info.
1154 1185
1155 @param testname name of the test (string) 1186 @param testname name of the test (string)
1156 @param doc short description of the test (string) 1187 @param doc short description of the test (string)
1157 """ 1188 """
1158 self.emit(SIGNAL('utStartTest'), testname, doc) 1189 self.utStartTest.emit(testname, doc)
1159 1190
1160 def clientUtStopTest(self): 1191 def clientUtStopTest(self):
1161 """ 1192 """
1162 Public method to process the client stop test info. 1193 Public method to process the client stop test info.
1163 """ 1194 """
1164 self.emit(SIGNAL('utStopTest')) 1195 self.utStopTest.emit()
1165 1196
1166 def clientUtTestFailed(self, testname, traceback): 1197 def clientUtTestFailed(self, testname, traceback):
1167 """ 1198 """
1168 Public method to process the client test failed info. 1199 Public method to process the client test failed info.
1169 1200
1170 @param testname name of the test (string) 1201 @param testname name of the test (string)
1171 @param traceback lines of traceback info (string) 1202 @param traceback lines of traceback info (string)
1172 """ 1203 """
1173 self.emit(SIGNAL('utTestFailed'), testname, traceback) 1204 self.utTestFailed.emit(testname, traceback)
1174 1205
1175 def clientUtTestErrored(self, testname, traceback): 1206 def clientUtTestErrored(self, testname, traceback):
1176 """ 1207 """
1177 Public method to process the client test errored info. 1208 Public method to process the client test errored info.
1178 1209
1179 @param testname name of the test (string) 1210 @param testname name of the test (string)
1180 @param traceback lines of traceback info (string) 1211 @param traceback lines of traceback info (string)
1181 """ 1212 """
1182 self.emit(SIGNAL('utTestErrored'), testname, traceback) 1213 self.utTestErrored.emit(testname, traceback)
1183 1214
1184 def clientUtFinished(self): 1215 def clientUtFinished(self):
1185 """ 1216 """
1186 Public method to process the client unit test finished info. 1217 Public method to process the client unit test finished info.
1187 """ 1218 """
1188 self.emit(SIGNAL('utFinished')) 1219 self.utFinished.emit()
1189 1220
1190 def passiveStartUp(self, fn, exc): 1221 def passiveStartUp(self, fn, exc):
1191 """ 1222 """
1192 Public method to handle a passive debug connection. 1223 Public method to handle a passive debug connection.
1193 1224
1197 print(self.trUtf8("Passive debug connection received")) 1228 print(self.trUtf8("Passive debug connection received"))
1198 self.passiveClientExited = False 1229 self.passiveClientExited = False
1199 self.debugging = True 1230 self.debugging = True
1200 self.__restoreBreakpoints() 1231 self.__restoreBreakpoints()
1201 self.__restoreWatchpoints() 1232 self.__restoreWatchpoints()
1202 self.emit(SIGNAL('passiveDebugStarted'), fn, exc) 1233 self.passiveDebugStarted.emit(fn, exc)
1203 1234
1204 def __passiveShutDown(self): 1235 def __passiveShutDown(self):
1205 """ 1236 """
1206 Private method to shut down a passive debug connection. 1237 Private method to shut down a passive debug connection.
1207 """ 1238 """

eric ide

mercurial