1. Debugger Breakpoints, finish implementation
2. Debugger Clear Breakpoints, implement 3. Nice yellow breakpoints for Chui :)
This commit is contained in:
parent
3875e90274
commit
669f4c3850
|
@ -52,7 +52,6 @@ class Idb(bdb.Bdb):
|
||||||
|
|
||||||
class Debugger:
|
class Debugger:
|
||||||
|
|
||||||
# interacting = 0 # XXX KBK 14Jun02 move to __init__
|
|
||||||
vstack = vsource = vlocals = vglobals = None
|
vstack = vsource = vlocals = vglobals = None
|
||||||
|
|
||||||
def __init__(self, pyshell, idb=None):
|
def __init__(self, pyshell, idb=None):
|
||||||
|
@ -157,7 +156,6 @@ class Debugger:
|
||||||
if self.vglobals.get():
|
if self.vglobals.get():
|
||||||
self.show_globals()
|
self.show_globals()
|
||||||
|
|
||||||
# frame = None # XXX KBK 14Jun02 Move to __init__
|
|
||||||
|
|
||||||
def interaction(self, message, frame, info=None):
|
def interaction(self, message, frame, info=None):
|
||||||
self.frame = frame
|
self.frame = frame
|
||||||
|
@ -321,16 +319,18 @@ class Debugger:
|
||||||
return
|
return
|
||||||
text.tag_add("BREAK", "insert linestart", "insert lineend +1char")
|
text.tag_add("BREAK", "insert linestart", "insert lineend +1char")
|
||||||
|
|
||||||
# A literal copy of Bdb.set_break() without the print statement at the end
|
def clear_breakpoint_here(self, edit):
|
||||||
#def set_break(self, filename, lineno, temporary=0, cond = None):
|
text = edit.text
|
||||||
# import linecache # Import as late as possible
|
filename = edit.io.filename
|
||||||
# filename = self.canonic(filename)
|
if not filename:
|
||||||
# line = linecache.getline(filename, lineno)
|
text.bell()
|
||||||
# if not line:
|
return
|
||||||
# return 'That line does not exist!'
|
lineno = int(float(text.index("insert")))
|
||||||
# if not self.breaks.has_key(filename):
|
msg = self.idb.clear_break(filename, lineno)
|
||||||
# self.breaks[filename] = []
|
if msg:
|
||||||
# list = self.breaks[filename]
|
text.bell()
|
||||||
# if not lineno in list:
|
return
|
||||||
# list.append(lineno)
|
text.tag_remove("BREAK", "insert linestart",\
|
||||||
# bp = bdb.Breakpoint(filename, lineno, temporary, cond)
|
"insert lineend +1char")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -96,10 +96,13 @@ class PyShellEditorWindow(EditorWindow):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
apply(EditorWindow.__init__, (self,) + args)
|
apply(EditorWindow.__init__, (self,) + args)
|
||||||
self.text.bind("<<set-breakpoint-here>>", self.set_breakpoint_here)
|
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)
|
self.text.bind("<<open-python-shell>>", self.flist.open_shell)
|
||||||
|
|
||||||
rmenu_specs = [
|
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):
|
def set_breakpoint_here(self, event=None):
|
||||||
|
@ -108,6 +111,12 @@ class PyShellEditorWindow(EditorWindow):
|
||||||
return
|
return
|
||||||
self.flist.pyshell.interp.debugger.set_breakpoint_here(self)
|
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):
|
class PyShellFileList(FileList):
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,9 @@ import Debugger
|
||||||
|
|
||||||
debugging = 0
|
debugging = 0
|
||||||
|
|
||||||
# In the PYTHON subprocess
|
#=======================================
|
||||||
|
#
|
||||||
|
# In the PYTHON subprocess:
|
||||||
|
|
||||||
frametable = {}
|
frametable = {}
|
||||||
dicttable = {}
|
dicttable = {}
|
||||||
|
@ -59,6 +61,8 @@ class IdbAdapter:
|
||||||
def __init__(self, idb):
|
def __init__(self, idb):
|
||||||
self.idb = idb
|
self.idb = idb
|
||||||
|
|
||||||
|
#----------called by an IdbProxy----------
|
||||||
|
|
||||||
def set_step(self):
|
def set_step(self):
|
||||||
self.idb.set_step()
|
self.idb.set_step()
|
||||||
|
|
||||||
|
@ -90,6 +94,15 @@ class IdbAdapter:
|
||||||
import __main__
|
import __main__
|
||||||
self.idb.run(cmd, __main__.__dict__)
|
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):
|
def frame_attr(self, fid, name):
|
||||||
frame = frametable[fid]
|
frame = frametable[fid]
|
||||||
return getattr(frame, name)
|
return getattr(frame, name)
|
||||||
|
@ -115,6 +128,8 @@ class IdbAdapter:
|
||||||
codetable[cid] = code
|
codetable[cid] = code
|
||||||
return cid
|
return cid
|
||||||
|
|
||||||
|
#----------called by a CodeProxy----------
|
||||||
|
|
||||||
def code_name(self, cid):
|
def code_name(self, cid):
|
||||||
code = codetable[cid]
|
code = codetable[cid]
|
||||||
return code.co_name
|
return code.co_name
|
||||||
|
@ -123,6 +138,8 @@ class IdbAdapter:
|
||||||
code = codetable[cid]
|
code = codetable[cid]
|
||||||
return code.co_filename
|
return code.co_filename
|
||||||
|
|
||||||
|
#----------called by a DictProxy----------
|
||||||
|
|
||||||
def dict_keys(self, did):
|
def dict_keys(self, did):
|
||||||
dict = dicttable[did]
|
dict = dicttable[did]
|
||||||
return dict.keys()
|
return dict.keys()
|
||||||
|
@ -141,8 +158,18 @@ class IdbAdapter:
|
||||||
# #value = None
|
# #value = None
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
#----------end class IdbAdapter----------
|
||||||
|
|
||||||
|
|
||||||
def start_debugger(conn, gui_adap_oid):
|
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)
|
gui_proxy = GUIProxy(conn, gui_adap_oid)
|
||||||
idb = Debugger.Idb(gui_proxy)
|
idb = Debugger.Idb(gui_proxy)
|
||||||
idb_adap = IdbAdapter(idb)
|
idb_adap = IdbAdapter(idb)
|
||||||
|
@ -150,7 +177,11 @@ def start_debugger(conn, gui_adap_oid):
|
||||||
conn.register(idb_adap_oid, idb_adap)
|
conn.register(idb_adap_oid, idb_adap)
|
||||||
return idb_adap_oid
|
return idb_adap_oid
|
||||||
|
|
||||||
# In the IDLE process
|
|
||||||
|
#=======================================
|
||||||
|
#
|
||||||
|
# In the IDLE process:
|
||||||
|
|
||||||
|
|
||||||
class FrameProxy:
|
class FrameProxy:
|
||||||
|
|
||||||
|
@ -193,6 +224,7 @@ class FrameProxy:
|
||||||
self._dictcache[did] = dp
|
self._dictcache[did] = dp
|
||||||
return dp
|
return dp
|
||||||
|
|
||||||
|
|
||||||
class CodeProxy:
|
class CodeProxy:
|
||||||
|
|
||||||
def __init__(self, conn, oid, cid):
|
def __init__(self, conn, oid, cid):
|
||||||
|
@ -208,6 +240,7 @@ class CodeProxy:
|
||||||
return self._conn.remotecall(self._oid, "code_filename",
|
return self._conn.remotecall(self._oid, "code_filename",
|
||||||
(self._cid,), {})
|
(self._cid,), {})
|
||||||
|
|
||||||
|
|
||||||
class DictProxy:
|
class DictProxy:
|
||||||
|
|
||||||
def __init__(self, conn, oid, did):
|
def __init__(self, conn, oid, did):
|
||||||
|
@ -226,6 +259,7 @@ class DictProxy:
|
||||||
##print >>sys.__stderr__, "failed DictProxy.__getattr__:", name
|
##print >>sys.__stderr__, "failed DictProxy.__getattr__:", name
|
||||||
raise AttributeError, name
|
raise AttributeError, name
|
||||||
|
|
||||||
|
|
||||||
class GUIAdapter:
|
class GUIAdapter:
|
||||||
|
|
||||||
def __init__(self, conn, gui):
|
def __init__(self, conn, gui):
|
||||||
|
@ -238,6 +272,7 @@ class GUIAdapter:
|
||||||
info = None # XXX for now
|
info = None # XXX for now
|
||||||
self.gui.interaction(message, frame, info)
|
self.gui.interaction(message, frame, info)
|
||||||
|
|
||||||
|
|
||||||
class IdbProxy:
|
class IdbProxy:
|
||||||
|
|
||||||
def __init__(self, conn, oid):
|
def __init__(self, conn, oid):
|
||||||
|
@ -274,14 +309,22 @@ class IdbProxy:
|
||||||
def set_quit(self):
|
def set_quit(self):
|
||||||
self.call("set_quit")
|
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):
|
def start_remote_debugger(conn, pyshell):
|
||||||
"""Start the subprocess debugger, initialize the debugger GUI and RPC link
|
"""Start the subprocess debugger, initialize the debugger GUI and RPC link
|
||||||
|
|
||||||
Start the debugger in the remote Python process. Instantiate IdbProxy,
|
Request the RPCServer start the Python subprocess debugger and link. Set
|
||||||
Debugger GUI, and Debugger GUIAdapter objects, and link them together.
|
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
|
Register the GUIAdapter to handle debugger GUI interaction requests coming
|
||||||
the subprocess debugger via the GUIProxy.
|
from the subprocess debugger via the GUIProxy.
|
||||||
|
|
||||||
The IdbAdapter will pass execution and environment requests coming from the
|
The IdbAdapter will pass execution and environment requests coming from the
|
||||||
Idle debugger GUI to the subprocess debugger via the IdbProxy.
|
Idle debugger GUI to the subprocess debugger via the IdbProxy.
|
||||||
|
|
|
@ -14,8 +14,8 @@ definition-foreground= #0000ff
|
||||||
definition-background= #ffffff
|
definition-background= #ffffff
|
||||||
hilite-foreground= #000000
|
hilite-foreground= #000000
|
||||||
hilite-background= gray
|
hilite-background= gray
|
||||||
break-foreground= #ff7777
|
break-foreground= black
|
||||||
break-background= #ffffff
|
break-background= #ffff55
|
||||||
hit-foreground= #ffffff
|
hit-foreground= #ffffff
|
||||||
hit-background= #000000
|
hit-background= #000000
|
||||||
error-foreground= #000000
|
error-foreground= #000000
|
||||||
|
@ -43,8 +43,8 @@ definition-foreground= #0000ff
|
||||||
definition-background= #ffffff
|
definition-background= #ffffff
|
||||||
hilite-foreground= #000000
|
hilite-foreground= #000000
|
||||||
hilite-background= gray
|
hilite-background= gray
|
||||||
break-foreground= #ff7777
|
break-foreground= black
|
||||||
break-background= #ffffff
|
break-background= #ffff55
|
||||||
hit-foreground= #ffffff
|
hit-foreground= #ffffff
|
||||||
hit-background= #000000
|
hit-background= #000000
|
||||||
error-foreground= #000000
|
error-foreground= #000000
|
||||||
|
|
Loading…
Reference in New Issue