Debugger/DebuggerInterfaceRuby.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1112
8a7d1b9d18db
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
29 DebugClientCapabilities.HasInterpreter | \ 29 DebugClientCapabilities.HasInterpreter | \
30 DebugClientCapabilities.HasCompleter 30 DebugClientCapabilities.HasCompleter
31 31
32 ClientTypeAssociations = [".rb"] 32 ClientTypeAssociations = [".rb"]
33 33
34
34 def getRegistryData(): 35 def getRegistryData():
35 """ 36 """
36 Module function to get characterising data for the debugger interface. 37 Module function to get characterising data for the debugger interface.
37 38
38 @return list of the following data. Client type (string), client 39 @return list of the following data. Client type (string), client
39 capabilities (integer), client type association (list of strings) 40 capabilities (integer), client type association (list of strings)
40 """ 41 """
41 return ["Ruby", ClientDefaultCapabilities, ClientTypeAssociations] 42 return ["Ruby", ClientDefaultCapabilities, ClientTypeAssociations]
43
42 44
43 class DebuggerInterfaceRuby(QObject): 45 class DebuggerInterfaceRuby(QObject):
44 """ 46 """
45 Class implementing the Ruby debugger interface for the debug server. 47 Class implementing the Ruby debugger interface for the debug server.
46 """ 48 """
76 Preferences.getDebugger("PathTranslationLocal") 78 Preferences.getDebugger("PathTranslationLocal")
77 self.translate = self.__remoteTranslation 79 self.translate = self.__remoteTranslation
78 else: 80 else:
79 self.translate = self.__identityTranslation 81 self.translate = self.__identityTranslation
80 82
81 def __identityTranslation(self, fn, remote2local = True): 83 def __identityTranslation(self, fn, remote2local=True):
82 """ 84 """
83 Private method to perform the identity path translation. 85 Private method to perform the identity path translation.
84 86
85 @param fn filename to be translated (string) 87 @param fn filename to be translated (string)
86 @param remote2local flag indicating the direction of translation 88 @param remote2local flag indicating the direction of translation
87 (False = local to remote, True = remote to local [default]) 89 (False = local to remote, True = remote to local [default])
88 @return translated filename (string) 90 @return translated filename (string)
89 """ 91 """
90 return fn 92 return fn
91 93
92 def __remoteTranslation(self, fn, remote2local = True): 94 def __remoteTranslation(self, fn, remote2local=True):
93 """ 95 """
94 Private method to perform the path translation. 96 Private method to perform the path translation.
95 97
96 @param fn filename to be translated (string) 98 @param fn filename to be translated (string)
97 @param remote2local flag indicating the direction of translation 99 @param remote2local flag indicating the direction of translation
101 if remote2local: 103 if remote2local:
102 return fn.replace(self.translateRemote, self.translateLocal) 104 return fn.replace(self.translateRemote, self.translateLocal)
103 else: 105 else:
104 return fn.replace(self.translateLocal, self.translateRemote) 106 return fn.replace(self.translateLocal, self.translateRemote)
105 107
106 def __startProcess(self, program, arguments, environment = None): 108 def __startProcess(self, program, arguments, environment=None):
107 """ 109 """
108 Private method to start the debugger client process. 110 Private method to start the debugger client process.
109 111
110 @param program name of the executable to start (string) 112 @param program name of the executable to start (string)
111 @param arguments arguments to be passed to the program (list of string) 113 @param arguments arguments to be passed to the program (list of string)
130 def startRemote(self, port, runInConsole): 132 def startRemote(self, port, runInConsole):
131 """ 133 """
132 Public method to start a remote Ruby interpreter. 134 Public method to start a remote Ruby interpreter.
133 135
134 @param port portnumber the debug server is listening on (integer) 136 @param port portnumber the debug server is listening on (integer)
135 @param runInConsole flag indicating to start the debugger in a 137 @param runInConsole flag indicating to start the debugger in a
136 console window (boolean) 138 console window (boolean)
137 @return client process object (QProcess) and a flag to indicate 139 @return client process object (QProcess) and a flag to indicate
138 a network connection (boolean) 140 a network connection (boolean)
139 """ 141 """
140 interpreter = Preferences.getDebugger("RubyInterpreter") 142 interpreter = Preferences.getDebugger("RubyInterpreter")
141 if interpreter == "": 143 if interpreter == "":
142 interpreter = "/usr/bin/ruby" 144 interpreter = "/usr/bin/ruby"
143 debugClient = os.path.join(getConfig('ericDir'), 145 debugClient = os.path.join(getConfig('ericDir'),
144 "DebugClients", "Ruby", "DebugClient.rb") 146 "DebugClients", "Ruby", "DebugClient.rb")
145 147
146 redirect = str(Preferences.getDebugger("RubyRedirect")) 148 redirect = str(Preferences.getDebugger("RubyRedirect"))
147 149
148 if Preferences.getDebugger("RemoteDbgEnabled"): 150 if Preferences.getDebugger("RemoteDbgEnabled"):
207 self.trUtf8("Start Debugger"), 209 self.trUtf8("Start Debugger"),
208 self.trUtf8( 210 self.trUtf8(
209 """<p>The debugger backend could not be started.</p>""")) 211 """<p>The debugger backend could not be started.</p>"""))
210 return process, self.__isNetworked 212 return process, self.__isNetworked
211 213
212 process = self.__startProcess(interpreter, 214 process = self.__startProcess(interpreter,
213 [debugClient, str(port), redirect, ipaddr], 215 [debugClient, str(port), redirect, ipaddr],
214 clientEnv) 216 clientEnv)
215 if process is None: 217 if process is None:
216 E5MessageBox.critical(None, 218 E5MessageBox.critical(None,
217 self.trUtf8("Start Debugger"), 219 self.trUtf8("Start Debugger"),
218 self.trUtf8("""<p>The debugger backend could not be started.</p>""")) 220 self.trUtf8("""<p>The debugger backend could not be started.</p>"""))
221 def startRemoteForProject(self, port, runInConsole): 223 def startRemoteForProject(self, port, runInConsole):
222 """ 224 """
223 Public method to start a remote Ruby interpreter for a project. 225 Public method to start a remote Ruby interpreter for a project.
224 226
225 @param port portnumber the debug server is listening on (integer) 227 @param port portnumber the debug server is listening on (integer)
226 @param runInConsole flag indicating to start the debugger in a 228 @param runInConsole flag indicating to start the debugger in a
227 console window (boolean) 229 console window (boolean)
228 @return pid of the client process (integer) and a flag to indicate 230 @return pid of the client process (integer) and a flag to indicate
229 a network connection (boolean) 231 a network connection (boolean)
230 """ 232 """
231 project = e5App().getObject("Project") 233 project = e5App().getObject("Project")
298 self.trUtf8("Start Debugger"), 300 self.trUtf8("Start Debugger"),
299 self.trUtf8( 301 self.trUtf8(
300 """<p>The debugger backend could not be started.</p>""")) 302 """<p>The debugger backend could not be started.</p>"""))
301 return process, self.__isNetworked 303 return process, self.__isNetworked
302 304
303 process = self.__startProcess(interpreter, 305 process = self.__startProcess(interpreter,
304 [debugClient, str(port), redirect, ipaddr], 306 [debugClient, str(port), redirect, ipaddr],
305 clientEnv) 307 clientEnv)
306 if process is None: 308 if process is None:
307 E5MessageBox.critical(None, 309 E5MessageBox.critical(None,
308 self.trUtf8("Start Debugger"), 310 self.trUtf8("Start Debugger"),
309 self.trUtf8("""<p>The debugger backend could not be started.</p>""")) 311 self.trUtf8("""<p>The debugger backend could not be started.</p>"""))
386 388
387 @param env environment settings (dictionary) 389 @param env environment settings (dictionary)
388 """ 390 """
389 self.__sendCommand('{0}{1}\n'.format(RequestEnv, str(env))) 391 self.__sendCommand('{0}{1}\n'.format(RequestEnv, str(env)))
390 392
391 def remoteLoad(self, fn, argv, wd, traceInterpreter = False, autoContinue = True, 393 def remoteLoad(self, fn, argv, wd, traceInterpreter=False, autoContinue=True,
392 autoFork = False, forkChild = False): 394 autoFork=False, forkChild=False):
393 """ 395 """
394 Public method to load a new program to debug. 396 Public method to load a new program to debug.
395 397
396 @param fn the filename to debug (string) 398 @param fn the filename to debug (string)
397 @param argv the commandline arguments to pass to the program (string) 399 @param argv the commandline arguments to pass to the program (string)
399 @keyparam traceInterpreter flag indicating if the interpreter library should be 401 @keyparam traceInterpreter flag indicating if the interpreter library should be
400 traced as well (boolean) 402 traced as well (boolean)
401 @keyparam autoContinue flag indicating, that the debugger should not stop 403 @keyparam autoContinue flag indicating, that the debugger should not stop
402 at the first executable line (boolean) 404 at the first executable line (boolean)
403 @keyparam autoFork flag indicating the automatic fork mode (boolean) (ignored) 405 @keyparam autoFork flag indicating the automatic fork mode (boolean) (ignored)
404 @keyparam forkChild flag indicating to debug the child after forking 406 @keyparam forkChild flag indicating to debug the child after forking
405 (boolean) (ignored) 407 (boolean) (ignored)
406 """ 408 """
407 self.__autoContinue = autoContinue 409 self.__autoContinue = autoContinue
408 410
409 wd = self.translate(wd, False) 411 wd = self.translate(wd, False)
410 fn = self.translate(os.path.abspath(fn), False) 412 fn = self.translate(os.path.abspath(fn), False)
411 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format( 413 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
412 RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)), 414 RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)),
413 traceInterpreter)) 415 traceInterpreter))
414 416
415 def remoteRun(self, fn, argv, wd, autoFork = False, forkChild = False): 417 def remoteRun(self, fn, argv, wd, autoFork=False, forkChild=False):
416 """ 418 """
417 Public method to load a new program to run. 419 Public method to load a new program to run.
418 420
419 @param fn the filename to run (string) 421 @param fn the filename to run (string)
420 @param argv the commandline arguments to pass to the program (string) 422 @param argv the commandline arguments to pass to the program (string)
421 @param wd the working directory for the program (string) 423 @param wd the working directory for the program (string)
422 @keyparam autoFork flag indicating the automatic fork mode (boolean) (ignored) 424 @keyparam autoFork flag indicating the automatic fork mode (boolean) (ignored)
423 @keyparam forkChild flag indicating to debug the child after forking 425 @keyparam forkChild flag indicating to debug the child after forking
424 (boolean) (ignored) 426 (boolean) (ignored)
425 """ 427 """
426 wd = self.translate(wd, False) 428 wd = self.translate(wd, False)
427 fn = self.translate(os.path.abspath(fn), False) 429 fn = self.translate(os.path.abspath(fn), False)
428 self.__sendCommand('{0}{1}|{2}|{3}\n'.format( 430 self.__sendCommand('{0}{1}|{2}|{3}\n'.format(
429 RequestRun, wd, fn, str(Utilities.parseOptionString(argv)))) 431 RequestRun, wd, fn, str(Utilities.parseOptionString(argv))))
430 432
431 def remoteCoverage(self, fn, argv, wd, erase = False): 433 def remoteCoverage(self, fn, argv, wd, erase=False):
432 """ 434 """
433 Public method to load a new program to collect coverage data. 435 Public method to load a new program to collect coverage data.
434 436
435 @param fn the filename to run (string) 437 @param fn the filename to run (string)
436 @param argv the commandline arguments to pass to the program (string) 438 @param argv the commandline arguments to pass to the program (string)
437 @param wd the working directory for the program (string) 439 @param wd the working directory for the program (string)
438 @keyparam erase flag indicating that coverage info should be 440 @keyparam erase flag indicating that coverage info should be
439 cleared first (boolean) 441 cleared first (boolean)
440 """ 442 """
441 raise NotImplementedError("Interface not available.") 443 raise NotImplementedError("Interface not available.")
442 444
443 def remoteProfile(self, fn, argv, wd, erase = False): 445 def remoteProfile(self, fn, argv, wd, erase=False):
444 """ 446 """
445 Public method to load a new program to collect profiling data. 447 Public method to load a new program to collect profiling data.
446 448
447 @param fn the filename to run (string) 449 @param fn the filename to run (string)
448 @param argv the commandline arguments to pass to the program (string) 450 @param argv the commandline arguments to pass to the program (string)
451 """ 453 """
452 raise NotImplementedError("Interface not available.") 454 raise NotImplementedError("Interface not available.")
453 455
454 def remoteStatement(self, stmt): 456 def remoteStatement(self, stmt):
455 """ 457 """
456 Public method to execute a Ruby statement. 458 Public method to execute a Ruby statement.
457 459
458 @param stmt the Ruby statement to execute (string). It 460 @param stmt the Ruby statement to execute (string). It
459 should not have a trailing newline. 461 should not have a trailing newline.
460 """ 462 """
461 self.__sendCommand('{0}\n'.format(stmt)) 463 self.__sendCommand('{0}\n'.format(stmt))
483 """ 485 """
484 Public method to stop the debugged program. 486 Public method to stop the debugged program.
485 """ 487 """
486 self.__sendCommand(RequestStepQuit + '\n') 488 self.__sendCommand(RequestStepQuit + '\n')
487 489
488 def remoteContinue(self, special = False): 490 def remoteContinue(self, special=False):
489 """ 491 """
490 Public method to continue the debugged program. 492 Public method to continue the debugged program.
491 493
492 @param special flag indicating a special continue operation (boolean) 494 @param special flag indicating a special continue operation (boolean)
493 """ 495 """
494 self.__sendCommand('{0}{1:d}\n'.format(RequestContinue, special)) 496 self.__sendCommand('{0}{1:d}\n'.format(RequestContinue, special))
495 497
496 def remoteBreakpoint(self, fn, line, set, cond = None, temp = False): 498 def remoteBreakpoint(self, fn, line, set, cond=None, temp=False):
497 """ 499 """
498 Public method to set or clear a breakpoint. 500 Public method to set or clear a breakpoint.
499 501
500 @param fn filename the breakpoint belongs to (string) 502 @param fn filename the breakpoint belongs to (string)
501 @param line linenumber of the breakpoint (int) 503 @param line linenumber of the breakpoint (int)
529 """ 531 """
530 fn = self.translate(fn, False) 532 fn = self.translate(fn, False)
531 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format( 533 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format(
532 RequestBreakIgnore, fn, line, count)) 534 RequestBreakIgnore, fn, line, count))
533 535
534 def remoteWatchpoint(self, cond, set, temp = False): 536 def remoteWatchpoint(self, cond, set, temp=False):
535 """ 537 """
536 Public method to set or clear a watch expression. 538 Public method to set or clear a watch expression.
537 539
538 @param cond expression of the watch expression (string) 540 @param cond expression of the watch expression (string)
539 @param set flag indicating setting or resetting a watch expression (boolean) 541 @param set flag indicating setting or resetting a watch expression (boolean)
560 @param count number of occurrences to ignore (int) 562 @param count number of occurrences to ignore (int)
561 """ 563 """
562 # cond is combination of cond and special (s. watch expression viewer) 564 # cond is combination of cond and special (s. watch expression viewer)
563 self.__sendCommand('{0}{1},{2:d}\n'.format(RequestWatchIgnore, cond, count)) 565 self.__sendCommand('{0}{1},{2:d}\n'.format(RequestWatchIgnore, cond, count))
564 566
565 def remoteRawInput(self,s): 567 def remoteRawInput(self, s):
566 """ 568 """
567 Public method to send the raw input to the debugged program. 569 Public method to send the raw input to the debugged program.
568 570
569 @param s the raw input (string) 571 @param s the raw input (string)
570 """ 572 """
582 584
583 @param tid id of the thread (integer) 585 @param tid id of the thread (integer)
584 """ 586 """
585 return 587 return
586 588
587 def remoteClientVariables(self, scope, filter, framenr = 0): 589 def remoteClientVariables(self, scope, filter, framenr=0):
588 """ 590 """
589 Public method to request the variables of the debugged program. 591 Public method to request the variables of the debugged program.
590 592
591 @param scope the scope of the variables (0 = local, 1 = global) 593 @param scope the scope of the variables (0 = local, 1 = global)
592 @param filter list of variable types to filter out (list of int) 594 @param filter list of variable types to filter out (list of int)
593 @param framenr framenumber of the variables to retrieve (int) 595 @param framenr framenumber of the variables to retrieve (int)
594 """ 596 """
595 self.__sendCommand('{0}{1:d}, {2:d}, {3}\n'.format( 597 self.__sendCommand('{0}{1:d}, {2:d}, {3}\n'.format(
596 RequestVariables, framenr, scope, str(filter))) 598 RequestVariables, framenr, scope, str(filter)))
597 599
598 def remoteClientVariable(self, scope, filter, var, framenr = 0): 600 def remoteClientVariable(self, scope, filter, var, framenr=0):
599 """ 601 """
600 Public method to request the variables of the debugged program. 602 Public method to request the variables of the debugged program.
601 603
602 @param scope the scope of the variables (0 = local, 1 = global) 604 @param scope the scope of the variables (0 = local, 1 = global)
603 @param filter list of variable types to filter out (list of int) 605 @param filter list of variable types to filter out (list of int)

eric ide

mercurial