Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74362
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ed Blackman <ed@edgewood.to> |
| Newsgroups | comp.lang.python |
| Subject | Save/restore breakpoints between pdb runs |
| Date | Fri, 11 Jul 2014 15:16:19 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 56 |
| Message-ID | <1405104539.54db53@strabo.loghyr> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii; format=flowed |
| Injection-Info | mx05.eternal-september.org; posting-host="d20be9fc9aa1c5ce3dcf8582a0b510cf"; logging-data="11166"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8XPTidznSMkgiJBzEAQN20+wcAjfmO3E=" |
| User-Agent | Mutt/1.5.23 (2014-03-12) |
| X-gpg-fingerprint | BB1F CFF8 C74F 6D41 A782 C878 DE7A D434 9855 3ECE |
| Content-Disposition | inline |
| Cancel-Lock | sha1:vzOxCReLsfUhVhF762YCw8xnajk= |
| X-gpg-key | http://pgp.dtype.org |
| Xref | csiph.com comp.lang.python:74362 |
Show key headers only | View raw
I've recently started using Python for my job (as opposed to writing
smallish scripts for personal use), and so have needed to debug quite a
bit more.
I've been using pdb mainly via 'python -m pdb script args'. Perhaps
it's my Java background, but even when I have permissions to change the
source, I find editing source to insert 'import pdb; pdb.set_trace()'
unnatural. The consequence is that I have to recreate my breakpoints
when I have to exit pdb.
I've written the following code, which I load from .pdbrc with
'execfile(os.path.expanduser('~/.pydb.py'))'
Is there an alternate solution to keeping persistant breakpoints that
works much better? My python editing happens on a lot of different
machines/VMs, so I prefer alternate solutions that allow me to sync over
a couple of files, not install new binaries.
If not:
1) If is there a way in pdb to set a breakpoint on a function that isn't
in the current file? I can see the .funcname property of the
breakpoint, and would prefer restoring breakpoints on functions so they
don't break if I change line numbers. "b func_name" works in the
current file, but "b file:func_name" doesn't.
2) Is there a way to list the commands for each breakpoint, so that they
can be restored as well?
Any other comments or suggestions for improvement would be welcome.
def savebps():
import pdb
bp_num = 0
for bp in pdb.bdb.Breakpoint.bpbynumber:
# pdb commands operate on breakpoint number, so keep track of
# the number the recreated breakpoint would have
if bp is None:
continue
else:
bp_num += 1
command = 'tbreak' if bp.temporary else 'b'
cond = '' if bp.cond is None else ', ' + bp.cond
print("%s %s:%d%s" % (command, bp.file, bp.line, cond))
if not bp.enabled:
print("disable %d" % (bp_num))
if bp.ignore > 0:
print("ignore %d %d" % (bp_num, bp.ignore))
print('')
--
Ed Blackman
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Save/restore breakpoints between pdb runs Ed Blackman <ed@edgewood.to> - 2014-07-11 15:16 -0400 Re: Save/restore breakpoints between pdb runs dieter <dieter@handshake.de> - 2014-07-12 08:05 +0200
csiph-web