160 return None, False |
162 return None, False |
161 |
163 |
162 debugClientType = Preferences.getDebugger("DebugClientType") |
164 debugClientType = Preferences.getDebugger("DebugClientType") |
163 if debugClientType == "standard": |
165 if debugClientType == "standard": |
164 debugClient = os.path.join(getConfig('ericDir'), |
166 debugClient = os.path.join(getConfig('ericDir'), |
165 "DebugClients", "Python", "DebugClient.py") |
167 "DebugClients", "Python", |
|
168 "DebugClient.py") |
166 elif debugClientType == "threaded": |
169 elif debugClientType == "threaded": |
167 debugClient = os.path.join(getConfig('ericDir'), |
170 debugClient = os.path.join(getConfig('ericDir'), |
168 "DebugClients", "Python", "DebugClientThreads.py") |
171 "DebugClients", "Python", |
|
172 "DebugClientThreads.py") |
169 else: |
173 else: |
170 debugClient = Preferences.getDebugger("DebugClient") |
174 debugClient = Preferences.getDebugger("DebugClient") |
171 if debugClient == "": |
175 if debugClient == "": |
172 debugClient = os.path.join(sys.path[0], |
176 debugClient = os.path.join(sys.path[0], |
173 "DebugClients", "Python", "DebugClient.py") |
177 "DebugClients", "Python", |
|
178 "DebugClient.py") |
174 |
179 |
175 redirect = str(Preferences.getDebugger("PythonRedirect")) |
180 redirect = str(Preferences.getDebugger("PythonRedirect")) |
176 noencoding = \ |
181 noencoding = Preferences.getDebugger("PythonNoEncoding") and \ |
177 Preferences.getDebugger("PythonNoEncoding") and '--no-encoding' or '' |
182 '--no-encoding' or '' |
178 |
183 |
179 if Preferences.getDebugger("RemoteDbgEnabled"): |
184 if Preferences.getDebugger("RemoteDbgEnabled"): |
180 ipaddr = self.debugServer.getHostAddress(False) |
185 ipaddr = self.debugServer.getHostAddress(False) |
181 rexec = Preferences.getDebugger("RemoteExecution") |
186 rexec = Preferences.getDebugger("RemoteExecution") |
182 rhost = Preferences.getDebugger("RemoteHost") |
187 rhost = Preferences.getDebugger("RemoteHost") |
235 process = self.__startProcess(args[0], args[1:], clientEnv) |
241 process = self.__startProcess(args[0], args[1:], clientEnv) |
236 if process is None: |
242 if process is None: |
237 E5MessageBox.critical(None, |
243 E5MessageBox.critical(None, |
238 self.trUtf8("Start Debugger"), |
244 self.trUtf8("Start Debugger"), |
239 self.trUtf8( |
245 self.trUtf8( |
240 """<p>The debugger backend could not be started.</p>""")) |
246 """<p>The debugger backend could not be""" |
|
247 """ started.</p>""")) |
241 return process, self.__isNetworked |
248 return process, self.__isNetworked |
242 |
249 |
243 process = self.__startProcess(interpreter, |
250 process = self.__startProcess(interpreter, |
244 [debugClient, noencoding, str(port), redirect, ipaddr], |
251 [debugClient, noencoding, str(port), redirect, ipaddr], |
245 clientEnv) |
252 clientEnv) |
246 if process is None: |
253 if process is None: |
247 E5MessageBox.critical(None, |
254 E5MessageBox.critical(None, |
248 self.trUtf8("Start Debugger"), |
255 self.trUtf8("Start Debugger"), |
249 self.trUtf8("""<p>The debugger backend could not be started.</p>""")) |
256 self.trUtf8( |
|
257 """<p>The debugger backend could not be started.</p>""")) |
250 return process, self.__isNetworked |
258 return process, self.__isNetworked |
251 |
259 |
252 def startRemoteForProject(self, port, runInConsole): |
260 def startRemoteForProject(self, port, runInConsole): |
253 """ |
261 """ |
254 Public method to start a remote Python interpreter for a project. |
262 Public method to start a remote Python interpreter for a project. |
285 process = self.__startProcess(args[0], args[1:]) |
293 process = self.__startProcess(args[0], args[1:]) |
286 if process is None: |
294 if process is None: |
287 E5MessageBox.critical(None, |
295 E5MessageBox.critical(None, |
288 self.trUtf8("Start Debugger"), |
296 self.trUtf8("Start Debugger"), |
289 self.trUtf8( |
297 self.trUtf8( |
290 """<p>The debugger backend could not be started.</p>""")) |
298 """<p>The debugger backend could not be""" |
|
299 """ started.</p>""")) |
291 # set translation function |
300 # set translation function |
292 if project.getDebugProperty("PATHTRANSLATION"): |
301 if project.getDebugProperty("PATHTRANSLATION"): |
293 self.translateRemote = project.getDebugProperty("REMOTEPATH") |
302 self.translateRemote = \ |
294 self.translateLocal = project.getDebugProperty("LOCALPATH") |
303 project.getDebugProperty("REMOTEPATH") |
|
304 self.translateLocal = \ |
|
305 project.getDebugProperty("LOCALPATH") |
295 self.translate = self.__remoteTranslation |
306 self.translate = self.__remoteTranslation |
296 else: |
307 else: |
297 self.translate = self.__identityTranslation |
308 self.translate = self.__identityTranslation |
298 return process, self.__isNetworked |
309 return process, self.__isNetworked |
299 |
310 |
328 process = self.__startProcess(args[0], args[1:], clientEnv) |
339 process = self.__startProcess(args[0], args[1:], clientEnv) |
329 if process is None: |
340 if process is None: |
330 E5MessageBox.critical(None, |
341 E5MessageBox.critical(None, |
331 self.trUtf8("Start Debugger"), |
342 self.trUtf8("Start Debugger"), |
332 self.trUtf8( |
343 self.trUtf8( |
333 """<p>The debugger backend could not be started.</p>""")) |
344 """<p>The debugger backend could not be""" |
|
345 """ started.</p>""")) |
334 return process, self.__isNetworked |
346 return process, self.__isNetworked |
335 |
347 |
336 process = self.__startProcess(interpreter, |
348 process = self.__startProcess(interpreter, |
337 [debugClient, noencoding, str(port), redirect, ipaddr], |
349 [debugClient, noencoding, str(port), redirect, ipaddr], |
338 clientEnv) |
350 clientEnv) |
339 if process is None: |
351 if process is None: |
340 E5MessageBox.critical(None, |
352 E5MessageBox.critical(None, |
341 self.trUtf8("Start Debugger"), |
353 self.trUtf8("Start Debugger"), |
342 self.trUtf8("""<p>The debugger backend could not be started.</p>""")) |
354 self.trUtf8( |
|
355 """<p>The debugger backend could not be started.</p>""")) |
343 return process, self.__isNetworked |
356 return process, self.__isNetworked |
344 |
357 |
345 def getClientCapabilities(self): |
358 def getClientCapabilities(self): |
346 """ |
359 """ |
347 Public method to retrieve the debug clients capabilities. |
360 Public method to retrieve the debug clients capabilities. |
417 """ |
430 """ |
418 Public method to set the environment for a program to debug, run, ... |
431 Public method to set the environment for a program to debug, run, ... |
419 |
432 |
420 @param env environment settings (dictionary) |
433 @param env environment settings (dictionary) |
421 """ |
434 """ |
422 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEnv, str(env))) |
435 self.__sendCommand('{0}{1}\n'.format( |
|
436 DebugProtocol.RequestEnv, str(env))) |
423 |
437 |
424 def remoteLoad(self, fn, argv, wd, traceInterpreter=False, autoContinue=True, |
438 def remoteLoad(self, fn, argv, wd, traceInterpreter=False, autoContinue=True, |
425 autoFork=False, forkChild=False): |
439 autoFork=False, forkChild=False): |
426 """ |
440 """ |
427 Public method to load a new program to debug. |
441 Public method to load a new program to debug. |
428 |
442 |
429 @param fn the filename to debug (string) |
443 @param fn the filename to debug (string) |
430 @param argv the commandline arguments to pass to the program (string) |
444 @param argv the commandline arguments to pass to the program (string) |
431 @param wd the working directory for the program (string) |
445 @param wd the working directory for the program (string) |
432 @keyparam traceInterpreter flag indicating if the interpreter library should be |
446 @keyparam traceInterpreter flag indicating if the interpreter library |
433 traced as well (boolean) |
447 should be traced as well (boolean) |
434 @keyparam autoContinue flag indicating, that the debugger should not stop |
448 @keyparam autoContinue flag indicating, that the debugger should not |
435 at the first executable line (boolean) |
449 stop at the first executable line (boolean) |
436 @keyparam autoFork flag indicating the automatic fork mode (boolean) |
450 @keyparam autoFork flag indicating the automatic fork mode (boolean) |
437 @keyparam forkChild flag indicating to debug the child after forking (boolean) |
451 @keyparam forkChild flag indicating to debug the child after forking |
|
452 (boolean) |
438 """ |
453 """ |
439 self.__autoContinue = autoContinue |
454 self.__autoContinue = autoContinue |
440 self.__scriptName = os.path.abspath(fn) |
455 self.__scriptName = os.path.abspath(fn) |
441 |
456 |
442 wd = self.translate(wd, False) |
457 wd = self.translate(wd, False) |
443 fn = self.translate(os.path.abspath(fn), False) |
458 fn = self.translate(os.path.abspath(fn), False) |
444 self.__sendCommand('{0}{1}\n'.format( |
459 self.__sendCommand('{0}{1}\n'.format( |
445 DebugProtocol.RequestForkMode, repr((autoFork, forkChild)))) |
460 DebugProtocol.RequestForkMode, repr((autoFork, forkChild)))) |
446 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format( |
461 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format( |
447 DebugProtocol.RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)), |
462 DebugProtocol.RequestLoad, wd, fn, |
448 traceInterpreter)) |
463 str(Utilities.parseOptionString(argv)), |
|
464 traceInterpreter)) |
449 |
465 |
450 def remoteRun(self, fn, argv, wd, autoFork=False, forkChild=False): |
466 def remoteRun(self, fn, argv, wd, autoFork=False, forkChild=False): |
451 """ |
467 """ |
452 Public method to load a new program to run. |
468 Public method to load a new program to run. |
453 |
469 |
454 @param fn the filename to run (string) |
470 @param fn the filename to run (string) |
455 @param argv the commandline arguments to pass to the program (string) |
471 @param argv the commandline arguments to pass to the program (string) |
456 @param wd the working directory for the program (string) |
472 @param wd the working directory for the program (string) |
457 @keyparam autoFork flag indicating the automatic fork mode (boolean) |
473 @keyparam autoFork flag indicating the automatic fork mode (boolean) |
458 @keyparam forkChild flag indicating to debug the child after forking (boolean) |
474 @keyparam forkChild flag indicating to debug the child after forking |
|
475 (boolean) |
459 """ |
476 """ |
460 self.__scriptName = os.path.abspath(fn) |
477 self.__scriptName = os.path.abspath(fn) |
461 |
478 |
462 wd = self.translate(wd, False) |
479 wd = self.translate(wd, False) |
463 fn = self.translate(os.path.abspath(fn), False) |
480 fn = self.translate(os.path.abspath(fn), False) |
464 self.__sendCommand('{0}{1}\n'.format( |
481 self.__sendCommand('{0}{1}\n'.format( |
465 DebugProtocol.RequestForkMode, repr((autoFork, forkChild)))) |
482 DebugProtocol.RequestForkMode, repr((autoFork, forkChild)))) |
466 self.__sendCommand('{0}{1}|{2}|{3}\n'.format( |
483 self.__sendCommand('{0}{1}|{2}|{3}\n'.format( |
467 DebugProtocol.RequestRun, wd, fn, str(Utilities.parseOptionString(argv)))) |
484 DebugProtocol.RequestRun, wd, fn, |
|
485 str(Utilities.parseOptionString(argv)))) |
468 |
486 |
469 def remoteCoverage(self, fn, argv, wd, erase=False): |
487 def remoteCoverage(self, fn, argv, wd, erase=False): |
470 """ |
488 """ |
471 Public method to load a new program to collect coverage data. |
489 Public method to load a new program to collect coverage data. |
472 |
490 |
479 self.__scriptName = os.path.abspath(fn) |
497 self.__scriptName = os.path.abspath(fn) |
480 |
498 |
481 wd = self.translate(wd, False) |
499 wd = self.translate(wd, False) |
482 fn = self.translate(os.path.abspath(fn), False) |
500 fn = self.translate(os.path.abspath(fn), False) |
483 self.__sendCommand('{0}{1}@@{2}@@{3}@@{4:d}\n'.format( |
501 self.__sendCommand('{0}{1}@@{2}@@{3}@@{4:d}\n'.format( |
484 DebugProtocol.RequestCoverage, wd, fn, str(Utilities.parseOptionString(argv)), |
502 DebugProtocol.RequestCoverage, wd, fn, |
485 erase)) |
503 str(Utilities.parseOptionString(argv)), erase)) |
486 |
504 |
487 def remoteProfile(self, fn, argv, wd, erase=False): |
505 def remoteProfile(self, fn, argv, wd, erase=False): |
488 """ |
506 """ |
489 Public method to load a new program to collect profiling data. |
507 Public method to load a new program to collect profiling data. |
490 |
508 |
491 @param fn the filename to run (string) |
509 @param fn the filename to run (string) |
492 @param argv the commandline arguments to pass to the program (string) |
510 @param argv the commandline arguments to pass to the program (string) |
493 @param wd the working directory for the program (string) |
511 @param wd the working directory for the program (string) |
494 @keyparam erase flag indicating that timing info should be cleared first (boolean) |
512 @keyparam erase flag indicating that timing info should be cleared |
|
513 first (boolean) |
495 """ |
514 """ |
496 self.__scriptName = os.path.abspath(fn) |
515 self.__scriptName = os.path.abspath(fn) |
497 |
516 |
498 wd = self.translate(wd, False) |
517 wd = self.translate(wd, False) |
499 fn = self.translate(os.path.abspath(fn), False) |
518 fn = self.translate(os.path.abspath(fn), False) |
553 @param cond condition of the breakpoint (string) |
573 @param cond condition of the breakpoint (string) |
554 @param temp flag indicating a temporary breakpoint (boolean) |
574 @param temp flag indicating a temporary breakpoint (boolean) |
555 """ |
575 """ |
556 fn = self.translate(fn, False) |
576 fn = self.translate(fn, False) |
557 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format( |
577 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format( |
558 DebugProtocol.RequestBreak, fn, line, temp, set, cond)) |
578 DebugProtocol.RequestBreak, fn, line, temp, set, |
|
579 cond)) |
559 |
580 |
560 def remoteBreakpointEnable(self, fn, line, enable): |
581 def remoteBreakpointEnable(self, fn, line, enable): |
561 """ |
582 """ |
562 Public method to enable or disable a breakpoint. |
583 Public method to enable or disable a breakpoint. |
563 |
584 |
564 @param fn filename the breakpoint belongs to (string) |
585 @param fn filename the breakpoint belongs to (string) |
565 @param line linenumber of the breakpoint (int) |
586 @param line linenumber of the breakpoint (int) |
566 @param enable flag indicating enabling or disabling a breakpoint (boolean) |
587 @param enable flag indicating enabling or disabling a breakpoint |
|
588 (boolean) |
567 """ |
589 """ |
568 fn = self.translate(fn, False) |
590 fn = self.translate(fn, False) |
569 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format( |
591 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format( |
570 DebugProtocol.RequestBreakEnable, fn, line, enable)) |
592 DebugProtocol.RequestBreakEnable, fn, line, enable)) |
571 |
593 |
596 def remoteWatchpointEnable(self, cond, enable): |
619 def remoteWatchpointEnable(self, cond, enable): |
597 """ |
620 """ |
598 Public method to enable or disable a watch expression. |
621 Public method to enable or disable a watch expression. |
599 |
622 |
600 @param cond expression of the watch expression (string) |
623 @param cond expression of the watch expression (string) |
601 @param enable flag indicating enabling or disabling a watch expression (boolean) |
624 @param enable flag indicating enabling or disabling a watch expression |
|
625 (boolean) |
602 """ |
626 """ |
603 # cond is combination of cond and special (s. watch expression viewer) |
627 # cond is combination of cond and special (s. watch expression viewer) |
604 self.__sendCommand('{0}{1},{2:d}\n'.format( |
628 self.__sendCommand('{0}{1},{2:d}\n'.format( |
605 DebugProtocol.RequestWatchEnable, cond, enable)) |
629 DebugProtocol.RequestWatchEnable, cond, enable)) |
606 |
630 |
607 def remoteWatchpointIgnore(self, cond, count): |
631 def remoteWatchpointIgnore(self, cond, count): |
608 """ |
632 """ |
609 Public method to ignore a watch expression the next couple of occurrences. |
633 Public method to ignore a watch expression the next couple of |
|
634 occurrences. |
610 |
635 |
611 @param cond expression of the watch expression (string) |
636 @param cond expression of the watch expression (string) |
612 @param count number of occurrences to ignore (int) |
637 @param count number of occurrences to ignore (int) |
613 """ |
638 """ |
614 # cond is combination of cond and special (s. watch expression viewer) |
639 # cond is combination of cond and special (s. watch expression viewer) |
678 """ |
705 """ |
679 if on: |
706 if on: |
680 cmd = "on" |
707 cmd = "on" |
681 else: |
708 else: |
682 cmd = "off" |
709 cmd = "off" |
683 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestCallTrace, cmd)) |
710 self.__sendCommand('{0}{1}\n'.format( |
|
711 DebugProtocol.RequestCallTrace, cmd)) |
684 |
712 |
685 def remoteEval(self, arg): |
713 def remoteEval(self, arg): |
686 """ |
714 """ |
687 Public method to evaluate arg in the current context of the debugged program. |
715 Public method to evaluate arg in the current context of the debugged |
|
716 program. |
688 |
717 |
689 @param arg the arguments to evaluate (string) |
718 @param arg the arguments to evaluate (string) |
690 """ |
719 """ |
691 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEval, arg)) |
720 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEval, arg)) |
692 |
721 |
693 def remoteExec(self, stmt): |
722 def remoteExec(self, stmt): |
694 """ |
723 """ |
695 Public method to execute stmt in the current context of the debugged program. |
724 Public method to execute stmt in the current context of the debugged |
|
725 program. |
696 |
726 |
697 @param stmt statement to execute (string) |
727 @param stmt statement to execute (string) |
698 """ |
728 """ |
699 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestExec, stmt)) |
729 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestExec, stmt)) |
700 |
730 |
715 Public slot to get the a list of possible commandline completions |
745 Public slot to get the a list of possible commandline completions |
716 from the remote client. |
746 from the remote client. |
717 |
747 |
718 @param text the text to be completed (string) |
748 @param text the text to be completed (string) |
719 """ |
749 """ |
720 self.__sendCommand("{0}{1}\n".format(DebugProtocol.RequestCompletion, text)) |
750 self.__sendCommand("{0}{1}\n".format( |
|
751 DebugProtocol.RequestCompletion, text)) |
721 |
752 |
722 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase): |
753 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase): |
723 """ |
754 """ |
724 Public method to prepare a new unittest run. |
755 Public method to prepare a new unittest run. |
725 |
756 |
726 @param fn the filename to load (string) |
757 @param fn the filename to load (string) |
727 @param tn the testname to load (string) |
758 @param tn the testname to load (string) |
728 @param tfn the test function name to load tests from (string) |
759 @param tfn the test function name to load tests from (string) |
729 @param failed list of failed test, if only failed test should be run |
760 @param failed list of failed test, if only failed test should be run |
730 (list of strings) |
761 (list of strings) |
731 @param cov flag indicating collection of coverage data is requested (boolean) |
762 @param cov flag indicating collection of coverage data is requested |
|
763 (boolean) |
732 @param covname filename to be used to assemble the coverage caches |
764 @param covname filename to be used to assemble the coverage caches |
733 filename (string) |
765 filename (string) |
734 @param coverase flag indicating erasure of coverage data is requested (boolean) |
766 @param coverase flag indicating erasure of coverage data is requested |
|
767 (boolean) |
735 """ |
768 """ |
736 self.__scriptName = os.path.abspath(fn) |
769 self.__scriptName = os.path.abspath(fn) |
737 |
770 |
738 fn = self.translate(os.path.abspath(fn), False) |
771 fn = self.translate(os.path.abspath(fn), False) |
739 self.__sendCommand('{0}{1}|{2}|{3}|{4}|{5:d}|{6}|{7:d}\n'.format( |
772 self.__sendCommand('{0}{1}|{2}|{3}|{4}|{5:d}|{6}|{7:d}\n'.format( |
970 self.debugServer.clientUtStopTest() |
1010 self.debugServer.clientUtStopTest() |
971 continue |
1011 continue |
972 |
1012 |
973 if resp == DebugProtocol.ResponseUTTestFailed: |
1013 if resp == DebugProtocol.ResponseUTTestFailed: |
974 testname, traceback, id = eval(evalArg) |
1014 testname, traceback, id = eval(evalArg) |
975 self.debugServer.clientUtTestFailed(testname, traceback, id) |
1015 self.debugServer.clientUtTestFailed( |
|
1016 testname, traceback, id) |
976 continue |
1017 continue |
977 |
1018 |
978 if resp == DebugProtocol.ResponseUTTestErrored: |
1019 if resp == DebugProtocol.ResponseUTTestErrored: |
979 testname, traceback, id = eval(evalArg) |
1020 testname, traceback, id = eval(evalArg) |
980 self.debugServer.clientUtTestErrored(testname, traceback, id) |
1021 self.debugServer.clientUtTestErrored( |
|
1022 testname, traceback, id) |
981 continue |
1023 continue |
982 |
1024 |
983 if resp == DebugProtocol.ResponseUTTestSkipped: |
1025 if resp == DebugProtocol.ResponseUTTestSkipped: |
984 testname, reason, id = eval(line[eoc:-1]) |
1026 testname, reason, id = eval(line[eoc:-1]) |
985 self.debugServer.clientUtTestSkipped(testname, reason, id) |
1027 self.debugServer.clientUtTestSkipped(testname, reason, id) |
986 continue |
1028 continue |
987 |
1029 |
988 if resp == DebugProtocol.ResponseUTTestFailedExpected: |
1030 if resp == DebugProtocol.ResponseUTTestFailedExpected: |
989 testname, traceback, id = eval(line[eoc:-1]) |
1031 testname, traceback, id = eval(line[eoc:-1]) |
990 self.debugServer.clientUtTestFailedExpected(testname, traceback, id) |
1032 self.debugServer.clientUtTestFailedExpected( |
|
1033 testname, traceback, id) |
991 continue |
1034 continue |
992 |
1035 |
993 if resp == DebugProtocol.ResponseUTTestSucceededUnexpected: |
1036 if resp == DebugProtocol.ResponseUTTestSucceededUnexpected: |
994 testname, id = eval(line[eoc:-1]) |
1037 testname, id = eval(line[eoc:-1]) |
995 self.debugServer.clientUtTestSucceededUnexpected(testname, id) |
1038 self.debugServer.clientUtTestSucceededUnexpected( |
|
1039 testname, id) |
996 continue |
1040 continue |
997 |
1041 |
998 if resp == DebugProtocol.ResponseUTFinished: |
1042 if resp == DebugProtocol.ResponseUTFinished: |
999 self.debugServer.clientUtFinished() |
1043 self.debugServer.clientUtFinished() |
1000 continue |
1044 continue |