2424import rpc
2525import Debugger
2626
27+ debugging = 0
28+
2729# In the PYTHON subprocess
2830
2931frametable = {}
@@ -43,9 +45,9 @@ def wrap_info(info):
4345
4446class GUIProxy :
4547
46- def __init__ (self , conn , oid ):
48+ def __init__ (self , conn , gui_adap_oid ):
4749 self .conn = conn
48- self .oid = oid
50+ self .oid = gui_adap_oid
4951
5052 def interaction (self , message , frame , info = None ):
5153 self .conn .remotecall (self .oid , "interaction" ,
@@ -128,24 +130,25 @@ def dict_keys(self, did):
128130 def dict_item (self , did , key ):
129131 dict = dicttable [did ]
130132 value = dict [key ]
131- try :
132- # Test for picklability
133- import cPickle
134- cPickle .dumps (value )
135- except :
136- value = None
133+ value = repr (value )
134+ # try:
135+ # # Test for picklability
136+ # import cPickle
137+ # pklstr = cPickle.dumps(value)
138+ # except:
139+ # print >>sys.__stderr__, "** dict_item pickle failed: ", value
140+ # raise
141+ # #value = None
137142 return value
138143
139- def start_debugger (conn , gui_oid ):
140- #
141- # launched in the python subprocess
142- #
143- gui = GUIProxy (conn , gui_oid )
144- idb = Debugger .Idb (gui )
145- ada = IdbAdapter (idb )
146- ada_oid = "idb_adapter"
147- conn .register (ada_oid , ada )
148- return ada_oid
144+ def start_debugger (conn , gui_adap_oid ):
145+ "Launch debugger in the remote python subprocess"
146+ gui_proxy = GUIProxy (conn , gui_adap_oid )
147+ idb = Debugger .Idb (gui_proxy )
148+ idb_adap = IdbAdapter (idb )
149+ idb_adap_oid = "idb_adapter"
150+ conn .register (idb_adap_oid , idb_adap )
151+ return idb_adap_oid
149152
150153# In the IDLE process
151154
@@ -223,14 +226,14 @@ def __getattr__(self, name):
223226 ##print >>sys.__stderr__, "failed DictProxy.__getattr__:", name
224227 raise AttributeError , name
225228
226- class GUIAdaper :
229+ class GUIAdapter :
227230
228231 def __init__ (self , conn , gui ):
229232 self .conn = conn
230233 self .gui = gui
231234
232235 def interaction (self , message , fid , iid ):
233- print "interaction(%s, %s, %s)" % (`message` , `fid` , `iid` )
236+ ## print "interaction: (%s, %s, %s)" % (`message`,`fid`, `iid`)
234237 frame = FrameProxy (self .conn , fid )
235238 info = None # XXX for now
236239 self .gui .interaction (message , frame , info )
@@ -272,16 +275,23 @@ def set_quit(self):
272275 self .call ("set_quit" )
273276
274277def start_remote_debugger (conn , pyshell ):
275- #
276- # instruct the (remote) subprocess to create
277- # a debugger instance, and lets it know that
278- # the local GUIAdapter called "gui_adapter"
279- # is waiting notification of debugging events
280- #
281- ada_oid = "gui_adapter"
282- idb_oid = conn .remotecall ("exec" , "start_debugger" , (ada_oid ,), {})
283- idb = IdbProxy (conn , idb_oid )
284- gui = Debugger .Debugger (pyshell , idb )
285- ada = GUIAdaper (conn , gui )
286- conn .register (ada_oid , ada )
278+ """Start the subprocess debugger, initialize the debugger GUI and RPC link
279+
280+ Start the debugger in the remote Python process. Instantiate IdbProxy,
281+ Debugger GUI, and Debugger GUIAdapter objects, and link them together.
282+
283+ The GUIAdapter will handle debugger GUI interaction requests coming from
284+ the subprocess debugger via the GUIProxy.
285+
286+ The IdbAdapter will pass execution and environment requests coming from the
287+ Idle debugger GUI to the subprocess debugger via the IdbProxy.
288+
289+ """
290+ gui_adap_oid = "gui_adapter"
291+ idb_adap_oid = conn .remotecall ("exec" , "start_the_debugger" ,\
292+ (gui_adap_oid ,), {})
293+ idb_proxy = IdbProxy (conn , idb_adap_oid )
294+ gui = Debugger .Debugger (pyshell , idb_proxy )
295+ gui_adap = GUIAdapter (conn , gui )
296+ conn .register (gui_adap_oid , gui_adap )
287297 return gui
0 commit comments