Debugger/DebuggerInterfaceRuby.py

changeset 406
eacf81fad150
parent 112
16893e193e9d
child 465
c20e25deb33a
equal deleted inserted replaced
405:374066392929 406:eacf81fad150
114 """ 114 """
115 proc = QProcess() 115 proc = QProcess()
116 if environment is not None: 116 if environment is not None:
117 env = [] 117 env = []
118 for key, value in list(environment.items()): 118 for key, value in list(environment.items()):
119 env.append("%s=%s" % (key, value)) 119 env.append("{0}={1}".format(key, value))
120 proc.setEnvironment(env) 120 proc.setEnvironment(env)
121 args = [] 121 args = []
122 for arg in arguments: 122 for arg in arguments:
123 args.append(arg) 123 args.append(arg)
124 proc.start(program, args) 124 proc.start(program, args)
362 self.disconnect(self.qsock, SIGNAL('disconnected()'), 362 self.disconnect(self.qsock, SIGNAL('disconnected()'),
363 self.debugServer.startClient) 363 self.debugServer.startClient)
364 self.disconnect(self.qsock, SIGNAL('readyRead()'), self.__parseClientLine) 364 self.disconnect(self.qsock, SIGNAL('readyRead()'), self.__parseClientLine)
365 365
366 # close down socket, and shut down client as well. 366 # close down socket, and shut down client as well.
367 self.__sendCommand('%s\n' % RequestShutdown) 367 self.__sendCommand('{0}\n'.format(RequestShutdown))
368 self.qsock.flush() 368 self.qsock.flush()
369 369
370 self.qsock.close() 370 self.qsock.close()
371 371
372 # reinitialize 372 # reinitialize
385 """ 385 """
386 Public method to set the environment for a program to debug, run, ... 386 Public method to set the environment for a program to debug, run, ...
387 387
388 @param env environment settings (dictionary) 388 @param env environment settings (dictionary)
389 """ 389 """
390 self.__sendCommand('%s%s\n' % (RequestEnv, str(env))) 390 self.__sendCommand('{0}{1}\n'.format(RequestEnv, str(env)))
391 391
392 def remoteLoad(self, fn, argv, wd, traceInterpreter = False, autoContinue = True, 392 def remoteLoad(self, fn, argv, wd, traceInterpreter = False, autoContinue = True,
393 autoFork = False, forkChild = False): 393 autoFork = False, forkChild = False):
394 """ 394 """
395 Public method to load a new program to debug. 395 Public method to load a new program to debug.
407 """ 407 """
408 self.__autoContinue = autoContinue 408 self.__autoContinue = autoContinue
409 409
410 wd = self.translate(wd, False) 410 wd = self.translate(wd, False)
411 fn = self.translate(os.path.abspath(fn), False) 411 fn = self.translate(os.path.abspath(fn), False)
412 self.__sendCommand('%s%s|%s|%s|%d\n' % \ 412 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
413 (RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)), 413 RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)),
414 traceInterpreter)) 414 traceInterpreter))
415 415
416 def remoteRun(self, fn, argv, wd, autoFork = False, forkChild = False): 416 def remoteRun(self, fn, argv, wd, autoFork = False, forkChild = False):
417 """ 417 """
418 Public method to load a new program to run. 418 Public method to load a new program to run.
424 @keyparam forkChild flag indicating to debug the child after forking 424 @keyparam forkChild flag indicating to debug the child after forking
425 (boolean) (ignored) 425 (boolean) (ignored)
426 """ 426 """
427 wd = self.translate(wd, False) 427 wd = self.translate(wd, False)
428 fn = self.translate(os.path.abspath(fn), False) 428 fn = self.translate(os.path.abspath(fn), False)
429 self.__sendCommand('%s%s|%s|%s\n' % \ 429 self.__sendCommand('{0}{1}|{2}|{3}\n'.format(
430 (RequestRun, wd, fn, str(Utilities.parseOptionString(argv)))) 430 RequestRun, wd, fn, str(Utilities.parseOptionString(argv))))
431 431
432 def remoteCoverage(self, fn, argv, wd, erase = False): 432 def remoteCoverage(self, fn, argv, wd, erase = False):
433 """ 433 """
434 Public method to load a new program to collect coverage data. 434 Public method to load a new program to collect coverage data.
435 435
457 Public method to execute a Ruby statement. 457 Public method to execute a Ruby statement.
458 458
459 @param stmt the Ruby statement to execute (string). It 459 @param stmt the Ruby statement to execute (string). It
460 should not have a trailing newline. 460 should not have a trailing newline.
461 """ 461 """
462 self.__sendCommand('%s\n' % stmt) 462 self.__sendCommand('{0}\n'.format(stmt))
463 self.__sendCommand(RequestOK + '\n') 463 self.__sendCommand(RequestOK + '\n')
464 464
465 def remoteStep(self): 465 def remoteStep(self):
466 """ 466 """
467 Public method to single step the debugged program. 467 Public method to single step the debugged program.
490 """ 490 """
491 Public method to continue the debugged program. 491 Public method to continue the debugged program.
492 492
493 @param special flag indicating a special continue operation (boolean) 493 @param special flag indicating a special continue operation (boolean)
494 """ 494 """
495 self.__sendCommand('%s%d\n' % (RequestContinue, special)) 495 self.__sendCommand('{0}{1:d}\n'.format(RequestContinue, special))
496 496
497 def remoteBreakpoint(self, fn, line, set, cond = None, temp = False): 497 def remoteBreakpoint(self, fn, line, set, cond = None, temp = False):
498 """ 498 """
499 Public method to set or clear a breakpoint. 499 Public method to set or clear a breakpoint.
500 500
503 @param set flag indicating setting or resetting a breakpoint (boolean) 503 @param set flag indicating setting or resetting a breakpoint (boolean)
504 @param cond condition of the breakpoint (string) 504 @param cond condition of the breakpoint (string)
505 @param temp flag indicating a temporary breakpoint (boolean) 505 @param temp flag indicating a temporary breakpoint (boolean)
506 """ 506 """
507 fn = self.translate(fn, False) 507 fn = self.translate(fn, False)
508 self.__sendCommand('%s%s@@%d@@%d@@%d@@%s\n' % \ 508 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format(
509 (RequestBreak, fn, line, temp, set, cond)) 509 RequestBreak, fn, line, temp, set, cond))
510 510
511 def remoteBreakpointEnable(self, fn, line, enable): 511 def remoteBreakpointEnable(self, fn, line, enable):
512 """ 512 """
513 Public method to enable or disable a breakpoint. 513 Public method to enable or disable a breakpoint.
514 514
515 @param fn filename the breakpoint belongs to (string) 515 @param fn filename the breakpoint belongs to (string)
516 @param line linenumber of the breakpoint (int) 516 @param line linenumber of the breakpoint (int)
517 @param enable flag indicating enabling or disabling a breakpoint (boolean) 517 @param enable flag indicating enabling or disabling a breakpoint (boolean)
518 """ 518 """
519 fn = self.translate(fn, False) 519 fn = self.translate(fn, False)
520 self.__sendCommand('%s%s,%d,%d\n' % (RequestBreakEnable, fn, line, enable)) 520 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format(
521 RequestBreakEnable, fn, line, enable))
521 522
522 def remoteBreakpointIgnore(self, fn, line, count): 523 def remoteBreakpointIgnore(self, fn, line, count):
523 """ 524 """
524 Public method to ignore a breakpoint the next couple of occurrences. 525 Public method to ignore a breakpoint the next couple of occurrences.
525 526
526 @param fn filename the breakpoint belongs to (string) 527 @param fn filename the breakpoint belongs to (string)
527 @param line linenumber of the breakpoint (int) 528 @param line linenumber of the breakpoint (int)
528 @param count number of occurrences to ignore (int) 529 @param count number of occurrences to ignore (int)
529 """ 530 """
530 fn = self.translate(fn, False) 531 fn = self.translate(fn, False)
531 self.__sendCommand('%s%s,%d,%d\n' % (RequestBreakIgnore, fn, line, count)) 532 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format(
533 RequestBreakIgnore, fn, line, count))
532 534
533 def remoteWatchpoint(self, cond, set, temp = False): 535 def remoteWatchpoint(self, cond, set, temp = False):
534 """ 536 """
535 Public method to set or clear a watch expression. 537 Public method to set or clear a watch expression.
536 538
537 @param cond expression of the watch expression (string) 539 @param cond expression of the watch expression (string)
538 @param set flag indicating setting or resetting a watch expression (boolean) 540 @param set flag indicating setting or resetting a watch expression (boolean)
539 @param temp flag indicating a temporary watch expression (boolean) 541 @param temp flag indicating a temporary watch expression (boolean)
540 """ 542 """
541 # cond is combination of cond and special (s. watch expression viewer) 543 # cond is combination of cond and special (s. watch expression viewer)
542 self.__sendCommand('%s%s@@%d@@%d\n' % (RequestWatch, cond, temp, set)) 544 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}\n'.format(RequestWatch, cond, temp, set))
543 545
544 def remoteWatchpointEnable(self, cond, enable): 546 def remoteWatchpointEnable(self, cond, enable):
545 """ 547 """
546 Public method to enable or disable a watch expression. 548 Public method to enable or disable a watch expression.
547 549
548 @param cond expression of the watch expression (string) 550 @param cond expression of the watch expression (string)
549 @param enable flag indicating enabling or disabling a watch expression (boolean) 551 @param enable flag indicating enabling or disabling a watch expression (boolean)
550 """ 552 """
551 # cond is combination of cond and special (s. watch expression viewer) 553 # cond is combination of cond and special (s. watch expression viewer)
552 self.__sendCommand('%s%s,%d\n' % (RequestWatchEnable, cond, enable)) 554 self.__sendCommand('{0}{1},{2:d}\n'.format(RequestWatchEnable, cond, enable))
553 555
554 def remoteWatchpointIgnore(self, cond, count): 556 def remoteWatchpointIgnore(self, cond, count):
555 """ 557 """
556 Public method to ignore a watch expression the next couple of occurrences. 558 Public method to ignore a watch expression the next couple of occurrences.
557 559
558 @param cond expression of the watch expression (string) 560 @param cond expression of the watch expression (string)
559 @param count number of occurrences to ignore (int) 561 @param count number of occurrences to ignore (int)
560 """ 562 """
561 # cond is combination of cond and special (s. watch expression viewer) 563 # cond is combination of cond and special (s. watch expression viewer)
562 self.__sendCommand('%s%s,%d\n' % (RequestWatchIgnore, cond, count)) 564 self.__sendCommand('{0}{1},{2:d}\n'.format(RequestWatchIgnore, cond, count))
563 565
564 def remoteRawInput(self,s): 566 def remoteRawInput(self,s):
565 """ 567 """
566 Public method to send the raw input to the debugged program. 568 Public method to send the raw input to the debugged program.
567 569
589 591
590 @param scope the scope of the variables (0 = local, 1 = global) 592 @param scope the scope of the variables (0 = local, 1 = global)
591 @param filter list of variable types to filter out (list of int) 593 @param filter list of variable types to filter out (list of int)
592 @param framenr framenumber of the variables to retrieve (int) 594 @param framenr framenumber of the variables to retrieve (int)
593 """ 595 """
594 self.__sendCommand('%s%d, %d, %s\n' % \ 596 self.__sendCommand('{0}{1:d}, {2:d}, {3}\n'.format(
595 (RequestVariables, framenr, scope, str(filter))) 597 RequestVariables, framenr, scope, str(filter)))
596 598
597 def remoteClientVariable(self, scope, filter, var, framenr = 0): 599 def remoteClientVariable(self, scope, filter, var, framenr = 0):
598 """ 600 """
599 Public method to request the variables of the debugged program. 601 Public method to request the variables of the debugged program.
600 602
601 @param scope the scope of the variables (0 = local, 1 = global) 603 @param scope the scope of the variables (0 = local, 1 = global)
602 @param filter list of variable types to filter out (list of int) 604 @param filter list of variable types to filter out (list of int)
603 @param var list encoded name of variable to retrieve (string) 605 @param var list encoded name of variable to retrieve (string)
604 @param framenr framenumber of the variables to retrieve (int) 606 @param framenr framenumber of the variables to retrieve (int)
605 """ 607 """
606 self.__sendCommand('%s%s, %d, %d, %s\n' % \ 608 self.__sendCommand('{0}{1}, {2:d}, {3:d}, {4}\n'.format(
607 (RequestVariable, str(var), framenr, scope, str(filter))) 609 RequestVariable, str(var), framenr, scope, str(filter)))
608 610
609 def remoteClientSetFilter(self, scope, filter): 611 def remoteClientSetFilter(self, scope, filter):
610 """ 612 """
611 Public method to set a variables filter list. 613 Public method to set a variables filter list.
612 614
613 @param scope the scope of the variables (0 = local, 1 = global) 615 @param scope the scope of the variables (0 = local, 1 = global)
614 @param filter regexp string for variable names to filter out (string) 616 @param filter regexp string for variable names to filter out (string)
615 """ 617 """
616 self.__sendCommand('%s%d, "%s"\n' % (RequestSetFilter, scope, filter)) 618 self.__sendCommand('{0}{1:d}, "{2}"\n'.format(RequestSetFilter, scope, filter))
617 619
618 def remoteEval(self, arg): 620 def remoteEval(self, arg):
619 """ 621 """
620 Public method to evaluate arg in the current context of the debugged program. 622 Public method to evaluate arg in the current context of the debugged program.
621 623
622 @param arg the arguments to evaluate (string) 624 @param arg the arguments to evaluate (string)
623 """ 625 """
624 self.__sendCommand('%s%s\n' % (RequestEval, arg)) 626 self.__sendCommand('{0}{1}\n'.format(RequestEval, arg))
625 627
626 def remoteExec(self, stmt): 628 def remoteExec(self, stmt):
627 """ 629 """
628 Public method to execute stmt in the current context of the debugged program. 630 Public method to execute stmt in the current context of the debugged program.
629 631
630 @param stmt statement to execute (string) 632 @param stmt statement to execute (string)
631 """ 633 """
632 self.__sendCommand('%s%s\n' % (RequestExec, stmt)) 634 self.__sendCommand('{0}{1}\n'.format(RequestExec, stmt))
633 635
634 def remoteBanner(self): 636 def remoteBanner(self):
635 """ 637 """
636 Public slot to get the banner info of the remote client. 638 Public slot to get the banner info of the remote client.
637 """ 639 """
648 Public slot to get the a list of possible commandline completions 650 Public slot to get the a list of possible commandline completions
649 from the remote client. 651 from the remote client.
650 652
651 @param text the text to be completed (string) 653 @param text the text to be completed (string)
652 """ 654 """
653 self.__sendCommand("%s%s\n" % (RequestCompletion, text)) 655 self.__sendCommand("{0}{1}\n".format(RequestCompletion, text))
654 656
655 def remoteUTPrepare(self, fn, tn, tfn, cov, covname, coverase): 657 def remoteUTPrepare(self, fn, tn, tfn, cov, covname, coverase):
656 """ 658 """
657 Public method to prepare a new unittest run. 659 Public method to prepare a new unittest run.
658 660

eric ide

mercurial