Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 669f4c3

Browse files
committed
1. Debugger Breakpoints, finish implementation
2. Debugger Clear Breakpoints, implement 3. Nice yellow breakpoints for Chui :)
1 parent 3875e90 commit 669f4c3

4 files changed

Lines changed: 79 additions & 27 deletions

File tree

Lib/idlelib/Debugger.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def __frame2message(self, frame):
5252

5353
class Debugger:
5454

55-
# interacting = 0 # XXX KBK 14Jun02 move to __init__
5655
vstack = vsource = vlocals = vglobals = None
5756

5857
def __init__(self, pyshell, idb=None):
@@ -157,7 +156,6 @@ def make_gui(self):
157156
if self.vglobals.get():
158157
self.show_globals()
159158

160-
# frame = None # XXX KBK 14Jun02 Move to __init__
161159

162160
def interaction(self, message, frame, info=None):
163161
self.frame = frame
@@ -321,16 +319,18 @@ def set_breakpoint_here(self, edit):
321319
return
322320
text.tag_add("BREAK", "insert linestart", "insert lineend +1char")
323321

324-
# A literal copy of Bdb.set_break() without the print statement at the end
325-
#def set_break(self, filename, lineno, temporary=0, cond = None):
326-
# import linecache # Import as late as possible
327-
# filename = self.canonic(filename)
328-
# line = linecache.getline(filename, lineno)
329-
# if not line:
330-
# return 'That line does not exist!'
331-
# if not self.breaks.has_key(filename):
332-
# self.breaks[filename] = []
333-
# list = self.breaks[filename]
334-
# if not lineno in list:
335-
# list.append(lineno)
336-
# bp = bdb.Breakpoint(filename, lineno, temporary, cond)
322+
def clear_breakpoint_here(self, edit):
323+
text = edit.text
324+
filename = edit.io.filename
325+
if not filename:
326+
text.bell()
327+
return
328+
lineno = int(float(text.index("insert")))
329+
msg = self.idb.clear_break(filename, lineno)
330+
if msg:
331+
text.bell()
332+
return
333+
text.tag_remove("BREAK", "insert linestart",\
334+
"insert lineend +1char")
335+
336+

Lib/idlelib/PyShell.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ class PyShellEditorWindow(EditorWindow):
9696
def __init__(self, *args):
9797
apply(EditorWindow.__init__, (self,) + args)
9898
self.text.bind("<<set-breakpoint-here>>", self.set_breakpoint_here)
99+
self.text.bind("<<clear-breakpoint-here>>",
100+
self.clear_breakpoint_here)
99101
self.text.bind("<<open-python-shell>>", self.flist.open_shell)
100102

101103
rmenu_specs = [
102-
("Set breakpoint here", "<<set-breakpoint-here>>"),
104+
("Set Breakpoint", "<<set-breakpoint-here>>"),
105+
("Clear Breakpoint", "<<clear-breakpoint-here>>")
103106
]
104107

105108
def set_breakpoint_here(self, event=None):
@@ -108,6 +111,12 @@ def set_breakpoint_here(self, event=None):
108111
return
109112
self.flist.pyshell.interp.debugger.set_breakpoint_here(self)
110113

114+
def clear_breakpoint_here(self, event=None):
115+
if not self.flist.pyshell or not self.flist.pyshell.interp.debugger:
116+
self.text.bell()
117+
return
118+
self.flist.pyshell.interp.debugger.clear_breakpoint_here(self)
119+
111120

112121
class PyShellFileList(FileList):
113122

Lib/idlelib/RemoteDebugger.py

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
debugging = 0
2828

29-
# In the PYTHON subprocess
29+
#=======================================
30+
#
31+
# In the PYTHON subprocess:
3032

3133
frametable = {}
3234
dicttable = {}
@@ -59,6 +61,8 @@ class IdbAdapter:
5961
def __init__(self, idb):
6062
self.idb = idb
6163

64+
#----------called by an IdbProxy----------
65+
6266
def set_step(self):
6367
self.idb.set_step()
6468

@@ -90,6 +94,15 @@ def run(self, cmd):
9094
import __main__
9195
self.idb.run(cmd, __main__.__dict__)
9296

97+
def set_break(self, filename, lineno):
98+
msg = self.idb.set_break(filename, lineno)
99+
return msg
100+
101+
def clear_break(self, filename, lineno):
102+
msg = self.idb.clear_break(filename, lineno)
103+
104+
#----------called by a FrameProxy----------
105+
93106
def frame_attr(self, fid, name):
94107
frame = frametable[fid]
95108
return getattr(frame, name)
@@ -115,6 +128,8 @@ def frame_code(self, fid):
115128
codetable[cid] = code
116129
return cid
117130

131+
#----------called by a CodeProxy----------
132+
118133
def code_name(self, cid):
119134
code = codetable[cid]
120135
return code.co_name
@@ -123,6 +138,8 @@ def code_filename(self, cid):
123138
code = codetable[cid]
124139
return code.co_filename
125140

141+
#----------called by a DictProxy----------
142+
126143
def dict_keys(self, did):
127144
dict = dicttable[did]
128145
return dict.keys()
@@ -141,16 +158,30 @@ def dict_item(self, did, key):
141158
# #value = None
142159
return value
143160

161+
#----------end class IdbAdapter----------
162+
163+
144164
def start_debugger(conn, gui_adap_oid):
145-
"Launch debugger in the remote python subprocess"
165+
"""Start the debugger and its RPC link in the Python subprocess
166+
167+
Start the subprocess side of the split debugger and set up that side of the
168+
RPC link by instantiating the GUIProxy, Idle debugger, and IdbAdapter
169+
objects and linking them together. Register the IdbAdapter to handle RPC
170+
requests from the split Debugger GUI via the IdbProxy.
171+
172+
"""
146173
gui_proxy = GUIProxy(conn, gui_adap_oid)
147174
idb = Debugger.Idb(gui_proxy)
148175
idb_adap = IdbAdapter(idb)
149176
idb_adap_oid = "idb_adapter"
150177
conn.register(idb_adap_oid, idb_adap)
151178
return idb_adap_oid
152179

153-
# In the IDLE process
180+
181+
#=======================================
182+
#
183+
# In the IDLE process:
184+
154185

155186
class FrameProxy:
156187

@@ -193,6 +224,7 @@ def _get_dict_proxy(self, did):
193224
self._dictcache[did] = dp
194225
return dp
195226

227+
196228
class CodeProxy:
197229

198230
def __init__(self, conn, oid, cid):
@@ -208,6 +240,7 @@ def __getattr__(self, name):
208240
return self._conn.remotecall(self._oid, "code_filename",
209241
(self._cid,), {})
210242

243+
211244
class DictProxy:
212245

213246
def __init__(self, conn, oid, did):
@@ -226,6 +259,7 @@ def __getattr__(self, name):
226259
##print >>sys.__stderr__, "failed DictProxy.__getattr__:", name
227260
raise AttributeError, name
228261

262+
229263
class GUIAdapter:
230264

231265
def __init__(self, conn, gui):
@@ -238,6 +272,7 @@ def interaction(self, message, fid, iid):
238272
info = None # XXX for now
239273
self.gui.interaction(message, frame, info)
240274

275+
241276
class IdbProxy:
242277

243278
def __init__(self, conn, oid):
@@ -274,14 +309,22 @@ def set_return(self, frame):
274309
def set_quit(self):
275310
self.call("set_quit")
276311

312+
def set_break(self, filename, lineno):
313+
msg = self.call("set_break", filename, lineno)
314+
return msg
315+
316+
def clear_break(self, filename, lineno):
317+
msg = self.call("clear_break", filename, lineno)
318+
277319
def start_remote_debugger(conn, pyshell):
278320
"""Start the subprocess debugger, initialize the debugger GUI and RPC link
279321
280-
Start the debugger in the remote Python process. Instantiate IdbProxy,
281-
Debugger GUI, and Debugger GUIAdapter objects, and link them together.
322+
Request the RPCServer start the Python subprocess debugger and link. Set
323+
up the Idle side of the split debugger by instantiating the IdbProxy,
324+
Debugger GUI, and Debugger GUIAdapter objects and linking them together.
282325
283-
The GUIAdapter will handle debugger GUI interaction requests coming from
284-
the subprocess debugger via the GUIProxy.
326+
Register the GUIAdapter to handle debugger GUI interaction requests coming
327+
from the subprocess debugger via the GUIProxy.
285328
286329
The IdbAdapter will pass execution and environment requests coming from the
287330
Idle debugger GUI to the subprocess debugger via the IdbProxy.

Lib/idlelib/config-highlight.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ definition-foreground= #0000ff
1414
definition-background= #ffffff
1515
hilite-foreground= #000000
1616
hilite-background= gray
17-
break-foreground= #ff7777
18-
break-background= #ffffff
17+
break-foreground= black
18+
break-background= #ffff55
1919
hit-foreground= #ffffff
2020
hit-background= #000000
2121
error-foreground= #000000
@@ -43,8 +43,8 @@ definition-foreground= #0000ff
4343
definition-background= #ffffff
4444
hilite-foreground= #000000
4545
hilite-background= gray
46-
break-foreground= #ff7777
47-
break-background= #ffffff
46+
break-foreground= black
47+
break-background= #ffff55
4848
hit-foreground= #ffffff
4949
hit-background= #000000
5050
error-foreground= #000000

0 commit comments

Comments
 (0)