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