|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2007 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dummy debugger interface for the debug server. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtCore import QObject |
|
13 |
|
14 |
|
15 ClientDefaultCapabilities = 0 |
|
16 |
|
17 ClientTypeAssociations = [] |
|
18 |
|
19 |
|
20 class DebuggerInterfaceNone(QObject): |
|
21 """ |
|
22 Class implementing a dummy debugger interface for the debug server. |
|
23 """ |
|
24 def __init__(self, debugServer, passive): |
|
25 """ |
|
26 Constructor |
|
27 |
|
28 @param debugServer reference to the debug server (DebugServer) |
|
29 @param passive flag indicating passive connection mode (boolean) |
|
30 """ |
|
31 super(DebuggerInterfaceNone, self).__init__() |
|
32 |
|
33 self.debugServer = debugServer |
|
34 self.passive = passive |
|
35 |
|
36 self.qsock = None |
|
37 self.queue = [] |
|
38 # set default values for capabilities of clients |
|
39 self.clientCapabilities = ClientDefaultCapabilities |
|
40 |
|
41 def startRemote(self, port, runInConsole, venvName, originalPathString, |
|
42 workingDir=None): |
|
43 """ |
|
44 Public method to start a remote Python interpreter. |
|
45 |
|
46 @param port port number the debug server is listening on |
|
47 @type int |
|
48 @param runInConsole flag indicating to start the debugger in a |
|
49 console window |
|
50 @type bool |
|
51 @param venvName name of the virtual environment to be used |
|
52 @type str |
|
53 @param originalPathString original PATH environment variable |
|
54 @type str |
|
55 @param workingDir directory to start the debugger client in |
|
56 @type str |
|
57 @return client process object, a flag to indicate a network connection |
|
58 and the name of the interpreter in case of a local execution |
|
59 @rtype tuple of (QProcess, bool, str) |
|
60 """ |
|
61 return None, True, "" |
|
62 |
|
63 def startRemoteForProject(self, port, runInConsole, venvName, |
|
64 originalPathString, workingDir=None): |
|
65 """ |
|
66 Public method to start a remote Python interpreter for a project. |
|
67 |
|
68 @param port port number the debug server is listening on |
|
69 @type int |
|
70 @param runInConsole flag indicating to start the debugger in a |
|
71 console window |
|
72 @type bool |
|
73 @param venvName name of the virtual environment to be used |
|
74 @type str |
|
75 @param originalPathString original PATH environment variable |
|
76 @type str |
|
77 @param workingDir directory to start the debugger client in |
|
78 @type str |
|
79 @return client process object, a flag to indicate a network connection |
|
80 and the name of the interpreter in case of a local execution |
|
81 @rtype tuple of (QProcess, bool, str) |
|
82 """ |
|
83 return None, True, "" |
|
84 |
|
85 def getClientCapabilities(self): |
|
86 """ |
|
87 Public method to retrieve the debug clients capabilities. |
|
88 |
|
89 @return debug client capabilities (integer) |
|
90 """ |
|
91 return self.clientCapabilities |
|
92 |
|
93 def newConnection(self, sock): |
|
94 """ |
|
95 Public slot to handle a new connection. |
|
96 |
|
97 @param sock reference to the socket object (QTcpSocket) |
|
98 @return flag indicating success (boolean) |
|
99 """ |
|
100 return False |
|
101 |
|
102 def flush(self): |
|
103 """ |
|
104 Public slot to flush the queue. |
|
105 """ |
|
106 self.queue = [] |
|
107 |
|
108 def shutdown(self): |
|
109 """ |
|
110 Public method to cleanly shut down. |
|
111 |
|
112 It closes our socket and shuts down |
|
113 the debug client. (Needed on Win OS) |
|
114 """ |
|
115 self.qsock = None |
|
116 self.queue = [] |
|
117 |
|
118 def isConnected(self): |
|
119 """ |
|
120 Public method to test, if a debug client has connected. |
|
121 |
|
122 @return flag indicating the connection status (boolean) |
|
123 """ |
|
124 return self.qsock is not None |
|
125 |
|
126 def remoteEnvironment(self, env): |
|
127 """ |
|
128 Public method to set the environment for a program to debug, run, ... |
|
129 |
|
130 @param env environment settings (dictionary) |
|
131 """ |
|
132 return |
|
133 |
|
134 def remoteLoad(self, fn, argv, wd, traceInterpreter=False, |
|
135 autoContinue=True, autoFork=False, forkChild=False): |
|
136 """ |
|
137 Public method to load a new program to debug. |
|
138 |
|
139 @param fn the filename to debug (string) |
|
140 @param argv the commandline arguments to pass to the program (string) |
|
141 @param wd the working directory for the program (string) |
|
142 @keyparam traceInterpreter flag indicating if the interpreter library |
|
143 should be traced as well (boolean) |
|
144 @keyparam autoContinue flag indicating, that the debugger should not |
|
145 stop at the first executable line (boolean) |
|
146 @keyparam autoFork flag indicating the automatic fork mode (boolean) |
|
147 @keyparam forkChild flag indicating to debug the child after forking |
|
148 (boolean) |
|
149 """ |
|
150 return |
|
151 |
|
152 def remoteRun(self, fn, argv, wd, autoFork=False, forkChild=False): |
|
153 """ |
|
154 Public method to load a new program to run. |
|
155 |
|
156 @param fn the filename to run (string) |
|
157 @param argv the commandline arguments to pass to the program (string) |
|
158 @param wd the working directory for the program (string) |
|
159 @keyparam autoFork flag indicating the automatic fork mode (boolean) |
|
160 @keyparam forkChild flag indicating to debug the child after forking |
|
161 (boolean) |
|
162 """ |
|
163 return |
|
164 |
|
165 def remoteCoverage(self, fn, argv, wd, erase=False): |
|
166 """ |
|
167 Public method to load a new program to collect coverage data. |
|
168 |
|
169 @param fn the filename to run (string) |
|
170 @param argv the commandline arguments to pass to the program (string) |
|
171 @param wd the working directory for the program (string) |
|
172 @keyparam erase flag indicating that coverage info should be |
|
173 cleared first (boolean) |
|
174 """ |
|
175 return |
|
176 |
|
177 def remoteProfile(self, fn, argv, wd, erase=False): |
|
178 """ |
|
179 Public method to load a new program to collect profiling data. |
|
180 |
|
181 @param fn the filename to run (string) |
|
182 @param argv the commandline arguments to pass to the program (string) |
|
183 @param wd the working directory for the program (string) |
|
184 @keyparam erase flag indicating that timing info should be cleared |
|
185 first (boolean) |
|
186 """ |
|
187 return |
|
188 |
|
189 def remoteStatement(self, stmt): |
|
190 """ |
|
191 Public method to execute a Python statement. |
|
192 |
|
193 @param stmt the Python statement to execute (string). It |
|
194 should not have a trailing newline. |
|
195 """ |
|
196 self.debugServer.signalClientStatement(False) |
|
197 return |
|
198 |
|
199 def remoteStep(self): |
|
200 """ |
|
201 Public method to single step the debugged program. |
|
202 """ |
|
203 return |
|
204 |
|
205 def remoteStepOver(self): |
|
206 """ |
|
207 Public method to step over the debugged program. |
|
208 """ |
|
209 return |
|
210 |
|
211 def remoteStepOut(self): |
|
212 """ |
|
213 Public method to step out the debugged program. |
|
214 """ |
|
215 return |
|
216 |
|
217 def remoteStepQuit(self): |
|
218 """ |
|
219 Public method to stop the debugged program. |
|
220 """ |
|
221 return |
|
222 |
|
223 def remoteContinue(self, special=False): |
|
224 """ |
|
225 Public method to continue the debugged program. |
|
226 |
|
227 @param special flag indicating a special continue operation |
|
228 """ |
|
229 return |
|
230 |
|
231 def remoteMoveIP(self, line): |
|
232 """ |
|
233 Public method to move the instruction pointer to a different line. |
|
234 |
|
235 @param line the new line, where execution should be continued |
|
236 """ |
|
237 return |
|
238 |
|
239 def remoteBreakpoint(self, fn, line, setBreakpoint, cond=None, temp=False): |
|
240 """ |
|
241 Public method to set or clear a breakpoint. |
|
242 |
|
243 @param fn filename the breakpoint belongs to (string) |
|
244 @param line linenumber of the breakpoint (int) |
|
245 @param setBreakpoint flag indicating setting or resetting a |
|
246 breakpoint (boolean) |
|
247 @param cond condition of the breakpoint (string) |
|
248 @param temp flag indicating a temporary breakpoint (boolean) |
|
249 """ |
|
250 return |
|
251 |
|
252 def remoteBreakpointEnable(self, fn, line, enable): |
|
253 """ |
|
254 Public method to enable or disable a breakpoint. |
|
255 |
|
256 @param fn filename the breakpoint belongs to (string) |
|
257 @param line linenumber of the breakpoint (int) |
|
258 @param enable flag indicating enabling or disabling a breakpoint |
|
259 (boolean) |
|
260 """ |
|
261 return |
|
262 |
|
263 def remoteBreakpointIgnore(self, fn, line, count): |
|
264 """ |
|
265 Public method to ignore a breakpoint the next couple of occurrences. |
|
266 |
|
267 @param fn filename the breakpoint belongs to (string) |
|
268 @param line linenumber of the breakpoint (int) |
|
269 @param count number of occurrences to ignore (int) |
|
270 """ |
|
271 return |
|
272 |
|
273 def remoteWatchpoint(self, cond, setWatch, temp=False): |
|
274 """ |
|
275 Public method to set or clear a watch expression. |
|
276 |
|
277 @param cond expression of the watch expression (string) |
|
278 @param setWatch flag indicating setting or resetting a watch expression |
|
279 (boolean) |
|
280 @param temp flag indicating a temporary watch expression (boolean) |
|
281 """ |
|
282 return |
|
283 |
|
284 def remoteWatchpointEnable(self, cond, enable): |
|
285 """ |
|
286 Public method to enable or disable a watch expression. |
|
287 |
|
288 @param cond expression of the watch expression (string) |
|
289 @param enable flag indicating enabling or disabling a watch |
|
290 expression (boolean) |
|
291 """ |
|
292 return |
|
293 |
|
294 def remoteWatchpointIgnore(self, cond, count): |
|
295 """ |
|
296 Public method to ignore a watch expression the next couple of |
|
297 occurrences. |
|
298 |
|
299 @param cond expression of the watch expression (string) |
|
300 @param count number of occurrences to ignore (int) |
|
301 """ |
|
302 return |
|
303 |
|
304 def remoteRawInput(self, s): |
|
305 """ |
|
306 Public method to send the raw input to the debugged program. |
|
307 |
|
308 @param s the raw input (string) |
|
309 """ |
|
310 return |
|
311 |
|
312 def remoteThreadList(self): |
|
313 """ |
|
314 Public method to request the list of threads from the client. |
|
315 """ |
|
316 return |
|
317 |
|
318 def remoteSetThread(self, tid): |
|
319 """ |
|
320 Public method to request to set the given thread as current thread. |
|
321 |
|
322 @param tid id of the thread (integer) |
|
323 """ |
|
324 return |
|
325 |
|
326 def remoteClientVariables(self, scope, filterList, framenr=0, maxSize=0): |
|
327 """ |
|
328 Public method to request the variables of the debugged program. |
|
329 |
|
330 @param scope the scope of the variables (0 = local, 1 = global) |
|
331 @type int |
|
332 @param filterList list of variable types to filter out |
|
333 @type list of int |
|
334 @param framenr framenumber of the variables to retrieve |
|
335 @type int |
|
336 @param maxSize maximum size the formatted value of a variable will |
|
337 be shown. If it is bigger than that, a 'too big' indication will |
|
338 be given (@@TOO_BIG_TO_SHOW@@). |
|
339 @type int |
|
340 """ |
|
341 return |
|
342 |
|
343 def remoteClientVariable(self, scope, filterList, var, framenr=0, |
|
344 maxSize=0): |
|
345 """ |
|
346 Public method to request the variables of the debugged program. |
|
347 |
|
348 @param scope the scope of the variables (0 = local, 1 = global) |
|
349 @type int |
|
350 @param filterList list of variable types to filter out |
|
351 @type list of int |
|
352 @param var list encoded name of variable to retrieve |
|
353 @type list of str |
|
354 @param framenr framenumber of the variables to retrieve (int) |
|
355 @type int |
|
356 @param maxSize maximum size the formatted value of a variable will |
|
357 be shown. If it is bigger than that, a 'too big' indication will |
|
358 be given (@@TOO_BIG_TO_SHOW@@). |
|
359 @type int |
|
360 """ |
|
361 return |
|
362 |
|
363 def remoteClientSetFilter(self, scope, filterStr): |
|
364 """ |
|
365 Public method to set a variables filter list. |
|
366 |
|
367 @param scope the scope of the variables (0 = local, 1 = global) |
|
368 @param filterStr regexp string for variable names to filter out |
|
369 (string) |
|
370 """ |
|
371 return |
|
372 |
|
373 def setCallTraceEnabled(self, on): |
|
374 """ |
|
375 Public method to set the call trace state. |
|
376 |
|
377 @param on flag indicating to enable the call trace function (boolean) |
|
378 """ |
|
379 return |
|
380 |
|
381 def remoteEval(self, arg): |
|
382 """ |
|
383 Public method to evaluate arg in the current context of the debugged |
|
384 program. |
|
385 |
|
386 @param arg the arguments to evaluate (string) |
|
387 """ |
|
388 return |
|
389 |
|
390 def remoteBanner(self): |
|
391 """ |
|
392 Public slot to get the banner info of the remote client. |
|
393 """ |
|
394 return |
|
395 |
|
396 def remoteCapabilities(self): |
|
397 """ |
|
398 Public slot to get the debug clients capabilities. |
|
399 """ |
|
400 return |
|
401 |
|
402 def remoteCompletion(self, text): |
|
403 """ |
|
404 Public slot to get the a list of possible commandline completions |
|
405 from the remote client. |
|
406 |
|
407 @param text the text to be completed (string) |
|
408 """ |
|
409 return |
|
410 |
|
411 def remoteUTDiscover(self, syspath, workdir, discoveryStart): |
|
412 """ |
|
413 Public method to perform a test case discovery. |
|
414 |
|
415 @param syspath list of directories to be added to sys.path on the |
|
416 remote side |
|
417 @type list of str |
|
418 @param workdir path name of the working directory |
|
419 @type str |
|
420 @param discoveryStart directory to start auto-discovery at |
|
421 @type str |
|
422 """ |
|
423 return |
|
424 |
|
425 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase, |
|
426 syspath, workdir, discover, discoveryStart, testCases, |
|
427 debug): |
|
428 """ |
|
429 Public method to prepare a new unittest run. |
|
430 |
|
431 @param fn name of file to load |
|
432 @type str |
|
433 @param tn name of test to load |
|
434 @type str |
|
435 @param tfn test function name to load tests from |
|
436 @type str |
|
437 @param failed list of failed test, if only failed test should be run |
|
438 @type list of str |
|
439 @param cov flag indicating collection of coverage data is requested |
|
440 @type bool |
|
441 @param covname name of file to be used to assemble the coverage caches |
|
442 filename |
|
443 @type str |
|
444 @param coverase flag indicating erasure of coverage data is requested |
|
445 @type bool |
|
446 @param syspath list of directories to be added to sys.path on the |
|
447 remote side |
|
448 @type list of str |
|
449 @param workdir path name of the working directory |
|
450 @type str |
|
451 @param discover flag indicating to discover the tests automatically |
|
452 @type bool |
|
453 @param discoveryStart directory to start auto-discovery at |
|
454 @type str |
|
455 @param testCases list of test cases to be loaded |
|
456 @type list of str |
|
457 @param debug flag indicating to run unittest with debugging |
|
458 @type bool |
|
459 """ |
|
460 return |
|
461 |
|
462 def remoteUTRun(self, debug, failfast): |
|
463 """ |
|
464 Public method to start a unittest run. |
|
465 |
|
466 @param debug flag indicating to run unittest with debugging |
|
467 @type bool |
|
468 @param failfast flag indicating to stop at the first error |
|
469 @type bool |
|
470 """ |
|
471 return |
|
472 |
|
473 def remoteUTStop(self): |
|
474 """ |
|
475 public method to stop a unittest run. |
|
476 """ |
|
477 return |
|
478 |
|
479 |
|
480 def createDebuggerInterfaceNone(debugServer, passive): |
|
481 """ |
|
482 Module function to create a debugger interface instance. |
|
483 |
|
484 |
|
485 @param debugServer reference to the debug server |
|
486 @type DebugServer |
|
487 @param passive flag indicating passive connection mode |
|
488 @type bool |
|
489 @return instantiated debugger interface |
|
490 @rtype DebuggerInterfaceNone |
|
491 """ |
|
492 return DebuggerInterfaceNone(debugServer, passive) |
|
493 |
|
494 |
|
495 def getRegistryData(): |
|
496 """ |
|
497 Module function to get characterizing data for the debugger interface. |
|
498 |
|
499 @return list of tuples containing the client type, the client capabilities, |
|
500 the client file type associations and a reference to the creation |
|
501 function |
|
502 @rtype list of tuple of (str, int, list of str, function) |
|
503 """ |
|
504 return [("None", ClientDefaultCapabilities, ClientTypeAssociations, |
|
505 createDebuggerInterfaceNone)] |