Debugger/DebuggerInterfacePython3.py

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

eric ide

mercurial