mirror of
https://github.com/python/cpython.git
synced 2025-12-09 02:35:14 +00:00
Change clear syntax to support three alternatives:
clear
clear file:line
clear bpno bpno ...
Also print the breakpoint data after calling set_break(), because the
print statement in set_break() has gone.
This commit is contained in:
parent
6ea27cc2c6
commit
816a9fbd2c
1 changed files with 47 additions and 3 deletions
50
Lib/pdb.py
50
Lib/pdb.py
|
|
@ -234,6 +234,11 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
# now set the break point
|
# now set the break point
|
||||||
err = self.set_break(filename, line, temporary, cond)
|
err = self.set_break(filename, line, temporary, cond)
|
||||||
if err: print '***', err
|
if err: print '***', err
|
||||||
|
else:
|
||||||
|
bp = self.get_breaks(filename, line)[-1]
|
||||||
|
print "Breakpoint %d at %s:%d" % (bp.number,
|
||||||
|
bp.file,
|
||||||
|
bp.line)
|
||||||
|
|
||||||
# To be overridden in derived debuggers
|
# To be overridden in derived debuggers
|
||||||
def defaultFile(self):
|
def defaultFile(self):
|
||||||
|
|
@ -383,6 +388,10 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
print bpnum, 'is reached.'
|
print bpnum, 'is reached.'
|
||||||
|
|
||||||
def do_clear(self, arg):
|
def do_clear(self, arg):
|
||||||
|
# Three possibilities, tried in this order:
|
||||||
|
# clear -> clear all breaks, ask for confirmation
|
||||||
|
# clear file:lineno -> clear all breaks at file:lineno
|
||||||
|
# clear bpno bpno ... -> clear breakpoints by number
|
||||||
if not arg:
|
if not arg:
|
||||||
try:
|
try:
|
||||||
reply = raw_input('Clear all breaks? ')
|
reply = raw_input('Clear all breaks? ')
|
||||||
|
|
@ -392,15 +401,48 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
if reply in ('y', 'yes'):
|
if reply in ('y', 'yes'):
|
||||||
self.clear_all_breaks()
|
self.clear_all_breaks()
|
||||||
return
|
return
|
||||||
|
if ':' in arg:
|
||||||
|
# Make sure it works for "clear C:\foo\bar.py:12"
|
||||||
|
i = string.rfind(arg, ':')
|
||||||
|
filename = arg[:i]
|
||||||
|
arg = arg[i+1:]
|
||||||
|
try:
|
||||||
|
lineno = int(arg)
|
||||||
|
except:
|
||||||
|
err = "Invalid line number (%s)" % arg
|
||||||
|
else:
|
||||||
|
err = self.clear_break(filename, lineno)
|
||||||
|
if err: print '***', err
|
||||||
|
return
|
||||||
numberlist = string.split(arg)
|
numberlist = string.split(arg)
|
||||||
for i in numberlist:
|
for i in numberlist:
|
||||||
err = self.clear_break(i)
|
err = self.clear_bpbynumber(i)
|
||||||
if err:
|
if err:
|
||||||
print '***'+err
|
print '***', err
|
||||||
else:
|
else:
|
||||||
print 'Deleted breakpoint %s ' % (i,)
|
print 'Deleted breakpoint %s ' % (i,)
|
||||||
do_cl = do_clear # 'c' is already an abbreviation for 'continue'
|
do_cl = do_clear # 'c' is already an abbreviation for 'continue'
|
||||||
|
|
||||||
|
def do_clear_break(self, arg):
|
||||||
|
if not arg:
|
||||||
|
self.do_clear("")
|
||||||
|
return
|
||||||
|
arg = string.strip(arg)
|
||||||
|
# First arg is file, second is line, ignore anything else
|
||||||
|
args = string.split(arg)
|
||||||
|
if len(args) < 2:
|
||||||
|
print '*** Specify file and line number.'
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
line = int(args[1])
|
||||||
|
except:
|
||||||
|
print '*** line number must be an integer.'
|
||||||
|
return
|
||||||
|
result =self.clear_break(args[0], line)
|
||||||
|
if result:
|
||||||
|
print result
|
||||||
|
do_clb = do_clear_break
|
||||||
|
|
||||||
def do_where(self, arg):
|
def do_where(self, arg):
|
||||||
self.print_stack_trace()
|
self.print_stack_trace()
|
||||||
do_w = do_where
|
do_w = do_where
|
||||||
|
|
@ -657,10 +699,12 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
self.help_cl()
|
self.help_cl()
|
||||||
|
|
||||||
def help_cl(self):
|
def help_cl(self):
|
||||||
|
print "cl(ear) filename:lineno"
|
||||||
print """cl(ear) [bpnumber [bpnumber...]]
|
print """cl(ear) [bpnumber [bpnumber...]]
|
||||||
With a space separated list of breakpoint numbers, clear
|
With a space separated list of breakpoint numbers, clear
|
||||||
those breakpoints. Without argument, clear all breaks (but
|
those breakpoints. Without argument, clear all breaks (but
|
||||||
first ask confirmation).
|
first ask confirmation). With a filename:lineno argument,
|
||||||
|
clear all breaks at that line in that file.
|
||||||
|
|
||||||
Note that the argument is different from previous versions of
|
Note that the argument is different from previous versions of
|
||||||
the debugger (in python distributions 1.5.1 and before) where
|
the debugger (in python distributions 1.5.1 and before) where
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue