mirror of
https://github.com/python/cpython.git
synced 2025-12-10 11:00:14 +00:00
Add the "until" command to pdb
This commit is contained in:
parent
aac5c8669f
commit
98353941ea
7 changed files with 49 additions and 16 deletions
|
|
@ -207,6 +207,11 @@ The :mod:`bdb` module also defines two classes:
|
||||||
|
|
||||||
Stop when returning from the given frame.
|
Stop when returning from the given frame.
|
||||||
|
|
||||||
|
.. method:: set_until(frame)
|
||||||
|
|
||||||
|
Stop when the line with the line no greater than the current one is
|
||||||
|
reached or when returning from current frame
|
||||||
|
|
||||||
.. method:: set_trace([frame])
|
.. method:: set_trace([frame])
|
||||||
|
|
||||||
Start debugging from *frame*. If *frame* is not specified, debugging
|
Start debugging from *frame*. If *frame* is not specified, debugging
|
||||||
|
|
|
||||||
|
|
@ -267,6 +267,12 @@ n(ext)
|
||||||
inside a called function, while ``next`` executes called functions at (nearly)
|
inside a called function, while ``next`` executes called functions at (nearly)
|
||||||
full speed, only stopping at the next line in the current function.)
|
full speed, only stopping at the next line in the current function.)
|
||||||
|
|
||||||
|
unt(il)
|
||||||
|
Continue execution until the line with the the line number greater than the
|
||||||
|
current one is reached or when returning from current frame
|
||||||
|
|
||||||
|
.. versionadded:: 2.6
|
||||||
|
|
||||||
r(eturn)
|
r(eturn)
|
||||||
Continue execution until the current function returns.
|
Continue execution until the current function returns.
|
||||||
|
|
||||||
|
|
|
||||||
33
Lib/bdb.py
33
Lib/bdb.py
|
|
@ -37,9 +37,7 @@ class Bdb:
|
||||||
import linecache
|
import linecache
|
||||||
linecache.checkcache()
|
linecache.checkcache()
|
||||||
self.botframe = None
|
self.botframe = None
|
||||||
self.stopframe = None
|
self._set_stopinfo(None, None)
|
||||||
self.returnframe = None
|
|
||||||
self.quitting = 0
|
|
||||||
|
|
||||||
def trace_dispatch(self, frame, event, arg):
|
def trace_dispatch(self, frame, event, arg):
|
||||||
if self.quitting:
|
if self.quitting:
|
||||||
|
|
@ -100,7 +98,7 @@ class Bdb:
|
||||||
# (CT) stopframe may now also be None, see dispatch_call.
|
# (CT) stopframe may now also be None, see dispatch_call.
|
||||||
# (CT) the former test for None is therefore removed from here.
|
# (CT) the former test for None is therefore removed from here.
|
||||||
if frame is self.stopframe:
|
if frame is self.stopframe:
|
||||||
return True
|
return frame.f_lineno >= self.stoplineno
|
||||||
while frame is not None and frame is not self.stopframe:
|
while frame is not None and frame is not self.stopframe:
|
||||||
if frame is self.botframe:
|
if frame is self.botframe:
|
||||||
return True
|
return True
|
||||||
|
|
@ -157,26 +155,31 @@ class Bdb:
|
||||||
but only if we are to stop at or just below this level."""
|
but only if we are to stop at or just below this level."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _set_stopinfo(self, stopframe, returnframe, stoplineno=-1):
|
||||||
|
self.stopframe = stopframe
|
||||||
|
self.returnframe = returnframe
|
||||||
|
self.quitting = 0
|
||||||
|
self.stoplineno = stoplineno
|
||||||
|
|
||||||
# Derived classes and clients can call the following methods
|
# Derived classes and clients can call the following methods
|
||||||
# to affect the stepping state.
|
# to affect the stepping state.
|
||||||
|
|
||||||
|
def set_until(self, frame): #the name "until" is borrowed from gdb
|
||||||
|
"""Stop when the line with the line no greater than the current one is
|
||||||
|
reached or when returning from current frame"""
|
||||||
|
self._set_stopinfo(frame, frame, frame.f_lineno+1)
|
||||||
|
|
||||||
def set_step(self):
|
def set_step(self):
|
||||||
"""Stop after one line of code."""
|
"""Stop after one line of code."""
|
||||||
self.stopframe = None
|
self._set_stopinfo(None,None)
|
||||||
self.returnframe = None
|
|
||||||
self.quitting = 0
|
|
||||||
|
|
||||||
def set_next(self, frame):
|
def set_next(self, frame):
|
||||||
"""Stop on the next line in or below the given frame."""
|
"""Stop on the next line in or below the given frame."""
|
||||||
self.stopframe = frame
|
self._set_stopinfo(frame, None)
|
||||||
self.returnframe = None
|
|
||||||
self.quitting = 0
|
|
||||||
|
|
||||||
def set_return(self, frame):
|
def set_return(self, frame):
|
||||||
"""Stop when returning from the given frame."""
|
"""Stop when returning from the given frame."""
|
||||||
self.stopframe = frame.f_back
|
self._set_stopinfo(frame.f_back, frame)
|
||||||
self.returnframe = frame
|
|
||||||
self.quitting = 0
|
|
||||||
|
|
||||||
def set_trace(self, frame=None):
|
def set_trace(self, frame=None):
|
||||||
"""Start debugging from `frame`.
|
"""Start debugging from `frame`.
|
||||||
|
|
@ -195,9 +198,7 @@ class Bdb:
|
||||||
|
|
||||||
def set_continue(self):
|
def set_continue(self):
|
||||||
# Don't stop except at breakpoints or when finished
|
# Don't stop except at breakpoints or when finished
|
||||||
self.stopframe = self.botframe
|
self._set_stopinfo(self.botframe, None)
|
||||||
self.returnframe = None
|
|
||||||
self.quitting = 0
|
|
||||||
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)
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,11 @@ n(ext)
|
||||||
Continue execution until the next line in the current function
|
Continue execution until the next line in the current function
|
||||||
is reached or it returns.
|
is reached or it returns.
|
||||||
|
|
||||||
|
unt(il)
|
||||||
|
Continue execution until the line with a number greater than the
|
||||||
|
current one is reached or until the current frame returns
|
||||||
|
|
||||||
|
|
||||||
r(eturn)
|
r(eturn)
|
||||||
Continue execution until the current function returns.
|
Continue execution until the current function returns.
|
||||||
|
|
||||||
|
|
|
||||||
13
Lib/pdb.py
13
Lib/pdb.py
|
|
@ -612,6 +612,11 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
self.lineno = None
|
self.lineno = None
|
||||||
do_d = do_down
|
do_d = do_down
|
||||||
|
|
||||||
|
def do_until(self, arg):
|
||||||
|
self.set_until(self.curframe)
|
||||||
|
return 1
|
||||||
|
do_unt = do_until
|
||||||
|
|
||||||
def do_step(self, arg):
|
def do_step(self, arg):
|
||||||
self.set_step()
|
self.set_step()
|
||||||
return 1
|
return 1
|
||||||
|
|
@ -962,6 +967,14 @@ i.e., the breakpoint is made unconditional."""
|
||||||
Execute the current line, stop at the first possible occasion
|
Execute the current line, stop at the first possible occasion
|
||||||
(either in a function that is called or in the current function)."""
|
(either in a function that is called or in the current function)."""
|
||||||
|
|
||||||
|
def help_until(self):
|
||||||
|
self.help_unt()
|
||||||
|
|
||||||
|
def help_unt(self):
|
||||||
|
print """unt(il)
|
||||||
|
Continue execution until the line with a number greater than the current
|
||||||
|
one is reached or until the current frame returns"""
|
||||||
|
|
||||||
def help_next(self):
|
def help_next(self):
|
||||||
self.help_n()
|
self.help_n()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -589,6 +589,7 @@ Nick Russo
|
||||||
Hajime Saitou
|
Hajime Saitou
|
||||||
Rich Salz
|
Rich Salz
|
||||||
Kevin Samborn
|
Kevin Samborn
|
||||||
|
Ilya Sandler
|
||||||
Ty Sarna
|
Ty Sarna
|
||||||
Ben Sayer
|
Ben Sayer
|
||||||
Michael Scharf
|
Michael Scharf
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,8 @@ Library
|
||||||
|
|
||||||
- os.path.walk is deprecated in favor of os.walk.
|
- os.path.walk is deprecated in favor of os.walk.
|
||||||
|
|
||||||
|
- pdb gained the "until" command
|
||||||
|
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue