Debugger/DebuggerInterfaceRuby.py

changeset 2988
f53c03574697
parent 2953
703452a2876f
child 3020
542e97d4ecb3
child 3057
10516539f238
equal deleted inserted replaced
2987:c99695c0f13a 2988:f53c03574697
65 self.qsock = None 65 self.qsock = None
66 self.queue = [] 66 self.queue = []
67 # set default values for capabilities of clients 67 # set default values for capabilities of clients
68 self.clientCapabilities = ClientDefaultCapabilities 68 self.clientCapabilities = ClientDefaultCapabilities
69 69
70 self.codec = QTextCodec.codecForName(str(Preferences.getSystem("StringEncoding"))) 70 self.codec = QTextCodec.codecForName(
71 str(Preferences.getSystem("StringEncoding")))
71 72
72 if passive: 73 if passive:
73 # set translation function 74 # set translation function
74 if Preferences.getDebugger("PathTranslation"): 75 if Preferences.getDebugger("PathTranslation"):
75 self.translateRemote = \ 76 self.translateRemote = \
109 """ 110 """
110 Private method to start the debugger client process. 111 Private method to start the debugger client process.
111 112
112 @param program name of the executable to start (string) 113 @param program name of the executable to start (string)
113 @param arguments arguments to be passed to the program (list of string) 114 @param arguments arguments to be passed to the program (list of string)
114 @param environment dictionary of environment settings to pass (dict of string) 115 @param environment dictionary of environment settings to pass
116 (dict of string)
115 @return the process object (QProcess) or None 117 @return the process object (QProcess) or None
116 """ 118 """
117 proc = QProcess() 119 proc = QProcess()
118 if environment is not None: 120 if environment is not None:
119 env = [] 121 env = []
161 process = self.__startProcess(args[0], args[1:]) 163 process = self.__startProcess(args[0], args[1:])
162 if process is None: 164 if process is None:
163 E5MessageBox.critical(None, 165 E5MessageBox.critical(None,
164 self.trUtf8("Start Debugger"), 166 self.trUtf8("Start Debugger"),
165 self.trUtf8( 167 self.trUtf8(
166 """<p>The debugger backend could not be started.</p>""")) 168 """<p>The debugger backend could not be"""
169 """ started.</p>"""))
167 170
168 # set translation function 171 # set translation function
169 if Preferences.getDebugger("PathTranslation"): 172 if Preferences.getDebugger("PathTranslation"):
170 self.translateRemote = \ 173 self.translateRemote = \
171 Preferences.getDebugger("PathTranslationRemote") 174 Preferences.getDebugger("PathTranslationRemote")
206 process = self.__startProcess(args[0], args[1:], clientEnv) 209 process = self.__startProcess(args[0], args[1:], clientEnv)
207 if process is None: 210 if process is None:
208 E5MessageBox.critical(None, 211 E5MessageBox.critical(None,
209 self.trUtf8("Start Debugger"), 212 self.trUtf8("Start Debugger"),
210 self.trUtf8( 213 self.trUtf8(
211 """<p>The debugger backend could not be started.</p>""")) 214 """<p>The debugger backend could not be"""
215 """ started.</p>"""))
212 return process, self.__isNetworked 216 return process, self.__isNetworked
213 217
214 process = self.__startProcess(interpreter, 218 process = self.__startProcess(interpreter,
215 [debugClient, str(port), redirect, ipaddr], 219 [debugClient, str(port), redirect, ipaddr],
216 clientEnv) 220 clientEnv)
217 if process is None: 221 if process is None:
218 E5MessageBox.critical(None, 222 E5MessageBox.critical(None,
219 self.trUtf8("Start Debugger"), 223 self.trUtf8("Start Debugger"),
220 self.trUtf8("""<p>The debugger backend could not be started.</p>""")) 224 self.trUtf8(
225 """<p>The debugger backend could not be started.</p>"""))
221 return process, self.__isNetworked 226 return process, self.__isNetworked
222 227
223 def startRemoteForProject(self, port, runInConsole): 228 def startRemoteForProject(self, port, runInConsole):
224 """ 229 """
225 Public method to start a remote Ruby interpreter for a project. 230 Public method to start a remote Ruby interpreter for a project.
254 process = self.__startProcess(args[0], args[1:]) 259 process = self.__startProcess(args[0], args[1:])
255 if process is None: 260 if process is None:
256 E5MessageBox.critical(None, 261 E5MessageBox.critical(None,
257 self.trUtf8("Start Debugger"), 262 self.trUtf8("Start Debugger"),
258 self.trUtf8( 263 self.trUtf8(
259 """<p>The debugger backend could not be started.</p>""")) 264 """<p>The debugger backend could not be"""
265 """ started.</p>"""))
260 # set translation function 266 # set translation function
261 if project.getDebugProperty("PATHTRANSLATION"): 267 if project.getDebugProperty("PATHTRANSLATION"):
262 self.translateRemote = project.getDebugProperty("REMOTEPATH") 268 self.translateRemote = \
263 self.translateLocal = project.getDebugProperty("LOCALPATH") 269 project.getDebugProperty("REMOTEPATH")
270 self.translateLocal = \
271 project.getDebugProperty("LOCALPATH")
264 self.translate = self.__remoteTranslation 272 self.translate = self.__remoteTranslation
265 else: 273 else:
266 self.translate = self.__identityTranslation 274 self.translate = self.__identityTranslation
267 return process, self.__isNetworked 275 return process, self.__isNetworked
268 276
297 process = self.__startProcess(args[0], args[1:], clientEnv) 305 process = self.__startProcess(args[0], args[1:], clientEnv)
298 if process is None: 306 if process is None:
299 E5MessageBox.critical(None, 307 E5MessageBox.critical(None,
300 self.trUtf8("Start Debugger"), 308 self.trUtf8("Start Debugger"),
301 self.trUtf8( 309 self.trUtf8(
302 """<p>The debugger backend could not be started.</p>""")) 310 """<p>The debugger backend could not be"""
311 """ started.</p>"""))
303 return process, self.__isNetworked 312 return process, self.__isNetworked
304 313
305 process = self.__startProcess(interpreter, 314 process = self.__startProcess(interpreter,
306 [debugClient, str(port), redirect, ipaddr], 315 [debugClient, str(port), redirect, ipaddr],
307 clientEnv) 316 clientEnv)
308 if process is None: 317 if process is None:
309 E5MessageBox.critical(None, 318 E5MessageBox.critical(None,
310 self.trUtf8("Start Debugger"), 319 self.trUtf8("Start Debugger"),
311 self.trUtf8("""<p>The debugger backend could not be started.</p>""")) 320 self.trUtf8(
321 """<p>The debugger backend could not be started.</p>"""))
312 return process, self.__isNetworked 322 return process, self.__isNetworked
313 323
314 def getClientCapabilities(self): 324 def getClientCapabilities(self):
315 """ 325 """
316 Public method to retrieve the debug clients capabilities. 326 Public method to retrieve the debug clients capabilities.
386 """ 396 """
387 Public method to set the environment for a program to debug, run, ... 397 Public method to set the environment for a program to debug, run, ...
388 398
389 @param env environment settings (dictionary) 399 @param env environment settings (dictionary)
390 """ 400 """
391 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEnv, str(env))) 401 self.__sendCommand('{0}{1}\n'.format(
392 402 DebugProtocol.RequestEnv, str(env)))
393 def remoteLoad(self, fn, argv, wd, traceInterpreter=False, autoContinue=True, 403
394 autoFork=False, forkChild=False): 404 def remoteLoad(self, fn, argv, wd, traceInterpreter=False,
405 autoContinue=True, autoFork=False, forkChild=False):
395 """ 406 """
396 Public method to load a new program to debug. 407 Public method to load a new program to debug.
397 408
398 @param fn the filename to debug (string) 409 @param fn the filename to debug (string)
399 @param argv the commandline arguments to pass to the program (string) 410 @param argv the commandline arguments to pass to the program (string)
400 @param wd the working directory for the program (string) 411 @param wd the working directory for the program (string)
401 @keyparam traceInterpreter flag indicating if the interpreter library should be 412 @keyparam traceInterpreter flag indicating if the interpreter library
402 traced as well (boolean) 413 should be traced as well (boolean)
403 @keyparam autoContinue flag indicating, that the debugger should not stop 414 @keyparam autoContinue flag indicating, that the debugger should not
404 at the first executable line (boolean) 415 stop at the first executable line (boolean)
405 @keyparam autoFork flag indicating the automatic fork mode (boolean) (ignored) 416 @keyparam autoFork flag indicating the automatic fork mode (boolean)
417 (ignored)
406 @keyparam forkChild flag indicating to debug the child after forking 418 @keyparam forkChild flag indicating to debug the child after forking
407 (boolean) (ignored) 419 (boolean) (ignored)
408 """ 420 """
409 self.__autoContinue = autoContinue 421 self.__autoContinue = autoContinue
410 422
411 wd = self.translate(wd, False) 423 wd = self.translate(wd, False)
412 fn = self.translate(os.path.abspath(fn), False) 424 fn = self.translate(os.path.abspath(fn), False)
413 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format( 425 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
414 DebugProtocol.RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)), 426 DebugProtocol.RequestLoad, wd, fn,
415 traceInterpreter)) 427 str(Utilities.parseOptionString(argv)),
428 traceInterpreter))
416 429
417 def remoteRun(self, fn, argv, wd, autoFork=False, forkChild=False): 430 def remoteRun(self, fn, argv, wd, autoFork=False, forkChild=False):
418 """ 431 """
419 Public method to load a new program to run. 432 Public method to load a new program to run.
420 433
421 @param fn the filename to run (string) 434 @param fn the filename to run (string)
422 @param argv the commandline arguments to pass to the program (string) 435 @param argv the commandline arguments to pass to the program (string)
423 @param wd the working directory for the program (string) 436 @param wd the working directory for the program (string)
424 @keyparam autoFork flag indicating the automatic fork mode (boolean) (ignored) 437 @keyparam autoFork flag indicating the automatic fork mode (boolean)
438 (ignored)
425 @keyparam forkChild flag indicating to debug the child after forking 439 @keyparam forkChild flag indicating to debug the child after forking
426 (boolean) (ignored) 440 (boolean) (ignored)
427 """ 441 """
428 wd = self.translate(wd, False) 442 wd = self.translate(wd, False)
429 fn = self.translate(os.path.abspath(fn), False) 443 fn = self.translate(os.path.abspath(fn), False)
430 self.__sendCommand('{0}{1}|{2}|{3}\n'.format( 444 self.__sendCommand('{0}{1}|{2}|{3}\n'.format(
431 DebugProtocol.RequestRun, wd, fn, str(Utilities.parseOptionString(argv)))) 445 DebugProtocol.RequestRun, wd, fn,
446 str(Utilities.parseOptionString(argv))))
432 447
433 def remoteCoverage(self, fn, argv, wd, erase=False): 448 def remoteCoverage(self, fn, argv, wd, erase=False):
434 """ 449 """
435 Public method to load a new program to collect coverage data. 450 Public method to load a new program to collect coverage data.
436 451
449 Public method to load a new program to collect profiling data. 464 Public method to load a new program to collect profiling data.
450 465
451 @param fn the filename to run (string) 466 @param fn the filename to run (string)
452 @param argv the commandline arguments to pass to the program (string) 467 @param argv the commandline arguments to pass to the program (string)
453 @param wd the working directory for the program (string) 468 @param wd the working directory for the program (string)
454 @keyparam erase flag indicating that timing info should be cleared first (boolean) 469 @keyparam erase flag indicating that timing info should be cleared
470 first (boolean)
455 @exception NotImplementedError raised to indicate that this interface 471 @exception NotImplementedError raised to indicate that this interface
456 is not supported 472 is not supported
457 """ 473 """
458 raise NotImplementedError("Interface not available.") 474 raise NotImplementedError("Interface not available.")
459 475
495 """ 511 """
496 Public method to continue the debugged program. 512 Public method to continue the debugged program.
497 513
498 @param special flag indicating a special continue operation (boolean) 514 @param special flag indicating a special continue operation (boolean)
499 """ 515 """
500 self.__sendCommand('{0}{1:d}\n'.format(DebugProtocol.RequestContinue, special)) 516 self.__sendCommand('{0}{1:d}\n'.format(
517 DebugProtocol.RequestContinue, special))
501 518
502 def remoteBreakpoint(self, fn, line, set, cond=None, temp=False): 519 def remoteBreakpoint(self, fn, line, set, cond=None, temp=False):
503 """ 520 """
504 Public method to set or clear a breakpoint. 521 Public method to set or clear a breakpoint.
505 522
509 @param cond condition of the breakpoint (string) 526 @param cond condition of the breakpoint (string)
510 @param temp flag indicating a temporary breakpoint (boolean) 527 @param temp flag indicating a temporary breakpoint (boolean)
511 """ 528 """
512 fn = self.translate(fn, False) 529 fn = self.translate(fn, False)
513 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format( 530 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format(
514 DebugProtocol.RequestBreak, fn, line, temp, set, cond)) 531 DebugProtocol.RequestBreak, fn, line, temp, set, cond))
515 532
516 def remoteBreakpointEnable(self, fn, line, enable): 533 def remoteBreakpointEnable(self, fn, line, enable):
517 """ 534 """
518 Public method to enable or disable a breakpoint. 535 Public method to enable or disable a breakpoint.
519 536
520 @param fn filename the breakpoint belongs to (string) 537 @param fn filename the breakpoint belongs to (string)
521 @param line linenumber of the breakpoint (int) 538 @param line linenumber of the breakpoint (int)
522 @param enable flag indicating enabling or disabling a breakpoint (boolean) 539 @param enable flag indicating enabling or disabling a breakpoint
540 (boolean)
523 """ 541 """
524 fn = self.translate(fn, False) 542 fn = self.translate(fn, False)
525 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format( 543 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format(
526 DebugProtocol.RequestBreakEnable, fn, line, enable)) 544 DebugProtocol.RequestBreakEnable, fn, line, enable))
527 545
540 def remoteWatchpoint(self, cond, set, temp=False): 558 def remoteWatchpoint(self, cond, set, temp=False):
541 """ 559 """
542 Public method to set or clear a watch expression. 560 Public method to set or clear a watch expression.
543 561
544 @param cond expression of the watch expression (string) 562 @param cond expression of the watch expression (string)
545 @param set flag indicating setting or resetting a watch expression (boolean) 563 @param set flag indicating setting or resetting a watch expression
564 (boolean)
546 @param temp flag indicating a temporary watch expression (boolean) 565 @param temp flag indicating a temporary watch expression (boolean)
547 """ 566 """
548 # cond is combination of cond and special (s. watch expression viewer) 567 # cond is combination of cond and special (s. watch expression viewer)
549 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}\n'.format( 568 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}\n'.format(
550 DebugProtocol.RequestWatch, cond, temp, set)) 569 DebugProtocol.RequestWatch, cond, temp, set))
552 def remoteWatchpointEnable(self, cond, enable): 571 def remoteWatchpointEnable(self, cond, enable):
553 """ 572 """
554 Public method to enable or disable a watch expression. 573 Public method to enable or disable a watch expression.
555 574
556 @param cond expression of the watch expression (string) 575 @param cond expression of the watch expression (string)
557 @param enable flag indicating enabling or disabling a watch expression (boolean) 576 @param enable flag indicating enabling or disabling a watch expression
577 (boolean)
558 """ 578 """
559 # cond is combination of cond and special (s. watch expression viewer) 579 # cond is combination of cond and special (s. watch expression viewer)
560 self.__sendCommand('{0}{1},{2:d}\n'.format( 580 self.__sendCommand('{0}{1},{2:d}\n'.format(
561 DebugProtocol.RequestWatchEnable, cond, enable)) 581 DebugProtocol.RequestWatchEnable, cond, enable))
562 582
563 def remoteWatchpointIgnore(self, cond, count): 583 def remoteWatchpointIgnore(self, cond, count):
564 """ 584 """
565 Public method to ignore a watch expression the next couple of occurrences. 585 Public method to ignore a watch expression the next couple of
586 occurrences.
566 587
567 @param cond expression of the watch expression (string) 588 @param cond expression of the watch expression (string)
568 @param count number of occurrences to ignore (int) 589 @param count number of occurrences to ignore (int)
569 """ 590 """
570 # cond is combination of cond and special (s. watch expression viewer) 591 # cond is combination of cond and special (s. watch expression viewer)
612 @param filter list of variable types to filter out (list of int) 633 @param filter list of variable types to filter out (list of int)
613 @param var list encoded name of variable to retrieve (string) 634 @param var list encoded name of variable to retrieve (string)
614 @param framenr framenumber of the variables to retrieve (int) 635 @param framenr framenumber of the variables to retrieve (int)
615 """ 636 """
616 self.__sendCommand('{0}{1}, {2:d}, {3:d}, {4}\n'.format( 637 self.__sendCommand('{0}{1}, {2:d}, {3:d}, {4}\n'.format(
617 DebugProtocol.RequestVariable, str(var), framenr, scope, str(filter))) 638 DebugProtocol.RequestVariable, str(var), framenr, scope,
639 str(filter)))
618 640
619 def remoteClientSetFilter(self, scope, filter): 641 def remoteClientSetFilter(self, scope, filter):
620 """ 642 """
621 Public method to set a variables filter list. 643 Public method to set a variables filter list.
622 644
634 """ 656 """
635 return 657 return
636 658
637 def remoteEval(self, arg): 659 def remoteEval(self, arg):
638 """ 660 """
639 Public method to evaluate arg in the current context of the debugged program. 661 Public method to evaluate arg in the current context of the debugged
662 program.
640 663
641 @param arg the arguments to evaluate (string) 664 @param arg the arguments to evaluate (string)
642 """ 665 """
643 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEval, arg)) 666 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEval, arg))
644 667
645 def remoteExec(self, stmt): 668 def remoteExec(self, stmt):
646 """ 669 """
647 Public method to execute stmt in the current context of the debugged program. 670 Public method to execute stmt in the current context of the debugged
671 program.
648 672
649 @param stmt statement to execute (string) 673 @param stmt statement to execute (string)
650 """ 674 """
651 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestExec, stmt)) 675 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestExec, stmt))
652 676
667 Public slot to get the a list of possible commandline completions 691 Public slot to get the a list of possible commandline completions
668 from the remote client. 692 from the remote client.
669 693
670 @param text the text to be completed (string) 694 @param text the text to be completed (string)
671 """ 695 """
672 self.__sendCommand("{0}{1}\n".format(DebugProtocol.RequestCompletion, text)) 696 self.__sendCommand("{0}{1}\n".format(
697 DebugProtocol.RequestCompletion, text))
673 698
674 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase): 699 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase):
675 """ 700 """
676 Public method to prepare a new unittest run. 701 Public method to prepare a new unittest run.
677 702
678 @param fn the filename to load (string) 703 @param fn the filename to load (string)
679 @param tn the testname to load (string) 704 @param tn the testname to load (string)
680 @param tfn the test function name to load tests from (string) 705 @param tfn the test function name to load tests from (string)
681 @param failed list of failed test, if only failed test should be run 706 @param failed list of failed test, if only failed test should be run
682 (list of strings) 707 (list of strings)
683 @param cov flag indicating collection of coverage data is requested (boolean) 708 @param cov flag indicating collection of coverage data is requested
709 (boolean)
684 @param covname filename to be used to assemble the coverage caches 710 @param covname filename to be used to assemble the coverage caches
685 filename (string) 711 filename (string)
686 @param coverase flag indicating erasure of coverage data is requested (boolean) 712 @param coverase flag indicating erasure of coverage data is requested
713 (boolean)
687 @exception NotImplementedError raised to indicate that this interface 714 @exception NotImplementedError raised to indicate that this interface
688 is not supported 715 is not supported
689 """ 716 """
690 raise NotImplementedError("Interface not available.") 717 raise NotImplementedError("Interface not available.")
691 718
791 stack = exclist[2:] 818 stack = exclist[2:]
792 except (IndexError, ValueError, SyntaxError): 819 except (IndexError, ValueError, SyntaxError):
793 exctype = None 820 exctype = None
794 excmessage = '' 821 excmessage = ''
795 stack = [] 822 stack = []
796 self.debugServer.signalClientException(exctype, excmessage, stack) 823 self.debugServer.signalClientException(
824 exctype, excmessage, stack)
797 continue 825 continue
798 826
799 if resp == DebugProtocol.ResponseSyntax: 827 if resp == DebugProtocol.ResponseSyntax:
800 exc = line[eoc:-1] 828 exc = line[eoc:-1]
801 exc = self.translate(exc, True) 829 exc = self.translate(exc, True)
806 except (IndexError, ValueError): 834 except (IndexError, ValueError):
807 message = None 835 message = None
808 fn = '' 836 fn = ''
809 ln = 0 837 ln = 0
810 cn = 0 838 cn = 0
811 self.debugServer.signalClientSyntaxError(message, fn, ln, cn) 839 self.debugServer.signalClientSyntaxError(
840 message, fn, ln, cn)
812 continue 841 continue
813 842
814 if resp == DebugProtocol.ResponseExit: 843 if resp == DebugProtocol.ResponseExit:
815 self.debugServer.signalClientExit(line[eoc:-1]) 844 self.debugServer.signalClientExit(line[eoc:-1])
816 continue 845 continue
827 self.debugServer.signalClientClearWatch(cond) 856 self.debugServer.signalClientClearWatch(cond)
828 continue 857 continue
829 858
830 if resp == DebugProtocol.ResponseBanner: 859 if resp == DebugProtocol.ResponseBanner:
831 version, platform, dbgclient = eval(line[eoc:-1]) 860 version, platform, dbgclient = eval(line[eoc:-1])
832 self.debugServer.signalClientBanner(version, platform, dbgclient) 861 self.debugServer.signalClientBanner(
862 version, platform, dbgclient)
833 continue 863 continue
834 864
835 if resp == DebugProtocol.ResponseCapabilities: 865 if resp == DebugProtocol.ResponseCapabilities:
836 cap, clType = eval(line[eoc:-1]) 866 cap, clType = eval(line[eoc:-1])
837 self.clientCapabilities = cap 867 self.clientCapabilities = cap

eric ide

mercurial