What is PDB++?
- Turn on 'sticky mode' by default (repaint the code at each debugging step).
- Persist breakpoints to a file and load them when the first
pdb.set_trace()is called. Also have the breakpoints auto-adjust to the next valid line if the code changes.
How do I install this?
- Install pdb++. (e.g.
pip install pdbpp).
- Copy the pdb.py file in this repository to your
site-packagesdirectory (or manually change the file).
How do I store breakpoints in a file?
.py-breakpoints file in your home directory, and put the breakpoint text (what you would usually specify manually in a PDB debugging session) on separate lines.
How do the breakpoints get initialized?
import pdb; pdb.set_trace() to the top of the script you're running. Once the set_trace() is called, the breakpoints will be read from the file and initialized.
Can I set a breakpoint from Emacs?
Yes. This function appends breakpoints (e.g.
/my/path/run.py:50) to my
(defun breakpoint-append() (interactive) (setq lnum (format-mode-line "%l")) (setq bp (concat (buffer-file-name) ":" lnum "\n")) (write-region bp nil "~/.py-breakpoints" 'append) )
If you're on Windows, you'll probably need to indicate the full path above (e.g.
Does this work on Windows?
Yes, pdb++ and these modifications do work on Windows if you use a console that supports colors (I used ConEmu).
This code is adapted from:
Any modifications are released under the MIT and/or BSD licenses.