Debugger/DebuggerInterfacePython3.py

branch
jsonrpc
changeset 5120
c5189d404cc7
parent 5119
80bd41498eef
child 5124
1ba8ee313b57
diff -r 80bd41498eef -r c5189d404cc7 Debugger/DebuggerInterfacePython3.py
--- a/Debugger/DebuggerInterfacePython3.py	Wed Aug 31 18:31:57 2016 +0200
+++ b/Debugger/DebuggerInterfacePython3.py	Wed Aug 31 19:55:49 2016 +0200
@@ -482,11 +482,18 @@
         
         wd = self.translate(wd, False)
         fn = self.translate(os.path.abspath(fn), False)
-        self.__sendCommand('{0}{1}\n'.format(
-            DebugProtocol.RequestForkMode, repr((autoFork, forkChild))))
-        self.__sendCommand('{0}{1}|{2}|{3}\n'.format(
-            DebugProtocol.RequestRun, wd, fn,
-            str(Utilities.parseOptionString(argv))))
+##        self.__sendCommand('{0}{1}\n'.format(
+##            DebugProtocol.RequestForkMode, repr((autoFork, forkChild))))
+##        self.__sendCommand('{0}{1}|{2}|{3}\n'.format(
+##            DebugProtocol.RequestRun, wd, fn,
+##            str(Utilities.parseOptionString(argv))))
+        self.__sendJsonCommand("RequestRun", {
+            "workdir": wd,
+            "filename": fn,
+            "argv": Utilities.parseOptionString(argv),
+            "autofork": autoFork,
+            "forkChild": forkChild,
+        })
     
     def remoteCoverage(self, fn, argv, wd, erase=False):
         """
@@ -502,10 +509,16 @@
         
         wd = self.translate(wd, False)
         fn = self.translate(os.path.abspath(fn), False)
-        self.__sendCommand('{0}{1}@@{2}@@{3}@@{4:d}\n'.format(
-            DebugProtocol.RequestCoverage, wd, fn,
-            str(Utilities.parseOptionString(argv)),
-            erase))
+##        self.__sendCommand('{0}{1}@@{2}@@{3}@@{4:d}\n'.format(
+##            DebugProtocol.RequestCoverage, wd, fn,
+##            str(Utilities.parseOptionString(argv)),
+##            erase))
+        self.__sendJsonCommand("RequestCoverage", {
+            "workdir": wd,
+            "filename": fn,
+            "argv": Utilities.parseOptionString(argv),
+            "erase": erase,
+        })
 
     def remoteProfile(self, fn, argv, wd, erase=False):
         """
@@ -521,9 +534,15 @@
         
         wd = self.translate(wd, False)
         fn = self.translate(os.path.abspath(fn), False)
-        self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
-            DebugProtocol.RequestProfile, wd, fn,
-            str(Utilities.parseOptionString(argv)), erase))
+##        self.__sendCommand('{0}{1}|{2}|{3}|{4:d}\n'.format(
+##            DebugProtocol.RequestProfile, wd, fn,
+##            str(Utilities.parseOptionString(argv)), erase))
+        self.__sendJsonCommand("RequestProfile", {
+            "workdir": wd,
+            "filename": fn,
+            "argv": Utilities.parseOptionString(argv),
+            "erase": erase,
+        })
 
     def remoteStatement(self, stmt):
         """
@@ -532,32 +551,39 @@
         @param stmt the Python statement to execute (string). It
               should not have a trailing newline.
         """
-        self.__sendCommand('{0}\n'.format(stmt))
-        self.__sendCommand(DebugProtocol.RequestOK + '\n')
+##        self.__sendCommand('{0}\n'.format(stmt))
+##        self.__sendCommand(DebugProtocol.RequestOK + '\n')
+        self.__sendJsonCommand("ExecuteStatement", {
+            "statement": stmt,
+        })
 
     def remoteStep(self):
         """
         Public method to single step the debugged program.
         """
-        self.__sendCommand(DebugProtocol.RequestStep + '\n')
+##        self.__sendCommand(DebugProtocol.RequestStep + '\n')
+        self.__sendJsonCommand("RequestStep", {})
 
     def remoteStepOver(self):
         """
         Public method to step over the debugged program.
         """
-        self.__sendCommand(DebugProtocol.RequestStepOver + '\n')
+##        self.__sendCommand(DebugProtocol.RequestStepOver + '\n')
+        self.__sendJsonCommand("RequestStepOver", {})
 
     def remoteStepOut(self):
         """
         Public method to step out the debugged program.
         """
-        self.__sendCommand(DebugProtocol.RequestStepOut + '\n')
+##        self.__sendCommand(DebugProtocol.RequestStepOut + '\n')
+        self.__sendJsonCommand("RequestStepOut", {})
 
     def remoteStepQuit(self):
         """
         Public method to stop the debugged program.
         """
-        self.__sendCommand(DebugProtocol.RequestStepQuit + '\n')
+##        self.__sendCommand(DebugProtocol.RequestStepQuit + '\n')
+        self.__sendJsonCommand("RequestStepQuit", {})
 
     def remoteContinue(self, special=False):
         """
@@ -565,8 +591,11 @@
         
         @param special flag indicating a special continue operation
         """
-        self.__sendCommand('{0}{1:d}\n'.format(
-            DebugProtocol.RequestContinue, special))
+##        self.__sendCommand('{0}{1:d}\n'.format(
+##            DebugProtocol.RequestContinue, special))
+        self.__sendJsonCommand("RequestContinue", {
+            "special": special,
+        })
 
     def remoteBreakpoint(self, fn, line, set, cond=None, temp=False):
         """
@@ -650,7 +679,10 @@
         
         @param s the raw input (string)
         """
-        self.__sendCommand(s + '\n')
+##        self.__sendCommand(s + '\n')
+        self.__sendJsonCommand("RawInput", {
+            "input": s,
+        })
     
     def remoteThreadList(self):
         """
@@ -902,14 +934,14 @@
                     self.debugServer.signalClientVariable(scope, variables)
                     continue
                 
-                if resp == DebugProtocol.ResponseOK:
-                    self.debugServer.signalClientStatement(False)
-                    continue
-                
-                if resp == DebugProtocol.ResponseContinue:
-                    self.debugServer.signalClientStatement(True)
-                    continue
-                
+##                if resp == DebugProtocol.ResponseOK:
+##                    self.debugServer.signalClientStatement(False)
+##                    continue
+##                
+##                if resp == DebugProtocol.ResponseContinue:
+##                    self.debugServer.signalClientStatement(True)
+##                    continue
+##                
                 if resp == DebugProtocol.ResponseException:
                     exc = line[eoc:-1]
                     exc = self.translate(exc, True)
@@ -988,11 +1020,11 @@
                     self.debugServer.signalClientWatchConditionError(cond)
                     continue
                 
-                if resp == DebugProtocol.ResponseRaw:
-                    prompt, echo = eval(line[eoc:-1])
-                    self.debugServer.signalClientRawInput(prompt, echo)
-                    continue
-                
+##                if resp == DebugProtocol.ResponseRaw:
+##                    prompt, echo = eval(line[eoc:-1])
+##                    self.debugServer.signalClientRawInput(prompt, echo)
+##                    continue
+##                
 ##                if resp == DebugProtocol.ResponseBanner:
 ##                    version, platform, dbgclient = eval(line[eoc:-1])
 ##                    self.debugServer.signalClientBanner(
@@ -1098,6 +1130,19 @@
                 params["platform"],
                 params["dbgclient"])
             return
+        
+        if method == "ResponseOK":
+            self.debugServer.signalClientStatement(False)
+            return
+        
+        if method == "ResponseContinue":
+            self.debugServer.signalClientStatement(True)
+            return
+        
+        if method == "RequestRaw":
+            self.debugServer.signalClientRawInput(
+                params["prompt"], params["echo"])
+            return
     
     def __sendCommand(self, cmd):
         """

eric ide

mercurial