Debugger/DebuggerInterfacePython.py

changeset 1112
8a7d1b9d18db
parent 1079
f05ca3490bd1
child 1131
7781e396c903
equal deleted inserted replaced
1109:9552b5e16a07 1112:8a7d1b9d18db
9 9
10 import sys 10 import sys
11 import os 11 import os
12 import re 12 import re
13 13
14 from PyQt4.QtCore import * 14 from PyQt4.QtCore import QObject, QTextCodec, QProcess, QTimer
15 from PyQt4.QtGui import QInputDialog 15 from PyQt4.QtGui import QInputDialog
16 16
17 from E5Gui.E5Application import e5App 17 from E5Gui.E5Application import e5App
18 from E5Gui import E5MessageBox 18 from E5Gui import E5MessageBox
19 19
20 from .DebugProtocol import * 20 from . import DebugProtocol
21 from . import DebugClientCapabilities 21 from . import DebugClientCapabilities
22 22
23 import Preferences 23 import Preferences
24 import Utilities 24 import Utilities
25 25
216 try: 216 try:
217 key, value = el.split('=', 1) 217 key, value = el.split('=', 1)
218 if value.startswith('"') or value.startswith("'"): 218 if value.startswith('"') or value.startswith("'"):
219 value = value[1:-1] 219 value = value[1:-1]
220 clientEnv[str(key)] = str(value) 220 clientEnv[str(key)] = str(value)
221 except UnpackError: 221 except ValueError:
222 pass 222 pass
223 223
224 ipaddr = self.debugServer.getHostAddress(True) 224 ipaddr = self.debugServer.getHostAddress(True)
225 if runInConsole or Preferences.getDebugger("ConsoleDbgEnabled"): 225 if runInConsole or Preferences.getDebugger("ConsoleDbgEnabled"):
226 ccmd = Preferences.getDebugger("ConsoleDbgCommand") 226 ccmd = Preferences.getDebugger("ConsoleDbgCommand")
308 try: 308 try:
309 key, value = el.split('=', 1) 309 key, value = el.split('=', 1)
310 if value.startswith('"') or value.startswith("'"): 310 if value.startswith('"') or value.startswith("'"):
311 value = value[1:-1] 311 value = value[1:-1]
312 clientEnv[str(key)] = str(value) 312 clientEnv[str(key)] = str(value)
313 except UnpackError: 313 except ValueError:
314 pass 314 pass
315 315
316 ipaddr = self.debugServer.getHostAddress(True) 316 ipaddr = self.debugServer.getHostAddress(True)
317 if runInConsole or project.getDebugProperty("CONSOLEDEBUGGER"): 317 if runInConsole or project.getDebugProperty("CONSOLEDEBUGGER"):
318 ccmd = project.getDebugProperty("CONSOLECOMMAND") or \ 318 ccmd = project.getDebugProperty("CONSOLECOMMAND") or \
391 # do not want any slots called during shutdown 391 # do not want any slots called during shutdown
392 self.qsock.disconnected.disconnect(self.debugServer.startClient) 392 self.qsock.disconnected.disconnect(self.debugServer.startClient)
393 self.qsock.readyRead[()].disconnect(self.__parseClientLine) 393 self.qsock.readyRead[()].disconnect(self.__parseClientLine)
394 394
395 # close down socket, and shut down client as well. 395 # close down socket, and shut down client as well.
396 self.__sendCommand('{0}\n'.format(RequestShutdown)) 396 self.__sendCommand('{0}\n'.format(DebugProtocol.RequestShutdown))
397 self.qsock.flush() 397 self.qsock.flush()
398 398
399 self.qsock.close() 399 self.qsock.close()
400 400
401 # reinitialize 401 # reinitialize
414 """ 414 """
415 Public method to set the environment for a program to debug, run, ... 415 Public method to set the environment for a program to debug, run, ...
416 416
417 @param env environment settings (dictionary) 417 @param env environment settings (dictionary)
418 """ 418 """
419 self.__sendCommand('{0}{1}\n'.format(RequestEnv, str(env))) 419 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEnv, str(env)))
420 420
421 def remoteLoad(self, fn, argv, wd, traceInterpreter=False, autoContinue=True, 421 def remoteLoad(self, fn, argv, wd, traceInterpreter=False, autoContinue=True,
422 autoFork=False, forkChild=False): 422 autoFork=False, forkChild=False):
423 """ 423 """
424 Public method to load a new program to debug. 424 Public method to load a new program to debug.
435 """ 435 """
436 self.__autoContinue = autoContinue 436 self.__autoContinue = autoContinue
437 437
438 wd = self.translate(wd, False) 438 wd = self.translate(wd, False)
439 fn = self.translate(os.path.abspath(fn), False) 439 fn = self.translate(os.path.abspath(fn), False)
440 self.__sendCommand('{0}{1}\n'.format(RequestForkMode, repr((autoFork, forkChild)))) 440 self.__sendCommand('{0}{1}\n'.format(
441 DebugProtocol.RequestForkMode, repr((autoFork, forkChild))))
441 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format( 442 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
442 RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)), 443 DebugProtocol.RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)),
443 traceInterpreter)) 444 traceInterpreter))
444 445
445 def remoteRun(self, fn, argv, wd, autoFork=False, forkChild=False): 446 def remoteRun(self, fn, argv, wd, autoFork=False, forkChild=False):
446 """ 447 """
447 Public method to load a new program to run. 448 Public method to load a new program to run.
452 @keyparam autoFork flag indicating the automatic fork mode (boolean) 453 @keyparam autoFork flag indicating the automatic fork mode (boolean)
453 @keyparam forkChild flag indicating to debug the child after forking (boolean) 454 @keyparam forkChild flag indicating to debug the child after forking (boolean)
454 """ 455 """
455 wd = self.translate(wd, False) 456 wd = self.translate(wd, False)
456 fn = self.translate(os.path.abspath(fn), False) 457 fn = self.translate(os.path.abspath(fn), False)
457 self.__sendCommand('{0}{1}\n'.format(RequestForkMode, repr((autoFork, forkChild)))) 458 self.__sendCommand('{0}{1}\n'.format(
459 DebugProtocol.RequestForkMode, repr((autoFork, forkChild))))
458 self.__sendCommand('{0}{1}|{2}|{3}\n'.format( 460 self.__sendCommand('{0}{1}|{2}|{3}\n'.format(
459 RequestRun, wd, fn, str(Utilities.parseOptionString(argv)))) 461 DebugProtocol.RequestRun, wd, fn, str(Utilities.parseOptionString(argv))))
460 462
461 def remoteCoverage(self, fn, argv, wd, erase=False): 463 def remoteCoverage(self, fn, argv, wd, erase=False):
462 """ 464 """
463 Public method to load a new program to collect coverage data. 465 Public method to load a new program to collect coverage data.
464 466
469 cleared first (boolean) 471 cleared first (boolean)
470 """ 472 """
471 wd = self.translate(wd, False) 473 wd = self.translate(wd, False)
472 fn = self.translate(os.path.abspath(fn), False) 474 fn = self.translate(os.path.abspath(fn), False)
473 self.__sendCommand('{0}{1}@@{2}@@{3}@@{4:d}\n'.format( 475 self.__sendCommand('{0}{1}@@{2}@@{3}@@{4:d}\n'.format(
474 RequestCoverage, wd, fn, str(Utilities.parseOptionString(argv)), 476 DebugProtocol.RequestCoverage, wd, fn, str(Utilities.parseOptionString(argv)),
475 erase)) 477 erase))
476 478
477 def remoteProfile(self, fn, argv, wd, erase=False): 479 def remoteProfile(self, fn, argv, wd, erase=False):
478 """ 480 """
479 Public method to load a new program to collect profiling data. 481 Public method to load a new program to collect profiling data.
484 @keyparam erase flag indicating that timing info should be cleared first (boolean) 486 @keyparam erase flag indicating that timing info should be cleared first (boolean)
485 """ 487 """
486 wd = self.translate(wd, False) 488 wd = self.translate(wd, False)
487 fn = self.translate(os.path.abspath(fn), False) 489 fn = self.translate(os.path.abspath(fn), False)
488 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format( 490 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
489 RequestProfile, wd, fn, str(Utilities.parseOptionString(argv)), erase)) 491 DebugProtocol.RequestProfile, wd, fn,
492 str(Utilities.parseOptionString(argv)), erase))
490 493
491 def remoteStatement(self, stmt): 494 def remoteStatement(self, stmt):
492 """ 495 """
493 Public method to execute a Python statement. 496 Public method to execute a Python statement.
494 497
495 @param stmt the Python statement to execute (string). It 498 @param stmt the Python statement to execute (string). It
496 should not have a trailing newline. 499 should not have a trailing newline.
497 """ 500 """
498 self.__sendCommand('{0}\n'.format(stmt)) 501 self.__sendCommand('{0}\n'.format(stmt))
499 self.__sendCommand(RequestOK + '\n') 502 self.__sendCommand(DebugProtocol.RequestOK + '\n')
500 503
501 def remoteStep(self): 504 def remoteStep(self):
502 """ 505 """
503 Public method to single step the debugged program. 506 Public method to single step the debugged program.
504 """ 507 """
505 self.__sendCommand(RequestStep + '\n') 508 self.__sendCommand(DebugProtocol.RequestStep + '\n')
506 509
507 def remoteStepOver(self): 510 def remoteStepOver(self):
508 """ 511 """
509 Public method to step over the debugged program. 512 Public method to step over the debugged program.
510 """ 513 """
511 self.__sendCommand(RequestStepOver + '\n') 514 self.__sendCommand(DebugProtocol.RequestStepOver + '\n')
512 515
513 def remoteStepOut(self): 516 def remoteStepOut(self):
514 """ 517 """
515 Public method to step out the debugged program. 518 Public method to step out the debugged program.
516 """ 519 """
517 self.__sendCommand(RequestStepOut + '\n') 520 self.__sendCommand(DebugProtocol.RequestStepOut + '\n')
518 521
519 def remoteStepQuit(self): 522 def remoteStepQuit(self):
520 """ 523 """
521 Public method to stop the debugged program. 524 Public method to stop the debugged program.
522 """ 525 """
523 self.__sendCommand(RequestStepQuit + '\n') 526 self.__sendCommand(DebugProtocol.RequestStepQuit + '\n')
524 527
525 def remoteContinue(self, special=False): 528 def remoteContinue(self, special=False):
526 """ 529 """
527 Public method to continue the debugged program. 530 Public method to continue the debugged program.
528 531
529 @param special flag indicating a special continue operation (boolean) 532 @param special flag indicating a special continue operation (boolean)
530 """ 533 """
531 self.__sendCommand('{0}{1:d}\n'.format(RequestContinue, special)) 534 self.__sendCommand('{0}{1:d}\n'.format(DebugProtocol.RequestContinue, special))
532 535
533 def remoteBreakpoint(self, fn, line, set, cond=None, temp=False): 536 def remoteBreakpoint(self, fn, line, set, cond=None, temp=False):
534 """ 537 """
535 Public method to set or clear a breakpoint. 538 Public method to set or clear a breakpoint.
536 539
540 @param cond condition of the breakpoint (string) 543 @param cond condition of the breakpoint (string)
541 @param temp flag indicating a temporary breakpoint (boolean) 544 @param temp flag indicating a temporary breakpoint (boolean)
542 """ 545 """
543 fn = self.translate(fn, False) 546 fn = self.translate(fn, False)
544 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format( 547 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}@@{4:d}@@{5}\n'.format(
545 RequestBreak, fn, line, temp, set, cond)) 548 DebugProtocol.RequestBreak, fn, line, temp, set, cond))
546 549
547 def remoteBreakpointEnable(self, fn, line, enable): 550 def remoteBreakpointEnable(self, fn, line, enable):
548 """ 551 """
549 Public method to enable or disable a breakpoint. 552 Public method to enable or disable a breakpoint.
550 553
552 @param line linenumber of the breakpoint (int) 555 @param line linenumber of the breakpoint (int)
553 @param enable flag indicating enabling or disabling a breakpoint (boolean) 556 @param enable flag indicating enabling or disabling a breakpoint (boolean)
554 """ 557 """
555 fn = self.translate(fn, False) 558 fn = self.translate(fn, False)
556 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format( 559 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format(
557 RequestBreakEnable, fn, line, enable)) 560 DebugProtocol.RequestBreakEnable, fn, line, enable))
558 561
559 def remoteBreakpointIgnore(self, fn, line, count): 562 def remoteBreakpointIgnore(self, fn, line, count):
560 """ 563 """
561 Public method to ignore a breakpoint the next couple of occurrences. 564 Public method to ignore a breakpoint the next couple of occurrences.
562 565
564 @param line linenumber of the breakpoint (int) 567 @param line linenumber of the breakpoint (int)
565 @param count number of occurrences to ignore (int) 568 @param count number of occurrences to ignore (int)
566 """ 569 """
567 fn = self.translate(fn, False) 570 fn = self.translate(fn, False)
568 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format( 571 self.__sendCommand('{0}{1},{2:d},{3:d}\n'.format(
569 RequestBreakIgnore, fn, line, count)) 572 DebugProtocol.RequestBreakIgnore, fn, line, count))
570 573
571 def remoteWatchpoint(self, cond, set, temp=False): 574 def remoteWatchpoint(self, cond, set, temp=False):
572 """ 575 """
573 Public method to set or clear a watch expression. 576 Public method to set or clear a watch expression.
574 577
575 @param cond expression of the watch expression (string) 578 @param cond expression of the watch expression (string)
576 @param set flag indicating setting or resetting a watch expression (boolean) 579 @param set flag indicating setting or resetting a watch expression (boolean)
577 @param temp flag indicating a temporary watch expression (boolean) 580 @param temp flag indicating a temporary watch expression (boolean)
578 """ 581 """
579 # cond is combination of cond and special (s. watch expression viewer) 582 # cond is combination of cond and special (s. watch expression viewer)
580 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}\n'.format(RequestWatch, cond, temp, set)) 583 self.__sendCommand('{0}{1}@@{2:d}@@{3:d}\n'.format(
584 DebugProtocol.RequestWatch, cond, temp, set))
581 585
582 def remoteWatchpointEnable(self, cond, enable): 586 def remoteWatchpointEnable(self, cond, enable):
583 """ 587 """
584 Public method to enable or disable a watch expression. 588 Public method to enable or disable a watch expression.
585 589
586 @param cond expression of the watch expression (string) 590 @param cond expression of the watch expression (string)
587 @param enable flag indicating enabling or disabling a watch expression (boolean) 591 @param enable flag indicating enabling or disabling a watch expression (boolean)
588 """ 592 """
589 # cond is combination of cond and special (s. watch expression viewer) 593 # cond is combination of cond and special (s. watch expression viewer)
590 self.__sendCommand('{0}{1},{2:d}\n'.format(RequestWatchEnable, cond, enable)) 594 self.__sendCommand('{0}{1},{2:d}\n'.format(
595 DebugProtocol.RequestWatchEnable, cond, enable))
591 596
592 def remoteWatchpointIgnore(self, cond, count): 597 def remoteWatchpointIgnore(self, cond, count):
593 """ 598 """
594 Public method to ignore a watch expression the next couple of occurrences. 599 Public method to ignore a watch expression the next couple of occurrences.
595 600
596 @param cond expression of the watch expression (string) 601 @param cond expression of the watch expression (string)
597 @param count number of occurrences to ignore (int) 602 @param count number of occurrences to ignore (int)
598 """ 603 """
599 # cond is combination of cond and special (s. watch expression viewer) 604 # cond is combination of cond and special (s. watch expression viewer)
600 self.__sendCommand('{0}{1},{2:d}\n'.format(RequestWatchIgnore, cond, count)) 605 self.__sendCommand('{0}{1},{2:d}\n'.format(
606 DebugProtocol.RequestWatchIgnore, cond, count))
601 607
602 def remoteRawInput(self, s): 608 def remoteRawInput(self, s):
603 """ 609 """
604 Public method to send the raw input to the debugged program. 610 Public method to send the raw input to the debugged program.
605 611
609 615
610 def remoteThreadList(self): 616 def remoteThreadList(self):
611 """ 617 """
612 Public method to request the list of threads from the client. 618 Public method to request the list of threads from the client.
613 """ 619 """
614 self.__sendCommand('{0}\n'.format(RequestThreadList)) 620 self.__sendCommand('{0}\n'.format(DebugProtocol.RequestThreadList))
615 621
616 def remoteSetThread(self, tid): 622 def remoteSetThread(self, tid):
617 """ 623 """
618 Public method to request to set the given thread as current thread. 624 Public method to request to set the given thread as current thread.
619 625
620 @param tid id of the thread (integer) 626 @param tid id of the thread (integer)
621 """ 627 """
622 self.__sendCommand('{0}{1:d}\n'.format(RequestThreadSet, tid)) 628 self.__sendCommand('{0}{1:d}\n'.format(DebugProtocol.RequestThreadSet, tid))
623 629
624 def remoteClientVariables(self, scope, filter, framenr=0): 630 def remoteClientVariables(self, scope, filter, framenr=0):
625 """ 631 """
626 Public method to request the variables of the debugged program. 632 Public method to request the variables of the debugged program.
627 633
628 @param scope the scope of the variables (0 = local, 1 = global) 634 @param scope the scope of the variables (0 = local, 1 = global)
629 @param filter list of variable types to filter out (list of int) 635 @param filter list of variable types to filter out (list of int)
630 @param framenr framenumber of the variables to retrieve (int) 636 @param framenr framenumber of the variables to retrieve (int)
631 """ 637 """
632 self.__sendCommand('{0}{1:d}, {2:d}, {3}\n'.format( 638 self.__sendCommand('{0}{1:d}, {2:d}, {3}\n'.format(
633 RequestVariables, framenr, scope, str(filter))) 639 DebugProtocol.RequestVariables, framenr, scope, str(filter)))
634 640
635 def remoteClientVariable(self, scope, filter, var, framenr=0): 641 def remoteClientVariable(self, scope, filter, var, framenr=0):
636 """ 642 """
637 Public method to request the variables of the debugged program. 643 Public method to request the variables of the debugged program.
638 644
640 @param filter list of variable types to filter out (list of int) 646 @param filter list of variable types to filter out (list of int)
641 @param var list encoded name of variable to retrieve (string) 647 @param var list encoded name of variable to retrieve (string)
642 @param framenr framenumber of the variables to retrieve (int) 648 @param framenr framenumber of the variables to retrieve (int)
643 """ 649 """
644 self.__sendCommand('{0}{1}, {2:d}, {3:d}, {4}\n'.format( 650 self.__sendCommand('{0}{1}, {2:d}, {3:d}, {4}\n'.format(
645 RequestVariable, str(var), framenr, scope, str(filter))) 651 DebugProtocol.RequestVariable, str(var), framenr, scope, str(filter)))
646 652
647 def remoteClientSetFilter(self, scope, filter): 653 def remoteClientSetFilter(self, scope, filter):
648 """ 654 """
649 Public method to set a variables filter list. 655 Public method to set a variables filter list.
650 656
651 @param scope the scope of the variables (0 = local, 1 = global) 657 @param scope the scope of the variables (0 = local, 1 = global)
652 @param filter regexp string for variable names to filter out (string) 658 @param filter regexp string for variable names to filter out (string)
653 """ 659 """
654 self.__sendCommand('{0}{1:d}, "{2}"\n'.format(RequestSetFilter, scope, filter)) 660 self.__sendCommand('{0}{1:d}, "{2}"\n'.format(
661 DebugProtocol.RequestSetFilter, scope, filter))
655 662
656 def remoteEval(self, arg): 663 def remoteEval(self, arg):
657 """ 664 """
658 Public method to evaluate arg in the current context of the debugged program. 665 Public method to evaluate arg in the current context of the debugged program.
659 666
660 @param arg the arguments to evaluate (string) 667 @param arg the arguments to evaluate (string)
661 """ 668 """
662 self.__sendCommand('{0}{1}\n'.format(RequestEval, arg)) 669 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestEval, arg))
663 670
664 def remoteExec(self, stmt): 671 def remoteExec(self, stmt):
665 """ 672 """
666 Public method to execute stmt in the current context of the debugged program. 673 Public method to execute stmt in the current context of the debugged program.
667 674
668 @param stmt statement to execute (string) 675 @param stmt statement to execute (string)
669 """ 676 """
670 self.__sendCommand('{0}{1}\n'.format(RequestExec, stmt)) 677 self.__sendCommand('{0}{1}\n'.format(DebugProtocol.RequestExec, stmt))
671 678
672 def remoteBanner(self): 679 def remoteBanner(self):
673 """ 680 """
674 Public slot to get the banner info of the remote client. 681 Public slot to get the banner info of the remote client.
675 """ 682 """
676 self.__sendCommand(RequestBanner + '\n') 683 self.__sendCommand(DebugProtocol.RequestBanner + '\n')
677 684
678 def remoteCapabilities(self): 685 def remoteCapabilities(self):
679 """ 686 """
680 Public slot to get the debug clients capabilities. 687 Public slot to get the debug clients capabilities.
681 """ 688 """
682 self.__sendCommand(RequestCapabilities + '\n') 689 self.__sendCommand(DebugProtocol.RequestCapabilities + '\n')
683 690
684 def remoteCompletion(self, text): 691 def remoteCompletion(self, text):
685 """ 692 """
686 Public slot to get the a list of possible commandline completions 693 Public slot to get the a list of possible commandline completions
687 from the remote client. 694 from the remote client.
688 695
689 @param text the text to be completed (string) 696 @param text the text to be completed (string)
690 """ 697 """
691 self.__sendCommand("{0}{1}\n".format(RequestCompletion, text)) 698 self.__sendCommand("{0}{1}\n".format(DebugProtocol.RequestCompletion, text))
692 699
693 def remoteUTPrepare(self, fn, tn, tfn, cov, covname, coverase): 700 def remoteUTPrepare(self, fn, tn, tfn, cov, covname, coverase):
694 """ 701 """
695 Public method to prepare a new unittest run. 702 Public method to prepare a new unittest run.
696 703
702 filename 709 filename
703 @param coverase flag indicating erasure of coverage data is requested 710 @param coverase flag indicating erasure of coverage data is requested
704 """ 711 """
705 fn = self.translate(os.path.abspath(fn), False) 712 fn = self.translate(os.path.abspath(fn), False)
706 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}|{5}|{6:d}\n'.format( 713 self.__sendCommand('{0}{1}|{2}|{3}|{4:d}|{5}|{6:d}\n'.format(
707 RequestUTPrepare, fn, tn, tfn, cov, covname, coverase)) 714 DebugProtocol.RequestUTPrepare, fn, tn, tfn, cov, covname, coverase))
708 715
709 def remoteUTRun(self): 716 def remoteUTRun(self):
710 """ 717 """
711 Public method to start a unittest run. 718 Public method to start a unittest run.
712 """ 719 """
713 self.__sendCommand('{0}\n'.format(RequestUTRun)) 720 self.__sendCommand('{0}\n'.format(DebugProtocol.RequestUTRun))
714 721
715 def remoteUTStop(self): 722 def remoteUTStop(self):
716 """ 723 """
717 Public method to stop a unittest run. 724 Public method to stop a unittest run.
718 """ 725 """
719 self.__sendCommand('{0}\n'.format(RequestUTStop)) 726 self.__sendCommand('{0}\n'.format(DebugProtocol.RequestUTStop))
720 727
721 def __askForkTo(self): 728 def __askForkTo(self):
722 """ 729 """
723 Private method to ask the user which branch of a fork to follow. 730 Private method to ask the user which branch of a fork to follow.
724 """ 731 """
728 self.trUtf8("Client forking"), 735 self.trUtf8("Client forking"),
729 self.trUtf8("Select the fork branch to follow."), 736 self.trUtf8("Select the fork branch to follow."),
730 selections, 737 selections,
731 0, False) 738 0, False)
732 if not ok or res == selections[0]: 739 if not ok or res == selections[0]:
733 self.__sendCommand(ResponseForkTo + 'parent\n') 740 self.__sendCommand(DebugProtocol.ResponseForkTo + 'parent\n')
734 else: 741 else:
735 self.__sendCommand(ResponseForkTo + 'child\n') 742 self.__sendCommand(DebugProtocol.ResponseForkTo + 'child\n')
736 743
737 def __parseClientLine(self): 744 def __parseClientLine(self):
738 """ 745 """
739 Private method to handle data from the client. 746 Private method to handle data from the client.
740 """ 747 """
742 qs = self.qsock.readLine() 749 qs = self.qsock.readLine()
743 if self.codec is not None: 750 if self.codec is not None:
744 line = self.codec.toUnicode(qs) 751 line = self.codec.toUnicode(qs)
745 else: 752 else:
746 line = bytes(qs).decode() 753 line = bytes(qs).decode()
747 if line.endswith(EOT): 754 if line.endswith(DebugProtocol.EOT):
748 line = line[:-len(EOT)] 755 line = line[:-len(DebugProtocol.EOT)]
749 if not line: 756 if not line:
750 continue 757 continue
751 758
752 ## print("Server: ", line) ##debug 759 ## print("Server: ", line) ##debug
753 760
766 773
767 if boc >= 0 and eoc > boc: 774 if boc >= 0 and eoc > boc:
768 resp = line[boc:eoc] 775 resp = line[boc:eoc]
769 evalArg = self.__unicodeRe.sub(r"\1", line[eoc:-1]) 776 evalArg = self.__unicodeRe.sub(r"\1", line[eoc:-1])
770 777
771 if resp == ResponseLine or resp == ResponseStack: 778 if resp == DebugProtocol.ResponseLine or \
779 resp == DebugProtocol.ResponseStack:
772 stack = eval(evalArg) 780 stack = eval(evalArg)
773 for s in stack: 781 for s in stack:
774 s[0] = self.translate(s[0], True) 782 s[0] = self.translate(s[0], True)
775 cf = stack[0] 783 cf = stack[0]
776 if self.__autoContinue: 784 if self.__autoContinue:
777 self.__autoContinue = False 785 self.__autoContinue = False
778 QTimer.singleShot(0, self.remoteContinue) 786 QTimer.singleShot(0, self.remoteContinue)
779 else: 787 else:
780 self.debugServer.signalClientLine(cf[0], int(cf[1]), 788 self.debugServer.signalClientLine(cf[0], int(cf[1]),
781 resp == ResponseStack) 789 resp == DebugProtocol.ResponseStack)
782 self.debugServer.signalClientStack(stack) 790 self.debugServer.signalClientStack(stack)
783 continue 791 continue
784 792
785 if resp == ResponseThreadList: 793 if resp == DebugProtocol.ResponseThreadList:
786 currentId, threadList = eval(evalArg) 794 currentId, threadList = eval(evalArg)
787 self.debugServer.signalClientThreadList(currentId, threadList) 795 self.debugServer.signalClientThreadList(currentId, threadList)
788 continue 796 continue
789 797
790 if resp == ResponseThreadSet: 798 if resp == DebugProtocol.ResponseThreadSet:
791 self.debugServer.signalClientThreadSet() 799 self.debugServer.signalClientThreadSet()
792 continue 800 continue
793 801
794 if resp == ResponseVariables: 802 if resp == DebugProtocol.ResponseVariables:
795 vlist = eval(evalArg) 803 vlist = eval(evalArg)
796 scope = vlist[0] 804 scope = vlist[0]
797 try: 805 try:
798 variables = vlist[1:] 806 variables = vlist[1:]
799 except IndexError: 807 except IndexError:
800 variables = [] 808 variables = []
801 self.debugServer.signalClientVariables(scope, variables) 809 self.debugServer.signalClientVariables(scope, variables)
802 continue 810 continue
803 811
804 if resp == ResponseVariable: 812 if resp == DebugProtocol.ResponseVariable:
805 vlist = eval(evalArg) 813 vlist = eval(evalArg)
806 scope = vlist[0] 814 scope = vlist[0]
807 try: 815 try:
808 variables = vlist[1:] 816 variables = vlist[1:]
809 except IndexError: 817 except IndexError:
810 variables = [] 818 variables = []
811 self.debugServer.signalClientVariable(scope, variables) 819 self.debugServer.signalClientVariable(scope, variables)
812 continue 820 continue
813 821
814 if resp == ResponseOK: 822 if resp == DebugProtocol.ResponseOK:
815 self.debugServer.signalClientStatement(False) 823 self.debugServer.signalClientStatement(False)
816 continue 824 continue
817 825
818 if resp == ResponseContinue: 826 if resp == DebugProtocol.ResponseContinue:
819 self.debugServer.signalClientStatement(True) 827 self.debugServer.signalClientStatement(True)
820 continue 828 continue
821 829
822 if resp == ResponseException: 830 if resp == DebugProtocol.ResponseException:
823 exc = self.translate(evalArg, True) 831 exc = self.translate(evalArg, True)
824 try: 832 try:
825 exclist = eval(exc) 833 exclist = eval(exc)
826 exctype = exclist[0] 834 exctype = exclist[0]
827 excmessage = exclist[1] 835 excmessage = exclist[1]
833 excmessage = '' 841 excmessage = ''
834 stack = [] 842 stack = []
835 self.debugServer.signalClientException(exctype, excmessage, stack) 843 self.debugServer.signalClientException(exctype, excmessage, stack)
836 continue 844 continue
837 845
838 if resp == ResponseSyntax: 846 if resp == DebugProtocol.ResponseSyntax:
839 exc = self.translate(evalArg, True) 847 exc = self.translate(evalArg, True)
840 try: 848 try:
841 message, (fn, ln, cn) = eval(exc) 849 message, (fn, ln, cn) = eval(exc)
842 if fn is None: 850 if fn is None:
843 fn = '' 851 fn = ''
849 if cn is None: 857 if cn is None:
850 cn = 0 858 cn = 0
851 self.debugServer.signalClientSyntaxError(message, fn, ln, cn) 859 self.debugServer.signalClientSyntaxError(message, fn, ln, cn)
852 continue 860 continue
853 861
854 if resp == ResponseExit: 862 if resp == DebugProtocol.ResponseExit:
855 self.debugServer.signalClientExit(evalArg) 863 self.debugServer.signalClientExit(evalArg)
856 continue 864 continue
857 865
858 if resp == ResponseClearBreak: 866 if resp == DebugProtocol.ResponseClearBreak:
859 fn, lineno = evalArg.split(',') 867 fn, lineno = evalArg.split(',')
860 lineno = int(lineno) 868 lineno = int(lineno)
861 fn = self.translate(fn, True) 869 fn = self.translate(fn, True)
862 self.debugServer.signalClientClearBreak(fn, lineno) 870 self.debugServer.signalClientClearBreak(fn, lineno)
863 continue 871 continue
864 872
865 if resp == ResponseBPConditionError: 873 if resp == DebugProtocol.ResponseBPConditionError:
866 fn, lineno = evalArg.split(',') 874 fn, lineno = evalArg.split(',')
867 lineno = int(lineno) 875 lineno = int(lineno)
868 fn = self.translate(fn, True) 876 fn = self.translate(fn, True)
869 self.debugServer.signalClientBreakConditionError(fn, lineno) 877 self.debugServer.signalClientBreakConditionError(fn, lineno)
870 continue 878 continue
871 879
872 if resp == ResponseClearWatch: 880 if resp == DebugProtocol.ResponseClearWatch:
873 self.debugServer.signalClientClearWatch(evalArg) 881 self.debugServer.signalClientClearWatch(evalArg)
874 continue 882 continue
875 883
876 if resp == ResponseWPConditionError: 884 if resp == DebugProtocol.ResponseWPConditionError:
877 self.debugServer.signalClientWatchConditionError(evalArg) 885 self.debugServer.signalClientWatchConditionError(evalArg)
878 continue 886 continue
879 887
880 if resp == ResponseRaw: 888 if resp == DebugProtocol.ResponseRaw:
881 prompt, echo = eval(evalArg) 889 prompt, echo = eval(evalArg)
882 self.debugServer.signalClientRawInput(prompt, echo) 890 self.debugServer.signalClientRawInput(prompt, echo)
883 continue 891 continue
884 892
885 if resp == ResponseBanner: 893 if resp == DebugProtocol.ResponseBanner:
886 version, platform, dbgclient = eval(evalArg) 894 version, platform, dbgclient = eval(evalArg)
887 self.debugServer.signalClientBanner(version, platform, dbgclient) 895 self.debugServer.signalClientBanner(version, platform, dbgclient)
888 continue 896 continue
889 897
890 if resp == ResponseCapabilities: 898 if resp == DebugProtocol.ResponseCapabilities:
891 cap, clType = eval(evalArg) 899 cap, clType = eval(evalArg)
892 self.clientCapabilities = cap 900 self.clientCapabilities = cap
893 self.debugServer.signalClientCapabilities(cap, clType) 901 self.debugServer.signalClientCapabilities(cap, clType)
894 continue 902 continue
895 903
896 if resp == ResponseCompletion: 904 if resp == DebugProtocol.ResponseCompletion:
897 clstring, text = evalArg.split('||') 905 clstring, text = evalArg.split('||')
898 cl = eval(clstring) 906 cl = eval(clstring)
899 self.debugServer.signalClientCompletionList(cl, text) 907 self.debugServer.signalClientCompletionList(cl, text)
900 continue 908 continue
901 909
902 if resp == PassiveStartup: 910 if resp == DebugProtocol.PassiveStartup:
903 fn, exc = evalArg.split('|') 911 fn, exc = evalArg.split('|')
904 exc = bool(exc) 912 exc = bool(exc)
905 fn = self.translate(fn, True) 913 fn = self.translate(fn, True)
906 self.debugServer.passiveStartUp(fn, exc) 914 self.debugServer.passiveStartUp(fn, exc)
907 continue 915 continue
908 916
909 if resp == ResponseUTPrepared: 917 if resp == DebugProtocol.ResponseUTPrepared:
910 res, exc_type, exc_value = eval(evalArg) 918 res, exc_type, exc_value = eval(evalArg)
911 self.debugServer.clientUtPrepared(res, exc_type, exc_value) 919 self.debugServer.clientUtPrepared(res, exc_type, exc_value)
912 continue 920 continue
913 921
914 if resp == ResponseUTStartTest: 922 if resp == DebugProtocol.ResponseUTStartTest:
915 testname, doc = eval(evalArg) 923 testname, doc = eval(evalArg)
916 self.debugServer.clientUtStartTest(testname, doc) 924 self.debugServer.clientUtStartTest(testname, doc)
917 continue 925 continue
918 926
919 if resp == ResponseUTStopTest: 927 if resp == DebugProtocol.ResponseUTStopTest:
920 self.debugServer.clientUtStopTest() 928 self.debugServer.clientUtStopTest()
921 continue 929 continue
922 930
923 if resp == ResponseUTTestFailed: 931 if resp == DebugProtocol.ResponseUTTestFailed:
924 testname, traceback = eval(evalArg) 932 testname, traceback = eval(evalArg)
925 self.debugServer.clientUtTestFailed(testname, traceback) 933 self.debugServer.clientUtTestFailed(testname, traceback)
926 continue 934 continue
927 935
928 if resp == ResponseUTTestErrored: 936 if resp == DebugProtocol.ResponseUTTestErrored:
929 testname, traceback = eval(evalArg) 937 testname, traceback = eval(evalArg)
930 self.debugServer.clientUtTestErrored(testname, traceback) 938 self.debugServer.clientUtTestErrored(testname, traceback)
931 continue 939 continue
932 940
933 if resp == ResponseUTFinished: 941 if resp == DebugProtocol.ResponseUTFinished:
934 self.debugServer.clientUtFinished() 942 self.debugServer.clientUtFinished()
935 continue 943 continue
936 944
937 if resp == RequestForkTo: 945 if resp == DebugProtocol.RequestForkTo:
938 self.__askForkTo() 946 self.__askForkTo()
939 continue 947 continue
940 948
941 self.debugServer.signalClientOutput(line) 949 self.debugServer.signalClientOutput(line)
942 950

eric ide

mercurial