PDB++ is code that extends the Python debugger PDB. This project extends PDB++, and is just a quick proof of concept.
- 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.
- Install pdb++. (e.g.
pip install pdbpp). - Copy the pdb.py file in this repository to your
site-packagesdirectory (or manually change the file).
Create a .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.
Example ~/.py-breakpoints file:
/home/jason/projects/st/run.py:15
Add an 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.
Yes. This function appends breakpoints (e.g. /my/path/run.py:50) to my .py-breakpoints file:
(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. c:/Users/BobSmith/.py-breakpoints).
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.