class Debugger:
- # interacting = 0 # XXX KBK 14Jun02 move to __init__
vstack = vsource = vlocals = vglobals = None
def __init__(self, pyshell, idb=None):
if self.vglobals.get():
self.show_globals()
- # frame = None # XXX KBK 14Jun02 Move to __init__
def interaction(self, message, frame, info=None):
self.frame = frame
return
text.tag_add("BREAK", "insert linestart", "insert lineend +1char")
- # A literal copy of Bdb.set_break() without the print statement at the end
- #def set_break(self, filename, lineno, temporary=0, cond = None):
- # import linecache # Import as late as possible
- # filename = self.canonic(filename)
- # line = linecache.getline(filename, lineno)
- # if not line:
- # return 'That line does not exist!'
- # if not self.breaks.has_key(filename):
- # self.breaks[filename] = []
- # list = self.breaks[filename]
- # if not lineno in list:
- # list.append(lineno)
- # bp = bdb.Breakpoint(filename, lineno, temporary, cond)
+ def clear_breakpoint_here(self, edit):
+ text = edit.text
+ filename = edit.io.filename
+ if not filename:
+ text.bell()
+ return
+ lineno = int(float(text.index("insert")))
+ msg = self.idb.clear_break(filename, lineno)
+ if msg:
+ text.bell()
+ return
+ text.tag_remove("BREAK", "insert linestart",\
+ "insert lineend +1char")
+
+
def __init__(self, *args):
apply(EditorWindow.__init__, (self,) + args)
self.text.bind("<<set-breakpoint-here>>", self.set_breakpoint_here)
+ self.text.bind("<<clear-breakpoint-here>>",
+ self.clear_breakpoint_here)
self.text.bind("<<open-python-shell>>", self.flist.open_shell)
rmenu_specs = [
- ("Set breakpoint here", "<<set-breakpoint-here>>"),
+ ("Set Breakpoint", "<<set-breakpoint-here>>"),
+ ("Clear Breakpoint", "<<clear-breakpoint-here>>")
]
def set_breakpoint_here(self, event=None):
return
self.flist.pyshell.interp.debugger.set_breakpoint_here(self)
+ def clear_breakpoint_here(self, event=None):
+ if not self.flist.pyshell or not self.flist.pyshell.interp.debugger:
+ self.text.bell()
+ return
+ self.flist.pyshell.interp.debugger.clear_breakpoint_here(self)
+
class PyShellFileList(FileList):
debugging = 0
-# In the PYTHON subprocess
+#=======================================
+#
+# In the PYTHON subprocess:
frametable = {}
dicttable = {}
def __init__(self, idb):
self.idb = idb
+ #----------called by an IdbProxy----------
+
def set_step(self):
self.idb.set_step()
import __main__
self.idb.run(cmd, __main__.__dict__)
+ def set_break(self, filename, lineno):
+ msg = self.idb.set_break(filename, lineno)
+ return msg
+
+ def clear_break(self, filename, lineno):
+ msg = self.idb.clear_break(filename, lineno)
+
+ #----------called by a FrameProxy----------
+
def frame_attr(self, fid, name):
frame = frametable[fid]
return getattr(frame, name)
codetable[cid] = code
return cid
+ #----------called by a CodeProxy----------
+
def code_name(self, cid):
code = codetable[cid]
return code.co_name
code = codetable[cid]
return code.co_filename
+ #----------called by a DictProxy----------
+
def dict_keys(self, did):
dict = dicttable[did]
return dict.keys()
# #value = None
return value
+#----------end class IdbAdapter----------
+
+
def start_debugger(conn, gui_adap_oid):
- "Launch debugger in the remote python subprocess"
+ """Start the debugger and its RPC link in the Python subprocess
+
+ Start the subprocess side of the split debugger and set up that side of the
+ RPC link by instantiating the GUIProxy, Idle debugger, and IdbAdapter
+ objects and linking them together. Register the IdbAdapter to handle RPC
+ requests from the split Debugger GUI via the IdbProxy.
+
+ """
gui_proxy = GUIProxy(conn, gui_adap_oid)
idb = Debugger.Idb(gui_proxy)
idb_adap = IdbAdapter(idb)
conn.register(idb_adap_oid, idb_adap)
return idb_adap_oid
-# In the IDLE process
+
+#=======================================
+#
+# In the IDLE process:
+
class FrameProxy:
self._dictcache[did] = dp
return dp
+
class CodeProxy:
def __init__(self, conn, oid, cid):
return self._conn.remotecall(self._oid, "code_filename",
(self._cid,), {})
+
class DictProxy:
def __init__(self, conn, oid, did):
##print >>sys.__stderr__, "failed DictProxy.__getattr__:", name
raise AttributeError, name
+
class GUIAdapter:
def __init__(self, conn, gui):
info = None # XXX for now
self.gui.interaction(message, frame, info)
+
class IdbProxy:
def __init__(self, conn, oid):
def set_quit(self):
self.call("set_quit")
+ def set_break(self, filename, lineno):
+ msg = self.call("set_break", filename, lineno)
+ return msg
+
+ def clear_break(self, filename, lineno):
+ msg = self.call("clear_break", filename, lineno)
+
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.
+ Request the RPCServer start the Python subprocess debugger and link. Set
+ up the Idle side of the split debugger by instantiating the IdbProxy,
+ Debugger GUI, and Debugger GUIAdapter objects and linking them together.
- The GUIAdapter will handle debugger GUI interaction requests coming from
- the subprocess debugger via the GUIProxy.
+ Register the GUIAdapter to 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.