[Idle-dev] CVS: idle Debugger.py,1.5,1.6 OldStackViewer.py,1.2,1.3 PyShell.py,1.15,1.16 RemoteDebugger.py,1.1,1.2 rpc.py,1.1,1.2 run.py,1.1,1.2

Kurt B. Kaiser kbk@users.sourceforge.net
Sat, 15 Jun 2002 20:32:26 -0700


Update of /cvsroot/idlefork/idle
In directory usw-pr-cvs1:/tmp/cvs-serv15129

Modified Files:
	Debugger.py OldStackViewer.py PyShell.py RemoteDebugger.py 
	rpc.py run.py 
Log Message:
Polish RemoteDebugger code.  
Use a repr() on the subprocess side when fetching dict values for stack.
The various dict entities are not needed by the debugger GUI, only
their representation.


Index: Debugger.py
===================================================================
RCS file: /cvsroot/idlefork/idle/Debugger.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** Debugger.py	26 May 2002 13:36:40 -0000	1.5
--- Debugger.py	16 Jun 2002 03:32:23 -0000	1.6
***************
*** 53,57 ****
  class Debugger:
  
!     interacting = 0
      vstack = vsource = vlocals = vglobals = None
  
--- 53,57 ----
  class Debugger:
  
!     # interacting = 0  # XXX KBK 14Jun02 move to __init__
      vstack = vsource = vlocals = vglobals = None
  
***************
*** 61,66 ****
          self.pyshell = pyshell
          self.idb = idb
          self.make_gui()
! 
      def run(self, *args):
          try:
--- 61,68 ----
          self.pyshell = pyshell
          self.idb = idb
+         self.frame = None
          self.make_gui()
!         self.interacting = 0
!         
      def run(self, *args):
          try:
***************
*** 156,160 ****
              self.show_globals()
  
!     frame = None
  
      def interaction(self, message, frame, info=None):
--- 158,162 ----
              self.show_globals()
  
!     # frame = None  # XXX KBK 14Jun02  Move to __init__
  
      def interaction(self, message, frame, info=None):
***************
*** 301,308 ****
              if lv and gv and ldict is gdict:
                  ldict = None
          if lv:
!             lv.load_dict(ldict, force)
          if gv:
!             gv.load_dict(gdict, force)
  
      def set_breakpoint_here(self, edit):
--- 303,311 ----
              if lv and gv and ldict is gdict:
                  ldict = None
+         # Calls OldStackviewer.NamespaceViewer.load_dict():
          if lv:
!             lv.load_dict(ldict, force, self.pyshell.interp.rpcclt)
          if gv:
!             gv.load_dict(gdict, force, self.pyshell.interp.rpcclt)
  
      def set_breakpoint_here(self, edit):
***************
*** 313,317 ****
              return
          lineno = int(float(text.index("insert")))
!         msg = self.set_break(filename, lineno)
          if msg:
              text.bell()
--- 316,320 ----
              return
          lineno = int(float(text.index("insert")))
!         msg = self.idb.set_break(filename, lineno)
          if msg:
              text.bell()

Index: OldStackViewer.py
===================================================================
RCS file: /cvsroot/idlefork/idle/OldStackViewer.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** OldStackViewer.py	4 Jul 2001 03:15:10 -0000	1.2
--- OldStackViewer.py	16 Jun 2002 03:32:23 -0000	1.3
***************
*** 233,237 ****
      dict = -1
  
!     def load_dict(self, dict, force=0):
          if dict is self.dict and not force:
              return
--- 233,237 ----
      dict = -1
  
!     def load_dict(self, dict, force=0, rpc_client=None):
          if dict is self.dict and not force:
              return
***************
*** 251,254 ****
--- 251,258 ----
                  value = dict[name]
                  svalue = self.repr.repr(value) # repr(value)
+                 # Strip extra quotes caused by calling repr on the (already)
+                 # repr'd value sent across the RPC interface:
+                 if rpc_client:
+                     svalue = svalue[1:-1]
                  l = Label(subframe, text=name)
                  l.grid(row=row, column=0, sticky="nw")

Index: PyShell.py
===================================================================
RCS file: /cvsroot/idlefork/idle/PyShell.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** PyShell.py	12 Jun 2002 03:28:57 -0000	1.15
--- PyShell.py	16 Jun 2002 03:32:24 -0000	1.16
***************
*** 530,533 ****
--- 530,536 ----
  
      def open_debugger(self):
+         # XXX KBK 13Jun02 An RPC client always exists now? Open remote
+         # debugger and return...dike the rest of this fcn and combine
+         # with open_remote_debugger?
          if self.interp.rpcclt:
              return self.open_remote_debugger()

Index: RemoteDebugger.py
===================================================================
RCS file: /cvsroot/idlefork/idle/RemoteDebugger.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** RemoteDebugger.py	26 May 2002 13:36:40 -0000	1.1
--- RemoteDebugger.py	16 Jun 2002 03:32:24 -0000	1.2
***************
*** 25,28 ****
--- 25,30 ----
  import Debugger
  
+ debugging = 0
+ 
  # In the PYTHON subprocess
  
***************
*** 44,50 ****
  class GUIProxy:
  
!     def __init__(self, conn, oid):
          self.conn = conn
!         self.oid = oid
  
      def interaction(self, message, frame, info=None):
--- 46,52 ----
  class GUIProxy:
  
!     def __init__(self, conn, gui_adap_oid):
          self.conn = conn
!         self.oid = gui_adap_oid
  
      def interaction(self, message, frame, info=None):
***************
*** 129,150 ****
          dict = dicttable[did]
          value = dict[key]
!         try:
!             # Test for picklability
!             import cPickle
!             cPickle.dumps(value)
!         except:
!             value = None
          return value
  
! def start_debugger(conn, gui_oid):
!     #
!     # launched in the python subprocess
!     #
!     gui = GUIProxy(conn, gui_oid)
!     idb = Debugger.Idb(gui)
!     ada = IdbAdapter(idb)
!     ada_oid = "idb_adapter"
!     conn.register(ada_oid, ada)
!     return ada_oid
  
  # In the IDLE process
--- 131,153 ----
          dict = dicttable[did]
          value = dict[key]
!         value = repr(value)
! #          try:
! #              # Test for picklability
! #              import cPickle
! #              pklstr = cPickle.dumps(value)
! #          except:
! #              print >>sys.__stderr__, "** dict_item pickle failed: ", value
! #              raise    
! #              #value = None
          return value
  
! def start_debugger(conn, gui_adap_oid):
!     "Launch debugger in the remote python subprocess"
!     gui_proxy = GUIProxy(conn, gui_adap_oid)
!     idb = Debugger.Idb(gui_proxy)
!     idb_adap = IdbAdapter(idb)
!     idb_adap_oid = "idb_adapter"
!     conn.register(idb_adap_oid, idb_adap)
!     return idb_adap_oid
  
  # In the IDLE process
***************
*** 224,228 ****
          raise AttributeError, name
  
! class GUIAdaper:
  
      def __init__(self, conn, gui):
--- 227,231 ----
          raise AttributeError, name
  
! class GUIAdapter:
  
      def __init__(self, conn, gui):
***************
*** 231,235 ****
  
      def interaction(self, message, fid, iid):
!         print "interaction(%s, %s, %s)" % (`message`, `fid`, `iid`)
          frame = FrameProxy(self.conn, fid)
          info = None # XXX for now
--- 234,238 ----
  
      def interaction(self, message, fid, iid):
!         ##print "interaction: (%s, %s, %s)" % (`message`,`fid`, `iid`)
          frame = FrameProxy(self.conn, fid)
          info = None # XXX for now
***************
*** 273,287 ****
  
  def start_remote_debugger(conn, pyshell):
!     #
!     # instruct the (remote) subprocess to create
!     # a debugger instance, and lets it know that 
!     # the local GUIAdapter called "gui_adapter"
!     # is waiting notification of debugging events
!     #
!     ada_oid = "gui_adapter"
!     idb_oid = conn.remotecall("exec", "start_debugger", (ada_oid,), {})
!     idb = IdbProxy(conn, idb_oid)
!     gui = Debugger.Debugger(pyshell, idb)
!     ada = GUIAdaper(conn, gui)
!     conn.register(ada_oid, ada)
      return gui
--- 276,297 ----
  
  def start_remote_debugger(conn, pyshell):
!     """Start the subprocess debugger, initialize the debugger GUI and RPC link
! 
!     Start the debugger in the remote Python process.  Instantiate IdbProxy,
!     Debugger GUI, and Debugger GUIAdapter objects, and link them together.
! 
!     The GUIAdapter will handle debugger GUI interaction requests coming from
!     the subprocess debugger via the GUIProxy.
! 
!     The IdbAdapter will pass execution and environment requests coming from the
!     Idle debugger GUI to the subprocess debugger via the IdbProxy.
! 
!     """
!     gui_adap_oid = "gui_adapter"
!     idb_adap_oid = conn.remotecall("exec", "start_the_debugger",\
!                                    (gui_adap_oid,), {})
!     idb_proxy = IdbProxy(conn, idb_adap_oid)
!     gui = Debugger.Debugger(pyshell, idb_proxy)
!     gui_adap = GUIAdapter(conn, gui)
!     conn.register(gui_adap_oid, gui_adap)
      return gui

Index: rpc.py
===================================================================
RCS file: /cvsroot/idlefork/idle/rpc.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** rpc.py	26 May 2002 13:36:40 -0000	1.1
--- rpc.py	16 Jun 2002 03:32:24 -0000	1.2
***************
*** 120,124 ****
  
      def localcall(self, request):
!         ##self.debug("localcall:", request) 
          try:
              how, (oid, methodname, args, kwargs) = request
--- 120,124 ----
  
      def localcall(self, request):
!         self.debug("localcall:", request) 
          try:
              how, (oid, methodname, args, kwargs) = request
***************
*** 166,169 ****
--- 166,170 ----
  
      def remotecall(self, oid, methodname, args, kwargs):
+         self.debug("remotecall:", oid, methodname, args, kwargs) 
          seq = self.asynccall(oid, methodname, args, kwargs)
          return self.asyncreturn(seq)
***************
*** 198,205 ****
                      else:
                          raise getattr(__import__(mod), name)(*args)
!             else:
!                 if mod:
!                     name = mod + "." + name
!                 raise name, args
          if how == "ERROR":
              raise RuntimeError, what
--- 199,208 ----
                      else:
                          raise getattr(__import__(mod), name)(*args)
! # XXX KBK 15Jun02  mod is False here, also want to raise remaining exceptions
! #           else:
! #               if mod:
! #                   name = mod + "." + name
! #               raise name, args
!             raise name, args
          if how == "ERROR":
              raise RuntimeError, what

Index: run.py
===================================================================
RCS file: /cvsroot/idlefork/idle/run.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** run.py	26 May 2002 13:36:40 -0000	1.1
--- run.py	16 Jun 2002 03:32:24 -0000	1.2
***************
*** 31,37 ****
          exec code in self.locals
  
!     def start_debugger(self, gui_oid):
          import RemoteDebugger
!         return RemoteDebugger.start_debugger(self.conn, gui_oid)
  
      def stackviewer(self, flist_oid=None):
--- 31,37 ----
          exec code in self.locals
  
!     def start_the_debugger(self, gui_adap_oid):
          import RemoteDebugger
!         return RemoteDebugger.start_debugger(self.conn, gui_adap_oid)
  
      def stackviewer(self, flist_oid=None):