Debugger/DebuggerInterfacePython.py

branch
5_0_x
changeset 712
58c7e6bbe7ec
parent 112
16893e193e9d
child 792
a13346916170
equal deleted inserted replaced
707:0676521505a6 712:58c7e6bbe7ec
7 Module implementing the Python debugger interface for the debug server. 7 Module implementing the Python debugger interface for the debug server.
8 """ 8 """
9 9
10 import sys 10 import sys
11 import os 11 import os
12 import re
12 13
13 from PyQt4.QtCore import * 14 from PyQt4.QtCore import *
14 from PyQt4.QtGui import QInputDialog, QMessageBox 15 from PyQt4.QtGui import QInputDialog, QMessageBox
15 16
16 from E5Gui.E5Application import e5App 17 from E5Gui.E5Application import e5App
69 self.queue = [] 70 self.queue = []
70 # set default values for capabilities of clients 71 # set default values for capabilities of clients
71 self.clientCapabilities = ClientDefaultCapabilities 72 self.clientCapabilities = ClientDefaultCapabilities
72 73
73 self.codec = QTextCodec.codecForName(Preferences.getSystem("StringEncoding")) 74 self.codec = QTextCodec.codecForName(Preferences.getSystem("StringEncoding"))
75
76 self.__unicodeRe = re.compile(r"""\bu(["'])""")
74 77
75 if passive: 78 if passive:
76 # set translation function 79 # set translation function
77 if Preferences.getDebugger("PathTranslation"): 80 if Preferences.getDebugger("PathTranslation"):
78 self.translateRemote = \ 81 self.translateRemote = \
757 eoc = line.find('<') + 1 760 eoc = line.find('<') + 1
758 boc = line.find('>') 761 boc = line.find('>')
759 762
760 if boc >= 0 and eoc > boc: 763 if boc >= 0 and eoc > boc:
761 resp = line[boc:eoc] 764 resp = line[boc:eoc]
765 evalArg = self.__unicodeRe.sub(r"\1", line[eoc:-1])
762 766
763 if resp == ResponseLine or resp == ResponseStack: 767 if resp == ResponseLine or resp == ResponseStack:
764 stack = eval(line[eoc:-1]) 768 stack = eval(evalArg)
765 for s in stack: 769 for s in stack:
766 s[0] = self.translate(s[0], True) 770 s[0] = self.translate(s[0], True)
767 cf = stack[0] 771 cf = stack[0]
768 if self.__autoContinue: 772 if self.__autoContinue:
769 self.__autoContinue = False 773 self.__autoContinue = False
773 resp == ResponseStack) 777 resp == ResponseStack)
774 self.debugServer.clientStack(stack) 778 self.debugServer.clientStack(stack)
775 continue 779 continue
776 780
777 if resp == ResponseThreadList: 781 if resp == ResponseThreadList:
778 currentId, threadList = eval(line[eoc:-1]) 782 currentId, threadList = eval(evalArg)
779 self.debugServer.clientThreadList(currentId, threadList) 783 self.debugServer.clientThreadList(currentId, threadList)
780 continue 784 continue
781 785
782 if resp == ResponseThreadSet: 786 if resp == ResponseThreadSet:
783 self.debugServer.clientThreadSet() 787 self.debugServer.clientThreadSet()
784 continue 788 continue
785 789
786 if resp == ResponseVariables: 790 if resp == ResponseVariables:
787 vlist = eval(line[eoc:-1]) 791 vlist = eval(evalArg)
788 scope = vlist[0] 792 scope = vlist[0]
789 try: 793 try:
790 variables = vlist[1:] 794 variables = vlist[1:]
791 except IndexError: 795 except IndexError:
792 variables = [] 796 variables = []
793 self.debugServer.clientVariables(scope, variables) 797 self.debugServer.clientVariables(scope, variables)
794 continue 798 continue
795 799
796 if resp == ResponseVariable: 800 if resp == ResponseVariable:
797 vlist = eval(line[eoc:-1]) 801 vlist = eval(evalArg)
798 scope = vlist[0] 802 scope = vlist[0]
799 try: 803 try:
800 variables = vlist[1:] 804 variables = vlist[1:]
801 except IndexError: 805 except IndexError:
802 variables = [] 806 variables = []
810 if resp == ResponseContinue: 814 if resp == ResponseContinue:
811 self.debugServer.clientStatement(True) 815 self.debugServer.clientStatement(True)
812 continue 816 continue
813 817
814 if resp == ResponseException: 818 if resp == ResponseException:
815 exc = line[eoc:-1] 819 exc = self.translate(evalArg, True)
816 exc = self.translate(exc, True)
817 try: 820 try:
818 exclist = eval(exc) 821 exclist = eval(exc)
819 exctype = exclist[0] 822 exctype = exclist[0]
820 excmessage = exclist[1] 823 excmessage = exclist[1]
821 stack = exclist[2:] 824 stack = exclist[2:]
825 stack = [] 828 stack = []
826 self.debugServer.clientException(exctype, excmessage, stack) 829 self.debugServer.clientException(exctype, excmessage, stack)
827 continue 830 continue
828 831
829 if resp == ResponseSyntax: 832 if resp == ResponseSyntax:
830 exc = line[eoc:-1] 833 exc = self.translate(evalArg, True)
831 exc = self.translate(exc, True)
832 try: 834 try:
833 message, (fn, ln, cn) = eval(exc) 835 message, (fn, ln, cn) = eval(exc)
834 if fn is None: 836 if fn is None:
835 fn = '' 837 fn = ''
836 except (IndexError, ValueError): 838 except (IndexError, ValueError):
842 cn = 0 844 cn = 0
843 self.debugServer.clientSyntaxError(message, fn, ln, cn) 845 self.debugServer.clientSyntaxError(message, fn, ln, cn)
844 continue 846 continue
845 847
846 if resp == ResponseExit: 848 if resp == ResponseExit:
847 self.debugServer.clientExit(line[eoc:-1]) 849 self.debugServer.clientExit(evalArg)
848 continue 850 continue
849 851
850 if resp == ResponseClearBreak: 852 if resp == ResponseClearBreak:
851 fn, lineno = line[eoc:-1].split(',') 853 fn, lineno = evalArg.split(',')
852 lineno = int(lineno) 854 lineno = int(lineno)
853 fn = self.translate(fn, True) 855 fn = self.translate(fn, True)
854 self.debugServer.clientClearBreak(fn, lineno) 856 self.debugServer.clientClearBreak(fn, lineno)
855 continue 857 continue
856 858
857 if resp == ResponseBPConditionError: 859 if resp == ResponseBPConditionError:
858 fn, lineno = line[eoc:-1].split(',') 860 fn, lineno = evalArg.split(',')
859 lineno = int(lineno) 861 lineno = int(lineno)
860 fn = self.translate(fn, True) 862 fn = self.translate(fn, True)
861 self.debugServer.clientBreakConditionError(fn, lineno) 863 self.debugServer.clientBreakConditionError(fn, lineno)
862 continue 864 continue
863 865
864 if resp == ResponseClearWatch: 866 if resp == ResponseClearWatch:
865 cond = line[eoc:-1] 867 self.debugServer.clientClearWatch(evalArg)
866 self.debugServer.clientClearWatch(cond)
867 continue 868 continue
868 869
869 if resp == ResponseWPConditionError: 870 if resp == ResponseWPConditionError:
870 cond = line[eoc:-1] 871 self.debugServer.clientWatchConditionError(evalArg)
871 self.debugServer.clientWatchConditionError(cond)
872 continue 872 continue
873 873
874 if resp == ResponseRaw: 874 if resp == ResponseRaw:
875 prompt, echo = eval(line[eoc:-1]) 875 prompt, echo = eval(evalArg)
876 self.debugServer.clientRawInput(prompt, echo) 876 self.debugServer.clientRawInput(prompt, echo)
877 continue 877 continue
878 878
879 if resp == ResponseBanner: 879 if resp == ResponseBanner:
880 version, platform, dbgclient = eval(line[eoc:-1]) 880 version, platform, dbgclient = eval(evalArg)
881 self.debugServer.clientBanner(version, platform, dbgclient) 881 self.debugServer.clientBanner(version, platform, dbgclient)
882 continue 882 continue
883 883
884 if resp == ResponseCapabilities: 884 if resp == ResponseCapabilities:
885 cap, clType = eval(line[eoc:-1]) 885 cap, clType = eval(evalArg)
886 self.clientCapabilities = cap 886 self.clientCapabilities = cap
887 self.debugServer.clientCapabilities(cap, clType) 887 self.debugServer.clientCapabilities(cap, clType)
888 continue 888 continue
889 889
890 if resp == ResponseCompletion: 890 if resp == ResponseCompletion:
891 clstring, text = line[eoc:-1].split('||') 891 clstring, text = evalArg.split('||')
892 cl = eval(clstring) 892 cl = eval(clstring)
893 self.debugServer.clientCompletionList(cl, text) 893 self.debugServer.clientCompletionList(cl, text)
894 continue 894 continue
895 895
896 if resp == PassiveStartup: 896 if resp == PassiveStartup:
897 fn, exc = line[eoc:-1].split('|') 897 fn, exc = evalArg.split('|')
898 exc = bool(exc) 898 exc = bool(exc)
899 fn = self.translate(fn, True) 899 fn = self.translate(fn, True)
900 self.debugServer.passiveStartUp(fn, exc) 900 self.debugServer.passiveStartUp(fn, exc)
901 continue 901 continue
902 902
903 if resp == ResponseUTPrepared: 903 if resp == ResponseUTPrepared:
904 res, exc_type, exc_value = eval(line[eoc:-1]) 904 res, exc_type, exc_value = eval(evalArg)
905 self.debugServer.clientUtPrepared(res, exc_type, exc_value) 905 self.debugServer.clientUtPrepared(res, exc_type, exc_value)
906 continue 906 continue
907 907
908 if resp == ResponseUTStartTest: 908 if resp == ResponseUTStartTest:
909 testname, doc = eval(line[eoc:-1]) 909 testname, doc = eval(evalArg)
910 self.debugServer.clientUtStartTest(testname, doc) 910 self.debugServer.clientUtStartTest(testname, doc)
911 continue 911 continue
912 912
913 if resp == ResponseUTStopTest: 913 if resp == ResponseUTStopTest:
914 self.debugServer.clientUtStopTest() 914 self.debugServer.clientUtStopTest()
915 continue 915 continue
916 916
917 if resp == ResponseUTTestFailed: 917 if resp == ResponseUTTestFailed:
918 testname, traceback = eval(line[eoc:-1]) 918 testname, traceback = eval(evalArg)
919 self.debugServer.clientUtTestFailed(testname, traceback) 919 self.debugServer.clientUtTestFailed(testname, traceback)
920 continue 920 continue
921 921
922 if resp == ResponseUTTestErrored: 922 if resp == ResponseUTTestErrored:
923 testname, traceback = eval(line[eoc:-1]) 923 testname, traceback = eval(evalArg)
924 self.debugServer.clientUtTestErrored(testname, traceback) 924 self.debugServer.clientUtTestErrored(testname, traceback)
925 continue 925 continue
926 926
927 if resp == ResponseUTFinished: 927 if resp == ResponseUTFinished:
928 self.debugServer.clientUtFinished() 928 self.debugServer.clientUtFinished()

eric ide

mercurial