Kaydet (Commit) dcbf1b94 authored tarafından Neal Norwitz's avatar Neal Norwitz

Backport fix by tismer for #210682

fixed an old buglet that caused bdb to be unable to
continue in the botframe, after a breakpoint was set.
the key idea is not to set botframe to the bottom level frame,
but its f_back, which actually might be None.
Additional changes: migrated old exception trick to use
sys._getframe(), which exists both in 2.1 and 2.2 .

Note: I believe Mark Hammond needs to look over his code now.
F5 correctly starts up in the debugger, but later on doesn't stop at a given
breakpoint any longer.

kind regards - chris
üst 6d36fd84
...@@ -64,7 +64,7 @@ class Bdb: ...@@ -64,7 +64,7 @@ class Bdb:
# XXX 'arg' is no longer used # XXX 'arg' is no longer used
if self.botframe is None: if self.botframe is None:
# First call of dispatch since reset() # First call of dispatch since reset()
self.botframe = frame self.botframe = frame.f_back # (CT) Note that this may also be None!
return self.trace_dispatch return self.trace_dispatch
if not (self.stop_here(frame) or self.break_anywhere(frame)): if not (self.stop_here(frame) or self.break_anywhere(frame)):
# No need to trace this function # No need to trace this function
...@@ -90,8 +90,8 @@ class Bdb: ...@@ -90,8 +90,8 @@ class Bdb:
# definition of stopping and breakpoints. # definition of stopping and breakpoints.
def stop_here(self, frame): def stop_here(self, frame):
if self.stopframe is None: # (CT) stopframe may now also be None, see dispatch_call.
return 1 # (CT) the former test for None is therefore removed from here.
if frame is self.stopframe: if frame is self.stopframe:
return 1 return 1
while frame is not None and frame is not self.stopframe: while frame is not None and frame is not self.stopframe:
...@@ -168,10 +168,7 @@ class Bdb: ...@@ -168,10 +168,7 @@ class Bdb:
def set_trace(self): def set_trace(self):
"""Start debugging from here.""" """Start debugging from here."""
try: frame = sys._getframe().f_back
1 + ''
except:
frame = sys.exc_info()[2].tb_frame.f_back
self.reset() self.reset()
while frame: while frame:
frame.f_trace = self.trace_dispatch frame.f_trace = self.trace_dispatch
...@@ -188,10 +185,7 @@ class Bdb: ...@@ -188,10 +185,7 @@ class Bdb:
if not self.breaks: if not self.breaks:
# no breakpoints; run without debugger overhead # no breakpoints; run without debugger overhead
sys.settrace(None) sys.settrace(None)
try: frame = sys._getframe().f_back
1 + '' # raise an exception
except:
frame = sys.exc_info()[2].tb_frame.f_back
while frame and frame is not self.botframe: while frame and frame is not self.botframe:
del frame.f_trace del frame.f_trace
frame = frame.f_back frame = frame.f_back
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment